Giter VIP home page Giter VIP logo

Comments (5)

stephensmalley avatar stephensmalley commented on July 23, 2024

setfiles -r /path/to/altroot /path/to/altroot/etc/selinux/targeted/contexts/files/file_contexts /path/to/altroot
Used in meta-selinux for OpenEmbedded.
Alternatively, Android extends make_ext4fs (system/extras/ext4_utils) to support labeling the ext4 images when they are generated initially.

from selinux.

stephensmalley avatar stephensmalley commented on July 23, 2024

Also, I believe Yocto added support for setting xattrs in their generated ext[34] filesystem images as well, such that the model is that meta-selinux runs setfiles -r to set the contexts on the files and then the image generation tools fetch those xattrs and set them in the generated image. I prefer the Android approach (unsurprisingly, since I wrote it originally) because it doesn't require the build host OS to deal with the security contexts at all; make_ext4fs directly looks up the correct context in file_contexts (when passed the appropriate options) and sets the xattr values in the generated image, without ever having to set a context on a file in a mounted filesystem on the build host. Aside from efficiency, this has the benefit that it avoids a potential problem when the build host OS has SELinux enabled and the contexts being set are unknown to its SELinux policy.

from selinux.

stephensmalley avatar stephensmalley commented on July 23, 2024

Also, just FYI, setfiles and restorecon are the same program these days, just with different command line interfaces and default behaviors selected by argv[0]. The original SELinux implementation from us only had setfiles, which was intended to be used to label filesystems even before first booting SELinux (and this was the basis for FreeBSD setfsmac(8)). Later Dan Walsh created a simpler restorecon utility for users to run on a SELinux-enabled system to restore contexts to their initial state. Over time, restorecon kept adding more functionality, overlapping significantly with setfiles, and eventually we coalesced them back into a single program. restorecon though is still only intended for use on a SELinux-enabled system, whereas setfiles is appropriate for running on SELinux-enabled or -disabled hosts.

from selinux.

stephensmalley avatar stephensmalley commented on July 23, 2024

I'm going to close this issue since I think it is already supported adequately via setfiles -r, but re-open or submit a new one if you encounter problems. NB If running on a SELinux-enabled build host, then some machinations may be necessary to set security contexts unknown to the build host SELinux policy on files in this way.

from selinux.

aduskett avatar aduskett commented on July 23, 2024

I know it's a late response, but I just wanted to thank you for the super helpful information!

from selinux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.