From 58201ca309d6d434521d253cd1374fcdaadd754b Mon Sep 17 00:00:00 2001 From: crims0n Date: Tue, 23 Nov 2021 11:42:41 +0300 Subject: [PATCH] fix --- .../01-core/rootcopy-install/etc/issue | 36 ++-- .../usr/lib/systemd/system/getty@.service | 1 - linux-live/initramfs/init | 2 +- linux-live/initramfs/initramfs_create | 1 + linux-live/initramfs/static/cmdline_parser | 161 ++++++++++++++++++ linux-live/livekitlib | 142 +-------------- 6 files changed, 186 insertions(+), 157 deletions(-) create mode 100755 linux-live/initramfs/static/cmdline_parser diff --git a/linux-live/basesystem/01-core/rootcopy-install/etc/issue b/linux-live/basesystem/01-core/rootcopy-install/etc/issue index 1a3e901..b67e63b 100644 --- a/linux-live/basesystem/01-core/rootcopy-install/etc/issue +++ b/linux-live/basesystem/01-core/rootcopy-install/etc/issue @@ -6,26 +6,22 @@ - Thank you for using MiniOS. - Based on Debian GNU/Linux. - Powered by Slax. - - :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  - +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  - +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  - +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  - +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  - #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  - ### ### ########### ### #### ########### ######## ########  - - : : - : Root login name: root : - : Password: toor : - : User login name: live : - : Password: evil : - - - + Thank you for using MiniOS. + Based on Debian GNU/Linux. + Powered by Slax. + + :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  + +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  + +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  + +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  + +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  + #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  + ### ### ########### ### #### ########### ######## ########  + + Root login name: root + Password: toor + User login name: live + Password: evil diff --git a/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/getty@.service b/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/getty@.service index 49e2871..3a805ae 100644 --- a/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/getty@.service +++ b/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/getty@.service @@ -11,7 +11,6 @@ Documentation=man:agetty(8) man:systemd-getty-generator(8) Documentation=http://0pointer.de/blog/projects/serial-console.html After=systemd-user-sessions.service plymouth-quit-wait.service After=rc-local.service -After=cmdline-parser.service # If additional gettys are spawned during boot then we should make # sure that this is synchronized before getty.target, even though diff --git a/linux-live/initramfs/init b/linux-live/initramfs/init index 0ca1a0f..5e763d8 100644 --- a/linux-live/initramfs/init +++ b/linux-live/initramfs/init @@ -56,7 +56,7 @@ copy_rootcopy_content "$DATA" "$UNION" # configure minios_configure "$UNION" - debug_shell + debug_shell # create fstab fstab_create "$UNION" "$DATAMNT" debug_shell diff --git a/linux-live/initramfs/initramfs_create b/linux-live/initramfs/initramfs_create index 5c1a007..9a4691c 100755 --- a/linux-live/initramfs/initramfs_create +++ b/linux-live/initramfs/initramfs_create @@ -53,6 +53,7 @@ cp static/mount.dynfilefs $INITRAMFS/bin/@mount.dynfilefs cp static/mount.httpfs2 $INITRAMFS/bin/@mount.httpfs2 cp static/mount.ntfs-3g $INITRAMFS/bin/@mount.ntfs-3g cp static/blkid $INITRAMFS/bin +cp static/cmdline_parser $INITRAMFS/bin chmod a+x $INITRAMFS/bin/* $INITRAMFS/bin/busybox | grep , | grep -v Copyright | tr "," " " | while read LINE; do diff --git a/linux-live/initramfs/static/cmdline_parser b/linux-live/initramfs/static/cmdline_parser new file mode 100755 index 0000000..32730df --- /dev/null +++ b/linux-live/initramfs/static/cmdline_parser @@ -0,0 +1,161 @@ +#!/bin/bash +# +# Сommand line parsing script. +# Author: crims0n. +# + +for i in $(cat /cmdline); do + case $i in + user_name=*) + USER_NAME="${i#*=}" + shift # past argument=value + ;; + user_password=*) + USER_PASSWORD="${i#*=}" + shift # past argument=value + ;; + root_password=*) + ROOT_PASSWORD="${i#*=}" + shift # past argument=value + ;; + ssh) + SSH=true + shift # past argument with no value + ;; + cloud) + CLOUD=true + shift # past argument with no value + ;; + *) + # unknown option + ;; + esac +done + +echo "USER_NAME=$USER_NAME" +echo "USER_PASSWORD=$USER_PASSWORD" +echo "ROOT_PASSWORD=$ROOT_PASSWORD" +echo "SSH=$SSH" +echo "CLOUD=$CLOUD" +sleep 5 + +if [ -z "$ROOT_PASSWORD" ]; then + ROOT_PASSWORD="toor" +fi +#echo "Set up password for user 'root'" +echo root:$ROOT_PASSWORD | chpasswd + +if [ "$CLOUD" != "true" ]; then + + if [ -z "$USER_NAME" ]; then + USER_NAME="live" + fi + #echo "Set up user '$USER_NAME'" + adduser --uid 1000 --gecos '' $USER_NAME --disabled-password + + if [ -z "$USER_PASSWORD" ]; then + USER_PASSWORD="evil" + fi + #echo "Set up password for user '$USER_NAME'" + echo $USER_NAME:$USER_PASSWORD | chpasswd + usermod -a -G sudo $USER_NAME + + sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' /etc/ssh/sshd_config + sed -i 's,#PasswordAuthentication yes,PasswordAuthentication yes,g' /etc/ssh/sshd_config +else + rm -rf /home/live +fi + +if [ "$SSH" = "true" ]; then + systemctl enable ssh-keygen + systemctl enable ssh +else + systemctl disable ssh-keygen + systemctl disable ssh +fi + +cat </etc/sudoers.d/90-minios +# live user is default user in minios. +# It needs passwordless sudo functionality. +$USER_NAME ALL=(ALL) NOPASSWD:ALL +EOF + +if [ "$CLOUD" != "true" ]; then + cat </etc/issue + + + \l + + + + + + Thank you for using MiniOS. + Based on Debian GNU/Linux. + Powered by Slax. + + :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  + +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  + +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  + +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  + +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  + #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  + ### ### ########### ### #### ########### ######## ########  + + Root login name: root + Password: $ROOT_PASSWORD + User login name: $USER_NAME + Password: $USER_PASSWORD + + + + + +EOF +else + cat </etc/issue + + + \l + + + + + + Thank you for using MiniOS. + Based on Debian GNU/Linux. + Powered by Slax. + + :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  + +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  + +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  + +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  + +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  + #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  + ### ### ########### ### #### ########### ######## ########  + + User login name set by + cloud-init. You must use + your ssh key to login. + Root login name: root + Password: $ROOT_PASSWORD + + + + + + +EOF +fi + +if [ -f /usr/lib/systemd/system/xorg.service ]; then + cat </usr/lib/systemd/system/xorg.service +[Unit] +Description=X-Window +ConditionKernelCommandLine=!text +After=systemd-user-sessions.service + +[Service] +ExecStart=/bin/su --login -c "/usr/bin/startx -- :0 vt7 -ac -nolisten tcp" $USERNAME +EOF +fi \ No newline at end of file diff --git a/linux-live/livekitlib b/linux-live/livekitlib index cc401cc..2481456 100644 --- a/linux-live/livekitlib +++ b/linux-live/livekitlib @@ -779,143 +779,15 @@ fstab_create() { minios_configure() { debug_log "minios_configure" "$*" - USER_NAME=$(cmdline_value user_name) - USER_PASSWORD=$(cmdline_value user_password) - ROOT_PASSWORD=$(cmdline_value root_password) + cp /bin/cmdline_parser $1/ + cat /proc/cmdline >$1/cmdline + ls -la $1/ + sleep 5 - if grep -vq ssh /proc/cmdline; then - SSH="true" - fi - - if grep -vq cloud /proc/cmdline; then - CLOUD="true" - fi - - if [ -z "$ROOT_PASSWORD" ]; then - ROOT_PASSWORD="toor" - fi - echo "Set up password for user 'root'" - echo root:$ROOT_PASSWORD | chpasswd - - if [ "$CLOUD" != "true" ]; then - - if [ -z "$USER_NAME" ]; then - USER_NAME="live" - fi - echo "Set up user '$USER_NAME'" - chroot $1 /bin/bash -c "adduser --uid 1000 --gecos '' $USER_NAME --disabled-password" - - if [ -z "$USER_PASSWORD" ]; then - USER_PASSWORD="evil" - fi - echo "Set up password for user '$USER_NAME'" - chroot $1 /bin/bash -c "echo $USER_NAME:$USER_PASSWORD | chpasswd" - chroot $1 /bin/bash -c "usermod -a -G sudo $USER_NAME" - - chroot $1 /bin/bash -c "sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' /etc/ssh/sshd_config" - chroot $1 /bin/bash -c "sed -i 's,#PasswordAuthentication yes,PasswordAuthentication yes,g' /etc/ssh/sshd_config" - else - chroot $1 /bin/bash -c "rm -rf /home/live" - fi - - if [ "$SSH" = "true" ]; then - sleep 3 - chroot $1 /bin/bash -c "systemctl enable ssh-keygen" - echo "ssh-keygen is enabled" - sleep 3 - chroot $1 /bin/bash -c "systemctl enable ssh" - echo "ssh is enabled" - sleep 3 - else - chroot $1 /bin/bash -c "systemctl disable ssh-keygen" - chroot $1 /bin/bash -c "systemctl disable ssh" - fi - cat <$1/etc/sudoers.d/90-minios -# live user is default user in minios. -# It needs passwordless sudo functionality. -$USER_NAME ALL=(ALL) NOPASSWD:ALL -EOF - - if [ "$CLOUD" != "true" ]; then - cat <$1/etc/issue - - - \l - - - - - - Thank you for using MiniOS. - Based on Debian GNU/Linux. - Powered by Slax. - - :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  - +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  - +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  - +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  - +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  - #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  - ### ### ########### ### #### ########### ######## ########  - - Root login name: root - Password: $ROOT_PASSWORD - User login name: $USER_NAME - Password: $USER_PASSWORD - - - - - -EOF - else - cat <$1/etc/issue - - - \l - - - - - - Thank you for using MiniOS. - Based on Debian GNU/Linux. - Powered by Slax. - - :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  - +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  - +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  - +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  - +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  - #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  - ### ### ########### ### #### ########### ######## ########  - - User login name set by - cloud-init. You must use - your ssh key to login. - Root login name: root - Password: $ROOT_PASSWORD - - - - - - -EOF - fi - - if [ -f $1/usr/lib/systemd/system/xorg.service ]; then - cat <$1/usr/lib/systemd/system/xorg.service -[Unit] -Description=X-Window -ConditionKernelCommandLine=!text -After=systemd-user-sessions.service - -[Service] -ExecStart=/bin/su --login -c "/usr/bin/startx -- :0 vt7 -ac -nolisten tcp" $USERNAME -EOF - fi + chroot $1 /bin/bash -c "/cmdline_parser" + rm -f $1/cmdline + rm -f $1/cmdline_parser } # Change root and execute init