From d97ff036ab05751ea499553792e0ae5fc73fb3f6 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 30 May 2011 13:11:03 +0000 Subject: [PATCH] Prevent races on resovlconf generation as well by adding a lock. --- etc/inc/system.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 347de9b8cb..72b2e0df69 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -116,9 +116,12 @@ function system_resolvconf_generate($dynupdate = false) { } } + $dnslock = lock('resolvconf', LOCK_EX); + $fd = fopen("{$g['varetc_path']}/resolv.conf", "w"); if (!$fd) { printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n"); + unlock($dnslock); return 1; } @@ -148,7 +151,9 @@ function system_resolvconf_generate($dynupdate = false) { } } } - + + unlock($dnslock); + return 0; }