wyrie
2010-10-18 4b88c2b95d7e21820adad02317aa0cfee98b29c1
Server: Gentoo updates

- Changed os updates from world to security advisories
- Added support for remote os update
- Added bind compatibility code
- Fixed bugs in cron compatibility


4 files modified
100 ■■■■ changed files
server/mods-available/monitor_core_module.inc.php 11 ●●●●● patch | view | raw | blame | history
server/mods-available/remoteaction_core_module.inc.php 14 ●●●● patch | view | raw | blame | history
server/plugins-available/bind_plugin.inc.php 61 ●●●● patch | view | raw | blame | history
server/plugins-available/cron_plugin.inc.php 14 ●●●●● patch | view | raw | blame | history
server/mods-available/monitor_core_module.inc.php
@@ -921,20 +921,17 @@
             * Then test the upgrade.
             * if there is any output, then there is a needed update
            */
            $emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
            $emergeData = shell_exec('glsa-check -t affected');
            if ($emergeData == '') {
                /* There is nothing to update! */
                $state = 'ok';
                $data['output'] = 'No unapplied GLSA\'s found on the system.';
            }
            else {
                /* There is something to update! */
                $state = 'warning';
                $state = 'info';
                $data['output'] = shell_exec('glsa-check -pv --nocolor affected 2>/dev/null');
            }
            /*
             * Fetch the output
            */
            $data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
        }
        else {
            /*
server/mods-available/remoteaction_core_module.inc.php
@@ -27,7 +27,7 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class remoteaction_core_module {
class remoteaction_core_module extends modules_base {
    var $module_name = 'remoteaction_core_module';
    var $class_name = 'remoteaction_core_module';
    /* No actions at this time. maybe later... */
@@ -132,9 +132,15 @@
        /*
         * Do the update
         */
        exec("aptitude update");
        exec("aptitude upgrade -y");
        //TODO : change this when distribution information has been integrated into server record
        if(file_exists('/etc/gentoo-release')) {
            exec("glsa-check -f --nocolor affected");
        }
        else {
            exec("aptitude update");
            exec("aptitude upgrade -y");
        }
        /*
         * All well done!
         */
server/plugins-available/bind_plugin.inc.php
@@ -105,8 +105,14 @@
            $records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
            $tpl->setLoop('zones',$records);
            
            $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
            //TODO : change this when distribution information has been integrated into server record
            if (file_exists('/etc/gentoo-release')) {
                $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri/'.substr($zone['origin'],0,-1));
            }
            else {
                $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
            }
            $app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
            file_put_contents($filename,$tpl->grab());
            chown($filename, escapeshellcmd($dns_config['bind_user']));
@@ -124,7 +130,14 @@
        
        //* Delete old domain file, if domain name has been changed
        if($data['old']['origin'] != $data['new']['origin']) {
            $filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
            //TODO : change this when distribution information has been integrated into server record
            if (file_exists('/etc/gentoo-release')) {
                $filename = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
            }
            else {
                $filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
            }
            if(is_file($filename)) unset($filename);
        }
        
@@ -144,7 +157,14 @@
        $this->write_named_conf($data,$dns_config);
        
        //* Delete the domain file
        $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
        //TODO : change this when distribution information has been integrated into server record
        if (file_exists('/etc/gentoo-release')) {
            $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
        }
        else {
            $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
        }
        if(is_file($zone_file_name)) unlink($zone_file_name);
        $app->log("Deleting BIND domain file: ".$zone_file_name,LOGLEVEL_DEBUG);
        
@@ -177,7 +197,14 @@
        
        //* Delete old domain file, if domain name has been changed
        if($data['old']['origin'] != $data['new']['origin']) {
            $filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
            //TODO : change this when distribution information has been integrated into server record
            if (file_exists('/etc/gentoo-release')) {
                $filename = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
            }
            else {
                $filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
            }
            if(is_file($filename)) unset($filename);
        }
        
@@ -198,7 +225,14 @@
        $this->write_named_conf($data,$dns_config);
        
        //* Delete the domain file
        $zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
        //TODO : change this when distribution information has been integrated into server record
        if (file_exists('/etc/gentoo-release')) {
            $zone_file_name = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
        }
        else {
            $zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
        }
        if(is_file($zone_file_name)) unlink($zone_file_name);
        $app->log("Deleting BIND domain file for secondary zone: ".$zone_file_name,LOGLEVEL_DEBUG);
        
@@ -260,6 +294,17 @@
        } else {
            $exclude_zone = '';
        }
        //TODO : change this when distribution information has been integrated into server record
        if (file_exists('/etc/gentoo-release')) {
            $pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri/';
            $sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/sec/';
        }
        else {
            $pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri.';
            $sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/slave/sec.';
        }
        //* Loop trough zones
        foreach($tmps as $tmp) {
@@ -274,7 +319,7 @@
            
            if($tmp['origin'] != $exclude_zone) {
                $zones[] = array(    'zone' => substr($tmp['origin'],0,-1),
                                    'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
                                    'zonefile_path' => $pri_zonefiles_path.substr($tmp['origin'],0,-1),
                                    'options' => $options
                                );
            }
@@ -299,7 +344,7 @@
            
            $zones_sec[] = array(    'zone' => substr($tmp['origin'],0,-1),
                                    'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($tmp['origin'],0,-1),
                                    'zonefile_path' => $sec_zonefiles_path.substr($tmp['origin'],0,-1),
                                    'options' => $options
                                );
server/plugins-available/cron_plugin.inc.php
@@ -133,6 +133,14 @@
            exec("setquota -T -u $username 604800 604800 -a &> /dev/null");
        }
        
        //TODO : change this when distribution information has been integrated into server record
        //* Gentoo requires a user to be part of the crontab group.
        if (file_exists('/etc/gentoo-release')) {
            if (strpos($app->system->get_user_groups($username), 'crontab') === false) {
                $app->system->add_user_to_group('crontab', $username);
            }
        }
        // make temp directory writable for the apache and website users
        chmod(escapeshellcmd($parent_domain["document_root"].'/tmp'), 0777);
        
@@ -214,6 +222,12 @@
        }
        
        $cron_file = escapeshellcmd($cron_config["crontab_dir"].'/ispc_'.$this->parent_domain["system_user"]);
        //TODO : change this when distribution information has been integrated into server record
        //* Gentoo vixie-cron requires files to end with .cron in the cron.d directory
        if (file_exists('/etc/gentoo-release')) {
            $cron_file .= '.cron';
        }
        if($cmd_count > 0) {
            file_put_contents($cron_file, $cron_content);
            $app->log("Wrote Cron file $cron_file with content:\n$cron_content",LOGLEVEL_DEBUG);