platform_system_sepolicy/tests
Jonas 5 Persson aa9d421655 Allow policy tests to support space in file names
Though libsepol supports it since selinux commit 644c5bbb,
test code couldn't handle whitespace in file name in policy
database.

Solved by splitting string once from left and then once
from right to avoid split of whitespace in file name.

Minimal reproducing example:
$ echo '(genfscon sysfs "/s/p a/ce" (USER ROLE TYPE ((SENS) (SENS))))' > s.cil
$ secilc -m -o s.db external/selinux/secilc/test/minimum.cil s.cil
$ searchpolicy --libpath out/host/linux-x86/lib64/libsepolwrap.so -sX --allow s.db
Traceback (most recent call last):
  File "/tmp/Soong.python_ra9it1nk/searchpolicy.py", line 52, in <module>
    pol = policy.Policy(args.policy, None, args.libpath)
  File "/tmp/Soong.python_ra9it1nk/policy.py", line 460, in __init__
    self.__InitGenfsCon()
  File "/tmp/Soong.python_ra9it1nk/policy.py", line 419, in __InitGenfsCon
    self.__GenfsDictAdd(self.__GenfsDict, buf.value.decode("ascii"))
  File "/tmp/Soong.python_ra9it1nk/policy.py", line 399, in __GenfsDictAdd
    fs, path, context = buf.split(" ")
ValueError: too many values to unpack (expected 3)

Test: manual, as described above
Test: cts SELinuxHostTest with spaces in a genfscon path
Change-Id: I7c74292513a63819ee7dc03ab4977ce9363589a4
2022-02-02 15:12:43 +01:00
..
include Assert types labeled in genfs_contexts have correct attributes 2018-03-23 14:34:46 -07:00
Android.bp compat_generator: find new types and removed types 2022-01-24 10:51:18 +09:00
check_prop_prefix.py Check vendor_property_contexts namespaces 2021-02-17 12:41:38 +09:00
combine_maps.py sepolicy: don't construct mappings for ignored types 2020-01-08 08:53:27 -08:00
fc_sort.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
fc_sort_test.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
mini_parser.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
policy.py Allow policy tests to support space in file names 2022-02-02 15:12:43 +01:00
searchpolicy.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
sepol_wrap.cpp gracefully handle hashtab_search failures 2018-09-26 14:28:44 -07:00
sepolicy_tests.py Use "data: libsepolwrap" in python binaries 2021-12-29 04:58:30 +00:00
treble_sepolicy_tests.py Use "data: libsepolwrap" in python binaries 2021-12-29 04:58:30 +00:00