From f7f628b5db770feb8b18990436baefaec55c460b Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sun, 13 Jul 2014 21:10:38 -0400 Subject: Add function to open temp files in selinux mode --- src/shared/fileio-label.c | 20 ++++++++++++++++++-- src/shared/fileio-label.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/shared') 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; +} diff --git a/src/shared/fileio-label.h b/src/shared/fileio-label.h index fce4fe0d73..25fa351be2 100644 --- a/src/shared/fileio-label.h +++ b/src/shared/fileio-label.h @@ -27,3 +27,5 @@ int write_string_file_atomic_label(const char *fn, const char *line); int write_env_file_label(const char *fname, char **l); +int fopen_temporary_label(const char *target, + const char *path, FILE **f, char **temp_path); -- cgit v1.2.3-54-g00ecf