All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Brindle <method@manicmethod.com>
To: Harry Ciao <qingtao.cao@windriver.com>
Cc: sds@tycho.nsa.gov, jmorris@namei.org, eparis@parisplace.org,
	selinux@tycho.nsa.gov
Subject: Re: [v0 PATCH 3/5] Handle the class in role_trans structure
Date: Wed, 23 Mar 2011 15:05:06 -0400	[thread overview]
Message-ID: <4D8A4462.7010404@manicmethod.com> (raw)
In-Reply-To: <1300847325-20308-7-git-send-email-qingtao.cao@windriver.com>

Harry Ciao wrote:
> From: Harry Ciao<harrytaurus2002@hotmail.com>
<snip>

> --- a/libsepol/src/write.c
> +++ b/libsepol/src/write.c
> @@ -462,11 +462,14 @@ static int cat_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
>   	return POLICYDB_SUCCESS;
>   }
>
> -static int role_trans_write(role_trans_t * r, struct policy_file *fp)
> +static int role_trans_write(policydb_t *p, struct policy_file *fp)
>   {
> +	role_trans_t *r = p->role_tr;
>   	role_trans_t *tr;
>   	uint32_t buf[3];
>   	size_t nel, items;
> +	int new_roletr = (p->policy_type == POLICY_KERN&&
> +			  p->policyvers>= POLICYDB_VERSION_ROLETRANS);
>
>   	nel = 0;
>   	for (tr = r; tr; tr = tr->next)
> @@ -478,9 +481,18 @@ static int role_trans_write(role_trans_t * r, struct policy_file *fp)
>   	for (tr = r; tr; tr = tr->next) {
>   		buf[0] = cpu_to_le32(tr->role);
>   		buf[1] = cpu_to_le32(tr->type);
> -		buf[2] = cpu_to_le32(tr->new_role);
> -		items = put_entry(buf, sizeof(uint32_t), 3, fp);
> -		if (items != 3)
> +		items = put_entry(buf, sizeof(uint32_t), 2, fp);
> +		if (items != 2)
> +			return POLICYDB_ERROR;
> +		if (new_roletr) {
> +			buf[0] = cpu_to_le32(tr->cclass);
> +			items = put_entry(buf, sizeof(uint32_t), 1, fp);
> +			if (items != 1)
> +				return POLICYDB_ERROR;
> +		}
> +		buf[0] = cpu_to_le32(tr->new_role);
> +		items = put_entry(buf, sizeof(uint32_t), 1, fp);
> +		if (items != 1)
>   			return POLICYDB_ERROR;
>   	}
>

You need to do something like range_write if you end up having a class set from 
the parser but you are building a lower version of the policy. The range write 
warning is:

         for (rt = p->range_tr; rt; rt = rt->next) {
                 if (!new_rangetr && rt->target_class != SECCLASS_PROCESS) {
                         if (!warning_issued)
                                 WARN(fp->handle, "Discarding range_transition "
                                      "rules for security classes other than "
                                      "\"process\"");
                         warning_issued = 1;
                         continue;
                 }

--
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.

  parent reply	other threads:[~2011-03-23 19:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23  2:28 v0 Add class support to the role_transition rule Harry Ciao
2011-03-23  2:28 ` [v0 PATCH 1/3] SELinux: Add class support to the role_trans structure Harry Ciao
2011-03-23 14:40   ` Eric Paris
2011-03-24  9:43     ` HarryCiao
2011-03-24 13:21       ` Stephen Smalley
2011-03-25  6:28         ` HarryCiao
2011-03-23  2:28 ` [v0 PATCH 2/3] SELinux: Compute role in newcontext for all classes Harry Ciao
2011-03-23 13:31   ` Stephen Smalley
2011-03-24  9:56     ` HarryCiao
2011-03-24 13:25       ` Stephen Smalley
2011-03-25  6:25         ` HarryCiao
2011-03-23 14:46   ` Eric Paris
2011-03-23  2:28 ` [v0 PATCH 3/3] SELinux: Write class field in role_trans_write Harry Ciao
2011-03-23 14:48   ` Eric Paris
2011-03-23 18:59     ` Joshua Brindle
2011-03-24 10:02       ` HarryCiao
2011-03-23  2:28 ` [v0 PATCH 1/5] Add class to role_trans & role_trans_rule Harry Ciao
2011-03-23  2:28 ` [v0 PATCH 2/5] Make role_transition parser to handle class field Harry Ciao
2011-03-23 19:30   ` Eric Paris
2011-03-23 19:41     ` Joshua Brindle
2011-03-23 20:14       ` Eric Paris
2011-03-23  2:28 ` [v0 PATCH 3/5] Handle the class in role_trans structure Harry Ciao
2011-03-23 13:26   ` Joshua Brindle
2011-03-23 19:05   ` Joshua Brindle [this message]
2011-03-24 10:36     ` HarryCiao
2011-03-23  2:28 ` [v0 PATCH 4/5] Handle the class in role_trans_rule structure Harry Ciao
2011-03-23  2:28 ` [v0 PATCH 5/5] Display the class in role_transition rule Harry Ciao
2011-03-23  8:21 ` v0 Add class support to the " Harry Ciao

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=4D8A4462.7010404@manicmethod.com \
    --to=method@manicmethod.com \
    --cc=eparis@parisplace.org \
    --cc=jmorris@namei.org \
    --cc=qingtao.cao@windriver.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.