From ee4eade2058ec8a49862d6df9764e2f2f30739dd Mon Sep 17 00:00:00 2001 From: Florian Best Date: Fri, 29 Nov 2019 13:08:18 +0100 Subject: [PATCH 4/4] Bug #49720: build samba including python3 package Signed-off-by: Florian Best --- samba/00_waf_python2.quilt | 4 +- samba/40_samba3upgrade.quilt | 16 +- samba/44_upgrade_debug.quilt | 8 +- samba/96_dnsupdate_exclude_interfaces.quilt | 6 +- ...x-LA-vs-DA-in-samba-tool-ntacl-syvolcheck.quilt | 14 +- ...-sysvolcheck-option-mask-msad-differences.quilt | 16 +- ...check-show-the-file-path-in-error-message.quilt | 6 +- samba/97_bug29665.quilt | 24 +-- ...tool-dbcheck-handle-name-conflict-objects.quilt | 36 ++-- samba/99_python3-samba-1.patch | 195 +++++++++++++++++++++ samba/99_python3-samba-2.patch | 27 +++ samba/99_python3-samba-3.patch | 23 +++ samba/99_python3-samba-4.quilt | 32 ++++ samba/99_python3-samba-5.quilt | 14 ++ 14 files changed, 356 insertions(+), 65 deletions(-) create mode 100644 samba/99_python3-samba-1.patch create mode 100644 samba/99_python3-samba-2.patch create mode 100644 samba/99_python3-samba-3.patch create mode 100644 samba/99_python3-samba-4.quilt create mode 100644 samba/99_python3-samba-5.quilt diff --git a/samba/00_waf_python2.quilt b/samba/00_waf_python2.quilt index d2755fd..45682d8 100644 --- a/samba/00_waf_python2.quilt +++ b/samba/00_waf_python2.quilt @@ -4,8 +4,8 @@ @conf def define(self, key, val, quote=True, comment=None): -+ if isinstance(key, unicode): -+ key = str(key) ++ if not isinstance(key, str) and not isinstance(key, bytes): ++ key = key.encode('utf-8') assert key and isinstance(key, str) if val is None: diff --git a/samba/40_samba3upgrade.quilt b/samba/40_samba3upgrade.quilt index b23a985..b07005b 100644 --- a/samba/40_samba3upgrade.quilt +++ b/samba/40_samba3upgrade.quilt @@ -29,9 +29,9 @@ # In a lot of Samba3 databases, aliases are marked as well known groups - (group_dom_sid, rid) = groupmap.sid.split() + try: -+ (group_dom_sid, rid) = groupmap.sid.split() ++ (group_dom_sid, rid) = groupmap.sid.split() + except: -+ logger.warn('Failed to split sid for %s' % groupmap.nt_name) ++ logger.warn('Failed to split sid for %s' % (groupmap.nt_name,)) + return if (group_dom_sid != security.dom_sid(security.SID_BUILTIN)): return @@ -71,14 +71,14 @@ - if sid == domainsid: - if rid >= next_rid: - next_rid = rid + 1 -+ logger.warn("GROUP '%s'", group.nt_name) -+ logger.warn("GROUP SID '%s'", group.sid) ++ logger.warn("GROUP '%s'", (group.nt_name,)) ++ logger.warn("GROUP SID '%s'", (group.sid,)) + try: + sid, rid = group.sid.split() + if sid == domainsid: + if rid >= next_rid: + next_rid = rid + 1 -+ except: ++ except Exception: + logger.warn("FAILED to get SID/rid") + continue @@ -104,15 +104,15 @@ except ldb.LdbError as e: - raise ProvisioningError("Could not open ldb connection to %s, the error message is: %s" % (url, e)) + logger.warning("Could not open ldb connection to %s, the error message is: %s\nTrying to dig.", url, e) -+ from urlparse import urlparse ++ from urlparse import urlparse # FIXME: python3 + import subprocess + url_hostname = urlparse(url).hostname + p1 = subprocess.Popen(["dig", "@localhost", url_hostname, "+short"], stdout=subprocess.PIPE) + (stdout, stderr) = p1.communicate() + if stdout: -+ ldb_object = Ldb(url.replace(url_hostname, stdout.rstrip('\n')), credentials=creds) ++ ldb_object = Ldb(url.replace(url_hostname, stdout.rstrip('\n')), credentials=creds) + else: -+ raise ProvisioningError("Could not open ldb connection to %s, the error message is: %s" % (url, e)) ++ raise ProvisioningError("Could not open ldb connection to %s, the error message is: %s" % (url, e)) else: break logger.info("Exporting posix attributes") diff --git a/samba/44_upgrade_debug.quilt b/samba/44_upgrade_debug.quilt index e549076..931a873 100644 --- a/samba/44_upgrade_debug.quilt +++ b/samba/44_upgrade_debug.quilt @@ -5,8 +5,8 @@ # Ignore uninitialized groups (gid = -1) if g.gid != -1: + try: -+ print('Importing group: %s' % g.nt_name) -+ except: ++ print('Importing group: %s' % (g.nt_name,)) ++ except Exception: + print('Importing group: ') add_group_from_mapping_entry(result.samdb, g, logger) add_ad_posix_idmap_entry(result.samdb, g.sid, g.gid, "ID_TYPE_GID", logger) @@ -16,8 +16,8 @@ logger.warn('User root has been kept in the directory, it should be removed in favour of the Administrator user') + try: -+ print('Importing user: %s' % username) -+ except: ++ print('Importing user: %s' % (username,)) ++ except Exception: + print('Importing user: ') s4_passdb.add_sam_account(userdata[username]) if username in uids: diff --git a/samba/96_dnsupdate_exclude_interfaces.quilt b/samba/96_dnsupdate_exclude_interfaces.quilt index 2ec86eb..c398b5b 100644 --- a/samba/96_dnsupdate_exclude_interfaces.quilt +++ b/samba/96_dnsupdate_exclude_interfaces.quilt @@ -42,14 +42,14 @@ It can be used on an UCS system in the following way: +exclude_interfaces = ucr.get('samba/register/exclude/interfaces') +if exclude_interfaces: + if opts.verbose: -+ print 'Exclude the following interfaces: %s' % exclude_interfaces ++ print('Exclude the following interfaces: %s' % exclude_interfaces) + for exclude_interface in exclude_interfaces.split(' '): + exclude_ips = get_ip_address(exclude_interface) + if exclude_ips: + IPs = [ip for ip in IPs if ip not in exclude_ips] + if opts.verbose: -+ print 'Exclude the following IP addresses: %s' % (exclude_ips,) -+ ++ print('Exclude the following IP addresses: %s' % (exclude_ips,)) ++ if opts.local: nsupdate_cmd = ['nsupdate','-l'] opts.nocreds = True diff --git a/samba/97_Bug-44282-fix-LA-vs-DA-in-samba-tool-ntacl-syvolcheck.quilt b/samba/97_Bug-44282-fix-LA-vs-DA-in-samba-tool-ntacl-syvolcheck.quilt index b8689ef..b38dad3 100644 --- a/samba/97_Bug-44282-fix-LA-vs-DA-in-samba-tool-ntacl-syvolcheck.quilt +++ b/samba/97_Bug-44282-fix-LA-vs-DA-in-samba-tool-ntacl-syvolcheck.quilt @@ -7,14 +7,14 @@ - if fsacl_sddl != acl: - raise ProvisioningError('%s ACL on GPO directory %s %s does not match expected value %s from GPO object' % (acl_type(direct_db_access), path, fsacl_sddl, acl)) + -+ ## Sanitize "domainsid" to be a security.dom_sid ++ # Sanitize "domainsid" to be a security.dom_sid + if isinstance(domainsid, str): + domainsid = security.dom_sid(domainsid) + -+ ## If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) ++ # If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) + if fsacl.owner_sid == security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINISTRATOR)): + fsacl.owner_sid = security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINS)) -+ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) ++ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) + + + if fsacl_sddl_mapped != acl: @@ -29,10 +29,10 @@ - if fsacl_sddl != acl: - raise ProvisioningError('%s ACL on GPO file %s %s does not match expected value %s from GPO object' % (acl_type(direct_db_access), os.path.join(root, name), fsacl_sddl, acl)) + -+ ## If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) ++ # If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) + if fsacl.owner_sid == security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINISTRATOR)): + fsacl.owner_sid = security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINS)) -+ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) ++ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) + + if fsacl_sddl_mapped != acl: + raise ProvisioningError('%s NTACL of GPO file %s %s does not match value %s expected from GPO object' % (acl_type(direct_db_access), os.path.join(root, name), fsacl_sddl_mapped, acl)) @@ -46,10 +46,10 @@ - if fsacl_sddl != acl: - raise ProvisioningError('%s ACL on GPO directory %s %s does not match expected value %s from GPO object' % (acl_type(direct_db_access), os.path.join(root, name), fsacl_sddl, acl)) + -+ ## If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) ++ # If LA in filesystem then treat it as DA for comparison (reversing what samba.ntacls.setntacl did) + if fsacl.owner_sid == security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINISTRATOR)): + fsacl.owner_sid = security.dom_sid("%s-%d" % (domainsid, security.DOMAIN_RID_ADMINS)) -+ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) ++ fsacl_sddl_mapped = fsacl.as_sddl(domainsid) + + if fsacl_sddl_mapped != acl: + raise ProvisioningError('%s NTACL of GPO directory %s %s does not match value %s expected from GPO object' % (acl_type(direct_db_access), os.path.join(root, name), fsacl_sddl_mapped, acl)) diff --git a/samba/97_Bug-46643-add-sysvolcheck-option-mask-msad-differences.quilt b/samba/97_Bug-46643-add-sysvolcheck-option-mask-msad-differences.quilt index d54b480..fdfa335 100644 --- a/samba/97_Bug-46643-add-sysvolcheck-option-mask-msad-differences.quilt +++ b/samba/97_Bug-46643-add-sysvolcheck-option-mask-msad-differences.quilt @@ -7,7 +7,7 @@ - def run(self, credopts=None, sambaopts=None, versionopts=None): + takes_options = [ + Option("--mask-msad-differences", help="Ignore standard differences to MS AD ACLs", action="store_true"), -+ ] ++ ] + def run(self, mask_msad_differences=False, credopts=None, sambaopts=None, versionopts=None): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) @@ -31,16 +31,16 @@ + try: + fsacl = getntacl(lp, path, direct_db_access=direct_db_access, service=SYSVOL_SERVICE) + fsacl_sddl = fsacl.as_sddl(domainsid) -+ except TypeError as error: ++ except TypeError: + return + except NTSTATUSError as error: + if check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): -+ print "ERROR: File not found", path ++ print("ERROR: File not found", path) + return + else: + raise + -+ ## Sanitize "domainsid" to be a security.dom_sid ++ # Sanitize "domainsid" to be a security.dom_sid + if isinstance(domainsid, str): + domainsid = security.dom_sid(domainsid) + @@ -117,16 +117,16 @@ + try: + ## also filter out ACE for CO, not present for GPT.INI of new GPOs created via GPMC + sd_masked.dacl_del(CO) -+ except: ++ except Exception: + pass + acl_expected_for_file = sd_masked.as_sddl(domainsid) + + sd_masked.type &= ~ security.SEC_DESC_DACL_AUTO_INHERIT_REQ + acl_expected_for_file_without_AR = sd_masked.as_sddl(domainsid) + -+ #print "ACL GPO: %s" % acl_expected_for_gpo -+ #print "ACL DIR: %s" % acl_expected_for_subdir -+ #print "ACL FILE: %s" % acl_expected_for_file ++ #print("ACL GPO: %s" % acl_expected_for_gpo) ++ #print("ACL DIR: %s" % acl_expected_for_subdir) ++ #print("ACL FILE: %s" % acl_expected_for_file) + + for root, dirs, files in os.walk(path, topdown=False): + for name in files: diff --git a/samba/97_Bug-47583-make-samba-tool-ntacl-sysvolcheck-show-the-file-path-in-error-message.quilt b/samba/97_Bug-47583-make-samba-tool-ntacl-sysvolcheck-show-the-file-path-in-error-message.quilt index 93dea7d..9ac9c59 100644 --- a/samba/97_Bug-47583-make-samba-tool-ntacl-sysvolcheck-show-the-file-path-in-error-message.quilt +++ b/samba/97_Bug-47583-make-samba-tool-ntacl-sysvolcheck-show-the-file-path-in-error-message.quilt @@ -43,16 +43,16 @@ index fa4cc59..c249df4 100644 - + try: + fsacl = getntacl(lp, path, direct_db_access=direct_db_access, service=SYSVOL_SERVICE) -+ fsacl_sddl = fsacl.as_sddl(domainsid) ++ fsacl_sddl = fsacl.as_sddl(domainsid) + except TypeError as error: + return + except NTSTATUSError as error: + if check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): -+ print "ERROR: File not found", path ++ print("ERROR: File not found", path) + return + else: + raise - ## Sanitize "domainsid" to be a security.dom_sid + # Sanitize "domainsid" to be a security.dom_sid if isinstance(domainsid, str): domainsid = security.dom_sid(domainsid) -- diff --git a/samba/97_bug29665.quilt b/samba/97_bug29665.quilt index 5221388..85b6d48 100644 --- a/samba/97_bug29665.quilt +++ b/samba/97_bug29665.quilt @@ -106,7 +106,7 @@ + raise CommandError("Either the username or '--filter' must be specified!") + + if filter is None: -+ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username)) ++ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username),) # FIXME: ldap filter escaping + + lp = sambaopts.get_loadparm() + creds = credopts.get_credentials(lp) @@ -119,7 +119,7 @@ + expression=filter, + attrs=["userPrincipalName"]) + -+ if (len(res) == 0): ++ if len(res) == 0: + raise CommandError("Failed to find user '%s': %s" % (username or filter, msg)) + + if "userPrincipalName" in res[0]: @@ -150,7 +150,7 @@ + "sambaopts": options.SambaOptions, + "credopts": options.CredentialsOptions, + "versionopts": options.VersionOptions, -+ } ++ } + + takes_options = [ + Option("-H", "--URL", help="LDB URL for database or target server", type=str, @@ -165,7 +165,7 @@ + raise CommandError("Either the username or '--filter' must be specified!") + + if filter is None: -+ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username)) ++ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username),) # FIXME: ldap filter escaping + + lp = sambaopts.get_loadparm() + creds = credopts.get_credentials(lp) @@ -178,7 +178,7 @@ + + try: + samdb.setupn(filter, upn) -+ except Exception, msg: ++ except Exception as msg: + raise CommandError("Failed to set userPrincipalName for user '%s': %s" % ( + username or filter, msg)) + self.outf.write("Set UserPrincipalName %s for user '%s' .\n" % ( @@ -221,7 +221,7 @@ + raise CommandError("Either the username or '--filter' must be specified!") + + if filter is None: -+ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username)) ++ filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username),) # FIXME: ldap filter escaping + + lp = sambaopts.get_loadparm() + creds = credopts.get_credentials(lp) @@ -231,7 +231,7 @@ + + try: + samdb.delupn(filter) -+ except Exception, msg: ++ except Exception as msg: + raise CommandError("Failed to remove userPrincipalName for user '%s': %s" % ( + username or filter, msg)) + @@ -514,7 +514,7 @@ + + found = self._find_user(user["name"]) + -+ self.assertEquals("%s" % found.get("userPrincipalName"), "%s" % upn) ++ self.assertEquals("%s" % found.get("userPrincipalName"), "%s" % (upn,)) + + def test_getpwent(self): @@ -545,16 +545,16 @@ + + try: + m = ldb.Message() -+ m.dn = ldb.Dn(samdb, "" % str(sid)) ++ m.dn = ldb.Dn(samdb, "" % (sid,)) + if xid_type == "ID_TYPE_UID": + m['userPrincipalName'] = ldb.MessageElement( + str(user_principal_name), ldb.FLAG_MOD_REPLACE, 'userPrincipalName') + + samdb.modify(m) -+ except ldb.LdbError, e: ++ except ldb.LdbError as e: + logger.warn( + 'Could not add userPrincipalName attr for AD entry for sid=%s, (%s)', -+ str(sid), str(e)) ++ sid, e) + def add_ad_posix_idmap_entry(samdb, sid, xid, xid_type, logger): @@ -572,7 +572,7 @@ (username in shells) and (shells[username] is not None) and \ (username in pgids) and (pgids[username] is not None): add_posix_attrs(samdb=result.samdb, sid=userdata[username].user_sid, name=username, nisdomain=domainname.lower(), xid_type="ID_TYPE_UID", home=homes[username], shell=shells[username], pgid=pgids[username], logger=logger) -+ if ( no_upn is not True ) and ( userdata[username].acct_ctrl & 16 ): ++ if (no_upn is not True) and (userdata[username].acct_ctrl & 16): + add_userPrincipalName(samdb=result.samdb, sid=userdata[username].user_sid, name=username, realm=realm, xid_type="ID_TYPE_UID", logger=logger) logger.info("Adding users to groups") diff --git a/samba/97_bug33616-samba-tool-dbcheck-handle-name-conflict-objects.quilt b/samba/97_bug33616-samba-tool-dbcheck-handle-name-conflict-objects.quilt index 99d19ec..76a52cb 100644 --- a/samba/97_bug33616-samba-tool-dbcheck-handle-name-conflict-objects.quilt +++ b/samba/97_bug33616-samba-tool-dbcheck-handle-name-conflict-objects.quilt @@ -39,10 +39,10 @@ Date: Tue Apr 1 12:16:10 2014 +0200 + print(msg) + for ch in sorted(choice.keys()): + print("[%s] %s" % (ch, choice[ch])) -+ v = raw_input("What do you want to do %s? " % sorted(choice.keys())) ++ v = raw_input("What do you want to do %s? " % sorted(choice.keys())) # FIXME: Python3 + v = v.upper() -+ if not v in map(str, choice.keys()): -+ print("Unknown response '%s'" % v) ++ if v not in map(str, choice.keys()): ++ print("Unknown response '%s'" % (v,)) + else: + return v + @@ -58,11 +58,11 @@ Date: Tue Apr 1 12:16:10 2014 +0200 + + try: + result = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE) -+ except ldb.LdbError, (enum, estr): -+ if enum != ldb.ERR_NO_SUCH_OBJECT: ++ except ldb.LdbError as exc: ++ if exc.args[0] != ldb.ERR_NO_SUCH_OBJECT: + raise + result = () -+ if not len(result) == 1: ++ if len(result) != 1: + return + self.report("WARNING: Found name conflict object!") + for line in self.samdb.write_ldif(result[0], ldb.CHANGETYPE_NONE).split("\n"): @@ -74,31 +74,31 @@ Date: Tue Apr 1 12:16:10 2014 +0200 + dn_non_cnf = cn + "," + base + try: + result = self.samdb.search(base=dn_non_cnf, scope=ldb.SCOPE_BASE) -+ except ldb.LdbError, (enum, estr): -+ if enum != ldb.ERR_NO_SUCH_OBJECT: ++ except ldb.LdbError as exc: ++ if exc.args[0] != ldb.ERR_NO_SUCH_OBJECT: + raise + result = () + -+ msg = "Delete the conflict object or rename it to %s?" % dn_non_cnf ++ msg = "Delete the conflict object or rename it to %s?" % (dn_non_cnf,) + choice = { -+ "1" : "delete the conflict object %s" % dn, ++ "1" : "delete the conflict object %s" % (dn,), + "2" : "rename the conflict object %s to %s" % (dn, dn_non_cnf), -+ "3" : "none", ++ "3" : "none", + } + if len(result) == 1: + self.report("Found corresponding non-conflict object!") + for line in self.samdb.write_ldif(result[0], ldb.CHANGETYPE_NONE).split("\n"): -+ self.report(" %s" % line) -+ msg = "Delete the conflict object or delete the non-conflict object and rename the conflict object to %s?" % dn_non_cnf ++ self.report(" %s" % (line,)) ++ msg = "Delete the conflict object or delete the non-conflict object and rename the conflict object to %s?" % (dn_non_cnf,) + choice["2"] = "delete the non-conflict object %s and rename the conflict object to %s" % (dn_non_cnf, dn_non_cnf) + answer = self.question(msg, choice, default="1") + if answer == "1": -+ if self.do_delete(dn, [], "Failed to delete DN %s" % dn): -+ self.report("Removed DN %s" % dn) ++ if self.do_delete(dn, [], "Failed to delete DN %s" % (dn,)): ++ self.report("Removed DN %s" % (dn,)) + elif answer == "2": + if len(result) == 1: -+ if self.do_delete(result[0].dn, [], "Failed to delete DN %s" % result[0].dn): -+ self.report("Removed DN %s" % result[0].dn) ++ if self.do_delete(result[0].dn, [], "Failed to delete DN %s" % (result[0].dn,)): ++ self.report("Removed DN %s" % (result[0].dn,)) + to_rdn, to_base = dn_non_cnf.split(",", 1) + to_rdn += "," + if self.do_rename(dn, to_rdn, to_base, [], "Failed to rename object %s into %s" % (dn, to_rdn + to_base)): @@ -112,7 +112,7 @@ Date: Tue Apr 1 12:16:10 2014 +0200 error_count += 1 + if self.check_for_conflicts: -+ if not "\\0ADEL" in str(dn).upper(): ++ if "\\0ADEL" not in str(dn).upper(): + if "\\0ACNF" in str(dn).upper(): + self.handle_conflicts(dn) + diff --git a/samba/99_python3-samba-1.patch b/samba/99_python3-samba-1.patch new file mode 100644 index 0000000..d96696d --- /dev/null +++ b/samba/99_python3-samba-1.patch @@ -0,0 +1,195 @@ +commit b6a3f4baf2c28996072ca3c4f10d9f00a8f1e380 +Author: Mathieu Parent +Date: Thu Aug 29 10:47:51 2019 +0200 + + Move to Python3 (from Ubuntu) + +diff --git debian/control debian/control +index 7aa228e..babcd50 100644 +--- debian/control ++++ debian/control +@@ -56,6 +56,14 @@ Build-Depends: bison, + python-tdb (>= 1.3.16~), + python-testtools, + python3, ++ python3-all-dev, ++ python3-dnspython, ++ python3-etcd, ++ python3-ldb, ++ python3-ldb-dev, ++ python3-talloc-dev, ++ python3-tdb, ++ python3-testtools, + xfslibs-dev [linux-any], + xsltproc, + zlib1g-dev (>= 1:1.2.3) +@@ -456,3 +464,24 @@ Description: clustered database to store temporary data + * CTDB supports a system of application specific management scripts, allowing + applications that depend on network or filesystem resources to be managed in + a highly available manner on a cluster. ++ ++Package: python3-samba ++Pre-Depends: ${misc:Pre-Depends} ++Architecture: any ++Section: python ++Provides: ${python3:Provides} ++Suggests: python3-gpgme ++Depends: python3-crypto, ++ python3-ldb, ++ python3-tdb, ++ samba-libs (= ${binary:Version}), ++ ${misc:Depends}, ++ ${python3:Depends}, ++ ${shlibs:Depends} ++Description: Python bindings for Samba ++ Samba is an implementation of the SMB/CIFS protocol for Unix systems, ++ providing support for cross-platform file sharing with Microsoft Windows, OS X, ++ and other Unix systems. Samba can also function as a domain controller ++ or member server in both NT4-style and Active Directory domains. ++ . ++ This package contains Python bindings for most Samba libraries. +diff --git debian/python-samba.install debian/python-samba.install +index 353fe0d..490ac41 100644 +--- debian/python-samba.install ++++ debian/python-samba.install +@@ -1 +1 @@ +-usr/lib/python*/*-packages/samba ++usr/lib/python2*/*-packages/samba +diff --git debian/python3-samba.install debian/python3-samba.install +new file mode 100644 +index 0000000..5908173 +--- /dev/null ++++ debian/python3-samba.install +@@ -0,0 +1 @@ ++usr/lib/python3*/*-packages/samba +diff --git debian/python3-samba.lintian-overrides debian/python3-samba.lintian-overrides +new file mode 100644 +index 0000000..89facf8 +--- /dev/null ++++ debian/python3-samba.lintian-overrides +@@ -0,0 +1,2 @@ ++# False positives, see #896012 ++python3-samba: library-not-linked-against-libc * +diff --git debian/rules debian/rules +index 36acb1c..456787f 100755 +--- debian/rules ++++ debian/rules +@@ -15,12 +15,12 @@ PYVERS=$(shell pyversions -vr) + + LDB_VERSION = $(shell pkg-config --modversion ldb) + LDB_EPOCH = $(shell dpkg-query -f '$${Version}' -W libldb-dev | sed 's/:.*//') +-LDB_NEXT_VERSION = $(shell python -c "x = '$(LDB_VERSION)'.split('.'); x[-1] = str(int(x[-1])+1); print '.'.join(x)") ++LDB_NEXT_VERSION = $(shell python3 -c "x = '$(LDB_VERSION)'.split('.'); x[-1] = str(int(x[-1])+1); print('.'.join(x))") + # samba ships ldb modules, which are specific to the ldb version, so we need a + # strict dependency on the upstream ldb version + # this also mean samba needs a rebuild when the upstream ldb version changes + LDB_DEPENDS = "libldb1 (<< $(LDB_EPOCH):$(LDB_NEXT_VERSION)~), libldb1 (>> $(LDB_EPOCH):$(LDB_VERSION)~)" +-export PYSHORT=$(shell pyversions -d) ++export PYSHORT=python3 + export PYTHON=$(shell which $(PYSHORT)) + export PYTHON_CONFIG="$(PYTHON)-config" + WAF = $(PYTHON) ./buildtools/bin/waf -v +@@ -76,6 +76,7 @@ conf_args = \ + --minimum-library-version="$(shell ./debian/autodeps.py --minimum-library-version)" \ + --with-cluster-support \ + --with-socketpath=/var/run/ctdb/ctdbd.socket \ ++ --extra-python=/usr/bin/python2 \ + --with-logdir=/var/log/ctdb + + ifeq ($(DEB_HOST_ARCH_OS), linux) +@@ -92,10 +93,10 @@ ifeq ($(DEB_HOST_ARCH_CPU), amd64) + endif + + %: +- dh $* --with python2 ++ dh $* --with python2,python3 + + override_dh_auto_configure: +- $(WAF) configure $(conf_args) ++ PYTHON="" $(WAF) configure $(conf_args) + + override_dh_auto_clean: + -$(WAF) clean +@@ -134,7 +135,7 @@ override_dh_install: + # get list of files in build log + find ${DESTDIR} + # Included in python-tevent +- rm $(DESTDIR)/usr/lib/python*/*-packages/_tevent.so ++ rm $(DESTDIR)/usr/lib/python*/*-packages/_tevent.* + rm $(DESTDIR)/usr/lib/python*/*-packages/tevent.py + # Already documented in debian/copyright + -rm $(DESTDIR)/usr/share/samba/setup/ad-schema/licence.txt +@@ -160,9 +161,11 @@ override_dh_install: + install -m755 debian/samba-common.dhcp $(DESTDIR)/etc/dhcp/dhclient-enter-hooks.d/samba + # Install other stuff not installed by "make install" + install -m 0755 debian/mksmbpasswd.awk $(DESTDIR)/usr/sbin/mksmbpasswd ++ # This moves the dckeytab module to the samba package in order to avoid ++ # a circular dependency between python3-samba, samba and samba-common-bin + mkdir -p debian/samba/usr/lib/$(PYSHORT)/dist-packages/samba +- mv $(DESTDIR)/usr/lib/$(PYSHORT)/dist-packages/samba/dckeytab.so \ +- debian/samba/usr/lib/$(PYSHORT)/dist-packages/samba/dckeytab.so ++ mv $(DESTDIR)/usr/lib/$(PYSHORT)/dist-packages/samba/dckeytab*.so \ ++ debian/samba/usr/lib/$(PYSHORT)/dist-packages/samba/ + mkdir -p $(DESTDIR)/etc/ufw/applications.d + install -m644 debian/samba.ufw.profile $(DESTDIR)/etc/ufw/applications.d/samba + # use upstream version of smb.conf.5 if there is no built version +diff --git debian/samba-dev.install debian/samba-dev.install +index 6a8dc5f..351b7e1 100644 +--- debian/samba-dev.install ++++ debian/samba-dev.install +@@ -93,6 +93,7 @@ usr/lib/*/libsamba-errors.so + usr/lib/*/libsamba-hostconfig.so + usr/lib/*/libsamba-passdb.so + usr/lib/*/libsamba-policy.so ++usr/lib/*/libsamba-policy.cpython-*.so + usr/lib/*/libsamba-util.so + usr/lib/*/libsamdb.so + usr/lib/*/libsmbconf.so +@@ -109,5 +110,6 @@ usr/lib/*/pkgconfig/netapi.pc + usr/lib/*/pkgconfig/samba-credentials.pc + usr/lib/*/pkgconfig/samba-hostconfig.pc + usr/lib/*/pkgconfig/samba-policy.pc ++usr/lib/*/pkgconfig/samba-policy.cpython-*.pc + usr/lib/*/pkgconfig/samba-util.pc + usr/lib/*/pkgconfig/samdb.pc +diff --git debian/samba-libs.install debian/samba-libs.install +index a2742f0..27ddc2f 100644 +--- debian/samba-libs.install ++++ debian/samba-libs.install +@@ -12,6 +12,7 @@ usr/lib/*/libsamba-errors.so.* + usr/lib/*/libsamba-hostconfig.so.* + usr/lib/*/libsamba-passdb.so.* + usr/lib/*/libsamba-policy.so.* ++usr/lib/*/libsamba-policy.cpython-*.so.* + usr/lib/*/libsamba-util.so.* + usr/lib/*/libsamdb.so.* + usr/lib/*/libsmbconf.so.0 +@@ -105,6 +106,8 @@ usr/lib/*/samba/libsamba-debug.so.0 + usr/lib/*/samba/libsamba-modules.so.* + usr/lib/*/samba/libsamba-net.so.* + usr/lib/*/samba/libsamba-python.so.0 ++usr/lib/*/samba/libsamba-net.cpython-*.so.* ++usr/lib/*/samba/libsamba-python.cpython-*.so.0 + usr/lib/*/samba/libsamba-security.so.* + usr/lib/*/samba/libsamba-sockets.so.* + usr/lib/*/samba/libsamba3-util.so.* +diff --git debian/samba-libs.lintian-overrides debian/samba-libs.lintian-overrides +index e9f8aed..15dac80 100644 +--- debian/samba-libs.lintian-overrides ++++ debian/samba-libs.lintian-overrides +@@ -1,6 +1,6 @@ + # the samba-libs package contains a number of libraries + # it doesn't make sense to have them in separate packages, as this would + # result in circular dependencies +-samba-libs: package-name-doesnt-match-sonames libdcerpc-binding0 libdcerpc-samr0 libdcerpc-server0 libdcerpc0 libndr-krb5pac0 libndr-nbt0 libndr-standard0 libndr0 libnetapi0 libsamba-credentials0 libsamba-errors1 libsamba-hostconfig0 libsamba-passdb0 libsamba-policy0 libsamba-util0 libsamdb0 libsmbconf0 libsmbldap2 libtevent-util0 ++samba-libs: package-name-doesnt-match-sonames libdcerpc-binding0 libdcerpc-samr0 libdcerpc-server0 libdcerpc0 libndr-krb5pac0 libndr-nbt0 libndr-standard0 libndr0 libnetapi0 libsamba-credentials0 libsamba-errors1 libsamba-hostconfig0 libsamba-passdb0 libsamba-policy0 libsamba-policy.cpython-* libsamba-util0 libsamdb0 libsmbconf0 libsmbldap2 libtevent-util0 + # Embedded Heimdal is patched + samba-libs: embedded-library usr/lib/*/samba/libgssapi-samba4.so.*: heimdal +diff --git debian/tests/python-smoke debian/tests/python-smoke +index 01e6681..31a6be6 100644 +--- debian/tests/python-smoke ++++ debian/tests/python-smoke +@@ -1,2 +1,2 @@ + #!/bin/sh +-python -c 'import samba.samba3' ++python -c 'import samba.samba3' && python3 -c 'import samba.samba3' diff --git a/samba/99_python3-samba-2.patch b/samba/99_python3-samba-2.patch new file mode 100644 index 0000000..482865d --- /dev/null +++ b/samba/99_python3-samba-2.patch @@ -0,0 +1,27 @@ +commit 2b644b748283bde6d384f4abb67886fd0bea7869 +Author: Mathieu Parent +Date: Tue Oct 1 21:04:19 2019 +0200 + + Do not run waf configure in parallel. Fix FTBFS on arm (Closes: #941467) + +diff --git debian/rules debian/rules +index 9710c71b0dc..0a569820b2a 100755 +--- debian/rules ++++ debian/rules +@@ -24,6 +24,7 @@ export PYSHORT=python3 + export PYTHON=$(shell which $(PYSHORT)) + export PYTHON_CONFIG="$(PYTHON)-config" + WAF = $(PYTHON) ./buildtools/bin/waf -v ++WAF_NO_PARALLEL = $(WAF) + + # turn DEB_BUILD_OPTIONS='foo,bar' into DEB_BUILD_OPT_FOO and DEB_BUILD_OPT_BAR + d_b_o:=$(shell echo "$$DEB_BUILD_OPTIONS"|sed 's/[^-[:alnum:]]/ /g'|tr a-z A-Z) +@@ -96,7 +97,7 @@ endif + dh $* --with python2,python3 + + override_dh_auto_configure: +- PYTHON="" $(WAF) configure $(conf_args) ++ PYTHON="" $(WAF_NO_PARALLEL) configure $(conf_args) + + override_dh_auto_clean: + -$(WAF) clean diff --git a/samba/99_python3-samba-3.patch b/samba/99_python3-samba-3.patch new file mode 100644 index 0000000..3ab4a63 --- /dev/null +++ b/samba/99_python3-samba-3.patch @@ -0,0 +1,23 @@ +commit 50178f6cd1de0ef874a32cecec3ea3a7ee5e1da4 +Author: Mathieu Parent +Date: Thu Oct 3 06:58:36 2019 +0200 + + Force one job during configure step with -j 1 (Closes: #941467) + + Not setting -j leads to default which is number of cpus. + + See https://salsa.debian.org/samba-team/samba/blob/478603e68024a9c352072c20e0f4f712dd4c5a1c/third_party/waf/waflib/Options.py#L177-212 + +diff --git debian/rules debian/rules +index 77f48ac5c33..bf9bd0d703d 100755 +--- debian/rules ++++ debian/rules +@@ -24,7 +24,7 @@ export PYSHORT=python3 + export PYTHON=$(shell which $(PYSHORT)) + export PYTHON_CONFIG="$(PYTHON)-config" + WAF = $(PYTHON) ./buildtools/bin/waf -v +-WAF_NO_PARALLEL = $(WAF) ++WAF_NO_PARALLEL = $(WAF) -j 1 + + # turn DEB_BUILD_OPTIONS='foo,bar' into DEB_BUILD_OPT_FOO and DEB_BUILD_OPT_BAR + d_b_o:=$(shell echo "$$DEB_BUILD_OPTIONS"|sed 's/[^-[:alnum:]]/ /g'|tr a-z A-Z) diff --git a/samba/99_python3-samba-4.quilt b/samba/99_python3-samba-4.quilt new file mode 100644 index 0000000..273be70 --- /dev/null +++ b/samba/99_python3-samba-4.quilt @@ -0,0 +1,32 @@ +commit 261ef9d5b62f0d49f858717e6d8b4b41f008efb5 +Author: Stefan Metzmacher +Date: Tue Mar 19 13:16:59 2019 +0100 + + dbcheck: fix the err_empty_attribute() check + + ldb.bytes('') == '' is never True in python3, + we nee ldb.bytes('') == b'' in order to + check that on attribute has an empty value, + that seems to work for python2 and python3. + + BUG: https://bugzilla.samba.org/show_bug.cgi?id=13843 + + Signed-off-by: Stefan Metzmacher + Reviewed-by: Noel Power + + Autobuild-User(master): Stefan Metzmacher + Autobuild-Date(master): Thu Mar 21 18:15:20 UTC 2019 on sn-devel-144 + +diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py +index c4747811c76..a0500c6c578 100644 +--- a/python/samba/dbchecker.py ++++ b/python/samba/dbchecker.py +@@ -2445,7 +2445,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) + + # check for empty attributes + for val in obj[attrname]: +- if val == '': ++ if val == b'': + self.err_empty_attribute(dn, attrname) + error_count += 1 + continue diff --git a/samba/99_python3-samba-5.quilt b/samba/99_python3-samba-5.quilt new file mode 100644 index 0000000..9c10173 --- /dev/null +++ b/samba/99_python3-samba-5.quilt @@ -0,0 +1,14 @@ +diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py +--- a/buildtools/wafsamba/samba_python.py ++++ b/buildtools/wafsamba/samba_python.py +@@ -203,6 +203,10 @@ + copied = ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE') + tuple(extra_env_vars) + for name in copied: + bld.all_envs['extrapython'][name] = bld.all_envs['default'][name] ++ bld.all_envs['extrapython']['INCLUDES_PYEXT'] = ['/usr/include/python2.7'] ++ bld.all_envs['extrapython']['INCLUDES_PYEMBED'] = ['/usr/include/python2.7'] ++ bld.all_envs['extrapython']['LIB_PYEXT'] = [x if x != 'python3.5m' else 'python2.7' for x in bld.all_envs['extrapython']['LIB_PYEXT']] ++ bld.all_envs['extrapython']['LIB_PYEMBED'] = [x if x != 'python3.5m' else 'python2.7' for x in bld.all_envs['extrapython']['LIB_PYEMBED']] + default_env = bld.all_envs['default'] + bld.all_envs['default'] = bld.all_envs['extrapython'] + yield -- 2.11.0