From 0d40a86deb661105949fd78ad74dc7554697094e Mon Sep 17 00:00:00 2001 From: Derek Jennings Date: Tue, 27 Aug 2013 11:57:04 +0100 Subject: fix race condition checking service status (mga#10830) --- NEWS | 2 ++ common/Wizcommon.pm | 11 ++++++++++- dhcp_wizard/Dhcp.pm | 2 +- dns_wizard/Bind.pm | 2 +- ftp_wizard/Proftpd.pm | 2 +- proxy_wizard/Squid.pm | 2 +- sshd_wizard/Sshd.pm | 2 +- web_wizard/Apache.pm | 2 +- 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 87d7cbf0..db6013b5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- fix race condition checking service status (mga#10830) + Version 3.7.5 - 27 May 2011, by Ennael - clean Mandriva references diff --git a/common/Wizcommon.pm b/common/Wizcommon.pm index 7e58107a..2fe045d0 100644 --- a/common/Wizcommon.pm +++ b/common/Wizcommon.pm @@ -27,7 +27,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); my $net; @@ -51,6 +51,15 @@ sub check_started { } } +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 8a02bba6..c4bfb2bc 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -269,7 +269,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/dns_wizard/Bind.pm b/dns_wizard/Bind.pm index cd4bdf2a..9a13e7cb 100644 --- a/dns_wizard/Bind.pm +++ b/dns_wizard/Bind.pm @@ -822,7 +822,7 @@ sub end_it { save_old_config(); # copy in correct place copy_good(); - services::restart_or_start('named'); + reload_or_restart('named'); } sub do_it_master { diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm index d3671348..d7b2e81d 100755 --- a/ftp_wizard/Proftpd.pm +++ b/ftp_wizard/Proftpd.pm @@ -316,7 +316,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 25bc8b16..72e0fdd7 100755 --- a/proxy_wizard/Squid.pm +++ b/proxy_wizard/Squid.pm @@ -288,7 +288,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 a560729e..ba9bb8db 100755 --- a/sshd_wizard/Sshd.pm +++ b/sshd_wizard/Sshd.pm @@ -213,7 +213,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 62ca5ed8..496a4f44 100755 --- a/web_wizard/Apache.pm +++ b/web_wizard/Apache.pm @@ -272,7 +272,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