commit:     4f9a09147887a6d108a8e55ab47a53d1016efee9
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 28 19:35:33 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Fri Aug 28 19:35:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=4f9a0914

gen_initramfs.sh: append_base_layout(): Create /etc/{group,passwd,shadow} in 
this function

These files should be present all the time, not just when built with --ssh 
option set.

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_initramfs.sh | 75 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 58 insertions(+), 17 deletions(-)

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index fcfa827..ae71c38 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -302,6 +302,7 @@ append_base_layout() {
                usr/bin \
                usr/lib \
                usr/sbin \
+               var/empty \
                var/log \
                var/run/lock \
        ; do
@@ -333,6 +334,63 @@ append_base_layout() {
        echo "proc          /proc       proc    defaults    0 0" >> 
"${TDIR}"/etc/fstab \
                || gen_die "Failed to add proc to '${TDIR}/etc/fstab'!"
 
+       print_info 2 "$(get_indent 2)>> Adding /etc/{group,passwd,shadow} ..."
+       cat >"${TDIR}"/etc/group <<-EOF
+       root:x:0:root
+       bin:x:1:root,bin,daemon
+       daemon:x:2:root,bin,daemon
+       sys:x:3:root,bin,adm
+       adm:x:4:root,adm,daemon
+       tty:x:5:
+       disk:x:6:root,adm
+       lp:x:7:lp
+       mem:x:8:
+       kmem:x:9:
+       wheel:x:10:root
+       floppy:x:11:root
+       news:x:13:news
+       uucp:x:14:uucp
+       console:x:17:
+       audio:x:18:
+       cdrom:x:19:
+       dialout:x:20:
+       tape:x:26:root
+       video:x:27:root
+       render:x:28:
+       rpc:x:32:
+       kvm:x:78:
+       usb:x:85:
+       input:x:97:
+       utmp:x:406:
+       nogroup:x:65533:
+       nobody:x:65534:
+       EOF
+
+       chmod 0644 "${TDIR}"/etc/group \
+               || gen_die "Failed to chmod of '${TDIR}/etc/group'!"
+
+       cat >"${TDIR}"/etc/passwd <<-EOF
+       root:x:0:0:root:/root:/usr/bin/login-remote.sh
+       nobody:x:65534:65534:nobody:/var/empty:/bin/false
+       EOF
+
+       chmod 0644 "${TDIR}"/etc/passwd \
+               || gen_die "Failed to chmod of '${TDIR}/etc/passwd'!"
+
+       echo "root:!:0:0:99999:7:::" > "${TDIR}"/etc/shadow \
+               || gen_die "Failed to create '/etc/shadow'!"
+
+       chmod 0640 "${TDIR}"/etc/shadow \
+               || gen_die "Failed to chmod of '${TDIR}/etc/shadow'!"
+
+       print_info 2 "$(get_indent 2)>> Adding /etc/nsswitch.conf ..."
+       cat >"${TDIR}"/etc/nsswitch.conf <<-EOF
+       # /etc/nsswitch.conf generated by genkernel
+       passwd:    files
+       shadow:    files
+       group:     files
+       EOF
+
        print_info 2 "$(get_indent 2)>> Adding /etc/ld.so.conf ..."
        cat >"${TDIR}"/etc/ld.so.conf <<-EOF
        # ld.so.conf generated by genkernel
@@ -1548,18 +1606,10 @@ append_dropbear() {
        cp -aL /etc/localtime "${TDIR}"/etc/ \
                || gen_die "Failed to copy '/etc/localtime'. Please set 
system's timezone!"
 
-       echo "root:x:0:0:root:/root:/usr/bin/login-remote.sh" > 
"${TDIR}"/etc/passwd \
-               || gen_die "Failed to create '/etc/passwd'!"
 
        echo "/usr/bin/login-remote.sh" > "${TDIR}"/etc/shells \
                || gen_die "Failed to create '/etc/shells'!"
 
-       echo "root:!:0:0:99999:7:::" > "${TDIR}"/etc/shadow \
-               || gen_die "Failed to create '/etc/shadow'!"
-
-       echo "root:x:0:root" > "${TDIR}"/etc/group \
-               || gen_die "Failed to create '/etc/group'!"
-
        chmod 0755 "${TDIR}"/usr/bin/login-remote.sh \
                || gen_die "Failed to chmod of 
'${TDIR}/usr/bin/login-remote.sh'!"
 
@@ -1572,15 +1622,6 @@ append_dropbear() {
        chmod 0755 "${TDIR}"/usr/sbin/unlock-zfs \
                || gen_die "Failed to chmod of '${TDIR}/usr/sbin/unlock-zfs'!"
 
-       chmod 0640 "${TDIR}"/etc/shadow \
-               || gen_die "Failed to chmod of '${TDIR}/etc/shadow'!"
-
-       chmod 0644 "${TDIR}"/etc/passwd \
-               || gen_die "Failed to chmod of '${TDIR}/etc/passwd'!"
-
-       chmod 0644 "${TDIR}"/etc/group \
-               || gen_die "Failed to chmod of '${TDIR}/etc/group'!"
-
        cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
        log_future_cpio_content
        find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F 
"${CPIO_ARCHIVE}" \

Reply via email to