diff options
-rw-r--r-- | src/udev/label.c | 153 | ||||
-rw-r--r-- | src/udev/label.h | 11 | ||||
-rw-r--r-- | src/udev/mkdir.c | 16 | ||||
-rw-r--r-- | src/udev/mkdir.h | 4 |
4 files changed, 0 insertions, 184 deletions
diff --git a/src/udev/label.c b/src/udev/label.c index 7e8d8f9277..1ab40f4bba 100644 --- a/src/udev/label.c +++ b/src/udev/label.c @@ -146,43 +146,6 @@ void label_finish(void) { #endif } -int label_get_create_label_from_exe(const char *exe, char **label) { - - int r = 0; - -#ifdef HAVE_SELINUX - security_context_t mycon = NULL, fcon = NULL; - security_class_t sclass; - - if (!use_selinux()) { - *label = NULL; - return 0; - } - - r = getcon(&mycon); - if (r < 0) - goto fail; - - r = getfilecon(exe, &fcon); - if (r < 0) - goto fail; - - sclass = string_to_security_class("process"); - r = security_compute_create(mycon, fcon, sclass, (security_context_t *) label); - if (r == 0) - log_debug("SELinux Socket context for %s will be set to %s", exe, *label); - -fail: - if (r < 0 && security_getenforce() == 1) - r = -errno; - - freecon(mycon); - freecon(fcon); -#endif - - return r; -} - int label_context_set(const char *path, mode_t mode) { int r = 0; @@ -212,24 +175,6 @@ int label_context_set(const char *path, mode_t mode) { return r; } -int label_socket_set(const char *label) { - -#ifdef HAVE_SELINUX - if (!use_selinux()) - return 0; - - if (setsockcreatecon((security_context_t) label) < 0) { - log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG, - "Failed to set SELinux context (%s) on socket: %m", label); - - if (security_getenforce() == 1) - return -errno; - } -#endif - - return 0; -} - void label_context_clear(void) { #ifdef HAVE_SELINUX @@ -240,26 +185,6 @@ void label_context_clear(void) { #endif } -void label_socket_clear(void) { - -#ifdef HAVE_SELINUX - if (!use_selinux()) - return; - - setsockcreatecon(NULL); -#endif -} - -void label_free(const char *label) { - -#ifdef HAVE_SELINUX - if (!use_selinux()) - return; - - freecon((security_context_t) label); -#endif -} - int label_mkdir(const char *path, mode_t mode, bool apply) { /* Creates a directory and labels it according to the SELinux policy */ @@ -309,81 +234,3 @@ skipped: #endif return mkdir(path, mode) < 0 ? -errno : 0; } - -int label_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 - int r; - security_context_t fcon = NULL; - const struct sockaddr_un *un; - char *path = NULL; - - assert(fd >= 0); - assert(addr); - assert(addrlen >= sizeof(sa_family_t)); - - if (!use_selinux() || !label_hnd) - goto skipped; - - /* Filter out non-local sockets */ - if (addr->sa_family != AF_UNIX) - goto skipped; - - /* Filter out anonymous sockets */ - if (addrlen < sizeof(sa_family_t) + 1) - goto skipped; - - /* Filter out abstract namespace sockets */ - un = (const struct sockaddr_un*) addr; - if (un->sun_path[0] == 0) - goto skipped; - - path = strndup(un->sun_path, addrlen - offsetof(struct sockaddr_un, sun_path)); - if (!path) - return -ENOMEM; - - if (path_is_absolute(path)) - r = selabel_lookup_raw(label_hnd, &fcon, path, S_IFSOCK); - else { - char *newpath; - - newpath = path_make_absolute_cwd(path); - - if (!newpath) { - free(path); - return -ENOMEM; - } - - r = selabel_lookup_raw(label_hnd, &fcon, newpath, S_IFSOCK); - free(newpath); - } - - if (r == 0) - r = setfscreatecon(fcon); - - if (r < 0 && errno != ENOENT) { - log_error("Failed to set security context %s for %s: %m", fcon, path); - - if (security_getenforce() == 1) { - r = -errno; - goto finish; - } - } - - r = bind(fd, addr, addrlen); - if (r < 0) - r = -errno; - -finish: - setfscreatecon(NULL); - freecon(fcon); - free(path); - - return r; - -skipped: -#endif - return bind(fd, addr, addrlen) < 0 ? -errno : 0; -} diff --git a/src/udev/label.h b/src/udev/label.h index 1220b18965..3d12ac2a92 100644 --- a/src/udev/label.h +++ b/src/udev/label.h @@ -30,18 +30,7 @@ void label_finish(void); int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs); -int label_socket_set(const char *label); -void label_socket_clear(void); - int label_context_set(const char *path, mode_t mode); void label_context_clear(void); -void label_free(const char *label); - -int label_get_create_label_from_exe(const char *exe, char **label); - int label_mkdir(const char *path, mode_t mode, bool apply); - -void label_retest_selinux(void); - -int label_bind(int fd, const struct sockaddr *addr, socklen_t addrlen); diff --git a/src/udev/mkdir.c b/src/udev/mkdir.c index 0e51b64f69..b9920ec207 100644 --- a/src/udev/mkdir.c +++ b/src/udev/mkdir.c @@ -30,10 +30,6 @@ #include "label.h" #include "util.h" -int mkdir_label(const char *path, mode_t mode) { - return label_mkdir(path, mode, true); -} - static int makedir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid, bool apply) { struct stat st; @@ -55,14 +51,6 @@ static int makedir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid, boo return 0; } -int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) { - return makedir_safe(path, mode, uid, gid, false); -} - -int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid) { - return makedir_safe(path, mode, uid, gid, true); -} - static int makedir_parents(const char *path, mode_t mode, bool apply) { struct stat st; const char *p, *e; @@ -141,7 +129,3 @@ static int makedir_p(const char *path, mode_t mode, bool apply) { int mkdir_p(const char *path, mode_t mode) { return makedir_p(path, mode, false); } - -int mkdir_p_label(const char *path, mode_t mode) { - return makedir_p(path, mode, true); -} diff --git a/src/udev/mkdir.h b/src/udev/mkdir.h index ce1c35e9ba..db3141ef59 100644 --- a/src/udev/mkdir.h +++ b/src/udev/mkdir.h @@ -22,11 +22,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -int mkdir_label(const char *path, mode_t mode); -int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid); -int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid); int mkdir_parents(const char *path, mode_t mode); int mkdir_parents_label(const char *path, mode_t mode); int mkdir_p(const char *path, mode_t mode); -int mkdir_p_label(const char *path, mode_t mode); #endif |