machine: escape % as %% in proxy values written to systemd unit conf#28820
Open
crawfordxx wants to merge 1 commit into
Open
machine: escape % as %% in proxy values written to systemd unit conf#28820crawfordxx wants to merge 1 commit into
crawfordxx wants to merge 1 commit into
Conversation
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
Honny1
reviewed
Jun 1, 2026
Contributor
Author
|
Thanks for the review, @Honny1! A test case covering the percent-sign escaping is already included in the PR: the "percent sign in proxy value is escaped for systemd" case in |
Honny1
reviewed
Jun 2, 2026
Contributor
Honny1
left a comment
There was a problem hiding this comment.
LGTM, please rebase on upstream main to run new CI. Thanks.
c1d5158 to
c2a2c72
Compare
systemd interprets % as specifier characters in unit configuration files (e.g. %H, %u, %40). Proxy environment variable values that contain percent-encoded URL characters (such as %40 for @ in usernames) cause systemd to emit warnings and fail to parse the generated /etc/systemd/system.conf.d/default-env.conf: system.conf.d/default-env.conf:2: Failed to resolve specifiers in HTTP_PROXY=http://user%40example.com@proxy:3128 Fix by adding a bash variable substitution that doubles every % to %% before writing to the systemd unit conf files. The profile.d and environment.d destinations do not need this escaping and continue to use the original value. Fixes podman-container-tools#28698 Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
c2a2c72 to
e250df5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
systemd treats
%as a specifier character in unit configuration files(e.g.
%H→ hostname,%40→@in percent-encoded strings).When proxy environment variables contain URL-percent-encoded characters
(common in credentials:
http://user%40example.com@proxy:3128), thegenerated
/etc/systemd/system.conf.d/default-env.confcontainsbare
%sequences that systemd tries to expand as specifiers, leading to:Fix
Introduce a bash variable substitution
${proxy//%/%%}that doublesevery
%to%%before writing to the systemd-specific conf files.The
%%is then decoded by systemd back to a literal%, preservingthe original value.
The
/etc/profile.d/default-env.shand/etc/environment.d/default-env.confdestinations do not perform specifier expansion, so they continue to use the
original value without escaping.
A new test case covering a proxy value with a percent-encoded character
is added alongside the update to the existing expected output.
Fixes #28698