pw_util.c (242324) | pw_util.c (244735) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 2002 Networks Associates Technology, Inc. 5 * All rights reserved. 6 * 7 * Portions of this software were developed for the FreeBSD Project by 8 * ThinkSec AS and NAI Labs, the Security Research Division of Network --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; 40#endif 41static const char rcsid[] = | 1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 2002 Networks Associates Technology, Inc. 5 * All rights reserved. 6 * 7 * Portions of this software were developed for the FreeBSD Project by 8 * ThinkSec AS and NAI Labs, the Security Research Division of Network --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; 40#endif 41static const char rcsid[] = |
42 "$FreeBSD: head/lib/libutil/pw_util.c 242324 2012-10-29 18:06:09Z bapt $"; | 42 "$FreeBSD: head/lib/libutil/pw_util.c 244735 2012-12-27 14:09:50Z bapt $"; |
43#endif /* not lint */ 44 45/* 46 * This file is used by all the "password" programs; vipw(8), chpass(1), 47 * and passwd(1). 48 */ 49 50#include <sys/param.h> --- 123 unchanged lines hidden (view full) --- 174 * If the master password file doesn't exist, the system is hosed. 175 * Might as well try to build one. Set the close-on-exec bit so 176 * that users can't get at the encrypted passwords while editing. 177 * Open should allow flock'ing the file; see 4.4BSD. XXX 178 */ 179 for (;;) { 180 struct stat st; 181 | 43#endif /* not lint */ 44 45/* 46 * This file is used by all the "password" programs; vipw(8), chpass(1), 47 * and passwd(1). 48 */ 49 50#include <sys/param.h> --- 123 unchanged lines hidden (view full) --- 174 * If the master password file doesn't exist, the system is hosed. 175 * Might as well try to build one. Set the close-on-exec bit so 176 * that users can't get at the encrypted passwords while editing. 177 * Open should allow flock'ing the file; see 4.4BSD. XXX 178 */ 179 for (;;) { 180 struct stat st; 181 |
182 lockfd = open(masterpasswd, O_RDONLY, 0); 183 if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) 184 err(1, "%s", masterpasswd); 185 /* XXX vulnerable to race conditions */ 186 if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) { | 182 lockfd = flopen(masterpasswd, O_RDONLY|O_NONBLOCK, 0); 183 if (lockfd == -1) { |
187 if (errno == EWOULDBLOCK) { 188 errx(1, "the password db file is busy"); 189 } else { 190 err(1, "could not lock the passwd file: "); 191 } 192 } 193 194 /* --- 473 unchanged lines hidden --- | 184 if (errno == EWOULDBLOCK) { 185 errx(1, "the password db file is busy"); 186 } else { 187 err(1, "could not lock the passwd file: "); 188 } 189 } 190 191 /* --- 473 unchanged lines hidden --- |