basic: add open_mkdir_at_full()

Add helper for open_mkdir_at() which accepts xopen flags, e.g. to pass
XO_LABEL to create the target with the correct security context.
This commit is contained in:
Christian Göttsche
2024-04-29 18:16:58 +02:00
parent 22b768d127
commit 4be62f821c
2 changed files with 9 additions and 6 deletions
+2 -2
View File
@@ -1025,7 +1025,7 @@ int parse_cifs_service(
return 0;
}
int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode) {
int open_mkdir_at_full(int dirfd, const char *path, int flags, XOpenFlags xopen_flags, mode_t mode) {
_cleanup_close_ int fd = -EBADF, parent_fd = -EBADF;
_cleanup_free_ char *fname = NULL, *parent = NULL;
int r;
@@ -1061,7 +1061,7 @@ int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode) {
path = fname;
}
fd = xopenat_full(dirfd, path, flags|O_CREAT|O_DIRECTORY|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
fd = xopenat_full(dirfd, path, flags|O_CREAT|O_DIRECTORY|O_NOFOLLOW, xopen_flags, mode);
if (IN_SET(fd, -ELOOP, -ENOTDIR))
return -EEXIST;
if (fd < 0)