default_contexts(5)
π default_contexts(5) β the SELinux default contexts config file π
okay bestie, so default_contexts(5)?? it's a whole manual page for the SELinux configuration file situation and honestly it's giving "quiet file, big job" energy. let's get into it π«Ά
β¨ NAME β¨
default_contexts β the SELinux default contexts configuration file, no cap. it's the file and it's literally called "default contexts." iconic naming tbh π
πΈ DESCRIPTION πΈ
so the default contexts configuration file, default_contexts, contains entries that let SELinux-aware login applications β think PAM(8) and its whole friend group β do their thing. like, they read this file to figure out which contexts they're allowed to use. slay.
SELinux-aware login applications generally use one or more of these libselinux functions, and every single one of them reads these files from the active policy path:
get_default_context(3)get_ordered_context_list(3)get_ordered_context_list_with_level(3)get_default_context_with_level(3)get_default_context_with_role(3)get_default_context_with_rolelevel(3)query_user_context(3)manual_user_enter_context(3)
okay so which file do they actually open?? the default context configuration file path for the active policy is returned by selinux_default_contexts_path(3). β¨ the default, default contexts file is:
/etc/selinux/{SELINUXTYPE}/contexts/default_contexts
and where does {SELINUXTYPE} come from?? it's the entry from the selinux configuration file config (peep selinux_config(5) for the deets). π¦
π FILE FORMAT π
every line in the default configuration file is built like this:
login_process user_login_process [user_login_process] ...
where, bestie, let me break it down:
login_processβ this one consists of arole:type[:range]entry that represents the login process context that are defined in the policy. (yes, that's the original phrasing, we keep the facts, we don't touch the grammar π)user_login_processβ this one consists of one or morerole:type[:range]entries that represent the user login process context defined in the policy. plural energy, multiple entries, we love to see it π
β reminder: therole:type[:range]shape is the whole moment here.roleandtypeare mandatory-ish in the pattern,rangeis the optional little cherry on top in the brackets. and yes,user_login_processcan appear more than once β that's the[user_login_process] ...part doing its thing. π
π₯ EXAMPLE π₯
here's what it actually looks like in the wild, fr fr:
# ./contexts/default_contexts
system_r:crond_t:s0 system_r:system_crond_t:s0
system_r:local_login_t:s0 user_r:user_t:s0 staff_r:staff_t:s0
system_r:remote_login_t:s0 user_r:user_t:s0
system_r:sshd_t:s0 user_r:user_t:s0
system_r:sulogin_t:s0 sysadm_r:sysadm_t:s0
system_r:xdm_t:s0 user_r:user_t:s0
see how local_login_t gets two user login processes while the others get one?? that's the [user_login_process] ... flex right there. ate. π
β¨
π SEE ALSO π
go read these next, i'm obsessed with them:
selinux(8)selinux_default_contexts_path(3)PAM(8)selinux_default_type_path(3)get_default_context(3)get_ordered_context_list(3)get_ordered_context_list_with_level(3)get_default_context_with_level(3)get_default_context_with_role(3)get_default_context_with_rolelevel(3)query_user_context(3)manual_user_enter_context(3)selinux_config(5)
and that's the whole page, bestie!! π«Ά this one's from Security Enhanced Linux, dated 28-Nov-2011, and it's the default_contexts(5) page β so if you ever need to know how login processes and user login processes get matched up, you know exactly where to look. mwah. πππ¦
π¦ where this page comes from
- alpine 3.24: libselinux-doc 3.10-r1 Β· Public-Domain
- centos-stream 10: libselinux-utils 3.11-3.el10 Β· LicenseRef-Fedora-Public-Domain
- centos-stream 9: libselinux-utils 3.6-5.el9 Β· Public Domain
- debian bookworm: selinux-utils 3.4-1+b6
- debian trixie: selinux-utils 3.8.1-1 Β· LicenseRef-public-domain
- fedora 43: libselinux-utils 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- nixos 26.05: libselinux 3.10
- nixpkgs unstable: libselinux 3.11
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- ubuntu jammy: selinux-utils 3.3-1build2
- ubuntu noble: selinux-utils 3.5-2ubuntu2 Β· LicenseRef-public-domain
- ubuntu noble: selinux-utils 3.5-2ubuntu2.1 Β· LicenseRef-public-domain
- ubuntu questing: selinux-utils 3.8.1-1build1
- ubuntu resolute: selinux-utils 3.9-4build1 Β· LicenseRef-public-domain
- ubuntu stonking: selinux-utils 3.11-2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms