Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Systemd service not running as specified user #4209

mhagen ·

I'm having trouble getting the QuickBuild service to run as the non-root user I specified in RUN_AS_USER in the agent.sh script. The service is installed using systemd running on Red Hat 8.1.

The service itself runs as expected on startup, but the QuickBuild dashboard isn't picking up the correct System Attributes (Path and other environment variables). This makes me suspect it isn't running as the correct user, the PATH displayed matches root's $PATH.

When I manually stop the QuickBuild service and run "sudo ./agent.sh console" as the specified user, everything works as I'd expect and the proper System Attributes are displayed. Running the service manually as that same user produces the incorrect results.

I've tried quite a few things: gave the user sudo with no password, ensured the QuickBuild files and folders are all owned by the user, but am having no luck.

When I run "systemctl status quickbuild" I see the line: TTY=unknown ; PWD=/opt/QuickBuild/bin ; USER=root ; COMMAND=/bin/cat /var/lib/waagent/ovf-env.xml

I noticed references to this xml file in: https://wiki.pmease.com/display/qb90/Launch+Node+in+Azure

I don't have the directory /var/lib/waagent on my machine, would this cause any issues? Is there anything else that I may be missing to get the service to run as a non-root user?

Thanks!

  • solved #4
  • replies 4
  • views 2169
  • stars 0
robinshen ADMIN ·

Which QB version are you using? The ovf-env.xml thing is only required if you are launching build agents via cloud profile. Have you re-installed the service (sudo ./agent.sh remove & sudo ./agent.sh install) after changing RUN_AS_USER?

mhagen ·

Using QuickBuild 9.0.12

Makes sense. I'm not using any cloud features, but I still see that message. If it's just something I can ignore that's fine, but before I had given the user sudo with no password it would tell me something about an invalid password (the systemctl status output appeared red).

I have tried reinstalled the service a few times after changing RUN_AS_USER, and also different orders of re-installs with reboots.

Just to cover all the bases, would there be an issue if the user has a dash in the name? (e.g. test-user)

robinshen ADMIN ·

When running as service, QuickBuild will not pick up environments of RUN_AS user automatically. If you want to load specific environments, please edit agent.sh and specify FILES_TO_SOURCE

mhagen ·

This worked perfectly thanks so much!

For anybody else that runs into this issue, I just added:

FILES_TO_SOURCE="/home/myuser/.bashrc"