From: KaiGai Kohei <kaigai@kaigai.gr.jp>
To: busybox@busybox.net, selinux@tycho.nsa.gov
Cc: rob@landley.net, dwalsh@redhat.com, russell@coker.com.au,
busybox@kaigai.gr.jp
Subject: [PATCH 6/8] busybox -- libselinux utilities applets
Date: Thu, 25 Jan 2007 23:44:52 +0900 [thread overview]
Message-ID: <45B8C264.5090402@kaigai.gr.jp> (raw)
In-Reply-To: <45B8C039.10907@kaigai.gr.jp>
[-- Attachment #1: Type: text/plain, Size: 267 bytes --]
[6/8] busybox-libselinux-06-togglesebool.patch
togglesebool - flip the current value of a SELinux
boolean variable.
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>
[-- Attachment #2: busybox-libselinux-06-togglesebool.patch --]
[-- Type: text/x-patch, Size: 2767 bytes --]
Index: selinux/togglesebool.c
===================================================================
--- selinux/togglesebool.c (revision 0)
+++ selinux/togglesebool.c (revision 0)
@@ -0,0 +1,106 @@
+/*
+ * togglesebool
+ *
+ * Based on libselinux 1.33.1
+ * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
+ *
+ * Copyright 1999-2004 Gentoo Technologies, Inc.
+ * Distributed under the terms of the GNU General Public License v2
+ * $Header: /var/cvsroot/gentoo-projects/hardened/policycoreutils-extra/src/toggle_bool.c,v 1.2 2004/06/18 04:09:04 pebenito Exp $
+ */
+
+#include "busybox.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <errno.h>
+#include <selinux/selinux.h>
+#include <syslog.h>
+#include <pwd.h>
+#include <string.h>
+
+/* Attempt to rollback the transaction. No need to check error
+ codes since this is rolling back something that blew up. */
+static void rollback(int argc, char **argv)
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ security_set_boolean(argv[i],
+ security_get_boolean_active(argv[i]));
+ exit(1);
+}
+
+int togglesebool_main(int argc, char **argv)
+{
+
+ int rc, i, commit = 0;
+
+ if (is_selinux_enabled() <= 0) {
+ bb_error_msg_and_die("SELinux is disabled");
+ }
+
+ if (argc < 2) {
+ bb_show_usage();
+ }
+
+ for (i = 1; i < argc; i++) {
+ printf("%s: ", argv[i]);
+ rc = security_get_boolean_active(argv[i]);
+ switch (rc) {
+ case 1:
+ if (security_set_boolean(argv[i], 0) >= 0) {
+ printf("inactive\n");
+ commit++;
+ } else {
+ printf("%s - rolling back all changes\n",
+ strerror(errno));
+ rollback(i, argv);
+ }
+ break;
+ case 0:
+ if (security_set_boolean(argv[i], 1) >= 0) {
+ printf("active\n");
+ commit++;
+ } else {
+ printf("%s - rolling back all changes\n",
+ strerror(errno));
+ rollback(i, argv);
+ }
+ break;
+ default:
+ if (errno == ENOENT)
+ printf
+ ("Boolean does not exist - rolling back all changes.\n");
+ else
+ printf("%s - rolling back all changes.\n",
+ strerror(errno));
+ rollback(i, argv);
+ break; /* Not reached. */
+ }
+ }
+
+ if (commit > 0) {
+ if (security_commit_booleans() < 0) {
+ printf("Commit failed. (%s) No change to booleans.\n",
+ strerror(errno));
+ } else {
+ /* syslog all the changes */
+ struct passwd *pwd = getpwuid(getuid());
+ for (i = 1; i < argc; i++) {
+ if (pwd && pwd->pw_name)
+ syslog(LOG_NOTICE,
+ "The %s policy boolean was toggled by %s",
+ argv[i], pwd->pw_name);
+ else
+ syslog(LOG_NOTICE,
+ "The %s policy boolean was toggled by uid:%d",
+ argv[i], getuid());
+
+ }
+ return 0;
+ }
+ }
+ return 1;
+}
next prev parent reply other threads:[~2007-01-25 14:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-25 14:35 [PATCH 0/8] busybox -- libselinux utilities applets KaiGai Kohei
2007-01-25 14:44 ` [PATCH 2/8] " KaiGai Kohei
[not found] ` <200701270054.34561.vda.linux@googlemail.com>
2007-01-29 13:47 ` KaiGai Kohei
2007-01-25 14:44 ` [PATCH 3/8] " KaiGai Kohei
2007-01-25 14:44 ` [PATCH 4/8] " KaiGai Kohei
[not found] ` <200701270059.34996.vda.linux@googlemail.com>
2007-01-29 14:06 ` KaiGai Kohei
[not found] ` <20070130092817.GA32212@aon.at>
2007-01-31 12:13 ` [busybox:00323] " KaiGai Kohei
2007-01-25 14:44 ` [PATCH 5/8] " KaiGai Kohei
2007-01-26 20:10 ` Christopher J. PeBenito
2007-01-29 12:28 ` Russell Coker
2007-01-29 14:44 ` KaiGai Kohei
2007-01-25 14:44 ` KaiGai Kohei [this message]
2007-01-25 14:45 ` [PATCH 7/8] " KaiGai Kohei
[not found] ` <200701270050.27149.vda.linux@googlemail.com>
2007-01-29 13:43 ` KaiGai Kohei
2007-01-25 14:45 ` [PATCH 8/8] " KaiGai Kohei
2007-01-26 15:29 ` [PATCH 0/8] " KaiGai Kohei
2007-01-29 17:38 ` James Carter
2007-01-26 19:36 ` Christopher J. PeBenito
2007-01-29 13:31 ` KaiGai Kohei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45B8C264.5090402@kaigai.gr.jp \
--to=kaigai@kaigai.gr.jp \
--cc=busybox@busybox.net \
--cc=busybox@kaigai.gr.jp \
--cc=dwalsh@redhat.com \
--cc=rob@landley.net \
--cc=russell@coker.com.au \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.