|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Need create new FTP-account via PHP!
I need this script for free hosting service.
When new user signup, I need automatically created FTP account with home dirrectory /home/userlogin and subdomain as userlogin.myhost.com Can anybody help me? I have root acces. I try use unix command as "useradd" via php: system("useradd user -p password -d /home/$user") bot it still not work. Please help!!! |
|
#2
|
|||
|
|||
|
Does PHP have root access as well?
|
|
#3
|
|||
|
|||
|
Hi,
As has been pointed out php does not have root access and for a good reason. You can easily wreck havoc with that kind of access. HOwever all is not lost there is still suexec and sudo.
__________________
A lean and mean secure FTP applet with GUI. Just 150 kb in size http://www.radinks.com/sftp |
|
#4
|
|||
|
|||
|
How can I set up root acces for PHP?
|
|
#5
|
|||
|
|||
|
Run it as root.
|
|
#6
|
|||
|
|||
|
u dont want root access for php.. one bug in any script and ur server goes down the drain
|
|
#7
|
|||
|
|||
|
I just went through this and ended up using a combination of php and shell scripts. I also took advantage of a program called super. This program has a tab file with entries that detail specific users with programs that they are allowed to run with root privilages. I avoided running apache or php as root to minimize security vulnerabilities. You're on the right track using the system call. I used the system function to run my super app that then referenced the shell script for creating users. This was all done on FreeBSD, the php code was:
function createUser($dur, $comp, $user, $passwd, $em){ system("/usr/local/bin/super userSetup.sh $dur $comp $user $passwd $em"); } I went a step further and used $dur to perform an automatic account expiration, $comp is what company this new user is associated with, and $em is the email account of the person that created the account. When the account is about to be deleted a message is sent to the person that create it. userSetup.sh is my shell script that actually runs the pw program to create local system accounts. This is a FreeBSD passwd manager command. I'm not sure what the equivalent would be for linux. The line within the shell script that creates the local account is: echo $4 | /usr/sbin/pw useradd -q -h 0 -n $3 -s /bin/none -d /home/$3 -m The options here are: -q quite mode, -h 0 accept input for password from stdin, -n the users name, -s users shell, -d home dir and -m to create the home dir. $4 is the password, $3 is the username. The other values passed to the shell script form php are used elsewhere in the shell script for setup of automatic account deletion. I also moved the shell scripts and php script that calls the shell script to a directory outside of apache's local dir. i.e. apache->php to collect new user info->pass info to php script outside of apache local dir->php script calls shell script also outside of apache local dir->shell script calls super prog->super references super.tab to see if the www user that apache/php is running as can run the referenced shell script (thus gaining root privs to execute the pw command and affect the accounts database)->pw is run with passed vaules->new local user with no shell env is created for ftp use only. Again an attempt at minimizing breaches. Hope this helps. Sionix |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > Need create new FTP-account via PHP! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|