FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old January 1st, 2004, 05:29 AM
artalex artalex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 artalex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!!!

Reply With Quote
  #2  
Old January 1st, 2004, 06:01 AM
realnowhereman realnowhereman is offline
Not there when you need me
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2001
Location: Berlin, Germany
Posts: 1,438 realnowhereman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 8
Does PHP have root access as well?

Reply With Quote
  #3  
Old January 1st, 2004, 08:20 AM
e4c5 e4c5 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2003
Posts: 778 e4c5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 20 sec
Reputation Power: 5
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

Reply With Quote
  #4  
Old January 1st, 2004, 08:27 AM
artalex artalex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 artalex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How can I set up root acces for PHP?

Reply With Quote
  #5  
Old January 1st, 2004, 08:49 AM
realnowhereman realnowhereman is offline
Not there when you need me
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2001
Location: Berlin, Germany
Posts: 1,438 realnowhereman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 8
Run it as root.

Reply With Quote
  #6  
Old January 1st, 2004, 10:06 AM
wizards wizards is offline
The Wizard
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 128 wizards User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
u dont want root access for php.. one bug in any script and ur server goes down the drain

Reply With Quote
  #7  
Old January 1st, 2004, 10:29 AM
sionix sionix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Chandler AZ
Posts: 2 sionix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Need create new FTP-account via PHP!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway