Commit graph

2740 commits

Author SHA1 Message Date
Sandeep Patil
89f111d56a move file_context APIs out of libselinux_vendor
am: 73c8059639  -s ours

Change-Id: Ia83495e606f4b0f7bd376bd6f9e9b58edfa63c1f
2017-07-07 19:22:50 +00:00
Sandeep Patil
9e7258c260 move selinux policy loading APIs to platform libselinux
am: 5ec3b433ee  -s ours

Change-Id: Iacbf110c95c84bbc51b4835639dd8ec29722c461
2017-07-07 19:22:47 +00:00
Sandeep Patil
0ccaf5bdd8 refactor: move common parts of libselinux builds into defaults
am: f5addf2232  -s ours

Change-Id: I491aac4504a825924ce1f8c047a3c2dd05c610fa
2017-07-07 19:22:43 +00:00
Vijay Venkatraman
63bc32b848 Add libselinux_vendor
am: 1c8c58625d  -s ours

Change-Id: I24c31918e48f68178762220d85bf3418480550b1
2017-07-07 19:22:40 +00:00
Sandeep Patil
73c8059639 move file_context APIs out of libselinux_vendor
Also make sure label_file.c is compiled in all targets that libselinux
is built for.

Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-pick from commit 554b7e4e82)

Change-Id: I49259c6cd6543329fe399fc92e07f16dc54c6395
Merged-In: I7e06ad6cad13d157ba1fb6bfd23ce9ceddf3ba79
2017-07-06 14:55:39 -07:00
Sandeep Patil
5ec3b433ee move selinux policy loading APIs to platform libselinux
Bug: 37919668
Bug: 37343404
Test: build and boot

(cherry-pick from commit 43d548e365)

Change-Id: If0de84db4052c86350001de11fc804d9daca1630
Merged-In: I3dd56e786ca25c314b5c6880587445e496db39a9
2017-07-06 14:55:39 -07:00
Sandeep Patil
f5addf2232 refactor: move common parts of libselinux builds into defaults
Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-picked from commit 51428ba055)

Change-Id: If42d24d381839c2a39f8cff3fc82ce5d3073eeb7
Merged-In: I375a4a2926326a5f733f4a49348e1ffae086ffd6
2017-07-06 14:55:29 -07:00
Vijay Venkatraman
1c8c58625d Add libselinux_vendor
Removed dependency on libpackageparser
Retained dependency on libpcre2

android_seapp.c = non-vendor functions
android.c = functions common to vendor and non-vendor

exported_vendor.map contains map for libselinux_vendor

(cherry-picked from commit cc1666de05)

Bug: 37343404
Test: Build vndservicemanager, libselinux.so and libselinux_vendor.so
Verify normal boot on sailfish and pass CTS Security
Merged-In: I020b1333ad4628b831c94a27f07d880f73dbde7a

Change-Id: I0ffc621ceb53b3531df458611f1322ebecd2da20
2017-07-06 09:31:54 -07:00
Brian Murray
6ff047f744 Improve selinux utils wrappers
am: d72d78d969

Change-Id: I3beba3e041932d0e49b4261a689332c519d4e79b
2017-06-26 21:58:08 +00:00
Brian Murray
d72d78d969 Improve selinux utils wrappers
Added checks to wrapper scripts for selinux utils. Before running
commands, verify enviromental variables are set and that required files
exists. Return an error code in the event of failure.

Test: Verify audit2allow, audit2why, sediff, seinfo commands still run.
Test: Verify failure if prerequisites are not satisfied.

Change-Id: I3705a90e0a81704829aa5a5feedbfe22aec5fa55
Signed-off-by: Brian Murray <Brian@Clover.com>
2017-06-23 09:08:33 -07:00
Chih-Hung Hsieh
616bd37b00 Add OWNERS in external/selinux am: e1ef2190d5
am: 2062c81d9f

Change-Id: I907c33164b6b8dd4b6caf3df9686416c1f20253d
2017-06-22 21:11:27 +00:00
Chih-Hung Hsieh
2062c81d9f Add OWNERS in external/selinux
am: e1ef2190d5

Change-Id: I345e681a0809c63dcbb2891c88f82ffdb3806788
2017-06-22 21:07:23 +00:00
Chih-Hung Hsieh
e1ef2190d5 Add OWNERS in external/selinux
* Owners are selected from top CL approvals or owners.
  They will be suggested to review/approve future CLs.
* OWNERS files are recognized by the new find-owners plugin, see .md files in
  https://gerrit.googlesource.com/plugins/find-owners/+/master/src/main/resources/Documentation/

