I am helping a friend set up an automated members join area.
I have the following php script:
while ($row = mysql_fetch_array($result))
{
$username = strtolower($row['username']);
$password = crypt($row['password']);
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$line1 = "/usr/bin/sudo /home/manager/public_html/newuser $username $password '$firstname $lastname'";
exec($line1);
echo "Added $username with password = $password<br>";
usleep(500);
}
I am not salting crypt, so is that the reason I am not getting passwords generated? Or at least not the proper ones.
If I add salt to the crypt parameters, would this work?
Here is a copy of the newuser script file:
#!/bin/bash
domain="server name"
clientip="IP address"
apacheconf="/opt/casp/apache-bundle/conf/httpd.conf"
/usr/bin/sudo /usr/sbin/useradd -d /home/$1 -g users -p $2 -s /bin/false -c "$3" -m $1
/usr/bin/sudo mkdir /home/$1/My_Files
/usr/bin/sudo mkdir /home/$1/My_Pictures
/usr/bin/sudo mkdir /home/$1/My_Website
/usr/bin/sudo cp ./default.html /home/$1/My_Website/
/usr/bin/sudo chown -R $1.users /home/$1/
/usr/bin/sudo chmod -R 755 /home/$1/
Apache Virtual Server
Write the following (at minimum) to httpd.conf (wherever it resides)
/usr/bin/sudo echo " " 1>>$apacheconf
/usr/bin/sudo echo "# Virtual Host Directive for $3" 1>>$apacheconf
/usr/bin/sudo echo "<VirtualHost $clientip>" 1>>$apacheconf
/usr/bin/sudo echo "DocumentRoot /home/$1/My_Website" 1>>$apacheconf
/usr/bin/sudo echo "ServerName $1.$domain" 1>>$apacheconf
/usr/bin/sudo echo "</VirtualHost>" 1>>$apacheconf
I know that I shouldn't be using sudo here, but this is primarily to convert the existing users over to Linux from his WinDoze server.
I am going to try to find a better way to do this as time permits.
Thanks for any help.
Jeff Dierkingserver name