some selinux modernizations (#36955)

This commit is contained in:
Yu Watanabe
2025-04-03 01:30:03 +09:00
committed by GitHub
3 changed files with 44 additions and 43 deletions
+6 -6
View File
@@ -407,14 +407,14 @@ int mac_selinux_apply_fd(int fd, const char *path, const char *label) {
return 0;
}
int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
int mac_selinux_get_create_label_from_exe(const char *exe, char **ret_label) {
#if HAVE_SELINUX
_cleanup_freecon_ char *mycon = NULL, *fcon = NULL;
security_class_t sclass;
int r;
assert(exe);
assert(label);
assert(ret_label);
r = selinux_init(/* force= */ false);
if (r < 0)
@@ -436,14 +436,14 @@ int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
if (sclass == 0)
return -ENOSYS;
return RET_NERRNO(security_compute_create_raw(mycon, fcon, sclass, label));
return RET_NERRNO(security_compute_create_raw(mycon, fcon, sclass, ret_label));
#else
return -EOPNOTSUPP;
#endif
}
int mac_selinux_get_our_label(char **ret) {
assert(ret);
int mac_selinux_get_our_label(char **ret_label) {
assert(ret_label);
#if HAVE_SELINUX
int r;
@@ -460,7 +460,7 @@ int mac_selinux_get_our_label(char **ret) {
if (!con)
return -EOPNOTSUPP;
*ret = TAKE_PTR(con);
*ret_label = TAKE_PTR(con);
return 0;
#else
return -EOPNOTSUPP;
+3 -3
View File
@@ -35,9 +35,9 @@ int mac_selinux_fix_full(int atfd, const char *inode_path, const char *label_pat
int mac_selinux_apply(const char *path, const char *label);
int mac_selinux_apply_fd(int fd, const char *path, const char *label);
int mac_selinux_get_create_label_from_exe(const char *exe, char **label);
int mac_selinux_get_our_label(char **label);
int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **label);
int mac_selinux_get_create_label_from_exe(const char *exe, char **ret_label);
int mac_selinux_get_our_label(char **ret_label);
int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **ret_label);
int mac_selinux_create_file_prepare_at(int dirfd, const char *path, mode_t mode);
static inline int mac_selinux_create_file_prepare(const char *path, mode_t mode) {