port write_env_file() to label_os_pre() + teach firstboot a bit of relabelling (#37869)
This is a clean-up, and also addresses some of the points of #37857.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "env-file.h"
|
||||
#include "env-file-label.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
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(dir_fd, fname, headers, l);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int write_vconsole_conf_label(char **l) {
|
||||
int r;
|
||||
|
||||
r = mac_selinux_create_file_prepare("/etc/vconsole.conf", S_IFREG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = write_vconsole_conf(AT_FDCWD, "/etc/vconsole.conf", l);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "forward.h"
|
||||
|
||||
/* 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(int dir_fd, const char *fname, char **headers, char **l);
|
||||
|
||||
int write_vconsole_conf_label(char **l);
|
||||
@@ -60,25 +60,6 @@ int symlink_label(const char *old_path, const char *new_path) {
|
||||
return mac_smack_fix(new_path, 0);
|
||||
}
|
||||
|
||||
int symlink_atomic_full_label(const char *from, const char *to, bool make_relative) {
|
||||
int r;
|
||||
|
||||
assert(from);
|
||||
assert(to);
|
||||
|
||||
r = mac_selinux_create_file_prepare(to, S_IFLNK);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = symlinkat_atomic_full(from, AT_FDCWD, to, make_relative);
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return mac_smack_fix(to, 0);
|
||||
}
|
||||
|
||||
int mknodat_label(int dirfd, const char *pathname, mode_t mode, dev_t dev) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@ static inline int label_fix(const char *path, LabelFixFlags flags) {
|
||||
}
|
||||
|
||||
int symlink_label(const char *old_path, const char *new_path);
|
||||
int symlink_atomic_full_label(const char *from, const char *to, bool make_relative);
|
||||
static inline int symlink_atomic_label(const char *from, const char *to) {
|
||||
return symlink_atomic_full_label(from, to, false);
|
||||
}
|
||||
|
||||
int mknodat_label(int dirfd, const char *pathname, mode_t mode, dev_t dev);
|
||||
static inline int mknod_label(const char *pathname, mode_t mode, dev_t dev) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "env-file-label.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -212,7 +211,12 @@ int locale_context_save(LocaleContext *c, char ***ret_set, char ***ret_unset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = write_env_file_label(AT_FDCWD, "/etc/locale.conf", NULL, set);
|
||||
r = write_env_file(
|
||||
AT_FDCWD,
|
||||
"/etc/locale.conf",
|
||||
/* headers= */ NULL,
|
||||
set,
|
||||
WRITE_ENV_FILE_LABEL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ shared_sources = files(
|
||||
'efi-loader.c',
|
||||
'elf-util.c',
|
||||
'enable-mempool.c',
|
||||
'env-file-label.c',
|
||||
'ethtool-util.c',
|
||||
'exec-util.c',
|
||||
'exit-status.c',
|
||||
|
||||
Reference in New Issue
Block a user