From 3d5cd23d0d478ce2fa002307465f0a9134158336 Mon Sep 17 00:00:00 2001 From: yangsong Date: Mon, 19 Mar 2018 16:28:05 +0800 Subject: [PATCH] fix issue chroot, rpm -qa error: Failed to initialize NSS library #4959 (#4967) --- xCAT-server/share/xcat/netboot/rh/genimage | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 2b535fea6..d78832f27 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -520,7 +520,7 @@ unless ($onlyinitrd) { # Hack uname when deal otherpkgs use_hackuname($arch, $kernelver); use_devnull(); - + use_devurandom(); foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { $yumcmd = $yumcmd_base; @@ -2355,6 +2355,18 @@ sub use_devnull { } } +#in rhels7.5, the /dev/urandom does not exist in rootimg directory +#which cause any rpm command fail with `error: Failed to initialize NSS library` +#create urandom in genimage to avoid the error +sub use_devurandom { + if (-e "$rootimg_dir/dev/urandom" and !-c "$rootimg_dir/dev/urandom") { + system("rm -f $rootimg_dir/dev/urandom"); + } + if (!-e "$rootimg_dir/dev/urandom") { + system("mknod -m444 $rootimg_dir/dev/urandom c 1 9"); + } +} + # Hack uname functions to match what's installed in the rootimg # instead of what's running on the management node. # Needed for some RPMs, especially kernel modules via DKMS.