Page MenuHomePhorge

ExecFuture / Diffusion returns "fatal: detected dubious ownership in repository at ..."
Closed, ResolvedPublic

Asked by ondrejk on Feb 3 2023, 08:08.

Details

Dear all,

my Phorge/Phabricator installation is unable to use "git" shell command. For example, when it tries to show history of repository, it fails:

Command failed with error #128!

COMMAND
git log --skip=0 -n 15 --pretty=format:'%H:%P' 79eb7fc914ea3b5936ea15a08af3154e7d2e1a36 -- 

STDOUT
(empty)

STDERR
fatal: detected dubious ownership in repository at '/storage/phabricator/storage-repo/35'
To add an exception for this directory, call:

	git config --global --add safe.directory /storage/phabricator/storage-repo/35

It returns the same error for all repositories (even for repos created today). What is strange, yesterday, all worked fine :-/
I tried to run the suggested command under several users (www-data, phab-daemon, root), so the directory is for sure marked as safe. I confirmed this from shell as the user "www-data" with:

git config --global --get-all safe.directory

Which return the directory as safe. Also, when run from command line as www-data user, it works fine:

$ git log --skip=0 -n 15 --pretty=format:'%H:%P' 79eb7fc914ea3b5936ea15a08af3154e7d2e1a36 -- 
79eb7fc914ea3b5936ea15a08af3154e7d2e1a36:

File ownership is set as follows:

drwxr-sr-x   7 phab-daemon www-data 4096 feb  3 09:05 .
drwxrwsr-x+ 23 www-data    www-data 4096 feb  3 08:51 ..
drwxr-sr-x   2 phab-daemon www-data 4096 feb  3 08:51 branches
-rw-r--r--   1 phab-daemon www-data  104 feb  3 09:05 config
-rw-r--r--   1 phab-daemon www-data   73 feb  3 08:51 description
-rw-r--r--   1 phab-daemon www-data   23 feb  3 09:05 HEAD
drwxr-sr-x   3 phab-daemon www-data 4096 feb  3 08:51 hooks
drwxr-sr-x   2 phab-daemon www-data 4096 feb  3 08:51 info
drwxr-sr-x   7 phab-daemon www-data 4096 feb  3 08:54 objects
drwxr-sr-x   4 phab-daemon www-data 4096 feb  3 08:51 refs

Do you have any idea, what can I do?

Answers

ondrejk
Updated 559 Days Ago

So I was able to resolve it by running this system command:

sudo git config --system --add safe.directory '*'

I don't know why the following is ignored, when git commands are executed from Phork/Phabricator:

su www-data
git config --global --add safe.directory '*'

Edited: at the moment you can only fix at system level. If you need to setup a fix just for the www-data user, try this patch first:

D25149: Config page: add $HOME to allow a gitconfig and help on "dubious ownership"

valerio.bozzolan
Updated 559 Days Ago

If you see that error from Diffusion that is probably an installation problem.

This error is shown if the user running git is operating on files that are not owned by that user. Double check your environment to verify this mismatch.

Note that Phorge/Phabricator runs git commands using something like sudo -u your-vcs-user git .... from the webserver user. So, it really tries to use the very same user you configured. So, if there is a mismatch, it's probably a problem of the system administrator.

https://we.phorge.it/book/phorge/article/diffusion_hosting/


But, if you have troubleshooted that error from the Config page, probably you are affected by some bugs:

T15282: Fix/avoid/simplify similar fatal: detected dubious ownership in repository at '/var/www/phorge'

T15242: /config/ can run git log commands that silently fail ("fatal: detected dubious ownership in repository at ....")

T15299: Config page runs git commands that should have an HOME to open gitconfig correctly

In short, the shortest solution is probably related to the installation process. Related patch to improve that:

D25236: Diviner: mention how to flag Arcanist and Phorge as "safe" git repos

New Answer

Answer

This question has been marked as closed, but you can still leave a new answer.