diff options
| author | Nick Hibma <n_hibma@FreeBSD.org> | 2002-06-23 19:23:46 +0000 |
|---|---|---|
| committer | Nick Hibma <n_hibma@FreeBSD.org> | 2002-06-23 19:23:46 +0000 |
| commit | c3a9c71d1da3d5ff0359720aa43aa8c3d74327b9 (patch) | |
| tree | bbff72da622974b8ad496a9bd5f814e83271c2a3 /libutil/pw_util.c | |
| parent | 39885fea466f2c6d648839abd52838e89fba1229 (diff) | |
| download | pw-darwin-c3a9c71d1da3d5ff0359720aa43aa8c3d74327b9.tar.gz pw-darwin-c3a9c71d1da3d5ff0359720aa43aa8c3d74327b9.zip | |
Be more clear in error messages.
Distinguish between a held lock and a failed lock op.
If rpc.lockd is not running on a diskless client this makes clearer
what the problem is.
Diffstat (limited to 'libutil/pw_util.c')
| -rw-r--r-- | libutil/pw_util.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c index 72c4723..444140d 100644 --- a/libutil/pw_util.c +++ b/libutil/pw_util.c @@ -185,16 +185,21 @@ pw_lock(void) 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)) - errx(1, "the password db file is busy"); + if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) { + if (errno == EWOULDBLOCK) { + errx(1, "the password db file is busy"); + } else { + err(1, "could not lock the passwd file: "); + } + } /* * If the password file was replaced while we were trying to * get the lock, our hardlink count will be 0 and we have to * close and retry. */ - if (fstat(lockfd, &st) < 0) - errx(1, "fstat() failed"); + if (fstat(lockfd, &st) == -1) + err(1, "fstat() failed: "); if (st.st_nlink != 0) break; close(lockfd); |
