diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-02-06 10:46:39 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-02-06 10:46:39 +0100 |
commit | ae327cc50fd9d3e59e9f60088243adfc69cb312e (patch) | |
tree | 4efe5520ba87a604cf35e3d5c00d196e214bf1ae | |
parent | b854e8abb7e1ff0b43c9f99e9b641895e4d6c148 (diff) |
fix busybox booting into root shellweek3
-rwxr-xr-x | rootfs/etc/init.d/rcS | 3 | ||||
-rw-r--r-- | rootfs/etc/inittab | 7 | ||||
-rw-r--r-- | rootfs/etc/passwd | 0 | ||||
-rw-r--r-- | rootfs/etc/profile | 1 | ||||
-rw-r--r-- | rootfs/etc/shadow | 0 | ||||
-rwxr-xr-x | state/gen | 5 | ||||
-rwxr-xr-x | util/mkrootfs | 17 |
7 files changed, 19 insertions, 14 deletions
diff --git a/rootfs/etc/init.d/rcS b/rootfs/etc/init.d/rcS index fc699e4..be9ca09 100755 --- a/rootfs/etc/init.d/rcS +++ b/rootfs/etc/init.d/rcS @@ -1,2 +1,5 @@ #!/bin/sh +# mount all drives in /etc/fstab /bin/mount -a +# set the system hostname +/bin/hostname -F /etc/hostname diff --git a/rootfs/etc/inittab b/rootfs/etc/inittab index 5f4a5fa..805a39d 100644 --- a/rootfs/etc/inittab +++ b/rootfs/etc/inittab @@ -1,9 +1,8 @@ # /etc/inittab init(8) - ::sysinit:/etc/init.d/rcS ::shutdown:/bin/umount -a -r ::restart:/sbin/init -# this could be really unsafe in production -::respawn:/sbin/getty -L ttyS0 115200 vt100 -ttyS0::respawn:-/bin/login -f root +# put a shell on ttyS0 (serial header on board) +ttyS0::respawn:/bin/sh + diff --git a/rootfs/etc/passwd b/rootfs/etc/passwd deleted file mode 100644 index e69de29..0000000 --- a/rootfs/etc/passwd +++ /dev/null diff --git a/rootfs/etc/profile b/rootfs/etc/profile index 3c2be89..557b21a 100644 --- a/rootfs/etc/profile +++ b/rootfs/etc/profile @@ -1,4 +1,5 @@ # /etc/profile umask 022 export PATH="$PATH:/usr/bin" +cd "$HOME" diff --git a/rootfs/etc/shadow b/rootfs/etc/shadow deleted file mode 100644 index e69de29..0000000 --- a/rootfs/etc/shadow +++ /dev/null @@ -77,6 +77,11 @@ if [ -n "$SDCARD_DISK" ] ; then if ($6 != "ROOTFS") exit(1) }' && SDCARD_FMT_OK=0 fi + else + # assume sd card is formatted correctly if SDCARD_PART_BOOT and + # SDCARD_PART_ROOTFS are already set + SDCARD_PART_OK=0 + SDCARD_FMT_OK=0 fi fi set_state sdcard_part $SDCARD_PART_OK diff --git a/util/mkrootfs b/util/mkrootfs index 5818fdb..91eff68 100755 --- a/util/mkrootfs +++ b/util/mkrootfs @@ -28,13 +28,10 @@ cp $CPFLAGS "$OVERLAY_FS/." . # setuid busybox chmod a=xrs,u+w bin/busybox -# # create /etc/passwd -# if ! [ -e etc/passwd ] ; then -# # TODO: add root to a group -# echo "root:x:0:0::/root:/bin/sh" > etc/passwd -# fi -# # and /etc/shadow -# if ! [ -e etc/shadow ] ; then -# echo "root:$(mkpasswd alpine):::::::" > etc/shadow -# fi -# +# create a root user +! [ -e etc/passwd ] && echo "root:x:0:0::/root:/bin/sh" > etc/passwd +! [ -e etc/shadow ] && echo "root:!:0:0:99999:0:::" > etc/shadow +! [ -e etc/group ] && echo "root:x:0:root" > etc/shadow + +# exit safely (continue makefile) +exit 0 |