summaryrefslogtreecommitdiffstats
path: root/pw/pw_group.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-07-11 16:58:47 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-07-11 16:58:47 +0000
commit5809c6a767c19d9ce6cca88efbcd54a6f19b5ce8 (patch)
treecb39d1446d4c98deea9d8fcbfee11bd28219e569 /pw/pw_group.c
parent6b05c812aab670bc774bcc5dcc38cfc87a401ab6 (diff)
downloadpw-darwin-5809c6a767c19d9ce6cca88efbcd54a6f19b5ce8.tar.gz
pw-darwin-5809c6a767c19d9ce6cca88efbcd54a6f19b5ce8.tar.zst
pw-darwin-5809c6a767c19d9ce6cca88efbcd54a6f19b5ce8.zip
Separate usernext/groupnext from the main functions
Diffstat (limited to 'pw/pw_group.c')
-rw-r--r--pw/pw_group.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/pw/pw_group.c b/pw/pw_group.c
index c664ef5..28a7c94 100644
--- a/pw/pw_group.c
+++ b/pw/pw_group.c
@@ -92,6 +92,18 @@ set_passwd(struct group *grp, bool update)
}
int
+pw_groupnext(struct userconf *cnf, bool quiet)
+{
+ gid_t next = gr_gidpolicy(cnf, -1);
+
+ if (quiet)
+ return (next);
+ printf("%u\n", next);
+
+ return (EXIT_SUCCESS);
+}
+
+int
pw_group(int mode, char *name, long id, struct cargs * args)
{
int rc;
@@ -109,21 +121,12 @@ pw_group(int mode, char *name, long id, struct cargs * args)
NULL
};
+ if (mode == M_NEXT)
+ return (pw_groupnext(cnf, getarg(args, 'q') != NULL));
+
if (mode == M_LOCK || mode == M_UNLOCK)
errx(EX_USAGE, "'lock' command is not available for groups");
- /*
- * With M_NEXT, we only need to return the
- * next gid to stdout
- */
- if (mode == M_NEXT) {
- 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')) {
SETGRENT();
while ((grp = GETGRENT()) != NULL)