diff -u sysklogd-1.5/syslogd.c sysklogd-1.5/syslogd.c --- sysklogd-1.5/syslogd.c +++ sysklogd-1.5/syslogd.c @@ -50,6 +50,10 @@ * Added option "-u " to drop privileges to given user after * initialisation. * + * Sat Jan 24 2008 21:32:00 CET 2008: Tormod Volden + * Added options -U and -G to change log file owner and/or group to + * the user (and/or primary group) of the -u option. + * * Steve Lord: Fix UNIX domain socket code, added linux kernel logging * change defines to * SYSLOG_INET - listen on a UDP socket @@ -619,6 +623,8 @@ static int debugging_on = 0; static int nlogs = -1; static int restart = 0; +uid_t owner = -1; +uid_t group = -1; #define MAXFUNIX 20 @@ -898,7 +904,7 @@ funix[i] = -1; } - while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:vu:")) != EOF) + while ((ch = getopt(argc, argv, "a:dhf:Gl:m:np:rs:vu:U")) != EOF) switch((char)ch) { case 'a': if (nfunix < MAXFUNIX) @@ -912,6 +918,9 @@ case 'f': /* configuration file */ ConfFile = optarg; break; + case 'G': + group = 0; + break; case 'h': NoHops = 0; break; @@ -961,6 +970,9 @@ exit (1); } break; + case 'U': + owner = 0; + break; case '?': default: usage(); @@ -968,6 +980,8 @@ if ((argc -= optind)) usage(); + if (owner == 0) owner = uid; + if (group == 0) group = gid; #ifndef TESTING if ( !(Debug || NoFork) ) { @@ -1278,7 +1292,7 @@ int usage() { - fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ + fprintf(stderr, "usage: syslogd [-drvhUG] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ " [-s domainlist] [-f conffile] [-u user]\n"); exit(1); } @@ -2785,6 +2799,7 @@ } else { f->f_file = open(p, O_WRONLY|O_APPEND|O_CREAT|O_NONBLOCK|O_NOCTTY, 0644); + fchown(f->f_file, owner, group); f->f_type = F_FILE; } diff -u sysklogd-1.5/debian/changelog sysklogd-1.5/debian/changelog --- sysklogd-1.5/debian/changelog +++ sysklogd-1.5/debian/changelog @@ -1,3 +1,9 @@ +sysklogd (1.5-5ubuntu4) jaunty; urgency=low + + * add -U and -G options to chown log files + + -- Tormod Volden Sat, 24 Jan 2009 21:35:13 +0100 + sysklogd (1.5-5ubuntu3) jaunty; urgency=low * Add test for /etc/unbound/syslogd to debian/rc (init script) to grab the