Skip to content

Commit

Permalink
Run PORTAGE_TRUST_HELPER before remote binary package operations
Browse files Browse the repository at this point in the history
Right now this is somewhat suboptimal because the helper is only
called if FEATURES="binpkg-request-signature" is set, but existing
signatures are also verified otherwise.

Closes: gentoo#1085
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
  • Loading branch information
akhuettel authored and palao committed Oct 16, 2023
1 parent 76368f7 commit 0905d99
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
python -m pip install --upgrade pip
# setuptools needed for 3.12+ because of https://github.com/mesonbuild/meson/issues/7702.
python -m pip install pytest setuptools
# symlink /bin/true to /usr/bin/getuto (or do we want to grab the script from github?)
sudo ln -s /bin/true /usr/bin/getuto
- name: Test meson install --destdir /tmp/install-root
run: |
echo -e "[binaries]\npython = '$(command -v python)'" > /tmp/native.ini
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Features:
* bintree: Add new API member (invalid_paths) to allow gentoolkit to later
clean up invalid binpkgs (bug #900224).

* Run PORTAGE_TRUST_HELPER before remote binary package operations.

Bug fixes:
* Prevent gpg from removing /dev/null when unlocking signing key (bug #912808).

Expand Down
3 changes: 3 additions & 0 deletions cnf/make.globals
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ PORTAGE_ELOG_MAILFROM="portage@localhost"
# Signing command used by egencache
PORTAGE_GPG_SIGNING_COMMAND="gpg --sign --digest-algo SHA256 --clearsign --yes --default-key \"\${PORTAGE_GPG_KEY}\" --homedir \"\${PORTAGE_GPG_DIR}\" \"\${FILE}\""

# Trust helper executable for installing and updating package verification keys
PORTAGE_TRUST_HELPER="/usr/bin/getuto"

# btrfs.* attributes are irrelevant, see bug #527636.
# security.* attributes may be special (see bug 461868), but
# security.capability is specifically not excluded (bug 548516).
Expand Down
12 changes: 12 additions & 0 deletions lib/portage/dbapi/bintree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,23 @@ def _populate_local(self, reindex=True):

return pkgindex if update_pkgindex else None

def _run_trust_helper(self):
portage_trust_helper = self.settings.get("PORTAGE_TRUST_HELPER", "")
if portage_trust_helper == "":
return
ret = subprocess.run(portage_trust_helper)
ret.check_returncode()

def _populate_remote(self, getbinpkg_refresh=True):
self._remote_has_index = False
self._remotepkgs = {}

if "binpkg-request-signature" in self.settings.features:
# This is somewhat broken, we *should* run the trust helper always
# when binpackages are involved, not only when we refuse unsigned
# ones. (If the keys have expired we end up refusing signed but
# technically invalid packages...)
self._run_trust_helper()
gpkg_only = True
else:
gpkg_only = False
Expand Down
1 change: 1 addition & 0 deletions lib/portage/package/ebuild/_config/special_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
"PORTAGE_RSYNC_RETRIES",
"PORTAGE_SSH_OPTS",
"PORTAGE_SYNC_STALE",
"PORTAGE_TRUST_HELPER",
"PORTAGE_USE",
"PORTAGE_LOG_FILTER_FILE_CMD",
"PORTAGE_LOGDIR",
Expand Down
9 changes: 9 additions & 0 deletions man/make.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,15 @@ Defaults to /var/tmp.

This should not be set to point anywhere under location of any repository.
.TP
\fBPORTAGE_TRUST_HELPER\fR = \fI[path]\fR
Defines an executable file which initializes and maintains
/etc/portage/gnupg, installing keys that are trusted for binary package
signing, and refreshing these keys from a key server. This helper is called
before all operations involving remote binary packages if and only if
binpkg-request-signature is in \fBFEATURES\fR.
.br
Defaults to "/usr/bin/getuto" (provided by app-portage/getuto).
.TP
\fBPORTAGE_USERNAME\fR = \fI[user]\fR
Defines the username to use when executing in userpriv/etc... modes (i.e.
non-root).
Expand Down

0 comments on commit 0905d99

Please sign in to comment.