commit: 37b108a7a4630583921484c0b5f513a7e384d851
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 6 18:03:50 2023 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Jun 14 19:21:01 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=37b108a7
doebuild: do not rely on os.access() for PORTAGE_TMPDIR write check
Calling os.access() on ${PORTAGE_TMPDIR}/portage will not trigger any
automount that the user may have configured there.
Instead, just try to create a file and catch PermissionError.
Bug: https://bugs.gentoo.org/890812
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/package/ebuild/doebuild.py | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/portage/package/ebuild/doebuild.py
b/lib/portage/package/ebuild/doebuild.py
index d30c6b8f0..8b65a7862 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -1608,7 +1608,22 @@ def _check_temp_dir(settings):
# for those people.
checkdir = first_existing(os.path.join(settings["PORTAGE_TMPDIR"],
"portage"))
- if not os.access(checkdir, os.W_OK):
+ try:
+ with tempfile.NamedTemporaryFile(prefix="exectest-", dir=checkdir) as
fd:
+ os.chmod(fd.name, 0o755)
+ if not os.access(fd.name, os.X_OK):
+ writemsg(
+ _(
+ "Can not execute files in %s\n"
+ "Likely cause is that you've mounted it with one of
the\n"
+ "following mount options: 'noexec', 'user',
'users'\n\n"
+ "Please make sure that portage can execute files in
this directory.\n"
+ )
+ % checkdir,
+ noiselevel=-1,
+ )
+ return 1
+ except PermissionError:
writemsg(
_(
"%s is not writable.\n"
@@ -1619,21 +1634,6 @@ def _check_temp_dir(settings):
)
return 1
- with tempfile.NamedTemporaryFile(prefix="exectest-", dir=checkdir) as fd:
- os.chmod(fd.name, 0o755)
- if not os.access(fd.name, os.X_OK):
- writemsg(
- _(
- "Can not execute files in %s\n"
- "Likely cause is that you've mounted it with one of the\n"
- "following mount options: 'noexec', 'user', 'users'\n\n"
- "Please make sure that portage can execute files in this
directory.\n"
- )
- % checkdir,
- noiselevel=-1,
- )
- return 1
-
return os.EX_OK