changeset 1742:05427d8112ee HEAD

comment updates. it's not possible to change the file mode if you're not the owner..
author Timo Sirainen <tss@iki.fi>
date Wed, 27 Aug 2003 01:15:36 +0300
parents 9df02b1533b3
children 37881cedb70d
files src/lib/safe-mkdir.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/safe-mkdir.c	Wed Aug 27 00:18:16 2003 +0300
+++ b/src/lib/safe-mkdir.c	Wed Aug 27 01:15:36 2003 +0300
@@ -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);