Skip to content

uwsgi creates spooler dirs and leaves them writable by root only #1858

@jpic

Description

@jpic

I noticed my deployment broke when i added multiple spoolers, ie. with --spooler=/spooler/mail --spooler=/spooler/stat: it would create the mail and stat directories inside /spooler and leave them writable by root only.

Then, it seems uwsgi's spooler is stuck in an endless loop trying to write inside this directory after changing uid from root.

spawned the uWSGI spooler on dir /spooler/mail with pid 15317                          OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/stat with pid 15318                          
chdir(): Permission denied [core/spooler.c line 437]                                   chdir(): Permission denied [core/spooler.c line 437]                                   OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15319                          
OOOPS the spooler is no more...trying respawn...                                       chdir(): Permission denied [core/spooler.c line 437]                                   spawned the uWSGI spooler on dir /spooler/stat with pid 15320                          
chdir(): Permission denied [core/spooler.c line 437]                                   OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15321                          
OOOPS the spooler is no more...trying respawn...                                       chdir(): Permission denied [core/spooler.c line 437]                                   spawned the uWSGI spooler on dir /spooler/stat with pid 15322                          
chdir(): Permission denied [core/spooler.c line 437]                                   OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15323                          
OOOPS the spooler is no more...trying respawn...                                       chdir(): Permission denied [core/spooler.c line 437]                                   spawned the uWSGI spooler on dir /spooler/stat with pid 15324                          chdir(): Permission denied [core/spooler.c line 437]                                   
OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15325                          OOOPS the spooler is no more...trying respawn...                                       chdir(): Permission denied [core/spooler.c line 437]                                   
spawned the uWSGI spooler on dir /spooler/stat with pid 15326                          chdir(): Permission denied [core/spooler.c line 437]                                   OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15327                          
OOOPS the spooler is no more...trying respawn...                                       chdir(): Permission denied [core/spooler.c line 437]                                   spawned the uWSGI spooler on dir /spooler/stat with pid 15328                          chdir(): Permission denied [core/spooler.c line 437]                                   
OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15329     

Just chown'ing the directories fixes uWSGI startup:

chdir(): Permission denied [core/spooler.c line 437]                                   
spawned the uWSGI spooler on dir /spooler/stat with pid 15352                          chdir(): Permission denied [core/spooler.c line 437]                                   OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/mail with pid 15353                          
OOOPS the spooler is no more...trying respawn...                                       spawned the uWSGI spooler on dir /spooler/stat with pid 15354                                                                                                                                                                                                        
[pid: 20|app: 0|req: 2/26] 93.174.144.106 () {44 vars in 767 bytes} [Mon Aug 27 08:28:13 2018] GET /demande => generated 23849 bytes in 192 msecs (HTTP/1.1 200) 7 headers in 449 bytes (1 switches on core 0)          

As you can see, it then leaves two working spooler processes (in a container, note that uwsgi started as pid 11):

docker exec -it my ps aux                     
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND               
root         1  0.0  0.0   4592   816 ?        Ss   06:19   0:00 /bin/sh -c /usr       
root        10  0.0  0.0   4316   888 ?        S    06:19   0:00 /usr/bin/dumb-i       
uwsgi       11  0.0  0.3 245388 55116 ?        Ss   06:19   0:20 uwsgi --spooler       
uwsgi       15  0.0  0.2 245388 41696 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       16  0.0  0.3 323876 53696 ?        Sl   06:19   0:00 uwsgi --spooler       
uwsgi       17  0.0  0.3 255824 57684 ?        S    06:19   0:01 uwsgi --spooler       
uwsgi       18  0.0  0.3 328408 58908 ?        Sl   06:19   0:01 uwsgi --spooler       
uwsgi       19  0.0  0.3 330532 61316 ?        Sl   06:19   0:01 uwsgi --spooler       
uwsgi       20  0.0  0.3 252528 53880 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       21  0.0  0.3 250788 51940 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       22  0.0  0.3 250788 51940 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       23  0.0  0.2 245388 41696 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       24  0.0  0.3 252516 53608 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       25  0.0  0.2 245528 43252 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi       26  0.0  0.3 251212 52300 ?        S    06:19   0:00 uwsgi --spooler       
uwsgi    15353  0.0  0.2 248056 48096 ?        SN   08:27   0:00 uwsgi --spooler       
uwsgi    15354  0.0  0.2 245388 40796 ?        SN   08:27   0:00 uwsgi --spooler       
root     15371  0.0  0.0  38976  3108 pts/0    Rs+  12:26   0:00 ps aux           

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions