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
42b7f645
Commit
42b7f645
authored
Dec 18, 2000
by
Kristin Wright
Browse files
made project a mandatory arg to mkacct
parent
6a4141fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
tbsetup/mkacct
View file @
42b7f645
#!/usr/local/bin/perl -wT
#!/usr/local/bin/perl -wT
# $Id: mkacct,v 1.3
0
2000-12-1
5 18:10:52 stoller
Exp $
# $Id: mkacct,v 1.3
1
2000-12-1
8 21:42:48 kwright
Exp $
use
English
;
use
English
;
use
Mysql
;
use
Mysql
;
...
@@ -10,7 +10,7 @@ my $control_subnet = "155\.99\.214\.";
...
@@ -10,7 +10,7 @@ my $control_subnet = "155\.99\.214\.";
my
$me
;
# alphanumeric username of $UID
my
$me
;
# alphanumeric username of $UID
my
$eid
;
# experiment ID from command line
my
$eid
;
# experiment ID from command line
my
$group_name
;
# project/group
that
the
above EID belongs to
my
$group_name
;
# project/group
from
the
command line
my
$group_number
;
# the number associated with group_name
my
$group_number
;
# the number associated with group_name
my
$dbh
;
# database handle
my
$dbh
;
# database handle
...
@@ -35,11 +35,10 @@ sub doqueries() {
...
@@ -35,11 +35,10 @@ sub doqueries() {
print
"
Selecting users...
\n
";
print
"
Selecting users...
\n
";
$db_query
=
$db_query
=
"
select u.uid,u.usr_pswd,u.unix_uid,u.usr_name
"
.
"
select u.uid,u.usr_pswd,u.unix_uid,u.usr_name
"
.
"
from experiments as e
"
.
"
from projects as p
"
.
"
left join projects as p on e.pid = p.pid
"
.
"
left join proj_memb as pm on p.pid = pm.pid
"
.
"
left join proj_memb as pm on p.pid = pm.pid
"
.
"
left join users as u on u.uid = pm.uid
"
.
"
left join users as u on u.uid = pm.uid
"
.
"
where
e.e
id = '
$
eid
'
";
"
where
p.p
id = '
$
group_name
'
";
$sth
=
$dbh
->
query
(
$db_query
);
$sth
=
$dbh
->
query
(
$db_query
);
while
(
@row
=
$sth
->
fetchrow_array
)
{
while
(
@row
=
$sth
->
fetchrow_array
)
{
...
@@ -83,9 +82,8 @@ sub doqueries() {
...
@@ -83,9 +82,8 @@ sub doqueries() {
# Note: In the end, I simply assign to 'plastic' as control
# Note: In the end, I simply assign to 'plastic' as control
# nodes are not yet set in the database. 12/3/00 -lkw
# nodes are not yet set in the database. 12/3/00 -lkw
#
#
$db_query
=
"
select p.unix_gid, p.pid, p.control_node
"
.
$db_query
=
"
select unix_gid, pid, control_node
"
.
"
from projects as p, experiments as e
"
.
"
from projects where pid='
$group_name
'
";
"
where p.pid=e.pid and e.eid='
$eid
'
";
$sth
=
$dbh
->
query
(
$db_query
);
$sth
=
$dbh
->
query
(
$db_query
);
got_tuples
(
$sth
)
or
die
"
$0: Error selecting group fields.
\n
";
got_tuples
(
$sth
)
or
die
"
$0: Error selecting group fields.
\n
";
@db_row
=
$sth
->
fetchrow_array
();
@db_row
=
$sth
->
fetchrow_array
();
...
@@ -127,7 +125,7 @@ sub is_node_ok() {
...
@@ -127,7 +125,7 @@ sub is_node_ok() {
return
0
;
return
0
;
}
}
# the node must be on the control ne
w
# the node must be on the control ne
t
if
(
!
(
$node
=~
/$control_subnet/
)
)
{
if
(
!
(
$node
=~
/$control_subnet/
)
)
{
return
0
;
return
0
;
}
}
...
@@ -228,9 +226,9 @@ sub sanitize() {
...
@@ -228,9 +226,9 @@ sub sanitize() {
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
## check usage
## check usage
if
(
$#ARGV
<
0
)
{
if
(
$#ARGV
<
1
)
{
die
("
Usage: mkacct <eid>
\n
"
.
die
("
Usage: mkacct <eid>
<pid>
\n
"
.
"
\t
Creates user accounts by experiment
.
\n
");
"
\t
Creates user accounts by experiment
/pid pair
\n
");
}
}
## sanitize eid
## sanitize eid
...
@@ -240,6 +238,13 @@ sub sanitize() {
...
@@ -240,6 +238,13 @@ sub sanitize() {
die
"
$0: EID
$ARGV
[0] has invalid characters.
\n
";
die
"
$0: EID
$ARGV
[0] has invalid characters.
\n
";
}
}
## sanitize project
if
(
$ARGV
[
1
]
=~
/^([A-Za-z0-9-]+)$/
)
{
$group_name
=
$
1
;
}
else
{
die
"
$0: Project argument
$ARGV
[1] has invalid characters.
\n
";
}
## effective uid must be root
## effective uid must be root
if
(
$>
!=
0
)
{
if
(
$>
!=
0
)
{
die
("
$0: Must have an EUID of 0 to create accounts.
\n
");
die
("
$0: Must have an EUID of 0 to create accounts.
\n
");
...
...
tbsetup/tbrun.tcl
View file @
42b7f645
...
@@ -130,7 +130,7 @@ if {[catch "exec $ifcboot $pid $eid $ifcfile >@ $logFp 2>@ $logFp" err]} {
...
@@ -130,7 +130,7 @@ if {[catch "exec $ifcboot $pid $eid $ifcfile >@ $logFp 2>@ $logFp" err]} {
outs
"PLACEHOLDER - Installing secondary packages."
outs
"PLACEHOLDER - Installing secondary packages."
outs
"Creating user accounts."
outs
"Creating user accounts."
if
{[
catch
"exec
$mkacct
$eid
>@
$log
Fp 2>@
$log
Fp"
err
]}
{
if
{[
catch
"exec
$mkacct
$eid
$pid
>@
$log
Fp 2>@
$log
Fp"
err
]}
{
outs stderr
"Error running
$mkacct.
(
$err
)"
outs stderr
"Error running
$mkacct.
(
$err
)"
exit 1
exit 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