Make log files readable to group "adm", if present.

Bug-Ubuntu: https://launchpad.net/bugs/345953
Patch-Name: logfiles_adm_readable.patch

Gbp-Pq: Name 0025-Make-log-files-readable-to-group-adm-if-present.patch
This commit is contained in:
Martin Pitt 2016-08-09 18:11:38 +02:00 committed by openKylinBot
parent dca4965086
commit 4e347e8f31
1 changed files with 9 additions and 2 deletions

View File

@ -21,6 +21,7 @@
# include <systemd/sd-journal.h>
#endif /* HAVE_ASL_H */
#include <syslog.h>
#include <grp.h>
/*
@ -110,6 +111,7 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */
filename[1024], /* Formatted log filename */
*ptr; /* Pointer into filename */
const char *logptr; /* Pointer into log filename */
struct group *loggrp; /* Group entry of log filename */
/*
@ -129,6 +131,11 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */
return (1);
}
/*
* Use adm group if possible, fall back to Group
*/
loggrp = getgrnam("adm");
/*
* Format the filename as needed...
*/
@ -241,7 +248,7 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */
* Change ownership and permissions of non-device logs...
*/
fchown(cupsFileNumber(*lf), RunUser, Group);
fchown(cupsFileNumber(*lf), RunUser, loggrp ? loggrp->gr_gid : Group);
fchmod(cupsFileNumber(*lf), LogFilePerm);
}
}
@ -284,7 +291,7 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */
* Change ownership and permissions of non-device logs...
*/
fchown(cupsFileNumber(*lf), RunUser, Group);
fchown(cupsFileNumber(*lf), RunUser, loggrp ? loggrp->gr_gid : Group);
fchmod(cupsFileNumber(*lf), LogFilePerm);
}