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

Fix git 2.35.2 safe directory errors #1749

Closed
ptman opened this issue Apr 13, 2022 · 4 comments
Closed

Fix git 2.35.2 safe directory errors #1749

ptman opened this issue Apr 13, 2022 · 4 comments
Labels

Comments

@ptman
Copy link
Contributor

ptman commented Apr 13, 2022

Describe the bug

https://github.blog/2022-04-12-git-security-vulnerability-announced/

FAILED! => {
"changed": false,
"msg": "Failed to set a new url https://github.com/vector-im/hydrogen-web.git for origin:
fatal: unsafe repository ('/matrix/client-hydrogen/docker-src' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /matrix/client-hydrogen/docker-src"
}

To Reproduce
My vars.yml file looks like this:

matrix_client_hydrogen_enabled: true

Expected behavior

No failure

Matrix Server:

  • OS: Ubuntu 20.04
  • Architecture: amd64
@spantaleev
Copy link
Owner

This version changes Git’s behavior when looking for a top-level .git directory to stop when its directory traversal changes ownership from the current user. (If you wish to make an exception to this behavior, you can use the new multi-valued safe.directory configuration).

Perhaps instead of using the safe.directory workaround, we should try to ensure that the user that git is started with, and the user of the directory we operate on (e.g. /matrix/client-hydrogen/docker-src) are the same. We may be mixing root and matrix somehow.

@lucianolacurcia
Copy link

I am getting similar error here:

TASK [matrix-client-element : Ensure Element Docker image is pulled] ************************************************************************************************************************************************
skipping: [matrix.***]

TASK [matrix-client-element : Ensure Element repository is present on self-build] ***********************************************************************************************************************************
fatal: [matrix.***]: FAILED! => changed=false
  msg: |-
    Failed to set a new url https://github.com/vector-im/riot-web.git for origin:  fatal: unsafe repository ('/matrix/client-element/docker-src' is owned by someone else)
    To add an exception for this directory, call:

            git config --global --add safe.directory /matrix/client-element/docker-src

PLAY RECAP **********************************************************************************************************************************************************************************************************
matrix.*** : ok=137  changed=3    unreachable=0    failed=1    skipped=1374 rescued=0    ignored=0

@spantaleev
Copy link
Owner

Form now on, we'll git clone (into /matrix/SERVICE/docker-src for self-building purposes) using the matrix user, instead of mixing root and matrix.


For those affected by this issue, you'll need to pull the latest commit of the playbook, as well as run this command on the Matrix server: find /matrix -maxdepth 2 -name 'docker-src' | xargs rm -rf

To learn more, see the changelog entry (Compatibility Break) Changes to docker-src permissions necessitating manual action

@ewonchang
Copy link

For me (Aarch64 Ubuntu server), the symptom was something related to git command permission error. Took me a while to find this solution. Thanks @spantaleev the method works like a charm

@luixxiul luixxiul added the bug label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants