summaryrefslogtreecommitdiff
path: root/src/basic/mkdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/mkdir.c')
-rw-r--r--src/basic/mkdir.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
index 6b1a98402c..7db09fc6a1 100644
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -31,10 +31,13 @@
int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkdir_func_t _mkdir) {
struct stat st;
+ int r;
- if (_mkdir(path, mode) >= 0)
- if (chmod_and_chown(path, mode, uid, gid) < 0)
- return -errno;
+ if (_mkdir(path, mode) >= 0) {
+ r = chmod_and_chown(path, mode, uid, gid);
+ if (r < 0)
+ return r;
+ }
if (lstat(path, &st) < 0)
return -errno;