summaryrefslogtreecommitdiffstats
path: root/usr.bin/su
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2004-06-13 11:21:06 +0000
committermarkm <markm@FreeBSD.org>2004-06-13 11:21:06 +0000
commitea8442f9ea6f63d7195f29b50c16b0d189a640d1 (patch)
treec7e5958f1c3545fa23b0aac34011e81f5dc319c1 /usr.bin/su
parentf670e3d9a849f66fd9524fcc3d86be41cad0bc91 (diff)
downloadFreeBSD-src-ea8442f9ea6f63d7195f29b50c16b0d189a640d1.zip
FreeBSD-src-ea8442f9ea6f63d7195f29b50c16b0d189a640d1.tar.gz
Paranoia, WARNS fixes and lint.
Diffstat (limited to 'usr.bin/su')
-rw-r--r--usr.bin/su/su.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 1a49ae3..f085323 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <grp.h>
-#include <libutil.h>
#include <login_cap.h>
#include <paths.h>
#include <pwd.h>
@@ -104,6 +103,7 @@ __FBSDID("$FreeBSD$");
pam_strerror(pamh, local_ret)); \
errx(1, "pam_set_item(" #what "): %s", \
pam_strerror(pamh, local_ret)); \
+ /* NOTREACHED */ \
} \
} while (0)
@@ -113,9 +113,9 @@ static pam_handle_t *pamh = NULL;
static char **environ_pam;
static char *ontty(void);
-static int chshell(char *);
-static void usage(void);
-static int export_pam_environment(void);
+static int chshell(const char *);
+static void usage(void) __dead2;
+static void export_pam_environment(void);
static int ok_to_export(const char *);
extern char **environ;
@@ -123,6 +123,7 @@ extern char **environ;
int
main(int argc, char *argv[])
{
+ static char *cleanenv;
struct passwd *pwd;
struct pam_conv conv = { openpam_ttyconv, NULL };
enum tristate iscsh;
@@ -133,9 +134,10 @@ main(int argc, char *argv[])
} np;
uid_t ruid;
pid_t child_pid, child_pgrp, pid;
- int asme, ch, asthem, fastlogin, prio, i, setwhat, retcode,
+ int asme, ch, asthem, fastlogin, prio, i, retcode,
statusp, setmaclabel;
- char *username, *cleanenv, *class, shellbuf[MAXPATHLEN];
+ u_int setwhat;
+ char *username, *class, shellbuf[MAXPATHLEN];
const char *p, *user, *shell, *mytty, **nargv;
struct sigaction sa, sa_int, sa_quit, sa_pipe;
int temp, fds[2];
@@ -169,6 +171,7 @@ main(int argc, char *argv[])
case '?':
default:
usage();
+ /* NOTREACHED */
}
if (optind < argc)
@@ -176,11 +179,12 @@ main(int argc, char *argv[])
if (user == NULL)
usage();
+ /* NOTREACHED */
if (strlen(user) > MAXLOGNAME - 1)
errx(1, "username too long");
- nargv = malloc(sizeof(char *) * (argc + 4));
+ nargv = malloc(sizeof(char *) * (size_t)(argc + 4));
if (nargv == NULL)
errx(1, "malloc failure");
@@ -241,10 +245,6 @@ main(int argc, char *argv[])
retcode = pam_authenticate(pamh, 0);
if (retcode != PAM_SUCCESS) {
-#if 0
- syslog(LOG_ERR, "pam_authenticate: %s",
- pam_strerror(pamh, retcode));
-#endif
syslog(LOG_AUTH|LOG_WARNING, "BAD SU %s to %s on %s",
username, user, mytty);
errx(1, "Sorry");
@@ -290,6 +290,8 @@ main(int argc, char *argv[])
if (asme) {
if (ruid != 0 && !chshell(pwd->pw_shell))
errx(1, "permission denied (shell)");
+ shell = _PATH_BSHELL;
+ iscsh = NO;
}
else if (pwd->pw_shell && *pwd->pw_shell) {
shell = pwd->pw_shell;
@@ -353,9 +355,8 @@ main(int argc, char *argv[])
sigaction(SIGTSTP, &sa, NULL);
statusp = 1;
if (pipe(fds) == -1) {
- err(1, "pipe");
PAM_END();
- exit(1);
+ err(1, "pipe");
}
child_pid = fork();
switch (child_pid) {
@@ -382,11 +383,10 @@ main(int argc, char *argv[])
if (pid == -1)
err(1, "waitpid");
PAM_END();
- exit(statusp);
+ exit(WEXITSTATUS(statusp));
case -1:
- err(1, "fork");
PAM_END();
- exit(1);
+ err(1, "fork");
case 0:
close(fds[1]);
read(fds[0], &temp, 1);
@@ -464,7 +464,7 @@ main(int argc, char *argv[])
}
}
-static int
+static void
export_pam_environment(void)
{
char **pp;
@@ -474,7 +474,6 @@ export_pam_environment(void)
putenv(*pp);
free(*pp);
}
- return PAM_SUCCESS;
}
/*
@@ -514,10 +513,11 @@ usage(void)
fprintf(stderr, "usage: su [-] [-flms] [-c class] [login [args]]\n");
exit(1);
+ /* NOTREACHED */
}
static int
-chshell(char *sh)
+chshell(const char *sh)
{
int r;
char *cp;
OpenPOWER on IntegriCloud