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:
nekral-guest
2008-04-16 21:52:46 +00:00
parent 10ebb14481
commit 7baffa5e74
11 changed files with 38 additions and 13 deletions

View File

@@ -170,6 +170,7 @@ static void reset (void)
while ( (pwent = getpwent ()) != NULL ) {
reset_one (pwent->pw_uid);
}
endpwent ();
}
}
@@ -246,8 +247,10 @@ static void setmax (int max)
setmax_one (user, max);
} else {
setpwent ();
while ((pwent = getpwent ()))
while ( (pwent = getpwent ()) != NULL ) {
setmax_one (pwent->pw_uid, max);
}
endpwent ();
}
}
@@ -288,8 +291,10 @@ static void set_locktime (long locktime)
set_locktime_one (user, locktime);
} else {
setpwent ();
while ((pwent = getpwent ()))
while ( (pwent = getpwent ()) != NULL ) {
set_locktime_one (pwent->pw_uid, locktime);
}
endpwent ();
}
}