Ensure that getpwent() is used in setpwent(), getpwent(),
endpwend() sequences (ditto for getgrent(), getspent(), and getsgent()). The only real (minor) issue was in login, which kept the passwd file open. * libmisc/entry.c: Remove unneeded setspent() and endspent() (only getspnam is called in the middle). * libmisc/find_new_ids.c: Make sure to close the password and group files with endpwent() and endgrent(). * libmisc/pwdcheck.c: Remove unneeded endspent() (only getspnam() is called before). * src/lastlog.c, src/passwd.c, src/groupmod.c, src/faillog.c, src/groups.c: Make sure to close the password file with endpwent(). * src/login.c: Remove unneeded setpwent() (only xgetpwnam is called before). * src/login.c, src/newgrp.c: Fix typos in comments.
This commit is contained in:
@@ -57,13 +57,12 @@ static void print_groups (const char *member)
|
||||
struct passwd *pwd;
|
||||
int flag = 0;
|
||||
|
||||
setgrent ();
|
||||
|
||||
/* local, no need for xgetpwnam */
|
||||
if ((pwd = getpwnam (member)) == 0) {
|
||||
fprintf (stderr, _("%s: unknown user %s\n"), Prog, member);
|
||||
exit (1);
|
||||
}
|
||||
setgrent ();
|
||||
while ((grp = getgrent ())) {
|
||||
if (is_on_list (grp->gr_mem, member)) {
|
||||
if (groups++)
|
||||
@@ -74,6 +73,7 @@ static void print_groups (const char *member)
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
endgrent ();
|
||||
/* local, no need for xgetgrgid */
|
||||
if (!flag && (grp = getgrgid (pwd->pw_gid))) {
|
||||
if (groups++)
|
||||
|
||||
Reference in New Issue
Block a user