base-files: fix merge of passwd/shadow/group lines with trailing colons
authorMatthias Schiffer <mschiffer@universe-factory.net>
Thu, 29 Aug 2024 18:24:02 +0000 (20:24 +0200)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Thu, 29 Aug 2024 19:07:15 +0000 (21:07 +0200)
Empty trailing fields get lost when the lines are split and merged again
at colons, resulting in unparsable entries. Only use the split fields for
matching against the other file, but emit the original line unchanged
to fix the issue.

Fixes: de7ca7dafadf ("base-files: merge /etc/passwd et al at sysupgrade config restore")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
package/base-files/files/lib/preinit/80_mount_root

index fa6abcde57f850a3b1d4cf6ed83d5e4031266f59..940c56c9258e35ac60a84d434d1e6b480ef63ea5 100644 (file)
@@ -9,7 +9,7 @@ missing_lines() {
        IFS=":"
        while read line; do
                set -- $line
-               grep -q "^$1:" "$file2" || echo "$*"
+               grep -q "^$1:" "$file2" || echo "$line"
        done < "$file1"
        IFS="$oIFS"
 }