Donate Now Goal amount for this year: 799 USD, Received: 100 USD (13%)
Please donate to help support this website. The funds will be used to purchase owned license of LiteSpeed Web Server Enterprise (2-CPU). It provides superior performance in terms of raw speed, scalability and anti-DDoS capabilities.

Page 1 of 2 12 Last
Results 1 to 10 of 12
  1. #1
    Experienced User
    Points: 11,468, Level: 70
    Level completed: 55%, Points required for next Level: 182
    Overall activity: 1.0%
    Achievements:
    31 days registered3 months registered1 year registeredTagger Second Class100 Experience Points

    Join Date
    Aug 2008
    Location
    Hell
    Posts
    1,115
    Liked
    17 times

    Confused Ubuntu "sudo" and PHP "shell_exec()" Help

    Hi All

    I am trying to get sudo commands running in shell_exec() of php but always failed to do as password is a must for sudo and I don't know how to bypass it.

    I am using:
    XAMPP 1.7.3
    Ubuntu 9.10
    Working on IPTABLES.

    SUDO -n does not bypass user authentication, so I don't get anything in browser (as I said php file), non sudo commands gives output but not those with sudo. So that means they don't run.

    I disabled the password prompt in sudoers, so shell script run without password prompt. But this $IPT script in php file is still not running.

    I can't go coding forward bcoz of this.

    PLZ do help me to bypass sudo in php shell_exec or pass the password along with the command (atleast I could not find the way to pass).

    I read a funda about reading details in some stored file but could not get how to do it.

    Plz feel free to help and share any idea that could work.

    AGAIN: sudo command in PHP file through Browser.

    Thx in Advance
    "Positivity Is The Key To Life, Never Loose It."

    "Mess Up Things In Life, Its How U Learn"

  2. #2
    *nix Technical Support
    Points: 25,110, Level: 95
    Level completed: 76%, Points required for next Level: 240
    Overall activity: 18.0%
    Achievements:
    Recommendation Second Class31 days registered3 months registered1 year registeredTagger Second Class
    Awards:
    Frequent Poster

    Join Date
    Jan 2009
    Location
    /home/hellnoire
    Posts
    10,231
    Liked
    293 times
    The only thing I could think of is running it as a root user... or making it seem like it.

    'sudo su' would give you root access, but you would need the password as it makes you root. It's security, amongst everything.

    'gksudo' is a 'graphical' sudo prompt... but you again would need a password.

    aside from those, you could set up a root user, it's not set up by default with Ubuntu, but I'm sure you could find ways to.

    I am stumped though, of why you'd need root/sudo usage with a PHP script... you installing something?
    pacman -Syyu life not found in sync db

  3. #3
    Experienced User
    Points: 11,468, Level: 70
    Level completed: 55%, Points required for next Level: 182
    Overall activity: 1.0%
    Achievements:
    31 days registered3 months registered1 year registeredTagger Second Class100 Experience Points

    Join Date
    Aug 2008
    Location
    Hell
    Posts
    1,115
    Liked
    17 times
    Thx for ur reply...

    Actually my Finally year project a small one though, GUI for Linux firewall (IPTABLES) and Squid making it Web Based....I know that there are more already available but this was the only one left in the Project List BAD LUCK all interesting one's were gone.

    My College server guys gave us this one, they want it web based so as to configure it from anywhere not necessarily the Server...

    I gave my username root rights changed sudoer to NOPASSWD for my login, .sh files work without pass prompt but shell_exec() does not get the privilege i guess....

    Searched on the internet found one guy saying use pipe-lining and he gave the syntax but it didn't seem to work for me or I must have done something wrong DON'T KNOW...as me new to PHP too figuring which of "..." and '....' where to use

    I found one more suPHP but LOL!! didn't understand wat to do with it, trying to figure it out...will inform later if succeeded

    Working on Linux Ubuntu for the First time, too much headache..
    Need to get hand over it soon or my project is screwed only 1.5 months left...

    If you would get anything plz do reply back..Thx

  4. #4
    *nix Technical Support
    Points: 25,110, Level: 95
    Level completed: 76%, Points required for next Level: 240
    Overall activity: 18.0%
    Achievements:
    Recommendation Second Class31 days registered3 months registered1 year registeredTagger Second Class
    Awards:
    Frequent Poster

    Join Date
    Jan 2009
    Location
    /home/hellnoire
    Posts
    10,231
    Liked
    293 times
    I'm afraid I don't. I use it but I don't program for it.

  5. #5
    Experienced User
    Points: 11,468, Level: 70
    Level completed: 55%, Points required for next Level: 182
    Overall activity: 1.0%
    Achievements:
    31 days registered3 months registered1 year registeredTagger Second Class100 Experience Points

    Join Date
    Aug 2008
    Location
    Hell
    Posts
    1,115
    Liked
    17 times
    Can you consult ur friend u spoke abt to me in PM, incase he has any idea PLZ...

  6. #6
    *nix Technical Support
    Points: 25,110, Level: 95
    Level completed: 76%, Points required for next Level: 240
    Overall activity: 18.0%
    Achievements:
    Recommendation Second Class31 days registered3 months registered1 year registeredTagger Second Class
    Awards:
    Frequent Poster

    Join Date
    Jan 2009
    Location
    /home/hellnoire
    Posts
    10,231
    Liked
    293 times
    Well, he sent me this as a response:

    Hm. I would think piping would be one of the best solutions. A few other lame things he (you) could try would be using a root shell, or a sudosu shell, and running the apache friends through the root terminal. Then do the same for the web browser.

    I don't have much to any experience with php. I use the "cookie-cutter" version that comes with windows basic xmapp. Which brings up the point that I've never used xmapp on anything other then Windows. And it's always worked without a hitch

    Pretty much you run the command to start the apache server, then the database server. open your browser with admin(root) rights and go to loopback. It should take you to the xmapp splash screen

    If he's not getting that far, then it's his xmapp/apache that's all t*tty. If he is, then when he clicks on the "phpMyAdmin" button, it would work because the default root password on xmapp is blank. Maybe I'm not understanding the problem right, a little more documentation would help, but that's my two cents

  7. #7
    Experienced User
    Points: 11,468, Level: 70
    Level completed: 55%, Points required for next Level: 182
    Overall activity: 1.0%
    Achievements:
    31 days registered3 months registered1 year registeredTagger Second Class100 Experience Points

    Join Date
    Aug 2008
    Location
    Hell
    Posts
    1,115
    Liked
    17 times
    Thx for ur and ur friends abrupt reply...

    I didn't understand the whole thing though, my fault..

    Could he help me know whether pipelining this way could do, I found it while searching the solution..

    <?php

    $output= shell_exec("echo ur_password | sudo -S ur_command");
    echo "<pre>$output</pre>";
    ?>
    so for me would it be....

    <?php

    $output= shell_exec("echo 1 | sudo -S iptables -L");
    echo "<pre>$output</pre>";
    ?>

    I tried with my xampp installation but failed nothing happens atleast i cant view any output.....
    Also if xampp is the problem thats what i interpreted of what he said, I may be wrong, so install Apache MySQL separately and then configure them and then use???

    One more thing just ask him if he used suPHP, ok as he said he has not used PHP much but incase he has come across it....

    Thx and sorry for the Trouble hellnoire...

  8. #8
    *nix Technical Support
    Points: 25,110, Level: 95
    Level completed: 76%, Points required for next Level: 240
    Overall activity: 18.0%
    Achievements:
    Recommendation Second Class31 days registered3 months registered1 year registeredTagger Second Class
    Awards:
    Frequent Poster

    Join Date
    Jan 2009
    Location
    /home/hellnoire
    Posts
    10,231
    Liked
    293 times
    His response:

    No, I haven't used it. I've only done apache stuff with a mySQL backend for hosting game servers. Xampp comes with it's own versions of Apache and MySQL.
    As far as I can tell, he's got the xampp wrong. Follow this guide http://www.apachefriends.org/en/xampp-linux.html

    And to quote from it, "The MySQL administrator (root) has no password."
    (This is a direct copy from him so I refers to him, he refers to you.)

  9. #9
    Experienced User
    Points: 11,468, Level: 70
    Level completed: 55%, Points required for next Level: 182
    Overall activity: 1.0%
    Achievements:
    31 days registered3 months registered1 year registeredTagger Second Class100 Experience Points

    Join Date
    Aug 2008
    Location
    Hell
    Posts
    1,115
    Liked
    17 times
    OK..hellnoire forget xampp, I'll check all config files later....College Time Now got to go..
    could he say something related to pipelining stuff i wrote in my previous comment...

  10. #10
    Newbie
    Points: 1,027, Level: 17
    Level completed: 27%, Points required for next Level: 73
    Overall activity: 0.4%
    Achievements:
    31 days registered3 months registered100 Experience Points1 year registered500 Experience Points

    Join Date
    Aug 2010
    Posts
    1
    Liked
    0 times
    can i have the code please... i hv a same case now...n have to finish it in sveral months... tx be4 for evrythng usefull....

 

 
Page 1 of 2 12 Last

Similar Threads

  1. Replies: 0
    Last Post: 12-16-2011, 10:23 PM
  2. Replies: 10
    Last Post: 03-19-2010, 01:23 PM
  3. problem in installing "dap91" & "klog"
    By Rameez in forum General Forum
    Replies: 1
    Last Post: 04-24-2009, 12:33 PM
  4. Replies: 2
    Last Post: 09-30-2008, 05:48 PM

Tags for this Thread

All times are GMT +8. The time now is 07:26 PM.