From 8f2c2f20b6383d7528ad86a26780b36f2a02e2d3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Aug 2017 12:46:09 +0200 Subject: [PATCH] mkdir: chmod_and_chown() returns errors as "return -errno", not in errno itself --- src/basic/mkdir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c index 6b1a984..7db09fc 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; -- 2.7.4