summaryrefslogtreecommitdiffstats
path: root/ipapython
Commit message (Collapse)AuthorAgeFilesLines
* Have all the scripts run in python 3 by defaultStanislav Laznicka2018-02-151-1/+1
| | | | | | | | | The Python 3 refactoring effort is finishing, it should be safe to turn all scripts to run in Python 3 by default. https://pagure.io/freeipa/issue/4985 Reviewed-By: Christian Heimes <cheimes@redhat.com>
* Unified ldap_initialize() functionChristian Heimes2018-02-151-7/+29
| | | | | | | | | | | Replace all ldap.initialize() calls with a helper function ldap_initialize(). It handles cacert and cert validation correctly. It also provides a unique place to handle python-ldap 3.0 bytes warnings in the future. Fixes: https://pagure.io/freeipa/issue/7411 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* ipaldap: allow GetEffectiveRights on individual operationsFraser Tweedale2018-02-091-16/+35
| | | | | | | | | | Allow caller to specify that the GetEffectiveRights server control should be used on a per-operation basis. Also update ldap2.get_effective_rights to use this new API. Part of: https://pagure.io/freeipa/issue/6609 Reviewed-By: Christian Heimes <cheimes@redhat.com>
* Replace hard-coded paths with path constantsChristian Heimes2018-02-081-7/+17
| | | | | | | | | | | Several run() calls used hard-coded paths rather than pre-defined paths from ipaplatform.paths. The patch fixes all places that I was able to find with a simple search. The fix simplifies Darix's port of freeIPA on openSuSE. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Fix pylint error in ipapython/dn.pyChristian Heimes2018-01-231-5/+7
| | | | | | | | ipapython/dn.py:1324: [R1710(inconsistent-return-statements), DN.__contains__] Either all return statements in a function should return an expression, or none of them should.) Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* LGTM: Remove redundant assignmentChristian Heimes2018-01-091-2/+0
| | | | | | | https://pagure.io/freeipa/issue/7344 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
* LGTM: Name unused variable in loopChristian Heimes2018-01-091-2/+2
| | | | | | | | | | For loop variable '_nothing' is not used in the loop body. The name 'unused' is used to indicate that a variable is unused. https://pagure.io/freeipa/issue/7344 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
* Require python-ldap 3.0.0b2Christian Heimes2017-12-191-8/+2
| | | | | | | | Use new LDAPBytesWarning to ignore python-ldap's bytes warnings. New build is available in @freeipa/freeipa-master. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Felipe Volpone <fbarreto@redhat.com>
* Use pylint 1.7.5 with fix for bad python3 importChristian Heimes2017-12-191-1/+1
| | | | | | Closes: https://pagure.io/freeipa/issue/7315 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Petr Cech <pcech@redhat.com>
* Fix pylint warnings inconsistent-return-statementsChristian Heimes2017-12-184-2/+8
| | | | | | | | | | Add consistent return to all functions and methods that are covered by tox -e pylint[23]. I haven't checked if return None is always a good idea or if we should rather raise an error. See: https://pagure.io/freeipa/issue/7326 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* NSSDB: use preferred convert commandChristian Heimes2017-12-071-8/+12
| | | | | | | | | | | | After further testing, Kai Engert proposed to use -N with -f -@ to convert a NSSDB from DBM to SQL format. https://fedoraproject.org/wiki/Changes/NSSDefaultFileFormatSql#Upgrade.2Fcompatibility_impact https://pagure.io/freeipa/issue/7049 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Update to python-ldap 3.0.0Christian Heimes2017-12-062-2/+17
| | | | | | | | | Replace python3-pyldap with python3-ldap. Remove some old code for compatibility with very old python-ldap. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Fix ca less IPA install on fips modeFlorence Blanc-Renaud2017-11-271-0/+4
| | | | | | | | | | | | | | | | | When ipa-server-install is run in fips mode and ca-less, the installer fails when the keys are provided with --{http|dirsrv|pkinit}-cert-file in a separate key file. The installer transforms the key into PKCS#8 format using openssl pkcs8 -topk8 but this command fails on a fips-enabled server, unless the options -v2 aes256 -v2prf hmacWithSHA256 are also provided. Fixes: https://pagure.io/freeipa/issue/7280 Reviewed-By: Christian Heimes <cheimes@redhat.com>
* Run tox tests for PyPI packages on TravisChristian Heimes2017-11-201-1/+1
| | | | | Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
* Support sqlite NSSDBChristian Heimes2017-11-161-21/+136
| | | | | | | | | | | Prepare CertDB and NSSDatabase to support sqlite DB format. NSSDatabase will automatically detect and use either old DBM or new SQL format. Old databases are not migrated yet. https://pagure.io/freeipa/issue/7049 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Use namespace-aware meta importer for ipaplatformChristian Heimes2017-11-153-29/+13
| | | | | | | | | | | | | | | | Instead of symlinks and build-time configuration the ipaplatform module is now able to auto-detect platforms on import time. The meta importer uses the platform 'ID' from /etc/os-releases. It falls back to 'ID_LIKE' on platforms like CentOS, which has ID=centos and ID_LIKE="rhel fedora". The meta importer is able to handle namespace packages and the ipaplatform package has been turned into a namespace package in order to support external platform specifications. https://fedorahosted.org/freeipa/ticket/6474 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Backup ipa-custodia conf and keysChristian Heimes2017-11-131-0/+19
| | | | | | | | https://pagure.io/freeipa/issue/7247 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Simo Sorce <ssorce@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
* Warning the user when using a loopback IP as forwarderFelipe Barreto2017-11-093-6/+35
| | | | | | | | | | Changing the --forwarder option to accept a loopback IP. Previously, an error would be raised, now we just show a warning message. Fixes: https://pagure.io/freeipa/issue/5801 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Use os.path.isfile() and isdir()Christian Heimes2017-10-201-18/+2
| | | | | | | | | | | Replace custom file_exists() and dir_exists() functions with proper functions from Python's stdlib. The change also gets rid of pylint's invalid bad-python3-import error, https://github.com/PyCQA/pylint/issues/1565 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* cli: simplify parsing of arbitrary typesFraser Tweedale2017-10-042-26/+18
| | | | | | | | | | | | | | | | | | | | | | | Add the 'constructor' type to IPAOption to allow parsing arbitrary types. When using this type, supply the 'constructor' attribute with the constructor of the type. The checker for the 'constructor' type attempts to construct the data, returning if successful else raising OptionValueError. The 'knob' interface remains unchanged but now accepts arbitrary constructors. This feature subsumes the '_option_callback' mechanism, which has been refactored away. This feature also subsumes the "dn" type in IPAOption, but this refactor is deferred. Part of: https://pagure.io/freeipa/issue/6858 Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
* pylint: disable __hash__ for some classesStanislav Laznicka2017-09-081-0/+2
| | | | | | | | | | pylint requires all classes implementing __eq__ to also implement __hash__. We disable hashing for the classes that miss the ability, should they ever be required to use it, it can be implemented then. https://pagure.io/freeipa/issue/6874 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* install.util: disable no-value-for-parameterStanislav Laznicka2017-09-081-0/+1
| | | | | | | | | | | InnerClassMeta is rather magical and seems to work as-is. There's a reason not to always send all parameters to the methods since they really don't have to be able to handle all the parameters all the time. https://pagure.io/freeipa/issue/6874 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* Fix cert file creation during CA-less installationStanislav Laznicka2017-08-251-1/+2
| | | | | | | | | | | | When writing extracted certs and keys to the file, we opened the same file at a different spot but the original file position indicator would not be moved when the certificate is written there. The result is that the certificate gets rewritten by the private key. This commit fixes it. Fixes: https://pagure.io/freeipa/issue/7118 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
* Fix incorrect 'with' statement in CA-less installationFraser Tweedale2017-08-251-2/+2
| | | | | | | Part of: https://pagure.io/freeipa/issue/7118 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
* ipautil: port host_port_open() to python 3Stanislav Laznicka2017-08-181-1/+1
| | | | | | | | socket.send() expects `Bytes` instance, not string https://pagure.io/freeipa/issue/4985 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* kerberos: fix sorting Principal objectsStanislav Laznicka2017-08-171-0/+12
| | | | | | | | | | When service-find was issued under Python 3, the command fails because it tried to sort a list of Principal objects which was not possible. https://pagure.io/freeipa/issue/4985 Reviewed-By: Felipe Volpone <fbarreto@redhat.com>
* log progress of wait_for_open_portsPetr Vobornik2017-08-111-1/+6
| | | | | | | | | To know what to focus on when some check fail. E.g. to detect that IPv6 address or its resolution for localhost is misconfigured. https://pagure.io/freeipa/issue/7083 Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
* control logging of host_port_open from callerPetr Vobornik2017-08-111-10/+4
| | | | | | | | | | | | | host_port_open copied logging behavior of ipa-replica-conncheck utility which doesn't make it much reusable. Now log level can be controlled from caller so other callers might use other logging level without host_port_open guessing what was the intention. https://pagure.io/freeipa/issue/7083 Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
* x509,certdb: handle certificates as bytesStanislav Laznicka2017-07-271-12/+22
| | | | | | | | | | | Certificates, both in PEM and DER format, should be handled as bytes in Python 3. https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Create a Certificate parameterStanislav Laznicka2017-07-271-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Up until now, Bytes parameter was used for certificate parameters throughout the framework. However, the Bytes parameter does nothing special for certificates, like validation, so this had to be done for each of the parameters which were supposed to represent a certificate. This commit introduces a special Certificate parameter which takes care of certificate validation so this does not have to be done separately. It also makes sure that the certificates represented by this parameter are always converted to DER format so that we can work with them in a unified manner throughout the framework. This commit also makes it possible to pass bytes directly during instantiation of the Certificate parameter and they are still represented correctly after their conversion in the _convert_scalar() method. https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* x509: Make certificates represented as objectsStanislav Laznicka2017-07-271-61/+45
| | | | | | | | https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Split x509.load_certificate() into PEM/DER functionsStanislav Laznicka2017-07-271-6/+6
| | | | | | | | | | | | | Splitting the load_certificate() function into two separate helps us word the requirements for the input explicitly. It also makes our backend similar to the one of python-cryptography so eventually we can swap python-cryptography for IPA x509 module. https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: make sure logging level is set to proper valueTomas Krizek2017-07-261-0/+18
| | | | | | | | During py.test initialization, the value 'debug' is passed instead of logging.DEBUG. Signed-off-by: Tomas Krizek <tkrizek@redhat.com> Reviewed-By: David Kupka <dkupka@redhat.com>
* logging: do not use `ipa_log_manager` to create module-level loggersJan Cholasta2017-07-141-0/+5
| | | | | | | | Replace all `ipa_log_manager.log_mgr.get_logger` calls to create module-level loggers with `logging.getLogger` calls and deprecate `ipa_log_manager.log_mgr.get_logger`. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: do not log into the root loggerJan Cholasta2017-07-146-49/+61
| | | | | | | Deprecate `ipa_log_manager.root_logger` and replace all calls to it with module-level logger calls. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: do not reference loggers in arguments and attributesJan Cholasta2017-07-142-6/+5
| | | | | | | | Remove logger arguments in all functions and logger attributes in all objects, with the exception of API object logger, which is now deprecated. Replace affected logger calls with module-level logger calls. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: remove object-specific loggersJan Cholasta2017-07-145-42/+84
| | | | | | | | | | Remove all object-specific loggers, with the exception of `Plugin.log`, which is now deprecated. Replace affected logger calls with module-level logger calls. Deprecate object-specific loggers in `ipa_log_manager.get_logger`. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: use the actual root logger as the root loggerJan Cholasta2017-07-141-12/+4
| | | | | | | | | | Use the actual root logger (`logging.getLogger()`) rather than the `ipa` logger (or the `root` logger in case of ipa-ods-exporter) as the root logger. Always configure logging on the root logger. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: port to standard Python loggingJan Cholasta2017-07-143-1711/+83
| | | | | | | | | | Use the standard `logging` module to configure logging instead of the in-house `ipapython.log_manager` module and remove `ipapython.log_manager`. Disable the logging-not-lazy and logging-format-interpolation pylint checks. Reviewed-By: Martin Basti <mbasti@redhat.com>
* logging: do not configure any handlers by defaultJan Cholasta2017-07-142-8/+4
| | | | | | | | | | Do not configure stderr handler by default and let the application do the configuration. Fix ipa-dnskeysync-replica and ipa-dnskeysyncd not to add stderr handler twice. Reviewed-By: Martin Basti <mbasti@redhat.com>
* ipapython/graph.py redundant variable fixAleksei Slaikovskii2017-07-141-2/+3
| | | | | | | | Changed deletion of edges in remove_vertex method because there's no need to store redundant variable in memory. Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* ipapython/graph.py String formattingAleksei Slaikovskii2017-07-141-2/+7
| | | | | | | Changed string formatting for Value Errors raise. Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* ipapython/graph.py complexity optimizationAleksei Slaikovskii2017-07-141-4/+6
| | | | | | | | | | | | Hi! I've just read the code and I saw that graph bfs uses not optimal for Python solution. So I've edited it with more optimal one. https://pagure.io/freeipa/issue/7051 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* IPAOptionParser: fix dict comprehensionMartin Basti2017-07-141-1/+4
| | | | | | The statement can be simplified and be more resources friendly Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
* ldap2: remove URI argument from ldap2 constructorJan Cholasta2017-07-041-9/+10
| | | | | | | | LDAPClient should be used for ad-hoc connections, so the argument is not necessary, and currently also unused. Reviewed-By: Martin Babinsky <mbabinsk@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
* py3: ipaldap: fix encoding of datetime objectsMartin Basti2017-06-211-1/+1
| | | | | | | | datetime objects were converted to string instead fo bytes. https://pagure.io/freeipa/issue/4985 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* py3: LDAPClient: remove __del__ methodMartin Basti2017-06-211-3/+0
| | | | | | | | | | | | | | | in py3 we are receiving ugly tracebacks due __del__ method that should be used very carefully or never. Due tracebacks, this doesn't work and context manager should be used for reliable connection termination. Exception ignored in: <bound method LDAPClient.__del__ of ipaserver.plugins.ldap2.ldap2()> Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/ipapython/ipaldap.py", line 1057, in __del__ File "/usr/lib/python3.5/site-packages/ipaserver/plugins/ldap2.py", line 123, in close File "/usr/lib/python3.5/site-packages/ipalib/backend.py", line 94, in isconnected NameError: name 'hasattr' is not defined Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* LDAPEntry: rename _orig to _orig_rawMartin Basti2017-06-211-8/+9
| | | | | | | | | | It was hard to detect what is supposed to be in self._orig variable. Renaming to _orig_raw makes clear for future generations that it contains bytes. https://pagure.io/freeipa/issue/4985 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* python-netifaces: update to reflect upstream changesMartin Basti2017-06-201-3/+14
| | | | | | | | | | | python-netifaces now provides IPv6 netmask in format mask/prefix. It breaks freeipa as it is unexpected format for python-netaddr. We must split netmask and provide only prefix for netaddr. https://pagure.io/freeipa/issue/7021 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
* Remove ip_netmask from option parserMartin Basti2017-06-201-3/+2
| | | | | | | | | | | ipa-dns-install uses ip_netmask=False --> parse_netmask=False, other installers uses default (parse_netmask=True). Use this consistent accross all installers. Also this option is unused (and shouldn't be used). https://pagure.io/freeipa/issue/4317 Reviewed-By: David Kupka <dkupka@redhat.com>