From 8c7e00418700afe6f299c02d6bdb5b6df91d624f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 18 May 2021 10:52:07 -0400 Subject: [PATCH] Use calculateAuthHash instead of generateAuthHash because we are sessionless and improve output on success and failure. Fixes #2329 --- web/api/app/Controller/MonitorsController.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index 4ecca6236..eb4eecf1f 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -266,7 +266,7 @@ class MonitorsController extends AppController { if ( $mToken ) { $auth = ' -T '.$mToken; } else if ( ZM_AUTH_RELAY == 'hashed' ) { - $auth = ' -A '.generateAuthHash(ZM_AUTH_HASH_IPS); + $auth = ' -A '.calculateAuthHash(ZM_AUTH_HASH_IPS?$_SERVER['REMOTE_ADDR']:''); } else if ( ZM_AUTH_RELAY == 'plain' ) { # Plain requires the plain text password which must either be in request or stored in session $password = $this->request->query('pass') ? $this->request->query('pass') : $this->request->data('pass');; @@ -290,12 +290,19 @@ class MonitorsController extends AppController { } $shellcmd = escapeshellcmd(ZM_PATH_BIN."/zmu $verbose -m$id $q $auth"); - $status = exec ($shellcmd); - - $this->set(array( - 'status' => $status, - '_serialize' => array('status'), - )); + $status = exec($shellcmd, $output, $rc); + if ($status) { + $this->set(array( + 'status'=>$rc, + 'error'=>$output, + '_serialize' => array('status','error'), + )); + } else { + $this->set(array( + 'status' => 'Ok', + '_serialize' => array('status'), + )); + } } // Check if a daemon is running for the monitor id