Results 1 to 10 of 12
- 02-13-2010 #1
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"
- 02-14-2010 #2*nix Technical Support
Achievements:




Awards:
- 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
- 02-14-2010 #3
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
- 02-14-2010 #4*nix Technical Support
Achievements:




Awards:
- 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.
- 02-14-2010 #5
Can you consult ur friend u spoke abt to me in PM, incase he has any idea PLZ...
- 02-15-2010 #6*nix Technical Support
Achievements:




Awards:
- 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
- 02-15-2010 #7
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..
so for me would it be....<?php
$output= shell_exec("echo ur_password | sudo -S ur_command");
echo "<pre>$output</pre>";
?>
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???<?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.....
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...
- 02-15-2010 #8*nix Technical Support
Achievements:




Awards:
- Join Date
- Jan 2009
- Location
- /home/hellnoire
- Posts
- 10,231
- Liked
- 293 times
His response:
(This is a direct copy from him so I refers to him, he refers to you.)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."
- 02-15-2010 #9
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...
- 08-23-2010 #10
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....
Similar Threads
-
Google to Launch "MAJEL" to compete with "Siri" Technology of Apple !
By Mjj in forum Mobile PhoneReplies: 0Last Post: 12-16-2011, 10:23 PM -
Why Do People Say "No Problem" in Response to "Thank You"?
By Alboguy in forum ChatReplies: 10Last Post: 03-19-2010, 01:23 PM -
problem in installing "dap91" & "klog"
By Rameez in forum General ForumReplies: 1Last Post: 04-24-2009, 12:33 PM -
"Connection Interrupted" and " Failed to Connect"
By Michael Y in forum NetworkReplies: 2Last Post: 09-30-2008, 05:48 PM


LinkBack URL
About LinkBacks





Reply With Quote