* 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:
parent
0833bc3cc0
commit
5df1f2f683
@ -1,3 +1,10 @@
|
|||||||
|
2008-09-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2008-09-13 Nicolas François <nicolas.francois@centraliens.net>
|
2008-09-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* lib/commonio.c: Ignore the return value of umask() when the mask
|
* lib/commonio.c: Ignore the return value of umask() when the mask
|
||||||
|
11
lib/getdef.c
11
lib/getdef.c
@ -39,6 +39,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "getdef.h"
|
#include "getdef.h"
|
||||||
/*
|
/*
|
||||||
* A configuration item definition.
|
* A configuration item definition.
|
||||||
@ -377,8 +378,9 @@ static void def_load (void)
|
|||||||
*/
|
*/
|
||||||
fp = fopen (def_fname, "r");
|
fp = fopen (def_fname, "r");
|
||||||
if (NULL == fp) {
|
if (NULL == fp) {
|
||||||
SYSLOG ((LOG_CRIT, "cannot open login definitions %s [%m]",
|
int err = errno;
|
||||||
def_fname));
|
SYSLOG ((LOG_CRIT, "cannot open login definitions %s [%s]",
|
||||||
|
def_fname, strerror (err)));
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,8 +428,9 @@ static void def_load (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ferror (fp) != 0) {
|
if (ferror (fp) != 0) {
|
||||||
SYSLOG ((LOG_CRIT, "cannot read login definitions %s [%m]",
|
int err = errno;
|
||||||
def_fname));
|
SYSLOG ((LOG_CRIT, "cannot read login definitions %s [%s]",
|
||||||
|
def_fname, strerror (err)));
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@ -56,9 +57,10 @@ int setup_groups (const struct passwd *info)
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
if (setgid (info->pw_gid) == -1) {
|
if (setgid (info->pw_gid) == -1) {
|
||||||
|
int err = errno;
|
||||||
perror ("setgid");
|
perror ("setgid");
|
||||||
SYSLOG ((LOG_ERR, "bad group ID `%d' for user `%s': %m\n",
|
SYSLOG ((LOG_ERR, "bad group ID `%d' for user `%s': %s\n",
|
||||||
info->pw_gid, info->pw_name));
|
info->pw_gid, info->pw_name, strerror (err)));
|
||||||
closelog ();
|
closelog ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -68,9 +70,10 @@ int setup_groups (const struct passwd *info)
|
|||||||
* the group set from the /etc/group file.
|
* the group set from the /etc/group file.
|
||||||
*/
|
*/
|
||||||
if (initgroups (info->pw_name, info->pw_gid) == -1) {
|
if (initgroups (info->pw_name, info->pw_gid) == -1) {
|
||||||
|
int err = errno;
|
||||||
perror ("initgroups");
|
perror ("initgroups");
|
||||||
SYSLOG ((LOG_ERR, "initgroups failed for user `%s': %m\n",
|
SYSLOG ((LOG_ERR, "initgroups failed for user `%s': %s\n",
|
||||||
info->pw_name));
|
info->pw_name, strerror (err)));
|
||||||
closelog ();
|
closelog ();
|
||||||
return -1;
|
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.
|
* Set the real UID to the UID value in the password file.
|
||||||
*/
|
*/
|
||||||
if (setuid (info->pw_uid) != 0) {
|
if (setuid (info->pw_uid) != 0) {
|
||||||
|
int err = errno;
|
||||||
perror ("setuid");
|
perror ("setuid");
|
||||||
SYSLOG ((LOG_ERR, "bad user ID `%d' for user `%s': %m\n",
|
SYSLOG ((LOG_ERR, "bad user ID `%d' for user `%s': %s\n",
|
||||||
(int) info->pw_uid, info->pw_name));
|
(int) info->pw_uid, info->pw_name, strerror (err)));
|
||||||
closelog ();
|
closelog ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,8 @@ int login_access (const char *user, const char *from)
|
|||||||
}
|
}
|
||||||
(void) fclose (fp);
|
(void) fclose (fp);
|
||||||
} else if (errno != ENOENT) {
|
} else if (errno != ENOENT) {
|
||||||
SYSLOG ((LOG_ERR, "cannot open %s: %m", TABLE));
|
int err = errno;
|
||||||
|
SYSLOG ((LOG_ERR, "cannot open %s: %s", TABLE, strerror (err)));
|
||||||
}
|
}
|
||||||
return (!match || (line[0] == '+'))?1:0;
|
return (!match || (line[0] == '+'))?1:0;
|
||||||
}
|
}
|
||||||
|
@ -76,17 +76,19 @@ int check_su_auth (const char *actual_id, const char *wanted_id)
|
|||||||
char *action;
|
char *action;
|
||||||
|
|
||||||
if (!(authfile_fd = fopen (SUAUTHFILE, "r"))) {
|
if (!(authfile_fd = fopen (SUAUTHFILE, "r"))) {
|
||||||
|
int err = errno;
|
||||||
/*
|
/*
|
||||||
* If the file doesn't exist - default to the standard su
|
* If the file doesn't exist - default to the standard su
|
||||||
* behaviour (no access control). If open fails for some
|
* behaviour (no access control). If open fails for some
|
||||||
* other reason - maybe someone is trying to fool us with
|
* other reason - maybe someone is trying to fool us with
|
||||||
* file descriptors limit etc., so deny access. --marekm
|
* file descriptors limit etc., so deny access. --marekm
|
||||||
*/
|
*/
|
||||||
if (errno == ENOENT)
|
if (ENOENT == err) {
|
||||||
return NOACTION;
|
return NOACTION;
|
||||||
|
}
|
||||||
SYSLOG ((LOG_ERR,
|
SYSLOG ((LOG_ERR,
|
||||||
"could not open/read config file '%s': %m\n",
|
"could not open/read config file '%s': %s\n",
|
||||||
SUAUTHFILE));
|
SUAUTHFILE, strerror (err)));
|
||||||
return DENY;
|
return DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user