semanage_selinux(8)

πŸ“¦
version 20250627+git412.dbf877ab7 Β· 7 versions
, in opensuse-leap 16.0

πŸ’– semanage_selinux(8) β€” bestie edition πŸ’–

Okay so listen, this is the manual page for semanage_selinux(8), and it's literally all about the SELinux policy for the semanage processes. I'm gonna walk you through it like we're texting, but don't worry β€” every single detail is here, no cap. Let's get into it! 🫢


✨ NAME ✨

semanage_selinux β€” Security Enhanced Linux Policy for the semanage processes. That's it, that's the name. Iconic, honestly. πŸ’…


🌸 DESCRIPTION 🌸

Security-Enhanced Linux secures the semanage processes via flexible mandatory access control. Like, it wraps them in a little security bubble and says "you shall not pass" to anything sketchy. πŸ›‘οΈ

The semanage processes execute with the semanage_t SELinux type. You can check if you have these processes running by executing the ps command with the -Z qualifier. It's giving detective energy, fr fr.

For example:

ps -eZ | grep semanage_t

That's you, being a little investigator. πŸ”


πŸšͺ ENTRYPOINTS πŸšͺ

The semanage_t SELinux type can be entered via the semanage_exec_t file type. Think of it like a VIP door β€” only certain executables get to walk through and become semanage_t.

The default entrypoint paths for the semanage_t domain are the following:

/usr/bin/semanage, /usr/bin/semodule, /usr/libexec/selinux/selinux-
autorelabel, /usr/libexec/selinux/semanage_migrate_store,
/usr/share/system-config-selinux/selinux_server.py, /usr/share/system-
config-selinux/system-config-selinux-dbus.py

Look at all those paths, slaying in a list. πŸŽ€


πŸ‘‘ PROCESS TYPES πŸ‘‘

SELinux defines process types (domains) for each process running on the system. It's like every process gets its own little personality, and SELinux is the astrology of it all. β™ˆβ™‰β™Š

You can see the context of a process using the -Z option to ps. Again, detective mode activated. πŸ•΅οΈβ€β™€οΈ

Policy governs the access confined processes have to files. SELinux semanage policy is very flexible, allowing users to set up their semanage processes in as secure a method as possible. So you can lock it down however you like, bestie.

The following process types are defined for semanage:

  • semanage_t
Note: semanage permissive -a semanage_t can be used to make the process type semanage_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. So it's like a "free pass" but the security cameras are still recording. 😭

πŸ“ BOOLEANS πŸ“

SELinux policy is customizable based on least access required. semanage policy is extremely flexible and has several booleans that allow you to manipulate the policy and run semanage with the tightest access possible. Booleans are basically the on/off switches of the SELinux world, and you're the one holding the remote. πŸŽ›οΈ

If you want to dontaudit all daemons scheduling requests (setsched, sys_nice), you must turn on the daemons_dontaudit_scheduling boolean. It's enabled by default, so it's already vibing.

setsebool -P daemons_dontaudit_scheduling 1

If you want to deny user domains applications to map a memory region as both executable and writable, this is dangerous and the executable should be reported in bugzilla, you must turn on the deny_execmem boolean. It's disabled by default, and honestly, keep it that way unless you know what you're doing. 🚨

setsebool -P deny_execmem 1

If you want to control the ability to mmap a low area of the address space, as configured by /proc/sys/vm/mmap_min_addr, you must turn on the mmap_low_allowed boolean. Disabled by default, so it's just sitting there, waiting.

setsebool -P mmap_low_allowed 1

If you want to allow system to run with NIS, you must turn on the nis_enabled boolean. Disabled by default. NIS is a whole retro vibe, but okay.

setsebool -P nis_enabled 1

If you want to disable kernel module loading, you must turn on the secure_mode_insmod boolean. Disabled by default. It's giving "extra secure, no funny business." πŸ”’

setsebool -P secure_mode_insmod 1

If you want to allow unconfined executables to make their heap memory executable β€” doing this is a really bad idea β€” probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla, you must turn on the selinuxuser_execheap boolean. Disabled by default. Like, don't do this unless you absolutely have to, bestie. 😬

setsebool -P selinuxuser_execheap 1

If you want to allow unconfined executables to make their stack executable β€” this should never, ever be necessary β€” probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla, you must turn on the selinuxuser_execstack boolean. Disabled by default. Seriously, red flag central. 🚩

setsebool -P selinuxuser_execstack 1

πŸ“ MANAGED FILES πŸ“

The SELinux process type semanage_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Note: the processes UID still need to have DAC permissions. So SELinux isn't the only bouncer at the club. πŸšͺ

file_type

  • all files on the system

Yeah, you read that right β€” literally all files on the system. It's giving main character energy with a very broad reach. πŸ’…


πŸŽ€ FILE CONTEXTS πŸŽ€

