diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index d41b73a70..48d83200c 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -330,7 +330,7 @@ bool MonitorStream::sendFrame(const char *filepath, struct timeval *timestamp) { fprintf(stdout, "Content-Length: %d\r\n", img_buffer_size); if ( fwrite(img_buffer, img_buffer_size, 1, stdout) != 1 ) { if ( ! zm_terminate ) - Error("Unable to send stream frame: %s", strerror(errno)); + Warning("Unable to send stream frame: %s", strerror(errno)); return false; } fputs("\r\n\r\n", stdout); @@ -407,7 +407,7 @@ bool MonitorStream::sendFrame(Image *image, struct timeval *timestamp) { if ( fwrite(img_buffer, img_buffer_size, 1, stdout) != 1 ) { if ( !zm_terminate ){ // If the pipe was closed, we will get signalled SIGPIPE to exit, which will set zm_terminate - Error("Unable to send stream frame: %s", strerror(errno)); + Warning("Unable to send stream frame: %s", strerror(errno)); } return false; } diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index 3f1770f42..0313bd97a 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -30,20 +30,37 @@ class HostController extends AppController { )); } - function getAuthHash() { - if ( $zmOptAuth == '1' ) { - require_once '../../../includes/auth.php'; - $this->set(array( - 'auth_hash' => generateAuthHash(ZM_AUTH_HASH_IPS), - '_serialize' => array('auth_hash') - ) ); - } else { - $this->set(array( - 'auth_hash' => '', - '_serialize' => array('auth_hash') - ) ); + function getCredentials() { + // ignore debug warnings from other functions + $this->view='Json'; + $credentials = ""; + $appendPassword = 0; + + $this->loadModel('Config'); + $isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value']; + + if ($isZmAuth) { + $zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value']; + if ($zmAuthRelay == 'hashed') { + $zmAuthHashIps= $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value']; + $credentials = 'auth='.generateAuthHash($zmAuthHashIps); + } + elseif ($zmAuthRelay == 'plain') { + // user will need to append the store password here + $credentials = "user=".$this->Session->read('user.Username')."&pass="; + $appendPassword = 1; + } + elseif ($zmAuthRelay == 'none') { + $credentials = "user=".$this->Session->read('user.Username'); + } } - } + $this->set(array( + 'credentials'=> $credentials, + 'append_password'=>$appendPassword, + '_serialize' => array('credentials', 'append_password') + ) ); + } + // If $mid is set, only return disk usage for that monitor // Else, return an array of total disk usage, and per-monitor