[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Catch exceptions when running import-users-from-passwd



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 dak/import_users_from_passwd.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/dak/import_users_from_passwd.py b/dak/import_users_from_passwd.py
index 9584867..b959e37 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
 
-- 
1.7.2.5


Reply to: