Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a3fd155 authored by Tom Cherry's avatar Tom Cherry
Browse files

Require a vendor_ prefix for users/groups in /vendor/etc/{passwd,group}

Bug: 79528966
Test: successful build with vendor_ prefixed users/groups
Test: expected build failure when not using vendor_ prefixed users/groups
Merged-In: If006c70178aa5bdcc9521a06ef8df2500f70bbb9
Change-Id: If006c70178aa5bdcc9521a06ef8df2500f70bbb9
(cherry picked from commit 2d197a1e)
parent 00e17fa8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid)
include $(BUILD_HEADER_LIBRARY)

##################################
# Generate the system/etc/passwd text file for the target
# Generate the vendor/etc/passwd text file for the target
# This file may be empty if no AIDs are defined in
# TARGET_FS_CONFIG_GEN files.
include $(CLEAR_VARS)
@@ -270,10 +270,10 @@ $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
$(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
	@mkdir -p $(dir $@)
	$(hide) $< passwd --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
	$(hide) $< passwd --required-prefix=vendor_ --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@

##################################
# Generate the system/etc/group text file for the target
# Generate the vendor/etc/group text file for the target
# This file may be empty if no AIDs are defined in
# TARGET_FS_CONFIG_GEN files.
include $(CLEAR_VARS)
@@ -289,7 +289,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
$(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
	@mkdir -p $(dir $@)
	$(hide) $< group --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
	$(hide) $< group --required-prefix=vendor_ --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@

system_android_filesystem_config :=
endif
+12 −1
Original line number Diff line number Diff line
@@ -1235,12 +1235,19 @@ class PasswdGen(BaseGenerator):
            help='An android_filesystem_config.h file'
            'to parse AIDs and OEM Ranges from')

        opt_group.add_argument(
            '--required-prefix',
            required=False,
            help='A prefix that the names are required to contain.')

    def __call__(self, args):

        hdr_parser = AIDHeaderParser(args['aid_header'])

        parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges)

        required_prefix = args['required_prefix']

        aids = parser.aids

        # nothing to do if no aids defined
@@ -1250,7 +1257,11 @@ class PasswdGen(BaseGenerator):
        print PasswdGen._GENERATED

        for aid in aids:
            if required_prefix is None or aid.friendly.startswith(required_prefix):
                self._print_formatted_line(aid)
            else:
                sys.exit("%s: AID '%s' must start with '%s'" %
                         (args['fsconfig'], aid.friendly, required_prefix))

    def _print_formatted_line(self, aid):
        """Prints the aid to stdout in the passwd format. Internal use only.