Bug 85308 - unit file options longer than 2048 characters are truncated
Summary: unit file options longer than 2048 characters are truncated
Status: RESOLVED MOVED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-21 23:59 UTC by Brian Waldon
Modified: 2017-02-10 10:15 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Brian Waldon 2014-10-21 23:59:55 UTC
Create a unit with an option longer than 2048 characters and attempt to start it. Check `systemctl status` and you are likely to see an error. The unit I used is a single ExecStart statement trying to echo 2018 periods:

[Service]
ExecStart=/bin/bash -c "echo ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................."


And here are the logs:

Oct 21 23:54:53 core-01 systemd[1]: [/run/systemd/system/foo.service:3] Missing '='.
Oct 21 23:54:58 core-01 systemd[1]: [/run/systemd/system/foo.service:2] String is not UTF-8 clean, ignoring assignment: /bin/bash -c "echo ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................


Note that the error seems to be telling me I have a malformed option line, but it clearly chopped off the trailing double quote that would make it valid. I dug into this a bit, and it looks like shared/config-parser.c's config_parse uses LINE_MAX, which is defined as 2048 on my system. I tried googling around for any documentation of what the actual line limit is, and came up empty handed.

The ideal path forward here is to remove the line length limit. If that is unreasonable, this limit should at least be documented somewhere obvious. Additionally, the line length should be checked and logged, as the unrelated error I ran into ("String is not UTF-8 clean") is a red herring.
Comment 1 Patrick Hemmer 2014-11-04 18:30:35 UTC
Is there any available workaround for this issue? I know with ExecStart, you can use a backslash to suppress the newline character, but this appears specific to ExecStart, and it does not work with other parameters such as Environment.
Comment 2 Lennart Poettering 2014-12-09 00:37:47 UTC
We have to enforce a line limit here, we cannot accept unbounded lines. Currently we use glibc's LINE_MAX limit for enforcement. We could of course bump the limit, but that's really just an arms race.

We should probably consider overly long lines parse failures. THe current bheaviour of just blindly pretend there was a line break after 2k chars is certaionly not good.
Comment 3 Lennart Poettering 2017-02-10 10:15:03 UTC
This is also tracked at:

https://github.com/systemd/systemd/issues/3302

Closing this here.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.