Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Services command results in startup errors when run with sudo #26214

Closed
wants to merge 1 commit into from

7 participants

Mo Lawson Adam Vandenberg Mike McQuaid Jan-Henrik Bruhn Bo Jeanes Chad Catlett Jack Nagel
Mo Lawson

I've just started using the brew services commands and ran into problems when I tried to use them with sudo to have a few services (dnsmasq and nginx) launch at startup (e.g. sudo brew services start dnsmasq)

In both cases, I didn't get any errors from the services commands directly, but neither service would actually start. I checked out the system logs, and both services were exiting with error codes when launchd tried to start them.

It appears to be a permissions/ownership problem caused by my user name being added to the generated plist file here. I updated those lines to skip making the UserName edits if the command has been run as root. That has fixed the issue for me, and the non-sudo version of the command still works, as well, but I'm not sure if the assumption I've made in these changes is a valid one for all cases.

Thanks for taking a look! And here is the output the config, etc. commands.

Adam Vandenberg adamv added the integration label
Mo Lawson

Any chance I could get someone to take a look at this PR? If it needs more info or clarification, I'd be happy to do that.

Adam Vandenberg
Owner

@Homebrew/owners who owns the services command?

Mike McQuaid
Owner

@adamv No-one, it seems. I don't think any of us use it. I wonder about having such things in Contributions, honestly.

Adam Vandenberg
Owner

I suggest it be ejected to a separate repository maintained by those that use it or wrote it.

Ping @jhbruhn

Not sure who else to ping from the file history.

Adam Vandenberg adamv added the contrib label
Jan-Henrik Bruhn

Uhm, AFAIK I never touched brew services. @adamv perhaps you opened brew-server? That's the only command I contributed to.

Adam Vandenberg
Owner

Sorry, I read the wrong file.

Adam Vandenberg
Owner

Ping @bjeanes & @chadcatlett - any interest in maintaining this command in an external repo?

Bo Jeanes

I use it, but I consider the feature mostly broken. I really want a nice way to do it, but don't want to maintain it. +1 for removing it. It can be excavated and extracted later by those who are sufficiently motivated (possibly future me).

Chad Catlett

I agree. While I do use it, it has a lot of issues. I'd say remove it until something better can come along, or someone creates something in their own repo.

Adam Vandenberg adamv self-assigned this
Adam Vandenberg adamv removed their assignment
Jack Nagel
Owner

Closing because of #28657.

Jack Nagel jacknagel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 27, 2014
  1. Mo Lawson
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 Library/Contributions/cmd/brew-services.rb
4 Library/Contributions/cmd/brew-services.rb
View
@@ -348,9 +348,9 @@ def generate_plist(data = nil)
gsub(%r{(<key>Label</key>\s*<string>)[^<]*(</string>)}, '\1' + label + '\2')
# and force fix UserName, if necessary
- if formula.startup_user != "root" && data =~ %r{<key>UserName</key>\s*<string>root</string>}
+ if !ServicesCli.root? && formula.startup_user != "root" && data =~ %r{<key>UserName</key>\s*<string>root</string>}
data = data.gsub(%r{(<key>UserName</key>\s*<string>)[^<]*(</string>)}, '\1' + formula.startup_user + '\2')
- elsif ServicesCli.root? && formula.startup_user != "root" && data !~ %r{<key>UserName</key>}
+ elsif !ServicesCli.root? && formula.startup_user != "root" && data !~ %r{<key>UserName</key>}
data = data.gsub(%r{(</dict>\s*</plist>)}, " <key>UserName</key><string>#{formula.startup_user}</string>\n\\1")
end
Something went wrong with that request. Please try again.