From: Mark Hymers Date: Fri, 29 Jul 2011 09:06:06 +0000 (+0100) Subject: Catch exceptions when running import-users-from-passwd X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26be481e34f6502bfaac1fbed2a00a2ed5a82350;p=dak Catch exceptions when running import-users-from-passwd Signed-off-by: Mark Hymers --- 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