Commit graph

386 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
343f97460f Use #if instead of #ifdef for compatibility checks
This has the advantage that it is slightly less verbose, and
also any potential typos in the macro names are immediately detected.
2019-06-16 18:12:45 +02:00
Zbigniew Jędrzejewski-Szmek
a17f3c0ec5 make: use -std=c99
I see no good reason to support old standards, when systemd itself
requires c99. Let's test with c99 in the CI.

Closes #62.
2019-06-16 17:37:53 +02:00
Zbigniew Jędrzejewski-Szmek
36c57e52be id128: update constants for systmed-243 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
83b4939e16 tests: add tests for all id128 funcs, including get_machine_app_specific() 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
b54707abf4 id128: conditionalize get_machine_app_specific on libsystemd version 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
56d6fc58c9 id128: do not copy the id128 buffer bytes
There doesn't seem to be any particular need to do this.

Also remove unused uuid variable.
2019-06-16 16:27:11 +02:00
Tomasz Meresiński
552ad76180 Add id128.get_machine_app_specific function 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
0198c4543d README: use some more <h2> tags 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
c0e9a8b949 Modernize C syntax 2019-06-16 16:27:11 +02:00
Marcel Waldvogel
5101a6a10a _listen_fd_with_names documentation now modeled after is_socket_sockaddr 2019-06-16 16:27:11 +02:00
Marcel Waldvogel
b1608daf27 Added support for listen_fds_with_names() 2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
a2471e2369 tests: add the reproducer from #51
The example relies on implementation details, but I don't see
why it wouldn't work everywhere. Let's pull it in, and if it breaks
somewhere, we can remove it.
2019-06-16 16:27:11 +02:00
Zbigniew Jędrzejewski-Szmek
7e32263d79
Merge pull request #51 from feedstock/fix_notify_fs_leak
Fix notify fs leak
2019-06-16 15:17:28 +02:00
ytyt-yt
20e0f72d40 add JournalHandler usage in README 2019-06-16 15:13:10 +02:00
Marcel Waldvogel
216f990565 Adapt to systemd 230 tool renaming, bump version 2019-06-16 15:11:12 +02:00
Marco Paolini
6ab8f8e3f1 Fix malloc retval check 2017-09-12 02:25:11 +01:00
Marco Paolini
d93d41fd58 Avoid ref leak in notify 2017-09-12 02:19:21 +01:00
Zbigniew Jędrzejewski-Szmek
c06c5d401d README: also mention CentoOS and RHEL in instructions
The latest supported version of Fedora is now 24, and python3 is
supported on all current versions, so drop references to old Fedora
from the README.

Fixes #47.
2017-04-14 10:54:40 -04:00
Zbigniew Jędrzejewski-Szmek
308ae4440c Prepare v234 v234 2017-03-25 21:33:59 -04:00
Zbigniew Jędrzejewski-Szmek
a54a7a2f51 Update to constants from systemd-233
In systemd-233 the format of the constants file changed to use
SD_ID128_MAKE_STR macro and long lines are broken with '\'.
Doing this in sed is too anyoing — add a simple python script to
do the processing.
2017-03-25 21:33:05 -04:00
Zbigniew Jędrzejewski-Szmek
a5dc4ab856 journal: fix repr of JournalHandler to match python3.6
We get <systemd.journal.JournalHandler object at ...> in older versions,
and <JournalHandler (NOTSET)> in since Python 3.6.
c075201147
2017-03-25 12:31:45 -04:00
Zbigniew Jędrzejewski-Szmek
2169cdea8d journal: do not convert extra args to string in JournalHandler
send() already does conversions in a type-specific way, and doing it
in journal handler would defeat those conversions. In particular, UUIDs
would be converted to early and have dashes.
2017-03-19 15:07:59 -04:00
Zbigniew Jędrzejewski-Szmek
aa5550a9b7 test_journal: add tests for MESSAGE_ID passing
MESSAGE_ID passing was broken before previous commit:
TypeError: send() got multiple values for keyword argument 'MESSAGE_ID'

With the previous commit it's broken differently:

