From 1203c9bf2f63938f7766a3022a9659b25712824f Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 11 Mar 2007 22:16:02 +0000 Subject: next portion of selinux updates: chcon, runcon. From Yuichi Nakamura KaiGai Kohei --- libbb/Kbuild | 1 + libbb/selinux_common.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 libbb/selinux_common.c (limited to 'libbb') diff --git a/libbb/Kbuild b/libbb/Kbuild index a53b17f44..ffded6a68 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild @@ -106,6 +106,7 @@ lib-$(CONFIG_SU) += correct_password.o lib-$(CONFIG_LOGIN) += correct_password.o lib-$(CONFIG_DF) += find_mount_point.o lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o +lib-$(CONFIG_SELINUX) += selinux_common.o # We shouldn't build xregcomp.c if we don't need it - this ensures we don't # require regex.h to be in the include dir even if we don't need it thereby diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c new file mode 100644 index 000000000..70d63a465 --- /dev/null +++ b/libbb/selinux_common.c @@ -0,0 +1,30 @@ +/* + * libbb/selinux_common.c + * -- common SELinux utility functions + * + * Copyright 2007 KaiGai Kohei + */ +#include "busybox.h" +#include + +context_t set_security_context_component(security_context_t cur_context, + char *user, char *role, char *type, char *range) +{ + context_t con = context_new(cur_context); + if (!con) + return NULL; + + if (user && context_user_set(con, user)) + goto error; + if (type && context_type_set(con, type)) + goto error; + if (range && context_range_set(con, range)) + goto error; + if (role && context_role_set(con, role)) + goto error; + return con; + +error: + context_free(con); + return NULL; +} -- cgit v1.2.3