Re: [systemd-devel] failing boot start jobs delay reboot
On Tue, Jan 20, 2015 at 7:03 AM, Felix Miata mrma...@earthlink.net wrote: Andrei Borzenkov composed on 2015-01-20 06:35 (UTC+0300): Mon, 19 Jan 2015 17:59:41 -0500 Felix Miata composed: Has anything been done in more recent releases about this? I do a lot of cloning, and sometimes produce typos on grub cmdlines and fstab lines. This produces long delays in init followed by emergency mode when the non-essential mount fails and fstab for that device does not include the nofail option. When I recognize early in init that I have made a fstab typo, I try to CAD to choose another boot choice that isn't broken and fix the typo, but that produces yet another start job wait for the same broken job, often followed by a gazillion failed to save sound card state messages from holding down CAD. openSUSEes, Mageias Fedoras (including Factories, Cauldrons Rawhides) comprise most of my installations subject to these self-inflicted delays that I can't recall being a problem with sysvinit. Self inflicted delays during boot or during Ctrl-Alt-Del? Both. Back upon a time initscripts used delays as well waiting for devices to appear. I think later it was basically converted to wait for udevsettle. For usual end user system udevsettle does not do much and so is more or less instant. I'm not sure whether this will be feasible today as default solution. You could try experimenting with adding x-systemd.device-timeout=1s to /etc/fstab and forcing udevsettle before local-fs-pre.target. When they occur during init they repeat during shutdown. Even when I let init complete and succeed to fix the typo or oversight, the init failure gets remembered and repeated at shutdown. Yes, that's the problem. For once, traditional workflow of - stop in emergency shell when mount fails - fix /etc/fstab - ^D to continue boot no more works, because /etc/fstab is not reevaluated so systemd will still try the same broken mount again. Also I have observed delays during shutdown/reboot /probably/ triggered by failed mounts but am not sure how to reproduce them. If you have simple step by step guide how to trigger such delays, would be great. Often the start job is on account of a volume label that has been replaced, usually along with a UUID, because the clone is a partition on the same HD. Fedora is particularly frustrating by embedding dependent root volume label and not obeying root= on cmdline (openSUSE obeys root=). Those typos usually have to be fixed by chroot to run dracut. -- ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] networkd: fix a typo in networkd-wait-online-manager.
On 01/20/2015 12:56 PM, Rami Rosen wrote: subscibe-subscribe Applied, thanks! --- src/network/networkd-wait-online-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c index 3f2b966..6f392fe 100644 --- a/src/network/networkd-wait-online-manager.c +++ b/src/network/networkd-wait-online-manager.c @@ -159,7 +159,7 @@ static int manager_rtnl_listen(Manager *m) { assert(m); -/* First, subscibe to interfaces coming and going */ +/* First, subscribe to interfaces coming and going */ r = sd_rtnl_open(m-rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR); if (r 0) return r; ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] networkd: fix a typo in networkd-wait-online-manager.
subscibe-subscribe --- src/network/networkd-wait-online-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c index 3f2b966..6f392fe 100644 --- a/src/network/networkd-wait-online-manager.c +++ b/src/network/networkd-wait-online-manager.c @@ -159,7 +159,7 @@ static int manager_rtnl_listen(Manager *m) { assert(m); -/* First, subscibe to interfaces coming and going */ +/* First, subscribe to interfaces coming and going */ r = sd_rtnl_open(m-rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR); if (r 0) return r; -- 1.9.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] failing boot start jobs delay reboot
Andrei Borzenkov composed on 2015-01-20 11:24 (UTC+0300): Felix Miata wrote: When they occur during init they repeat during shutdown. Even when I let init complete and succeed to fix the typo or oversight, the init failure gets remembered and repeated at shutdown. Yes, that's the problem. For once, traditional workflow of - stop in emergency shell when mount fails - fix /etc/fstab - ^D to continue boot no more works, because /etc/fstab is not reevaluated so systemd will still try the same broken mount again. Also I have observed delays during shutdown/reboot /probably/ triggered by failed mounts but am not sure how to reproduce them. If you have simple step by step guide how to trigger such delays, would be great. Given what I have written in this thread, I am puzzled that you ask this. Try what I just did (on multiboot host gx28c with 8 or more volume lines in eash installation's fstab; 'fdisk -l | grep /dev/sda | wc -l' produces 24 on this host): 1-have fstab entries for openSUSE 13.1 and TW mount using the form LABEL= 2-in TW's fstab, misspell the volume label for 13.1 3-boot TW 4-when the waiting for dev-disk-by\x2dlabel-LABEL.device (failing volume's label) start job appears, right away CAD, and shutdown will proceed normally for a short time, after which the waiting for dev-disk-by\x2dlabel-LABEL.device previously experienced will institute a similar delay before reboot completes 5-boot 13.1 6-restore TW's fstab to have correct volume label spellings next boot I repeated on same host using Fedora 20 and 21 to get similar delays. For both TW and F21 I also tried letting init proceed into emergency shell, fixing fstab, then CAD, whereupon reboot proceeded quickly for both. To reach Fedora 20 emergency shell after a very long wait (3 minutes here on 2.8GHz 32 bit single core P4), include a misspelled root volume after LABEL= on cmdline. (Warning: /dev/disk/by-label/fedor23 does not exist; Generating...) -- The wise are known for their understanding, and pleasant words are persuasive. Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] systemd-216 breaks combined ReadOnlyDirectories / ReadWriteDirectories
after upgrade to Fedora 21 with new systemd namespaces like below no longer works which breaks *all my systemd-units* why? ReadOnlyDirectories=/var/lib ReadWriteDirectories=/var/lib/mysql 150120 13:44:01 [ERROR] Can't start server : Bind on unix socket: Read-only file system 150120 13:44:01 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysqld_dbmail.sock ? signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] sysv-generator: Handle .sh suffixes when translating Provides:
Hey all, the recent fix for sysv-generator's Provides: handling [1] caused, or rather uncovered, another bug which now creates symlinks to itself foo.service - foo.service for any /etc/init.d/foo.sh. The generator would output an error message like Failed to create unit file path.../foo.service: File exists instead of creating the actual foo.service file. I. e. this completely breaks translating init scripts with .sh. Fix with corresponding test case attached. This is a test case for the test suite I sent in my previous mail; that might still need some masssaging, so if you are ok with this fix, I'll commit that without the test case, and add the test case to the suite separately. Martin [1] http://cgit.freedesktop.org/systemd/systemd/commit/?id=b7e7184634d5 -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) From cbd7f20422f044ba192d11afe2d3a29bcf7a5f69 Mon Sep 17 00:00:00 2001 From: Martin Pitt martin.p...@ubuntu.com Date: Tue, 20 Jan 2015 16:41:31 +0100 Subject: [PATCH 2/2] sysv-generator: Handle .sh suffixes when translating Provides: When deciding whether the provided name equals the file name in sysv_translate_facility(), also consider them equal if the file name has a .sh suffix. This was uncovered by commit b7e7184 which then created a symlink name.service to itself for .sh suffixed init.d scripts. For additional robustness, refuse to create symlinks to itself in add_alias(). --- src/sysv-generator/sysv-generator.c | 16 +++- test/sysv-generator-test.py | 37 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 4774981..6334fd3 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -119,6 +119,11 @@ static int add_alias(const char *service, const char *alias) { assert(service); assert(alias); +if (streq(service, alias)) { +log_error(Ignoring creation of an alias %s for itself, service); +return 0; +} + link = strjoin(arg_dest, /, alias, NULL); if (!link) return log_oom(); @@ -263,6 +268,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char unsigned i; char *r; const char *n; +_cleanup_free_ char *filename_no_sh = NULL; assert(name); assert(_r); @@ -284,6 +290,14 @@ static int sysv_translate_facility(const char *name, const char *filename, char goto finish; } +/* strip .sh suffix from file name for comparison */ +filename_no_sh = strdup(filename); +if (!filename_no_sh) +return -ENOMEM; +if (endswith(filename, .sh)) +filename_no_sh[strlen(filename)-3] = '\0'; +log_debug(sysv_translate_facility: translating %s fname %s no_sh %s, name, filename, filename_no_sh); + /* If we don't know this name, fallback heuristics to figure * out whether something is a target or a service alias. */ @@ -293,7 +307,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char /* Facilities starting with $ are most likely targets */ r = unit_name_build(n, NULL, .target); -} else if (filename streq(name, filename)) +} else if (filename streq(name, filename_no_sh)) /* Names equaling the file name of the services are redundant */ return 0; else diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py index e281a7f..53d729a 100644 --- a/test/sysv-generator-test.py +++ b/test/sysv-generator-test.py @@ -172,6 +172,43 @@ class SysvGeneratorTest(unittest.TestCase): self.assertEqual(os.readlink(os.path.join(self.out_dir, f)), 'foo.service') +def test_sh_suffix(self): +'''init.d script with .sh suffix''' + +self.add_sysv('foo.sh', {}, enable=True) +err, results = self.run_generator() +s = results['foo.service'] + +self.assertEqual(s.sections(), ['Unit', 'Service']) +# should not have a .sh +self.assertEqual(s.get('Unit', 'Description'), 'LSB: test foo service') + +# calls correct script with .sh +init_script = os.path.join(self.init_d_dir, 'foo.sh') +self.assertEqual(s.get('Service', 'ExecStart'), + '%s start' % init_script) +self.assertEqual(s.get('Service', 'ExecStop'), + '%s stop' % init_script) + +# should be enabled +target = os.readlink(os.path.join( +self.out_dir, 'runlevel2.target.wants', 'foo.service')) +self.assertTrue(os.path.exists(target)) +
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
Zbigniew Jędrzejewski-Szmek [2015-01-20 16:48 +0100]: Maybe we could do this check in configure.ac/Makefile.am (add the test to the list conditinally)? Yes, that's a good idea. We already test for python presence and extract the version, so we shouldn't duplicate the tests here and have an extra wrapper. Unfortunately automake's TESTS only accepts single arguments, i. e. scripts without any arguments. But we need to call $(PYTHON) test/x.py thus we need an argument. An alternative would be to add a new TESTS_PYTHON = test/sysv-generator-test.py test/rule-syntax-check.py (and perhaps more in the future) and integrate that into Makefile.am. That would make Makefile.am more complex, but avoid the extra wrappers. WDYT? Thanks, Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
On Tue, Jan 20, 2015 at 04:19:24PM +0100, Martin Pitt wrote: Hello all, We've had numerous problems with the SysV generator in the past, and we just recently introduced another regression: init.d scripts which end in .sh are now totally broken. Thus I think it's high time to write some integration tests for that. The attached patch provides the necessary framework and an initial set of tests; e. g. test_multiple_provides() covers Michael's recent commit b7e71846. I can reproduce the .sh bug from above with a simple |def test_sh_suffix(self): |'''init.d script with .sh suffix''' | |self.add_sysv('foo.sh', {}, enable=True) |err, results = self.run_generator() |[... actual checks here, not written yet ...] which currently fails with | == | FAIL: test_sh_suffix (__main__.SysvGeneratorTest) | init.d script with .sh suffix | -- | Traceback (most recent call last): | File test/../test/sysv-generator-test.py, line 179, in test_sh_suffix | err, results = self.run_generator() | File test/../test/sysv-generator-test.py, line 58, in run_generator | self.assertFalse('Fail' in err, err) | AssertionError: True is not false : Looking for unit files in (higher priority first): | /etc/systemd/system | /run/systemd/system | /usr/local/lib/systemd/system | /lib/systemd/system | /usr/lib/systemd/system | Looking for SysV init scripts in: | /tmp/sysv-gen-test.7qlq6kg2/init.d | Looking for SysV rcN.d links in: | /tmp/sysv-gen-test.7qlq6kg2 | Failed to create unit file /tmp/sysv-gen-test.7qlq6kg2/output/foo.service: File exists Indeed it just creates a symlink pointing to itself and nothing else. I will look into that actual bug in a bit, and write a complete test along with it. But before I spend more work on the tests, I'd appreciate a quick review of it whether the general structure is ok for you. As this deals with temp dirs, cleaning them up, running external programs, parsing their output etc., I chose Python for this, as this stuff is just s much faster and convenient to write. We already have test/rule-syntax-check.py, so there's precedent :-) As automake's tests are rather limited and require a single command without arguments, but I want to make this obey configure's $(PYTHON) and skip the test properly if python 3 is not available, I created a simple shell wrapper around it. Obviously this is still lacking a lot of important cases; I'm happy to add them later on, I just wanted to get some initial generic feedback. Thanks, Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) From 7d4f85e42ff5a7a05477e712dcb58ab99d02a87a Mon Sep 17 00:00:00 2001 From: Martin Pitt martin.p...@ubuntu.com Date: Tue, 20 Jan 2015 16:08:05 +0100 Subject: [PATCH] test: add initial integration test for systemd-sysv-generator This is still missing a lot of important scenarios and corner cases, but provides the groundwork and covers a recent bug (commit b7e718) --- Makefile.am | 9 ++- test/sysv-generator-test.py | 177 test/sysv-generator-test.sh | 33 + 3 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 test/sysv-generator-test.py create mode 100755 test/sysv-generator-test.sh diff --git a/Makefile.am b/Makefile.am index 788e634..f7ae578 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3767,7 +3767,9 @@ endif # -- TESTS += \ test/udev-test.pl \ - test/rules-test.sh + test/rules-test.sh \ + test/sysv-generator-test.sh \ + $(NULL) manual_tests += \ test-libudev \ @@ -3812,7 +3814,10 @@ EXTRA_DIST += \ test/sys.tar.xz \ test/udev-test.pl \ test/rules-test.sh \ - test/rule-syntax-check.py + test/rule-syntax-check.py \ + test/sysv-generator-test.sh \ + test/sysv-generator-test.py \ + $(NULL) # -- ata_id_SOURCES = \ diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py new file mode 100644 index 000..a3f80ca --- /dev/null +++ b/test/sysv-generator-test.py @@ -0,0 +1,177 @@ +# systemd-sysv-generator integration test +# +# (C) 2015 Canonical Ltd. +# Author: Martin Pitt martin.p...@ubuntu.com +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# systemd is
[systemd-devel] [PATCH] initial sysv-generator test suite
Hello all, We've had numerous problems with the SysV generator in the past, and we just recently introduced another regression: init.d scripts which end in .sh are now totally broken. Thus I think it's high time to write some integration tests for that. The attached patch provides the necessary framework and an initial set of tests; e. g. test_multiple_provides() covers Michael's recent commit b7e71846. I can reproduce the .sh bug from above with a simple |def test_sh_suffix(self): |'''init.d script with .sh suffix''' | |self.add_sysv('foo.sh', {}, enable=True) |err, results = self.run_generator() |[... actual checks here, not written yet ...] which currently fails with | == | FAIL: test_sh_suffix (__main__.SysvGeneratorTest) | init.d script with .sh suffix | -- | Traceback (most recent call last): | File test/../test/sysv-generator-test.py, line 179, in test_sh_suffix | err, results = self.run_generator() | File test/../test/sysv-generator-test.py, line 58, in run_generator | self.assertFalse('Fail' in err, err) | AssertionError: True is not false : Looking for unit files in (higher priority first): | /etc/systemd/system | /run/systemd/system | /usr/local/lib/systemd/system | /lib/systemd/system | /usr/lib/systemd/system | Looking for SysV init scripts in: | /tmp/sysv-gen-test.7qlq6kg2/init.d | Looking for SysV rcN.d links in: | /tmp/sysv-gen-test.7qlq6kg2 | Failed to create unit file /tmp/sysv-gen-test.7qlq6kg2/output/foo.service: File exists Indeed it just creates a symlink pointing to itself and nothing else. I will look into that actual bug in a bit, and write a complete test along with it. But before I spend more work on the tests, I'd appreciate a quick review of it whether the general structure is ok for you. As this deals with temp dirs, cleaning them up, running external programs, parsing their output etc., I chose Python for this, as this stuff is just s much faster and convenient to write. We already have test/rule-syntax-check.py, so there's precedent :-) As automake's tests are rather limited and require a single command without arguments, but I want to make this obey configure's $(PYTHON) and skip the test properly if python 3 is not available, I created a simple shell wrapper around it. Obviously this is still lacking a lot of important cases; I'm happy to add them later on, I just wanted to get some initial generic feedback. Thanks, Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) From 7d4f85e42ff5a7a05477e712dcb58ab99d02a87a Mon Sep 17 00:00:00 2001 From: Martin Pitt martin.p...@ubuntu.com Date: Tue, 20 Jan 2015 16:08:05 +0100 Subject: [PATCH] test: add initial integration test for systemd-sysv-generator This is still missing a lot of important scenarios and corner cases, but provides the groundwork and covers a recent bug (commit b7e718) --- Makefile.am | 9 ++- test/sysv-generator-test.py | 177 test/sysv-generator-test.sh | 33 + 3 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 test/sysv-generator-test.py create mode 100755 test/sysv-generator-test.sh diff --git a/Makefile.am b/Makefile.am index 788e634..f7ae578 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3767,7 +3767,9 @@ endif # -- TESTS += \ test/udev-test.pl \ - test/rules-test.sh + test/rules-test.sh \ + test/sysv-generator-test.sh \ + $(NULL) manual_tests += \ test-libudev \ @@ -3812,7 +3814,10 @@ EXTRA_DIST += \ test/sys.tar.xz \ test/udev-test.pl \ test/rules-test.sh \ - test/rule-syntax-check.py + test/rule-syntax-check.py \ + test/sysv-generator-test.sh \ + test/sysv-generator-test.py \ + $(NULL) # -- ata_id_SOURCES = \ diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py new file mode 100644 index 000..a3f80ca --- /dev/null +++ b/test/sysv-generator-test.py @@ -0,0 +1,177 @@ +# systemd-sysv-generator integration test +# +# (C) 2015 Canonical Ltd. +# Author: Martin Pitt martin.p...@ubuntu.com +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
On 20 January 2015 at 16:49, Martin Pitt martin.p...@ubuntu.com wrote: Zbigniew Jędrzejewski-Szmek [2015-01-20 16:48 +0100]: Maybe we could do this check in configure.ac/Makefile.am (add the test to the list conditinally)? Yes, that's a good idea. We already test for python presence and extract the version, so we shouldn't duplicate the tests here and have an extra wrapper. Unfortunately automake's TESTS only accepts single arguments, i. e. scripts without any arguments. But we need to call $(PYTHON) test/x.py thus we need an argument. With parallel test harness in automake (everyone should have it by now) you can set custom runner of your test, based on extensions, e.g. from automake manual: TESTS = foo.pl bar.py baz TEST_EXTENSIONS = .pl .py PL_LOG_COMPILER = $(PERL) AM_PL_LOG_FLAGS = -w PY_LOG_COMPILER = $(PYTHON) AM_PY_LOG_FLAGS = -v LOG_COMPILER = ./wrapper-script AM_LOG_FLAGS = -d If above is not enough hint, i can poke automake-foo to support $(PYTHON) tests when $(PYTHON) is available. An alternative would be to add a new TESTS_PYTHON = test/sysv-generator-test.py test/rule-syntax-check.py (and perhaps more in the future) and integrate that into Makefile.am. That would make Makefile.am more complex, but avoid the extra wrappers. WDYT? Thanks, Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Regards, Dimitri. Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 4/9] sd-icmp6-nd: Add helper function to get the IPv6 link MTU
Update MTU according to the latest value received. --- src/libsystemd-network/sd-icmp6-nd.c | 27 +++ src/systemd/sd-icmp6-nd.h| 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c index cff69c5..0cf2760 100644 --- a/src/libsystemd-network/sd-icmp6-nd.c +++ b/src/libsystemd-network/sd-icmp6-nd.c @@ -237,6 +237,18 @@ int sd_icmp6_nd_new(sd_icmp6_nd **ret) { return 0; } +int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu) { +assert_return(nd, -EINVAL); +assert_return(mtu, -EINVAL); + +if (nd-mtu == 0) +return -ENOMSG; + +*mtu = nd-mtu; + +return 0; +} + static int icmp6_ra_parse(sd_icmp6_nd *nd, struct nd_router_advert *ra, ssize_t len) { void *opt; @@ -256,11 +268,26 @@ static int icmp6_ra_parse(sd_icmp6_nd *nd, struct nd_router_advert *ra, opt_hdr = opt; while (len != 0 len = opt_hdr-nd_opt_len * ICMP6_OPT_LEN_UNITS) { +struct nd_opt_mtu *opt_mtu; +uint32_t mtu; if (opt_hdr-nd_opt_len == 0) return -ENOMSG; switch (opt_hdr-nd_opt_type) { +case ND_OPT_MTU: +opt_mtu = opt; + +mtu = be32toh(opt_mtu-nd_opt_mtu_mtu); + +if (mtu != nd-mtu) { +nd-mtu = MAX(mtu, IP6_MIN_MTU); + +log_icmp6_nd(nd, Router Advertisement link MTU %d using %d, + mtu, nd-mtu); +} + +break; } diff --git a/src/systemd/sd-icmp6-nd.h b/src/systemd/sd-icmp6-nd.h index 73f91aa..73ebccf 100644 --- a/src/systemd/sd-icmp6-nd.h +++ b/src/systemd/sd-icmp6-nd.h @@ -51,6 +51,8 @@ sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd); sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd); int sd_icmp6_nd_new(sd_icmp6_nd **ret); +int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu); + int sd_icmp6_nd_stop(sd_icmp6_nd *nd); int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd); -- 2.1.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 1/9] sd-dhcp6-lease: Revise address iteration functions
Revise the address iteration functions so that one helper function resets the iterator to the start of the address list while the second one fetches addresses one by one. The test case is also updated. --- src/libsystemd-network/sd-dhcp6-lease.c| 26 - src/libsystemd-network/test-dhcp6-client.c | 45 +++--- src/systemd/sd-dhcp6-lease.h | 13 - 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index 8960fac..542690e 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -146,10 +146,9 @@ int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid) { return 0; } -int sd_dhcp6_lease_get_next_address(sd_dhcp6_lease *lease, -struct in6_addr *addr, -uint32_t *lifetime_preferred, -uint32_t *lifetime_valid) { +int sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease, struct in6_addr *addr, + uint32_t *lifetime_preferred, + uint32_t *lifetime_valid) { assert_return(lease, -EINVAL); assert_return(addr, -EINVAL); assert_return(lifetime_preferred, -EINVAL); @@ -169,22 +168,9 @@ int sd_dhcp6_lease_get_next_address(sd_dhcp6_lease *lease, return 0; } -int sd_dhcp6_lease_get_first_address(sd_dhcp6_lease *lease, - struct in6_addr *addr, - uint32_t *lifetime_preferred, - uint32_t *lifetime_valid) { -assert_return(lease, -EINVAL); -assert_return(addr, -EINVAL); -assert_return(lifetime_preferred, -EINVAL); -assert_return(lifetime_valid, -EINVAL); - -if (!lease-ia.addresses) -return -ENOMSG; - -lease-addr_iter = lease-ia.addresses; - -return sd_dhcp6_lease_get_next_address(lease, addr, lifetime_preferred, - lifetime_valid); +void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease) { +if (lease) +lease-addr_iter = lease-ia.addresses; } sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease) { diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 7590839..9386f31 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -286,26 +286,27 @@ static int test_advertise_option(sd_event *e) { assert_se(opt_clientid); -assert_se(sd_dhcp6_lease_get_first_address(lease, addr, lt_pref, - lt_valid) = 0); +sd_dhcp6_lease_reset_address_iter(lease); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) = 0); assert_se(!memcmp(addr, msg_advertise[42], sizeof(addr))); assert_se(lt_pref == 150); assert_se(lt_valid == 180); -assert_se(sd_dhcp6_lease_get_next_address(lease, addr, lt_pref, - lt_valid) == -ENOMSG); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) == -ENOMSG); -assert_se(sd_dhcp6_lease_get_first_address(lease, addr, lt_pref, - lt_valid) = 0); +sd_dhcp6_lease_reset_address_iter(lease); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) = 0); assert_se(!memcmp(addr, msg_advertise[42], sizeof(addr))); -assert_se(sd_dhcp6_lease_get_next_address(lease, addr, lt_pref, - lt_valid) == -ENOMSG); -assert_se(sd_dhcp6_lease_get_next_address(lease, addr, lt_pref, - lt_valid) == -ENOMSG); -assert_se(sd_dhcp6_lease_get_first_address(lease, addr, lt_pref, - lt_valid) = 0); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) == -ENOMSG); +sd_dhcp6_lease_reset_address_iter(lease); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) = 0); assert_se(!memcmp(addr, msg_advertise[42], sizeof(addr))); -assert_se(sd_dhcp6_lease_get_next_address(lease, addr, lt_pref, - lt_valid) == -ENOMSG); +assert_se(sd_dhcp6_lease_get_address(lease, addr, lt_pref, + lt_valid) == -ENOMSG);
[systemd-devel] [PATCH v2 3/9] sd-icmp6-nd: Add link and prefix structures for ICMPv6
Each ICMPv6 structure has an interface index and will therefore be associated with an IPv6 link containing a list of of prefixes. --- v2: Keep the check that 'len' is not equal to zero as the option header points to the next option that might not exist One struct CamelCapsed, the other merged into sd_icmp6_nd Other changes according to comments src/libsystemd-network/sd-icmp6-nd.c | 52 1 file changed, 52 insertions(+) diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c index cac431b..85b8ff9 100644 --- a/src/libsystemd-network/sd-icmp6-nd.c +++ b/src/libsystemd-network/sd-icmp6-nd.c @@ -44,6 +44,18 @@ enum icmp6_nd_state { #define ICMP6_ND_RECV_SIZE (IP6_MIN_MTU - sizeof(struct ip6_hdr)) #define ICMP6_OPT_LEN_UNITS 8 +typedef struct ICMP6Prefix ICMP6Prefix; + +struct ICMP6Prefix { +RefCount n_ref; + +LIST_FIELDS(ICMP6Prefix, prefixes); + +uint8_t len; +sd_event_source *timeout_valid; +struct in6_addr addr; +}; + struct sd_icmp6_nd { RefCount n_ref; @@ -52,6 +64,8 @@ struct sd_icmp6_nd { int event_priority; int index; struct ether_addr mac_addr; +uint32_t mtu; +LIST_HEAD(ICMP6Prefix, prefixes); int fd; sd_event_source *recv; sd_event_source *timeout; @@ -62,6 +76,35 @@ struct sd_icmp6_nd { #define log_icmp6_nd(p, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, ICMPv6 CLIENT: fmt, ##__VA_ARGS__) +static ICMP6Prefix *icmp6_prefix_unref(ICMP6Prefix *prefix) { +if (prefix REFCNT_DEC(prefix-n_ref) = 0) { +prefix-timeout_valid = +sd_event_source_unref(prefix-timeout_valid); + +free(prefix); +} + +return NULL; +} + +static int icmp6_prefix_new(ICMP6Prefix **ret) { +_cleanup_free_ ICMP6Prefix *prefix = NULL; + +assert(ret); + +prefix = new0(ICMP6Prefix, 1); +if (!prefix) +return -ENOMEM; + +prefix-n_ref = REFCNT_INIT; +LIST_INIT(prefixes, prefix); + +*ret = prefix; +prefix = NULL; + +return 0; +} + static void icmp6_nd_notify(sd_icmp6_nd *nd, int event) { if (nd-callback) @@ -152,10 +195,17 @@ static int icmp6_nd_init(sd_icmp6_nd *nd) { sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd) { if (nd REFCNT_DEC(nd-n_ref) == 0) { +ICMP6Prefix *prefix, *p; icmp6_nd_init(nd); sd_icmp6_nd_detach_event(nd); +LIST_FOREACH_SAFE(prefixes, prefix, p, nd-prefixes) { +LIST_REMOVE(prefixes, nd-prefixes, prefix); + +prefix = icmp6_prefix_unref(prefix); +} + free(nd); } @@ -179,6 +229,8 @@ int sd_icmp6_nd_new(sd_icmp6_nd **ret) { nd-index = -1; nd-fd = -1; +LIST_HEAD_INIT(nd-prefixes); + *ret = nd; nd = NULL; -- 2.1.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 5/9] test-icmp6-rs: Add trivial test case for an MTU that is not present
--- src/libsystemd-network/test-icmp6-rs.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libsystemd-network/test-icmp6-rs.c b/src/libsystemd-network/test-icmp6-rs.c index be64d33..9d50c57 100644 --- a/src/libsystemd-network/test-icmp6-rs.c +++ b/src/libsystemd-network/test-icmp6-rs.c @@ -93,6 +93,8 @@ static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) { { ND_RA_FLAG_OTHER, ICMP6_EVENT_ROUTER_ADVERTISMENT_OTHER }, { ND_RA_FLAG_MANAGED, ICMP6_EVENT_ROUTER_ADVERTISMENT_MANAGED } }; +uint32_t mtu; + assert_se(nd); assert_se(event == flag_event[idx].event); @@ -101,10 +103,14 @@ static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) { if (verbose) printf( got event %d\n, event); -if (idx 3) +if (idx 3) { send_ra(flag_event[idx].flag); -else -sd_event_exit(e, 0); +return; +} + +assert_se(sd_icmp6_ra_get_mtu(nd, mtu) == -ENOMSG); + +sd_event_exit(e, 0); } static void test_rs(sd_event *e) { -- 2.1.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 8/9] sd-icmp6-nd: Add support for fetching the latest expired prefix
Keep the expired prefix for the duration of the prefix expiration event and remove it afterwards. --- src/libsystemd-network/sd-icmp6-nd.c | 20 src/systemd/sd-icmp6-nd.h| 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c index 4ebeeef..f09ad60 100644 --- a/src/libsystemd-network/sd-icmp6-nd.c +++ b/src/libsystemd-network/sd-icmp6-nd.c @@ -65,6 +65,7 @@ struct sd_icmp6_nd { int index; struct ether_addr mac_addr; uint32_t mtu; +ICMP6Prefix *expired_prefix; LIST_HEAD(ICMP6Prefix, prefixes); int fd; sd_event_source *recv; @@ -266,8 +267,11 @@ static int icmp6_ra_prefix_timeout(sd_event_source *s, uint64_t usec, LIST_REMOVE(prefixes, nd-prefixes, prefix); +nd-expired_prefix = prefix; icmp6_nd_notify(nd, ICMP6_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED); +nd-expired_prefix = NULL; + prefix = icmp6_prefix_unref(prefix); break; @@ -372,6 +376,22 @@ int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr, return 0; } +int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr, +uint8_t *prefixlen) +{ +assert_return(nd, -EINVAL); +assert_return(addr, -EINVAL); +assert_return(prefixlen, -EINVAL); + +if (!nd-expired_prefix) +return -EADDRNOTAVAIL; + +*addr = nd-expired_prefix-addr; +*prefixlen = nd-expired_prefix-len; + +return 0; +} + static int icmp6_ra_prefix_update(sd_icmp6_nd *nd, ssize_t len, const struct nd_opt_prefix_info *prefix_opt) { int r; diff --git a/src/systemd/sd-icmp6-nd.h b/src/systemd/sd-icmp6-nd.h index 86cf25a..79b4074 100644 --- a/src/systemd/sd-icmp6-nd.h +++ b/src/systemd/sd-icmp6-nd.h @@ -58,6 +58,8 @@ int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen, int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu); int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr, uint8_t *prefixlen); +int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr, +uint8_t *prefixlen); int sd_icmp6_nd_stop(sd_icmp6_nd *nd); int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd); -- 2.1.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
On 01/20/2015 03:19 PM, Martin Pitt wrote: initial generic feedback We only provide backwards compatibility with initscript which are lsb compliance and I dont think .something ending on a script confirms to that standard hence that test should be unnecessary and that initscript be fixed upstream as in that .something ending removed ( or better yet that initscript be migrated ) JBG ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] networkd link file not setting MTU
Hi Ian, Did you try to reboot? Note that .link files are applied by udev (so usually during early boot). You can override their settings from .network files in some cases (at least with current git you can). I was not able to reproduce here (with git). journalctl -b -u systemd-udevd may contain some hints if you can still reproduce when rebooting. Cheers, Tom On Wed, Jan 21, 2015 at 12:48 AM, Ian Pilcher arequip...@gmail.com wrote: I am trying to use systemd-networkd on Fedora 21, and I haven't been able to get it to set the MTU of an interface correctly: [root@localhost network]# cat eth0.link [Match] MACAddress=52:54:00:d8:3d:3e [Link] MTUBytes=8996 [root@localhost network]# [root@localhost network]# cat eth0.network [Match] MACAddress=52:54:00:d8:3d:3e [Network] DHCP=yes [root@localhost network]# ifconfig eth0: flags=4163UP,BROADCAST,RUNNING,MULTICAST mtu 1500 inet 172.31.253.166 netmask 255.255.255.0 broadcast 172.31.253.255 inet6 fe80::5054:ff:fed8:3d3e prefixlen 64 scopeid 0x20link ether 52:54:00:d8:3d:3e txqueuelen 1000 (Ethernet) RX packets 389 bytes 35608 (34.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 245 bytes 28600 (27.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73UP,LOOPBACK,RUNNING mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10host loop txqueuelen 0 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 As you can see, the MTU is not being set, although setting it manually works fine: [root@localhost network]# ifconfig eth0 mtu 8996 [root@localhost network]# ifconfig eth0 eth0: flags=4163UP,BROADCAST,RUNNING,MULTICAST mtu 8996 inet 172.31.253.166 netmask 255.255.255.0 broadcast 172.31.253.255 inet6 fe80::5054:ff:fed8:3d3e prefixlen 64 scopeid 0x20link ether 52:54:00:d8:3d:3e txqueuelen 1000 (Ethernet) RX packets 586 bytes 51538 (50.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 288 bytes 33908 (33.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 Any idea what I'm missing? -- Ian Pilcher arequip...@gmail.com I grew up before Mark Zuckerberg invented friendship ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
On Tue, Jan 20, 2015 at 8:08 PM, Martin Pitt martin.p...@ubuntu.com wrote: Hey Jóhann, Jóhann B. Guðmundsson [2015-01-20 17:55 +]: We only provide backwards compatibility with initscript which are lsb compliance and I dont think .something ending on a script confirms to that standard hence that test should be unnecessary and that initscript be fixed upstream as in that .something ending removed ( or better yet that initscript be migrated ) But the generator already handles .sh extensions, as they do exist in the wild (and being compatible to them is the whole point of the generator -- for new things you'd write a proper unit right away). It's just missing that .sh extension handling in that particular place, and as it's (correctly) doing it in another you get that bug. Initscripts ending with .sh was indeed a case handled by the sysv-generator from the beginning. I think that fixing this specific issue makes sense and the patch (in the other email) looks pretty simple to me. Thanks for writing all these tests Martin. The bugs found in the generator are embarrassing and in hindsight I should have tested this more thoroughly on a debian system instead of just fedora. I look forward to all your tests of this. Let me know if I can help out with extending the test cases or anything. - Thomas ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] networkd link file not setting MTU
On Tue, Jan 20, 2015 at 4:40 PM, Tom Gundersen t...@jklm.no wrote: Hi Ian, Did you try to reboot? Note that .link files are applied by udev (so usually during early boot). You can override their settings from .network files in some cases (at least with current git you can). Out of curiosity and for future reference, is there any way to get udev to apply the link files without rebooting? E.g. possibly with a udevadm trigger command of some sort. Thank you, -- Cameron Norman ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] networkd link file not setting MTU
I am trying to use systemd-networkd on Fedora 21, and I haven't been able to get it to set the MTU of an interface correctly: [root@localhost network]# cat eth0.link [Match] MACAddress=52:54:00:d8:3d:3e [Link] MTUBytes=8996 [root@localhost network]# [root@localhost network]# cat eth0.network [Match] MACAddress=52:54:00:d8:3d:3e [Network] DHCP=yes [root@localhost network]# ifconfig eth0: flags=4163UP,BROADCAST,RUNNING,MULTICAST mtu 1500 inet 172.31.253.166 netmask 255.255.255.0 broadcast 172.31.253.255 inet6 fe80::5054:ff:fed8:3d3e prefixlen 64 scopeid 0x20link ether 52:54:00:d8:3d:3e txqueuelen 1000 (Ethernet) RX packets 389 bytes 35608 (34.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 245 bytes 28600 (27.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73UP,LOOPBACK,RUNNING mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10host loop txqueuelen 0 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 As you can see, the MTU is not being set, although setting it manually works fine: [root@localhost network]# ifconfig eth0 mtu 8996 [root@localhost network]# ifconfig eth0 eth0: flags=4163UP,BROADCAST,RUNNING,MULTICAST mtu 8996 inet 172.31.253.166 netmask 255.255.255.0 broadcast 172.31.253.255 inet6 fe80::5054:ff:fed8:3d3e prefixlen 64 scopeid 0x20link ether 52:54:00:d8:3d:3e txqueuelen 1000 (Ethernet) RX packets 586 bytes 51538 (50.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 288 bytes 33908 (33.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 Any idea what I'm missing? -- Ian Pilcher arequip...@gmail.com I grew up before Mark Zuckerberg invented friendship ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
Martin Pitt [2015-01-20 16:19 +0100]: Thus I think it's high time to write some integration tests for that. The attached patch provides the necessary framework and an initial set of tests; e. g. test_multiple_provides() covers Michael's recent commit b7e71846. Zbigniew and Thomas generally ack'ed this, so I pushed this as http://cgit.freedesktop.org/systemd/systemd/commit/?id=e28aa58 Improvements since the first version: - no shell wrapper any more - several new tests, including a reproducer for the bogus orderings bug in commit 1ed0c19 - assert_enabled() helper for making test cases smaller - now works with both python 2 and 3, so the $(PYTHON) is python3 condition got dropped Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2] sysv-generator: Handle .sh suffixes when translating Provides:
Martin Pitt [2015-01-20 17:44 +0100]: the recent fix for sysv-generator's Provides: handling [1] caused, or rather uncovered, another bug which now creates symlinks to itself foo.service - foo.service for any /etc/init.d/foo.sh. The generator would output an error message like Failed to create unit file path.../foo.service: File exists instead of creating the actual foo.service file. I. e. this completely breaks translating init scripts with .sh. Reworked the patch to apply to current master (where the sysv-generator test suite now landed), drop the log_debug() leftover, and clean up the tests. Note that Michael points out some more problems with the Provides: alias handling ([1], [2]); I'll work on those next, but this is already a self-contained and urgent fix, so I think it's good to push. Thanks, Martin [1] https://bugs.debian.org/775265#36 [2] https://bugs.debian.org/775404 -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) From 300db087ab7ef2769d3b0528a41abbf505194ff7 Mon Sep 17 00:00:00 2001 From: Martin Pitt martin.p...@ubuntu.com Date: Tue, 20 Jan 2015 16:41:31 +0100 Subject: [PATCH] sysv-generator: Handle .sh suffixes when translating Provides: When deciding whether the provided name equals the file name in sysv_translate_facility(), also consider them equal if the file name has a .sh suffix. This was uncovered by commit b7e7184 which then created a symlink name.service to itself for .sh suffixed init.d scripts. For additional robustness, refuse to create symlinks to itself in add_alias(). Add test case which reproduces the bug. --- src/sysv-generator/sysv-generator.c | 15 ++- test/sysv-generator-test.py | 36 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 4774981..a47b072 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -119,6 +119,11 @@ static int add_alias(const char *service, const char *alias) { assert(service); assert(alias); +if (streq(service, alias)) { +log_error(Ignoring creation of an alias %s for itself, service); +return 0; +} + link = strjoin(arg_dest, /, alias, NULL); if (!link) return log_oom(); @@ -263,6 +268,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char unsigned i; char *r; const char *n; +_cleanup_free_ char *filename_no_sh = NULL; assert(name); assert(_r); @@ -284,6 +290,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char goto finish; } +/* strip .sh suffix from file name for comparison */ +filename_no_sh = strdup(filename); +if (!filename_no_sh) +return -ENOMEM; +if (endswith(filename, .sh)) +filename_no_sh[strlen(filename)-3] = '\0'; + /* If we don't know this name, fallback heuristics to figure * out whether something is a target or a service alias. */ @@ -293,7 +306,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char /* Facilities starting with $ are most likely targets */ r = unit_name_build(n, NULL, .target); -} else if (filename streq(name, filename)) +} else if (filename streq(name, filename_no_sh)) /* Names equaling the file name of the services are redundant */ return 0; else diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py index 028de91..6193b3d 100644 --- a/test/sysv-generator-test.py +++ b/test/sysv-generator-test.py @@ -275,6 +275,42 @@ class SysvGeneratorTest(unittest.TestCase): err, results = self.run_generator() self.assertEqual(results, {}) +def test_sh_suffix(self): +'''init.d script with .sh suffix''' + +self.add_sysv('foo.sh', {}, enable=True) +err, results = self.run_generator() +s = results['foo.service'] + +self.assertEqual(s.sections(), ['Unit', 'Service']) +# should not have a .sh +self.assertEqual(s.get('Unit', 'Description'), 'LSB: test foo service') + +# calls correct script with .sh +init_script = os.path.join(self.init_d_dir, 'foo.sh') +self.assertEqual(s.get('Service', 'ExecStart'), + '%s start' % init_script) +self.assertEqual(s.get('Service', 'ExecStop'), + '%s stop' % init_script) + +self.assert_enabled('foo.service', [2, 3, 4, 5]) + +def test_sh_suffix_with_provides(self): +'''init.d script with .sh suffix and Provides:''' + +self.add_sysv('foo.sh', {'Provides': 'foo
Re: [systemd-devel] [PATCH] Fix systemd crash (on assert) during shutdown/reboot in unprivileged container
Andrei Borzenkov [2015-01-16 19:32 +0300]: If I as user do systemctl stop /dev/pts I expect it to unmount /dev/pts not fake dead state. Well, not all such commands can be expected to do something useful. Stopping mounts which the system depends on is going to break it, so trying to systemctl stop -- -.mount is rightfully refused already, while unmounting other things like /dev/pts will just eventually break your system anyway. Personally I think that Stephane's second patch was just about the right compromise: http://lists.freedesktop.org/archives/systemd-devel/attachments/20150115/f56f60ce/attachment-0001.patch It is reasonably future-proof (unlike the first patch) and avoids the problem you mentioned too, i. e. silently not doing operations while they appear to be successful. @Lennart: We now have three patches -- could you make an executive decision which one we take? :-) Thanks, Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) signature.asc Description: Digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
Hey Dimitri, Dimitri John Ledkov [2015-01-20 18:23 +]: With parallel test harness in automake (everyone should have it by now) you can set custom runner of your test, based on extensions, e.g. from automake manual: TESTS = foo.pl bar.py baz TEST_EXTENSIONS = .pl .py PL_LOG_COMPILER = $(PERL) AM_PL_LOG_FLAGS = -w PY_LOG_COMPILER = $(PYTHON) Yay, thanks for pointing this out! That makes the whole thing indeed much friendlier. I pushed http://cgit.freedesktop.org/systemd/systemd/commit/?id=e8015e6e2 as preparatory work to move the remaining logic out of the rules-test.sh wrapper for rule-syntax-check.py, and then http://cgit.freedesktop.org/systemd/systemd/commit/?id=72521ab9fd to eliminiate it completely, and only run the *.py tests with HAVE_PYTHON. I'll rework the sysv-generator test suite patch tomorrow and add some more tests. Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] initial sysv-generator test suite
Hey Jóhann, Jóhann B. Guðmundsson [2015-01-20 17:55 +]: We only provide backwards compatibility with initscript which are lsb compliance and I dont think .something ending on a script confirms to that standard hence that test should be unnecessary and that initscript be fixed upstream as in that .something ending removed ( or better yet that initscript be migrated ) But the generator already handles .sh extensions, as they do exist in the wild (and being compatible to them is the whole point of the generator -- for new things you'd write a proper unit right away). It's just missing that .sh extension handling in that particular place, and as it's (correctly) doing it in another you get that bug. Martin -- Martin Pitt| http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel