CVS commit: src/usr.bin/passwd

2017-10-11 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Oct 12 05:00:23 UTC 2017

Modified Files:
src/usr.bin/passwd: passwd.c

Log Message:
fix compile error without USE_PAM (-Werror,-Wmissing-noreturn)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/passwd/passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/passwd.c
diff -u src/usr.bin/passwd/passwd.c:1.31 src/usr.bin/passwd/passwd.c:1.32
--- src/usr.bin/passwd/passwd.c:1.31	Sat Sep  3 02:24:04 2016
+++ src/usr.bin/passwd/passwd.c	Thu Oct 12 05:00:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: passwd.c,v 1.31 2016/09/03 02:24:04 sevan Exp $	*/
+/*	$NetBSD: passwd.c,v 1.32 2017/10/12 05:00:23 ryo Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "from: @(#)passwd.c8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: passwd.c,v 1.31 2016/09/03 02:24:04 sevan Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.32 2017/10/12 05:00:23 ryo Exp $");
 #endif
 #endif /* not lint */
 
@@ -231,7 +231,7 @@ static struct pw_module_s {
 	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 };
  
-static void
+static void __attribute__((__noreturn__))
 usage(void)
 {
 	int i;



CVS commit: src/usr.bin/passwd

2017-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 28 23:44:51 UTC 2017

Modified Files:
src/usr.bin/passwd: Makefile

Log Message:
add sqlite3


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/passwd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/Makefile
diff -u src/usr.bin/passwd/Makefile:1.44 src/usr.bin/passwd/Makefile:1.45
--- src/usr.bin/passwd/Makefile:1.44	Wed Feb 13 18:19:14 2013
+++ src/usr.bin/passwd/Makefile	Sat Jan 28 18:44:51 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.44 2013/02/13 23:19:14 christos Exp $
+#	$NetBSD: Makefile,v 1.45 2017/01/28 23:44:51 christos Exp $
 #	from: @(#)Makefile8.3 (Berkeley) 4/2/94
 
 .include 
@@ -30,7 +30,9 @@ CPPFLAGS+= -DKERBEROS5
 SRCS+=	krb5_passwd.c
 
 DPADD+=	${LIBKRB5} ${LIBCRYPTO} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN} ${LIBCRYPT}
+DPADD+=	${LIBSQLITE3}
 LDADD+=	-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lcrypt
+LDADD+=	-lsqlite3
 .ifdef OVERRIDE_HEIMDAL_KPASSWD
 LINKS+=	${BINDIR}/passwd ${BINDIR}/kpasswd
 MAN+=	kpasswd.1



CVS commit: src/usr.bin/passwd

2013-02-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 13 23:19:14 UTC 2013

Modified Files:
src/usr.bin/passwd: Makefile

Log Message:
Keep the built-in support for passwd -k, but don't make the kpasswd link or
install the kpasswd man page since these are provided by heimdal. I ifdef'ed
them so that the code to install them is still with the Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/passwd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/Makefile
diff -u src/usr.bin/passwd/Makefile:1.43 src/usr.bin/passwd/Makefile:1.44
--- src/usr.bin/passwd/Makefile:1.43	Mon Feb 11 18:11:48 2013
+++ src/usr.bin/passwd/Makefile	Wed Feb 13 18:19:14 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.43 2013/02/11 23:11:48 christos Exp $
+#	$NetBSD: Makefile,v 1.44 2013/02/13 23:19:14 christos Exp $
 #	from: @(#)Makefile8.3 (Berkeley) 4/2/94
 
 .include bsd.own.mk
@@ -25,13 +25,13 @@ LDADD+= -lcrypt -lutil
 BINOWN=	root
 BINMODE=4555
 
-.ifdef OVERRIDE_HEIMDAL_KPASSWD
 .if (${USE_KERBEROS} != no)
 CPPFLAGS+= -DKERBEROS5
 SRCS+=	krb5_passwd.c
 
 DPADD+=	${LIBKRB5} ${LIBCRYPTO} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN} ${LIBCRYPT}
 LDADD+=	-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lcrypt
+.ifdef OVERRIDE_HEIMDAL_KPASSWD
 LINKS+=	${BINDIR}/passwd ${BINDIR}/kpasswd
 MAN+=	kpasswd.1
 .endif



CVS commit: src/usr.bin/passwd

2013-02-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 11 23:11:49 UTC 2013

Modified Files:
src/usr.bin/passwd: Makefile

Log Message:
don't build kpasswd; heimdal does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/passwd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/Makefile
diff -u src/usr.bin/passwd/Makefile:1.42 src/usr.bin/passwd/Makefile:1.43
--- src/usr.bin/passwd/Makefile:1.42	Sun Apr 24 17:42:06 2011
+++ src/usr.bin/passwd/Makefile	Mon Feb 11 18:11:48 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.42 2011/04/24 21:42:06 elric Exp $
+#	$NetBSD: Makefile,v 1.43 2013/02/11 23:11:48 christos Exp $
 #	from: @(#)Makefile8.3 (Berkeley) 4/2/94
 
 .include bsd.own.mk
