diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2011-10-08 14:07:18 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2011-10-08 14:15:11 +0200 |
commit | dc3df567bef9a462fd48d233f88ee59dbadcbd89 (patch) | |
tree | 3d693b59a927f086d0543379dc0d9371b3127868 | |
parent | 9c979e88dcf46f310c54d71914722479892a5449 (diff) | |
download | samba-dc3df567bef9a462fd48d233f88ee59dbadcbd89.tar.gz samba-dc3df567bef9a462fd48d233f88ee59dbadcbd89.tar.bz2 samba-dc3df567bef9a462fd48d233f88ee59dbadcbd89.zip |
upgrade: Avoid catching all exceptions, just catch the ones we care about.
-rw-r--r-- | source4/scripting/python/samba/upgrade.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py index 4c293ed308..60cff51198 100644 --- a/source4/scripting/python/samba/upgrade.py +++ b/source4/scripting/python/samba/upgrade.py @@ -19,7 +19,6 @@ __docformat__ = "restructuredText" -import grp import ldb import time import pwd @@ -486,15 +485,12 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=Fa realm) # Find machine account and password - machinepass = None - machinerid = None - machinesid = None next_rid = 1000 try: machinepass = secrets_db.get_machine_password(netbiosname) - except: - pass + except KeyError: + machinepass = None # We must close the direct pytdb database before the C code loads it secrets_db.close() @@ -512,9 +508,11 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=Fa # Get machine account, sid, rid try: machineacct = s3db.getsampwnam('%s$' % netbiosname) + except passdb.error: + machinerid = None + machinesid = None + else: machinesid, machinerid = machineacct.user_sid.split() - except: - pass # Export account policy logger.info("Exporting account policy") @@ -536,7 +534,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=Fa elif group.sid_name_use == lsa.SID_NAME_DOM_GRP: try: members = s3db.enum_group_members(group.sid) - except: + except passdb.error: continue groupmembers[group.nt_name] = members elif group.sid_name_use == lsa.SID_NAME_WKN_GRP: @@ -590,10 +588,10 @@ Please fix this account before attempting to upgrade again userdata[username] = user try: uids[username] = s3db.sid_to_id(user.user_sid)[0] - except: + except passdb.error: try: uids[username] = pwd.getpwnam(username).pw_uid - except: + except passdb.error: pass if not admin_user and username.lower() == 'root': |