]> git.decadent.org.uk Git - dak.git/commitdiff
Catch exceptions when running import-users-from-passwd
authorMark Hymers <mhy@debian.org>
Fri, 29 Jul 2011 09:06:06 +0000 (10:06 +0100)
committerMark Hymers <mhy@debian.org>
Fri, 29 Jul 2011 09:06:06 +0000 (10:06 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/import_users_from_passwd.py

index 958486710251b99e5ac5e2ebf5a6cf75efef37b2..b959e37fa64e9f4b2020d7d6afe2226193b844ec 100755 (executable)
@@ -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