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
Change-Id: If006c70178aa5bdcc9521a06ef8df2500f70bbb9
diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py
index d51d075..ed63c0e 100755
--- a/tools/fs_config/fs_config_generator.py
+++ b/tools/fs_config/fs_config_generator.py
@@ -1235,12 +1235,19 @@
             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 @@
         print PasswdGen._GENERATED
 
         for aid in aids:
-            self._print_formatted_line(aid)
+            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.