unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 692 forks source link

Chroot is called in each process after chroot of caller #2128

Open ondratu opened 4 years ago

ondratu commented 4 years ago

As i write here http://lists.unbit.it/pipermail/uwsgi/2020-February/009028.html, i try to use chroot on my Debian Buster. I do some another example on another machine with the same problem. Here is another log when i use only chroot (no uid or gid).

Problem is in master process, when i disable it by master=false, uwsgi starts.

[uwsgi]

# one day may be included
# ini = /srv/example_net/etc/uwsgi.ini
chroot = /srv/example_net

autoload = true
plugin = python3

# wsgi-file = /srv/app.py
# chdir = /srv
# module = app:app

check-static = /srv/www

master = true
threads = 5

python-autoreload = true
optimize = 2
# limit-as = 32

# uid = example_net
# gid = example_net

http = 127.0.0.1:31001
pidfile = /srv/example_net/var/run/uwsgi.pid
daemonize = /srv/example_net/var/log/uwsgi.log
#socket = /var/run/uwsgi.socket
stats = /var/run/uwsgi.stats
touch-reload = /var/run/uwsgi.reload

and the log after start

*** Starting uWSGI 2.0.18-debian (64bit) on [Fri Feb 28 08:30:03 2020] ***
compiled with version: 9.2.1 20200203 on 18 February 2020 19:38:45
os: Linux-5.3.0-3-amd64 #1 SMP Debian 5.3.15-1 (2019-12-07)
nodename: dell
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 12
current working directory: /etc/uwsgi-emperor/vassals
writing pidfile to /srv/example_net/var/run/uwsgi.pid
detected binary path: /usr/bin/uwsgi-core
uWSGI running as root, you can use --uid/--gid/--chroot options
chroot() to /srv/example_net
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your processes number limit is 62689
your memory page size is 4096 bytes
detected max file descriptor number: 1024
building mime-types dictionary from file /etc/mime.types...567 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 127.0.0.1:31001 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:42517 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
chroot() to /srv/example_net
chroot(): No such file or directory [core/utils.c line 592]
ondratu commented 4 years ago

error is from version 2.0.16 version 2.0.15 works

rdeioris commented 4 years ago

Hi, does using http-socket instead of http fixes the issue ?

ondratu commented 4 years ago

No

** Starting uWSGI 2.0.18-debian (64bit) on [Thu Mar  5 21:06:41 2020] ***
compiled with version: 9.2.1 20200224 on 28 February 2020 14:19:58
os: Linux-5.4.0-4-amd64 #1 SMP Debian 5.4.19-1 (2020-02-13)
nodename: dell
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 12
current working directory: /etc/uwsgi-emperor
writing pidfile to /srv/example_net/var/run/uwsgi.pid
detected binary path: /usr/bin/uwsgi-core
uWSGI running as root, you can use --uid/--gid/--chroot options
chroot() to /srv/example_net
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your processes number limit is 62687
your memory page size is 4096 bytes
detected max file descriptor number: 1024
building mime-types dictionary from file /etc/mime.types...567 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:31001 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
chroot() to /srv/example_net
chroot(): No such file or directory [core/utils.c line 592]
awelzel commented 4 years ago

Hey @ondratu , I've pushed a fix on top of 2.0.18. If you want to give it a shot:

$ pip --no-cache install git+https://github.com/awelzel/uwsgi.git@do-not-chroot-multiple-times-2.0

You can find a description in #2132 .

@rdeioris - thoughts if that is good enough?

ondratu commented 4 years ago

thx @awelzel, it works ! :-) :+1:

cs-niraj-nandane commented 3 years ago

I am also facing same issue. Which version fixes this?