From 3110dc8fd781c704c53052c4d5ff1f426fdb22c4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 11 Jun 2019 10:59:32 -0400 Subject: [PATCH] Fix SLE15 genimage with existing passwd SLE15 code was overwriting valid /etc/passwd on partially built images. --- xCAT-server/share/xcat/netboot/sle/genimage | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage index 5df177836..6ced54174 100755 --- a/xCAT-server/share/xcat/netboot/sle/genimage +++ b/xCAT-server/share/xcat/netboot/sle/genimage @@ -397,11 +397,13 @@ unless ($onlyinitrd) { #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; #$yumcmd .= "install "; #mkpath("$rootimg_dir/var/lib/yum"); - mkpath("$rootimg_dir/etc/"); - my $passwdfile; - open($passwdfile, ">", "$rootimg_dir/etc/passwd"); - print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; - my $yumcmd; + if (! -f "$rootimg_dir/etc/passwd") { + mkpath("$rootimg_dir/etc/"); + my $passwdfile; + open($passwdfile, ">", "$rootimg_dir/etc/passwd"); + print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; + } + my $yumcmd; if ($osver_host < 11) { $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; } else {