Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I have a server for which I have created a cron job "sendalerts" to users. Mind you this "sendalerts.php" should be runnable from two methods (via browser and also via a cron job)

So cron's job is to execute a php file which then sends the alerts out, something like this:

01 01 * * * /usr/bin/php -f /var/www/vhosts/xxxxx.com/xxx/sendalerts.php

But it keeps failing with the log message:

Could not open input file: /var/www/vhosts/xxxxx.com/xxx/sendalerts.php

So I checked the file group and owner of "sendalerts.php" and realized it was "anothergroup" (since it was created through Plesk filemanager) for which "root" is not a member. I then deleted and recreated "sendalerts.php" from SSH with root. But this would not grant me access to running the same file in browser as I would sometimes want to (manually send the alerts).

Yet I get the same log error when cron tries to execute (Could not open input file: /var/www/vhosts/xxxxx.com/xxx/sendalerts.php)

Currently my possible solution would be to recreate the same file using Plesk filemanager and then add "root" user to the "anothergroup" group .

But for this my question is: would that be a safe and secure thing to do? Considering now the group "anothergroup" may have "root" user permissions (if I'm not wrong in my understanding).

share

migration rejected from webmasters.stackexchange.com Jan 2 at 21:08

This question came from our site for pro webmasters. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Gilles, Mark, Jens Erat, TildalWave, Steve Jan 2 at 21:08

  • This question does not appear to be about Information security within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
This question appears to be off-topic because the only security aspect is due to a misinterpretation of the error message. It should have been migrated to Unix & Linux, not to Information Security. –  Gilles Jan 2 at 6:02

1 Answer 1

up vote 4 down vote accepted

Yeah.... your description of the situation makes absolutely no sense at all.

Root is god on a unix system. Root will be able to read, write and execute any file on your system unless you do something wonky with Selinux. The error message does not indicate a permissions problem either.

The situation is mostly like caused by the fact that your PHP script does not have a shebang line so your shell is unable to execute it correctly.

Add #!/bin/env php to the start of your file and it should work.

share
    
Also, in general it's a bad idea to run scripts like this as root. It probably suffices to have it run as whichever user is logically the owner of the file. –  Stephen Touset Oct 15 '13 at 23:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.