コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @return  $this
  */
 public function createElements(array $formData)
 {
     $this->addElement('select', 'logging_log', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Logging Type'), 'description' => $this->translate('The type of logging to utilize.'), 'multiOptions' => array('syslog' => 'Syslog', 'file' => $this->translate('File', 'app.config.logging.type'), 'none' => $this->translate('None', 'app.config.logging.type'))));
     if (!isset($formData['logging_log']) || $formData['logging_log'] !== 'none') {
         $this->addElement('select', 'logging_level', array('required' => true, 'label' => $this->translate('Logging Level'), 'description' => $this->translate('The maximum logging level to emit.'), 'multiOptions' => array(Logger::$levels[Logger::ERROR] => $this->translate('Error', 'app.config.logging.level'), Logger::$levels[Logger::WARNING] => $this->translate('Warning', 'app.config.logging.level'), Logger::$levels[Logger::INFO] => $this->translate('Information', 'app.config.logging.level'), Logger::$levels[Logger::DEBUG] => $this->translate('Debug', 'app.config.logging.level'))));
     }
     if (false === isset($formData['logging_log']) || $formData['logging_log'] === 'syslog') {
         $this->addElement('text', 'logging_application', array('required' => true, 'label' => $this->translate('Application Prefix'), 'description' => $this->translate('The name of the application by which to prefix syslog messages.'), 'requirement' => $this->translate('The application prefix must not contain whitespace.'), 'value' => 'icingaweb2', 'validators' => array(array('Regex', false, array('pattern' => '/^\\S+$/', 'messages' => array('regexNotMatch' => $this->translate('The application prefix must not contain whitespace.')))))));
         if (!isset($formData['logging_log']) || $formData['logging_log'] === 'syslog') {
             if (Platform::isWindows()) {
                 /* @see https://secure.php.net/manual/en/function.openlog.php */
                 $this->addElement('hidden', 'logging_facility', array('value' => 'user', 'disabled' => true));
             } else {
                 $facilities = array_keys(SyslogWriter::$facilities);
                 $this->addElement('select', 'logging_facility', array('required' => true, 'label' => $this->translate('Facility'), 'description' => $this->translate('The syslog facility to utilize.'), 'value' => 'user', 'multiOptions' => array_combine($facilities, $facilities)));
             }
         }
     } elseif (isset($formData['logging_log']) && $formData['logging_log'] === 'file') {
         $this->addElement('text', 'logging_file', array('required' => true, 'label' => $this->translate('File path'), 'description' => $this->translate('The full path to the log file to write messages to.'), 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array('WritablePathValidator')));
     }
     return $this;
 }
コード例 #2
0
 /**
  * Constructor
  *
  * @param string $baseDir   Icinga Web 2 base directory
  * @param string $configDir Path to Icinga Web 2's configuration files
  */
 protected function __construct($baseDir = null, $configDir = null)
 {
     if ($baseDir === null) {
         $baseDir = dirname($this->getBootstrapDirectory());
     }
     $this->baseDir = $baseDir;
     $this->appDir = $baseDir . '/application';
     $this->vendorDir = $baseDir . '/library/vendor';
     $this->libDir = realpath(__DIR__ . '/../..');
     $this->setupAutoloader();
     if ($configDir === null) {
         $configDir = getenv('ICINGAWEB_CONFIGDIR');
         if ($configDir === false) {
             $configDir = Platform::isWindows() ? $baseDir . '/config' : '/etc/icingaweb2';
         }
     }
     $canonical = realpath($configDir);
     $this->configDir = $canonical ? $canonical : $configDir;
     set_include_path(implode(PATH_SEPARATOR, array($this->vendorDir, get_include_path())));
     Benchmark::measure('Bootstrap, autoloader registered');
     Icinga::setApp($this);
     require_once dirname(__FILE__) . '/functions.php';
 }
コード例 #3
0
 protected function prepareTlsEnvironment()
 {
     $strict_tls = true;
     // TODO: allow variable known CA location (system VS Icinga)
     if (Platform::isWindows()) {
         // putenv('LDAP...')
     } else {
         if ($strict_tls) {
             $ldap_conf = $this->getConfigDir('ldap_ca.conf');
         } else {
             $ldap_conf = $this->getConfigDir('ldap_nocert.conf');
         }
         putenv('LDAPRC=' . $ldap_conf);
         if (getenv('LDAPRC') !== $ldap_conf) {
             throw new Exception('putenv failed');
         }
     }
 }
コード例 #4
0
ファイル: LdapConnection.php プロジェクト: bebehei/icingaweb2
 /**
  * Set up how to handle StartTLS connections
  *
  * @throws  LdapException   In case the LDAPRC environment variable cannot be set
  */
 protected function prepareTlsEnvironment()
 {
     // TODO: allow variable known CA location (system VS Icinga)
     if (Platform::isWindows()) {
         putenv('LDAPTLS_REQCERT=never');
     } else {
         if ($this->validateCertificate) {
             $ldap_conf = $this->getConfigDir('ldap_ca.conf');
         } else {
             $ldap_conf = $this->getConfigDir('ldap_nocert.conf');
         }
         putenv('LDAPRC=' . $ldap_conf);
         // TODO: Does not have any effect
         if (getenv('LDAPRC') !== $ldap_conf) {
             throw new LdapException('putenv failed');
         }
     }
 }