File: pid_perms

package info (click to toggle)
ndppd 0.2.5-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 268 kB
  • sloc: cpp: 2,178; sh: 83; makefile: 36
file content (28 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Description: Umask pid file permissions
 Pid file was created with default 666 permissions. This causes security
 issues when trying to stop the process. init stopped working because
 start-stop-daemon(8) refuses to handle these nasty permissions, since dpkg
 version 1.19.3.
Author: Jean-Michel Vourgère <nirgal@debian.org>
Bug-Debian: https://bugs.debian.org/942117
Bug: https://github.com/DanielAdolfsson/ndppd/issues/56
Forwarded: yes
Last-Update: 2019-10-12

Index: ndppd-0.2.5/src/ndppd.cc
===================================================================
--- ndppd-0.2.5.orig/src/ndppd.cc
+++ ndppd-0.2.5/src/ndppd.cc
@@ -274,10 +274,12 @@ int main(int argc, char* argv[], char* e
         return -1;
 
     if (!pidfile.empty()) {
+        mode_t old_umask = umask(022);
         std::ofstream pf;
         pf.open(pidfile.c_str(), std::ios::out | std::ios::trunc);
         pf << getpid() << std::endl;
         pf.close();
+        umask(old_umask);
     }
 
     // Time stuff.