Sun Mar 15 20:03:49 2009 UTC ()
Pull up following revision(s) (requested by mlelstv in ticket #562):
	usr.sbin/user/user.c: revision 1.121
bin/40994: Michael van Elst: usermod -l change password so user is unable to
login. User getpwnam_r to avoid trashing result of previous call to getpwnam().


(snj)
diff -r1.120 -r1.120.4.1 src/usr.sbin/user/user.c

cvs diff -r1.120 -r1.120.4.1 src/usr.sbin/user/user.c (expand / switch to context diff)
--- src/usr.sbin/user/user.c 2008/07/21 13:37:00 1.120
+++ src/usr.sbin/user/user.c 2009/03/15 20:03:49 1.120.4.1
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.120 2008/07/21 13:37:00 lukem Exp $ */
+/* $NetBSD: user.c,v 1.120.4.1 2009/03/15 20:03:49 snj Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.120 2008/07/21 13:37:00 lukem Exp $");
+__RCSID("$NetBSD: user.c,v 1.120.4.1 2009/03/15 20:03:49 snj Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1385,7 +1385,7 @@
 static int
 moduser(char *login_name, char *newlogin, user_t *up, int allow_samba)
 {
-	struct passwd  *pwp;
+	struct passwd  *pwp, pw;
 	struct group   *grp;
 	const char     *homedir;
 	char	       *locked_pwd;
@@ -1395,6 +1395,7 @@
 	FILE	       *master;
 	char		newdir[MaxFileNameLen];
 	char	        buf[MaxEntryLen];
+	char		pwbuf[MaxEntryLen];
 	char	       *colon;
 	int		masterfd;
 	int		ptmpfd;
@@ -1404,7 +1405,8 @@
 		errx(EXIT_FAILURE, "Can't modify user `%s': invalid login name",
 		    login_name);
 	}
-	if ((pwp = getpwnam(login_name)) == NULL) {
+	if (getpwnam_r(login_name, &pw, pwbuf, sizeof(pwbuf), &pwp) != 0
+	    || pwp == NULL) {
 		errx(EXIT_FAILURE, "Can't modify user `%s': no such user",
 		    login_name);
 	}