php's exec function

Dear Experts,

I have a php page which uses the following line:

exec("sh script.sh", $retval);

I have script.sh in the same directory as my php page,  How do I make script.sh safe?  What permissions should it be set too?

Thanks
ixf
LVL 1
narmi2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

karoldvlCommented:
As you don't use input data from the user:
exec("sh script.sh", $retval);

 this should be reasonably safe. If you intend to in the future, this would be a major point to think about.

All depends on what your script does, and how safe this script is in itself (even indirect threats - overusage/DoS?).
 
 You should use the minimal permission set that works for you. Maybe:
chmod 0500 script.sh
would suffice, depends on your server config (if not, try chmod 0550 script.sh).

It would be probably good to avoid listing the content of the script to the outside world (.htaccess, permissions, moving it out of web root?).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
narmi2Author Commented:
The script downloads a file from the internet, processes it to create another file based on the original downloaded file, then deletes the original downloaded file.
0
karoldvlCommented:
In this case it wouldn't hurt to move the script and all the processing (temp files) out of your website directory if it's feasible.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.