From 5593186c998c3f63c7abadd3eaa97e55004fc182 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 22 Feb 2026 13:50:59 +0100 Subject: m fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 2 - COPYING | 2 +- DEPENDENCIES | 35 +++++++---------- Makefile | 46 ++++++++++++++-------- README | 3 +- got | 76 ++++++++++++++---------------------- gotrc-examples/README | 10 +---- gotrc-examples/allow-uppercase | 32 +++++++-------- gotrc-examples/baudrate | 14 +++---- gotrc-examples/cerberus | 8 ++-- gotrc-examples/commands | 82 +++++++++++++++++++-------------------- gotrc-examples/hide-username | 29 +++++++------- gotrc-examples/issue-file | 15 +++---- gotrc-examples/loadkeys | 34 ++++++++-------- gotrc-examples/lower-left-ponysay | 27 ++++++------- gotrc-examples/no-empty-user | 14 +++---- gotrc-examples/readline | 8 ++-- gotrc-examples/revoke-access | 12 +++--- info/gates-of-tartaros.texinfo | 31 +++++++-------- 19 files changed, 217 insertions(+), 263 deletions(-) diff --git a/.gitignore b/.gitignore index 4028b6e..de04d95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -_/ obj/ \#*\# __pycache__/ @@ -24,4 +23,3 @@ __pycache__/ *.toc *.tp *.vr - diff --git a/COPYING b/COPYING index 51b1b98..440f6d4 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ gates-of-tartaros – Minimal replacement for agetty with SSH support -Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DEPENDENCIES b/DEPENDENCIES index 85b55df..7974750 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,26 +1,19 @@ RUNTIME DEPENDENCIES: - -util-linux login login is used for authorisation and login -util-linux setsid used to start login in a new session -bash bash (out-out) gates-of-tartaros is written in Bash -dash dash (opt-in) gates-of-tartaros is compatible with Dash -openssh ssh (optional) used for SSH login -coreutils env (opt-out) used to get the path to Bash in the shebangs -coreutils stty used to lock the TTY if somepony ties something evil -coreutils sleep used to wait for ten minues if somepony ties something evil -coreutils uname used to get the name of the operating system as a distribution name fallback - - + login + setsid + bash (default) or dash + ssh + env + stty + sleep + uname BUILD DEPENDENCIES: - -make make required -sed sed required -coreutils cp required -coreutils rm required -coreutils install required -texinfo makeinfo opt-out: for info manual -gzip gzip opt-out: for info manual compression - + make + sh + sed + cp + mkdir + makeinfo (opt-out: for info manual) diff --git a/Makefile b/Makefile index aa21c1e..1930b77 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,20 @@ SSH = ssh SH = bash SH_SHEBANG = /usr/bin/env $(SH) -ECHO = /usr/bin/echo -EXAMPLES = README lower-left-ponysay allow-uppercase issue-file \ - commands no-empty-user baudrate cerberus hide-username \ - readline revoke-access loadkeys +EXAMPLES =\ + allow-uppercase\ + baudrate\ + cerberus\ + commands\ + hide-username\ + issue-file\ + loadkeys\ + lower-left-ponysay\ + no-empty-user\ + readline\ + revoke-access\ + README @@ -84,7 +93,6 @@ got.install: got sed -i 's:@etc@:$(SYSCONF):g' "$@" sed -i 's:@command@:$(COMMAND):g' "$@" sed -i 's:@ssh@:$(SSH):g' "$@" - sed -i 's:@echo@:$(ECHO):g' "$@" @@ -99,33 +107,38 @@ install-cmd: install-core install-examples .PHONY: install-core install-core: got.install - install -Dm755 -- "got.install" "$(DESTDIR)$(PREFIX)$(SBIN)/got" - install -d -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)" - install -m644 -- COPYING LICENSE "$(DESTDIR)$(LICENSES)/$(PKGNAME)" + mkdir -p -- "$(DESTDIR)$(PREFIX)$(SBIN)/" + cp -- got.install "$(DESTDIR)$(PREFIX)$(SBIN)/got" + mkdir -p -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/" + cp -- COPYING LICENSE "$(DESTDIR)$(LICENSES)/$(PKGNAME)/" .PHONY: install-examples install-examples: $(foreach EXAMPLE, $(EXAMPLES), gotrc-examples/$(EXAMPLE)) - install -d -- "$(DESTDIR)$(SYSCONF)/gotrc.examples" - install -m644 -- $^ "$(DESTDIR)$(SYSCONF)/gotrc.examples" + mkdir -p -- "$(DESTDIR)$(SYSCONF)/gotrc.examples" + cp -- $(foreach EXAMPLE, $(EXAMPLES), gotrc-examples/$(EXAMPLE)) "$(DESTDIR)$(SYSCONF)/gotrc.examples" .PHONY: install-doc install-doc: install-info install-pdf install-ps install-dvi .PHONY: install-info install-info: gates-of-tartaros.info - install -Dm644 -- "$<" "$(DESTDIR)$(DATA)/info/$(PKGNAME).info" + mkdir -p -- "$(DESTDIR)$(DATA)/info/" + cp -- gates-of-tartaros.info "$(DESTDIR)$(DATA)/info/$(PKGNAME).info" .PHONY: install-pdf install-pdf: gates-of-tartaros.pdf - install -Dm644 -- "$<" "$(DESTDIR)$(DATA)/doc/$(PKGNAME).pdf" + mkdir -p -- "$(DESTDIR)$(DATA)/doc/" + cp -- gates-of-tartaros.pdf "$(DESTDIR)$(DATA)/doc/$(PKGNAME).pdf" .PHONY: install-ps install-ps: gates-of-tartaros.ps - install -Dm644 -- "$<" "$(DESTDIR)$(DATA)/doc/$(PKGNAME).ps" + mkdir -p -- "$(DESTDIR)$(DATA)/doc/" + cp -- gates-of-tartaros.ps "$(DESTDIR)$(DATA)/doc/$(PKGNAME).ps" .PHONY: install-dvi install-dvi: gates-of-tartaros.dvi - install -Dm644 -- "$<" "$(DESTDIR)$(DATA)/doc/$(PKGNAME).dvi" + mkdir -p -- "$(DESTDIR)$(DATA)/doc/" + cp -- gates-of-tartaros.dvi "$(DESTDIR)$(DATA)/doc/$(PKGNAME).dvi" @@ -135,7 +148,7 @@ uninstall: -rm -r -- "$(DESTDIR)$(SYSCONF)/gotrc.examples" -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/COPYING" -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/LICENSE" - -rm -d -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)" + -rmdir -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)" -rm -- "$(DESTDIR)$(DATA)/info/$(PKGNAME).info" -rm -- "$(DESTDIR)$(DATA)/doc/$(PKGNAME).pdf" -rm -- "$(DESTDIR)$(DATA)/doc/$(PKGNAME).ps" @@ -145,5 +158,4 @@ uninstall: .PHONY: clean clean: - -rm -fr *.install *.{info,pdf,ps,dvi} obj - + -rm -fr -- *.install *.info *.pdf *.ps *.dvi obj diff --git a/README b/README index 5a7a10a..58cc5a6 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ gates-of-tartaros uses more memory than agetty. You can configure your install to use dash instead of bash by running make with the -argument SH=dash. Doing so will more halve +argument SH=dash. Doing so will more than halve the memory usage, reducing the memory usage to slightly below that of agetty. @@ -22,4 +22,3 @@ Usage: Example: got tty1 TERM=linux - diff --git a/got b/got index 62940dd..81a6350 100755 --- a/got +++ b/got @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +21,8 @@ # Read the parameters: the first is the tty, the rest are exports tty="$1" shift 1 -if [ ! $# = 0 ]; then - export "$@" +if test ! $# = 0; then + export "$@" fi # Change TTY @@ -35,77 +35,62 @@ exec 2>&0 tty_settings="$(stty --save)" -# This is required if you want to use dash (and ash, since dash -# [dash not ash] does not recognise $''). -echo () -{ - @echo@ "$@" -} - - # Function used for printing information on the terminal for the user display_function=_display -_display () -{ - echo -en '\e[H\e[2J\e[?0c' - echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" - echo - echo -n 'Login: ' +_display () { + printf '\033[H\033[2J\033[?0c' + printf "\033[%sm%s (%s)\033[0m\n" "${ANSI_COLOR}" "${NAME}" "${tty}" + printf '\nLogin: ' } # Function for reading the username form the terminal read_function=_read -_read () -{ - read user +_read () { + read user } # Function for logging in the user login_function=_login -_login () -{ - if [ ! "${user%@*}" = "${user}" ]; then - $_use_ssh_function - elif [ ! "${user}" = "" ] && [ "${user%%-*}" = "" ]; then - $_lock_tty_function - else - $_use_login_function - fi +_login () { + if test ! "${user%@*}" = "${user}"; then + $_use_ssh_function + elif test -n "${user}" && test -z "${user%%-*}"; then + $_lock_tty_function + else + $_use_login_function + fi } # Function for locking the TTY _lock_tty_function=_lock_tty -_lock_tty () -{ - stty -icanon -echo -isig -ixon -ixoff -ixany - echo -e '\e[01;31mNice try! Sleeping for 10 minutes...\e[00m' - sleep 600 +_lock_tty () { + stty -icanon -echo -isig -ixon -ixoff -ixany + printf '\033[01;31mNice try! Sleeping for 10 minutes...\033[0m\n' + sleep 600 } # Function for performing the log in with `ssh` _use_ssh_function=_use_ssh -_use_ssh () -{ - setsid -c ssh ${user} || sleep 3 - # The sleep allows you to see any error you made +_use_ssh () { + setsid -c ssh ${user} || sleep 3 + # The sleep allows you to see any error you made } # Function for performing the log in with `login` _use_login_function=_use_login -_use_login () -{ - setsid -c login -- "${user}" +_use_login () { + setsid -c login -- "${user}" } # Load OS information and extensions NAME="$(uname -o)" ANSI_COLOR='01;34' # must be exactly ANSI_COLOR as it is defined in /etc/os-release -if [ -f "@etc@/os-release" ]; then - . "@etc@/os-release" +if test -f "@etc@/os-release"; then + . "@etc@/os-release" fi -if [ -f "@etc@/@command@rc" ]; then - . "@etc@/@command@rc" +if test -f "@etc@/@command@rc"; then + . "@etc@/@command@rc" fi # Let the user log in @@ -115,4 +100,3 @@ $login_function # Restore the TTY settings for the next run stty "${tty_settings}" - diff --git a/gotrc-examples/README b/gotrc-examples/README index cdd2d29..1ed40e4 100644 --- a/gotrc-examples/README +++ b/gotrc-examples/README @@ -1,15 +1,9 @@ -These are templates you can used for your gotrc file. +These are templates you can use for your gotrc file. If you are happy with them as is, you can include -them directly in your by gotrc file with for example: +them directly in your gotrc file, for example: . /etc/gotrc-examples/no-empty-user Although, it may be better to copy the ones you are using into a directory named /etc/got.d and include them from there. - -If you create any cool or useful extensions yourself -and do not object to licenses them under the GNU -General Public License version 3, please submit them -to . - diff --git a/gotrc-examples/allow-uppercase b/gotrc-examples/allow-uppercase index 3bb0db1..556f137 100644 --- a/gotrc-examples/allow-uppercase +++ b/gotrc-examples/allow-uppercase @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,21 +24,19 @@ read_function_allow_uppercase=$read_function read_function=_read_allow_uppercase -_read_allow_uppercase () -{ - $read_function_allow_uppercase - lower="" - for word in $user; do - if [ ! "${word%%-*}" = "" ]; then # This check is done so SSH arguments are not made into lower case - word="$(echo "${word}" | sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/')" +_read_allow_uppercase () { + $read_function_allow_uppercase + lower="" + for word in $user; do + if test -n "${word%%-*}"; then # This check is done so SSH arguments are not made into lower case + word="$(echo "${word}" | sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/')" + fi + lower="${lower} ${word}" + done + lower="${lower# *}" + if test ! "${lower}" = "${user}"; then + #stty olcuc ## Uncomment this if you want to go old-school Unix, too bad + ## it will break colours and only uppercases ASCII letters. + user="${lower}" fi - lower="${lower} ${word}" - done - lower="${lower# *}" - if [ ! "${lower}" = "${user}" ]; then - #stty olcuc ## Uncomment this if you want to go old-school Unix, too bad - ## it will break colours and only uppercases ASCII letters. - user="${lower}" - fi } - diff --git a/gotrc-examples/baudrate b/gotrc-examples/baudrate index 684722f..7fc29aa 100644 --- a/gotrc-examples/baudrate +++ b/gotrc-examples/baudrate @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,11 +29,9 @@ display_function_baudrate=$display_function display_function=_display_baudrate -_display_baudrate () -{ - if [ ! "${BAUDRATE}" = "" ]; then - stty ${BAUDRATE} - fi - $display_function_baudrate +_display_baudrate () { + if test -n "${BAUDRATE}"; then + stty ${BAUDRATE} + fi + $display_function_baudrate } - diff --git a/gotrc-examples/cerberus b/gotrc-examples/cerberus index e0761ca..9efa783 100644 --- a/gotrc-examples/cerberus +++ b/gotrc-examples/cerberus @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,8 +22,6 @@ # cerberus instead of login -_use_login () -{ - exec cerberus -- "${user}" +_use_login () { + exec cerberus -- "${user}" } - diff --git a/gotrc-examples/commands b/gotrc-examples/commands index 0d57eca..6605884 100644 --- a/gotrc-examples/commands +++ b/gotrc-examples/commands @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,42 +24,41 @@ login_function_commands=$login_function login_function=_login_commands -_login_commands () -{ - if [ ! "${user}" = "" ] && [ "${user%%+*}" = "" ]; then - if [ "${user}" = "+shutdown" ]; then - shutdown -h now - elif [ "${user}" = "+reboot" ]; then - reboot - elif [ "${user}" = "+time" ]; then - echo - date +%Y-\(%m\)%b-%d\ %T,\ %a\ w%W/%V,\ %Z - read __ - elif [ "${user}" = "+battery" ]; then - echo - acpi -V - read __ - elif [ "${user}" = "+backlight" ]; then - if [ "${LANG%UTF-8*}" = "${LANG}" ]; then - export LANG="en_GB.UTF-8" - fi - adjbacklight - elif [ "${user}" = "+keyboard" ]; then - echo "Enter keyboard layout: (e.g. sv-latin1)" - read -r layout - if [ ! "$(echo ${layout})" = "" ]; then - loadkeys -C "/dev/${tty}" -- ${layout} - if [ ! $? = 0 ]; then - echo 'Press ENTER to continue...' - read - fi - fi - elif [ "${user}" = "+1" ]; then - echo "Enter parameters: (e.g. tty7 TERM=linux)" - read -r params - setsid -- "$0" $params & - else - cat <