svn commit: trunk/busybox/loginutils
vda at busybox.net
vda at busybox.net
Sat Jul 14 15:51:29 PDT 2007
Author: vda
Date: 2007-07-14 15:51:28 -0700 (Sat, 14 Jul 2007)
New Revision: 19091
Log:
adduser: close /etc/{passwd,shadow} before calling passwd etc.
Spotted by Natanael Copa <natanael.copa at gmail.com>
Modified:
trunk/busybox/loginutils/adduser.c
Changeset:
Modified: trunk/busybox/loginutils/adduser.c
===================================================================
--- trunk/busybox/loginutils/adduser.c 2007-07-14 22:43:10 UTC (rev 19090)
+++ trunk/busybox/loginutils/adduser.c 2007-07-14 22:51:28 UTC (rev 19091)
@@ -109,8 +109,9 @@
if (putpwent(p, file) == -1) {
bb_perror_nomsg_and_die();
}
- if (ENABLE_FEATURE_CLEAN_UP)
- fclose(file);
+ /* Do fclose even if !ENABLE_FEATURE_CLEAN_UP.
+ * We will exec passwd, files must be flushed & closed before that! */
+ fclose(file);
#if ENABLE_FEATURE_SHADOWPASSWDS
/* add to shadow if necessary */
@@ -123,8 +124,7 @@
0, /* sp->sp_min */
99999, /* sp->sp_max */
7); /* sp->sp_warn */
- if (ENABLE_FEATURE_CLEAN_UP)
- fclose(file);
+ fclose(file);
}
#endif
@@ -134,7 +134,7 @@
if (addgroup) addgroup_wrapper(p);
/* Clear the umask for this process so it doesn't
- * * screw up the permissions on the mkdir and chown. */
+ * screw up the permissions on the mkdir and chown. */
umask(0);
if (!(option_mask32 & OPT_DONT_MAKE_HOME)) {
/* Set the owner and group so it is owned by the new user,
More information about the busybox-cvs
mailing list