diff options
author | Ron Yorston <rmy@pobox.com> | 2023-08-30 13:07:13 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-08-30 13:07:13 +0100 |
commit | 2af141a2c069c56d56f110414f600f3a38ad8617 (patch) | |
tree | 0709c2d3ec4babe557a6fdcbe5334d3665bea0a4 | |
parent | 89e67c6f7a77e0e16cbf394f18d4cb121e37f544 (diff) | |
download | busybox-w32-2af141a2c069c56d56f110414f600f3a38ad8617.tar.gz busybox-w32-2af141a2c069c56d56f110414f600f3a38ad8617.tar.bz2 busybox-w32-2af141a2c069c56d56f110414f600f3a38ad8617.zip |
ash: changes to login shell functionality
Upstream BusyBox supports the usual Unix functionality where the
login process adds a '-' prefix to the shell's argv[0]. Since
busybox-w32 doesn't have a login process this serves no purpose
and can be removed.
Instead it would be useful to have a way to invoke a login shell
without requiring any arguments. Advantages would be:
- easier to configure busybox-w32 'ash' as the SSH login shell;
- double clicking on a shell binary could start a login shell.
Add 'lash' as an alias for 'ash' which starts a login shell without
requiring the '-l' option.
Saves 16 bytes.
-rw-r--r-- | libbb/appletlib.c | 3 | ||||
-rw-r--r-- | shell/ash.c | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index bf9ae4603..6b610743a 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -1379,9 +1379,10 @@ int main(int argc UNUSED_PARAM, char **argv) | |||
1379 | argv++; | 1379 | argv++; |
1380 | # endif | 1380 | # endif |
1381 | applet_name = argv[0]; | 1381 | applet_name = argv[0]; |
1382 | # if !ENABLE_PLATFORM_MINGW32 | ||
1382 | if (applet_name[0] == '-') | 1383 | if (applet_name[0] == '-') |
1383 | applet_name++; | 1384 | applet_name++; |
1384 | # if ENABLE_PLATFORM_MINGW32 | 1385 | # else |
1385 | str_tolower(argv[0]); | 1386 | str_tolower(argv[0]); |
1386 | bs_to_slash(argv[0]); | 1387 | bs_to_slash(argv[0]); |
1387 | if (has_exe_suffix_or_dot(argv[0])) { | 1388 | if (has_exe_suffix_or_dot(argv[0])) { |
diff --git a/shell/ash.c b/shell/ash.c index 2ea87a049..95f399b0b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -209,6 +209,9 @@ | |||
209 | //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) | 209 | //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) |
210 | // APPLET_ODDNAME:name main location suid_type help | 210 | // APPLET_ODDNAME:name main location suid_type help |
211 | //applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) | 211 | //applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) |
212 | //applet:IF_PLATFORM_MINGW32( | ||
213 | //applet:IF_SH_IS_ASH( APPLET_ODDNAME(lash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) | ||
214 | //applet:) | ||
212 | //applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) | 215 | //applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) |
213 | 216 | ||
214 | //kbuild:lib-$(CONFIG_SHELL_ASH) += ash.o ash_ptr_hack.o shell_common.o | 217 | //kbuild:lib-$(CONFIG_SHELL_ASH) += ash.o ash_ptr_hack.o shell_common.o |
@@ -15999,7 +16002,11 @@ procargs(char **argv) | |||
15999 | int login_sh; | 16002 | int login_sh; |
16000 | 16003 | ||
16001 | xargv = argv; | 16004 | xargv = argv; |
16005 | #if ENABLE_PLATFORM_MINGW32 | ||
16006 | login_sh = applet_name[0] == 'l'; | ||
16007 | #else | ||
16002 | login_sh = xargv[0] && xargv[0][0] == '-'; | 16008 | login_sh = xargv[0] && xargv[0][0] == '-'; |
16009 | #endif | ||
16003 | #if NUM_SCRIPTS > 0 | 16010 | #if NUM_SCRIPTS > 0 |
16004 | if (minusc) | 16011 | if (minusc) |
16005 | goto setarg0; | 16012 | goto setarg0; |