Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004

    Lightbulb Unanswered: Useradd passing variable from shell script to PHP.

    Hi guys, this is the 1st post and i hope that someone can solve my problem. This is the 1st time i'm touching shell script and have encounter some problems along the way.

    I need to do something like mail system. Ex. (yahoo mail).
    I gt User interface to create new user and password.
    The thing is i'm using a php script to execute the shell script which contains the useradd function to add a user. I'm working on a mandrake machine.

    I was unable to adduser. I guess that because i'm not root so i'm not able to adduser. But how do i add the command on the shell script to let it execute as a root?? I'm really a novice of shell script. Or is it some other possible problems?? I have try to figure out myself but maybe i'm too dumb. Please help out.


    #if [ "$(whoami)" != "root" ] ; then
    # echo "Error: You must be root to run this command." >&2
    # exit 1

    export PATH

    #if [ "$1" = "" ] ; then
    # echo "You must key in your username as first argument and password as second argument"
    # exit 1
    # elif [ "$2" = "" ] ; then
    # echo "you must key in your password as second argument"
    # exit 1
    $User $1
    echo $1

    echo $2 > passwdfile

    Pw="passwd" #Creating password
    #export $Pw
    $Pw --stdin $1 < passwdfile

    rm -rf passwdfile

    If this question has been ask before, kindly quote the post thanks..
    Last edited by Junn; 11-25-04 at 04:59. Reason: forgot to add the coding

  2. #2
    Join Date
    Jun 2003
    Toronto, Canada
    Provided Answers: 1
    I would be very careful about running something as root from the web. For example, what do you think would happen if somebody enters "-g 0 user" as a username? Or, better yet, "auser && rm -rf /"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts