Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
fd5c3258
Commit
fd5c3258
authored
Jan 27, 2015
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project to grant and revoke access. Add GetProject(). Minor fix.
parent
2f28c29d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
db/Lease.pm.in
db/Lease.pm.in
+32
-2
No files found.
db/Lease.pm.in
View file @
fd5c3258
#
!/usr/bin/perl -wT
#
#
Copyright
(
c
)
2012
-
201
4
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2012
-
201
5
University
of
Utah
and
the
Flux
Group
.
#
#
{{{
EMULAB
-
LICENSE
#
...
...
@@ -197,6 +197,7 @@ sub gid($) {return $_[0]->{'DBROW'}->{'gid'}; }
sub
idx
($)
{
return
$
_
[
0
]->{
'DBROW'
}->{
'lease_idx'
};
}
sub
lease_idx
($)
{
return
$
_
[
0
]->
idx
();
}
sub
owner
($)
{
return
$
_
[
0
]->{
'DBROW'
}->{
'owner_uid'
};
}
sub
owner_urn
($)
{
return
$
_
[
0
]->{
'DBROW'
}->{
'owner_urn'
};
}
sub
type
($)
{
return
$
_
[
0
]->{
'DBROW'
}->{
'type'
};
}
sub
inception
($)
{
return
str2time
($
_
[
0
]->{
'DBROW'
}->{
'inception'
});
}
sub
lease_end
($)
{
return
str2time
($
_
[
0
]->{
'DBROW'
}->{
'lease_end'
});
}
...
...
@@ -229,7 +230,7 @@ sub Lookup($$;$$)
$
wclause
=
"pid='$1' and gid='$1' and lease_id='$2'"
;
}
elsif
($
arg1
=~
/^([-\
w
]+)\/([-\
w
]+)\/([-\
w
]+)$/)
{
$
wclause
=
"pid='$1' and gid='$2' and lease_id='$
arg2
'"
;
$
wclause
=
"pid='$1' and gid='$2' and lease_id='$
3
'"
;
}
else
{
return
undef
;
...
...
@@ -1509,6 +1510,11 @@ sub GrantAccess($$$)
$
perm_id
=
$
target
->
pid
()
.
"/"
.
$
target
->
gid
();
$
perm_type
=
"group"
;
}
elsif
(
ref
($
target
)
eq
"Project"
)
{
$
perm_idx
=
$
target
->
gid_idx
();
$
perm_id
=
$
target
->
pid
()
.
"/"
.
$
target
->
gid
();
$
perm_type
=
"group"
;
}
elsif
($
target
eq
GLOBAL_PERM_ANON_RO
())
{
$
perm_idx
=
GLOBAL_PERM_ANON_RO_IDX
();
$
perm_id
=
GLOBAL_PERM_ANON_RO
();
...
...
@@ -1555,6 +1561,10 @@ sub RevokeAccess($$)
$
perm_idx
=
$
target
->
gid_idx
();
$
perm_type
=
"group"
;
}
elsif
(
ref
($
target
)
eq
"Project"
)
{
$
perm_idx
=
$
target
->
gid_idx
();
$
perm_type
=
"group"
;
}
elsif
($
target
eq
GLOBAL_PERM_ANON_RO
())
{
$
perm_idx
=
GLOBAL_PERM_ANON_RO_IDX
();
$
perm_type
=
"global"
;
...
...
@@ -1859,6 +1869,26 @@ sub TakeLock($)
return
0
;
}
#
#
Load
the
project
.
#
sub
GetProject
($)
{
my
($
self
)
=
@
_
;
#
Must
be
a
real
reference
.
return
undef
if
(
! ref($self));
my
$
project
=
Project
->
Lookup
($
self
->
pid
());
if
(
! defined($project)) {
print
(
"*** WARNING: Could not lookup project object for $self!"
,
1
);
return
undef
;
}
return
$
project
;
}
package
Lease
::
Blockstore
;
use
base
qw
(
Lease
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment