diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-14 03:10:38 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-14 03:11:07 +0200 |
commit | f7f628b5db770feb8b18990436baefaec55c460b (patch) | |
tree | 2c660c583d95d07b1b53f985ed82a9a7583a74bf /src/shared/fileio-label.c | |
parent | sysusers: preserve label of /etc/{passwd, group} (diff) | |
download | systemd-f7f628b5db770feb8b18990436baefaec55c460b.tar.xz systemd-f7f628b5db770feb8b18990436baefaec55c460b.zip |
Add function to open temp files in selinux mode
Diffstat (limited to 'src/shared/fileio-label.c')
-rw-r--r-- | src/shared/fileio-label.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/shared/fileio-label.c b/src/shared/fileio-label.c index 0711826e85..417ca5695a 100644 --- a/src/shared/fileio-label.c +++ b/src/shared/fileio-label.c @@ -25,12 +25,13 @@ #include "fileio-label.h" #include "label.h" +#include "util.h" int write_string_file_atomic_label(const char *fn, const char *line) { int r; r = label_context_set(fn, S_IFREG); - if (r < 0) + if (r < 0) return r; write_string_file_atomic(fn, line); @@ -44,7 +45,7 @@ int write_env_file_label(const char *fname, char **l) { int r; r = label_context_set(fname, S_IFREG); - if (r < 0) + if (r < 0) return r; write_env_file(fname, l); @@ -53,3 +54,18 @@ int write_env_file_label(const char *fname, char **l) { return r; } + +int fopen_temporary_label(const char *target, + const char *path, FILE **f, char **temp_path) { + int r; + + r = label_context_set("/etc/passwd", S_IFREG); + if (r < 0) + return r; + + r = fopen_temporary(path, f, temp_path); + + label_context_clear(); + + return r; +} |