Loading tools/fs_config/Android.mk +18 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,24 @@ $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_G @mkdir -p $(dir $@) $(hide) $< passwd --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ ################################## # Generate the system/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) LOCAL_MODULE := group 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) $< group --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ system_android_filesystem_config := endif Loading tools/fs_config/fs_config_generator.py +59 −13 Original line number Diff line number Diff line Loading @@ -89,6 +89,32 @@ class Utils(object): return any(lower <= value <= upper for (lower, upper) in ranges) @staticmethod def get_login_and_uid_cleansed(aid): """Returns a passwd/group file safe logon and uid. This checks that the logon and uid of the AID do not contain the delimiter ":" for a passwd/group file. Args: aid (AID): The aid to check Returns: logon, uid of the AID after checking its safe. Raises: ValueError: If there is a delimiter charcter found. """ logon = aid.friendly uid = aid.normalized_value if ':' in uid: raise ValueError( 'Cannot specify delimiter character ":" in uid: "%s"' % uid) if ':' in logon: raise ValueError( 'Cannot specify delimiter character ":" in logon: "%s"' % logon) return logon, uid class AID(object): """This class represents an Android ID or an AID. Loading Loading @@ -1191,12 +1217,10 @@ class PasswdGen(BaseGenerator): print PasswdGen._GENERATED for aid in aids: self._print_aid_passwd_line(aid) self._print_formatted_line(aid) def _print_aid_passwd_line(self, aid): """ Prints the aid to stdout in the passwd format. Internal use only. def _print_formatted_line(self, aid): """Prints the aid to stdout in the passwd format. Internal use only. Colon delimited: login name, friendly name Loading @@ -1214,18 +1238,40 @@ class PasswdGen(BaseGenerator): 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) try: logon, uid = Utils.get_login_and_uid_cleansed(aid) except ValueError as exception: sys.exit(exception) print "%s::%s:%s::/:/system/bin/sh" % (logon, uid, uid) @generator('group') class GroupGen(PasswdGen): """Generates the /etc/group file per man (5) group.""" # Overrides parent def _print_formatted_line(self, aid): """Prints the aid to stdout in the group format. Internal use only. Formatted (per man 5 group) like: group_name:password:GID:user_list Args: aid (AID): The aid to print. """ if self._old_file != aid.found: self._old_file = aid.found print PasswdGen._FILE_COMMENT % aid.found try: logon, uid = Utils.get_login_and_uid_cleansed(aid) except ValueError as exception: sys.exit(exception) print "%s::%s:" % (logon, uid) def main(): """Main entry point for execution.""" Loading Loading
tools/fs_config/Android.mk +18 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,24 @@ $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_G @mkdir -p $(dir $@) $(hide) $< passwd --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ ################################## # Generate the system/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) LOCAL_MODULE := group 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) $< group --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ system_android_filesystem_config := endif Loading
tools/fs_config/fs_config_generator.py +59 −13 Original line number Diff line number Diff line Loading @@ -89,6 +89,32 @@ class Utils(object): return any(lower <= value <= upper for (lower, upper) in ranges) @staticmethod def get_login_and_uid_cleansed(aid): """Returns a passwd/group file safe logon and uid. This checks that the logon and uid of the AID do not contain the delimiter ":" for a passwd/group file. Args: aid (AID): The aid to check Returns: logon, uid of the AID after checking its safe. Raises: ValueError: If there is a delimiter charcter found. """ logon = aid.friendly uid = aid.normalized_value if ':' in uid: raise ValueError( 'Cannot specify delimiter character ":" in uid: "%s"' % uid) if ':' in logon: raise ValueError( 'Cannot specify delimiter character ":" in logon: "%s"' % logon) return logon, uid class AID(object): """This class represents an Android ID or an AID. Loading Loading @@ -1191,12 +1217,10 @@ class PasswdGen(BaseGenerator): print PasswdGen._GENERATED for aid in aids: self._print_aid_passwd_line(aid) self._print_formatted_line(aid) def _print_aid_passwd_line(self, aid): """ Prints the aid to stdout in the passwd format. Internal use only. def _print_formatted_line(self, aid): """Prints the aid to stdout in the passwd format. Internal use only. Colon delimited: login name, friendly name Loading @@ -1214,18 +1238,40 @@ class PasswdGen(BaseGenerator): 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) try: logon, uid = Utils.get_login_and_uid_cleansed(aid) except ValueError as exception: sys.exit(exception) print "%s::%s:%s::/:/system/bin/sh" % (logon, uid, uid) @generator('group') class GroupGen(PasswdGen): """Generates the /etc/group file per man (5) group.""" # Overrides parent def _print_formatted_line(self, aid): """Prints the aid to stdout in the group format. Internal use only. Formatted (per man 5 group) like: group_name:password:GID:user_list Args: aid (AID): The aid to print. """ if self._old_file != aid.found: self._old_file = aid.found print PasswdGen._FILE_COMMENT % aid.found try: logon, uid = Utils.get_login_and_uid_cleansed(aid) except ValueError as exception: sys.exit(exception) print "%s::%s:" % (logon, uid) def main(): """Main entry point for execution.""" Loading