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 
fopen_temporary_label(const char * target,const char * path,FILE ** f,char ** temp_path)9 int fopen_temporary_label(
10                 const char *target,
11                 const char *path,
12                 FILE **f,
13                 char **temp_path) {
14 
15         int r;
16 
17         r = mac_selinux_create_file_prepare(target, S_IFREG);
18         if (r < 0)
19                 return r;
20 
21         r = fopen_temporary(path, f, temp_path);
22 
23         mac_selinux_create_file_clear();
24 
25         return r;
26 }
27