Pidfile check can be read-only. Removed old ifdef in password.c
authorJeremy Allison <jra@samba.org>
Wed, 1 Aug 2001 17:32:45 +0000 (17:32 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 1 Aug 2001 17:32:45 +0000 (17:32 +0000)
Jeremy.

source/lib/pidfile.c
source/smbd/password.c

index 25ff85483d0b5b04cc829ea876b8c6521a1406a1..9de672010a40f1620f55831a2ec3eb7b5c78be23 100644 (file)
@@ -41,7 +41,7 @@ pid_t pidfile_pid(char *name)
 
        slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_lockdir(), name);
 
-       fd = sys_open(pidFile, O_NONBLOCK | O_RDWR, 0644);
+       fd = sys_open(pidFile, O_NONBLOCK | O_RONLY, 0644);
        if (fd == -1) {
                return 0;
        }
@@ -49,24 +49,24 @@ pid_t pidfile_pid(char *name)
        ZERO_ARRAY(pidstr);
 
        if (read(fd, pidstr, sizeof(pidstr)-1) <= 0) {
-               goto ok;
+               goto noproc;
        }
 
        ret = atoi(pidstr);
        
        if (!process_exists((pid_t)ret)) {
-               goto ok;
+               goto noproc;
        }
 
-       if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_WRLCK)) {
+       if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_RDLCK)) {
                /* we could get the lock - it can't be a Samba process */
-               goto ok;
+               goto noproc;
        }
 
        close(fd);
        return (pid_t)ret;
 
ok:
noproc:
        close(fd);
        unlink(pidFile);
        return 0;
index bc05d5f500ea0f92bee23f02b80f74e9d5f050ed..743d6ebffec8a16510ca80d38f739d8a59413434 100644 (file)
@@ -42,31 +42,10 @@ Get the next challenge value - no repeats.
 ********************************************************************/
 void generate_next_challenge(char *challenge)
 {
-#if 0
-        /* 
-         * Leave this ifdef'd out while we test
-         * the new crypto random number generator.
-         * JRA.
-         */
-       unsigned char buf[16];
-       static int counter = 0;
-       struct timeval tval;
-       int v1,v2;
-
-       /* get a sort-of random number */
-       GetTimeOfDay(&tval);
-       v1 = (counter++) + sys_getpid() + tval.tv_sec;
-       v2 = (counter++) * sys_getpid() + tval.tv_usec;
-       SIVAL(challenge,0,v1);
-       SIVAL(challenge,4,v2);
-
-       /* mash it up with md4 */
-       mdfour(buf, (unsigned char *)challenge, 8);
-#else
-        unsigned char buf[8];
+       unsigned char buf[8];
+
+       generate_random_buffer(buf,8,False);
 
-        generate_random_buffer(buf,8,False);
-#endif 
        memcpy(saved_challenge, buf, 8);
        memcpy(challenge,buf,8);
        challenge_sent = True;