Git credential-cache manager is not treating `path=` correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I report this potential bug:
https://stackoverflow.com/questions/76963207/git-credential-cache-does-not-matchpath-correctly

I really dont get Git `2.41.0` and its crude `git credential-cache` manager:

When I test `git credential-cache` with the below script (`setsid test.sh`).
if it can report 3 different passwords it will fail with

```
fatal: could not read Username for
'https://www.server.com/repos/1.git': No such device or address
```
on the first run,
and when the script runs **a second time** it will pass happily.

The `git credential-store` on the other hand does not work at all and
on the first `git credential fill` prompt the user.

**Question: What is going on here. This makes no sense and results in
peculiar fails on CI**

*Note: setsid is to detach from the controlling terminal that git does
not prompt or something.*
*Note: We need `useHttpPath=true` to tell Git to use the `path` in
credential `fill` statements (AFAIK).


```shell
#!/bin/bash
set -e
# set -x
# IMPORTANT: =======================================
# Execute this script inside a container
# and check if it reports all password correctly
#
# ==================================================

# git credential-cache exit || true

git config --global --unset-all credential.helper || true
git config --global --add credential.helper ""
# git config --global --add credential.helper "store" # Does not work at all.
git config --global --add credential.helper "cache --timeout=7200"

git config --global
"credential.https://www.server.com/repos/1.git.useHttpPath"; true
git config --global
"credential.https://www.server.com/repos/2.git.useHttpPath"; true

export GIT_TRACE=1

# Add 3 credentials, 2 specifics with `path=`
# 1 with general host.
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/1.git"
    echo "username=banana"
    echo "password=banana1"
} | git credential approve

{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/2.git"
    echo "username=banana"
    echo "password=banana2"
} | git credential approve

{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "username=banana"
    echo "password=general"
} | git credential approve

echo "Check the credentials"
# Check it
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/1.git"
} | git credential fill | grep -q "password=banana1" || {
    echo "wrong pass banana1"
    exit 1
}

{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/2.git"
} | git credential fill | grep -q "password=banana2" || {
    echo "wrong pass banana2"
    exit 1
}

{
    echo "protocol=https"
    echo "host=www.server.com"
} | git credential fill | grep -q "password=general" || {
    echo "wrong pass general"
    exit 1
}

echo "all passwords correctly reported"
```



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux