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

Fix systemd command line quoting #18865

Merged
merged 4 commits into from
Dec 4, 2024
Merged

Fix systemd command line quoting #18865

merged 4 commits into from
Dec 4, 2024

Conversation

ZhongRuoyu
Copy link
Member

@ZhongRuoyu ZhongRuoyu commented Dec 3, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

We need a way to escape systemd command lines properly as systemd treats unrecognised escape sequences as separate literal characters. So, a helper function Utils::Service::systemd_quote is added and used for generation of systemd unit config files, replacing Utils::Shell::sh_quote.

Fixes #18802 (affected formulae still need rebuilding can be fixed by brew reinstall as service file is re-generated at install time).

We need a way to escape systemd command lines properly as systemd treats
unrecognised escape sequences as separate literal characters. This helper
function does that.
Fixes #18802 (affected formulae still need rebuilding).
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ZhongRuoyu, good idea!

@MikeMcQuaid MikeMcQuaid enabled auto-merge December 4, 2024 09:25
@MikeMcQuaid MikeMcQuaid merged commit 2d8a19d into master Dec 4, 2024
28 checks passed
@MikeMcQuaid MikeMcQuaid deleted the systemd-quote branch December 4, 2024 10:25
apainintheneck added a commit that referenced this pull request Dec 7, 2024
This was originally added in #18865.

```console
$ brew ruby -e 'p "activemq".f.service.to_systemd_unit'
/usr/local/Homebrew/Library/Homebrew/service.rb:458:in `block in to_systemd_unit': uninitialized constant Utils::Service (NameError)
        from /usr/local/Homebrew/Library/Homebrew/service.rb:458:in `map'
        from /usr/local/Homebrew/Library/Homebrew/service.rb:458:in `to_systemd_unit'
        from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11685/lib/types/private/methods/call_validation.rb:278:in `bind_call'
        from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11685/lib/types/private/methods/call_validation.rb:278:in `validate_call'
        from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11685/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
        from -e:1:in `<main>'
```

```console
$ brew ruby -e 'p "activemq".f.service.to_systemd_unit'
"[Unit]\nDescription=Homebrew generated unit for activemq\n\n[Install]\nWantedBy=default.target\n\n[Service]\nType=simple\nExecStart=\"/usr/local/opt/activemq/bin/activemq\" \"console\"\nWorkingDirectory=/usr/local/opt/activemq/libexec\n"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman cannot start on Linux due to faulty homebrew.podman.service file
3 participants