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
0b73a121
Commit
0b73a121
authored
Sep 27, 2001
by
Robert Ricci
Browse files
Changed to use libdb, and removed some unnecessary boilerplate
parent
88a251cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
db/webcontrol.in
View file @
0b73a121
...
...
@@ -15,12 +15,8 @@ my $optlist = "m:l:";
#
# Configure variables
#
my
$TB
=
"
@prefix
@
";
my
$DBNAME
=
"
@TBDBNAME
@
";
# un-taint path
$ENV
{'
PATH
'}
=
'
/bin:/usr/bin:/usr/local/bin:/usr/site/bin
';
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
use
lib
"
@prefix
@/lib
";
use
libdb
;
#
# Turn off line buffering on output
...
...
@@ -59,36 +55,23 @@ if (defined($options{"l"})) {
}
}
#
# Set up for querying the database.
#
use
Mysql
;
my
$DB
=
Mysql
->
connect
("
localhost
",
$DBNAME
,
"
script
",
"
none
");
#
# Only root or admin types!
#
if
(
$UID
!=
0
)
{
(
$name
)
=
getpwuid
(
$UID
)
or
die
"
$UID
not in passwd file
\n
";
$db_result
=
$DB
->
query
("
select admin from users where uid='
$name
'
");
@row
=
$db_result
->
fetchrow_array
();
if
(
$row
[
0
]
!=
1
)
{
if
((
$UID
!=
0
)
&&
(
!
TBAdmin
(
$UID
)))
{
die
("
Only root or TB administrators can control the web interface.
\n
");
}
}
if
(
$setmesg
)
{
if
(
$message
eq
"")
{
print
"
Clearing Web Message of the Day
\n
";
$db_result
=
$DB
->
query
("
delete from loginmessage
");
DBQueryFatal
("
delete from loginmessage
");
}
else
{
print
"
Setting Web Message of the Day to
$message
\n
";
$db_result
=
$DB
->
query
("
replace into loginmessage (valid, message)
"
.
DBQueryFatal
("
replace into loginmessage (valid, message)
"
.
"
values(1, '
$message
')
");
}
}
...
...
@@ -97,12 +80,12 @@ if ($setlogin) {
if
(
$logins
)
{
print
"
Enabling Web Interface logins
\n
";
$db_result
=
$DB
->
query
("
delete from nologins
");
DBQueryFatal
("
delete from nologins
");
}
else
{
print
"
Disabling Web Interface logins
\n
";
$db_result
=
$DB
->
query
("
replace into nologins (nologins) values(1)
");
DBQueryFatal
("
replace into nologins (nologins) values(1)
");
}
}
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