Backport patches with Python3 support from upstream

This commit is contained in:
Lukas Slebodnik 2015-01-21 21:14:41 +01:00
parent 781433f093
commit 3412a6a279
6 changed files with 1734 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
From b4e68a8ca2db179f37988df043efe3c6a23d572c Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 9 Feb 2015 16:46:05 +0100
Subject: [PATCH 6/9] SSSDConfig: Remove unused exception name
"except ValueError, e:" was the syntax used for what is normally written
as "except ValueError as e:" in modern Python. The old syntax is still
supported in python2 for backwards compatibility.
This means "except ValueError, KeyError:" is not equivalent to
"except (ValueError, KeyError):" but to "except ValueError as KeyError:"
and variable with name "KeyError" was not used in exception handler.
Resolves:
https://fedorahosted.org/sssd/ticket/2017
Reviewed-by: Petr Viktorin <pviktori@redhat.com>
(cherry picked from commit 1ac368d0962ef8cc83dcd642c7fec8b3cba5b6fe)
---
src/config/SSSDConfig/__init__.py.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index 500bd717fec7abcaafd5153ccca7847b91e208ad..e05c98b6a334893116747968b9ddfabce05fa981 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -525,7 +525,7 @@ class SSSDConfigSchema(SSSDChangeConf):
mandatory,
desc,
[subtype(split_option[DEFAULT])])
- except ValueError, KeyError:
+ except ValueError:
raise ParsingError
else:
try:
@@ -544,7 +544,7 @@ class SSSDConfigSchema(SSSDChangeConf):
mandatory,
desc,
primarytype(split_option[DEFAULT]))
- except ValueError, KeyError:
+ except ValueError:
raise ParsingError
elif optionlen > 4:
@@ -559,7 +559,7 @@ class SSSDConfigSchema(SSSDChangeConf):
else:
newvalue = subtype(x)
fixed_options.extend([newvalue])
- except ValueError, KeyError:
+ except ValueError:
raise ParsingError
else:
fixed_options.extend([x])
--
2.1.0

View File

