Commit 7cd38ddb authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Revert last revision; wrong file committed.

parent 748240a9
......@@ -869,76 +869,6 @@ sub Shutdown($)
return GeniResponse->Create(GENIRESPONSE_SUCCESS);
}
#
# Extend a slice expiration time.
#
sub RenewSlice($)
{
my ($argref) = @_;
my $credstr = $argref->{'credential'};
my $expires = $argref->{'valid_until'};
my $message = "Error renewing slice";
if (! (defined($credstr) && defined($expires))) {
return GeniResponse->Create(GENIRESPONSE_BADARGS);
}
my $credential = GeniCredential->CreateFromSigned($credstr);
if (!defined($credential)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not create GeniCredential object");
}
#
# Make sure the credential was issued to the caller.
#
if ($credential->owner_uuid() ne $ENV{'GENIUUID'}) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"This is not your credential!");
}
my $slice = GeniSlice->Lookup($credential->target_uuid());
if (!defined($slice)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Unknown slice for this credential");
}
$credential->HasPrivilege( "pi" ) or
$credential->HasPrivilege( "bind" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" );
#
# Figure out new expiration time; this is the time at which we can
# idleswap the slice out.
#
if (! ($expires =~ /^[-\w:.\/]+/)) {
$message = "Illegal valid_until in rspec";
goto bad;
}
# Convert to a localtime.
my $when = timegm(strptime($expires));
if (!defined($when)) {
$message = "Could not parse valid_until";
goto bad;
}
#
# Do we need a policy limit?
#
my $diff = $when - time();
if ($diff < (60 * 5) || $diff > (3600 * 24 * 100)) {
$message = "valid_until out of range";
goto bad;
}
if ($slice->SetExpiration($when) != 0) {
$message = "Could not set expiration time";
goto bad;
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS);
bad:
return GeniResponse->Create(GENIRESPONSE_ERROR, undef, $message);
}
#
# Register a sliver.
#
......
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