Test: build/make/tools/checkowners.py -c -v OWNERS
Change-Id: I23e0280ae8c42e251e2ca7fe0cc475fd333720a4
2017-06-22 12:17:12 -07:00
Jeff Vander Stoep
fc9e362950 Move non-treble devices to split file_contexts
am: 6ef44cbece

Change-Id: Ia60185a553c4240b5e3b592af91ef6f57aa6a3ef
2017-06-12 22:14:26 +00:00
Jeff Vander Stoep
6ef44cbece Move non-treble devices to split file_contexts
Bug: 38502071
Test: build and boot non-Treble Bullhead, run CTS tests below
Test: build and boot Treble Marlin, run CTS tests below
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testAospFileContexts
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testValidFileContexts
Change-Id: I8d37fa1b4f71af113b9751c65292a2e94d62b3d4
Merged-In: Ia3792e5e8c8d9ef7177d6e309a1e0df54bbf75a5
2017-06-10 04:16:10 +00:00
Jeff Vander Stoep
e5aad97f07 libsepol: migrate to soong
am: 22ffa0d0ae  -s ours

Change-Id: I717d16a2b59c633462cb2677b4609e73272a3af2
2017-06-06 03:54:35 +00:00
Jeff Vander Stoep
22ffa0d0ae libsepol: migrate to soong
Clean up build warning
1 warning generated.
[ 55% 4201/7636] cc
out/soong/.interme...nal/selinux/libsepol/cil/src/android.o
external/selinux/libsepol/cil/src/android.c:396:87: warning: unused
parameter 'args' [-Wunused-parameter]
static int cil_attrib_typepermissive(struct cil_tree_node *node,
struct version_args *args)

Bug: 37512442
Test: build and boot Marlin.
Change-Id: I83c4908ce7ca90cfbcb84455dd539db5f0b88c5a
(cherry picked from commit a762060607)
2017-06-05 08:08:22 -07:00
Tom Cherry
bc0510a1ab Use the same sources for linux_bionic and linux targets am: 3a5152cc05 am: a5546632ba
am: 1380aa7887

Change-Id: I7ade7752cd854613ddd01228addc8310458ce687
2017-05-12 21:57:02 +00:00
Tom Cherry
1380aa7887 Use the same sources for linux_bionic and linux targets am: 3a5152cc05
am: a5546632ba

Change-Id: I28f1e9a3965f96e31132c95a0623d97a1ce07096
2017-05-12 21:51:32 +00:00
Tom Cherry
a5546632ba Use the same sources for linux_bionic and linux targets
am: 3a5152cc05

Change-Id: Ief0461bcab77c0a0b979360269dea89839fb58b5
2017-05-12 21:49:48 +00:00
Tom Cherry
3a5152cc05 Use the same sources for linux_bionic and linux targets
Bug: 31559095
Test: Enable host bionic and build
Merged-In: If8b761fcaa0fab10727121660186fbbb1db32612
Change-Id: If8b761fcaa0fab10727121660186fbbb1db32612
2017-05-12 11:27:27 -07:00
Nick Kralevich
55b2dcc928 Merge remote-tracking branch 'aosp/upstream-master' into mymerge am: bab053dbca am: 5734074732
am: 936db8fc13

Change-Id: I9f8d3055e73b91d8adf8d2152b0ddf65b79ca8e3
2017-05-12 17:38:24 +00:00
Nick Kralevich
936db8fc13 Merge remote-tracking branch 'aosp/upstream-master' into mymerge am: bab053dbca
am: 5734074732

Change-Id: I229e42ffc042b8487b5103f8239f41af122444cc
2017-05-12 17:33:55 +00:00
Nick Kralevich
5734074732 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
am: bab053dbca

Change-Id: I70f3c954701d0896f566c5a7b4ce6ab45ead7a15
2017-05-12 17:29:23 +00:00
Nick Kralevich
bab053dbca Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Please see go/android-upstream for merging a remote tracking branch into
Android. Automatic replication is already enabled for external/selinux.
This just merges those changes into Android's master branch.

Test: Android compiles and no obvious problems.
Bug: 31559095
Change-Id: Icc1961056366997632dea7d958e08593c27ab632
2017-05-12 08:31:58 -07:00
Tom Cherry
9cc62ce35d procattr.c: Use __BIONIC__ instead of __ANDROID__
This check is not specific to Android devices. If libselinux were used
with Bionic on a normal Linux system this check would still be needed.

Signed-off-by: Tom Cherry <tomcherry@google.com>
2017-05-12 08:54:04 -04:00
Jeff Vander Stoep
9b0630287f Merge "sefcontext_compile: migrate to soong" am: 99ff65ee40 am: ca2f63513a
am: 0b168dc90a  -s ours

