Title: Jim Keir
Hi,

Apologies - new files attached. I note that one of the issues in the patch is already covered by another bug (#87515) - I'm not precious about which one is used, but we do need the problem fixed one way or the other. I'd rather be using a released (or to-be-released) version than a modified one.

Thanks,
Jim

On 25/05/2011 14:43, Paul Martin wrote:
Unified diffs only, please. "diff -u"

Without the context it is almost impossible to apply such patches
against newer upstream source code.

Could you please resubmit in unified format?


--

Jim Keir

Technical Consultant


Prologic Plc

Redwood House, Berkhamsted, Hertfordshire. HP4 2DH, UK

Tel: +44 (0)1442 876277
Fax: +44 (0)1442 877245

Email: jk...@prologic.com

Web: www.prologic.com


The Business Solution For Fashion & Lifestyle

--- config.c    2011-03-08 12:15:26.000000000 +0000
+++ ../logrotate-3.7.9/config.c 2011-05-24 11:34:58.342359700 +0100
@@ -104,7 +104,7 @@
 
        chptr = start;
 
-       while( (len = mbrtowc(&pwc, chptr, strlen(chptr), NULL)) != 0 ) {
+       while( chptr[0] && (len = mbrtowc(&pwc, chptr, strlen(chptr), NULL)) != 
0 ) {
                if( len == (size_t)(-1) || len == (size_t)(-2) || 
!iswprint(pwc) || iswblank(pwc) ) {
                    message(MESS_ERROR, "%s:%d bad %s path %s\n",
                            configFile, lineNum, key, start);
@@ -553,7 +553,7 @@
     }
 
        length = sb.st_size;
-#ifdef __hpux
+#if defined(__hpux) || defined(__CYGWIN__)
        buf = (char *)malloc(length+2);
         if (buf==(char *)NULL)
         {
@@ -584,7 +584,7 @@
        /* knowing the buffer ends with a newline makes things (a bit) cleaner 
*/
        buf[length + 1] = '\0';
        buf[length] = '\n';
-#ifndef __hpux
+#if !(defined(__hpux) || defined(__CYGWIN__))
        madvise(buf, (size_t)(length + 2),
                        MADV_SEQUENTIAL | MADV_WILLNEED | MADV_DONTFORK);
 #endif
@@ -696,6 +696,14 @@
                newlog->flags &= ~LOG_FLAG_COMPRESS;
 
                *endtag = oldchar, start = endtag;
+           } else if (!strcmp(start, "duplicateok")) {
+               newlog->flags |= LOG_FLAG_DUPLICATEOK;
+
+               *endtag = oldchar, start = endtag;
+           } else if (!strcmp(start, "noduplicateok")) {
+               newlog->flags &= ~LOG_FLAG_DUPLICATEOK;
+
+               *endtag = oldchar, start = endtag;
            } else if (!strcmp(start, "delaycompress")) {
                newlog->flags |= LOG_FLAG_DELAYCOMPRESS;
 
@@ -1439,22 +1447,34 @@
 
                    for (log = logs.tqh_first; log != NULL;
                                log = log->list.tqe_next) {
-                       for (k = 0; k < log->numFiles; k++) {
-                           if (!strcmp(log->files[k],
-                                       globResult.gl_pathv[i])) {
-                               message(MESS_ERROR,
-                                       "%s:%d duplicate log entry for %s\n",
-                                       configFile, lineNum,
-                                       globResult.gl_pathv[i]);
-                               logerror = 1;
-                               goto duperror;
-                           }
-                       }
+                               for (k = 0; k < log->numFiles; k++) {
+                                       if (!strcmp(log->files[k],
+                                               globResult.gl_pathv[i])) {
+                                               if (log->flags & 
LOG_FLAG_DUPLICATEOK) {
+                                                       message(MESS_VERBOSE,
+                                                               "%s:%d 
duplicate log entry for %s using pattern \"%s\"\n",
+                                                               configFile, 
lineNum,
+                                                               
globResult.gl_pathv[i],
+                                                               log->pattern);
+                                                       /* Already registered, 
but the original definition allows duplicates.
+                                                        * Allow the program to 
continue, using the original match. */
+                                                       goto dupcontinue;
+                                               } else {
+                                                       message(MESS_ERROR,
+                                                               "%s:%d 
duplicate log entry for %s\n",
+                                                               configFile, 
lineNum,
+                                                               
globResult.gl_pathv[i]);
+                                                       logerror = 1;
+                                                       goto duperror;
+                                               }
+                                       }
+                               }
                    }
 
                    newlog->files[newlog->numFiles] =
                        strdup(globResult.gl_pathv[i]);
                    newlog->numFiles++;
+dupcontinue: {}
                }
 duperror:
                globfree(&globResult);
--- logrotate.c 2011-03-08 11:07:19.000000000 +0000
+++ ../logrotate-3.7.9/logrotate.c      2011-05-25 13:25:12.135348600 +0100
@@ -1418,6 +1418,11 @@
        for (i = 0; i < hashSize; i++) {
                for (p = states[i]->head.lh_first; p != NULL;
                                p = p->list.le_next) {
+
+                       if (p->sb.st_ctime == 0 && p->sb.st_ino == 0) {
+                               continue;
+                       }
+
                        fputc('"', f);
                        for (chptr = p->fn; *chptr; chptr++) {
                                switch (*chptr) {
--- logrotate.h 2010-06-28 09:04:56.000000000 +0100
+++ ../logrotate-3.7.9/logrotate.h      2011-05-23 17:12:06.260082900 +0100
@@ -18,6 +18,7 @@
 #define LOG_FLAG_COPY          (1 << 8)
 #define LOG_FLAG_DATEEXT       (1 << 9)
 #define LOG_FLAG_SHRED         (1 << 10)
+#define LOG_FLAG_DUPLICATEOK   (1 << 11)
 
 #define NO_MODE ((mode_t) -1)
 #define NO_UID  ((uid_t) -1)

Reply via email to