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

Unable to start services - "The UserName key is not supported for non-System services." #56

Closed
daFish opened this issue May 27, 2016 · 16 comments · Fixed by #59
Closed
Labels

Comments

@daFish
Copy link
Contributor

daFish commented May 27, 2016

Since upgrading to OS X 10.11.5 I can no longer start services like httpd22.

brew services start httpd22 results in ==> Successfully started``httpd22``(label: homebrew.mxcl.httpd22) which is perfectly fine.

However, when inspecting the logs using syslog -k Sender com.apple.xpc.launchd I noticed the following entries:

May 27 09:48:22 name com.apple.xpc.launchd[1] (homebrew.mxcl.httpd22) <Error>: The UserName key is not supported for non-System services.
May 27 09:48:22 name com.apple.xpc.launchd[1] (homebrew.mxcl.httpd22[22553]) <Warning>: Service exited with abnormal code: 1

The .plist-file contains the section in question which was perfectly fine prior the update. Anyone experienced anything like that before?

@MikeMcQuaid
Copy link
Member

I'm also on 10.11.5 and am not able to reproduce this. The UserName stuff should be cleaned up at some point but it's not what's causing this error. What happens if you run httpd22 manually? Smells like it could be a local configuration issue.

@daFish
Copy link
Contributor Author

daFish commented May 27, 2016

Running it manually works. This gets weirder and weirder.

@MikeMcQuaid
Copy link
Member

@daFish I'm afraid this doesn't look like a Homebrew issue. If you can figure out a fix and create a PR then we'll consider it. Sorry!

@daFish
Copy link
Contributor Author

daFish commented May 30, 2016

Thanks, @MikeMcQuaid. I try to come up with a solution. However, I have the exact same issue on another machine running 10.11.5.

@MikeMcQuaid
Copy link
Member

@daFish Try to remove the UserName key and then brew reinstall.

@daFish
Copy link
Contributor Author

daFish commented May 30, 2016

@MikeMcQuaid Still doesn't work. The UserName key is always readded when starting the service.

@daFish
Copy link
Contributor Author

daFish commented May 30, 2016

Starting the service with sudo works as expected.

@MikeMcQuaid
Copy link
Member

@daFish You may also want to try and remove the relevant UserName code from brew services and see if that fixes it.

@MikeMcQuaid
Copy link
Member

also CC @ilovezfs for thoughts.

@MikeMcQuaid MikeMcQuaid reopened this May 30, 2016
@ilovezfs
Copy link
Contributor

Perhaps they got stricter and made the incorrect usage an error instead of just ignoring it.

As a workaround, @daFish can you try opening brew-services.rb, and changing

    # Force fix UserName
    if !ServicesCli.root?
      if data =~ %r{<key>UserName</key>}
        # Replace existing UserName value with current user
        data = data.gsub(%r{(<key>UserName</key>\s*<string>)[^<]*(</string>)}, '\1' + ServicesCli.user + '\2')
      else
        # Add UserName key and value to end of plist if it doesn't already exist
        data = data.gsub(%r{(\s*</dict>\s*</plist>)}, "\n    <key>UserName</key>\n    <string>" + ServicesCli.user + "</string>\\1")
      end
    elsif data =~ %r{<key>UserName</key>}
      # Always remove UserName key entirely if running as root
      data = data.gsub(%r{(<key>UserName</key>\s*<string>)[^<]*(</string>)}, "")
    end

to

    if data =~ %r{<key>UserName</key>}
      data = data.gsub(%r{(<key>UserName</key>\s*<string>)[^<]*(</string>)}, "")
    end

@daFish
Copy link
Contributor Author

daFish commented May 30, 2016

@ilovezfs This worked and I was able to start the services without any problems.

@ilovezfs
Copy link
Contributor

Cool. You may want to commit that change for now, since brew update will try to stash it otherwise.

cd /usr/local/Library/Taps/homebrew/homebrew-services
git add cmd/brew-services.rb
git commit -m "username go away please"

@MikeMcQuaid
Copy link
Member

@ilovezfs Thanks! Would you or @daFish mind making a PR for that?

@ilovezfs
Copy link
Contributor

@MikeMcQuaid Sure. Let's go with that as a workaround, clean up the formulae, and then drop the section entirely.

@MikeMcQuaid
Copy link
Member

@ilovezfs Sounds good.

ilovezfs added a commit to ilovezfs/homebrew-services that referenced this issue May 30, 2016
This will avoid setting the key inappropriately, but will also continue
to prevent "legitimate" use of the key (e.g., setting UserName "php" for
a daemon).

Closes Homebrew#56.
@daFish
Copy link
Contributor Author

daFish commented May 30, 2016

@MikeMcQuaid Done.

@lock lock bot added the outdated label Jan 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants