diff options
author | bapt <bapt@FreeBSD.org> | 2012-12-27 14:09:50 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-12-27 14:09:50 +0000 |
commit | 925e83c0bd84aa809deda8a20cab358ea1c0780b (patch) | |
tree | 59730ef56a5c93ebde101a13ff5a9c4b1109f4c4 /lib/libutil/pw_util.c | |
parent | e2e297c506f64de57458124db77b210dae820682 (diff) | |
download | FreeBSD-src-925e83c0bd84aa809deda8a20cab358ea1c0780b.zip FreeBSD-src-925e83c0bd84aa809deda8a20cab358ea1c0780b.tar.gz |
Use flopen(3) instead of open(2) + flock(2)
Diffstat (limited to 'lib/libutil/pw_util.c')
-rw-r--r-- | lib/libutil/pw_util.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index 4bf3001..24c0263 100644 --- a/lib/libutil/pw_util.c +++ b/lib/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, 0); + if (lockfd == -1) { if (errno == EWOULDBLOCK) { errx(1, "the password db file is busy"); } else { |