Skip to content

Commit 127db05

Browse files
committed
[Fix] Vendored pkg_lib sync: 1.0.7 → 1.0.8
[Fix] POSIX herestring compat: process substitution → herestring in pkg_backup_prune, pkg_restore_files [Fix] ln -sfn symlink safety: -n flag prevents following existing symlink-to-directory
1 parent 6974848 commit 127db05

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ v2.0.1 | Mar 25 2026:
8181
-- Changes --
8282

8383
[Change] Vendored lib sync: tlog_lib 2.0.5, alert_lib 1.0.6, elog_lib 1.0.5,
84+
[Fix] pkg_lib 1.0.7 → 1.0.8: POSIX herestring compat, ln -sfn symlink safety
8485
[Change] tests/infra: batsman 1.4.0 → 1.4.1 — parallel-jobs smoke test fix
8586
pkg_lib 1.0.7
8687
[Change] Alert templates: consolidate summary into headers; drop "TOTAL" prefix from

CHANGELOG.RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ v2.0.1 | Mar 25 2026:
8181
-- Changes --
8282

8383
[Change] Vendored lib sync: tlog_lib 2.0.5, alert_lib 1.0.6, elog_lib 1.0.5,
84+
[Fix] pkg_lib 1.0.7 → 1.0.8: POSIX herestring compat, ln -sfn symlink safety
8485
[Change] tests/infra: batsman 1.4.0 → 1.4.1 — parallel-jobs smoke test fix
8586
pkg_lib 1.0.7
8687
[Change] Alert templates: consolidate summary into headers; drop "TOTAL" prefix from

files/internals/pkg_lib.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# pkg_lib.sh — Shared Packaging & Installer Library 1.0.6
3+
# pkg_lib.sh — Shared Packaging & Installer Library 1.0.8
44
###
55
# Copyright (C) 2002-2026 R-fx Networks <proj@rfxn.com>
66
# Ryan MacDonald <ryan@rfxn.com>
@@ -29,7 +29,7 @@
2929
[[ -n "${_PKG_LIB_LOADED:-}" ]] && return 0 2>/dev/null
3030
_PKG_LIB_LOADED=1
3131
# shellcheck disable=SC2034 # version checked by consumers
32-
PKG_LIB_VERSION="1.0.7"
32+
PKG_LIB_VERSION="1.0.8"
3333

3434
# Configurable defaults — consuming projects override via environment
3535
PKG_NO_COLOR="${PKG_NO_COLOR:-0}"
@@ -706,7 +706,7 @@ pkg_backup_prune() {
706706
command rm -rf "$entry_path"
707707
pruned=$((pruned + 1))
708708
fi
709-
done < <(find "$parent_dir" -maxdepth 1 -mindepth 1 -printf '%f\n' 2>/dev/null)
709+
done <<< "$(find "$parent_dir" -maxdepth 1 -mindepth 1 -printf '%f\n' 2>/dev/null)"
710710

711711
if [[ "$pruned" -gt 0 ]]; then
712712
pkg_info "pruned ${pruned} old backup(s)"
@@ -773,7 +773,7 @@ pkg_restore_files() {
773773
else
774774
pkg_warn "pkg_restore_files: failed to restore ${relpath}"
775775
fi
776-
done < <(find "$backup_path" -name "$pattern" -not -type d 2>/dev/null)
776+
done <<< "$(find "$backup_path" -name "$pattern" -not -type d 2>/dev/null)"
777777
done
778778

779779
if [[ "$restored" -eq 0 ]]; then
@@ -960,8 +960,9 @@ pkg_symlink() {
960960
return 1
961961
fi
962962

963-
# Reduced TOCTOU: ln -sf replaces rm+ln with a single coreutils call
964-
command ln -sf "$target" "$link_path" || {
963+
# Reduced TOCTOU: ln -sfn replaces rm+ln with a single coreutils call
964+
# -n prevents following existing symlink-to-directory (classic ln -sf gotcha)
965+
command ln -sfn "$target" "$link_path" || {
965966
pkg_error "pkg_symlink: failed to create symlink ${link_path} -> ${target}"
966967
return 1
967968
}

0 commit comments

Comments
 (0)