All of lore.kernel.org
 help / color / mirror / Atom feed
* BusyBox: load_policy applet
@ 2007-03-23  6:15 Yuichi Nakamura
  2007-03-23 12:49 ` Stephen Smalley
  0 siblings, 1 reply; 34+ messages in thread
From: Yuichi Nakamura @ 2007-03-23  6:15 UTC (permalink / raw)
  To: busybox; +Cc: busybox, vda.linux, selinux

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]


Attached patch is to support load_policy for BusyBox.
load_policy is a program to load SELinux policy to kernel.
This applet is very important for SELinux, 
because SELinux is not activated until policy is loaded.

And this applet is _not_ based on latest load_policy, 
is based on old load_policy.
This is because the size of latest load_policy is bigger than old one,
and old load_policy has enough feature for embedded device.

Please review and consider merging.
Regards,
-- 
Yuichi Nakamura
Hitachi Software Engineering Co., Ltd.
SELinux Policy Editor: http://seedit.sourceforge.net/

[-- Attachment #2: busybox-load_policy.v1.patch --]
[-- Type: application/octet-stream, Size: 3001 bytes --]

Index: include/usage.h
===================================================================
--- include/usage.h	(revision 18212)
+++ include/usage.h	(working copy)
@@ -1758,6 +1758,10 @@
        "$ ls -l /tmp/ls\n" \
        "lrwxrwxrwx    1 root     root            7 Apr 12 18:39 ls -> BusyBox*\n"
 
+#define load_policy_trivial_usage \
+       "[FILE]"
+#define load_policy_full_usage
+
 #define loadfont_trivial_usage \
        "< font"
 #define loadfont_full_usage \
Index: include/applets.h
===================================================================
--- include/applets.h	(revision 18212)
+++ include/applets.h	(working copy)
@@ -180,6 +180,7 @@ USE_SETARCH(APPLET_NOUSAGE(linux32, seta
 USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_FEATURE_INITRD(APPLET_NOUSAGE(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_NEVER))
 USE_LN(APPLET(ln, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
 USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER))
 USE_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
Index: selinux/load_policy.c
===================================================================
--- selinux/load_policy.c	(revision 0)
+++ selinux/load_policy.c	(revision 0)
@@ -0,0 +1,31 @@
+/*
+ * load_policy
+ * This implementation is based on old load_policy to be small.
+ * Author: Yuichi Nakamura <ynakam@hitachisoft.jp>
+ */
+#include "busybox.h"
+
+int load_policy_main(int argc, char *argv[]);
+int load_policy_main(int argc, char *argv[])
+{
+	int fd;
+	struct stat st;
+	void *data;
+	if(argc != 2) {
+		bb_show_usage();
+	}
+	
+	fd = xopen(argv[1], O_RDONLY);
+	if (fstat(fd, &st) < 0 ) {
+		bb_perror_msg_and_die("can't fstat");
+	}
+	data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+	if (data == MAP_FAILED) {
+		bb_perror_msg_and_die("can't mmap");
+	}
+	if (security_load_policy(data, st.st_size) < 0) {
+		bb_perror_msg_and_die("can't security_load_policy");
+	}
+		
+	return 0;
+}
Index: selinux/Config.in
===================================================================
--- selinux/Config.in	(revision 18212)
+++ selinux/Config.in	(working copy)
@@ -34,6 +34,13 @@ config GETSEBOOL
 	help
 	  Enable support to get SELinux boolean values.
 
+config LOAD_POLICY
+	bool "load_policy"
+	default n
+	depends on SELINUX
+	help
+	  Enable support to load SELinux policy.
+
 config MATCHPATHCON
 	bool "matchpathcon"
 	default n
Index: selinux/Kbuild
===================================================================
--- selinux/Kbuild	(revision 18212)
+++ selinux/Kbuild	(working copy)
@@ -9,6 +9,7 @@ lib-y:=
 lib-$(CONFIG_CHCON)		+= chcon.o
 lib-$(CONFIG_GETENFORCE)	+= getenforce.o
 lib-$(CONFIG_GETSEBOOL)		+= getsebool.o
+lib-$(CONFIG_LOAD_POLICY)	+= load_policy.o
 lib-$(CONFIG_MATCHPATHCON)	+= matchpathcon.o
 lib-$(CONFIG_RUNCON)		+= runcon.o
 lib-$(CONFIG_SELINUXENABLED)	+= selinuxenabled.o

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2007-03-28 14:11 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23  6:15 BusyBox: load_policy applet Yuichi Nakamura
2007-03-23 12:49 ` Stephen Smalley
2007-03-26  1:28   ` Yuichi Nakamura
2007-03-26 14:08     ` Separating libselinux/libsepol (Was: Re: BusyBox: load_policy applet) Stephen Smalley
2007-03-26 16:12       ` Christopher J. PeBenito
2007-03-26 16:35         ` Stephen Smalley
2007-03-27  0:59           ` Yuichi Nakamura
2007-03-27 12:15             ` Stephen Smalley
2007-03-28  1:57               ` KaiGai Kohei
2007-03-28  8:40                 ` Yuichi Nakamura
2007-03-28  9:12                   ` [busybox:00575] " KaiGai Kohei
2007-03-28 12:04                     ` Stephen Smalley
2007-03-28 12:34                       ` Joshua Brindle
2007-03-28 12:00                 ` Stephen Smalley
2007-03-28  2:19               ` Yuichi Nakamura
2007-03-27  2:58           ` Ryan Bradetich
2007-03-27 12:32             ` Christopher J. PeBenito
2007-03-26 16:37         ` Karl MacMillan
2007-03-26 20:13           ` Christopher J. PeBenito
2007-03-27 12:45             ` Stephen Smalley
2007-03-27 15:42               ` Christopher J. PeBenito
2007-03-27 15:48                 ` Stephen Smalley
2007-03-27 16:02                   ` Karl MacMillan
2007-03-27 18:43                     ` Christopher J. PeBenito
2007-03-27 18:47                       ` Stephen Smalley
2007-03-27 19:09                         ` Karl MacMillan
2007-03-27 19:32                           ` Christopher J. PeBenito
2007-03-27 20:31                       ` Ryan Bradetich
2007-03-28 10:26                       ` Russell Coker
2007-03-28 12:06                         ` Stephen Smalley
2007-03-28 14:11                           ` Russell Coker
2007-03-28 12:17                         ` Christopher J. PeBenito
2007-03-27 20:14                   ` Ryan Bradetich
2007-03-27 20:35                     ` Joshua Brindle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.