Jump to content

shell_exec permission


aravin

Recommended Posts

i have a problem run following script

 

<?php

$output=shell_exec("echo 'password' | sudo -S  <command>").

echo $output;

?>

 

i already adding "www-data ALL=NOPASSWD: ALL” in my etc/sudoers folder but it still not working. i really appreciate if somebody can help me and give step to solve it.

 

:(

Link to comment
Share on other sites

i have a problem run following script

 

<?php

$output=shell_exec("echo 'password' | sudo -S  <command>").

echo $output;

?>

 

i already adding "www-data ALL=NOPASSWD: ALL” in my etc/sudoers folder but it still not working. i really appreciate if somebody can help me and give step to solve it.

 

:(

 

it's not safe to remove ALL restrictions, so you should instead remove restrictions from the functions you're calling.

 

for example, if you wanted to remove root prerequisite for fdisk, you'd type 'sudo visudo' in terminal and add this line:

www-data ALL=(root) NOPASSWD: /sbin/fdisk

 

then you can do a shell_exec("sudo fdisk"); and get results.  now i haven't tested it but i add the entire command, including arguments in the sudoers (the file you edit when you do a sudo visudo) might unlock just the command with that specific set of arguments, but i'm not sure of this, i didn't feel like testing it.

 

make sure you only edit sudoers with sudo visudo from terminal, if you do a gksudo gedit sudoers, and you edit it incorrectly and save it, you're going to be in ALOT of trouble lol

 

good luck

Link to comment
Share on other sites

I get some out put by tring this coding. But my password is not correct even i have try many possible password.

 

code:

<?php

$output=shell_exec("echo 'password' | sudo -S  <command> 2>&1" );

echo $output;

?>

 

 

error:

[sudo] password for nobody:

Sorry, try again.

[sudo] password for nobody:

sudo: 1 incorrect password attempt

 

any idea to solve it?

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.