______________________________ test_journalhandler_message_id_on_handler _______________________________

    def test_journalhandler_message_id_on_handler():
        record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None)
        sender = MockSender()
        handler = journal.JournalHandler(logging.INFO, sender_function=sender.send,
                                         MESSAGE_ID=TEST_MID)
        handler.emit(record)
        assert len(sender.buf) == 1
>       assert 'MESSAGE_ID=' + TEST_MID.hex in sender.buf[0]
E       assert ('MESSAGE_ID=' + '8441372f8dca4ca98694a6091fd8519f') in ['MESSAGE=test', 'MESSAGE_ID=8441372f-8dca-4ca9-8694-a6091fd8519f', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...]
E        +  where '8441372f8dca4ca98694a6091fd8519f' = UUID('8441372f-8dca-4ca9-8694-a6091fd8519f').hex

systemd/test/test_journal.py:116: AssertionError
______________________________ test_journalhandler_message_id_on_message _______________________________

    def test_journalhandler_message_id_on_message():
        record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None)
        record.__dict__['MESSAGE_ID'] = TEST_MID2
        sender = MockSender()
        handler = journal.JournalHandler(logging.INFO, sender_function=sender.send,
                                         MESSAGE_ID=TEST_MID)
        handler.emit(record)
        assert len(sender.buf) == 1
>       assert 'MESSAGE_ID=' + TEST_MID2.hex in sender.buf[0]
E       assert ('MESSAGE_ID=' + '8441370000000000000000001fd85000') in ['MESSAGE=test', 'MESSAGE_ID=84413700-0000-0000-0000-00001fd85000', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...]
E        +  where '8441370000000000000000001fd85000' = UUID('84413700-0000-0000-0000-00001fd85000').hex

systemd/test/test_journal.py:135: AssertionError
============================ 2 failed, 53 passed, 6 skipped in 0.16 seconds ============================
2017-03-19 15:06:19 -04:00
Wesley Bowman
08857486e6 Remove mid from JournalHandler
Removed mid variable from JournalHandler since the MESSAGE_ID is already
in the extras variable. MESSAGE_ID was being set to None, but this won't
appear in the logs.
2017-03-19 13:33:32 -04:00
Zbigniew Jędrzejewski-Szmek
84371c2cfd journal: rename SENDER_FUNCTION to sender_function
Let's not try to make it look like a journal field. It should
be a normal parameter.

