From d87f76019fc231ec20d95126a7fee0487e7be5f0 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Tue, 14 Aug 2012 10:56:20 -0400 Subject: [PATCH] - Added new web folder named private to web folder layout. The folder is intended to store data that shall not be visible in the web directory, it is owned by the user of the web. - Changed ownership of web root directory to root user in all security modes to prevent symlink attacks. - Apache log files are now owned by user root. - Improved functions in system library. --- server/plugins-available/software_update_plugin.inc.php | 46 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 34 insertions(+), 12 deletions(-) diff --git a/server/plugins-available/software_update_plugin.inc.php b/server/plugins-available/software_update_plugin.inc.php index be73c8b..a6b7162 100644 --- a/server/plugins-available/software_update_plugin.inc.php +++ b/server/plugins-available/software_update_plugin.inc.php @@ -1,7 +1,7 @@ <?php /* -Copyright (c) 2007, Till Brehm, projektfarm Gmbh +Copyright (c) 2007-2012, Till Brehm, projektfarm Gmbh, Oliver Vogel www.muv.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -35,7 +35,7 @@ //* This function is called during ispconfig installation to determine // if a symlink shall be created for this plugin. - function onInstall() { + public function onInstall() { global $conf; return true; @@ -47,33 +47,35 @@ This function is called when the plugin is loaded */ - function onLoad() { + public function onLoad() { global $app; /* Register for the events */ - //* Mailboxes $app->plugins->registerEvent('software_update_inst_insert',$this->plugin_name,'process'); //$app->plugins->registerEvent('software_update_inst_update',$this->plugin_name,'process'); //$app->plugins->registerEvent('software_update_inst_delete',$this->plugin_name,'process'); + //* Register for actions + $app->plugins->registerAction('os_update',$this->plugin_name,'os_update'); + } - function set_install_status($inst_id, $status) { + private function set_install_status($inst_id, $status) { global $app; $app->db->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'"); $app->dbmaster->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'"); } - function process($event_name,$data) { + public function process($event_name,$data) { global $app, $conf; //* Get the info of the package: - $software_update_id = intval($data["new"]["software_update_id"]); + $software_update_id = intval($data["new"]["software_update_id"]); $software_update = $app->db->queryOneRecord("SELECT * FROM software_update WHERE software_update_id = '$software_update_id'"); $software_package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = '".$app->db->quote($software_update['package_name'])."'"); @@ -97,7 +99,7 @@ $temp_dir = '/tmp/'.md5 (uniqid (rand())); $app->log("The temp dir is $temp_dir",LOGLEVEL_DEBUG); mkdir($temp_dir); - if($installuser != '') exec('chown '.$installuser.' '.$temp_dir); + if($installuser != '') chown($temp_dir, $installuser); if(!is_dir($temp_dir)) { $app->log("Unable to create temp directory.",LOGLEVEL_WARN); @@ -135,7 +137,7 @@ $app->log("No package file found. Download failed? Installation aborted.",LOGLEVEL_WARN); exec("rm -rf $temp_dir"); $app->log("Deleting the temp directory $temp_dir",LOGLEVEL_DEBUG); - $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); + $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); return false; } @@ -148,10 +150,10 @@ $app->log("The md5 sum of the downloaded file is incorrect. Update aborted.",LOGLEVEL_WARN); exec("rm -rf $temp_dir"); $app->log("Deleting the temp directory $temp_dir",LOGLEVEL_DEBUG); - $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); + $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); return false; } else { - $app->log("md5sum of the downloaded file is verified.",LOGLEVEL_DEBUG); + $app->log("MD5 checksum of the downloaded file verified.",LOGLEVEL_DEBUG); } @@ -271,7 +273,27 @@ } } + + //* Operating system update + public function os_update($action_name,$data) { + global $app; + + //** Debian and compatible Linux distributions + if(file_exists('/etc/debian_version')) { + exec("aptitude update"); + exec("aptitude safe-upgrade -y"); + $app->log('Execeuted Debian / Ubuntu update',LOGLEVEL_DEBUG); + } + + //** Gentoo Linux + if(file_exists('/etc/gentoo-release')) { + exec("glsa-check -f --nocolor affected"); + $app->log('Execeuted Gentoo update',LOGLEVEL_DEBUG); + } + + return 'ok'; + } } // end class -?> \ No newline at end of file +?> -- Gitblit v1.9.1