Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
6978c4a5
Commit
6978c4a5
authored
Feb 04, 2015
by
Leigh B Stoller
Browse files
Add LookupAccess() to see if a target (user,group) has access to an image,
returning a writeable flag.
parent
36b179cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
db/Image.pm.in
View file @
6978c4a5
#
!/usr/bin/perl -wT
#
#
Copyright
(
c
)
2007
-
201
4
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2007
-
201
5
University
of
Utah
and
the
Flux
Group
.
#
#
{{{
EMULAB
-
LICENSE
#
...
...
@@ -1693,6 +1693,41 @@ sub GrantAccess($$$)
return
0
;
}
sub
LookupAccess
($$$$)
{
my
($
self
,
$
target
,
$
paccess
,
$
pwriteable
)
=
@
_
;
my
$
imageid
=
$
self
->
imageid
();
my
$
imagename
=
$
self
->
imagename
();
my
($
perm_idx
,
$
perm_id
,
$
perm_type
);
if
(
ref
($
target
)
eq
"User"
)
{
$
perm_idx
=
$
target
->
uid_idx
();
$
perm_id
=
$
target
->
uid
();
$
perm_type
=
"user"
;
}
elsif
(
ref
($
target
)
eq
"Group"
)
{
$
perm_idx
=
$
target
->
gid_idx
();
$
perm_id
=
$
target
->
pid
()
.
"/"
.
$
target
->
gid
();
$
perm_type
=
"group"
;
}
my
$
query_result
=
DBQueryWarn
(
"select allow_write from image_permissions "
.
"where imageid='$imageid' and "
.
" permission_type='$perm_type' and "
.
" permission_idx='$perm_idx'"
);
return
-
1
if
(
!$query_result);
if
(
!$query_result->numrows) {
$$
paccess
=
0
;
$$
pwriteable
=
0
if
(
defined
($
pwriteable
));
}
my
($
writeable
)
=
$
query_result
->
fetchrow_array
();
$$
paccess
=
1
;
$$
pwriteable
=
$
writeable
if
(
defined
($
pwriteable
));
return
0
;
}
sub
RevokeAccess
($$)
{
my
($
self
,
$
target
)
=
@
_
;
...
...
Write
Preview
Supports
Markdown
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