Patch to getdefaultcon to print just the correct match and add verbose option
-----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-----
utils/getdefaultcon.c +13 -5
@@ -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 ; }
Chad Sellers
Acked-byQuoted 59 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I 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.orgiEYEARECAAYFAkmu54AACgkQrlYvE4MpobNoZACdHgQDP2Hp/KDBpGCD7G08HjOX p68An25Uu83SlOqjKyy9EG8ZgdIcuTCB
=L6UU
-----END PGP SIGNATURE-----utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +2
-2-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);utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +0
-0@@ -31,6 +32,9 @@case 'r':
role = strdup(optarg);
break;utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +3
-0+ case 'v': + verbose = 1; + break;default:
usage(argv[0], "invalid option", 1);
}utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +7
-3@@ -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);
utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 line 88
Quoted 6 lines
utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +1
-1@@ -76,5 +84,5 @@ free(dlevel); free(usercon); - return 0; + return ret >= 0; }
Looks good to me.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 64 lines · Chad Sellers
Quoted 62 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I 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.orgiEYEARECAAYFAkmu54AACgkQrlYvE4MpobNoZACdHgQDP2Hp/KDBpGCD7G08HjOX p68An25Uu83SlOqjKyy9EG8ZgdIcuTCB
=L6UU
-----END PGP SIGNATURE-----utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +2
-2-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);utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +0
-0@@ -31,6 +32,9 @@case 'r':
role = strdup(optarg);
break;utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +3
-0+ case 'v': + verbose = 1; + break;default:
usage(argv[0], "invalid option", 1);
}utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +7
-3@@ -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);utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +0
-0@@ -76,5 +84,5 @@ free(dlevel); free(usercon);
Quoted 8 lines
utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 line 88
Quoted 3 lines
utils/getdefaultcon.c 2009-03-04 15:23:52.000000000 renamed from utils/getdefaultcon.c 2008-08-28 09:34:24.000000000 -0400 +1
-1- return 0; + return ret >= 0; }Looks good to me.
Acked-by Chad Sellers <[email protected]>
Merged in libselinux-2.0.81
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.