RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1288600 - sysv generator may produce unit file containing lines that are longer than 2048 characters
Summary: sysv generator may produce unit file containing lines that are longer than 20...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: Branislav Blaškovič
URL:
Whiteboard:
Depends On:
Blocks: 1203710 1289485 1313485
TreeView+ depends on / blocked
 
Reported: 2015-12-04 17:12 UTC by Zdenek Pytela
Modified: 2019-12-16 05:09 UTC (History)
8 users (show)

Fixed In Version: systemd-219-20.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 00:48:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 2099 0 None closed systemd limits maximum length of input line in unit file to 2048 bytes 2020-09-16 08:53:10 UTC
Red Hat Knowledge Base (Solution) 3187552 0 None None None 2017-09-18 10:01:11 UTC
Red Hat Product Errata RHBA-2016:2216 0 normal SHIPPED_LIVE systemd bug fix and enhancement update 2016-11-03 13:24:51 UTC

Description Zdenek Pytela 2015-12-04 17:12:00 UTC
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

Comment 2 Michal Sekletar 2015-12-04 19:32:13 UTC
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

Comment 3 Zdenek Pytela 2015-12-07 09:45:33 UTC
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.

Comment 4 Lukáš Nykrýn 2016-01-12 14:20:06 UTC
> 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.

Comment 5 Lukáš Nykrýn 2016-01-21 13:11:31 UTC
We need to backport https://github.com/systemd/systemd/commit/c584ffc0b75d4b9e9229bf1d8edb7d89562be3c1

Comment 6 Lars Delhage 2016-01-21 14:16:18 UTC
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

Comment 7 Lukáš Nykrýn 2016-01-21 14:32:14 UTC
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.

Comment 8 Lukáš Nykrýn 2016-01-29 15:04:35 UTC
backported to staging https://github.com/lnykryn/systemd-rhel/commit/72b3ff75e786efa2c9b2fdfb50e46597434c5420 -> post

Comment 15 Branislav Blaškovič 2016-09-13 12:42:24 UTC
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.

Comment 17 errata-xmlrpc 2016-11-04 00:48:10 UTC
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


Note You need to log in before you can comment on or make changes to this bug.