]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
comment updates. it's not possible to change the file mode if you're not the
authorTimo Sirainen <tss@iki.fi>
Tue, 26 Aug 2003 22:15:36 +0000 (01:15 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 26 Aug 2003 22:15:36 +0000 (01:15 +0300)
owner..

--HG--
branch : HEAD

src/lib/safe-mkdir.c

index 0cb8802e272805ffe967045bc5376eab88a6df36..a582d2ea16e026485f8435af781cc4d99750951e 100644 (file)
@@ -35,6 +35,8 @@ int safe_mkdir(const char *dir, mode_t mode, uid_t uid, gid_t gid)
        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 @@ int safe_mkdir(const char *dir, mode_t mode, uid_t uid, gid_t gid)
        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);