cwd = os.getcwd() message on Openbsd #10203

Closed
opened 2025-12-29 21:28:16 +01:00 by adam · 3 comments
Owner

Originally created by @mikygee on GitHub (Sep 7, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.11

Python Version

3.10

Steps to Reproduce

On openbsd, I used version 7.5 the latest

Expected Behavior

On openbsd pwd should be used, not cwd

Observed Behavior

OS: Openbsd 7.5
Netbox: v4.0.11

Hello,

I'm trying to execute netbox like this
# su -s /bin/ksh _netbox -c '/var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn --name netbox --pid /var/run/netbox/netbox.pid --user=www --group=www --config /var/www/htdocs/applications/netbox-4.0.11/gunicorn.py --log-level=info --log-file=- netbox.wsgi:application'

And I see these messages

Traceback (most recent call last):
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py", line 448, in getcwd
    a = os.stat(os.environ['PWD'])
FileNotFoundError: [Errno 2] No such file or directory: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn", line 5, in <module>
    from gunicorn.app.wsgiapp import run
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 8, in <module>
    from gunicorn.app.base import Application
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/app/base.py", line 12, in <module>
    from gunicorn.config import Config, get_default_config_file
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/config.py", line 1060, in <module>
    class Chdir(Setting):
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/config.py", line 1065, in Chdir
    default = util.getcwd()
  File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py", line 455, in getcwd
    cwd = os.getcwd()
PermissionError: [Errno 13] Permission denied

cwd doesn't exist on openbsd, it's pwd here.

I manage to avoid the error like this
# su -s /bin/ksh _netbox -c 'cd /var/www/htdocs/applications/netbox-4.0.11 && export PWD=/var/www/htdocs/applications/netbox-4.0.11 && /var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn --name netbox --pid /var/run/netbox/netbox.pid --user=www --group=www --config /var/www/htdocs/applications/netbox-4.0.11/gunicorn.py --log-level=info --log-file=- netbox.wsgi:application'
But what should be used is not the PWD environnement variable but the pwd command.

At line 445 file netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py, I don't see any pwd related command, just cwd

def getcwd():
    # get current path, try to use PWD env first
    try:
        a = os.stat(os.environ['PWD'])
        b = os.stat(os.getcwd())
        if a.st_ino == b.st_ino and a.st_dev == b.st_dev:
            cwd = os.environ['PWD']
        else:
            cwd = os.getcwd()
    except Exception:
        cwd = os.getcwd()
    return cwd

Thank you

Originally created by @mikygee on GitHub (Sep 7, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.11 ### Python Version 3.10 ### Steps to Reproduce On openbsd, I used version 7.5 the latest ### Expected Behavior On openbsd pwd should be used, not cwd ### Observed Behavior OS: Openbsd 7.5 Netbox: v4.0.11 Hello, I'm trying to execute netbox like this `# su -s /bin/ksh _netbox -c '/var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn --name netbox --pid /var/run/netbox/netbox.pid --user=www --group=www --config /var/www/htdocs/applications/netbox-4.0.11/gunicorn.py --log-level=info --log-file=- netbox.wsgi:application'` And I see these messages ``` Traceback (most recent call last): File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py", line 448, in getcwd a = os.stat(os.environ['PWD']) FileNotFoundError: [Errno 2] No such file or directory: '' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn", line 5, in <module> from gunicorn.app.wsgiapp import run File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 8, in <module> from gunicorn.app.base import Application File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/app/base.py", line 12, in <module> from gunicorn.config import Config, get_default_config_file File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/config.py", line 1060, in <module> class Chdir(Setting): File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/config.py", line 1065, in Chdir default = util.getcwd() File "/var/www/htdocs/applications/netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py", line 455, in getcwd cwd = os.getcwd() PermissionError: [Errno 13] Permission denied ``` cwd doesn't exist on openbsd, it's pwd here. I manage to avoid the error like this `# su -s /bin/ksh _netbox -c 'cd /var/www/htdocs/applications/netbox-4.0.11 && export PWD=/var/www/htdocs/applications/netbox-4.0.11 && /var/www/htdocs/applications/netbox-4.0.11/env/bin/gunicorn --name netbox --pid /var/run/netbox/netbox.pid --user=www --group=www --config /var/www/htdocs/applications/netbox-4.0.11/gunicorn.py --log-level=info --log-file=- netbox.wsgi:application'` But what should be used is not the PWD environnement variable but the pwd command. At line 445 file netbox-4.0.11/env/lib/python3.10/site-packages/gunicorn/util.py, I don't see any pwd related command, just cwd ``` def getcwd(): # get current path, try to use PWD env first try: a = os.stat(os.environ['PWD']) b = os.stat(os.getcwd()) if a.st_ino == b.st_ino and a.st_dev == b.st_dev: cwd = os.environ['PWD'] else: cwd = os.getcwd() except Exception: cwd = os.getcwd() return cwd ``` Thank you
adam closed this issue 2025-12-29 21:28:16 +01:00
Author
Owner

@peteeckel commented on GitHub (Sep 8, 2024):

That looks pretty much like a gunicorn issue to me ...

@peteeckel commented on GitHub (Sep 8, 2024): That looks pretty much like a gunicorn issue to me ...
Author
Owner

@mikygee commented on GitHub (Sep 8, 2024):

Thank you Pete, I opened a ticket there to see where it goes.

@mikygee commented on GitHub (Sep 8, 2024): Thank you Pete, I opened a ticket there to see where it goes.
Author
Owner

@mikygee commented on GitHub (Sep 8, 2024):

I close the ticket.

@mikygee commented on GitHub (Sep 8, 2024): I close the ticket.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10203