Failed install script on Debian when nginx is part of other groups
anilex opened this issue · 1 comments
anilex commented
When trying to install on Debian 8 I receive the following error:
9. ...
10. Checking if sudo -u nginx can be used for tests ... failed. (109 != nginx)
11. ...
when I check:
root@myhost:~/nginx_amplify# id nginx
uid=109(nginx) gid=115(nginx) groups=115(nginx),1001(example1.com),1002(example2.com),1003(example3.com),1004(example4.com),1005(example5.com)
When I open the install.sh on a row 472:
sudo_output=`sudo -u ${amplify_user} /bin/sh -c "id -un" 2>/dev/null`
When I run just:
root@myhost:~/nginx_amplify# id -un nginx
nginx
But when I run:
root@myhost:~/nginx_amplify# sudo -u nginx /bin/sh -c "id -un" 2>/dev/null
109
Please, note the difference of receving the username and the uid!
The rest is almost expected:
The row 474:
if [ "${sudo_output}" = "${amplify_user}" ]; then
or in other words... if (109 == nginx) leads us to the error row 477: (109 != nginx)
when trying to launch with
root@myhost:~/nginx_amplify# systemctl status amplify-agent.service
● amplify-agent.service - LSB: Stop/start nginx-amplify-agent
Loaded: loaded (/etc/init.d/amplify-agent)
Active: failed (Result: exit-code) since Sun 2016-11-27 05:03:04 EET; 5s ago
Process: 12137 ExecStart=/etc/init.d/amplify-agent start (code=exited, status=1/FAILURE)
Nov 27 05:03:04 amplify-agent[12137]: File "/usr/lib/python2.7/sysconfig.py", line 210, in _getuserbase
Nov 27 05:03:04 amplify-agent[12137]: return env_base if env_base else joinuser("~", ".local")
Nov 27 05:03:04 amplify-agent[12137]: File "/usr/lib/python2.7/sysconfig.py", line 196, in joinuser
Nov 27 05:03:04 amplify-agent[12137]: return os.path.expanduser(os.path.join(*args))
Nov 27 05:03:04 amplify-agent[12137]: File "/usr/lib/python2.7/posixpath.py", line 269, in expanduser
Nov 27 05:03:04 amplify-agent[12137]: userhome = pwd.getpwuid(os.getuid()).pw_dir
Nov 27 05:03:04 amplify-agent[12137]: KeyError: 'getpwuid(): uid not found: 109'
Nov 27 05:03:04 systemd[1]: amplify-agent.service: control process exited, code=exited status=1
Nov 27 05:03:04 systemd[1]: Failed to start LSB: Stop/start nginx-amplify-agent.
Nov 27 05:03:04 systemd[1]: Unit amplify-agent.service entered failed state.
root@myhost:~/nginx_amplify#
anilex commented
The wrong output 109 of
root@myhost:~/nginx_amplify# sudo -u nginx /bin/sh -c "id -un" 2>/dev/null
109
was caused by insufficient permissions of /etc/passwd.
When I changed the permissions from 640 to 644 the output was as expected
root@myhost:~/nginx_amplify# sudo -u nginx /bin/sh -c "id -un" 2>/dev/null
nginx
and this allowed the installer to continue without errors.