diff --git a/debian/control b/debian/control index b5188399..a22ba681 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Section: utils XS-Autobuild: yes Priority: optional Standards-Version: 4.0.1 -Build-Depends: debhelper (>=10), dh-systemd, doxygen, linux-libc-dev, libudev-dev, lsb-release, libcxl-dev, help2man +Build-Depends: debhelper (>=10), dh-systemd, doxygen, linux-libc-dev, libudev-dev, libcxl-dev, help2man Homepage: https://github.com/open-power Vcs-Browser: https://github.com/open-power/capiflash.git Vcs-Git: https://github.com/open-power/capiflash.git @@ -19,4 +19,4 @@ Description: IBM Capiflash IO Data Engine This provides IO and utility support for IBM Capiflash adapters, and includes a NoSQL Software Interface. The latest adapter firmware updates are provided separately - in cxlflashimage. \ No newline at end of file + in cxlflashimage. diff --git a/debian/rules b/debian/rules index f3543364..66befaa5 100755 --- a/debian/rules +++ b/debian/rules @@ -15,8 +15,6 @@ else endif endif -export OSRELEASE=$(shell /usr/bin/lsb_release -sr) - export PWD=$(shell pwd) export SURELOCKROOT=$(shell pwd) diff --git a/src/build/install/resources/capi_flash b/src/build/install/resources/capi_flash index e0866cea..1bc403dc 100755 --- a/src/build/install/resources/capi_flash +++ b/src/build/install/resources/capi_flash @@ -547,8 +547,6 @@ if ($ARGV[0]) } if ($prthelp) {usage();} -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions\n"; #------------------------------------------------------------------------------- # Make stdout autoflush @@ -630,6 +628,9 @@ else #------------------------------------------------------------------------------- $list && exit; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; + #------------------------------------------------------------------------------- # VM - validate target #------------------------------------------------------------------------------- diff --git a/src/build/install/resources/cflash_capacity b/src/build/install/resources/cflash_capacity index a3c4d6dd..2cd131ba 100755 --- a/src/build/install/resources/cflash_capacity +++ b/src/build/install/resources/cflash_capacity @@ -81,12 +81,8 @@ if ($prthelp) {usage();} select(STDOUT); $| = 1; -#check sudo permissions -if (`id -u` != 0) -{ - print "Run with sudo permissions\n"; - exit -2; -} +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #------------------------------------------------------------------------------- # list Devices diff --git a/src/build/install/resources/cflash_inject b/src/build/install/resources/cflash_inject index 2c72b68f..74cdee84 100755 --- a/src/build/install/resources/cflash_inject +++ b/src/build/install/resources/cflash_inject @@ -92,6 +92,9 @@ sub usage() exit 0; } +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; + #------------------------------------------------------------------------------- # Parse Options #------------------------------------------------------------------------------- @@ -131,11 +134,6 @@ if ($ARGV[0]) } if ($prthelp || (!$dev && ($afu==-1 || $port==-1))) {usage();} -#check sudo permissions -if (`id -u` != 0) {print "Run with sudo permissions\n"; exit 0;} - -`chmod +x /usr/lib*/cxlflash/ext/flashgt_nvme_override`; - #------------------------------------------------------------------------------- # Make stdout autoflush #------------------------------------------------------------------------------- @@ -200,19 +198,19 @@ elsif ($clear) { $opcode="0xff"; $parms="$afustr --opcode $opcode --param 0x02 --port $port --entry $entry --offset 4 --mask 0xFFFF00FF --data 0"; - $cmd="/usr/lib*/cxlflash/ext/flashgt_nvme_override $parms"; + $cmd="/usr/bin/flashgt_nvme_override $parms"; } elsif ($wear>=0) { $data=sprintf("0x%.2x00", $wear); $parms="$afustr --opcode $opcode --param 0x02 --port $port --entry $entry --offset 4 --mask 0xFFFF00FF --data $data"; - $cmd="/usr/lib*/cxlflash/ext/flashgt_nvme_override $parms"; + $cmd="/usr/bin/flashgt_nvme_override $parms"; } elsif ($temp>=0) { $data=sprintf("0x0%.3x00", $temp+273); $parms="$afustr --opcode $opcode --param 0x02 --port $port --entry $entry --offset 0 --mask 0xFF0000FF --data $data"; - $cmd="/usr/lib*/cxlflash/ext/flashgt_nvme_override $parms"; + $cmd="/usr/bin/flashgt_nvme_override $parms"; } system($cmd); diff --git a/src/build/install/resources/cflash_mfg_init b/src/build/install/resources/cflash_mfg_init old mode 100644 new mode 100755 index 8a4b8557..89da8936 --- a/src/build/install/resources/cflash_mfg_init +++ b/src/build/install/resources/cflash_mfg_init @@ -73,8 +73,8 @@ if ($ARGV[0]) } if ($prthelp) {usage();} -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions\n"; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; if (defined $serial) {(length($serial)==8) || die "serial is not 8 chars\n";} diff --git a/src/build/install/resources/cflash_perf b/src/build/install/resources/cflash_perf index c66f96db..cd5ea62e 100755 --- a/src/build/install/resources/cflash_perf +++ b/src/build/install/resources/cflash_perf @@ -95,8 +95,8 @@ if ($ARGV[0]) if ($prthelp) {usage();} $sleep = $sleep > 60 ? 60 : $sleep; -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions"; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #------------------------------------------------------------------------------- # BMC -list CAPI Devices diff --git a/src/build/install/resources/cflash_perfcheck b/src/build/install/resources/cflash_perfcheck old mode 100644 new mode 100755 index 66471173..80225683 --- a/src/build/install/resources/cflash_perfcheck +++ b/src/build/install/resources/cflash_perfcheck @@ -82,8 +82,8 @@ if ($ARGV[0]) } if ($prthelp) {usage();} -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions\n"; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; $ENV{'PATH'}="$ENV{'PATH'}:/usr/bin"; diff --git a/src/build/install/resources/cflash_perst b/src/build/install/resources/cflash_perst index 074f152f..7bcadc02 100755 --- a/src/build/install/resources/cflash_perst +++ b/src/build/install/resources/cflash_perst @@ -92,12 +92,8 @@ if ($ARGV[0]) } if ($prthelp) {usage();} -#check sudo permissions -if (`id -u` != 0) -{ - print "Run with sudo permissions to perst\n"; - exit -2; -} +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #check cxlflash is not loaded system("lsmod | grep cxlflash >/dev/null"); diff --git a/src/build/install/resources/cflash_reset b/src/build/install/resources/cflash_reset index 8c5eac87..851fb176 100755 --- a/src/build/install/resources/cflash_reset +++ b/src/build/install/resources/cflash_reset @@ -95,12 +95,8 @@ if ( `cat /etc/redhat-release 2>/dev/null` =~ "Red Hat" ) {$redhat=1;} if (! $force) {print "sorry, not supported yet\n"; exit 0;} -#check sudo permissions -if (`id -u` != 0) -{ - print "Run with sudo permissions\n"; - exit -2; -} +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #------------------------------------------------------------------------------- # Make stdout autoflush diff --git a/src/build/install/resources/cflash_stick b/src/build/install/resources/cflash_stick index 6e0c01ce..4cf784f4 100755 --- a/src/build/install/resources/cflash_stick +++ b/src/build/install/resources/cflash_stick @@ -80,8 +80,8 @@ if ($ARGV[0]) } if ($prthelp) {usage();} -#check sudo permissions -if (`id -u` != 0) {print "Run with sudo permissions\n"; exit 0;} +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #------------------------------------------------------------------------------- # Make stdout autoflush diff --git a/src/build/install/resources/cflash_temp b/src/build/install/resources/cflash_temp index 3ebac608..561c4543 100755 --- a/src/build/install/resources/cflash_temp +++ b/src/build/install/resources/cflash_temp @@ -76,8 +76,8 @@ if ($prthelp) {usage();} if ( `cat /etc/os-release 2>/dev/null` =~ "Red Hat" ) {$redhat=1;} if ( `cat /etc/os-release 2>/dev/null` =~ "Ubuntu" ) {$ubuntu=1;} -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions"; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #ensure sg_write_buffer is available if ( $redhat ) {$cmd="rpm -qa | grep -v udev|grep -v libs | grep sg3_utils >/dev/null "; } diff --git a/src/build/install/resources/cflash_version b/src/build/install/resources/cflash_version index 84d0929d..2352da04 100755 --- a/src/build/install/resources/cflash_version +++ b/src/build/install/resources/cflash_version @@ -27,9 +27,6 @@ if [[ $1 =~ help || $1 =~ -h ]]; then echo "Usage: $(basename $0)"; exit 0; fi if [[ $1 =~ version ]]; then echo "v1.0"; exit 0; fi -# check permissions -if [[ $(id -u) != 0 ]]; then echo "use sudo"; exit 1; fi - export PATH=$PATH:/usr/bin #determine distro @@ -132,14 +129,22 @@ then n2=$(echo $EXISTS_GRUB_VER|awk -F. '{print $2}') n3=$(echo $EXISTS_GRUB_VER|awk -F. '{print $3}'|awk -F- '{print $1}') n4=$(echo $EXISTS_GRUB_VER|awk -F- '{print $2}'|awk -F. '{print $1}') - if [[ ($n1 -lt 4) || - ($n1 -eq 4 && $n2 -lt 4) || - ($n1 -eq 4 && $n2 -eq 4 && $n3 -eq 0 && $n4 -lt 36) ]] + if [[ ! -z ${EXISTS_GRUB_VER} && + (($n1 -lt 4) || + ($n1 -eq 4 && $n2 -lt 4) || + ($n1 -eq 4 && $n2 -eq 4 && $n3 -eq 0 && $n4 -lt 36)) ]] then err_rc=6 echo "ERROR: Grub: grub.cfg($EXISTS_GRUB_VER) => Required($K_VER_GRUB) or newer" fi + #check permissions + if [[ ! ($(groups ${USER}) =~ cxl || $(id -u ${USER}) -eq 0) ]] + then + echo "You do not have enough permissions to check the firmware levels" + exit $err_rc + fi + if [[ -e /usr/bin/capi_flash ]] then IFS=$'\n' @@ -229,24 +234,33 @@ then echo "ERROR: cxlflash-test: Installed($EXISTS_CF_TEST_VER) != Required($CF_VER)" fi - EXISTS_K_VER=$(rpm -q kernel) - if [[ ! $EXISTS_K_VER =~ $K_VER ]] + EXISTS_K_VER=$(rpm -qa|grep $(uname -a|awk '{print $3}')|awk -Fkernel- '{print $2}') + n1=$(echo $EXISTS_K_VER|awk -F. '{print $1}') + n2=$(echo $EXISTS_K_VER|awk -F. '{print $2}') + if [[ ($n1 -lt 3) || ($n1 -eq 3 && $n2 -lt 10) ]] then - err_rc=5 - echo "WARNING: Kernel: Booted($(uname -a|awk '{print $3}')) != Required($K_VER)" + err_rc=5 + echo "ERROR: Kernel: Booted($EXISTS_K_VER) => Required($K_VER) or newer" else - echo "INFO: Kernel: $K_VER" + echo "INFO: Kernel: $EXISTS_K_VER" fi - EXISTS_GRUB_VER=$(grep initrd /boot/grub2/grub.cfg | head -1 | awk -Finitramfs- '{print $2}') + EXISTS_GRUB_VER=$(grep initrd /boot/grub2/grub.cfg 2>/dev/null| head -1 | awk -Finitramfs- '{print $2}') n1=$(echo $EXISTS_GRUB_VER|awk -F. '{print $1}') n2=$(echo $EXISTS_GRUB_VER|awk -F. '{print $2}') - if [[ ($n1 -lt 3) || ($n1 -eq 3 && $n2 -lt 10) ]] + if [[ ! -z ${EXISTS_GRUB_VER} && (($n1 -lt 3) || ($n1 -eq 3 && $n2 -lt 10)) ]] then err_rc=6 echo "WARNING: Grub: grub.cfg($EXISTS_GRUB_VER) != Required($K_VER_GRUB)" fi + #check permissions + if [[ ! ($(groups ${USER}) =~ cxl || $(id -u ${USER}) -eq 0) ]] + then + echo "You do not have enough permissions to check the firmware levels" + exit $err_rc + fi + if [[ -e /usr/bin/capi_flash ]] then IFS=$'\n' diff --git a/src/build/install/resources/cflash_wear b/src/build/install/resources/cflash_wear index bc309d22..71e7024c 100755 --- a/src/build/install/resources/cflash_wear +++ b/src/build/install/resources/cflash_wear @@ -77,8 +77,8 @@ if ($prthelp) {usage();} if ( `cat /etc/os-release 2>/dev/null` =~ "Red Hat" ) {$redhat=1;} if ( `cat /etc/os-release 2>/dev/null` =~ "Ubuntu" ) {$ubuntu=1;} -#check sudo permissions -(`id -u` == 0) || die "Run with sudo permissions"; +#check permissions +(! (`groups $ENV{'USER'}` =~ / cxl/ || `id -u $ENV{'USER'}` == 0)) && die "You do not have enough permissions\n"; #ensure sg_write_buffer is available if ( $redhat ) {$cmd="rpm -qa | grep -v udev | grep -v libs | grep sg3_utils >/dev/null "; } diff --git a/src/build/install/resources/cflashutils b/src/build/install/resources/cflashutils index 9cd3a590..0be19c77 100755 --- a/src/build/install/resources/cflashutils +++ b/src/build/install/resources/cflashutils @@ -190,7 +190,7 @@ ctrlblockdevmap() fi echo "INFO: sgdev:$dev mode:$tgmode action:${scsiaction} sddev:$blockdev" >> $LOGFILE; #if there's something to do, call either bind or unbind appropriately - if [[ "$scsiaction" != "noop" && $blockdev ]]; then + if [[ "$scsiaction" != "noop" && $blockdev && $(id -u ${USER}) -eq 0 ]]; then out=$(echo -n "$scsitopo" > /sys/bus/scsi/drivers/sd/$scsiaction 2>&1) echo "INFO: action:${scsiaction} sgdev:$dev sddev:$blockdev scsitopo:$scsitopo rc:$?" >> $LOGFILE; fi @@ -305,16 +305,20 @@ getluntablestate() #@returns rc to 0 on success, OR sets return code to non-zero value on error dotableupdate() { - #check sudo permissions - SUDO=$(id -u) - if [[ $SUDO != 0 ]]; then echo "run with sudo permissions to refresh"; return; fi + #check permissions + if [[ ! ($(groups ${USER}) =~ cxl || $(id -u ${USER}) -eq 0) ]]; then echo "You do not have enough permissions"; return; fi #attempt to rescan for cxl scsi devices local host; - for host in $(ls /sys/module/cxlflash/drivers/pci:cxlflash/*:*:*.*/ 2>/dev/null| grep host) - do - echo "- - -" > /sys/class/scsi_host/$host/scan - done + if [[ $(id -u ${USER}) -eq 0 ]] + then + for host in $(ls /sys/module/cxlflash/drivers/pci:cxlflash/*:*:*.*/ 2>/dev/null| grep host) + do + echo "- - -" > /sys/class/scsi_host/$host/scan + done + else + echo "unable to scan for new luns, not enough permissions" + fi #list of all known SG devices - local to prevent this from causing side effects / problems in udev handler local _SGDEVS=`ls /sys/module/cxlflash/drivers/pci:cxlflash/*:*:*.*/host*/target*:*:*/*:*:*:*/scsi_generic 2>/dev/null| grep sg` diff --git a/src/build/install/resources/cxlffdc b/src/build/install/resources/cxlffdc index 97dda9f5..e35e28e9 100755 --- a/src/build/install/resources/cxlffdc +++ b/src/build/install/resources/cxlffdc @@ -28,10 +28,22 @@ if [[ $1 =~ version ]]; then echo "v1.0"; exit 0; fi export PATH=$PATH:/usr/bin -DATADIR=/var/log/cflash/cxlffdc -PREVDIR=/var/log/cflash/prev -MISCDIR=/var/log/cflash/misc -TARBALL=/var/log/cflash/cxlffdc."$(date|awk '{print $4"_"$2"_"$3"_"$6}'|sed 's/:/_/'g)".tgz +DIR=cxlffdc."$(date|awk '{print $4"_"$2"_"$3"_"$6}'|sed 's/:/_/'g)" + +#check permissions +if [[ $(id -u ${USER}) -eq 0 ]] +then + DATAPATH=/var/log/cflash + perms=1 +else + echo "****************************************" + echo "*** run with sudo for better results ***" + echo "****************************************" + DATAPATH=/tmp +fi + +DATADIR=${DATAPATH}/${DIR} +MISCDIR=${DATAPATH}/misc BINDIR=/usr/bin pgz=$(ls /usr/lib/cxlflash/ext/p*gz 2>/dev/null) ptd=/usr/lib/cxlflash/ext/ptd @@ -89,15 +101,10 @@ fi ################## # main ################## -if [[ $EUID -ne 0 ]]; then - echo "This script must be run with sudo" 1>&2 - exit 1 -fi ret=$(pwd) -if [[ -e $DATADIR ]]; then rm -rf $DATADIR; fi -if [[ -e $PREVDIR ]]; then rm -rf $PREVDIR; fi -mkdir $DATADIR +if [[ -e $DATADIR ]]; then rm -rf $DATADIR 2>/dev/null; fi +mkdir -p $DATADIR cd $DATADIR cardnums=`ls -d /sys/class/cxl/card* | awk -F"/sys/class/cxl/card" '{ print $2 }'` @@ -108,10 +115,10 @@ do then printf "\n INFO: psl trace on VM Not Supported! \n\n" else - if [[ -f ${BINDIR}/psl_dump_data ]] + if [[ -f ${BINDIR}/psl_trace_dump && $perms -eq 1 ]] then echo "Dumping PSL data for card$i" - ${BINDIR}/psl_dump_data card$i $i >/dev/null + ${BINDIR}/psl_trace_dump ${DATADIR}/card$i $i >/dev/null fi fi done @@ -231,10 +238,10 @@ do done cd .. -tar -cvzf $TARBALL cxlffdc -mv $DATADIR $PREVDIR +tar -czf $DIR.tgz $DIR +rm -Rf $DIR echo "INFO: FFDC Collected below." -ls -l $TARBALL +ls -l $DATADIR.tgz cd $ret diff --git a/src/build/version.txt b/src/build/version.txt index fc0f738e..99805be8 100644 --- a/src/build/version.txt +++ b/src/build/version.txt @@ -1 +1 @@ -4.3.2557 +4.3.2560