To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
hi!
i'm tearing my hair out and just wondered if anyone knows the answer to this. Im trying to run a php script as cgi to add a new ftp user.
the adduser works fine, but how on earth can i change/add the password, since , on a command line, you would have to hit return twice te re-enter the new password. i tried everything, but its just not happening.
any hints clues etc would be most appreciated. thanks.
here's what i've got
<code from here>
#!/usr/bin/php
<?
$ftp_path="the path";
$folder="the folder";
$user_name="the user name";
exec ($setpw , $result1Array);
reset($result1Array);
while (list ($key, $val) = each ($result1Array))
{
$resultLines .= "\n" . trim($val);
}
exec ($setpw1, $result2Array);
reset($result2Array);
while (list ($key, $val) = each ($result2Array))
{
$resultLines .= "\n" . trim($val);
}
exec ($setpw2, $result2Array);
reset($result2Array);
while (list ($key, $val) = each ($result2Array))
{
$resultLines .= "\n" . trim($val);
}
// not working to here
// set rights from here - is fine
// more code etc etc
?>
i also tried all sorts of permutations for the set password part , but to no avail, nor did i find any more usable hints anywhere on the net.
Thnks for your time guys
this is probably more then you wanted to know but pay close attention how I took the password and encrypted it shadow style then I used the -p switch that will add it to the shadow file automatically.
(OH YEAH I WENT BALD FIGURING THIS OUT)
John
__________________
I think Therefore I code
---
Try the All new Jkcool.com instant Messenger Http://www.jkcool.com/sitefiles/im.php
---
oh yeah forgot. I added all my users to a database so I would check it against that as well as my home directory just to make sure I didn't do an add user with a user that already exsisted. Also ignore how $md5pass= crypt($password) I had a hard time figureing out how to make the password shadow style and I never changed the varible so it should probably read $shadowpass = crypt($password); FYI
John
__________________
I think Therefore I code
---
Try the All new Jkcool.com instant Messenger Http://www.jkcool.com/sitefiles/im.php
---
function rannum(){
mt_srand((double)microtime()*1000000);
$num = mt_rand(46,122);
return $num;
}
function genchr(){
// return random salt character
do {
$num = rannum();
} while (($num>57 && $num<65) || ($num>90 && $num<97));
$char = chr($num);
return $char;
}
function saltstr($size){
// make salt
for($i=1;$i<=$size;$i++) {
$string = $string.genchr();
}
return $string;
}
function gensalt($type){
if($type=="md5") {
// use md5 encryptions for debian systems
return sprintf("$1$%s$",saltstr(8));
} else {
// default to regular 2 char des
return saltstr(2);
}
}
using these functions you would then set the password using this:
Code:
$crypt = crypt($password,gensalt($passtype));
where passtype is either md5 or des depending on your system.
then you can call usemod like this:
Code:
echo `usermod 2>&1 -p '$crypt' $username`
Most of this code is taken from our exim web config program called Theem, that we're working on polishing up and then eventually releasing.