Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174626242
D41076.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1005 B
Referenced Files
None
Subscribers
None
D41076.diff
View Options
diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h
--- a/usr.sbin/pw/pw.h
+++ b/usr.sbin/pw/pw.h
@@ -114,3 +114,5 @@
uintmax_t strtounum(const char * __restrict, uintmax_t, uintmax_t,
const char ** __restrict);
+
+bool grp_has_member(struct group *grp, const char *name);
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -418,7 +418,7 @@
return (EXIT_SUCCESS);
}
-static bool
+bool
grp_has_member(struct group *grp, const char *name)
{
int j;
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -1408,6 +1408,9 @@
if (cmdcnf->groups != NULL) {
for (i = 0; i < cmdcnf->groups->sl_cur; i++) {
grp = GETGRNAM(cmdcnf->groups->sl_str[i]);
+ /* gr_add doesn't check if new member is already in group */
+ if (grp_has_member(grp, pwd->pw_name))
+ continue;
grp = gr_add(grp, pwd->pw_name);
/*
* grp can only be NULL in 2 cases:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 5, 6:49 PM (22 m, 5 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40218552
Default Alt Text
D41076.diff (1005 B)
Attached To
Mode
D41076: pw: check for user in group entry before adding them
Attached
Detach File
Event Timeline
Log In to Comment