custom change password script

2 posts / 0 new
Last post
#1 Tue, 12/18/2007 - 07:48
chattanoogaonline

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

Sun, 06/07/2009 - 07:28
mhosts

<b>chattanoogaonline wrote:</b>
<div class='quote'>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 &lt;username&gt; -opass &lt;oldpassword&gt; -pass &lt;newpassword&gt;[/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.&lt;br&gt;&lt;br&gt;Post edited by: chattanoogaonline, at: 2007/12/18 07:49</div>

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 &quot;#./change-password.pl username oldpass newpass&quot;.

Edit the following lines from:
[code:1]# Read inputs
$| = 1;
if ($ARGV[0]) {
$username = $ARGV[0];
}
else {
print &quot;Username: &quot;;
chop($username = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
}
print &quot;Old password: &quot;;
chop($oldpass = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
print &quot;New password: &quot;;
chop($newpass = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
if (!$username) {
&amp;error_exit(&quot;No username given&quot;&Acirc;&laquo;&Acirc;&raquo;);
}
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 &quot;Username: &quot;;
chop($username = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
}
if ($ARGV[1]) {
$oldpass = $ARGV[1];
}
else {
print &quot;Old password: &quot;;
chop($oldpass = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
}
if ($ARGV[2]) {
$newpass = $ARGV[2];
}
else {
print &quot;New password: &quot;;
chop($newpass = &lt;STDIN&gt;&Acirc;&laquo;&Acirc;&raquo;);
}
if (!$username) {
&amp;error_exit(&quot;No username given&quot;&Acirc;&laquo;&Acirc;&raquo;);
}
sleep(5); # To prevent brute force attacks[/code:1]

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

Topic locked