@@ -25,6 +25,7 @@ LDADD+= -lcrypt -lutil
 BINOWN=	root
 BINMODE=4555
 
+.ifdef OVERRIDE_HEIMDAL_KPASSWD
 .if (${USE_KERBEROS} != no)
 CPPFLAGS+= -DKERBEROS5
 SRCS+=	krb5_passwd.c
@@ -34,6 +35,7 @@ LDADD+=	-lkrb5 -lcrypto -lasn1 -lcom_err
 LINKS+=	${BINDIR}/passwd ${BINDIR}/kpasswd
 MAN+=	kpasswd.1
 .endif
+.endif
 
 .if (${USE_PAM} != no)
 CPPFLAGS+=-DUSE_PAM



CVS commit: src/usr.bin/passwd

2012-04-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 22 23:43:51 UTC 2012

Modified Files:
src/usr.bin/passwd: krb5_passwd.c

Log Message:
- fix non pam build
- merge duplicated error code
- fix opt struct leak


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/passwd/krb5_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/krb5_passwd.c
diff -u src/usr.bin/passwd/krb5_passwd.c:1.19 src/usr.bin/passwd/krb5_passwd.c:1.20
--- src/usr.bin/passwd/krb5_passwd.c:1.19	Sun Apr 24 17:16:43 2011
+++ src/usr.bin/passwd/krb5_passwd.c	Sun Apr 22 19:43:51 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: krb5_passwd.c,v 1.19 2011/04/24 21:16:43 elric Exp $ */
+/* $NetBSD: krb5_passwd.c,v 1.20 2012/04/22 23:43:51 christos Exp $ */
 
 /*
  * Copyright (c) 2000, 2005 The NetBSD Foundation, Inc.
@@ -45,6 +45,17 @@
 
 #include extern.h
 
+static void
+pwkrb5_warn(const char *msg, krb5_context context, krb5_error_code ret)
+{
+const char *errtxt = krb5_get_error_message(context, ret);
+if (errtxt != NULL) {
+	warnx(%s: %s, msg, errtxt);
+	krb5_free_error_message(context, errtxt);
+} else
+	warnx(%s: %d, msg, ret);
+}
+
 #ifdef USE_PAM
 
 void
@@ -75,7 +86,6 @@ pwkrb5_process(const char *username, int
 	krb5_data result_code_string, result_string;
 	char pwbuf[BUFSIZ];
 	int ch;
-	const char *errtxt;
 
 	while ((ch = getopt(argc, argv, 5ku:)) != -1) {
 		switch (ch) {
@@ -131,13 +141,7 @@ pwkrb5_process(const char *username, int
 
 	ret = krb5_get_init_creds_opt_alloc(context, opt);
 	if (ret) {
-		errtxt = krb5_get_error_message(context, ret);
-		if (errtxt != NULL) {
-			warnx(failed to allocate opts: %s, errtxt);
-			krb5_free_error_message(context, errtxt);
-		} else {
-			warnx(failed to allocate opts: %d, ret);
-		}
+		pwkrb5_warn(failed to allocate opts, context, ret);
 		goto bad;
 	}
 
@@ -147,13 +151,8 @@ pwkrb5_process(const char *username, int
 
 	ret = krb5_parse_name(context, username, principal);
 	if (ret) {
-		errtxt = krb5_get_error_message(context, ret);
-		if (errtxt != NULL) {
-			warnx(failed to parse principal: %s, errtxt);
-			krb5_free_error_message(context, errtxt);
-		} else {
-			warnx(failed to parse principal: %d, ret);
-		}
+		krb5_get_init_creds_opt_free(context, opt);
+		pwkrb5_warn(failed to parse principal, context, ret);
 		goto bad;
 	}
 
@@ -167,7 +166,7 @@ pwkrb5_process(const char *username, int
 	   kadmin/changepw,
 	   opt);
 
-
+	krb5_get_init_creds_opt_free(context, opt);
 	switch (ret) {
 	case 0:
 		break;
@@ -182,13 +181,7 @@ pwkrb5_process(const char *username, int
 		goto bad;
 
 	default:
-		errtxt = krb5_get_error_message(context, ret);
-		if (errtxt != NULL) {
-			warnx(failed to get credentials: %s, errtxt);
-			krb5_free_error_message(context, errtxt);
-		} else {
-			warnx(failed to get credentials: %d, ret);
-		}
+		pwkrb5_warn(failed to get credentials, context, ret);
 		goto bad;
  	}
 
@@ -205,13 +198,7 @@ pwkrb5_process(const char *username, int
 result_code_string,
 result_string);
 	if (ret) {
-		errtxt = krb5_get_error_message(context, ret);
-		if (errtxt != NULL) {
-			warnx(unable to set password: %s, errtxt);
-			krb5_free_error_message(context, errtxt);
-		} else {
-			warnx(unable to set password: %d, ret);
-		}
+		pwkrb5_warn(unable to set password, context, ret);
 		goto bad;
 	}
 
@@ -283,48 +270,39 @@ krb5_end(void)
 krb5_free_context(defcontext);
 }
 
-
 int
 krb5_chpw(const char *username)
 {
 krb5_error_code ret;
 krb5_context context;
 krb5_principal principal;
-krb5_get_init_creds_opt opt;
+krb5_get_init_creds_opt *opt;
 krb5_creds cred;
 int result_code;
 krb5_data result_code_string, result_string;
 char pwbuf[BUFSIZ];
-const char *errtxt;
 
 ret = krb5_init_context (context);
 if (ret) {
-	errtxt = krb5_get_error_message(context, ret);
-	if (errtxt != NULL) {
-	warnx(failed kerberos initialisation: %s, errtxt);
-	krb5_free_error_message(context, errtxt);
-	} else {
-	warnx(failed kerberos initialisation: %d, ret);
-	}
+	pwkrb5_warn(failed kerberos initialisation, context, ret);
 	return 1;
 }
 
-krb5_get_init_creds_opt_init (opt);
+ret = krb5_get_init_creds_opt_alloc (context, opt);
+if (ret) {
+	pwkrb5_warn(failed to allocate credential opt, context, ret);
+	return 1;
+}
 
-krb5_get_init_creds_opt_set_tkt_life (opt, 300);
-krb5_get_init_creds_opt_set_forwardable (opt, FALSE);
-krb5_get_init_creds_opt_set_proxiable (opt, FALSE);
+krb5_get_init_creds_opt_set_tkt_life (opt, 300);
+krb5_get_init_creds_opt_set_forwardable (opt, FALSE);
+krb5_get_init_creds_opt_set_proxiable (opt, FALSE);
 
 if(username != NULL) {
 ret = krb5_parse_name (context, username, principal);
 if (ret) {
-	errtxt = krb5_get_error_message(context, ret);
-	  

CVS commit: src/usr.bin/passwd

2012-03-24 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Mar 25 05:55:07 UTC 2012

Modified Files:
src/usr.bin/passwd: local_passwd.c yp_passwd.c

Log Message:
fix non-PAM build


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/passwd/local_passwd.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/passwd/yp_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/local_passwd.c
diff -u src/usr.bin/passwd/local_passwd.c:1.35 src/usr.bin/passwd/local_passwd.c:1.36
--- src/usr.bin/passwd/local_passwd.c:1.35	Wed Aug 31 16:24:58 2011
+++ src/usr.bin/passwd/local_passwd.c	Sun Mar 25 05:55:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: local_passwd.c,v 1.35 2011/08/31 16:24:58 plunky Exp $	*/
+/*	$NetBSD: local_passwd.c,v 1.36 2012/03/25 05:55:07 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from: @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: local_passwd.c,v 1.35 2011/08/31 16:24:58 plunky Exp $);
+__RCSID($NetBSD: local_passwd.c,v 1.36 2012/03/25 05:55:07 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -230,8 +230,7 @@ pwlocal_process(const char *username, in
 static int force_local;
 
 int
-local_init(progname)
-	const char *progname;
+local_init(const char *progname)
 {
 	force_local = 0;
 	return (0);
@@ -251,7 +250,7 @@ local_arg(char ch, const char *arg)
 }
 
 int
-local_arg_end()
+local_arg_end(void)
 {
 	if (force_local)
 		return(PW_USE_FORCE);
@@ -259,14 +258,13 @@ local_arg_end()
 }
 
 void
-local_end()
+local_end(void)
 {
 	/* NOOP */
 }
 
 int
