]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add LogFileGroup directive (Issue #34)
authorMichael R Sweet <msweet@msweet.org>
Sat, 14 Nov 2020 15:04:43 +0000 (10:04 -0500)
committerMichael R Sweet <msweet@msweet.org>
Sat, 14 Nov 2020 15:04:43 +0000 (10:04 -0500)
CHANGES-OPENPRINTING.md
man/cups-files.conf.5
scheduler/conf.c
scheduler/conf.h
scheduler/log.c

index 8a7c799727d6fd563c72a820b1c559cdb5a9d18f..a70a1fa42825b12b84dfb4fd208bc4c7865e33bf 100644 (file)
@@ -25,6 +25,8 @@ Changes in CUPS v2.3.3op1
   (Issue #30, Issue #31)
 - The scheduler no longer adds the local hostname to the ServerAlias list
   (Issue #32)
+- Added `LogFileGroup` directive in "cups-files.conf" to control the group
+  owner of log files (Issue #34)
 - Added `--with-max-log-size` configure option (Issue #35)
 - Added `--enable-sync-on-close` configure option (Issue #37)
 - Added `--with-error-policy` configure option (Issue #38)
index d9b9a63e3c26425077254365df29e64b2df775b2..0bfc211595bdc41b3ccf62e51a9dc41afcb3cc93 100644 (file)
@@ -131,6 +131,12 @@ Bad startup file permissions are fatal, for example shared TLS certificate and k
 \fBGroup \fIgroup-name-or-number\fR
 Specifies the group name or ID that will be used when executing external programs.
 The default group is operating system specific but is usually "lp" or "nobody".
+.RE
+.\"#LogFileGroup
+.TP 5
+\fBLogFileGroup \fIgroup-name-or-number\fR
+Specifies the group name or ID that will be used for log files.
+The default group is operating system specific but is usually "lp" or "nobody".
 .\"#LogFilePerm
 .TP 5
 \fBLogFilePerm \fImode\fR
index 8dfebe546777aa77a495087e8e47fd54d1f30b8e..74531a8c78392ce9ccd9faa21a86c71e504773e9 100644 (file)
@@ -723,6 +723,7 @@ cupsdReadConfiguration(void)
   ListenBackLog            = SOMAXCONN;
   LogDebugHistory          = 200;
   LogFilePerm              = CUPS_DEFAULT_LOG_FILE_PERM;
+  LogFileGroup             = Group;
   LogLevel                 = CUPSD_LOG_WARN;
   LogTimeFormat            = CUPSD_TIME_STANDARD;
   MaxClients               = 100;
@@ -3511,6 +3512,31 @@ read_cups_files_conf(cups_file_t *fp)    /* I - File to read from */
        }
       }
     }
+    else if (!_cups_strcasecmp(line, "LogFileGroup") && value)
+    {
+     /*
+      * Group ID to log as...
+      */
+
+      if (isdigit(value[0]))
+        LogFileGroup = (gid_t)atoi(value);
+      else
+      {
+        endgrent();
+       group = getgrnam(value);
+
+       if (group != NULL)
+         LogFileGroup = group->gr_gid;
+       else
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Unknown LogFileGroup \"%s\" on line %d of %s.", value,
+                         linenum, CupsFilesFile);
+         if (FatalErrors & CUPSD_FATAL_CONFIG)
+           return (0);
+       }
+      }
+    }
     else if (!_cups_strcasecmp(line, "PassEnv") && value)
     {
      /*
index b4e14eed99d157b2c1e02c1e4708ca85f08678f4..7d5eb4018df834f6224644e4298cbee0906a4855 100644 (file)
@@ -173,6 +173,8 @@ VAR mode_t          ConfigFilePerm          VALUE(0640U),
                                        /* Permissions for config files */
                        LogFilePerm             VALUE(0644U);
                                        /* Permissions for log files */
+VAR gid_t              LogFileGroup            VALUE(0);
+                                       /* Group ID for log files */
 VAR cupsd_loglevel_t   LogLevel                VALUE(CUPSD_LOG_WARN);
                                        /* Error log level */
 VAR cupsd_time_t       LogTimeFormat           VALUE(CUPSD_TIME_STANDARD);
index 2bd1952f7d1decd39edf1d1a699e4795504a426b..17331ff02e761e6b49f68390ae52de4803993f99 100644 (file)
@@ -241,7 +241,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, LogFileGroup);
       fchmod(cupsFileNumber(*lf), LogFilePerm);
     }
   }
@@ -284,7 +284,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, LogFileGroup);
     fchmod(cupsFileNumber(*lf), LogFilePerm);
   }