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