summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2008-10-29 16:32:30 -0700
committerBob Gilligan <gilligan@vyatta.com>2008-10-29 16:32:30 -0700
commit78e41fb517a63c4a9cc225975e4714f84918149d (patch)
tree5a490f5f62b8be03c18b230e50bb1f7c327d86a5 /templates
parent5304fabe0b0eb212936ca1f47e4cf98d73fd6b81 (diff)
downloadvyatta-op-78e41fb517a63c4a9cc225975e4714f84918149d.tar.gz
vyatta-op-78e41fb517a63c4a9cc225975e4714f84918149d.zip
Bugfix: 3841: Allow admin level users to run the RAID op mode commands.
Diffstat (limited to 'templates')
-rw-r--r--templates/add/raid/node.tag/member/node.tag/node.def4
-rw-r--r--templates/format/disk/node.tag/like/node.tag/node.def12
-rw-r--r--templates/remove/raid/node.tag/member/node.tag/node.def6
-rw-r--r--templates/show/disk/node.tag/format/node.def4
-rw-r--r--templates/show/raid/node.tag/node.def9
5 files changed, 25 insertions, 10 deletions
diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def
index 293b4ea..b30c313 100644
--- a/templates/add/raid/node.tag/member/node.tag/node.def
+++ b/templates/add/raid/node.tag/member/node.tag/node.def
@@ -28,9 +28,11 @@ run:
echo "actual members are: $membership"
elif [ -z "$valid_partition" ]; then
echo "$member_to_add is not a valid disk partition"
+ elif [ ! -r /dev/$raid_set ]; then
+ echo "Must be admin or root to add RAID set member"
else
echo "adding member $member_to_add to RAID set $raid_set"
- mdadm /dev/$raid_set --add /dev/$member_to_add
+ sudo /sbin/mdadm /dev/$raid_set --add /dev/$member_to_add
if [ $? -ne 0 ]; then
echo "Unable to add member to RAID set"
fi
diff --git a/templates/format/disk/node.tag/like/node.tag/node.def b/templates/format/disk/node.tag/like/node.tag/node.def
index 8927dc8..588e633 100644
--- a/templates/format/disk/node.tag/like/node.tag/node.def
+++ b/templates/format/disk/node.tag/like/node.tag/node.def
@@ -10,12 +10,12 @@ allowed:
run:
proto_disk=$5
format_disk=$3
- backup_dir=/var/log/vyatta
+ backup_dir=/var/tmp
eligible_format_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"`
eligible_proto_disks=`echo $eligible_format_disks | sed -e s/$format_disk//g`
proto_eligible=`echo $eligible_proto_disks | grep $proto_disk`
format_eligible=`echo $eligible_format_disks | grep $format_disk`
- busy_check=`sfdisk -R /dev/$format_disk 2>&1`
+ busy_check=`sudo /sbin/sfdisk -R /dev/$format_disk 2>&1`
if [ $proto_disk = $format_disk ]; then
echo "The two disk drives must be different."
@@ -29,6 +29,8 @@ run:
echo "Device $proto_disk can not be used as a prototype for $format_disk"
elif [ -n "$busy_check" ]; then
echo "Disk device $format_disk is busy. Can't format it now."
+ elif [ ! -r /dev/$format_disk ]; then
+ echo "Must be admin or root to format disk"
else
echo "This will re-format disk $format_disk so that it has the same disk"
echo "partion sizes and offsets as $proto_disk. This will not copy"
@@ -40,18 +42,18 @@ run:
if [ "$response" = "yes" ]; then
echo "OK. Re-formating disk drive $format_disk..."
echo "Making backup copy of partitions..."
- sfdisk -d /dev/$format_disk > $backup_dir/backup_$format_disk.`date +%F-%R`
+ sudo /sbin/sfdisk -d /dev/$format_disk > $backup_dir/backup_$format_disk.`date +%F-%R`
sleep 1
partitions=`cat /proc/partitions | grep $format_disk'[0-9]' | awk '{ print $4 }' | sed 's/[a-z]//g'`
if [ -n "$partitions" ]; then
echo -n "Deleting old partitions..."
for part in $partitions ; do
- parted /dev/$format_disk rm $part
+ sudo /sbin/parted /dev/$format_disk rm $part
done
echo ""
fi
echo "Creating new partitions on $format_disk based on $proto_disk..."
- sfdisk -d /dev/$proto_disk | sfdisk --force /dev/$format_disk
+ sudo /sbin/sfdisk -d /dev/$proto_disk | sudo /sbin/sfdisk --force /dev/$format_disk
echo "Done."
else
echo "OK. Disk drive $format_drive will not be re-formated."
diff --git a/templates/remove/raid/node.tag/member/node.tag/node.def b/templates/remove/raid/node.tag/member/node.tag/node.def
index d384fd3..a48fd4a 100644
--- a/templates/remove/raid/node.tag/member/node.tag/node.def
+++ b/templates/remove/raid/node.tag/member/node.tag/node.def
@@ -20,14 +20,16 @@ run:
echo "actual members are: $membership"
elif [ "$num_members" -eq "1" ]; then
echo "Can't remove last member of a RAID set"
+ elif [ ! -r /dev/$raid_set ]; then
+ echo "Must be admin or root to remove RAID set member"
else
echo "removing member $member from RAID set $raid_set"
- mdadm /dev/$raid_set --fail /dev/$member_to_remove
+ sudo /sbin/mdadm /dev/$raid_set --fail /dev/$member_to_remove
if [ $? -ne 0 ]; then
echo "Unable to mark member as failed"
else
sleep 1
- mdadm /dev/$raid_set --remove /dev/$member_to_remove
+ sudo /sbin/mdadm /dev/$raid_set --remove /dev/$member_to_remove
if [ $? -ne 0 ]; then
echo "Unable to remove member from RAID set"
fi
diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def
index e05b4ad..e5829ca 100644
--- a/templates/show/disk/node.tag/format/node.def
+++ b/templates/show/disk/node.tag/format/node.def
@@ -7,6 +7,8 @@ run:
if [ -z "$is_a_disk" ]; then
echo "$disk_dev is not a disk device"
+ elif [ ! -r /dev/${disk_dev} ]; then
+ echo "Must be admin or root to display disk formating"
else
- fdisk -l /dev/${disk_dev}
+ /sbin/fdisk -l /dev/${disk_dev}
fi
diff --git a/templates/show/raid/node.tag/node.def b/templates/show/raid/node.tag/node.def
index bc83a73..4f9928d 100644
--- a/templates/show/raid/node.tag/node.def
+++ b/templates/show/raid/node.tag/node.def
@@ -12,5 +12,12 @@ run:
if [ -z $valid_set ]; then
echo "$raid_set_name is not a RAID set"
else
- mdadm --detail /dev/${raid_set_name}
+ if [ -r /dev/${raid_set_name} ]; 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.
+ sudo /sbin/mdadm --detail /dev/${raid_set_name}
+ else
+ echo "Must be administrator or root to display RAID status"
+ fi
fi \ No newline at end of file