`apk add` tries to set directory permissions when running as non-root user
From the apk-tools documentation:
--no-chown Do not change file owner or group. By default apk will manage the file ownership when running as root. However, this option is turned on when running as non-root user, as changing file ownership is not permitted by the system then.
Reproducing the error
# as a non-root user
$ mkdir -p test-sysroot/etc/apk/keys
$ uname -m > test-sysroot/etc/apk/arch
$ cp /etc/apk/repositories test-sysroot/etc/apk
# let's try to install vim
$ apk --root=$PWD/test-sysroot add --initdb --allow-untrusted vim
(1/6) Installing vim-common (9.1.0-r1)
(2/6) Installing musl (1.2.5-r0)
(3/6) Installing xxd (9.1.0-r1)
(4/6) Installing ncurses-terminfo-base (6.4_p20231125-r0)
(5/6) Installing libncursesw (6.4_p20231125-r0)
(6/6) Installing vim (9.1.0-r1)
ERROR: 71 errors updating directory permissions
OK: 32 MiB in 6 packages
Expected behaviour
After vim is installed apk
should not try to set any permissions, as --no-chown
is implicitly passed by running as a non-root user.
Note: Passing --no-chown
explicitly results in the same behaviour.
Actual behaviour
apk
tries to set to set directory permissions despite the --no-chown
flag in database.c:2101.