Re: wildcards in file_contexts.subs for NixOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday, 24 February 2019 11:36:34 PM AEDT Nicolas Iooss wrote:
> 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.

We should be able to accept the performance overhead of regexs because we 
typically do less than a dozen checks of the subs file before doing hundreds of 
checks of the file_contexts file which has regexes (on my Debian/Stretch laptop 
there are 4572 lines in the file_contexts file and 27 in the subst file including 
comments).  I'm not advocating regexs as such, merely suggesting that we 
shouldn't rule out the possibility.

You are correct that my patch misses the double level needed.  The way the 
code works is that the custom subst file is checked and then the distribution 
subst file is checked afterwards.  I had put in my NixOS rule as a custom subst 
file (via semanage fcontext) so the tests passed.  I had also misread the 
source to think that it was already doing recursive checks of the subst files.

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

Sure, that sounds like a reasonable idea.

Before I get to the stage of submitting a patch with a merge request I'll put 
in some comments too.


Russell Coker





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux