Skip to contentSkip to conversation

SELinux for upstream coreutils, finally (RFC: does mkdir need -Z?)

DISCUSSION Jim Meyering 5 participants 12 messages Mar 30, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

I've merged the SELinux changes onto the trunk. For reference, this work is based on the patches from Fedora, as of about 6 months ago, but with some semantic changes. For example, I've removed the --lcontext and --scontext options that were specific to their version of ls. Since the new -Z option enables printing of the security context, you can get the same behavior with -lZ, and -Z respectively. Their -Z option would print mode, user, group, security context and file name (effectively eliminating link count, size, and date) in an attempt to fit everything on a limited-width line. With this version of ls, there is no equivalent to that -Z. However, you can approximate it using stat.

Also, I've removed the vast majority of the cpp directives that guarded SELinux-related things in src/*.c. Instead, now there are stub functions that are compiled on systems lacking SELinux support, so the callers are more readable/maintainable.

Unlike with other SELinux-enabled coreutils, here, mv and cp do not provide the "-Z context" option. It is not the job of such programs to *change* the security context (which that -Z context enabled).

Regarding the --context=C (-Z C) option that is now accepted by mkdir, mknod, mkfifo, and install, I am inclined to
omit it altogether, and there was a lot of discussion on the SELinux mailing list, boiling down to whether the alternative I proposed was sufficiently "usable". Hoping to get some feedback about that from "regular" SELinux users, I summarized and posted to fedora-list, here:

    http://www.redhat.com/archives/fedora-list/2006-August/msg02264.html

Unfortunately, that provoked no discussion.

I'm still not entirely convinced that mkdir, mknod, mkfifo, and install need the option, and would welcome opinions one way or the other. There's a good chance that I'll remove those -Z options before coreutils-6.10.

Another tidbit (from a ChangeLog entry, below):

Change how "cp -a" and "cp --preserve=context" work with SELinux. Now, cp -a attempts to preserve context, but failure to do so does not change cp's exit status. However "cp --preserve=context" is similar, but failure *does* cause cp to exit with nonzero status.