Followup for dce0a855c3.
2017-03-19 13:28:15 -04:00
Zbigniew Jędrzejewski-Szmek
5498ad7513 daemon: properly skip sd_is_socket_sockaddr calls if not available
As with other functions, the wrapper is always present, but returns
OSError: [Errno 38] Function not implemented.
2017-03-19 13:17:13 -04:00
Zbigniew Jędrzejewski-Szmek
fe9756d3ab Makefile: add convenience "shell" target to start python shell 2017-03-19 13:17:13 -04:00
Zbigniew Jędrzejewski-Szmek
3f9386a435 Makefile: add "doc" target for convenience 2017-03-19 13:17:13 -04:00
Zbigniew Jędrzejewski-Szmek
ae08cbfe11 Makefile: remove unneeded -I/usr/include from flags
gcc warns about an include directive that shadows the system include
directory at high verbosity levels. Let's filter it out (pkgconfig
implements that) to reduce noise and also to make the command line
shorter.
2017-03-19 13:17:13 -04:00
Wesley Bowman
73807b49c4 Fix styling to match PEP8 in most places (#45)
Backwards compatibility for mapPriority is retained.
2017-03-14 17:36:46 -04:00
Zbigniew Jędrzejewski-Szmek
e121ae49ab Merge pull request #34 from keszybz/test-skipping
Improve test skipping on old systems.
2017-03-13 16:03:49 -04:00
Zbigniew Jędrzejewski-Szmek
c7e393b3ca journal: improve docstring formatting a bit 2017-03-12 12:46:16 -04:00
Zbigniew Jędrzejewski-Szmek
14b05bfff5 Adjust import order, spacing, operators as recommended by pylint 2017-03-12 12:27:49 -04:00
Zbigniew Jędrzejewski-Szmek
5aab3fc3b4 tests: move login tests from doctest to separate file
This way we can skip ENOENT (which happens in containers).
While at it, let's extend the tests a bit, so that we at least
call all functions and check the type of the return value.

Also, drop '.nspawn' from the machine name, nspawn doesn't
use that suffix any more.
2017-03-12 12:26:51 -04:00
Jimmy Cao
8921c79fb9 Prevent non-str values from being concatenated with + (#40)
Make _make_line concatenate only strings directly.
2017-03-12 12:16:45 -04:00
Zbigniew Jędrzejewski-Szmek
753a4ca5ff Merge pull request #31 from keszybz/is_socket_sockaddr
daemon: add basic support for sd_is_socket_sockaddr
2017-03-11 14:26:27 -05:00
Jeongsoo, Park
dce0a855c3 replace dict.iteritems() with dict.items() to support py3 (#39)
py3 doesn't have dict.iteritems() anymore.
2017-03-11 13:57:44 -05:00
Mike Gilbert
35a27a4372 test_daemon: xfail test_notify_with_socket if bind() fails (#42)
This bind() call may fail if TMPDIR is too long.

Bug: https://bugs.gentoo.org/610368
2017-03-11 13:51:16 -05:00
Ville Skyttä
ea8e705939 Python 3.6 invalid escape sequence deprecation fixes (#43)
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
2017-03-11 13:47:37 -05:00
Johannes Weberhofer
3645c3597e Added section for installation on openSUSE & SLE (#35) 2016-12-16 21:08:42 -05:00
Zbigniew Jędrzejewski-Szmek
bc691d8e29 Fix handling of addresses without port and add tests 2016-12-15 21:15:51 -05:00
Zbigniew Jędrzejewski-Szmek
4a3cee1ad3 daemon: add wrapper for sd_is_socket_sockaddr and tests
Specifying the address without does not work.
2016-12-15 21:15:51 -05:00
Zbigniew Jędrzejewski-Szmek
5ffc226890 _daemon: allow specifying flowinfo
Not particularly useful, but let's have it for completeness.
2016-12-15 21:00:08 -05:00
Zbigniew Jędrzejewski-Szmek
17a1dad795 util: add compatibility for old glibc
Oh, Ubuntu!
2016-12-15 21:00:08 -05:00
Zbigniew Jędrzejewski-Szmek
63cc41a456 daemon: add basic support for sd_is_socket_sockaddr
Later on a proper wrapper in daemon.py should be added.
2016-12-15 21:00:08 -05:00
Zbigniew Jędrzejewski-Szmek
5d3be8ccba _daemon,_reader: return ENOSYS instead of NotImplemented
In _reader we were raising OSError(errno=ENOSYS), but in _dameon
we were raising NotImplementedError. Let's always use ENOSYS.

Also, make the messages in _reader more specific.

Fixes #33.
2016-12-15 20:57:44 -05:00
Zbigniew Jędrzejewski-Szmek
5d1e3fbcdc tests: skip journal.stream tests on ENOENT error
When running in a chroot, doctests that called journal.stream would
fail with ENOENT. Move the tests to test_journal, where we can skip
tests properly (without uglyfying the documentation).

Fixes #32.
2016-12-15 20:57:44 -05:00
Zbigniew Jędrzejewski-Szmek
930bf89796 setup.py: allow LIBSYSTEMD_VERSION to be overridden
This is useful when testing against old or unreleases versions of
the library:
  make PYTHON=python3 INCLUDE_DIR=/home/zbyszek/src/systemd-master/src LIBSYSTEMD_VERSION=233
2016-12-14 22:52:47 -05:00
Zbigniew Jędrzejewski-Szmek
b4cfd41a06 Makefile: use $(INCLUDE_DIR) also for compilation
This way we can compile against unreleased systemd:
make PYTHON=python3 INCLUDE_DIR=/home/zbyszek/src/systemd/src
(cd build/lib.linux-x86_64-3.5; systemd-socket-activate -E LD_LIBRARY_PATH=/home/zbyszek/src/systemd-master/.libs -l2000 -l127.0.0.1:2001 python3)
2016-12-13 20:27:47 -05:00
Zbigniew Jędrzejewski-Szmek
e4ff9e6f7c build-sys: add sign and upload targets 2016-12-13 20:27:47 -05:00