summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 14:54:07 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 14:54:07 +0000
commited070f3fb430bf14b9fae10c25312f6dc4235aa6 (patch)
tree79d8c933c3c15d70be2199190d7f5821d2e212b5 /pw
parent39d77815028ba1a72509c07e0a8583493f6ec0a8 (diff)
downloadpw-darwin-ed070f3fb430bf14b9fae10c25312f6dc4235aa6.tar.gz
pw-darwin-ed070f3fb430bf14b9fae10c25312f6dc4235aa6.tar.zst
pw-darwin-ed070f3fb430bf14b9fae10c25312f6dc4235aa6.zip
Handle -C and -Y locally and stop adding them to arglist
Diffstat (limited to 'pw')
-rw-r--r--pw/pw.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/pw/pw.c b/pw/pw.c
index 174a9dc..991019d 100644
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -102,7 +102,7 @@ main(int argc, char *argv[])
char *config = NULL;
struct stat st;
char arg;
- bool relocated = false;
+ bool relocated, nis;
static const char *opts[W_NUM][M_NUM] =
{
@@ -130,6 +130,7 @@ main(int argc, char *argv[])
pw_group
};
+ relocated = nis = false;
conf.rootdir[0] = '\0';
strlcpy(conf.etcpath, _PATH_PWD, sizeof(conf.etcpath));
@@ -210,10 +211,20 @@ main(int argc, char *argv[])
optarg = NULL;
while ((ch = getopt(argc, argv, opts[which][mode])) != -1) {
- if (ch == '?')
+ switch (ch) {
+ case '?':
errx(EX_USAGE, "unknown switch");
- else
+ break;
+ case 'C':
+ config = optarg;
+ break;
+ case 'Y':
+ nis = true;
+ break;
+ default:
addarg(&arglist, ch, optarg);
+ break;
+ }
optarg = NULL;
}
@@ -234,7 +245,6 @@ main(int argc, char *argv[])
* Set our base working path if not overridden
*/
- config = getarg(&arglist, 'C') ? getarg(&arglist, 'C')->val : NULL;
if (config == NULL) { /* Only override config location if -C not specified */
asprintf(&config, "%s/pw.conf", conf.etcpath);
if (config == NULL)
@@ -252,7 +262,7 @@ main(int argc, char *argv[])
* If everything went ok, and we've been asked to update
* the NIS maps, then do it now
*/
- if (ch == EXIT_SUCCESS && getarg(&arglist, 'Y') != NULL) {
+ if (ch == EXIT_SUCCESS && nis) {
pid_t pid;
fflush(NULL);