* src/newgrp.c: Use a %lu format and cast group and user IDs to
unsigned long integers. * src/newgrp.c: The ID argument of audit_logger is an unsigned int. * src/newgrp.c: Ignore the return value of signal() (the signal handlers are assumed to be the default one and are restored later). * src/newgrp.c: Do not checl if a pid_t is < 0, check if equal to (pid_t)-1.
This commit is contained in:
parent
56327f6298
commit
f626317e90
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/newgrp.c: Use a %lu format and cast group and user IDs to
|
||||||
|
unsigned long integers.
|
||||||
|
* src/newgrp.c: The ID argument of audit_logger is an unsigned
|
||||||
|
int.
|
||||||
|
* src/newgrp.c: Ignore the return value of signal() (the signal
|
||||||
|
handlers are assumed to be the default one and are restored
|
||||||
|
later).
|
||||||
|
* src/newgrp.c: Do not checl if a pid_t is < 0, check if equal
|
||||||
|
to (pid_t)-1.
|
||||||
|
|
||||||
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* libmisc/isexpired.c: Cast number of days to a long integer.
|
* libmisc/isexpired.c: Cast number of days to a long integer.
|
||||||
|
110
src/newgrp.c
110
src/newgrp.c
@ -184,9 +184,11 @@ static void check_perms (const struct group *grp,
|
|||||||
strcmp (cpasswd, grp->gr_passwd) != 0) {
|
strcmp (cpasswd, grp->gr_passwd) != 0) {
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"authentication new-gid=%d", grp->gr_gid);
|
"authentication new-gid=%lu",
|
||||||
|
(unsigned long) grp->gr_gid);
|
||||||
audit_logger (AUDIT_GRP_AUTH, Prog,
|
audit_logger (AUDIT_GRP_AUTH, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"Invalid password for group `%s' from `%s'",
|
"Invalid password for group `%s' from `%s'",
|
||||||
@ -197,9 +199,11 @@ static void check_perms (const struct group *grp,
|
|||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"authentication new-gid=%d", grp->gr_gid);
|
"authentication new-gid=%lu",
|
||||||
|
(unsigned long) grp->gr_gid);
|
||||||
audit_logger (AUDIT_GRP_AUTH, Prog,
|
audit_logger (AUDIT_GRP_AUTH, Prog,
|
||||||
audit_buf, NULL, getuid (), 1);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,10 +219,12 @@ failure:
|
|||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-group=%s", groupname);
|
"changing new-group=%s", groupname);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
} else {
|
} else {
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog, "changing",
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
NULL, getuid (), 0);
|
"changing", NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
@ -274,14 +280,16 @@ static void syslog_sg (const char *name, const char *group)
|
|||||||
{
|
{
|
||||||
pid_t child, pid;
|
pid_t child, pid;
|
||||||
|
|
||||||
signal (SIGINT, SIG_IGN);
|
/* Ignore these signals. The signal handlers will later be
|
||||||
signal (SIGQUIT, SIG_IGN);
|
* restored to the default handlers. */
|
||||||
signal (SIGHUP, SIG_IGN);
|
(void) signal (SIGINT, SIG_IGN);
|
||||||
signal (SIGTSTP, SIG_IGN);
|
(void) signal (SIGQUIT, SIG_IGN);
|
||||||
signal (SIGTTIN, SIG_IGN);
|
(void) signal (SIGHUP, SIG_IGN);
|
||||||
signal (SIGTTOU, SIG_IGN);
|
(void) signal (SIGTSTP, SIG_IGN);
|
||||||
|
(void) signal (SIGTTIN, SIG_IGN);
|
||||||
|
(void) signal (SIGTTOU, SIG_IGN);
|
||||||
child = fork ();
|
child = fork ();
|
||||||
if (child < 0) {
|
if ((pid_t)-1 == child) {
|
||||||
/* error in fork() */
|
/* error in fork() */
|
||||||
fprintf (stderr, _("%s: failure forking: %s\n"),
|
fprintf (stderr, _("%s: failure forking: %s\n"),
|
||||||
is_newgrp ? "newgrp" : "sg", strerror (errno));
|
is_newgrp ? "newgrp" : "sg", strerror (errno));
|
||||||
@ -290,10 +298,12 @@ static void syslog_sg (const char *name, const char *group)
|
|||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-group=%s", group);
|
"changing new-group=%s", group);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
} else {
|
} else {
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog, "changing",
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
NULL, getuid (), 0);
|
"changing", NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
@ -321,27 +331,28 @@ static void syslog_sg (const char *name, const char *group)
|
|||||||
name, loginname, tty, grp->gr_name));
|
name, loginname, tty, grp->gr_name));
|
||||||
} else {
|
} else {
|
||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"user `%s' (login `%s' on %s) returned to group `%d'",
|
"user `%s' (login `%s' on %s) returned to group `%lu'",
|
||||||
name, loginname, tty, gid));
|
name, loginname, tty,
|
||||||
|
(unsigned long) gid));
|
||||||
/* Either the user's passwd entry has a
|
/* Either the user's passwd entry has a
|
||||||
* GID that does not match with any group,
|
* GID that does not match with any group,
|
||||||
* or the group was deleted while the user
|
* or the group was deleted while the user
|
||||||
* was in a newgrp session.*/
|
* was in a newgrp session.*/
|
||||||
SYSLOG ((LOG_WARN,
|
SYSLOG ((LOG_WARN,
|
||||||
"unknown GID `%u' used by user `%s'",
|
"unknown GID `%lu' used by user `%s'",
|
||||||
gid, name));
|
(unsigned long) gid, name));
|
||||||
}
|
}
|
||||||
closelog ();
|
closelog ();
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* child - restore signals to their default state */
|
/* child - restore signals to their default state */
|
||||||
signal (SIGINT, SIG_DFL);
|
(void) signal (SIGINT, SIG_DFL);
|
||||||
signal (SIGQUIT, SIG_DFL);
|
(void) signal (SIGQUIT, SIG_DFL);
|
||||||
signal (SIGHUP, SIG_DFL);
|
(void) signal (SIGHUP, SIG_DFL);
|
||||||
signal (SIGTSTP, SIG_DFL);
|
(void) signal (SIGTSTP, SIG_DFL);
|
||||||
signal (SIGTTIN, SIG_DFL);
|
(void) signal (SIGTTIN, SIG_DFL);
|
||||||
signal (SIGTTOU, SIG_DFL);
|
(void) signal (SIGTTOU, SIG_DFL);
|
||||||
}
|
}
|
||||||
#endif /* USE_PAM */
|
#endif /* USE_PAM */
|
||||||
}
|
}
|
||||||
@ -410,12 +421,15 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
pwd = get_my_pwent ();
|
pwd = get_my_pwent ();
|
||||||
if (NULL == pwd) {
|
if (NULL == pwd) {
|
||||||
fprintf (stderr, _("unknown UID: %u\n"), getuid ());
|
fprintf (stderr, _("unknown UID: %lu\n"),
|
||||||
|
(unsigned long) getuid ());
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog, "changing", NULL,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
getuid (), 0);
|
"changing", NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_WARN, "unknown UID %u", getuid ()));
|
SYSLOG ((LOG_WARN, "unknown UID %lu",
|
||||||
|
(unsigned long) getuid ()));
|
||||||
closelog ();
|
closelog ();
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
@ -530,10 +544,12 @@ int main (int argc, char **argv)
|
|||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-group=%s", group);
|
"changing new-group=%s", group);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
} else {
|
} else {
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
"changing", NULL, getuid (), 0);
|
"changing", NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
@ -660,9 +676,10 @@ int main (int argc, char **argv)
|
|||||||
perror ("setgid");
|
perror ("setgid");
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-gid=%d", gid);
|
"changing new-gid=%lu", (unsigned long) gid);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
@ -671,9 +688,10 @@ int main (int argc, char **argv)
|
|||||||
perror ("setuid");
|
perror ("setuid");
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-gid=%d", gid);
|
"changing new-gid=%lu", (unsigned long) gid);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
@ -687,9 +705,10 @@ int main (int argc, char **argv)
|
|||||||
execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-gid=%d", gid);
|
"changing new-gid=%lu", (unsigned long) gid);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
perror ("/bin/sh");
|
perror ("/bin/sh");
|
||||||
exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
||||||
@ -760,8 +779,11 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
snprintf (audit_buf, sizeof(audit_buf), "changing new-gid=%d", gid);
|
snprintf (audit_buf, sizeof(audit_buf), "changing new-gid=%lu",
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog, audit_buf, NULL, getuid (), 1);
|
(unsigned long) gid);
|
||||||
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 1);
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Exec the login shell and go away. We are trying to get back to
|
* Exec the login shell and go away. We are trying to get back to
|
||||||
@ -788,10 +810,12 @@ int main (int argc, char **argv)
|
|||||||
snprintf (audit_buf, sizeof(audit_buf),
|
snprintf (audit_buf, sizeof(audit_buf),
|
||||||
"changing new-group=%s", group);
|
"changing new-group=%s", group);
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
audit_buf, NULL, getuid (), 0);
|
audit_buf, NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
} else {
|
} else {
|
||||||
audit_logger (AUDIT_CHGRP_ID, Prog,
|
audit_logger (AUDIT_CHGRP_ID, Prog,
|
||||||
"changing", NULL, getuid (), 0);
|
"changing", NULL,
|
||||||
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
|
Loading…
Reference in New Issue
Block a user