diff mbox series

base-files: merge /etc/passwd support more than just /rom based installs

Message ID CAA21KT-qhPSQzjkOKyK2rdwn0UgVgMZWq+Z_R8gbAj4raj3pOQ@mail.gmail.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series base-files: merge /etc/passwd support more than just /rom based installs | expand

Commit Message

Imran K Nov. 27, 2020, 6:19 a.m. UTC
Support more than /rom only when migrating user accounts

Signed-by: Imran Khan <gururug@gmail.com>

---

---

Comments

Henrique de Moraes Holschuh Nov. 27, 2020, 2:13 p.m. UTC | #1
On 27/11/2020 03:19, Imran K wrote:
> Support more than /rom only when migrating user accounts

This is the kind of thing you must do safely (e.g. using mktemp -dt && 
chmod 0700 <the-mktemp-created-dir> && { ... }), unless you can prove 
there is no way someone might have messed with /tmp before or during the 
script's execution.

And if you can prove it is safe (which it might well be), that 
explanation ought to be in the commit log...

Also, cp -f and rm -f might be better choices.

> diff --git a/package/base-files/files/lib/preinit/80_mount_root
> b/package/base-files/files/lib/preinit/80_mount_root
> index 56d3fa3797..1c5bdbc9d8 100644
> --- a/package/base-files/files/lib/preinit/80_mount_root
> +++ b/package/base-files/files/lib/preinit/80_mount_root
> @@ -20,11 +20,17 @@ do_mount_root() {
>    boot_run_hook preinit_mount_root
>    [ -f /sysupgrade.tgz ] && {
>    echo "- config restore -"
> - cd /
> +         cp /etc/passwd /tmp/
> + cp /etc/group /tmp/
> + cp /etc/shadow /tmp/
> +        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
> + missing_lines /tmp/passwd /etc/passwd >> /etc/passwd
> + missing_lines /tmp/group /etc/group >> /etc/group
> + missing_lines /tmp/shadow /etc/shadow >> /etc/shadow
> +        rm /tmp/shadow 2>/dev/null
> +        rm /tmp/passwd 2>/dev/null
> +        rm /tmp/group 2>/dev/null
>    # Prevent configuration corruption on a power loss
>    sync
>    }
diff mbox series

Patch

diff --git a/package/base-files/files/lib/preinit/80_mount_root
b/package/base-files/files/lib/preinit/80_mount_root
index 56d3fa3797..1c5bdbc9d8 100644
--- a/package/base-files/files/lib/preinit/80_mount_root
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -20,11 +20,17 @@  do_mount_root() {
  boot_run_hook preinit_mount_root
  [ -f /sysupgrade.tgz ] && {
  echo "- config restore -"
- cd /
+         cp /etc/passwd /tmp/
+ cp /etc/group /tmp/
+ cp /etc/shadow /tmp/
+        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
+ missing_lines /tmp/passwd /etc/passwd >> /etc/passwd
+ missing_lines /tmp/group /etc/group >> /etc/group
+ missing_lines /tmp/shadow /etc/shadow >> /etc/shadow
+        rm /tmp/shadow 2>/dev/null
+        rm /tmp/passwd 2>/dev/null
+        rm /tmp/group 2>/dev/null
  # Prevent configuration corruption on a power loss
  sync
  }