Commit Graph

481 Commits

Author SHA1 Message Date
Frédéric Péters e4f50c8b25 perl: pass $(LDFLAGS) to Makefile.PL (#71393)
LDFLAGS is set during the Debian build to pass hardening flags and
we want them to be applied to the perl module.
2022-11-20 12:24:51 +01:00
Benjamin Dauvergne f83d02f314 Revert "Use the AM_PATH_PYTHON macro instead of custom macros"
This reverts commit 23d91efac3.
2022-04-27 14:54:06 +02:00
Benjamin Dauvergne 23d91efac3 Use the AM_PATH_PYTHON macro instead of custom macros 2022-04-27 10:44:57 +02:00
Benjamin Dauvergne a28fb8c8e1 Does not decref boolean constants (#57268)
TRUE/FALSE are special references in CPython bindings whose reference
count must never be updated.
2021-09-28 10:23:10 +02:00
Benjamin Dauvergne 23035115a3 Clear Python error indicator after logging (#56572)
Lasso log using the GLib logging API and the Python binding install a
hook to delegate logging to a Python logger named "lasso".

During the logging call the error indicator can be set to signal an
exception. The indicator will still be set when we return from the Lasso
API call, and is not handled by the Python wrapping of the C functions.
If our function returns a non-NULL value, the Python interpreter will
raise because this situation is forbidden.

To prevent it, if we detect that an exception occurred during logging
calls, we print it to stderr, clear the error indicator and return
immediately.
2021-09-11 19:20:25 +02:00
Benjamin Dauvergne 53b0bd3569 Change default key encryption padding algorithm to RSA-OAEP (#56023)
The key encryption padding algorithm is now configurable, the default
being changed to OAEP. It's possible to set the default through
./configure with:

    --with-default-key-encryption-method=[rsa-pkcs1|rsa-oaep]

at initialization time with an environment variable:

    LASSO_DEFAULT_KEY_ENCRYPTION_METHOD=[rsa-pkcs1|rsa-oaep]

or at runtime for a service provider:

    lasso_provider_set_key_encryption_method(LassoProvider *provider,
        LassoKeyEncryptionMethod key_encryption_method)

The setting is global for all encrypted nodes (Assertion or NameID).
2021-09-11 19:20:04 +02:00
Benjamin Dauvergne 1e718bd3aa Python: fix formatting (#56023) 2021-09-11 19:19:59 +02:00
Benjamin Dauvergne 4a880977d1 Remove ID-WSF 1.0, 2.0 and WS-* support (#56644)
It has been deprecated for a long time.
2021-09-11 18:54:41 +02:00
Benjamin Dauvergne 149de8cd0b python: clear warnings about PY_SSIZE_T_CLEAN (#55561)
Using the python3 bindings on recent python3 >=3.8 versions shows:

   DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats

https://docs.python.org/3.9/whatsnew/changelog.html?highlight=py_ssize_t_clean#id193
2021-07-13 13:21:13 +02:00
Benjamin Dauvergne b6321b4db2 python: clear warnings about assertX methods (#55561) 2021-07-13 13:20:47 +02:00
Jakub Hrozek f70eee9ef7 python: Skip the DSA key test unless SHA-1 is configured (#54037)
lasso supports DSA-XXX only with SHA-1. The alternative is to use
DSA-SHA256.
2021-06-24 02:15:23 +02:00
Benjamin Dauvergne bd7acfd2f3 Python: improve display of warnings in the binding generator 2021-03-09 10:36:40 +01:00
Benjamin Dauvergne 9b1e68f683 bindings: disable java tests when java is disabled 2021-02-24 23:01:08 +01:00
Benjamin Dauvergne 2dbca5edf3 Fix: python3 bindings (#51249)
The __str__ method called itself, resulting in an RecursionError.

======================================================================
ERROR: test14 (__main__.BindingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./binding_tests.py", line 336, in test14
    assert isinstance(str(cm.exception), str)
  File "../lasso.py", line 69, in __str__
    return '<lasso.%s: %s>' % (self.__class__.__name__, self)
  File "../lasso.py", line 69, in __str__
    return '<lasso.%s: %s>' % (self.__class__.__name__, self)
  File "../lasso.py", line 69, in __str__
    return '<lasso.%s: %s>' % (self.__class__.__name__, self)
  [Previous line repeated 489 more times]
  File "../lasso.py", line 68, in __str__
    if sys.version_info >= (3,):
RecursionError: maximum recursion depth exceeded in comparison

----------------------------------------------------------------------
2021-02-24 22:59:30 +01:00
Benjamin Dauvergne 6c166563b2 python: do not leak out_pyvalue if method call protocol is not respected (#44287) 2020-10-12 15:25:01 +02:00
Benjamin Dauvergne 4696e2709b python: do not raise in valid_seq() (#44287) 2020-10-12 15:25:01 +02:00
Benjamin Dauvergne 77bed35c42 python: return NULL if get_list_of_strings() fails (#44287) 2020-10-12 15:25:01 +02:00
Benjamin Dauvergne 5f5bc888b1 python: return NULL if get_list_of_pygobject fails (#44287) 2020-10-12 15:25:01 +02:00
Benjamin Dauvergne 6ed8e04ff1 python: return NULL if get_list_of_xml_nodes fails (#44287) 2020-10-12 15:25:01 +02:00
Benjamin Dauvergne 4cf6bd4ff7 python: return NULL if set_list_of_pygobject fails (#44287) 2020-10-12 15:25:00 +02:00
Benjamin Dauvergne c844abd8e4 python: return NULL if set_list_of_xml_nodes fails (#44287) 2020-10-12 15:24:46 +02:00
Benjamin Dauvergne c53b6b5a73 python: return NULL if set_list_of_strings fails (#44287) 2020-10-12 15:24:45 +02:00
Benjamin Dauvergne ed528ce26a python: return NULL if set_hashtable_of_strings fails (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 57ee8d2f2a python: return NULL if set_hashtable_of_pygobject fails (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 8591451270 python: free internal string buffer if needed in set_list_of_strings (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne f80b2bb50e python: check if hashtable is NULL before deallocatio (#44287)n 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 0289da907f python: add a failure label to method wrappers (#44287)
To separate wrapping code from unwinding and error handling code.
2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 35682272ec python: add macro for early return (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 05dea2eab5 python: remove newline before method call (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne 9db28c0c32 python: simplify get_logger_object (#44287) 2020-10-12 15:24:11 +02:00
Benjamin Dauvergne a8f82e67ef python: fix warning about discarded const modifier (#44287) 2020-10-12 15:24:10 +02:00
Benjamin Dauvergne 637514a874 python: replace exception by warning on logging path (#44287) 2020-10-12 15:24:10 +02:00
Benjamin Dauvergne 8ae9d3a09b python: use simpler call format to prevent warning about PY_SSIZE_T_CLEAN (#44287) 2020-10-12 15:24:10 +02:00
Benjamin Dauvergne 11bc68bbbc python: remove deprecated PyErr_Warn (#44287) 2020-10-12 15:24:10 +02:00
Benjamin Dauvergne a1dbd489fc python: remove unused PyString_Size (#44287) 2020-10-12 15:24:10 +02:00
Benjamin Dauvergne 04ded420c8 python: Exception.message was removed in python3 (#45995) 2020-08-21 11:48:19 +02:00
Benjamin Dauvergne 92d12b9954 Keep order of SessionIndexes 2020-04-22 04:45:52 +02:00
Bernhard M. Wiedemann 1b51873ccf Sort input file lists (#40454)
so that lasso.py, lasso/types.c and liblasso.so.3.13.0
build reproducibly
in spite of indeterministic filesystem readdir order.
For some reason, lasso/extract_sections.py lasso/extract_symbols.py
do not need such patches to get a reproducible openSUSE package.

See https://reproducible-builds.org/ for why this is good.

This patch was done while working on reproducible builds for openSUSE.

License: MIT
Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
2020-03-05 12:51:17 +01:00
Tomohiro "Tomo-p" KATO 9c8c4b9937 Add PHP 7 binding (#28608)
License: MIT
2019-09-09 15:10:06 +02:00
Benjamin Dauvergne 0a5a222e17 Fix python multi-version builds on jessie and stretch
debian/rules supposed that lasso Makefile would always prefer python2 to
python3, it's not the case anymore. Also recent python3 improvements to
bindings scripts did not work with python 3.5 on jessie (on jessie/3.5
default open() encoding is still ASCII not UTF-8 as with the default
UTF-8 of later python3 versions).
2019-09-05 10:34:22 +02:00
Benjamin Dauvergne 150de26bff Clean python cache when building python3 binding
Python3 store .pyc cache in hidden directory __pycache__, distcheck
complained that the source directory was not completely clean after a
distclean.
2018-07-24 11:29:28 +02:00
John Dennis 3d9d58d52c Make more Python scripts compatible with both Py2 and Py3
While porting other Python code in the repo to run under Py3 (as well
as Py2) it was discovered there were a number of other Python scripts
which also needed porting. However these scripts are never invoked
during a build so there was no easy way to test the porting work. I
assume these scripts are for developers only and/or are
historical. Because there was no way for me to test the porting
changes on these scripts I did not want to include the changes in the
patch for the Py3 porting which fixed scripts that are invoked during
the build (the former patch is mandatory, this patch is optional at
the moment). I did verify the scripts compile cleanly under both Py2
and Py3, however it's possible I missed porting something or the error
does not show up until run-time.

Examples of the required changes are:

* Replace use of the built-in function file() with open().  file()
  does not exist in Py3, open works in both Py2 and Py3.  The code was
  also modified to use a file context manager (e.g. with open(xxx) as
  f:). This assures open files are properly closed when the code block
  using the file goes out of scope. This is a standard modern Python
  idiom.

* Replace all use of the print keyword with the six.print_()
  function, which itself is an emulation of Py3's print function. Py3
  no longer has a print keyword, only a print() function.

* The dict methods .keys(), .values(), .items() no longer return a
  list in Py3, instead they return a "view" object which is an
  iterator whose result is an unordered set. The most notable
  consequence is you cannot index the result of these functions like
  your could in Py2 (e.g. dict.keys()[0] will raise a run time
  exception).

* Replace use of StringIO.StringIO and cStringIO with
  six.StringIO. Py3 no longer has cStringIO and the six variant
  handles the correct import.

* Py3 no longer allows the "except xxx, variable" syntax, where
  variable appering after the comma is assigned the exception object,
  you must use the "as" keyword to perform the variable assignment
  (e.g. execpt xxx as variable)

* Python PEP 3113 removed tuple parameter unpacking. Therefore you can
  no longer define a formal parameter list that contains tuple
  notation representing a single parameter that is unpacked into
  multiple arguments.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
John Dennis a76390813a Downcase UTF-8 file encoding name
Python and Emacs (and others?) recognize a special directive line in a
file that identifies what encoding the file is encoded in. See Python
PEP 263. For example:

The general form of the directive is:

where xxx is the name of a codec. Python codec names are lower case
with underscores used to seperate words.

In both Python and Emacs one can create aliases for the codecs so you
can use an alternate name to refer to the same codec.

Python is forgiving with respect to case, underscore and
hyphens. Python will automatically create an alias for a codec name by
downcasing it and replacing hyphens with underscores, thus "UTF-8" is
actually an alias for the "utf_8" codec. Unfortunately emacs does not
automatically create such aliases, although one can add aliases via a
custom initialization file, but doing so requires every user using
emacs to edit the files to manually create their own aliases.

If you try to write a file in emacs with the "UTF-8" codec name it
won't recognize it as "utf-8", instead you'll get errors like this:

  Warning (mule): Invalid coding system ‘UTF-8’ is specified
  for the current buffer/file by the :coding tag.
  It is highly recommended to fix it before writing to a file.

and you must force the file to be written by responding to additional
propmpts.

This patch simply downcases the the "UTF-8" codec name to "utf-8" so
that both Python and Emacs will accept the codec name.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
John Dennis 2ca0303524 fix duplicate definition of LogoutTestCase and logoutSuite
Commit 6f617027e added a duplicate definition of the LogoutTestCase
class containing only 1 test which shaddowed the original
LogoutTestCase containing 4 tests. The logoutSuite variable was also
shadowed and the allTests variable contained a duplicate of
logoutSuite causing the 2nd definition of LogoutTestCase to be run
twice.

Not only were the original 4 tests not being run but the entire unit
test in profiles_tests.py was failing under Python3. This is because
the unittest code in Py3 deletes a test from it's list of tests to run
once it's been run. The second time the logoutSuite was invoked it no
longer contained any tests which caused an exception to be raised
because there were no tests to be run.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
John Dennis 17c39c3990 Make Python scripts compatible with both Py2 and Py3
During the build if the Python3 interpreter is used a number of
scripts will fail because they were never ported from Py2 to Py3. In
general we want Python code to be compatible with both Py2 and
Py3. This patch brings the scripts up to date with Py3 but retains
backwards compatibility with Py2 (specifically Py 2.7, the last Py2
release).

Examples of the required changes are:

* Replace use of the built-in function file() with open().  file()
  does not exist in Py3, open works in both Py2 and Py3.  The code was
  also modified to use a file context manager (e.g. with open(xxx) as
  f:). This assures open files are properly closed when the code block
  using the file goes out of scope. This is a standard modern Python
  idiom.

* Replace all use of the print keyword with the six.print_()
  function, which itself is an emulation of Py3's print function. Py3
  no longer has a print keyword, only a print() function.

* The dict methods .keys(), .values(), .items() no longer return a
  list in Py3, instead they return a "view" object which is an
  iterator whose result is an unordered set. The most notable
  consequence is you cannot index the result of these functions like
  your could in Py2 (e.g. dict.keys()[0] will raise a run time
  exception).

* Replace use of StringIO.StringIO and cStringIO with
  six.StringIO. Py3 no longer has cStringIO and the six variant
  handles the correct import.

* Py3 no longer allows the "except xxx, variable" syntax, where
  variable appering after the comma is assigned the exception object,
  you must use the "as" keyword to perform the variable assignment
  (e.g. execpt xxx as variable)

Note: the modifications in this patch are the minimum necessary to get
the build to run with the Py3 interpreter. There are numerous other
Python scripts in the repo which need Py3 porting as well but because
they are not invoked during a build they will be updated in a
subsequent patch.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
John Dennis 87040110ed Use python interpreter specified configure script
The configure script allows you to specify the python interpreter to
use via the --with-python option. There were several places where the
python interpreter was implicity invoked without using the specified
version. This can create a number of problems in an environment with
multiple python versions as is the case during the transition from
Python 2 to Python 3. Python 2 is not compatible with Python
3. Lasso's Python code is supposed to be compatible with both
versions. But during the build and when running the unit tests it is
essential the same interpreter be used consistently otherwise you can
have problems.

This patch assures whenever python is invoked it does so via the
$(PYTHON) configuration variable.

What about shebang lines (e.g #/usr/bin/python) at the top of scripts?
Python PEP 394 (https://www.python.org/dev/peps/pep-0394/) covers
this. Basically it says if a script is compatible only with Py2 the
shebang should be #/usr/bin/python2, if only compatible with Py3 the
shebang should be #/usr/bin/python3. However, if the script is
compatible with both versions it can continue to use the
compatible with both Py2 and Py3.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
Frédéric Péters eb6e0e23b4 python: add a classmethod for lasso.profileGetIssuer (#24831) 2018-06-28 08:55:59 +02:00
Benjamin Dauvergne 9853289bc7 perl/tests: build Makefile.perl before running the tests 2018-05-30 16:50:00 +02:00
Benjamin Dauvergne 39ca2d4833 perl: set DESTDIR and PREFIX at Makefile's creation 2018-04-30 16:01:50 +02:00
Benjamin Dauvergne aace9d3182 perl: force use of the in-tree lasso when running tests (fixes #23276) 2018-04-29 20:17:27 +02:00