-local_chpw(uname)
-	const char *uname;
+local_chpw(const char *uname)
 {
 	struct passwd *pw;
 	struct passwd old_pw;

Index: src/usr.bin/passwd/yp_passwd.c
diff -u src/usr.bin/passwd/yp_passwd.c:1.36 src/usr.bin/passwd/yp_passwd.c:1.37
--- src/usr.bin/passwd/yp_passwd.c:1.36	Fri Sep 16 15:39:27 2011
+++ src/usr.bin/passwd/yp_passwd.c	Sun Mar 25 05:55:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: yp_passwd.c,v 1.36 2011/09/16 15:39:27 joerg Exp $	*/
+/*	$NetBSD: yp_passwd.c,v 1.37 2012/03/25 05:55:07 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from:  @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: yp_passwd.c,v 1.36 2011/09/16 15:39:27 joerg Exp $);
+__RCSID($NetBSD: yp_passwd.c,v 1.37 2012/03/25 05:55:07 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -329,8 +329,7 @@ pwyp_process(const char *username, int a
 static	int yflag;
 
 int
-yp_init(progname)
-	const char *progname;
+yp_init(const char *progname)
 {
 	int yppwd;
 



CVS commit: src/usr.bin/passwd

2011-04-24 Thread Roland Dowdeswell
Module Name:src
Committed By:   elric
Date:   Sun Apr 24 21:16:44 UTC 2011

Modified Files:
src/usr.bin/passwd: krb5_passwd.c

Log Message:
Stop using functions deprecated by Heimdal.  Also, if krb5_init_context()
fails, we can't use Kerberos functions to grab error strings, we
resort to strerror(3) which is what Heimdal's deprecated function
does in this case.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/passwd/krb5_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/krb5_passwd.c
diff -u src/usr.bin/passwd/krb5_passwd.c:1.18 src/usr.bin/passwd/krb5_passwd.c:1.19
--- src/usr.bin/passwd/krb5_passwd.c:1.18	Sat Apr 18 09:04:34 2009
+++ src/usr.bin/passwd/krb5_passwd.c	Sun Apr 24 21:16:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: krb5_passwd.c,v 1.18 2009/04/18 09:04:34 mlelstv Exp $ */
+/* $NetBSD: krb5_passwd.c,v 1.19 2011/04/24 21:16:43 elric Exp $ */
 
 /*
  * Copyright (c) 2000, 2005 The NetBSD Foundation, Inc.
@@ -68,13 +68,14 @@
 {
 	krb5_context context;
 	krb5_error_code ret;
-	krb5_get_init_creds_opt opt;
+	krb5_get_init_creds_opt *opt;
 	krb5_principal principal;
 	krb5_creds cred;
 	int result_code;
 	krb5_data result_code_string, result_string;
 	char pwbuf[BUFSIZ];
 	int ch;
+	const char *errtxt;
 
 	while ((ch = getopt(argc, argv, 5ku:)) != -1) {
 		switch (ch) {
@@ -125,21 +126,34 @@
 	if (ret != 0) {
 		if (ret == ENXIO)
 			errx(1, Kerberos 5 not in use.);
-		warnx(Unable to initialize Kerberos 5: %s,
-		krb5_get_err_text(context, ret));
-		goto bad;
+		errx(1, Unable to initialize Kerberos 5: %s, strerror(ret));
 	}
 
-	krb5_get_init_creds_opt_init(opt);
+	ret = krb5_get_init_creds_opt_alloc(context, opt);
+	if (ret) {
+		errtxt = krb5_get_error_message(context, ret);
+		if (errtxt != NULL) {
+			warnx(failed to allocate opts: %s, errtxt);
+			krb5_free_error_message(context, errtxt);
+		} else {
+			warnx(failed to allocate opts: %d, ret);
+		}
+		goto bad;
+	}
 
-	krb5_get_init_creds_opt_set_tkt_life(opt, 300L);
-	krb5_get_init_creds_opt_set_forwardable(opt, FALSE);
-	krb5_get_init_creds_opt_set_proxiable(opt, FALSE);
+	krb5_get_init_creds_opt_set_tkt_life(opt, 300L);
+	krb5_get_init_creds_opt_set_forwardable(opt, FALSE);
+	krb5_get_init_creds_opt_set_proxiable(opt, FALSE);
 
 	ret = krb5_parse_name(context, username, principal);
 	if (ret) {
-		warnx(failed to parse principal: %s, 
-		krb5_get_err_text(context, ret));
+		errtxt = krb5_get_error_message(context, ret);
+		if (errtxt != NULL) {
+			warnx(failed to parse principal: %s, errtxt);
+			krb5_free_error_message(context, errtxt);
+		} else {
+			warnx(failed to parse principal: %d, ret);
+		}
 		goto bad;
 	}
 
@@ -151,7 +165,7 @@
 	   NULL,
 	   0L,
 	   kadmin/changepw,
-	   opt);
+	   opt);
 
 
 	switch (ret) {
@@ -168,8 +182,13 @@
 		goto bad;
 
 	default:
-		warnx(failed to get credentials: %s, 
-		krb5_get_err_text(context, ret));
+		errtxt = krb5_get_error_message(context, ret);
+		if (errtxt != NULL) {
+			warnx(failed to get credentials: %s, errtxt);
+			krb5_free_error_message(context, errtxt);
+		} else {
+			warnx(failed to get credentials: %d, ret);
+		}
 		goto bad;
  	}
 
@@ -186,8 +205,13 @@
 result_code_string,
 result_string);
 	if (ret) {
-		warnx(unable to set password: %s,
-		krb5_get_err_text(context, ret));
+		errtxt = krb5_get_error_message(context, ret);
+		if (errtxt != NULL) {
+			warnx(unable to set password: %s, errtxt);
+			krb5_free_error_message(context, errtxt);
+		} else {
+			warnx(unable to set password: %d, ret);
+		}
 		goto bad;
 	}
 
@@ -271,11 +295,17 @@
 int result_code;
 krb5_data result_code_string, result_string;
 char pwbuf[BUFSIZ];
+const char *errtxt;
 
 ret = krb5_init_context (context);
 if (ret) {
-	warnx(failed kerberos initialisation: %s, 
-	  krb5_get_err_text(context, ret));
+	errtxt = krb5_get_error_message(context, ret);
+	if (errtxt != NULL) {
+	warnx(failed kerberos initialisation: %s, errtxt);
+	krb5_free_error_message(context, errtxt);
+	} else {
+	warnx(failed kerberos initialisation: %d, ret);
+	}
 	return 1;
 }
 
@@ -288,8 +318,13 @@
 if(username != NULL) {
 ret = krb5_parse_name (context, username, principal);
 if (ret) {
-	warnx(failed to parse principal: %s, 
-		  krb5_get_err_text(context, ret));
+	errtxt = krb5_get_error_message(context, ret);
+	if (errtxt != NULL) {
+		warnx(failed to parse principal: %s, errtxt);
+		krb5_free_error_message(context, errtxt);
+	} else {
+		warnx(failed to parse principal: %d, ret);
+	}
 	return 1;
 	}
 } else
@@ -317,8 +352,13 @@
 	return 1;
 break;
 default:
-	warnx(failed to get credentials: %s, 
-	  krb5_get_err_text(context, ret));
+	errtxt = krb5_get_error_message(context, ret);
+	if (errtxt != NULL) {
+	

CVS commit: src/usr.bin/passwd

2010-09-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep  8 13:44:44 UTC 2010

Modified Files:
src/usr.bin/passwd: yp_passwd.c

Log Message:
PR/43852: Wolfgang Stukenbrock: yp_passwd command may destroy NIS database
entries when used on a server that includes users via netgroups.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/passwd/yp_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/yp_passwd.c
diff -u src/usr.bin/passwd/yp_passwd.c:1.33 src/usr.bin/passwd/yp_passwd.c:1.34
--- src/usr.bin/passwd/yp_passwd.c:1.33	Sun Apr 12 19:59:37 2009
+++ src/usr.bin/passwd/yp_passwd.c	Wed Sep  8 09:44:44 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: yp_passwd.c,v 1.33 2009/04/12 23:59:37 lukem Exp $	*/
+/*	$NetBSD: yp_passwd.c,v 1.34 2010/09/08 13:44:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from:  @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: yp_passwd.c,v 1.33 2009/04/12 23:59:37 lukem Exp $);
+__RCSID($NetBSD: yp_passwd.c,v 1.34 2010/09/08 13:44:44 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -168,21 +168,26 @@
 ypgetpwnam(const char *nam, struct passwd *pwd)
 {
 	char *val;
-	int reason, vallen;
-	int flags;
+	int reason, vallen, namlen = (int)strlen(nam);
+	int flags = 0;
 	int ok = 0;
 	
 	val = NULL;
-	reason = yp_match(domain, passwd.byname, nam, (int)strlen(nam),
-			  val, vallen);
+	reason = yp_match(domain, master.passwd.byname, nam, namlen,
+  val, vallen);
+	if (reason == YPERR_MAP) {
+		reason = yp_match(domain, passwd.byname, nam, namlen,
+  val, vallen);
+		flags = _PASSWORD_OLDFMT;
+	}
 	if (reason != 0)
 		goto out;
 
-	flags = _PASSWORD_OLDFMT;
 	if (pw_scan(val, pwd, flags) == 0)
 		goto out;
 
 	ok = 1;
+	val = NULL;	/* Don't free the memory, it is still in use */
 out:
 	if (val)
 		free(val);
@@ -213,7 +218,7 @@
 	char *master;
 	int ch, r, rpcport, status;
 	struct yppasswd ypp;
-	struct passwd pwb, *pw;
+	struct passwd pwb, pwb2, *pw;
 	char pwbuf[1024];
 	struct timeval tv;
 	CLIENT *client;
@@ -266,7 +271,7 @@
 	 * the daemon.
 	 */
 	if ((r = yp_master(domain, passwd.byname, master)) != 0)
-		errx(1, can't find the master NIS server.  Reason: %s,
+		errx(1, can't find the master NIS server. Reason: %s,
 		yperr_string(r));
 
 	/*
@@ -285,16 +290,16 @@
 
 	/* Bail out if this is a local (non-yp) user, */
 	/* then get user's login identity */
-	if (!ypgetpwnam(username, pw = pwb) ||
-	getpwnam_r(username, pwb, pwbuf, sizeof(pwbuf), pw) ||
+	if (!ypgetpwnam(username, pwb) ||
+	getpwnam_r(username, pwb2, pwbuf, sizeof(pwbuf), pw) ||
 	pw == NULL)
 		errx(1, NIS unknown user %s, username);
 
-	if (uid  uid != pw-pw_uid)
+	if (uid  uid != pwb.pw_uid)
 		errx(1, you may only change your own password: %s,
 		strerror(EACCES));
 
-	makeypp(ypp, pw);
+	makeypp(ypp, pwb);
 
 	client = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, udp);
 	if (client == NULL)



CVS commit: src/usr.bin/passwd

2010-09-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep  8 13:58:47 UTC 2010

Modified Files:
src/usr.bin/passwd: yp_passwd.c

Log Message:
KNF, make error messages consistent.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/passwd/yp_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/yp_passwd.c
diff -u src/usr.bin/passwd/yp_passwd.c:1.34 src/usr.bin/passwd/yp_passwd.c:1.35
--- src/usr.bin/passwd/yp_passwd.c:1.34	Wed Sep  8 09:44:44 2010
+++ src/usr.bin/passwd/yp_passwd.c	Wed Sep  8 09:58:46 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: yp_passwd.c,v 1.34 2010/09/08 13:44:44 christos Exp $	*/
+/*	$NetBSD: yp_passwd.c,v 1.35 2010/09/08 13:58:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from:  @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: yp_passwd.c,v 1.34 2010/09/08 13:44:44 christos Exp $);
+__RCSID($NetBSD: yp_passwd.c,v 1.35 2010/09/08 13:58:46 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -85,8 +85,8 @@
 	int tries;
 	const char *p, *t;
 	char *result;
-	static char buf[_PASSWORD_LEN+1];
-	char salt[_PASSWORD_LEN+1];
+	static char buf[_PASSWORD_LEN + 1];
+	char salt[_PASSWORD_LEN + 1];
 	char option[LINE_MAX], *key, *opt;
 
 	(void)printf(Changing NIS password for %s.\n, pw-pw_name);
@@ -96,7 +96,7 @@
 	
 		if (pw-pw_passwd[0]) {
 			if (strcmp(crypt(p = getpass(Old password:),
-	 pw-pw_passwd),  pw-pw_passwd)) {
+			pw-pw_passwd),  pw-pw_passwd)) {
 (void)printf(Sorry.\n);
 pwerror(NULL, 0, 1);
 			}
@@ -123,9 +123,9 @@
 		for (t = p; *t  islower((unsigned char)*t); ++t);
 		if (!*t  ++tries  2) {
 			(void)printf(Please don't use an all-lower case 
- password.\nUnusual capitalization, 
- control characters or digits are 
- suggested.\n);
+			password.\nUnusual capitalization, 
+			control characters or digits are 
+			suggested.\n);
 			continue;
 		}
 		(void)strlcpy(buf, p, sizeof(buf));
@@ -146,7 +146,7 @@
 		(void)printf(not enough core.\n);
 		pwerror(NULL, 0, 0);
 	}
-	return (result);
+	return result;
 }
 
 static void
@@ -169,15 +169,16 @@
 {
 	char *val;
 	int reason, vallen, namlen = (int)strlen(nam);
-	int flags = 0;
-	int ok = 0;
+	int flags;
+	int ok;
 	
+	flags = ok = 0;
 	val = NULL;
 	reason = yp_match(domain, master.passwd.byname, nam, namlen,
-  val, vallen);
+	val, vallen);
 	if (reason == YPERR_MAP) {
 		reason = yp_match(domain, passwd.byname, nam, namlen,
-  val, vallen);
+		val, vallen);
 		flags = _PASSWORD_OLDFMT;
 	}
 	if (reason != 0)
@@ -200,7 +201,7 @@
 pwyp_usage(const char *prefix)
 {
 
-	(void) fprintf(stderr, %s %s [-d nis | -y] [user]\n,
+	(void)fprintf(stderr, %s %s [-d nis | -y] [user]\n,
 	prefix, getprogname());
 }
 
@@ -208,7 +209,7 @@
 pwyp_argv0_usage(const char *prefix)
 {
 
-	(void) fprintf(stderr, %s %s [user]\n,
+	(void)fprintf(stderr, %s %s [user]\n,
 	prefix, getprogname());
 }
 
@@ -217,6 +218,7 @@
 {
 	char *master;
 	int ch, r, rpcport, status;
+	enum clnt_stat yr;
 	struct yppasswd ypp;
 	struct passwd pwb, pwb2, *pw;
 	char pwbuf[1024];
@@ -249,12 +251,12 @@
 		break;
 	default:
 		usage();
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	if (_yp_check(NULL) == 0) {
 		/* can't use YP. */
-		errx(1, NIS not in use.);
+		errx(EXIT_FAILURE, NIS not in use.);
 	}
 
 	uid = getuid();
@@ -263,7 +265,7 @@
 	 * Get local domain
 	 */
 	if ((r = yp_get_default_domain(domain)) != 0)
-		errx(1, can't get local NIS domain.  Reason: %s,
+		errx(EXIT_FAILURE, Can't get local NIS domain (%s),
 		yperr_string(r));
 
 	/*
@@ -271,7 +273,7 @@
 	 * the daemon.
 	 */
 	if ((r = yp_master(domain, passwd.byname, master)) != 0)
-		errx(1, can't find the master NIS server. Reason: %s,
+		errx(EXIT_FAILURE, Can't find the master NIS server (%s),
 		yperr_string(r));
 
 	/*
@@ -279,40 +281,42 @@
 	 */
 	if ((rpcport = getrpcport(master, YPPASSWDPROG,
 	YPPASSWDPROC_UPDATE, IPPROTO_UDP)) == 0)
-		errx(1, master NIS server not running yppasswd daemon.\n\t%s\n,
-		Can't change NIS password.);
+		errx(EXIT_FAILURE, Master NIS server not running yppasswd 
+		daemon);
 
 	/*
 	 * Be sure the port is privileged
 	 */
 	if (rpcport = IPPORT_RESERVED)
-		errx(1, yppasswd daemon is on an invalid port.);
+		errx(EXIT_FAILURE, Yppasswd daemon is on an invalid port);
 
 	/* Bail out if this is a local (non-yp) user, */
 	/* then get user's login identity */
 	if (!ypgetpwnam(username, pwb) ||
 	getpwnam_r(username, pwb2, pwbuf, sizeof(pwbuf), pw) ||
 	pw == NULL)
-		errx(1, NIS unknown user %s, username);
+		errx(EXIT_FAILURE, NIS unknown user %s, username);
 
-	if (uid  uid != pwb.pw_uid)
-		errx(1, you may only change your own password: %s,
-		strerror(EACCES));
+	if (uid  uid != pwb.pw_uid) {
+		errno = 

CVS commit: src/usr.bin/passwd

2009-04-17 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Apr 17 20:25:08 UTC 2009

Modified Files:
src/usr.bin/passwd: local_passwd.c passwd.c

Log Message:
Rename variables to fix GCC warnings: local variables optopt and optarg
shadow globals.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/passwd/local_passwd.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/passwd/passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/local_passwd.c
diff -u src/usr.bin/passwd/local_passwd.c:1.32 src/usr.bin/passwd/local_passwd.c:1.33
--- src/usr.bin/passwd/local_passwd.c:1.32	Sun Apr 12 23:59:37 2009
+++ src/usr.bin/passwd/local_passwd.c	Fri Apr 17 20:25:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: local_passwd.c,v 1.32 2009/04/12 23:59:37 lukem Exp $	*/
+/*	$NetBSD: local_passwd.c,v 1.33 2009/04/17 20:25:08 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from: @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: local_passwd.c,v 1.32 2009/04/12 23:59:37 lukem Exp $);
+__RCSID($NetBSD: local_passwd.c,v 1.33 2009/04/17 20:25:08 dyoung Exp $);
 #endif
 #endif /* not lint */
 
@@ -228,9 +228,9 @@
 }
 
 int
-local_arg(char arg, const char *optarg)
+local_arg(char ch, const char *arg)
 {
-	switch (arg) {
+	switch (ch) {
 	case 'l':
 		force_local = 1;
 		break;

Index: src/usr.bin/passwd/passwd.c
diff -u src/usr.bin/passwd/passwd.c:1.29 src/usr.bin/passwd/passwd.c:1.30
--- src/usr.bin/passwd/passwd.c:1.29	Sun Apr 12 23:59:37 2009
+++ src/usr.bin/passwd/passwd.c	Fri Apr 17 20:25:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: passwd.c,v 1.29 2009/04/12 23:59:37 lukem Exp $	*/
+/*	$NetBSD: passwd.c,v 1.30 2009/04/17 20:25:08 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = from: @(#)passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: passwd.c,v 1.29 2009/04/12 23:59:37 lukem Exp $);
+__RCSID($NetBSD: passwd.c,v 1.30 2009/04/17 20:25:08 dyoung Exp $);
 #endif
 #endif /* not lint */
 
@@ -250,7 +250,7 @@
 	int ch;
 	char *username;
 	char optstring[64];  /* if we ever get more than 64 args, shoot me. */
-	const char *curopt, *optopt;
+	const char *curopt, *oopt;
 	int i, j;
 	int valid;
 	int use_always;
@@ -306,15 +306,15 @@
 
 		curopt = pw_modules[i].args;
 		while (*curopt != '\0') {
-			if ((optopt = strchr(optstring, *curopt)) == NULL) {
+			if ((oopt = strchr(optstring, *curopt)) == NULL) {
 optstring[j++] = *curopt;
 if (curopt[1] == ':') {
 	curopt++;
 	optstring[j++] = *curopt;
 }
 optstring[j] = '\0';
-			} else if ((optopt[1] == ':'  curopt[1] != ':') ||
-			(optopt[1] != ':'  curopt[1] == ':')) {
+			} else if ((oopt[1] == ':'  curopt[1] != ':') ||
+			(oopt[1] != ':'  curopt[1] == ':')) {
 errx(1, NetBSD ERROR!  Different password 
 modules have two different ideas about 
 %c argument format., curopt[0]);
@@ -329,8 +329,8 @@
 		for (i = 0; pw_modules[i].pw_init != NULL; i++) {
 			if (pw_modules[i].invalid)
 continue;
-			if ((optopt = strchr(pw_modules[i].args, ch)) != NULL) {
-j = (optopt[1] == ':') ?
+			if ((oopt = strchr(pw_modules[i].args, ch)) != NULL) {
+j = (oopt[1] == ':') ?
 ! (*pw_modules[i].pw_arg)(ch, optarg) :
 ! (*pw_modules[i].pw_arg)(ch, NULL);
 if (j != 0)



CVS commit: src/usr.bin/passwd

2009-04-12 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Apr 12 23:59:37 UTC 2009

Modified Files:
src/usr.bin/passwd: local_passwd.c passwd.c yp_passwd.c

Log Message:
Fix WARNS=4 issues


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/passwd/local_passwd.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/passwd/passwd.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/passwd/yp_passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/passwd/local_passwd.c
diff -u src/usr.bin/passwd/local_passwd.c:1.31 src/usr.bin/passwd/local_passwd.c:1.32
--- src/usr.bin/passwd/local_passwd.c:1.31	Fri Jan 25 19:36:27 2008
+++ src/usr.bin/passwd/local_passwd.c	Sun Apr 12 23:59:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: local_passwd.c,v 1.31 2008/01/25 19:36:27 christos Exp $	*/
+/*	$NetBSD: local_passwd.c,v 1.32 2009/04/12 23:59:37 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from: @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: local_passwd.c,v 1.31 2008/01/25 19:36:27 christos Exp $);
+__RCSID($NetBSD: local_passwd.c,v 1.32 2009/04/12 23:59:37 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -81,7 +81,7 @@
 			(void)printf(Password unchanged.\n);
 			pw_error(NULL, 0, 0);
 		}
-		if (min_pw_len  0  strlen(p)  min_pw_len) {
+		if (min_pw_len  0  (int)strlen(p)  min_pw_len) {
 			(void) printf(Password is too short.\n);
 			continue;
 		}

Index: src/usr.bin/passwd/passwd.c
diff -u src/usr.bin/passwd/passwd.c:1.28 src/usr.bin/passwd/passwd.c:1.29
--- src/usr.bin/passwd/passwd.c:1.28	Mon Jul 21 14:19:24 2008
+++ src/usr.bin/passwd/passwd.c	Sun Apr 12 23:59:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: passwd.c,v 1.28 2008/07/21 14:19:24 lukem Exp $	*/
+/*	$NetBSD: passwd.c,v 1.29 2009/04/12 23:59:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = from: @(#)passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: passwd.c,v 1.28 2008/07/21 14:19:24 lukem Exp $);
+__RCSID($NetBSD: passwd.c,v 1.29 2009/04/12 23:59:37 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -79,7 +79,7 @@
 	/* default -- use whatever PAM decides */
 	{ NULL, NULL, 0, NULL, pwpam_process },
 
-	{ 0 }
+	{ NULL, NULL, 0, NULL, NULL }
 };
 
 static const struct pw_module_s *personality;

Index: src/usr.bin/passwd/yp_passwd.c
diff -u src/usr.bin/passwd/yp_passwd.c:1.32 src/usr.bin/passwd/yp_passwd.c:1.33
--- src/usr.bin/passwd/yp_passwd.c:1.32	Fri Jan 25 19:36:12 2008
+++ src/usr.bin/passwd/yp_passwd.c	Sun Apr 12 23:59:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: yp_passwd.c,v 1.32 2008/01/25 19:36:12 christos Exp $	*/
+/*	$NetBSD: yp_passwd.c,v 1.33 2009/04/12 23:59:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from:  @(#)local_passwd.c8.3 (Berkeley) 4/2/94;
 #else
-__RCSID($NetBSD: yp_passwd.c,v 1.32 2008/01/25 19:36:12 christos Exp $);
+__RCSID($NetBSD: yp_passwd.c,v 1.33 2009/04/12 23:59:37 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -71,10 +71,10 @@
 static char *domain;
 
 static void
-pwerror(char *name, int err, int eval)
+pwerror(const char *name, int show_err, int eval)
 {
 
-	if (err)
+	if (show_err)
 		warn(%s, name);
 	errx(eval, NIS passwd database unchanged);
 }
@@ -83,7 +83,8 @@
 getnewpasswd(struct passwd *pw, char **old_pass)
 {
 	int tries;
-	char *p, *t;
+	const char *p, *t;
+	char *result;
 	static char buf[_PASSWORD_LEN+1];
 	char salt[_PASSWORD_LEN+1];
 	char option[LINE_MAX], *key, *opt;
@@ -140,12 +141,12 @@
 		warn(Couldn't generate salt);
 		pwerror(NULL, 0, 0);
 	}
-	p = strdup(crypt(buf, salt));
-	if (!p) {
+	result = strdup(crypt(buf, salt));
+	if (!result) {
 		(void)printf(not enough core.\n);
 		pwerror(NULL, 0, 0);
 	}
-	return (p);
+	return (result);
 }
 
 static void