* src/newgrp.c: Added splint annotations.
* src/newgrp.c: audit_buf is only used in newgrp. Make it static. * src/newgrp.c: Ignore the return value of fputs(). * src/newgrp.c: Use exit(EXIT_FAILURE) instead of exit(1).
This commit is contained in:
parent
3d2f164dca
commit
af8ff8c1ca
@ -1,3 +1,10 @@
|
|||||||
|
2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/newgrp.c: Added splint annotations.
|
||||||
|
* src/newgrp.c: audit_buf is only used in newgrp. Make it static.
|
||||||
|
* src/newgrp.c: Ignore the return value of fputs().
|
||||||
|
* src/newgrp.c: Use exit(EXIT_FAILURE) instead of exit(1).
|
||||||
|
|
||||||
2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* libmisc/pwdcheck.c (passwd_check): The progname is not used.
|
* libmisc/pwdcheck.c (passwd_check): The progname is not used.
|
||||||
|
38
src/newgrp.c
38
src/newgrp.c
@ -53,13 +53,13 @@ extern char **environ;
|
|||||||
|
|
||||||
#ifdef HAVE_SETGROUPS
|
#ifdef HAVE_SETGROUPS
|
||||||
static int ngroups;
|
static int ngroups;
|
||||||
static GETGROUPS_T *grouplist;
|
static /*@null@*/ /*@only@*/GETGROUPS_T *grouplist;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool is_newgrp;
|
static bool is_newgrp;
|
||||||
|
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
char audit_buf[80];
|
static char audit_buf[80];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
@ -75,9 +75,9 @@ static void syslog_sg (const char *name, const char *group);
|
|||||||
static void usage (void)
|
static void usage (void)
|
||||||
{
|
{
|
||||||
if (is_newgrp) {
|
if (is_newgrp) {
|
||||||
fputs (_("Usage: newgrp [-] [group]\n"), stderr);
|
(void) fputs (_("Usage: newgrp [-] [group]\n"), stderr);
|
||||||
} else {
|
} else {
|
||||||
fputs (_("Usage: sg group [[-c] command]\n"), stderr);
|
(void) fputs (_("Usage: sg group [[-c] command]\n"), stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ static void usage (void)
|
|||||||
* find_matching_group - search all groups of a given group id for
|
* find_matching_group - search all groups of a given group id for
|
||||||
* membership of a given username
|
* membership of a given username
|
||||||
*/
|
*/
|
||||||
static struct group *find_matching_group (const char *name, gid_t gid)
|
static /*@null@*/struct group *find_matching_group (const char *name, gid_t gid)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
char **look;
|
char **look;
|
||||||
@ -195,8 +195,8 @@ static void check_perms (const struct group *grp,
|
|||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"Invalid password for group '%s' from '%s'",
|
"Invalid password for group '%s' from '%s'",
|
||||||
groupname, pwd->pw_name));
|
groupname, pwd->pw_name));
|
||||||
sleep (1);
|
(void) sleep (1);
|
||||||
fputs (_("Invalid password.\n"), stderr);
|
(void) fputs (_("Invalid password.\n"), stderr);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
@ -229,7 +229,7 @@ failure:
|
|||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
@ -308,7 +308,7 @@ static void syslog_sg (const char *name, const char *group)
|
|||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
} else if (child != 0) {
|
} else if (child != 0) {
|
||||||
/* parent - wait for child to finish, then log session close */
|
/* parent - wait for child to finish, then log session close */
|
||||||
int cst = 0;
|
int cst = 0;
|
||||||
@ -345,7 +345,7 @@ static void syslog_sg (const char *name, const char *group)
|
|||||||
(unsigned long) gid, name));
|
(unsigned long) gid, name));
|
||||||
}
|
}
|
||||||
closelog ();
|
closelog ();
|
||||||
exit (0);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* child - restore signals to their default state */
|
/* child - restore signals to their default state */
|
||||||
@ -376,7 +376,7 @@ int main (int argc, char **argv)
|
|||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
char **envp = environ;
|
char **envp = environ;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
struct group *grp;
|
/*@null@*/struct group *grp;
|
||||||
|
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
struct sgrp *sgrp;
|
struct sgrp *sgrp;
|
||||||
@ -433,7 +433,7 @@ int main (int argc, char **argv)
|
|||||||
SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
|
SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
|
||||||
(unsigned long) getuid ()));
|
(unsigned long) getuid ()));
|
||||||
closelog ();
|
closelog ();
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
name = pwd->pw_name;
|
name = pwd->pw_name;
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ int main (int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
usage ();
|
usage ();
|
||||||
closelog ();
|
closelog ();
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
|
|
||||||
@ -555,7 +555,7 @@ int main (int argc, char **argv)
|
|||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SETGROUPS */
|
#endif /* HAVE_SETGROUPS */
|
||||||
|
|
||||||
@ -661,7 +661,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (i == ngroups) {
|
if (i == ngroups) {
|
||||||
if (ngroups >= sysconf (_SC_NGROUPS_MAX)) {
|
if (ngroups >= sysconf (_SC_NGROUPS_MAX)) {
|
||||||
fputs (_("too many groups\n"), stderr);
|
(void) fputs (_("too many groups\n"), stderr);
|
||||||
} else {
|
} else {
|
||||||
grouplist[ngroups++] = gid;
|
grouplist[ngroups++] = gid;
|
||||||
if (setgroups (ngroups, grouplist) != 0) {
|
if (setgroups (ngroups, grouplist) != 0) {
|
||||||
@ -685,7 +685,7 @@ int main (int argc, char **argv)
|
|||||||
audit_buf, NULL,
|
audit_buf, NULL,
|
||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setuid (getuid ()) != 0) {
|
if (setuid (getuid ()) != 0) {
|
||||||
@ -697,7 +697,7 @@ int main (int argc, char **argv)
|
|||||||
audit_buf, NULL,
|
audit_buf, NULL,
|
||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -795,7 +795,7 @@ int main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
err = shell (prog, initflag ? (char *) 0 : cp, newenvp);
|
err = shell (prog, initflag ? (char *) 0 : cp, newenvp);
|
||||||
exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
||||||
/* NOTREACHED */
|
/* @notreached@ */
|
||||||
failure:
|
failure:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -822,6 +822,6 @@ int main (int argc, char **argv)
|
|||||||
(unsigned int) getuid (), 0);
|
(unsigned int) getuid (), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user