diff options
author | bapt <bapt@FreeBSD.org> | 2015-12-30 23:25:45 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-12-30 23:25:45 +0000 |
commit | c7542adcf16878404fe49d6b920e5e19d379be0d (patch) | |
tree | 7de600e801270479f79518a6343f90d516a12f9c /usr.sbin/pw | |
parent | ecf8336fcdf81e2aeb30a7ab82841dd7299ceb98 (diff) | |
download | FreeBSD-src-c7542adcf16878404fe49d6b920e5e19d379be0d.zip FreeBSD-src-c7542adcf16878404fe49d6b920e5e19d379be0d.tar.gz |
MFC: r292846, r292847, r292849
Restore dryrun support for pw groupmod
Remove useless assignement of linelen
Simplify code for parsing extra groups
Diffstat (limited to 'usr.sbin/pw')
-rw-r--r-- | usr.sbin/pw/pw_conf.c | 2 | ||||
-rw-r--r-- | usr.sbin/pw/pw_group.c | 5 | ||||
-rw-r--r-- | usr.sbin/pw/pw_vpw.c | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c index e9606b4..d30c80e 100644 --- a/usr.sbin/pw/pw_conf.c +++ b/usr.sbin/pw/pw_conf.c @@ -313,7 +313,7 @@ read_userconfig(char const * file) ? NULL : newstr(q); break; case _UC_EXTRAGROUPS: - for (i = 0; q != NULL; q = strtok(NULL, toks)) { + while ((q = strtok(NULL, toks)) != NULL) { if (config.groups == NULL) config.groups = sl_init(); sl_add(config.groups, newstr(q)); diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c index 67beab9..289a4c8 100644 --- a/usr.sbin/pw/pw_group.c +++ b/usr.sbin/pw/pw_group.c @@ -664,6 +664,11 @@ pw_group_mod(int argc, char **argv, char *arg1) grp_add_members(&grp, newmembers); } + if (dryrun) { + print_group(grp, pretty); + return (EXIT_SUCCESS); + } + if ((rc = chggrent(name, grp)) != 0) { if (rc == -1) errx(EX_IOERR, "group '%s' not available (NIS?)", diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c index a23c66e..2d1c75b 100644 --- a/usr.sbin/pw/pw_vpw.c +++ b/usr.sbin/pw/pw_vpw.c @@ -70,7 +70,6 @@ vnextpwent(char const *nam, uid_t uid, int doclose) pw = NULL; line = NULL; linecap = 0; - linelen = 0; if (pwd_fp != NULL || (pwd_fp = fopen(getpwpath(_MASTERPASSWD), "r")) != NULL) { while ((linelen = getline(&line, &linecap, pwd_fp)) > 0) { @@ -153,7 +152,6 @@ vnextgrent(char const *nam, gid_t gid, int doclose) gr = NULL; line = NULL; linecap = 0; - linelen = 0; if (grp_fp != NULL || (grp_fp = fopen(getgrpath(_GROUP), "r")) != NULL) { while ((linelen = getline(&line, &linecap, grp_fp)) > 0) { |