chiark / gitweb /
core: add "invocation ID" concept to service manager
[elogind.git] / src / basic / fileio-label.c
1 /***
2   This file is part of systemd.
3
4   Copyright 2010 Lennart Poettering
5   Copyright 2010 Harald Hoyer
6
7   systemd is free software; you can redistribute it and/or modify it
8   under the terms of the GNU Lesser General Public License as published by
9   the Free Software Foundation; either version 2.1 of the License, or
10   (at your option) any later version.
11
12   systemd is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   Lesser General Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public License
18   along with systemd; If not, see <http://www.gnu.org/licenses/>.
19 ***/
20
21 #include <sys/stat.h>
22
23 #include "fileio-label.h"
24 //#include "fileio.h"
25 #include "selinux-util.h"
26
27 int write_string_file_atomic_label(const char *fn, const char *line) {
28         int r;
29
30         r = mac_selinux_create_file_prepare(fn, S_IFREG);
31         if (r < 0)
32                 return r;
33
34         r = write_string_file(fn, line, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
35
36         mac_selinux_create_file_clear();
37
38         return r;
39 }
40
41 #if 0 /// UNNEEDED by elogind
42 int write_env_file_label(const char *fname, char **l) {
43         int r;
44
45         r = mac_selinux_create_file_prepare(fname, S_IFREG);
46         if (r < 0)
47                 return r;
48
49         r = write_env_file(fname, l);
50
51         mac_selinux_create_file_clear();
52
53         return r;
54 }
55
56 int fopen_temporary_label(const char *target,
57                           const char *path, FILE **f, char **temp_path) {
58         int r;
59
60         r = mac_selinux_create_file_prepare(target, S_IFREG);
61         if (r < 0)
62                 return r;
63
64         r = fopen_temporary(path, f, temp_path);
65
66         mac_selinux_create_file_clear();
67
68         return r;
69 }
70 #endif // 0