The Samba-Bugzilla – Attachment 8264 Details for
Bug 9271
backport samba-tool fixes from master
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Rework ldap attribute fetch in classicupgrade for missing attributes
bug-classicupgrade-1.diff (text/plain), 3.83 KB, created by
Karolin Seeger
on 2012-12-03 11:15:33 UTC
(
hide
)
Description:
Rework ldap attribute fetch in classicupgrade for missing attributes
Filename:
MIME Type:
Creator:
Karolin Seeger
Created:
2012-12-03 11:15:33 UTC
Size:
3.83 KB
patch
obsolete
>From 9ba5300e80c15c62cd1c3fda6c19928e8a7e7379 Mon Sep 17 00:00:00 2001 >From: Andrew Bartlett <abartlet@samba.org> >Date: Sun, 11 Nov 2012 11:35:02 +1100 >Subject: [PATCH] samba-tool: Rework ldap attribute fetch in classicupgrade > for missing attributes > >Is is not required that these additional attributes be filled in, so >catch KeyError in both the nsswitch and ldap backend case. > >We rework get_posix_attr_from_ldap_backend() so it raises KeyError >rather than trying to return None, and does not ignore other errors. > >Andrew Bartlett > >Tested-by: Chirana Gheorghita Eugeniu Theodor <office@adaptcom.ro> >Signed-off-by: Andrew Bartlett <abartlet@samba.org> >Reviewed-by: Jelmer Vernooij <jelmer@samba.org> >(cherry picked from commit b4d8629f511005540cb1fbbbe9abfb278c064ba2) >--- > source4/scripting/python/samba/upgrade.py | 41 +++++++++++++++++------------ > 1 files changed, 24 insertions(+), 17 deletions(-) > >diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py >index 786bb65..13d33c1 100644 >--- a/source4/scripting/python/samba/upgrade.py >+++ b/source4/scripting/python/samba/upgrade.py >@@ -539,13 +539,14 @@ def get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, user, attr): > expression=("(&(objectClass=posixAccount)(uid=%s))" > % (user)), attrs=[attr]) > except ldb.LdbError, e: >- logger.warning("Failed to retrieve attribute %s for user %s, the error is: %s", attr, user, e) >+ raise ProvisioningError("Failed to retrieve attribute %s for user %s, the error is: %s", attr, user, e) > else: >- if msg.count == 1: >+ if msg.count <= 1: >+ # This will raise KeyError (which is what we want) if there isn't a entry for this user > return msg[0][attr][0] > else: > logger.warning("LDAP entry for user %s contains more than one %s", user, attr) >- return None >+ raise KeyError > > > def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, >@@ -794,23 +795,29 @@ Please fix this account before attempting to upgrade again > for entry in userlist: > username = entry['account_name'] > if username in uids.keys(): >- if ldap: >- homes[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "homeDirectory") >- shells[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "loginShell") >- pgids[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "gidNumber") >- else: >- try: >+ try: >+ if ldap: >+ homes[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "homeDirectory") >+ else: > homes[username] = pwd.getpwnam(username).pw_dir >- except KeyError: >- pass >- try: >+ except KeyError: >+ pass >+ >+ try: >+ if ldap: >+ shells[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "loginShell") >+ else: > shells[username] = pwd.getpwnam(username).pw_shell >- except KeyError: >- pass >- try: >+ except KeyError: >+ pass >+ >+ try: >+ if ldap: >+ pgids[username] = get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, username, "gidNumber") >+ else: > pgids[username] = pwd.getpwnam(username).pw_gid >- except KeyError: >- pass >+ except KeyError: >+ pass > > logger.info("Reading WINS database") > samba3_winsdb = None >-- >1.7.7 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
metze
:
review+
Actions:
View
Attachments on
bug 9271
:
8018
|
8021
|
8032
| 8264