@ -0,0 +1,276 @@
From d71ad29db423b6d164b346ea3c1baab29d8d8d49 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Thu, 29 Jan 2015 09:46:27 +0100
Subject: [PATCH 7/9] SSSDConfig: Port missing parts to python3
* fix incompatible imports
* fix translation.[u]?gettext
* fix dict method has_key
* fix octal literals PEP 3127
* long is not defined in python3
Resolves:
https://fedorahosted.org/sssd/ticket/2017
Reviewed-by: Petr Viktorin <pviktori@redhat.com>
(cherry picked from commit a71004c112cd5d61d3a9e37a4cfc5760dc9a1cec)
---
src/config/SSSDConfig/__init__.py.in | 41 +++++++++++++++++++-----------------
src/config/SSSDConfigTest.py | 24 ++++++++++-----------
2 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index e05c98b6a334893116747968b9ddfabce05fa981..95b3f0ca190a84ede0ba26ce6dd60262431bb9fa 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -6,9 +6,9 @@ Created on Sep 18, 2009
import os
import gettext
-import exceptions
import re
-from ipachangeconf import SSSDChangeConf
+import sys
+from .ipachangeconf import SSSDChangeConf
# Exceptions
class SSSDConfigException(Exception): pass
@@ -32,7 +32,10 @@ PACKAGE = 'sss_daemon'
LOCALEDIR = '/usr/share/locale'
translation = gettext.translation(PACKAGE, LOCALEDIR, fallback=True)
-_ = translation.ugettext
+if sys.version_info[0] > 2:
+ _ = translation.gettext
+else:
+ _ = translation.ugettext
# TODO: This needs to be made external
option_strings = {
@@ -444,7 +447,7 @@ class SSSDConfigSchema(SSSDChangeConf):
self.type_lookup = {
'bool' : bool,
'int' : int,
- 'long' : long,
+ 'long' : long if sys.version_info[0] == 2 else int,
'float': float,
'str' : str,
'list' : list,
@@ -479,7 +482,7 @@ class SSSDConfigSchema(SSSDChangeConf):
subtype = self.type_lookup[split_option[SUBTYPE]]
mandatory = self.bool_lookup[split_option[MANDATORY]]
- if option_strings.has_key(option['name']):
+ if option['name'] in option_strings:
desc = option_strings[option['name']]
else:
desc = None
@@ -608,7 +611,7 @@ class SSSDConfigSchema(SSSDChangeConf):
splitsection = section['name'].split('/')
if (splitsection[0] == 'provider'):
if(len(splitsection) == 3):
- if not providers.has_key(splitsection[1]):
+ if splitsection[1] not in providers:
providers[splitsection[1]] = []
providers[splitsection[1]].extend([splitsection[2]])
for key in providers.keys():
@@ -672,7 +675,7 @@ class SSSDConfigObject(object):
=== Errors ===
No errors
"""
- if self.options.has_key(optionname):
+ if optionname in self.options:
del self.options[optionname]
class SSSDService(SSSDConfigObject):
@@ -1307,12 +1310,12 @@ class SSSDDomain(SSSDConfigObject):
# We should now have a list of options used only by this
# provider. So we remove them.
for option in options:
- if self.options.has_key(option):
+ if option in self.options:
del self.options[option]
# Remove this provider from the option list
option = '%s_provider' % provider_type
- if self.options.has_key(option):
+ if option in self.options:
del self.options[option]
self.providers.remove((provider, provider_type))
@@ -1450,9 +1453,9 @@ class SSSDConfig(SSSDChangeConf):
outputfile = self.configfile
# open() will raise IOError if it fails
- old_umask = os.umask(0177)
+ old_umask = os.umask(0o177)
of = open(outputfile, "wb")
- output = self.dump(self.opts)
+ output = self.dump(self.opts).encode('utf-8')
of.write(output)
of.close()
os.umask(old_umask)
@@ -1475,7 +1478,7 @@ class SSSDConfig(SSSDChangeConf):
if (self.has_option('sssd', 'services')):
active_services = striplist(self.get('sssd', 'services').split(','))
service_dict = dict.fromkeys(active_services)
- if service_dict.has_key(''):
+ if '' in service_dict:
del service_dict['']
# Remove any entries in this list that don't
@@ -1631,7 +1634,7 @@ class SSSDConfig(SSSDChangeConf):
# This guarantees uniqueness and makes it easy
# to add a new value
service_dict = dict.fromkeys(striplist(item['value'].split(',')))
- if service_dict.has_key(''):
+ if '' in service_dict:
del service_dict['']
# Add a new key for the service being activated
@@ -1672,11 +1675,11 @@ class SSSDConfig(SSSDChangeConf):
# This guarantees uniqueness and makes it easy
# to remove the one unwanted value.
service_dict = dict.fromkeys(striplist(item['value'].split(',')))
- if service_dict.has_key(''):
+ if '' in service_dict:
del service_dict['']
# Remove the unwanted service from the lest
- if service_dict.has_key(name):
+ if name in service_dict:
del service_dict[name]
# Write out the joined keys
@@ -1758,7 +1761,7 @@ class SSSDConfig(SSSDChangeConf):
if (self.has_option('sssd', 'domains')):
active_domains = striplist(self.get('sssd', 'domains').split(','))
domain_dict = dict.fromkeys(active_domains)
- if domain_dict.has_key(''):
+ if '' in domain_dict:
del domain_dict['']
# Remove any entries in this list that don't
@@ -1953,7 +1956,7 @@ class SSSDConfig(SSSDChangeConf):
# This guarantees uniqueness and makes it easy
# to add a new value
domain_dict = dict.fromkeys(striplist(item['value'].split(',')))
- if domain_dict.has_key(''):
+ if '' in domain_dict:
del domain_dict['']
# Add a new key for the domain being activated
@@ -1994,11 +1997,11 @@ class SSSDConfig(SSSDChangeConf):
# This guarantees uniqueness and makes it easy
# to remove the one unwanted value.
domain_dict = dict.fromkeys(striplist(item['value'].split(',')))
- if domain_dict.has_key(''):
+ if '' in domain_dict:
del domain_dict['']
# Remove the unwanted domain from the lest
- if domain_dict.has_key(name):
+ if name in domain_dict:
del domain_dict[name]
# Write out the joined keys
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index bdca8517dedd793af88fdcc0712f7ab620feb228..865079fea295d1ecc89f2c4927f54b7aba0f7567 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -748,12 +748,12 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
# Ensure that all of the expected defaults are there
for provider in control_provider_dict.keys():
for ptype in control_provider_dict[provider]:
- self.assertTrue(providers.has_key(provider))
+ self.assertTrue(provider in providers)
self.assertTrue(ptype in providers[provider])
for provider in providers.keys():
for ptype in providers[provider]:
- self.assertTrue(control_provider_dict.has_key(provider))
+ self.assertTrue(provider in control_provider_dict)
self.assertTrue(ptype in control_provider_dict[provider])
def testListProviderOptions(self):
@@ -1003,7 +1003,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
# Remove the local ID provider and add an LDAP one
# LDAP ID providers can also use the krb5_realm
domain.remove_provider('id')
- self.assertFalse(domain.options.has_key('id_provider'))
+ self.assertFalse('id_provider' in domain.options)
domain.add_provider('ldap', 'id')
@@ -1020,7 +1020,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
domain.remove_provider('id')
self.assertEquals(domain.get_option('krb5_realm'),
'EXAMPLE.COM')
- self.assertFalse(domain.options.has_key('ldap_uri'))
+ self.assertFalse('ldap_uri' in domain.options)
# Put the LOCAL provider back
domain.add_provider('local', 'id')
@@ -1028,7 +1028,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
# Remove the auth domain and verify that the options
# revert to the backup_list
domain.remove_provider('auth')
- self.assertFalse(domain.options.has_key('auth_provider'))
+ self.assertFalse('auth_provider' in domain.options)
options = domain.list_options()
self.assertTrue(type(options) == dict,
@@ -1047,21 +1047,21 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
option)
# Ensure that the krb5_realm option is now gone
- self.assertFalse(domain.options.has_key('krb5_realm'))
+ self.assertFalse('krb5_realm' in domain.options)
# Test removing nonexistent provider - Real
domain.remove_provider('id')
- self.assertFalse(domain.options.has_key('id_provider'))
+ self.assertFalse('id_provider' in domain.options)
# Test removing nonexistent provider - Bad backend type
# Should pass without complaint
domain.remove_provider('id')
- self.assertFalse(domain.options.has_key('id_provider'))
+ self.assertFalse('id_provider' in domain.options)
# Test removing nonexistent provider - Bad provider type
# Should pass without complaint
domain.remove_provider('nosuchprovider')
- self.assertFalse(domain.options.has_key('nosuchprovider_provider'))
+ self.assertFalse('nosuchprovider_provider' in domain.options)
def testGetOption(self):
domain = SSSDConfig.SSSDDomain('sssd', self.schema)
@@ -1367,7 +1367,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
# Positive test - Service with invalid option loads
# but ignores the invalid option
service = sssdconfig.get_service('pam')
- self.assertFalse(service.options.has_key('nosuchoption'))
+ self.assertFalse('nosuchoption' in service.options)
def testNewService(self):
sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
@@ -1598,13 +1598,13 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
# Expected result: Domain is imported, but does not contain the
# unknown provider entry
domain = sssdconfig.get_domain('INVALIDPROVIDER')
- self.assertFalse(domain.options.has_key('chpass_provider'))
+ self.assertFalse('chpass_provider' in domain.options)
# Positive Test - Domain with unknown option
# Expected result: Domain is imported, but does not contain the
# unknown option entry
domain = sssdconfig.get_domain('INVALIDOPTION')
- self.assertFalse(domain.options.has_key('nosuchoption'))
+ self.assertFalse('nosuchoption' in domain.options)
def testNewDomain(self):
sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
--
2.1.0

View File

@ -0,0 +1,112 @@
From 3d992dd766b49a185147b4daa7f919d40f72ac6e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Wed, 28 Jan 2015 16:10:12 +0100
Subject: [PATCH 8/9] Remove strict requirements of python2
* fix hashbangs
* remove strict requirements of python2 in build system
Resolves:
https://fedorahosted.org/sssd/ticket/2017
Reviewed-by: Petr Viktorin <pviktori@redhat.com>
(cherry picked from commit e8058322725ba050014777ee2484f7e833ab1e3a)
Fedora:
Fix patching missing file in tarball
The text leading up to this was:
--------------------------
|diff --git a/src/tests/python-test.py b/src/tests/python-test.py
|index 81e09c4bb96fb710e9e5fbcca051fc2c0581fc60..9c1dd3fca0cceba601aa37b07a9c8a4ca48e0441 100644
|--- a/src/tests/python-test.py
|+++ b/src/tests/python-test.py
--------------------------
---
configure.ac | 1 -
src/config/SSSDConfigTest.py | 2 +-
src/external/python.m4 | 2 +-
src/sbus/sbus_codegen | 2 +-
src/tests/pyhbac-test.py | 2 +-
src/tests/pysss_murmur-test.py | 2 +-
src/tools/sss_obfuscate | 2 +-
7 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index e5ec204ad9671d15deb1830c60168e066a66f198..580add9c90a3abbaaa58762cc0dbde99f47cfc4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -248,7 +248,6 @@ AM_CONDITIONAL([HAVE_MANPAGES], [test "x$HAVE_MANPAGES" != "x"])
AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
if test x$HAVE_PYTHON_BINDINGS != x; then
- PYTHON=python2
AM_PATH_PYTHON([2.4])
AM_CHECK_PYTHON_HEADERS([],
AC_MSG_ERROR([Could not find python headers]))
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index 865079fea295d1ecc89f2c4927f54b7aba0f7567..3a5312ea945b5247c69e97b73565b7061e037b69 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
'''
Created on Sep 18, 2009
diff --git a/src/external/python.m4 b/src/external/python.m4
index 25fc7f3972a0f3e13b78160af20a7bde32ab9aec..a1bd87a0ee3a56ddd25c4aba7687ffc7540b4ec2 100644
--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -9,7 +9,7 @@ AC_DEFUN([AM_PYTHON_CONFIG],
dnl We need to check for python build flags using distutils.sysconfig
dnl We cannot use python-config, as it was not available on older
dnl versions of python
- AC_PATH_PROG(PYTHON, python2)
+ AC_PATH_PROG(PYTHON, python)
AC_MSG_CHECKING([for working python])
if test -x "$PYTHON"; then
PYTHON_CFLAGS="`$PYTHON -c \"from distutils import sysconfig; \
diff --git a/src/sbus/sbus_codegen b/src/sbus/sbus_codegen
index b4e63f33e6e5ef9fb56646142a29c97d35ca3ebf..6a96c40f5c2fdc95c9ed1238f53d0f9b9349fb98 100755
--- a/src/sbus/sbus_codegen
+++ b/src/sbus/sbus_codegen
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
#
# Authors:
diff --git a/src/tests/pyhbac-test.py b/src/tests/pyhbac-test.py
index b7f27026b6d1ca12a0759c09e31e1f2c2a2c484c..0abc5703dedb2466b4d99718b5b524951b8af95c 100755
--- a/src/tests/pyhbac-test.py
+++ b/src/tests/pyhbac-test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
from __future__ import print_function
import unittest
diff --git a/src/tests/pysss_murmur-test.py b/src/tests/pysss_murmur-test.py
index 41cb350f7b1fe1d82a5977eb66233ea2b38441ec..0b28f45e67cb4b033516a585867085dba7b412e6 100755
--- a/src/tests/pysss_murmur-test.py
+++ b/src/tests/pysss_murmur-test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
# SSSD
#
# Unit tests for pysss_murmur
diff --git a/src/tools/sss_obfuscate b/src/tools/sss_obfuscate
index 86e7daa1f626c76bdd54f5a4a37bde35b32eba1f..fbea1213d8f7e99ab3b1a6d7d24accf8a6194094 100644
--- a/src/tools/sss_obfuscate
+++ b/src/tools/sss_obfuscate
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
import sys
from optparse import OptionParser
--
2.1.0

View File

@ -0,0 +1,81 @@
From 4613c38c5a0fda122380074cade3aa700a6367f2 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Thu, 29 Jan 2015 10:32:23 +0100
Subject: [PATCH 9/9] sbus_codegen: Port to python3
Resolves:
https://fedorahosted.org/sssd/ticket/2017
Reviewed-by: Petr Viktorin <pviktori@redhat.com>
---
src/sbus/sbus_codegen | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/sbus/sbus_codegen b/src/sbus/sbus_codegen
index 6a96c40f5c2fdc95c9ed1238f53d0f9b9349fb98..d12b07d09923e3f5482178077ded9df11036c91c 100755
--- a/src/sbus/sbus_codegen
+++ b/src/sbus/sbus_codegen
@@ -60,14 +60,19 @@
# to generate for a given interface or method. By default the codegen will
# build up a symbol name from the DBus name.
#
+from __future__ import print_function
import optparse
import os
import re
-import StringIO
import sys
import xml.parsers.expat
+if sys.version_info[0] > 2:
+ import io as StringIO
+else:
+ import StringIO
+
# -----------------------------------------------------------------------------
# Objects
@@ -765,13 +770,13 @@ class DBusXMLParser:
self.arg_count = 0
try:
- with open(filename, "r") as f:
+ with open(filename, "rb") as f:
parser.ParseFile(f)
- except DBusXmlException, ex:
+ except DBusXmlException as ex:
ex.line = parser.CurrentLineNumber
ex.file = filename
raise
- except xml.parsers.expat.ExpatError, ex:
+ except xml.parsers.expat.ExpatError as ex:
exc = DBusXmlException(str(ex))
exc.line = ex.lineno
exc.file = filename
@@ -895,11 +900,11 @@ def parse_options():
(options, args) = parser.parse_args()
if not args:
- print >> sys.stderr, "sbus_codegen: no input file specified"
+ print("sbus_codegen: no input file specified", file=sys.stderr)
sys.exit(2)
if options.mode not in ["header", "source"]:
- print >> sys.stderr, "sbus_codegen: specify --mode=header or --mode=source"
+ print("sbus_codegen: specify --mode=header or --mode=source", file=sys.stderr)
return options, args
@@ -928,6 +933,6 @@ def main():
if __name__ == "__main__":
try:
main()
- except DBusXmlException, ex:
- print >> sys.stderr, str(ex)
+ except DBusXmlException as ex:
+ print(str(ex), file=sys.stderr)
sys.exit(1)
--
2.1.0

View File

@ -27,7 +27,7 @@
Name: sssd
Version: 1.12.3
Release: 6%{?dist}
Release: 7%{?dist}
Group: Applications/System
Summary: System Security Services Daemon
License: GPLv3+
@ -40,6 +40,11 @@ Patch0001: 0001-logrotate-Fix-warning-file-size-changed-while-zippin.patch
Patch0002: 0002-MAN-dyndns_iface-supports-only-one-interface.patch
Patch0003: 0003-krb5-fix-entry-order-in-MEMORY-keytab.patch
Patch0004: 0004-MONITOR-Fix-double-free.patch
Patch0005: 0005-Python3-support-in-SSSD.patch
Patch0006: 0006-SSSDConfig-Remove-unused-exception-name.patch
Patch0007: 0007-SSSDConfig-Port-missing-parts-to-python3.patch
Patch0008: 0008-Remove-strict-requirements-of-python2.patch
Patch0009: 0009-sbus_codegen-Port-to-python3.patch
### Dependencies ###
Requires: sssd-common = %{version}-%{release}
@ -887,6 +892,9 @@ if [ $1 -eq 0 ]; then
fi
%changelog
* Sat Feb 14 2015 Lukas Slebodnik <lslebodn@redhat.com> - 1.12.3-7
- Backport patches with Python3 support from upstream
* Thu Feb 12 2015 Lukas Slebodnik <lslebodn@redhat.com> - 1.12.3-6
- Fix double free in monitor
- Resolves: rhbz#1186887 [abrt] sssd-common: talloc_abort():
@ -902,7 +910,7 @@ fi
* Mon Jan 19 2015 Lukas Slebodnik <lslebodn@redhat.com> - 1.12.3-3
- Apply a number of patches from upstream to fix issues found 1.12.3
- Resolves: rhbz#1176373 - dyndns_iface does not accept multiple
- Resolves: rhbz#1176374 - dyndns_iface does not accept multiple
interfaces, or isn't documented to be able to
- Resolves: rhbz#988068 - getpwnam_r fails for non-existing users when sssd is
not running