From 0b8e4bc5851f675c4a32bfc1c7b0f610d5288a0d0db7539f77e0daad692027b0 Mon Sep 17 00:00:00 2001 From: Johannes Segitz Date: Mon, 8 Sep 2014 09:42:21 +0000 Subject: [PATCH] Accepting request 247967 from home:jsegitz:branches:security:SELinux - updated selinux-ready script to handle initrd files compressed with xz OBS-URL: https://build.opensuse.org/request/show/247967 OBS-URL: https://build.opensuse.org/package/show/security:SELinux/libselinux?expand=0&rev=79 --- libselinux.changes | 5 +++++ selinux-ready | 33 ++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/libselinux.changes b/libselinux.changes index 96bae57..496afd0 100644 --- a/libselinux.changes +++ b/libselinux.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Sep 8 08:25:11 UTC 2014 - jsegitz@suse.com + +- updated selinux-ready script to handle initrd files compressed with xz + ------------------------------------------------------------------- Sun May 18 00:15:17 UTC 2014 - crrodriguez@opensuse.org diff --git a/selinux-ready b/selinux-ready index 278276d..667c95e 100644 --- a/selinux-ready +++ b/selinux-ready @@ -97,9 +97,9 @@ check_mkinitrd() return 2 fi - cp /boot/$INITRD $TD/i.cpio.gz 2>/dev/null + cp /boot/$INITRD $TD/ 2>/dev/null - if ! [ -f "$TD/i.cpio.gz" ];then + if ! [ -f "$TD/$INITRD" ];then printf "\tcheck_mkinitrd: ERR. Error while copying initrd file.'\n" return 2 fi @@ -109,11 +109,30 @@ check_mkinitrd() cd $TD mkdir initrd-extracted cd initrd-extracted - gunzip -c $TD/i.cpio.gz | cpio -i --force-local --no-absolute-filenames 2>/dev/null - grep -E -- $MCMD boot/* 2>&1 >/dev/null - FLG1=$? - grep -E -- load_policy boot/* 2>&1 >/dev/null - FLG2=$? + INITRD_FORMAT=$(file $TD/$INITRD | awk -F' ' '{print $2}') + case $INITRD_FORMAT in + 'XZ' ) + xz -d -c $TD/$INITRD | cpio -i --force-local --no-absolute-filenames 2>/dev/null ;; + 'gzip' ) + gzip -d -c $TD/$INITRD | cpio -i --force-local --no-absolute-filenames 2>/dev/null ;; + * ) + printf "\tcheck_mkinitrd: ERR. Error while extracting initrd file.'\n" + return 2 + esac + if [ -d boot ]; then + grep -E -- $MCMD boot/* 2>&1 >/dev/null + FLG1=$? + grep -E -- load_policy boot/* 2>&1 >/dev/null + FLG2=$? + else + # looks like we're using dracut/systemd. We can only check if libselinux1 + # exists + if [ -f lib64/libselinux.so.1 ]; then + # if this exists + FLG1=0 + FLG2=0 + fi + fi popd 2>&1>/dev/null if [ $FLG1 == 0 -a $FLG2 == 0 ];then