Bug 1288600
| Summary: | sysv generator may produce unit file containing lines that are longer than 2048 characters | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Zdenek Pytela <zpytela> |
| Component: | systemd | Assignee: | systemd-maint |
| Status: | CLOSED ERRATA | QA Contact: | Branislav Blaškovič <bblaskov> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.2 | CC: | bblaskov, fkrska, jscotka, ldelhage, lnykryn, msekleta, systemd-maint-list, systemd-maint |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | systemd-219-20.el7 | Doc Type: | Bug Fix |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2016-11-04 00:48:10 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1203710, 1289485, 1313485 | ||
systemd generally uses fgets() function for line oriented input. We pass to fgets() stack allocated array of size LINE_MAX. Constant LINE_MAX is on Linux defined as _POSIX2_LINE_MAX. Minimum length of _POSIX2_LINE_MAX according to spec is 2048 [1]. Note that LINE_MAX is compile time constant. I am not entirely sure what would be the best fix. Probably the easiest one, is to redefine LINE_MAX to some higher value. Another option is to use getline() instead of fgets() for line oriented input. I think that would be the preferred option, however it requires patching systemd in many places. At any rate, I will bring this upstream. [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html Michal, Thank you for explanation. What could be a recommended workaround for now, creating a meta-target, possibly more targets with a wrapper script? I would also like to raise a question if some of the directives can be specified multiple times, i. e. After=a.service After=b.service in future versions. > I would also like to raise a question if some of the directives can be
> specified multiple times, i. e.
> After=a.service
> After=b.service
This is absolutely fine and you can do that.
We need to backport https://github.com/systemd/systemd/commit/c584ffc0b75d4b9e9229bf1d8edb7d89562be3c1 I was the one who initiated this bugzilla and our case is that we get units like this generated by systemd from SysV init-scripts, since we have loads of SysV init-scripts. So in our case it's not a sloution to put several "After" on separate line, since the unit file (/run/systemd/generator.late/foo.service is auto-generated. Our workaround so far (until we move to native systemd unit files) is to have the same start value in the LSB header for all our SysV services. It looks like it's been fixed in https://github.com/systemd/systemd/pull/2401 By the way, as a workaround you can now compile the systemd-sysv-generator from upstream sources and replace the shipped one in /usr/lib/systemd/systemd-generators But anyway I will try to backport it to rhel-7.3. backported to staging https://github.com/lnykryn/systemd-rhel/commit/72b3ff75e786efa2c9b2fdfb50e46597434c5420 -> post The attached testcase tests, if sysv-generator generates multiple After/Before lines on /etc/init.d/network initscript (which is part of initscripts component). NEW PACKAGE: :: [ LOG ] :: Package versions: :: [ LOG ] :: systemd-219-29.el7.x86_64 :: [ PASS ] :: Command '/usr/lib/systemd/system-generators/systemd-sysv-generator' (Expected 0, got 0) :: [ PASS ] :: Command 'grep After /tmp/network.service' (Expected 0, got 0) :: [ PASS ] :: Command 'test 1 -lt 6' (Expected 0, got 0) :: [ PASS ] :: Command 'grep Before /tmp/network.service' (Expected 0, got 0) :: [ PASS ] :: Command 'test 1 -lt 7' (Expected 0, got 0) :: [ LOG ] :: Duration: 1s :: [ LOG ] :: Assertions: 5 good, 0 bad :: [ PASS ] :: RESULT: Test OLD PACKAGE: :: [ LOG ] :: Package versions: :: [ LOG ] :: systemd-219-19.el7.x86_64 :: [ PASS ] :: Command '/usr/lib/systemd/system-generators/systemd-sysv-generator' (Expected 0, got 0) :: [ PASS ] :: Command 'grep After /tmp/network.service' (Expected 0, got 0) :: [ PASS ] :: Command 'test 1 -lt 2' (Expected 0, got 0) :: [ PASS ] :: Command 'grep Before /tmp/network.service' (Expected 0, got 0) :: [ FAIL ] :: Command 'test 1 -lt 1' (Expected 0, got 1) :: [ LOG ] :: Duration: 0s :: [ LOG ] :: Assertions: 4 good, 1 bad :: [ FAIL ] :: RESULT: Test Removing need info, as far as changing of summary kind of answers it. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2016-2216.html |
Description of problem: systemd fails to load a unit with a line longer than 2048 characters Version-Release number of selected component (if applicable): systemd-219-19.el7.x86_64 How reproducible: always Steps to Reproduce: 1. After= line with more than 2048 characters in a service unit Actual results: # systemctl status rsyncd -l Failed to restart rsyncd.service: Unit rsyncd.service failed to load: Bad message. See system logs and 'systemctl status rsyncd.service' for details. ● rsyncd.service - fast remote file copy program daemon Loaded: error (Reason: Bad message) Active: active (running) since Fri 2015-12-04 18:03:09 CET; 16s ago Main PID: 15886 (rsync) CGroup: /system.slice/rsyncd.service └─15886 /usr/bin/rsync --daemon --no-detach dec 04 18:03:09 my-rhel71 systemd[1]: Started fast remote file copy program daemon. dec 04 18:03:09 my-rhel71 systemd[1]: Starting fast remote file copy program daemon... dec 04 18:03:09 my-rhel71 rsyncd[15886]: rsyncd version 3.0.9 starting, listening on port 873 dec 04 18:03:09 my-rhel71 rsyncd[15886]: rsyncd version 3.0.9 starting, listening on port 873 dec 04 18:03:25 my-rhel71 systemd[1]: [/usr/lib/systemd/system/rsyncd.service:4] Failed to add dependency on juno-fra, ignoring: Invalid argument dec 04 18:03:25 my-rhel71 systemd[1]: [/usr/lib/systemd/system/rsyncd.service:5] Missing '='. Expected results: <no error> Additional info: reproduced on After= and Before= lines