From: James Carlson Date: Wed, 30 Jan 2008 14:26:53 +0000 (+0000) Subject: Fixed uninitialized 'pw' variable in HAS_SHADOW logic in session.c due X-Git-Tag: ppp-2.4.7~99 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=1c8af01fd1c14975b6ea9d757578ccbcafd97abb Fixed uninitialized 'pw' variable in HAS_SHADOW logic in session.c due to flaw in initial integration. Enabled HAS_SHADOW for Solaris, which always has shadow password files. Fixed all of pppd to compile with gcc -Wall on Solaris. (Still need fixes for kernel modules; blocking Makedefs.gcc update.) Tested with and without PAM, with gcc and Sun's cc. --- diff --git a/pppd/Makefile.sol2 b/pppd/Makefile.sol2 index 49e73c7..1ad4b13 100644 --- a/pppd/Makefile.sol2 +++ b/pppd/Makefile.sol2 @@ -1,6 +1,6 @@ # # Makefile for pppd under Solaris 2. -# $Id: Makefile.sol2,v 1.29 2007/12/01 20:10:51 carlsonj Exp $ +# $Id: Makefile.sol2,v 1.30 2008/01/30 14:26:52 carlsonj Exp $ # include ../Makedefs.com @@ -12,8 +12,11 @@ OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o eap.o md5.o \ tty.o ccp.o ecp.o auth.o options.o demand.o utils.o sys-solaris.o \ chap-md5.o session.o +# Solaris uses shadow passwords +CFLAGS += -DHAS_SHADOW + # -# uncomment the following to enable plugins +# Comment the following out to disable plugins # CFLAGS += -DPLUGIN LIBS += -ldl diff --git a/pppd/session.c b/pppd/session.c index f9f8fc0..491d3bf 100644 --- a/pppd/session.c +++ b/pppd/session.c @@ -294,9 +294,11 @@ session_start(flags, user, passwd, ttyName, msg) #else /* #ifdef USE_PAM */ /* - * Use the non-PAM methods directly + * Use the non-PAM methods directly. 'pw' will remain NULL if the user + * has not been authenticated using local UNIX system services. */ + pw = NULL; if ((SESS_AUTH & flags)) { pw = getpwnam(user); @@ -362,7 +364,12 @@ session_start(flags, user, passwd, ttyName, msg) logged_in = 1; #if defined(_PATH_LASTLOG) && !defined(USE_PAM) - { + /* + * Enter the user in lastlog only if he has been authenticated using + * local system services. If he has not, then we don't know what his + * UID might be, and lastlog is indexed by UID. + */ + if (pw != NULL) { struct lastlog ll; int fd; diff --git a/pppd/sys-solaris.c b/pppd/sys-solaris.c index 06e8f73..50ce3df 100644 --- a/pppd/sys-solaris.c +++ b/pppd/sys-solaris.c @@ -85,7 +85,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: sys-solaris.c,v 1.15 2007/06/19 02:08:35 carlsonj Exp $" +#define RCSID "$Id: sys-solaris.c,v 1.16 2008/01/30 14:26:53 carlsonj Exp $" #include #include @@ -2220,7 +2220,7 @@ get_hw_addr_dlpi(name, hwaddr) char *name; struct sockaddr *hwaddr; { - char *p, *q; + char *q; int unit, iffd, adrlen; unsigned char *adrp; char ifdev[24]; @@ -2744,7 +2744,6 @@ get_pty(master_fdp, slave_fdp, slave_name, uid) { int mfd, sfd; char *pty_name; - struct termios tios; mfd = open("/dev/ptmx", O_RDWR); if (mfd < 0) {