Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: Error opening the trusted directory #2232

Open
am11 opened this issue Jan 23, 2024 · 1 comment
Open

pkg: Error opening the trusted directory #2232

am11 opened this issue Jan 23, 2024 · 1 comment

Comments

@am11
Copy link

am11 commented Jan 23, 2024

Hit this error when recently upgraded from 1.17.0 to 1.20.0 in cross toolchain setup dotnet/dotnet-buildtools-prereqs-docker#965.

Repro (ubuntu amd64):

#!/usr/bin/env bash
set -e

__RootfsDir=$(pwd)/.tools/rootfs/x64
__FreeBSDPkg=1.20.0 # works with 1.17.0

mkdir -p $__RootfsDir/usr/local/etc
wget -O - https://download.freebsd.org/ftp/releases/amd64/amd64/14.0-RELEASE/base.txz | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
echo "ABI = \"FreeBSD:14:amd64\"; FINGERPRINTS = \"$__RootfsDir/usr/share/keys\"; REPOS_DIR = [\"$__RootfsDir/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf
echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"$__RootfsDir/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf

mkdir -p $__RootfsDir/tmp
wget -O - "https://github.com/freebsd/pkg/archive/${__FreeBSDPkg}.tar.gz" | tar -C $__RootfsDir/tmp -zxf -
cd $__RootfsDir/tmp/pkg-$__FreeBSDPkg

mkdir -p $__RootfsDir/host/etc
./autogen.sh && ./configure --prefix="$__RootfsDir"/host && make -j && make install
rm -rf $__RootfsDir/tmp/pkg-$__FreeBSDPkg

INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf update
INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf install --yes libunwind icu libinotify openssl krb5 terminfo-db

With pwd=/testdir, it fails:

pkg: Error opening the trusted directory /testdir/.tools/rootfs/x64/usr/share/keys/pkg/trusted
pkg: Error loading trusted certificates
Unable to update repository FreeBSD
Error updating repositories!

seems like RELATIVE_PATH macro trims the leading / which fails openat:

if ((fd = openat(ctx.rootfd, RELATIVE_PATH(path), O_DIRECTORY)) == -1) {

strace:

[pid 11734] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11739, si_uid=33333, si_status=0, si_utime=42, si_stime=6} ---
[pid 11734] openat(4, "testdir/.tools/rootfs/x64/usr/share/keys/pkg/trusted", O_RDONLY|O_DIRECTORY) = -1 ENOENT (No such file or directory)
[pid 11734] write(2, "pkg: ", 5pkg: )        = 5
@Thefrank
Copy link

1.17.2 appears to be the last version that worked. 1.17.3 started throwing the above error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants