#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Canada
    Posts
    16
    Rep Power
    0
    HI, does anybody know how to create a new Linux user account by PHP, so that only that user could go to his won account? I tried system("useradd xxx") but didn't work...did I forget anything? or are there any other ways to do that? Thanks!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    Well, as you may know 'adduser' or 'useradd' require a touch more i/o than just 'useradd username'. For instance, it asks which type of shell you want, what you want for a password, and some other stuff (I usually run windows, so i'm unsure of what it asks specifically), and then asks to confirm the addition. I'm not sure exactly how to go about it, but if you know specifically what it asks, you can try to do something like this:

    system("useradd [user]n[password]nrnrn");

    (P.S.: Remember n stands for new line, and r stands for carriage return (the push of the Enter key to confirm the choices made).)

    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    No easy way. Use man useradd to inform yourself about the various switches that useradd accepts and you will be able to use system() to call it.

    But...as always with UNIX there is one huge BUT...You probably cannot even run it, because PHP runs under privileges same as Apache, and that is the user "nobody". You probably need yo run useradd as root, meaning you will have to write a small suid program to do this. I don't know how to do this in PHP...

    And don't and I mean DON'T setup PHP to run as root, or useradd to be accessible by "nobody"...

Similar Threads

  1. How to create LDAP on linux??
    By cleverpig in forum LDAP Programming
    Replies: 4
    Last Post: June 2nd, 2004, 11:55 PM
  2. create user permissions question
    By rmang in forum MySQL Help
    Replies: 2
    Last Post: March 7th, 2004, 04:03 PM
  3. Envisage Windows 14.99 a Year: Envisage Linux 24.99 a Year:
    By smillward in forum Web Hosting Offers
    Replies: 3
    Last Post: February 17th, 2004, 01:19 PM
  4. PHP User restrictions
    By Mastah in forum PHP Development
    Replies: 2
    Last Post: February 9th, 2004, 02:41 AM
  5. Replies: 0
    Last Post: January 31st, 2004, 02:15 AM

IMN logo majestic logo threadwatch logo seochat tools logo