Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 942394 - sys-apps/portage: Make sure XDG_CONFIG_HOME is set to proper value when switching user context to prevent a permission denied warning
Summary: sys-apps/portage: Make sure XDG_CONFIG_HOME is set to proper value when switc...
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2024-10-28 08:41 UTC by konsolebox
Modified: 2024-10-29 02:38 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix that simply excludes the variable (example-fix.patch,790 bytes, patch)
2024-10-28 09:04 UTC, konsolebox
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description konsolebox 2024-10-28 08:41:44 UTC
I get "warning: unable to access '/home/some-directory/.config/git/attributes': Permission denied" unless I unset the XDG_CONFIG_HOME variable or set it to `${HOME}/.config` in a wrapper.  ${HOME} in this case being /var/lib/portage/home.

I'm not sure this is only happens in my system because of all the wrapper scripts I make but portage clearly doesn't refer to the variable at all so I might as well just post a bug for it for future reference.

Basically what I think happens is portage ran as EUID 0 switches user context to portage but preserves the value of XDG_CONFIG_HOME causing git to refer to the directory specified in it but it doesn't.  So portage so unset it or something.

As an aside git also refers to the XDG_CACHE_HOME variable so portage might as  well correct that variable when switching even though it may not really be directly affecting porage's runtime just for consistency.  The XDG_CACHE_HOME variable is mentioned in Documentation/git-credential-cache.txt.

Git version: 2.46.0

Suggestion to reproduce:

1) Make sure `sudo env | grep ^XDG_CONFIG_HOME=` (or without sudo as root) produces an output and that the directory displayed is only accessible to the user.  E.g., the directory or the parent directory is set to 0750.

2) Run `sudo emerge --sync` or as root simply run `emerge --sync`.

3) Adding the '-i' option to both sudo commands above might help.  If the XDG variables are generated by a PAM module, it can only be reproduced if sudo is also configured to call the PAM module or use another module to give a similar effect.  I use pam_xdg for sudo which complies with the XDG Base Directory Specification.

Anyway regardless if XDG_CONFIG_HOME is commonly set in root or not, portage, as a user of the git command should properly set the value when switching user contexts.  For consistency at least.
Comment 1 konsolebox 2024-10-28 09:04:39 UTC
Created attachment 907111 [details, diff]
Fix that simply excludes the variable