chiark / gitweb /
e4c1170aef9bdce3e04e432384d9be46c4db247c
[elogind.git] / src / basic / label.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <errno.h>
4 #include <sys/stat.h>
5 #include <unistd.h>
6
7 //#include "btrfs-util.h"
8 #include "label.h"
9 #include "macro.h"
10 #include "selinux-util.h"
11 #include "smack-util.h"
12
13 int label_fix(const char *path, LabelFixFlags flags) {
14         int r, q;
15
16         r = mac_selinux_fix(path, flags);
17         q = mac_smack_fix(path, flags);
18
19         if (r < 0)
20                 return r;
21         if (q < 0)
22                 return q;
23
24         return 0;
25 }
26
27
28 #if 0 /// UNNEEDED by elogind
29 int symlink_label(const char *old_path, const char *new_path) {
30         int r;
31
32         assert(old_path);
33         assert(new_path);
34
35         r = mac_selinux_create_file_prepare(new_path, S_IFLNK);
36         if (r < 0)
37                 return r;
38
39         if (symlink(old_path, new_path) < 0)
40                 r = -errno;
41
42         mac_selinux_create_file_clear();
43
44         if (r < 0)
45                 return r;
46
47         return mac_smack_fix(new_path, 0);
48 }
49
50 int btrfs_subvol_make_label(const char *path) {
51         int r;
52
53         assert(path);
54
55         r = mac_selinux_create_file_prepare(path, S_IFDIR);
56         if (r < 0)
57                 return r;
58
59         r = btrfs_subvol_make(path);
60         mac_selinux_create_file_clear();
61
62         if (r < 0)
63                 return r;
64
65         return mac_smack_fix(path, 0);
66 }
67 #endif // 0