util-lib: split out env file parsing code into env-file.c
It's quite complex, let's split this out. No code changes, just some file rearranging.
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-show.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "macro.h"
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "list.h"
|
||||
#include "macro.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "env-file.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "proc-cmdline.h"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "device-nodes.h"
|
||||
#include "device-util.h"
|
||||
#include "dissect-image.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "env-file-label.h"
|
||||
#include "env-file.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
int write_env_file_label(const char *fname, char **l) {
|
||||
int r;
|
||||
|
||||
r = mac_selinux_create_file_prepare(fname, S_IFREG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = write_env_file(fname, l);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
/* These functions are split out of fileio.h (and not for example just flags to the functions they wrap) in order to
|
||||
* 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);
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
#include "exec-util.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
@@ -20,20 +20,6 @@ int write_string_file_atomic_label_ts(const char *fn, const char *line, struct t
|
||||
return r;
|
||||
}
|
||||
|
||||
int write_env_file_label(const char *fname, char **l) {
|
||||
int r;
|
||||
|
||||
r = mac_selinux_create_file_prepare(fname, S_IFREG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = write_env_file(fname, l);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ int write_string_file_atomic_label_ts(const char *fn, const char *line, struct t
|
||||
static inline int write_string_file_atomic_label(const char *fn, const char *line) {
|
||||
return write_string_file_atomic_label_ts(fn, line, NULL);
|
||||
}
|
||||
int write_env_file_label(const char *fname, char **l);
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void);
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "copy.h"
|
||||
#include "dirent-util.h"
|
||||
#include "dissect-image.h"
|
||||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "hostname-util.h"
|
||||
|
||||
@@ -52,6 +52,8 @@ shared_sources = files('''
|
||||
efivars.c
|
||||
efivars.h
|
||||
enable-mempool.c
|
||||
env-file-label.c
|
||||
env-file-label.h
|
||||
exec-util.c
|
||||
exec-util.h
|
||||
exit-status.c
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
#include "os-util.h"
|
||||
#include "strv.h"
|
||||
#include "fileio.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
int path_is_os_tree(const char *path) {
|
||||
int r;
|
||||
|
||||
+1
-1
@@ -14,8 +14,8 @@
|
||||
#undef basename
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "path-util.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fileio.h"
|
||||
#include "env-file.h"
|
||||
#include "log.h"
|
||||
#include "parse-util.h"
|
||||
#include "string-table.h"
|
||||
|
||||
Reference in New Issue
Block a user