[Fedora-directory-commits] ldapserver/ldap/servers/slapd log.h, 1.8, 1.9 log.c, 1.24, 1.25

Noriko Hosoi nhosoi at fedoraproject.org
Wed Dec 10 06:23:26 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv12831

Modified Files:
	log.h log.c 
Log Message:
Resolves: #475338
Summary: LOG: the intenal type of maxlogsize, maxdiskspace and minfreespace 
should be 64-bit integer
Description: support nsslapd-*log-maxlogsize, nsslapd-*log-logmaxdiskspace and
nsslapd-*log-logminfreediskspace larger than 2GB.



Index: log.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- log.h	8 Oct 2008 17:29:03 -0000	1.8
+++ log.h	10 Dec 2008 06:23:24 -0000	1.9
@@ -116,9 +116,9 @@
 
 
 struct logfileinfo {
-	int		l_size;  		/* size is in KB */
-	time_t		l_ctime;		/* log creation time*/
-	struct logfileinfo	*l_next;		/* next log */
+    PRInt64            l_size;     /* size is in bytes */
+    time_t             l_ctime;    /* log creation time*/
+    struct logfileinfo *l_next;    /* next log */
 };
 typedef struct logfileinfo	LogFileInfo;
 
@@ -127,7 +127,7 @@
     char    *current;                   /* current pointer into buffer */
     size_t  maxsize;                    /* size of buffer */
     PRLock *lock;                       /* lock for access logging */
-	PRInt32 refcount;					/* Reference count for buffer copies */
+    PRInt32 refcount;                   /* Reference count for buffer copies */
 };
 typedef struct logbufinfo LogBufferInfo;
 
@@ -136,7 +136,7 @@
 	int		log_access_state;
 	int		log_access_mode;			/* access mode */
 	int		log_access_maxnumlogs;		/* Number of logs */
-	int		log_access_maxlogsize;		/* max log size in bytes*/
+	PRInt64	log_access_maxlogsize;		/* max log size in bytes*/
 	int		log_access_rotationtime;	/* time in units. */
 	int		log_access_rotationunit;	/* time in units. */
 	int		log_access_rotationtime_secs; 	/* time in seconds */
@@ -144,8 +144,8 @@
 	int		log_access_rotationsynchour;	/* 0-23 */
 	int		log_access_rotationsyncmin;	/* 0-59 */
 	time_t	log_access_rotationsyncclock;	/* clock in seconds */
-	int		log_access_maxdiskspace;	/* space in bytes */
-	int		log_access_minfreespace;	/* free space in bytes */
+	PRInt64	log_access_maxdiskspace;	/* space in bytes */
+	PRInt64	log_access_minfreespace;	/* free space in bytes */
 	int		log_access_exptime;		/* time */
 	int		log_access_exptimeunit;		/* unit time */
 	int		log_access_exptime_secs;	/* time in secs */
@@ -163,7 +163,7 @@
 	int		log_error_state;
 	int		log_error_mode;				/* access mode */
 	int		log_error_maxnumlogs;		/* Number of logs */
-	int		log_error_maxlogsize;		/* max log size in bytes*/
+	PRInt64	log_error_maxlogsize;		/* max log size in bytes*/
 	int		log_error_rotationtime;	/* time in units. */
 	int		log_error_rotationunit;	/* time in units. */
 	int		log_error_rotationtime_secs; 	/* time in seconds */
@@ -171,8 +171,8 @@
 	int		log_error_rotationsynchour;	/* 0-23 */
 	int		log_error_rotationsyncmin;	/* 0-59 */
 	time_t	log_error_rotationsyncclock;	/* clock in seconds */
-	int		log_error_maxdiskspace;	/* space in bytes */
-	int		log_error_minfreespace;	/* free space in bytes */
+	PRInt64	log_error_maxdiskspace;	/* space in bytes */
+	PRInt64	log_error_minfreespace;	/* free space in bytes */
 	int		log_error_exptime;	/* time */
 	int		log_error_exptimeunit;	/* unit time */
 	int		log_error_exptime_secs;	/* time in secs */
@@ -189,7 +189,7 @@
 	int		log_audit_state;
 	int		log_audit_mode;			/* access mode */
 	int		log_audit_maxnumlogs;	/* Number of logs */
