tianon / gosu

Simple Go-based setuid+setgid+setgroups+exec
Apache License 2.0
4.71k stars 319 forks source link

Hangs with exec "$@" #78

Closed markfaine closed 3 years ago

markfaine commented 4 years ago

I'm exec-ing a script as my container's entrypoint, the script does some setup (still as root) and then at the end I call:

exec /usr/sbin/gosu ansible:ansible "$@"

However, it just hangs, regardless of the command I pass to the container. When I do a ctrl-c I see the usage help for gosu.

Is there something wrong with the way I'm executing gosu?

Thanks

markfaine commented 4 years ago

Update, it wasn't hanging, it was just fixuid taking forever, however, it still fails to run the command with the same error.

tianon commented 4 years ago

That sounds like you're missing a command -- what is "$@" set to? I'd suggest running the script with set +x so you can see the full command being run.

markfaine commented 4 years ago

Thanks, excellent idea. I'm getting closer I think. Do you know what could be causing this error?

+ TZ=CST6CDT
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/virtualenv/bin
+ ANSIBLE_CONFIG=/home/ansible/ansible.cfg
+ export TZ PATH ANSIBLE_CONFIG
+ /usr/local/bin/fixuid -q
export HOME="/home/ansible"
+ /usr/sbin/gosu ansible:ansible bash -c /wrapper.sh
error: failed switching to "ansible:ansible": operation not permitted
tianon commented 4 years ago

That sounds like you're either not running as root or you've got something else (seccomp, apparmor, etc) blocking your ability to switch your effective UID.

tianon commented 3 years ago

I'm going to close since this isn't something I can reproduce. :sweat_smile: