Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""Unit test suite for the fs_config_genertor.py tool."""
|
|
|
|
|
|
|
|
import tempfile
|
|
|
|
import textwrap
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from fs_config_generator import AID
|
|
|
|
from fs_config_generator import AIDHeaderParser
|
|
|
|
from fs_config_generator import FSConfigFileParser
|
|
|
|
from fs_config_generator import FSConfig
|
|
|
|
from fs_config_generator import Utils
|
|
|
|
|
|
|
|
|
|
|
|
# Disable protected access so we can test class internal
|
|
|
|
# methods. Also, disable invalid-name as some of the
|
|
|
|
# class method names are over length.
|
|
|
|
# pylint: disable=protected-access,invalid-name
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
"""Test class for unit tests"""
|
|
|
|
|
|
|
|
def test_is_overlap(self):
|
|
|
|
"""Test overlap detection helper"""
|
|
|
|
|
|
|
|
self.assertTrue(AIDHeaderParser._is_overlap((0, 1), (1, 2)))
|
|
|
|
|
|
|
|
self.assertTrue(AIDHeaderParser._is_overlap((0, 100), (90, 200)))
|
|
|
|
|
|
|
|
self.assertTrue(AIDHeaderParser._is_overlap((20, 50), (1, 101)))
|
|
|
|
|
|
|
|
self.assertFalse(AIDHeaderParser._is_overlap((0, 100), (101, 200)))
|
|
|
|
|
|
|
|
self.assertFalse(AIDHeaderParser._is_overlap((-10, 0), (10, 20)))
|
|
|
|
|
|
|
|
def test_in_any_range(self):
|
|
|
|
"""Test if value in range"""
|
|
|
|
|
|
|
|
self.assertFalse(Utils.in_any_range(50, [(100, 200), (1, 2), (1, 1)]))
|
|
|
|
self.assertFalse(Utils.in_any_range(250, [(100, 200), (1, 2), (1, 1)]))
|
|
|
|
|
|
|
|
self.assertTrue(Utils.in_any_range(100, [(100, 200), (1, 2), (1, 1)]))
|
|
|
|
self.assertTrue(Utils.in_any_range(200, [(100, 200), (1, 2), (1, 1)]))
|
|
|
|
self.assertTrue(Utils.in_any_range(150, [(100, 200)]))
|
|
|
|
|
|
|
|
def test_aid(self):
|
|
|
|
"""Test AID class constructor"""
|
|
|
|
|
2019-02-13 22:24:52 +00:00
|
|
|
aid = AID('AID_FOO_BAR', '0xFF', 'myfakefile', '/system/bin/sh')
|
|
|
|
self.assertEqual(aid.identifier, 'AID_FOO_BAR')
|
|
|
|
self.assertEqual(aid.value, '0xFF')
|
|
|
|
self.assertEqual(aid.found, 'myfakefile')
|
|
|
|
self.assertEqual(aid.normalized_value, '255')
|
|
|
|
self.assertEqual(aid.friendly, 'foo_bar')
|
|
|
|
self.assertEqual(aid.login_shell, '/system/bin/sh')
|
|
|
|
|
|
|
|
aid = AID('AID_MEDIA_EX', '1234', 'myfakefile', '/vendor/bin/sh')
|
|
|
|
self.assertEqual(aid.identifier, 'AID_MEDIA_EX')
|
|
|
|
self.assertEqual(aid.value, '1234')
|
|
|
|
self.assertEqual(aid.found, 'myfakefile')
|
|
|
|
self.assertEqual(aid.normalized_value, '1234')
|
|
|
|
self.assertEqual(aid.friendly, 'mediaex')
|
|
|
|
self.assertEqual(aid.login_shell, '/vendor/bin/sh')
|
Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
|
|
|
|
def test_aid_header_parser_good(self):
|
|
|
|
"""Test AID Header Parser good input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_FOO 1000
|
|
|
|
#define AID_BAR 1001
|
|
|
|
#define SOMETHING "something"
|
|
|
|
#define AID_OEM_RESERVED_START 2900
|
|
|
|
#define AID_OEM_RESERVED_END 2999
|
|
|
|
#define AID_OEM_RESERVED_1_START 7000
|
|
|
|
#define AID_OEM_RESERVED_1_END 8000
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
parser = AIDHeaderParser(temp_file.name)
|
|
|
|
oem_ranges = parser.oem_ranges
|
|
|
|
aids = parser.aids
|
|
|
|
|
|
|
|
self.assertTrue((2900, 2999) in oem_ranges)
|
|
|
|
self.assertFalse((5000, 6000) in oem_ranges)
|
|
|
|
|
|
|
|
for aid in aids:
|
|
|
|
self.assertTrue(aid.normalized_value in ['1000', '1001'])
|
|
|
|
self.assertFalse(aid.normalized_value in ['1', '2', '3'])
|
|
|
|
|
|
|
|
def test_aid_header_parser_good_unordered(self):
|
|
|
|
"""Test AID Header Parser good unordered input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_FOO 1000
|
|
|
|
#define AID_OEM_RESERVED_1_END 8000
|
|
|
|
#define AID_BAR 1001
|
|
|
|
#define SOMETHING "something"
|
|
|
|
#define AID_OEM_RESERVED_END 2999
|
|
|
|
#define AID_OEM_RESERVED_1_START 7000
|
|
|
|
#define AID_OEM_RESERVED_START 2900
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
parser = AIDHeaderParser(temp_file.name)
|
|
|
|
oem_ranges = parser.oem_ranges
|
|
|
|
aids = parser.aids
|
|
|
|
|
|
|
|
self.assertTrue((2900, 2999) in oem_ranges)
|
|
|
|
self.assertFalse((5000, 6000) in oem_ranges)
|
|
|
|
|
|
|
|
for aid in aids:
|
|
|
|
self.assertTrue(aid.normalized_value in ['1000', '1001'])
|
|
|
|
self.assertFalse(aid.normalized_value in ['1', '2', '3'])
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_aid(self):
|
|
|
|
"""Test AID Header Parser bad aid input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_FOO "bad"
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_oem_range(self):
|
|
|
|
"""Test AID Header Parser bad oem range input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_OEM_RESERVED_START 2900
|
|
|
|
#define AID_OEM_RESERVED_END 1800
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_oem_range_no_end(self):
|
|
|
|
"""Test AID Header Parser bad oem range (no end) input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_OEM_RESERVED_START 2900
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_oem_range_no_start(self):
|
|
|
|
"""Test AID Header Parser bad oem range (no start) input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_OEM_RESERVED_END 2900
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_oem_range_mismatch_start_end(self):
|
|
|
|
"""Test AID Header Parser bad oem range mismatched input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_OEM_RESERVED_START 2900
|
|
|
|
#define AID_OEM_RESERVED_2_END 2900
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_bad_duplicate_ranges(self):
|
|
|
|
"""Test AID Header Parser exits cleanly on duplicate AIDs"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_FOO 100
|
|
|
|
#define AID_BAR 100
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
AIDHeaderParser(temp_file.name)
|
|
|
|
|
|
|
|
def test_aid_header_parser_no_bad_aids(self):
|
|
|
|
"""Test AID Header Parser that it doesn't contain:
|
|
|
|
Ranges, ie things the end with "_START" or "_END"
|
|
|
|
AID_APP
|
|
|
|
AID_USER
|
|
|
|
For more details see:
|
|
|
|
- https://android-review.googlesource.com/#/c/313024
|
|
|
|
- https://android-review.googlesource.com/#/c/313169
|
|
|
|
"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
#define AID_APP 10000 /* TODO: switch users over to AID_APP_START */
|
|
|
|
#define AID_APP_START 10000 /* first app user */
|
|
|
|
#define AID_APP_END 19999 /* last app user */
|
|
|
|
|
|
|
|
#define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */
|
|
|
|
#define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */
|
|
|
|
|
|
|
|
#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
|
|
|
|
#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */
|
|
|
|
|
|
|
|
#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */
|
|
|
|
#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */
|
|
|
|
|
|
|
|
#define AID_USER 100000 /* TODO: switch users over to AID_USER_OFFSET */
|
|
|
|
#define AID_USER_OFFSET 100000 /* offset for uid ranges for each user */
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
parser = AIDHeaderParser(temp_file.name)
|
|
|
|
aids = parser.aids
|
|
|
|
|
|
|
|
bad_aids = ['_START', '_END', 'AID_APP', 'AID_USER']
|
|
|
|
|
|
|
|
for aid in aids:
|
|
|
|
self.assertFalse(
|
|
|
|
any(bad in aid.identifier for bad in bad_aids),
|
|
|
|
'Not expecting keywords "%s" in aids "%s"' %
|
|
|
|
(str(bad_aids), str([tmp.identifier for tmp in aids])))
|
|
|
|
|
|
|
|
def test_fs_config_file_parser_good(self):
|
|
|
|
"""Test FSConfig Parser good input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
[/system/bin/file]
|
|
|
|
user: AID_FOO
|
|
|
|
group: AID_SYSTEM
|
|
|
|
mode: 0777
|
|
|
|
caps: BLOCK_SUSPEND
|
|
|
|
|
|
|
|
[/vendor/path/dir/]
|
|
|
|
user: AID_FOO
|
|
|
|
group: AID_SYSTEM
|
|
|
|
mode: 0777
|
|
|
|
caps: 0
|
|
|
|
|
|
|
|
[AID_OEM1]
|
|
|
|
# 5001 in base16
|
|
|
|
value: 0x1389
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
parser = FSConfigFileParser([temp_file.name], [(5000, 5999)])
|
|
|
|
files = parser.files
|
|
|
|
dirs = parser.dirs
|
|
|
|
aids = parser.aids
|
|
|
|
|
2019-02-13 22:24:52 +00:00
|
|
|
self.assertEqual(len(files), 1)
|
|
|
|
self.assertEqual(len(dirs), 1)
|
|
|
|
self.assertEqual(len(aids), 1)
|
Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
|
|
|
|
aid = aids[0]
|
|
|
|
fcap = files[0]
|
|
|
|
dcap = dirs[0]
|
|
|
|
|
|
|
|
self.assertEqual(fcap,
|
|
|
|
FSConfig('0777', 'AID_FOO', 'AID_SYSTEM',
|
2019-02-13 22:02:30 +00:00
|
|
|
'CAP_BLOCK_SUSPEND',
|
Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
'/system/bin/file', temp_file.name))
|
|
|
|
|
|
|
|
self.assertEqual(dcap,
|
2019-02-13 22:02:30 +00:00
|
|
|
FSConfig('0777', 'AID_FOO', 'AID_SYSTEM', '0',
|
Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
'/vendor/path/dir/', temp_file.name))
|
|
|
|
|
2019-02-13 22:24:52 +00:00
|
|
|
self.assertEqual(aid, AID('AID_OEM1', '0x1389', temp_file.name, '/vendor/bin/sh'))
|
Revert "Revert "Merge changes from topic 'fsconfig-2'""
This reverts commit fad4b4b715be25e874829345a14219716fc8c157.
Incorporating the following fixes:
1.
fsconfig: fix fs_config_* build for discovered headers
When android_file system_config.h is picked up from the device
directory, neither TARGET_FS_CONFIG_GEN or TARGET_ANDROID_FILESYSTEM_CONFIG_H
are specified. Thus, the build is not generating the required fs_config_files
and fs_config_dirs.
Test: Ensure that make fs_config_files works, and produces the same output as before
Build the system image and mount it as a loop back and dump the file system
capabilities with getcap. Verify that output to the supplied
android_file system_config.h
From the loopback of the system.img mount, from CWD system/bin:
$ getcap *
cnss-daemon = cap_net_bind_service+ep
hostapd = cap_net_admin,cap_net_raw+ep
imsdatadaemon = cap_net_bind_service+ep
ims_rtp_daemon = cap_net_bind_service+ep
logd = cap_setgid,cap_audit_control,cap_syslog+ep
mm-qcamera-daemon = cap_sys_nice+ep
pm-service = cap_net_bind_service+ep
run-as = cap_setgid,cap_setuid+ep
surfaceflinger = cap_sys_nice+ep
webview_zygote32 = cap_setgid,cap_setuid,cap_setpcap+ep
webview_zygote64 = cap_setgid,cap_setuid,cap_setpcap+ep
Compared to the android_filesystem_config.h:
{ 00700, AID_CAMERA, AID_SHELL, (1ULL << CAP_SYS_NICE), "system/bin/mm-qcamera-daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/pm-service" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/cnss-daemon"},
2.
fsconfig: fix error message for duplicate AID
Fixes:
raise ValueError('Duplicate aid value "%u" for %s' % value,
TypeError: %u format: a number is required, not str
and
raise ValueError('Duplicate aid value "%s" for %s' % value,
TypeError: not enough arguments for format string
3.
fsconfig: add test for duplicate ranges
Add a test for duplicate range detection.
4.
fsconfig: skip AID_APP, AID_USER and all ranges
Do not output AID_APP, AID_USER and ranges. A range
is defined as ending with AID_ and ending in _START or
_END.
5.
fsconfig: test for skip AID_APP, AID_USER and all ranges
Test against AIDs that caused the bionic tests to fail.
Change-Id: I95569a9ccc83bd3231f8a6f395532cc2de316bd2
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-12-13 23:37:07 +00:00
|
|
|
|
|
|
|
def test_fs_config_file_parser_bad(self):
|
|
|
|
"""Test FSConfig Parser bad input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
[/system/bin/file]
|
|
|
|
caps: BLOCK_SUSPEND
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
FSConfigFileParser([temp_file.name], [(5000, 5999)])
|
|
|
|
|
|
|
|
def test_fs_config_file_parser_bad_aid_range(self):
|
|
|
|
"""Test FSConfig Parser bad aid range value input file"""
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as temp_file:
|
|
|
|
temp_file.write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
[AID_OEM1]
|
|
|
|
value: 25
|
|
|
|
"""))
|
|
|
|
temp_file.flush()
|
|
|
|
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
FSConfigFileParser([temp_file.name], [(5000, 5999)])
|