X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Ffileio-label.c;h=bec988ca7872c143bf794872c4612068e6c0f958;hp=5bf127bcf19f6c713c341fc101b4b457760664ef;hb=d8d5781c1eb031477670facc132e198f8fddd56c;hpb=a5c32cff1f56afe6f0c6c70d91a88a7a8238b2d7;ds=sidebyside diff --git a/src/shared/fileio-label.c b/src/shared/fileio-label.c index 5bf127bcf..bec988ca7 100644 --- a/src/shared/fileio-label.c +++ b/src/shared/fileio-label.c @@ -19,23 +19,21 @@ You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ -#include -#include -#include +#include "util.h" +#include "selinux-util.h" #include "fileio-label.h" -#include "label.h" -int write_one_line_file_atomic_label(const char *fn, const char *line) { +int write_string_file_atomic_label(const char *fn, const char *line) { int r; - r = label_context_set(fn, S_IFREG); - if (r < 0) + r = mac_selinux_create_file_prepare(fn, S_IFREG); + if (r < 0) return r; - write_one_line_file_atomic(fn, line); + r = write_string_file_atomic(fn, line); - label_context_clear(); + mac_selinux_create_file_clear(); return r; } @@ -43,13 +41,28 @@ int write_one_line_file_atomic_label(const char *fn, const char *line) { int write_env_file_label(const char *fname, char **l) { int r; - r = label_context_set(fname, S_IFREG); - if (r < 0) + r = mac_selinux_create_file_prepare(fname, S_IFREG); + if (r < 0) return r; - write_env_file(fname, l); + r = write_env_file(fname, l); - label_context_clear(); + mac_selinux_create_file_clear(); + + return r; +} + +int fopen_temporary_label(const char *target, + const char *path, FILE **f, char **temp_path) { + int r; + + r = mac_selinux_create_file_prepare(target, S_IFREG); + if (r < 0) + return r; + + r = fopen_temporary(path, f, temp_path); + + mac_selinux_create_file_clear(); return r; }