Change-Id: I6eb9917c04f8cd2b0c70aef8424abbe00aa53b72
2017-05-11 18:45:15 +00:00
Jeff Vander Stoep
0b168dc90a Merge "sefcontext_compile: migrate to soong" am: 99ff65ee40
am: ca2f63513a

Change-Id: I8e35a702fe07ffe0d4326b88662e096f3a558efb
2017-05-11 18:42:45 +00:00
Jeff Vander Stoep
ca2f63513a Merge "sefcontext_compile: migrate to soong"
am: 99ff65ee40

Change-Id: I79c9a83cd55e592a03d91d0fccd3086e9ef27a68
2017-05-11 18:40:44 +00:00
Treehugger Robot
99ff65ee40 Merge "sefcontext_compile: migrate to soong" 2017-05-11 18:29:52 +00:00
Jeff Vander Stoep
16e4a8dab3 sefcontext_compile: migrate to soong
Bug: 37512442
Test: build and boot Marlin.
Test: "bpfmt -w Android.bp"
Change-Id: Ib5a0aa8eb29457e3191bad12229a0a4171daa6b6
Merged-in: I25cd36c1233712fdffcef4aef9b53155fb724dbe
2017-05-11 17:27:49 +00:00
Jeff Vander Stoep
d2e7805e54 Merge remote-tracking branch 'aosp/upstream-master' into merge_expandattribute am: d48d465bdd am: c92eff368b
am: 43a4b00614

Change-Id: I9c20985b8e1e16f3ea7a634e1cf5d99e7e933f4b
2017-05-11 16:49:03 +00:00
Jeff Vander Stoep
43a4b00614 Merge remote-tracking branch 'aosp/upstream-master' into merge_expandattribute am: d48d465bdd
am: c92eff368b

Change-Id: Ie99f3f7d65352b9020cdafbcc348c667a15a1cc4
2017-05-11 16:46:33 +00:00
Jeff Vander Stoep
c92eff368b Merge remote-tracking branch 'aosp/upstream-master' into merge_expandattribute
am: d48d465bdd

Change-Id: I448e10673b6ab74c47b217358258887273e2738f
2017-05-11 16:44:33 +00:00
Jeff Vander Stoep
d48d465bdd Merge remote-tracking branch 'aosp/upstream-master' into merge_expandattribute
Bug: 36508258
Bug: 37319524
Test: build and boot Marlin
Change-Id: Ib31a900ac70919835bcfc6bf9f6938a7aec622c2
2017-05-11 07:50:16 -07:00
Stephen Smalley
c3118041df checkpolicy,libsepol: drop unnecessary usage of s6_addr32
s6_addr32 is not portable; use s6_addr instead.
This obviates the need for #ifdef __APPLE__ conditionals in these cases.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-05-10 10:25:56 -04:00
Jeff Vander Stoep
d5554b168b secilc: Migrate to soong am: dfb7841f31 am: f26f4a1859
am: 95a7e330c3

Change-Id: I25cd36c1233712fdffcef4aef9b53155fb724dbe
2017-05-09 18:48:44 +00:00
Alan Jenkins
3db61481ad policycoreutils: fixfiles: use a consistent order for options to restorecon
It helps see the differences (hopefully there are only intended differences
now!).

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:57 -04:00
Alan Jenkins
c51b99acbc policycoreutils: fixfiles: don't ignore -F when run in -C mode
This was supposedly fixed in 2009.
http://selinux.fedoraproject.narkive.com/ZskMsNrx/fixfiles-f-option

`-F` was mentioned again in 2013 (commit 2910ca21).

It doesn't look like `-F -C` was fixed though.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:50 -04:00
Alan Jenkins
6e289bb7bf policycoreutils: fixfiles: remove bad modes of "relabel" command
* `fixfiles -B relabel` or `fixfiles -C previouscontext relabel` would
  skip the code that handles e.g. `/var/tmp`, which would be run by
  `fixfiles relabel`.  It would still remove all files in /tmp (subject to
  user confirmation).  This is confusing, undocumented, and unlikely to
  be intentional.

* `fixfiles relabel path1 path2` is the same, except it would only relabel
  the first path.

* `fixfiles -R ... relabel` was equivalent to `fixfiles -R ... restore`,
  again contradicting the man page.

Also `fixfiles onboot` would ignore paths, -C, or -R.

fixfiles is mostly for users, where it should be acceptable to remove these
non-sensical combinations.

`fixfiles -C` is used in selinux-policy rpm install scripts.  However I
believe the rpms used `fixfiles -C previouscontext restore`, and did not
either require user interaction or blow away /tmp without prompting.  So
they should still work fine.

