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
4a73b9ce
Commit
4a73b9ce
authored
Aug 30, 2016
by
Leigh B Stoller
Browse files
Move chpass into an accountproxy command, rather the ssh invoking
chpass directly.
parent
59fb0036
Changes
2
Hide whitespace changes
Inline
Side-by-side
account/accountsetup.in
View file @
4a73b9ce
...
...
@@ -42,6 +42,7 @@ sub usage()
print
"
Usage: accountsetup adduser ...
\n
";
print
"
accountsetup deluser ...
\n
";
print
"
accountsetup moduser ...
\n
";
print
"
accountsetup chpass ...
\n
";
print
"
accountsetup addproject ...
\n
";
print
"
accountsetup addgroup ...
\n
";
print
"
accountsetup delproject ...
\n
";
...
...
@@ -124,6 +125,7 @@ my @GDIRLIST = ("exp", "images", "logs", "tarfiles", "rpms", "tiplogs");
sub
AddUser
();
sub
DeleteUser
();
sub
ModifyUser
();
sub
ChangePassword
();
sub
AddProject
();
sub
AddGroup
();
sub
DelProject
();
...
...
@@ -177,6 +179,10 @@ SWITCH: for ($cmd) {
ModifyUser
();
last
SWITCH
;
};
/^chpass$/
&&
do
{
ChangePassword
();
last
SWITCH
;
};
/^addproject$/
&&
do
{
AddProject
();
last
SWITCH
;
...
...
@@ -233,7 +239,6 @@ sub AddUser()
my
$hdir
=
shift
(
@ARGV
);
my
$gid
=
shift
(
@ARGV
);
my
$shell
=
shift
(
@ARGV
);
my
$hash
=
(
@ARGV
?
shift
(
@ARGV
)
:
undef
);
if
(
!
-
d
"
$hdir
")
{
# XXX we only handle homedirs of the form /users/$user here...
...
...
@@ -284,13 +289,6 @@ sub AddUser()
chmod
(
0700
,
"
$hdir
/
$dir
")
or
fatal
("
Could not chmod '
$hdir
/
$dir
' to 0700: $!
");
}
#
# Finally, set any initial password hash
#
if
(
defined
(
$hash
)
&&
mysystem
("
$CHPASS
-p '
$hash
'
$user
"))
{
fatal
("
Could not initialize password
");
}
return
0
;
}
...
...
@@ -346,6 +344,20 @@ sub ModifyUser()
return
0
;
}
sub
ChangePassword
()
{
if
(
@ARGV
!=
2
)
{
fatal
("
chpass: Wrong number of arguments
");
}
my
$user
=
shift
(
@ARGV
);
my
$hash
=
shift
(
@ARGV
);
if
(
mysystem
("
$CHPASS
-p '
$hash
'
$user
"))
{
fatal
("
Could not change password
");
}
return
0
;
}
#
# Usage: deactivate username
#
...
...
account/tbacct.in
View file @
4a73b9ce
...
...
@@ -467,7 +467,8 @@ sub AddUser()
$pswd
=~
s/\*/\\\*/g
;
print
"
Initializing user
$user
password on
$CONTROL
.
\n
";
if
(
system
("
$SSH
-host
$CONTROL
$CHPASS
-p '
$pswd
'
$user
"))
{
if
(
system
("
$SSH
-host
$CONTROL
"
.
"
\"
$ACCOUNTPROXY
chpass
$user
'
$pswd
'
\"
"))
{
fatal
("
Could not initialize password for
$user
on
$CONTROL
!
");
}
}
...
...
@@ -678,7 +679,7 @@ sub UpdatePassword()
my
$new_pswd
=
shift
(
@ARGV
);
# Lets not do this if no changes.
if
(
$new_pswd
eq
$target_user
->
pswd
())
{
if
(
$new_pswd
eq
$target_user
->
pswd
()
&&
!
$force
)
{
print
"
Password has not changed ...
\n
";
return
0
;
}
...
...
@@ -752,9 +753,10 @@ sub UpdatePassword()
$UID
=
0
;
if
(
$CONTROL
ne
$BOSSNODE
)
{
print
"
Updating user
$user
password on
$CONTROL
.
\n
";
if
(
system
("
$SSH
-host
$CONTROL
$CHPASS
-p '
$safe_pswd
'
$user
"))
{
fatal
("
Could not change password for user
$user
on
$CONTROL
!
");
if
(
system
("
$SSH
-host
$CONTROL
"
.
"
\"
$ACCOUNTPROXY
chpass
$user
'
$safe_pswd
'
\"
"))
{
fatal
("
Could not change password for
$user
on
$CONTROL
!
");
}
}
$UID
=
$SAVEUID
;
...
...
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