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

Unable to upload report #1080

Open
elixdreamer opened this issue Sep 15, 2023 · 3 comments
Open

Unable to upload report #1080

elixdreamer opened this issue Sep 15, 2023 · 3 comments

Comments

@elixdreamer
Copy link

Current Behavior

When uploading a report, the following error appears:

Insufficient write permission to the media root. The configured media root is . Ensure that the user NetBox runs as has access to write files to all locations within this path.

<class 'PermissionError'>

[Errno 13] Permission denied: '/opt/netbox/netbox/reports/example.py'

Python version: 3.11.4
NetBox version: 3.6.1
Plugins: None installed

Issue located, insufficient rights on the _data folder

root@debian-docker:~# ls -al /var/lib/docker/volumes/netbox-docker_netbox-reports-files/
total 12
drwx-----x  3 root root 4096 May 11 16:29 .
drwx-----x 11 root root 4096 Sep 15 14:21 ..
drwxr-xr-x  3 root root 4096 Sep 15 13:51 _data

Expected Behavior

Upload possible after changing the folder _data

root@debian-docker:~# chmod 775 /var/lib/docker/volumes/netbox-docker_netbox-reports-files/_data/
root@debian-docker:~# ls -al /var/lib/docker/volumes/netbox-docker_netbox-reports-files/
total 12
drwx-----x  3 root root 4096 May 11 16:29 .
drwx-----x 11 root root 4096 Sep 15 14:21 ..
drwxrwxr-x  3 root root 4096 Sep 15 13:51 _data

Docker Compose Version

Docker Compose version v2.21.0

Docker Version

Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:32:16 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The git Revision

b47e85a

The git Status

On branch release
Your branch is up to date with 'origin/release'.

Startup Command

docker compose up -d

NetBox Logs

netbox  | 127.0.0.1 - - [15/Sep/2023:13:27:02 +0000] "GET /api/ HTTP/1.1" 200 510 "-" "curl/7.88.1"
netbox  | 172.30.0.6 - - [15/Sep/2023:13:27:03 +0000] "POST /extras/reports/add/ HTTP/1.1" 500 1867 "https://10.127.103.157/extras/reports/add/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
netbox  | 172.30.0.6 - - [15/Sep/2023:13:27:03 +0000] "GET /static/netbox-light.css HTTP/1.1" 200 232798 "https://10.127.103.157/extras/reports/add/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"

Content of docker-compose.override.yml

version: '3.4'
services:
  # netbox
  netbox:
    container_name: netbox
    environment:
      TIME_ZONE: "Europe/Brussels"
    restart: unless-stopped
@Kani999
Copy link

Kani999 commented Sep 21, 2023

When you execute docker-compose exec -u root netbox /bin/bash command how does your rights looks at the scripts or reports folder?

I've changed the rights to user "unit" as you can see below and now it works for me.

drwxrwxr-x 3 unit root 4.0K Sep 20 10:14 .
drwxr-xr-x 1 root root 4.0K Sep 21 10:20 ..
-rw-rw-r-- 1 unit root    0 May  7 05:48 __init__.py
drwxrwxr-x 2 unit unit 4.0K Sep 21 04:00 __pycache__
-rw-rw-r-- 1 unit unit 5.4K Sep 20 11:05 my_uploaded_script.py

@elixdreamer
Copy link
Author

This is how my rights look atm after changing the volume on my host.

root@0a67e28ea37c:/opt/netbox/netbox# ls -al scripts/
total 12
drwxr-xr-x 2 root root 4096 May 11 14:29 .
drwxr-xr-x 1 root root 4096 Sep 21 06:10 ..
-rw-r--r-- 1 root root    0 Apr 15 06:43 __init__.py
root@0a67e28ea37c:/opt/netbox/netbox# ls -al reports/
total 16
drwxrwxr-x 3 root root 4096 Sep 15 11:51 .
drwxr-xr-x 1 root root 4096 Sep 21 06:10 ..
-rw-r--r-- 1 root root    0 Apr 15 06:43 __init__.py
drwxrwxr-x 2 unit root 4096 Sep 15 11:50 __pycache__

@Kani999
Copy link

Kani999 commented Sep 25, 2023

I had the same error as you, and editing rights to the following lines fixed the problem:

  • scripts/reports drwxrwxr-x 3 unit root
  • pycache drwxrwxr-x 2 unit unit
  • init -rw-rw-r-- 1 unit root

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

2 participants