aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* pivot_root: make it NOFORKDenys Vlasenko2017-08-052-3/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* partprobe: make it NOEXECDenys Vlasenko2017-08-052-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sv, svc: make them NOEXECDenys Vlasenko2017-08-052-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* svc: fix a case where with more than option, getopt() state is not resetDenys Vlasenko2017-08-051-5/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* blockdev, fsfreeze, fstrim, mountpoint: make NOEXECDenys Vlasenko2017-08-055-8/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: use _exit, not exit, in bb_daemonize_or_rexec()Denys Vlasenko2017-08-046-15/+22
| | | | | | | | | 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>
* stty: make in NOEXECDenys Vlasenko2017-08-042-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* make 17 state-changing execing applets (ex: "nice PROG ARGS") noexecDenys Vlasenko2017-08-0412-43/+44
| | | | | | | | | | | | | | | | | | | | The applets with "<applet> [opts] PROG ARGS" API very quickly exec another program, noexec is okay for them: chpst/envdir/envuidgid/softlimit/setuidgid chroot chrt ionice nice nohup setarch/linux32/linux64 taskset cttyhack "reset" and "sulogin" applets don't have this form, but also exec another program at once, thus made noexec too. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mesg: make in NOFORKDenys Vlasenko2017-08-042-26/+31
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* pmap: tweak help text, show usage if no params are givenDenys Vlasenko2017-08-042-31/+32
| | | | | | | | | | Noticed while auditing nofork/noexec status function old new delta pmap_main 70 80 +10 packed_usage 31747 31744 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* runlevel: make it NOEXECDenys Vlasenko2017-08-042-20/+20
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mktemp: make it NOEXECDenys Vlasenko2017-08-042-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* chat: trim help textDenys Vlasenko2017-08-043-47/+58
| | | | | | | | | Noticed while auditing nofork/noexec status function old new delta packed_usage 31777 31747 -30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* getopt32: move support for "always treat first arg as option" to users (tar/ar)Denys Vlasenko2017-08-043-36/+10
| | | | | | | | | | | | | Now getopt() never leaks (and never performs) any xmalloc's. function old new delta ar_main 522 556 +34 tar_main 986 1014 +28 getopt32 1458 1350 -108 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 62/-108) Total: -46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* getopt32: factor out code to treat all args as optionsDenys Vlasenko2017-08-046-32/+41
| | | | | | | | | | | | | Working towards making getopt32() xmalloc-free function old new delta make_all_argv_opts - 58 +58 top_main 914 912 -2 getopt32 1517 1458 -59 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/2 up/down: 58/-61) Total: -3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tweak NOFORK_NOEXEC.lstDenys Vlasenko2017-08-041-9/+11
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: BASH_XTRACEFD bashismDenys Vlasenko2017-08-041-0/+10
| | | | | | | | | Based on patch by Johannes Schindelin <johannes.schindelin@gmx.de> function old new delta evalcommand 1447 1500 +53 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: remove no-longer-used variableJohannes Schindelin2017-08-041-2/+0
| | | | | | | | | | | As of 035486c75 (ash: significant overhaul of redirect saving logic, 2017-07-31), the sv_pos variable is no longer used (just assigned to, with no further effect). Let's just remove it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: INT_OFF/INT_ON around run_nofork_applet()Denys Vlasenko2017-08-041-3/+19
| | | | | | | function old new delta evalcommand 1441 1447 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sheel: improve comments on signal handlingDenys Vlasenko2017-08-044-17/+45
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* modutils: make them NOEXEC except depmodDenys Vlasenko2017-08-047-16/+19
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* microcom: require exactly one non-optionDenys Vlasenko2017-08-041-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: add a fixme comment at run_nofork_appletDenys Vlasenko2017-08-031-1/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* nofork: fix a bug uncovered by hush testsuite (forgotten fflush)Denys Vlasenko2017-08-032-1/+3
| | | | | | | function old new delta run_nofork_applet 280 287 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* getopt: make it NOEXECDenys Vlasenko2017-08-032-14/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* new NOFORKs: pwdx,kill[all5],ttysize,realpath,readlink NOEXECs: date,resizeDenys Vlasenko2017-08-0311-93/+106
| | | | | | | | | | function old new delta run_nofork_applet 258 280 +22 readlink_main 112 123 +11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0) Total: 33 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: FEDORA_COMPAT option (so far only tweaks uname)Denys Vlasenko2017-08-032-1/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* new NOFORKs: clear, nproc, tty, uname, arch, unlink, whichDenys Vlasenko2017-08-037-8/+414
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: do not accept "if() { echo; }" function defDenys Vlasenko2017-08-025-17/+60
| | | | | | | | | | | | | | function old new delta parse_stream 2634 2692 +58 msg_and_die_if_script - 21 +21 syntax_error_unexpected_ch 41 46 +5 syntax_error_at 14 18 +4 die_if_script 31 28 -3 setup_redirects 319 308 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/2 up/down: 88/-14) Total: 74 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* line editing: make read_line_input() not take timeout paramDenys Vlasenko2017-08-026-20/+30
| | | | | | | | | | | | | | | | | | It's almost always -1. function old new delta read_line_input 3902 3912 +10 new_line_input_t 24 31 +7 pgetc 583 585 +2 save_command_ps_at_cur_history 80 78 -2 read_line 76 74 -2 fgetc_interactive 246 244 -2 addLines 84 82 -2 doCommands 2226 2222 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/5 up/down: 19/-12) Total: 7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make SIGINT handling visually less confusingDenys Vlasenko2017-08-021-3/+3
| | | | | | | | | | | | | | | | | | | | | $ echo $$ 18448 $ echo $? <wait here, run "kill -INT 18448" in other shell><press enter> <=== NOTHING?? $ That empty line does not look right. After this patch: $ echo $$ 18448 $ echo $? <wait here, run "kill -INT 18448" in other shell><press enter> ^C $ function old new delta fgetc_interactive 245 246 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* NOFORK fixesDenys Vlasenko2017-08-026-6/+48
| | | | | | | | | | | | | | | | | | "rm -i FILE" and "yes" can now be interrupted by ^C in hush. This also now works: $ usleep 19999999 ^C $ echo $? 130 function old new delta run_pipe 1668 1711 +43 pseudo_exec_argv 312 321 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* do not use `a' quoting style in commentsDenys Vlasenko2017-08-0235-42/+42
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: do not use `a' quoting in help textsDenys Vlasenko2017-08-026-6/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: align --login code with dashDenys Vlasenko2017-07-311-13/+17
| | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 13 Jul 2008 22:34:50 +0800 [OPTIONS] Added support for -l This patch adds support for the -l option (login shell) as required by the LSB. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> It's a bit bigger, but gets rid of one global variable function old new delta options 554 576 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* test: fix 4-argument caseDenys Vlasenko2017-07-311-9/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream dash commit: Date: Sun, 13 Jul 2008 19:20:10 +0800 Fixed 3,4-argument cases for test per POSIX ----- Forwarded message from Gerrit Pape <pape@smarden.org> ----- Subject: Bug#455828: dash: 4-argument test "test \( ! -e \)" yields an error Date: Fri, 28 Dec 2007 08:53:29 +0000 From: Gerrit Pape <pape@smarden.org> To: Vincent Lefevre <vincent@vinc17.org>, 455828@bugs.debian.org On Thu, Dec 27, 2007 at 06:23:20PM +0100, Vincent Lefevre wrote: > On 2007-12-27 16:00:06 +0000, Gerrit Pape wrote: > > On Wed, Dec 12, 2007 at 02:18:47AM +0100, Vincent Lefevre wrote: > > > According to POSIX[*], "test \( ! -e \)" is a 4-argument test and is > > > here equivalent to "test ! -e". But dash (like ksh93 and bash) yields > > > an error: > > > > > > $ test \( ! -e \) || echo $? > > > test: 1: closing paren expected > > > 2 > > > $ test ! -e || echo $? > > > 1 > > > > Hi Vincent, > > > > the -e switch to test takes an argument, a pathname. > > According to POSIX, in both above examples, "-e" is *not* a switch, > just a string. > > test \( ! -e \) > > means: return true if the string "-e" is empty, otherwhise return false. > The error in dash is that it incorrectly thinks that "-e" is a switch in > this context. I see, you're right. Thanks, Gerrit. ----- End forwarded message ----- This patch hard-codes the 3,4-argument cases in the way required by POSIX. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta test_main 370 421 +51 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove redundant "G_flag_return_in_progress = -1"Denys Vlasenko2017-07-311-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix "true | func_with_return" not allowing return.Denys Vlasenko2017-07-319-8/+52
| | | | | | | function old new delta pseudo_exec_argv 305 312 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix display of ">&-" redirect in job stringsDenys Vlasenko2017-07-311-1/+8
| | | | | | | function old new delta cmdtxt 558 569 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: functions have priority over builtins (!)Denys Vlasenko2017-07-315-14/+39
| | | | | | | | | | function old new delta pseudo_exec_argv 291 305 +14 run_pipe 1560 1555 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-5) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: if STANDALONE, close interactive fd for NOEXECed childrenDenys Vlasenko2017-07-311-2/+15
| | | | | | | function old new delta pseudo_exec_argv 291 305 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: ">&10" redirects to script/tty fds should not workDenys Vlasenko2017-07-312-19/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | The fact that shell has open fds to tty and/or scripts should be unobservable, if possible. In particular, if redirect tries to dup one of them via ">&script_fd", it's better to pretend that script_fd is closed, and thus redirect fails with EBADF. Fixes these two testcase failures: ash-redir/redir_to_bad_fd.tests hush-redir/redir_to_bad_fd3.tests function old new delta redirect 1018 1129 +111 setup_redirects 250 359 +109 readtoken1 2651 2655 +4 cmdloop 185 187 +2 changepath 194 195 +1 save_fd_on_redirect 203 194 -9 evaltree 501 484 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/2 up/down: 227/-26) Total: 201 bytes text data bss dec hex filename 914553 485 6848 921886 e111e busybox_old 914754 485 6848 922087 e11e7 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: significant overhaul of redirect saving logicDenys Vlasenko2017-07-3111-143/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New code is similar to what hush is doing. Make CLOSED to -1: same as dash. popredir() loses "restore" parameter: same as dash. COPYFD_RESTORE bit is no longer necessary. This change fixes this interactive bug: $ ls -l /proc/$$/fd 10>&- ash: can't set tty process group: Bad file descriptor ash: can't set tty process group: Bad file descriptor [1]+ Done(2) ls -l /proc/${\$}/fd 10>&4294967295 function old new delta unwindredir 29 27 -2 tryexec 154 152 -2 evaltree 503 501 -2 evalcommand 1369 1367 -2 cmdloop 187 185 -2 redirect 1029 1018 -11 popredir 153 123 -30 need_to_remember 36 - -36 is_hidden_fd 68 - -68 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/7 up/down: 0/-155) Total: -155 bytes text data bss dec hex filename 914572 485 6848 921905 e1131 busybox_old 914553 485 6848 921886 e111e busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: massage redirect code to be slightly more like ashDenys Vlasenko2017-07-311-37/+72
| | | | | | | | | | | | | function old new delta save_fd_on_redirect - 203 +203 xdup_CLOEXEC_and_close - 75 +75 setup_redirects 245 250 +5 xdup_and_close 72 - -72 save_fds_on_redirect 221 - -221 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/0 up/down: 283/-293) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: remove REDIR_SAVEFD2Denys Vlasenko2017-07-311-32/+37
| | | | | | | | | | function old new delta evalcommand 1364 1369 +5 redirect 1055 1014 -41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-41) Total: -36 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: if !ENABLE_ASH_EXPAND_PRMT, disable PSSYNTAX codeDenys Vlasenko2017-07-291-2/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [REDIR] Fix popredir on abnormal exit from built-inDenys Vlasenko2017-07-291-26/+44
| | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 May 2010 15:03:46 +0800 [REDIR] Fix popredir on abnormal exit from built-in Just like the poplocalvar problem recently fixed, redirections can also be leaked in case of an abnormal exit. This patch fixes it using the same method as poplocalvar, by storing the previous redirection state and restoring to that point. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [PARSER] Add FAKEEOFMARK for expandstrDenys Vlasenko2017-07-291-19/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 Dec 2007 13:54:16 +1100 [PARSER] Add FAKEEOFMARK for expandstr Previously expandstr used the string "" to indicate that it needs to be treated just like a here-doc except that there is no terminator. However, the string "" is in fact a valid here-doc terminator so now that we deal with it correctly expandstr no longer works in the presence of new-lines in the prompt. This patch introduces the FAKEEOFMARK macro which does not equal any real EOF marker but is distinct from the NULL pointer which is used to indicate non-here-doc contexts. Thanks to Markus Triska for reporting this regression. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Unfortunately, I did not find the failing example for this old fix. I also tweaked the code which was added by this commit: " Date: Mon Sep 24 18:30:02 2007 +0000 ash: fix prompt expansion (Natanael Copa <natanael.copa@gmail.com>) " since other parts of code do expect expandstr() to use DQSYNTAX, not PSSYNTAX. function old new delta parse_stream 2609 2634 +25 setprompt_if 128 133 +5 read_profile 32 37 +5 evalcommand 1334 1339 +5 expandstr 122 120 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 40/-2) Total: 38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of empty heredoc EOF markerDenys Vlasenko2017-07-295-17/+63
| | | | | | | function old new delta parse_stream 2609 2634 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [PARSER] Removed noexpand/length check on eofmarkDenys Vlasenko2017-07-293-70/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream comment: Date: Sun, 11 Nov 2007 14:21:23 +0800 [PARSER] Removed noexpand/length check on eofmark On Tue, Oct 30, 2007 at 04:23:35AM +0000, Oleg Verych wrote: > > } 8<<"" > ====================== Actually this (the empty delim) only works with dash by accident. I've tried bash and pdksh and they both terminate on the first empty line which is what you would expect rather than EOF. The real Korn shell does something completely different. I've fixed this in dash to conform to bash/pdksh. > In [0] it's stated, that delimiter isn't evaluated (expanded), only > quoiting must be checked. That if() seems to be completely bogus. OK I agree. The reason it was there is because the parser would have already replaced the dollar sign by an internal representation. I've fixed it properly with this patch. Test case: cat <<- $a OK $a cat <<- "" OK echo OK Old result: dash: Syntax error: Illegal eof marker for << redirection OK echo OK New result: OK OK OK function old new delta parsefname 227 152 -75 readtoken1 2819 2651 -168 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-243) Total: -243 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>