Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Aug 2001 11:58:05 +0100
From:      Mark Murray <mark@grondar.za>
To:        audit@freebsd.org
Subject:   [patch] su(1) WARNS=2 cleanup
Message-ID:  <200108071058.f77Aw6Z43835@grimreaper.grondar.za>

next in thread | raw e-mail | index | archive | help
Hi

Please review.

The PAM_SET_ITEM() thing is a separate commit.

Thanks!

M

Index: Makefile
===================================================================
RCS file: /home/ncvs/src/usr.bin/su/Makefile,v
retrieving revision 1.32
diff -u -d -r1.32 Makefile
--- Makefile	2001/05/26 09:52:36	1.32
+++ Makefile	2001/08/06 14:04:14
@@ -5,6 +5,7 @@
 
 DPADD+= ${LIBUTIL} ${LIBPAM}
 LDADD+= -lutil ${MINUSLPAM}
+WARNS?=	2
 
 BINMODE=4555
 INSTALLFLAGS=-fschg
Index: su.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/su/su.c,v
retrieving revision 1.39
diff -u -d -r1.39 su.c
--- su.c	2001/05/26 09:52:36	1.39
+++ su.c	2001/08/06 14:07:11
@@ -67,7 +67,7 @@
 #include <security/pam_appl.h>
 #include <security/pam_misc.h>
 
-#define PAM_END do {						\
+#define PAM_END() do {						\
 	int local_ret;						\
 	if (pamh != NULL && creds_set) {			\
 		local_ret = pam_setcred(pamh, PAM_DELETE_CRED);	\
@@ -120,9 +120,10 @@
 	gid_t		gid;
 	int		asme, ch, asthem, fastlogin, prio, i, setwhat, retcode,
 			statusp, child_pid, child_pgrp, ret_pid;
-	char		*p, *user, *shell, *username, *cleanenv, **nargv, **np,
-			*class, *mytty, shellbuf[MAXPATHLEN],
-			myhost[MAXHOSTNAMELEN + 1];
+	char		*username, *cleanenv, **nargv,
+			*class, shellbuf[MAXPATHLEN],
+			myhost[MAXHOSTNAMELEN + 1], **np;
+	const char	*p, *user, *shell, *mytty;
 
 	shell = class = cleanenv = NULL;
 	asme = asthem = fastlogin = statusp = 0;
@@ -213,6 +214,8 @@
 		errx(1, "pam_start: %s", pam_strerror(pamh, retcode));
 	}
 
+	PAM_SET_ITEM(PAM_RUSER, (const void *)getlogin());
+
 	gethostname(myhost, sizeof(myhost));
 	PAM_SET_ITEM(PAM_RHOST, myhost);
 
@@ -325,11 +328,11 @@
 		}
 		if (ret_pid == -1)
 			err(1, "waitpid");
-		PAM_END;
+		PAM_END();
 		exit(statusp);
 	case -1:
 		err(1, "fork");
-		PAM_END;
+		PAM_END();
 		exit(1);
 	case 0:
 		/*
@@ -378,18 +381,19 @@
 
 		if (iscsh == YES) {
 			if (fastlogin)
-				*np-- = "-f";
+				(const char *)(*np--) = "-f";
 			if (asme)
-				*np-- = "-m";
+				(const char *)(*np--) = "-m";
 		}
 		/* csh strips the first character... */
-		*np = asthem ? "-su" : iscsh == YES ? "_su" : "su";
+		(const char *)(*np)
+			= asthem ? "-su" : iscsh == YES ? "_su" : "su";
 
 		if (ruid != 0)
 			syslog(LOG_NOTICE, "%s to %s%s", username, user,
 			    ontty());
 
-		execv(shell, np);
+		execv(shell, (char * const *)np);
 		err(1, "%s", shell);
 	}
 }

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108071058.f77Aw6Z43835>