Commit 7bafb170 authored by Leigh Stoller's avatar Leigh Stoller

Do not allow non-admins to turn off autoswap or set it to more then

five days out. The user can bypass this though since the time is in
hours, and they can just set it everyday. But, most people will not
catch onto that.
parent 77a696ae
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -381,15 +381,23 @@ if (exists($editexp_args{"noidleswap_reason"})) {
#
# AutoSwap
#
if (exists($editexp_args{"autoswap"})) {
if ($editexp_args{"autoswap"} ne "1") {
if (!$this_user->IsAdmin()) {
UserError("Max Duration: ".
"you must ask testbed operations to disable this");
}
$editexp_args{"autoswap"} = 0;
}
}
if (exists($editexp_args{"autoswap_timeout"})) {
if ($editexp_args{"autoswap_timeout"} <= 0) {
UserError("Max Duration: Invalid time provided");
}
}
if (exists($editexp_args{"autoswap"})) {
if ($editexp_args{"autoswap"} ne "1") {
$editexp_args{"autoswap"} = 0;
#XXX $editexp_args{"autoswap_timeout"} = 0;
if ($editexp_args{"autoswap_timeout"} > (24 * 5) &&
!$this_user->IsAdmin()) {
UserError("Max Duration: 5 days maximum - ".
"you must ask testbed operations for more");
}
}
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -259,6 +259,10 @@ if (!isset($formfields["exp_idleswap_timeout"]) ||
if (!isset($formfields["exp_autoswap"]) ||
strcmp($formfields["exp_autoswap"], "1")) {
if (!ISADMIN()) {
$errors["Max. Duration"] =
"You must ask testbed operations to disable this";
}
$formfields["exp_autoswap"] = 0;
}
else {
......@@ -269,6 +273,11 @@ else {
($formfields["exp_autoswap_timeout"] + 0) <= 0) {
$errors["Max. Duration"] = "No or invalid time provided";
}
# The user can override autoswap timeout, but limit unless an admin.
if ($formfields["exp_idleswap_timeout"] > 24 * 5 && !ISADMIN()) {
$errors["Max. Duration"] = "5 days maximum - ".
"you must ask testbed operations for more";
}
}
#
......
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