From 672b6cc486f140e5598abd41be9d5daebc422b40 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 17 Dec 2022 10:55:26 +0100 Subject: op-mode: T707: explicitly use sudo when working with RAID devices --- src/op_mode/show_raid.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/op_mode/show_raid.sh') diff --git a/src/op_mode/show_raid.sh b/src/op_mode/show_raid.sh index ba4174692..ab5d4d50f 100755 --- a/src/op_mode/show_raid.sh +++ b/src/op_mode/show_raid.sh @@ -1,5 +1,13 @@ #!/bin/bash +if [ "$EUID" -ne 0 ]; then + # This should work without sudo because we have read + # access to the dev, but for some reason mdadm must be + # run as root in order to succeed. + echo "Please run as root" + exit 1 +fi + raid_set_name=$1 raid_sets=`cat /proc/partitions | grep md | awk '{ print $4 }'` valid_set=`echo $raid_sets | grep $raid_set_name` @@ -10,7 +18,7 @@ else # This should work without sudo because we have read # access to the dev, but for some reason mdadm must be # run as root in order to succeed. - sudo /sbin/mdadm --detail /dev/${raid_set_name} + mdadm --detail /dev/${raid_set_name} else echo "Must be administrator or root to display RAID status" fi -- cgit v1.2.3