1*2d543d20SAndroid Build Coastguard WorkerSELinux Userspace 2*2d543d20SAndroid Build Coastguard Worker================= 3*2d543d20SAndroid Build Coastguard Worker 4*2d543d20SAndroid Build Coastguard Worker 5*2d543d20SAndroid Build Coastguard Worker[](https://github.com/SELinuxProject/selinux/actions/workflows/run_tests.yml) 6*2d543d20SAndroid Build Coastguard Worker[](https://github.com/SELinuxProject/selinux/actions/workflows/vm_testsuite.yml) 7*2d543d20SAndroid Build Coastguard Worker[](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#selinux) 8*2d543d20SAndroid Build Coastguard Worker[](https://github.com/SELinuxProject/selinux/actions/workflows/cifuzz.yml) 9*2d543d20SAndroid Build Coastguard Worker 10*2d543d20SAndroid Build Coastguard WorkerSELinux is a flexible Mandatory Access Control (MAC) system built into the 11*2d543d20SAndroid Build Coastguard WorkerLinux Kernel. SELinux provides administrators with a comprehensive access 12*2d543d20SAndroid Build Coastguard Workercontrol mechanism that enables greater access granularity over the existing 13*2d543d20SAndroid Build Coastguard WorkerLinux Discretionary Access Controls (DAC) and is present in many major Linux 14*2d543d20SAndroid Build Coastguard Workerdistributions. This repository contains the sources for the SELinux utilities 15*2d543d20SAndroid Build Coastguard Workerand system libraries which allow for the configuration and management of an 16*2d543d20SAndroid Build Coastguard WorkerSELinux-based system. 17*2d543d20SAndroid Build Coastguard Worker 18*2d543d20SAndroid Build Coastguard WorkerPlease submit all bug reports and patches to the <[email protected]> 19*2d543d20SAndroid Build Coastguard Workermailing list. You can subscribe by sending "subscribe selinux" in the body of 20*2d543d20SAndroid Build Coastguard Workeran email to <[email protected]>. Archives of the mailing list are 21*2d543d20SAndroid Build Coastguard Workeravailable at https://lore.kernel.org/selinux. 22*2d543d20SAndroid Build Coastguard Worker 23*2d543d20SAndroid Build Coastguard WorkerInstallation 24*2d543d20SAndroid Build Coastguard Worker------------ 25*2d543d20SAndroid Build Coastguard Worker 26*2d543d20SAndroid Build Coastguard WorkerSELinux libraries and tools are packaged in several Linux distributions: 27*2d543d20SAndroid Build Coastguard Worker 28*2d543d20SAndroid Build Coastguard Worker* Alpine Linux (https://pkgs.alpinelinux.org/package/edge/testing/x86/policycoreutils) 29*2d543d20SAndroid Build Coastguard Worker* Arch Linux User Repository (https://aur.archlinux.org/packages/policycoreutils/) 30*2d543d20SAndroid Build Coastguard Worker* Buildroot (https://git.buildroot.net/buildroot/tree/package/policycoreutils) 31*2d543d20SAndroid Build Coastguard Worker* Debian and Ubuntu (https://packages.debian.org/sid/policycoreutils) 32*2d543d20SAndroid Build Coastguard Worker* Gentoo (https://packages.gentoo.org/packages/sys-apps/policycoreutils) 33*2d543d20SAndroid Build Coastguard Worker* RHEL and Fedora (https://src.fedoraproject.org/rpms/policycoreutils) 34*2d543d20SAndroid Build Coastguard Worker* Yocto Project (http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/tree/recipes-security/selinux) 35*2d543d20SAndroid Build Coastguard Worker* and many more (https://repology.org/project/policycoreutils/versions) 36*2d543d20SAndroid Build Coastguard Worker 37*2d543d20SAndroid Build Coastguard Worker 38*2d543d20SAndroid Build Coastguard WorkerBuilding and testing 39*2d543d20SAndroid Build Coastguard Worker-------------------- 40*2d543d20SAndroid Build Coastguard Worker 41*2d543d20SAndroid Build Coastguard WorkerBuild dependencies on Fedora: 42*2d543d20SAndroid Build Coastguard Worker 43*2d543d20SAndroid Build Coastguard Worker```sh 44*2d543d20SAndroid Build Coastguard Worker# For C libraries and programs 45*2d543d20SAndroid Build Coastguard Workerdnf install \ 46*2d543d20SAndroid Build Coastguard Worker audit-libs-devel \ 47*2d543d20SAndroid Build Coastguard Worker bison \ 48*2d543d20SAndroid Build Coastguard Worker bzip2-devel \ 49*2d543d20SAndroid Build Coastguard Worker CUnit-devel \ 50*2d543d20SAndroid Build Coastguard Worker diffutils \ 51*2d543d20SAndroid Build Coastguard Worker flex \ 52*2d543d20SAndroid Build Coastguard Worker gcc \ 53*2d543d20SAndroid Build Coastguard Worker gettext \ 54*2d543d20SAndroid Build Coastguard Worker glib2-devel \ 55*2d543d20SAndroid Build Coastguard Worker make \ 56*2d543d20SAndroid Build Coastguard Worker libcap-devel \ 57*2d543d20SAndroid Build Coastguard Worker libcap-ng-devel \ 58*2d543d20SAndroid Build Coastguard Worker pam-devel \ 59*2d543d20SAndroid Build Coastguard Worker pcre2-devel \ 60*2d543d20SAndroid Build Coastguard Worker xmlto 61*2d543d20SAndroid Build Coastguard Worker 62*2d543d20SAndroid Build Coastguard Worker# For Python and Ruby bindings 63*2d543d20SAndroid Build Coastguard Workerdnf install \ 64*2d543d20SAndroid Build Coastguard Worker python3-devel \ 65*2d543d20SAndroid Build Coastguard Worker python3-pip \ 66*2d543d20SAndroid Build Coastguard Worker python3-setuptools \ 67*2d543d20SAndroid Build Coastguard Worker python3-wheel \ 68*2d543d20SAndroid Build Coastguard Worker ruby-devel \ 69*2d543d20SAndroid Build Coastguard Worker swig 70*2d543d20SAndroid Build Coastguard Worker``` 71*2d543d20SAndroid Build Coastguard Worker 72*2d543d20SAndroid Build Coastguard WorkerBuild dependencies on Debian: 73*2d543d20SAndroid Build Coastguard Worker 74*2d543d20SAndroid Build Coastguard Worker```sh 75*2d543d20SAndroid Build Coastguard Worker# For C libraries and programs 76*2d543d20SAndroid Build Coastguard Workerapt-get install --no-install-recommends --no-install-suggests \ 77*2d543d20SAndroid Build Coastguard Worker bison \ 78*2d543d20SAndroid Build Coastguard Worker flex \ 79*2d543d20SAndroid Build Coastguard Worker gawk \ 80*2d543d20SAndroid Build Coastguard Worker gcc \ 81*2d543d20SAndroid Build Coastguard Worker gettext \ 82*2d543d20SAndroid Build Coastguard Worker make \ 83*2d543d20SAndroid Build Coastguard Worker libaudit-dev \ 84*2d543d20SAndroid Build Coastguard Worker libbz2-dev \ 85*2d543d20SAndroid Build Coastguard Worker libcap-dev \ 86*2d543d20SAndroid Build Coastguard Worker libcap-ng-dev \ 87*2d543d20SAndroid Build Coastguard Worker libcunit1-dev \ 88*2d543d20SAndroid Build Coastguard Worker libglib2.0-dev \ 89*2d543d20SAndroid Build Coastguard Worker libpcre2-dev \ 90*2d543d20SAndroid Build Coastguard Worker pkgconf \ 91*2d543d20SAndroid Build Coastguard Worker python3 \ 92*2d543d20SAndroid Build Coastguard Worker systemd \ 93*2d543d20SAndroid Build Coastguard Worker xmlto 94*2d543d20SAndroid Build Coastguard Worker 95*2d543d20SAndroid Build Coastguard Worker# For Python and Ruby bindings 96*2d543d20SAndroid Build Coastguard Workerapt-get install --no-install-recommends --no-install-suggests \ 97*2d543d20SAndroid Build Coastguard Worker python3-dev \ 98*2d543d20SAndroid Build Coastguard Worker python3-pip \ 99*2d543d20SAndroid Build Coastguard Worker python3-setuptools \ 100*2d543d20SAndroid Build Coastguard Worker python3-wheel \ 101*2d543d20SAndroid Build Coastguard Worker ruby-dev \ 102*2d543d20SAndroid Build Coastguard Worker swig 103*2d543d20SAndroid Build Coastguard Worker``` 104*2d543d20SAndroid Build Coastguard Worker 105*2d543d20SAndroid Build Coastguard WorkerTo build and install everything under a private directory, run: 106*2d543d20SAndroid Build Coastguard Worker 107*2d543d20SAndroid Build Coastguard Worker make clean distclean 108*2d543d20SAndroid Build Coastguard Worker 109*2d543d20SAndroid Build Coastguard Worker make DESTDIR=~/obj install install-rubywrap install-pywrap 110*2d543d20SAndroid Build Coastguard Worker 111*2d543d20SAndroid Build Coastguard WorkerOn Debian the environment variable `DEB_PYTHON_INSTALL_LAYOUT` needs to be set 112*2d543d20SAndroid Build Coastguard Workerto `deb` when installing the Python wrappers in order to create the correct 113*2d543d20SAndroid Build Coastguard WorkerPython directory structure. 114*2d543d20SAndroid Build Coastguard WorkerOn Debian systems older than bookworm set 115*2d543d20SAndroid Build Coastguard Worker`PYTHON_SETUP_ARGS='--install-option "--install-layout=deb"'` instead. 116*2d543d20SAndroid Build Coastguard Worker 117*2d543d20SAndroid Build Coastguard WorkerTo run tests with the built libraries and programs, several paths (relative to `$DESTDIR`) need to be added to variables `$LD_LIBRARY_PATH`, `$PATH` and `$PYTHONPATH`. 118*2d543d20SAndroid Build Coastguard WorkerThis can be done using [./scripts/env_use_destdir](./scripts/env_use_destdir): 119*2d543d20SAndroid Build Coastguard Worker 120*2d543d20SAndroid Build Coastguard Worker DESTDIR=~/obj ./scripts/env_use_destdir make test 121*2d543d20SAndroid Build Coastguard Worker 122*2d543d20SAndroid Build Coastguard WorkerSome tests require the reference policy to be installed (for example in `python/sepolgen`). 123*2d543d20SAndroid Build Coastguard Worker 124*2d543d20SAndroid Build Coastguard WorkerTo install as the default system libraries and binaries 125*2d543d20SAndroid Build Coastguard Worker(overwriting any previously installed ones - dangerous!), 126*2d543d20SAndroid Build Coastguard Workeron x86_64, run: 127*2d543d20SAndroid Build Coastguard Worker 128*2d543d20SAndroid Build Coastguard Worker make LIBDIR=/usr/lib64 SHLIBDIR=/lib64 install install-pywrap relabel 129*2d543d20SAndroid Build Coastguard Worker 130*2d543d20SAndroid Build Coastguard Workeror on x86 (32-bit), run: 131*2d543d20SAndroid Build Coastguard Worker 132*2d543d20SAndroid Build Coastguard Worker make install install-pywrap relabel 133*2d543d20SAndroid Build Coastguard Worker 134*2d543d20SAndroid Build Coastguard WorkerThis may render your system unusable if the upstream SELinux userspace 135*2d543d20SAndroid Build Coastguard Workerlacks library functions or other dependencies relied upon by your 136*2d543d20SAndroid Build Coastguard Workerdistribution. If it breaks, you get to keep both pieces. 137*2d543d20SAndroid Build Coastguard Worker 138*2d543d20SAndroid Build Coastguard Worker 139*2d543d20SAndroid Build Coastguard Worker## Setting CFLAGS 140*2d543d20SAndroid Build Coastguard Worker 141*2d543d20SAndroid Build Coastguard WorkerSetting CFLAGS during the make process will cause the omission of many defaults. While the project strives 142*2d543d20SAndroid Build Coastguard Workerto provide a reasonable set of default flags, custom CFLAGS could break the build, or have other undesired 143*2d543d20SAndroid Build Coastguard Workerchanges on the build output. Thus, be very careful when setting CFLAGS. CFLAGS that are encouraged to be 144*2d543d20SAndroid Build Coastguard Workerset when overriding are: 145*2d543d20SAndroid Build Coastguard Worker 146*2d543d20SAndroid Build Coastguard Worker- -fno-semantic-interposition for gcc or compilers that do not do this. clang does this by default. clang-10 and up 147*2d543d20SAndroid Build Coastguard Worker will support passing this flag, but ignore it. Previous clang versions fail. 148*2d543d20SAndroid Build Coastguard Worker 149*2d543d20SAndroid Build Coastguard Worker 150*2d543d20SAndroid Build Coastguard WorkermacOS 151*2d543d20SAndroid Build Coastguard Worker----- 152*2d543d20SAndroid Build Coastguard Worker 153*2d543d20SAndroid Build Coastguard WorkerTo install libsepol on macOS (mainly for policy analysis): 154*2d543d20SAndroid Build Coastguard Worker 155*2d543d20SAndroid Build Coastguard Worker cd libsepol; make PREFIX=/usr/local install 156*2d543d20SAndroid Build Coastguard Worker 157*2d543d20SAndroid Build Coastguard WorkerThis requires GNU coreutils: 158*2d543d20SAndroid Build Coastguard Worker 159*2d543d20SAndroid Build Coastguard Worker brew install coreutils 160