tree-wide: port various places over to open_mkdir_at()

This commit is contained in:
Lennart Poettering
2021-11-17 21:48:29 +01:00
parent c73094f3ac
commit 96603ea076
4 changed files with 24 additions and 27 deletions
+3 -11
View File
@@ -485,8 +485,6 @@ static int hardlink_context_setup(
}
static int hardlink_context_realize(HardlinkContext *c) {
int r;
if (!c)
return 0;
@@ -498,15 +496,9 @@ static int hardlink_context_realize(HardlinkContext *c) {
assert(c->subdir);
if (mkdirat(c->parent_fd, c->subdir, 0700) < 0)
return -errno;
c->dir_fd = openat(c->parent_fd, c->subdir, O_RDONLY|O_DIRECTORY|O_CLOEXEC);
if (c->dir_fd < 0) {
r = -errno;
(void) unlinkat(c->parent_fd, c->subdir, AT_REMOVEDIR);
return r;
}
c->dir_fd = open_mkdir_at(c->parent_fd, c->subdir, O_EXCL|O_CLOEXEC, 0700);
if (c->dir_fd < 0)
return c->dir_fd;
return 1;
}
+3 -3
View File
@@ -215,10 +215,10 @@ int get_credential_host_secret(CredentialSecretFlags flags, void **ret, size_t *
fn = "credential.secret";
}
(void) mkdir_p(p, 0755);
dfd = open(p, O_CLOEXEC|O_DIRECTORY|O_RDONLY);
mkdir_parents(p, 0755);
dfd = open_mkdir_at(AT_FDCWD, p, O_CLOEXEC, 0755);
if (dfd < 0)
return -errno;
return dfd;
if (FLAGS_SET(flags, CREDENTIAL_SECRET_FAIL_ON_TEMPORARY_FS)) {
r = fd_is_temporary_fs(dfd);