summaryrefslogtreecommitdiff
path: root/usr.sbin/user/user.c
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2012-01-28 14:25:46 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2012-01-28 14:25:46 +0000
commitb28d083a33d0227bf561a2a99d8219d5d6ae4e9e (patch)
tree263ae7d03518c572d24c4ef685e385c1c4e8cf7c /usr.sbin/user/user.c
parent8d0a8eccf3789619d510795165bec8c545480a72 (diff)
Make it possible to remove a user from all secondary groups by using:
usermod -S '' username Original patch from jca at wxcvbn dot org. Added a comment to the man page. man tweaks and ok jmc@ ok miod@
Diffstat (limited to 'usr.sbin/user/user.c')
-rw-r--r--usr.sbin/user/user.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index d92e651c550..f6599c86d84 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.88 2012/01/28 10:20:01 ajacoutot Exp $ */
+/* $OpenBSD: user.c,v 1.89 2012/01/28 14:25:45 ajacoutot Exp $ */
/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
/*
@@ -1522,22 +1522,22 @@ moduser(char *login_name, char *newlogin, user_t *up)
err(EXIT_FAILURE, "can't move `%s' to `%s'",
homedir, pwp->pw_dir);
}
- if (up->u_groupc > 0) {
- if (up->u_flags & F_SETSECGROUP) {
- for (i = 0 ; i < up->u_groupc ; i++) {
- if ((grp = getgrnam(up->u_groupv[i])) == NULL) {
- (void) close(ptmpfd);
- pw_abort();
- errx(EXIT_FAILURE, "aborting, group `%s' does not exist",
- up->u_groupv[i]);
- }
- }
- if (!rm_user_from_groups(newlogin)) {
+ if (up->u_flags & F_SETSECGROUP) {
+ for (i = 0 ; i < up->u_groupc ; i++) {
+ if ((grp = getgrnam(up->u_groupv[i])) == NULL) {
(void) close(ptmpfd);
pw_abort();
- errx(EXIT_FAILURE, "can't reset groups for `%s'", newlogin);
+ errx(EXIT_FAILURE, "aborting, group `%s' does not exist",
+ up->u_groupv[i]);
}
}
+ if (!rm_user_from_groups(newlogin)) {
+ (void) close(ptmpfd);
+ pw_abort();
+ errx(EXIT_FAILURE, "can't reset groups for `%s'", newlogin);
+ }
+ }
+ if (up->u_groupc > 0) {
if (!append_group(newlogin, up->u_groupc, up->u_groupv)) {
(void) close(ptmpfd);
pw_abort();