Skip to content

Commit ec480fe

Browse files
committed
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.
1 parent 6e327f9 commit ec480fe

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

usr.sbin/pw/pw.8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.\"
2525
.\" $FreeBSD$
2626
.\"
27-
.Dd June 7, 2015
27+
.Dd June 3, 2015
2828
.Dt PW 8
2929
.Os
3030
.Sh NAME
@@ -128,6 +128,7 @@
128128
.Op Fl V Ar etcdir
129129
.Ar usernext
130130
.Op Fl C Ar config
131+
.Op Fl q
131132
.Nm
132133
.Op Fl R Ar rootdir
133134
.Op Fl V Ar etcdir
@@ -183,6 +184,7 @@
183184
.Op Fl V Ar etcdir
184185
.Ar groupnext
185186
.Op Fl C Ar config
187+
.Op Fl q
186188
.Nm
187189
.Op Fl R Ar rootdir
188190
.Op Fl V Ar etcdir

usr.sbin/pw/pw.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
113113
"R:V:C:qn:u:rY",
114114
"R:V:C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:FNPY",
115115
"R:V:C:qn:u:FPa7",
116-
"R:V:C:",
116+
"R:V:C:q",
117117
"R:V:C:q",
118118
"R:V:C:q"
119119
},
@@ -122,7 +122,7 @@ main(int argc, char *argv[])
122122
"R:V:C:qn:g:Y",
123123
"R:V:C:qn:d:g:l:h:H:FM:m:NPY",
124124
"R:V:C:qn:g:FPa",
125-
"R:V:C:"
125+
"R:V:C:q"
126126
}
127127
};
128128

@@ -469,7 +469,8 @@ cmdhelp(int mode, int which)
469469
"usage: pw usernext [switches]\n"
470470
"\t-V etcdir alternate /etc location\n"
471471
"\t-R rootir alternate root directory\n"
472-
"\t-C config configuration file\n",
472+
"\t-C config configuration file\n"
473+
"\t-q quiet operation\n",
473474
"usage pw: lock [switches]\n"
474475
"\t-V etcdir alternate /etc locations\n"
475476
"\t-C config configuration file\n"
@@ -523,6 +524,7 @@ cmdhelp(int mode, int which)
523524
"\t-V etcdir alternate /etc location\n"
524525
"\t-R rootir alternate root directory\n"
525526
"\t-C config configuration file\n"
527+
"\t-q quiet operation\n"
526528
}
527529
};
528530

usr.sbin/pw/pw_group.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ pw_group(int mode, char *name, long id, struct cargs * args)
7373
* next gid to stdout
7474
*/
7575
if (mode == M_NEXT) {
76-
printf("%u\n", gr_gidpolicy(cnf, id));
77-
return (EXIT_SUCCESS);
76+
gid_t next = gr_gidpolicy(cnf, id);
77+
if (getarg(args, 'q'))
78+
return next;
79+
printf("%u\n", next);
80+
return EXIT_SUCCESS;
7881
}
7982

8083
if (mode == M_PRINT && getarg(args, 'a')) {

usr.sbin/pw/pw_user.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,14 @@ pw_user(int mode, char *name, long id, struct cargs * args)
158158
* With M_NEXT, we only need to return the
159159
* next uid to stdout
160160
*/
161-
if (mode == M_NEXT) {
162-
printf("%u:", pw_uidpolicy(cnf, id));
161+
if (mode == M_NEXT)
162+
{
163+
uid_t next = pw_uidpolicy(cnf, id);
164+
if (getarg(args, 'q'))
165+
return next;
166+
printf("%u:", next);
163167
pw_group(mode, name, -1, args);
164-
return (EXIT_SUCCESS);
168+
return EXIT_SUCCESS;
165169
}
166170

167171
/*

0 commit comments

Comments
 (0)