[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 8/8] busybox -- libselinux utilities applets
From:       Denis Vlasenko <vda.linux () googlemail ! com>
Date:       2007-01-27 0:15:47
Message-ID: 200701270115.47942.vda.linux () googlemail ! com
[Download RAW message or body]

On Thursday 25 January 2007 15:45, KaiGai Kohei wrote:
> [8/8] busybox-libselinux-08-setenforce.patch
>   setenforce - modify the mode SELinux is running in Enforcing
>   mode or Permissive.
> 
> Signed-off-by: Hiroshi Shinji <shiroshi@my.email.ne.jp>
> Signed-off-by: KaiGai Kohei <kaigai@kaigai.gr.jp>
> 
> --
> KaiGai Kohei <kaigai@kaigai.gr.jp>

--- selinux/setenforce.cšššššššš(revision 0)
+++ selinux/setenforce.cšššššššš(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * setenforce
+ *
+ * Based on libselinux 1.33.1
+ * Port to BusyBox šHiroshi Shinji <shiroshi@my.email.ne.jp>
+ *
+ */
+
+#include "busybox.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <strings.h>
+#include <selinux/selinux.h>
+
+int setenforce_main(int argc, char **argv)
+{
+šššššššint rc = 0;
+šššššššif (argc != 2) {
+šššššššššššššššbb_show_usage();
+ššššššš}
+
+šššššššif (is_selinux_enabled() <= 0) {
+šššššššššššššššbb_error_msg("SELinux is disabled");
+šššššššššššššššreturn 1;
+ššššššš}
+šššššššif (strlen(argv[1]) == 1 && (argv[1][0] == '0' || argv[1][0] == '1')) {

You mean, "if ((unsigned char)(argv[1][0]-'0') <= 1 && !argv[1][1])..." ?

+šššššššššššššššrc = security_setenforce(atoi(argv[1]));
+ššššššš} else {
+šššššššššššššššif (strcasecmp(argv[1], "enforcing") == 0) {
+šššššššššššššššššššššššrc = security_setenforce(1);
+ššššššššššššššš} else if (strcasecmp(argv[1], "permissive") == 0) {
+šššššššššššššššššššššššrc = security_setenforce(0);
+ššššššššššššššš} else
+šššššššššššššššššššššššbb_show_usage();
+ššššššš}
+šššššššif (rc < 0) {
+šššššššššššššššbb_error_msg("setenforce() failed");

If errno is set to meaningful value, bb_perror_msg() gives more
informative messages (appends ": <strerror>".

+šššššššššššššššreturn 2;
+ššššššš}
+šššššššreturn 0;
+}
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic