Not able to clone a repo: fatal: detected dubious ownership in repository

Bug #2032919 reported by Sven Anders
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
diskimage-builder
New
Undecided
Unassigned

Bug Description

When I tried to create an Octavia Amphore on an ubuntu 22.04 with git 2.34.1

I have run in the following Error:
```
2023-08-24 09:12:23.484 | (0001 / 0002)
2023-08-24 09:12:23.500 | Updating cache of /home/sanders/tmp/octavia in /home/sanders/.cache/image-create/source-repositories/amphora_agent_e6b0e705176b0282fce5791af353e17e509f6e90 with ref master
2023-08-24 09:12:23.512 | Cloning from amphora-agent cache and applying ref master
2023-08-24 09:12:23.682 | HEAD is now at a88aa18d Merge "Fix the issue of losing nf_conntrace* values after a reboot."
2023-08-24 09:12:23.684 | fatal: detected dubious ownership in repository at '/home/sanders/tmp/x1/dib_build.WIyP3c3x/mnt/opt/amphora-agent'
2023-08-24 09:12:23.684 | To add an exception for this directory, call:
2023-08-24 09:12:23.684 |
2023-08-24 09:12:23.684 | git config --global --add safe.directory /home/sanders/tmp/x1/dib_build.WIyP3c3x/mnt/opt/amphora-agent
```

Please note that I set `TMP_DIR=/home/sanders/tmp/x1` but the error is still there if I use the default.

I was able to hotfix it with the follwoing path:

```
--- /usr/lib/python3/dist-packages/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories.orig 2023-08-24 11:04:58.417844792 +0200
+++ /usr/lib/python3/dist-packages/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories 2023-08-24 11:39:40.923188247 +0200
@@ -171,6 +171,11 @@
                     fi
                 else
                     sudo git clone -q $CACHE_PATH $REPO_DEST
+
+ echo "Git config add global ${REPO_DEST}"
+ sudo git config --global --add safe.directory ${REPO_DEST}
+ git config --global --add safe.directory ${REPO_DEST}
+
                     pushd $REPO_DEST > /dev/null
                     if [[ "$REPOREF" == "*" ]]; then
                         sudo git fetch -q --prune --update-head-ok $CACHE_PATH \
@@ -184,6 +189,10 @@
                     fi
                     popd > /dev/null

+ echo "Git config unset global ${REPO_DEST}"
+ sudo git config --global --unset safe.directory ${REPO_DEST}
+ git config --global --unset safe.directory ${REPO_DEST}
+
                     # Write the sha being used into the source-repositories manifest
                     echo "$REPONAME git $REPOPATH $REPOLOCATION $git_sha" >> $GIT_MANIFEST
                 fi

```

Revision history for this message
petergray (petergray3219) wrote :

The error message "fatal: detected dubious ownership in repository at '/home/sanders/tmp/x1/dib_build.WIyP3c3x/mnt/opt/amphora-agent'" means that the folder '/home/sanders/tmp/x1/dib_build.WIyP3c3x/mnt/opt/amphora-agent' is owned by someone else, not you. This can happen if another person made the folder or changed its ownership. To fix it, you added the folder to a special list in Git settings to avoid this check. But, this isn't very safe. A better way is to change the folder's ownership to yours. To do this, run: "sudo chown -R sanders /home/sanders/tmp/x1/dib_build.WIyP3c3x/mnt/opt/amphora-agent". After this, the error should go away. Remember: the special list applies to all your folders, don't use it for shared folders. Use "ls -l" to check ownership. Hope this helps! Ask if you need more help. Source: https://www.poolservicesanantonio.us/pool-renovation-services/

Revision history for this message
Sven Anders (tabacha) wrote :

I can not change the dir with chmod, because it was not created by me, but by diskimage-builder. But I just saw, that in a never version the diskimage-builder was changed that only root is doing git commands, not the sanders user.

https://opendev.org/openstack/diskimage-builder/commit/4cb3346fec6715d3f2ba7953face5296f497956a

so I will try to update to this version.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.