Skip to content

Commit 4b88c2b

Browse files
author
wyrie
committed
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
1 parent d090dbf commit 4b88c2b

File tree

4 files changed

+81
-19
lines changed

4 files changed

+81
-19
lines changed

server/mods-available/monitor_core_module.inc.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,20 +921,17 @@ function monitorSystemUpdate() {
921921
* Then test the upgrade.
922922
* if there is any output, then there is a needed update
923923
*/
924-
$emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
924+
$emergeData = shell_exec('glsa-check -t affected');
925925
if ($emergeData == '') {
926926
/* There is nothing to update! */
927927
$state = 'ok';
928+
$data['output'] = 'No unapplied GLSA\'s found on the system.';
928929
}
929930
else {
930931
/* There is something to update! */
931-
$state = 'warning';
932+
$state = 'info';
933+
$data['output'] = shell_exec('glsa-check -pv --nocolor affected 2>/dev/null');
932934
}
933-
934-
/*
935-
* Fetch the output
936-
*/
937-
$data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
938935
}
939936
else {
940937
/*

server/mods-available/remoteaction_core_module.inc.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30-
class remoteaction_core_module {
30+
class remoteaction_core_module extends modules_base {
3131
var $module_name = 'remoteaction_core_module';
3232
var $class_name = 'remoteaction_core_module';
3333
/* No actions at this time. maybe later... */
@@ -132,9 +132,15 @@ private function _doOsUpdate($action) {
132132
/*
133133
* Do the update
134134
*/
135-
exec("aptitude update");
136-
exec("aptitude upgrade -y");
137-
135+
//TODO : change this when distribution information has been integrated into server record
136+
if(file_exists('/etc/gentoo-release')) {
137+
exec("glsa-check -f --nocolor affected");
138+
}
139+
else {
140+
exec("aptitude update");
141+
exec("aptitude upgrade -y");
142+
}
143+
138144
/*
139145
* All well done!
140146
*/

server/plugins-available/bind_plugin.inc.php

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,14 @@ function soa_update($event_name,$data) {
105105
$records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
106106
$tpl->setLoop('zones',$records);
107107

108-
109-
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
108+
//TODO : change this when distribution information has been integrated into server record
109+
if (file_exists('/etc/gentoo-release')) {
110+
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri/'.substr($zone['origin'],0,-1));
111+
}
112+
else {
113+
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
114+
}
115+
110116
$app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
111117
file_put_contents($filename,$tpl->grab());
112118
chown($filename, escapeshellcmd($dns_config['bind_user']));
@@ -124,7 +130,14 @@ function soa_update($event_name,$data) {
124130

125131
//* Delete old domain file, if domain name has been changed
126132
if($data['old']['origin'] != $data['new']['origin']) {
127-
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
133+
//TODO : change this when distribution information has been integrated into server record
134+
if (file_exists('/etc/gentoo-release')) {
135+
$filename = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
136+
}
137+
else {
138+
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
139+
}
140+
128141
if(is_file($filename)) unset($filename);
129142
}
130143

@@ -144,7 +157,14 @@ function soa_delete($event_name,$data) {
144157
$this->write_named_conf($data,$dns_config);
145158

146159
//* Delete the domain file
147-
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
160+
//TODO : change this when distribution information has been integrated into server record
161+
if (file_exists('/etc/gentoo-release')) {
162+
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
163+
}
164+
else {
165+
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
166+
}
167+
148168
if(is_file($zone_file_name)) unlink($zone_file_name);
149169
$app->log("Deleting BIND domain file: ".$zone_file_name,LOGLEVEL_DEBUG);
150170

@@ -177,7 +197,14 @@ function slave_update($event_name,$data) {
177197

178198
//* Delete old domain file, if domain name has been changed
179199
if($data['old']['origin'] != $data['new']['origin']) {
180-
$filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
200+
//TODO : change this when distribution information has been integrated into server record
201+
if (file_exists('/etc/gentoo-release')) {
202+
$filename = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
203+
}
204+
else {
205+
$filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
206+
}
207+
181208
if(is_file($filename)) unset($filename);
182209
}
183210

@@ -198,7 +225,14 @@ function slave_delete($event_name,$data) {
198225
$this->write_named_conf($data,$dns_config);
199226

200227
//* Delete the domain file
201-
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
228+
//TODO : change this when distribution information has been integrated into server record
229+
if (file_exists('/etc/gentoo-release')) {
230+
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
231+
}
232+
else {
233+
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
234+
}
235+
202236
if(is_file($zone_file_name)) unlink($zone_file_name);
203237
$app->log("Deleting BIND domain file for secondary zone: ".$zone_file_name,LOGLEVEL_DEBUG);
204238

@@ -260,6 +294,17 @@ function write_named_conf($data, $dns_config) {
260294
} else {
261295
$exclude_zone = '';
262296
}
297+
298+
//TODO : change this when distribution information has been integrated into server record
299+
if (file_exists('/etc/gentoo-release')) {
300+
$pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri/';
301+
$sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/sec/';
302+
303+
}
304+
else {
305+
$pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri.';
306+
$sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/slave/sec.';
307+
}
263308

264309
//* Loop trough zones
265310
foreach($tmps as $tmp) {
@@ -274,7 +319,7 @@ function write_named_conf($data, $dns_config) {
274319

275320
if($tmp['origin'] != $exclude_zone) {
276321
$zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
277-
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
322+
'zonefile_path' => $pri_zonefiles_path.substr($tmp['origin'],0,-1),
278323
'options' => $options
279324
);
280325
}
@@ -299,7 +344,7 @@ function write_named_conf($data, $dns_config) {
299344

300345

301346
$zones_sec[] = array( 'zone' => substr($tmp['origin'],0,-1),
302-
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($tmp['origin'],0,-1),
347+
'zonefile_path' => $sec_zonefiles_path.substr($tmp['origin'],0,-1),
303348
'options' => $options
304349
);
305350

server/plugins-available/cron_plugin.inc.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ function update($event_name,$data) {
133133
exec("setquota -T -u $username 604800 604800 -a &> /dev/null");
134134
}
135135

136+
//TODO : change this when distribution information has been integrated into server record
137+
//* Gentoo requires a user to be part of the crontab group.
138+
if (file_exists('/etc/gentoo-release')) {
139+
if (strpos($app->system->get_user_groups($username), 'crontab') === false) {
140+
$app->system->add_user_to_group('crontab', $username);
141+
}
142+
}
143+
136144
// make temp directory writable for the apache and website users
137145
chmod(escapeshellcmd($parent_domain["document_root"].'/tmp'), 0777);
138146

@@ -214,6 +222,12 @@ function _write_crontab() {
214222
}
215223

216224
$cron_file = escapeshellcmd($cron_config["crontab_dir"].'/ispc_'.$this->parent_domain["system_user"]);
225+
//TODO : change this when distribution information has been integrated into server record
226+
//* Gentoo vixie-cron requires files to end with .cron in the cron.d directory
227+
if (file_exists('/etc/gentoo-release')) {
228+
$cron_file .= '.cron';
229+
}
230+
217231
if($cmd_count > 0) {
218232
file_put_contents($cron_file, $cron_content);
219233
$app->log("Wrote Cron file $cron_file with content:\n$cron_content",LOGLEVEL_DEBUG);

0 commit comments

Comments
 (0)