Commit ca65cbd9 authored by Leigh Stoller's avatar Leigh Stoller

Hide the image path selection box for mere users, and force paths

from directory to filename when IMAGEDIRECTORIES is turned off, or
not admin|feature enabled.
parent 64c34d7a
...@@ -56,6 +56,7 @@ my $TBPROJ_DIR = "@PROJROOT_DIR@"; ...@@ -56,6 +56,7 @@ my $TBPROJ_DIR = "@PROJROOT_DIR@";
my $CREATEIMAGE = "$TB/bin/create_image"; my $CREATEIMAGE = "$TB/bin/create_image";
my $CLONEIMAGE = "$TB/sbin/clone_image"; my $CLONEIMAGE = "$TB/sbin/clone_image";
my $RUNSONXEN = "$TB/sbin/runsonxen"; my $RUNSONXEN = "$TB/sbin/runsonxen";
my $DOIMAGEDIRS = @IMAGEDIRECTORIES@;
# #
# Untaint the path # Untaint the path
...@@ -79,6 +80,7 @@ use Project; ...@@ -79,6 +80,7 @@ use Project;
use Image; use Image;
use OSinfo; use OSinfo;
use Node; use Node;
use EmulabFeatures;
# Protos # Protos
sub fatal($); sub fatal($);
...@@ -552,6 +554,17 @@ elsif (! $isadmin) { ...@@ -552,6 +554,17 @@ elsif (! $isadmin) {
UserError("Path: Invalid Path"); UserError("Path: Invalid Path");
} }
} }
#
# Image path from the web interface does not respect the
# IMAGEDIRECTORIES feature or config variable. We fix it up here.
#
if ($newimageid_args{"path"} =~ /\/$/ &&
(! $DOIMAGEDIRS ||
! ($isadmin ||
EmulabFeatures->FeatureEnabled("ImageDirectories",
$this_user, $group)))) {
$newimageid_args{"path"} =~ s/\/$/.ndz/;
}
if ($newimageid_args{"path"} =~ /\/$/) { if ($newimageid_args{"path"} =~ /\/$/) {
if (-e $newimageid_args{"path"} && ! -d $newimageid_args{"path"}) { if (-e $newimageid_args{"path"} && ! -d $newimageid_args{"path"}) {
UserError("Path: invalid path, it should be a directory"); UserError("Path: invalid path, it should be a directory");
......
...@@ -483,7 +483,8 @@ function SPITFORM($formfields, $errors) ...@@ -483,7 +483,8 @@ function SPITFORM($formfields, $errors)
# #
# Path to image. # Path to image.
# #
echo "<tr> $style = ($isadmin ? "" : "style='display:none;'");
echo "<tr $style>
<td>Directory for Image:<br> <td>Directory for Image:<br>
(must reside in $TBPROJ_DIR)</td> (must reside in $TBPROJ_DIR)</td>
<td class=left> <td class=left>
......
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