diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-03-14 12:57:58 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-03-14 12:57:58 +0000 |
commit | 20bb22d61b986d2036c681fc33db60f2b2b3c1c7 (patch) | |
tree | 14ebce65d712fd6cf90bb28264ef6fda30787dd2 /source/nmbd | |
parent | b0e1183b2cbeb7a3150b7250cd19d14c9e5508b6 (diff) | |
download | samba-20bb22d61b986d2036c681fc33db60f2b2b3c1c7.tar.gz samba-20bb22d61b986d2036c681fc33db60f2b2b3c1c7.tar.xz samba-20bb22d61b986d2036c681fc33db60f2b2b3c1c7.zip |
added the ability to start/stop the server from SWAT.
I needed to modify the way the pidfile is handled in nmbd and smbd to
do this. Jeremy, you may wish to look at what I've done as it probably
breaks the Whistle use of pidfiles. In particular I've removed the -f
option and instead smbd and nmbd always create a pidfile in the lock
directory.
Diffstat (limited to 'source/nmbd')
-rw-r--r-- | source/nmbd/nmbd.c | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index f199a21ea8a..e757aa46c41 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -549,7 +549,6 @@ int main(int argc,char *argv[]) int opt; extern FILE *dbf; extern char *optarg; - char pidFile[100] = { 0 }; global_nmb_port = NMB_PORT; *host_file = 0; @@ -599,9 +598,6 @@ int main(int argc,char *argv[]) { switch (opt) { - case 'f': - strncpy(pidFile, optarg, sizeof(pidFile)); - break; case 's': pstrcpy(servicesf,optarg); break; @@ -695,40 +691,11 @@ int main(int argc,char *argv[]) become_daemon(); } - if (!directory_exist(lp_lockdir(), NULL)) - { - mkdir(lp_lockdir(), 0755); - } - - if (*pidFile) - { - int fd; - char buf[20]; - -#ifdef O_NONBLOCK - fd = open( pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_TRUNC, 0644 ); -#else - fd = open( pidFile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); -#endif - if ( fd < 0 ) - { - DEBUG(0,("ERROR: can't open %s: %s\n", pidFile, strerror(errno))); - exit(1); - } - if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False) - { - DEBUG(0,("ERROR: nmbd is already running\n")); - exit(1); - } - sprintf(buf, "%u\n", (unsigned int) getpid()); - if (write(fd, buf, strlen(buf)) < 0) - { - DEBUG(0,("ERROR: can't write to %s: %s\n", pidFile, strerror(errno))); - exit(1); - } - /* Leave pid file open & locked for the duration... */ + if (!directory_exist(lp_lockdir(), NULL)) { + mkdir(lp_lockdir(), 0755); } + pidfile_create("nmbd"); DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) ); |