Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-dev@l.g.o
Cc: base-system@g.o, Mike Gilbert <floppym@g.o>
Subject: [gentoo-dev] [PATCH] savedconfig.eclass: drop faulty permissions check
Date: Mon, 27 Sep 2021 00:09:39
Message-Id: 20210927000908.12700-1-floppym@gentoo.org
1 This check was meant to test if the user has accidentally restricted
2 access to the /etc/portage/savedconfig directory. There are a few
3 problems:
4
5 1. We don't actually need read access on the directory. We really need
6 the execute bit set so that we can access files within the directory.
7
8 2. There may be permissions issues on subdirectories, and we would fail
9 to detect them.
10
11 3. There is no easy way to distingish between EACCES and ENOENT using
12 shell commands. We get an exit status of 1 from [[ -r ${path} ]] if
13 there is a permissions problem or if some component of the path does
14 not exist. This makes resolving problem 2 difficult without using a
15 more robust language with direct access to errno.
16
17 Instead of trying to detect a permissions problem, just output a warning
18 telling the user to check permissions if we cannot find a config file.
19
20 Bug: https://bugs.gentoo.org/289168
21 Bug: https://bugs.gentoo.org/814995
22 Signed-off-by: Mike Gilbert <floppym@g.o>
23 ---
24 eclass/savedconfig.eclass | 10 +++-------
25 1 file changed, 3 insertions(+), 7 deletions(-)
26
27 diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass
28 index e90a9b618d6..c4fd0c492f4 100644
29 --- a/eclass/savedconfig.eclass
30 +++ b/eclass/savedconfig.eclass
31 @@ -1,4 +1,4 @@
32 -# Copyright 1999-2020 Gentoo Authors
33 +# Copyright 1999-2021 Gentoo Authors
34 # Distributed under the terms of the GNU General Public License v2
35
36 # @ECLASS: savedconfig.eclass
37 @@ -146,14 +146,10 @@ restore_config() {
38 treecopy . "${dest}" || die "Failed to restore ${found} to $1"
39 popd > /dev/null
40 else
41 - # maybe the user is screwing around with perms they shouldnt #289168
42 - if [[ ! -r ${base} ]] ; then
43 - eerror "Unable to read ${base} -- please check its permissions."
44 - die "Reading config files failed"
45 - fi
46 ewarn "No saved config to restore - please remove USE=savedconfig or"
47 ewarn "provide a configuration file in ${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig/${CATEGORY}/${PN}"
48 - ewarn "Your config file(s) will not be used this time"
49 + ewarn "and ensure the build process has permission to access it."
50 + ewarn "Your config file(s) will not be used this time."
51 fi
52 }
53
54 --
55 2.33.0