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

hitch-1.5.1 won't run workers as user hitch, even when explicitly set #322

Closed
ingvarha opened this issue Nov 26, 2019 · 6 comments
Closed

Comments

@ingvarha
Copy link

Platform: Fedora 30/x86_64
Hitch won't start when called as root, even when worker user is explicitly configured

Example run:
root# hitch --version; hitch -u hitch -g hitch -L 2 default.example.com.pem
hitch 1.5.1
20191127T004027.155239 [24633] {core} hitch 1.5.1 starting
20191127T004027.155457 [24633] {core} Using OpenSSL version 1010104f.
20191127T004027.160547 [24633] {core} Listening on 0.0.0.0:8443
20191127T004027.160628 [24633] {core} Listening on [::]:8443
20191127T004027.160643 [24633] {core} Loading certificate pem files (1)
20191127T004027.161955 [24633] {core} Using DH parameters from default.example.com.pem
20191127T004027.161983 [24633] {core} DH initialized with 1024 bit key
20191127T004027.162084 [24633] {core} ECDH Initialized with NIST P-256
20191127T004027.162274 [24633] {core} ERROR: Refusing to run workers as root, unless user and group is explicitly set to root.

This used to work with hitch-1.5.0:
[root@nohup ~]# hitch --version; hitch -u hitch -g hitch -L 2 default.example.com.pem
hitch 1.5.0

20191127T004127.922584 [24850] {core} hitch 1.5.0 starting
20191127T004127.922619 [24850] {core} Using OpenSSL version 1010104f.
20191127T004127.924167 [24850] {core} Listening on 0.0.0.0:8443
20191127T004127.924192 [24850] {core} Listening on [::]:8443
20191127T004127.924196 [24850] {core} Loading certificate pem files (1)
20191127T004127.924672 [24850] {core} Using DH parameters from default.example.com.pem
20191127T004127.924681 [24850] {core} DH initialized with 1024 bit key
20191127T004127.924726 [24850] {core} ECDH Initialized with NIST P-256
20191127T004127.924936 [24850] {core} hitch 1.5.0 initialization complete
20191127T004127.924966 [24851] {core} Process 0 online
20191127T004127.925074 [24851] {core} Successfully attached to CPU #0
20191127T004127.925083 [24852] {ocsp} Note: No OCSP responder URI found for cert default.example.com.pem

root# pgrep hitch | xargs ps -o pid,user,command -p
PID USER COMMAND
24850 root hitch -u hitch -g hitch -L 2 default.example.com.pem
24851 hitch hitch -u hitch -g hitch -L 2 default.example.com.pem
24852 hitch hitch -u hitch -g hitch -L 2 default.example.com.pem

Note that when starting as a non-privileged user, hitch-1.5.1 will actually try to start, and may succeed if it does not need to bind to privileged ports:

root# hitch --version; su - hitch -s /bin/sh -c "hitch -L 2 default.example.com.pem"
hitch 1.5.1
20191127T005040.406259 [25940] {core} hitch 1.5.1 starting
20191127T005040.406295 [25940] {core} Using OpenSSL version 1010104f.
20191127T005040.407678 [25940] {core} Listening on 0.0.0.0:8443
20191127T005040.407701 [25940] {core} Listening on [::]:8443
20191127T005040.407704 [25940] {core} Loading certificate pem files (1)
20191127T005040.408090 [25940] {core} Using DH parameters from default.example.com.pem
20191127T005040.408097 [25940] {core} DH initialized with 1024 bit key
20191127T005040.408131 [25940] {core} ECDH Initialized with NIST P-256
20191127T005040.408324 [25940] {core} hitch 1.5.1 initialization complete
20191127T005040.408311 [25985] {core} Process 0 online
20191127T005040.408440 [25986] {ocsp} Note: No OCSP responder URI found for cert default.example.com.pem
20191127T005040.408475 [25985] {core} Successfully attached to CPU #0

@ingvarha
Copy link
Author

Reverting 55b2f62 does, not surprisingly circumvent the problem.

@ingvarha
Copy link
Author

It is actually enough to revert just the change in main, so I may add this patch, and it will run as expected:

@ingvarha
Copy link
Author

foo.patch.txt

@ingvarha
Copy link
Author

This is hitch-1.5.1 running with the patch above:

root# hitch --version; hitch -L 1 default.example.com.pem
hitch 1.5.1
20191127T012833.656040 [11268] {core} hitch 1.5.1 starting
20191127T012833.658222 [11268] {core} Loading certificate pem files (1)
20191127T012833.658664 [11268] {core} ERROR: Refusing to run workers as root.

root# hitch --version; hitch -u hitch -L 1 default.example.com.pem
hitch 1.5.1
20191127T012856.056718 [11275] {core} hitch 1.5.1 starting
20191127T012856.058142 [11275] {core} Loading certificate pem files (1)
20191127T012856.058597 [11275] {core} hitch 1.5.1 initialization complete
20191127T012856.058617 [11276] {core} Process 0 online

root# hitch --version; hitch -u root -L 1 default.example.com.pem
hitch 1.5.1
20191127T012909.497039 [11285] {core} hitch 1.5.1 starting
20191127T012909.498672 [11285] {core} Loading certificate pem files (1)
20191127T012909.499553 [11285] {core} hitch 1.5.1 initialization complete
20191127T012909.499550 [11286] {core} Process 0 online

@rezan
Copy link

rezan commented Nov 27, 2019

Are you testing from source or package?

We have already pulled the 1.5.1 packages due to this bug. And yes, the commit you have pointed out is what broke things. So removing it should resolve the issue. We should have this officially patched soon.

@daghf daghf closed this as completed in dedfa54 Nov 27, 2019
@daghf
Copy link
Member

daghf commented Nov 27, 2019

Thanks a lot @ingvarha - I've applied your fix now. Looks like 1.5.1 will be a very short-lived release - I'll roll 1.5.2 immediately.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue May 17, 2020
hitch-1.5.2 (2019-11-27)
------------------------

* Fix a problem introduced in the previous release that prevented us
  from running as a non-privileged user (Issue: 322_).

.. _322: varnish/hitch#322


hitch-1.5.1 (2019-11-26)
------------------------

* Support for TCP Fast Open. Is is disabled by default (Issue: 185_)
* Various code cleanups and minor bug fixes.

.. _185: varnish/hitch#185
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