Package: logrotate
Version: 3.7.1-3
Severity: wishlist
Tags: patch

Logrotate should allow the user to specify the create uid/gid
numerically.  This is useful with network filesystems which have their
own set of uids that don't map to a system username.

-- Package-specific info:
Contents of /etc/logrotate.d
total 76
-rw-r--r-- 1 root root 137 2006-01-15 15:24 acpid
-rw-r--r-- 1 root root 366 2005-05-11 04:33 apache
-rw-r--r-- 1 root root 240 2006-01-16 04:15 apache2
-rw-r--r-- 1 root root  79 2003-06-09 15:05 aptitude
-rw-r--r-- 1 root root 384 2003-12-08 17:25 base-config
-rw-r--r-- 1 root root 215 2005-05-16 19:52 clamav-freshclam
-rw-r--r-- 1 root root 308 2004-01-20 15:17 distcc
-rw-r--r-- 1 root root 111 2005-06-28 08:22 dpkg
-rw-r--r-- 1 root root 273 2006-10-23 14:10 exim4-base
-rw-r--r-- 1 root root 151 2002-11-11 10:54 iptraf
-rw-r--r-- 1 root root 466 2005-05-04 19:13 nessusd
-rw-r--r-- 1 root root 153 2005-11-03 15:34 postgresql-common
-rw-r--r-- 1 root root  94 2003-10-30 15:44 ppp
-rw-r--r-- 1 root root 417 2006-02-11 15:45 privoxy
-rw-r--r-- 1 root root 330 2005-05-27 02:19 samba
-rw-r--r-- 1 root root 159 2001-10-29 18:29 samba.dpkg-old
-rw-r--r-- 1 root root  68 2004-02-08 03:18 scrollkeeper
-rw-r--r-- 1 root root 120 2003-01-24 08:35 tetrinetx
-rw-r--r-- 1 root root 333 2005-08-31 11:02 xdm


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.11
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages logrotate depends on:
ii  base-passwd                 3.5.11       Debian base system master password
ii  cron                        3.0pl1-100   management of regular background p
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libpopt0                    1.10-3       lib for parsing cmdline parameters
ii  libselinux1                 1.32-3       SELinux shared libraries

Versions of packages logrotate recommends:
ii  mailx            1:8.1.2-0.20050715cvs-1 A simple mail user agent

-- no debconf information
diff -ur logrotate-3.7.1/config.c new/config.c
--- logrotate-3.7.1/config.c	2003-08-07 06:13:14.000000000 -0500
+++ new/config.c	2007-03-22 11:36:47.000000000 -0500
@@ -14,6 +14,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <assert.h>
+#include <limits.h>
 
 #include "basenames.h"
 #include "log.h"
@@ -544,24 +555,38 @@
 		    newlog->createMode = createMode;
 		
 		if (rc > 1) {
-		    pw = getpwnam(createOwner);
-		    if (!pw) {
-			message(MESS_ERROR, "%s:%d unknown user '%s'\n", 
-				configFile, lineNum, createOwner);
-			return 1;
-		    } 
-		    newlog->createUid = pw->pw_uid;
-		    endpwent();
+		    char* endptr;
+		    uid_t myuid;
+		    myuid = strtoul(createOwner, &endptr, 10);
+		    if (createOwner[0] != '\0' && *endptr == '\0' && myuid != ULONG_MAX)
+			newlog->createUid = myuid;
+		    else {
+			pw = getpwnam(createOwner);
+			if (!pw) {
+			    message(MESS_ERROR, "%s:%d unknown user '%s'\n", 
+				    configFile, lineNum, createOwner);
+			    return 1;
+			} 
+			newlog->createUid = pw->pw_uid;
+			endpwent();
+		    }
 		} 
 		if (rc > 2) {
-		    group = getgrnam(createGroup);
-		    if (!group) {
-			message(MESS_ERROR, "%s:%d unknown group '%s'\n", 
-				configFile, lineNum, createGroup);
-			return 1;
-		    } 
-		    newlog->createGid = group->gr_gid;
-		    endgrent();
+		    char* endptr;
+		    gid_t mygid;
+		    mygid = strtoul(createGroup, &endptr, 10);
+		    if (createGroup[0] != '\0' && *endptr == '\0' && mygid != ULONG_MAX)
+			newlog->createGid = mygid;
+		    else {
+			group = getgrnam(createGroup);
+			if (!group) {
+			    message(MESS_ERROR, "%s:%d unknown group '%s'\n", 
+				    configFile, lineNum, createGroup);
+			    return 1;
+			} 
+			newlog->createGid = group->gr_gid;
+			endgrent();
+		    }
 		} 
 
 		newlog->flags |= LOG_FLAG_CREATE;

Reply via email to