[PATCH] base-files: sysupgrade: include configured dirs

Daniel Golle daniel at makrotopia.org
Tue Aug 3 10:32:48 PDT 2021


When the directory nodes themselves are not in the tar, the
permissions on restore depend on the way the restore is executed.
A 750 dir will be restored as 755 by luci and 700 by shell.
Make sure directories get included in the list as well.

For compatbility reasons, do not change the output of list-backup and
do not show directories there as the output of that command may be
intepreted by existing (external) scripts/tools.

Reported-by: fda77 <fda77 at users.noreply.github.com>
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 package/base-files/files/sbin/sysupgrade | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 7e0a00e13b..5ccfb55911 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -134,9 +134,13 @@ list_changed_conffiles() {
 list_static_conffiles() {
 	local filter=$1
 
-	find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
-		/etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
-		\( -type f -o -type l \) $filter 2>/dev/null
+	local items="$(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null)"
+	# directories
+	for item in $items; do
+		[ -d $item ] && echo ${item%%/}/
+	done
+	# files
+	find $items \( -type f -o -type l \) $filter 2>/dev/null
 }
 
 add_conffiles() {
@@ -270,7 +274,7 @@ do_save_conffiles() {
 if [ $CONF_BACKUP_LIST -eq 1 ]; then
 	run_hooks "$CONFFILES" $sysupgrade_init_conffiles
 	[ "$SAVE_INSTALLED_PKGS" -eq 1 ] && echo ${INSTALLED_PACKAGES} >> "$CONFFILES"
-	cat "$CONFFILES"
+	grep -v '/$' "$CONFFILES"  # for compatibility dont show dirs
 	rm -f "$CONFFILES"
 	exit 0
 fi
-- 
2.32.0




More information about the openwrt-devel mailing list