env-util: make write_env_file() optionally take headers

This also makes write_env_file() and write_env_file_label() optionally
take dir_fd, and drop write_env_file_at().

Preparation for later commits.
This commit is contained in:
Yu Watanabe
2023-10-31 17:15:21 +09:00
parent 78101ca9cc
commit f155cb6d75
10 changed files with 19 additions and 16 deletions
+2 -2
View File
@@ -6,14 +6,14 @@
#include "env-file.h"
#include "selinux-util.h"
int write_env_file_label(const char *fname, char **l) {
int write_env_file_label(int dir_fd, const char *fname, char **headers, char **l) {
int r;
r = mac_selinux_create_file_prepare(fname, S_IFREG);
if (r < 0)
return r;
r = write_env_file(fname, l);
r = write_env_file(dir_fd, fname, headers, l);
mac_selinux_create_file_clear();
+1 -1
View File
@@ -5,4 +5,4 @@
* optimize linking: This way, -lselinux is needed only for the callers of these functions that need selinux, but not
* for all */
int write_env_file_label(const char *fname, char **l);
int write_env_file_label(int dir_fd, const char *fname, char **headers, char **l);
+1 -1
View File
@@ -208,7 +208,7 @@ int locale_context_save(LocaleContext *c, char ***ret_set, char ***ret_unset) {
return 0;
}
r = write_env_file_label("/etc/locale.conf", set);
r = write_env_file_label(AT_FDCWD, "/etc/locale.conf", NULL, set);
if (r < 0)
return r;