[dovecot-cvs] dovecot/src/lib safe-mkdir.c,1.4,1.5

cras at procontrol.fi cras at procontrol.fi
Wed Aug 27 02:15:39 EEST 2003


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv4405/lib

Modified Files:
	safe-mkdir.c 
Log Message:
comment updates. it's not possible to change the file mode if you're not the
owner..



Index: safe-mkdir.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/safe-mkdir.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- safe-mkdir.c	26 Aug 2003 21:18:16 -0000	1.4
+++ safe-mkdir.c	26 Aug 2003 22:15:36 -0000	1.5
@@ -35,6 +35,8 @@
 	if (!S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
 		i_fatal("Not a directory %s", dir);
 
+	/* change the file owner first, since it's the only user one who
+	   can mess up with the file mode. */
 	if (st.st_uid != uid || st.st_gid != gid) {
 		if (fchown(fd, uid, gid) < 0)
 			i_fatal("fchown() failed for %s: %m", dir);
@@ -50,9 +52,7 @@
 	if (close(fd) < 0)
 		i_fatal("close() failed for %s: %m", dir);
 
-	/* make sure we succeeded in everything. chown() and chmod()
-	   are racy: user owned 0777 file - change either and the user
-	   can still change it back. */
+	/* paranoia: make sure we succeeded in everything. */
 	if (lstat(dir, &st) < 0)
 		i_fatal("lstat() check failed for %s: %m", dir);
 



More information about the dovecot-cvs mailing list