All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Nicolas Iooss <nicolas.iooss@m4x.org>,
	Jason Zaman <jason@perfinion.com>,
	selinux <selinux@tycho.nsa.gov>
Subject: Re: genhomedircon USERID and USERNAME patches
Date: Tue, 12 Apr 2016 08:57:02 -0400	[thread overview]
Message-ID: <570CF09E.10100@tycho.nsa.gov> (raw)
In-Reply-To: <CAJfZ7=mZnyW8-+BH02VJX7fBONyJTOHjHmkqByidz8cWw37Lcg@mail.gmail.com>

On 04/11/2016 05:44 PM, Nicolas Iooss wrote:
> On Fri, Apr 8, 2016 at 6:05 PM, Jason Zaman <jason@perfinion.com
> <mailto:jason@perfinion.com>> wrote:
> 
>     Hi all,
> 
>     I finally finished adding more templates to genhomedircon and a lot
>     of general
>     cleanups.
> 
>     The first few patches refactor the templating functions so they are
>     smaller and
>     easier to add new. All the common bits were taken out and they all
>     take the
>     user_entry_t struct instead of passing args one by one.
> 
>     The last three patches add the new templating types. I went with
>     %{USERID} and
>     %{USERNAME}. They now have a clear start and end unlike USER in the
>     past and $
>     is end of line in regexes so % seems safer. The matcher for USER now
>     specifically excludes any line that has the new patterns in it too
>     so there can
>     be no conflict. It appears to work in the testing I have done with
>     adding
>     strange fcontexts. make test passes in the repo too but i have not
>     run the full
>     selinux-testsuite.
> 
> 
> Hi,
> Thanks for your work. Your patches are very well built and I have been
> able to test them without any trouble. Here are some comments:
> * In Patch 1, the last parameter of write_replacements() can be made a
> const pointer: "const replacement_pair_t *repl" (parameters s and tpl
> too but there are not currently const pointers).
> * Patch 5 introduces a "gid" field in "struct user_entry", which is not
> used in the templates. Why did you introduce it?
> * Patch 7 introduces two functions, write_username_context
> and write_userid_context, which handle lines containing %{USERNAME}
> and %{USERID} separately. If a line includes both patterns, like
> "%{USERID}-%{USERNAME}", the generated file will have for root user two
> lines: one with "%{USERID}-root" and the other "0-%{USERNAME}". As a
> user I would have expected both templates to be replaced. I believe this
> may be achieved by merging the two predicate functions together (in
> patch 6), and the substitutions functions too (in patch 7).
>  
> 
> 
>     %{USERNAME} defaults to ".*" in the fallback just like USER
>     originally did
>     %{USERID} defaults to "[0-9]+" for the fallback.
> 
>     Another thing I noticed was that HOME_DIR's fallback is "[^/]*",
>     should it be +
>     instead of *? I dont think it makes a huge difference because then
>     it should
>     match HOME_ROOT but it still seems wrong.
> 
> 
> I agree. Moreover empty usernames or usernames with / look wrong to me
> too. As refpolicy seems to use "USER" as if there was no slash in it,
> IMHO I would suggest using "[^/]+" for %{USERNAME} default value too.
> 
> By the way, by grep'ing HOME_DIR in refpolicy I got a hit in a support
> script, "support/genhomedircon" [1]. This script is invoked only when
> building modular policy and I have not found an easy way to
> invoke semanage_genhomedircon() from either the command line or a Python
> script. Does this script needs to be updated or is there a way to use
> libsemanage implementation instead?
> 
> Cheers,
> Nicolas
> 
> [1] https://github.com/TresysTechnology/refpolicy/blob/master/support/genhomedircon

