コード例 #1
0
ファイル: DaemonConfigDNS.php プロジェクト: gOOvER/EasySCP
 /**
  * @return mixed
  */
 public static function CreatePDNSPass()
 {
     System_Daemon::debug('Starting "DaemonConfigDNS::createPDNSPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_DNS.xml');
     System_Daemon::debug('Building the new pdns config file');
     $xml->{'PDNS_USER'} = 'powerdns';
     $xml->{'PDNS_PASS'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $xml->{'HOSTNAME'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0640);
     // Create/Update Powerdns control user account if needed
     System_Daemon::debug('Adding the PowerDNS control user');
     $sql_param = array(':PDNS_USER' => $xml->{'PDNS_USER'}, ':PDNS_PASS' => DB::decrypt_data($xml->{'PDNS_PASS'}), ':HOSTNAME' => $xml->{'HOSTNAME'});
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :PDNS_USER@:HOSTNAME IDENTIFIED BY :PDNS_PASS;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     $sql_param = array(':DATABASE_USER' => DaemonConfig::$cfg->DATABASE_USER, ':DATABASE_HOST' => idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'}));
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :DATABASE_USER@:DATABASE_HOST;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     System_Daemon::debug('Finished "DaemonConfigDNS::createPDNSPass" subprocess.');
     return true;
 }
コード例 #2
0
ファイル: DaemonConfigFTP.php プロジェクト: gOOvER/EasySCP
 /**
  * @return mixed
  */
 public static function CreateProFTPdPass()
 {
     System_Daemon::debug('Starting "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     System_Daemon::debug('Building the new ftp config file');
     $xml->{'DB_DATABASE'} = DB::$DB_DATABASE;
     $xml->{'DB_HOST'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $xml->{'FTP_USER'} = 'vftp';
     $xml->{'FTP_PASSWORD'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     $sql_param = array(':DATABASE_HOST' => $xml->{'DB_HOST'}, ':FTP_USER' => $xml->{'FTP_USER'}, ':FTP_PASSWORD' => DB::decrypt_data($xml->{'FTP_PASSWORD'}));
     $sql_query = "\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     /*
     
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'ROOT_DIR'} . '/../setup/config.xml');
     
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     
     $sql_param = array(
     	':DATABASE_HOST'=> $xml->{'DB_HOST'},
     	':FTP_USER'		=> $xml->{'FTP_USER'},
     	':FTP_PASSWORD'	=> $xml->{'FTP_PASSWORD'}
     );
     
     $sql_query = "
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	FLUSH PRIVILEGES;
     ";
     
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     
     if (!file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml')) {
     	$ftp = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     
     	System_Daemon::debug('Building the new ftp config file');
     
     	$ftp->{'DB_DATABASE'}	= $xml->{'DB_DATABASE'};
     	$ftp->{'DB_HOST'}		= $xml->{'DB_HOST'};
     	$ftp->{'FTP_USER'}		= $xml->{'FTP_USER'};
     	$ftp->{'FTP_PASSWORD'}	= DB::encrypt_data($xml->{'FTP_PASSWORD'});
     
     	$handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     	fwrite($handle, $ftp->asXML());
     	fclose($handle);
     }
     */
     System_Daemon::debug('Finished "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     return true;
 }
コード例 #3
0
ファイル: DaemonConfigMail.php プロジェクト: gOOvER/EasySCP
 /**
  * @return mixed
  */
 public static function SaveMTAConfig()
 {
     System_Daemon::debug('Starting "DaemonConfigMail::SaveMTAConfig" subprocess.');
     /**
      * Postfix main.cf
      */
     // Backup current main.cf if exists
     if (file_exists(DaemonConfig::$distro->{'POSTFIX_CONF_FILE'})) {
         exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$distro->{'POSTFIX_CONF_FILE'} . ' ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/backup/main.cf' . '_' . date("Y_m_d_H_i_s"), $result, $error);
     }
     // Loading the template from /etc/easyscp/postfix/, Building the file
     $tpl_param = array('MTA_HOSTNAME' => idn_to_ascii(DaemonConfig::$cfg->{'SERVER_HOSTNAME'}), 'MTA_LOCAL_DOMAIN' => idn_to_ascii(DaemonConfig::$cfg->{'SERVER_HOSTNAME'}) . '.local', 'MTA_VERSION' => DaemonConfig::$cfg->{'Version'}, 'MTA_TRANSPORT' => DaemonConfig::$distro->{'MTA_TRANSPORT'}, 'MTA_LOCAL_MAIL_DIR' => DaemonConfig::$distro->{'MTA_LOCAL_MAIL_DIR'}, 'MTA_LOCAL_ALIAS_HASH' => DaemonConfig::$distro->{'MTA_LOCAL_ALIAS_HASH'}, 'MTA_VIRTUAL_MAIL_DIR' => DaemonConfig::$distro->{'MTA_VIRTUAL_MAIL_DIR'}, 'MTA_VIRTUAL_DMN' => DaemonConfig::$distro->{'MTA_VIRTUAL_DMN'}, 'MTA_VIRTUAL_MAILBOX' => DaemonConfig::$distro->{'MTA_VIRTUAL_MAILBOX'}, 'MTA_VIRTUAL_ALIAS' => DaemonConfig::$distro->{'MTA_VIRTUAL_ALIAS'}, 'MTA_MAILBOX_MIN_UID' => DaemonConfig::$cfg->{'MTA_MAILBOX_MIN_UID'}, 'MTA_MAILBOX_UID' => DaemonConfig::$cfg->{'MTA_MAILBOX_UID'}, 'MTA_MAILBOX_GID' => DaemonConfig::$cfg->{'MTA_MAILBOX_GID'}, 'PORT_POSTGREY' => DaemonConfig::$cfg->{'PORT_POSTGREY'}, 'MTA_SSL' => DaemonConfig::$cfg->{'MTA_SSL_STATUS'} == '1' ? true : false);
     $tpl = DaemonCommon::getTemplate($tpl_param);
     $config = $tpl->fetch('postfix/parts/' . DaemonConfig::$cfg->{'DistName'} . '_' . DaemonConfig::$cfg->{'DistVersion'} . '/main.cf');
     $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/main.cf';
     $tpl = NULL;
     unset($tpl);
     // Storing the new file in working directory
     if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
         return 'Error: Failed to write ' . $confFile;
     }
     // Installing the new file in production directory
     exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/main.cf ' . DaemonConfig::$distro->{'POSTFIX_CONF_FILE'}, $result, $error);
     /**
      * Postfix master.cf
      */
     // Backup current master.cf if exists
     if (file_exists(DaemonConfig::$distro->{'POSTFIX_MASTER_CONF_FILE'})) {
         exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$distro->{'POSTFIX_MASTER_CONF_FILE'} . ' ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/backup/master.cf' . '_' . date("Y_m_d_H_i_s"), $result, $error);
     }
     // Storing the new file in working directory
     exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/parts/' . DaemonConfig::$cfg->{'DistName'} . '_' . DaemonConfig::$cfg->{'DistVersion'} . '/master.cf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/master.cf', $result, $error);
     DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/master.cf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
     // Installing the new file in production directory
     exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/master.cf ' . DaemonConfig::$distro->{'POSTFIX_MASTER_CONF_FILE'}, $result, $error);
     // Loading the template from /etc/easyscp/postfix/, Building the file
     $MTA_DB_HOST = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $MTA_DB_USER = '******';
     $MTA_DB_PASS = DaemonCommon::generatePassword(9);
     $MTA_CONFIG_FILES = array('domains', 'email2email', 'forwardings', 'mailboxes', 'transports');
     $tpl_param = array('MTA_DB_USER' => $MTA_DB_USER, 'MTA_DB_PASS' => $MTA_DB_PASS);
     foreach ($MTA_CONFIG_FILES as $FILE) {
         $tpl = DaemonCommon::getTemplate($tpl_param);
         $config = $tpl->fetch('postfix/parts/mysql-virtual_' . $FILE . '.cf');
         $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/mysql-virtual_' . $FILE . '.cf';
         $tpl = NULL;
         unset($tpl);
         // Storing the new file in working directory
         if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
             return 'Error: Failed to write ' . $confFile;
         }
         // Installing the new file in production directory
         exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/postfix/working/mysql-virtual_' . $FILE . '.cf ' . DaemonConfig::$distro->{'MTA_VIRTUAL_CONF_DIR'} . '/mysql-virtual_' . $FILE . '.cf', $result, $error);
     }
     # Adding the mail_admin user
     $sql_param = array(':MTA_DB_HOST' => $MTA_DB_HOST, ':MTA_DB_USER' => $MTA_DB_USER, ':MTA_DB_PASS' => $MTA_DB_PASS);
     $sql_query = "\n\t\t\tGRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO :MTA_DB_USER@:MTA_DB_HOST IDENTIFIED BY :MTA_DB_PASS;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     /**
      * Dovecot Konfiguration
      */
     $configPath = 'dovecot/parts/' . DaemonConfig::$cfg->{'DistName'} . '_' . DaemonConfig::$cfg->{'DistVersion'};
     switch (DaemonConfig::$cfg->{'DistName'} . '_' . DaemonConfig::$cfg->{'DistVersion'}) {
         default:
             /**
              * 10-auth.conf
              */
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/10-auth.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-auth.conf', $result, $error);
             DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-auth.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-auth.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/10-auth.conf', $result, $error);
             /**
              * 10-logging.conf
              */
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -f ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/10-logging.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-logging.conf', $result, $error);
             DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-logging.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-logging.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/10-logging.conf', $result, $error);
             /**
              * 10-mail.conf
              */
             $tpl_param = array('MTA_VIRTUAL_MAIL_DIR' => DaemonConfig::$distro->{'MTA_VIRTUAL_MAIL_DIR'}, 'MTA_MAILBOX_UID' => DaemonConfig::$cfg->{'MTA_MAILBOX_UID'});
             $tpl = DaemonCommon::getTemplate($tpl_param);
             $config = $tpl->fetch($configPath . '/10-mail.conf');
             $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-mail.conf';
             $tpl = NULL;
             unset($tpl);
             if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
                 return 'Error: Failed to write ' . $confFile;
             }
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-mail.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/10-mail.conf', $result, $error);
             /**
              * 10-master.conf
              */
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/10-master.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-master.conf', $result, $error);
             DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-master.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-master.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/10-master.conf', $result, $error);
             /**
              * 10-ssl.conf
              */
             if (file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/10-ssl.conf')) {
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/10-ssl.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-ssl.conf', $result, $error);
                 DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-ssl.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/10-ssl.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/10-ssl.conf', $result, $error);
             }
             /**
              * 15-lda.conf
              */
             $tpl_param = array('DEFAULT_ADMIN_ADDRESS' => DaemonConfig::$cfg->{'DEFAULT_ADMIN_ADDRESS'});
             $tpl = DaemonCommon::getTemplate($tpl_param);
             $config = $tpl->fetch($configPath . '/15-lda.conf');
             $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/15-lda.conf';
             $tpl = NULL;
             unset($tpl);
             if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
                 return 'Error: Failed to write ' . $confFile;
             }
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/15-lda.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/15-lda.conf', $result, $error);
             /**
              * 20-lmtp.conf
              */
             if (file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/20-lmtp.conf')) {
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/20-lmtp.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-lmtp.conf', $result, $error);
                 DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-lmtp.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-lmtp.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/20-lmtp.conf', $result, $error);
             }
             /**
              * 20-managesieve.conf
              */
             if (file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/20-managesieve.conf')) {
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/20-managesieve.conf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-managesieve.conf', $result, $error);
                 DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-managesieve.conf', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644);
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/20-managesieve.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/20-managesieve.conf', $result, $error);
             }
             /**
              * 90-sieve.conf
              */
             if (file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/' . $configPath . '/90-sieve.conf')) {
                 $tpl_param = array('MTA_VIRTUAL_MAIL_DIR' => DaemonConfig::$distro->{'MTA_VIRTUAL_MAIL_DIR'});
                 $tpl = DaemonCommon::getTemplate($tpl_param);
                 $config = $tpl->fetch($configPath . '/90-sieve.conf');
                 $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/90-sieve.conf';
                 $tpl = NULL;
                 unset($tpl);
                 if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
                     return 'Error: Failed to write ' . $confFile;
                 }
                 exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/90-sieve.conf ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/90-sieve.conf', $result, $error);
             }
             /**
              * auth-sql.conf.ext
              */
             $tpl_param = array('MTA_MAILBOX_UID' => DaemonConfig::$cfg->{'MTA_MAILBOX_UID'}, 'MTA_MAILBOX_GID' => DaemonConfig::$cfg->{'MTA_MAILBOX_GID'}, 'MTA_VIRTUAL_MAIL_DIR' => DaemonConfig::$distro->{'MTA_VIRTUAL_MAIL_DIR'});
             $tpl = DaemonCommon::getTemplate($tpl_param);
             $config = $tpl->fetch($configPath . '/auth-sql.conf.ext');
             $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/auth-sql.conf.ext';
             $tpl = NULL;
             unset($tpl);
             if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
                 return 'Error: Failed to write ' . $confFile;
             }
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/auth-sql.conf.ext ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/conf.d/auth-sql.conf.ext', $result, $error);
             /**
              * dovecot-sql.conf.ext
              */
             $tpl_param = array('MTA_DB_HOST' => $MTA_DB_HOST, 'MTA_DB_USER' => $MTA_DB_USER, 'MTA_DB_PASS' => $MTA_DB_PASS);
             $tpl = DaemonCommon::getTemplate($tpl_param);
             $config = $tpl->fetch($configPath . '/dovecot-sql.conf.ext');
             $confFile = DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/dovecot-sql.conf.ext';
             $tpl = NULL;
             unset($tpl);
             // Storing the new file in working directory
             if (!DaemonCommon::systemWriteContentToFile($confFile, $config, DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0644)) {
                 return 'Error: Failed to write ' . $confFile;
             }
             // Installing the new file in production directory
             exec(DaemonConfig::$cmd->{'CMD_CP'} . ' -pf ' . DaemonConfig::$cfg->{'CONF_DIR'} . '/dovecot/working/dovecot-sql.conf.ext ' . DaemonConfig::$distro->{'DOVECOT_CONF_DIR'} . '/dovecot-sql.conf.ext', $result, $error);
     }
     unset($configPath);
     // Sonstige Anpassungen
     switch (DaemonConfig::$cfg->{'DistName'}) {
         case 'CentOS':
             // Wird auf CentOS benötigt da ansonsten bei unzustellbaren Mails der Fehler
             // "status=bounced (can't create user output file. Command output: procmail: Couldn't create "/var/spool/mail/nobody" )" im log erscheint.
             // "procmail" hat hier wohl nicht die richtigen Rechte.
             if (file_exists('/usr/bin/procmail')) {
                 exec("chmod g+s /usr/bin/procmail", $result, $error);
             }
             break;
         default:
     }
     System_Daemon::debug('Finished "DaemonConfigMail::SaveMTAConfig" subprocess.');
     return true;
 }
