php's exec function

Dear Experts,

I have a php page which uses the following line:

exec("sh", $retval);

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

As you don't use input data from the user:
exec("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
would suffice, depends on your server config (if not, try chmod 0550

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?).

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.
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.
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.