Add support for ignoring locking failures. This is only enabled when
you've specified a directory. It is intended to be used in building custom releases over NFS where locking may be unreliable at best and there is no contention that the locking is designed to arbitrate. Other uses of this flag are discouraged. Document same in usage and man page (including the warning about unwise). Sponsored by: Timing Solutions
This commit is contained in:
parent
0def575fd7
commit
9906740e39
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132509
@ -43,6 +43,7 @@
|
||||
.Op Fl C
|
||||
.Op Fl N
|
||||
.Op Fl p
|
||||
.Op Fl i
|
||||
.Op Fl d Ar directory
|
||||
.Op Fl s Ar cachesize
|
||||
.Op Fl u Ar username
|
||||
@ -82,6 +83,16 @@ the rebuilding of the database.
|
||||
.It Fl p
|
||||
Create a Version 7 style password file and install it into
|
||||
.Pa /etc/passwd .
|
||||
.It Fl i
|
||||
Ignore locking failure of the
|
||||
.Pa master.passwd
|
||||
file.
|
||||
This option is intended to be used to build password files in
|
||||
the release process over NFS where no contention can happen.
|
||||
A non-default directory must also be specified with the
|
||||
.Fl d
|
||||
option for locking to be ignored.
|
||||
Other use of this option is strongly discouraged.
|
||||
.It Fl d Ar directory
|
||||
Store databases into specified destination directory instead of
|
||||
.Pa /etc .
|
||||
|
@ -115,10 +115,10 @@ main(int argc, char *argv[])
|
||||
char sbuf2[MAXPATHLEN];
|
||||
char *username;
|
||||
u_int method, methoduid;
|
||||
int Cflag;
|
||||
int Cflag, dflag, iflag;
|
||||
int nblock = 0;
|
||||
|
||||
Cflag = 0;
|
||||
iflag = dflag = Cflag = 0;
|
||||
strcpy(prefix, _PATH_PWD);
|
||||
makeold = 0;
|
||||
username = NULL;
|
||||
@ -131,8 +131,12 @@ main(int argc, char *argv[])
|
||||
nblock = LOCK_NB; /* will fail if locked */
|
||||
break;
|
||||
case 'd':
|
||||
dflag++;
|
||||
strlcpy(prefix, optarg, sizeof(prefix));
|
||||
break;
|
||||
case 'i':
|
||||
iflag++;
|
||||
break;
|
||||
case 'p': /* create V7 "file.orig" */
|
||||
makeold = 1;
|
||||
break;
|
||||
@ -184,7 +188,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if (!(fp = fopen(pname, "r")))
|
||||
error(pname);
|
||||
if (flock(fileno(fp), LOCK_EX|nblock) < 0)
|
||||
if (flock(fileno(fp), LOCK_EX|nblock) < 0 && !(dflag && iflag))
|
||||
error("flock");
|
||||
if (fstat(fileno(fp), &st) < 0)
|
||||
error(pname);
|
||||
@ -752,6 +756,6 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: pwd_mkdb [-C] [-N] [-p] [-d <dest dir>] [-s <cachesize>] [-u <local username>] file\n");
|
||||
"usage: pwd_mkdb [-C] [-N] [-i] [-p] [-d <dest dir>] [-s <cachesize>] [-u <local username>] file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user