开发者

shell_exec not working

开发者 https://www.devze.com 2023-01-30 17:42 出处:网络
Here\'s my command: sudo /usr/local/bin/jpegoptim --max=50 /home/someuser/public_html/reports/images/r121662.jpg

Here's my command:

sudo /usr/local/bin/jpegoptim --max=50 /home/someuser/public_html/reports/images/r121662.jpg

This co开发者_JAVA百科mmand is supposed to compress an image. I tried running this command using backtick operator and shell_exec, neither will work. The file doesn't compress.

But this command runs when I run it directly in the shell logged in as someuser. I've modified sudoers to accept the command without requiring a password. The file is compressed when I run it in the shell.

Apache is configured to run with suPHP, and the PHP files belong to someuser as well. I've further ensured this by writing a test php script just saying system(id); and running it in the browser. That tells me that the script is indeed being run by someuser.

Also, safe_mode is off.

EDIT: Ok, I got it to output the error

sudo: sorry, you must have a tty to run sudo

Now, what does it mean?!


Thanks to Catalin , I was able to get an output. It said sudo: sorry, you must have a tty to run sudo which required requiretty to be disabled for someuser. That is the best solution I got, if there's a way to disable requiretty for a single user calling a single command, please let me know.


sudo typically requires terminal input (i.e., must have a tty) as it will attempt to ask the user for a password before allowing you to execute a command. Do you really need to use sudo to run the command? Try removing the sudo.


Try sudo -S to see if setting it to read the password from stdin (even though it doesn't need one) will bypass the test for a tty.

0

精彩评论

暂无评论...
验证码 换一张
取 消