0

This question has been asked previously in https://joomla.stackexchange.com/questions/20697/securing-a-joomla-installation-on-apache-mod-php but it may belong here better since it is not Joomla specific.

I'm trying to execute a script in tcsh, and receive different results from running the commands individually on the command line to executing the script. The attempt is to secure all directories below public_html; and assign more open permissions to some directories afterwards (e.g. cache, logs etc).

find ./public_html -type f ! -user apache -exec chmod 644 {} \;
find ./public_html -type d ! -user apache -exec chmod 755 {} \;
chmod -R 777 public_html/cache/
chmod -R 777 public_html/administrator/cache/
chmod -R 777 public_html/logs/
chmod -R 777 public_html/tmp/

In the above, quite often I find all permissions restricted but e.g. the cache, log or tmp directories unwritable after running the script. If I execute all commands one after another on the command line it works as expected. It'd be great if you might have an idea what I should be looking at instead?

Thanks for any suggestion.

ExternalUse
  • 165
  • 1
  • 7

1 Answers1

0

Hm, no answers - I'm still not sure why it doesn't work this way, but I've now found that find ...directory also includes the directory itself. So I've now changed the chmod commands to

find public_html/cache/ public_html/administrator/cache/ public_html/logs/  -type f ! -user apache -exec chmod 666{} \;
find public_html/cache/ public_html/administrator/cache/ public_html/logs/ -type d ! -user apache -exec chmod 777{} \;

That works for me. I recon that during shell execution in a row, it errors out once it encounters a file/directory where the script does not have rights to chmod.

ExternalUse
  • 165
  • 1
  • 7