From 9bfe466b61cba71512473509e178e8b0a2fc3fe5 Mon Sep 17 00:00:00 2001 From: xroche Date: Mon, 13 Oct 2014 16:09:05 +0200 Subject: [PATCH] Integration of Smack LSM in toybox Link against libattr and libsmack. Change-Id: I8602077c69376c0a88f534a0514bf96dbd4a209e Signed-off-by: Jan Cybulski --- scripts/make.sh | 8 +++++++- toys/lsb/mknod.c | 4 ++++ toys/pending/ps.c | 4 ++++ toys/posix/cp.c | 4 ++++ toys/posix/id.c | 4 ++++ toys/posix/ls.c | 4 ++++ toys/posix/mkdir.c | 4 ++++ toys/posix/mkfifo.c | 4 ++++ 8 files changed, 35 insertions(+), 1 deletion(-) diff --git a/scripts/make.sh b/scripts/make.sh index 4cb1927..6a137d5 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -9,6 +9,12 @@ source ./configure [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=".config" +if [ ! -z "$USE_SMACK" ] +then + echo "Using Smack" + CFLAGS="$CFLAGS -DUSE_SMACK" +fi + # Since each cc invocation is short, launch half again as many processes # as we have processors so they don't exit faster than we can start them. [ -z "$CPUS" ] && @@ -90,7 +96,7 @@ then # for it. > generated/optlibs.dat - for i in util crypt m resolv selinux + for i in util crypt m resolv selinux smack attr do echo "int main(int argc, char *argv[]) {return 0;}" | \ ${CROSS_COMPILE}${CC} $CFLAGS -xc - -o /dev/null -Wl,--as-needed -l$i > /dev/null 2>/dev/null && diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c index 35a127d..ae6876a 100644 --- a/toys/lsb/mknod.c +++ b/toys/lsb/mknod.c @@ -21,6 +21,10 @@ config MKNOD #define FOR_mknod #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( char *m; ) diff --git a/toys/pending/ps.c b/toys/pending/ps.c index 3427557..43db01e 100644 --- a/toys/pending/ps.c +++ b/toys/pending/ps.c @@ -24,6 +24,10 @@ config PS #define FOR_ps #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( struct arg_list *llist_o; unsigned screen_width; diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 2959f67..0502c25 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -86,6 +86,10 @@ config INSTALL #define FOR_cp #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( // install's options char *group; diff --git a/toys/posix/id.c b/toys/posix/id.c index 353aa04..c3fe609 100644 --- a/toys/posix/id.c +++ b/toys/posix/id.c @@ -62,6 +62,10 @@ config WHOAMI #define FOR_id #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( int do_u, do_n, do_G, do_Z, is_groups; ) diff --git a/toys/posix/ls.c b/toys/posix/ls.c index a924137..aba56e6 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -47,6 +47,10 @@ config LS_COLOR #define FOR_ls #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + // test sst output (suid/sticky in ls flaglist) // ls -lR starts .: then ./subdir: diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c index 739f961..4c39ae0 100644 --- a/toys/posix/mkdir.c +++ b/toys/posix/mkdir.c @@ -22,6 +22,10 @@ config MKDIR #define FOR_mkdir #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( char *arg_mode; ) diff --git a/toys/posix/mkfifo.c b/toys/posix/mkfifo.c index 15fab70..ea1fe30 100644 --- a/toys/posix/mkfifo.c +++ b/toys/posix/mkfifo.c @@ -18,6 +18,10 @@ config MKFIFO #define FOR_mkfifo #include "toys.h" +#ifdef USE_SMACK +#include +#endif //USE_SMACK + GLOBALS( char *m_string; mode_t mode; -- 2.7.4