custom change password script

I have been looking at the remote API and the possibility of creating a custom password change scripttfor Virtualmin. There is already a change-password.pl script that is used my usermin to change the virtualmin users passwords but it does not seem like it is something that can be used by the remote API since it does not have parameters that I can pass into the program. It looks like it checks $ARGV[0] for the username and if it is there it bypasses the prompt to enter the username and goes directly to the Old Password Prompt.

Are there plans to add an updated version that I can pass all this info to using command line parameters like the other scripts in the command line API? Something like

[code:1]./change-password.pl -user <username> -opass <oldpassword> -pass <newpassword>[/code:1]

I am considering writing this so I can develop script using the remote API to allow my users to change their passwords without having to access usermin.<br><br>Post edited by: chattanoogaonline, at: 2007/12/18 07:49

chattanoogaonline wrote:

I have been looking at the remote API and the possibility of creating a custom password change scripttfor Virtualmin. There is already a change-password.pl script that is used my usermin to change the virtualmin users passwords but it does not seem like it is something that can be used by the remote API since it does not have parameters that I can pass into the program. It looks like it checks $ARGV[0] for the username and if it is there it bypasses the prompt to enter the username and goes directly to the Old Password Prompt.

Are there plans to add an updated version that I can pass all this info to using command line parameters like the other scripts in the command line API? Something like

[code:1]./change-password.pl -user <username> -opass <oldpassword> -pass <newpassword>[/code:1]

I am considering writing this so I can develop script using the remote API to allow my users to change their passwords without having to access usermin.<br><br>Post edited by: chattanoogaonline, at: 2007/12/18 07:49

I know this thread is a little old but it’s very easy to make the file do this… The following modification to change-password.pl will allow the input of “#./change-password.pl username oldpass newpass”.

Edit the following lines from:

[code:1]# Read inputs
$| = 1;
if ($ARGV[0]) {
$username = $ARGV[0];
}
else {
print "Username: ";
chop($username = <STDIN>«»);
}
print "Old password: ";
chop($oldpass = <STDIN>«»);
print "New password: ";
chop($newpass = <STDIN>«»);
if (!$username) {
&error_exit("No username given"«»);
}
sleep(5); # To prevent brute force attacks
[/code:1]

And change to This:

[code:1]# Read inputs
$| = 1;
if ($ARGV[0]) {
$username = $ARGV[0];
}
else {
print "Username: ";
chop($username = <STDIN>«»);
}
if ($ARGV[1]) {
$oldpass = $ARGV[1];
}
else {
print "Old password: ";
chop($oldpass = <STDIN>«»);
}
if ($ARGV[2]) {
$newpass = $ARGV[2];
}
else {
print "New password: ";
chop($newpass = <STDIN>«»);
}
if (!$username) {
&error_exit("No username given"«»);
}
sleep(5); # To prevent brute force attacks[/code:1]

Hope this helps if you’re still having the problem.