-	int		log_audit_maxlogsize;	/* max log size in bytes*/
+	PRInt64	log_audit_maxlogsize;	/* max log size in bytes*/
 	int		log_audit_rotationtime;	/* time in units. */
 	int		log_audit_rotationunit;	/* time in units. */
 	int		log_audit_rotationtime_secs; 	/* time in seconds */
@@ -197,8 +197,8 @@
 	int		log_audit_rotationsynchour;	/* 0-23 */
 	int		log_audit_rotationsyncmin;	/* 0-59 */
 	time_t	log_audit_rotationsyncclock;	/* clock in seconds */
-	int		log_audit_maxdiskspace;	/* space in bytes */
-	int		log_audit_minfreespace;	/* free space in bytes */
+	PRInt64	log_audit_maxdiskspace;	/* space in bytes */
+	PRInt64	log_audit_minfreespace;	/* free space in bytes */
 	int		log_audit_exptime;	/* time */
 	int		log_audit_exptimeunit;	/* unit time */
 	int		log_audit_exptime_secs;	/* time in secs */


Index: log.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- log.c	1 Dec 2008 18:05:35 -0000	1.24
+++ log.c	10 Dec 2008 06:23:24 -0000	1.25
@@ -121,9 +121,9 @@
 static int 	log__access_rotationinfof(char *pathname);
 static int 	log__error_rotationinfof(char *pathname);
 static int 	log__audit_rotationinfof(char *pathname);
-static int 	log__extract_logheader (FILE *fp, long  *f_ctime, int *f_size);
+static int 	log__extract_logheader (FILE *fp, long  *f_ctime, PRInt64 *f_size);
 static int	log__check_prevlogs (FILE *fp, char *filename);
-static int 	log__getfilesize(LOGFD fp);
+static PRInt64 	log__getfilesize(LOGFD fp);
 static int 	log__enough_freespace(char  *path);
 
 static int 	vslapd_log_error(LOGFD fp, char *subsystem, char *fmt, va_list ap, int locked );
