summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2004-07-21 17:38:04 +0000
committerimp <imp@FreeBSD.org>2004-07-21 17:38:04 +0000
commit697fd69b851e325aff839d56bd1bda29af5b50f5 (patch)
treefda3fc992608d758e04a139ceeb5bd23c85a9792 /usr.sbin
parentfc96a672a7a0b1968e7ace3d7393d759e113144a (diff)
downloadFreeBSD-src-697fd69b851e325aff839d56bd1bda29af5b50f5.zip
FreeBSD-src-697fd69b851e325aff839d56bd1bda29af5b50f5.tar.gz
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
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.811
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c12
2 files changed, 19 insertions, 4 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.8 b/usr.sbin/pwd_mkdb/pwd_mkdb.8
index 9d47412..a29ab4e 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.8
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.8
@@ -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 .
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 5731aef..204a588 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -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);
}
OpenPOWER on IntegriCloud