Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2008 20:55:58 -0700 (PDT)
From:      Unga <unga888@yahoo.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   [PATCH] pw_update() return success on failure
Message-ID:  <127065.62863.qm@web57007.mail.re3.yahoo.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hi all
 
In the present implementation if the pwdb() of /usr/src/usr.sbin/pw/pwupd.c fails,  pw_update() (of the same file) still return rc=0, therefore, subsequent  functions still continue to proceed without passwd and  master.passwd been updated. The attached patch fixes this  issue. If this patch is acceptable, appreciate if it could  be applied to both current and RELENG_7.
 
Kind regards
Unga



      
[-- Attachment #2 --]
diff -Naur pw.orig/pwupd.c pw/pwupd.c
--- pw.orig/pwupd.c	2008-07-07 10:28:52.000000000 +0800
+++ pw/pwupd.c	2008-07-07 11:27:37.000000000 +0800
@@ -139,7 +139,7 @@
 static int
 pw_update(struct passwd * pwd, char const * user, int mode)
 {
-	int             rc = 0;
+	int rc;
 
 	ENDPWENT();
 
@@ -148,7 +148,8 @@
 	 * Note: -C is only available in FreeBSD 2.2 and above
 	 */
 #ifdef HAVE_PWDB_C
-	if (pwdb("-C", (char *)NULL) == 0) {	/* Check only */
+	rc = pwdb("-C", (char *)NULL); /* Check only */
+	if (rc == 0) {
 #else
 	{				/* No -C */
 #endif
home | help

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