[pulseaudio-commits] r1891 - /branches/lennart/src/pulsecore/pid.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Sep 23 12:23:45 PDT 2007


Author: lennart
Date: Sun Sep 23 21:23:44 2007
New Revision: 1891

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1891&root=pulseaudio&view=rev
Log:
use O_NOFOLLOW when creating PID file, to avoid symlink vulnerability

Modified:
    branches/lennart/src/pulsecore/pid.c

Modified: branches/lennart/src/pulsecore/pid.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/pid.c?rev=1891&root=pulseaudio&r1=1890&r2=1891&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/pid.c (original)
+++ branches/lennart/src/pulsecore/pid.c Sun Sep 23 21:23:44 2007
@@ -88,7 +88,12 @@
     for (;;) {
         struct stat st;
 
-        if ((fd = open(fn, mode, S_IRUSR|S_IWUSR)) < 0) {
+        if ((fd = open(fn, mode|O_NOCTTY
+#ifdef O_NOFOLLOW
+                       |O_NOFOLLOW
+#endif
+                       , S_IRUSR|S_IWUSR
+             )) < 0) {
             if (mode != O_RDONLY || errno != ENOENT)
                 pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
             goto fail;
@@ -184,7 +189,7 @@
 fail:
     if (fd >= 0) {
         pa_lock_fd(fd, 0);
-        
+
         if (pa_close(fd) < 0) {
             pa_log("Failed to close PID file '%s': %s", fn, pa_cstrerror(errno));
             ret = -1;
@@ -204,8 +209,7 @@
     pa_runtime_path("pid", fn, sizeof(fn));
 
     if ((fd = open_pid_file(fn, O_RDWR)) < 0) {
-        pa_log_warn("Failed to open PID file '%s': %s",
-            fn, pa_cstrerror(errno));
+        pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
         goto fail;
     }
 




More information about the pulseaudio-commits mailing list