Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM creating user using exec in PHP

date posted 8th January 2003 17:07

On Wed, 8 Jan 2003, Nigell Boulton wrote:

> I am trying to create a user on my linux server using PHP. If i cut and paste the string from $command2 into a SSH shell, it creates the account. What kind of permissions should i run on this script.
>
>

useradd normally needs root privs to do it's work. Having CGI/PHP/etc
running as root is rarely a good idea though.

A better way of doing this would be to do something like:

groupadd -r webuseradd
; create a system group (-r) named webuseradd
chown root.webuseradd /etc/passwd
chown root.webuseradd /etc/shadow
chmod g+rw /etc/passwd
chmod g+rw /etc/shadow
; make /etc/shadow and /etc/passwd group writable and in the webuseradd
; group

then have your PHP script run as a user in the webuseradd group.

Also, if you're getting user or groupnames from the user, be sure that
you've removed all possible shell metacharacters from the strings you're
pasting into a useradd command - otherwise a malicious user could append a ;
or similar and have that exec command run other commands... the safest
approach is to only let [a-zA-Z0-9] through!

Best Regards,
Alex.
--
Alex Butcher Brainbench MVP for Internet Security: www.brainbench.com
Bristol, UK Need reliable and secure network systems?
PGP/GnuPG ID:0x271fd950



Messages by Day
January 31st 2003
January 30th 2003
January 29th 2003
January 28th 2003
January 27th 2003
January 26th 2003
January 25th 2003
January 24th 2003
January 23rd 2003
January 22nd 2003
January 21st 2003
January 20th 2003
January 19th 2003
January 18th 2003
January 17th 2003
January 16th 2003
January 15th 2003
January 14th 2003
January 13th 2003
January 12th 2003
January 11th 2003
January 10th 2003
January 9th 2003
January 8th 2003
January 7th 2003
January 6th 2003
January 5th 2003
January 4th 2003
January 3rd 2003
January 2nd 2003
January 1st 2003


Messages by Month
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000