With these combinations removed, we can remove the `exit` calls which were
seen in some of the (non-error) code paths in `restore()`.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:39 -04:00
Alan Jenkins
96d11a281e policycoreutils: fixfiles: un-document -R -a option
`fixfiles -R -a` is much less useful than it was made to sound, because -R
now works recursively.  Therefore `fixfiles -R -a` relabels every file on
the system, multiple times.  On my system it took over 5 times as long as
plain `fixfiles` (which takes about a minute).

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:31 -04:00
Alan Jenkins
3475893b6f policycoreutils: fixfiles: refactor into the set -u dialect
This commit allows the use of `set -u` to detect reads of unset variables.
But what I really liked was making the code more explicit about these
modes.  I hope that this is easier for a new reader to reason about.

`fixfiles restore` has accumulated five different modes it can run in.
Now use a single variable to indicate the mode, out-of-band of the
variables used for the individual modes.

Apparently `set -u` / `set -o nounset` doesn't work correctly with arrays.
If we ever need bash arrays, we can simply remove `set -u`.  The `set -u`
dialect is a strict subset.  See http://mywiki.wooledge.org/BashFAQ/112

Extra notes:

RESTORE_MODE was created because I couldn't bring myself to use an empty
FILEPATH, as a special case to indicate the default mode.  Arguments
to the script (paths) could be empty already, so it would mean I had to
work out how we behaved in that case and decide whether it was reasonable.

It turns out the `-B | -N time` mode is distinct and does not respect
paths.  So we can tell the user we're not going to do anything with the
paths they passed.  Make sure this distinction is shown in the usage error
message.

We already rejected the combination of `-R rpmpackage,... dir/file...`.
Being aware of the different modes just causes more bogus combinations
to be rejected.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:21 -04:00
Alan Jenkins
f499b02feb policycoreutils: fixfiles: if restorecon aborts, we should too
New users may try something like `fixfiles restore -v /dir/file` -
not realizing they are required to use `fixfiles -v restore /dir/file`.

Detect that `restorecon` aborts due to being run on the non-existent file
`-v`, and stop immediately.  This will show the error much more clearly,
instead of continuing to restore `/dir/file` *without* verbose messages.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:47:11 -04:00
Alan Jenkins
2aa88f7201 policycoreutils: fixfiles: usage errors are fatal
The idea is to print a usage error, then terminate with EXIT_FAILURE.

Don't print the usage error twice when run with no command.

Don't try to check for bogus extra arguments _after_
performing a long-running operation... particularly
if that operation terminates the script with EXIT_SUCCESS first.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:46:51 -04:00
Alan Jenkins
658800ef3d policycoreutils: fixfiles: syntax error
$ shellcheck fixfiles
...
In fixfiles line 94:
	  [[ "${i}" =~ "^[[:blank:]]*#" ]] && continue
                       ^-- SC2076: Don't quote rhs of =~, it'll match
                                   literally rather than as a regex.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:46:35 -04:00
Alan Jenkins
42f91ba291 policycoreutils: fixfiles: remove two unused variables
DIRS was suspicious because you can't store file names in a normal variable,
and it's not that common to use arrays in bash.  It's not actually used.

While we're here, there's another variable which is never used
and should just be removed.  (Pointed out by `shellcheck`.
It makes a couple of other points too, but I have more specific
patches I want to put those in).

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:46:23 -04:00
Alan Jenkins
ce2a7fb143 policycoreutils: fixfiles: tidy up usage(), manpage synopsis
Make sure usage() in fixfiles shows all the current options.
It's printed when there's a user error, so it needs to be
helpful!  (Excluding the deprecated option - see below).

manpage:

Remove the deprecated option `-l logfile`.

Add missing space in `restore|[-f] relabel`.

It's not clear why `-R rpmpackagename` was considered optional in the
second invocation.  (If the user omits it, they are just performing the
first invocation).  It desn't match usage() in fixfiles either.

Clean up bolding for `fixfiles onboot`.

Disable justification (troff "adjustment") in the synopsis.  We want the
common options in the different invocations to line up consistently.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2017-05-09 14:45:40 -04:00
Jeff Vander Stoep
95a7e330c3 secilc: Migrate to soong am: dfb7841f31
am: f26f4a1859

Change-Id: I64757fb7f1523bd8b7abd28248e5323305c30879
2017-05-09 18:34:32 +00:00
Jeff Vander Stoep
f26f4a1859 secilc: Migrate to soong
am: dfb7841f31

Change-Id: I6ed51d50d0eba10371c85a7e48ca13dc1003673e
2017-05-09 18:24:33 +00:00
Jeff Vander Stoep
73d1258d9f Checkpolicy: Migrate to soong am: c158e00746 am: 0dbd9f02d7
am: a1388b1628

Change-Id: I50911de4d545a2bea563918c61a5f32e1d243d6e
2017-05-09 16:43:01 +00:00