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

Running command as normal user with s6? #207

Closed
bborysenko opened this issue Apr 26, 2017 · 2 comments
Closed

Running command as normal user with s6? #207

bborysenko opened this issue Apr 26, 2017 · 2 comments

Comments

@bborysenko
Copy link

Hello,

What is the best way to run command under the s6 supervisor as normal user?

I have tried s6-setuidgid, but since $HOME is not changed it fails in some cases. For example:

/usr/src/app # s6-setuidgid owox git config --global user.name docker
warning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
error: could not lock config file /root/.gitconfig: Permission denied
@eratolekov
Copy link

Hi

I'm using

#!/usr/bin/with-contenv sh

exec s6-setuidgid user /path/to/script.sh

/path/to/script.sh:

#! /bin/bash -e

HOME=~user
export HOME
...

xcafebabe added a commit to xcafebabe/gobstoppers that referenced this issue Aug 2, 2017
Merged all process in one single RUN to save image space and also remove node user. Can not be used with rpi-alpine-base due to just-containers/s6-overlay#207
@jprjr
Copy link
Member

jprjr commented Mar 14, 2018

That's something to generally be aware of - by default most environment variables are removed, and a lot of apps expect variables like HOME to be available.

I've thought about writing a short script that sets things like HOME. In the meantime, here's an example of running a shell with CMD as not-root:

CMD ["/usr/bin/execlineb", "-P", "-c", "emptyenv export HOME /home/user s6-setuidgid user /bin/bash"]

@jprjr jprjr closed this as completed Feb 5, 2019
tribut added a commit to tribut/homeassistant-docker-venv that referenced this issue Apr 9, 2021
s6-setuidgid does not change the environment, so HOME is still set to
root's home directory.
See just-containers/s6-overlay#207

Fixes #20
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

No branches or pull requests

3 participants