From 4e347e8f31f7338043e23b0022e00c85a2f7df2d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 9 Aug 2016 18:11:38 +0200 Subject: [PATCH] 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 --- scheduler/log.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scheduler/log.c b/scheduler/log.c index 2bd1952..ae0aa55 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -21,6 +21,7 @@ # include #endif /* HAVE_ASL_H */ #include +#include /* @@ -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); }