From: biao716.wang Date: Mon, 12 Apr 2021 11:11:25 +0000 (+0900) Subject: encrypt user password with SHA512 instead of MD5 X-Git-Tag: accepted/tizen/devbase/tools/20210517.061543~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a0597e264ce2c2bf5942c6ce6ed620da782ddfb;p=tools%2Fmic.git encrypt user password with SHA512 instead of MD5 and for root account, need to add it to certain groups if there exist userconfig.groups Change-Id: I76eb7f32bc4cfab8f12d3c64f3dcc250cfa44cbf Signed-off-by: biao716.wang --- diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index e19e003..46bcca2 100755 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -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):