Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Hussamuddin Nasir
emulab-devel
Commits
39da13e6
Commit
39da13e6
authored
Mar 05, 2013
by
Leigh Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a checkbox to control whether a new type is initially restricted
from users.
parent
1077ffe7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
13 deletions
+53
-13
backend/editnodetype.in
backend/editnodetype.in
+21
-9
www/editnodetype.php3
www/editnodetype.php3
+32
-4
No files found.
backend/editnodetype.in
View file @
39da13e6
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-201
2
University of Utah and the Flux Group.
# Copyright (c) 2000-201
3
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -32,12 +32,13 @@ use Data::Dumper;
#
sub
usage
()
{
print
("
Usage: editnodetype [-v] <xmlfile>
\n
");
print
("
Usage: editnodetype [-v]
[-p]
<xmlfile>
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dv
";
my
$debug
=
0
;
my
$verify
=
0
;
# Check data and return status only.
my
$optlist
=
"
dvp
";
my
$restrict
=
0
;
my
$debug
=
0
;
my
$verify
=
0
;
# Check data and return status only.
#
# Configure variables
...
...
@@ -45,6 +46,7 @@ my $verify = 0; # Check data and return status only.
my
$TB
=
"
@prefix
@
";
my
$TBOPS
=
"
@TBOPSEMAIL
@
";
my
$TBAUDIT
=
"
@TBAUDITEMAIL
@
";
my
$UPDATEPERMS
=
"
$TB
/sbin/update_permissions
";
#
# Untaint the path
...
...
@@ -86,6 +88,9 @@ if (defined($options{"d"})) {
if
(
defined
(
$options
{"
v
"}))
{
$verify
=
1
;
}
if
(
defined
(
$options
{"
p
"}))
{
$restrict
=
1
;
}
if
(
@ARGV
!=
1
)
{
usage
();
}
...
...
@@ -587,10 +592,17 @@ if ($new_type) {
"
attrvalue='
$value
'
");
}
# And a group policy that prevents new type from being used.
DBQueryFatal
("
replace into group_policies
"
.
"
(pid_idx, gid_idx, pid, gid, policy, auxdata, count)
"
.
"
values (0, 0, '-', '-', 'type', '
$node_type
', 0)
");
if
(
$restrict
)
{
# And a group policy that prevents new type from being used.
DBQueryFatal
("
replace into group_policies
"
.
"
(pid_idx, gid_idx, pid, gid, policy, auxdata, count)
"
.
"
values (0, 0, '-', '-', 'type', '
$node_type
', 0)
");
#
# Now update the permissions table.
#
system
(
$UPDATEPERMS
);
}
}
else
{
DBQueryFatal
("
update node_types set
"
.
...
...
www/editnodetype.php3
View file @
39da13e6
<?php
#
# Copyright (c) 2000-201
2
University of Utah and the Flux Group.
# Copyright (c) 2000-201
3
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -347,6 +347,24 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors)
</td>
</tr>
\n
"
;
if
(
$new_type
)
{
echo
"<tr>
<td colspan=2>Restricted?:</td>
<td class=left>
<input type=checkbox
name=
\"
formfields[restricted]
\"
value=Yep"
;
if
(
isset
(
$formfields
[
"restricted"
])
&&
$formfields
[
"restricted"
]
==
"Yep"
)
echo
" checked"
;
echo
" > (Initially restrict nodes to emulab-ops)
</td>
</tr>
\n
"
;
}
#
# Now do attributes.
#
...
...
@@ -699,7 +717,14 @@ if (isset($newattribute_name) && $newattribute_name != "" &&
$args
[
"attr_${newattribute_type}_
$newattribute_name
"
]
=
$newattribute_value
;
}
if
(
!
(
$result
=
SetNodeType
(
$node_type
,
$args
,
$errors
)))
{
# Restricted checkbox.
$restricted
=
0
;
if
(
isset
(
$new_type
)
&&
isset
(
$formfields
[
'restricted'
])
&&
$formfields
[
'restricted'
]
==
"Yep"
)
{
$restricted
=
1
;
}
if
(
!
(
$result
=
SetNodeType
(
$node_type
,
$restricted
,
$args
,
$errors
)))
{
# Always respit the form so that the form fields are not lost.
# I just hate it when that happens so lets not be guilty of it ourselves.
SPITFORM
(
$node_type
,
$formfields
,
$attributes
,
$deletes
,
$errors
);
...
...
@@ -723,7 +748,7 @@ PAGEFOOTER();
#
# Create or edit a nodetype. (No class for that at present.)
#
function
SetNodeType
(
$node_type
,
$args
,
&
$errors
)
{
function
SetNodeType
(
$node_type
,
$
restricted
,
$
args
,
&
$errors
)
{
global
$suexec_output
,
$suexec_output_array
;
#
...
...
@@ -754,7 +779,10 @@ function SetNodeType($node_type, $args, &$errors) {
fclose
(
$fp
);
chmod
(
$xmlname
,
0666
);
$retval
=
SUEXEC
(
"nobody"
,
"nobody"
,
"webeditnodetype
$xmlname
"
,
# Restricted checkbox.
$optarg
=
(
$restricted
?
"-p"
:
""
);
$retval
=
SUEXEC
(
"nobody"
,
"nobody"
,
"webeditnodetype
$optarg
$xmlname
"
,
SUEXEC_ACTION_IGNORE
);
if
(
$retval
)
{
...
...
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