---------------------
With these changes, coreutils still builds and passes all tests on Linux systems (I've tried 2.4.x and 2.6.x, with and without SELinux, and with different versions of libc).

Below, I'm including only the diffstat summary, and the ChangeLog. If you want to see the whole diff, this produces it:

    git-diff 8487f9c HEAD

Portability testing (and adding new tests) aside, there are still things left to do, including NEWS and documentation updates.

---------------------

 .cvsignore                   |    1
 .gitignore                   |    1
 AUTHORS                      |    2
 ChangeLog                    |  215 +++++++++++++++
 README                       |   16 -
 bootstrap.conf               |    4
 gl/lib/se-context_.h         |   31 ++
 gl/lib/se-selinux_.h         |   54 +++
 gl/lib/selinux-at.c          |   92 ++++++
 gl/lib/selinux-at.h          |   24 +
 gl/m4/selinux-context-h.m4   |   18 +
 gl/m4/selinux-selinux-h.m4   |   18 +
 gl/modules/selinux-at        |   32 ++
 gl/modules/selinux-h         |   54 +++
 lib/.cvsignore               |    7
 lib/.gitignore               |    7
 m4/.cvsignore                |    2
 m4/.gitignore                |    2
 man/Makefile.am              |    7
 man/chcon.x                  |    4
 man/runcon.x                 |   14 +
 po/ChangeLog                 |    8
 po/POTFILES.in               |    4
 src/Makefile.am              |   25 +
 src/chcon.c                  |  590 +++++++++++++++++++++++++++++++++++++++++++
 src/copy.c                   |   86 ++++++
 src/copy.h                   |   21 +
 src/cp.c                     |   32 +-
 src/id.c                     |   63 +++-
 src/install.c                |  104 +++++++
 src/ls.c                     |   91 ++++--
 src/mkdir.c                  |   18 +
 src/mkfifo.c                 |   18 +
 src/mknod.c                  |   18 +
 src/mv.c                     |    5
 src/runcon.c                 |  249 ++++++++++++++++++
 src/stat.c                   |   47 ++-
 src/system.h                 |    2
 tests/Makefile.am            |    8
 tests/chmod/equals           |    4
 tests/cp/Makefile.am         |    1
 tests/cp/cp-a-selinux        |   94 ++++++
 tests/cp/cp-parents          |    6
 tests/cp/fail-perm           |    5
 tests/cp/link-preserve       |    2
 tests/help-version           |    7
 tests/install/basic-1        |    5
 tests/misc/Makefile.am       |    6
 tests/misc/chcon             |   73 +++++
 tests/misc/chcon-fail        |   41 ++
 tests/misc/mknod             |    6
 tests/misc/runcon-no-reorder |   57 ++++
 tests/misc/selinux           |   61 ++++
 tests/mkdir/parents          |    8
 tests/mkdir/special-1        |    8
 tests/mv/partition-perm      |    2
 tests/selinux                |   24 +
 57 files changed, 2296 insertions(+), 108 deletions(-)

2007-03-30 Jim Meyering <[email protected]>

* ChangeLog-selinux: Remove file.
Move its contents into this file, removing old dates.

* src/runcon.c (main): Don't reorder arguments. Reported by Ulrich Drepper in <http://bugzilla.redhat.com/232652>.
* tests/misc/runcon-no-reorder: New file. Test for the above.
* tests/misc/Makefile.am (TESTS): Add runcon-no-reorder.

* src/runcon.c (main): Remove "." at end of a diagnostic.

* src/runcon.c: New program.
* src/Makefile.am (bin_PROGRAMS): Add runcon. (runcon_LDADD): Define.
* README: Add runcon to the list of programs.
* AUTHORS: Add this: runcon: Russell Coker
* tests/help-version: Add runcon as an exception.
* man/Makefile.am (dist_man_MANS): Add runcon.1. (runcon.1): New dependency.

mkfifo, mknod: Accept new "-Z, --context=C" option.
* src/mkfifo.c, src/mknod.c: Include <selinux/selinux.h>. (main): Honor it.
* src/Makefile.am (mkfifo_LDADD, mknod_LDADD): Use $(LIB_SELINUX).

mkdir: Accept new "-Z, --context=C" option.
* src/mkdir.c: Include <selinux/selinux.h>. (main): Honor it.
* src/Makefile.am (mkdir_LDADD): Use $(LIB_SELINUX).

* tests/cp/cp-a-selinux: New file. Test for the bug reported in
<http://bugzilla.redhat.com/219900>.
* tests/cp/Makefile.am (TESTS): Add cp-a-selinux.

* tests/selinux: New file.
* tests/Makefile.am (EXTRA_DIST): Add selinux.
* tests/misc/selinux: Source the new script, rather than open coding it.

Change how "cp -a" and "cp --preserve=context" work with SELinux. Now, cp -a attempts to preserve context, but failure to do so does not change cp's exit status. However "cp --preserve=context" is similar, but failure *does* cause cp to exit with nonzero status.
* src/copy.h (struct cp_options) [require_preserve_context]: New member.
* src/copy.c (copy_reg, copy_internal): Implement the above.
* src/mv.c (cp_option_init): Initialize the new member.
* src/install.c (cp_option_init): Likewise.
* src/cp.c (cp_option_init): Likewise. (decode_preserve_arg): Set it or reset it.

cp, mv, install: add SELinux support, but unlike with the Red Hat patch, mv and cp do not provide the "-Z context" option.
* src/copy.c: Include <selinux/selinux.h>. (restore_default_fscreatecon): New function.
(copy_reg): Make cp --preserve=context work for existing destination. (copy_internal): Likewise for new destinations.
* src/copy.h (cp_options) [preserve_security_context]: New member.
* src/cp.c: Include <selinux/selinux.h>. (selinux_enabled): New global.
(usage): Mention new --preserve=context option. (PRESERVE_CONTEXT): Define/use.
(decode_preserve_arg): Handle PRESERVE_CONTEXT.
(main): Remove an obsolete comment.
If --preserve=context is specified on a system without SELinux enabled, give a diagnostic and fail.
* src/mv.c: Include <selinux/selinux.h>.
Set x->preserve_security_context if SELinux is enabled.
* src/install.c: Accept new "-Z, --context=C" option. Accept --preserve-context option (but not -P option). Accept alternate spelling: --preserve_context, for now. Include <selinux/selinux.h> and "quotearg.h". (selinux_enabled, use_default_selinux_context): New globals. (PRESERVE_CONTEXT_OPTION): Define.
(cp_option_init): Default: do not preserve security context. (setdefaultfilecon): New function.
(main): Honor new options.
* src/Makefile.am (mv_LDADD, cp_LDADD, ginstall_LDADD):
Add $(LIB_SELINUX).
* src/system.h (GETOPT_SELINUX_CONTEXT_OPTION_DECL): Define.

* tests/misc/selinux [VERBOSE]: Print version info for each of the tested tools, not just ls.

* src/c99-to-c89.diff: Remove the ls.c patch, now that I've temporarily removed the offending c99'ism.

* src/chcon.c (usage): Split a string literal that was longer than 509.

* src/ls.c (gobble_file): Don't call getfilecon unless print_scontext. Upon failed getfilecon, accept not just ENOTSUP, but also ENODATA.

* src/c99-to-c89.diff: Adjust offsets.

* AUTHORS: Add chcon.

* src/c99-to-c89.diff: Remove trailing blanks.

* src/chcon.c: Don't include "dirname.h". system.h already includes it.

* gl/lib/selinux-at.c: Remove a use of HAVE_CONFIG_H.

* src/c99-to-c89.diff: Handle a new c99'ism in ls.c.

* src/id.c (main): Tweak id -Z diagnostic.

id: Add SELinux support: -Z option.
* src/id.c (main): Apply patches from Fedora, with these changes:
Remove #ifdef WITH_SELINUX.
Use error (EXIT_FAILURE, not fprintf+exit(1).
* src/Makefile.am (id_LDADD): Define, so as to add $(LIB_SELINUX).

stat: Add support for SELinux in the form of a %C format directive.
* src/stat.c (follow_links): Make this variable file-global. (out_file_context): New function.
(print_statfs): Honor %C.
(print_stat): Honor %C.
(do_stat): Remove follow_links parameter.
(usage): Document the two %C directives.
(main): Accept -Z (though it's a no-op).
* src/Makefile.am (stat_LDADD): Define.

ls: Add support for SELinux and a slightly modified -Z option. I started with the patches from Red Hat.
The entries below tell how the code evolved.

* src/ls.c (print_long_format, print_file_name_and_frills): When there is no security context (due to getfilecon/lgetfilecon failing with e.g. ENOTSUP), print it as "?", not "".
* src/ls.c (print_file_name_and_frills): Make -Z work without -l. (length_of_file_name_and_frills): Likewise.

* src/ls.c: Remove the --lcontext and --scontext options. Change the way -Z, --context work so that it no longer implies -l. Thus, -Z -l will work like -lcontext and -Z without -l will work like --scontext.

Adjust tests to reflect new 'ls -l' syntax -- affects only systems with SELinux when operating on a file with no ACL. These tests assumed that everything before the first space on each line is the 10-byte mode string. But there may also be a "+" in the 11th column, just before the space. However, note that this is not new. The same thing would have happened even without the change below, when listing a file with an ACL.
* tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm:
* tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod:
* tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm:

Don't make compilation depend on USE_ACL. An SELinux security context counts as an "alternate access control method", so ls must output a "+" for each file with a security context.
* src/ls.c [struct fileinfo] (have_acl): Declare unconditionally. (FILE_HAS_ACL): Remove macro definition. Use f->have_acl directly. (gobble_file): Record whether a file has a security context, and update the condition used to determine whether to print the "+". (gobble_file): Call getfilecon/lgetfilecon also when format == long_format, so that we get the "+".

* src/ls.c (gobble_file): Add a comment explaining why (with a security context option) ls doesn't exit nonzero due to e.g., getfilecon failing with errno == ENOTSUP.

* src/ls.c (gobble_file): Ignore failure of getfilecon if it's due to ENOTSUP.

* src/ls.c (gobble_file): Factor out three small blocks using getfilecon and lgetfilecon.
Don't ignore return value from getfilecon and lgetfilecon.

* src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C ternary operator).
(print_scontext_format): Likewise.
(print_scontext): Declare to be "bool", not int. Adjust uses.

* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX).

* tests/misc/chcon: New file.
* tests/misc/chcon-fail: New file.
* tests/Makefile.am (check-root): Run new, root-only misc/chcon test.
* tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail.

* tests/misc/Makefile.am (TESTS): Add selinux.
* tests/misc/selinux: New file.
* tests/help-version: Skip chcon.
* man/chcon.x: New file.
* man/Makefile.am: Build chcon.1.

New program: chcon
* gl/modules/selinux-at: New module. Check for libselinux and set LIB_SELINUX here, unconditionally, rather than depending on the configure-time --enable-selinux option.
* gl/modules/selinux-h: New module.
* bootstrap.conf (gnulib_modules): Add selinux-at.
* gl/lib/selinux-at.c, gl/lib/selinux-at.h: New files.
* gl/lib/se-selinux_.h: New file.
* gl/lib/se-context_.h: New file.
* gl/m4/selinux-selinux-h.m4: New file.
* gl/m4/selinux-context-h.m4: New file.
* src/Makefile.am (bin_PROGRAMS): Add chcon. (chcon_LDADD): Define.
* README: Add chcon to the list of programs.
* src/chcon.c: Rewrite the original (Red Hat) chcon to use fts.

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

#1 lore raw
Quoted 2 lines · Jim Meyering

Regarding the --context=C (-Z C) option that is now accepted by mkdir, mknod, mkfifo, and install, I am inclined to

Currently mkdir, mknod, and mkfifo support a -m option to set the mode. Install has options to also set the owner and group.

I think that all programs which set the uid and gid of a file should also be able to set the SE Linux context.

It also seems reasonable that a program which can create a file with particular permissions should also be permitted to create it with a particular context.

Quoted 3 lines

I'm still not entirely convinced that mkdir, mknod, mkfifo, and install need the option, and would welcome opinions one way or the other. There's a good chance that I'll remove those -Z options before coreutils-6.10.

Oh well, if you merge most of the changes then that's still less work for us in maintaining patches.

Signature · 9 lines
[email protected]
http://etbe.blogspot.com/          My Blog

http://www.coker.com.au/sponsorship.html Sponsoring Free Software development

--
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.
#2 lore raw
Quoted 6 lines · Russell Coker
Quoted 2 lines · Jim Meyering

Regarding the --context=C (-Z C) option that is now accepted by mkdir, mknod, mkfifo, and install, I am inclined to

Currently mkdir, mknod, and mkfifo support a -m option to set the mode. Install has options to also set the owner and group.

Hi Russell,

Thanks for the quick feedback.
As implied here,

    http://www.redhat.com/archives/fedora-list/2006-August/msg02264.html

I agree that one should be able to get the effect you want. However, adding a -Z option to each and every affected program is not the only way.

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

I would prefer not to add new options in so many programs when a less-invasive approach is possible.

Quoted 6 lines

I think that all programs which set the uid and gid of a file should also be able to set the SE Linux context.

It also seems reasonable that a program which can create a file with particular permissions should also be permitted to create it with a particular context.

I was hoping for feedback on whether the proposed alternative (using fscon and maybe runcon proxies) looked viable from a usability standpoint.

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

#3 lore raw
Quoted 7 lines · Jim Meyering

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

How about:
umask whatever ; mkdir /new/directory

Instead of mkdir -m whatever /new/directory?

Quoted 9 lines
Quoted 6 lines

I think that all programs which set the uid and gid of a file should also be able to set the SE Linux context.

It also seems reasonable that a program which can create a file with particular permissions should also be permitted to create it with a particular context.

I was hoping for feedback on whether the proposed alternative (using fscon and maybe runcon proxies) looked viable from a usability standpoint.

Firstly there is the issue that fscon needs kernel changes to implement, then there is the issue that inheriting fscon can potentially give undesired results if privileged programs such as /bin/passwd forget to unset it, so therefore we need a policy method to control whether such inheriting of the fscon is permitted.

Adding an option to utilities is by far the easiest option.

Signature · 9 lines
[email protected]
http://etbe.blogspot.com/          My Blog

http://www.coker.com.au/sponsorship.html Sponsoring Free Software development

--
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.
#10 lore raw
In reply to Jim Meyering
Quoted 18 lines · Jim Meyering
Quoted 6 lines · Russell Coker
Quoted 2 lines · Jim Meyering

Regarding the --context=C (-Z C) option that is now accepted by mkdir, mknod, mkfifo, and install, I am inclined to

Currently mkdir, mknod, and mkfifo support a -m option to set the mode. Install has options to also set the owner and group.

Hi Russell,

Thanks for the quick feedback.
As implied here,

    http://www.redhat.com/archives/fedora-list/2006-August/msg02264.html

I agree that one should be able to get the effect you want. However, adding a -Z option to each and every affected program is not the only way.

Quoted 8 lines

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

I still think that this is problematic from a user perspective (in addition to the implementation issues). It is not as much the complication of using the command - though that is not ideal. It is more that I think it will be much harder for the user to find fscon than an option if they do not know that they exist.

If there are some selinux options in coreutils it would be natural for a user to look for other options to accomplish what you want. In this case I don't think that most users would, upon not finding an option, think to look for a completely separate tool.

Karl

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

#4 lore raw
In reply to Russell Coker
Quoted 5 lines · Russell Coker
Quoted 4 lines · Jim Meyering

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

Quoted 8 lines
Quoted 3 lines

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

How about:
umask whatever ; mkdir /new/directory

Instead of mkdir -m whatever /new/directory?

I agree that having to use umask like that would be a pain, but largely because you generally want to use it in a sub-shell so it doesn't affect other commands. But fscon wouldn't have that problem.

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

I think that all programs which set the uid and gid of a file should also be able to set the SE Linux context.

It also seems reasonable that a program which can create a file with particular permissions should also be permitted to create it with a particular context.

Quoted 8 lines
Quoted 2 lines

I was hoping for feedback on whether the proposed alternative (using fscon and maybe runcon proxies) looked viable from a usability standpoint.

Firstly there is the issue that fscon needs kernel changes to implement, then there is the issue that inheriting fscon can potentially give undesired results if privileged programs such as /bin/passwd forget to unset it, so therefore we need a policy method to control whether such inheriting of the fscon is permitted.

True, getting to the point at which we can write a usable "fscon" is not trivial. But neither is adding a -Z option to so many programs that create files. From a software engineering standpoint, I much prefer the one-tool approach, even if we end up ceding to usability demands and adding -Z to the more commonly used programs: mkdir and install.

Quoted 1 line

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

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

#5 lore raw
Quoted 13 lines · Jim Meyering
Quoted 12 lines · Russell Coker
Quoted 7 lines · Jim Meyering

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

How about:
umask whatever ; mkdir /new/directory

Quoted 7 lines
Quoted 1 line

Instead of mkdir -m whatever /new/directory?

I agree that having to use umask like that would be a pain, but largely because you generally want to use it in a sub-shell so it doesn't affect other commands. But fscon wouldn't have that problem.

Well - as Russell points out it does have a similar problem with privileged commands.

Quoted 6 lines

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

The policy can set a default that is roughly analogous to umask - but appropriate to SELinux - via type transition rules with a fallback to inheritance from the creating process / containing directory. Matchpathcon also has some overlap here.

<snip>

Quoted 10 lines
Quoted 2 lines

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

I think it is far from clear that fscon is a better solution, either from a usage or security perspective. It also shifts complexity from userspace to the kernel, which is seldom desirable.

Quoted 7 lines

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

That wasn't what I got out of that discussion. The usability concerns are important, but the proposed kernel mechanism has some serious semantic issues that I don't think have been resolved. Again, I don't think that we are actually searching for a better solution, but rather shifting where the complexity resides. The '-Z' option, while requiring changing a lot of software, is conceptually clear and doesn't require much code. That makes it the better option in my opinion.

Another important point to me: will distros just carry patches to add '-Z' for forever? Russell seemed to indicate that Debian will and I assume that Fedora and RHEL will. What about others - Josh/Chris, will you continue to carry patches if necessary in Gentoo?

Karl

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

#6 lore raw
Quoted 79 lines · Karl MacMillan
Quoted 15 lines · Jim Meyering
Quoted 13 lines · Russell Coker
Quoted 8 lines · Jim Meyering

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

How about:
umask whatever ; mkdir /new/directory

Quoted 8 lines
Quoted 2 lines

Instead of mkdir -m whatever /new/directory?

I agree that having to use umask like that would be a pain, but largely because you generally want to use it in a sub-shell so it doesn't affect other commands. But fscon wouldn't have that problem.

Well - as Russell points out it does have a similar problem with privileged commands.

Quoted 7 lines

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

The policy can set a default that is roughly analogous to umask - but appropriate to SELinux - via type transition rules with a fallback to inheritance from the creating process / containing directory. Matchpathcon also has some overlap here.

<snip>

Quoted 10 lines
Quoted 2 lines

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

I think it is far from clear that fscon is a better solution, either from a usage or security perspective. It also shifts complexity from userspace to the kernel, which is seldom desirable.

Quoted 8 lines

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

That wasn't what I got out of that discussion. The usability concerns are important, but the proposed kernel mechanism has some serious semantic issues that I don't think have been resolved. Again, I don't think that we are actually searching for a better solution, but rather shifting where the complexity resides. The '-Z' option, while requiring changing a lot of software, is conceptually clear and doesn't require much code. That makes it the better option in my opinion.

Quoted 5 lines

Another important point to me: will distros just carry patches to add '-Z' for forever? Russell seemed to indicate that Debian will and I assume that Fedora and RHEL will. What about others - Josh/Chris, will you continue to carry patches if necessary in Gentoo?

I don't like the idea of fscon for the reasons stated above. Users having the ability to find out
about the tool, unknown side effects. So Fedora and RHEL will continue to carry a patch
if the -Z does not make it upstream.

Quoted 9 lines

Karl

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

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

#7 lore raw
In reply to Karl MacMillan

Karl MacMillan <[email protected]> wrote:
...

Quoted 10 lines
Quoted 5 lines

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

The policy can set a default that is roughly analogous to umask - but appropriate to SELinux - via type transition rules with a fallback to inheritance from the creating process / containing directory. Matchpathcon also has some overlap here.

Do you mean we *can* implement fscon already?
I don't think I could have misunderstood things that badly.

What I meant is that because of the fscreate-context-clearing that happens (I think it was) at exec time, currently we can't write a program to implement fscon semantics.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

Quoted 3 lines

I think it is far from clear that fscon is a better solution, either from a usage or security perspective. It also shifts complexity from userspace to the kernel, which is seldom desirable.

Actually, last summer, I was actually hoping for a quick negative, along the lines "no, with SELinux it is not reasonable to make the changes required to support fscon". But I never got that. On the contrary, I got the message that it was doable, but not trivial. Stephen Smalley's replies gave me this impression. Please be specific, if you think I misinterpreted something.

Quoted 7 lines
Quoted 6 lines

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

Quoted 7 lines

That wasn't what I got out of that discussion. The usability concerns are important, but the proposed kernel mechanism has some serious semantic issues that I don't think have been resolved. Again, I don't think that we are actually searching for a better solution, but rather shifting where the complexity resides. The '-Z' option, while requiring changing a lot of software, is conceptually clear and doesn't require much code. That makes it the better option in my opinion.

Perhaps if I knew more about SELinux, I would understand why it seems better to add a new option to so many tools (there are far more than just these four in coreutils) than to provide a single tool that could also be applied to programs that we don't have the luxury of adding options to.

If the people responsible for SELinux development can tell me they are confident that my pursuing this is not worthwhile, (i.e., fscon won't be implementable any time soon), I'll have no choice but to let this thread die. That's what I wanted months ago -- it sure would have saved some debating.

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

#9 lore raw
In reply to Karl MacMillan
Quoted 70 lines · Karl MacMillan
Quoted 13 lines · Jim Meyering
Quoted 12 lines · Russell Coker
Quoted 7 lines · Jim Meyering

What did you think of the proposal (in the link above) for

fscon CTX mkdir /new/directory

IMHO, it's not so much less "user friendly" than this equivalent:

mkdir -C CTX /new/directory

How about:
umask whatever ; mkdir /new/directory

Quoted 7 lines
Quoted 1 line

Instead of mkdir -m whatever /new/directory?

I agree that having to use umask like that would be a pain, but largely because you generally want to use it in a sub-shell so it doesn't affect other commands. But fscon wouldn't have that problem.

Well - as Russell points out it does have a similar problem with privileged commands.

Quoted 6 lines

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

The policy can set a default that is roughly analogous to umask - but appropriate to SELinux - via type transition rules with a fallback to inheritance from the creating process / containing directory. Matchpathcon also has some overlap here.

<snip>

Quoted 10 lines
Quoted 2 lines

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

I think it is far from clear that fscon is a better solution, either from a usage or security perspective. It also shifts complexity from userspace to the kernel, which is seldom desirable.

Quoted 7 lines

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

That wasn't what I got out of that discussion. The usability concerns are important, but the proposed kernel mechanism has some serious semantic issues that I don't think have been resolved. Again, I don't think that we are actually searching for a better solution, but rather shifting where the complexity resides. The '-Z' option, while requiring changing a lot of software, is conceptually clear and doesn't require much code. That makes it the better option in my opinion.

Quoted 4 lines

Another important point to me: will distros just carry patches to add '-Z' for forever? Russell seemed to indicate that Debian will and I assume that Fedora and RHEL will. What about others - Josh/Chris, will you continue to carry patches if necessary in Gentoo?

Yes.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#8 lore raw
In reply to Jim Meyering
Quoted 8 lines · Jim Meyering

Karl MacMillan <[email protected]> wrote:
...

Quoted 6 lines
Quoted 5 lines

However, your example raises a good point: with mode-setting, we *do* have the option of selecting a default mode via the "umask" command. Currently, there is no analog to set the default SELinux file system context, and that is part of why I'm arguing for the ability to write "fscon".

Quoted 8 lines
Quoted 4 lines

The policy can set a default that is roughly analogous to umask - but appropriate to SELinux - via type transition rules with a fallback to inheritance from the creating process / containing directory. Matchpathcon also has some overlap here.

Do you mean we *can* implement fscon already?
I don't think I could have misunderstood things that badly.

No, I mean that type transition rules can specify types for new files based on application / directory type pairs. This largely eliminates the need for a umask like mechanism.

Quoted 4 lines

What I meant is that because of the fscreate-context-clearing that happens (I think it was) at exec time, currently we can't write a program to implement fscon semantics.

Correct. I was responding to what I thought was a suggestion that a umask like command was generally useful by saying that there were other mechanism already in place to largely eliminate that need.

Quoted 13 lines
Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Adding an option to utilities is by far the easiest option.

In some sense (especially in the short term), it does look easier simply to add the option to each program that needs it. And I wouldn't have to write so much, explaining my position :-) However, as upstream maintainer, I have to try to find the right (long term) solution. I'm reluctant to lock coreutils in to the short-term-easy solution if with a little perseverance and patience we can get to a better one.

Quoted 3 lines

I think it is far from clear that fscon is a better solution, either from a usage or security perspective. It also shifts complexity from userspace to the kernel, which is seldom desirable.

Quoted 7 lines

Actually, last summer, I was actually hoping for a quick negative, along the lines "no, with SELinux it is not reasonable to make the changes required to support fscon". But I never got that. On the contrary, I got the message that it was doable, but not trivial. Stephen Smalley's replies gave me this impression. Please be specific, if you think I misinterpreted something.

It is definitely possible to implement this mechanism - it is not clear to me that the potential benefits outweigh the potential problems.

The main concern is that a less privileged application could fool a more privileged application into creating files with the wrong context by allowing fscreate to be inherited across exec. With the mechanism needed by fscon applications will need to specifically protect against this threat (requiring code) and / or new permissions will need to be created to allow policy to control the inheritance.

Quoted 20 lines
Quoted 7 lines
Quoted 6 lines

As I understood the outcome of our discussions on the selinux list back in July, it would be feasible to make fscon work, but not trivial. The main objection appeared to be that fscon would not be easy for regular users to find/understand/use, and that's why I ended up posting to fedora-list:
trying to get feedback from people not already up to their elbows in the guts of SELinux.

Quoted 7 lines

That wasn't what I got out of that discussion. The usability concerns are important, but the proposed kernel mechanism has some serious semantic issues that I don't think have been resolved. Again, I don't think that we are actually searching for a better solution, but rather shifting where the complexity resides. The '-Z' option, while requiring changing a lot of software, is conceptually clear and doesn't require much code. That makes it the better option in my opinion.

Perhaps if I knew more about SELinux, I would understand why it seems better to add a new option to so many tools (there are far more than just these four in coreutils) than to provide a single tool that could also be applied to programs that we don't have the luxury of adding options to.

Quoted 5 lines

If the people responsible for SELinux development can tell me they are confident that my pursuing this is not worthwhile, (i.e., fscon won't be implementable any time soon), I'll have no choice but to let this thread die. That's what I wanted months ago -- it sure would have saved some debating.

Well - I'm not a kernel maintainer for SELinux so I can't really say no to this. However, I think that pursuing it is not worthwhile.

Karl

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

#11 lore raw
In reply to Jim Meyering
Quoted 1 line · Jim Meyering

I've merged the SELinux changes onto the trunk.

In case you're interested in trying it out,
here's a snapshot including the new SELinux bits:

http://meyering.net/cu/coreutils-6.9+.tar.gz
http://meyering.net/cu/coreutils-6.9+.tar.gz.sig

aka

http://meyering.net/cu/coreutils-6.9+-ss-2007-03-30.20.07.11+0.tar.gz
http://meyering.net/cu/coreutils-6.9+-ss-2007-03-30.20.07.11+0.tar.gz.sig

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