Commit Graph

157 Commits

Author SHA1 Message Date
Mario Abajo
7de0ab21d9 login: permit change expired password wit PAM
Signed-off-by: Mario Abajo <marioabajo@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-07 12:28:00 +02:00
Denys Vlasenko
2a2ca93530 login: implement LOGIN_TIMEOUT
function                                             old     new   delta
packed_usage                                       33559   33598     +39
login_main                                           953     986     +33
.rodata                                           103161  103175     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 86/0)               Total: 86 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-19 00:27:44 +01:00
Denys Vlasenko
77a51a2709 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 16:53:11 +01:00
Denys Vlasenko
f4f6e5144b libbb: exec_login_shell() - new function
function                                             old     new   delta
exec_login_shell                                       -      12     +12
sulogin_main                                         247     240      -7
login_main                                           960     953      -7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 12/-14)             Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-02 21:51:08 +01:00
Denys Vlasenko
2075aa93e0 libbb: rename run_shell() to exec_shell()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-02 21:28:47 +01:00
Denys Vlasenko
50ead33c45 login: log to syslog every bad password, not only 3rd
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-02 17:47:16 +01:00
Denys Vlasenko
87bd558f3f libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there
function                                             old     new   delta
pause_after_failed_login                               -       9      +9
vlock_main                                           358     353      -5
sulogin_main                                         252     247      -5
su_main                                              484     479      -5
passwd_main                                          936     931      -5
login_main                                           967     962      -5
bb_do_delay                                           68       -     -68
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/5 up/down: 9/-93)             Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:32:48 +01:00
Joachim Nilsson
a4747230ab login: update UTMP before forking
/bin/login updates the preliminary UTMP record created by /bin/getty for
$LOGNAME.  However, if the PID of login is not the same as getty, then
it will create a new entry.  This causes GLIBC getlogin(3) to return the
string 'LOGIN' (set by getty) instead of $LOGNAME.  This affects tools
like /usr/bin/logname but also various 3rd party PAM applications.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 12:09:53 +01:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
b052dbea54 login: remove extra IF(), no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-02 17:13:20 +02:00
Denys Vlasenko
db5a6daa7f login: close PAM session on errors as well, not only on success
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-22 17:04:16 +01:00
Denys Vlasenko
7bcde5f00d libbb.h: always include sys/resource.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 17:23:27 +02:00
Denys Vlasenko
b182e9ad60 libbb: use _exit, not exit, in bb_daemonize_or_rexec()
By the time we reach exit in parent, child already exited or execed.
We should not re-run libc cleanup code.

While at it, introduce bb_daemon_helper() and add a few comments.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-04 23:04:17 +02:00
Denys Vlasenko
68b653b66b config: trim/improve item names and help texts, take 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 10:53:09 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
4eed2c6c50 Update menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
a3de0b3b86 libbb: make check_password() also return CHECKPASS_PW_HAS_EMPTY_PASSWORD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 13:04:05 +02:00
Kaarle Ritvanen
517a82c5b6 login: move check_securetty to libbb
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 12:39:03 +02:00
Denys Vlasenko
f560422fa0 Big cleanup in config help and description
Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
4ea0ebdd42 Selinux complains about deprecated selinux/flask.h, stop including it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 13:52:13 +01:00
Denys Vlasenko
79e2598c48 su: expand help; simplify passing of -c CMD to run_shell()
Also, added a comment about bug 9401 (TIOCSTI input injection).

