1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

Merge pull request #20800 from keszybz/smack-compilatio-fix

smack: move helper function to smack-util.c
This commit is contained in:
Yu Watanabe 2021-09-22 16:56:37 +09:00 committed by GitHub
commit 7df4e57470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 19 deletions

View File

@ -1024,8 +1024,11 @@ else
endif
conf.set10('HAVE_APPARMOR', have)
conf.set10('HAVE_SMACK_RUN_LABEL', get_option('smack-run-label') != '')
conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
have = get_option('smack') and get_option('smack-run-label') != ''
conf.set10('HAVE_SMACK_RUN_LABEL', have)
if have
conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
endif
want_polkit = get_option('polkit')
install_polkit = false

View File

@ -1434,16 +1434,3 @@ int warn_file_is_world_accessible(const char *filename, struct stat *st, const c
filename, st->st_mode & 07777);
return 0;
}
int rename_and_apply_smack_floor_label(const char *from, const char *to) {
int r = 0;
if (rename(from, to) < 0)
return -errno;
#if HAVE_SMACK_RUN_LABEL
r = mac_smack_apply(to, SMACK_ATTR_ACCESS, SMACK_FLOOR_LABEL);
if (r < 0)
return r;
#endif
return r;
}

View File

@ -124,5 +124,3 @@ static inline int read_nul_string(FILE *f, size_t limit, char **ret) {
int safe_fgetc(FILE *f, char *ret);
int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line);
int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);

View File

@ -322,7 +322,7 @@ int mac_smack_setup(bool *loaded_policy) {
return 0;
}
#ifdef SMACK_RUN_LABEL
#if HAVE_SMACK_RUN_LABEL
r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
if (r < 0)
log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m");

View File

@ -32,6 +32,7 @@
#include "proc-cmdline.h"
#include "pwquality-util.h"
#include "random-util.h"
#include "smack-util.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"

View File

@ -278,7 +278,7 @@ static int symlink_controller(const char *target, const char *alias) {
if (r < 0)
return log_error_errno(r, "Failed to create symlink %s: %m", a);
#ifdef SMACK_RUN_LABEL
#if HAVE_SMACK_RUN_LABEL
const char *p;
p = strjoina("/sys/fs/cgroup/", target);

View File

@ -284,3 +284,16 @@ int mac_smack_copy(const char *dest, const char *src) {
return 0;
}
#endif
int rename_and_apply_smack_floor_label(const char *from, const char *to) {
int r = 0;
if (rename(from, to) < 0)
return -errno;
#if HAVE_SMACK_RUN_LABEL
r = mac_smack_apply(to, SMACK_ATTR_ACCESS, SMACK_FLOOR_LABEL);
if (r < 0)
return r;
#endif
return r;
}

View File

@ -44,3 +44,5 @@ int mac_smack_apply(const char *path, SmackAttr attr, const char *label);
int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label);
int mac_smack_apply_pid(pid_t pid, const char *label);
int mac_smack_copy(const char *dest, const char *src);
int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);