All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Haines <richard_c_haines@btinternet.com>
To: Stephen Smalley <sds@tycho.nsa.gov>,
	"selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>
Subject: Re: [RFC PATCH V2] libselinux: Add selinux_restorecon function
Date: Thu, 1 Oct 2015 15:18:47 +0000 (UTC)	[thread overview]
Message-ID: <212239354.5552563.1443712727654.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <560AF385.1090407@tycho.nsa.gov>






> On Tuesday, 29 September 2015, 21:25, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> > On 09/27/2015 08:06 AM, Richard Haines wrote:
>>  The selinux_restorecon(3) man page details this function that relies
>>  on the selabel_digest(3) function available from [1] (as not yet
>>  part of upstream libselinux).
>> 
>>  It has been built using the work from Android where an SHA1 hash
>>  of the specfiles is held in an extended attribute to enhance
>>  performance. Also contains components from policycoreutils/setfiles.
>> 
>>  The utils/selinux_restorecon.c utility demonstrates the functionality.
>> 
>>  [1] http://marc.info/?l=selinux&m=144274383217343&w=2
>> 
>>  Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>

>>  ---
------------ snip --------------
>>  +
>>  +extern int selinux_restorecon(const char **pathname_list,
>>  +                    const char **exclude_list,
>>  +                    const char *fc_path,
>>  +                    unsigned int restorecon_flags);
> 

> This is a more cumbersome interface for typical users than the Android one.

To make this easier would you prefer it to just take a single pathname and the
flags (and maybe the fc_path as well, or add another interface to take it as
discussed below)

The only reason I put the exclude_list is to allow filesystems that don't have
xattr support to be excluded by the caller. This could probably be resolved by
always setting the FTS_XDEV flag with the caller ensuring they cover their
relevant filesystems.

---------------- snip ----------------------

>>  +    fc_sehandle = selabel_open(SELABEL_CTX_FILE, fc_opts, 
> NUM_SELABEL_OPTS);
>>  +    if (!fc_sehandle) {
>>  +        selinux_log(SELINUX_ERROR,
>>  +                "Error obtaining file context handle: %s\n",
>>  +                            strerror(errno));
>>  +        return -1;
>>  +    }
> 
> Android only does this once, not on every call to restorecon.
> Caller that wants to use selabel_open() itself with custom options can 
> use selinux_android_set_sethandle() after selabel_open() call; 

> otherwise, callers don't ever have to specify selabel_open() args.

I could implement a similar interface to selinux_android_file_context_handle
(I guess that is what you are referring to) that would also take the fc_path
if this would be useful, it then keep selinux_restorecon simple and in line
with Android.

> 

  reply	other threads:[~2015-10-01 15:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-27 12:06 [RFC PATCH V2] libselinux: Add selinux_restorecon function Richard Haines
2015-09-27 22:24 ` Nir Soffer
2015-09-28 14:00   ` Richard Haines
2015-09-29 20:24 ` Stephen Smalley
2015-10-01 15:18   ` Richard Haines [this message]
2015-10-09 20:02     ` Stephen Smalley

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=212239354.5552563.1443712727654.JavaMail.yahoo@mail.yahoo.com \
    --to=richard_c_haines@btinternet.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.