diff options
| author | David E. O'Brien <obrien@FreeBSD.org> | 2013-02-08 16:10:16 +0000 |
|---|---|---|
| committer | David E. O'Brien <obrien@FreeBSD.org> | 2013-02-08 16:10:16 +0000 |
| commit | 17bc9031bfed577deb2722150179f4c8c11abfe2 (patch) | |
| tree | 9be766d6f5e109ffbe3ffdec25b319a8009cb1fb /libutil/pw_util.c | |
| parent | 23a2b3b59c24cacf1622e3ffb1274c07aca04840 (diff) | |
| parent | 496692e30905aa38932d451f3324c659231b9e84 (diff) | |
| download | pw-darwin-17bc9031bfed577deb2722150179f4c8c11abfe2.tar.gz pw-darwin-17bc9031bfed577deb2722150179f4c8c11abfe2.zip | |
Sync with HEAD.
Diffstat (limited to 'libutil/pw_util.c')
| -rw-r--r-- | libutil/pw_util.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c index 4bf3001..befd1fb 100644 --- a/libutil/pw_util.c +++ b/libutil/pw_util.c @@ -179,11 +179,8 @@ pw_lock(void) for (;;) { struct stat st; - lockfd = open(masterpasswd, O_RDONLY, 0); - if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) - err(1, "%s", masterpasswd); - /* XXX vulnerable to race conditions */ - if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) { + lockfd = flopen(masterpasswd, O_RDONLY|O_NONBLOCK|O_CLOEXEC, 0); + if (lockfd == -1) { if (errno == EWOULDBLOCK) { errx(1, "the password db file is busy"); } else { |