@@ -767,9 +767,9 @@
 log_set_logsize(const char *attrname, char *logsize_str, int logtype, char *returntext, int apply)
 {
 	int	rv = LDAP_SUCCESS;
-	int mdiskspace= 0;
-	int	max_logsize;
-	int logsize;
+	PRInt64 mdiskspace= 0;  /* in bytes */
+	PRInt64	max_logsize;    /* in bytes */
+	int logsize;            /* in megabytes */
 	slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
 
 	if (!apply || !logsize_str || !*logsize_str)
@@ -778,7 +778,7 @@
 	logsize = atoi(logsize_str);
 	
 	/* convert it to bytes */
-	max_logsize = logsize * LOG_MB_IN_BYTES;
+	max_logsize = (PRInt64)logsize * LOG_MB_IN_BYTES;
 
 	if (max_logsize <= 0) {
 	  max_logsize = -1;
@@ -831,11 +831,11 @@
 	   default:
 		rv = 1;
 	}
-	/* logsize will be in n MB. Convert it to bytes  */
+	/* logsize is in MB */
 	if (rv == 2) {
 		LDAPDebug (LDAP_DEBUG_ANY, 
 			   "Invalid value for Maximum log size:"
-			   "Maxlogsize:%d MB  Maxdisksize:%d MB\n", 
+			   "Maxlogsize:%d (MB) exceeds Maxdisksize:%d (MB)\n", 
 			    logsize, mdiskspace/LOG_MB_IN_BYTES,0);
 
 			rv = LDAP_OPERATIONS_ERROR;
@@ -1244,9 +1244,9 @@
 log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
 {
 	int	rv = 0;
-  	int	mlogsize;
-	int maxdiskspace;
-	int	s_maxdiskspace;
+  	PRInt64	mlogsize;	  /* in bytes */
+	PRInt64 maxdiskspace; /* in bytes */
+	int	s_maxdiskspace;   /* in megabytes */
   
   	slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
 	
@@ -1261,8 +1261,7 @@
 	if (!apply || !maxdiskspace_str || !*maxdiskspace_str)
 		return rv;
 
-	maxdiskspace = atoi(maxdiskspace_str);
-	s_maxdiskspace = maxdiskspace;
+	s_maxdiskspace = atoi(maxdiskspace_str);
 
 	/* Disk space are in MB  but store in bytes */
 	switch (logtype) {
@@ -1282,44 +1281,42 @@
 		rv = 1;
 		mlogsize = -1;
 	}
-	maxdiskspace *=  LOG_MB_IN_BYTES;
+	maxdiskspace = (PRInt64)s_maxdiskspace * LOG_MB_IN_BYTES;
 	if (maxdiskspace < 0) {
 		maxdiskspace = -1;
-	}
-	else if (maxdiskspace  < mlogsize) {
+	} else if (maxdiskspace < mlogsize) {
 		rv = LDAP_OPERATIONS_ERROR;
 		PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
-				"%s: maxdiskspace \"%d\" is less than max log size \"%d\"",
-				attrname, maxdiskspace, mlogsize );
+			"%s: \"%d (MB)\" is less than max log size \"%d (MB)\"",
+			attrname, s_maxdiskspace, (int)(mlogsize/LOG_MB_IN_BYTES) );
 	}
 
 	switch (logtype) {
 	   case SLAPD_ACCESS_LOG:
 		if (rv== 0 && apply) {
-		  loginfo.log_access_maxdiskspace = maxdiskspace;
-		  fe_cfg->accesslog_maxdiskspace = s_maxdiskspace  ;
+		  loginfo.log_access_maxdiskspace = maxdiskspace;  /* in bytes */
+		  fe_cfg->accesslog_maxdiskspace = s_maxdiskspace; /* in megabytes */
 		}
 		LOG_ACCESS_UNLOCK_WRITE();
 		break;
 	   case SLAPD_ERROR_LOG:
 		if (rv== 0 && apply) {
-		  loginfo.log_error_maxdiskspace = maxdiskspace;
-		  fe_cfg->errorlog_maxdiskspace = s_maxdiskspace;
+		  loginfo.log_error_maxdiskspace = maxdiskspace;  /* in bytes */
+		  fe_cfg->errorlog_maxdiskspace = s_maxdiskspace; /* in megabytes */
 		}
 		LOG_ERROR_UNLOCK_WRITE();
 		break;
 	   case SLAPD_AUDIT_LOG:
 		if (rv== 0 && apply) {
-		  loginfo.log_audit_maxdiskspace = maxdiskspace;
-		  fe_cfg->auditlog_maxdiskspace = s_maxdiskspace;
+		  loginfo.log_audit_maxdiskspace = maxdiskspace;  /* in bytes */
+		  fe_cfg->auditlog_maxdiskspace = s_maxdiskspace; /* in megabytes */
 		}
 		LOG_AUDIT_UNLOCK_WRITE();
 		break;
 	   default:
 		 PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, 
-				 "%s: invalid maximum log disk size:"
-				 "Maxdiskspace:%d MB Maxlogsize:%d MB \n",
-				 attrname, maxdiskspace, mlogsize);
+			"%s: invalid log type (%d) for setting maximum disk space: %d MB\n",
+			attrname, logtype, s_maxdiskspace);
 		 rv = LDAP_OPERATIONS_ERROR;
 	}
 	return rv;
