From 577824cadb88a52417c8a551d1aa6b70b2224b22 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 15:09:53 +0000 Subject: Handle dryrun (-N) via global pwconf --- pw/pw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pw/pw.c') diff --git a/pw/pw.c b/pw/pw.c index 991019d..7a86680 100644 --- a/pw/pw.c +++ b/pw/pw.c @@ -132,6 +132,7 @@ main(int argc, char *argv[]) relocated = nis = false; conf.rootdir[0] = '\0'; + conf.dryrun = false; strlcpy(conf.etcpath, _PATH_PWD, sizeof(conf.etcpath)); LIST_INIT(&arglist); @@ -218,6 +219,9 @@ main(int argc, char *argv[]) case 'C': config = optarg; break; + case 'N': + conf.dryrun = true; + break; case 'Y': nis = true; break; @@ -231,7 +235,7 @@ main(int argc, char *argv[]) /* * Must be root to attempt an update */ - if (geteuid() != 0 && mode != M_PRINT && mode != M_NEXT && getarg(&arglist, 'N')==NULL) + if (geteuid() != 0 && mode != M_PRINT && mode != M_NEXT && !conf.dryrun) errx(EX_NOPERM, "you must be root to run this program"); /* -- cgit v1.2.3