dovecot-2.0: mkdir_*chown/chgrp(): If chown() fails, rmdir() the...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jan 16 21:15:13 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/c75a13e5b678
changeset: 12563:c75a13e5b678
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jan 16 21:15:10 2011 +0200
description:
mkdir_*chown/chgrp(): If chown() fails, rmdir() the directory.

diffstat:

 src/lib/mkdir-parents.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r 113b54dcb950 -r c75a13e5b678 src/lib/mkdir-parents.c
--- a/src/lib/mkdir-parents.c	Sun Jan 16 18:53:27 2011 +0200
+++ b/src/lib/mkdir-parents.c	Sun Jan 16 21:15:10 2011 +0200
@@ -33,12 +33,16 @@
 		return -1;
 	}
 	if (chown(path, uid, gid) < 0) {
+		orig_errno = errno;
+		if (rmdir(path) < 0)
+			i_error("rmdir(%s) failed: %m", path);
+		errno = orig_errno;
+
 		if (errno == EPERM && uid == (uid_t)-1) {
 			i_error("%s", eperm_error_get_chgrp("chown", path, gid,
 							    gid_origin));
 			return -1;
 		}
-		orig_errno = errno;
 
 		str = t_str_new(256);
 		str_printfa(str, "chown(%s, %ld", path,


More information about the dovecot-cvs mailing list