From 41d8cf30c967d8d8336b37ae17b0592fc06c4bc6 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 13 Nov 2024 11:56:39 +0100 Subject: [PATCH] src: small audit regarding "pkg" use Running the grep below lights up a few spots still: # git grep 'pkg[^/\[\.a-z'"'"',()_+"]' Make a few decisions for the future: * Use "pkg-static" outside the firmware code consistently with a full path * Modify ambiguous code or comments to not be found by the grep above * Firmware uses PKG now if we ever have to pivot to pkg-static or when we need to overwise modify the call. The goal of this excerise was to find all stray package manager spots that may run their own embedded pkg-update without the proper environment which should be gone for now. --- README.md | 4 ++-- src/etc/rc.syshook.d/upgrade/10-sanity.sh | 2 +- src/etc/rc.syshook.d/upgrade/90-cleanup.sh | 2 +- src/opnsense/scripts/firmware/check.sh | 2 +- src/opnsense/scripts/firmware/hostnames.sh | 2 +- src/www/crash_reporter.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 48ab1797a..bc8dbda50 100644 --- a/README.md +++ b/README.md @@ -113,8 +113,8 @@ For php code you will need to have `phpcs` and `phpcbf` installed. You can use the package `php-codesniffer` on Debian/Ubuntu. Python code will require `pycodestyle`. -For easier development you may want to use an OPNsense VM and run: -`pkg install os-debug` that will install all the necessary tools. +For easier development you may want to use an OPNsense VM and install +the `os-debug` plugin that will offer the necessary tools. make sweep ---------- diff --git a/src/etc/rc.syshook.d/upgrade/10-sanity.sh b/src/etc/rc.syshook.d/upgrade/10-sanity.sh index 506153789..779cc153a 100755 --- a/src/etc/rc.syshook.d/upgrade/10-sanity.sh +++ b/src/etc/rc.syshook.d/upgrade/10-sanity.sh @@ -7,7 +7,7 @@ if [ -z "${CORE}" ]; then exit 1 fi -if [ -z "$(pkg query %n ${CORE})" ]; then +if [ -z "$(/usr/local/sbin/pkg-static query %n ${CORE})" ]; then echo "Core package \"${CORE}\" not known to package database." exit 1 fi diff --git a/src/etc/rc.syshook.d/upgrade/90-cleanup.sh b/src/etc/rc.syshook.d/upgrade/90-cleanup.sh index 87ede7f8a..b9a2c0df7 100755 --- a/src/etc/rc.syshook.d/upgrade/90-cleanup.sh +++ b/src/etc/rc.syshook.d/upgrade/90-cleanup.sh @@ -1,4 +1,4 @@ #!/bin/sh -# run a cleanup beforehand to avoid later pkg-upgrade failures +# run a cleanup beforehand to avoid later upgrade failures opnsense-update -Fs diff --git a/src/opnsense/scripts/firmware/check.sh b/src/opnsense/scripts/firmware/check.sh index 132761e98..d4fe88352 100755 --- a/src/opnsense/scripts/firmware/check.sh +++ b/src/opnsense/scripts/firmware/check.sh @@ -109,7 +109,7 @@ fi (${PKG} update -f 2>&1) | ${TEE} ${LOCKFILE} ${OUTFILE} # always update the package manager so we can see the real updates directly -(${PKG} upgrade -r ${product_repo} -Uy pkg 2>&1) | ${TEE} ${LOCKFILE} +(${PKG} upgrade -r ${product_repo} -Uy 'pkg' 2>&1) | ${TEE} ${LOCKFILE} # parse early errors if grep -q 'No address record' ${OUTFILE}; then diff --git a/src/opnsense/scripts/firmware/hostnames.sh b/src/opnsense/scripts/firmware/hostnames.sh index a14d041ab..9ac554dab 100755 --- a/src/opnsense/scripts/firmware/hostnames.sh +++ b/src/opnsense/scripts/firmware/hostnames.sh @@ -29,7 +29,7 @@ URLS=$(opnsense-update -M; opnsense-update -X) -# Make a few assumptions about plugged pkg repositories: +# Make a few assumptions about plugged package repositories: # # * grab the "url" key, delimited with double quotes # * remove the spurious "pkg+" prefix to treat it as raw HTTP(S) diff --git a/src/www/crash_reporter.php b/src/www/crash_reporter.php index 0cc07c966..3bb705ce8 100644 --- a/src/www/crash_reporter.php +++ b/src/www/crash_reporter.php @@ -84,7 +84,7 @@ function upload_crash_report($files, $agent) include('head.inc'); -$plugins = implode(' ', explode("\n", shell_safe('pkg info -g "os-*"'))); +$plugins = implode(' ', explode("\n", shell_safe('/usr/local/sbin/pkg-static info -g "os-*"'))); $product = product::getInstance(); $crash_report_header = sprintf(