From owner-freebsd-bugs Wed Mar 10 10:50:16 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 47F551515E for ; Wed, 10 Mar 1999 10:50:14 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id KAA74106; Wed, 10 Mar 1999 10:50:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 5D84C152BB; Wed, 10 Mar 1999 10:48:56 -0800 (PST) Message-Id: <19990310184856.5D84C152BB@hub.freebsd.org> Date: Wed, 10 Mar 1999 10:48:56 -0800 (PST) From: lopez@cisco.com To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: i386/10531: uu_lock stores wrong pid if lock exists and locking process doesn't Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 10531 >Category: i386 >Synopsis: uu_lock stores wrong pid if lock exists and locking process doesn't >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 10 10:50:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Lawrence D. Lopez >Release: 3.0 >Organization: cisco systems/network masters/l3ds >Environment: FreeBSD nptestbed2.dtdtools.cisco.com 3.0-RELEASE FreeBSD 3.0-RELEASE #78: Wed Mar 10 12:54:22 EST 1999 lawlopez@nptestbed2.dtdtools.cisco.com:/usr/src/sys/compile/NPTESTBED2 i386 >Description: /usr/src/lib/libutil/uucplock.c 8.1 If a lock file exists and the processes which created the lock file does not exist then a process using uu_lock creates a lock file with the process id which is in the old lock file. This prevents subsequent detection of the fact that the program which created the lock file still has the lock file locked because the lock file has the processid of the previous creator of the lock file in it. >How-To-Repeat: 1) compile the following program. 2) run the following program. Control C it. 3) run the following program. Control Z it. 4) repeat step 3) until you are bored. All of the processes in step 3) think they have the lock. /* cc -o uulock uulock.c -lutil */ main() { char c; int i = uu_lock("special"); if (i == 0) { printf("we have the lock\n"); for (;;) sleep(1); } printf("we do not have the lock\n"); } >Fix: In /usr/src/lib/libutil/uuplock.c static const char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93"; Change: 73c73 < pid_t pid; --- > pid_t pid, pid_old; 98c98 < if ((pid = get_pid (fd, &err)) == -1) --- > if ((pid_old = get_pid (fd, &err)) == -1) 103c103 < if (kill(pid, 0) == 0 || errno != ESRCH) --- > if (kill(pid_old, 0) == 0 || errno != ESRCH) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message