dovecot-2.0: safe_mkdir(): uid/gid can now be -1 to mean "don't ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Mar 16 14:39:05 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/acc07775bab3
changeset: 10913:acc07775bab3
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Mar 16 14:29:25 2010 +0200
description:
safe_mkdir(): uid/gid can now be -1 to mean "don't change it".

diffstat:

 src/lib/safe-mkdir.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 56dda1de9b6f -r acc07775bab3 src/lib/safe-mkdir.c
--- a/src/lib/safe-mkdir.c	Mon Mar 15 15:16:44 2010 +0200
+++ b/src/lib/safe-mkdir.c	Tue Mar 16 14:29:25 2010 +0200
@@ -39,7 +39,8 @@
 
 	/* 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 ((st.st_uid != uid && uid != (uid_t)-1) ||
+	    (st.st_gid != gid && gid != (gid_t)-1)) {
 		if (fchown(fd, uid, gid) < 0)
 			i_fatal("fchown() failed for %s: %m", dir);
 		ret = changed_ret;
@@ -65,7 +66,8 @@
 		i_fatal("safe_mkdir() failed: %s (%o) is still not mode %o",
 			dir, (int)st.st_mode, (int)mode);
 	}
-	if (st.st_uid != uid || st.st_gid != gid) {
+	if ((st.st_uid != uid && uid != (uid_t)-1) ||
+	    (st.st_gid != gid && gid != (gid_t)-1)) {
 		i_fatal("safe_mkdir() failed: %s (%s, %s) "
 			"is still not owned by %s.%s",
 			dir, dec2str(st.st_uid), dec2str(st.st_gid),


More information about the dovecot-cvs mailing list