Browse code

freshclam: make pid file readable by all

Changes the umask so that anyone can read the pid file.

Micah Snyder authored on 2020/09/07 06:11:18
Showing 1 changed files
... ...
@@ -126,7 +126,7 @@ static int writepid(const char *pidfile)
126 126
 {
127 127
     FILE *fd;
128 128
     int old_umask;
129
-    old_umask = umask(0006);
129
+    old_umask = umask(0002);
130 130
     if ((fd = fopen(pidfile, "w")) == NULL) {
131 131
         logg("!Can't save PID to file %s: %s\n", pidfile, strerror(errno));
132 132
         return 1;
... ...
@@ -140,10 +140,10 @@ static int writepid(const char *pidfile)
140 140
     /*If the file has already been created by a different user, it will just be
141 141
      * rewritten by us, but not change the ownership, so do that explicitly.
142 142
      */
143
-    if (0 == geteuid()){
144
-        struct passwd * pw = getpwuid(0);
145
-        int ret = lchown(pidfile, pw->pw_uid, pw->pw_gid);
146
-        if (ret){
143
+    if (0 == geteuid()) {
144
+        struct passwd *pw = getpwuid(0);
145
+        int ret           = lchown(pidfile, pw->pw_uid, pw->pw_gid);
146
+        if (ret) {
147 147
             logg("!Can't change ownership of PID file %s '%s'\n", pidfile, strerror(errno));
148 148
             return 1;
149 149
         }
... ...
@@ -1536,7 +1536,7 @@ int main(int argc, char **argv)
1536 1536
 
1537 1537
 #ifdef HAVE_PWD_H
1538 1538
     const struct optstruct *logFileOpt = NULL;
1539
-    const char * logFileName = NULL;
1539
+    const char *logFileName            = NULL;
1540 1540
 #endif /* HAVE_PWD_H */
1541 1541
 
1542 1542
     fc_ctx fc_context = {0};
... ...
@@ -1880,7 +1880,7 @@ int main(int argc, char **argv)
1880 1880
         /*  Get the log file name to pass it into drop_privileges.  */
1881 1881
         logFileOpt = optget(opts, "UpdateLogFile");
1882 1882
         if (logFileOpt->enabled) {
1883
-           logFileName  = logFileOpt->strarg;
1883
+            logFileName = logFileOpt->strarg;
1884 1884
         }
1885 1885
 
1886 1886
         /*