Loading tools/fs_config/Android.mk +19 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,6 @@ LOCAL_GENERATED_SOURCES := $(oem) $(gen) my_fs_config_h := $(gen) my_gen_oem_aid := $(oem) system_android_filesystem_config := gen := oem := endif Loading Loading @@ -151,6 +150,25 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid)) LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid) include $(BUILD_STATIC_LIBRARY) ################################## # Generate the system/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) LOCAL_MODULE := passwd LOCAL_MODULE_CLASS := ETC include $(BUILD_SYSTEM)/base_rules.mk $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) $(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) > $@ system_android_filesystem_config := endif ANDROID_FS_CONFIG_H := Loading tools/fs_config/fs_config_generator.py +73 −0 Original line number Diff line number Diff line Loading @@ -1153,6 +1153,79 @@ class OEMAidGen(BaseGenerator): print OEMAidGen._GENERIC_DEFINE % (aid.identifier, aid.value) @generator('passwd') class PasswdGen(BaseGenerator): """Generates the /etc/passwd file per man (5) passwd.""" _GENERATED = ('#\n# THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n#') _FILE_COMMENT = '# Defined in file: \"%s\"' def __init__(self): self._old_file = None def add_opts(self, opt_group): opt_group.add_argument( 'fsconfig', nargs='+', help='The list of fsconfig files to parse.') opt_group.add_argument( '--aid-header', required=True, help='An android_filesystem_config.h file' 'to parse AIDs and OEM Ranges from') def __call__(self, args): hdr_parser = AIDHeaderParser(args['aid_header']) parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges) aids = parser.aids # nothing to do if no aids defined if len(aids) == 0: return print PasswdGen._GENERATED for aid in aids: self._print_aid_passwd_line(aid) def _print_aid_passwd_line(self, aid): """ Prints the aid to stdout in the passwd format. Internal use only. Colon delimited: login name, friendly name encrypted password (optional) uid (int) gid (int) User name or comment field home directory interpreter (optional) Args: aid (AID): The aid to print. """ if self._old_file != aid.found: self._old_file = aid.found print PasswdGen._FILE_COMMENT % aid.found logon = aid.friendly uid = aid.normalized_value if ':' in uid: sys.exit('Cannot specify delimiter character ":" in uid: "%s"' % uid) if ':' in logon: sys.exit('Cannot specify delimiter character ":" in logon: "%s"' % logon) print "%s::%s:%s::/:/system/bin/sh" % (logon, uid, uid) def main(): """Main entry point for execution.""" Loading Loading
tools/fs_config/Android.mk +19 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,6 @@ LOCAL_GENERATED_SOURCES := $(oem) $(gen) my_fs_config_h := $(gen) my_gen_oem_aid := $(oem) system_android_filesystem_config := gen := oem := endif Loading Loading @@ -151,6 +150,25 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid)) LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid) include $(BUILD_STATIC_LIBRARY) ################################## # Generate the system/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) LOCAL_MODULE := passwd LOCAL_MODULE_CLASS := ETC include $(BUILD_SYSTEM)/base_rules.mk $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) $(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) > $@ system_android_filesystem_config := endif ANDROID_FS_CONFIG_H := Loading
tools/fs_config/fs_config_generator.py +73 −0 Original line number Diff line number Diff line Loading @@ -1153,6 +1153,79 @@ class OEMAidGen(BaseGenerator): print OEMAidGen._GENERIC_DEFINE % (aid.identifier, aid.value) @generator('passwd') class PasswdGen(BaseGenerator): """Generates the /etc/passwd file per man (5) passwd.""" _GENERATED = ('#\n# THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n#') _FILE_COMMENT = '# Defined in file: \"%s\"' def __init__(self): self._old_file = None def add_opts(self, opt_group): opt_group.add_argument( 'fsconfig', nargs='+', help='The list of fsconfig files to parse.') opt_group.add_argument( '--aid-header', required=True, help='An android_filesystem_config.h file' 'to parse AIDs and OEM Ranges from') def __call__(self, args): hdr_parser = AIDHeaderParser(args['aid_header']) parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges) aids = parser.aids # nothing to do if no aids defined if len(aids) == 0: return print PasswdGen._GENERATED for aid in aids: self._print_aid_passwd_line(aid) def _print_aid_passwd_line(self, aid): """ Prints the aid to stdout in the passwd format. Internal use only. Colon delimited: login name, friendly name encrypted password (optional) uid (int) gid (int) User name or comment field home directory interpreter (optional) Args: aid (AID): The aid to print. """ if self._old_file != aid.found: self._old_file = aid.found print PasswdGen._FILE_COMMENT % aid.found logon = aid.friendly uid = aid.normalized_value if ':' in uid: sys.exit('Cannot specify delimiter character ":" in uid: "%s"' % uid) if ':' in logon: sys.exit('Cannot specify delimiter character ":" in logon: "%s"' % logon) print "%s::%s:%s::/:/system/bin/sh" % (logon, uid, uid) def main(): """Main entry point for execution.""" Loading