aboutsummaryrefslogtreecommitdiff
path: root/loginutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sush: new appletsu_cmd2Ron Yorston2023-04-231-1/+29
| | | | | | | Introduce the new applet sush. It's like su but it permits additional arguments on the command line which are passed to the elevated shell. Adds 144-168 bytes. (O bytes if it's not enabled.)
* su: properly quote commandRon Yorston2023-04-231-8/+15
| | | | | | | | | | Previously the command passed to the elevated shell was placed in literal double quotes on the command line. Instead it should be subject to full quoting by the quote_arg() function. Tweak command line processing. Costs 24-32 bytes.
* Merge busybox into mergeRon Yorston2022-02-093-8/+12
|\ | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIRDenys Vlasenko2022-01-133-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | Double negatives are hard to grok. function old new delta login_main 986 988 +2 su_main 474 470 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4) Total: -2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2022-01-132-9/+43
|\| | | | | | | | | | | | | Fix merge conflicts in coreutils/ls.c and shell/ash.c. Update config files to turn off SHA1_HWACCEL. It uses non-portable assembler.
| * sulogin: util-linux does not say "normal startup" on Ctrl-DDenys Vlasenko2022-01-131-1/+2
| | | | | | | | | | | | | | | | | | | | function old new delta sulogin_main 341 331 -10 .rodata 104327 104312 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-25) Total: -25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sulogin: start _login_ shell only with -pDenys Vlasenko2022-01-131-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Also, shorten/eliminate messages to be closer to util-linux. function old new delta packed_usage 34233 34238 +5 sulogin_main 340 341 +1 .rodata 104380 104327 -53 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 6/-53) Total: -47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: ^C with SIG_INGed SIGINT should not exit the shellDenys Vlasenko2022-01-132-1/+8
| | | | | | | | | | | | | | function old new delta __pgetc 501 522 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sulogin: increase util-linux compatibilityDenys Vlasenko2022-01-121-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Change to root's HOME. Set some envvars. Steal ctty if necessary and possible. function old new delta sulogin_main 240 340 +100 setup_environment 225 233 +8 su_main 479 474 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 108/-5) Total: 103 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2022-01-063-5/+5
|\| | | | | | | | | | | Fix merge conflict in miscutils/less.c. Use exit_SUCCESS() where possible.
| * libbb: code shrink: introduce and use [_]exit_SUCCESS()Denys Vlasenko2022-01-052-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_SUCCESS - 7 +7 _exit_SUCCESS - 7 +7 run_pipe 1562 1567 +5 pseudo_exec_argv 399 400 +1 finish 86 87 +1 start_stop_daemon_main 1109 1107 -2 shutdown_on_signal 38 36 -2 runsv_main 1662 1660 -2 redirect 1070 1068 -2 read_line 79 77 -2 pause_and_low_level_reboot 54 52 -2 list_i2c_busses_and_exit 483 481 -2 less_exit 12 10 -2 identify 4123 4121 -2 grep_file 1161 1159 -2 getty_main 1519 1517 -2 fsck_minix_main 2681 2679 -2 free_session 132 130 -2 fdisk_main 4739 4737 -2 clean_up_and_exit 53 51 -2 bsd_select 1566 1564 -2 bb_daemonize_or_rexec 198 196 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS)Denys Vlasenko2022-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta fflush_stdout_and_exit_SUCCESS - 7 +7 xxd_main 890 888 -2 vlock_main 353 351 -2 uuencode_main 318 316 -2 uniq_main 427 425 -2 uname_main 250 248 -2 sort_main 853 851 -2 shuf_main 500 498 -2 route_main 238 236 -2 readlink_main 113 111 -2 nice_main 156 154 -2 last_main 957 955 -2 ipcs_main 960 958 -2 env_main 209 207 -2 chrt_main 464 462 -2 cal_main 921 919 -2 baseNUM_main 650 648 -2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 7/-32) Total: -25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-06-281-1/+1
|\|
| * *: more --help tweaksDenys Vlasenko2021-06-151-1/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33552 33541 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-05-141-3/+13
|\|
| * login: permit change expired password wit PAMMario Abajo2021-05-071-0/+3
| | | | | | | | | | Signed-off-by: Mario Abajo <marioabajo@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * login: implement LOGIN_TIMEOUTDenys Vlasenko2021-03-191-3/+10
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2021-02-051-3/+3
|\|
| * cryptpw: typo in usage messageRon Yorston2021-02-021-3/+3
| | | | | | | | | | | | | | '[-p N]' should be '[-P N]' in the trivial usage message. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-01-148-38/+22
|\|
| * randomconfig fixesDenys Vlasenko2020-12-291-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tweak help textsDenys Vlasenko2020-12-161-9/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33650 33605 -45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * help text: replace [OPTIONS] with actual options (if not too long)Denys Vlasenko2020-12-131-9/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33620 33665 +45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * help text tweaksDenys Vlasenko2020-12-131-1/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33547 33545 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: exec_login_shell() - new functionDenys Vlasenko2020-12-022-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
| * libbb: rename run_shell() to exec_shell()Denys Vlasenko2020-12-023-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * login: log to syslog every bad password, not only 3rdDenys Vlasenko2020-12-021-4/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * use write_str() functions where appropriateDenys Vlasenko2020-11-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | function old new delta chat_main 1300 1295 -5 finalize_tty_attrs 80 70 -10 getty_main 1538 1519 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-34) Total: -34 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: introduce and use sleep1()Denys Vlasenko2020-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping thereDenys Vlasenko2020-11-295-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * login: update UTMP before forkingJoachim Nilsson2020-11-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | /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>
* | Merge branch 'busybox' into mergeRon Yorston2020-07-091-2/+8
|\|
| * deluser: check if specified home is a directory before removing itSören Tempel2020-06-091-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Alpine, some users use /dev/null as a home directory. When removing such a user with `deluser --remove-home` this causes the /dev/null device file to be removed which is undesirable. To prevent this pitfall, check if the home directory specified for the user is an actual directory (or a symlink to a directory). Implementations of similar tools for other operating systems also implement such checks. For instance, the OpenBSD rmuser(1) implementation [0]. [0]: https://github.com/openbsd/src/blob/b69faa6c70c5bfcfdddc6138cd8e0ee18cc15b03/usr.sbin/adduser/rmuser.perl#L143-L151 function old new delta deluser_main 337 380 +43 Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: use lazy loading for certain DLLsRon Yorston2020-06-021-1/+6
| | | | | | | | | | | | | | | | | | Only a handful of functions are used from shell32.dll, userenv.dll and psapi.dll. Mostly these functions are in out of the way places. By loading the functions only when required we can avoid the startup cost of linking the three DLLs in the common case that they aren't needed.
* | Merge branch 'busybox' into mergeRon Yorston2019-08-168-22/+22
|\|
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-028-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'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>
* | Merge branch 'busybox' into mergeRon Yorston2019-05-274-6/+6
|\|
| * login: remove extra IF(), no code changesDenys Vlasenko2019-05-021-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Optionally re-introduce bb_info_msg()James Byrne2019-04-303-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was eliminated and calls to it changed to be bb_error_msg(). The downside of this is that daemons now log all messages to syslog at the LOG_ERR level which makes it hard to filter errors from informational messages. This change optionally re-introduces bb_info_msg(), controlled by a new option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that were removed (only in applets that set logmode to LOGMODE_SYSLOG or LOGMODE_BOTH), and also changes informational messages in ifplugd and ntpd. The code size change of this is as follows (using 'defconfig' on x86_64 with gcc 7.3.0-27ubuntu1~18.04) function old new delta bb_info_msg - 182 +182 bb_vinfo_msg - 27 +27 static.log7 194 198 +4 log8 190 191 +1 log5 190 191 +1 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45) Total: 170 bytes If you don't care about everything being logged at LOG_ERR level then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller: function old new delta static.log7 194 200 +6 log8 190 193 +3 log5 190 193 +3 syslog_level 1 - -1 bb_verror_msg 583 581 -2 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48) Total: -36 bytes Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: add function to convert slashes to backslashesRon Yorston2019-03-151-6/+3
| | | | | | | | | | | | | | | | | | There are now two places where slashes are converted to backslashes throughout a string so it makes sense to create a function to do this. To avoid confusion rename convert_slashes() to bs_to_slash() and call the new function slash_to_bs().
* | su: canonicalise directory before elevating privilegesRon Yorston2019-03-141-5/+11
| | | | | | | | | | | | If the current directory is in a drive mapped to a network share we may not be able to access it once we have elevated privileges. Avoid this by canonicalising the path before calling ShellExecuteEx().
* | win32: changes to user idsRon Yorston2019-03-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formalise the use of 0 as the uid of a process running with elevated privileges: - Rewrite getuid(2) to return DEFAULT_UID by default and 0 if the process has elevated privileges. - geteuid(2) and the corresponding functions for groups are aliases for getuid(2). - Change root's home directory to be whatever GetSystemDirectory() returns, probably C:/Windows/System32 in most cases. - Remove the special handling of geteuid(2) in the line editing code. With these changes the shell started by 'su' is a lot more like a *nix root shell.
* | su: change title of console windowRon Yorston2019-03-091-1/+3
| |
* | su: work when binary has a UNC pathRon Yorston2019-03-091-1/+11
| | | | | | | | | | | | ShellExecuteEx() requires backslashes as the file separator if the binary to be executed has a UNC path. Convert separators unconditionally.
* | su, wget: use magic '--busybox' flagRon Yorston2019-03-081-5/+2
| | | | | | | | | | | | I've been a bit lax about ensuring the --busybox flag is passed in command lines. It's needed to avoid problems if the binary is called something like sh.exe.
* | ash, su: add -d flag to set directory in ash, use it in suRon Yorston2019-03-081-2/+5
| | | | | | | | | | | | | | | | When busybox-w32 is installed in C:/Windows/System32 su doesn't run in the same directory as its parent as intended. Work around this by adding a flag to the shell to set the working directory.
* | su: add a basic implementation for WIN32Ron Yorston2019-03-072-0/+51
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the undocumented 'runas' verb in a call to ShellExecuteEx() to run a shell with elevated privileges. Because of the way ShellExecuteEx() works this: - requires that you acknowledge a User Account Control prompt (if you're an Administrator); - requires that you enter an Administrator's password (if you aren't an Administrator); - creates a separate console window for the privileged shell. Variables from the parent shell aren't passed to its privileged child, only variables from the environment. It's possible to specify a command to run when the shell starts. This can be used to pass shell variables: su -c "HELLO='hello world'; GOODBYE=$GOODBYE" Or do fancy things like: su -c "ls -l; read -p 'Hit return to exit: '; exit" It's probably best to put double quotes around the command and use single quotes inside it. Apparently ShellExecuteEx() requires double quotes to be entered in triplicate: su -c 'HELLO="""hello world"""'
* login: close PAM session on errors as well, not only on successDenys Vlasenko2019-01-221-3/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* adduser: fix a bug of getpwnam() overwriting shell name, closes 8586Denys Vlasenko2019-01-121-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* passwd: initialize pointers correctlyEinar Jón2019-01-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | Fix for running passwd as root (or sudo passwd $USER). Crashed on call to free(orig) during cleanup. Fix regression from commit 17058a06c4333fc0c492c168c8a971ebd0fd5a5a Root user never changes the orig pointer, so when cleaning up, passwd tried to free orig=(char*)"" Example: sudo passwd $USER Changing password for xxx New password: Bad password: too short Retype password: Passwords don't match free(): invalid pointer Aborted function old new delta passwd_main 958 961 +3 Signed-off-by: Einar Jón <tolvupostur@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>