* src/groupmems.c: When removing an user, check if deluser is on
the list, not adduser. This fixes a segmentation fault for every call of groupmems -d. * libmisc/list.c: Add assertions to help identifying these issues. * libmisc/list.c: Avoid implicit conversion of pointers to booleans.
This commit is contained in:
parent
77f81fa0b6
commit
0c7df2f9a0
@ -1,3 +1,12 @@
|
|||||||
|
2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/groupmems.c: When removing an user, check if deluser is on
|
||||||
|
the list, not adduser. This fixes a segmentation fault for every
|
||||||
|
call of groupmems -d.
|
||||||
|
* libmisc/list.c: Add assertions to help identifying these issues.
|
||||||
|
* libmisc/list.c: Avoid implicit conversion of pointers to
|
||||||
|
booleans.
|
||||||
|
|
||||||
2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
|
2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* NEWS, src/groupmems.c: Use the "groupmems" PAM service name
|
* NEWS, src/groupmems.c: Use the "groupmems" PAM service name
|
||||||
|
1
NEWS
1
NEWS
@ -18,6 +18,7 @@ shadow-4.1.2.1 -> shadow-4.1.3 UNRELEASED
|
|||||||
group.
|
group.
|
||||||
* Added syslog support.
|
* Added syslog support.
|
||||||
* Use the groupmems PAM service name instead of groupmod.
|
* Use the groupmems PAM service name instead of groupmod.
|
||||||
|
* Fix segmentation faults when adding or removing users from a group.
|
||||||
- newusers
|
- newusers
|
||||||
* Implement the -r, --system option.
|
* Implement the -r, --system option.
|
||||||
- passwd
|
- passwd
|
||||||
|
@ -50,6 +50,8 @@ char **add_list (char **list, const char *member)
|
|||||||
int i;
|
int i;
|
||||||
char **tmp;
|
char **tmp;
|
||||||
|
|
||||||
|
assert (NULL != member);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan the list for the new name. Return the original list
|
* Scan the list for the new name. Return the original list
|
||||||
* pointer if it is present.
|
* pointer if it is present.
|
||||||
@ -97,6 +99,8 @@ char **del_list (char **list, const char *member)
|
|||||||
int i, j;
|
int i, j;
|
||||||
char **tmp;
|
char **tmp;
|
||||||
|
|
||||||
|
assert (NULL != member);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan the list for the old name. Return the original list
|
* Scan the list for the old name. Return the original list
|
||||||
* pointer if it is not present.
|
* pointer if it is not present.
|
||||||
@ -142,12 +146,12 @@ char **dup_list (char *const *list)
|
|||||||
int i;
|
int i;
|
||||||
char **tmp;
|
char **tmp;
|
||||||
|
|
||||||
for (i = 0; list[i]; i++);
|
for (i = 0; NULL != list[i]; i++);
|
||||||
|
|
||||||
tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
|
tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (*list) {
|
while (NULL != *list) {
|
||||||
tmp[i] = xstrdup (*list);
|
tmp[i] = xstrdup (*list);
|
||||||
i++;
|
i++;
|
||||||
list++;
|
list++;
|
||||||
@ -159,12 +163,15 @@ char **dup_list (char *const *list)
|
|||||||
|
|
||||||
bool is_on_list (char *const *list, const char *member)
|
bool is_on_list (char *const *list, const char *member)
|
||||||
{
|
{
|
||||||
while (*list) {
|
assert (NULL != member);
|
||||||
|
|
||||||
|
while (NULL != *list) {
|
||||||
if (strcmp (*list, member) == 0) {
|
if (strcmp (*list, member) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
list++;
|
list++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +186,8 @@ char **comma_to_list (const char *comma)
|
|||||||
int i;
|
int i;
|
||||||
char *cp, *cp2;
|
char *cp, *cp2;
|
||||||
|
|
||||||
|
assert (NULL != comma);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make a copy since we are going to be modifying the list
|
* Make a copy since we are going to be modifying the list
|
||||||
*/
|
*/
|
||||||
|
@ -291,7 +291,7 @@ int main (int argc, char **argv)
|
|||||||
fail_exit (13);
|
fail_exit (13);
|
||||||
}
|
}
|
||||||
} else if (NULL != deluser) {
|
} else if (NULL != deluser) {
|
||||||
if (!is_on_list (grp->gr_mem, adduser)) {
|
if (!is_on_list (grp->gr_mem, deluser)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: user '%s' is not a member of '%s'\n"),
|
_("%s: user '%s' is not a member of '%s'\n"),
|
||||||
Prog, deluser, grp->gr_name);
|
Prog, deluser, grp->gr_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user