]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/tmpfile-util-label.c
Merge pull request #26038 from lilyinstarlight/fix/fstab-generator-sysroot-without...
[thirdparty/systemd.git] / src / shared / tmpfile-util-label.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <sys/stat.h>
4
5 #include "selinux-util.h"
6 #include "tmpfile-util-label.h"
7 #include "tmpfile-util.h"
8
9 int fopen_temporary_at_label(
10 int dir_fd,
11 const char *target,
12 const char *path,
13 FILE **f,
14 char **temp_path) {
15
16 int r;
17
18 assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
19 assert(path);
20
21 r = mac_selinux_create_file_prepare_at(dir_fd, target, S_IFREG);
22 if (r < 0)
23 return r;
24
25 r = fopen_temporary_at(dir_fd, path, f, temp_path);
26
27 mac_selinux_create_file_clear();
28
29 return r;
30 }