busybox/loginutils
Denys Vlasenko ec16c030bd libbb: introduce and use sleep1()
function                                             old     new   delta
sleep1                                                 -       9      +9
run_shutdown_and_kill_processes                       97      95      -2
restore_state_and_exit                               116     114      -2
reread_partition_table                                67      65      -2
flush_buffer_cache                                    80      78      -2
chat_main                                           1302    1300      -2
timeout_main                                         310     307      -3
telnet_main                                         1235    1232      -3
stop_handler                                          86      83      -3
process_action                                      1078    1075      -3
nbdclient_main                                      1185    1182      -3
init_main                                            789     786      -3
getty_main                                          1541    1538      -3
do_time                                              410     407      -3
runsv_main                                          1682    1677      -5
pause_and_low_level_reboot                            59      54      -5
inetd_main                                          1917    1911      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50)            Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:37:34 +01:00
..
add-remove-shell.c config: update size information 2018-12-28 03:20:17 +01:00
addgroup.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
adduser.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
chpasswd.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
cryptpw.c libbb: switch bb_ask_noecho() to "mallocing" string return API 2018-04-07 15:50:30 +02:00
deluser.c deluser: check if specified home is a directory before removing it 2020-06-09 18:04:31 +02:00
getty.c libbb: introduce and use sleep1() 2020-11-29 11:37:34 +01:00
Kbuild.src loginutils/*: convert to new-style "one file" applets 2015-10-19 01:20:36 +02:00
login.c libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there 2020-11-29 11:32:48 +01:00
passwd.c libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there 2020-11-29 11:32:48 +01:00
README comment and readme updates 2016-11-04 14:13:58 +01:00
su.c libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there 2020-11-29 11:32:48 +01:00
sulogin.c libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there 2020-11-29 11:32:48 +01:00
vlock.c libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there 2020-11-29 11:32:48 +01:00

	Getty

??? Should getty open tty with or without O_NONBLOCK?
For serial lines, it means "should getty wait for Carrier Detect pin?"
I checked other getties:

- agetty always uses O_NONBLOCK
- mgetty uses O_NONBLOCK unless run with -b, or as "getty"

??? If we decided to use O_NONBLOCK (perhaps optionally with -b),
when getty should send -I INITSTR data to tty? After open succeeds?
What if we also want to initialize *modem* with some AT commands?

??? Should we check/create /var/lock/LCK..ttyPFX lockfiles?

??? mgetty opens tty but does NOT lock it, then waits for input via
select/poll, and when input is available, it checks lock file.
If it exists, mgetty exits (it assumes someone else uses the line).
If no, it creates the file (lock the tty). Sounds like a good algorithm
to use if we are called with -w...

Getty should establish a new session and process group, and ensure
that tty is a ctty.

??? Should getty ensure that other processes which might have opened
fds to this tty be disconnected? agetty has a -R option which makes
agetty call vhangup() after tty is opened. (Then agetty opens it again,
since it probably vhangup'ed its own fd too).

Getty should leave the tty in approximately the same state as "stty sane"
before it execs login program. Minor things we do conditionally are:
	c_iflag |= ICRNL; // if '\r' was used to end username

??? mgetty uses per-tty file to ignore connects, /etc/nologin.ttyxx -
is it useful?

It should be possible to run "getty 0 -" from a shell prompt.
[This currently doesn't work from interactive shell since setsid()
fails in process group leader. The workaround is to run it as a child
of something. sh -c 'getty - 0; true' usually works. Should we fix this?]
It should leave tty in a sane state when it exits (Ctrl-D, -t SEC timeout):
echo should be on, speed, control chars properly set, etc.
(However, it can't restore ctty. The symptom is that "</dev/tty"
fails in the parent shell after getty exits: /dev/tty can't be opened).

Getty should write LOGIN_PROCESS utmp record before it starts waiting
for username to be entered.

	Login

Login should not try to set up tty parameters - apart from switching echo
off while entering password, and switching it back on after.

Login should not leave "echo off" state when it times out reading password
or otherwise terminates (Ctrl-C, Ctrl-D etc).

??? Should login establish a new session and/or process group, and ensure
that tty is a ctty? Without this, running login directly (not via getty)
from e.g. initscript will usually result with a login session without
ctty and without session/pgrp properly created...

It should be possible to run "login [USER]" from a shell prompt,
and it should work (not block/die/error out).
Similarly to getty, it should leave tty in the sane state when it exits.

??? Should login write LOGIN_PROCESS utmp record before it starts waiting
for username/password to be entered?

Login should write USER_PROCESS utmp record just before it is about
to exec user's shell.