chiark / gitweb /
sysusers: fix selinux context of backup files
[elogind.git] / src / shared / fileio-label.c
index 5bf127bcf19f6c713c341fc101b4b457760664ef..c3def3c568fd615ffbec57b6c9f11de5d7ec8aaa 100644 (file)
 
 #include "fileio-label.h"
 #include "label.h"
+#include "util.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)
+        if (r < 0)
                 return r;
 
-        write_one_line_file_atomic(fn, line);
+        write_string_file_atomic(fn, line);
 
         label_context_clear();
 
@@ -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(target, S_IFREG);
+        if (r < 0)
+                return r;
+
+        r = fopen_temporary(path, f, temp_path);
+
+        label_context_clear();
+
+        return r;
+}