* libmisc/setugid.c, src/login_nopam.c, src/suauth.c,

lib/getdef.c: Replace the %m format string by strerror(). This
	avoids errno to be reset between the system call error and the
	report function.
This commit is contained in:
nekral-guest
2008-09-13 18:03:50 +00:00
parent 0833bc3cc0
commit 5df1f2f683
5 changed files with 31 additions and 14 deletions

View File

@ -40,6 +40,7 @@
#include <stdio.h>
#include <grp.h>
#include <errno.h>
#include "prototypes.h"
#include "defines.h"
#include <pwd.h>
@ -56,9 +57,10 @@ int setup_groups (const struct passwd *info)
* file.
*/
if (setgid (info->pw_gid) == -1) {
int err = errno;
perror ("setgid");
SYSLOG ((LOG_ERR, "bad group ID `%d' for user `%s': %m\n",
info->pw_gid, info->pw_name));
SYSLOG ((LOG_ERR, "bad group ID `%d' for user `%s': %s\n",
info->pw_gid, info->pw_name, strerror (err)));
closelog ();
return -1;
}
@ -68,9 +70,10 @@ int setup_groups (const struct passwd *info)
* the group set from the /etc/group file.
*/
if (initgroups (info->pw_name, info->pw_gid) == -1) {
int err = errno;
perror ("initgroups");
SYSLOG ((LOG_ERR, "initgroups failed for user `%s': %m\n",
info->pw_name));
SYSLOG ((LOG_ERR, "initgroups failed for user `%s': %s\n",
info->pw_name, strerror (err)));
closelog ();
return -1;
}
@ -84,9 +87,10 @@ int change_uid (const struct passwd *info)
* Set the real UID to the UID value in the password file.
*/
if (setuid (info->pw_uid) != 0) {
int err = errno;
perror ("setuid");
SYSLOG ((LOG_ERR, "bad user ID `%d' for user `%s': %m\n",
(int) info->pw_uid, info->pw_name));
SYSLOG ((LOG_ERR, "bad user ID `%d' for user `%s': %s\n",
(int) info->pw_uid, info->pw_name, strerror (err)));
closelog ();
return -1;
}