This file is indexed.

/usr/share/zabbix/include/classes/class.cconfigfile.php is in zabbix-frontend-php 1:1.8.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php

class CConfigFile{
	public $configFile = null;
	public $config = array();
	public $error = '';

// STATIC methods
	private static function exception($error){
		throw new Exception($error);
	}

// PUBLIC methods
	public function __construct($file=null){
		$this->setDefaults();

		if(!is_null($file))
			$this->setFile($file);
	}

	public function setFile($file){
		$this->configFile = $file;
	}

	public function load(){
		try{
			if(!file_exists($this->configFile)){
				self::exception('Config file does not exist.');
			}

			ob_start();
			include($this->configFile);
			ob_end_clean();

// config file in plain php is bad
// {{{
			$dbs = array('MYSQL', 'POSTGRESQL', 'ORACLE', 'IBM_DB2', 'SQLITE3');
			if(!isset($DB['TYPE']) && !isset($DB_TYPE))
				self::exception('DB type is not set.');
			else if(isset($DB['TYPE']) && !in_array($DB['TYPE'], $dbs))
				self::exception('DB type has wrong value. Possible values '.implode(', ', $dbs));
			else if(isset($DB_TYPE) && !isset($DB['TYPE']) && !in_array($DB_TYPE, $dbs))
				self::exception('DB type has wrong value. Possible values '.implode(', ', $dbs));
			else if(!isset($DB['DATABASE']) && !isset($DB_DATABASE))
				self::exception('DB database is not set.');
// }}}

			$this->setDefaults();

			if(isset($DB['TYPE'])) $this->config['DB']['TYPE'] = $DB['TYPE'];
			else if(isset($DB_TYPE)) $this->config['DB']['TYPE'] = $DB_TYPE;

			if(isset($DB['DATABASE'])) $this->config['DB']['DATABASE'] = $DB['DATABASE'];
			else if(isset($DB_DATABASE)) $this->config['DB']['DATABASE'] = $DB_DATABASE;

			if(isset($DB['SERVER'])) $this->config['DB']['SERVER'] = $DB['SERVER'];
			else if(isset($DB_SERVER)) $this->config['DB']['SERVER'] = $DB_SERVER;

			if(isset($DB['PORT'])) $this->config['DB']['PORT'] = $DB['PORT'];
			else if(isset($DB_PORT)) $this->config['DB']['PORT'] = $DB_PORT;

			if(isset($DB['USER'])) $this->config['DB']['USER'] = $DB['USER'];
			else if(isset($DB_USER)) $this->config['DB']['USER'] = $DB_USER;

			if(isset($DB['PASSWORD'])) $this->config['DB']['PASSWORD'] = $DB['PASSWORD'];
			else if(isset($DB_PASSWORD)) $this->config['DB']['PASSWORD'] = $DB_PASSWORD;

			if(isset($DB['SCHEMA'])) $this->config['DB']['SCHEMA'] = $DB['SCHEMA'];

			if(isset($ZBX_SERVER)) $this->config['ZBX_SERVER'] = $ZBX_SERVER;
			if(isset($ZBX_SERVER_PORT)) $this->config['ZBX_SERVER_PORT'] = $ZBX_SERVER_PORT;
			if(isset($ZBX_SERVER_NAME)) $this->config['ZBX_SERVER_NAME'] = $ZBX_SERVER_NAME;

			return true;
		}
		catch(Exception $e){
			$this->error = $e->getMessage();
			return false;
		}
	}

	public function makeGlobal(){
		global $DB, $ZBX_SERVER, $ZBX_SERVER_PORT, $ZBX_SERVER_NAME;

		$DB = $this->config['DB'];
		$ZBX_SERVER = $this->config['ZBX_SERVER'];
		$ZBX_SERVER_PORT = $this->config['ZBX_SERVER_PORT'];
		$ZBX_SERVER_NAME = $this->config['ZBX_SERVER_NAME'];
	}

	public function save(){
		try{
			if(is_null($this->configFile)){
				self::exception('Cannot save, config file is not set.');
			}

			$this->check();

			if(!file_put_contents($this->configFile, $this->getString())){
				self::exception('Cannot write config file.');
			}
		}
		catch(Exception $e){
			$this->error = $e->getMessage();
			return false;
		}
	}

	public function getString(){
		return
'<?php
// Zabbix GUI configuration file
global $DB;

$DB["TYPE"]				= \''.$this->config['DB']['TYPE'].'\';
$DB["SERVER"]			= \''.$this->config['DB']['SERVER'].'\';
$DB["PORT"]				= \''.$this->config['DB']['PORT'].'\';
$DB["DATABASE"]			= \''.$this->config['DB']['DATABASE'].'\';
$DB["USER"]				= \''.$this->config['DB']['USER'].'\';
$DB["PASSWORD"]			= \''.$this->config['DB']['PASSWORD'].'\';
// SCHEMA is relevant only for IBM_DB2 database
$DB["SCHEMA"]			= \''.$this->config['DB']['SCHEMA'].'\';

$ZBX_SERVER				= \''.$this->config['ZBX_SERVER'].'\';
$ZBX_SERVER_PORT		= \''.$this->config['ZBX_SERVER_PORT'].'\';
$ZBX_SERVER_NAME		= \''.$this->config['ZBX_SERVER_NAME'].'\';

$IMAGE_FORMAT_DEFAULT	= IMAGE_FORMAT_PNG;
?>
';
	}

// PROTECTED methods
	protected function setDefaults(){
		$this->config['DB'] = array(
			'TYPE' => null,
			'SERVER' => 'localhost',
			'PORT' => '0',
			'DATABASE' => null,
			'USER' => '',
			'PASSWORD' => '',
			'SCHEMA' => '',
		);
		$this->config['ZBX_SERVER'] = 'localhost';
		$this->config['ZBX_SERVER_PORT'] = '10051';
		$this->config['ZBX_SERVER_NAME'] = '';
	}

	protected function check(){
		$dbs = array('MYSQL', 'POSTGRESQL', 'ORACLE', 'IBM_DB2', 'SQLITE3');

		if(!isset($this->config['DB']['TYPE'])){
			self::exception('DB type is not set.');
		}
		else if(!in_array($this->config['DB']['TYPE'], $dbs)){
			self::exception('DB type has wrong value. Possible values '.implode(', ', $dbs));
		}
		else if(!isset($this->config['DB']['DATABASE'])){
			self::exception('DB database is not set.');
		}
	}
}
?>