How to allow commands for php's exec()

Discussion in 'General' started by Xenocide, Aug 27, 2014.

  1. Xenocide

    Xenocide Member

    Good day everyone,

    I was wondering how I could go about allowing php's exec to execute a certain binary?

    For example, If i try and run "whoami" I get:

    Code:
    [Wed Aug 27 12:51:46 2014] [error] [client x.x.x.x] sh: whoami: command not found
    In the error log.

    Using something like
    Code:
    <?php 
    echo exec("whoami"); 
    ?>
    If I wanted to allow whoami to be ran, what would I need to do?

    Many thanks
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    As far as I know, you cant restrict which commands exec can run. when you activate exec, then all commands that are accessible for the user of the website can be run with exec.
     
  3. Xenocide

    Xenocide Member

    Hi Till,

    Thank you for that. I thought that might be the case. How would I allow a command to be ran as that user, in that case? Say I wanted to allow a user to run whoami?
     
  4. florian030

    florian030 Well-Known Member HowtoForge Supporter

    You should use the full-path. Apache uses /usr/bin. Maybe whoami is located in a different directory.
     

Share This Page