コード例 #4
0
ファイル: DaemonCoreSetup.php プロジェクト: gOOvER/EasySCP
function GUI_RoundCube()
{
    $cubeUser = '******';
    $cubeUserPwd = DaemonCommon::generatePassword(18);
    $cubeDBHost = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
    $rc = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_RC.xml');
    System_Daemon::debug('Building the new roundcube config file');
    $rc->{'CUBE_USER'} = $cubeUser;
    $rc->{'CUBE_PASS'} = DB::encrypt_data($cubeUserPwd);
    $rc->{'DATABASE_HOST'} = $cubeDBHost;
    $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_RC.xml', "wb");
    fwrite($handle, $rc->asXML());
    fclose($handle);
    DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_RC.xml', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0640);
    DaemonConfigTools::SaveRCConfig();
    $sql_param = array(':CUBE_USER' => $cubeUser, ':CUBE_PASS' => $cubeUserPwd, ':HOSTNAME' => $cubeDBHost);
    $sql_query = "\n\t\tGRANT ALL PRIVILEGES ON roundcubemail.* TO :CUBE_USER@:HOSTNAME IDENTIFIED BY :CUBE_PASS;\n\t\tFLUSH PRIVILEGES;\n\t";
    DB::prepare($sql_query);
    DB::execute($sql_param)->closeCursor();
    return 'Ok';
}