svn commit: trunk/busybox/loginutils

vda at busybox.net vda at busybox.net
Sat Mar 24 16:06:47 UTC 2007


Author: vda
Date: 2007-03-24 09:06:46 -0700 (Sat, 24 Mar 2007)
New Revision: 18229

Log:
adduser: don't bomb out if shadow password file doesn't exist
(from Tito <farmatito at tiscali.it>)


Modified:
   trunk/busybox/loginutils/adduser.c


Changeset:
Modified: trunk/busybox/loginutils/adduser.c
===================================================================
--- trunk/busybox/loginutils/adduser.c	2007-03-24 15:40:16 UTC (rev 18228)
+++ trunk/busybox/loginutils/adduser.c	2007-03-24 16:06:46 UTC (rev 18229)
@@ -109,19 +109,23 @@
 	if (putpwent(p, file) == -1) {
 		bb_perror_nomsg_and_die();
 	}
-	fclose(file);
+	if (ENABLE_FEATURE_CLEAN_UP)
+		fclose(file);
 
 #if ENABLE_FEATURE_SHADOWPASSWDS
 	/* add to shadow if necessary */
-	file = xfopen(bb_path_shadow_file, "a");
-	fseek(file, 0, SEEK_END);
-	fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
-			p->pw_name,             /* username */
-			time(NULL) / 86400,     /* sp->sp_lstchg */
-			0,                      /* sp->sp_min */
-			99999,                  /* sp->sp_max */
-			7);                     /* sp->sp_warn */
-	fclose(file);
+	file = fopen_or_warn(bb_path_shadow_file, "a");
+	if (file) {
+		fseek(file, 0, SEEK_END);
+		fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
+				p->pw_name,             /* username */
+				time(NULL) / 86400,     /* sp->sp_lstchg */
+				0,                      /* sp->sp_min */
+				99999,                  /* sp->sp_max */
+				7);                     /* sp->sp_warn */
+		if (ENABLE_FEATURE_CLEAN_UP)
+			fclose(file);
+	}
 #endif
 
 	/* add to group */




More information about the busybox-cvs mailing list