@@ -1335,8 +1332,8 @@
 log_set_mindiskspace(const char *attrname, char *minfreespace_str, int logtype, char *errorbuf, int apply)
 {
 	int	rv=LDAP_SUCCESS;
-	int minfreespaceB; 
-	int minfreespace;
+	int minfreespace;      /* in megabytes */
+	PRInt64 minfreespaceB; /* in bytes */
 	
 	slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
 	
@@ -1357,7 +1354,7 @@
 
 	/* Disk space are in MB  but store in bytes */
 	if (minfreespace >= 1 ) {
-		minfreespaceB = minfreespace * LOG_MB_IN_BYTES;
+		minfreespaceB = (PRInt64)minfreespace * LOG_MB_IN_BYTES;
 		switch (logtype) {
 		   case SLAPD_ACCESS_LOG:
 			LOG_ACCESS_LOCK_WRITE( );
@@ -2115,13 +2112,13 @@
 	** in the array stack.
 	*/
 	if (loginfo.log_access_fdes != NULL) {
-		struct  logfileinfo 	*log;
-		char			newfile[BUFSIZ];
-		int			f_size;
+		struct logfileinfo *log;
+		char               newfile[BUFSIZ];
+		PRInt64            f_size;
 
 		/* get rid of the old one */
 		if ((f_size = log__getfilesize(loginfo.log_access_fdes)) == -1) {
-			/* Then assume that we have the max size */
+			/* Then assume that we have the max size (in bytes) */
 			f_size = loginfo.log_access_maxlogsize;
 		}
 
@@ -2158,15 +2155,13 @@
 		}
 	} 
 
-
 	/* open a new log file */
 	if (! LOG_OPEN_APPEND(fp, loginfo.log_access_file, loginfo.log_access_mode)) {
 		int oserr = errno;
 		loginfo.log_access_fdes = NULL;
 		if (!locked)  LOG_ACCESS_UNLOCK_WRITE();
-		LDAPDebug( LDAP_DEBUG_ANY, "access file open %s failed errno %d (%s)\n",
-					    loginfo.log_access_file,
-				            oserr, slapd_system_strerror(oserr));
+		LDAPDebug(LDAP_DEBUG_ANY, "access file open %s failed errno %d (%s)\n",
+				  loginfo.log_access_file, oserr, slapd_system_strerror(oserr));
 		return LOG_UNABLE_TO_OPENFILE;
 	}
 
@@ -2198,8 +2193,9 @@
 	logp = loginfo.log_access_logchain;
 	while ( logp) {
 		log_convert_time (logp->l_ctime, tbuf, 1 /*short*/);
-		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%u)\n",
-			PREVLOGFILE, loginfo.log_access_file, tbuf, logp->l_ctime, logp->l_size);
+		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%"
+			NSPRI64 "d)\n", PREVLOGFILE, loginfo.log_access_file, tbuf, 
+			logp->l_ctime, logp->l_size);
 		LOG_WRITE(fpinfo, buffer, strlen(buffer), 0);
 		logp = logp->l_next;
 	}
@@ -2236,8 +2232,9 @@
 	time_t	log_createtime= 0;
 	time_t	syncclock = 0;
 	int	type = LOG_CONTINUE;
-	int	f_size = 0;
-	int	maxlogsize, nlogs;
+	PRInt64	f_size = 0;
+	PRInt64	maxlogsize;
+	int	nlogs;
 	int	rotationtime_secs = -1;
 	int	sync_enabled = 0, timeunit = 0;
 
@@ -2316,22 +2313,24 @@
 	}
 
 log_rotate:
-    /*
-    ** Don't send messages to the error log whilst we're rotating it.
-    ** This'll lead to a recursive call to the logging function, and
-    ** an assertion trying to relock the write lock.
-    */
+	/*
+	** Don't send messages to the error log whilst we're rotating it.
+	** This'll lead to a recursive call to the logging function, and
+	** an assertion trying to relock the write lock.
+	*/
 	if (logtype!=SLAPD_ERROR_LOG)
-    {
-    	if (type == LOG_SIZE_EXCEEDED) {
-    		LDAPDebug (LDAP_DEBUG_TRACE,
-    			   "LOGINFO:End of Log because size exceeded(Max:%d bytes) (Is:%d bytes)\n", maxlogsize, f_size, 0);
-    	} else  if ( type == LOG_EXPIRED) {
-    		LDAPDebug(LDAP_DEBUG_TRACE,
-    			   "LOGINFO:End of Log because time exceeded(Max:%d secs) (Is:%ld secs)\n",
-    				rotationtime_secs, curr_time - log_createtime,0);
-    	}
-    }
+	{
+		if (type == LOG_SIZE_EXCEEDED) {
+			LDAPDebug (LDAP_DEBUG_TRACE,
+				   "LOGINFO:End of Log because size exceeded(Max:%" 
+				   NSPRI64 "d bytes) (Is:%" NSPRI64 "d bytes)\n",
+				   maxlogsize, f_size, 0);
+		} else  if ( type == LOG_EXPIRED) {
+			LDAPDebug(LDAP_DEBUG_TRACE,
+				   "LOGINFO:End of Log because time exceeded(Max:%d secs) (Is:%ld secs)\n",
+					rotationtime_secs, curr_time - log_createtime,0);
+		}
+	}
 	return (type == LOG_CONTINUE) ? LOG_CONTINUE : LOG_ROTATE;
 }
 
