All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Iooss <nicolas.iooss@m4x.org>
To: Russell Coker <russell.coker@daisee.com>
Cc: "selinux@vger.kernel.org" <selinux@vger.kernel.org>
Subject: Re: wildcards in file_contexts.subs for NixOS
Date: Sun, 24 Feb 2019 23:36:34 +0100	[thread overview]
Message-ID: <CAJfZ7=m4Nv5ynUPhekij+Bn4MXOw6xm9x27mFERZ3+Xw9X7Ojw@mail.gmail.com> (raw)
In-Reply-To: <7853167.K65cXu0y11@neuromancer>

On Fri, Feb 22, 2019 at 5:26 AM Russell Coker <russell.coker@daisee.com> wrote:
>
> https://nixos.org/
>
> The NixOS distribution of Linux is based on having hashes of packages in the
> path names.
>
> /nix/store/l2b7y9waqwp4i1f03899yfsmzk8i7rid-shadow-4.5/bin/usermod
> /nix/store/l2b7y9waqwp4i1f03899yfsmzk8i7rid-shadow-4.5/bin/vipw
> /nix/store/lvrxkcf4b398nyiayknsqr44p8pl51s9-drbd-8.4.4/bin/drbdadm
> /nix/store/lvrxkcf4b398nyiayknsqr44p8pl51s9-drbd-8.4.4/bin/drbdsetup
> /nix/store/mzxhj1cxrhbqvsga4155xhw44iigwxxs-shadow-4.5-su/bin/su
> /nix/store/n3d4l234fppvz40jjyqlxa1jxglzbs48-xen-4.8.2/bin/xenconsoled
> /nix/store/n3d4l234fppvz40jjyqlxa1jxglzbs48-xen-4.8.2/bin/xenstored
> /nix/store/n3d4l234fppvz40jjyqlxa1jxglzbs48-xen-4.8.2/bin/xl
> /nix/store/n419slr5x6h4ydk2dd56nkwki7qpkf6v-fuse-2.9.7/bin/fusermount
> /nix/store/n419slr5x6h4ydk2dd56nkwki7qpkf6v-fuse-2.9.7/bin/mount.fuse
> /nix/store/pc4j7b2bvac49qmjllhw9rk0fnbr86fs-libvirt-3.10.0/bin/libvirtd
> /nix/store/pc4j7b2bvac49qmjllhw9rk0fnbr86fs-libvirt-3.10.0/bin/virsh
> /nix/store/pc4j7b2bvac49qmjllhw9rk0fnbr86fs-libvirt-3.10.0/bin/virtlockd
> /nix/store/pc4j7b2bvac49qmjllhw9rk0fnbr86fs-libvirt-3.10.0/bin/virtlogd
> /nix/store/pr94n9l1kvpiqilhjr308xbr8qmzilih-extra-utils/bin/blkid
> /nix/store/pr94n9l1kvpiqilhjr308xbr8qmzilih-extra-utils/bin/dmsetup
> /nix/store/pr94n9l1kvpiqilhjr308xbr8qmzilih-extra-utils/bin/e2fsck
>
> Above is a random sample of binaries that need labelling on a NixOS system.
> Before anyone asks, the naming of such paths is core to the way NixOS works,
> requesting a change in that regard is not viable.
>
> NixOS can run as a full OS (managing grub etc) or it can run on a system
> running a regular Linux distribution.  Running as a full OS or as a labelled
> chroot are the use cases that interest me.
>
> semanage fcontext -a -e / "/nix/store/*"
>
> setfiles -r /chroot/nix /etc/selinux/default/contexts/files/file_contexts \
> /chroot/nix/store -v
>
> I've written a patch to support commands like the above to label a Nix store
> (the above is a chroot example but the next step is to get full SE Linux
> support in NixOS).
>
> I've attached the patch.  I don't expect this version to be accepted upstream
> as-is.  But it's a place to start the discussion about how to approach this
> problem.
>
> Russell Coker
>
> PS Please use my personal address russell@coker.com.au for SE Linux
> discussions unrelated to NixOS.

Hello,

I agree it would be nice to be able to use SELinux on NixOS, and that
the first step consists in handling the file paths that are very
specific to this distribution. The patch you submitted adds the
support of source file contexts ending with "/*", but it does not
allow things like "match /chroot/nix/*/bin and replace it with
/usr/bin". This could be solved in several ways. The most
straightforward way probably consists in making selabel_sub_key() call
selabel_sub() several times, until no substitution occurred. An other
possibility could consist in using fnmatch() or regexp to match the
source pattern of substitution files, but I guess this would impact
performance too much.

I agree with adding support of source entries ending with "/*" in file
context substitution files. If others agree with this, for the next
iteration of the patch I suggest naming the new member of struct
selabel_sub "ends_with_star" instead of "wildcard". This would make
the code easier to understand.

Thanks,
Nicolas


  reply	other threads:[~2019-02-24 22:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22  4:26 wildcards in file_contexts.subs for NixOS Russell Coker
2019-02-24 22:36 ` Nicolas Iooss [this message]
2019-02-25  0:18   ` Russell Coker

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='CAJfZ7=m4Nv5ynUPhekij+Bn4MXOw6xm9x27mFERZ3+Xw9X7Ojw@mail.gmail.com' \
    --to=nicolas.iooss@m4x.org \
    --cc=russell.coker@daisee.com \
    --cc=selinux@vger.kernel.org \
    /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.