mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-28 16:43:09 +00:00
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.
This commit is contained in:
parent
befd9c61ce
commit
074dccd545
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98693
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user