From bfbd12f7608cddca02f9a958b2864fe8134e7115 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Wed, 14 Nov 2012 02:45:46 +0100
Subject: [PATCH] Warn on invalid lines in HTTP user files

Without this change, invalid lines or values would be silently ignored.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/http/auth.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/http/auth.py b/lib/http/auth.py
index 1e33f2cdb..5dec95b6e 100644
--- a/lib/http/auth.py
+++ b/lib/http/auth.py
@@ -310,6 +310,8 @@ def ParsePasswordFile(contents):
     parts = line.split(None, 2)
     if len(parts) < 2:
       # Invalid line
+      # TODO: Return line number from FilterEmptyLinesAndComments
+      logging.warning("Ignoring non-comment line with less than two fields")
       continue
 
     name = parts[0]
@@ -320,6 +322,8 @@ def ParsePasswordFile(contents):
     if len(parts) >= 3:
       for part in parts[2].split(","):
         options.append(part.strip())
+    else:
+      logging.warning("Ignoring values for user '%s': %s", name, parts[3:])
 
     users[name] = PasswordFileUser(name, password, options)
 
-- 
GitLab