Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnvironmentFile parsing: line continuation characters at the end of comments are not ignored #27975

Closed
rocketraman opened this issue Jun 8, 2023 · 0 comments · Fixed by #28079
Labels
bug 🐛 Programming errors, that need preferential fixing pid1

Comments

@rocketraman
Copy link

rocketraman commented Jun 8, 2023

systemd version the issue has been seen with

253

Used distribution

Fedora CoreOS 38

Linux kernel version used

6.2.15-300.fc38.x86_64

CPU architectures issue was seen on

x86_64

Component

systemd

Expected behaviour you didn't see

I have a unit that references an EnvironmentFile. My environment file looks like this:

# This is a comment \
FOO=bar

My expectation is that FOO will be set to bar, as the line-continuation character should be ignored since it is part of a comment.

For reference: POSIX shells (tried with sh and bash) ignore the line-continuation character at the end of a comment. For example:

#!/bin/sh
# This is a comment \
FOO=bar
echo $FOO

will print bar.

Unexpected behaviour you saw

systemd is parsing the line continuation character at the end of the comment line, and thus including the next FOO=bar line as part of the comment.

Steps to reproduce the problem

No response

Additional program output to the terminal or log subsystem illustrating the issue

No response

@rocketraman rocketraman added the bug 🐛 Programming errors, that need preferential fixing label Jun 8, 2023
@github-actions github-actions bot added the pid1 label Jun 8, 2023
timkenhan pushed a commit to timkenhan/elogind that referenced this issue Oct 24, 2023
…te COMMENT_ESCAPE

When we see a "\" in COMMENT state, we change the state to COMMENT_ESCAPE. When we got
a new character, we reset the state to COMMENT, but this character is not dispatched.
Usually the character is NEWLINE, if so we will stay in COMMENT state until we find
the next NEWLINE.

fix: systemd/systemd#27975
Yamakuzure pushed a commit to elogind/elogind that referenced this issue Nov 11, 2023
…te COMMENT_ESCAPE

When we see a "\" in COMMENT state, we change the state to COMMENT_ESCAPE. When we got
a new character, we reset the state to COMMENT, but this character is not dispatched.
Usually the character is NEWLINE, if so we will stay in COMMENT state until we find
the next NEWLINE.

fix: systemd/systemd#27975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing pid1
Development

Successfully merging a pull request may close this issue.

1 participant