summaryrefslogtreecommitdiffstats
path: root/usr.bin/su
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-09-04 17:10:57 +0000
committermarkm <markm@FreeBSD.org>2001-09-04 17:10:57 +0000
commit8fd9133a9f24ed33e1dafa6af3994a9996df2f62 (patch)
tree54f289d174faad844dd23ed77be8f007a9d026a7 /usr.bin/su
parent67ffe2e20325b02d34088606594673184dc10e50 (diff)
downloadFreeBSD-src-8fd9133a9f24ed33e1dafa6af3994a9996df2f62.zip
FreeBSD-src-8fd9133a9f24ed33e1dafa6af3994a9996df2f62.tar.gz
WARNS=2 fixes.
The remaining problem of converting highly incompatible pointer types is done by "laundering" the value through a union. This solves the problem (in my own mind) of how a "const char *" _ever_ actually gets a value in a WARNS=2 world.
Diffstat (limited to 'usr.bin/su')
-rw-r--r--usr.bin/su/Makefile4
-rw-r--r--usr.bin/su/su.c16
2 files changed, 11 insertions, 9 deletions
diff --git a/usr.bin/su/Makefile b/usr.bin/su/Makefile
index ccf6536..7d20843 100644
--- a/usr.bin/su/Makefile
+++ b/usr.bin/su/Makefile
@@ -6,9 +6,7 @@ PROG= su
DPADD+= ${LIBUTIL} ${LIBPAM}
LDADD+= -lutil ${MINUSLPAM}
-# Cannot be enabled because of a truly nasty warning/problem
-# concering execv(2)'s second argument.
-#WARNS?= 2
+WARNS?= 2
BINMODE=4555
INSTALLFLAGS=-fschg
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 8f03a4c..a5e454a 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -114,13 +114,17 @@ main(int argc, char *argv[])
struct pam_conv conv = {misc_conv, NULL};
enum tristate iscsh;
login_cap_t *lc;
+ union {
+ const char **a;
+ char * const b[1];
+ } np;
uid_t ruid;
gid_t gid;
int asme, ch, asthem, fastlogin, prio, i, setwhat, retcode,
statusp, child_pid, child_pgrp, ret_pid;
char *username, *cleanenv, *class, shellbuf[MAXPATHLEN],
myhost[MAXHOSTNAMELEN + 1];
- const char *p, *user, *shell, *mytty, **nargv, **np;
+ const char *p, *user, *shell, *mytty, **nargv;
shell = class = cleanenv = NULL;
asme = asthem = fastlogin = statusp = 0;
@@ -165,7 +169,7 @@ main(int argc, char *argv[])
nargv[argc + 3] = NULL;
for (i = argc; i >= optind; i--)
nargv[i + 3] = argv[i];
- np = &nargv[i + 3];
+ np.a = &nargv[i + 3];
argv += optind;
@@ -378,18 +382,18 @@ main(int argc, char *argv[])
if (iscsh == YES) {
if (fastlogin)
- *np-- = "-f";
+ *np.a-- = "-f";
if (asme)
- *np-- = "-m";
+ *np.a-- = "-m";
}
/* csh strips the first character... */
- *np = asthem ? "-su" : iscsh == YES ? "_su" : "su";
+ *np.a = asthem ? "-su" : iscsh == YES ? "_su" : "su";
if (ruid != 0)
syslog(LOG_NOTICE, "%s to %s%s", username, user,
ontty());
- execv(shell, np);
+ execv(shell, np.b);
err(1, "%s", shell);
}
}
OpenPOWER on IntegriCloud