Question on source4/smbd/pidfile.c

Maurice Gittens mainmanmauricio at gmail.com
Sat Aug 7 07:14:25 MDT 2010


Hi,

while browsing the samba source code I came across source4/smbd/pidfile.c
Can anyone explain why the following patch would not be needed for this
file?

index de93a03..e777d73 100644
--- a/source4/smbd/pidfile.c
+++ b/source4/smbd/pidfile.c
@@ -42,7 +42,7 @@ pid_t pidfile_pid(const char *piddir, const char *name)
                return 0;
        }

-       fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
+       fd = open(pidFile, O_RDONLY, 0644);

        if (fd == -1) {
                SAFE_FREE(pidFile);
@@ -72,7 +72,6 @@ pid_t pidfile_pid(const char *piddir, const char *name)

  noproc:
        close(fd);
-       unlink(pidFile);
        SAFE_FREE(pidFile);
        return 0;
 }


Opening the pidFile in nonblocking mode seems like an invitation to a race
and unlink(pidFile), which we didn't create ourselves also
does not seem like the right thing todo.

Cheers,
Maurice


More information about the samba-technical mailing list