summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-06-08 05:27:34 +0000
committerbapt <bapt@FreeBSD.org>2015-06-08 05:27:34 +0000
commitec480fe320d4aa3e3de9a2d528d9c3a8bf4ec4cc (patch)
tree5e4a90e22670f8094a1456cfb287ccf021079274
parent6e327f93661ec99c2f7e70dc01edb9049442e46a (diff)
downloadFreeBSD-src-ec480fe320d4aa3e3de9a2d528d9c3a8bf4ec4cc.zip
FreeBSD-src-ec480fe320d4aa3e3de9a2d528d9c3a8bf4ec4cc.tar.gz
backout remove of -q option for pw [user|group] next
While the return code is broken, some corner case usage depends on the functionnality, so backout until we get better regression tests covering those corner case usage.
-rw-r--r--usr.sbin/pw/pw.84
-rw-r--r--usr.sbin/pw/pw.c8
-rw-r--r--usr.sbin/pw/pw_group.c7
-rw-r--r--usr.sbin/pw/pw_user.c10
4 files changed, 20 insertions, 9 deletions
diff --git a/usr.sbin/pw/pw.8 b/usr.sbin/pw/pw.8
index 1c1f740..9074313 100644
--- a/usr.sbin/pw/pw.8
+++ b/usr.sbin/pw/pw.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 7, 2015
+.Dd June 3, 2015
.Dt PW 8
.Os
.Sh NAME
@@ -128,6 +128,7 @@
.Op Fl V Ar etcdir
.Ar usernext
.Op Fl C Ar config
+.Op Fl q
.Nm
.Op Fl R Ar rootdir
.Op Fl V Ar etcdir
@@ -183,6 +184,7 @@
.Op Fl V Ar etcdir
.Ar groupnext
.Op Fl C Ar config
+.Op Fl q
.Nm
.Op Fl R Ar rootdir
.Op Fl V Ar etcdir
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index b21f6c0..30fb55b 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
"R:V:C:qn:u:rY",
"R:V:C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:FNPY",
"R:V:C:qn:u:FPa7",
- "R:V:C:",
+ "R:V:C:q",
"R:V:C:q",
"R:V:C:q"
},
@@ -122,7 +122,7 @@ main(int argc, char *argv[])
"R:V:C:qn:g:Y",
"R:V:C:qn:d:g:l:h:H:FM:m:NPY",
"R:V:C:qn:g:FPa",
- "R:V:C:"
+ "R:V:C:q"
}
};
@@ -469,7 +469,8 @@ cmdhelp(int mode, int which)
"usage: pw usernext [switches]\n"
"\t-V etcdir alternate /etc location\n"
"\t-R rootir alternate root directory\n"
- "\t-C config configuration file\n",
+ "\t-C config configuration file\n"
+ "\t-q quiet operation\n",
"usage pw: lock [switches]\n"
"\t-V etcdir alternate /etc locations\n"
"\t-C config configuration file\n"
@@ -523,6 +524,7 @@ cmdhelp(int mode, int which)
"\t-V etcdir alternate /etc location\n"
"\t-R rootir alternate root directory\n"
"\t-C config configuration file\n"
+ "\t-q quiet operation\n"
}
};
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index daa121d..b9cce0d 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -73,8 +73,11 @@ pw_group(int mode, char *name, long id, struct cargs * args)
* next gid to stdout
*/
if (mode == M_NEXT) {
- printf("%u\n", gr_gidpolicy(cnf, id));
- return (EXIT_SUCCESS);
+ gid_t next = gr_gidpolicy(cnf, id);
+ if (getarg(args, 'q'))
+ return next;
+ printf("%u\n", next);
+ return EXIT_SUCCESS;
}
if (mode == M_PRINT && getarg(args, 'a')) {
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index ea3cb3d..c3b2751 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -158,10 +158,14 @@ pw_user(int mode, char *name, long id, struct cargs * args)
* With M_NEXT, we only need to return the
* next uid to stdout
*/
- if (mode == M_NEXT) {
- printf("%u:", pw_uidpolicy(cnf, id));
+ if (mode == M_NEXT)
+ {
+ uid_t next = pw_uidpolicy(cnf, id);
+ if (getarg(args, 'q'))
+ return next;
+ printf("%u:", next);
pw_group(mode, name, -1, args);
- return (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
/*
OpenPOWER on IntegriCloud