encrypt user password with SHA512 instead of MD5
authorbiao716.wang <biao716.wang@samsung.com>
Tue, 16 Aug 2022 08:16:37 +0000 (17:16 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Tue, 16 Aug 2022 08:16:39 +0000 (17:16 +0900)
and for root account, need to add it to certain groups if there exist userconfig.groups
Change-Id: I21078f303344c26d8475ceb949940ab7de507a1d
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/kickstart/__init__.py

index 318b8bf1a1e66f922ca4b7716fd10f89ecfb8ab1..833fd72a0f54f9510318692718ade43f9806469c 100755 (executable)
@@ -312,7 +312,7 @@ class UserConfig(KickstartConfig):
         p1 = subprocess.Popen(["/bin/echo", "%s:%s" %(user, password)],
                               stdout = subprocess.PIPE,
                               preexec_fn = self.chroot)
-        p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-m"],
+        p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-c","SHA512"],
                               stdin = p1.stdout,
                               stdout = subprocess.PIPE,
                               preexec_fn = self.chroot)
@@ -353,6 +353,12 @@ class UserConfig(KickstartConfig):
     @apply_wrapper
     def apply(self, user):
         for userconfig in user.userList:
+            #There exist root user already.
+            if userconfig.name == "root":
+                msger.debug("root user, just set root user groups attribution")
+                if userconfig.groups:
+                    self.call(["/usr/sbin/usermod", "-a", "-G", "%s" % string.join(userconfig.groups, ","), "root"])
+                continue
             self.addUser(userconfig)
 
 class ServicesConfig(KickstartConfig):