cron.php and shell access

cron.php and shell access

by Thomas Forsberg -
Number of replies: 5
I am running Moodle on a Windows IIS server where the IIS user's access to shell.exe blocked for security reasons.  This means that PHP cannot eun shell commands for example for backup when cron.php runs.

Are there anyone that has any solution to this issue or has information how to run php commands in a secure way ?


Thomas
Average of ratings: -
In reply to Thomas Forsberg

Re: cron.php and shell access

by Tim Allen -
Hi Thomas,

You don't have to use a PHP shell command to run cron. Have you read the cron instructions on Moodle docs? If not have a look and then come back here if you need more help. smile

Tim.
In reply to Tim Allen

Re: cron.php and shell access

by Ken Wilson -

Tim

I think Thomas is referring to the security settings in Windows which mean that any command shell executions (not PHP ones) that are needed to be executed are usually given full rights of the anonymous IUSR_machinename user for anything to work - big security issues here smile.

The way to go on this one is to create an account with sufficient privileges and apply this to the executable. See Rory Allford's post in this thread.

Ken

In reply to Ken Wilson

Re: cron.php and shell access

by Thomas Forsberg -
Ken,

you are right, the cron job is basically ok, we set that up as a scheduled task. The problem is that moodle checks and starts the php command with a shell exec. In PHP 5 I have found a file called php-win.exe that is supposed to NOT run in a shell, but I am not sure how to implement it...


Thomas
In reply to Thomas Forsberg

Re: cron.php and shell access

by Ken Wilson -

Thomas

From reading this document, the php-win.exe is a replacement for the old php-cli.exe - so it looks like it still runs in a command shell, but without any output shown.

It would be useful to know which moodle command are you trying to get to run through shell.exe, so that I can try and test things out also.

Thanks

Ken

In reply to Ken Wilson

Re: cron.php and shell access

by Thomas Forsberg -

I think that for example the backup job fails since it runs php in a shell.  If I run the unit test, I get the error:

Fail: lib/simpletest/slowtestcode.php r_breadcrumb.gif slow_code_test r_breadcrumb.gif test_php_syntax r_breadcrumb.gif
Cannot test PHP syntax because PHP is not on the path. at [C:\Inetpub\wwwroot\elearning\lib\simpletest\slowtestcode.php line 34]

It looks like this error is the result of the failure of

if (!shell_exec($this->phppath . ' -v')) {

This is a test is a shell can be opened, isn't it ?

In the install.txt in php5 the php-win.exe is explained with "executes scripts without an opened command prompt".  Does that mean that it still opens cmd.exe, but hidden, or is it a real windows application ?

Thomas