[openwrt/openwrt] base-files: merge /etc/passwd et al at sysupgrade config restore
LEDE Commits
lede-commits at lists.infradead.org
Thu Oct 22 09:54:04 EDT 2020
dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/de7ca7dafadfd650d031e0379ce0c002868d5936
commit de7ca7dafadfd650d031e0379ce0c002868d5936
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Thu Oct 22 13:13:39 2020 +0100
base-files: merge /etc/passwd et al at sysupgrade config restore
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
package/base-files/Makefile | 2 +-
package/base-files/files/lib/preinit/80_mount_root | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 27bf7ae3f9..84b2f2d5ec 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/feeds.mk
PKG_NAME:=base-files
-PKG_RELEASE:=232
+PKG_RELEASE:=233
PKG_FLAGS:=nonshared
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root
index 265a3f18df..56d3fa3797 100644
--- a/package/base-files/files/lib/preinit/80_mount_root
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -2,6 +2,19 @@
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
+missing_lines() {
+ local file1 file2 line
+ file1="$1"
+ file2="$2"
+ oIFS="$IFS"
+ IFS=":"
+ while read line; do
+ set -- $line
+ grep -q "^$1:" "$file2" || echo "$*"
+ done < "$file1"
+ IFS="$oIFS"
+}
+
do_mount_root() {
mount_root
boot_run_hook preinit_mount_root
@@ -9,6 +22,9 @@ do_mount_root() {
echo "- config restore -"
cd /
tar xzf /sysupgrade.tgz
+ missing_lines /rom/etc/passwd /etc/passwd >> /etc/passwd
+ missing_lines /rom/etc/group /etc/group >> /etc/group
+ missing_lines /rom/etc/shadow /etc/shadow >> /etc/shadow
# Prevent configuration corruption on a power loss
sync
}
More information about the lede-commits
mailing list