Thanks to visit codestin.com
Credit goes to github.com

Skip to content

500: initRepository - fatal: detected dubious ownership in repository #8047

@thchha

Description

@thchha

Gogs version

0.14.0+dev

Git version

  • Server: 2.47.2
  • Client: (server error)

Operating system

Linux git 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64 Linux (Debian 12.12)

Database

psql (PostgreSQL) 15.14 (Debian 15.14-0+deb12u1)

Describe the bug

When trying to create a repository from the UI (regardless of the user) a Internal Server Error (500) is reported.
Within gogs.log it reads:

2025/10/15 22:38:01 [TRACE] Template: repo/create
2025/10/15 22:38:04 [TRACE] Session ID: f3d9a844b4729956
2025/10/15 22:38:04 [TRACE] CSRF Token: _GUXS3HruKoGYdm6tn1NVftBvh46MTc2MDU2Nzg3OTAzOTA1MDQwNw
2025/10/15 22:38:04 [ERROR] [...gogs/internal/route/repo/repo.go:100 handleCreateError()] CreatePost: initRepository: set default branch: exit status 128 - fatal: detected dubious ownership in repository at '/data/git/gogs-repositories/tomes/test.git'
To add an exception for this directory, call:

        git config --global --add safe.directory /data/git/gogs-repositories/tomes/test.git
2025/10/15 22:38:04 [TRACE] Template: status/500

The same ERROR is shown in the web UI at the 500-page.

To reproduce

I run gogs with via:

ExecStart=/usr/bin/podman run \
        --cidfile=%t/%n.ctr-id \
        --cgroups=no-conmon \
        --rm \
        --sdnotify=conmon \
        -d \
        --replace \
        --name=gogs \
        -p 10022:22 \
        -p 3000:3000 \
        -v /srv/git/:/data gogs:latest

Notable requirement: /srv/git is a NFSv3 share; Here my directory listing:

deploy@git:/srv$ ls -la git/
total 20
drwxrwxrwx+ 5 root root   4096 Oct 15 18:07 .
drwxr-xr-x  4  501 deploy 4096 Jul 21 20:52 ..
drwxr-xr-x+ 4  501 deploy 4096 Oct 15 22:37 git
drwxr-xr-x+ 5  501 deploy 4096 Oct 15 18:30 gogs
drwx------+ 2  501 deploy 4096 Oct 15 18:07 ssh

Expected behavior

I could globally configure git within my container such that all repositories created are accepted as safe.
Or better: I can simply create bare repositories via the web interface.

Additional context

Today I updated my gogs image - With the image between 27.07.2025 - 31.07.2025 tagged latest from docker.io I was able to create repositories from the UI.
Mostlikely this has something to do with my NFSv3 share. But I am unable to replace the device in the next years and can not change the file system since the device is locked down.

I removed permissions for others for user tomes; But he still can't create repositories (nor can the admin gogs):

deploy@git:/srv$ ls -la git/git/gogs-repositories/
total 16
drwxrwxrwx+ 4 501 deploy 4096 Oct 15 22:25 .
drwxr-xr-x+ 4 501 deploy 4096 Oct 15 22:37 ..
drwxrwxrwx+ 2 501 deploy 4096 Oct 15 22:25 gogs
drwxrwx---+ 2 501 deploy 4096 Oct 15 22:37 tomes

Starting gogs shows many, many warnings like this:
Oct 15 22:37:48 git gogs[148681]: chown: /data/ssh/ssh_host_rsa_key.pub: Operation not permitted

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions