From: Steve Lawrence <slawrence@tresys.com>
To: Eric Paris <eparis@redhat.com>
Cc: "selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>,
"method@manicmethod.com" <method@manicmethod.com>,
"sds@tycho.nsa.gov" <sds@tycho.nsa.gov>
Subject: Re: [PATCH] checkpolicy: use #define for dismod selections
Date: Mon, 2 May 2011 14:43:50 -0400 [thread overview]
Message-ID: <4DBEFB66.1090300@tresys.com> (raw)
In-Reply-To: <1301333944.14296.20.camel@localhost.localdomain>
On 03/28/2011 01:39 PM, Eric Paris wrote:
> We just use random numbers to make menu selections. Use #defines and
> names that make some sense instead.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
>
> ---
>
> diff -up checkpolicy-2.0.23/test/dismod.c.eparis1 checkpolicy-2.0.23/test/dismod.c
> --- checkpolicy-2.0.23/test/dismod.c.eparis1 2010-12-21 16:35:45.000000000 -0500
> +++ checkpolicy-2.0.23/test/dismod.c 2011-03-23 13:58:31.561072307 -0400
> @@ -45,6 +45,14 @@
> #define le32_to_cpu(x) bswap_32(x)
> #endif
>
> +#define DISPLAY_AVBLOCK_COND_AVTAB 0
> +#define DISPLAY_AVBLOCK_UNCOND_AVTAB 1
> +#define DISPLAY_AVBLOCK_ROLE_TYPE_NODE 2 /* unused? */
> +#define DISPLAY_AVBLOCK_ROLE_TRANS 3
> +#define DISPLAY_AVBLOCK_ROLE_ALLOW 4
> +#define DISPLAY_AVBLOCK_REQUIRES 5
> +#define DISPLAY_AVBLOCK_DECLARES 6
> +
> static policydb_t policydb;
> extern unsigned int ss_initialized;
>
> @@ -571,7 +579,7 @@ int display_avdecl(avrule_decl_t * decl,
> fprintf(out_fp, "decl %u:%s\n", decl->decl_id,
> (decl->enabled ? " [enabled]" : ""));
> switch (field) {
> - case 0:{
> + case DISPLAY_AVBLOCK_COND_AVTAB:{
> cond_list_t *cond = decl->cond_list;
> avrule_t *avrule;
> while (cond) {
> @@ -599,7 +607,7 @@ int display_avdecl(avrule_decl_t * decl,
> }
> break;
> }
> - case 1:{
> + case DISPLAY_AVBLOCK_UNCOND_AVTAB:{
> avrule_t *avrule = decl->avrules;
> if (avrule == NULL) {
> fprintf(out_fp, " <empty>\n");
> @@ -613,26 +621,26 @@ int display_avdecl(avrule_decl_t * decl,
> }
> break;
> }
> - case 2:{ /* role_type_node */
> + case DISPLAY_AVBLOCK_ROLE_TYPE_NODE:{ /* role_type_node */
> break;
> }
> - case 3:{
> + case DISPLAY_AVBLOCK_ROLE_TRANS:{
> display_role_trans(decl->role_tr_rules, policy, out_fp);
> break;
> }
> - case 4:{
> + case DISPLAY_AVBLOCK_ROLE_ALLOW:{
> display_role_allow(decl->role_allow_rules, policy,
> out_fp);
> break;
> }
> - case 5:{
> + case DISPLAY_AVBLOCK_REQUIRES:{
> if (display_scope_index
> (&decl->required, policy, out_fp)) {
> return -1;
> }
> break;
> }
> - case 6:{
> + case DISPLAY_AVBLOCK_DECLARES:{
> if (display_scope_index
> (&decl->declared, policy, out_fp)) {
> return -1;
> @@ -861,15 +869,16 @@ int main(int argc, char **argv)
> fgets(ans, sizeof(ans), stdin);
> switch (ans[0]) {
>
> - case '1':{
> - fprintf(out_fp, "unconditional avtab:\n");
> - display_avblock(1, RENDER_UNCONDITIONAL,
> - &policydb, out_fp);
> - break;
> - }
> + case '1':
> + fprintf(out_fp, "unconditional avtab:\n");
> + display_avblock(DISPLAY_AVBLOCK_UNCOND_AVTAB,
> + RENDER_UNCONDITIONAL, &policydb,
> + out_fp);
> + break;
> case '2':
> fprintf(out_fp, "conditional avtab:\n");
> - display_avblock(0, RENDER_UNCONDITIONAL, &policydb,
> + display_avblock(DISPLAY_AVBLOCK_COND_AVTAB,
> + RENDER_UNCONDITIONAL, &policydb,
> out_fp);
> break;
> case '3':
> @@ -892,11 +901,13 @@ int main(int argc, char **argv)
> break;
> case '7':
> fprintf(out_fp, "role transitions:\n");
> - display_avblock(3, 0, &policydb, out_fp);
> + display_avblock(DISPLAY_AVBLOCK_ROLE_TRANS, 0,
> + &policydb, out_fp);
> break;
> case '8':
> fprintf(out_fp, "role allows:\n");
> - display_avblock(4, 0, &policydb, out_fp);
> + display_avblock(DISPLAY_AVBLOCK_ROLE_ALLOW, 0,
> + &policydb, out_fp);
> break;
> case '9':
> display_policycon(&policydb, out_fp);
> @@ -906,11 +917,13 @@ int main(int argc, char **argv)
> break;
> case 'a':
> fprintf(out_fp, "avrule block requirements:\n");
> - display_avblock(5, 0, &policydb, out_fp);
> + display_avblock(DISPLAY_AVBLOCK_REQUIRES, 0,
> + &policydb, out_fp);
> break;
> case 'b':
> fprintf(out_fp, "avrule block declarations:\n");
> - display_avblock(6, 0, &policydb, out_fp);
> + display_avblock(DISPLAY_AVBLOCK_DECLARES, 0,
> + &policydb, out_fp);
> break;
> case 'c':
> display_policycaps(&policydb, out_fp);
>
>
>
Applied in checkpolicy-2.0.25.
Thanks.
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
prev parent reply other threads:[~2011-05-02 18:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-28 17:39 [PATCH] checkpolicy: use #define for dismod selections Eric Paris
2011-05-02 18:43 ` Steve Lawrence [this message]
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=4DBEFB66.1090300@tresys.com \
--to=slawrence@tresys.com \
--cc=eparis@redhat.com \
--cc=method@manicmethod.com \
--cc=sds@tycho.nsa.gov \
--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.