function                                             old     new   delta
packed_usage                                       30909   30932     +23
su_main                                              470     487     +17
sulogin_main                                         260     258      -2
run_applet_and_exit                                  681     678      -3
run_shell                                            166     126     -40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-03 22:13:08 +01:00
Denys Vlasenko
47cfbf32fd *: add most of the required setup_common_bufsiz() calls
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:18:48 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Denys Vlasenko
bae8f98633 login: add commented-out PAM double password avoidance from BZ 4003
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-01-03 22:43:40 +01:00
Denys Vlasenko
c47917865d login: explain -h HOST option better
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-21 16:06:40 +02:00
Denys Vlasenko
95dee81a46 loginutils/*: convert to new-style "one file" applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-19 01:20:36 +02:00
Sören Tempel
d862717328 login: don't print motd if .hushlogin exists in users home
function                                             old     new   delta
login_main                                           978     996     +18

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 22:16:48 +02:00
Denys Vlasenko
da9212667c libbb: code shrink by factoring out common update_utmp_DEAD_PROCESS
function                                             old     new   delta
update_utmp_DEAD_PROCESS                               -      17     +17
telnetd_main                                        1685    1674     -11
mark_terminated                                       56      45     -11
handle_sigchld                                        74      63     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 15:37:58 +01:00
Denys Vlasenko
9c1c605b1a sulogin: use common password-checking routine.
This needed some extensions correct_passwd() function,
which got renamed ask_and_check_password() to better describe what it does.

function                                             old     new   delta
ask_and_check_password_extended                        -     215    +215
ask_and_check_password                                 -      12     +12
vlock_main                                           394     397      +3
sulogin_main                                         494     326    -168
correct_password                                     207       -    -207
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/1 up/down: 230/-375)         Total: -145 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-19 13:09:06 +01:00
Denys Vlasenko
dba7094d62 login: increase login name size limit from 32 to 64
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-15 17:06:37 +02:00
Sergey Naumov
7eaa03709b login: -f should not ask for password even with PAM
Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-30 12:52:56 +01:00
Denys Vlasenko
e9dc354df8 getty: fix a minor problem of Ctrl-D not printing '\n'
Also removed defines for control chars which are never changed,
and added login/getty README.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-23 23:58:59 +02:00
Denys Vlasenko
7449e18190 getty,login: tighten up handling of ctty, pgrp, and tty attr restoring on timeout
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-22 06:27:41 +02:00
Ian Wienand
378ab68199 login: new option LOGIN_SESSION_AS_CHILD
Signed-off-by: Ian Wienand <ianw@vmware.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-14 08:41:38 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Pere Orga
6a3e01d5a9 move help text from include/usage.src.h to debianutils/*.c e2fsprogs/*.c editors/*.c loginutils/*.c mailutils/*.c
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-03 01:33:55 +02:00
Ryan Phillips
cf9074b54b login: set PAM RHOST
Signed-off-by: Ryan Phillips <ryan@trolocsis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-22 18:27:21 +01:00
Denys Vlasenko
7d4e7a27af s/FAIL_DELAY/LOGIN_FAIL_DELAY/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-08 21:07:05 +01:00
Denys Vlasenko
bd74e3d8be libbb/login/su: do not sanitize shell name twice
function                                             old     new   delta
setup_environment                                    191     205     +14
login_main                                          1002     987     -15
su_main                                              474     458     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-31)            Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-06 18:49:40 +01:00
Denys Vlasenko
8d0e0cdadf move utmp.h include to libbb.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-25 23:21:46 +01:00
Ian Wienand
260fb551ff login: apply PAM environment
login should apply the PAM environment modified by plugins
such as pam_env.  Other 'login's do a similar thing.

I tested this by setting some env variables with pam_env which were
correctly applied.

Signed-off-by: Ian Wienand <ianw@vmware.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-27 02:13:06 +01:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Alexander Shishkin
78b286fea5 login: free fromhost upon cleaning up
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 05:49:55 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Jeremie Koenig
f812eace18 init,loginutils: termios portability fixes
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-19 00:45:42 +02:00
Ladislav Michl
a73b87e934 *: s/"/bin/sh"/DEFAULT_SHELL, run_shell() API fix, remove unneeded strdup
function                                             old     new   delta
run_shell                                            157     166      +9
su_main                                              477     470      -7
sulogin_main                                         515     503     -12

Signed-off-by: Ladislav Michl <Ladislav.Michl@seznam.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-27 03:23:31 +02:00
Denys Vlasenko
f8d8aa1cea libbb: add skip_dev_pfx()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-06 18:50:05 +02:00
Denys Vlasenko
3a41611bc5 telnetd: write LOGIN/DEAD_PROCESS utmp records. Closes bug 1363
function                                             old     new   delta
write_new_utmp                                         -     253    +253
skip_dev_pfx                                           -      30     +30
handle_sigchld                                        42      72     +30
telnetd_main                                        1650    1673     +23
make_new_session                                     415     438     +23
...
login_main                                          1140    1148      +8
update_utmp                                          337     313     -24
write_wtmp                                           220     154     -66
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 11/6 up/down: 406/-115)         Total: ~291 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-05 22:10:38 +02:00
Denys Vlasenko
37f5bef63c libbb: split update_utmp from login/getty in preparation to use it for telnetd
function                                             old     new   delta
update_utent                                           -     339    +339
login_main                                          1498    1128    -370
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 339/-370)          Total: -31 bytes

function                                             old     new   delta
update_utmp                                          246     337     +91
login_main                                          1128    1140     +12
getty_main                                          1908    1918     +10
...
update_utent                                         339       -    -339
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 5/6 up/down: 119/-368)         Total: -249 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-05 03:18:40 +02:00
Denys Vlasenko
4c721049c3 who: fix attempts to open '/dev/dev/ttyX'; make columns a bit wider, add -H
function                                             old     new   delta
who_main                                             292     363     +71

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-04 23:45:09 +02:00