From 3916cbf9575d4b4db015fd629fdcaf395724cd9c Mon Sep 17 00:00:00 2001 From: Derek Jennings Date: Tue, 27 Aug 2013 00:59:13 +0100 Subject: fix race condition checking service status (mga#10934) --- common/Wizcommon.pm | 11 ++++++++++- dhcp_wizard/Dhcp.pm | 2 +- ftp_wizard/Proftpd.pm | 2 +- proxy_wizard/Squid.pm | 2 +- sshd_wizard/Sshd.pm | 2 +- web_wizard/Apache.pm | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/common/Wizcommon.pm b/common/Wizcommon.pm index 5caa0766..34a94f48 100644 --- a/common/Wizcommon.pm +++ b/common/Wizcommon.pm @@ -28,7 +28,7 @@ use MDK::Common; use MDK::Wizard::IFCFG; our @ISA = qw(Exporter); -our @EXPORT = qw(check_started check_starts_on_boot test_host_domain); +our @EXPORT = qw(check_started check_starts_on_boot test_host_domain reload_or_restart); sub check_dhcp { my ($wiz) = @_; @@ -48,6 +48,15 @@ sub check_started { return 'error_end' if !$isrunning; } +sub reload_or_restart { + my ($service) = @_; + if (run_program::rooted($::prefix, '/bin/mountpoint', '-q', '/sys/fs/cgroup/systemd')) { + run_program::rooted($::prefix, '/bin/systemctl', 'reload-or-restart', "$service.service"); + } else { + run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", "restart"); + } +} + sub check_starts_on_boot($$) { my ($in, $servicename) = @_; if (!services::starts_on_boot($servicename)) { diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index e8411f52..4f83b478 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -261,7 +261,7 @@ mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $w s/#\s+doption routers.*//; } "/etc/dhcpd.conf"; - services::restart_or_start('dhcpd'); + reload_or_restart('dhcpd'); check_started('dhcpd'); } diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm index b2afda55..22695c4e 100755 --- a/ftp_wizard/Proftpd.pm +++ b/ftp_wizard/Proftpd.pm @@ -317,7 +317,7 @@ sub do_it { add_options($cle, $val); } - services::restart_or_start('proftpd'); + reload_or_restart('proftpd'); check_started('proftpd'); } diff --git a/proxy_wizard/Squid.pm b/proxy_wizard/Squid.pm index 662974fc..f46091af 100755 --- a/proxy_wizard/Squid.pm +++ b/proxy_wizard/Squid.pm @@ -278,7 +278,7 @@ level = $o->{var}{wiz_squid_level}"); } $file; system("/sbin/chkconfig --level 345 squid on"); - services::restart_or_start('squid'); + reload_or_restart('squid'); undef $w; check_started('squid'); } diff --git a/sshd_wizard/Sshd.pm b/sshd_wizard/Sshd.pm index 99c524cd..e86a4028 100755 --- a/sshd_wizard/Sshd.pm +++ b/sshd_wizard/Sshd.pm @@ -214,7 +214,7 @@ sub new { sub write_conf_restart_ssh { $sshd->write_conf($conf); - services::restart_or_start('sshd'); + reload_or_restart('sshd'); } sub global_config { diff --git a/web_wizard/Apache.pm b/web_wizard/Apache.pm index 79395930..a2db5da5 100755 --- a/web_wizard/Apache.pm +++ b/web_wizard/Apache.pm @@ -271,7 +271,7 @@ sub do_it { chg_docroot(); chg_user_dir(); - services::restart_or_start('httpd'); + reload_or_restart('httpd'); undef $w; check_started($o->{var}{servicecheck}); } -- cgit v1.2.1