FaxSMS Cron job, what is the correct entry?

I have been trying to get the FaxSMS notifications to automatically go out.
Server Ubuntu 20.04

30 8 * * * /usr/bin/php -q /var/www/html/openemr/interface/modules/custom_modules/oe-module-faxsms/library/rc_sms_notification.php

This does not send any messages out. What is the correct line ?

The cron syntax looks OK.
Would suggest running the command manually to see if there’s any errors when you execute it in real time, or sending the cron output to a log file of some sort for examination. There might be some feedback in mail messages if the system cron daemon is doing the normal internal e-mail notifications to the user whose cron job it is. I have never used the onboard Fax/SMS so not sure what else would go wrong once the command runs successfully locally, but from past experience working with Clickatell, Vonage, etc, there’s a lot of ways for SMS communications to fail even if the local server side processes execute normally.
One other thing to check, make sure that the CLI PHP is set to the expected version, e.g., you can have Apache running the module/plug-ins for say , PHP8.1, but the command line could be pointing at something different if there are multiple versions installed, which is pretty common on Ubuntu and other Debian based distros.

The CLI is pointed to 7.4.3 of PHP. Apache is on the same version. The is OpenEMR 7.0.0(2).
When I run the command from the CLI. It does not send any message that way either.
Only when I run the command from the browser does it work. I just saw that from the command line. I get the not Authorized at the very end.

So, this script is not configured to run from the command line.
Now, I need to make it possible to run this from the commandline.

That’s a problem with a lot of things in V7 versus previous, it won’t execute without the user auth token that would have been present in an authenticated browser session.
You might have to make a copy, and tweak a version of rc_sms_notification.php that bypasses user auth so it can run autonomously in the background.

1 Like

The system falls apart in the AppDispatch. Following the logic from line 47

$TYPE = "SMS";
$CRON_TIME = 150;
// use service if needed
if ($TYPE === "SMS") {
    $clientApp = AppDispatch::getApiService('sms');
    $cred = $clientApp->getCredentials();
    //var_dump($cred);die;
    if (!$clientApp->verifyAcl()) {
        //die("<h3>" . xlt("Not Authorised!") . "</h3>");
    }
}

$cred = $clientApp->getCredentials(); comes back empty and when the verifyAcl is run to see if the authUser which there is not one on a cron is an admin. The auth comes back false and stops the process there.
If I just comment out the die statement, the cron runs and messages go out. No other changes needed. I will circle back on Monday to update this thread.

Authentication is bypassed. There is a namespace path issue.
@juggernautsei are you running in localhost or a domain?

I locked the service down pretty tight for security so I’ll need to add use case for cli.
It’d be later tonight or in morning. That script has been messaged for 10 years!
@juggernautsei

@juggernautsei For now just patch out the call to verifyAcl(). I think Robert added that check still, I think there is also an issue running on a domain other than localhost.

Domain.

Not for sure what the messaged for 10 years means. But I was sure what the purpose of the script was but not reaching the intended goal because of not using local host.
What was the thinking behind cli and localhost?

This had me stumped for a week because I did not start looking at the code until I finally saw the unauthorized as I previously wrote.

I will stand down and watch the seal team one go to work.
Sorry for stirring things up.

Not a problem Sherwin. The ten years is because this script was a clone of the original.

I’ll need to sort this out. There’s nothing secure about this script.

If you pass in authUser e.g ‘admin’ cli arg and the set $_SESSION[‘authUser’] to authUser that should get you going.

This is what I added.

if ($TYPE === "SMS") {
    $_SESSION['authUser'] = 'admin';
    $clientApp = AppDispatch::getApiService('sms');
    $cred = $clientApp->getCredentials();
    if (!$clientApp->verifyAcl()) {
        die("<h3>" . xlt("Not Authorised!") . "</h3>");
    }
}

No joy.

@juggernautsei ‘admin’ was an example…
It needs to be a valid user with at least admin, docs if using session or valid permissions for passed in user.

    // $_SESSION['authUser'] = 'aldavis';
    $clientApp = AppDispatch::getApiService('sms');
    $cred = $clientApp->getCredentials();
    if (!$clientApp->verifyAcl('admin', 'docs', 'aldavis')) {
        die("<h3>" . xlt("Not Authorised!") . "</h3>");
    }

@sjpadgett , that worked. The cron will be active now.

I’ll be adding args to add user to run from cli and will put here Modules Manager action hooks for module cleanup by sjpadgett · Pull Request #7150 · openemr/openemr · GitHub

New command line for cron

Usage:   php rc_sms_notification.php [options]
Example: php rc_sms_notification.php site=default user=admin type=sms testrun=1
    --help  Display this help message
    Options:
      site={site_id}    Site
      user={authUser}   Authorized username not id.
      type={sms}        Send method SMS or email.
      testrun={1}       Test run set to 1
1 Like