From 3b9201fb91580abcafdaf9c60021410cacc3f17c Mon Sep 17 00:00:00 2001 From: Johannes Feichtner Date: Tue, 15 Sep 2015 23:33:40 +0200 Subject: [PATCH] Nginx: Fix for redundantly inserted auth blocks The problem occurs if a Vhost is assigned multiple different auth names in Froxlor. Each block is then added repeatedly, leading to an unparseable configuration --- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 4bff60a1..aae88026 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -788,7 +788,18 @@ class nginx extends HttpConfigBase { $returnval[$x]['path'] = $path; $returnval[$x]['root'] = makeCorrectDir($domain['documentroot']); - $returnval[$x]['authname'] = $row_htpasswds['authname']; + + // Ensure there is only one auth name per password block, otherwise + // the directives are inserted multiple times -> invalid config + $authname = $row_htpasswds['authname']; + for ($i = 0; $i < $x; $i++) { + if ($returnval[$i]['usrf'] == $htpasswd_filename) { + $authname = $returnval[$i]['authname']; + break; + } + } + $returnval[$x]['authname'] = $authname; + $returnval[$x]['usrf'] = $htpasswd_filename; $x++; }