diff mbox series

base-files: sysupgrade: include configured dirs

Message ID YQl9wONXTIOI1PJI@makrotopia.org
State Under Review
Delegated to: Daniel Golle
Headers show
Series base-files: sysupgrade: include configured dirs | expand

Commit Message

Daniel Golle Aug. 3, 2021, 5:32 p.m. UTC
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@users.noreply.github.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 package/base-files/files/sbin/sysupgrade | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

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