On Tue, Nov 07, 2000 at 03:23:19PM +0100, Frederic Crozat wrote:
> > somebody has an idea about where the problem comes from ? bad rules ?
> > logrotate bug ?
>
> It's a logrotate bug and Renaud (sysklog maintainer) has modified
> logrotate config file to circonvent this bug ..
>
> You have probably upgrade your old sysklog package and old config file
> (/etc/logrotate.d/syslog) has been used.. Check if
> /etc/logrotate.d/syslog.rpmnew exist and use it instead..
Definite solution is to fix logrotate to ignore suffixes.
I've sent patches to logrotate maintainer in the middle of September.
If anybody needs it, see attachments.
Regards,
Dmitry
+-------------------------------------------------------------------------+
Dmitry V. Levin mailto:[EMAIL PROTECTED]
Software Engineer PGP pubkey http://www.fandra.org/users/ldv/pgpkeys.html
IPLabs Linux Team http://linux.iplabs.ru
Fandra Project http://www.fandra.org
+-------------------------------------------------------------------------+
UNIX is user friendly. It's just very selective about who it's friends are.
--- logrotate-3.3-orig/logrotate.h Wed Sep 13 00:26:11 2000
+++ logrotate-3.3/logrotate.h Wed Sep 13 00:27:01 2000
@@ -41,7 +41,7 @@
glob_t globMem; /* at least we could theoretically free this */
} logInfo;
-int readConfigPath(char * path, logInfo * defConfig,
+int readConfigPath(const char * path, logInfo * defConfig,
logInfo ** logsPtr, int * numLogsPtr);
extern int debug;
--- logrotate-3.3-orig/logrotate.c Wed Sep 13 00:26:11 2000
+++ logrotate-3.3/logrotate.c Wed Sep 13 00:26:50 2000
@@ -788,7 +788,7 @@
}
-int main(int argc, char ** argv) {
+int main(int argc, const char ** argv) {
logInfo defConfig = { NULL, NULL, 0, NULL, ROT_SIZE,
/* threshHold */ 1024 * 1024, 0,
/* pre */ NULL, NULL, NULL, NULL,
@@ -803,7 +803,7 @@
int i;
int rc = 0;
int arg;
- char ** files, ** file;
+ const char ** files, ** file;
poptContext optCon;
struct poptOption options[] = {
{ "debug", 'd', 0, 0, 'd',
--- logrotate-3.3-orig/config.c Wed Sep 13 00:31:27 2000
+++ logrotate-3.3/config.c Wed Sep 13 00:30:58 2000
@@ -29,11 +29,11 @@
static char ** tabooExts = NULL;
int tabooCount = 0;
-static int readConfigFile(char * configFile, logInfo * defConfig,
+static int readConfigFile(const char * configFile, logInfo * defConfig,
logInfo ** logsPtr, int * numLogsPtr);
static int globerr(const char * pathname, int theerr);
-static int isolateValue(char * fileName, int lineNum, char * key,
+static int isolateValue(const char * fileName, int lineNum, char * key,
char ** startPtr, char ** endPtr) {
char * chptr = *startPtr;
@@ -63,7 +63,7 @@
return 0;
}
-static char *readPath(char *configFile, int lineNum, char *key,
+static char *readPath(const char *configFile, int lineNum, char *key,
char **startPtr) {
char oldchar;
char *endtag, *chptr;
@@ -96,7 +96,7 @@
return NULL;
}
-static char * readAddress(char * configFile, int lineNum, char * key,
+static char * readAddress(const char * configFile, int lineNum, char * key,
char ** startPtr) {
char oldchar;
char * endtag, * chptr;
@@ -127,7 +127,7 @@
return NULL;
}
-int readConfigPath(char * path, logInfo * defConfig,
+int readConfigPath(const char * path, logInfo * defConfig,
logInfo ** logsPtr, int * numLogsPtr) {
struct stat sb;
DIR * dir;
@@ -223,7 +223,7 @@
return 1;
}
-static int readConfigFile(char * configFile, logInfo * defConfig,
+static int readConfigFile(const char * configFile, logInfo * defConfig,
logInfo ** logsPtr, int * numLogsPtr) {
int fd;
char * buf, * endtag;
# Patch for logrotate-3.3 to extend support of taboo suffixes;
# by Dmitry V. Levin <[EMAIL PROTECTED]>
#
# This patch is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This patch is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this patch; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
--- logrotate-3.3-orig/config.c Thu Sep 14 15:56:48 2000
+++ logrotate-3.3/config.c Thu Sep 14 16:01:46 2000
@@ -22,7 +22,7 @@
#define GLOB_ABORTED GLOB_ABEND
#endif
-static char * defTabooExts[] = { ".rpmsave", ".rpmorig", "~", ",v" };
+static char * defTabooExts[] = { ".rpmsave", ".rpmorig", ".gz", ".bz2", "~", ",v" };
static int defTabooCount = sizeof(defTabooExts) / sizeof(char *);
/* I shouldn't use globals here :-( */
@@ -63,6 +63,48 @@
return 0;
}
+/*
+ * Returns false if given name ending with on of taboo suffixes.
+ */
+static int valid_name( const char *name )
+{
+ unsigned n_len = strlen( name );
+ int i;
+
+ for ( i = 0; i < tabooCount; ++i )
+ {
+ const char *t = tabooExts[i];
+ unsigned t_len = strlen( t );
+
+ if ( n_len < t_len )
+ continue;
+
+ if ( !memcmp( name + n_len - t_len, t, t_len ) )
+ {
+ message( MESS_DEBUG, "Ignoring %s, because of %s ending\n",
+name, t );
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Returns false if given logfile name isn't allowed to rotate.
+ */
+static int valid_logname( const char *name )
+{
+ struct stat stb;
+
+ if ( !lstat( name, &stb ) && !S_ISREG( stb.st_mode ) )
+ {
+ message( MESS_DEBUG, "Ignoring %s, because of wrong file type %#x\n",
+ name, stb.st_mode );
+ return 0;
+ }
+ return valid_name( name );
+}
+
static char *readPath(const char *configFile, int lineNum, char *key,
char **startPtr) {
char oldchar;
@@ -133,7 +175,6 @@
DIR * dir;
struct dirent * ent;
int here;
- int i;
if (!tabooExts) {
tabooExts = malloc(sizeof(*tabooExts) * defTabooCount);
@@ -180,26 +221,18 @@
close(here);
closedir(dir);
return 1;
- } else if (ent && ent->d_name[0] == '.' && (!ent->d_name[1] ||
+ }
+ if (ent && ent->d_name[0] == '.' && (!ent->d_name[1] ||
(ent->d_name[1] == '.' && !ent->d_name[2]))) {
/* noop */
- } else if (ent) {
- for (i = 0; i < tabooCount; i++) {
- if (!strcmp(ent->d_name + strlen(ent->d_name) -
- strlen(tabooExts[i]), tabooExts[i])) {
- message(MESS_DEBUG, "Ignoring %s, because of %s "
- "ending\n", ent->d_name, tabooExts[i]);
- break;
- }
- }
-
- if (i == tabooCount) {
- if (readConfigFile(ent->d_name, defConfig, logsPtr,
- numLogsPtr)) {
- fchdir(here);
- close(here);
- return 1;
- }
+ continue;
+ }
+ if ( ent && valid_name( ent->d_name ) )
+ {
+ if (readConfigFile(ent->d_name, defConfig, logsPtr, numLogsPtr)) {
+ fchdir(here);
+ close(here);
+ return 1;
}
}
} while (ent);
@@ -699,7 +732,7 @@
for (i = 0; i < globResult.gl_pathc; i++) {
/* if we glob directories we can get false matches */
- if (!lstat(globResult.gl_pathv[i], &sb) && S_ISDIR(sb.st_mode))
+ if ( !valid_logname( globResult.gl_pathv[i] ) )
continue;
for (j = 0; j < *numLogsPtr - 1; j++) {
PGP signature