@@ -2349,18 +2348,18 @@
 log__delete_access_logfile()
 {
 
-	struct logfileinfo	*logp = NULL;
-	struct logfileinfo	*delete_logp = NULL;
-	struct logfileinfo	*p_delete_logp = NULL;
-	struct logfileinfo	*prev_logp = NULL;
-	int			total_size=0;
-	time_t			cur_time;
-	int			f_size;
-	int			numoflogs=loginfo.log_numof_access_logs;
-	int			rv = 0;
-	char			*logstr;
-	char			buffer[BUFSIZ];
-	char			tbuf[TBUFSIZE];
+	struct logfileinfo *logp = NULL;
+	struct logfileinfo *delete_logp = NULL;
+	struct logfileinfo *p_delete_logp = NULL;
+	struct logfileinfo *prev_logp = NULL;
+	PRInt64            total_size=0;
+	time_t             cur_time;
+	PRInt64            f_size;
+	int                numoflogs=loginfo.log_numof_access_logs;
+	int                rv = 0;
+	char               *logstr;
+	char               buffer[BUFSIZ];
+	char               tbuf[TBUFSIZE];
 	
 	/* If we have only one log, then  will delete this one */
 	if (loginfo.log_access_maxnumlogs == 1) {
@@ -2629,7 +2628,7 @@
 log__access_rotationinfof(char *pathname)
 {
 	long	f_ctime;
-	int		f_size;
+	PRInt64	f_size;
 	int		main_log = 1;
 	time_t	now;
 	FILE	*fp;
@@ -2782,14 +2781,17 @@
 *	size info of all the old log files.
 ******************************************************************************/ 
 static int
-log__extract_logheader (FILE *fp, long  *f_ctime, int *f_size)
+log__extract_logheader (FILE *fp, long *f_ctime, PRInt64 *f_size)
 {
 
 	char		buf[BUFSIZ];
 	char		*p, *s, *next;
 
+	if (NULL == f_ctime || NULL == f_size) {
+		return LOG_ERROR;
+	}
 	*f_ctime = 0L;
-	*f_size = 0;
+	*f_size = 0L;
 
 	if ( fp == NULL)
 		return LOG_ERROR;
@@ -2817,11 +2819,11 @@
 	*s = '\0';
 	
 	/* Now p must hold the ctime value */
-	*f_ctime = atoi(p);
+	*f_ctime = strtol(p, (char **)NULL, 0); 
 
 	if ((p = strchr(next, '(')) == NULL) {
 		/* that's fine -- it means we have no size info */
-		*f_size = 0;
+		*f_size = 0L;
 		return LOG_CONTINUE;
 	}
 
@@ -2833,7 +2835,7 @@
 	*next = '\0';
 	
 	/* Now p must hold the size value */
-	*f_size = atoi(p);
+	*f_size = strtoll(p, (char **)NULL, 0);
 
 	/* check if the Previous Log file really exists */
 	if ((p = strstr(buf, PREVLOGFILE)) != NULL) {
@@ -2867,7 +2869,7 @@
  * probably a safe assumption for now.
  */
 #ifdef XP_WIN32
-static int 
+static PRInt64 
 log__getfilesize(LOGFD fp)
 {
 	struct stat	info;
@@ -2876,10 +2878,10 @@
 	if ((rv = fstat(fileno(fp), &info)) != 0) {
 		return -1;
 	}
-	return info.st_size;
+	return (PRInt64)info.st_size;
 } 
 #else
-static int
+static PRInt64
 log__getfilesize(LOGFD fp)
 {
 	PRFileInfo      info;
@@ -2887,7 +2889,7 @@
 	if (PR_GetOpenFileInfo (fp, &info) == PR_FAILURE) {
 		return -1;
 	}
-	return info.size;
+	return (PRInt64)info.size;	/* type of size is off_t */
 }
 #endif
 
@@ -3049,18 +3051,18 @@
 log__delete_error_logfile(int locked)
 {
 
-	struct logfileinfo	*logp = NULL;
-	struct logfileinfo	*delete_logp = NULL;
-	struct logfileinfo	*p_delete_logp = NULL;
-	struct logfileinfo	*prev_logp = NULL;
-	int			total_size=0;
-	time_t			cur_time;
-	int			f_size;
-	int			numoflogs=loginfo.log_numof_error_logs;
-	int			rv = 0;
-	char			*logstr;
-	char			buffer[BUFSIZ];
-	char			tbuf[TBUFSIZE];
+	struct logfileinfo *logp = NULL;
+	struct logfileinfo *delete_logp = NULL;
+	struct logfileinfo *p_delete_logp = NULL;
+	struct logfileinfo *prev_logp = NULL;
+	PRInt64            total_size=0;
+	time_t             cur_time;
+	PRInt64            f_size;
+	int                numoflogs=loginfo.log_numof_error_logs;
+	int                rv = 0;
+	char               *logstr;
+	char               buffer[BUFSIZ];
+	char               tbuf[TBUFSIZE];
 
 
 	/* If we have only one log, then  will delete this one */
@@ -3222,18 +3224,18 @@
 static int
 log__delete_audit_logfile()
 {
-	struct logfileinfo	*logp = NULL;
-	struct logfileinfo	*delete_logp = NULL;
-	struct logfileinfo	*p_delete_logp = NULL;
-	struct logfileinfo	*prev_logp = NULL;
-	int			total_size=0;
-	time_t			cur_time;
-	int			f_size;
-	int			numoflogs=loginfo.log_numof_audit_logs;
-	int			rv = 0;
-	char			*logstr;
-	char			buffer[BUFSIZ];
-	char			tbuf[TBUFSIZE];
+	struct logfileinfo *logp = NULL;
+	struct logfileinfo *delete_logp = NULL;
+	struct logfileinfo *p_delete_logp = NULL;
+	struct logfileinfo *prev_logp = NULL;
+	PRInt64     total_size=0;
+	time_t      cur_time;
+	PRInt64     f_size;
+	int         numoflogs=loginfo.log_numof_audit_logs;
+	int         rv = 0;
+	char        *logstr;
+	char        buffer[BUFSIZ];
+	char        tbuf[TBUFSIZE];
 
 	/* If we have only one log, then  will delete this one */
 	if (loginfo.log_audit_maxnumlogs == 1) {
@@ -3378,7 +3380,7 @@
 log__error_rotationinfof( char *pathname)
 {
 	long	f_ctime;
-	int		f_size;
+	PRInt64	f_size;
 	int		main_log = 1;
 	time_t	now;
 	FILE	*fp;
@@ -3465,7 +3467,7 @@
 log__audit_rotationinfof( char *pathname)
 {
 	long	f_ctime;
-	int		f_size;
+	PRInt64	f_size;
 	int		main_log = 1;
 	time_t	now;
 	FILE	*fp;
@@ -3607,9 +3609,9 @@
 	** in the array stack.
 	*/
 	if (loginfo.log_error_fdes != NULL) {
-		struct  logfileinfo 	*log;
-		char			newfile[BUFSIZ];
-		int			f_size;
+		struct logfileinfo *log;
+		char               newfile[BUFSIZ];
+		PRInt64            f_size;
 
 		/* get rid of the old one */
 		if ((f_size = log__getfilesize(loginfo.log_error_fdes)) == -1) {
@@ -3704,8 +3706,9 @@
 	logp = loginfo.log_error_logchain;
 	while (logp) {
 		log_convert_time (logp->l_ctime, tbuf, 1 /*short */);
-		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%u)\n",
-			PREVLOGFILE, loginfo.log_error_file, tbuf, logp->l_ctime, logp->l_size);
+		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%" 
+			NSPRI64 "d)\n", PREVLOGFILE, loginfo.log_error_file, tbuf, 
+			logp->l_ctime, logp->l_size);
 		LOG_WRITE(fpinfo, buffer, strlen(buffer), 0);
 		logp = logp->l_next;
 	}
@@ -3747,9 +3750,9 @@
 	** in the array stack.
 	*/
 	if (loginfo.log_audit_fdes != NULL) {
-		struct  logfileinfo 	*log;
-		char			newfile[BUFSIZ];
-		int			f_size;
+		struct  logfileinfo *log;
+		char                newfile[BUFSIZ];
+		PRInt64             f_size;
 
 
 		/* get rid of the old one */
@@ -3758,7 +3761,6 @@
 			f_size = loginfo.log_audit_maxlogsize;
 		}
 
-
 		/* Check if I have to delete any old file, delete it if it is required. */
 		while (log__delete_audit_logfile());
 
@@ -3785,7 +3787,6 @@
 		}
 	} 
 
-
 	/* open a new log file */
 	if (! LOG_OPEN_APPEND(fp, loginfo.log_audit_file, loginfo.log_audit_mode)) {
 		LDAPDebug(LDAP_DEBUG_ANY, "WARNING: can't open file %s. "
@@ -3825,8 +3826,9 @@
 	logp = loginfo.log_audit_logchain;
 	while ( logp) {
 		log_convert_time (logp->l_ctime, tbuf, 1 /*short */);	
-		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%d) (%d)\n",
-			PREVLOGFILE, loginfo.log_audit_file, tbuf, (int)logp->l_ctime, logp->l_size);
+		PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%"
+			NSPRI64 "d)\n", PREVLOGFILE, loginfo.log_audit_file, tbuf, 
+			logp->l_ctime, logp->l_size);
 		LOG_WRITE(fpinfo, buffer, strlen(buffer), 0);
 		logp = logp->l_next;
 	}
@@ -4041,15 +4043,17 @@
 int
 check_log_max_size( char *maxdiskspace_str,
                     char *mlogsize_str,
-                    int maxdiskspace,
-                    int mlogsize,
+                    int maxdiskspace, /* in megabytes */
+                    int mlogsize,     /* in megabytes */
                     char * returntext,
                     int logtype)
 {
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
     int rc = LDAP_SUCCESS;
-    int current_mlogsize = -1;
-    int current_maxdiskspace = -1;
+    int     current_mlogsize = -1;     /* in megabytes */
+    int     current_maxdiskspace = -1; /* in megabytes */
+    PRInt64 mlogsizeB;                 /* in bytes */
+    PRInt64 maxdiskspaceB;             /* in bytes */
  
     switch (logtype)
     {
@@ -4070,35 +4074,40 @@
             current_maxdiskspace = -1;
     }
  
-    if ( maxdiskspace == -1 )
+    if ( maxdiskspace == -1 ) {
         maxdiskspace = current_maxdiskspace;
-    if ( mlogsize == -1 )
+    }
+    maxdiskspaceB = (PRInt64)maxdiskspace * LOG_MB_IN_BYTES;
+
+    if ( mlogsize == -1 ) {
         mlogsize = current_mlogsize;
+    }
+    mlogsizeB = (PRInt64)mlogsize * LOG_MB_IN_BYTES;
  
     if ( maxdiskspace < mlogsize )
     {
         /* fail */
         PR_snprintf ( returntext, SLAPI_DSE_RETURNTEXT_SIZE,
-                "%s: maxdiskspace \"%d\" is less than max log size \"%d\"",
-                maxdiskspace_str, maxdiskspace*LOG_MB_IN_BYTES, mlogsize*LOG_MB_IN_BYTES );
+          "%s: maxdiskspace \"%d (MB)\" is less than max log size \"%d (MB)\"",
+          maxdiskspace_str, maxdiskspace, mlogsize );
         rc = LDAP_OPERATIONS_ERROR;
     }
     switch (logtype)
     {
         case SLAPD_ACCESS_LOG:
-			loginfo.log_access_maxlogsize = mlogsize * LOG_MB_IN_BYTES;
-			loginfo.log_access_maxdiskspace = maxdiskspace * LOG_MB_IN_BYTES;
+            loginfo.log_access_maxlogsize = mlogsizeB;
+            loginfo.log_access_maxdiskspace = maxdiskspaceB;
             break;
         case SLAPD_ERROR_LOG:
-			loginfo.log_error_maxlogsize = mlogsize  * LOG_MB_IN_BYTES;
-			loginfo.log_error_maxdiskspace = maxdiskspace  * LOG_MB_IN_BYTES;
+            loginfo.log_error_maxlogsize = mlogsizeB;
+            loginfo.log_error_maxdiskspace = maxdiskspaceB;
             break;
         case SLAPD_AUDIT_LOG:
-			loginfo.log_audit_maxlogsize = mlogsize * LOG_MB_IN_BYTES;
-			loginfo.log_audit_maxdiskspace = maxdiskspace  * LOG_MB_IN_BYTES;
+            loginfo.log_audit_maxlogsize = mlogsizeB;
+            loginfo.log_audit_maxdiskspace = maxdiskspaceB;
             break;
         default:
-			break;
+            break;
     }
  
     return rc;




More information about the Fedora-directory-commits mailing list