From fea974d01416c9ecb57f801b1796d1332918063a Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Mon, 23 Jan 2012 09:53:52 -0500 Subject: [PATCH] Fixed: FS#1997 - Check encoding of the subject in ispconfig mail sending function. --- server/plugins-available/nginx_plugin.inc.php | 94 ++++++++++++++++++++++++++++++---------------- 1 files changed, 61 insertions(+), 33 deletions(-) diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index f0c8925..149a4d1 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -41,7 +41,7 @@ function onInstall() { global $conf; - if($conf['services']['web'] == true) { + if($conf['services']['web'] == true && !@is_link('/usr/local/ispconfig/server/plugins-enabled/apache2_plugin.inc.php')) { return true; } else { return false; @@ -198,7 +198,17 @@ if(trim($data["new"]["ssl_request"]) != '') file_put_contents($csr_file,$data["new"]["ssl_request"]); if(trim($data["new"]["ssl_cert"]) != '') file_put_contents($crt_file,$data["new"]["ssl_cert"]); // for nginx, bundle files have to be appended to the certificate file - if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($crt_file,$data["new"]["ssl_bundle"], FILE_APPEND); + if(trim($data["new"]["ssl_bundle"]) != ''){ + if(file_exists($crt_file)){ + $crt_file_contents = trim(file_get_contents($crt_file)); + } else { + $crt_file_contents = ''; + } + if($crt_file_contents != '') $crt_file_contents .= "\n"; + $crt_file_contents .= $data["new"]["ssl_bundle"]; + file_put_contents($crt_file,$app->file->unix_nl($crt_file_contents)); + unset($crt_file_contents); + } /* Update the DB of the (local) Server */ $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); /* Update also the master-DB of the Server-Farm */ @@ -246,7 +256,13 @@ function update($event_name,$data) { global $app, $conf; - + + //* Check if the apache plugin is enabled + if(@is_link('/usr/local/ispconfig/server/plugins-enabled/apache2_plugin.inc.php')) { + $app->log('The nginx plugin can not be used together with the apache2 plugin..',LOGLEVEL_WARN); + return 0; + } + if($this->action != 'insert') $this->action = 'update'; if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) { @@ -323,8 +339,14 @@ $tmp_docroot = explode('/',$data['old']['document_root']); unset($tmp_docroot[count($tmp_docroot)-1]); $old_dir = implode('/',$tmp_docroot); - - exec('rm -rf '.$data['new']['document_root']); + + //* Check if there is already some data in the new docroot and rename it as we need a clean path to move the existing site to the new path + if(@is_dir($data['new']['document_root'])) { + rename($data['new']['document_root'],$data['new']['document_root'].'_bak_'.date('Y_m_d')); + $app->log('Renaming existing directory in new docroot location. mv '.$data['new']['document_root'].' '.$data['new']['document_root'].'_bak_'.date('Y_m_d'),LOGLEVEL_DEBUG); + } + + //* Create new base directory, if it does not exist yet if(!is_dir($new_dir)) exec('mkdir -p '.$new_dir); exec('mv '.$data['old']['document_root'].' '.$new_dir); $app->log('Moving site to new document root: mv '.$data['old']['document_root'].' '.$new_dir,LOGLEVEL_DEBUG); @@ -502,18 +524,42 @@ // Create group and user, if not exist $app->uses('system'); + + if($web_config['connect_userid_to_webid'] == 'y') { + //* Calculate the uid and gid + $connect_userid_to_webid_start = ($web_config['connect_userid_to_webid_start'] < 1000)?1000:intval($web_config['connect_userid_to_webid_start']); + $fixed_uid_gid = intval($connect_userid_to_webid_start + $data['new']['domain_id']); + $fixed_uid_param = '--uid '.$fixed_uid_gid; + $fixed_gid_param = '--gid '.$fixed_uid_gid; + + //* Check if a ispconfigend user and group exists and create them + if(!$app->system->is_group('ispconfigend')) { + exec('groupadd --gid '.($connect_userid_to_webid_start + 10000).' ispconfigend'); + } + if(!$app->system->is_user('ispconfigend')) { + exec('useradd -g ispconfigend -d /usr/local/ispconfig --uid '.($connect_userid_to_webid_start + 10000).' ispconfigend'); + } + } else { + $fixed_uid_param = ''; + $fixed_gid_param = ''; + } $groupname = escapeshellcmd($data['new']['system_group']); if($data['new']['system_group'] != '' && !$app->system->is_group($data['new']['system_group'])) { - exec('groupadd '.$groupname); + exec('groupadd '.$fixed_gid_param.' '.$groupname); if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' groupadd '.$groupname); $app->log('Adding the group: '.$groupname,LOGLEVEL_DEBUG); } $username = escapeshellcmd($data['new']['system_user']); if($data['new']['system_user'] != '' && !$app->system->is_user($data['new']['system_user'])) { - exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname -G sshusers $username -s /bin/false"); - if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname -G sshusers $username -s /bin/false"); + if($web_config['add_web_users_to_sshusers_group'] == 'y') { + exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param -G sshusers $username -s /bin/false"); + if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param -G sshusers $username -s /bin/false"); + } else { + exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param $username -s /bin/false"); + if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param $username -s /bin/false"); + } $app->log('Adding the user: '.$username,LOGLEVEL_DEBUG); } @@ -554,10 +600,12 @@ // Set Log symlink to 755 to make the logs accessible by the FTP user $this->_exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"])."/log"); - $command = 'usermod'; - $command .= ' --groups sshusers'; - $command .= ' '.escapeshellcmd($data['new']['system_user']); - $this->_exec($command); + if($web_config['add_web_users_to_sshusers_group'] == 'y') { + $command = 'usermod'; + $command .= ' --groups sshusers'; + $command .= ' '.escapeshellcmd($data['new']['system_user']); + $this->_exec($command); + } //* if we have a chrooted nginx environment if($nginx_chrooted) { @@ -1083,27 +1131,7 @@ //* This function is called when a IP on the server is inserted, updated or deleted function server_ip($event_name,$data) { - global $app, $conf; - - // load the server configuration options - $app->uses('getconf'); - $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); - - $app->load('tpl'); - - $tpl = new tpl(); - $tpl->newTemplate('apache_ispconfig.conf.master'); - $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); - - if(count($records) > 0) { - $tpl->setLoop('ip_adresses',$records); - } - - $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/ispconfig.conf'); - file_put_contents($vhost_file,$tpl->grab()); - $app->log('Writing the conf file: '.$vhost_file,LOGLEVEL_DEBUG); - unset($tpl); - + return; } //* Create or update the .htaccess folder protection -- Gitblit v1.9.1