Beispiel #1
0
 public function setHeaders(Swift_Mime_HeaderSet $headers)
 {
     $bodyLen = $this->_bodyLen;
     if (is_bool($bodyLen)) {
         $bodyLen = -1;
     }
     $hash = $this->_hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256;
     $bodyCanon = $this->_bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
     $headerCanon = $this->_headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
     $this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
     // Hardcode signature Margin for now
     $this->_dkimHandler->setMargin(78);
     if (!is_numeric($this->_signatureTimestamp)) {
         OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time());
     } else {
         if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) {
             throw new Swift_SwiftException('Unable to force signature timestamp [' . openssl_error_string() . ']');
         }
     }
     if (isset($this->_signerIdentity)) {
         $this->_dkimHandler->setSigner($this->_signerIdentity);
     }
     $listHeaders = $headers->listAll();
     foreach ($listHeaders as $hName) {
         // Check if we need to ignore Header
         if (!isset($this->_ignoredHeaders[strtolower($hName)])) {
             $tmp = $headers->getAll($hName);
             if ($headers->has($hName)) {
                 foreach ($tmp as $header) {
                     if ($header->getFieldBody() != '') {
                         $htosign = $header->toString();
                         $this->_dkimHandler->header($htosign);
                         $this->_signedHeaders[] = $header->getFieldName();
                     }
                 }
             }
         }
     }
     return $this;
 }
Beispiel #2
0
 /**
  * Run installation and setup
  * @param DatabaseSqlite3 &$db Database object
  * @return boolean
  */
 public function run(&$db)
 {
     // Set object access to database
     $this->db = $db;
     Log::debug('Starting operating system setup');
     // Get operating system information
     if (is_file('/etc/os-release')) {
         // Generic release file
         $os = file_get_contents('/etc/os-release');
         // Grab Linux distribution name
         $id = array();
         $rc = preg_match('/\\nID="?([^"\\n]*)"?\\n/', $os, $id);
         if ($rc !== 1 || !isset($id[1])) {
             Log::error('Error while trying to detect the Linux distribution name');
             return false;
         } else {
             $id = $id[1];
         }
         // Grab Linux distribution version
         $version = array();
         $rc = preg_match('/\\nVERSION_ID="?([^"\\n]*)"?\\n/', $os, $version);
         if ($rc !== 1 || !isset($version[1])) {
             Log::error('Error while trying to detect the Linux distribution version');
             return false;
         } else {
             $version = (int) $version[1];
         }
         // Verify supported CentOS 7
         if ($id !== "centos" || $version !== 7) {
             Log::error('Operating system distribution and/or version not supported by this setup module');
             return false;
         }
         $rc = preg_match('/\\nPRETTY_NAME="?([^"\\n]*)"?\\n/', $os, $fullId);
         if ($rc !== 1 || isset($fullId[1])) {
             Log::debug('Detected: ' . $fullId[1]);
         }
     } else {
         Log::error('File not found: /etc/os-release');
         // Generic release file not found
         return false;
     }
     // Requirements for the setup procedure
     if (class_exists('PDO', false) === false) {
         Log::error('The PDO package is required by the setup procedure. Please install it by running "yum install php-pdo".');
         exit(9);
     }
     if (function_exists('mb_substr') === false) {
         Log::error('The multibyte package is required by the setup procedure. Please install it by running "yum install php-mbstring".');
         exit(9);
     }
     // Required repositories
     $rc = $this->_repository();
     if ($rc === false) {
         return false;
     }
     // Required packages
     $rc = $this->_package();
     if ($rc === false) {
         return false;
     }
     // Setup SELinux
     $rc = $this->_selinux($this->db);
     if ($rc === false) {
         return false;
     }
     // Load and setup external features
     // PHP
     $feature = new Php();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // OpenDKIM
     $feature = new OpenDKIM();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable OpenDKIM
     if (Config::read('opendkim') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // NSD
     $feature = new Nsd();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable NSD
     if (Config::read('nsd') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // ClamAV
     $feature = new ClamAV();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable ClamAV
     if (Config::read('clamav') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Spamassassin
     $feature = new SpamAssassin();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Spamassassin
     if (Config::read('spamassassin') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Postfix
     $feature = new Postfix();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Postfix
     if (Config::read('postfix') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Dovecot
     $feature = new Dovecot();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Dovecot
     if (Config::read('dovecot') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // MariaDB
     $feature = new MariaDb();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable MariaDB
     if (Config::read('mariadb') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Roundcube webmail
     $feature = new Roundcube();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Disable Roundcube if needed, else leave enabled by default
     if (Config::read('roundcube') === 'disabled') {
         $feature->disable();
     }
     // Apache
     $feature = new Apache();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Apache
     if (Config::read('apache') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     return true;
 }