Solved git 'fatal: detected dubious ownership in repository'

I am working (as root) in a checked out branch of a git repository. At 08:31 this morning I did this:
Code:
[root@openxpki-3 openxpki (hll_ca2016)]# service openxpki onerestart
Service dirs recreated...
Executing: USER=openxpki /usr/local/bin/openxpkictl --config /usr/local/etc/openxpki/config.d restart
Stopping OpenXPKI
Stopping gracefully, 3 (sub)processes remaining...
DONE.
Starting OpenXPKI Community Edition v3.24.2
try/catch is experimental at /usr/local/lib/perl5/site_perl/OpenXPKI/Server/Init.pm line 103.
try/catch is experimental at /usr/local/lib/perl5/site_perl/OpenXPKI/Server/Init.pm line 107.
OpenXPKI Server is running and accepting requests.
DONE.
[root@openxpki-3 openxpki]# hgt alias

Note that after the script runs the checked out branch (hll_ca2026) no longer forms part of the prompt. When I try to see what branch I am now in I get this result:
Code:
[root@openxpki-3 openxpki]# git branch
fatal: detected dubious ownership in repository at '/usr/local/etc/openxpki'
To add an exception for this directory, call:

    git config --global --add safe.directory /usr/local/etc/openxpki

Other than running the service script shown above nothing else changed on this system. I am the only user logged in. The PWD directory contains the .git directory tree.

I logged on as root in a new session and get the same result. When I su to the user openxpki the issue goes away:
Code:
[root@openxpki-3 openxpki]# su -m openxpki
openxpki@openxpki-3:/usr/local/etc/openxpki % git br
  community
* hll_ca2016
  master
openxpki@openxpki-3:/usr/local/etc/openxpki %

Q. What is happening?

A. The service script silently changed the permissions on all the files in the branch.
Code:
openxpki@openxpki-3:/usr/local/etc/openxpki % git status
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/ignore': Permission denied
warning: unable to access '/root/.config/git/ignore': Permission denied
On branch hll_ca2016
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   Makefile
. . . all files in repository
    modified:   webui/default.conf

openxpki@openxpki-3:/usr/local/etc/openxpki % git diff Makefile
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
diff --git a/Makefile b/Makefile
old mode 100644
new mode 100755

openxpki@openxpki-3:/usr/local/etc/openxpki % git diff webui/default.conf
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
diff --git a/webui/default.conf b/webui/default.conf
old mode 100644
new mode 100755

Fix:
Code:
[root@openxpki-3 openxpki]# git config --global --add safe.directory /usr/local/etc/openxpki
[root@openxpki-3 openxpki (hll_ca2016)]#
 
Back
Top