Professional Web Applications Themes

EXEC command - PHP Development

How do you run this ? Which user ? if its done via Apache - you can't run useradd with the apache user name. if you run it from command line make sure you are root. Nabil wrote: ...

  1. #1

    Default Re: exec command

    How do you run this ? Which user ?

    if its done via Apache - you can't run useradd with the apache user name.
    if you run it from command line make sure you are root.

    Nabil wrote: 
    Gal Guest

  2. #2

    Default exec command

    hi all;

    I want to execute
    #useradd -d /home/all -g wahtever -s /bin/bash newuser

    how can I do it ... I used exec and shell_exec and system
    I tried all the following but with no hope

    exec('useradd -d /home/all -g wahtever -s /bin/bash newuser') or die ('not
    done');
    exec('/usr/sbin/useradd -d /home/all -g wahtever -s /bin/bash newuser') or
    die ('not done');
    shell_exec('useradd -d /home/all -g wahtever -s /bin/bash newuser') or die
    ('not done');
    Nabil Guest

  3. #3

    Default Re: [PHP] exec command

    You can use sudo (man sudo), but keep in mind security!!!

    nabil wrote: 
    Marek Guest

  4. #4

    Default Re: [PHP] exec command

    so when i use php exec to do it , am i using apache user (nobody) or am i
    using php user , is there a php user ?
    so what can i do ?
    i want to execute
    #useradd -d /home/all -g wahtever -s /bin/false newuser
    as i want to create only pop user on the system when my user make
    regestration.. to give him an email account

    any comment ?



    "Ray Hunter" <com> wrote in message
    news:info.trw.com... 
    >
    > You have to be root to add a user to the system...and just a heads
    > up...you might want to rethink doing this from apache or php. The
    > security implications alone make me cringe.
    >
    > --
    > Ray[/ref]
    Nabil Guest

  5. #5

    Default Re: [PHP] exec command

    "Nabil" <com> wrote in message
    news:pair.com... 
    am i 

    Question to your answer has already been given.
    Review the thread and you will see it.

    But to answer your question (again):
    You are running as the user the Apache daemon got started.
    Apache handles the request and recognizes that it has to
    hand the request to PHP.

    Still you will have to check the stuff entered before
    executing!!!
    See the posts by Javier Tacon!!

    And to get it work, you must get the command executed as
    root. This may be achieved by using sudo (please lookup
    the man pages or internet for help on that!).

    Just one comment at last:
    Don't let Apache run as root! That would make it all worse
    than using sudo for your script, because Apache could
    execute critical code killing your system when running
    as root. One who is in practice could hack your system
    within seconds.
    Apache always MUST run as a non-privileged user!


    HTH.

    --
    Dennis Sterzenbach
    www.darknoise.de
    Dennis Guest

  6. #6

    Default EXEC command

    On apache server running on a linux box:

    at bash prompt

    echo test >> /home/shared/textfile

    adds test to the end of textfile

    shared is set up so anyone can write there.

    However the php script:

    <?
    $s="\"echo test >> /home/shared/textfile\"";
    exec($s) ;
    ?>

    does nothing.

    Am I missing something obvious?

    Thanks

    Kevin


    Kevin Guest

  7. #7

    Default Re: EXEC command

    On Sun, 29 Aug 2004 16:20:56 +0100, "Kevin" <kevinsomewhere.co.uk> wrote:
    >On apache server running on a linux box:
    >
    >at bash prompt
    >
    >echo test >> /home/shared/textfile
    >
    >adds test to the end of textfile
    >
    >shared is set up so anyone can write there.
    >
    >However the php script:
    >
    ><?
    >$s="\"echo test >> /home/shared/textfile\"";
    ^^ ^^

    Why are these here?
    >exec($s) ;
    >?>
    >
    >does nothing.
    >
    >Am I missing something obvious?
    As well as the above, you're not checking the return code or output.

    --
    Andy Hassall / <andyandyh.co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Hassall Guest

  8. #8

    Default Re: EXEC command

    > >exec($s) ;
    > >
    > >does nothing.
    > >
    > >Am I missing something obvious?
    Yes I was being blocked by safe mode

    I have created a php.ini file just containing

    safe_mode = off

    Now it is fine.

    Kevin


    Kevin Guest

Similar Threads

  1. #25325 [Fbk->Opn]: command from exec do not migrate in an openMosix cluster
    By carb at videotron dot ca in forum PHP Development
    Replies: 1
    Last Post: August 30th, 11:35 PM
  2. Replies: 0
    Last Post: August 30th, 10:59 PM
  3. better exec() command
    By steronz in forum PHP Development
    Replies: 1
    Last Post: July 24th, 06:55 AM
  4. [PHP] Exec command not working through php
    By Mike Morton in forum PHP Development
    Replies: 0
    Last Post: July 15th, 10:51 PM
  5. Exec command not working through php
    By Mike Morton in forum PHP Development
    Replies: 2
    Last Post: July 15th, 10:17 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139