Expand description
§selinux-sys
: Unsafe Rust bindings for libselinux
SELinux is a flexible Mandatory Access Control (MAC) for Linux.
This crate exposes neither deprecated nor undocumented SELinux API functions and types.
This crate is Linux-specific. Building it for non-Linux platforms, or for the Linux kernel, results in an empty crate.
§Supported environment variables
This crate depends on some environment variables, and variants of those.
For each environment variable (e.g., CC
), the following are the accepted
variants of it:
<var>_<target>
, e.g.,CC_aarch64-unknown-linux-gnu
.<var>_<target-with-underscores>
, e.g.,CC_aarch64_unknown_linux_gnu
.TARGET_<var>
, e.g.,TARGET_CC
.<var>
, e.g.,CC
.
The following environment variables (and their variants) affect how this crate is built:
SELINUX_STATIC
SELINUX_PATH
SELINUX_INCLUDE_DIR
SELINUX_LIB_DIR
SYSROOT
CC
CFLAGS
§Dynamic or static linking
This crate links to libselinux
dynamically if possible, except when targeting
platforms based on the musl
C library.
This behavior can be changed either by setting the environment variable
SELINUX_STATIC
to 1
, or by enabling the crate feature static
.
If both are defined, then the value of SELINUX_STATIC
takes precedence.
Setting SELINUX_STATIC
to 0
mandates dynamic linking.
§Finding SELinux library and headers
By default, this crate finds SELinux headers and library based on the default target C compiler.
This behavior can be changed by:
- Either defining the environment variable
SELINUX_PATH
to the path of a directory containing the sub-directoriesinclude
andlib
where the headers and library are installed. - Or by defining one or both of the environment variables
SELINUX_INCLUDE_DIR
andSELINUX_LIB_DIR
to paths to the directories where headers and library are present. IfSELINUX_PATH
is also defined, thenSELINUX_INCLUDE_DIR
andSELINUX_LIB_DIR
take precedence.
§Depending on this crate
This crate provides the following variables to other crates that depend on it:
DEP_SELINUX_INCLUDE
: Path of the directory where library C header files reside.DEP_SELINUX_LIB
: Path of the directory where the library binary resides.
§Versioning
This project adheres to Semantic Versioning.
The CHANGELOG.md
file details notable changes over time.
Modules§
Structs§
- SELboolean
- av_
decision - avc_
cache_ stats - avc_
entry - avc_
entry_ ref - avc_
lock_ callback - avc_
log_ callback - avc_
memory_ callback - avc_
thread_ callback - context_
s_ t - dir_
xattr - security_
class_ mapping - security_
id - selabel_
handle - selinux_
opt
Constants§
- AVC_
CACHE_ STATS - AVC_
CALLBACK_ AUDITALLOW_ DISABLE - AVC_
CALLBACK_ AUDITALLOW_ ENABLE - AVC_
CALLBACK_ AUDITDENY_ DISABLE - AVC_
CALLBACK_ AUDITDENY_ ENABLE - AVC_
CALLBACK_ GRANT - AVC_
CALLBACK_ RESET - AVC_
CALLBACK_ REVOKE - AVC_
CALLBACK_ TRY_ REVOKE - AVC_
OPT_ SETENFORCE - AVC_
OPT_ UNUSED - MATCHPATHCON_
BASEONLY - MATCHPATHCON_
NOTRANS - MATCHPATHCON_
VALIDATE - SECSID_
WILD - Unspecified SID.
- SELABEL_
CTX_ ANDROID_ PROP - SELABEL_
CTX_ ANDROID_ SERVICE - SELABEL_
CTX_ DB - SELABEL_
CTX_ FILE - SELABEL_
CTX_ MEDIA - SELABEL_
CTX_ X - SELABEL_
DB_ BLOB - SELABEL_
DB_ COLUMN - SELABEL_
DB_ DATABASE - SELABEL_
DB_ DATATYPE - SELABEL_
DB_ EXCEPTION - SELABEL_
DB_ LANGUAGE - SELABEL_
DB_ PROCEDURE - SELABEL_
DB_ SCHEMA - SELABEL_
DB_ SEQUENCE - SELABEL_
DB_ TABLE - SELABEL_
DB_ TUPLE - SELABEL_
DB_ VIEW - SELABEL_
NOPT - SELABEL_
OPT_ BASEONLY - SELABEL_
OPT_ DIGEST - SELABEL_
OPT_ PATH - SELABEL_
OPT_ SUBSET - SELABEL_
OPT_ UNUSED - SELABEL_
OPT_ VALIDATE - SELABEL_
X_ CLIENT - SELABEL_
X_ EVENT - SELABEL_
X_ EXT - SELABEL_
X_ POLYPROP - SELABEL_
X_ POLYSELN - SELABEL_
X_ PROP - SELABEL_
X_ SELN - SELINUX_
AVC - SELINUX_
AVD_ FLAGS_ PERMISSIVE - SELINUX_
CB_ AUDIT - SELINUX_
CB_ LOG - SELINUX_
CB_ POLICYLOAD - SELINUX_
CB_ SETENFORCE - SELINUX_
CB_ VALIDATE - SELINUX_
DEFAULTUSER - SELINUX_
ERROR - SELINUX_
INFO - SELINUX_
POLICYLOAD - SELINUX_
RESTORECON_ ABORT_ ON_ ERROR - SELINUX_
RESTORECON_ ADD_ ASSOC - SELINUX_
RESTORECON_ CONFLICT_ ERROR - SELINUX_
RESTORECON_ COUNT_ ERRORS - SELINUX_
RESTORECON_ IGNORE_ DIGEST - SELINUX_
RESTORECON_ IGNORE_ MOUNTS - SELINUX_
RESTORECON_ IGNORE_ NOENTRY - SELINUX_
RESTORECON_ LOG_ MATCHES - SELINUX_
RESTORECON_ MASS_ RELABEL - SELINUX_
RESTORECON_ NOCHANGE - SELINUX_
RESTORECON_ PROGRESS - SELINUX_
RESTORECON_ REALPATH - SELINUX_
RESTORECON_ RECURSE - SELINUX_
RESTORECON_ SET_ SPECFILE_ CTX - SELINUX_
RESTORECON_ SKIP_ DIGEST - SELINUX_
RESTORECON_ SYSLOG_ CHANGES - SELINUX_
RESTORECON_ VERBOSE - SELINUX_
RESTORECON_ XATTR_ DELETE_ ALL_ DIGESTS - SELINUX_
RESTORECON_ XATTR_ DELETE_ NONMATCH_ DIGESTS - SELINUX_
RESTORECON_ XATTR_ IGNORE_ MOUNTS - SELINUX_
RESTORECON_ XATTR_ RECURSE - SELINUX_
RESTORECON_ XDEV - SELINUX_
SETENFORCE - SELINUX_
TRANS_ DIR - SELINUX_
WARNING
Functions§
- avc_
add_ ⚠callback - avc_
audit ⚠ - avc_
av_ ⚠stats - avc_
cache_ ⚠stats - avc_
cleanup ⚠ - avc_
compute_ ⚠create - avc_
compute_ ⚠member - avc_
context_ ⚠to_ sid - avc_
context_ ⚠to_ sid_ raw - avc_
destroy ⚠ - avc_
entry_ ⚠ref_ init - Initialize an
avc_entry_ref
structure. - avc_
get_ ⚠initial_ sid - avc_
has_ ⚠perm - avc_
has_ ⚠perm_ noaudit - avc_
netlink_ ⚠acquire_ fd - avc_
netlink_ ⚠check_ nb - avc_
netlink_ ⚠close - avc_
netlink_ ⚠loop - avc_
netlink_ ⚠open - avc_
netlink_ ⚠release_ fd - avc_
open ⚠ - avc_
reset ⚠ - avc_
sid_ ⚠stats - avc_
sid_ ⚠to_ context - avc_
sid_ ⚠to_ context_ raw - context_
free ⚠ - context_
new ⚠ - context_
range_ ⚠get - context_
range_ ⚠set - context_
role_ ⚠get - context_
role_ ⚠set - context_
str ⚠ - context_
type_ ⚠get - context_
type_ ⚠set - context_
user_ ⚠get - context_
user_ ⚠set - fgetfilecon⚠
- fgetfilecon_
raw ⚠ - fini_
selinuxmnt ⚠ - freecon⚠
- freeconary⚠
- fsetfilecon⚠
- fsetfilecon_
raw ⚠ - get_
default_ ⚠context - get_
default_ ⚠context_ with_ level - get_
default_ ⚠context_ with_ role - get_
default_ ⚠context_ with_ rolelevel - get_
default_ ⚠type - get_
ordered_ ⚠context_ list - get_
ordered_ ⚠context_ list_ with_ level - getcon⚠
- getcon_
raw ⚠ - getexeccon⚠
- getexeccon_
raw ⚠ - getfilecon⚠
- getfilecon_
raw ⚠ - getfscreatecon⚠
- getfscreatecon_
raw ⚠ - getkeycreatecon⚠
- getkeycreatecon_
raw ⚠ - getpeercon⚠
- getpeercon_
raw ⚠ - getpidcon⚠
- getpidcon_
raw ⚠ - getprevcon⚠
- getprevcon_
raw ⚠ - getseuser⚠
- getseuserbyname⚠
- getsockcreatecon⚠
- getsockcreatecon_
raw ⚠ - is_
context_ ⚠customizable - is_
selinux_ ⚠enabled - is_
selinux_ ⚠mls_ enabled - lgetfilecon⚠
- lgetfilecon_
raw ⚠ - lsetfilecon⚠
- lsetfilecon_
raw ⚠ - manual_
user_ ⚠enter_ context - matchmediacon⚠
- matchpathcon_
checkmatches ⚠ - matchpathcon_
filespec_ ⚠add - matchpathcon_
filespec_ ⚠destroy - matchpathcon_
filespec_ ⚠eval - mode_
to_ ⚠security_ class - print_
access_ ⚠vector - query_
user_ ⚠context - security_
av_ ⚠perm_ to_ string - security_
av_ ⚠string - security_
canonicalize_ ⚠context - security_
canonicalize_ ⚠context_ raw - security_
check_ ⚠context - security_
check_ ⚠context_ raw - security_
class_ ⚠to_ string - security_
commit_ ⚠booleans - security_
compute_ ⚠av - security_
compute_ ⚠av_ flags - security_
compute_ ⚠av_ flags_ raw - security_
compute_ ⚠av_ raw - security_
compute_ ⚠create - security_
compute_ ⚠create_ name - security_
compute_ ⚠create_ name_ raw - security_
compute_ ⚠create_ raw - security_
compute_ ⚠member - security_
compute_ ⚠member_ raw - security_
compute_ ⚠relabel - security_
compute_ ⚠relabel_ raw - security_
deny_ ⚠unknown - security_
disable ⚠ - security_
get_ ⚠boolean_ active - security_
get_ ⚠boolean_ names - security_
get_ ⚠boolean_ pending - security_
get_ ⚠checkreqprot - security_
get_ ⚠initial_ context - security_
get_ ⚠initial_ context_ raw - security_
getenforce ⚠ - security_
load_ ⚠policy - security_
policyvers ⚠ - security_
reject_ ⚠unknown - security_
set_ ⚠boolean - security_
set_ ⚠boolean_ list - security_
setenforce ⚠ - security_
validatetrans ⚠ - security_
validatetrans_ ⚠raw - selabel_
close ⚠ - selabel_
cmp ⚠ - selabel_
digest ⚠ - selabel_
get_ ⚠digests_ all_ partial_ matches - selabel_
hash_ ⚠all_ partial_ matches - selabel_
lookup ⚠ - selabel_
lookup_ ⚠best_ match - selabel_
lookup_ ⚠best_ match_ raw - selabel_
lookup_ ⚠raw - selabel_
open ⚠ - selabel_
partial_ ⚠match - selabel_
stats ⚠ - selinux_
binary_ ⚠policy_ path - selinux_
boolean_ ⚠sub - selinux_
booleans_ ⚠subs_ path - selinux_
check_ ⚠access - selinux_
check_ ⚠securetty_ context - selinux_
colors_ ⚠path - selinux_
contexts_ ⚠path - selinux_
current_ ⚠policy_ path - selinux_
customizable_ ⚠types_ path - selinux_
default_ ⚠context_ path - selinux_
default_ ⚠type_ path - selinux_
failsafe_ ⚠context_ path - selinux_
file_ ⚠context_ cmp - selinux_
file_ ⚠context_ homedir_ path - selinux_
file_ ⚠context_ local_ path - selinux_
file_ ⚠context_ path - selinux_
file_ ⚠context_ subs_ dist_ path - selinux_
file_ ⚠context_ subs_ path - selinux_
file_ ⚠context_ verify - selinux_
flush_ ⚠class_ cache - selinux_
get_ ⚠callback - selinux_
getenforcemode ⚠ - selinux_
getpolicytype ⚠ - selinux_
homedir_ ⚠context_ path - selinux_
init_ ⚠load_ policy - selinux_
lsetfilecon_ ⚠default - selinux_
lxc_ ⚠contexts_ path - selinux_
media_ ⚠context_ path - selinux_
mkload_ ⚠policy - selinux_
netfilter_ ⚠context_ path - selinux_
openrc_ ⚠contexts_ path - selinux_
openssh_ ⚠contexts_ path - selinux_
path ⚠ - selinux_
policy_ ⚠root - selinux_
raw_ ⚠context_ to_ color - selinux_
raw_ ⚠to_ trans_ context - selinux_
removable_ ⚠context_ path - selinux_
reset_ ⚠config - selinux_
restorecon ⚠ - selinux_
restorecon_ ⚠default_ handle - selinux_
restorecon_ ⚠get_ skipped_ errors - selinux_
restorecon_ ⚠parallel - selinux_
restorecon_ ⚠set_ alt_ rootpath - selinux_
restorecon_ ⚠set_ exclude_ list - selinux_
restorecon_ ⚠set_ sehandle - selinux_
restorecon_ ⚠xattr - selinux_
securetty_ ⚠types_ path - selinux_
sepgsql_ ⚠context_ path - selinux_
set_ ⚠callback - selinux_
set_ ⚠mapping - selinux_
set_ ⚠policy_ root - selinux_
snapperd_ ⚠contexts_ path - selinux_
status_ ⚠close - selinux_
status_ ⚠deny_ unknown - selinux_
status_ ⚠getenforce - selinux_
status_ ⚠open - selinux_
status_ ⚠policyload - selinux_
status_ ⚠updated - selinux_
systemd_ ⚠contexts_ path - selinux_
trans_ ⚠to_ raw_ context - selinux_
translations_ ⚠path - selinux_
user_ ⚠contexts_ path - selinux_
usersconf_ ⚠path - selinux_
virtual_ ⚠domain_ context_ path - selinux_
virtual_ ⚠image_ context_ path - selinux_
x_ ⚠context_ path - set_
matchpathcon_ ⚠canoncon - set_
matchpathcon_ ⚠flags - set_
matchpathcon_ ⚠invalidcon - set_
matchpathcon_ ⚠printf - set_
selinuxmnt ⚠ - setcon⚠
- setcon_
raw ⚠ - setexeccon⚠
- setexeccon_
raw ⚠ - setfilecon⚠
- setfilecon_
raw ⚠ - setfscreatecon⚠
- setfscreatecon_
raw ⚠ - setkeycreatecon⚠
- setkeycreatecon_
raw ⚠ - setsockcreatecon⚠
- setsockcreatecon_
raw ⚠ - string_
to_ ⚠av_ perm - string_
to_ ⚠security_ class