diff --git a/python-ldapdomaindump.changes b/python-ldapdomaindump.changes index 3788501..12c4e5b 100644 --- a/python-ldapdomaindump.changes +++ b/python-ldapdomaindump.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Wed Sep 6 05:58:09 UTC 2023 - Steve Kowalik + +- Add missing Requires on update-alternatives. +- Switch to autosetup and pyproject macros. +- Add patch remove-future-requirement.patch, dropping requirement on future +- Stop using globs in %files. +- dos2unix the unpacked files. + ------------------------------------------------------------------- Thu Jan 5 19:57:29 UTC 2023 - Yogalakshmi Arunachalam diff --git a/python-ldapdomaindump.spec b/python-ldapdomaindump.spec index b067f0c..c22e8ac 100644 --- a/python-ldapdomaindump.spec +++ b/python-ldapdomaindump.spec @@ -17,25 +17,28 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-ldapdomaindump Version: 0.9.4 Release: 0 Summary: Active Directory information dumper via LDAP License: MIT -Group: Development/Languages/Python URL: https://github.com/dirkjanm/ldapdomaindump/ Source: https://files.pythonhosted.org/packages/source/l/ldapdomaindump/ldapdomaindump-%{version}.tar.gz +# PATCH-FIX-UPSTREAM Based on gh#dirkjanm/ldapdomaindump#55 +Patch0: remove-future-requirement.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: dos2unix BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-dnspython -Requires: python-future Requires: python-ldap3 >= 2.5 +Requires(post): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module dnspython} -BuildRequires: %{python_module future} BuildRequires: %{python_module ldap3 >= 2.5} # /SECTION %python_subpackages @@ -44,18 +47,19 @@ BuildRequires: %{python_module ldap3 >= 2.5} Active Directory information dumper via LDAP. %prep -%setup -q -n ldapdomaindump-%{version} +%autosetup -p1 -n ldapdomaindump-%{version} sed -i 's|#!%{_bindir}/env python|#!%{_bindir}/python3|g' \ bin/ldd2pretty \ bin/ldapdomaindump \ bin/ldd2bloodhound sed -i '/^#!\//, 1d' ldapdomaindump/__main__.py +find . -type f -exec dos2unix {} \; %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_clone -a %{buildroot}%{_bindir}/ldapdomaindump %python_clone -a %{buildroot}%{_bindir}/ldd2bloodhound %python_clone -a %{buildroot}%{_bindir}/ldd2pretty @@ -76,6 +80,7 @@ sed -i '/^#!\//, 1d' ldapdomaindump/__main__.py %python_alternative %{_bindir}/ldapdomaindump %python_alternative %{_bindir}/ldd2bloodhound %python_alternative %{_bindir}/ldd2pretty -%{python_sitelib}/ldapdomaindump* +%{python_sitelib}/ldapdomaindump +%{python_sitelib}/ldapdomaindump-%{version}.dist-info %changelog diff --git a/remove-future-requirement.patch b/remove-future-requirement.patch new file mode 100644 index 0000000..1e4d88f --- /dev/null +++ b/remove-future-requirement.patch @@ -0,0 +1,204 @@ +From 413ceec72fb36832b92b7afdeaa7b164ee1837fc Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Wed, 6 Sep 2023 15:45:39 +1000 +Subject: [PATCH] Drop future requirement, require Python 3.6+ + +With Python 2 having been unsupported for two and a half years, it's +past time to remove support for it, and by extension, the future module. +I've switched to Python 3.6 code, and forced that requirement in +setup.py + +Closes #53 +--- + Readme.md | 2 +- + ldapdomaindump/__init__.py | 26 ++++++++++---------------- + ldapdomaindump/convert.py | 8 +++----- + ldapdomaindump/pretty.py | 4 +--- + requirements.txt | 1 - + setup.py | 3 ++- + 6 files changed, 17 insertions(+), 27 deletions(-) + +Index: ldapdomaindump-0.9.4/Readme.md +=================================================================== +--- ldapdomaindump-0.9.4.orig/Readme.md ++++ ldapdomaindump-0.9.4/Readme.md +@@ -25,7 +25,7 @@ As well as two grouped files: + - *domain_computers_by_os*: Domain computers sorted by Operating System + + ## Dependencies and installation +-Requires [ldap3](https://github.com/cannatag/ldap3) > 2.0, [dnspython](https://github.com/rthalley/dnspython) and [future](https://python-future.org/). ldapdomaindump runs on both python 2 and 3. ++Requires [ldap3](https://github.com/cannatag/ldap3) > 2.0 and [dnspython](https://github.com/rthalley/dnspython). ldapdomaindump requires Python 3.6 or greater. + + Dependencies can be installed manually with `pip install ldap3 dnspython future`, but should in most cases be handled by pip when you install the main package either from git or pypi. + +Index: ldapdomaindump-0.9.4/ldapdomaindump/__init__.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/__init__.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/__init__.py +@@ -21,22 +21,16 @@ + # SOFTWARE. + # + #################### +-from __future__ import unicode_literals + import sys, os, re, codecs, json, argparse, getpass, base64 + # import class and constants + from datetime import datetime, timedelta +-try: +- from urllib.parse import quote_plus +-except ImportError: +- from urllib import quote_plus ++from urllib.parse import quote_plus + import ldap3 + from ldap3 import Server, Connection, SIMPLE, SYNC, ALL, SASL, NTLM + from ldap3.core.exceptions import LDAPKeyError, LDAPAttributeError, LDAPCursorError, LDAPInvalidDnError + from ldap3.abstract import attribute, attrDef + from ldap3.utils import dn + from ldap3.protocol.formatters.formatters import format_sid +-from builtins import str +-from future.utils import itervalues, iteritems, native_str + + # dnspython, for resolving hostnames + import dns.resolver +@@ -125,7 +119,7 @@ MINIMAL_USERATTRIBUTES = ['cn', 'name', + MINIMAL_GROUPATTRIBUTES = ['cn', 'name', 'sAMAccountName', 'memberOf', 'description', 'whenCreated', 'whenChanged', 'objectSid', 'distinguishedName', 'objectClass'] + + #Class containing the default config +-class domainDumpConfig(object): ++class domainDumpConfig(): + def __init__(self): + #Base path + self.basepath = '.' +@@ -158,7 +152,7 @@ class domainDumpConfig(object): + self.minimal = False #Only query minimal list of attributes + + #Domaindumper main class +-class domainDumper(object): ++class domainDumper(): + def __init__(self, server, connection, config, root=None): + self.server = server + self.connection = connection +@@ -429,7 +423,7 @@ class domainDumper(object): + rw.generateComputersByOsReport(self) + rw.generateUsersByGroupReport(self) + +-class reportWriter(object): ++class reportWriter(): + def __init__(self, config): + self.config = config + self.dd = None +@@ -474,7 +468,7 @@ class reportWriter(object): + outflags = [] + if attr is None or attr.value is None: + return outflags +- for flag, val in iteritems(flags_def): ++ for flag, val in flags_def.items(): + if int(attr.value) & val: + outflags.append(flag) + return outflags +@@ -484,7 +478,7 @@ class reportWriter(object): + outflags = [] + if attr is None: + return outflags +- for flag, val in iteritems(flags_def): ++ for flag, val in flags_def.items(): + if int(attr.value) == val: + outflags.append(flag) + return outflags +@@ -528,7 +522,7 @@ class reportWriter(object): + #Generate several HTML tables for grouped reports + def generateGroupedHtmlTables(self, groups, attributes): + first = True +- for groupname, members in iteritems(groups): ++ for groupname, members in groups.items(): + yield self.generateHtmlTable(members, attributes, groupname, first, specialGroupsFormat=True) + if first: + first = False +@@ -761,7 +755,7 @@ class reportWriter(object): + #Start of the list + yield '[' + firstGroup = True +- for group in iteritems(groups): ++ for group in groups.items(): + if not firstGroup: + #Separate items + yield ',' +@@ -867,8 +861,8 @@ def main(): + #Main parameters + #maingroup = parser.add_argument_group("Main options") + parser.add_argument("host", type=str, metavar='HOSTNAME', help="Hostname/ip or ldap://host:port connection string to connect to (use ldaps:// to use SSL)") +- parser.add_argument("-u", "--user", type=native_str, metavar='USERNAME', help="DOMAIN\\username for authentication, leave empty for anonymous authentication") +- parser.add_argument("-p", "--password", type=native_str, metavar='PASSWORD', help="Password or LM:NTLM hash, will prompt if not specified") ++ parser.add_argument("-u", "--user", type=str, metavar='USERNAME', help="DOMAIN\\username for authentication, leave empty for anonymous authentication") ++ parser.add_argument("-p", "--password", type=str, metavar='PASSWORD', help="Password or LM:NTLM hash, will prompt if not specified") + parser.add_argument("-at", "--authtype", type=str, choices=['NTLM', 'SIMPLE'], default='NTLM', help="Authentication type (NTLM or SIMPLE, default: NTLM)") + + #Output parameters +Index: ldapdomaindump-0.9.4/ldapdomaindump/convert.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/convert.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/convert.py +@@ -6,13 +6,11 @@ import json + import codecs + import re + from ldapdomaindump import trust_flags, trust_directions +-from builtins import str +-from future.utils import itervalues, iteritems + + logging.basicConfig() + logger = logging.getLogger('ldd2bloodhound') + +-class Utils(object): ++class Utils(): + @staticmethod + def ldap_to_domain(ldap): + return re.sub(',DC=', '.', ldap[ldap.find('DC='):], flags=re.I)[3:] +@@ -27,7 +25,7 @@ class Utils(object): + 'memberOf': groupo['attributes']['memberOf'] if 'memberOf' in groupo['attributes'] else [] + } + +-class BloodHoundConverter(object): ++class BloodHoundConverter(): + def __init__(self): + # Input files + self.computers_files = [] +@@ -87,7 +85,7 @@ class BloodHoundConverter(object): + # Read group mapping - write to csv + # file is already created here, we just append + with codecs.open('group_membership.csv', 'a', 'utf-8') as outfile: +- for group in itervalues(self.groups_by_dn): ++ for group in self.groups_by_dn.values(): + for membergroup in group['memberOf']: + try: + outfile.write('%s,%s,%s\n' % (self.groups_by_dn[membergroup]['principal'], group['principal'], 'group')) +Index: ldapdomaindump-0.9.4/ldapdomaindump/pretty.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/pretty.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/pretty.py +@@ -1,12 +1,10 @@ +-from __future__ import print_function +-from builtins import str + import argparse + import json + import os.path + import re + from time import strftime, gmtime + +-class PrettyOuput(object): ++class PrettyOuput(): + + def d2b(self, a): + tbin = [] +Index: ldapdomaindump-0.9.4/setup.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/setup.py ++++ ldapdomaindump-0.9.4/setup.py +@@ -6,7 +6,8 @@ setup(name='ldapdomaindump', + author_email='dirkjan@sanoweb.nl', + url='https://github.com/dirkjanm/ldapdomaindump/', + packages=['ldapdomaindump'], +- install_requires=['dnspython', 'ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6', 'future'], ++ requires_python=">=3.6", ++ install_requires=['dnspython', 'ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6'], + package_data={'ldapdomaindump': ['style.css']}, + include_package_data=True, + scripts=['bin/ldapdomaindump', 'bin/ldd2bloodhound', 'bin/ldd2pretty'],