summaryrefslogtreecommitdiff
path: root/src/basic/mkdir.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-03-29 16:00:03 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-04-03 15:28:00 +0200
commit2c71aa77a5f600ad151f9d28e449cb96bf60e8d8 (patch)
tree88c54df52e70d531d6b75328372d1d36e33d4057 /src/basic/mkdir.c
parentacbb504eaf1be51572b1c0d0d490ac478bc41c64 (diff)
downloadsystemd-2c71aa77a5f600ad151f9d28e449cb96bf60e8d8.tar.gz
basic/mkdir: simplify error handling
If we created the dir successfully, we let chmod_and_chown_at() do its thing and shouldn't go into the part where we check if the existing directory has the right permissions and ownership and possibly adjust them. The code was doing that, by relying on the fact that chmod_and_chown_at() does not return -EEXIST. That's probably true, but seems unnecessarilly complicated. Follow-up for c1b1492a94b43ca636eb383c3b058feff27ff7b1.
Diffstat (limited to 'src/basic/mkdir.c')
-rw-r--r--src/basic/mkdir.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
index 3b7cf7a0bf..41af1482bc 100644
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -33,11 +33,8 @@ int mkdirat_safe_internal(
assert(_mkdirat && _mkdirat != mkdirat);
r = _mkdirat(dir_fd, path, mode);
- if (r >= 0) {
- r = chmod_and_chown_at(dir_fd, path, mode, uid, gid);
- if (r < 0)
- return r;
- }
+ if (r >= 0)
+ return chmod_and_chown_at(dir_fd, path, mode, uid, gid);
if (r != -EEXIST)
return r;