svn commit: r365037 - in head/bin/sh: . tests/builtins
Author: jilles Date: Tue Sep 1 13:19:15 2020 New Revision: 365037 URL: https://svnweb.freebsd.org/changeset/base/365037 Log: sh: Write absolute path in command -vV and type POSIX is pretty clear that command -v, command -V and type shall write absolute pathnames. Therefore, we need to prepend the current directory's name to relative pathnames. This can happen either when PATH contains a relative pathname or when the operand contains a slash but is not an absolute pathname. Added: head/bin/sh/tests/builtins/command13.0 (contents, props changed) head/bin/sh/tests/builtins/command14.0 (contents, props changed) head/bin/sh/tests/builtins/type4.0 (contents, props changed) Modified: head/bin/sh/exec.c head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Tue Sep 1 12:21:17 2020(r365036) +++ head/bin/sh/exec.c Tue Sep 1 13:19:15 2020(r365037) @@ -679,6 +679,21 @@ isfunc(const char *name) } +static void +print_absolute_path(const char *name) +{ + const char *pwd; + + if (*name != '/' && (pwd = lookupvar("PWD")) != NULL && *pwd != '\0') { + out1str(pwd); + if (strcmp(pwd, "/") != 0) + outcslow('/', out1); + } + out1str(name); + outcslow('\n', out1); +} + + /* * Shared code for the following builtin commands: *type, command -v, command -V @@ -745,20 +760,16 @@ typecmd_impl(int argc, char **argv, int cmd, const cha name = padvance(, , argv[i]); stunalloc(name); } while (--j >= 0); - if (cmd == TYPECMD_SMALLV) - out1fmt("%s\n", name); - else - out1fmt("%s is%s %s\n", argv[i], + if (cmd != TYPECMD_SMALLV) + out1fmt("%s is%s ", argv[i], (cmdp && cmd == TYPECMD_TYPE) ? - " a tracked alias for" : "", - name); + " a tracked alias for" : ""); + print_absolute_path(name); } else { if (eaccess(argv[i], X_OK) == 0) { - if (cmd == TYPECMD_SMALLV) - out1fmt("%s\n", argv[i]); - else - out1fmt("%s is %s\n", argv[i], - argv[i]); + if (cmd != TYPECMD_SMALLV) + out1fmt("%s is ", argv[i]); + print_absolute_path(argv[i]); } else { if (cmd != TYPECMD_SMALLV) outfmt(out2, "%s: %s\n", Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Tue Sep 1 12:21:17 2020 (r365036) +++ head/bin/sh/tests/builtins/Makefile Tue Sep 1 13:19:15 2020 (r365037) @@ -69,6 +69,8 @@ ${PACKAGE}FILES+= command9.0 ${PACKAGE}FILES+= command10.0 ${PACKAGE}FILES+= command11.0 ${PACKAGE}FILES+= command12.0 +${PACKAGE}FILES+= command13.0 +${PACKAGE}FILES+= command14.0 ${PACKAGE}FILES+= dot1.0 ${PACKAGE}FILES+= dot2.0 ${PACKAGE}FILES+= dot3.0 @@ -170,6 +172,7 @@ ${PACKAGE}FILES+= trap9.0 ${PACKAGE}FILES+= type1.0 type1.0.stderr ${PACKAGE}FILES+= type2.0 ${PACKAGE}FILES+= type3.0 +${PACKAGE}FILES+= type4.0 ${PACKAGE}FILES+= unalias.0 ${PACKAGE}FILES+= var-assign.0 ${PACKAGE}FILES+= var-assign2.0 Added: head/bin/sh/tests/builtins/command13.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/command13.0 Tue Sep 1 13:19:15 2020 (r365037) @@ -0,0 +1,21 @@ +# $FreeBSD$ + +failures=0 + +check() { + if [ "$1" != "$2" ] && { [ "$#" -lt 3 ] || [ "$1" != "$3" ]; } then + echo "Mismatch found" + echo "Expected: $2" + if [ "$#" -ge 3 ]; then + echo "Alternative expected: $3" + fi + echo "Actual: $1" +
svn commit: r364919 - in head/bin/sh: . tests/execution
Author: jilles Date: Fri Aug 28 15:35:45 2020 New Revision: 364919 URL: https://svnweb.freebsd.org/changeset/base/364919 Log: sh: Keep ignored SIGINT/SIGQUIT after set in a background job If job control is not enabled, a background job (... &) ignores SIGINT and SIGQUIT, but this can be reverted using the trap builtin in the same shell environment. Using the set builtin to change options would also revert SIGINT and SIGQUIT to their previous dispositions. This broke due to r317298. Calling setsignal() reverts the effect of ignoresig(). Reported by: bdrewery MFC after:1 week Added: head/bin/sh/tests/execution/bg13.0 (contents, props changed) Modified: head/bin/sh/main.c head/bin/sh/tests/execution/Makefile head/bin/sh/trap.c head/bin/sh/trap.h Modified: head/bin/sh/main.c == --- head/bin/sh/main.c Fri Aug 28 15:09:43 2020(r364918) +++ head/bin/sh/main.c Fri Aug 28 15:35:45 2020(r364919) @@ -134,6 +134,7 @@ main(int argc, char *argv[]) setstackmark(); setstackmark(); procargs(argc, argv); + trap_init(); pwd_init(iflag); INTON; if (iflag) Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileFri Aug 28 15:09:43 2020 (r364918) +++ head/bin/sh/tests/execution/MakefileFri Aug 28 15:35:45 2020 (r364919) @@ -19,6 +19,7 @@ ${PACKAGE}FILES+= bg9.0 ${PACKAGE}FILES+= bg10.0 bg10.0.stdout ${PACKAGE}FILES+= bg11.0 ${PACKAGE}FILES+= bg12.0 +${PACKAGE}FILES+= bg13.0 ${PACKAGE}FILES+= env1.0 ${PACKAGE}FILES+= fork1.0 ${PACKAGE}FILES+= fork2.0 Added: head/bin/sh/tests/execution/bg13.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/bg13.0 Fri Aug 28 15:35:45 2020 (r364919) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.` +trap 'rm -rf $T' 0 +cd $T || exit 3 +mkfifo fifo1 +# Use a trap, not the default action, since the shell may catch SIGINT and +# therefore its processing may be delayed. +{ set -C; trap 'exit 5' TERM; read dummy fifo1 +kill -INT "$!" +kill -TERM "$!" +exec 3>&- +wait "$!" +r=$? +[ "$r" = 5 ] Modified: head/bin/sh/trap.c == --- head/bin/sh/trap.c Fri Aug 28 15:09:43 2020(r364918) +++ head/bin/sh/trap.c Fri Aug 28 15:35:45 2020(r364919) @@ -474,14 +474,20 @@ dotrap(void) } +void +trap_init(void) +{ + setsignal(SIGINT); + setsignal(SIGQUIT); +} + + /* * Controls whether the shell is interactive or not based on iflag. */ void setinteractive(void) { - setsignal(SIGINT); - setsignal(SIGQUIT); setsignal(SIGTERM); } Modified: head/bin/sh/trap.h == --- head/bin/sh/trap.h Fri Aug 28 15:09:43 2020(r364918) +++ head/bin/sh/trap.h Fri Aug 28 15:35:45 2020(r364919) @@ -45,6 +45,7 @@ void ignoresig(int); int issigchldtrapped(void); void onsig(int); void dotrap(void); +void trap_init(void); void setinteractive(void); void exitshell(int) __dead2; void exitshell_savedstatus(void) __dead2; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r363057 - head/bin/sh
Author: jilles Date: Thu Jul 9 20:53:56 2020 New Revision: 363057 URL: https://svnweb.freebsd.org/changeset/base/363057 Log: sh: Do not ignore INTOFF during a trap INTOFF postpones SIGINT processing and INTON enables it again. This is important so an interactive shell can return to the top level prompt when Ctrl+C is pressed. Given that INTON is automatically done when a builtin completes, the part where onsig() ignores suppressint when in_dotrap is true is both unnecessary and unsafe. If the trap is for some other signal than SIGINT, arbitrary code could have been interrupted. Historically, INTOFF remained in effect for longer. Reviewed by: bdrewery MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D25270 Modified: head/bin/sh/trap.c Modified: head/bin/sh/trap.c == --- head/bin/sh/trap.c Thu Jul 9 19:11:57 2020(r363056) +++ head/bin/sh/trap.c Thu Jul 9 20:53:56 2020(r363057) @@ -382,12 +382,7 @@ onsig(int signo) { if (signo == SIGINT && trap[SIGINT] == NULL) { - /* -* The !in_dotrap here is safe. The only way we can arrive -* here with in_dotrap set is that a trap handler set SIGINT to -* SIG_DFL and killed itself. -*/ - if (suppressint && !in_dotrap) + if (suppressint) SET_PENDING_INT; else onint(); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362738 - head/bin/sh/tests
Author: jilles Date: Sun Jun 28 21:33:08 2020 New Revision: 362738 URL: https://svnweb.freebsd.org/changeset/base/362738 Log: sh/tests: Re-enable bin.sh.execution.functional_test.bg12.0 This reverts r362646. PR: 247559 MFC after:1 week Modified: head/bin/sh/tests/functional_test.sh Modified: head/bin/sh/tests/functional_test.sh == --- head/bin/sh/tests/functional_test.shSun Jun 28 21:15:29 2020 (r362737) +++ head/bin/sh/tests/functional_test.shSun Jun 28 21:33:08 2020 (r362738) @@ -27,7 +27,6 @@ # $FreeBSD$ SRCDIR=$(atf_get_srcdir) -CATEGORY=$(basename ${SRCDIR}) check() { @@ -61,20 +60,7 @@ add_testcase() esac atf_test_case ${tc_escaped} - - if [ "$(atf_config_get ci false)" = "true" ]; then - case "${CATEGORY}/${tc}" in - execution/bg12.0) - eval "${tc_escaped}_body() { atf_skip 'https://bugs.freebsd.org/247559'; }" - ;; - *) - eval "${tc_escaped}_body() { check ${tc}; }" - ;; - esac - else - eval "${tc_escaped}_body() { check ${tc}; }" - fi - + eval "${tc_escaped}_body() { check ${tc}; }" atf_add_test_case ${tc_escaped} } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362737 - head/bin/sh/tests/execution
Author: jilles Date: Sun Jun 28 21:15:29 2020 New Revision: 362737 URL: https://svnweb.freebsd.org/changeset/base/362737 Log: sh/tests: Fix flaky execution/bg12.0 When job control is not enabled, the shell ignores SIGINT while waiting for a foreground process unless that process exits on SIGINT. In this case, the foreground process is sleep and it does not exit on SIGINT because the signal is only sent to the shell. Depending on order of events, this could cause the SIGINT to be unexpectedly ignored. On lightly loaded bare metal, the chance of this happening tends to be less than 0.01% but with higher loads and/or virtualization it becomes more likely. Starting the sleep in background and using the wait builtin ensures SIGINT will not be ignored. PR: 247559 Reported by: lwhsu MFC after:1 week Modified: head/bin/sh/tests/execution/bg12.0 Modified: head/bin/sh/tests/execution/bg12.0 == --- head/bin/sh/tests/execution/bg12.0 Sun Jun 28 21:11:10 2020 (r362736) +++ head/bin/sh/tests/execution/bg12.0 Sun Jun 28 21:15:29 2020 (r362737) @@ -4,7 +4,7 @@ T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.` trap 'rm -rf $T' 0 cd $T || exit 3 mkfifo fifo1 -{ trap - INT; : >fifo1; sleep 5; exit 4; } & +{ trap - INT; : >fifo1; sleep 5 & wait; exit 4; } & : https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362182 - head/bin/sh/tests/execution
Author: jilles Date: Sun Jun 14 19:41:24 2020 New Revision: 362182 URL: https://svnweb.freebsd.org/changeset/base/362182 Log: sh/tests: Add tests for SIGINT in non-jobc background commands If job control is not enabled, background commands shall ignore SIGINT and SIGQUIT, and it shall be possible to override that ignore in the same shell. MFC after:1 week Added: head/bin/sh/tests/execution/bg11.0 (contents, props changed) head/bin/sh/tests/execution/bg12.0 (contents, props changed) Modified: head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileSun Jun 14 18:49:06 2020 (r362181) +++ head/bin/sh/tests/execution/MakefileSun Jun 14 19:41:24 2020 (r362182) @@ -17,6 +17,8 @@ ${PACKAGE}FILES+= bg7.0 ${PACKAGE}FILES+= bg8.0 ${PACKAGE}FILES+= bg9.0 ${PACKAGE}FILES+= bg10.0 bg10.0.stdout +${PACKAGE}FILES+= bg11.0 +${PACKAGE}FILES+= bg12.0 ${PACKAGE}FILES+= env1.0 ${PACKAGE}FILES+= fork1.0 ${PACKAGE}FILES+= fork2.0 Added: head/bin/sh/tests/execution/bg11.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/bg11.0 Sun Jun 14 19:41:24 2020 (r362182) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.` +trap 'rm -rf $T' 0 +cd $T || exit 3 +mkfifo fifo1 +# Use a trap, not the default action, since the shell may catch SIGINT and +# therefore its processing may be delayed. +{ trap 'exit 5' TERM; read dummy fifo1 +kill -INT "$!" +kill -TERM "$!" +exec 3>&- +wait "$!" +r=$? +[ "$r" = 5 ] Added: head/bin/sh/tests/execution/bg12.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/bg12.0 Sun Jun 14 19:41:24 2020 (r362182) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.` +trap 'rm -rf $T' 0 +cd $T || exit 3 +mkfifo fifo1 +{ trap - INT; : >fifo1; sleep 5; exit 4; } & +: https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361647 - in head/bin/sh: . tests/execution
Author: jilles Date: Sat May 30 16:00:49 2020 New Revision: 361647 URL: https://svnweb.freebsd.org/changeset/base/361647 Log: sh: Allow more scripts without #! Austin Group bugs #1226 and #1250 changed the requirements for shell scripts without #! (POSIX does not specify #!; this is about the shell execution when execve(2) returns an [ENOEXEC] error). POSIX says we shall allow execution if the initial part intended to be parsed by the shell consists of characters and does not contain the NUL character. This allows concatenating a shell script (ending with exec or exit) and a binary payload. In order to reject common binary files such as PNG images, check that there is a lowercase letter or expansion before the last newline before the NUL character, in addition to the check for the newline character suggested by POSIX. Added: head/bin/sh/tests/execution/shellproc6.0 (contents, props changed) Modified: head/bin/sh/exec.c head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Sat May 30 13:39:56 2020(r361646) +++ head/bin/sh/exec.c Sat May 30 16:00:49 2020(r361647) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include /* @@ -140,6 +141,37 @@ shellexec(char **argv, char **envp, const char *path, } +static bool +isbinary(const char *data, size_t len) +{ + const char *nul, *p; + bool hasletter; + + nul = memchr(data, '\0', len); + if (nul == NULL) + return false; + /* +* POSIX says we shall allow execution if the initial part intended +* to be parsed by the shell consists of characters and does not +* contain the NUL character. This allows concatenating a shell +* script (ending with exec or exit) and a binary payload. +* +* In order to reject common binary files such as PNG images, check +* that there is a lowercase letter or expansion before the last +* newline before the NUL character, in addition to the check for +* the newline character suggested by POSIX. +*/ + hasletter = false; + for (p = data; *p != '\0'; p++) { + if ((*p >= 'a' && *p <= 'z') || *p == '$' || *p == '`') + hasletter = true; + if (hasletter && *p == '\n') + return false; + } + return true; +} + + static void tryexec(char *cmd, char **argv, char **envp) { @@ -155,7 +187,7 @@ tryexec(char *cmd, char **argv, char **envp) if (in != -1) { n = pread(in, buf, sizeof buf, 0); close(in); - if (n > 0 && memchr(buf, '\0', n) != NULL) { + if (n > 0 && isbinary(buf, n)) { errno = ENOEXEC; return; } Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileSat May 30 13:39:56 2020 (r361646) +++ head/bin/sh/tests/execution/MakefileSat May 30 16:00:49 2020 (r361647) @@ -59,6 +59,7 @@ ${PACKAGE}FILES+= shellproc2.0 ${PACKAGE}FILES+= shellproc3.0 ${PACKAGE}FILES+= shellproc4.0 ${PACKAGE}FILES+= shellproc5.0 +${PACKAGE}FILES+= shellproc6.0 ${PACKAGE}FILES+= subshell1.0 subshell1.0.stdout ${PACKAGE}FILES+= subshell2.0 ${PACKAGE}FILES+= subshell3.0 Added: head/bin/sh/tests/execution/shellproc6.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/shellproc6.0Sat May 30 16:00:49 2020 (r361647) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +T=`mktemp -d "${TMPDIR:-/tmp}/sh-test."` || exit +trap 'rm -rf "${T}"' 0 +printf 'printf "this "\necho is a test\nexit\n\0' >"$T/testshellproc" +chmod 755 "$T/testshellproc" +PATH=$T:$PATH +[ "`testshellproc`" = "this is a test" ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361384 - head/bin/sh
Author: jilles Date: Fri May 22 14:46:23 2020 New Revision: 361384 URL: https://svnweb.freebsd.org/changeset/base/361384 Log: sh: Remove a comment that was obsoleted by r358152 Since r358152, the read builtin has used a buffer. Also, remove a space at the end of the line in a comment. No functional change is intended. Modified: head/bin/sh/miscbltin.c Modified: head/bin/sh/miscbltin.c == --- head/bin/sh/miscbltin.c Fri May 22 13:27:02 2020(r361383) +++ head/bin/sh/miscbltin.c Fri May 22 14:46:23 2020(r361384) @@ -124,7 +124,7 @@ fdctx_destroy(struct fdctx *fdc) * Reposition the file offset. Here is the layout of buf: * * | off -* v +* v * |*|---| * buf ep buf+buflen * |<- residue ->| @@ -142,8 +142,6 @@ fdctx_destroy(struct fdctx *fdc) /* * The read builtin. The -r option causes backslashes to be treated like * ordinary characters. - * - * This uses unbuffered input, which may be avoidable in some cases. * * Note that if IFS=' :' then read x y should work so that: * 'a b' x='a', y='b' ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361117 - head/bin/sh/tests/execution
Author: jilles Date: Sat May 16 19:38:58 2020 New Revision: 361117 URL: https://svnweb.freebsd.org/changeset/base/361117 Log: sh/tests: Fix keywords on newly added test Modified: Directory Properties: head/bin/sh/tests/execution/unknown2.0 (props changed) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361112 - in head/bin/sh: . tests/execution
Author: jilles Date: Sat May 16 16:29:23 2020 New Revision: 361112 URL: https://svnweb.freebsd.org/changeset/base/361112 Log: sh: Fix double INTON with vfork The shell maintains a count of the number of times SIGINT processing has been disabled via INTOFF, so SIGINT processing resumes when all disables have enabled again (INTON). If an error occurs in a vfork() child, the processing of the error enables SIGINT processing again, and the INTON in vforkexecshell() causes the count to become negative. As a result, a later INTOFF may not actually disable SIGINT processing. This might cause memory corruption if a SIGINT arrives at an inopportune time. As of r360452, it causes the shell to abort when it would unsafely allocate or free memory in certain ways. Note that various places such as errors in non-special builtins unconditionally reset the count to 0, so the problem might still not always be visible. PR: 246497 Reported by: jbeich MFC after:2 weeks Added: head/bin/sh/tests/execution/unknown2.0 (contents, props changed) Modified: head/bin/sh/jobs.c head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Sat May 16 14:33:08 2020(r36) +++ head/bin/sh/jobs.c Sat May 16 16:29:23 2020(r361112) @@ -1008,9 +1008,11 @@ vforkexecshell(struct job *jp, char **argv, char **env pid_t pid; struct jmploc jmploc; struct jmploc *savehandler; + int inton; TRACE(("vforkexecshell(%%%td, %s, %p) called\n", jp - jobtab, argv[0], (void *)pip)); + inton = is_int_on(); INTOFF; flushall(); savehandler = handler; @@ -1045,7 +1047,7 @@ vforkexecshell(struct job *jp, char **argv, char **env setcurjob(jp); #endif } - INTON; + SETINTON(inton); TRACE(("In parent shell: child = %d\n", (int)pid)); return pid; } Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileSat May 16 14:33:08 2020 (r36) +++ head/bin/sh/tests/execution/MakefileSat May 16 16:29:23 2020 (r361112) @@ -64,6 +64,7 @@ ${PACKAGE}FILES+= subshell2.0 ${PACKAGE}FILES+= subshell3.0 ${PACKAGE}FILES+= subshell4.0 ${PACKAGE}FILES+= unknown1.0 +${PACKAGE}FILES+= unknown2.0 ${PACKAGE}FILES+= var-assign1.0 .include Added: head/bin/sh/tests/execution/unknown2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/unknown2.0 Sat May 16 16:29:23 2020 (r361112) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +{ + : $(/var/empty/nosuchtool) + : $(:) +} 2>/dev/null ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360992 - head/bin/sh/tests/parser
Author: jilles Date: Tue May 12 21:59:21 2020 New Revision: 360992 URL: https://svnweb.freebsd.org/changeset/base/360992 Log: sh/tests: Test some obscure cases with aliasing keywords Added: head/bin/sh/tests/parser/alias19.0 (contents, props changed) head/bin/sh/tests/parser/alias19.0.stdout (contents, props changed) head/bin/sh/tests/parser/alias20.0 (contents, props changed) head/bin/sh/tests/parser/alias20.0.stdout (contents, props changed) Modified: head/bin/sh/tests/parser/Makefile Modified: head/bin/sh/tests/parser/Makefile == --- head/bin/sh/tests/parser/Makefile Tue May 12 21:51:56 2020 (r360991) +++ head/bin/sh/tests/parser/Makefile Tue May 12 21:59:21 2020 (r360992) @@ -25,6 +25,8 @@ ${PACKAGE}FILES+= alias15.0 alias15.0.stdout ${PACKAGE}FILES+= alias16.0 ${PACKAGE}FILES+= alias17.0 ${PACKAGE}FILES+= alias18.0 +${PACKAGE}FILES+= alias19.0 alias19.0.stdout +${PACKAGE}FILES+= alias20.0 alias20.0.stdout ${PACKAGE}FILES+= and-pipe-not.0 ${PACKAGE}FILES+= case1.0 ${PACKAGE}FILES+= case2.0 Added: head/bin/sh/tests/parser/alias19.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/parser/alias19.0 Tue May 12 21:59:21 2020 (r360992) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +alias begin={ end=} +begin +cat
svn commit: r360452 - head/bin/sh
Author: jilles Date: Tue Apr 28 20:34:27 2020 New Revision: 360452 URL: https://svnweb.freebsd.org/changeset/base/360452 Log: sh: Assert INTOFF rather than applying it in ck* As I noted in https://reviews.freebsd.org/D22756, INTOFF should be in effect when calling ckmalloc/ckrealloc/ckfree to avoid memory leaks and double frees. Therefore, change the functions to check if INTOFF is in effect instead of applying it. Reviewed by: bdrewery Differential Revision:https://reviews.freebsd.org/D24599 Modified: head/bin/sh/memalloc.c Modified: head/bin/sh/memalloc.c == --- head/bin/sh/memalloc.c Tue Apr 28 20:14:38 2020(r360451) +++ head/bin/sh/memalloc.c Tue Apr 28 20:34:27 2020(r360452) @@ -50,6 +50,13 @@ __FBSDID("$FreeBSD$"); #include #include +static void +badalloc(const char *message) +{ + write(2, message, strlen(message)); + abort(); +} + /* * Like malloc, but returns an error when out of space. */ @@ -59,9 +66,9 @@ ckmalloc(size_t nbytes) { pointer p; - INTOFF; + if (!is_int_on()) + badalloc("Unsafe ckmalloc() call\n"); p = malloc(nbytes); - INTON; if (p == NULL) error("Out of space"); return p; @@ -75,9 +82,9 @@ ckmalloc(size_t nbytes) pointer ckrealloc(pointer p, int nbytes) { - INTOFF; + if (!is_int_on()) + badalloc("Unsafe ckrealloc() call\n"); p = realloc(p, nbytes); - INTON; if (p == NULL) error("Out of space"); return p; @@ -86,9 +93,9 @@ ckrealloc(pointer p, int nbytes) void ckfree(pointer p) { - INTOFF; + if (!is_int_on()) + badalloc("Unsafe ckfree() call\n"); free(p); - INTON; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360210 - head/bin/sh
Author: jilles Date: Wed Apr 22 21:45:43 2020 New Revision: 360210 URL: https://svnweb.freebsd.org/changeset/base/360210 Log: sh: Remove remnants to compile out fc completely r360139 made compiling with NO_HISTORY work. This #define does not remove the fc and bind builtins completely but makes them always write an error message. However, there was also some code in builtins.def and mkbuiltins to remove the fc builtin entirely (but not the bind builtin). The additional build system complication to make this work seems not worth it, so remove that code. Modified: head/bin/sh/builtins.def head/bin/sh/mkbuiltins Modified: head/bin/sh/builtins.def == --- head/bin/sh/builtins.defWed Apr 22 21:22:33 2020(r360209) +++ head/bin/sh/builtins.defWed Apr 22 21:45:43 2020(r360210) @@ -39,8 +39,6 @@ # of a C routine. # The -j flag specifies that this command is to be excluded from systems # without job control. -# The -h flag specifies that this command is to be excluded from systems -# based on the NO_HISTORY compile-time symbol. # The -n flag specifies that this command can safely be run in the same # process when it is the only command in a command substitution. Some # commands have special logic defined in safe_builtin(). @@ -71,7 +69,7 @@ fgcmd -j fg freebsd_wordexpcmd freebsd_wordexp getoptscmd getopts hashcmdhash -histcmd -h fc +histcmdfc jobidcmd -njobid jobscmd -n jobs killcmd -n kill Modified: head/bin/sh/mkbuiltins == --- head/bin/sh/mkbuiltins Wed Apr 22 21:22:33 2020(r360209) +++ head/bin/sh/mkbuiltins Wed Apr 22 21:45:43 2020(r360210) @@ -35,11 +35,6 @@ # $FreeBSD$ temp=`mktemp -t ka` -havehist=1 -if [ "X$1" = "X-h" ]; then - havehist=0 - shift -fi srcdir=$1 havejobs=0 if grep '^#define[ ]*JOBS[ ]*1' $srcdir/shell.h > /dev/null @@ -56,8 +51,8 @@ cat <<\! #include "builtins.h" ! -awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ -print $0}' $srcdir/builtins.def | sed 's/-[hj]//' > $temp +awk '/^[^#]/ {if('$havejobs' || $2 != "-j") \ +print $0}' $srcdir/builtins.def | sed 's/-j//' > $temp echo 'int (*const builtinfunc[])(int, char **) = {' awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp echo '}; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r357138 - head/bin/pwait
On 26-01-2020 11:49, Pawel Jakub Dawidek wrote: Author: pjd Date: Sun Jan 26 10:49:24 2020 New Revision: 357138 URL: https://svnweb.freebsd.org/changeset/base/357138 Log: - Be consistent with using sysexits(3) codes. - Turn fprintf()+exit() into errx(). Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 07:24:49 2020(r357137) +++ head/bin/pwait/pwait.c Sun Jan 26 10:49:24 2020(r357138) @@ -53,8 +53,7 @@ static void usage(void) { - fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); - exit(EX_USAGE); + errx(EX_USAGE, "usage: pwait [-t timeout] [-v] pid ..."); This adds a "pwait: " before the line, which most other programs do not do. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r356251 - head/bin/sh
Author: jilles Date: Wed Jan 1 12:06:37 2020 New Revision: 356251 URL: https://svnweb.freebsd.org/changeset/base/356251 Log: sh: Fix rare memory leak with SIGINT If getcwd() failed earlier on but later succeeded in the pwd builtin, there was no INTOFF protection between calling savestr() and storing its result. It is quite rare for getcwd() to fail, and rarer for it to succeed later in the same directory. Found via code inspection for changing ckmalloc() and similar to assert INTOFF protection instead of applying it directly (which protects against corrupting malloc's internal state but allows memory leaks or double frees). MFC after:1 week Modified: head/bin/sh/cd.c Modified: head/bin/sh/cd.c == --- head/bin/sh/cd.cWed Jan 1 09:22:06 2020(r356250) +++ head/bin/sh/cd.cWed Jan 1 12:06:37 2020(r356251) @@ -376,8 +376,11 @@ getpwd(void) return curdir; p = getpwd2(); - if (p != NULL) + if (p != NULL) { + INTOFF; curdir = savestr(p); + INTON; + } return curdir; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r356208 - head/bin/sh/tests/execution
Author: jilles Date: Mon Dec 30 21:32:55 2019 New Revision: 356208 URL: https://svnweb.freebsd.org/changeset/base/356208 Log: sh: Test that executing various binary files is rejected If executing a file fails with an [ENOEXEC] error, the shell executes the file as a shell script, except that this execution may instead result in an error message if the file is binary. Per a recent Austin Group interpretation, we will need to change this to allow a concatenation of a shell script and a binary payload. See Austin Group bugs #1226 and #1250. MFC after:1 week Added: head/bin/sh/tests/execution/shellproc2.0 (contents, props changed) head/bin/sh/tests/execution/shellproc3.0 (contents, props changed) head/bin/sh/tests/execution/shellproc4.0 (contents, props changed) head/bin/sh/tests/execution/shellproc5.0 (contents, props changed) Modified: head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileMon Dec 30 20:30:31 2019 (r356207) +++ head/bin/sh/tests/execution/MakefileMon Dec 30 21:32:55 2019 (r356208) @@ -55,6 +55,10 @@ ${PACKAGE}FILES+=set-x2.0 ${PACKAGE}FILES+= set-x3.0 ${PACKAGE}FILES+= set-x4.0 ${PACKAGE}FILES+= shellproc1.0 +${PACKAGE}FILES+= shellproc2.0 +${PACKAGE}FILES+= shellproc3.0 +${PACKAGE}FILES+= shellproc4.0 +${PACKAGE}FILES+= shellproc5.0 ${PACKAGE}FILES+= subshell1.0 subshell1.0.stdout ${PACKAGE}FILES+= subshell2.0 ${PACKAGE}FILES+= subshell3.0 Added: head/bin/sh/tests/execution/shellproc2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/shellproc2.0Mon Dec 30 21:32:55 2019 (r356208) @@ -0,0 +1,18 @@ +# $FreeBSD$ +# This tests a quality of implementation issue. +# Shells are not required to reject executing binary files as shell scripts +# but executing, for example, ELF files for a different architecture as +# shell scripts may have annoying side effects. + +T=`mktemp -d "${TMPDIR:-/tmp}/sh-test."` || exit +trap 'rm -rf "${T}"' 0 +printf '\0' >"$T/testshellproc" +chmod 755 "$T/testshellproc" +if [ ! -s "$T/testshellproc" ]; then + printf "printf did not write a NUL character\n" >&2 + exit 2 +fi +PATH=$T:$PATH +errout=`testshellproc 3>&2 2>&1 >&3 3>&-` +r=$? +[ "$r" = 126 ] && [ -n "$errout" ] Added: head/bin/sh/tests/execution/shellproc3.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/shellproc3.0Mon Dec 30 21:32:55 2019 (r356208) @@ -0,0 +1,14 @@ +# $FreeBSD$ +# This tests a quality of implementation issue. +# Shells are not required to reject executing binary files as shell scripts +# but executing, for example, ELF files for a different architecture as +# shell scripts may have annoying side effects. + +T=`mktemp -d "${TMPDIR:-/tmp}/sh-test."` || exit +trap 'rm -rf "${T}"' 0 +printf '\177ELF\001!!\011\0\0\0\0\0\0\0\0' >"$T/testshellproc" +chmod 755 "$T/testshellproc" +PATH=$T:$PATH +errout=`testshellproc 3>&2 2>&1 >&3 3>&-` +r=$? +[ "$r" = 126 ] && [ -n "$errout" ] Added: head/bin/sh/tests/execution/shellproc4.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/shellproc4.0Mon Dec 30 21:32:55 2019 (r356208) @@ -0,0 +1,14 @@ +# $FreeBSD$ +# This tests a quality of implementation issue. +# Shells are not required to reject executing binary files as shell scripts +# but executing, for example, ELF files for a different architecture as +# shell scripts may have annoying side effects. + +T=`mktemp -d "${TMPDIR:-/tmp}/sh-test."` || exit +trap 'rm -rf "${T}"' 0 +printf '\211PNG\015\012\032\012\0\0\0\015IHDR' >"$T/testshellproc" +chmod 755 "$T/testshellproc" +PATH=$T:$PATH +errout=`testshellproc 3>&2 2>&1 >&3 3>&-` +r=$? +[ "$r" = 126 ] && [ -n "$errout" ] Added: head/bin/sh/tests/execution/shellproc5.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/shellproc5.0Mon Dec 30 21:32:55 2019 (r356208) @@ -0,0 +1,14 @@ +# $FreeBSD$ +# This tests a quality of implementation issue. +# Shells are not required to reject executing binary files as shell scripts +# but executing, for example, ELF files for a different architecture as +# shell scripts may have annoying side effects. + +T=`mktemp -d "${TMPDIR:-/tmp}/sh-test."` ||
Re: svn commit: r346017 - in head: libexec/rc libexec/rc/rc.d share/man/man5
On Tue, Apr 09, 2019 at 10:24:16PM +0100, Chris Rees wrote: > On 9 April 2019 22:13:29 BST, Chris Rees wrote: > >On 9 April 2019 22:08:35 BST, "Rodney W. Grimes" > > wrote: > >>> On 09/04/2019 20:59, Chris Rees wrote: > >>> > On 9 April 2019 20:55:07 BST, "Rodney W. Grimes" > >> wrote: > >>> >>> On 09/04/2019 21:33, Rodney W. Grimes wrote: > >>> >>>> I think the trigger issue is: > >>> >>>> grep zfs /etc/rc.d/zvol > >>> >>>> rcvar="zfs_enable" > >>> >>>> required_modules="zfs" > >>> >>>> that module requires may be going south with the > >>> >>>> new code when the module is built into the kernel. > >>> >>> Maybe it's because the module's name is zfsctrl (for whatever > >>reason) > >>> >> while the > >>> >>> module file is named zfs.ko. > >>> >> I suspect that could also lead to issues with the new code. > >>> >> It seems to be failing to detect that zfs is infact functional in > >>the > >>> >> kernel, > >>> >> and blindly, or not so blindly, trying to load zfs,ko, which when > >>you > >>> >> build > >>> >> it into the kernel you usually do so without any modules built, > >so > >>> >> there is > >>> >> no /boot/kernel/zfs.ko, and even if you did build it any attempt > >>to > >>> >> load > >>> >> it would return an error. > >>> > Loading with it built in isn't a problem, as I showed earlier. > >>> > Loading when it doesn't exist *is*. > >>> > I'm torn. Either we could revert this, or add a check to the > >>required_modules function instead, which I think is the better solution. > >>> Hang on, > >>> [crees@pegasus]~% sudo kldload -n zfsctrl && echo yes > >>> yes > >>I think your testing the return value of sudo here? > >Sudo returns the child's return value. > Turns out Oliver had also reported this to current@ with a log > https://lists.freebsd.org/pipermail/freebsd-current/2019-April/073148.html > Jilles@, mind if I revert this while I get some testing on this > scenario done? > It seems to me that zfs may not be included in the kernel, just > zfsctrl, or something like that. It seems like kldload -n does not work as expected for zfs, so reverting seems the right approach. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352869 - in head: contrib/netbsd-tests/lib/libc/sys tests/sys/posixshm tests/sys/vm
Author: jilles Date: Sun Sep 29 15:17:58 2019 New Revision: 352869 URL: https://svnweb.freebsd.org/changeset/base/352869 Log: Adjust tests after page fault changes in r352807 Commit r352807 fixed various signal numbers and codes from page faults; adjust the tests so they expect the fixes to be present. PR: 211924 Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c head/tests/sys/posixshm/posixshm_test.c head/tests/sys/vm/page_fault_signal.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c == --- head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Sun Sep 29 10:45:13 2019(r352868) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Sun Sep 29 15:17:58 2019(r352869) @@ -480,10 +480,6 @@ ATF_TC_BODY(mmap_truncate_signal, tc) int fd, sta; pid_t pid; -#ifdef __FreeBSD__ - atf_tc_expect_fail("testcase fails with SIGSEGV on FreeBSD; bug # 211924"); -#endif - fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) Modified: head/tests/sys/posixshm/posixshm_test.c == --- head/tests/sys/posixshm/posixshm_test.c Sun Sep 29 10:45:13 2019 (r352868) +++ head/tests/sys/posixshm/posixshm_test.c Sun Sep 29 15:17:58 2019 (r352869) @@ -697,7 +697,7 @@ ATF_TC_BODY(object_resize, tc) /* * The previous ftruncate(2) shrunk the backing object * so that this address is no longer valid, so reading -* from it should trigger a SIGSEGV. +* from it should trigger a SIGBUS. */ c = page[pagesize]; fprintf(stderr, "child: page 1: '%c'\n", c); @@ -707,7 +707,7 @@ ATF_TC_BODY(object_resize, tc) if (wait() < 0) atf_tc_fail("wait failed; errno=%d", errno); - if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGSEGV) + if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGBUS) atf_tc_fail("child terminated with status %x", status); /* Grow the object back to 2 pages. */ Modified: head/tests/sys/vm/page_fault_signal.c == --- head/tests/sys/vm/page_fault_signal.c Sun Sep 29 10:45:13 2019 (r352868) +++ head/tests/sys/vm/page_fault_signal.c Sun Sep 29 15:17:58 2019 (r352869) @@ -129,7 +129,6 @@ ATF_TC_BODY(page_fault_signal__bus_objerr_1, tc) int fd; int sz; - atf_tc_expect_fail("bug 211924"); sz = getpagesize(); fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd != -1); @@ -153,7 +152,6 @@ ATF_TC_BODY(page_fault_signal__bus_objerr_2, tc) int r; int sz; - atf_tc_expect_fail("bug 211924"); sz = getpagesize(); fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd != -1); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352495 - head/tests/sys/vm
Author: jilles Date: Wed Sep 18 21:00:32 2019 New Revision: 352495 URL: https://svnweb.freebsd.org/changeset/base/352495 Log: Add some tests for page fault signals and codes It is useful to have some tests for page fault signals. More tests would be useful but creating the conditions (such as various kinds of running out of memory and I/O errors) is more complicated. The tests page_fault_signal__bus_objerr_1 and page_fault_signal__bus_objerr_2 depend on https://reviews.freebsd.org/D21566 before they can pass. PR: 211924 Reviewed by: kib Differential Revision:https://reviews.freebsd.org/D21624 Added: head/tests/sys/vm/page_fault_signal.c (contents, props changed) Modified: head/tests/sys/vm/Makefile Modified: head/tests/sys/vm/Makefile == --- head/tests/sys/vm/Makefile Wed Sep 18 19:53:58 2019(r352494) +++ head/tests/sys/vm/Makefile Wed Sep 18 21:00:32 2019(r352495) @@ -5,6 +5,7 @@ PACKAGE=tests TESTSDIR= ${TESTSBASE}/sys/vm ATF_TESTS_C+= mlock_test \ - mmap_test + mmap_test \ + page_fault_signal .include Added: head/tests/sys/vm/page_fault_signal.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/vm/page_fault_signal.c Wed Sep 18 21:00:32 2019 (r352495) @@ -0,0 +1,184 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Jilles Tjoelker + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include +#include + +static sigjmp_buf sig_env; +static volatile int last_sig, last_code; + +static void +sighandler(int sig, siginfo_t *info, void *context __unused) +{ + + last_sig = sig; + last_code = info->si_code; + siglongjmp(sig_env, 1); +} + +static void +setup_signals(void) +{ + struct sigaction sa; + int r; + + sa.sa_sigaction = sighandler; + sa.sa_flags = SA_RESTART | SA_RESETHAND | SA_SIGINFO; + r = sigfillset(_mask); + ATF_REQUIRE(r != -1); + r = sigaction(SIGILL, , NULL); + ATF_REQUIRE(r != -1); + r = sigaction(SIGBUS, , NULL); + ATF_REQUIRE(r != -1); + r = sigaction(SIGSEGV, , NULL); + ATF_REQUIRE(r != -1); +} + +ATF_TC_WITHOUT_HEAD(page_fault_signal__segv_maperr_1); +ATF_TC_BODY(page_fault_signal__segv_maperr_1, tc) +{ + int *p; + int r; + int sz; + + sz = getpagesize(); + p = mmap(NULL, sz, PROT_READ, MAP_ANON, -1, 0); + ATF_REQUIRE(p != MAP_FAILED); + r = munmap(p, sz); + ATF_REQUIRE(r != -1); + if (sigsetjmp(sig_env, 1) == 0) { + setup_signals(); + *(volatile int *)p = 1; + } + ATF_CHECK_EQ(SIGSEGV, last_sig); + ATF_CHECK_EQ(SEGV_MAPERR, last_code); +} + +ATF_TC_WITHOUT_HEAD(page_fault_signal__segv_accerr_1); +ATF_TC_BODY(page_fault_signal__segv_accerr_1, tc) +{ + int *p; + int sz; + + sz = getpagesize(); + p = mmap(NULL, sz, PROT_READ, MAP_ANON, -1, 0); + ATF_REQUIRE(p != MAP_FAILED); + if (sigsetjmp(sig_env, 1) == 0) { + setup_signals(); + *(volatile int *)p = 1; + } + (void)munmap(p, sz); + ATF_CHECK_EQ(SIGSEGV, last_sig); + ATF_CHECK_EQ(SEGV_ACCERR, last_code); +} + +ATF_TC_WITHOUT_HEAD(page_fault_signal__segv_accerr_2); +ATF_TC_BODY(page_fault_signal__segv_accerr_2, tc) +{ + int *p; + volatile int dummy; + int sz; + +
svn commit: r351819 - head/usr.bin/procstat/tests
Author: jilles Date: Wed Sep 4 16:25:41 2019 New Revision: 351819 URL: https://svnweb.freebsd.org/changeset/base/351819 Log: procstat/tests: Fix flakiness by waiting for program to start Some of the procstat tests start a program "while1" and examine the process using procstat, but did not wait properly for it to start (kill -0 will succeed immediately after the child process has been created). Instead, have "while1" write something when it starts, and use a fifo to wait for that. PR: 233587, 233588 Reviewed by: ngie MFC after:1 week Differential Revision:https://reviews.freebsd.org/D21519 Modified: head/usr.bin/procstat/tests/procstat_test.sh head/usr.bin/procstat/tests/while1.c Modified: head/usr.bin/procstat/tests/procstat_test.sh == --- head/usr.bin/procstat/tests/procstat_test.shWed Sep 4 15:55:44 2019(r351818) +++ head/usr.bin/procstat/tests/procstat_test.shWed Sep 4 16:25:41 2019(r351819) @@ -25,7 +25,6 @@ # $FreeBSD$ # -MAX_TRIES=20 PROG_PID= PROG_PATH=$(atf_get_srcdir)/while1 @@ -37,16 +36,13 @@ start_program() PROG_COMM=while1 PROG_PATH=$(atf_get_srcdir)/$PROG_COMM - $PROG_PATH $* & + mkfifo wait_for_start || atf_fail "mkfifo" + $PROG_PATH $* >wait_for_start & PROG_PID=$! - try=0 - while [ $try -lt $MAX_TRIES ] && ! kill -0 $PROG_PID; do - sleep 0.5 - : $(( try += 1 )) - done - if [ $try -ge $MAX_TRIES ]; then - atf_fail "Polled for program start $MAX_TRIES tries and failed" + if ! read dummy https://bugs.freebsd.org/233587; - arguments="my arguments" start_program $arguments @@ -104,8 +98,6 @@ environment_head() } environment_body() { - atf_skip "https://bugs.freebsd.org/233588; - var="MY_VARIABLE=foo" eval "export $var" Modified: head/usr.bin/procstat/tests/while1.c == --- head/usr.bin/procstat/tests/while1.cWed Sep 4 15:55:44 2019 (r351818) +++ head/usr.bin/procstat/tests/while1.cWed Sep 4 16:25:41 2019 (r351819) @@ -33,7 +33,8 @@ int main(void) { + if (write(STDOUT_FILENO, "started\n", 8) != 8) + abort(); for (;;) - usleep(100); - exit(1); + pause(); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r351643 - in head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common: dtraceUtil speculation
On Tue, Sep 03, 2019 at 06:42:00PM +0800, Li-Wen Hsu wrote: > On Mon, Sep 2, 2019 at 11:49 PM Rodney W. Grimes > wrote: > > > > On Aug 31, 2019, at 16:29, Warner Losh wrote: > > > >> On Sat, Aug 31, 2019 at 5:29 PM Conrad Meyer wrote: > > > >> Thanks Li-Wen! Might it be less fragile to have the test fixture > > > >> create a file, if the test(s) will expect one to be present to read? > > > > Or just use the realpath $0, which you know has to exist :) > > > I don?t know if this would work, with other some of the dtrace > > > tests are called. Plus, that relies on a FreeBSD utility which > > > doesn?t necessarily exist on Linux and I don?t think exists on > > > IllumOS. > > > It makes more sense to create a file with mktemp and test for it > > > in the loop to make the tests portable over to IllumOS, since > > > that?s where they originally came from and can be contributed back > > > to. > > Agreed, especially if these tests are expected to be portable the > > assumption of existance of /COPYRIGHT is a mistake/bug. > Thanks for the inputs. Indeed, depending on any irrelevant files or > FreeBSD specified tools both do not sound a good solution. After > reading these test cases again, I feel that creating a temp file might > be slightly over engineering because in the end we also need to take > care of cleaning, in normal and abnormal exiting cases. In these > tests, we only need someone calls open(2) and read(2). > How about changing them to `cat / > /dev/null` ? Reading a directory as bytes is not portable. For example, FreeBSD fdescfs and nfs do not allow it, and Linux does not allow it at all. Apart from the fact that the resulting bytes depend on the filesystem type, this operation is problematic because it may expose filenames that were previously deleted. The files /etc/group and /etc/passwd exist on most operating systems, but for optimal portability a temporary file seems unavoidable (assuming that data must come from a regular file). -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r350658 - head/tests/sys/kern
Author: jilles Date: Tue Aug 6 21:17:22 2019 New Revision: 350658 URL: https://svnweb.freebsd.org/changeset/base/350658 Log: Add a test for kill() on a zombie Added: head/tests/sys/kern/kill_zombie.c (contents, props changed) Modified: head/tests/sys/kern/Makefile Modified: head/tests/sys/kern/Makefile == --- head/tests/sys/kern/MakefileTue Aug 6 20:21:57 2019 (r350657) +++ head/tests/sys/kern/MakefileTue Aug 6 21:17:22 2019 (r350658) @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/sys/kern #ATF_TESTS_C+= kcov ATF_TESTS_C+= kern_copyin ATF_TESTS_C+= kern_descrip_test +ATF_TESTS_C+= kill_zombie ATF_TESTS_C+= ptrace_test TEST_METADATA.ptrace_test+=timeout="15" ATF_TESTS_C+= reaper Added: head/tests/sys/kern/kill_zombie.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/kern/kill_zombie.c Tue Aug 6 21:17:22 2019 (r350658) @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2018 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +ATF_TC_WITHOUT_HEAD(kill_zombie); +ATF_TC_BODY(kill_zombie, tc) +{ + pid_t child, pid; + int status, r; + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + _exit(42); + } + + r = waitid(P_PID, child, NULL, WEXITED | WNOWAIT); + ATF_REQUIRE(r == 0); + + r = kill(child, SIGTERM); + ATF_CHECK(r == 0); + + status = -1; + pid = waitpid(child, , 0); + ATF_REQUIRE(pid == child); + ATF_CHECK(WIFEXITED(status) && WEXITSTATUS(status) == 42); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, kill_zombie); + return (atf_no_error()); +} ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r350425 - head/usr.bin/printf
Author: jilles Date: Mon Jul 29 20:43:07 2019 New Revision: 350425 URL: https://svnweb.freebsd.org/changeset/base/350425 Log: printf(1): Note that \c only works in %b strings PR: 238313 Reported by: Andras Farkas MFC after:1 week Modified: head/usr.bin/printf/printf.1 Modified: head/usr.bin/printf/printf.1 == --- head/usr.bin/printf/printf.1Mon Jul 29 20:41:11 2019 (r350424) +++ head/usr.bin/printf/printf.1Mon Jul 29 20:43:07 2019 (r350425) @@ -31,7 +31,7 @@ .\"@(#)printf.18.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 21, 2014 +.Dd July 29, 2019 .Dt PRINTF 1 .Os .Sh NAME @@ -87,8 +87,6 @@ are as follows: Write a character. .It Cm \eb Write a character. -.It Cm \ec -Ignore remaining characters in this string. .It Cm \ef Write a character. .It Cm \en @@ -289,7 +287,12 @@ The permitted escape sequences are slightly different octal escapes are .Cm \e0 Ns Ar num instead of -.Cm \e Ns Ar num . +.Cm \e Ns Ar num +and that an additional escape sequence +.Cm \ec +stops further output from this +.Nm +invocation. .It Cm n$ Allows reordering of the output according to .Ar argument . ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r349974 - head/libexec/rc/rc.d
On Sat, Jul 13, 2019 at 04:07:38PM +, Ian Lepore wrote: > Author: ian > Date: Sat Jul 13 16:07:38 2019 > New Revision: 349974 > URL: https://svnweb.freebsd.org/changeset/base/349974 > Log: > Limit access to system accounting files. > In 2013 the security chapter of the Handbook was updated in r42501 to > suggest limiting access to the system accounting file [*1] by creating the > initial file with a mode of 0600. This was in part based on a discussion in > the forums [*2]. Unfortunately, this advice is overridden by the fact that a > new file is created as part of periodic daily processing, and the file mode > is set by the rc.d/accounting script. > These changes update the accounting script to create the directory with mode > 0750 if it doesn't already exist, and to create the daily file with mode > 0640. This limits write access to root only, read access to root and members > of wheel, and eliminates world access completely. For admins who want to > prevent even members of wheel from accessing the files, the mode of the > /var/account directory can be manually changed to 0700, because the script > never creates or changes that directory if it already exists. I like it. However, the /var/account directory is normally created by mtree: etc/mtree/BSD.var.dist. Perhaps the permissions should be adjusted there as well. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r350116 - head/lib/libc/gen
On Thu, Jul 18, 2019 at 09:41:15PM +, Brooks Davis wrote: > On Thu, Jul 18, 2019 at 09:33:56PM +, Brooks Davis wrote: > > Author: brooks > > Date: Thu Jul 18 21:33:55 2019 > > New Revision: 350116 > > URL: https://svnweb.freebsd.org/changeset/base/350116 > > Log: > > Document that setmode(3) is not thread safe. > > In some circumstances, setmode(3) may call umask(2) twice to retrieve > > the current mode and then restore it. Between calls, the process will > > have a umask of 0. > This race isn't especially serious, since it only occurs when > security.bsd.unprivileged_proc_debug=0, but it's probably something to > fix. The easiest solution would probably be to implement a getumask() > syscall. Or make the KERN_PROC_UMASK sysctl work on the process itself even if security.bsd.unprivileged_proc_debug=0. This security sysctl is currently also lowering security. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r346017 - in head: libexec/rc libexec/rc/rc.d share/man/man5
On Tue, Apr 09, 2019 at 10:24:16PM +0100, Chris Rees wrote: > On 9 April 2019 22:13:29 BST, Chris Rees wrote: > >On 9 April 2019 22:08:35 BST, "Rodney W. Grimes" > > wrote: > >>> On 09/04/2019 20:59, Chris Rees wrote: > >>> > On 9 April 2019 20:55:07 BST, "Rodney W. Grimes" > >> wrote: > >>> >>> On 09/04/2019 21:33, Rodney W. Grimes wrote: > >>> >>>> I think the trigger issue is: > >>> >>>> grep zfs /etc/rc.d/zvol > >>> >>>> rcvar="zfs_enable" > >>> >>>> required_modules="zfs" > >>> >>>> that module requires may be going south with the > >>> >>>> new code when the module is built into the kernel. > >>> >>> Maybe it's because the module's name is zfsctrl (for whatever > >>reason) > >>> >> while the > >>> >>> module file is named zfs.ko. > >>> >> I suspect that could also lead to issues with the new code. > >>> >> It seems to be failing to detect that zfs is infact functional in > >>the > >>> >> kernel, > >>> >> and blindly, or not so blindly, trying to load zfs,ko, which when > >>you > >>> >> build > >>> >> it into the kernel you usually do so without any modules built, > >so > >>> >> there is > >>> >> no /boot/kernel/zfs.ko, and even if you did build it any attempt > >>to > >>> >> load > >>> >> it would return an error. > >>> > Loading with it built in isn't a problem, as I showed earlier. > >>> > Loading when it doesn't exist *is*. > >>> > I'm torn. Either we could revert this, or add a check to the > >>required_modules function instead, which I think is the better solution. > >>> Hang on, > >>> [crees@pegasus]~% sudo kldload -n zfsctrl && echo yes > >>> yes > >>I think your testing the return value of sudo here? > >Sudo returns the child's return value. > Turns out Oliver had also reported this to current@ with a log > https://lists.freebsd.org/pipermail/freebsd-current/2019-April/073148.html > Jilles@, mind if I revert this while I get some testing on this > scenario done? > It seems to me that zfs may not be included in the kernel, just > zfsctrl, or something like that. It seems like kldload -n does not work as expected for zfs, so reverting seems the right approach. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344902 - head/bin/sh/tests/expansion
Author: jilles Date: Thu Mar 7 22:51:58 2019 New Revision: 344902 URL: https://svnweb.freebsd.org/changeset/base/344902 Log: sh/tests: Improve failure messages of expansion/arith15.0 Modified: head/bin/sh/tests/expansion/arith15.0 Modified: head/bin/sh/tests/expansion/arith15.0 == --- head/bin/sh/tests/expansion/arith15.0 Thu Mar 7 22:34:45 2019 (r344901) +++ head/bin/sh/tests/expansion/arith15.0 Thu Mar 7 22:51:58 2019 (r344902) @@ -12,9 +12,9 @@ check() { XXX=-9223372036854775808 check "XXX"-9223372036854775808 check "XXX - 1"9223372036854775807 -check $(($XXX - 1))9223372036854775807 -check $(($XXX - 2))9223372036854775806 -check $((0x8000 == 0x7fff)) \ +check "$XXX - 1" 9223372036854775807 +check "$XXX - 2" 9223372036854775806 +check "0x8000 == 0x7fff" \ 0 exit $((failures != 0)) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r344570 - head/usr.sbin/sysrc
On Tue, Feb 26, 2019 at 04:47:59AM -0800, Rodney W. Grimes wrote: > [ Charset UTF-8 unsupported, converting... ] > > Author: 0mp (ports committer) > > Date: Tue Feb 26 09:28:10 2019 > > New Revision: 344570 > > URL: https://svnweb.freebsd.org/changeset/base/344570 > > Log: > > sysrc.8: Pet igor and mandoc > This only tells the source of why you changed some, > a good commit log entry tells me that, and what it > is that you changed. You normally do not need to > name the file your changed in a commit log as the > log is attached to the file, sometimes it does make > since to mention a file name in a log entry when you > are describing the changes to just that file in a > commit that includes many files. > A better log might of been: > Pet igor and mandoc. Remove unneeded .Li, use .Fx as needed, > escape hard stop, and sort cross references. Naming the affected area, file or directory can be useful to make the commit message understandable outside of its file's context without needing to look at the diff or list of changed files. Even better, there is a convention of making the first line of the commit message a summary. When following this convention, displaying just the first line of each commit's message allows a good overview of recent changes in the whole tree. I'm happy to see that quite a few committers follow this convention. An extended description can follow the summary after an empty line, but I don't think it is necessary for this commit as the information that would be written there is obvious from the diff. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344502 - in head/bin/sh: . tests/execution
Author: jilles Date: Sun Feb 24 21:05:13 2019 New Revision: 344502 URL: https://svnweb.freebsd.org/changeset/base/344502 Log: sh: Add set -o pipefail The pipefail option allows checking the exit status of all commands in a pipeline more easily, at a limited cost of complexity in sh itself. It works similarly to the option in bash, ksh93 and mksh. Like ksh93 and unlike bash and mksh, the state of the option is saved when a pipeline is started. Therefore, even in the case of commands like A | B & a later change of the option does not change the exit status, the same way (A | B) & works. Since SIGPIPE is not handled specially, more work in the script is required for a proper exit status for pipelines containing commands such as head that may terminate successfully without reading all input. This can be something like ( cmd1 r=$? if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then exit 0 else exit "$r" fi ) | head PR: 224270 Relnotes: yes Added: head/bin/sh/tests/execution/pipefail1.0 (contents, props changed) head/bin/sh/tests/execution/pipefail2.42 (contents, props changed) head/bin/sh/tests/execution/pipefail3.42 (contents, props changed) head/bin/sh/tests/execution/pipefail4.42 (contents, props changed) head/bin/sh/tests/execution/pipefail5.42 (contents, props changed) head/bin/sh/tests/execution/pipefail6.42 (contents, props changed) head/bin/sh/tests/execution/pipefail7.0 (contents, props changed) Modified: head/bin/sh/jobs.c head/bin/sh/options.h head/bin/sh/sh.1 head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Sun Feb 24 20:55:00 2019(r344501) +++ head/bin/sh/jobs.c Sun Feb 24 21:05:13 2019(r344502) @@ -105,6 +105,7 @@ struct job { char changed; /* true if status has changed */ char foreground;/* true if running in the foreground */ char remembered;/* true if $! referenced */ + char pipefail; /* pass any non-zero status */ #if JOBS char jobctl;/* job running under job control */ struct job *next; /* job used after this one */ @@ -144,6 +145,7 @@ static void setcurjob(struct job *); static void deljob(struct job *); static struct job *getcurjob(struct job *); #endif +static int getjobstatus(const struct job *); static void printjobcmd(struct job *); static void showjob(struct job *, int); @@ -341,6 +343,20 @@ jobscmd(int argc __unused, char *argv[] __unused) return (0); } +static int getjobstatus(const struct job *jp) +{ + int i, status; + + if (!jp->pipefail) + return (jp->ps[jp->nprocs - 1].status); + for (i = jp->nprocs - 1; i >= 0; i--) { + status = jp->ps[i].status; + if (status != 0) + return (status); + } + return (0); +} + static void printjobcmd(struct job *jp) { @@ -377,7 +393,7 @@ showjob(struct job *jp, int mode) } #endif coredump = ""; - status = jp->ps[jp->nprocs - 1].status; + status = getjobstatus(jp); if (jp->state == 0) { statestr = "Running"; #if JOBS @@ -556,7 +572,7 @@ waitcmdloop(struct job *job) do { if (job != NULL) { if (job->state == JOBDONE) { - status = job->ps[job->nprocs - 1].status; + status = getjobstatus(job); if (WIFEXITED(status)) retval = WEXITSTATUS(status); else @@ -781,6 +797,7 @@ makejob(union node *node __unused, int nprocs) jp->nprocs = 0; jp->foreground = 0; jp->remembered = 0; + jp->pipefail = pipefailflag; #if JOBS jp->jobctl = jobctl; jp->next = NULL; @@ -1076,7 +1093,7 @@ waitforjob(struct job *jp, int *signaled) if (jp->state == JOBSTOPPED) setcurjob(jp); #endif - status = jp->ps[jp->nprocs - 1].status; + status = getjobstatus(jp); if (signaled != NULL) *signaled = WIFSIGNALED(status); /* convert to 8 bits */ Modified: head/bin/sh/options.h == --- head/bin/sh/options.h Sun Feb 24 20:55:00 2019(r344501) +++ head/bin/sh/options.h Sun Feb 24 21:05:13 2019(r344502) @@ -67,9 +67,10 @@ struct shparam { #definePflag optval[17] #definehflag optval[18] #definenologflag optval[19] +#definepipefailflag optval[20] #define NSHORTOPTS 19 -#define NOPTS 20 +#define NOPTS 21 extern char
svn commit: r344306 - head/bin/sh
Author: jilles Date: Tue Feb 19 21:27:30 2019 New Revision: 344306 URL: https://svnweb.freebsd.org/changeset/base/344306 Log: sh: Send normal output from bind builtin to stdout PR: 233343 Submitted by: Yuichiro NAITO (original version) Modified: head/bin/sh/histedit.c head/bin/sh/output.c head/bin/sh/output.h Modified: head/bin/sh/histedit.c == --- head/bin/sh/histedit.c Tue Feb 19 21:22:22 2019(r344305) +++ head/bin/sh/histedit.c Tue Feb 19 21:27:30 2019(r344306) @@ -472,10 +472,31 @@ str_to_event(const char *str, int last) int bindcmd(int argc, char **argv) { + int ret; + FILE *old; + FILE *out; if (el == NULL) error("line editing is disabled"); - return (el_parse(el, argc, __DECONST(const char **, argv))); + + INTOFF; + + out = out1fp(); + if (out == NULL) + error("Out of space"); + + el_get(el, EL_GETFP, 1, ); + el_set(el, EL_SETFP, 1, out); + + ret = el_parse(el, argc, __DECONST(const char **, argv)); + + el_set(el, EL_SETFP, 1, old); + + fclose(out); + + INTON; + + return ret; } #else Modified: head/bin/sh/output.c == --- head/bin/sh/output.cTue Feb 19 21:22:22 2019(r344305) +++ head/bin/sh/output.cTue Feb 19 21:27:30 2019(r344306) @@ -340,6 +340,12 @@ doformat(struct output *dest, const char *f, va_list a } } +FILE * +out1fp(void) +{ + return fwopen(out1, doformat_wr); +} + /* * Version of write which resumes after a signal is caught. */ Modified: head/bin/sh/output.h == --- head/bin/sh/output.hTue Feb 19 21:22:22 2019(r344305) +++ head/bin/sh/output.hTue Feb 19 21:27:30 2019(r344306) @@ -39,6 +39,7 @@ #include #include +#include struct output { char *nextc; @@ -75,6 +76,7 @@ void out1fmt(const char *, ...) __printflike(1, 2); void out2fmt_flush(const char *, ...) __printflike(1, 2); void fmtstr(char *, int, const char *, ...) __printflike(3, 4); void doformat(struct output *, const char *, va_list) __printflike(2, 0); +FILE *out1fp(void); int xwrite(int, const char *, int); #define outc(c, file) ((file)->nextc == (file)->bufend ? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r343981 - in head/bin/sh: . tests/expansion
Author: jilles Date: Sun Feb 10 22:23:05 2019 New Revision: 343981 URL: https://svnweb.freebsd.org/changeset/base/343981 Log: sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) SVN r342880 was designed to fix $((-9223372036854775808)) and things like $((0x8000)) but also broke error detection for values of variables without dollar sign ($((x))). For compatibility, overflow in plain literals continues to be ignored and the value is clamped to the boundary (except 9223372036854775808 which is changed to -9223372036854775808). Reviewed by: se (although he would like error checking to be removed) MFC after:2 weeks X-MFC-with: r342880 Differential Revision:https://reviews.freebsd.org/D18926 Added: head/bin/sh/tests/expansion/arith16.0 (contents, props changed) head/bin/sh/tests/expansion/arith17.0 (contents, props changed) Modified: head/bin/sh/arith_yacc.c head/bin/sh/arith_yacc.h head/bin/sh/arith_yylex.c head/bin/sh/shell.h head/bin/sh/tests/expansion/Makefile Modified: head/bin/sh/arith_yacc.c == --- head/bin/sh/arith_yacc.cSun Feb 10 21:32:39 2019(r343980) +++ head/bin/sh/arith_yacc.cSun Feb 10 22:23:05 2019(r343981) @@ -104,7 +104,7 @@ static arith_t arith_lookupvarint(char *varname) if (str == NULL || *str == '\0') str = "0"; errno = 0; - result = strtoarith_t(str, , 0); + result = strtoarith_t(str, ); if (errno != 0 || *p != '\0') yyerror("variable conversion error"); return result; Modified: head/bin/sh/arith_yacc.h == --- head/bin/sh/arith_yacc.hSun Feb 10 21:32:39 2019(r343980) +++ head/bin/sh/arith_yacc.hSun Feb 10 22:23:05 2019(r343981) @@ -90,4 +90,5 @@ union yystype { extern union yystype yylval; +arith_t strtoarith_t(const char *restrict nptr, char **restrict endptr); int yylex(void); Modified: head/bin/sh/arith_yylex.c == --- head/bin/sh/arith_yylex.c Sun Feb 10 21:32:39 2019(r343980) +++ head/bin/sh/arith_yylex.c Sun Feb 10 22:23:05 2019(r343981) @@ -35,6 +35,8 @@ #include __FBSDID("$FreeBSD$"); +#include +#include #include #include #include @@ -50,6 +52,32 @@ __FBSDID("$FreeBSD$"); #error Arithmetic tokens are out of order. #endif +arith_t +strtoarith_t(const char *restrict nptr, char **restrict endptr) +{ + arith_t val; + + while (isspace((unsigned char)*nptr)) + nptr++; + switch (*nptr) { + case '-': + return strtoimax(nptr, endptr, 0); + case '0': + return (arith_t)strtoumax(nptr, endptr, 0); + default: + val = (arith_t)strtoumax(nptr, endptr, 0); + if (val >= 0) + return val; + else if (val == ARITH_MIN) { + errno = ERANGE; + return ARITH_MIN; + } else { + errno = ERANGE; + return ARITH_MAX; + } + } +} + int yylex(void) { @@ -78,7 +106,7 @@ yylex(void) case '7': case '8': case '9': - yylval.val = strtoarith_t(buf, , 0); + yylval.val = strtoarith_t(buf, ); arith_buf = end; return ARITH_NUM; case 'A': Modified: head/bin/sh/shell.h == --- head/bin/sh/shell.h Sun Feb 10 21:32:39 2019(r343980) +++ head/bin/sh/shell.h Sun Feb 10 22:23:05 2019(r343981) @@ -59,7 +59,6 @@ */ typedef intmax_t arith_t; #defineARITH_FORMAT_STR "%" PRIdMAX -#definestrtoarith_t(nptr, endptr, base) (intmax_t)strtoumax(nptr, endptr, base) #defineARITH_MIN INTMAX_MIN #defineARITH_MAX INTMAX_MAX Modified: head/bin/sh/tests/expansion/Makefile == --- head/bin/sh/tests/expansion/MakefileSun Feb 10 21:32:39 2019 (r343980) +++ head/bin/sh/tests/expansion/MakefileSun Feb 10 22:23:05 2019 (r343981) @@ -22,6 +22,8 @@ ${PACKAGE}FILES+= arith12.0 ${PACKAGE}FILES+= arith13.0 ${PACKAGE}FILES+= arith14.0 ${PACKAGE}FILES+= arith15.0 +${PACKAGE}FILES+= arith16.0 +${PACKAGE}FILES+= arith17.0 ${PACKAGE}FILES+= assign1.0 ${PACKAGE}FILES+= cmdsubst1.0 ${PACKAGE}FILES+= cmdsubst2.0 Added: head/bin/sh/tests/expansion/arith16.0
svn commit: r343922 - head/sbin/dhclient
Author: jilles Date: Fri Feb 8 23:03:28 2019 New Revision: 343922 URL: https://svnweb.freebsd.org/changeset/base/343922 Log: dhclient: Return non-zero status when script exits due to a signal r343896 made it such that a non-zero exit status was passed through, but was still wrong if the script exits on a signal. POSIX does not say what the WEXITSTATUS macro returns in this case and in practice 0 is a common value. Instead, translate the wait status into 8 bits the same way as the shell calculates $?. Reviewed by: kib, Nash Kaminski MFC after:1 week Modified: head/sbin/dhclient/dhclient.c Modified: head/sbin/dhclient/dhclient.c == --- head/sbin/dhclient/dhclient.c Fri Feb 8 22:10:40 2019 (r343921) +++ head/sbin/dhclient/dhclient.c Fri Feb 8 23:03:28 2019 (r343922) @@ -2348,7 +2348,8 @@ priv_script_go(void) if (ip) script_flush_env(ip->client); - return WEXITSTATUS(wstatus); + return (WIFEXITED(wstatus) ? + WEXITSTATUS(wstatus) : 128 + WTERMSIG(wstatus)); } void ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r343896 - head/sbin/dhclient
On Fri, Feb 08, 2019 at 07:36:08AM +, Konstantin Belousov wrote: > Author: kib > Date: Fri Feb 8 07:36:08 2019 > New Revision: 343896 > URL: https://svnweb.freebsd.org/changeset/base/343896 > Log: > Correctly return exit status from the exited process. > This is also OpenBSD rev. 1.117, as pointed out by > Ryan Moeller . > Submitted by: Nash Kaminski > MFC after: 1 week > Modified: > head/sbin/dhclient/dhclient.c > Modified: head/sbin/dhclient/dhclient.c > == > --- head/sbin/dhclient/dhclient.c Fri Feb 8 06:19:28 2019 > (r343895) > +++ head/sbin/dhclient/dhclient.c Fri Feb 8 07:36:08 2019 > (r343896) > @@ -2348,7 +2348,7 @@ priv_script_go(void) > if (ip) > script_flush_env(ip->client); > > - return (wstatus & 0xff); > + return WEXITSTATUS(wstatus); > } > > void This is probably a big improvement in practice, but it is still wrong if the script exits on a signal. POSIX does not say what the WEXITSTATUS macro returns in this case and in practice 0 is a common value. Perhaps you want return WIFEXITED(wstatus) ? WEXITSTATUS(wstatus) : 128 + WTERMSIG(wstatus); imitating what the shell does to translate a wait status into 8 bits? -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r343215 - head/bin/sh
Author: jilles Date: Sun Jan 20 14:25:25 2019 New Revision: 343215 URL: https://svnweb.freebsd.org/changeset/base/343215 Log: sh: Send libedit "ferr" output to fd 2 The libedit "fout" output must be sent to fd 2 since it contains prompts that POSIX says must be sent to fd 2. However, the libedit "ferr" output receives error messages such as from "bind" that make no sense to send to fd 1. Modified: head/bin/sh/histedit.c Modified: head/bin/sh/histedit.c == --- head/bin/sh/histedit.c Sun Jan 20 14:02:54 2019(r343214) +++ head/bin/sh/histedit.c Sun Jan 20 14:25:25 2019(r343215) @@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$"); History *hist; /* history cookie */ EditLine *el; /* editline cookie */ int displayhist; -static FILE *el_in, *el_out, *el_err; +static FILE *el_in, *el_out; static char *fc_replace(const char *, char *, char *); static int not_fcnumber(const char *); @@ -106,18 +106,16 @@ histedit(void) INTOFF; if (el_in == NULL) el_in = fdopen(0, "r"); - if (el_err == NULL) - el_err = fdopen(1, "w"); if (el_out == NULL) el_out = fdopen(2, "w"); - if (el_in == NULL || el_err == NULL || el_out == NULL) + if (el_in == NULL || el_out == NULL) goto bad; term = lookupvar("TERM"); if (term) setenv("TERM", term, 1); else unsetenv("TERM"); - el = el_init(arg0, el_in, el_out, el_err); + el = el_init(arg0, el_in, el_out, el_out); if (el != NULL) { if (hist) el_set(el, EL_HIST, history, hist); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r343105 - head/lib/libedit
Author: jilles Date: Wed Jan 16 21:59:18 2019 New Revision: 343105 URL: https://svnweb.freebsd.org/changeset/base/343105 Log: libedit: Avoid out of bounds read in 'bind' command This is CVS revision 1.31 from NetBSD lib/libedit/chartype.c: Make sure that argv is NULL terminated since functions like tty_stty rely on it to be so (Gerry Swinslow) This broke when the wide-character support was enabled in libedit. The conversion from multibyte to wide-character did not supply the apparently expected terminating NULL in the new argv array. PR: 233343 Submitted by: Yuichiro NAITO Obtained from:NetBSD MFC after:1 week Modified: head/lib/libedit/chartype.c Modified: head/lib/libedit/chartype.c == --- head/lib/libedit/chartype.c Wed Jan 16 21:13:50 2019(r343104) +++ head/lib/libedit/chartype.c Wed Jan 16 21:59:18 2019(r343105) @@ -157,7 +157,7 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1) return NULL; - wargv = el_malloc((size_t)argc * sizeof(*wargv)); + wargv = el_malloc((size_t)(argc + 1) * sizeof(*wargv)); for (i = 0, p = conv->wbuff; i < argc; ++i) { if (!argv[i]) { /* don't pass null pointers to mbstowcs */ @@ -175,6 +175,7 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer bufspace -= (size_t)bytes; p += bytes; } + wargv[i] = NULL; return wargv; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r342817 - head/usr.bin/getconf
Author: jilles Date: Sun Jan 6 21:43:14 2019 New Revision: 342817 URL: https://svnweb.freebsd.org/changeset/base/342817 Log: getconf(1): Minor mdoc fix MFC after:1 week Modified: head/usr.bin/getconf/getconf.1 Modified: head/usr.bin/getconf/getconf.1 == --- head/usr.bin/getconf/getconf.1 Sun Jan 6 21:34:05 2019 (r342816) +++ head/usr.bin/getconf/getconf.1 Sun Jan 6 21:43:14 2019 (r342817) @@ -70,7 +70,7 @@ Otherwise, all system configuration variables are reported using .Xr confstr 3 and -.Xr sysconf 3. +.Xr sysconf 3 . .Pp The second form of the command, with two mandatory arguments, retrieves file- and file system-specific ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r342816 - head/lib/libc/sys
Author: jilles Date: Sun Jan 6 21:34:05 2019 New Revision: 342816 URL: https://svnweb.freebsd.org/changeset/base/342816 Log: thr_wake(2): Minor mdoc fixes MFC after:1 week Modified: head/lib/libc/sys/thr_wake.2 Modified: head/lib/libc/sys/thr_wake.2 == --- head/lib/libc/sys/thr_wake.2Sun Jan 6 21:24:44 2019 (r342815) +++ head/lib/libc/sys/thr_wake.2Sun Jan 6 21:34:05 2019 (r342816) @@ -67,7 +67,7 @@ of that thread in the kernel to fail immediately with .Er EINTR error. The flag is cleared by an interruptible sleep attempt or by a call to -.Xr thr_suspend 2. +.Xr thr_suspend 2 . This is used by the system threading library to implement cancellation. .Pp If @@ -96,7 +96,7 @@ of the calling thread. .El .Sh SEE ALSO .Xr ps 1 , -.Xr thr_self 2 +.Xr thr_self 2 , .Xr thr_suspend 2 , .Xr pthread_cancel 3 , .Xr pthread_resume_np 3 , ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r342740 - head/bin/sh
Author: jilles Date: Thu Jan 3 20:22:35 2019 New Revision: 342740 URL: https://svnweb.freebsd.org/changeset/base/342740 Log: sh: Do not place exported but unset variables into the environment PR: 233545 Submitted by: Jan Beich Obtained from:NetBSD Modified: head/bin/sh/var.c Modified: head/bin/sh/var.c == --- head/bin/sh/var.c Thu Jan 3 19:35:07 2019(r342739) +++ head/bin/sh/var.c Thu Jan 3 20:22:35 2019(r342740) @@ -558,13 +558,13 @@ environment(void) nenv = 0; for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { for (vp = *vpp ; vp ; vp = vp->next) - if (vp->flags & VEXPORT) + if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) nenv++; } ep = env = stalloc((nenv + 1) * sizeof *env); for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { for (vp = *vpp ; vp ; vp = vp->next) - if (vp->flags & VEXPORT) + if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) *ep++ = vp->text; } *ep = NULL; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r342741 - head/bin/sh/tests/execution
Author: jilles Date: Thu Jan 3 20:23:12 2019 New Revision: 342741 URL: https://svnweb.freebsd.org/changeset/base/342741 Log: sh: Add test for exported but unset variables PR: 233545 Added: head/bin/sh/tests/execution/env1.0 (contents, props changed) Modified: head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/tests/execution/Makefile == --- head/bin/sh/tests/execution/MakefileThu Jan 3 20:22:35 2019 (r342740) +++ head/bin/sh/tests/execution/MakefileThu Jan 3 20:23:12 2019 (r342741) @@ -17,6 +17,7 @@ ${PACKAGE}FILES+= bg7.0 ${PACKAGE}FILES+= bg8.0 ${PACKAGE}FILES+= bg9.0 ${PACKAGE}FILES+= bg10.0 bg10.0.stdout +${PACKAGE}FILES+= env1.0 ${PACKAGE}FILES+= fork1.0 ${PACKAGE}FILES+= fork2.0 ${PACKAGE}FILES+= fork3.0 Added: head/bin/sh/tests/execution/env1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/env1.0 Thu Jan 3 20:23:12 2019 (r342741) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +unset somestrangevar +export somestrangevar +[ "`$SH -c 'echo ${somestrangevar-unset}'`" = unset ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r342572 - head/sys/kern
Author: jilles Date: Fri Dec 28 13:32:14 2018 New Revision: 342572 URL: https://svnweb.freebsd.org/changeset/base/342572 Log: pfind, pfind_any: Correct zombie logic SVN r340744 erroneously changed pfind() to return any process including zombies and pfind_any() to return only non-zombie processes. In particular, this caused kill() on a zombie process to fail with [ESRCH]. There is no direct test case for this but /usr/tests/bin/sh/builtins/kill1.0 occasionally triggers it (as reported by lwhsu). Conversely, returning zombies from pfind() seems likely to violate invariants and cause panics, but I have not looked at this. PR: 233646 Reviewed by: mjg, kib, ngie Differential Revision:https://reviews.freebsd.org/D18665 Modified: head/sys/kern/kern_proc.c Modified: head/sys/kern/kern_proc.c == --- head/sys/kern/kern_proc.c Fri Dec 28 10:10:16 2018(r342571) +++ head/sys/kern/kern_proc.c Fri Dec 28 13:32:14 2018(r342572) @@ -388,7 +388,7 @@ _pfind(pid_t pid, bool zombie) if (p->p_pid == pid) { PROC_LOCK(p); if (p->p_state == PRS_NEW || - (zombie && p->p_state == PRS_ZOMBIE)) { + (!zombie && p->p_state == PRS_ZOMBIE)) { PROC_UNLOCK(p); p = NULL; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r341725 - head/bin/sh
Author: jilles Date: Sat Dec 8 12:49:19 2018 New Revision: 341725 URL: https://svnweb.freebsd.org/changeset/base/341725 Log: sh(1): Remove -c string from set builtin documentation Altering the -c string at run time does not make sense and is not possible. MFC after:1 week Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Sat Dec 8 11:38:39 2018(r341724) +++ head/bin/sh/sh.1Sat Dec 8 12:49:19 2018(r341725) @@ -32,7 +32,7 @@ .\"from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd November 27, 2018 +.Dd December 8, 2018 .Dt SH 1 .Os .Sh NAME @@ -2485,8 +2485,8 @@ lines, suitable for re-input to the shell. See the .Sx Functions subsection. -.It Ic set Oo Fl /+abCEefIimnpTuVvx Oc Oo Fl /+o Ar longname Oc Oo -.Fl c Ar string Oc Op Fl - Ar arg ... +.It Ic set Oo Fl /+abCEefIimnpTuVvx Oc Oo Fl /+o Ar longname +.Oc Op Fl - Ar arg ... The .Ic set command performs three different functions: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r341164 - in head/bin/sh: . tests/expansion
Author: jilles Date: Wed Nov 28 20:03:53 2018 New Revision: 341164 URL: https://svnweb.freebsd.org/changeset/base/341164 Log: sh: Fix ${param?} default error message If word in ${param?word} is missing, the shell shall write a default error message. So expanding ${param?} when param is not set should write an error message like sh: param: parameter not set This was broken by r316417. PR: 233585 Added: head/bin/sh/tests/expansion/question2.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/tests/expansion/Makefile Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cWed Nov 28 19:54:02 2018(r341163) +++ head/bin/sh/expand.cWed Nov 28 20:03:53 2018(r341164) @@ -623,10 +623,11 @@ static const char * subevalvar_misc(const char *p, struct nodelist **restrict argbackq, const char *var, int subtype, int startloc, int varflags) { + const char *end; char *startp; int amount; - p = argstr(p, argbackq, EXP_TILDE, NULL); + end = argstr(p, argbackq, EXP_TILDE, NULL); STACKSTRNUL(expdest); startp = stackblock() + startloc; @@ -635,7 +636,7 @@ subevalvar_misc(const char *p, struct nodelist **restr setvar(var, startp, 0); amount = startp - expdest; STADJUST(amount, expdest); - return p; + return end; case VSQUESTION: if (*p != CTLENDVAR) { Modified: head/bin/sh/tests/expansion/Makefile == --- head/bin/sh/tests/expansion/MakefileWed Nov 28 19:54:02 2018 (r341163) +++ head/bin/sh/tests/expansion/MakefileWed Nov 28 20:03:53 2018 (r341164) @@ -86,6 +86,7 @@ ${PACKAGE}FILES+= plus-minus7.0 ${PACKAGE}FILES+= plus-minus8.0 ${PACKAGE}FILES+= plus-minus9.0 ${PACKAGE}FILES+= question1.0 +${PACKAGE}FILES+= question2.0 ${PACKAGE}FILES+= readonly1.0 ${PACKAGE}FILES+= redir1.0 ${PACKAGE}FILES+= set-u1.0 Added: head/bin/sh/tests/expansion/question2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/question2.0 Wed Nov 28 20:03:53 2018 (r341164) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +unset dummyvar +msg=`(: ${dummyvar?}) 2>&1` +r=$? +[ "$r" != 0 ] && case $msg in +*dummyvar?* | *?dummyvar*) : ;; +*) + printf 'Bad message: [%s]\n' "$msg" + exit 1 +esac ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r341097 - in head/bin/sh: . tests/errors
Author: jilles Date: Tue Nov 27 21:49:59 2018 New Revision: 341097 URL: https://svnweb.freebsd.org/changeset/base/341097 Log: sh: Use 126 and 127 exit status for failures opening a script This affects scripts named on the command line, named with a '.' special builtin and found via the PATH %func autoloading mechanism. PR: 231986 Added: head/bin/sh/tests/errors/script-error1.0 (contents, props changed) Modified: head/bin/sh/input.c head/bin/sh/sh.1 head/bin/sh/tests/errors/Makefile Modified: head/bin/sh/input.c == --- head/bin/sh/input.c Tue Nov 27 21:40:51 2018(r341096) +++ head/bin/sh/input.c Tue Nov 27 21:49:59 2018(r341097) @@ -359,12 +359,16 @@ popstring(void) void setinputfile(const char *fname, int push) { + int e; int fd; int fd2; INTOFF; - if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0) - error("cannot open %s: %s", fname, strerror(errno)); + if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0) { + e = errno; + errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126, + "cannot open %s: %s", fname, strerror(e)); + } if (fd < 10) { fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10); close(fd); Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Tue Nov 27 21:40:51 2018(r341096) +++ head/bin/sh/sh.1Tue Nov 27 21:49:59 2018(r341097) @@ -32,7 +32,7 @@ .\"from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd July 19, 2018 +.Dd November 27, 2018 .Dt SH 1 .Os .Sh NAME @@ -2819,7 +2819,11 @@ Shell database. Privileged shell profile. .El .Sh EXIT STATUS -Errors that are detected by the shell, such as a syntax error, will +If the +.Ar script +cannot be found, the exit status will be 127; +if it cannot be opened for another reason, the exit status will be 126. +Other errors that are detected by the shell, such as a syntax error, will cause the shell to exit with a non-zero exit status. If the shell is not an interactive shell, the execution of the shell file will be aborted. Modified: head/bin/sh/tests/errors/Makefile == --- head/bin/sh/tests/errors/Makefile Tue Nov 27 21:40:51 2018 (r341096) +++ head/bin/sh/tests/errors/Makefile Tue Nov 27 21:49:59 2018 (r341097) @@ -30,6 +30,7 @@ ${PACKAGE}FILES+= redirection-error5.0 ${PACKAGE}FILES+= redirection-error6.0 ${PACKAGE}FILES+= redirection-error7.0 ${PACKAGE}FILES+= redirection-error8.0 +${PACKAGE}FILES+= script-error1.0 ${PACKAGE}FILES+= write-error1.0 .include Added: head/bin/sh/tests/errors/script-error1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/errors/script-error1.0Tue Nov 27 21:49:59 2018 (r341097) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +{ stderr=$(${SH} /var/empty/nosuchscript 2>&1 >&3); } 3>&1 +r=$? +[ -n "$stderr" ] && [ "$r" = 127 ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r340284 - head/bin/sh
Author: jilles Date: Fri Nov 9 14:58:24 2018 New Revision: 340284 URL: https://svnweb.freebsd.org/changeset/base/340284 Log: sh: Unify EXERROR and EXEXEC The difference between EXERROR and EXEXEC was that EXEXEC passed along exitstatus and EXERROR set exitstatus to 2 in the handling code. By changing the places that raised EXERROR to set exitstatus to 2, the handling of EXERROR and EXEXEC becomes the same. Modified: head/bin/sh/TOUR head/bin/sh/error.c head/bin/sh/error.h head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/jobs.c head/bin/sh/main.c Modified: head/bin/sh/TOUR == --- head/bin/sh/TOURFri Nov 9 13:47:06 2018(r340283) +++ head/bin/sh/TOURFri Nov 9 14:58:24 2018(r340284) @@ -35,7 +35,7 @@ EXCEPTIONS: Code for dealing with exceptions appears exceptions.c. The C language doesn't include exception handling, so I implement it using setjmp and longjmp. The global variable exception contains the type of exception. EXERROR is raised by -calling error. EXINT is an interrupt. +calling error or errorwithstatus. EXINT is an interrupt. INTERRUPTS: In an interactive shell, an interrupt will cause an EXINT exception to return to the main command loop. (Exception: Modified: head/bin/sh/error.c == --- head/bin/sh/error.c Fri Nov 9 13:47:06 2018(r340283) +++ head/bin/sh/error.c Fri Nov 9 14:58:24 2018(r340284) @@ -67,7 +67,7 @@ volatile sig_atomic_t suppressint; volatile sig_atomic_t intpending; -static void exverror(int, const char *, va_list) __printf0like(2, 0) __dead2; +static void verrorwithstatus(int, const char *, va_list) __printf0like(2, 0) __dead2; /* * Called to raise an exception. Since C doesn't include exceptions, we @@ -154,7 +154,7 @@ warning(const char *msg, ...) * formatting. It then raises the error exception. */ static void -exverror(int cond, const char *msg, va_list ap) +verrorwithstatus(int status, const char *msg, va_list ap) { /* * An interrupt trumps an error. Certain places catch error @@ -168,14 +168,17 @@ exverror(int cond, const char *msg, va_list ap) #ifdef DEBUG if (msg) - TRACE(("exverror(%d, \"%s\") pid=%d\n", cond, msg, getpid())); + TRACE(("verrorwithstatus(%d, \"%s\") pid=%d\n", + status, msg, getpid())); else - TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid())); + TRACE(("verrorwithstatus(%d, NULL) pid=%d\n", + status, getpid())); #endif if (msg) vwarning(msg, ap); flushall(); - exraise(cond); + exitstatus = status; + exraise(EXERROR); } @@ -184,16 +187,16 @@ error(const char *msg, ...) { va_list ap; va_start(ap, msg); - exverror(EXERROR, msg, ap); + verrorwithstatus(2, msg, ap); va_end(ap); } void -exerror(int cond, const char *msg, ...) +errorwithstatus(int status, const char *msg, ...) { va_list ap; va_start(ap, msg); - exverror(cond, msg, ap); + verrorwithstatus(status, msg, ap); va_end(ap); } Modified: head/bin/sh/error.h == --- head/bin/sh/error.h Fri Nov 9 13:47:06 2018(r340283) +++ head/bin/sh/error.h Fri Nov 9 14:58:24 2018(r340284) @@ -55,9 +55,8 @@ extern volatile sig_atomic_t exception; /* exceptions */ #define EXINT 0/* SIGINT received */ -#define EXERROR 1 /* a generic error */ -#define EXEXEC 2 /* command execution failed */ -#define EXEXIT 3 /* call exitshell(exitstatus) */ +#define EXERROR 1 /* a generic error with exitstatus */ +#define EXEXIT 2 /* call exitshell(exitstatus) */ /* @@ -83,7 +82,7 @@ void exraise(int) __dead2; void onint(void) __dead2; void warning(const char *, ...) __printflike(1, 2); void error(const char *, ...) __printf0like(1, 2) __dead2; -void exerror(int, const char *, ...) __printf0like(2, 3) __dead2; +void errorwithstatus(int, const char *, ...) __printf0like(2, 3) __dead2; /* Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Fri Nov 9 13:47:06 2018(r340283) +++ head/bin/sh/eval.c Fri Nov 9 14:58:24 2018(r340284) @@ -466,13 +466,9 @@ evalredir(union node *n, int flags) handler = savehandler; e = exception; popredir(); - if (e == EXERROR || e == EXEXEC) { - if (in_redirect) { - if (e == EXERROR) - exitstatus = 2; - FORCEINTON; - return; -
svn commit: r339822 - head/bin/sh
Author: jilles Date: Sat Oct 27 20:17:57 2018 New Revision: 339822 URL: https://svnweb.freebsd.org/changeset/base/339822 Log: sh: Use exitstatus instead of exerrno to pass EXEXEC status No functional change is intended. Modified: head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/exec.h head/bin/sh/jobs.c head/bin/sh/main.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Sat Oct 27 19:08:06 2018(r339821) +++ head/bin/sh/eval.c Sat Oct 27 20:17:57 2018(r339822) @@ -468,7 +468,8 @@ evalredir(union node *n, int flags) popredir(); if (e == EXERROR || e == EXEXEC) { if (in_redirect) { - exitstatus = 2; + if (e == EXERROR) + exitstatus = 2; FORCEINTON; return; } @@ -669,8 +670,10 @@ evalbackcmd(union node *n, struct backcmd *result) forcelocal++; savehandler = handler; if (setjmp(jmploc.loc)) { - if (exception == EXERROR || exception == EXEXEC) + if (exception == EXERROR) exitstatus = 2; + else if (exception == EXEXEC) + /* nothing */; else if (exception != 0) { handler = savehandler; forcelocal--; @@ -1089,7 +1092,7 @@ evalcommand(union node *cmd, int flags, struct backcmd e = exception; if (e == EXINT) exitstatus = SIGINT+128; - else if (e != EXEXIT) + else if (e != EXEXEC && e != EXEXIT) exitstatus = 2; goto cmddone; } Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Sat Oct 27 19:08:06 2018(r339821) +++ head/bin/sh/exec.c Sat Oct 27 20:17:57 2018(r339822) @@ -91,7 +91,6 @@ struct tblentry { static struct tblentry *cmdtable[CMDTABLESIZE]; static int cmdtable_cd = 0;/* cmdtable contains cd-dependent entries */ -int exerrno = 0; /* Last exec error */ static void tryexec(char *, char **, char **); @@ -135,10 +134,10 @@ shellexec(char **argv, char **envp, const char *path, /* Map to POSIX errors */ if (e == ENOENT || e == ENOTDIR) { - exerrno = 127; + exitstatus = 127; exerror(EXEXEC, "%s: not found", argv[0]); } else { - exerrno = 126; + exitstatus = 126; exerror(EXEXEC, "%s: %s", argv[0], strerror(e)); } } Modified: head/bin/sh/exec.h == --- head/bin/sh/exec.h Sat Oct 27 19:08:06 2018(r339821) +++ head/bin/sh/exec.h Sat Oct 27 20:17:57 2018(r339822) @@ -61,8 +61,6 @@ struct cmdentry { #define DO_ERR 0x01/* prints errors */ #define DO_NOFUNC 0x02/* don't return shell functions, for command */ -extern int exerrno;/* last exec error */ - void shellexec(char **, char **, const char *, int) __dead2; char *padvance(const char **, const char **, const char *); void find_command(const char *, struct cmdentry *, int, const char *); Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Sat Oct 27 19:08:06 2018(r339821) +++ head/bin/sh/jobs.c Sat Oct 27 20:17:57 2018(r339822) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "var.h" #include "builtins.h" +#include "eval.h" /* @@ -1005,7 +1006,7 @@ vforkexecshell(struct job *jp, char **argv, char **env if (pid == 0) { TRACE(("Child shell %d\n", (int)getpid())); if (setjmp(jmploc.loc)) - _exit(exception == EXEXEC ? exerrno : 2); + _exit(exception == EXEXEC ? exitstatus : 2); if (pip != NULL) { close(pip[0]); if (pip[1] != 1) { Modified: head/bin/sh/main.c == --- head/bin/sh/main.c Sat Oct 27 19:08:06 2018(r339821) +++ head/bin/sh/main.c Sat Oct 27 20:17:57 2018(r339822) @@ -106,10 +106,6 @@ main(int argc, char *argv[]) state = 0; if (setjmp(main_handler.loc)) { switch (exception) { - case EXEXEC: - exitstatus = exerrno; - break;
svn commit: r338473 - head/bin/sh
Author: jilles Date: Wed Sep 5 19:16:09 2018 New Revision: 338473 URL: https://svnweb.freebsd.org/changeset/base/338473 Log: sh: Fix formal overflow in pointer arithmetic The intention is to lower the value of the pointer, which according to ubsan cannot be done by adding an unsigned quantity. Reported by: kevans Approved by: re (kib) MFC after:1 week Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cWed Sep 5 19:05:30 2018(r338472) +++ head/bin/sh/expand.cWed Sep 5 19:16:09 2018(r338473) @@ -896,7 +896,7 @@ reprocess(int startloc, int flag, int subtype, int quo startp = stackblock() + startloc; len = expdest - startp; - if (len >= SIZE_MAX / 2) + if (len >= SIZE_MAX / 2 || len > PTRDIFF_MAX) abort(); INTOFF; if (len >= buflen) { @@ -912,7 +912,7 @@ reprocess(int startloc, int flag, int subtype, int quo INTON; memcpy(buf, startp, len); buf[len] = '\0'; - STADJUST(-len, expdest); + STADJUST(-(ptrdiff_t)len, expdest); for (zpos = 0;;) { zlen = strlen(buf + zpos); strtodest(buf + zpos, flag, subtype, quoted, dst); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r337728 - head/usr.bin/printf/tests
Author: jilles Date: Mon Aug 13 21:54:27 2018 New Revision: 337728 URL: https://svnweb.freebsd.org/changeset/base/337728 Log: printf: Add test for width and precision in %b format PR: 229641 Submitted by: pfg Added: head/usr.bin/printf/tests/regress.bwidth.out (contents, props changed) Modified: head/usr.bin/printf/tests/Makefile head/usr.bin/printf/tests/regress.sh Modified: head/usr.bin/printf/tests/Makefile == --- head/usr.bin/printf/tests/Makefile Mon Aug 13 21:53:18 2018 (r337727) +++ head/usr.bin/printf/tests/Makefile Mon Aug 13 21:54:27 2018 (r337728) @@ -5,6 +5,7 @@ PACKAGE=tests TAP_TESTS_SH= legacy_test ${PACKAGE}FILES+= regress.b.out +${PACKAGE}FILES+= regress.bwidth.out ${PACKAGE}FILES+= regress.d.out ${PACKAGE}FILES+= regress.f.out ${PACKAGE}FILES+= regress.l1.out Added: head/usr.bin/printf/tests/regress.bwidth.out == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/printf/tests/regress.bwidth.outMon Aug 13 21:54:27 2018(r337728) @@ -0,0 +1 @@ + a Modified: head/usr.bin/printf/tests/regress.sh == --- head/usr.bin/printf/tests/regress.shMon Aug 13 21:53:18 2018 (r337727) +++ head/usr.bin/printf/tests/regress.shMon Aug 13 21:54:27 2018 (r337728) @@ -2,7 +2,7 @@ REGRESSION_START($1) -echo '1..23' +echo '1..24' REGRESSION_TEST(`b', `printf "abc%b%b" "def\n" "\cghi"') REGRESSION_TEST(`d', `printf "%d,%5d,%.5d,%0*d,%.*d\n" 123 123 123 5 123 5 123') @@ -27,5 +27,6 @@ REGRESSION_TEST(`missingpos1', `printf "%*.*1\$s" 1 1 REGRESSION_TEST(`missingpos1', `printf "%1\$*2\$.*s" 1 1 1 2>&1') REGRESSION_TEST(`missingpos1', `printf "%*1\$.*2\$s" 1 1 1 2>&1') REGRESSION_TEST(`missingpos1', `printf "%1\$*.*2\$s" 1 1 1 2>&1') +REGRESSION_TEST(`bwidth', `printf "%8.2b" "a\nb\n"') REGRESSION_END() ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r337618 - head/usr.bin/printf
Author: jilles Date: Sat Aug 11 11:13:34 2018 New Revision: 337618 URL: https://svnweb.freebsd.org/changeset/base/337618 Log: printf: Fix \c in %b in printf builtin exiting the shell after r337458 SVN r337458 erroneously partially reverted r265885. This is immediately visible when running the Kyua/ATF tests for usr.bin/printf, which actually test sh's printf builtin. PR: 229641 Modified: head/usr.bin/printf/printf.c Modified: head/usr.bin/printf/printf.c == --- head/usr.bin/printf/printf.cSat Aug 11 11:05:22 2018 (r337617) +++ head/usr.bin/printf/printf.cSat Aug 11 11:13:34 2018 (r337618) @@ -388,7 +388,7 @@ printf_doformat(char *fmt, int *rval) free(p); if (getout) - exit(*rval); + return (end_fmt); break; } case 'c': { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r336320 - in head/bin/sh: . tests/builtins
Author: jilles Date: Sun Jul 15 21:55:17 2018 New Revision: 336320 URL: https://svnweb.freebsd.org/changeset/base/336320 Log: sh: Don't treat % specially in CDPATH Added: head/bin/sh/tests/builtins/cd11.0 (contents, props changed) Modified: head/bin/sh/cd.c head/bin/sh/exec.c head/bin/sh/exec.h head/bin/sh/main.c head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/cd.c == --- head/bin/sh/cd.cSun Jul 15 21:10:19 2018(r336319) +++ head/bin/sh/cd.cSun Jul 15 21:55:17 2018(r336320) @@ -120,7 +120,7 @@ cdcmd(int argc __unused, char **argv __unused) (dest[0] == '.' && dest[1] == '.' && (dest[2] == '/' || dest[2] == '\0')) || (path = bltinlookup("CDPATH", 1)) == NULL) path = ""; - while ((p = padvance(, dest)) != NULL) { + while ((p = padvance(, NULL, dest)) != NULL) { if (stat(p, ) < 0) { if (errno != ENOENT) errno1 = errno; Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Sun Jul 15 21:10:19 2018(r336319) +++ head/bin/sh/exec.c Sun Jul 15 21:55:17 2018(r336320) @@ -113,6 +113,7 @@ void shellexec(char **argv, char **envp, const char *path, int idx) { char *cmdname; + const char *opt; int e; if (strchr(argv[0], '/') != NULL) { @@ -120,8 +121,8 @@ shellexec(char **argv, char **envp, const char *path, e = errno; } else { e = ENOENT; - while ((cmdname = padvance(, argv[0])) != NULL) { - if (--idx < 0 && pathopt == NULL) { + while ((cmdname = padvance(, , argv[0])) != NULL) { + if (--idx < 0 && opt == NULL) { tryexec(cmdname, argv, envp); if (errno != ENOENT && errno != ENOTDIR) e = errno; @@ -174,16 +175,14 @@ tryexec(char *cmd, char **argv, char **envp) * Do a path search. The variable path (passed by reference) should be * set to the start of the path before the first call; padvance will update * this value as it proceeds. Successive calls to padvance will return - * the possible path expansions in sequence. If an option (indicated by - * a percent sign) appears in the path entry then the global variable - * pathopt will be set to point to it; otherwise pathopt will be set to - * NULL. + * the possible path expansions in sequence. If popt is not NULL, options + * are processed: if an option (indicated by a percent sign) appears in + * the path entry then *popt will be set to point to it; else *popt will be + * set to NULL. If popt is NULL, percent signs are not special. */ -const char *pathopt; - char * -padvance(const char **path, const char *name) +padvance(const char **path, const char **popt, const char *name) { const char *p, *start; char *q; @@ -192,8 +191,12 @@ padvance(const char **path, const char *name) if (*path == NULL) return NULL; start = *path; - for (p = start; *p && *p != ':' && *p != '%'; p++) - ; /* nothing */ + if (popt != NULL) + for (p = start; *p && *p != ':' && *p != '%'; p++) + ; /* nothing */ + else + for (p = start; *p && *p != ':'; p++) + ; /* nothing */ namelen = strlen(name); len = p - start + namelen + 2; /* "2" is for '/' and '\0' */ STARTSTACKSTR(q); @@ -204,10 +207,12 @@ padvance(const char **path, const char *name) *q++ = '/'; } memcpy(q, name, namelen + 1); - pathopt = NULL; - if (*p == '%') { - pathopt = ++p; - while (*p && *p != ':') p++; + if (popt != NULL) { + if (*p == '%') { + *popt = ++p; + while (*p && *p != ':') p++; + } else + *popt = NULL; } if (*p == ':') *path = p + 1; @@ -277,14 +282,14 @@ static void printentry(struct tblentry *cmdp, int verbose) { int idx; - const char *path; + const char *path, *opt; char *name; if (cmdp->cmdtype == CMDNORMAL) { idx = cmdp->param.index; path = pathval(); do { - name = padvance(, cmdp->cmdname); + name = padvance(, , cmdp->cmdname); stunalloc(name); } while (--idx >= 0); out1str(name); @@ -321,6 +326,7 @@ find_command(const char *name, struct cmdentry *entry, { struct tblentry *cmdp, loc_cmd; int idx; + const char *opt; char
svn commit: r336303 - head/bin/sh
Author: jilles Date: Sun Jul 15 09:14:30 2018 New Revision: 336303 URL: https://svnweb.freebsd.org/changeset/base/336303 Log: sh: Don't use padvance() for MAIL/MAILPATH Using padvance() requires undoing its append of '/' and prevents adjusting its '%' logic to allow most directories with '%' in PATH. No functional change is intended. Modified: head/bin/sh/mail.c Modified: head/bin/sh/mail.c == --- head/bin/sh/mail.c Sun Jul 15 05:29:39 2018(r336302) +++ head/bin/sh/mail.c Sun Jul 15 09:14:30 2018(r336303) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); */ #include "shell.h" -#include "exec.h" /* defines padvance() */ #include "mail.h" #include "var.h" #include "output.h" @@ -72,9 +71,9 @@ void chkmail(int silent) { int i; - const char *mpath; + char *mpath; char *p; - char *q; + char *msg; struct stackmark smark; struct stat statb; @@ -83,22 +82,25 @@ chkmail(int silent) if (nmboxes == 0) return; setstackmark(); - mpath = mpathset()? mpathval() : mailval(); + mpath = stsavestr(mpathset()? mpathval() : mailval()); for (i = 0 ; i < nmboxes ; i++) { - p = padvance(, ""); - if (p == NULL) - break; + p = mpath; if (*p == '\0') - continue; - for (q = p ; *q ; q++); - if (q[-1] != '/') - abort(); - q[-1] = '\0'; /* delete trailing '/' */ + break; + mpath = strchrnul(mpath, ':'); + if (*mpath != '\0') { + *mpath++ = '\0'; + if (p == mpath - 1) + continue; + } + msg = strchr(p, '%'); + if (msg != NULL) + *msg++ = '\0'; #ifdef notdef /* this is what the System V shell claims to do (it lies) */ if (stat(p, ) < 0) statb.st_mtime = 0; if (statb.st_mtime > mailtime[i] && ! silent) { - out2str(pathopt? pathopt : "you have mail"); + out2str(msg? msg : "you have mail"); out2c('\n'); } mailtime[i] = statb.st_mtime; @@ -106,7 +108,7 @@ chkmail(int silent) if (stat(p, ) < 0) statb.st_size = 0; if (statb.st_size > mailtime[i] && ! silent) { - out2str(pathopt? pathopt : "you have mail"); + out2str(msg? msg : "you have mail"); out2c('\n'); } mailtime[i] = statb.st_size; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r335836 - head/usr.bin/top
On Tue, Jul 03, 2018 at 02:09:56AM +0900, Hiroki Sato wrote: > 後藤大地 wrote > in <459bd898-8072-426e-a968-96c1382ac...@icloud.com>: > da> > 2018/07/02 15:55、Hiroki Sato のメール: > da> > Eitan Adler wrote > da> > in > : > da> > li> On 1 July 2018 at 10:08, Conrad Meyer wrote: > da> > li> > I don't think code to decode UTF-8 belongs in top(1). I don't > know > da> > li> > what the goal of this routine is, but I doubt this is the right > way to > da> > li> > accomplish it. > da> > li> > da> > li> For the record, I agree. This is why I didn't click "accept" on the > da> > li> revision. I don't fully oppose leaving it in top(1) for now as we > work > da> > li> out the API, but long term its the wrong place. > da> > li> > da> > li> https://reviews.freebsd.org/D16058 is the review. > da> > I strongly object this kind of encoding-specific routine. Please > da> > back out it. The problem is that top(1) does not support multibyte > da> > encoding in functions for printing, and using C99 wide/multibyte > da> > character manipulation API such as iswprint(3) is the way to solve > da> > it. Doing getenv("LANG") and assuming an encoding based on it is a > da> > very bad practice to internationalize software. > da> I respect what you mean. > da> Once I back out, I will begin implementing it in a different way. > da> Please advise which function should be used for implementation > da> (iswprint (3) and what other functions should be used?) > Roughly speaking, POSIX/XPG/C99 I18N model requires the following > steps: > 1. Call setlocale(LC_ALL, "") first. > 2. Use mbs<->wcs and/or mb<->wc conversion functions in C95/C99 to > manipulate characters and strings depending on what you want to > do. The printable() function should use mbtowc(3) and > iswprint(3), for example. And wcslen(3) should be used to > determine the length of characters to be printed instead of > strlen(). > Note that if mbs->wcs or mb->wc conversion fails with EILSEQ at > some point, some of the character(s) are invalid for printing. > This can happen because command-line parameters in top(1) are not > always encoded in one specified in LC_CTYPE or LANG. It should > also be handled as non-printable. However, to make matters worse, > each process does not always use a single, same locale as top(1). > A process invoked with LANG=ja_JP.eucJP may have EUC-JP characters > in its ARGV array even if top(1) runs by another user whose LANG > is en_US.UTF-8. You have to determine which locale should be used > before doing mb->wc conversion. It is not so simple. > 3. Print the multibyte characters by using strvisx(3) family, which > supports multibyte character, or swprintf(3) family if you want to > format wide characters directly. Note that buffer length for > strvisx(3) must be calculated by using MB_LEN_MAX. In this case, calling setlocale() and then using strvisx() seems the right solution. If locales differ across processes this may result in mojibake but that cannot really be helped. Even analyzing other processes' locale variables is not fully reliable, since strings may be incorrectly encoded even in the process's real locale, environment variables cannot be read across users and the environment block may be overwritten by a program. In general, although using conversion to wide characters allows users a lot of flexibility, I don't think it is the best in all situations: * The result of mbstowcs() is a UTF-32 string which consumes a lot of memory. A loop with mbrtowc() may also be slow. Many operations can be done directly on UTF-8 strings with no or little additional complexity compared to byte strings. * If there is an invalid multibyte character, there is little flexibility to handle this usefully and securely, since so little is known about the encoding. The best handling may depend on the context. Therefore, in /bin/sh, I have only implemented multibyte support for UTF-8. All other encodings have bytes treated as characters. However, I do agree that getenv("LANG") is bad. Instead, setlocale() should be used. After that, nl_langinfo(CODESET) can be called and the result compared to "UTF-8". -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r335905 - head/usr.bin/rup
Author: jilles Date: Tue Jul 3 19:09:46 2018 New Revision: 335905 URL: https://svnweb.freebsd.org/changeset/base/335905 Log: rup: Fix -Wcast-align warnings Fix possible strict aliasing issue (if time_t is the same size as int but not int but for example long) which also resulted in a false positive warning on systems with 64-bit time_t. Pointer casts are bad; we can just copy the time_t. Elsewhere, avoid casting char * to int * by using memcpy(). Reviewed by: eadler Differential Revision:https://reviews.freebsd.org/D16075 Modified: head/usr.bin/rup/Makefile head/usr.bin/rup/rup.c Modified: head/usr.bin/rup/Makefile == --- head/usr.bin/rup/Makefile Tue Jul 3 18:45:04 2018(r335904) +++ head/usr.bin/rup/Makefile Tue Jul 3 19:09:46 2018(r335905) @@ -4,6 +4,4 @@ PROG= rup LIBADD=rpcsvc -NO_WCAST_ALIGN=# Size is explicitly handled - .include Modified: head/usr.bin/rup/rup.c == --- head/usr.bin/rup/rup.c Tue Jul 3 18:45:04 2018(r335904) +++ head/usr.bin/rup/rup.c Tue Jul 3 19:09:46 2018(r335905) @@ -120,27 +120,16 @@ rstat_reply(statstime *host_stat, struct sockaddr_in * printf("%-*s\t", HOST_WIDTH, host); - if (sizeof(time_t) == sizeof(host_stat->curtime.tv_sec)) { - tmp_time = localtime((time_t *)_stat->curtime.tv_sec); - host_time = *tmp_time; + tmp_time_t = host_stat->curtime.tv_sec; + tmp_time = localtime(_time_t); + host_time = *tmp_time; - host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; + host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; - tmp_time = gmtime((time_t *)_stat->curtime.tv_sec); - host_uptime = *tmp_time; - } - else { /* non-32-bit time_t */ - tmp_time_t = host_stat->curtime.tv_sec; - tmp_time = localtime(_time_t); - host_time = *tmp_time; + tmp_time_t = host_stat->curtime.tv_sec; + tmp_time = gmtime(_time_t); + host_uptime = *tmp_time; - host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; - - tmp_time_t = host_stat->curtime.tv_sec; - tmp_time = gmtime(_time_t); - host_uptime = *tmp_time; - } - #define updays (host_stat->curtime.tv_sec / 86400) if (host_uptime.tm_yday != 0) sprintf(days_buf, "%3d day%s, ", updays, @@ -205,7 +194,7 @@ onehost(char *host) return(-1); } - addr.sin_addr.s_addr = *(int *)hp->h_addr; + memcpy(_addr.s_addr, hp->h_addr, sizeof(int)); rstat_reply(_stat, ); clnt_destroy(rstat_clnt); return (0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r335041 - head/lib/libc/stdlib
On Wed, Jun 13, 2018 at 08:03:13PM +1000, Bruce Evans wrote: > On Wed, 13 Jun 2018, Eitan Adler wrote: > > Log: > > libc: remove explicit cast NULL in atoi > > There isn't any reason to cast NULL so just remove it. Noticed when > > cleaning up top. > There are many reasons to cast NULL for all members of the ato*() family: > - it is required if no prototype is in scope > - C99 specifies ato*() in terms of strtol*() and uses the cast to NULL, >probably because this is simplest. Omitting the cast is just wrong >if no prototype is in scope. Writing the explicit cast is simpler than >writing caveats that the stated equivalence is only valid if a prototype >is in scope. > - POSIX specifies ato*() in terms of strtol*() and uses the cast to NULL, >exactly as in C99, probably because it defers to the C standard and >doesn't and doesn't risk breaking it by changing its wording except when >extending it. These reasons can be summarized to a single reason: the cast is required if no prototype is in scope. I think it is unwise to call any function without a prototype in scope, since this runs a risk of undefined behaviour if you get the types wrong. For the code in libc, we ensure a prototype is in scope and no cast is required. For the code in the man page, I doubt we should allow for programmers that play tricks by declaring system functions manually using K declarations or (even worse) call functions without declaring them at all. Note that NULL may still need a cast when passed to a function with variable number of parameters. Ideally these types are also checked using attributes. > FreeBSD used to do the same here, and should do the same here and > elsewhere by copying better wording from POSIX whenever possible. For some reason, the FreeBSD text does not have the exception about error handling. This exception permits an implementation like musl's which calculates using int and hard-codes base 10, even if the compiler documents a cast from long to int as truncating bits. I don't think we should take advantage of this, though, since making atoi() faster than strtol() may encourage people to use atoi(). -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r334008 - head/bin/sh
On Tue, May 22, 2018 at 10:17:41AM +0200, O. Hartmann wrote: > On Mon, 21 May 2018 21:45:53 -0700 > Cy Schubert <cy.schub...@cschubert.com> wrote: > > In message <20180522061339.21497...@freyja.zeit4.iv.bundesimmobilien.de> > > , "O. H > > artmann" writes: > > > On Mon, 21 May 2018 21:52:48 + (UTC) > > > Jilles Tjoelker <jil...@freebsd.org> wrote: > > > > Author: jilles > > > > Date: Mon May 21 21:52:48 2018 > > > > New Revision: 334008 > > > > URL: https://svnweb.freebsd.org/changeset/base/334008 > > > > Log: > > > > sh: Split CNL syntax category to avoid a check on state[level].syntax > > > > No functional change is intended. > > > > Modified: > > > > head/bin/sh/mksyntax.c > > > > head/bin/sh/parser.c > [snip] > > > Have this been tested? Doesn't compile for me: > > > [...] > > > Building /usr/obj/usr/src/amd64.amd64/kerberos5/libexec/hprop/hprop > > > --- all_subdir_rescue --- > > > --- parser.o --- > > > /usr/src/bin/sh/parser.c:1440:9: error: use of undeclared identifier > > > 'CQNL' > > > case CQNL: > > > ^ > > > --- all_subdir_gnu --- > > > Building > > > /usr/obj/usr/src/amd64.amd64/gnu/usr.bin/gdb/libgdb/amd64bsd-nat.o > > > --- all_subdir_rescue --- > > > 1 error generated. > > > *** [parser.o] Error code 1 > > > make[6]: stopped in /usr/src/bin/sh > > CQNL is defined in /usr/obj/opt/src/svn-current/amd64.amd64/bin/sh/synta > > x.h, generated by mksyntax. > > slippy$ ag -s CQNL /export/obj/opt/src/svn-current/amd64.amd64/bin/sh/*. > > h > > /export/obj/opt/src/svn-current/amd64.amd64/bin/sh/syntax.h > > 11:#define CQNL 2 /* newline character in quotes */ > > slippy$ > > Remove the file if it's not defined in your syntax.h. > > Just out of interest, do you use meta mode? > I think such a question is of common interest if errors/bugs like that occur: > Yes, I use/compile world/kernel with META mode. The change itself is fine. It built for me and for Jenkins (ci.freebsd.org). What is not fine is an incremental build with meta mode. Apparently, the syntax.h: .NOMETA rule added in r301285 causes bmake to build some files against the old syntax.h, even though syntax.c and syntax.h will be rebuilt. To fix this, it may be possible to generate a meta file for syntax.h based on the one for syntax.c. The same would be done for builtins.[ch] and nodes.[ch]. Conceptually simpler is accepting what make would like: one command generates one file only. This is not really new with meta mode since a somewhat ugly .ORDER declaration had been necessary before. The .c content can go inside a #ifdef in the .h file so the .c file need not be autogenerated, or the tools can be run twice, once to generate the .c file and once to generate the .h file. In both cases, the tools will be somewhat uglier in order to simplify the build system. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r334008 - head/bin/sh
Author: jilles Date: Mon May 21 21:52:48 2018 New Revision: 334008 URL: https://svnweb.freebsd.org/changeset/base/334008 Log: sh: Split CNL syntax category to avoid a check on state[level].syntax No functional change is intended. Modified: head/bin/sh/mksyntax.c head/bin/sh/parser.c Modified: head/bin/sh/mksyntax.c == --- head/bin/sh/mksyntax.c Mon May 21 21:44:47 2018(r334007) +++ head/bin/sh/mksyntax.c Mon May 21 21:52:48 2018(r334008) @@ -65,6 +65,7 @@ struct synclass { static const struct synclass synclass[] = { { "CWORD", "character is nothing special" }, { "CNL","newline character" }, + { "CQNL", "newline character in quotes" }, { "CBACK", "a backslash character" }, { "CSBACK", "a backslash character in single quotes" }, { "CSQUOTE","single quote" }, @@ -185,7 +186,7 @@ main(int argc __unused, char **argv __unused) fputs("\n/* syntax table used when in double quotes */\n", cfile); init("dqsyntax"); add_default(); - add("\n", "CNL"); + add("\n", "CQNL"); add("\\", "CBACK"); add("\"", "CENDQUOTE"); add("`", "CBQUOTE"); @@ -198,7 +199,7 @@ main(int argc __unused, char **argv __unused) fputs("\n/* syntax table used when in single quotes */\n", cfile); init("sqsyntax"); add_default(); - add("\n", "CNL"); + add("\n", "CQNL"); add("\\", "CSBACK"); add("'", "CENDQUOTE"); /* ':/' for tilde expansion, '-^]' for [a\-x] pattern ranges */ @@ -208,7 +209,7 @@ main(int argc __unused, char **argv __unused) fputs("\n/* syntax table used when in arithmetic */\n", cfile); init("arisyntax"); add_default(); - add("\n", "CNL"); + add("\n", "CQNL"); add("\\", "CBACK"); add("`", "CBQUOTE"); add("\"", "CIGN"); Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cMon May 21 21:44:47 2018(r334007) +++ head/bin/sh/parser.cMon May 21 21:52:48 2018(r334008) @@ -1434,9 +1434,10 @@ readtoken1(int firstc, char const *initialsyntax, cons switch(synentry) { case CNL: /* '\n' */ - if (level == 0 && - state[level].syntax == BASESYNTAX) + if (level == 0) goto endword; /* exit outer loop */ + /* FALLTHROUGH */ + case CQNL: USTPUTC(c, out); plinno++; if (doprompt) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r333927 - in head/bin/sh: . tests/expansion
Author: jilles Date: Sun May 20 17:25:52 2018 New Revision: 333927 URL: https://svnweb.freebsd.org/changeset/base/333927 Log: sh: Allow unquoted newlines in word in ${param+word} etc. POSIX requires accepting unquoted newlines in word in parameter expansions like ${param+word}, ${param#word}, although the Bourne shell did not support it, it is not commonly used and might make it harder to find a missing closing brace. It was also strange that something like foo="${bar# }" was rejected. Reported by: Martijn Dekker via Robert Elz Added: head/bin/sh/tests/expansion/plus-minus9.0 (contents, props changed) head/bin/sh/tests/expansion/trim10.0 (contents, props changed) head/bin/sh/tests/expansion/trim11.0 (contents, props changed) Modified: head/bin/sh/parser.c head/bin/sh/tests/expansion/Makefile Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cSun May 20 16:03:21 2018(r333926) +++ head/bin/sh/parser.cSun May 20 17:25:52 2018(r333927) @@ -1434,7 +1434,8 @@ readtoken1(int firstc, char const *initialsyntax, cons switch(synentry) { case CNL: /* '\n' */ - if (state[level].syntax == BASESYNTAX) + if (level == 0 && + state[level].syntax == BASESYNTAX) goto endword; /* exit outer loop */ USTPUTC(c, out); plinno++; Modified: head/bin/sh/tests/expansion/Makefile == --- head/bin/sh/tests/expansion/MakefileSun May 20 16:03:21 2018 (r333926) +++ head/bin/sh/tests/expansion/MakefileSun May 20 17:25:52 2018 (r333927) @@ -84,6 +84,7 @@ ${PACKAGE}FILES+= plus-minus5.0 ${PACKAGE}FILES+= plus-minus6.0 ${PACKAGE}FILES+= plus-minus7.0 ${PACKAGE}FILES+= plus-minus8.0 +${PACKAGE}FILES+= plus-minus9.0 ${PACKAGE}FILES+= question1.0 ${PACKAGE}FILES+= readonly1.0 ${PACKAGE}FILES+= redir1.0 @@ -101,5 +102,7 @@ ${PACKAGE}FILES+= trim6.0 ${PACKAGE}FILES+= trim7.0 ${PACKAGE}FILES+= trim8.0 ${PACKAGE}FILES+= trim9.0 +${PACKAGE}FILES+= trim10.0 +${PACKAGE}FILES+= trim11.0 .include Added: head/bin/sh/tests/expansion/plus-minus9.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/plus-minus9.0 Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +a=1 +b=${a+ +} +n=' +' +[ "$b" = "$n" ] Added: head/bin/sh/tests/expansion/trim10.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/trim10.0Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +a='z +' +b=${a% +} +[ "$b" = z ] Added: head/bin/sh/tests/expansion/trim11.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/trim11.0Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +a='z +' +b="${a% +}" +[ "$b" = z ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r333507 - head/bin/sh/tests/parser
Author: jilles Date: Fri May 11 21:56:01 2018 New Revision: 333507 URL: https://svnweb.freebsd.org/changeset/base/333507 Log: sh: Test that backslash-newline within single-quotes is not special This works correctly, but the test may be helpful when modifying the parser. Added: head/bin/sh/tests/parser/line-cont12.0 (contents, props changed) Modified: head/bin/sh/tests/parser/Makefile Modified: head/bin/sh/tests/parser/Makefile == --- head/bin/sh/tests/parser/Makefile Fri May 11 21:46:53 2018 (r333506) +++ head/bin/sh/tests/parser/Makefile Fri May 11 21:56:01 2018 (r333507) @@ -74,6 +74,7 @@ ${PACKAGE}FILES+= line-cont8.0 ${PACKAGE}FILES+= line-cont9.0 ${PACKAGE}FILES+= line-cont10.0 ${PACKAGE}FILES+= line-cont11.0 +${PACKAGE}FILES+= line-cont12.0 ${PACKAGE}FILES+= no-space1.0 ${PACKAGE}FILES+= no-space2.0 ${PACKAGE}FILES+= nul1.0 Added: head/bin/sh/tests/parser/line-cont12.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/parser/line-cont12.0 Fri May 11 21:56:01 2018 (r333507) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +[ '\ +' = "\\ +" ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r333092 - in head/bin/sh: . tests/builtins
Author: jilles Date: Sun Apr 29 17:46:08 2018 New Revision: 333092 URL: https://svnweb.freebsd.org/changeset/base/333092 Log: sh: Don't have [ match any [[:class:]] Submitted by: Robert Elz MFC after:3 days Added: head/bin/sh/tests/builtins/case23.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cSun Apr 29 12:43:08 2018(r333091) +++ head/bin/sh/expand.cSun Apr 29 17:46:08 2018(r333092) @@ -1342,8 +1342,10 @@ patmatch(const char *pattern, const char *string) } if (c == '[' && *p == ':') { found |= match_charclass(p, chr, ); - if (end != NULL) + if (end != NULL) { p = end; + continue; + } } if (c == CTLESC) c = *p++; Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Sun Apr 29 12:43:08 2018 (r333091) +++ head/bin/sh/tests/builtins/Makefile Sun Apr 29 17:46:08 2018 (r333092) @@ -42,6 +42,7 @@ ${PACKAGE}FILES+= case19.0 ${PACKAGE}FILES+= case20.0 ${PACKAGE}FILES+= case21.0 ${PACKAGE}FILES+= case22.0 +${PACKAGE}FILES+= case23.0 ${PACKAGE}FILES+= cd1.0 ${PACKAGE}FILES+= cd2.0 ${PACKAGE}FILES+= cd3.0 Added: head/bin/sh/tests/builtins/case23.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/case23.0 Sun Apr 29 17:46:08 2018 (r333092) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +case [ in +[[:alpha:]]) echo bad +esac ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r331955 - head/share/man/man8
Author: jilles Date: Tue Apr 3 21:44:43 2018 New Revision: 331955 URL: https://svnweb.freebsd.org/changeset/base/331955 Log: rc.subr.8: Improve documentation of ${name}_limits and ${name}_login_class Submitted by: 0mp Differential Revision:https://reviews.freebsd.org/D14928 Modified: head/share/man/man8/rc.subr.8 Modified: head/share/man/man8/rc.subr.8 == --- head/share/man/man8/rc.subr.8 Tue Apr 3 21:38:11 2018 (r331954) +++ head/share/man/man8/rc.subr.8 Tue Apr 3 21:44:43 2018 (r331955) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 18, 2016 +.Dd April 3, 2018 .Dt RC.SUBR 8 .Os .Sh NAME @@ -584,21 +584,27 @@ Only supported after .Pa /usr is mounted. .It Va ${name}_limits -.Xr limits 1 -to apply to +Resource limits to apply to .Va command . This will be passed as arguments to the .Xr limits 1 utility. +By default, the resource limits are based on the login class defined in +.Va ${name}_login_class . +.It Va ${name}_login_class +Login class to use with +.Va ${name}_limits . +Defaults to +.Dq Li daemon . .It Va ${name}_oomprotect .Xr protect 1 .Va command from being killed when swap space is exhausted. If -.Em YES +.Dq Li YES is used, no child processes are protected. If -.Em ALL , +.Dq Li ALL , protect all child processes. .It Va ${name}_program Full path to the command. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r328818 - head/bin/sh
Author: jilles Date: Fri Feb 2 22:53:58 2018 New Revision: 328818 URL: https://svnweb.freebsd.org/changeset/base/328818 Log: sh: Refactor job status printing, preparing for -o pipefail and similar No functional change is intended. Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Fri Feb 2 22:28:12 2018(r328817) +++ head/bin/sh/jobs.c Fri Feb 2 22:53:58 2018(r328818) @@ -362,7 +362,7 @@ showjob(struct job *jp, int mode) const char *statestr, *coredump; struct procstat *ps; struct job *j; - int col, curr, i, jobno, prev, procno; + int col, curr, i, jobno, prev, procno, status; char c; procno = (mode == SHOWJOBS_PGIDS) ? 1 : jp->nprocs; @@ -376,11 +376,12 @@ showjob(struct job *jp, int mode) } #endif coredump = ""; - ps = jp->ps + jp->nprocs - 1; + status = jp->ps[jp->nprocs - 1].status; if (jp->state == 0) { statestr = "Running"; #if JOBS } else if (jp->state == JOBSTOPPED) { + ps = jp->ps + jp->nprocs - 1; while (!WIFSTOPPED(ps->status) && ps > jp->ps) ps--; if (WIFSTOPPED(ps->status)) @@ -391,20 +392,20 @@ showjob(struct job *jp, int mode) if (statestr == NULL) statestr = "Suspended"; #endif - } else if (WIFEXITED(ps->status)) { - if (WEXITSTATUS(ps->status) == 0) + } else if (WIFEXITED(status)) { + if (WEXITSTATUS(status) == 0) statestr = "Done"; else { fmtstr(statebuf, sizeof(statebuf), "Done(%d)", - WEXITSTATUS(ps->status)); + WEXITSTATUS(status)); statestr = statebuf; } } else { - i = WTERMSIG(ps->status); + i = WTERMSIG(status); statestr = strsignal(i); if (statestr == NULL) statestr = "Unknown signal"; - if (WCOREDUMP(ps->status)) + if (WCOREDUMP(status)) coredump = " (core dumped)"; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r328060 - head/usr.sbin/service
On Tue, Jan 16, 2018 at 08:14:31PM +, Kyle Evans wrote: > Author: kevans > Date: Tue Jan 16 20:14:31 2018 > New Revision: 328060 > URL: https://svnweb.freebsd.org/changeset/base/328060 > Log: > service(8): Reset OPTIND properly now that we're parsing args twice > r328032 introduced a second round of argument parsing to proxy the request > through to a jail as needed, but failed to reset OPTIND before getting to > the second round of parsing to allow other flags to be set. > Reported by:Oleg Ginzburg > Modified: > head/usr.sbin/service/service.sh > Modified: head/usr.sbin/service/service.sh > == > --- head/usr.sbin/service/service.sh Tue Jan 16 20:02:07 2018 > (r328059) > +++ head/usr.sbin/service/service.sh Tue Jan 16 20:14:31 2018 > (r328060) > @@ -79,6 +79,7 @@ if [ -n "$JAIL" ]; then > exit $? > fi > > +OPTIND=1 > while getopts ${accepted_argstr} COMMAND_LINE_ARGUMENT ; do > case "${COMMAND_LINE_ARGUMENT}" in > e) ENABLED=eopt ;; Hi, Although this solves the immediate problem of all existing options becoming no-ops, the new -j option still behaves strangely if it is not used with "-j" and the jail name as the first two arguments, since the shift commands will shift away other arguments. One way to fix this avoids depending on the exact options known by the jailed service(8) and accepts that the -j option must be first (either -j JAIL as two arguments or -jJAIL as one argument). This parsing would be open-coded and there would be only one getopts loop. Another way to fix this allows using the -j option as any other option. This would also use one getopts loop and reconstruct a command line for the jailed service(8) based on the variables like ENABLED (the values for set options can be changed to simplify this since the rest of the script only cares about non-empty or not). -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327565 - head/usr.bin/find/tests
Author: jilles Date: Thu Jan 4 22:59:24 2018 New Revision: 327565 URL: https://svnweb.freebsd.org/changeset/base/327565 Log: find: Speed up tests by using touch -d instead of sleep for timestamps I have verified that the tests still detect the absence of the r327362 fix. Modified: head/usr.bin/find/tests/find_test.sh Modified: head/usr.bin/find/tests/find_test.sh == --- head/usr.bin/find/tests/find_test.shThu Jan 4 22:38:01 2018 (r327564) +++ head/usr.bin/find/tests/find_test.shThu Jan 4 22:59:24 2018 (r327565) @@ -36,10 +36,9 @@ find_newer_link_body() { atf_check -s exit:0 mkdir test atf_check -s exit:0 ln -s file1 test/link - atf_check -s exit:0 sleep 1.1 - atf_check -s exit:0 touch test/file2 - atf_check -s exit:0 sleep 1.1 - atf_check -s exit:0 touch test/file1 + atf_check -s exit:0 touch -d 2017-12-31T10:00:00Z -h test/link + atf_check -s exit:0 touch -d 2017-12-31T11:00:00Z test/file2 + atf_check -s exit:0 touch -d 2017-12-31T12:00:00Z test/file1 # find(1) should evaluate 'link' as a symlink rather than its target # (with -P / without -L flags). Since link was created first, the ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r325726 - head/sys/kern
On Thu, Dec 28, 2017 at 05:25:25PM +0100, Jilles Tjoelker wrote: > On Thu, Dec 28, 2017 at 12:40:31PM +, Antoine Brodin wrote: > > On Sat, Nov 11, 2017 at 10:39 PM, Mateusz Guzik <m...@freebsd.org> wrote: > > > Author: mjg > > > Date: Sat Nov 11 22:39:33 2017 > > > New Revision: 325726 > > > URL: https://svnweb.freebsd.org/changeset/base/325726 > > > Log: > > > Avoid locking and refing in sysctl_kern_proc_args if possible. > > > Turns out the sysctl is called a lot e.g. by pkg-static. > > > Modified: > > > head/sys/kern/kern_proc.c > > There is a regression after this commit: x11-toolkits/gnustep-gui no > > longer builds. > > You can find a failure log at > > http://pb2.nyi.freebsd.org/data/111i386-default-PR224618/2017-12-28_12h28m51s/logs/errors/gnustep-gui-0.25.1_3.log > > The failure seems to be from lang/gnustep-base: > > /* get the argument vectors */ > > vectors = kvm_getargv(kptr, proc_ptr, 0); > It looks like the new fast path only works properly if p->p_args is not > NULL. If p->p_args is NULL, this usually means that the arguments are > longer than ps_arg_cache_limit and must be retrieved from (pageable) > process memory and not wired p->p_args->ar_args. It is possible to > duplicate that piece of code as well but that is probably not worth it. I created a review that fixes the problem, but I am not completely sure that it preserves the original intent of the optimization: https://reviews.freebsd.org/D13729 -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327475 - head/bin/sh
Author: jilles Date: Mon Jan 1 22:31:52 2018 New Revision: 327475 URL: https://svnweb.freebsd.org/changeset/base/327475 Log: sh: Move various structs from jobs.h to jobs.c These implementation details of jobs.c need not be exposed. Modified: head/bin/sh/jobs.c head/bin/sh/jobs.h Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Mon Jan 1 22:10:21 2018(r327474) +++ head/bin/sh/jobs.c Mon Jan 1 22:31:52 2018(r327475) @@ -75,6 +75,42 @@ __FBSDID("$FreeBSD$"); #include "builtins.h" +/* + * A job structure contains information about a job. A job is either a + * single process or a set of processes contained in a pipeline. In the + * latter case, pidlist will be non-NULL, and will point to a -1 terminated + * array of pids. + */ + +struct procstat { + pid_t pid; /* process id */ + int status; /* status flags (defined above) */ + char *cmd; /* text of command being run */ +}; + + +/* states */ +#define JOBSTOPPED 1 /* all procs are stopped */ +#define JOBDONE 2 /* all procs are completed */ + + +struct job { + struct procstat ps0;/* status of process */ + struct procstat *ps;/* status or processes when more than one */ + short nprocs; /* number of processes */ + pid_t pgrp; /* process group of this job */ + char state; /* true if job is finished */ + char used; /* true if this entry is in used */ + char changed; /* true if status has changed */ + char foreground;/* true if running in the foreground */ + char remembered;/* true if $! referenced */ +#if JOBS + char jobctl;/* job running under job control */ + struct job *next; /* job used after this one */ +#endif +}; + + static struct job *jobtab; /* array of jobs */ static int njobs; /* size of array */ static pid_t backgndpid = -1; /* pid of last background process */ Modified: head/bin/sh/jobs.h == --- head/bin/sh/jobs.h Mon Jan 1 22:10:21 2018(r327474) +++ head/bin/sh/jobs.h Mon Jan 1 22:31:52 2018(r327475) @@ -40,40 +40,7 @@ #include /* for sig_atomic_t */ -/* - * A job structure contains information about a job. A job is either a - * single process or a set of processes contained in a pipeline. In the - * latter case, pidlist will be non-NULL, and will point to a -1 terminated - * array of pids. - */ - -struct procstat { - pid_t pid; /* process id */ - int status; /* status flags (defined above) */ - char *cmd; /* text of command being run */ -}; - - -/* states */ -#define JOBSTOPPED 1 /* all procs are stopped */ -#define JOBDONE 2 /* all procs are completed */ - - -struct job { - struct procstat ps0;/* status of process */ - struct procstat *ps;/* status or processes when more than one */ - short nprocs; /* number of processes */ - pid_t pgrp; /* process group of this job */ - char state; /* true if job is finished */ - char used; /* true if this entry is in used */ - char changed; /* true if status has changed */ - char foreground;/* true if running in the foreground */ - char remembered;/* true if $! referenced */ -#if JOBS - char jobctl;/* job running under job control */ - struct job *next; /* job used after this one */ -#endif -}; +struct job; enum { SHOWJOBS_DEFAULT, /* job number, status, command */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327440 - in head: etc/mtree usr.bin/find
Author: jilles Date: Sun Dec 31 19:24:13 2017 New Revision: 327440 URL: https://svnweb.freebsd.org/changeset/base/327440 Log: find: Link tests to the build Modified: head/etc/mtree/BSD.tests.dist head/usr.bin/find/Makefile Modified: head/etc/mtree/BSD.tests.dist == --- head/etc/mtree/BSD.tests.dist Sun Dec 31 18:53:13 2017 (r327439) +++ head/etc/mtree/BSD.tests.dist Sun Dec 31 19:24:13 2017 (r327440) @@ -664,6 +664,8 @@ .. file2c .. +find +.. fold .. getconf Modified: head/usr.bin/find/Makefile == --- head/usr.bin/find/Makefile Sun Dec 31 18:53:13 2017(r327439) +++ head/usr.bin/find/Makefile Sun Dec 31 19:24:13 2017(r327440) @@ -1,6 +1,8 @@ # @(#)Makefile8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include + PROG= find SRCS= find.c function.c ls.c main.c misc.c operator.c option.c \ getdate.y @@ -8,7 +10,7 @@ YFLAGS= NO_WMISSING_VARIABLE_DECLARATIONS= -#HAS_TESTS= -#SUBDIR.${MK_TESTS}+= tests +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests .include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r325726 - head/sys/kern
On Thu, Dec 28, 2017 at 12:40:31PM +, Antoine Brodin wrote: > On Sat, Nov 11, 2017 at 10:39 PM, Mateusz Guzik <m...@freebsd.org> wrote: > > Author: mjg > > Date: Sat Nov 11 22:39:33 2017 > > New Revision: 325726 > > URL: https://svnweb.freebsd.org/changeset/base/325726 > > Log: > > Avoid locking and refing in sysctl_kern_proc_args if possible. > > Turns out the sysctl is called a lot e.g. by pkg-static. > > Modified: > > head/sys/kern/kern_proc.c > There is a regression after this commit: x11-toolkits/gnustep-gui no > longer builds. > You can find a failure log at > http://pb2.nyi.freebsd.org/data/111i386-default-PR224618/2017-12-28_12h28m51s/logs/errors/gnustep-gui-0.25.1_3.log > The failure seems to be from lang/gnustep-base: > /* get the argument vectors */ > vectors = kvm_getargv(kptr, proc_ptr, 0); It looks like the new fast path only works properly if p->p_args is not NULL. If p->p_args is NULL, this usually means that the arguments are longer than ps_arg_cache_limit and must be retrieved from (pageable) process memory and not wired p->p_args->ar_args. It is possible to duplicate that piece of code as well but that is probably not worth it. A simple reproducer is sh -c 'n=$(sysctl -n kern.ps_arg_cache_limit); exec ps -p "$$" -o "args=$(printf "%0${n}d" 0)"' On head, the second line is [ps] indicating that KERN_PROC_ARGS did not return the expected string. On stable/10 and stable/11, the second line is a truncated version of the command line like ps -p 86963 -o args=00 A prerequisite for this reproducer is that kern.ps_arg_cache_limit is not set so high that it is impractical to exceed it but not {ARG_MAX}. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327212 - head/bin/sh
Author: jilles Date: Tue Dec 26 16:23:18 2017 New Revision: 327212 URL: https://svnweb.freebsd.org/changeset/base/327212 Log: sh: Don't leak wait* implementation details from jobs.c Modified: head/bin/sh/eval.c head/bin/sh/jobs.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue Dec 26 16:20:38 2017(r327211) +++ head/bin/sh/eval.c Tue Dec 26 16:23:18 2017(r327212) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* For WIFSIGNALED(status) */ #include /* @@ -840,7 +839,7 @@ evalcommand(union node *cmd, int flags, struct backcmd struct parsefile *savetopfile; volatile int e; char *lastarg; - int realstatus; + int signaled; int do_clearcmdentry; const char *path = pathval(); int i; @@ -1163,9 +1162,9 @@ cmddone: parent:/* parent process gets here (if we forked) */ if (mode == FORK_FG) { /* argument to fork */ INTOFF; - exitstatus = waitforjob(jp, ); + exitstatus = waitforjob(jp, ); INTON; - if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) { + if (iflag && loopnest > 0 && signaled) { evalskip = SKIPBREAK; skipcount = loopnest; } Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Tue Dec 26 16:20:38 2017(r327211) +++ head/bin/sh/jobs.c Tue Dec 26 16:23:18 2017(r327212) @@ -1016,7 +1016,7 @@ vforkexecshell(struct job *jp, char **argv, char **env */ int -waitforjob(struct job *jp, int *origstatus) +waitforjob(struct job *jp, int *signaled) { #if JOBS int propagate_int = jp->jobctl && jp->foreground; @@ -1039,8 +1039,8 @@ waitforjob(struct job *jp, int *origstatus) setcurjob(jp); #endif status = jp->ps[jp->nprocs - 1].status; - if (origstatus != NULL) - *origstatus = status; + if (signaled != NULL) + *signaled = WIFSIGNALED(status); /* convert to 8 bits */ if (WIFEXITED(status)) st = WEXITSTATUS(status); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327211 - head/usr.sbin/nandtool
Author: jilles Date: Tue Dec 26 16:20:38 2017 New Revision: 327211 URL: https://svnweb.freebsd.org/changeset/base/327211 Log: nandtool: Add missing mode for open() with O_CREAT If O_CREAT is given, open() needs a mode argument. Follow the umask by passing 0666. Reviewed by: imp MFC after:1 week Differential Revision:https://reviews.freebsd.org/D13607 Modified: head/usr.sbin/nandtool/nand_read.c head/usr.sbin/nandtool/nand_readoob.c Modified: head/usr.sbin/nandtool/nand_read.c == --- head/usr.sbin/nandtool/nand_read.c Tue Dec 26 16:13:20 2017 (r327210) +++ head/usr.sbin/nandtool/nand_read.c Tue Dec 26 16:20:38 2017 (r327211) @@ -52,7 +52,7 @@ int nand_read(struct cmd_param *params) } if ((out = param_get_string(params, "out"))) { - out_fd = open(out, O_WRONLY|O_CREAT); + out_fd = open(out, O_WRONLY|O_CREAT, 0666); if (out_fd == -1) { perrorf("Cannot open %s for writing", out); return (1); Modified: head/usr.sbin/nandtool/nand_readoob.c == --- head/usr.sbin/nandtool/nand_readoob.c Tue Dec 26 16:13:20 2017 (r327210) +++ head/usr.sbin/nandtool/nand_readoob.c Tue Dec 26 16:20:38 2017 (r327211) @@ -59,7 +59,7 @@ int nand_read_oob(struct cmd_param *params) } if ((out = param_get_string(params, "out"))) { - if ((fd_out = open(out, O_WRONLY | O_CREAT)) == -1) { + if ((fd_out = open(out, O_WRONLY | O_CREAT, 0666)) == -1) { perrorf("Cannot open %s", out); ret = 1; goto out; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327121 - head/bin/sh
Author: jilles Date: Sat Dec 23 22:58:19 2017 New Revision: 327121 URL: https://svnweb.freebsd.org/changeset/base/327121 Log: sh(1): Markup and spelling fixes Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Sat Dec 23 22:57:14 2017(r327120) +++ head/bin/sh/sh.1Sat Dec 23 22:58:19 2017(r327121) @@ -343,7 +343,7 @@ Write each command variable subjected to parameter expansion and arithmetic expansion) to standard error before it is executed. Useful for debugging. -.It nolog +.It Li nolog Another do-nothing option for .Tn POSIX compliance. @@ -2739,7 +2739,7 @@ were a known job that exited with exit status 127. If no operands are given, wait for all jobs to complete and return an exit status of zero. .El -.Ss Commandline Editing +.Ss Command Line Editing When .Nm is being used interactively from a terminal, the current command ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r326603 - head/contrib/mdocml
Author: jilles Date: Tue Dec 5 23:06:15 2017 New Revision: 326603 URL: https://svnweb.freebsd.org/changeset/base/326603 Log: mdoc(7): Update .Dd for previous commit Modified: head/contrib/mdocml/mdoc.7 Modified: head/contrib/mdocml/mdoc.7 == --- head/contrib/mdocml/mdoc.7 Tue Dec 5 23:02:31 2017(r326602) +++ head/contrib/mdocml/mdoc.7 Tue Dec 5 23:06:15 2017(r326603) @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 20 2017 $ +.Dd $Mdocdate: December 5 2017 $ .Dt MDOC 7 .Os .Sh NAME ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r326601 - head/contrib/mdocml
Author: jilles Date: Tue Dec 5 23:00:41 2017 New Revision: 326601 URL: https://svnweb.freebsd.org/changeset/base/326601 Log: mdocml: Add IEEE Std 1003.1-2008, 2016 edition Also document IEEE Std 1003.1-2008, 2013 edition in mdoc(7) (as well as the 2016 edition). Submitted by: Yuri Pankov Reviewed by: bjk Differential Revision:https://reviews.freebsd.org/D13349 Modified: head/contrib/mdocml/mdoc.7 head/contrib/mdocml/st.in Modified: head/contrib/mdocml/mdoc.7 == --- head/contrib/mdocml/mdoc.7 Tue Dec 5 22:24:20 2017(r326600) +++ head/contrib/mdocml/mdoc.7 Tue Dec 5 23:00:41 2017(r326601) @@ -2575,6 +2575,17 @@ The second and last Technical Corrigendum. .br This standard is also called X/Open Portability Guide version 7. +.Pp +.It \-p1003.1-2013 +.St -p1003.1-2013 +.br +The 2013 edition incorporates Technical Corrigendum 1. +.Pp +.It \-p1003.1-2016 +.St -p1003.1-2016 +.br +The 2016 edition incorporates Technical Corrigendum 1 and +Technical Corrigendum 2. .El .It Other standards .Pp Modified: head/contrib/mdocml/st.in == --- head/contrib/mdocml/st.in Tue Dec 5 22:24:20 2017(r326600) +++ head/contrib/mdocml/st.in Tue Dec 5 23:00:41 2017(r326601) @@ -35,6 +35,7 @@ LINE("-p1003.1-2001", "IEEE Std 1003.1-2001 (\\(LqPOSI LINE("-p1003.1-2004", "IEEE Std 1003.1-2004 (\\(LqPOSIX.1\\(Rq)") LINE("-p1003.1-2008", "IEEE Std 1003.1-2008 (\\(LqPOSIX.1\\(Rq)") LINE("-p1003.1-2013", "IEEE Std 1003.1-2008, 2013 Edition (\\(LqPOSIX.1\\(Rq)") +LINE("-p1003.1-2016", "IEEE Std 1003.1-2008, 2016 Edition (\\(LqPOSIX.1\\(Rq)") LINE("-p1003.1", "IEEE Std 1003.1 (\\(LqPOSIX.1\\(Rq)") LINE("-p1003.1b", "IEEE Std 1003.1b (\\(LqPOSIX.1b\\(Rq)") LINE("-p1003.1b-93", "IEEE Std 1003.1b-1993 (\\(LqPOSIX.1b\\(Rq)") ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r325017 - head/sys/contrib/libnv
Author: jilles Date: Thu Oct 26 18:32:04 2017 New Revision: 325017 URL: https://svnweb.freebsd.org/changeset/base/325017 Log: libnv: Fix strict-aliasing violation with cookie In rS323851, some casts were adjusted in calls to nvlist_next() and nvlist_get_pararr() in order to make scan-build happy. I think these changes just confused scan-build into not reporting the strict-aliasing violation. For example, nvlist_xdescriptors() is causing nvlist_next() to write to its local variable nvp of type nvpair_t * using the lvalue *cookiep of type void *, which is not allowed. Given the APIs of nvlist_next(), nvlist_get_parent() and nvlist_get_pararr(), one possible fix is to create a local void *cookie in nvlist_xdescriptors() and other places, and to convert the value to nvpair_t * when necessary. This patch implements that fix. Reviewed by: oshogbo MFC after:1 week Differential Revision:https://reviews.freebsd.org/D12760 Modified: head/sys/contrib/libnv/nvlist.c Modified: head/sys/contrib/libnv/nvlist.c == --- head/sys/contrib/libnv/nvlist.c Thu Oct 26 17:56:34 2017 (r325016) +++ head/sys/contrib/libnv/nvlist.c Thu Oct 26 18:32:04 2017 (r325017) @@ -707,15 +707,17 @@ out: static int * nvlist_xdescriptors(const nvlist_t *nvl, int *descs) { + void *cookie; nvpair_t *nvp; int type; NVLIST_ASSERT(nvl); PJDLOG_ASSERT(nvl->nvl_error == 0); - nvp = NULL; + cookie = NULL; do { - while (nvlist_next(nvl, , (void *)) != NULL) { + while (nvlist_next(nvl, , ) != NULL) { + nvp = cookie; switch (type) { case NV_TYPE_DESCRIPTOR: *descs = nvpair_get_descriptor(nvp); @@ -737,7 +739,7 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) } case NV_TYPE_NVLIST: nvl = nvpair_get_nvlist(nvp); - nvp = NULL; + cookie = NULL; break; case NV_TYPE_NVLIST_ARRAY: { @@ -749,12 +751,12 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) PJDLOG_ASSERT(nitems > 0); nvl = value[0]; - nvp = NULL; + cookie = NULL; break; } } } - } while ((nvl = nvlist_get_pararr(nvl, (void *))) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, )) != NULL); return (descs); } @@ -784,6 +786,7 @@ size_t nvlist_ndescriptors(const nvlist_t *nvl) { #ifndef _KERNEL + void *cookie; nvpair_t *nvp; size_t ndescs; int type; @@ -792,16 +795,17 @@ nvlist_ndescriptors(const nvlist_t *nvl) PJDLOG_ASSERT(nvl->nvl_error == 0); ndescs = 0; - nvp = NULL; + cookie = NULL; do { - while (nvlist_next(nvl, , (void *)) != NULL) { + while (nvlist_next(nvl, , ) != NULL) { + nvp = cookie; switch (type) { case NV_TYPE_DESCRIPTOR: ndescs++; break; case NV_TYPE_NVLIST: nvl = nvpair_get_nvlist(nvp); - nvp = NULL; + cookie = NULL; break; case NV_TYPE_NVLIST_ARRAY: { @@ -813,7 +817,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) PJDLOG_ASSERT(nitems > 0); nvl = value[0]; - nvp = NULL; + cookie = NULL; break; } case NV_TYPE_DESCRIPTOR_ARRAY: @@ -827,7 +831,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) } } } - } while ((nvl = nvlist_get_pararr(nvl, (void *))) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, )) != NULL); return (ndescs); #else ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r324866 - head/include
Author: jilles Date: Sun Oct 22 20:01:07 2017 New Revision: 324866 URL: https://svnweb.freebsd.org/changeset/base/324866 Log: libc: Do not refer to _DefaultRuneLocale in ctype inlines Referring to _DefaultRuneLocale causes this >4KB structure to be copied to all executables that use inlines (except PIE executables). This only affects the case where thread local storage is available. _CurrentRuneLocale cannot be NULL, so the check can be removed entirely. _DefaultRuneLocale needs to remain available for now since libc++ uses it. The __isctype inline in include/_ctype.h also refers to _DefaultRuneLocale and remains available because it may still be used by third party software. Reviewed by: bdrewery, theraven Differential Revision:https://reviews.freebsd.org/D10363 Modified: head/include/runetype.h Modified: head/include/runetype.h == --- head/include/runetype.h Sun Oct 22 19:17:25 2017(r324865) +++ head/include/runetype.h Sun Oct 22 20:01:07 2017(r324866) @@ -95,9 +95,7 @@ static __inline const _RuneLocale *__getCurrentRuneLoc if (_ThreadRuneLocale) return _ThreadRuneLocale; - if (_CurrentRuneLocale) - return _CurrentRuneLocale; - return &_DefaultRuneLocale; + return _CurrentRuneLocale; } #endif /* __NO_TLS || __RUNETYPE_INTERNAL */ #define _CurrentRuneLocale (__getCurrentRuneLocale()) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r324625 - head/etc
Author: jilles Date: Sun Oct 15 11:28:41 2017 New Revision: 324625 URL: https://svnweb.freebsd.org/changeset/base/324625 Log: rc.subr: Remove test that is always true. The code above always sets _pidcmd to a non-empty value. Modified: head/etc/rc.subr Modified: head/etc/rc.subr == --- head/etc/rc.subrSun Oct 15 10:59:31 2017(r324624) +++ head/etc/rc.subrSun Oct 15 11:28:41 2017(r324625) @@ -930,9 +930,7 @@ run_rc_command() else _pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')' fi - if [ -n "$_pidcmd" ]; then - _keywords="${_keywords} status poll" - fi + _keywords="${_keywords} status poll" fi if [ -z "$rc_arg" ]; then ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r323177 - in head: sys/compat/cloudabi sys/contrib/cloudabi usr.bin/truss
On Tue, Sep 05, 2017 at 07:46:45AM +, Ed Schouten wrote: > Author: ed > Date: Tue Sep 5 07:46:45 2017 > New Revision: 323177 > URL: https://svnweb.freebsd.org/changeset/base/323177 > Log: > Merge pipes and socket pairs. > Now that CloudABI's sockets API has been changed to be addressless and > only connected socket instances are used (e.g., socket pairs), they have > become fairly similar to pipes. The only differences on CloudABI is that > socket pairs additionally support shutdown(), send() and recv(). > To simplify the ABI, we've therefore decided to remove pipes as a > separate file descriptor type and just let pipe() return a socket pair > of type SOCK_STREAM. S_ISFIFO() and S_ISSOCK() are now defined > identically. Although this is correct from a functionality point of view (S_IFIFO and S_IFSOCK are probably expected to be different in a POSIX context, but this is unlikely to break anything that is not already broken), it is a partial reversal of previous changes to FreeBSD that created separate implementations for pipes (first unnamed pipes in 1996, later fifos in 2012 r232055). The main reason for these changes was performance. Unfortunately, I do not have concrete benchmarks in the CloudABI context. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r322455 - head/bin/sh/tests/invocation
Author: jilles Date: Sun Aug 13 14:36:10 2017 New Revision: 322455 URL: https://svnweb.freebsd.org/changeset/base/322455 Log: sh: Add test for sh -c with missing command string. This already works correctly. Added: head/bin/sh/tests/invocation/sh-c-missing1.0 (contents, props changed) Modified: head/bin/sh/tests/invocation/Makefile Modified: head/bin/sh/tests/invocation/Makefile == --- head/bin/sh/tests/invocation/Makefile Sun Aug 13 07:40:05 2017 (r322454) +++ head/bin/sh/tests/invocation/Makefile Sun Aug 13 14:36:10 2017 (r322455) @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T} ATF_TESTS_SH= functional_test ${PACKAGE}FILES+= sh-ac1.0 +${PACKAGE}FILES+= sh-c-missing1.0 ${PACKAGE}FILES+= sh-c1.0 ${PACKAGE}FILES+= sh-ca1.0 ${PACKAGE}FILES+= sh-fca1.0 Added: head/bin/sh/tests/invocation/sh-c-missing1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/sh-c-missing1.0Sun Aug 13 14:36:10 2017(r322455) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! echo echo bad | ${SH} -c 2>/dev/null ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r322438 - in head: bin/sh/tests bin/sh/tests/invocation etc/mtree
Author: jilles Date: Sat Aug 12 19:17:48 2017 New Revision: 322438 URL: https://svnweb.freebsd.org/changeset/base/322438 Log: sh: Add tests for sh -c that already pass. PR: 220587 Submitted by: Ryan Moeller Added: head/bin/sh/tests/invocation/ head/bin/sh/tests/invocation/Makefile (contents, props changed) head/bin/sh/tests/invocation/sh-ac1.0 (contents, props changed) head/bin/sh/tests/invocation/sh-c1.0 (contents, props changed) head/bin/sh/tests/invocation/sh-ca1.0 (contents, props changed) head/bin/sh/tests/invocation/sh-fca1.0 (contents, props changed) Modified: head/bin/sh/tests/Makefile head/etc/mtree/BSD.tests.dist Modified: head/bin/sh/tests/Makefile == --- head/bin/sh/tests/Makefile Sat Aug 12 18:42:54 2017(r322437) +++ head/bin/sh/tests/Makefile Sat Aug 12 19:17:48 2017(r322438) @@ -6,6 +6,7 @@ TESTS_SUBDIRS+= builtins TESTS_SUBDIRS+=errors TESTS_SUBDIRS+=execution TESTS_SUBDIRS+=expansion +TESTS_SUBDIRS+=invocation TESTS_SUBDIRS+=parameters TESTS_SUBDIRS+=parser TESTS_SUBDIRS+=set-e Added: head/bin/sh/tests/invocation/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/Makefile Sat Aug 12 19:17:48 2017 (r322438) @@ -0,0 +1,15 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T} + +.PATH: ${.CURDIR:H} +ATF_TESTS_SH= functional_test + +${PACKAGE}FILES+= sh-ac1.0 +${PACKAGE}FILES+= sh-c1.0 +${PACKAGE}FILES+= sh-ca1.0 +${PACKAGE}FILES+= sh-fca1.0 + +.include Added: head/bin/sh/tests/invocation/sh-ac1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/sh-ac1.0 Sat Aug 12 19:17:48 2017 (r322438) @@ -0,0 +1,7 @@ +# $FreeBSD$ +# Test that attached options before c are processed + +case `${SH} -ac 'echo $-:$0' moo` in +*a*:moo) true ;; +*) false ;; +esac Added: head/bin/sh/tests/invocation/sh-c1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/sh-c1.0Sat Aug 12 19:17:48 2017 (r322438) @@ -0,0 +1,4 @@ +# $FreeBSD$ +# Test that -c executes command_string with the given name and arg + +${SH} -c 'echo $0 $@' moo foo | grep -qx -- "moo foo" Added: head/bin/sh/tests/invocation/sh-ca1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/sh-ca1.0 Sat Aug 12 19:17:48 2017 (r322438) @@ -0,0 +1,7 @@ +# $FreeBSD$ +# Test that attached options after c are processed + +case `${SH} -ca 'echo $-:$0' moo` in +*a*:moo) true ;; +*) false ;; +esac Added: head/bin/sh/tests/invocation/sh-fca1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/invocation/sh-fca1.0 Sat Aug 12 19:17:48 2017 (r322438) @@ -0,0 +1,7 @@ +# $FreeBSD$ +# Test that attached options before and after c are processed + +case `${SH} -fca 'echo $-:$-:$0:$@' foo -bar` in +*f*:*a*:foo:-bar) true ;; +*) false ;; +esac Modified: head/etc/mtree/BSD.tests.dist == --- head/etc/mtree/BSD.tests.dist Sat Aug 12 18:42:54 2017 (r322437) +++ head/etc/mtree/BSD.tests.dist Sat Aug 12 19:17:48 2017 (r322438) @@ -39,6 +39,8 @@ .. expansion .. +invocation +.. parameters .. parser ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r321171 - head/bin/sh
Author: jilles Date: Tue Jul 18 19:00:15 2017 New Revision: 321171 URL: https://svnweb.freebsd.org/changeset/base/321171 Log: sh: Remove broken #ifdef NOHACK code (related to sh -c). Apart from the fact that subtle syntactic changes make a poor compile-time option, the NOHACK case has been obviously broken since it was added, because it uses q uninitialized if (*p != '\0'). No functional change is intended. Modified: head/bin/sh/options.c Modified: head/bin/sh/options.c == --- head/bin/sh/options.c Tue Jul 18 18:56:51 2017(r321170) +++ head/bin/sh/options.c Tue Jul 18 19:00:15 2017(r321171) @@ -191,16 +191,11 @@ options(int cmdline) while ((c = *p++) != '\0') { if (c == 'c' && cmdline) { char *q; -#ifdef NOHACK /* removing this code allows sh -ce 'foo' for compat */ - if (*p == '\0') -#endif - q = *argptr++; + + q = *argptr++; if (q == NULL || minusc != NULL) error("Bad -c option"); minusc = q; -#ifdef NOHACK - break; -#endif } else if (c == 'o') { minus_o(*argptr, val); if (*argptr) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r320340 - in head/bin/sh: . tests/builtins
Author: jilles Date: Sun Jun 25 21:53:08 2017 New Revision: 320340 URL: https://svnweb.freebsd.org/changeset/base/320340 Log: sh: Ignore error when cd writes the directory actually switched to. If CDPATH is used non-trivially or the operand is "-", cd writes the directory actually switched to. (We currently do this only in interactive shells, but POSIX requires this in non-interactive shells as well.) As mentioned in Austin group bug #1045, cd shall not return an error while leaving the current directory changed. Therefore, ignore any write error. Added: head/bin/sh/tests/builtins/cd10.0 (contents, props changed) Modified: head/bin/sh/cd.c head/bin/sh/sh.1 head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/cd.c == --- head/bin/sh/cd.cSun Jun 25 20:06:05 2017(r320339) +++ head/bin/sh/cd.cSun Jun 25 21:53:08 2017(r320340) @@ -164,8 +164,17 @@ docd(char *dest, int print, int phys) if ((phys || (rc = cdlogical(dest)) < 0) && (rc = cdphysical(dest)) < 0) return (-1); - if (print && iflag && curdir) + if (print && iflag && curdir) { out1fmt("%s\n", curdir); + /* +* Ignore write errors to preserve the invariant that the +* current directory is changed iff the exit status is 0 +* (or 1 if -e was given and the full pathname could not be +* determined). +*/ + flushout(out1); + outclearerror(out1); + } return (rc); } Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Sun Jun 25 20:06:05 2017(r320339) +++ head/bin/sh/sh.1Sun Jun 25 21:53:08 2017(r320340) @@ -2018,6 +2018,11 @@ to return exit status 1 if the full pathname of the ne cannot be determined reliably or at all. Normally this is not considered an error, although a warning is printed. +.Pp +If changing the directory fails, the exit status is greater than 1. +If the directory is changed, the exit status is 0, or also 1 if +.Fl e +was given. .It Ic chdir A synonym for the .Ic cd Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Sun Jun 25 20:06:05 2017 (r320339) +++ head/bin/sh/tests/builtins/Makefile Sun Jun 25 21:53:08 2017 (r320340) @@ -51,6 +51,7 @@ ${PACKAGE}FILES+= cd6.0 ${PACKAGE}FILES+= cd7.0 ${PACKAGE}FILES+= cd8.0 ${PACKAGE}FILES+= cd9.0 cd9.0.stdout +${PACKAGE}FILES+= cd10.0 ${PACKAGE}FILES+= command1.0 ${PACKAGE}FILES+= command2.0 ${PACKAGE}FILES+= command3.0 Added: head/bin/sh/tests/builtins/cd10.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/cd10.0 Sun Jun 25 21:53:08 2017 (r320340) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +# Precondition +(cd /bin) || exit +# Verify write error is ignored. +$SH +m -ic 'CDPATH=/:; cd bin 1https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319828 - head/etc
Author: jilles Date: Sun Jun 11 19:06:07 2017 New Revision: 319828 URL: https://svnweb.freebsd.org/changeset/base/319828 Log: rc.subr: Optimize repeated sourcing. When /etc/rc runs all /etc/rc.d scripts, it has already loaded /etc/rc.subr but each /etc/rc.d script sources it again (since /etc/rc.d scripts must also work when started stand-alone). Therefore, if rc.subr is already loaded, return so sh need not parse the rest of the file. A second effect is that there is no longer a compound command around most of rc.subr. This reduces memory usage while sh is loading rc.subr for the first time (but this memory is free()d once rc.subr is loaded). For purposes of porting this to other systems, I do not recommend porting this to systems with shells that do not have the change to the return special builtin like in r255215 (before FreeBSD 10.0-RELEASE). This change ensures that return in the top level of a dot script returns from the dot script, even if the dot script was sourced from a function. A comparison of CPU time on an amd64 bhyve virtual machine from a times command added near the end of /etc/rc, all four values summed: x orig1 + quickreturn +--+ | ++ + xx x| ||__M__A_| |__M___A__| | +--+ N Min MaxMedian AvgStddev x 3 1.704 1.802 1.726 1.744 0.051419841 + 3 1.467 1.559 1.487 1.504 0.048387326 Difference at 95.0% confidence -0.239667 +/- 0.113163 -13.7424% +/- 6.48873% (Student's t, pooled s = 0.0499266) Modified: head/etc/rc.subr Modified: head/etc/rc.subr == --- head/etc/rc.subrSun Jun 11 19:05:45 2017(r319827) +++ head/etc/rc.subrSun Jun 11 19:06:07 2017(r319828) @@ -38,7 +38,9 @@ # Operating System dependent/independent variables # -if [ -z "${_rc_subr_loaded}" ]; then +if [ -n "${_rc_subr_loaded}" ]; then + return +fi _rc_subr_loaded="YES" @@ -2126,7 +2128,3 @@ _echoonce() if kenv -q rc.debug > /dev/null ; then rc_debug=YES fi - -fi # [ -z "${_rc_subr_loaded}" ] - -_rc_subr_loaded=: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319826 - head/bin/sh
Author: jilles Date: Sun Jun 11 16:54:04 2017 New Revision: 319826 URL: https://svnweb.freebsd.org/changeset/base/319826 Log: sh: Enable interrupts before executing EXIT trap and doing final flush. Modified: head/bin/sh/trap.c Modified: head/bin/sh/trap.c == --- head/bin/sh/trap.c Sun Jun 11 14:39:08 2017(r319825) +++ head/bin/sh/trap.c Sun Jun 11 16:54:04 2017(r319826) @@ -526,11 +526,13 @@ exitshell_savedstatus(void) */ evalskip = 0; trap[0] = NULL; + FORCEINTON; evalstring(p, 0); } } if (!setjmp(loc2.loc)) { handler = /* probably unnecessary */ + FORCEINTON; flushall(); #if JOBS setjobctl(0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319663 - head/lib/libc/sys
Author: jilles Date: Wed Jun 7 21:21:14 2017 New Revision: 319663 URL: https://svnweb.freebsd.org/changeset/base/319663 Log: libc: Remove futimens() and utimensat() compat stubs. The futimens() and utimensat() compat stubs allowed using these functions on kernels that did not have the system calls yet (10.2, old 11-current). Also remove the documentation of the [ENOTSUP] error that could occur with an old kernel. A -DNO_CLEAN build may fail because the depend files refer to the deleted files. Deleted: head/lib/libc/sys/futimens.c head/lib/libc/sys/utimensat.c Modified: head/lib/libc/sys/Makefile.inc head/lib/libc/sys/utimensat.2 Modified: head/lib/libc/sys/Makefile.inc == --- head/lib/libc/sys/Makefile.inc Wed Jun 7 21:18:28 2017 (r319662) +++ head/lib/libc/sys/Makefile.inc Wed Jun 7 21:21:14 2017 (r319663) @@ -37,10 +37,6 @@ SRCS+= \ SRCS+= getdents.c lstat.c mknod.c stat.c -SRCS+= futimens.c utimensat.c -NOASM+= futimens.o utimensat.o -PSEUDO+= _futimens.o _utimensat.o - SRCS+= pipe.c INTERPOSED = \ Modified: head/lib/libc/sys/utimensat.2 == --- head/lib/libc/sys/utimensat.2 Wed Jun 7 21:18:28 2017 (r319662) +++ head/lib/libc/sys/utimensat.2 Wed Jun 7 21:21:14 2017 (r319663) @@ -31,7 +31,7 @@ .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 17, 2016 +.Dd June 7, 2017 .Dt UTIMENSAT 2 .Os .Sh NAME @@ -267,10 +267,6 @@ argument is not an absolute path and is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. -.It Bq Er ENOTSUP -The running kernel does not support this system call and -.Dv AT_SYMLINK_NOFOLLOW -is used with a path relative to a file descriptor. .El .Sh SEE ALSO .Xr chflags 2 , ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319635 - head/bin/sh
Author: jilles Date: Tue Jun 6 21:08:05 2017 New Revision: 319635 URL: https://svnweb.freebsd.org/changeset/base/319635 Log: sh: Call fc -e editor with interrupts enabled. Starting the fc -e editor can execute arbitrary script, and executing arbitrary script with INTOFF in effect may cause unexpected results. This change (together with other changes) serves mainly to allow asserting that INTOFF is not in effect when starting the evaluation of a node. Modified: head/bin/sh/histedit.c Modified: head/bin/sh/histedit.c == --- head/bin/sh/histedit.c Tue Jun 6 21:03:43 2017(r319634) +++ head/bin/sh/histedit.c Tue Jun 6 21:08:05 2017(r319635) @@ -376,10 +376,10 @@ histcmd(int argc, char **argv __unused) char *editcmd; fclose(efp); + INTON; editcmd = stalloc(strlen(editor) + strlen(editfile) + 2); sprintf(editcmd, "%s %s", editor, editfile); evalstring(editcmd, 0); /* XXX - should use no JC command */ - INTON; readcmdfile(editfile); /* XXX - should read back - quick tst */ unlink(editfile); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319591 - head/bin/sh
Author: jilles Date: Sun Jun 4 21:58:02 2017 New Revision: 319591 URL: https://svnweb.freebsd.org/changeset/base/319591 Log: sh: Make sure to process SIGINT if SETINTON re-enables processing. If INTON re-enables interrupts, it processes any interrupt that occurred while interrupts were disabled. Make SETINTON do the same. Modified: head/bin/sh/error.h Modified: head/bin/sh/error.h == --- head/bin/sh/error.h Sun Jun 4 21:39:37 2017(r319590) +++ head/bin/sh/error.h Sun Jun 4 21:58:02 2017(r319591) @@ -73,7 +73,7 @@ extern volatile sig_atomic_t intpending; #define INTOFF suppressint++ #define INTON { if (--suppressint == 0 && intpending) onint(); } #define is_int_on() suppressint -#define SETINTON(s) suppressint = (s) +#define SETINTON(s) do { suppressint = (s); if (suppressint == 0 && intpending) onint(); } while (0) #define FORCEINTON {suppressint = 0; if (intpending) onint();} #define SET_PENDING_INT intpending = 1 #define CLEAR_PENDING_INT intpending = 0 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319590 - head/tests/sys/aio
Author: jilles Date: Sun Jun 4 21:39:37 2017 New Revision: 319590 URL: https://svnweb.freebsd.org/changeset/base/319590 Log: tests/sys/aio: Add missing mode to open() calls with O_CREAT. Modified: head/tests/sys/aio/aio_test.c Modified: head/tests/sys/aio/aio_test.c == --- head/tests/sys/aio/aio_test.c Sun Jun 4 21:28:52 2017 (r319589) +++ head/tests/sys/aio/aio_test.c Sun Jun 4 21:39:37 2017 (r319590) @@ -385,7 +385,7 @@ aio_file_test(completion comp) ATF_REQUIRE_KERNEL_MODULE("aio"); ATF_REQUIRE_UNSAFE_AIO(); - fd = open(FILE_PATHNAME, O_RDWR | O_CREAT); + fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); arg.afa_fd = fd; @@ -834,7 +834,7 @@ ATF_TC_BODY(aio_large_read_test, tc) len = INT_MAX; #endif - fd = open(FILE_PATHNAME, O_RDWR | O_CREAT); + fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); unlink(FILE_PATHNAME); @@ -1088,7 +1088,7 @@ ATF_TC_BODY(aio_fsync_test, tc) ATF_REQUIRE_KERNEL_MODULE("aio"); ATF_REQUIRE_UNSAFE_AIO(); - fd = open(FILE_PATHNAME, O_RDWR | O_CREAT); + fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); unlink(FILE_PATHNAME); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r319575 - in head/bin/sh: . tests/errors
Author: jilles Date: Sun Jun 4 20:52:55 2017 New Revision: 319575 URL: https://svnweb.freebsd.org/changeset/base/319575 Log: sh: Fix INTOFF leak when a redirection on a compound command fails. Reported by: bdrewery Added: head/bin/sh/tests/errors/redirection-error8.0 (contents, props changed) Modified: head/bin/sh/eval.c head/bin/sh/tests/errors/Makefile Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Sun Jun 4 19:58:14 2017(r319574) +++ head/bin/sh/eval.c Sun Jun 4 20:52:55 2017(r319575) @@ -470,6 +470,7 @@ evalredir(union node *n, int flags) if (e == EXERROR || e == EXEXEC) { if (in_redirect) { exitstatus = 2; + FORCEINTON; return; } } Modified: head/bin/sh/tests/errors/Makefile == --- head/bin/sh/tests/errors/Makefile Sun Jun 4 19:58:14 2017 (r319574) +++ head/bin/sh/tests/errors/Makefile Sun Jun 4 20:52:55 2017 (r319575) @@ -29,6 +29,7 @@ ${PACKAGE}FILES+= redirection-error4.0 ${PACKAGE}FILES+= redirection-error5.0 ${PACKAGE}FILES+= redirection-error6.0 ${PACKAGE}FILES+= redirection-error7.0 +${PACKAGE}FILES+= redirection-error8.0 ${PACKAGE}FILES+= write-error1.0 .include Added: head/bin/sh/tests/errors/redirection-error8.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/errors/redirection-error8.0 Sun Jun 4 20:52:55 2017(r319575) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +$SH -c '{ { :; } /dev/null || kill -INT $$; echo continued' +r=$? +[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = INT ] ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r318592 - in head/usr.bin/compress: . tests
Author: jilles Date: Sun May 21 14:35:16 2017 New Revision: 318592 URL: https://svnweb.freebsd.org/changeset/base/318592 Log: compress: Allow uncompress -c with multiple pathnames, as required by POSIX. Per POSIX, allow passing multiple pathnames to uncompress -c, concatenating the uncompressed data. Passing multiple pathnames to compress -c remains disallowed, since the result cannot be decompressed. PR: 219387 Reported by: Jörg Schilling Modified: head/usr.bin/compress/compress.c head/usr.bin/compress/tests/compress_test.sh Modified: head/usr.bin/compress/compress.c == --- head/usr.bin/compress/compress.cSun May 21 14:05:32 2017 (r318591) +++ head/usr.bin/compress/compress.cSun May 21 14:35:16 2017 (r318592) @@ -129,7 +129,7 @@ main(int argc, char *argv[]) exit (eval); } - if (cat == 1 && argc > 1) + if (cat == 1 && style == COMPRESS && argc > 1) errx(1, "the -c option permits only a single file argument"); for (; *argv; ++argv) Modified: head/usr.bin/compress/tests/compress_test.sh == --- head/usr.bin/compress/tests/compress_test.shSun May 21 14:05:32 2017(r318591) +++ head/usr.bin/compress/tests/compress_test.shSun May 21 14:35:16 2017(r318592) @@ -161,6 +161,27 @@ compress_uncompress_file_2_body() atf_check cmp file2 expectfile2 } +atf_test_case compress_uncompress_file_minusc_1 +compress_uncompress_file_minusc_1_head() +{ + atf_set "descr" \ + "Test compressing and uncompressing some data, passing two filenames to uncompress -c" +} +compress_uncompress_file_minusc_1_body() +{ + printf '%01000d\n' 7 8 >expectfile1 + printf '%01000d\n' 8 7 >expectfile2 + cp expectfile1 file1 + cp expectfile2 file2 + atf_check compress file1 file2 + atf_check -s exit:1 cmp -s file1.Z expectfile1 + atf_check -s exit:1 cmp -s file2.Z expectfile2 + atf_check -s exit:1 cmp -s file1.Z file2.Z + atf_check -x 'uncompress -c file1.Z file2.Z >all' + atf_check -x 'cat expectfile1 expectfile2 >expectall' + atf_check cmp all expectall +} + atf_init_test_cases() { atf_add_test_case uncompress_file_1 @@ -171,4 +192,5 @@ atf_init_test_cases() atf_add_test_case compress_uncompress_minusc_1 atf_add_test_case compress_uncompress_file_1 atf_add_test_case compress_uncompress_file_2 + atf_add_test_case compress_uncompress_file_minusc_1 } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r318591 - in head: etc/mtree usr.bin/compress usr.bin/compress/tests
Author: jilles Date: Sun May 21 14:05:32 2017 New Revision: 318591 URL: https://svnweb.freebsd.org/changeset/base/318591 Log: compress: Add basic tests. Added: head/usr.bin/compress/tests/ head/usr.bin/compress/tests/Makefile (contents, props changed) head/usr.bin/compress/tests/compress_test.sh (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/usr.bin/compress/Makefile Modified: head/etc/mtree/BSD.tests.dist == --- head/etc/mtree/BSD.tests.dist Sun May 21 00:06:36 2017 (r318590) +++ head/etc/mtree/BSD.tests.dist Sun May 21 14:05:32 2017 (r318591) @@ -606,6 +606,8 @@ .. cmp .. +compress +.. cpio .. col Modified: head/usr.bin/compress/Makefile == --- head/usr.bin/compress/Makefile Sun May 21 00:06:36 2017 (r318590) +++ head/usr.bin/compress/Makefile Sun May 21 14:05:32 2017 (r318591) @@ -1,6 +1,8 @@ # @(#)Makefile8.2 (Berkeley) 4/17/94 # $FreeBSD$ +.include + PROG= compress SRCS= compress.c zopen.c LINKS= ${BINDIR}/compress ${BINDIR}/uncompress @@ -9,4 +11,8 @@ MLINKS=compress.1 uncompress.1 # XXX zopen is not part of libc # MAN=zopen.3 +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Added: head/usr.bin/compress/tests/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/compress/tests/MakefileSun May 21 14:05:32 2017 (r318591) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +PACKAGE= tests + +ATF_TESTS_SH= compress_test + +.include Added: head/usr.bin/compress/tests/compress_test.sh == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/compress/tests/compress_test.shSun May 21 14:05:32 2017(r318591) @@ -0,0 +1,174 @@ +# Copyright (c) 2017 Jilles Tjoelker <jil...@freebsd.org> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +#notice, this list of conditions and the following disclaimer in the +#documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +atf_test_case uncompress_file_1 +uncompress_file_1_head() +{ + atf_set "descr" \ + "Test uncompress without options, filename with .Z" +} +uncompress_file_1_body() +{ + printf '%01000d\n' 7 >expectfile1 + printf "\ +\037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\ +\310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\ +\152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\ +\050\123\252\134\211\360\206\002" >file1.Z + atf_check uncompress file1.Z + atf_check cmp file1 expectfile1 + atf_check test ! -e file1.Z +} + +atf_test_case uncompress_file_2 +uncompress_file_2_head() +{ + atf_set "descr" \ + "Test uncompress without options, filename without .Z" +} +uncompress_file_2_body() +{ + printf '%01000d\n' 7 >expectfile1 + printf "\ +\037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\ +\310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\ +\152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\ +\050\123\252\134\211\360\206\002" >file1.Z + atf_check uncompress file1 + atf_check cmp file1 expectfile1 + atf_check test ! -e file1.Z +} + +atf_test_case uncompress_stdio_1 +uncompress_stdio_1_head() +{ + atf_set "descr" \ + "Test un
svn commit: r318502 - head/bin/sh
Author: jilles Date: Thu May 18 22:10:04 2017 New Revision: 318502 URL: https://svnweb.freebsd.org/changeset/base/318502 Log: sh: Keep output buffer across builtins. Allocating and deallocating repeatedly the 1024-byte buffer for stdout from builtins costs CPU time for little or no benefit. A simple loop containing builtins that write to a file descriptor, such as i=0; while [ "$i" -lt 100 ]; do printf .; i=$((i+1)); done >/dev/null is over 10% faster in a simple benchmark on an amd64 virtual machine. Modified: head/bin/sh/output.c Modified: head/bin/sh/output.c == --- head/bin/sh/output.cThu May 18 21:44:14 2017(r318501) +++ head/bin/sh/output.cThu May 18 22:10:04 2017(r318502) @@ -254,14 +254,7 @@ flushout(struct output *dest) void freestdout(void) { - INTOFF; - if (output.buf) { - ckfree(output.buf); - output.nextc = NULL; - output.buf = NULL; - output.bufend = NULL; - } - INTON; + output.nextc = output.buf; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r318501 - head/bin/sh
Author: jilles Date: Thu May 18 21:44:14 2017 New Revision: 318501 URL: https://svnweb.freebsd.org/changeset/base/318501 Log: sh: Ensure memout.bufsize matches allocated buffer, if it exists. Modified: head/bin/sh/eval.c head/bin/sh/output.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Thu May 18 21:23:39 2017(r318500) +++ head/bin/sh/eval.c Thu May 18 21:44:14 2017(r318501) @@ -1081,8 +1081,6 @@ evalcommand(union node *cmd, int flags, mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH; if (flags == EV_BACKCMD) { memout.nextc = memout.buf; - memout.bufend = memout.buf; - memout.bufsize = 64; mode |= REDIR_BACKQ; } savecmdname = commandname; @@ -1139,6 +1137,7 @@ cmddone: memout.buf = NULL; memout.nextc = NULL; memout.bufend = NULL; + memout.bufsize = 64; } if (cmdentry.u.index != EXECCMD) popredir(); Modified: head/bin/sh/output.c == --- head/bin/sh/output.cThu May 18 21:23:39 2017(r318500) +++ head/bin/sh/output.cThu May 18 21:44:14 2017(r318501) @@ -73,7 +73,7 @@ static int doformat_wr(void *, const cha struct output output = {NULL, NULL, NULL, OUTBUFSIZ, 1, 0}; struct output errout = {NULL, NULL, NULL, 256, 2, 0}; -struct output memout = {NULL, NULL, NULL, 0, MEM_OUT, 0}; +struct output memout = {NULL, NULL, NULL, 64, MEM_OUT, 0}; struct output *out1 = struct output *out2 = @@ -208,7 +208,7 @@ outbin(const void *data, size_t len, str void emptyoutbuf(struct output *dest) { - int offset; + int offset, newsize; if (dest->buf == NULL) { INTOFF; @@ -218,10 +218,11 @@ emptyoutbuf(struct output *dest) INTON; } else if (dest->fd == MEM_OUT) { offset = dest->nextc - dest->buf; + newsize = dest->bufsize << 1; INTOFF; - dest->bufsize <<= 1; - dest->buf = ckrealloc(dest->buf, dest->bufsize); - dest->bufend = dest->buf + dest->bufsize; + dest->buf = ckrealloc(dest->buf, newsize); + dest->bufsize = newsize; + dest->bufend = dest->buf + newsize; dest->nextc = dest->buf + offset; INTON; } else { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r318385 - head/bin/sh
Author: jilles Date: Tue May 16 21:54:51 2017 New Revision: 318385 URL: https://svnweb.freebsd.org/changeset/base/318385 Log: sh: Simplify output buffering. Similarly to how STPUTC was changed, change struct output to store the pointer just past the end of the available space instead of the size of the available space, so after writing a character it is only necessary to increment a pointer and not to decrement a counter. Modified: head/bin/sh/eval.c head/bin/sh/output.c head/bin/sh/output.h Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue May 16 21:50:29 2017(r318384) +++ head/bin/sh/eval.c Tue May 16 21:54:51 2017(r318385) @@ -1080,8 +1080,8 @@ evalcommand(union node *cmd, int flags, #endif mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH; if (flags == EV_BACKCMD) { - memout.nleft = 0; memout.nextc = memout.buf; + memout.bufend = memout.buf; memout.bufsize = 64; mode |= REDIR_BACKQ; } @@ -1134,8 +1134,11 @@ cmddone: exitshell(exitstatus); if (flags == EV_BACKCMD) { backcmd->buf = memout.buf; - backcmd->nleft = memout.nextc - memout.buf; + backcmd->nleft = memout.buf != NULL ? + memout.nextc - memout.buf : 0; memout.buf = NULL; + memout.nextc = NULL; + memout.bufend = NULL; } if (cmdentry.u.index != EXECCMD) popredir(); Modified: head/bin/sh/output.c == --- head/bin/sh/output.cTue May 16 21:50:29 2017(r318384) +++ head/bin/sh/output.cTue May 16 21:54:51 2017(r318385) @@ -71,9 +71,9 @@ __FBSDID("$FreeBSD$"); static int doformat_wr(void *, const char *, int); -struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0}; -struct output errout = {NULL, 0, NULL, 256, 2, 0}; -struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0}; +struct output output = {NULL, NULL, NULL, OUTBUFSIZ, 1, 0}; +struct output errout = {NULL, NULL, NULL, 256, 2, 0}; +struct output memout = {NULL, NULL, NULL, 0, MEM_OUT, 0}; struct output *out1 = struct output *out2 = @@ -214,20 +214,19 @@ emptyoutbuf(struct output *dest) INTOFF; dest->buf = ckmalloc(dest->bufsize); dest->nextc = dest->buf; - dest->nleft = dest->bufsize; + dest->bufend = dest->buf + dest->bufsize; INTON; } else if (dest->fd == MEM_OUT) { - offset = dest->bufsize; + offset = dest->nextc - dest->buf; INTOFF; dest->bufsize <<= 1; dest->buf = ckrealloc(dest->buf, dest->bufsize); - dest->nleft = dest->bufsize - offset; + dest->bufend = dest->buf + dest->bufsize; dest->nextc = dest->buf + offset; INTON; } else { flushout(dest); } - dest->nleft--; } @@ -248,7 +247,6 @@ flushout(struct output *dest) if (xwrite(dest->fd, dest->buf, dest->nextc - dest->buf) < 0) dest->flags |= OUTPUT_ERR; dest->nextc = dest->buf; - dest->nleft = dest->bufsize; } @@ -258,8 +256,9 @@ freestdout(void) INTOFF; if (output.buf) { ckfree(output.buf); + output.nextc = NULL; output.buf = NULL; - output.nleft = 0; + output.bufend = NULL; } INTON; } Modified: head/bin/sh/output.h == --- head/bin/sh/output.hTue May 16 21:50:29 2017(r318384) +++ head/bin/sh/output.hTue May 16 21:54:51 2017(r318385) @@ -40,7 +40,7 @@ struct output { char *nextc; - int nleft; + char *bufend; char *buf; int bufsize; short fd; @@ -75,7 +75,7 @@ void fmtstr(char *, int, const char *, . void doformat(struct output *, const char *, va_list) __printflike(2, 0); int xwrite(int, const char *, int); -#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) +#define outc(c, file) ((file)->nextc == (file)->bufend ? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) #define out1c(c) outc(c, out1); #define out2c(c) outcslow(c, out2); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to
svn commit: r318269 - in head/bin/sh: . tests/builtins
Author: jilles Date: Sun May 14 13:14:19 2017 New Revision: 318269 URL: https://svnweb.freebsd.org/changeset/base/318269 Log: sh: Fix '-' from quoted arithmetic in case/glob pattern range. It does not make much sense to generate the '-' in a pattern bracket expression using arithmetic expansion, but it does not make sense to forbid it either. Try to avoid reprocessing the string if it is unnecessary. Added: head/bin/sh/tests/builtins/case22.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cSun May 14 12:41:58 2017(r318268) +++ head/bin/sh/expand.cSun May 14 13:14:19 2017(r318269) @@ -440,8 +440,15 @@ expari(const char *p, struct nodelist ** fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result); adj = strlen(expdest); STADJUST(adj, expdest); - if (!quoted) - reprocess(expdest - adj - stackblock(), flag, VSNORMAL, 0, dst); + /* +* If this is quoted, a '-' must not indicate a range in [...]. +* If this is not quoted, splitting may occur. +*/ + if (quoted ? + result < 0 && begoff > 1 && flag & (EXP_GLOB | EXP_CASE) : + flag & EXP_SPLIT) + reprocess(expdest - adj - stackblock(), flag, VSNORMAL, quoted, + dst); return p; } Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Sun May 14 12:41:58 2017 (r318268) +++ head/bin/sh/tests/builtins/Makefile Sun May 14 13:14:19 2017 (r318269) @@ -41,6 +41,7 @@ ${PACKAGE}FILES+= case18.0 ${PACKAGE}FILES+= case19.0 ${PACKAGE}FILES+= case20.0 ${PACKAGE}FILES+= case21.0 +${PACKAGE}FILES+= case22.0 ${PACKAGE}FILES+= cd1.0 ${PACKAGE}FILES+= cd2.0 ${PACKAGE}FILES+= cd3.0 Added: head/bin/sh/tests/builtins/case22.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/case22.0 Sun May 14 13:14:19 2017 (r318269) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +case 5 in +[0"$((-9))"]) echo bad1 ;; +esac + +case - in +[0"$((-9))"]) ;; +*) echo bad2 ;; +esac ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r318258 - head/bin/sh/tests/builtins
Author: jilles Date: Sat May 13 20:28:32 2017 New Revision: 318258 URL: https://svnweb.freebsd.org/changeset/base/318258 Log: sh: Add test for arithmetic expansion in [x-y] pattern range. It does not make much sense to generate the '-' in a pattern bracket expression using arithmetic expansion, but it does not make sense to forbid it either. This test already passes. Added: head/bin/sh/tests/builtins/case21.0 (contents, props changed) Modified: head/bin/sh/tests/builtins/Makefile Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Sat May 13 19:59:03 2017 (r318257) +++ head/bin/sh/tests/builtins/Makefile Sat May 13 20:28:32 2017 (r318258) @@ -40,6 +40,7 @@ ${PACKAGE}FILES+= case17.0 ${PACKAGE}FILES+= case18.0 ${PACKAGE}FILES+= case19.0 ${PACKAGE}FILES+= case20.0 +${PACKAGE}FILES+= case21.0 ${PACKAGE}FILES+= cd1.0 ${PACKAGE}FILES+= cd2.0 ${PACKAGE}FILES+= cd3.0 Added: head/bin/sh/tests/builtins/case21.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/case21.0 Sat May 13 20:28:32 2017 (r318258) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +case 5 in +[0$((-9))]) ;; +*) echo bad1 ;; +esac + +case - in +[0$((-9))]) echo bad2 ;; +esac ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r317913 - head/lib/libc/gen
Author: jilles Date: Sun May 7 19:52:56 2017 New Revision: 317913 URL: https://svnweb.freebsd.org/changeset/base/317913 Log: glob: Fix comment about collapsing asterisks after r317749. After r317749, collapsing adjacent asterisks is still required, but for a different reason. Modified: head/lib/libc/gen/glob.c Modified: head/lib/libc/gen/glob.c == --- head/lib/libc/gen/glob.cSun May 7 19:49:46 2017(r317912) +++ head/lib/libc/gen/glob.cSun May 7 19:52:56 2017(r317913) @@ -581,7 +581,8 @@ glob0(const Char *pattern, glob_t *pglob case STAR: pglob->gl_flags |= GLOB_MAGCHAR; /* collapse adjacent stars to one, -* to avoid exponential behavior +* to ensure "**" at the end continues to match the +* empty string */ if (bufnext == patbuf || bufnext[-1] != M_ALL) *bufnext++ = M_ALL; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r317912 - in head/bin/sh: . tests/builtins
Author: jilles Date: Sun May 7 19:49:46 2017 New Revision: 317912 URL: https://svnweb.freebsd.org/changeset/base/317912 Log: sh: Fix INTOFF leak after a builtin with different locale settings. After executing a builtin with different locale settings such as LC_ALL=C true SIGINT handling was left disabled indefinitely. MFC after:1 week Added: head/bin/sh/tests/builtins/locale2.0 (contents, props changed) Modified: head/bin/sh/tests/builtins/Makefile head/bin/sh/var.c Modified: head/bin/sh/tests/builtins/Makefile == --- head/bin/sh/tests/builtins/Makefile Sun May 7 19:47:50 2017 (r317911) +++ head/bin/sh/tests/builtins/Makefile Sun May 7 19:49:46 2017 (r317912) @@ -120,6 +120,7 @@ ${PACKAGE}FILES+= local7.0 .if ${MK_NLS} != "no" ${PACKAGE}FILES+= locale1.0 .endif +${PACKAGE}FILES+= locale2.0 ${PACKAGE}FILES+= printf1.0 ${PACKAGE}FILES+= printf2.0 ${PACKAGE}FILES+= printf3.0 Added: head/bin/sh/tests/builtins/locale2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/locale2.0Sun May 7 19:49:46 2017 (r317912) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +$SH -c 'LC_ALL=C true; kill -INT $$; echo continued' +r=$? +[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = INT ] Modified: head/bin/sh/var.c == --- head/bin/sh/var.c Sun May 7 19:47:50 2017(r317911) +++ head/bin/sh/var.c Sun May 7 19:49:46 2017(r317912) @@ -513,7 +513,7 @@ bltinunsetlocale(void) if (localevar(cmdenviron->args[i])) { setlocale(LC_ALL, ""); updatecharset(); - return; + break; } } INTON; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r317909 - head/usr.bin/resizewin
On Sun, May 07, 2017 at 09:01:43PM +0300, Konstantin Belousov wrote: > On Sun, May 07, 2017 at 05:21:23PM +, Edward Tomasz Napierala wrote: > > Author: trasz > > Date: Sun May 7 17:21:22 2017 > > New Revision: 317909 > > URL: https://svnweb.freebsd.org/changeset/base/317909 > > Log: > > Make resizewin(1) discard the terminal queues, to lower the chance > > for "unable to parse response" error which happens when youre typing > > too fast for the machine you're running it on. > > Reviewed by: cem, Daniel O'Connor <dar...@dons.net.au> > > MFC after:2 weeks > > Sponsored by: DARPA, AFRL > > Differential Revision:https://reviews.freebsd.org/D10624 > > Modified: > > head/usr.bin/resizewin/resizewin.c > > > > Modified: head/usr.bin/resizewin/resizewin.c > > == > > --- head/usr.bin/resizewin/resizewin.c Sun May 7 14:59:45 2017 > > (r317908) > > +++ head/usr.bin/resizewin/resizewin.c Sun May 7 17:21:22 2017 > > (r317909) > > @@ -52,7 +52,7 @@ main(__unused int argc, __unused char ** > > { > > struct termios old, new; > > struct winsize w; > > - int ret, fd, cnt, error; > > + int ret, fd, cnt, error, what; > > char data[20]; > > struct timeval then, now; > > > > @@ -71,6 +71,12 @@ main(__unused int argc, __unused char ** > > if (tcsetattr(fd, TCSANOW, ) == -1) > > exit(1); > > > > + /* Discard input received so far */ > > + what = FREAD | FWRITE; > > + error = ioctl(fd, TIOCFLUSH, ); > This is correctly spelled tcflush(fd, TCIOFLUSH); Alternatively, the above TCSANOW could be changed to TCSAFLUSH. The effect is slightly different in that pending output is drained instead of discarded. In any case, the TIOCFLUSH ioctl is non-standard and should not be used directly. -- Jilles Tjoelker ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r317882 - head/bin/sh
Author: jilles Date: Sat May 6 13:28:42 2017 New Revision: 317882 URL: https://svnweb.freebsd.org/changeset/base/317882 Log: sh: Update TOUR and comments for some code changes, some of them old. Also, improve some terminology in TOUR and comments. Modified: head/bin/sh/TOUR head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/expand.c head/bin/sh/options.c Modified: head/bin/sh/TOUR == --- head/bin/sh/TOURSat May 6 11:18:36 2017(r317881) +++ head/bin/sh/TOURSat May 6 13:28:42 2017(r317882) @@ -24,7 +24,7 @@ programs is: program input files generates --- --- - -mkbuiltins builtinsbuiltins.h builtins.c +mkbuiltins builtins.defbuiltins.h builtins.c mknodes nodetypes nodes.h nodes.c mksyntax- syntax.h syntax.c mktokens- token.h @@ -108,10 +108,12 @@ The text field of a NARG structure point word. The text consists of ordinary characters and a number of special codes defined in parser.h. The special codes are: -CTLVAR Variable substitution -CTLENDVAR End of variable substitution +CTLVAR Parameter expansion +CTLENDVAR End of parameter expansion CTLBACKQCommand substitution CTLBACKQ|CTLQUOTE Command substitution inside double quotes +CTLARI Arithmetic expansion +CTLENDARI End of arithmetic expansion CTLESC Escape next character A variable substitution contains the following elements: @@ -130,18 +132,31 @@ stitution. The possible types are: VSQUESTION|VSNUL${var:?text} VSASSIGN${var=text} VSASSIGN|VSNUL ${var:=text} +VSTRIMLEFT ${var#text} +VSTRIMLEFTMAX ${var##text} +VSTRIMRIGHT ${var%text} +VSTRIMRIGHTMAX ${var%%text} +VSLENGTH${#var} +VSERROR delayed error In addition, the type field will have the VSQUOTE flag set if the -variable is enclosed in double quotes. The name of the variable -comes next, terminated by an equals sign. If the type is not -VSNORMAL, then the text field in the substitution follows, ter- -minated by a CTLENDVAR byte. +variable is enclosed in double quotes and the VSLINENO flag if +LINENO is being expanded (the parameter name is the decimal line +number). The parameter's name comes next, terminated by an equals +sign. If the type is not VSNORMAL (including when it is VSLENGTH), +then the text field in the substitution follows, terminated by a +CTLENDVAR byte. + +The type VSERROR is used to allow parsing bad substitutions like +${var[7]} and generate an error when they are expanded. Commands in back quotes are parsed and stored in a linked list. The locations of these commands in the string are indicated by CTLBACKQ and CTLBACKQ+CTLQUOTE characters, depending upon whether the back quotes were enclosed in double quotes. +Arithmetic expansion starts with CTLARI and ends with CTLENDARI. + The character CTLESC escapes the next character, so that in case any of the CTL characters mentioned above appear in the input, they can be passed through transparently. CTLESC is also used to @@ -153,11 +168,11 @@ right. In the case of here documents wh variable and command substitution, the parser doesn't insert any CTLESC characters to begin with (so the contents of the text field can be written without any processing). Other here docu- -ments, and words which are not subject to splitting and file name -generation, have the CTLESC characters removed during the vari- -able and command substitution phase. Words which are subject to -splitting and file name generation have the CTLESC characters re- -moved as part of the file name phase. +ments, and words which are not subject to file name generation, +have the CTLESC characters removed during the variable and command +substitution phase. Words which are subject to file name +generation have the CTLESC characters removed as part of the file +name phase. EXECUTION: Command execution is handled by the following files: eval.c The top level routines. @@ -199,10 +214,10 @@ later.) The routine shellexec is the interface to the exec system call. -EXPAND.C: Arguments are processed in three passes. The first -(performed by the routine argstr) performs variable and command -substitution. The second (ifsbreakup) performs word splitting -and the third (expandmeta) performs file name generation. +EXPAND.C: As the routine argstr generates words by parameter +expansion, command substitution and arithmetic expansion, it +performs word splitting on the result. As each word
svn commit: r317709 - head/usr.bin/csplit
Author: jilles Date: Tue May 2 21:56:20 2017 New Revision: 317709 URL: https://svnweb.freebsd.org/changeset/base/317709 Log: csplit: Fix check of fputs() return value, making csplit work again. As of r295638, fputs() returns the number of bytes written (if not more than INT_MAX). This broke csplit completely, since csplit assumed only success only for the return value 0. PR: 213510 Submitted by: J.R. Oldroyd MFC after:1 week Relnotes: yes Modified: head/usr.bin/csplit/csplit.c Modified: head/usr.bin/csplit/csplit.c == --- head/usr.bin/csplit/csplit.cTue May 2 21:33:27 2017 (r317708) +++ head/usr.bin/csplit/csplit.cTue May 2 21:56:20 2017 (r317709) @@ -195,7 +195,7 @@ main(int argc, char *argv[]) /* Copy the rest into a new file. */ if (!feof(infile)) { ofp = newfile(); - while ((p = get_line()) != NULL && fputs(p, ofp) == 0) + while ((p = get_line()) != NULL && fputs(p, ofp) != EOF) ; if (!sflag) printf("%jd\n", (intmax_t)ftello(ofp)); @@ -392,7 +392,7 @@ do_rexp(const char *expr) /* Read and output lines until we get a match. */ first = 1; while ((p = get_line()) != NULL) { - if (fputs(p, ofp) != 0) + if (fputs(p, ofp) == EOF) break; if (!first && regexec(, p, 0, NULL, 0) == 0) break; @@ -453,7 +453,7 @@ do_lineno(const char *expr) while (lineno + 1 != lastline) { if ((p = get_line()) == NULL) errx(1, "%ld: out of range", lastline); - if (fputs(p, ofp) != 0) + if (fputs(p, ofp) == EOF) break; } if (!sflag) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r317598 - head/usr.bin/printf
Author: jilles Date: Sat Apr 29 21:48:11 2017 New Revision: 317598 URL: https://svnweb.freebsd.org/changeset/base/317598 Log: printf: Output formatted data directly, instead of via asprintf. Long ago, sh used to have its own optimized and restricted string formatting implementation, which the printf builtin had to bypass via asprintf() to a temporary buffer. Since sh has used libc's string formatting implementation for a long time, remove the workaround. Add a check to keep printf %c '' working the same way (output nothing); POSIX allows both outputting nothing and outputting a NUL byte. Also, this change avoids silently discarding format directives for whose output asprintf() cannot allocate memory. Modified: head/usr.bin/printf/printf.c Modified: head/usr.bin/printf/printf.c == --- head/usr.bin/printf/printf.cSat Apr 29 19:20:50 2017 (r317597) +++ head/usr.bin/printf/printf.cSat Apr 29 21:48:11 2017 (r317598) @@ -70,20 +70,15 @@ static const char rcsid[] = #endif #definePF(f, func) do { \ - char *b = NULL; \ if (havewidth) \ if (haveprec) \ - (void)asprintf(, f, fieldwidth, precision, func); \ + (void)printf(f, fieldwidth, precision, func); \ else\ - (void)asprintf(, f, fieldwidth, func);\ + (void)printf(f, fieldwidth, func); \ else if (haveprec) \ - (void)asprintf(, f, precision, func); \ + (void)printf(f, precision, func); \ else\ - (void)asprintf(, f, func);\ - if (b) {\ - (void)fputs(b, stdout); \ - free(b);\ - } \ + (void)printf(f, func); \ } while (0) static int asciicode(void); @@ -394,7 +389,8 @@ printf_doformat(char *fmt, int *rval) char p; p = getchr(); - PF(start, p); + if (p != '\0') + PF(start, p); break; } case 's': { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r317559 - head/bin/sh
Author: jilles Date: Fri Apr 28 16:16:22 2017 New Revision: 317559 URL: https://svnweb.freebsd.org/changeset/base/317559 Log: sh: Simplify handling of newlines in command substitution. Unless we need to split on newlines, just append them as normal and remove them at the end. Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cFri Apr 28 15:38:34 2017(r317558) +++ head/bin/sh/expand.cFri Apr 28 16:16:22 2017(r317559) @@ -462,6 +462,7 @@ expbackq(union node *cmd, int quoted, in int quotes = flag & (EXP_GLOB | EXP_CASE); size_t nnl; const char *ifs; + int startloc; INTOFF; p = grabstackstr(dest); @@ -469,6 +470,7 @@ expbackq(union node *cmd, int quoted, in ungrabstackstr(p, dest); p = in.buf; + startloc = dest - stackblock(); nnl = 0; if (!quoted && flag & EXP_SPLIT) ifs = ifsset() ? ifsval() : " \t\n"; @@ -490,31 +492,24 @@ expbackq(union node *cmd, int quoted, in lastc = *p++; if (lastc == '\0') continue; - if (lastc == '\n') { - nnl++; - } else { - if (nnl > 0) { - if (strchr(ifs, '\n') != NULL) { - NEXTWORD('\n', flag, dest, dst); - nnl = 0; - } else { - CHECKSTRSPACE(nnl + 2, dest); - while (nnl > 0) { - nnl--; - USTPUTC('\n', dest); - } - } - } - if (strchr(ifs, lastc) != NULL) + if (nnl > 0 && lastc != '\n') { + NEXTWORD('\n', flag, dest, dst); + nnl = 0; + } + if (strchr(ifs, lastc) != NULL) { + if (lastc == '\n') + nnl++; + else NEXTWORD(lastc, flag, dest, dst); - else { - CHECKSTRSPACE(2, dest); - if (quotes && syntax[(int)lastc] == CCTL) - USTPUTC(CTLESC, dest); - USTPUTC(lastc, dest); - } + } else { + CHECKSTRSPACE(2, dest); + if (quotes && syntax[(int)lastc] == CCTL) + USTPUTC(CTLESC, dest); + USTPUTC(lastc, dest); } } + while (dest > stackblock() + startloc && STTOPC(dest) == '\n') + STUNPUTC(dest); if (in.fd >= 0) close(in.fd); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"