From 697fd69b851e325aff839d56bd1bda29af5b50f5 Mon Sep 17 00:00:00 2001 From: imp Date: Wed, 21 Jul 2004 17:38:04 +0000 Subject: 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 --- usr.sbin/pwd_mkdb/pwd_mkdb.8 | 11 +++++++++++ usr.sbin/pwd_mkdb/pwd_mkdb.c | 12 ++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'usr.sbin') 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 ] [-s ] [-u ] file\n"); +"usage: pwd_mkdb [-C] [-N] [-i] [-p] [-d ] [-s ] [-u ] file\n"); exit(1); } -- cgit v1.1