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 | c063e9ec3e90508e846dd51e22a643c74c02f7c1 (patch) | |
tree | acc4717e33dfdf1a6492e00b5737da1a3a708be0 /source3/smbd | |
parent | e2b50d04ad5eb5fa7c10b59cf5ba0cfe374ab240 (diff) | |
download | samba-c063e9ec3e90508e846dd51e22a643c74c02f7c1.tar.gz samba-c063e9ec3e90508e846dd51e22a643c74c02f7c1.tar.bz2 samba-c063e9ec3e90508e846dd51e22a643c74c02f7c1.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.
(This used to be commit 20bb22d61b986d2036c681fc33db60f2b2b3c1c7)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/server.c | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index b42ebd6c0f..ca4a95f59d 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -5144,9 +5144,6 @@ static void usage(char *pname) int port = SMB_PORT; int opt; extern char *optarg; - char pidFile[100]; - - *pidFile = '\0'; #ifdef NEED_AUTH_PARAMETERS set_auth_parameters(argc,argv); @@ -5200,9 +5197,6 @@ static void usage(char *pname) while ((opt = getopt(argc, argv, "O:i:l:s:d:Dp:hPaf:")) != EOF) switch (opt) { - case 'f': - strncpy(pidFile, optarg, sizeof(pidFile)); - break; case 'O': strcpy(user_socket_options,optarg); break; @@ -5328,33 +5322,9 @@ static void usage(char *pname) mkdir(lp_lockdir(), 0755); } - if (*pidFile) - { - int fd; - char buf[20]; - - if ((fd = open(pidFile, -#ifdef O_NONBLOCK - O_NONBLOCK | -#endif - O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 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: smbd 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 (is_daemon) { + pidfile_create("smbd"); + } if (!open_sockets(is_daemon,port)) exit(1); |