All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: SE Linux <selinux@tycho.nsa.gov>
Subject: Patch to getdefaultcon to print just the correct match and add verbose option
Date: Wed, 04 Mar 2009 15:41:37 -0500	[thread overview]
Message-ID: <49AEE781.5030301@redhat.com> (raw)

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I really want to rename this to selinuxdefaultcon, which is what we ship
in Fedora.

Also exit with proper error on failure.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkmu54AACgkQrlYvE4MpobNoZACdHgQDP2Hp/KDBpGCD7G08HjOX
p68An25Uu83SlOqjKyy9EG8ZgdIcuTCB
=L6UU
-----END PGP SIGNATURE-----

[-- Attachment #2: libselinux-getdefaultcon.patch --]
[-- Type: text/plain, Size: 1144 bytes --]

--- nsalibselinux/utils/getdefaultcon.c	2008-08-28 09:34:24.000000000 -0400
+++ libselinux-2.0.78/utils/getdefaultcon.c	2009-03-04 15:23:52.000000000 -0500
@@ -22,8 +22,9 @@
 	security_context_t usercon = NULL, cur_context = NULL;
 	char *user = NULL, *level = NULL, *role=NULL, *seuser=NULL, *dlevel=NULL;
 	int ret, opt;
+	int verbose = 0;
 
-	while ((opt = getopt(argc, argv, "l:r:")) > 0) {
+	while ((opt = getopt(argc, argv, "l:r:v")) > 0) {
 		switch (opt) {
 		case 'l':
 			level = strdup(optarg);
@@ -31,6 +32,9 @@
 		case 'r':
 			role = strdup(optarg);
 			break;
+		case 'v':
+			verbose = 1;
+			break;
 		default:
 			usage(argv[0], "invalid option", 1);
 		}
@@ -66,9 +70,13 @@
 	}
 	if (ret < 0)
 		perror(argv[0]);
-	else
-		printf("%s: %s from %s %s %s %s -> %s\n", argv[0], user, cur_context, seuser, role, level, usercon);
-
+	else {
+		if (verbose) {
+			printf("%s: %s from %s %s %s %s -> %s\n", argv[0], user, cur_context, seuser, role, level, usercon);
+		} else {
+			printf("%s", usercon);
+		}
+	}
 
 	free(role);
 	free(seuser);
@@ -76,5 +84,5 @@
 	free(dlevel);
 	free(usercon);
 
-	return 0;
+	return ret >= 0;
 }

[-- Attachment #3: libselinux-getdefaultcon.patch.sig --]
[-- Type: application/pgp-signature, Size: 72 bytes --]

             reply	other threads:[~2009-03-04 20:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04 20:41 Daniel J Walsh [this message]
2009-05-14 20:05 ` Patch to getdefaultcon to print just the correct match and add verbose option Chad Sellers
2009-05-18 15:32   ` Joshua Brindle

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=49AEE781.5030301@redhat.com \
    --to=dwalsh@redhat.com \
    --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.