|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| .circleci/ | H | 25-Apr-2025 | - | 42 | 29 |
| .github/workflows/ | H | 25-Apr-2025 | - | 280 | 223 |
| checkpolicy/ | H | 25-Apr-2025 | - | 15,008 | 12,796 |
| dbus/ | H | 25-Apr-2025 | - | 672 | 546 |
| gui/ | H | 25-Apr-2025 | - | 95,364 | 76,398 |
| libselinux/ | H | 25-Apr-2025 | - | 35,214 | 27,642 |
| libsemanage/ | H | 25-Apr-2025 | - | 39,710 | 28,358 |
| libsepol/ | H | 25-Apr-2025 | - | 140,819 | 105,641 |
| mcstrans/ | H | 25-Apr-2025 | - | 6,134 | 4,699 |
| policycoreutils/ | H | 25-Apr-2025 | - | 181,856 | 143,977 |
| python/ | H | 25-Apr-2025 | - | 374,198 | 301,330 |
| restorecond/ | H | 25-Apr-2025 | - | 1,997 | 1,435 |
| sandbox/ | H | 25-Apr-2025 | - | 6,522 | 5,315 |
| scripts/ | H | 25-Apr-2025 | - | 746 | 459 |
| secilc/ | H | 25-Apr-2025 | - | 10,527 | 8,524 |
| semodule-utils/ | H | 25-Apr-2025 | - | 1,464 | 1,217 |
| .gitignore | H A D | 25-Apr-2025 | 277 | 28 | 25 |
| Android.bp | H A D | 25-Apr-2025 | 1.4 KiB | 44 | 41 |
| CONTRIBUTING.md | H A D | 25-Apr-2025 | 3.6 KiB | 88 | 61 |
| CleanSpec.mk | H A D | 25-Apr-2025 | 310 | 7 | 3 |
| LICENSE | H A D | 25-Apr-2025 | 289 | 6 | 5 |
| METADATA | H A D | 25-Apr-2025 | 558 | 20 | 18 |
| MODULE_LICENSE_GPL | HD | 25-Apr-2025 | 0 | | |
| Makefile | H A D | 25-Apr-2025 | 1.3 KiB | 53 | 46 |
| NOTICE | H A D | 25-Apr-2025 | 106.1 KiB | 2,061 | 1,704 |
| OWNERS | H A D | 25-Apr-2025 | 34 | 3 | 2 |
| README.android | H A D | 25-Apr-2025 | 1.7 KiB | 42 | 31 |
| README.md | H A D | 25-Apr-2025 | 5.4 KiB | 160 | 123 |
| SECURITY.md | H A D | 25-Apr-2025 | 3.1 KiB | 64 | 52 |
| VERSION | H A D | 25-Apr-2025 | 4 | 2 | 1 |
README.android
1This fork of Android differs in the following ways:
2 - README.android
3 - All Android.mk and Android.bp files
4 - ALL MODULE_LICENSE_* files
5 - libselinux/include/selinux/android.h
6 - libselinux/src/android/android.c
7
8All other changes should be upstreamed to selinux as
9Android no longer carries changes outside of those files.
10
11The upstream project can be found at:
12https://github.com/SELinuxProject/selinux
13
14Thus, since all changes are in separate files, updates merged from
15upstream should occur with no merge conflicts.
16
17This fork differs from upstream libselinux in at least the following ways:
18
19* The Android fork omits compiling many of the src files and specifies
20 custom build configurations. The exact details, are encoded in the
21 Android.bp and Android.mk files.
22
23* The SELinux policy files are all located in / rather than under
24 /etc/selinux since /etc is not available in Android until /system
25 is mounted and use fixed paths, not dependent on /etc/selinux/config.
26
27* The kernel policy file (sepolicy in Android, policy.N in Linux) does
28 not include a version suffix since Android does not need to support
29 booting multiple kernels.
30
31* The policy loading logic does not support automatic downgrading of
32 the kernel policy file to a version known to the kernel, since this
33 requires libsepol on the device and is only needed to support mixing
34 and matching kernels and userspace easily.
35
36* restorecon functionality, including recursive restorecon, has been
37 been upstreamed as selinux_restorecon(), but there are residual
38 differences between it and selinux_android_restorecon().
39
40* Support for seapp_contexts, a new Android-specific SELinux
41 configuration file has been added within android.c.
42
README.md
1SELinux Userspace
2=================
3
4
5[](https://github.com/SELinuxProject/selinux/actions/workflows/run_tests.yml)
6[](https://github.com/SELinuxProject/selinux/actions/workflows/vm_testsuite.yml)
7[](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#selinux)
8[](https://github.com/SELinuxProject/selinux/actions/workflows/cifuzz.yml)
9
10SELinux is a flexible Mandatory Access Control (MAC) system built into the
11Linux Kernel. SELinux provides administrators with a comprehensive access
12control mechanism that enables greater access granularity over the existing
13Linux Discretionary Access Controls (DAC) and is present in many major Linux
14distributions. This repository contains the sources for the SELinux utilities
15and system libraries which allow for the configuration and management of an
16SELinux-based system.
17
18Please submit all bug reports and patches to the <[email protected]>
19mailing list. You can subscribe by sending "subscribe selinux" in the body of
20an email to <[email protected]>. Archives of the mailing list are
21available at https://lore.kernel.org/selinux.
22
23Installation
24------------
25
26SELinux libraries and tools are packaged in several Linux distributions:
27
28* Alpine Linux (https://pkgs.alpinelinux.org/package/edge/testing/x86/policycoreutils)
29* Arch Linux User Repository (https://aur.archlinux.org/packages/policycoreutils/)
30* Buildroot (https://git.buildroot.net/buildroot/tree/package/policycoreutils)
31* Debian and Ubuntu (https://packages.debian.org/sid/policycoreutils)
32* Gentoo (https://packages.gentoo.org/packages/sys-apps/policycoreutils)
33* RHEL and Fedora (https://src.fedoraproject.org/rpms/policycoreutils)
34* Yocto Project (http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/tree/recipes-security/selinux)
35* and many more (https://repology.org/project/policycoreutils/versions)
36
37
38Building and testing
39--------------------
40
41Build dependencies on Fedora:
42
43```sh
44# For C libraries and programs
45dnf install \
46 audit-libs-devel \
47 bison \
48 bzip2-devel \
49 CUnit-devel \
50 diffutils \
51 flex \
52 gcc \
53 gettext \
54 glib2-devel \
55 make \
56 libcap-devel \
57 libcap-ng-devel \
58 pam-devel \
59 pcre2-devel \
60 xmlto
61
62# For Python and Ruby bindings
63dnf install \
64 python3-devel \
65 python3-pip \
66 python3-setuptools \
67 python3-wheel \
68 ruby-devel \
69 swig
70```
71
72Build dependencies on Debian:
73
74```sh
75# For C libraries and programs
76apt-get install --no-install-recommends --no-install-suggests \
77 bison \
78 flex \
79 gawk \
80 gcc \
81 gettext \
82 make \
83 libaudit-dev \
84 libbz2-dev \
85 libcap-dev \
86 libcap-ng-dev \
87 libcunit1-dev \
88 libglib2.0-dev \
89 libpcre2-dev \
90 pkgconf \
91 python3 \
92 systemd \
93 xmlto
94
95# For Python and Ruby bindings
96apt-get install --no-install-recommends --no-install-suggests \
97 python3-dev \
98 python3-pip \
99 python3-setuptools \
100 python3-wheel \
101 ruby-dev \
102 swig
103```
104
105To build and install everything under a private directory, run:
106
107 make clean distclean
108
109 make DESTDIR=~/obj install install-rubywrap install-pywrap
110
111On Debian the environment variable `DEB_PYTHON_INSTALL_LAYOUT` needs to be set
112to `deb` when installing the Python wrappers in order to create the correct
113Python directory structure.
114On Debian systems older than bookworm set
115`PYTHON_SETUP_ARGS='--install-option "--install-layout=deb"'` instead.
116
117To 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`.
118This can be done using [./scripts/env_use_destdir](./scripts/env_use_destdir):
119
120 DESTDIR=~/obj ./scripts/env_use_destdir make test
121
122Some tests require the reference policy to be installed (for example in `python/sepolgen`).
123
124To install as the default system libraries and binaries
125(overwriting any previously installed ones - dangerous!),
126on x86_64, run:
127
128 make LIBDIR=/usr/lib64 SHLIBDIR=/lib64 install install-pywrap relabel
129
130or on x86 (32-bit), run:
131
132 make install install-pywrap relabel
133
134This may render your system unusable if the upstream SELinux userspace
135lacks library functions or other dependencies relied upon by your
136distribution. If it breaks, you get to keep both pieces.
137
138
139## Setting CFLAGS
140
141Setting CFLAGS during the make process will cause the omission of many defaults. While the project strives
142to provide a reasonable set of default flags, custom CFLAGS could break the build, or have other undesired
143changes on the build output. Thus, be very careful when setting CFLAGS. CFLAGS that are encouraged to be
144set when overriding are:
145
146- -fno-semantic-interposition for gcc or compilers that do not do this. clang does this by default. clang-10 and up
147 will support passing this flag, but ignore it. Previous clang versions fail.
148
149
150macOS
151-----
152
153To install libsepol on macOS (mainly for policy analysis):
154
155 cd libsepol; make PREFIX=/usr/local install
156
157This requires GNU coreutils:
158
159 brew install coreutils
160