I believe the script is obsolete under modular policy (only used on
monolithic builds), and you can trigger semanage_genhomedircon() just by
running semodule -Bn.  /usr/sbin/genhomedircon is a symlink to semodule,
and semodule runs as if invoked with -Bn when called under that name.

  parent reply	other threads:[~2016-04-12 12:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01  9:36 genhomedircon uid template Jason Zaman
2016-02-01 19:30 ` Stephen Smalley
2016-02-02  6:26   ` Jason Zaman
2016-02-02 13:57     ` Christopher J. PeBenito
2016-02-02 15:03     ` Stephen Smalley
2016-02-02 20:39       ` Nicolas Iooss
2016-04-08 16:05 ` genhomedircon USERID and USERNAME patches Jason Zaman
2016-04-08 16:05   ` [PATCH 1/7] genhomedircon: factor out common replacement code Jason Zaman
2016-04-08 16:05   ` [PATCH 2/7] genhomedircon: move fallback user to genhomedircon_user_entry_t Jason Zaman
2016-04-08 16:05   ` [PATCH 3/7] genhomedircon: rename FALLBACK #defines consistent with struct Jason Zaman
2016-04-08 16:05   ` [PATCH 4/7] genhomedircon: make all write context funcs take user_entry struct Jason Zaman
2016-04-08 16:05   ` [PATCH 5/7] genhomedircon: Add uid and gid to struct user_entry Jason Zaman
2016-04-08 16:05   ` [PATCH 6/7] genhomedircon: make USERID, USERNAME context lists Jason Zaman
2016-04-08 16:05   ` [PATCH 7/7] genhomedircon: write contexts for username and userid Jason Zaman
2016-04-11 21:44   ` genhomedircon USERID and USERNAME patches Nicolas Iooss
2016-04-12  7:56     ` Dominick Grift
2016-04-12 11:51     ` Jason Zaman
2016-04-12 12:57     ` Stephen Smalley [this message]
2016-04-12 14:35       ` Christopher J. PeBenito
2016-04-13 16:34         ` Dominick Grift
2016-04-13 17:00           ` Stephen Smalley
2016-04-13 17:10             ` Dominick Grift
2016-04-13 17:18               ` Dominick Grift
2016-04-13 18:25                 ` Dominick Grift
2016-04-17 10:12                   ` Dominick Grift
2016-04-17 12:03                     ` Dominick Grift
2016-04-17 19:19                       ` Dominick Grift
2016-04-18  6:23                         ` Dominick Grift
2016-04-23  6:04   ` genhomedircon USERID and USERNAME patches v2 Jason Zaman
2016-04-23  6:04     ` [PATCH v2 1/8] genhomedircon: factor out common replacement code Jason Zaman
2016-04-23  6:04     ` [PATCH v2 2/8] genhomedircon: move fallback user to genhomedircon_user_entry_t Jason Zaman
2016-04-29 16:54       ` Stephen Smalley
2016-04-29 19:23         ` Jason Zaman
2016-04-29 20:29           ` Stephen Smalley
2016-04-23  6:04     ` [PATCH v2 3/8] genhomedircon: rename FALLBACK #defines consistent with struct Jason Zaman
2016-04-23  6:04     ` [PATCH v2 4/8] genhomedircon: make all write context funcs take user_entry struct Jason Zaman
2016-04-23  6:04     ` [PATCH v2 5/8] genhomedircon: Add uid and gid to struct user_entry Jason Zaman
2016-04-27 17:04       ` Stephen Smalley
2016-04-28 17:53         ` Jason Zaman
2016-04-28 18:13           ` Stephen Smalley
2016-04-29 12:01             ` Jason Zaman
2016-04-23  6:04     ` [PATCH v2 6/8] genhomedircon: make USERID, USERNAME context lists Jason Zaman
2016-04-23  6:04     ` [PATCH v2 7/8] genhomedircon: write contexts for username and userid Jason Zaman
2016-04-23  6:04     ` [PATCH v2 8/8] genhomedircon: fix FALLBACK_NAME regex Jason Zaman
2016-04-26 22:03     ` genhomedircon USERID and USERNAME patches v2 Nicolas Iooss
2016-04-29 12:04   ` [PATCH v3 5/8] genhomedircon: Add uid and gid to struct user_entry Jason Zaman
2016-04-29 20:28     ` 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=570CF09E.10100@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=jason@perfinion.com \
    --cc=nicolas.iooss@m4x.org \
    --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.