SELinux requires files to have an extended attribute to define the file type. It's like every file has a little name tag. 🏷️

You can see the context of a file using the -Z option to ls. Again with the -Z! It's consistent, we love that.

Policy governs the access confined processes have to these files. SELinux semanage policy is very flexible, allowing users to set up their semanage processes in as secure a method as possible. Same energy as before, but now we're talking files.


πŸ”„ EQUIVALENCE DIRECTORIES πŸ”„

semanage policy stores data with multiple different file context types under the /var/lib/selinux directory. If you would like to store the data in a different directory, you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory, you would execute the following command:

semanage fcontext -a -e /var/lib/selinux /srv/selinux
restorecon -R -v /srv/selinux

That's you, relocating data like you're moving apartments. 🏠➑️🏑


πŸ“‚ STANDARD FILE CONTEXT πŸ“‚

SELinux defines the file context types for semanage. If you wanted to store files with these types in a different path, you need to execute the semanage command to specify alternate labeling and then use restorecon to put the labels on disk. It's a two-step process, bestie.

semanage fcontext -a -t semanage_store_t '/srv/semanage/content(/.*)?'
restorecon -R -v /srv/mysemanage_content
Note: SELinux often uses regular expressions to specify labels that match multiple files. So those (/.*)? bits are doing the heavy lifting. Regex girlies rise up. ✨

The following file types are defined for semanage:

semanage_exec_t

  • Set files with the semanage_exec_t type if you want to transition an executable to the semanage_t domain. So this is the "become a semanage process" type. VIP only. 🎟️

Paths:

/usr/bin/semanage, /usr/bin/semodule, /usr/libexec/selinux/selinux-
autorelabel, /usr/libexec/selinux/semanage_migrate_store,
/usr/share/system-config-selinux/selinux_server.py,
/usr/share/system-config-selinux/system-config-selinux-dbus.py

semanage_read_lock_t

  • Set files with the semanage_read_lock_t type if you want to treat the files as semanage read lock data, stored under the /var/lock directory. It's the "read lock" era. πŸ”’

Paths:

/etc/selinux/([^/]*/)?modules/semanage.read.LOCK,
/var/lib/selinux/[^/]+/semanage.read.LOCK

semanage_store_t

  • Set files with the semanage_store_t type if you want to treat the files as semanage store data. This is where the policy stuff lives. πŸ—„οΈ

Paths:

/etc/selinux/([^/]*/)?policy(/.*)?,
/etc/selinux/([^/]*/)?modules/(active|tmp|previous)(/.*)?,
/etc/selinux/(minimum|mls|targeted)/(active|tmp|previous)(/.*)?,
/var/lib/selinux(/.*)?, /etc/share/selinux/mls(/.*)?,
/etc/share/selinux/targeted(/.*)?

semanage_tmp_t

  • Set files with the semanage_tmp_t type if you want to store semanage temporary files in the /tmp directories. Temp files, but make them SELinux official. πŸ—‘οΈβœ¨

semanage_trans_lock_t

  • Set files with the semanage_trans_lock_t type if you want to treat the files as semanage trans lock data, stored under the /var/lock directory. Another lock type, because why not. πŸ”

Paths:

/etc/selinux/([^/]*/)?modules/semanage.trans.LOCK,
/var/lib/selinux/[^/]+/semanage.trans.LOCK
Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context, you need to use the semanage fcontext command. This will modify the SELinux labeling database. You will need to use restorecon to apply the labels. So chcon is the quick fix, semanage fcontext is the commitment. Choose wisely. πŸ’

πŸ› οΈ COMMANDS πŸ› οΈ

semanage fcontext can also be used to manipulate default file context mappings. It's the multi-tool of file contexts.

semanage permissive can also be used to manipulate whether or not a process type is permissive. So you can flip the "free pass" switch on and off.

semanage module can also be used to enable/disable/install/remove policy modules. Module management, slay.

semanage boolean can also be used to manipulate the booleans. That's the on/off switches we talked about earlier, but now you can control them directly.

system-config-selinux is a GUI tool available to customize SELinux policy settings. For the visual learners and clicky girls. πŸ–±οΈ


✍️ AUTHOR ✍️

This manual page was auto-generated using sepolicy manpage. So it wasn't even written by a human, it was birthed by a script. Still iconic though. πŸ€–πŸ’–


πŸ‘€ SEE ALSO πŸ‘€

selinux(8), semanage(8), semanage(8) (yes, it's listed twice, we love a double mention), restorecon(8), chcon(1), sepolicy(8), setsebool(8)


And that's the whole page, bestie! Thanks for reading, and remember: SELinux is just doing its best to keep your processes safe. Now go forth and semanage responsibly. πŸ’…βœ¨

semanage β€” 26-10-06 β€” semanage_selinux(8) 🫢

πŸ“¦ where this page comes from