Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CLI script as specific user #4

Closed
exodus4d opened this issue Jun 26, 2016 · 3 comments
Closed

Run CLI script as specific user #4

exodus4d opened this issue Jun 26, 2016 · 3 comments
Labels

Comments

@exodus4d
Copy link

Thanks for the script!

The Cron scripts are executed with user "root". This is fine in most cases....

It looks like F3 stores all cached files in /tmp/cache/ with owner/group root:root. Any other cached files (non cronjob cache) have the web server user as owner (e.g. nginx:nginx or www:www,...).
The $f3->clear('CACHE'); can not delete this files from root:root when triggered by a user.

Can we add a configurable default user for all CLI exec();calls? Something like this: http://serverfault.com/a/453823
`

@xfra35
Copy link
Owner

xfra35 commented Jun 27, 2016

Hi @exodus4d

The Cron scripts are executed with user "root"

This is not correct. This depends on who is calling the script:

  • when running the script from the browser, the user is the web server user (www:www, etc...)
  • when running the script from the command line, the user is the caller user, that is to say:
    • myuser if you're running php index.php /cron (considering you're logged as myuser)
    • root if you're running sudo php index.php /cron or if you're logged as root
    • otheruser if you're running sudo -u otheruser php index.php /cron
  • when running the script from a crontab, the user is the crontab user, that is to say:
    • myuser if you're running crontab mycrontab (considering you're logged as myuser)
    • root if you're running sudo crontab mycrontab or if you're logged as root
    • otheruser if you're running crontab -u otheruser mycrontab

In your case, I think you can solve your issue by:

  1. removing the root crontab
  2. creating a crontab for the web user

So if you're logged as root (which seems to be your case):

crontab -r
crontab -u www mycrontab

Replace www by the web server user and don't forget to remove or to chown all files created by root in /tmp/cache.

@xfra35
Copy link
Owner

xfra35 commented Jun 27, 2016

I've added a block about user permissions in the docs.

@exodus4d
Copy link
Author

Thanks for the quick response! :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants