Commit 97b9703c authored by Ryan Jackson's avatar Ryan Jackson

Fixed a bug that broke frisbee on pc600 nodes

parent be9cb211
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
#
# Create a disk image. Caller must have sudo permission!
#
sub usage()
{
print STDOUT "Usage: create-image [-s slice] <device file> <filename>\n";
exit(-1);
}
my $optlist = "rs:";
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/sbin:/usr/bin:";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# No configure vars.
#
my $sudo = "/usr/local/bin/sudo";
my $zipper = "/usr/local/bin/imagezip";
my $slice = "";
my $device;
my $filename;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV != 2) {
usage();
}
if (defined($options{"s"})) {
my $num = $options{"s"};
if ($num =~ /(\d)/) {
$num = $1;
}
else {
die("Tainted slice number: $num");
}
$slice = "-s $num";
# XXX for now we do not generate relocation info on slices
# XXX there are still some issues with LILO/GRUB
$slice = "-N $slice";
}
$device = $ARGV[0];
$filename = $ARGV[1];
#
# Untaint the arguments.
#
# Note different taint check (allow /).
if ($device =~ /^([-\w.\/]+)$/) {
$device = $1;
}
else {
die("Tainted device name: $device");
}
if ($filename =~ /^([-\w.\/\+]+)$/) {
$filename = $1;
}
else {
die("Tainted output filename: $filename");
}
$device =~ m#/dev/(\D+)(\d+)#;
($dtype, $dunit) = ($1, $2);
$dunit -= 4 if ($dtype eq 'ad' && $dunit > 3);
$dunit =~ y/01234567/abcdefgh/;
$device = "/dev/sd$dunit";
#
# Run the command using sudo, since by definition only testbed users
# with proper trust should be able to zip up a disk. sudo will fail
# if the user is not in the proper group.
#
if (system("$sudo $zipper $slice $device $filename")) {
print STDERR "*** Failed to create image!\n";
exit 1;
}
exit 0;
......@@ -12,7 +12,8 @@ dunit=`echo $disk | sed -e 's/..\([0-7]\)/\1/'`
case $disk in
# IDE
ad[0-3])
dtype="hd"
#dtype="hd"
dtype="sd"
d=`echo $dunit | sed -e 'y/0123/048c/'`
lrootdev="3${d}${part}"
;;
......
......@@ -65,7 +65,7 @@ install_mbr()
if ! dd if=$disk of=/dev/null bs=512 count=1 2>/dev/null; then
echo "WARNING: could not read from $disk, MBR not changed"
return -1
return 255
fi
if [ "$OS" = Linux ]; then
......@@ -99,7 +99,7 @@ install_mbr()
if ! [ -r $MBR_PATH/mbr{$new_mbr_ver}.dd ]; then
echo "WARNING: cannot find MBR version $new_mbr_ver, not installed"
return -1
return 255
fi
echo "Installing MBR version $new_mbr_ver ..."
......@@ -217,7 +217,7 @@ write_image()
port=${address##*:}
if [ $port = $address ]; then
echo "*** WARNING: no port specified for frisbee"
return -1
return 255
fi
address=${address%%:*}
;;
......@@ -242,7 +242,7 @@ write_image()
echo "wget succeeded getting the image"
else
echo "wget failed, status $rc"
return -1
return 255
fi
imagefile=/images/${filename##*/}
;;
......@@ -251,7 +251,7 @@ write_image()
;;
*)
echo "*** WARNING: Unsupported protocol $protocol!"
return -1
return 255
;;
esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment