]>
Commit | Line | Data |
---|---|---|
a5c32cff HH |
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 | ***/ | |
a5c32cff | 20 | |
11c3a366 TA |
21 | #include <sys/stat.h> |
22 | ||
d7b8eec7 | 23 | #include "fileio-label.h" |
11c3a366 | 24 | #include "fileio.h" |
93cc7779 | 25 | #include "selinux-util.h" |
a5c32cff | 26 | |
39c38d77 | 27 | int write_string_file_atomic_label_ts(const char *fn, const char *line, struct timespec *ts) { |
a5c32cff HH |
28 | int r; |
29 | ||
ecabcf8b | 30 | r = mac_selinux_create_file_prepare(fn, S_IFREG); |
f7f628b5 | 31 | if (r < 0) |
a5c32cff HH |
32 | return r; |
33 | ||
39c38d77 | 34 | r = write_string_file_ts(fn, line, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC, ts); |
a5c32cff | 35 | |
ecabcf8b | 36 | mac_selinux_create_file_clear(); |
a5c32cff HH |
37 | |
38 | return r; | |
39 | } | |
40 | ||
41 | int write_env_file_label(const char *fname, char **l) { | |
42 | int r; | |
43 | ||
ecabcf8b | 44 | r = mac_selinux_create_file_prepare(fname, S_IFREG); |
f7f628b5 | 45 | if (r < 0) |
a5c32cff HH |
46 | return r; |
47 | ||
754fc0c7 | 48 | r = write_env_file(fname, l); |
a5c32cff | 49 | |
ecabcf8b | 50 | mac_selinux_create_file_clear(); |
a5c32cff HH |
51 | |
52 | return r; | |
53 | } | |
f7f628b5 ZJS |
54 | |
55 | int fopen_temporary_label(const char *target, | |
56 | const char *path, FILE **f, char **temp_path) { | |
57 | int r; | |
58 | ||
ecabcf8b | 59 | r = mac_selinux_create_file_prepare(target, S_IFREG); |
f7f628b5 ZJS |
60 | if (r < 0) |
61 | return r; | |
62 | ||
63 | r = fopen_temporary(path, f, temp_path); | |
64 | ||
ecabcf8b | 65 | mac_selinux_create_file_clear(); |
f7f628b5 ZJS |
66 | |
67 | return r; | |
68 | } |