mirror of
https://github.com/systemd/systemd.git
synced 2025-02-23 13:57:33 +03:00
tree-wide: get rid of selinux_context_t (#3732)
9eb9c93275
deprecated selinux_context_t. Replace with a simple char* everywhere.
Alternative fix for #3719.
This commit is contained in:
parent
8d00539d99
commit
2ed968802c
@ -41,10 +41,10 @@
|
||||
#include "util.h"
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(security_context_t, freecon);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(context_t, context_free);
|
||||
|
||||
#define _cleanup_security_context_free_ _cleanup_(freeconp)
|
||||
#define _cleanup_freecon_ _cleanup_(freeconp)
|
||||
#define _cleanup_context_free_ _cleanup_(context_freep)
|
||||
|
||||
static int cached_use = -1;
|
||||
@ -143,7 +143,7 @@ int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
|
||||
|
||||
r = lstat(path, &st);
|
||||
if (r >= 0) {
|
||||
_cleanup_security_context_free_ security_context_t fcon = NULL;
|
||||
_cleanup_freecon_ char* fcon = NULL;
|
||||
|
||||
r = selabel_lookup_raw(label_hnd, &fcon, path, st.st_mode);
|
||||
|
||||
@ -186,7 +186,7 @@ int mac_selinux_apply(const char *path, const char *label) {
|
||||
assert(path);
|
||||
assert(label);
|
||||
|
||||
if (setfilecon(path, (security_context_t) label) < 0) {
|
||||
if (setfilecon(path, label) < 0) {
|
||||
log_enforcing("Failed to set SELinux security context %s on path %s: %m", label, path);
|
||||
if (security_getenforce() > 0)
|
||||
return -errno;
|
||||
@ -199,7 +199,7 @@ int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
|
||||
int r = -EOPNOTSUPP;
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
_cleanup_security_context_free_ security_context_t mycon = NULL, fcon = NULL;
|
||||
_cleanup_freecon_ char *mycon = NULL, *fcon = NULL;
|
||||
security_class_t sclass;
|
||||
|
||||
assert(exe);
|
||||
@ -217,7 +217,7 @@ int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
|
||||
return -errno;
|
||||
|
||||
sclass = string_to_security_class("process");
|
||||
r = security_compute_create_raw(mycon, fcon, sclass, (security_context_t *) label);
|
||||
r = security_compute_create_raw(mycon, fcon, sclass, label);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
#endif
|
||||
@ -246,7 +246,7 @@ int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *
|
||||
int r = -EOPNOTSUPP;
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
_cleanup_security_context_free_ security_context_t mycon = NULL, peercon = NULL, fcon = NULL;
|
||||
_cleanup_freecon_ char *mycon = NULL, *peercon = NULL, *fcon = NULL;
|
||||
_cleanup_context_free_ context_t pcon = NULL, bcon = NULL;
|
||||
security_class_t sclass;
|
||||
const char *range = NULL;
|
||||
@ -296,7 +296,7 @@ int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *
|
||||
return -ENOMEM;
|
||||
|
||||
sclass = string_to_security_class("process");
|
||||
r = security_compute_create_raw(mycon, fcon, sclass, (security_context_t *) label);
|
||||
r = security_compute_create_raw(mycon, fcon, sclass, label);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
#endif
|
||||
@ -314,7 +314,7 @@ char* mac_selinux_free(char *label) {
|
||||
return NULL;
|
||||
|
||||
|
||||
freecon((security_context_t) label);
|
||||
freecon(label);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
@ -323,7 +323,7 @@ char* mac_selinux_free(char *label) {
|
||||
int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
_cleanup_security_context_free_ security_context_t filecon = NULL;
|
||||
_cleanup_freecon_ char *filecon = NULL;
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
@ -383,7 +383,7 @@ int mac_selinux_create_socket_prepare(const char *label) {
|
||||
|
||||
assert(label);
|
||||
|
||||
if (setsockcreatecon((security_context_t) label) < 0) {
|
||||
if (setsockcreatecon(label) < 0) {
|
||||
log_enforcing("Failed to set SELinux security context %s for sockets: %m", label);
|
||||
|
||||
if (security_getenforce() == 1)
|
||||
@ -411,7 +411,7 @@ int mac_selinux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen) {
|
||||
/* Binds a socket and label its file system object according to the SELinux policy */
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
_cleanup_security_context_free_ security_context_t fcon = NULL;
|
||||
_cleanup_freecon_ char *fcon = NULL;
|
||||
const struct sockaddr_un *un;
|
||||
bool context_changed = false;
|
||||
char *path;
|
||||
|
@ -191,7 +191,7 @@ int mac_selinux_generic_access_check(
|
||||
const char *tclass = NULL, *scon = NULL;
|
||||
struct audit_info audit_info = {};
|
||||
_cleanup_free_ char *cl = NULL;
|
||||
security_context_t fcon = NULL;
|
||||
char *fcon = NULL;
|
||||
char **cmdline = NULL;
|
||||
int r = 0;
|
||||
|
||||
|
@ -44,7 +44,7 @@ int mac_selinux_setup(bool *loaded_policy) {
|
||||
#ifdef HAVE_SELINUX
|
||||
int enforce = 0;
|
||||
usec_t before_load, after_load;
|
||||
security_context_t con;
|
||||
char *con;
|
||||
int r;
|
||||
union selinux_callback cb;
|
||||
bool initialized = false;
|
||||
|
@ -727,7 +727,7 @@ static void dispatch_message_real(
|
||||
*((char*) mempcpy(stpcpy(x, "_SELINUX_CONTEXT="), label, label_len)) = 0;
|
||||
IOVEC_SET_STRING(iovec[n++], x);
|
||||
} else {
|
||||
security_context_t con;
|
||||
char *con;
|
||||
|
||||
if (getpidcon(ucred->pid, &con) >= 0) {
|
||||
x = strjoina("_SELINUX_CONTEXT=", con);
|
||||
|
@ -2642,7 +2642,7 @@ static int inner_child(
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
if (arg_selinux_context)
|
||||
if (setexeccon((security_context_t) arg_selinux_context) < 0)
|
||||
if (setexeccon(arg_selinux_context) < 0)
|
||||
return log_error_errno(errno, "setexeccon(\"%s\") failed: %m", arg_selinux_context);
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user