pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sysutils/sysupgrade: Wrong shell used --> wipes local changes to /etc
On Thu, Nov 19, 2026 at 03:20:59PM +0100, Kusalananda Kähäri wrote:
> Hi,
>
> I've notice that the sysutils/sysupgrade package, when built and
> installed locally (here, NetBSD 11.1 with a bleeding edge pkgsrc
> is used), sometimes uses the /usr/pkg/sbin/mksh shell as its shell
> interpreter rather than /bin/sh. This has serious consequences when
> extracting the sets, as the part of the script related to this relies
> on the shell's handling of quoted strings, and the sh and ksh shells do
> this differently.
>
> Here's the relevant code:
>
> 355 for set_name in "${@:-$(shtk_config_get SETS)}"; do
> 356 case "${set_name}" in
> 357 *etc) ;; # Handled by etcupdate.
> 358 kern-*)
> 359 shtk_cli_error "SETS should not contain any kernel sets;" \
> 360 "found ${set_name}"
> 361 ;;
> 362 modules) ;; # Handled by modules.
> 363 *) sets="${sets} ${set_name}" ;;
> 364 esac
> 365 done
>
> When "$@" is empty (which it will be if running either "sysupgrade sets"
> with no extra arguments, or "sysupgrade auto"), the sh shell will expand
> the quoted expression "$(shtk_config_get SETS)" into a list of set
> names, while the mksh shell will not split it. With sh, "sets" will be
> a space-delimited list of sets with some sets (etc.tar.xz, for example)
> removed, but with mksh, it will be a space-delimited list with these
> sets retained.
>
> A later loop, a bit further down, splits the "sets" string the same
> way in both shells, and whatever sets it contains are extracted. The
> effect is that any local changes to files under /etc (e.g. to passwd and
> rc.conf) are reverted.
>
> 371 shtk_cli_info "Upgrading base system"
> 372 for set_name in ${sets}; do
> 373 extract_set "${set_name}"
> 374 done
>
> I have two systems with identical pkgsrc mk.conf files, both with
>
> TOOLS_PLATFORM.sh?= /usr/pkg/bin/mksh
Sorry, the point of pointing out my two (obviously not actually)
identical systems is that on one, the correct shell, /bin/sh, is
inserted, while the wring shell is picked on the other.
>
> I don't fully understand how the interpreter shell is inserted into the
> script when the package is built (it's distributed _without_ "#!"-line).
> Any input is welcomed.
>
> Andreas
Home |
Main Index |
Thread Index |
Old Index