From 26be481e34f6502bfaac1fbed2a00a2ed5a82350 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Fri, 29 Jul 2011 10:06:06 +0100 Subject: [PATCH] Catch exceptions when running import-users-from-passwd Signed-off-by: Mark Hymers --- dak/import_users_from_passwd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dak/import_users_from_passwd.py b/dak/import_users_from_passwd.py index 95848671..b959e37f 100755 --- a/dak/import_users_from_passwd.py +++ b/dak/import_users_from_passwd.py @@ -115,7 +115,12 @@ def main (): # NB: I never figured out how to use a bind parameter for this query # XXX: Fix this as it looks like a potential SQL injection attack to me # (hence the safe_name match we do) - q = session.execute('CREATE USER "%s"' % (uname)) + try: + q = session.execute('CREATE USER "%s"' % (uname)) + session.commit() + except Exception, e: + utils.warn("Could not create user %s (%s)" % (uname, str(e))) + session.rollback() else: print "NOT CREATING USER %s. Doesn't match safety regex" % uname -- 2.39.5