CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Nov 16 11:27:50 UTC 2021 Modified Files: src/bin/sh: eval.c miscbltin.c redir.c Log Message: Detect write errors to stdout, and exit(1) from some built-in commands which (primarily) are used just to generate output (or with a particular option combination do so). To generate a diff of this commit: cvs rdiff -u -r1.184 -r1.185 src/bin/sh/eval.c cvs rdiff -u -r1.45 -r1.46 src/bin/sh/miscbltin.c cvs rdiff -u -r1.70 -r1.71 src/bin/sh/redir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.184 src/bin/sh/eval.c:1.185 --- src/bin/sh/eval.c:1.184 Tue Nov 16 11:25:44 2021 +++ src/bin/sh/eval.c Tue Nov 16 11:27:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.184 2021/11/16 11:25:44 kre Exp $ */ +/* $NetBSD: eval.c,v 1.185 2021/11/16 11:27:50 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.184 2021/11/16 11:25:44 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.185 2021/11/16 11:27:50 kre Exp $"); #endif #endif /* not lint */ @@ -1346,6 +1346,7 @@ evalcommand(union node *cmd, int flgs, s optreset = 1; optind = 1; builtin_flags = flags; + clr_err(out1); /* discard previous I/O errors */ exitstatus = cmdentry.u.bltin(argc, argv); } else { e = exception; Index: src/bin/sh/miscbltin.c diff -u src/bin/sh/miscbltin.c:1.45 src/bin/sh/miscbltin.c:1.46 --- src/bin/sh/miscbltin.c:1.45 Wed Sep 15 18:30:57 2021 +++ src/bin/sh/miscbltin.c Tue Nov 16 11:27:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: miscbltin.c,v 1.45 2021/09/15 18:30:57 kre Exp $ */ +/* $NetBSD: miscbltin.c,v 1.46 2021/11/16 11:27:50 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: miscbltin.c,v 1.45 2021/09/15 18:30:57 kre Exp $"); +__RCSID("$NetBSD: miscbltin.c,v 1.46 2021/11/16 11:27:50 kre Exp $"); #endif #endif /* not lint */ @@ -288,6 +288,11 @@ umaskcmd(int argc, char **argv) umask(~mask & 0777); } } + flushout(out1); + if (io_err(out1)) { + out2str("umask: I/O error\n"); + return 1; + } return 0; } @@ -445,7 +450,7 @@ ulimitcmd(int argc, char **argv) out1fmt("%c", which ? '\t' : '\n'); } } - return 0; + goto done; } if (getrlimit(l->cmd, ) == -1) @@ -477,5 +482,11 @@ ulimitcmd(int argc, char **argv) #endif } } + done:; + flushout(out1); + if (io_err(out1)) { + out2str("ulimit: I/O error (stdout)\n"); + return 1; + } return 0; } Index: src/bin/sh/redir.c diff -u src/bin/sh/redir.c:1.70 src/bin/sh/redir.c:1.71 --- src/bin/sh/redir.c:1.70 Wed Nov 10 15:26:34 2021 +++ src/bin/sh/redir.c Tue Nov 16 11:27:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: redir.c,v 1.70 2021/11/10 15:26:34 kre Exp $ */ +/* $NetBSD: redir.c,v 1.71 2021/11/16 11:27:50 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: redir.c,v 1.70 2021/11/10 15:26:34 kre Exp $"); +__RCSID("$NetBSD: redir.c,v 1.71 2021/11/16 11:27:50 kre Exp $"); #endif #endif /* not lint */ @@ -1033,10 +1033,8 @@ fdflagscmd(int argc, char *argv[]) for (i = 0; i <= max_user_fd; i++) printone(i, 0, verbose, 1); - return 0; - } - while ((num = *argv++) != NULL) { + } else while ((num = *argv++) != NULL) { int fd = number(num); while (num[0] == '0' && num[1] != '\0') /* skip 0's */ @@ -1050,6 +1048,11 @@ fdflagscmd(int argc, char *argv[]) else printone(fd, 1, verbose, argc > 1); } + flushout(out1); + if (io_err(out1)) { + out2str("fdflags: I/O error\n"); + return 1; + } return 0; }
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Tue Nov 16 11:15:26 UTC 2021 Modified Files: src/tests/bin/sh: t_redir.sh Log Message: Fix a test that has been (unnoticed) failing ever since printf(1) was changed to exit(1) when it detects a write error to stdout. Running printf with stdout closed is guaranteed to generate such a condition. Until the previous commit, while the test case was actually failing (stderr was expected to be empty. and was not) this was unnoticed. We don't want the output (obviously), we also don't want the error message, so just direct the latter to /dev/null. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/bin/sh/t_redir.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Tue Nov 16 11:15:26 UTC 2021 Modified Files: src/tests/bin/sh: t_redir.sh Log Message: Fix a test that has been (unnoticed) failing ever since printf(1) was changed to exit(1) when it detects a write error to stdout. Running printf with stdout closed is guaranteed to generate such a condition. Until the previous commit, while the test case was actually failing (stderr was expected to be empty. and was not) this was unnoticed. We don't want the output (obviously), we also don't want the error message, so just direct the latter to /dev/null. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/bin/sh/t_redir.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/bin/sh/t_redir.sh diff -u src/tests/bin/sh/t_redir.sh:1.12 src/tests/bin/sh/t_redir.sh:1.13 --- src/tests/bin/sh/t_redir.sh:1.12 Tue Nov 16 11:12:14 2021 +++ src/tests/bin/sh/t_redir.sh Tue Nov 16 11:15:26 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_redir.sh,v 1.12 2021/11/16 11:12:14 kre Exp $ +# $NetBSD: t_redir.sh,v 1.13 2021/11/16 11:15:26 kre Exp $ # # Copyright (c) 2016 The NetBSD Foundation, Inc. # All rights reserved. @@ -927,7 +927,7 @@ validate_fn_redirects_body() echo ' . ./f-def || echo >&2 FAIL - f >&- + f >&- 2>/dev/null printf "%s\n" stdin2 ' | atf_check -s exit:0 -o inline:'stdin2\n' -e empty ${TEST_SH} || atf_fail "stdin2 test failure"
CVS commit: src/bin
Module Name:src Committed By: kre Date: Tue Nov 16 16:57:15 UTC 2021 Modified Files: src/bin/pwd: pwd.c src/bin/sh: cd.c Log Message: Make pwd (both /bin/pwd and the /bin/sh built-in version) check for write errors on stdout, and indicate an error if that happens. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/bin/pwd/pwd.c cvs rdiff -u -r1.51 -r1.52 src/bin/sh/cd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin
Module Name:src Committed By: kre Date: Tue Nov 16 16:57:15 UTC 2021 Modified Files: src/bin/pwd: pwd.c src/bin/sh: cd.c Log Message: Make pwd (both /bin/pwd and the /bin/sh built-in version) check for write errors on stdout, and indicate an error if that happens. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/bin/pwd/pwd.c cvs rdiff -u -r1.51 -r1.52 src/bin/sh/cd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pwd/pwd.c diff -u src/bin/pwd/pwd.c:1.22 src/bin/pwd/pwd.c:1.23 --- src/bin/pwd/pwd.c:1.22 Mon Aug 29 14:51:19 2011 +++ src/bin/pwd/pwd.c Tue Nov 16 16:57:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pwd.c,v 1.22 2011/08/29 14:51:19 joerg Exp $ */ +/* $NetBSD: pwd.c,v 1.23 2021/11/16 16:57:15 kre Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)pwd.c 8.3 (Berkeley) 4/1/94"; #else -__RCSID("$NetBSD: pwd.c,v 1.22 2011/08/29 14:51:19 joerg Exp $"); +__RCSID("$NetBSD: pwd.c,v 1.23 2021/11/16 16:57:15 kre Exp $"); #endif #endif /* not lint */ @@ -107,6 +107,10 @@ main(int argc, char *argv[]) (void)printf("%s\n", p); + (void)fflush(stdout); + if (ferror(stdout)) + err(EXIT_FAILURE, "stdout"); + exit(EXIT_SUCCESS); /* NOTREACHED */ } Index: src/bin/sh/cd.c diff -u src/bin/sh/cd.c:1.51 src/bin/sh/cd.c:1.52 --- src/bin/sh/cd.c:1.51 Sun Oct 31 02:12:01 2021 +++ src/bin/sh/cd.c Tue Nov 16 16:57:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $ */ +/* $NetBSD: cd.c,v 1.52 2021/11/16 16:57:15 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $"); +__RCSID("$NetBSD: cd.c,v 1.52 2021/11/16 16:57:15 kre Exp $"); #endif #endif /* not lint */ @@ -364,8 +364,15 @@ pwdcmd(int argc, char **argv) if (curdir == NULL) error("Unable to find current directory"); } + + flushout(out1); /* make sure buffer is empty */ + clr_err(out1); /* and forget any earlier errors */ out1str(curdir); out1c('\n'); + flushout(out1); + if (io_err(out1)) + error("stdout: %s", strerror(errno)); + return 0; }
Re: CVS commit: src/etc/rc.d
Date:Fri, 26 Nov 2021 13:11:36 + From:"Stephen Borrill" Message-ID: <20211126131136.63fabf...@cvs.netbsd.org> | Load rc configuration based on rcvar, not name, so that correct settings | in /etc/rc.conf.d are loaded. This looks wrong to me (and a pullup request so soon after making a change, before it has had any time for testing in HEAD is a *really* bad idea). | Usually this does not matter as rcvar and name are set to the same value. | For pf_boot and npf_boot, rcvar is set to pf and npf respectively. | | Prior to the change, if: | rc.conf contains nfp=YES [ignoring the typo there] | rc.conf.d/npf does not exist Nor should it, that's not the file that is supposed to be used. In rc.conf(5): rc.d(8) scripts that use load_rc_config from rc.subr(8) also support sourcing an optional end-user provided per-script override file /etc/rc.conf.d/service, (where service is the contents of the name variable in the rc.d(8) script). That is, what should happen to make this work... | If: | rc.conf contains npf=NO (or is not set) | rc.conf.d/npf contains npf=YES is that rc.conf.d/npf_boot should contain npf=YES The rc.conf.d files have the same names as the rc.d/script files in general, for good reason, as while they often only contain this rcvar setting, they can contain overrides to anything in the script. Further, if there is more than one rcvar in a script (which I think has happened once or twice) the settings for both of them would go in the same file, not one file for each of them. | This means that in the latter case, at boot time the npfctl start command | is never run and the firewall is not operational. Because of user error. Please revert this change, and request the pullup be undone as well. kre
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:21:54 UTC 2021 Modified Files: src/tests/bin/sh: t_here.sh Log Message: PR bin/53550 /bin/sh's processing of here doc expansions has changed. Now it happens in the context of the parent shell, so side effects are visible there, just like all other redirection expansions. We need to stop testing that that doesn't happen, and instead test that it does. This is that change. Add another test case which is testing exactly the example from the PR (well, with a different exit status, 1 is too generic and could happen by accident) to make sure we don't reintroduce that bug sometime. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/bin/sh/t_here.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/bin/sh/t_here.sh diff -u src/tests/bin/sh/t_here.sh:1.8 src/tests/bin/sh/t_here.sh:1.9 --- src/tests/bin/sh/t_here.sh:1.8 Thu Sep 9 00:04:51 2021 +++ src/tests/bin/sh/t_here.sh Mon Nov 22 05:21:54 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_here.sh,v 1.8 2021/09/09 00:04:51 kre Exp $ +# $NetBSD: t_here.sh,v 1.9 2021/11/22 05:21:54 kre Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -515,13 +515,36 @@ quoting_body() { results } +# +# This next test is really just testing what our shell happens to do. +# There doesn't seem to be any spec on in which context expansions +# in redirects are processed. Most shells do them in the parent +# shell context, meaning that side effects of the expansion become +# visible to the shell - a couple process redirect expansions in +# a subshell, meaning that side effects are lost. +# +# Before PR bin/53550 was fixed, the NetBSD sh evaluated all redirect +# expansions, except here documents, in the context of the shell, and +# here document redirects in a subshell context. That distinction +# makes no real sense (and only an old, and maybe still current, FreeBSD +# shell shares that pecadillo.) Afer that fix, the NetBSD shell joins +# almost all others in expanding redirects (all of them) in the shell +# context, meaning that side effects of here documenty expansions become +# visible in the shell. +# +# Before the fix, we used to get "2\n1\n" as the output from this +# test, now the variable assignment in the here document persists +# and we get "2\n2\n" as do most other shells. (bash is a notable +# exception, but it does all redirect expansions in a subshell context) +# + atf_test_case side_effects side_effects_head() { atf_set "descr" "Tests how side effects in here documents are handled" } side_effects_body() { - atf_check -s exit:0 -o inline:'2\n1\n' -e empty ${TEST_SH} -c ' + atf_check -s exit:0 -o inline:'2\n2\n' -e empty ${TEST_SH} -c ' unset X cat <<-EOF ${X=2} @@ -530,6 +553,23 @@ side_effects_body() { ' } +# This is a test for the specific bug reported in PR bin/53550 +# This should work in any shell. + +atf_test_case exit_status +exit_status_head() { + atf_set descr "Tests exit status of a command substitution in a heredoc" +} +exit_status_body() { + + # PR bin/53550 test + atf_check -s exit:7 -o empty -e empty ${TEST_SH} -c ' + <<-EOF + $(exit 7) + EOF + ' +} + # The following tests a problem reported on the austin-list 2021-09-08 # by oguzismailuy...@gmail.com ... it affected all ash derived shells atf_test_case hard_cases @@ -623,6 +663,7 @@ vicious_body() { atf_init_test_cases() { atf_add_test_case do_simple # not worthy of a comment atf_add_test_case end_markers # the mundane, the weird, the bizarre + atf_add_test_case exit_status # PR bin/53550, cmdsub in heredoc atf_add_test_case incomplete # where the end marker isn't... atf_add_test_case lineends # test weird line endings in heredocs atf_add_test_case multiple # multiple << operators on one cmd
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:21:54 UTC 2021 Modified Files: src/tests/bin/sh: t_here.sh Log Message: PR bin/53550 /bin/sh's processing of here doc expansions has changed. Now it happens in the context of the parent shell, so side effects are visible there, just like all other redirection expansions. We need to stop testing that that doesn't happen, and instead test that it does. This is that change. Add another test case which is testing exactly the example from the PR (well, with a different exit status, 1 is too generic and could happen by accident) to make sure we don't reintroduce that bug sometime. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/bin/sh/t_here.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:07:15 UTC 2021 Modified Files: src/tests/bin/sh: t_option.sh t_syntax.sh t_varval.sh Log Message: More tests that were doing ... | atf_check ... which allows the atf_check to fail without causing the test to fail (unless this is the (very) last command in the test case, in which case it will fail with what can be interpreted as an internal error)/ Check for this failing and explicitly atf_fail whwn it does. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_option.sh cvs rdiff -u -r1.11 -r1.12 src/tests/bin/sh/t_syntax.sh cvs rdiff -u -r1.1 -r1.2 src/tests/bin/sh/t_varval.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:07:15 UTC 2021 Modified Files: src/tests/bin/sh: t_option.sh t_syntax.sh t_varval.sh Log Message: More tests that were doing ... | atf_check ... which allows the atf_check to fail without causing the test to fail (unless this is the (very) last command in the test case, in which case it will fail with what can be interpreted as an internal error)/ Check for this failing and explicitly atf_fail whwn it does. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_option.sh cvs rdiff -u -r1.11 -r1.12 src/tests/bin/sh/t_syntax.sh cvs rdiff -u -r1.1 -r1.2 src/tests/bin/sh/t_varval.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/bin/sh/t_option.sh diff -u src/tests/bin/sh/t_option.sh:1.7 src/tests/bin/sh/t_option.sh:1.8 --- src/tests/bin/sh/t_option.sh:1.7 Thu Jul 11 03:49:51 2019 +++ src/tests/bin/sh/t_option.sh Mon Nov 22 05:07:15 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_option.sh,v 1.7 2019/07/11 03:49:51 msaitoh Exp $ +# $NetBSD: t_option.sh,v 1.8 2021/11/22 05:07:15 kre Exp $ # # Copyright (c) 2016 The NetBSD Foundation, Inc. # All rights reserved. @@ -454,7 +454,8 @@ set_v_body() { -o not-match:for -o not-match:do -o not-match:done \ -e match:printf -e match:111 -e not-match:111222 \ -e match:for -e match:do -e match:done \ -${TEST_SH} +${TEST_SH} || + atf_fail '111 222 333 test failure' } atf_test_case set_x Index: src/tests/bin/sh/t_syntax.sh diff -u src/tests/bin/sh/t_syntax.sh:1.11 src/tests/bin/sh/t_syntax.sh:1.12 --- src/tests/bin/sh/t_syntax.sh:1.11 Tue Nov 16 11:12:14 2021 +++ src/tests/bin/sh/t_syntax.sh Mon Nov 22 05:07:15 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_syntax.sh,v 1.11 2021/11/16 11:12:14 kre Exp $ +# $NetBSD: t_syntax.sh,v 1.12 2021/11/22 05:07:15 kre Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -113,7 +113,7 @@ b_comments_body() { atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \ 'echo \## #\#' - cat <<-'DONE'|atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} + cat <<-'DONE' | # test comments do not provoke synax errors !\ echo foo # ( { " hello while : # that's forever @@ -124,6 +124,8 @@ b_comments_body() { # "hello exit 0 DONE + atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} || + atf_fail "ignoring comments" } atf_test_case c_line_wrapping Index: src/tests/bin/sh/t_varval.sh diff -u src/tests/bin/sh/t_varval.sh:1.1 src/tests/bin/sh/t_varval.sh:1.2 --- src/tests/bin/sh/t_varval.sh:1.1 Wed Mar 16 15:49:19 2016 +++ src/tests/bin/sh/t_varval.sh Mon Nov 22 05:07:15 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_varval.sh,v 1.1 2016/03/16 15:49:19 christos Exp $ +# $NetBSD: t_varval.sh,v 1.2 2021/11/22 05:07:15 kre Exp $ # # Copyright (c) 2016 The NetBSD Foundation, Inc. # All rights reserved. @@ -82,23 +82,28 @@ aaa_head() { aaa_body() { oneline "echo " 9 '' | atf_check -s exit:0 -o inline:'prefix\tsuffix\n' -e empty \ - ${TEST_SH} + ${TEST_SH} || +atf_fail 'echo 9 -> tab' oneline "VAR=" 65 '; echo "${#VAR}:${VAR}"' | atf_check -s exit:0 -o inline:'13:prefixAsuffix\n' -e empty \ - ${TEST_SH} + ${TEST_SH} || +atf_fail '65 -> A' oneline "VAR=" 1 '; echo "${#VAR}:${VAR}"' | atf_check -s exit:0 -o inline:'13:prefixsuffix\n' -e empty \ - ${TEST_SH} + ${TEST_SH} || +atf_fail '1 -> ^A' oneline "VAR=" 10 '; echo "${#VAR}:${VAR}"' | atf_check -s exit:0 -o inline:'13:prefix\nsuffix\n' -e empty \ - ${TEST_SH} + ${TEST_SH} || +atf_fail '10 -> \n' rm -f prefix* 2>/dev/null || : oneline "echo hello >" 45 "" | - atf_check -s exit:0 -o empty -e empty ${TEST_SH} + atf_check -s exit:0 -o empty -e empty ${TEST_SH} || + atf_fail 'redir into 45 -> E' test -f "prefix-suffix" || atf_fail "failed to create prefix-suffix (45)" test -s "prefix-suffix" || @@ -119,7 +124,8 @@ assignment_body() { rm -f results || : mkdata "VAR=" -- '; echo ${#VAR}' | - atf_check -s exit:0 -o save:results -e empty ${TEST_SH} + atf_check -s exit:0 -o save:results -e empty ${TEST_SH} || + atf_fail 'making results' test -z $( grep -v "^13$" results ) || atf_fail "Incorrect lengths: $(grep -nv '^13$' results)" @@ -136,7 +142,8 @@ cmdline_body() { rm -f results || : mkdata "VAR=" -- '; echo "${VAR}"' | - atf_check -s exit:0 -o save:results -e empty ${TEST_SH} + atf_check -s exit:0 -o save:results -e empty ${TEST_SH} || + atf_fail 'making results' # 256 because one output line contains a \n ... test $( wc -l < results ) -eq 256 || @@ -165,7 +172,8 @@ redirect_body() { mkdir prefix # one of the files will be prefix/suffix mkdata "VAR=" -- '; echo "${VAR}" > "${VAR}"' | - atf_check -s exit:0 -o empty -e empty ${TEST_SH} + atf_check -s exit:0 -o empty -e empty ${TEST_SH} || + atf_fail "$VAR -> ./$VAR"
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:17:43 UTC 2021 Modified Files: src/bin/sh: eval.c expand.c expand.h nodetypes redir.c Log Message: PR bin/53550 Here we go again... One more time to redo how here docs are processed (it has been a few years since the last time!) This is actually a relatively minor change, mostly to timimg (to just when things happen). Now here docs are expanded at the same time the "filename" word in a redirect is expanded, rather than later when the heredoc was being sent to its process. This actually makes things more consistent - but does break one of the ATF tests which was testing that we were (effectively) internally inconsistent in this area. Not all shells agree on the context in which redirection expansions should happen, some make any side effects visible to the parent shell (the majority do) others do the redirection expansions in a subshell so any side effcts are lost. We used to have a foot in each camp, with the majority for everything but here docs, and the minority for here docs. Now we're all the way with LBJ ... (or something like that). To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/bin/sh/eval.c cvs rdiff -u -r1.140 -r1.141 src/bin/sh/expand.c cvs rdiff -u -r1.25 -r1.26 src/bin/sh/expand.h cvs rdiff -u -r1.19 -r1.20 src/bin/sh/nodetypes cvs rdiff -u -r1.71 -r1.72 src/bin/sh/redir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Nov 22 05:17:43 UTC 2021 Modified Files: src/bin/sh: eval.c expand.c expand.h nodetypes redir.c Log Message: PR bin/53550 Here we go again... One more time to redo how here docs are processed (it has been a few years since the last time!) This is actually a relatively minor change, mostly to timimg (to just when things happen). Now here docs are expanded at the same time the "filename" word in a redirect is expanded, rather than later when the heredoc was being sent to its process. This actually makes things more consistent - but does break one of the ATF tests which was testing that we were (effectively) internally inconsistent in this area. Not all shells agree on the context in which redirection expansions should happen, some make any side effects visible to the parent shell (the majority do) others do the redirection expansions in a subshell so any side effcts are lost. We used to have a foot in each camp, with the majority for everything but here docs, and the minority for here docs. Now we're all the way with LBJ ... (or something like that). To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/bin/sh/eval.c cvs rdiff -u -r1.140 -r1.141 src/bin/sh/expand.c cvs rdiff -u -r1.25 -r1.26 src/bin/sh/expand.h cvs rdiff -u -r1.19 -r1.20 src/bin/sh/nodetypes cvs rdiff -u -r1.71 -r1.72 src/bin/sh/redir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.185 src/bin/sh/eval.c:1.186 --- src/bin/sh/eval.c:1.185 Tue Nov 16 11:27:50 2021 +++ src/bin/sh/eval.c Mon Nov 22 05:17:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.185 2021/11/16 11:27:50 kre Exp $ */ +/* $NetBSD: eval.c,v 1.186 2021/11/22 05:17:43 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.185 2021/11/16 11:27:50 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.186 2021/11/22 05:17:43 kre Exp $"); #endif #endif /* not lint */ @@ -618,6 +618,12 @@ expredir(union node *n) fixredir(redir, fn.list->text, 1); } break; + case NHERE: + redir->nhere.text = redir->nhere.doc->narg.text; + break; + case NXHERE: + redir->nhere.text = expandhere(redir->nhere.doc); + break; } } } Index: src/bin/sh/expand.c diff -u src/bin/sh/expand.c:1.140 src/bin/sh/expand.c:1.141 --- src/bin/sh/expand.c:1.140 Wed Nov 10 15:26:34 2021 +++ src/bin/sh/expand.c Mon Nov 22 05:17:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.140 2021/11/10 15:26:34 kre Exp $ */ +/* $NetBSD: expand.c,v 1.141 2021/11/22 05:17:43 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; #else -__RCSID("$NetBSD: expand.c,v 1.140 2021/11/10 15:26:34 kre Exp $"); +__RCSID("$NetBSD: expand.c,v 1.141 2021/11/22 05:17:43 kre Exp $"); #endif #endif /* not lint */ @@ -143,16 +143,16 @@ STATIC void rmescapes_nl(char *); * Expand shell variables and backquotes inside a here document. */ -void -expandhere(union node *arg, int fd) +char * +expandhere(union node *arg) { int len; - VTRACE(DBG_EXPAND|DBG_REDIR, ("expandhere() fd=%d\n", fd)); - herefd = fd; + VTRACE(DBG_EXPAND|DBG_REDIR, ("expandhere(%p)\n", arg)); expandarg(arg, NULL, 0); len = rmescapes(stackblock()); - xwrite(fd, stackblock(), len); + VTRACE(DBG_EXPAND|DBG_REDIR, ("expandhere() -> %d\n", len)); + return stalloc(len + 1); /* include the \0 */ } Index: src/bin/sh/expand.h diff -u src/bin/sh/expand.h:1.25 src/bin/sh/expand.h:1.26 --- src/bin/sh/expand.h:1.25 Thu Feb 13 05:19:05 2020 +++ src/bin/sh/expand.h Mon Nov 22 05:17:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.h,v 1.25 2020/02/13 05:19:05 kre Exp $ */ +/* $NetBSD: expand.h,v 1.26 2021/11/22 05:17:43 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -65,7 +65,7 @@ struct arglist { union node; -void expandhere(union node *, int); +char *expandhere(union node *); void expandarg(union node *, struct arglist *, int); int rmescapes(char *); int casematch(union node *, char *); Index: src/bin/sh/nodetypes diff -u src/bin/sh/nodetypes:1.19 src/bin/sh/nodetypes:1.20 --- src/bin/sh/nodetypes:1.19 Tue Nov 16 11:25:44 2021 +++ src/bin/sh/nodetypes Mon Nov 22 05:17:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: nodetypes,v 1.19 2021/11/16 11:25:44 kre Exp $ +# $NetBSD: nodetypes,v 1.20 2021/11/22 05:17:43 kre Exp $ # Copyright (c) 1991, 1993 # The Regents of the University of California. All rights reserved. # @@ -143,6 +143,7 @@ NXHERE nhere # fdnhere.doc->narg.text); - if (len <= PIPESIZE) { - xwrite(pip[1], redir->nhere.doc->narg.text, len); - goto out; - } + len = strlen(redir->nhere.text); + VTRACE(DBG_REDIR, ("openhere(%p) [%d] \"%.*s\"%s\n", redir, len, + (len < 40 ?
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Nov 20 01:52:51 UTC 2021 Modified Files: src/bin/sh: sh.1 Log Message: Improve the wording of the "Argument List Processing" section (where all the sh options, also used with "set", are listed) in response to a discussion on icb conveyed to me by Darrin B. Jewell. A few improvements to the description of the "set" built-in as well. Bump Dd to cover all of this month's changes (so far). To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Nov 20 01:52:51 UTC 2021 Modified Files: src/bin/sh: sh.1 Log Message: Improve the wording of the "Argument List Processing" section (where all the sh options, also used with "set", are listed) in response to a discussion on icb conveyed to me by Darrin B. Jewell. A few improvements to the description of the "set" built-in as well. Bump Dd to cover all of this month's changes (so far). To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.238 src/bin/sh/sh.1:1.239 --- src/bin/sh/sh.1:1.238 Tue Nov 16 23:39:34 2021 +++ src/bin/sh/sh.1 Sat Nov 20 01:52:51 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.238 2021/11/16 23:39:34 rillig Exp $ +.\" $NetBSD: sh.1,v 1.239 2021/11/20 01:52:51 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd October 31, 2021 +.Dd November 20, 2021 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -266,12 +266,24 @@ or only, either on the command line, or with the .Ic set built-in command. +Those are listed in the table below after the options +with a one letter, flag, equivalent. +.Pp Other options described are for the command line only. Specifying a dash .Dq Cm \- turns the option on, while using a plus .Dq Cm + disables the option. +This may seem counter-intuitive, but is in line with the +common practice where +.Ic cmd Fl x +runs +.Ic cmd +with the +.Sq x +option set. +.Pp The following options can be set from the command line and, unless otherwise stated, with the .Ic set @@ -371,6 +383,16 @@ Ignore EOFs from input when interactive. (After a large number of consecutive EOFs the shell will exit anyway.) .It Fl i Em interactive Force the shell to behave interactively. +If not set on the command line, +this option is set automatically at shell startup if +the shell is reading from standard input (no +.Fl c , +or +.Ar command_file +given at invocation of +.Nm ) , +and standard input and standard error refer to +terminmal type devices. .It Fl L Em local_lineno When set, before a function is defined, causes the variable @@ -389,7 +411,7 @@ For more details see the section .Sx LINENO below. .It Fl m Em monitor -Turn on job control (set automatically when interactive). +Turn on job control (set automatically at shell startup when interactive). .It Fl n Em noexec Read and parse commands, but do not execute them. This is useful for checking the syntax of shell scripts. @@ -442,7 +464,7 @@ This option has no effect when set or re already started reading from the command_file, or from standard input. Note that the .Fl s -flag being set does not cause the shell to be interactive. +flag being set does not, of itself, cause the shell to be interactive. .It Fl u Em nounset Write a message to standard error when attempting to obtain a value from a variable that is not set, @@ -471,7 +493,7 @@ if it had been set). section below.) .It Fl v Em verbose The shell writes its input to standard error as it is read. -Useful for debugging. +Perhaps ocassionally useful for some debugging. .It Fl X Em xlock Cause output from the .Ic xtrace @@ -503,12 +525,30 @@ is set, means that which existed immediately before any redirections to be applied to the command are performed. Useful for debugging. +.El +.Pp +The following options have no one letter variant, +and are used only in conjunction with +.Fl o +or +.Cm +o , +either on the command line, or via the +.Ic set +built-in command. +.Bl -tag -width ".Fl L Em local_lineno" -offset indent .It "\ \ " Em cdprint Make an interactive shell always print the new directory name when changed by the .Ic cd command. -In a non-interactive shell this option has no effect. +In a non-interactive shell this option has no effect +unless the +.Em posix +option is set. +However, +.Em cdprint +is an extension to POSIX, so these two options should +rarely be set at the same time. .It "\ \ " Em nolog Prevent the entry of function definitions into the command history (see .Ic fc @@ -3579,12 +3619,17 @@ command instead, if you want to return f your shell. .\" .Pp -.It Ic set Oo { Fl options | Cm +options | Cm \-- } Oc Ar arg ... +.It set +.It set { Fl o | Cm +o } +.It Ic set Oo { Fl options | Cm +options } ... Oc Oo Cm \-\|\- Oc Oo Ar arg ... Oc +.Pp The .Ic set command performs four different functions. .Pp -With no arguments, it lists the values of all shell variables. +With no arguments, +.Ic set +lists the names and values of all set shell variables. .Pp With a single option of either .Dq Fl o @@ -3604,7 +3649,11 @@ If options are given, it sets the specif flags, or clears
CVS commit: src/lib/libcurses
Module Name:src Committed By: kre Date: Tue Nov 16 23:23:02 UTC 2021 Modified Files: src/lib/libcurses: ins_wstr.c Log Message: Move 'i' into DEBUG only code (now there be three). Hopefully unbreaks !DEBUG builds. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/ins_wstr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libcurses
Module Name:src Committed By: kre Date: Tue Nov 16 23:23:02 UTC 2021 Modified Files: src/lib/libcurses: ins_wstr.c Log Message: Move 'i' into DEBUG only code (now there be three). Hopefully unbreaks !DEBUG builds. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/ins_wstr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ins_wstr.c diff -u src/lib/libcurses/ins_wstr.c:1.19 src/lib/libcurses/ins_wstr.c:1.20 --- src/lib/libcurses/ins_wstr.c:1.19 Tue Nov 16 21:00:50 2021 +++ src/lib/libcurses/ins_wstr.c Tue Nov 16 23:23:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $ */ +/* $NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $"); +__RCSID("$NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $"); #endif /* not lint */ #include @@ -135,7 +135,7 @@ wins_nwstr(WINDOW *win, const wchar_t *w const wchar_t *scp; cchar_t cc; wchar_t *lstr, *slstr; - int i, width, len, lx, sx, x, y, tx, ty, cw, pcw, newx, tn, w; + int width, len, lx, sx, x, y, tx, ty, cw, pcw, newx, tn, w; wchar_t ws[] = L" "; /* check for leading non-spacing character */ @@ -294,6 +294,8 @@ loopdone: *lnp->firstchp = newx; #ifdef DEBUG { + int i; + __CTRACE(__CTRACE_INPUT, "before===\n"); for (i = 0; i < win->maxx; i++) __CTRACE(__CTRACE_INPUT, @@ -334,6 +336,8 @@ loopdone: } #ifdef DEBUG { +int i; + __CTRACE(__CTRACE_INPUT, "=after shift\n"); for (i = 0; i < win->maxx; i++) __CTRACE(__CTRACE_INPUT, @@ -363,6 +367,8 @@ loopdone: #ifdef DEBUG { + int i; + __CTRACE(__CTRACE_INPUT, "lx = %d, x = %x\n", lx, x); __CTRACE(__CTRACE_INPUT, "after===\n"); for (i = 0; i < win->maxx; i++)
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: kre Date: Wed Nov 17 04:33:26 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi Log Message: Adjust new libcurses test filenames to the ones atually installed. Possibly the intent was that the names used here were correct, and the error is where they're installed - if so, that can be corrected later. Hopefully this will fix the remaining current build issue. To generate a diff of this commit: cvs rdiff -u -r1.1164 -r1.1165 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: kre Date: Wed Nov 17 04:33:26 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi Log Message: Adjust new libcurses test filenames to the ones atually installed. Possibly the intent was that the names used here were correct, and the error is where they're installed - if so, that can be corrected later. Hopefully this will fix the remaining current build issue. To generate a diff of this commit: cvs rdiff -u -r1.1164 -r1.1165 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1164 src/distrib/sets/lists/tests/mi:1.1165 --- src/distrib/sets/lists/tests/mi:1.1164 Tue Nov 16 21:05:33 2021 +++ src/distrib/sets/lists/tests/mi Wed Nov 17 04:33:26 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1164 2021/11/16 21:05:33 blymn Exp $ +# $NetBSD: mi,v 1.1165 2021/11/17 04:33:26 kre Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -3460,9 +3460,9 @@ ./usr/tests/lib/libcurses/check_files/mvwins_wch.chk tests-lib-tests compattestfile,atf ./usr/tests/lib/libcurses/check_files/mvwins_wstr1.chk tests-lib-tests compattestfile,atf ./usr/tests/lib/libcurses/check_files/mvwins_wstr2.chk tests-lib-tests compattestfile,atf -./usr/tests/lib/libcurses/check_files/mvwins_wstr3.chk tests-lib-tests compattestfile,atf -./usr/tests/lib/libcurses/check_files/mvwins_wstr4.chk tests-lib-tests compattestfile,atf -./usr/tests/lib/libcurses/check_files/mvwins_wstr5.chk tests-lib-tests compattestfile,atf +./usr/tests/lib/libcurses/check_files/wins_wstr3.chk tests-lib-tests compattestfile,atf +./usr/tests/lib/libcurses/check_files/wins_wstr4.chk tests-lib-tests compattestfile,atf +./usr/tests/lib/libcurses/check_files/wins_wstr5.chk tests-lib-tests compattestfile,atf ./usr/tests/lib/libcurses/check_files/notimeout.chk tests-lib-tests compattestfile,atf ./usr/tests/lib/libcurses/check_files/overlay1.chk tests-lib-tests compattestfile,atf ./usr/tests/lib/libcurses/check_files/overlay2.chk tests-lib-tests compattestfile,atf
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Oct 31 02:12:01 UTC 2021 Modified Files: src/bin/sh: cd.c Log Message: PR bin/45390 - fix for folly four In the pwd builtin, verify that curdir names '.' before simply printing it. Never alter PWD or OLDPWD in the pwd command. Also while here, implement the (new: coming in POSIX, but has existed for a while in several other shells) -e option to cd (with -e, cd -P will exit(1) if the chdir() succeeds, but PWD cannot be discovered). cd now prints the directory name used (if different from that given, or cdprint is on) if interactive or (the new bit)in posix mode. Some additional/changed comments added, and a DEBUG mode trace call that was accidentally put inside an #if 0 block moved to where it can do some good. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/bin/sh/cd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Oct 31 02:12:01 UTC 2021 Modified Files: src/bin/sh: cd.c Log Message: PR bin/45390 - fix for folly four In the pwd builtin, verify that curdir names '.' before simply printing it. Never alter PWD or OLDPWD in the pwd command. Also while here, implement the (new: coming in POSIX, but has existed for a while in several other shells) -e option to cd (with -e, cd -P will exit(1) if the chdir() succeeds, but PWD cannot be discovered). cd now prints the directory name used (if different from that given, or cdprint is on) if interactive or (the new bit)in posix mode. Some additional/changed comments added, and a DEBUG mode trace call that was accidentally put inside an #if 0 block moved to where it can do some good. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/bin/sh/cd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/cd.c diff -u src/bin/sh/cd.c:1.50 src/bin/sh/cd.c:1.51 --- src/bin/sh/cd.c:1.50 Wed Jul 5 20:00:27 2017 +++ src/bin/sh/cd.c Sun Oct 31 02:12:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.50 2017/07/05 20:00:27 kre Exp $ */ +/* $NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,12 +37,13 @@ #if 0 static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: cd.c,v 1.50 2017/07/05 20:00:27 kre Exp $"); +__RCSID("$NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include #include @@ -67,10 +68,11 @@ __RCSID("$NetBSD: cd.c,v 1.50 2017/07/05 #include "show.h" #include "cd.h" -STATIC int docd(const char *, int); +STATIC int docd(const char *, bool, bool); STATIC char *getcomponent(void); -STATIC void updatepwd(const char *); +STATIC bool updatepwd(const char *); STATIC void find_curdir(int noerror); +STATIC bool is_curdir(const char *); char *curdir = NULL; /* current working directory */ char *prevdir; /* previous working directory */ @@ -84,10 +86,13 @@ cdcmd(int argc, char **argv) char *p; char *d; struct stat statb; + char opt; + bool eopt = false; int print = cdprint; /* set -o cdprint to enable */ - while (nextopt("P") != '\0') - ; + while ((opt = nextopt("Pe")) != '\0') + if (opt == 'e') + eopt = true; /* * Try (quite hard) to have 'curdir' defined, nothing has set @@ -128,19 +133,13 @@ cdcmd(int argc, char **argv) stunalloc(p); if (stat(p, ) >= 0 && S_ISDIR(statb.st_mode)) { int dopr = print; + int x; - if (!print) { -/* - * XXX - rethink - */ -if (p[0] == '.' && p[1] == '/' && p[2] != '\0') - dopr = strcmp(p + 2, dest); -else - dopr = strcmp(p, dest); - } - if (docd(p, dopr) >= 0) -return 0; + if (!print) +dopr = strcmp(p, dest); + if ((x = docd(p, dopr != 0, eopt)) >= 0) +return x; } } error("can't cd to %s", dest); @@ -154,8 +153,10 @@ cdcmd(int argc, char **argv) */ STATIC int -docd(const char *dest, int print) +docd(const char *dest, bool print, bool eopt) { + bool gotpwd; + #if 0 /* no "cd -L" (ever) so all this is just a waste of time ... */ char *p; char *q; @@ -164,8 +165,6 @@ docd(const char *dest, int print) int first; int badstat; - CTRACE(DBG_CMDS, ("docd(\"%s\", %d) called\n", dest, print)); - /* * Check each component of the path. If we find a symlink or * something we can't stat, clear curdir to force a getcwd() @@ -199,16 +198,19 @@ docd(const char *dest, int print) } #endif + CTRACE(DBG_CMDS, ("docd(\"%s\", %s, %s) called\n", dest, + print ? "true" : "false", eopt ? "true" : "false")); + INTOFF; if (chdir(dest) < 0) { INTON; return -1; } - updatepwd(NULL); /* only do cd -P, no "pretend" -L mode */ + gotpwd = updatepwd(NULL); /* only do cd -P, no "pretend" -L mode */ INTON; - if (print && iflag == 1 && curdir) - out1fmt("%s\n", curdir); - return 0; + if (print && (iflag || posix)) + out1fmt("%s\n", gotpwd ? curdir : dest); + return gotpwd || !eopt ? 0 : 1; } @@ -245,7 +247,7 @@ getcomponent(void) * that the current directory has changed. */ -STATIC void +STATIC bool updatepwd(const char *dir) { char *new; @@ -256,7 +258,7 @@ updatepwd(const char *dir) /* * If our argument is NULL, we don't know the current directory * any more because we traversed a symbolic link or something - * we couldn't stat(). + * we couldn't stat(). Or we simply don't trust what we had. */ if (dir == NULL || curdir == NULL) { if (prevdir) @@ -269,10 +271,14 @@ updatepwd(const char *dir) if (curdir) { setvar("OLDPWD", prevdir, VEXPORT); setvar("PWD", curdir, VEXPORT); + return true; } else unsetvar("PWD", 0); - return; + return false; } + + /* XXX none of the following code is ever executed any more */ + cdcomppath =
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Oct 31 02:12:08 UTC 2021 Modified Files: src/bin/sh: sh.1 Log Message: PR bin/45390 Be explicit about what happens to PWD after a successful cd command. Also be very clear that "cd" and "cd -P" are the same thing, and the only cd variant implemented. Also, when it is appropriate to print the new directory after a cd command, note that it happens if interactive (as it always has here) and also if the posix option is set (for POSIX compat, where "interactive" is irrelevant). Mention that "cd -" is a case where the new directory is printed (along with paths relative to a non-empty CDPATH entry, and where the "cd old new" (string replacement in curdir) is used. While here document the new -e option to cd. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Oct 31 02:12:08 UTC 2021 Modified Files: src/bin/sh: sh.1 Log Message: PR bin/45390 Be explicit about what happens to PWD after a successful cd command. Also be very clear that "cd" and "cd -P" are the same thing, and the only cd variant implemented. Also, when it is appropriate to print the new directory after a cd command, note that it happens if interactive (as it always has here) and also if the posix option is set (for POSIX compat, where "interactive" is irrelevant). Mention that "cd -" is a case where the new directory is printed (along with paths relative to a non-empty CDPATH entry, and where the "cd old new" (string replacement in curdir) is used. While here document the new -e option to cd. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.235 src/bin/sh/sh.1:1.236 --- src/bin/sh/sh.1:1.235 Tue Oct 26 00:05:38 2021 +++ src/bin/sh/sh.1 Sun Oct 31 02:12:08 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.235 2021/10/26 00:05:38 kre Exp $ +.\" $NetBSD: sh.1,v 1.236 2021/10/31 02:12:08 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd October 25, 2021 +.Dd October 31, 2021 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -83,10 +83,7 @@ .Sh DESCRIPTION .Nm is the standard command interpreter for the system. -The current version of -.Nm -is in the process of being changed to conform more closely to the -POSIX 1003.2 and 1003.2a specifications for the shell. +It is a re-implementation and extension of the Bourne shell. This version has many features which make it appear similar in some respects to the Korn shell, but it is not a Korn shell clone (see @@ -2445,7 +2442,7 @@ of utilities, the name for built-ins or .El .\" .Pp -.It Ic cd Oo Fl P Oc Op Ar directory Op Ar replace +.It Ic cd Oo Fl Pe Oc Op Ar directory Op Ar replace Switch to the specified directory (default .Ev $HOME ) . If @@ -2480,14 +2477,44 @@ is the same as that of .Pp The .Fl P -option instructs the shell to update +option +(which is the unalterable default in this +.Nm ) +instructs the shell to +change to the directory specified (or determined) +and if successful +update +.Ev PWD +with the new physical directory path. +That is the path name, not traversing any symbolic links, +of the altered working directory of the shell. +.Pp +The +.Fl e +option alters the interpretation of the exit status. +.Ic cd +will exit with status 0 if successful. +If the directory was successfully changed, but .Ev PWD -with the specified physical directory path and change to that directory. -This is the default. +was unable to be updated, +.Ic cd +will exit with status 1 if the +.Fl e +option was given, and status 0 otherwise. +Upon any other error, +including usage errors, +and failing to successfully change directory, +.Ic cd +will exit with status 2. .Pp -When the directory changes, the variable +When the directory changes, +and +.Ev PWD +is updated, the variable .Ev OLDPWD -is set to the working directory before the change. +is set to the working directory +.Po \&\$ Ns Ev PWD Ns Pc +as it was before the change. .Pp Some shells also support a .Fl L @@ -2497,21 +2524,32 @@ with the logical path and to change the accordingly. This is not supported. .Pp -In an interactive shell, the +In an interactive shell, or if the +.Cm posix +option is set, the .Ic cd command will print out the name of the -directory that it actually switched to if this is different from the name +directory that it actually switched to +.Po that is, the pathname passed to the successful +.Xr chdir 2 +.No system call Pc +if this is different from the name that the user gave, -or always if the +or if the .Cm cdprint option is set. -The destination may be different either because the +The destination may be different because +a non-empty element of the .Ev CDPATH -mechanism was used -.\" or because a symbolic link was crossed. -or if the +mechanism was used, +.\" or because a symbolic link was crossed. XXX Definitively not. +or because the .Ar replace -argument was used. +argument was used, +or because the +.Ar directory +parameter was specified as +.Dq \&\- . .\" .Pp .It Ic eval Ar string ...
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Oct 26 10:07:20 UTC 2021 Modified Files: src/bin/sh: main.c memalloc.c memalloc.h Log Message: Use a type-correct end marker for strstrcat() rather than NULL, as for a function with unknown number & types of args, the compiler isn't able to automatically convert to the correct type. Issue pointed out in off list e-mail by Rolland Illig ... Thanks. The first arg (pointer to where to put length of result) is of a known type, so doesn't have the same issue - we can keep using NULL for that one when the length isn't needed. Also, make sure to return a correctly null terminated null string in the (absurd) case that there are no non-null args to strstrcat() (though there are much better ways to generate "" on the stack). Since there is currently just one call in the code, and it has real string args, this isn't an issue for now, but who knows, some day. NFCI - if there is any real change, then it is a change that is required. XXX pullup -9 (together with the previous changes) To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/bin/sh/main.c cvs rdiff -u -r1.34 -r1.35 src/bin/sh/memalloc.c cvs rdiff -u -r1.19 -r1.20 src/bin/sh/memalloc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Oct 26 10:07:20 UTC 2021 Modified Files: src/bin/sh: main.c memalloc.c memalloc.h Log Message: Use a type-correct end marker for strstrcat() rather than NULL, as for a function with unknown number & types of args, the compiler isn't able to automatically convert to the correct type. Issue pointed out in off list e-mail by Rolland Illig ... Thanks. The first arg (pointer to where to put length of result) is of a known type, so doesn't have the same issue - we can keep using NULL for that one when the length isn't needed. Also, make sure to return a correctly null terminated null string in the (absurd) case that there are no non-null args to strstrcat() (though there are much better ways to generate "" on the stack). Since there is currently just one call in the code, and it has real string args, this isn't an issue for now, but who knows, some day. NFCI - if there is any real change, then it is a change that is required. XXX pullup -9 (together with the previous changes) To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/bin/sh/main.c cvs rdiff -u -r1.34 -r1.35 src/bin/sh/memalloc.c cvs rdiff -u -r1.19 -r1.20 src/bin/sh/memalloc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.87 src/bin/sh/main.c:1.88 --- src/bin/sh/main.c:1.87 Tue Oct 26 00:05:38 2021 +++ src/bin/sh/main.c Tue Oct 26 10:07:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.87 2021/10/26 00:05:38 kre Exp $ */ +/* $NetBSD: main.c,v 1.88 2021/10/26 10:07:20 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.87 2021/10/26 00:05:38 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.88 2021/10/26 10:07:20 kre Exp $"); #endif #endif /* not lint */ @@ -241,7 +241,7 @@ main(int argc, char **argv) home = lookupvar("HOME"); if (home == NULL) home = nullstr; - profile = ststrcat(NULL, home, "/.profile", NULL); + profile = ststrcat(NULL, home, "/.profile", STSTRC_END); read_profile(profile); stunalloc(profile); } Index: src/bin/sh/memalloc.c diff -u src/bin/sh/memalloc.c:1.34 src/bin/sh/memalloc.c:1.35 --- src/bin/sh/memalloc.c:1.34 Tue Oct 26 00:05:38 2021 +++ src/bin/sh/memalloc.c Tue Oct 26 10:07:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: memalloc.c,v 1.34 2021/10/26 00:05:38 kre Exp $ */ +/* $NetBSD: memalloc.c,v 1.35 2021/10/26 10:07:20 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: memalloc.c,v 1.34 2021/10/26 00:05:38 kre Exp $"); +__RCSID("$NetBSD: memalloc.c,v 1.35 2021/10/26 10:07:20 kre Exp $"); #endif #endif /* not lint */ @@ -350,6 +350,7 @@ ungrabstackstr(char *s, char *p) * Remaining args are pointers to strings - sufficient space to hold * the concat of the strings is allocated on the stack, the strings * are copied into that space, and a pointer to its start is retured. + * The arg list is terminated with STSTRC_END. * * Use stunalloc(string) (in proper sequence) to release the string */ @@ -365,7 +366,7 @@ ststrcat(size_t *lp, ...) n = 0; va_start(ap, lp); arg = va_arg(ap, const char *); - while (arg != NULL) { + while (arg != STSTRC_END) { len = strlen(arg); if (n < sizeof(alen)/sizeof(alen[0])) alen[n++] = len; @@ -380,12 +381,13 @@ ststrcat(size_t *lp, ...) if (tlen >= INT_MAX) error("ststrcat() over length botch"); str = (char *)stalloc((int)tlen + 1); /* 1 for \0 */ + str[tlen] = '\0'; /* in case of no args */ n = 0; nxt = str; va_start(ap, lp); arg = va_arg(ap, const char *); - while (arg != NULL) { + while (arg != STSTRC_END) { if (n < sizeof(alen)/sizeof(alen[0])) len = alen[n++]; else Index: src/bin/sh/memalloc.h diff -u src/bin/sh/memalloc.h:1.19 src/bin/sh/memalloc.h:1.20 --- src/bin/sh/memalloc.h:1.19 Tue Oct 26 00:05:38 2021 +++ src/bin/sh/memalloc.h Tue Oct 26 10:07:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: memalloc.h,v 1.19 2021/10/26 00:05:38 kre Exp $ */ +/* $NetBSD: memalloc.h,v 1.20 2021/10/26 10:07:20 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -61,7 +61,9 @@ void grabstackblock(int); char *growstackstr(void); char *makestrspace(void); void ungrabstackstr(char *, char *); + char *ststrcat(size_t *, ...); +#define STSTRC_END ((const char *)0)
Re: CVS commit: src/bin/sh
ps: Also, the code is (while refactored a little) essentially the same as the -p code you added in 2015 ... just now avoiding repeatedly calling geteuid() (etc) - the value it returns won't change unless the code does something to change it. kre
Re: CVS commit: src
Date:Tue, 26 Oct 2021 15:37:56 +0200 From:Joerg Sonnenberger Message-ID: | Personally, I would prefer to just kill -pg support completely, but | that's a separate discussion. Yes, it is. | I don't think per-file profiling is that useful Nor do I in general. However, doing routine call counting on mcount (or anything it calls) would simply be absurd. If you want to know how mant times mcount has been called, you simply sum all the other counters. (pc sampling, however it is done, detecting mcount is fine). I agree that forcing inlining is a good idea, and should be done, but I also feel that disabling profiling of mcount is also the right thing to do. I don't think we need a general ability to disable profiling on any random file/function but if that is the easiest and cleanest way to be able to disable profiling of mcount then I can accept it - provided that's all it is actually used for, kre
Re: CVS commit: src/bin/sh
Date:Tue, 26 Oct 2021 15:07:23 - (UTC) From:chris...@astron.com (Christos Zoulas) Message-ID: | No issetugid()? No, because I'm not sure I understand that, nor that I believe: A process is tainted if [...] it has changed any of its real, effective or saved user or group ID's since it began execution. nor how that would apply to sh. Further: This system call exists so that library routines (e.g., libc) where perhaps it might be useful (I really have no idea) but that's not the situation of concern. What matters is if a sh is run from a set[ug]id process (or stranger perhaps, someone makes a copy of sh set[ug]id) that, at least until someone says "this is safe now" it doesn't do anything too dangerous. Just checking the uid/gid against euid/egid seems adequate for that. kre
CVS commit: src/lib/libc
Module Name:src Committed By: kre Date: Fri Oct 29 19:27:07 UTC 2021 Modified Files: src/lib/libc/gen: popen.c src/lib/libc/stdlib: system.c Log Message: Add "--" 'options end' parameter to the sh -c call that runs the command, so that the command cannot appear to be more options (which always then fails, as there would be no arg for "-c" to treat as the command string in that case). For the full (LONG) explanation, see: http://mail-index.netbsd.org/current-users/2021/10/29/msg041629.html To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libc/gen/popen.c cvs rdiff -u -r1.25 -r1.26 src/lib/libc/stdlib/system.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc
Module Name:src Committed By: kre Date: Fri Oct 29 19:27:07 UTC 2021 Modified Files: src/lib/libc/gen: popen.c src/lib/libc/stdlib: system.c Log Message: Add "--" 'options end' parameter to the sh -c call that runs the command, so that the command cannot appear to be more options (which always then fails, as there would be no arg for "-c" to treat as the command string in that case). For the full (LONG) explanation, see: http://mail-index.netbsd.org/current-users/2021/10/29/msg041629.html To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libc/gen/popen.c cvs rdiff -u -r1.25 -r1.26 src/lib/libc/stdlib/system.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/popen.c diff -u src/lib/libc/gen/popen.c:1.36 src/lib/libc/gen/popen.c:1.37 --- src/lib/libc/gen/popen.c:1.36 Thu Jan 24 18:01:38 2019 +++ src/lib/libc/gen/popen.c Fri Oct 29 19:27:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $ */ +/* $NetBSD: popen.c,v 1.37 2021/10/29 19:27:06 kre Exp $ */ /* * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $"); +__RCSID("$NetBSD: popen.c,v 1.37 2021/10/29 19:27:06 kre Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -209,7 +209,7 @@ popen(const char *cmd, const char *type) /* NOTREACHED */ case 0:/* Child. */ pdes_child(pdes, type); - execl(_PATH_BSHELL, "sh", "-c", cmd, NULL); + execl(_PATH_BSHELL, "sh", "-c", "--", cmd, NULL); _exit(127); /* NOTREACHED */ } Index: src/lib/libc/stdlib/system.c diff -u src/lib/libc/stdlib/system.c:1.25 src/lib/libc/stdlib/system.c:1.26 --- src/lib/libc/stdlib/system.c:1.25 Tue Jan 20 18:31:25 2015 +++ src/lib/libc/stdlib/system.c Fri Oct 29 19:27:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: system.c,v 1.25 2015/01/20 18:31:25 christos Exp $ */ +/* $NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $ */ /* * Copyright (c) 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: system.c,v 1.25 2015/01/20 18:31:25 christos Exp $"); +__RCSID("$NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -56,8 +56,8 @@ system(const char *command) struct sigaction intsa, quitsa, sa; sigset_t nmask, omask; int pstat; - const char *argp[] = {"sh", "-c", NULL, NULL}; - argp[2] = command; + const char *argp[] = {"sh", "-c", "--", NULL, NULL}; + argp[3] = command; /* * ISO/IEC 9899:1999 in 7.20.4.6 describes this special case.
Re: CVS commit: src
Date:Fri, 29 Oct 2021 17:50:38 + From:"Roland Illig" Message-ID: <20211029175038.33b08f...@cvs.netbsd.org> | Log Message: | indent: use prev/curr/next to refer to the current token | | The word 'last' just didn't match with 'next'. That depends upon how it is used, last is one of those "flexible" words which means different things, depending upon the context. Eg: "last night" does not mean the night before doomsday, it means the night that just passed (the previous night if you like, though no-one would say that with that meaning). With that usage, last and next fit together just fine, today is Saturday Oct 30, where I am (my timezone), last Thursday was Oct 28, next Thursday is Nov 4. Perfectly clear, and normal usages. On the other hand the "last apple" usually means there are none left after this one, but this one can be ambiguous, and more context is needed. "I want the last apple" has that meaning. "The last apple tasted sweeter than the others" probably has the "previous" meaning (though might now), though again, I doubt anyone would use "previous" in that kind of sentence, "last" is normal, whether it means "the one I just ate" (however many are left), or "the one after which there were no more". That difference is usually immaterial, as if there are no more the last one eaten would be the last one... Note: I am not objecting to the change, just that perhaps sometimes all that is not clear to you might be just fine for others. kre
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Fri Oct 22 21:01:07 UTC 2021 Modified Files: src/external/public-domain/tz/dist: TZDATA_VERSION asia australasia backward leap-seconds.list leapseconds version Log Message: Update to tzdata2021e (with much of 2020b still omitted) This includes 2021c (no changes) 2021d (Fiji change) 2021e (Palestine) Fiji has cancelled summer time changes for 2021/2 summer. Currently assume it will be back in 2022/3. Palestine ends summer time October 29 01:00 (rather than Oct 30). Pacific/Enderbury is renamed to Pacific/Kanton and updated for historic data (Pacific/Enderbury retained as a link for compat). Historic timestamp fixes for Niue, Rarotonga, Tongatapu To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/external/public-domain/tz/dist/TZDATA_VERSION cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/asia \ src/external/public-domain/tz/dist/australasia \ src/external/public-domain/tz/dist/version cvs rdiff -u -r1.1.1.12 -r1.2 src/external/public-domain/tz/dist/backward cvs rdiff -u -r1.1.1.15 -r1.2 \ src/external/public-domain/tz/dist/leap-seconds.list cvs rdiff -u -r1.1.1.18 -r1.2 src/external/public-domain/tz/dist/leapseconds Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Fri Oct 22 21:01:07 UTC 2021 Modified Files: src/external/public-domain/tz/dist: TZDATA_VERSION asia australasia backward leap-seconds.list leapseconds version Log Message: Update to tzdata2021e (with much of 2020b still omitted) This includes 2021c (no changes) 2021d (Fiji change) 2021e (Palestine) Fiji has cancelled summer time changes for 2021/2 summer. Currently assume it will be back in 2022/3. Palestine ends summer time October 29 01:00 (rather than Oct 30). Pacific/Enderbury is renamed to Pacific/Kanton and updated for historic data (Pacific/Enderbury retained as a link for compat). Historic timestamp fixes for Niue, Rarotonga, Tongatapu To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/external/public-domain/tz/dist/TZDATA_VERSION cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/asia \ src/external/public-domain/tz/dist/australasia \ src/external/public-domain/tz/dist/version cvs rdiff -u -r1.1.1.12 -r1.2 src/external/public-domain/tz/dist/backward cvs rdiff -u -r1.1.1.15 -r1.2 \ src/external/public-domain/tz/dist/leap-seconds.list cvs rdiff -u -r1.1.1.18 -r1.2 src/external/public-domain/tz/dist/leapseconds Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/public-domain/tz/dist/TZDATA_VERSION diff -u src/external/public-domain/tz/dist/TZDATA_VERSION:1.25 src/external/public-domain/tz/dist/TZDATA_VERSION:1.26 --- src/external/public-domain/tz/dist/TZDATA_VERSION:1.25 Fri Oct 1 22:35:06 2021 +++ src/external/public-domain/tz/dist/TZDATA_VERSION Fri Oct 22 21:01:06 2021 @@ -1 +1 @@ -tzdata-2021b-partial +tzdata-2021e-(part-2021b) Index: src/external/public-domain/tz/dist/asia diff -u src/external/public-domain/tz/dist/asia:1.2 src/external/public-domain/tz/dist/asia:1.3 --- src/external/public-domain/tz/dist/asia:1.2 Fri Oct 1 22:35:06 2021 +++ src/external/public-domain/tz/dist/asia Fri Oct 22 21:01:06 2021 @@ -34,9 +34,6 @@ # Byalokoz EL. New Counting of Time in Russia since July 1, 1919. # (See the 'europe' file for a fuller citation.) # -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). -# # The following alphabetic abbreviations appear in these tables # (corrections are welcome): # std dst @@ -2749,7 +2746,7 @@ Rule NBorneo 1935 1941 - Dec 14 0:00 0 - # # peninsular Malaysia # taken from Mok Ly Yng (2003-10-30) -# http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html +# https://web.archive.org/web/20190822231045/http://www.math.nus.edu.sg/~mathelmr/teaching/timezone.html # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. @@ -3388,11 +3385,6 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # shall [end] on Oct 24th 2020 at 01:00AM by delaying the clock by 60 minutes. # http://www.palestinecabinet.gov.ps/portal/Meeting/Details/51584 -# From Tim Parenti (2020-10-20): -# Predict future fall transitions at 01:00 on the Saturday preceding October's -# last Sunday (i.e., Sat>=24). This is consistent with our predictions since -# 2016, although the time of the change differed slightly in 2019. - # From Pierre Cashon (2020-10-20): # The summer time this year started on March 28 at 00:00. # https://wafa.ps/ar_page.aspx?id=GveQNZa872839351758aGveQNZ @@ -3405,6 +3397,17 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # For now, guess spring-ahead transitions are at 00:00 on the Saturday # preceding March's last Sunday (i.e., Sat>=24). +# From P Chan (2021-10-18): +# http://wafa.ps/Pages/Details/34701 +# Palestine winter time will start from midnight 2021-10-29 (Thursday-Friday). +# +# From Heba Hemad, Palestine Ministry of Telecom & IT (2021-10-20): +# ... winter time will begin in Palestine from Friday 10-29, 01:00 AM +# by 60 minutes backwards. +# +# From Paul Eggert (2021-10-20): +# Guess future fall transitions on October's last Friday at 01:00. + # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 - @@ -3440,7 +3443,8 @@ Rule Palestine 2016 2018 - Oct Sat>=24 1 Rule Palestine 2019 only - Mar 29 0:00 1:00 S Rule Palestine 2019 only - Oct Sat>=24 0:00 0 - Rule Palestine 2020 max - Mar Sat>=24 0:00 1:00 S -Rule Palestine 2020 max - Oct Sat>=24 1:00 0 - +Rule Palestine 2020 only - Oct 24 1:00 0 - +Rule Palestine 2021 max - Oct lastFri 1:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -3509,6 +3513,12 @@ Zone Asia/Hebron 2:20:23 - LMT 1900 Oct # influence of the sources. There is no current abbreviation for DST, # so use "PDT", the usual American style. +# From P Chan (2021-05-10): +# Here's a fairly comprehensive article in Japanese: +#
CVS commit: src/distrib/sets/lists/base
Module Name:src Committed By: kre Date: Fri Oct 22 21:03:01 UTC 2021 Modified Files: src/distrib/sets/lists/base: mi Log Message: tzdata2021e update, zoneinfo Pacific/Enderbury renamed to Pacific/Kanton (old name retained) - so add new zone file for Pacific/Kanton To generate a diff of this commit: cvs rdiff -u -r1.1284 -r1.1285 src/distrib/sets/lists/base/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.1284 src/distrib/sets/lists/base/mi:1.1285 --- src/distrib/sets/lists/base/mi:1.1284 Sat Sep 25 08:54:30 2021 +++ src/distrib/sets/lists/base/mi Fri Oct 22 21:03:01 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1284 2021/09/25 08:54:30 maya Exp $ +# $NetBSD: mi,v 1.1285 2021/10/22 21:03:01 kre Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -5856,6 +5856,7 @@ ./usr/share/zoneinfo/Pacific/Guam base-sys-share share ./usr/share/zoneinfo/Pacific/Honolulu base-sys-share share ./usr/share/zoneinfo/Pacific/Johnston base-sys-share share +./usr/share/zoneinfo/Pacific/Kanton base-sys-share share ./usr/share/zoneinfo/Pacific/Kiritimati base-sys-share share ./usr/share/zoneinfo/Pacific/Kosrae base-sys-share share ./usr/share/zoneinfo/Pacific/Kwajalein base-sys-share share
CVS commit: src/distrib/sets/lists/base
Module Name:src Committed By: kre Date: Fri Oct 22 21:03:01 UTC 2021 Modified Files: src/distrib/sets/lists/base: mi Log Message: tzdata2021e update, zoneinfo Pacific/Enderbury renamed to Pacific/Kanton (old name retained) - so add new zone file for Pacific/Kanton To generate a diff of this commit: cvs rdiff -u -r1.1284 -r1.1285 src/distrib/sets/lists/base/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: kre Date: Fri Oct 22 21:03:50 UTC 2021 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Note tzdata2021e update. To generate a diff of this commit: cvs rdiff -u -r1.1823 -r1.1824 src/doc/3RDPARTY cvs rdiff -u -r1.2844 -r1.2845 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1823 src/doc/3RDPARTY:1.1824 --- src/doc/3RDPARTY:1.1823 Fri Oct 22 14:27:38 2021 +++ src/doc/3RDPARTY Fri Oct 22 21:03:50 2021 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1823 2021/10/22 14:27:38 christos Exp $ +# $NetBSD: 3RDPARTY,v 1.1824 2021/10/22 21:03:50 kre Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -1411,7 +1411,7 @@ Added changes from a5 -> a12 manually. Package: tz Version: tzcode2021e / tzdata2021e -Current Vers: tzcode2021e / tzdata2021c +Current Vers: tzcode2021e / tzdata2021e Maintainer: Paul Eggert Archive Site: ftp://ftp.iana.org/tz/releases/ Archive Site: ftp://munnari.oz.au/pub/oldtz/ @@ -1427,7 +1427,8 @@ Don't use src/lib/libc/time/tzcode2netbs Diffs are now applied by hand, since we have too many diffs (re-entrant tzcode, register removal) to apply. The diffs have been submitted upstream but there is too much inertia to apply them. Check for .gitignore files. -For the data files, do use external/public-domain/tz/tzdata2netbsd. +For the data files, do use external/public-domain/tz/tzdata2netbsd (usually, +for now, late 2021, do it manually). Package: wpa_supplicant/hostapd Version: 2.9 Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2844 src/doc/CHANGES:1.2845 --- src/doc/CHANGES:1.2844 Fri Oct 22 14:27:38 2021 +++ src/doc/CHANGES Fri Oct 22 21:03:50 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2844 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2845 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -446,3 +446,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0: aarch64: Enable MKRELRO and MKPIE by default. [nia 20211014] dhcpcd(8): Update to dhcpcd-9.4.1. [roy 20211022] tzcode: Updated to 2021e. [christos 20211022] + tzdata: updated to 2021e (still missing trash from 2021b) [kre 20211022]
CVS commit: src/doc
Module Name:src Committed By: kre Date: Fri Oct 22 21:03:50 UTC 2021 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Note tzdata2021e update. To generate a diff of this commit: cvs rdiff -u -r1.1823 -r1.1824 src/doc/3RDPARTY cvs rdiff -u -r1.2844 -r1.2845 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src
Date:Sat, 6 Nov 2021 10:40:58 -0700 From:Alistair Crooks Message-ID: | The author of the software made a conscious decision | to make the variable unsigned, sincr the length | would never be less than zero. | | The author then made a default definition for the | lower bound of the length, and made it 0. Both of those are readonable. | I find it ironic that an overbearing, | over-eager compiler takes these, | decides that the condition could never be true, I have not looked at the code, but this suggests that with the decisions above, the code is then going and checking if the impossible is true. "since the length would never be less than 0" the data type cannot store valuse less than 0, so testing if such a value is less than 0 is stupid, and proobabky indicates a logic error. | and so a cast to an integer type is now needed | to shut up the overeager compiler, I agree with your implication, doing that would be insane, and potentially break correct code, if the var was ever > INT_MAX and <= UINT_MAX then the test with the cast would indicate an invalid length, which, perhaps, it is not. The right thing to do is to delete the meaningless test. If you're concerned that the assumptions/decisions above might one day be altered, then instead of deleting the test, put it in a #if MIN_VALUE != 0 #endif block instead. So: | Nevertheless, I'll make the changes you suggest don't do that. kre
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Oct 26 00:05:38 UTC 2021 Modified Files: src/bin/sh: main.c memalloc.c memalloc.h options.c sh.1 shell.h Log Message: PR bin/56464 After almost 30 years, finally do the right thing and read $HOME/.profile rather than .profile in the initial directory (it was that way in version 1.1 ...) All other ash descendants seem to have fixed this long ago. While here, copy a feature from FreeBSD which allows "set +p" (if a shell run by a setuid process with the -p flag is privileged) to reset the privileges. Once done (the set +p) it cannot be undone (a later set -p sets the 'p' flag, but that's all it does) - that just becomes a one bit storage location. We do this, as (also copying from FreeBSD, and because it is the right thing to do) we don't run .profile in a privileged shell - FreeBSD run /etc/suid_profile in that case (not a good name, it also applies to setgid shells) but I see no real need for that, we run /etc/profile in any case, anything that would go in /etc/suid_profile can just go in /etc/profile instead (with suitable guards so the commands only run in priv'd shells). One or two minor DEBUG mode changes (notably having priv'd shells identify themselves in the DEBUG trace) and sh.1 changes with doc of the "set +p" change, the effect that has on $PSc and a few other wording tweaks. XXX pullup -9 (not -8, this isn't worth it for the short lifetime that has left - if it took 28+ years for anyone to notice this, it cannot be having all that much effect). To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/bin/sh/main.c cvs rdiff -u -r1.33 -r1.34 src/bin/sh/memalloc.c cvs rdiff -u -r1.18 -r1.19 src/bin/sh/memalloc.h cvs rdiff -u -r1.55 -r1.56 src/bin/sh/options.c cvs rdiff -u -r1.234 -r1.235 src/bin/sh/sh.1 cvs rdiff -u -r1.30 -r1.31 src/bin/sh/shell.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Oct 26 00:05:38 UTC 2021 Modified Files: src/bin/sh: main.c memalloc.c memalloc.h options.c sh.1 shell.h Log Message: PR bin/56464 After almost 30 years, finally do the right thing and read $HOME/.profile rather than .profile in the initial directory (it was that way in version 1.1 ...) All other ash descendants seem to have fixed this long ago. While here, copy a feature from FreeBSD which allows "set +p" (if a shell run by a setuid process with the -p flag is privileged) to reset the privileges. Once done (the set +p) it cannot be undone (a later set -p sets the 'p' flag, but that's all it does) - that just becomes a one bit storage location. We do this, as (also copying from FreeBSD, and because it is the right thing to do) we don't run .profile in a privileged shell - FreeBSD run /etc/suid_profile in that case (not a good name, it also applies to setgid shells) but I see no real need for that, we run /etc/profile in any case, anything that would go in /etc/suid_profile can just go in /etc/profile instead (with suitable guards so the commands only run in priv'd shells). One or two minor DEBUG mode changes (notably having priv'd shells identify themselves in the DEBUG trace) and sh.1 changes with doc of the "set +p" change, the effect that has on $PSc and a few other wording tweaks. XXX pullup -9 (not -8, this isn't worth it for the short lifetime that has left - if it took 28+ years for anyone to notice this, it cannot be having all that much effect). To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/bin/sh/main.c cvs rdiff -u -r1.33 -r1.34 src/bin/sh/memalloc.c cvs rdiff -u -r1.18 -r1.19 src/bin/sh/memalloc.h cvs rdiff -u -r1.55 -r1.56 src/bin/sh/options.c cvs rdiff -u -r1.234 -r1.235 src/bin/sh/sh.1 cvs rdiff -u -r1.30 -r1.31 src/bin/sh/shell.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.86 src/bin/sh/main.c:1.87 --- src/bin/sh/main.c:1.86 Wed Sep 15 18:29:45 2021 +++ src/bin/sh/main.c Tue Oct 26 00:05:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.86 2021/09/15 18:29:45 kre Exp $ */ +/* $NetBSD: main.c,v 1.87 2021/10/26 00:05:38 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.86 2021/09/15 18:29:45 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.87 2021/10/26 00:05:38 kre Exp $"); #endif #endif /* not lint */ @@ -51,6 +51,7 @@ __RCSID("$NetBSD: main.c,v 1.86 2021/09/ #include #include #include +#include #include #include #include @@ -86,6 +87,7 @@ int rootshell; struct jmploc main_handler; int max_user_fd; long user_fd_limit; +bool privileged; #if PROFILE short profile_buf[16384]; extern int etext(); @@ -110,6 +112,7 @@ main(int argc, char **argv) uid_t uid; gid_t gid; sigset_t mask; + bool waspriv; /* * If we happen to be invoked with SIGCHLD ignored, we cannot @@ -129,6 +132,8 @@ main(int argc, char **argv) uid = getuid(); gid = getgid(); + waspriv = privileged = (uid != geteuid()) || (gid != getegid()); + max_user_fd = fcntl(0, F_MAXFD); if (max_user_fd < 2) max_user_fd = 2; @@ -194,6 +199,8 @@ main(int argc, char **argv) debug = 1; /* this may be reset by procargs() later */ #endif opentrace(); + if (privileged) + trputs("Privileged "); trputs("Shell args: "); trargs(argv); #if DEBUG >= 3 set_debug(((DEBUG)==3 ? "_@" : "++"), 1); @@ -206,6 +213,7 @@ main(int argc, char **argv) setstackmark(); procargs(argc, argv); +#if 0 /* This now happens (indirectly) in the procargs() just above */ /* * Limit bogus system(3) or popen(3) calls in setuid binaries, * by requiring the -p flag @@ -216,18 +224,35 @@ main(int argc, char **argv) /* PS1 might need to be changed accordingly. */ choose_ps1(); } +#else /* except for this one little bit */ + if (waspriv && !privileged) + choose_ps1(); +#endif if (argv[0] && argv[0][0] == '-') { state = 1; read_profile("/etc/profile"); state1: state = 2; - read_profile(".profile"); + if (!privileged) { + char *profile; + const char *home; + + home = lookupvar("HOME"); + if (home == NULL) +home = nullstr; + profile = ststrcat(NULL, home, "/.profile", NULL); + read_profile(profile); + stunalloc(profile); + } +#if 0 /* FreeBSD does (effectively) ...*/ + else + read_profile("/etc/suid_profile"); +#endif } state2: state = 3; - if ((iflag || !posix) && - getuid() == geteuid() && getgid() == getegid()) { + if ((iflag || !posix) && !privileged) { struct stackmark env_smark; setstackmark(_smark); @@ -256,6 +281,8 @@ main(int argc, char **argv) setsignal(sigs[i], 0); } + rststackmark(); /* this one is never popped */ + if (minusc)
Re: CVS commit: src/usr.bin/make
Date:Thu, 9 Dec 2021 22:25:58 + From:"Roland Illig" Message-ID: <20211209222558.cdf22f...@cvs.netbsd.org> | make: avoid recursion in CondParser_Or | | Previously, a long chain of '1 || 1 || 1 || 1 || ...' led to a deep | recursion. Furhermore, the code didn't match the grammar on superficial | reading: the grammar said "or || and", the code said "and || or". | | No functional change. That obviously wasn't true. That means that you just guessed at that, so the comment should have been "No functional change intended" instead, but more importantly, for changes this significant you should *always* be doing a test release build before committing. I know that you have reverted this now, which is fine, but for the record the problem was that your change broke short circuit evaluation. Once an || test returns true, you don't do any more of them, the answer is already known. The expression that failed depended upon that, as is allowed. kre
Re: CVS commit: src/usr.bin/make/unit-tests
Date:Thu, 9 Dec 2021 23:57:19 + From:"Roland Illig" Message-ID: <20211209235719.cde20f...@cvs.netbsd.org> | Log Message: | tests/make: prevent the bug from cond.c 1.283 from happening again This new test (while OK of itself) would not have done that. I suspect this test would have passed with that broken version. The actual condition that failed was (effectively) .if 1 && (defined(VAR) || ${VAR} != "string") not .if 0 In that, the "i &&" part is largely irrelevant, you didn't touch && parsing in the change that broke things, just || parsing, so implementing a test that tests short circuit eval of && will not help (this one, it could help others). This is actually not a good text of short circuit eval of && though, it is complicated by the complex (and breakable, as seen) condition on the rhs, better would be .if defined(VAR) && ${VAR} == "yes" or something simple like that. With simple tests for basic short circuit eval, you can then add tests for more complex cases .if 1 && 1 && defined(VAR) && ${VAR} == "yes" (and similar for ||), and after those pass, tests for various complicated combinations of || and && (all with something relying on short circuit eval to verify that things are not tested which should not be). kre
Re: CVS commit: src/usr.bin/make
Date:Fri, 10 Dec 2021 01:36:10 +0100 (GMT+01:00) From:Roland Illig Message-ID: | I guess there's really no way around running the whole build before each | commit, to reach a build success rate of 99.9 %. What I tend to do, where possible, is make a bunch of changes during the day starting from a known buildable HEAD (in my case, day does not necessarily, or even often, match daylight very closely at all, but that's irrelevant), related changes or just plain random ones, then do a release build while I sleep. If it works, then after I am properly awake, go about doing all the appropriate commits, fairly close together. Then if no-one else left the build in a broken state, cvs update everything, and start another build, just to verify it still all builds cleanly. While that happens, I can be doing whatever else needs doing, more changes for the next set, or just walking the dog... If I go for a while not making any changes, I do the cvs update and build cycle again before starting back working on the code. This handles all the "change broke everything" issues (including set list issues) but not always the "change broke my port" problems, so you also need to watch the releng buildbot stats, and if some ports stop building, go look at the logs to see if my change might have caused tha The b5 i386 build broke e-mail helps, but i386 is just one alt port. Do remember that there is very rarely and pressing urgency for changes you are making to get committed. A delay of a few days from change complete to change committed generally hurts no-one. kre ps changes to things that cannot break the build, like man page sources, TODO, CHANGES,.. and often comments, if you are fairly convinced that nothing else will care are not much helped by build testing, so that can often be ommitted. Tests however are not in that category ... not working properly can be ok, not building is not.
CVS commit: src/sys/ddb
Module Name:src Committed By: kre Date: Mon Dec 13 03:17:50 UTC 2021 Modified Files: src/sys/ddb: db_sym.c Log Message: mv out: label into the #ifdef _KERNEL section, as it is only referenced from there. Hopefully ubbreak buikd of usr.sbin/crash To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/ddb/db_sym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: kre Date: Mon Dec 13 03:17:50 UTC 2021 Modified Files: src/sys/ddb: db_sym.c Log Message: mv out: label into the #ifdef _KERNEL section, as it is only referenced from there. Hopefully ubbreak buikd of usr.sbin/crash To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/ddb/db_sym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_sym.c diff -u src/sys/ddb/db_sym.c:1.68 src/sys/ddb/db_sym.c:1.69 --- src/sys/ddb/db_sym.c:1.68 Mon Dec 13 01:25:29 2021 +++ src/sys/ddb/db_sym.c Mon Dec 13 03:17:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_sym.c,v 1.68 2021/12/13 01:25:29 chs Exp $ */ +/* $NetBSD: db_sym.c,v 1.69 2021/12/13 03:17:50 kre Exp $ */ /* * Mach Operating System @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.68 2021/12/13 01:25:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.69 2021/12/13 03:17:50 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_ddbparam.h" @@ -449,8 +449,8 @@ db_printsym(db_expr_t off, db_strategy_t return; } } + out:; #endif -out: (*pr)("%s", db_num_to_str(off)); return; }
CVS commit: src/lib/libc/stdlib
Module Name:src Committed By: kre Date: Sun Mar 13 01:44:37 UTC 2022 Modified Files: src/lib/libc/stdlib: hcreate.c Log Message: Avoid referencing uninit'd memory. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/stdlib/hcreate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/stdlib/hcreate.c diff -u src/lib/libc/stdlib/hcreate.c:1.12 src/lib/libc/stdlib/hcreate.c:1.13 --- src/lib/libc/stdlib/hcreate.c:1.12 Sat Mar 12 17:31:39 2022 +++ src/lib/libc/stdlib/hcreate.c Sun Mar 13 01:44:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: hcreate.c,v 1.12 2022/03/12 17:31:39 christos Exp $ */ +/* $NetBSD: hcreate.c,v 1.13 2022/03/13 01:44:37 kre Exp $ */ /* * Copyright (c) 2001 Christopher G. Demetriou @@ -43,7 +43,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: hcreate.c,v 1.12 2022/03/12 17:31:39 christos Exp $"); +__RCSID("$NetBSD: hcreate.c,v 1.13 2022/03/13 01:44:37 kre Exp $"); #endif /* LIBC_SCCS and not lint */ #if !defined(lint) @@ -124,6 +124,7 @@ hcreate_r(size_t nel, struct hsearch_dat /* Allocate the table. */ head->size = nel; head->filled = 0; + table = NULL; errno = reallocarr(, nel, sizeof(*table)); if (errno) return 0;
CVS commit: src/lib/libc/stdlib
Module Name:src Committed By: kre Date: Sun Mar 13 01:44:37 UTC 2022 Modified Files: src/lib/libc/stdlib: hcreate.c Log Message: Avoid referencing uninit'd memory. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/stdlib/hcreate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/lib/libc/time
Date:Thu, 24 Mar 2022 23:32:30 +0100 From:Roland Illig Message-ID: <6bb00924-edaf-a4c8-348e-ba1304d57...@gmx.de> | Someone should clean up this mess. No, they probabky shouldn't, in general. That source comes from the tz project (currently from tzcode2022a) with local modifications. I think upstream mostly uses ts=4 (or more likely the emacs equivalent). we mostky use tab, and view with ts=8 and yes, that can mead to ugly results. But to ease merging of future versions, this should be touched as little as possible. kre ps: one way and another we have plenty of localtime testing, not all in tests/libc. At least for general correctness. I don't know if all the various hard casez are as well tested locally, but changes that would affect thise generally come from upstream. Lots of people do lots of tests on the upstream code.
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:22:20 UTC 2022 Modified Files: src/external/public-domain/tz/dist: TZDATA_VERSION Log Message: Updated to tzdata2022agtz which is a 2022a fork with backzone zones moved back into the main data repo (restoring old data) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/external/public-domain/tz/dist/TZDATA_VERSION Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/public-domain/tz/dist/TZDATA_VERSION diff -u src/external/public-domain/tz/dist/TZDATA_VERSION:1.26 src/external/public-domain/tz/dist/TZDATA_VERSION:1.27 --- src/external/public-domain/tz/dist/TZDATA_VERSION:1.26 Fri Oct 22 21:01:06 2021 +++ src/external/public-domain/tz/dist/TZDATA_VERSION Sun Mar 20 18:22:20 2022 @@ -1 +1 @@ -tzdata-2021e-(part-2021b) +tzdata-2022agtz
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:22:20 UTC 2022 Modified Files: src/external/public-domain/tz/dist: TZDATA_VERSION Log Message: Updated to tzdata2022agtz which is a 2022a fork with backzone zones moved back into the main data repo (restoring old data) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/external/public-domain/tz/dist/TZDATA_VERSION Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:20:19 UTC 2022 Modified Files: src/external/public-domain/tz/dist: asia australasia backward leap-seconds.list leapseconds version Log Message: Merge tzdata2022agtz To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/public-domain/tz/dist/asia \ src/external/public-domain/tz/dist/australasia \ src/external/public-domain/tz/dist/version cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/backward \ src/external/public-domain/tz/dist/leap-seconds.list \ src/external/public-domain/tz/dist/leapseconds Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/public-domain/tz/dist/asia diff -u src/external/public-domain/tz/dist/asia:1.3 src/external/public-domain/tz/dist/asia:1.4 --- src/external/public-domain/tz/dist/asia:1.3 Fri Oct 22 21:01:06 2021 +++ src/external/public-domain/tz/dist/asia Sun Mar 20 18:20:19 2022 @@ -150,7 +150,11 @@ Zone Asia/Baku 3:19:24 - LMT 1924 May 2 4:00 Azer +04/+05 # Bahrain -# See Asia/Qatar. +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Bahrain 3:22:20 - LMT 1941 Jul 20 # Manamah + 3:30 - +0330 1944 Jan 1 + 4:00 - +04 1972 Jun + 3:00 - +03 # Bangladesh # From Alexander Krivenyshev (2009-05-13): @@ -278,7 +282,13 @@ Zone Asia/Yangon 6:24:47 - LMT 1880 6:30 - +0630 # Cambodia -# See Asia/Bangkok. +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jul 1 + 7:06:30 - PLMT 1911 May 1 + 7:00 - +07 1942 Dec 31 23:00 + 8:00 - +08 1945 Mar 14 23:00 + 9:00 - +09 1945 Sep 2 + 7:00 - +07 # China @@ -2703,10 +2713,20 @@ Zone Asia/Pyongyang 8:23:00 - LMT 1908 A ### # Kuwait -# See Asia/Riyadh. +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Kuwait 3:11:56 - LMT 1950 + 3:00 - +03 # Laos -# See Asia/Bangkok. +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Vientiane 6:50:24 - LMT 1906 Jul 1 + 7:06:30 - PLMT 1911 May 1 + 7:00 - +07 1942 Dec 31 23:00 + 8:00 - +08 1945 Mar 14 23:00 + 9:00 - +09 1945 Sep 2 + 7:00 - +07 1947 Apr 1 + 8:00 - +08 1955 Apr 15 + 7:00 - +07 # Lebanon @@ -2747,6 +2767,7 @@ Rule NBorneo 1935 1941 - Dec 14 0:00 0 - # peninsular Malaysia # taken from Mok Ly Yng (2003-10-30) # https://web.archive.org/web/20190822231045/http://www.math.nus.edu.sg/~mathelmr/teaching/timezone.html +# This agrees with Singapore since 1905-06-01. # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. @@ -2936,7 +2957,9 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 5:45 - +0545 # Oman -# See Asia/Dubai. +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Muscat 3:54:24 - LMT 1920 + 4:00 - +04 # Pakistan @@ -3405,8 +3428,12 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # ... winter time will begin in Palestine from Friday 10-29, 01:00 AM # by 60 minutes backwards. # -# From Paul Eggert (2021-10-20): -# Guess future fall transitions on October's last Friday at 01:00. +# From Tim Parenti (2021-10-25), per Paul Eggert (2021-10-24): +# Guess future fall transitions at 01:00 on the Friday preceding October's +# last Sunday (i.e., Fri>=23), as this is more consistent with recent practice. + +# From Heba Hamad (2022-03-10): +# summer time will begin in Palestine from Sunday 03-27-2022, 00:00 AM. # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S @@ -3442,9 +3469,10 @@ Rule Palestine 2016 2018 - Mar Sat>=24 1 Rule Palestine 2016 2018 - Oct Sat>=24 1:00 0 - Rule Palestine 2019 only - Mar 29 0:00 1:00 S Rule Palestine 2019 only - Oct Sat>=24 0:00 0 - -Rule Palestine 2020 max - Mar Sat>=24 0:00 1:00 S +Rule Palestine 2020 2021 - Mar Sat>=24 0:00 1:00 S Rule Palestine 2020 only - Oct 24 1:00 0 - -Rule Palestine 2021 max - Oct lastFri 1:00 0 - +Rule Palestine 2021 max - Oct Fri>=23 1:00 0 - +Rule Palestine 2022 max - Mar Sun>=25 0:00 1:00 S # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -3538,7 +3566,6 @@ Zone Asia/Manila -15:56:00 - LMT 1844 De Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha 4:00 - +04 1972 Jun 3:00 - +03 -Link Asia/Qatar Asia/Bahrain # Saudi Arabia # @@ -3585,8 +3612,6 @@ Link Asia/Qatar Asia/Bahrain # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14 3:00 - +03 -Link Asia/Riyadh Asia/Aden # Yemen -Link Asia/Riyadh Asia/Kuwait # Singapore # taken from Mok Ly Yng (2003-10-30) @@ -3843,8 +3868,6 @@ Zone Asia/Dushanbe 4:35:12 - LMT 1924 Ma Zone Asia/Bangkok 6:42:04 - LMT 1880 6:42:04 - BMT 1920 Apr # Bangkok Mean Time 7:00 - +07 -Link Asia/Bangkok Asia/Phnom_Penh # Cambodia -Link Asia/Bangkok Asia/Vientiane # Laos
CVS commit: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:20:19 UTC 2022 Modified Files: src/external/public-domain/tz/dist: asia australasia backward leap-seconds.list leapseconds version Log Message: Merge tzdata2022agtz To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/public-domain/tz/dist/asia \ src/external/public-domain/tz/dist/australasia \ src/external/public-domain/tz/dist/version cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/backward \ src/external/public-domain/tz/dist/leap-seconds.list \ src/external/public-domain/tz/dist/leapseconds Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS import: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:00:00 UTC 2022 Update of /cvsroot/src/external/public-domain/tz/dist In directory ivanova.netbsd.org:/tmp/cvs-serv21813 Log Message: Import tzdata2022agtz not from ftp://ftp.iana.org/tz/releases/tzdata2022agtz.tar.gz (2022a comes from ftp://ftp.iana.org/tz/releases/tzdata2022a.tar.gz) Note that 2022agtz is mechanically derived from 2022a by moving back zone data from the "backzone" file that had been removed as "redundant" (because differences to some other zone are all prior to 1970) so that this pre 1970 data is restored. It isn't necessarily correct in all cases, but it is usually better than using some other zone's data which is just as likely to be incorrect for where it applies, and more so elsewhere. Summary of changes in tzdata2022a (2022-03-15 23:02:01 -0700): * Palestine will spring forward on 2022-03-27, not 2022-03-26. * From 1992 through spring 1996, Ukraine's DST transitions were at 02:00 standard time, not at 01:00 UTC. * Chile's Santiago Mean Time and its LMT precursor have been adjusted eastward by 1 second to align with past and present law. * Changes to commentary. Status: Vendor Tag: TZDATA Release Tags: TZDATA2022AGTZ C src/external/public-domain/tz/dist/leap-seconds.list U src/external/public-domain/tz/dist/calendars U src/external/public-domain/tz/dist/CONTRIBUTING U src/external/public-domain/tz/dist/LICENSE U src/external/public-domain/tz/dist/Makefile U src/external/public-domain/tz/dist/NEWS U src/external/public-domain/tz/dist/README N src/external/public-domain/tz/dist/SECURITY U src/external/public-domain/tz/dist/theory.html C src/external/public-domain/tz/dist/version U src/external/public-domain/tz/dist/africa U src/external/public-domain/tz/dist/antarctica C src/external/public-domain/tz/dist/asia C src/external/public-domain/tz/dist/australasia U src/external/public-domain/tz/dist/europe U src/external/public-domain/tz/dist/northamerica U src/external/public-domain/tz/dist/southamerica U src/external/public-domain/tz/dist/etcetera U src/external/public-domain/tz/dist/factory C src/external/public-domain/tz/dist/backward U src/external/public-domain/tz/dist/backzone U src/external/public-domain/tz/dist/iso3166.tab U src/external/public-domain/tz/dist/checklinks.awk C src/external/public-domain/tz/dist/leapseconds U src/external/public-domain/tz/dist/zone.tab U src/external/public-domain/tz/dist/leapseconds.awk U src/external/public-domain/tz/dist/checktab.awk U src/external/public-domain/tz/dist/zoneinfo2tdf.pl U src/external/public-domain/tz/dist/ziguard.awk U src/external/public-domain/tz/dist/zishrink.awk 6 conflicts created by this import. Use the following command to help the merge: cvs checkout -jTZDATA:yesterday -jTZDATA src/external/public-domain/tz/dist
CVS import: src/external/public-domain/tz/dist
Module Name:src Committed By: kre Date: Sun Mar 20 18:00:00 UTC 2022 Update of /cvsroot/src/external/public-domain/tz/dist In directory ivanova.netbsd.org:/tmp/cvs-serv21813 Log Message: Import tzdata2022agtz not from ftp://ftp.iana.org/tz/releases/tzdata2022agtz.tar.gz (2022a comes from ftp://ftp.iana.org/tz/releases/tzdata2022a.tar.gz) Note that 2022agtz is mechanically derived from 2022a by moving back zone data from the "backzone" file that had been removed as "redundant" (because differences to some other zone are all prior to 1970) so that this pre 1970 data is restored. It isn't necessarily correct in all cases, but it is usually better than using some other zone's data which is just as likely to be incorrect for where it applies, and more so elsewhere. Summary of changes in tzdata2022a (2022-03-15 23:02:01 -0700): * Palestine will spring forward on 2022-03-27, not 2022-03-26. * From 1992 through spring 1996, Ukraine's DST transitions were at 02:00 standard time, not at 01:00 UTC. * Chile's Santiago Mean Time and its LMT precursor have been adjusted eastward by 1 second to align with past and present law. * Changes to commentary. Status: Vendor Tag: TZDATA Release Tags: TZDATA2022AGTZ C src/external/public-domain/tz/dist/leap-seconds.list U src/external/public-domain/tz/dist/calendars U src/external/public-domain/tz/dist/CONTRIBUTING U src/external/public-domain/tz/dist/LICENSE U src/external/public-domain/tz/dist/Makefile U src/external/public-domain/tz/dist/NEWS U src/external/public-domain/tz/dist/README N src/external/public-domain/tz/dist/SECURITY U src/external/public-domain/tz/dist/theory.html C src/external/public-domain/tz/dist/version U src/external/public-domain/tz/dist/africa U src/external/public-domain/tz/dist/antarctica C src/external/public-domain/tz/dist/asia C src/external/public-domain/tz/dist/australasia U src/external/public-domain/tz/dist/europe U src/external/public-domain/tz/dist/northamerica U src/external/public-domain/tz/dist/southamerica U src/external/public-domain/tz/dist/etcetera U src/external/public-domain/tz/dist/factory C src/external/public-domain/tz/dist/backward U src/external/public-domain/tz/dist/backzone U src/external/public-domain/tz/dist/iso3166.tab U src/external/public-domain/tz/dist/checklinks.awk C src/external/public-domain/tz/dist/leapseconds U src/external/public-domain/tz/dist/zone.tab U src/external/public-domain/tz/dist/leapseconds.awk U src/external/public-domain/tz/dist/checktab.awk U src/external/public-domain/tz/dist/zoneinfo2tdf.pl U src/external/public-domain/tz/dist/ziguard.awk U src/external/public-domain/tz/dist/zishrink.awk 6 conflicts created by this import. Use the following command to help the merge: cvs checkout -jTZDATA:yesterday -jTZDATA src/external/public-domain/tz/dist
CVS commit: src/doc
Module Name:src Committed By: kre Date: Sun Mar 20 18:04:52 UTC 2022 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Note tzdata 2022a (using tzdata2022agtz upstream fork) To generate a diff of this commit: cvs rdiff -u -r1.1845 -r1.1846 src/doc/3RDPARTY cvs rdiff -u -r1.2865 -r1.2866 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: kre Date: Sun Mar 20 18:04:52 UTC 2022 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Note tzdata 2022a (using tzdata2022agtz upstream fork) To generate a diff of this commit: cvs rdiff -u -r1.1845 -r1.1846 src/doc/3RDPARTY cvs rdiff -u -r1.2865 -r1.2866 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1845 src/doc/3RDPARTY:1.1846 --- src/doc/3RDPARTY:1.1845 Tue Mar 15 21:02:11 2022 +++ src/doc/3RDPARTY Sun Mar 20 18:04:52 2022 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1845 2022/03/15 21:02:11 christos Exp $ +# $NetBSD: 3RDPARTY,v 1.1846 2022/03/20 18:04:52 kre Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -1410,8 +1410,8 @@ Notes: Added changes from a5 -> a12 manually. Package: tz -Version: tzcode2021e / tzdata2021e -Current Vers: tzcode2021e / tzdata2021e +Version: tzcode2021e / tzdata2022agtz +Current Vers: tzcode2022a / tzdata2022a Maintainer: Paul Eggert Archive Site: ftp://ftp.iana.org/tz/releases/ Archive Site: ftp://munnari.oz.au/pub/oldtz/ Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2865 src/doc/CHANGES:1.2866 --- src/doc/CHANGES:1.2865 Tue Mar 15 21:02:11 2022 +++ src/doc/CHANGES Sun Mar 20 18:04:52 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2865 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2866 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -482,3 +482,6 @@ Changes from NetBSD 9.0 to NetBSD 10.0: udf: Fix locking up CD/DVD burner issue that would lockup the FS. [reinoud 20220309] OpenSSL: Imported 1.1.1n. [christos 20220315] + tzdata: updated to 2022a (using the 2022agtz fork to restore data + from previously merged zones) [kre 20220320] +
Re: null-terminated vs. nul-terminated
Date:Tue, 29 Mar 2022 07:40:04 -0400 From:Greg Troxel Message-ID: | It may have been BSD style, but I think it's wrong to use lowercase for | an ASCII codepoint. But we use soh esc nl del (etc) in lower case all the time. You might also want to look at share/misc/ascii kre
Re: null-terminated vs. nul-terminated
And yes I know nl isnot really ascii, but lf and cr are also typically used in lower case. This whole discussion is childish. It doesn't matter. kre
Re: CVS commit: src/tests/fs/vfs
Date:Tue, 1 Feb 2022 18:27:24 + From:"Martin Husemann" Message-ID: <20220201182724.90f82f...@cvs.netbsd.org> | Test mkdir(2) with one or more trailing slashes - this currently fails | for v7fs. As it should I think, trailing slashes are not simply deleted in v7fs. If you do mkdir /path/to/dir/ in a v7 fs, then you're guaranteed (unless some other error happens earlier) either ENOENT if /path/to/dir doesn't already exist, ENOTDIR if it it does but isn't a directory, or EEXIST if it exists and is a directory. The thing to be created always follows the final slash, everything prior to that is path to look up, and must all exist and be directories (with appropriate permissions, etc).In this case the "thing" is "" which is (kind of) an alias for "." (without ever actually looking up "."). It can never not exist if the preceding path all exists. If this was ever changed, it would not truly be a v7fs any more. kre ps: I never understood the fascination with always writing directory names with a trailing / - it seems to come largely from filename completion where the '/' is added if the name found is a directory, so you can just go on typing anything that is to follow in the path (but could easily be removed again if no more components are added - just isn't) but it makes no sense for this to have happened with mkdir, filename completion can only find files that exist, not ones to be created, so it couldn't be that which adds the '/' after the directory name - some human must be doing that, but why? It seems to be to be just meaningless extra unneeded typing.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Wed Feb 2 01:21:34 UTC 2022 Modified Files: src/bin/sh: histedit.c Log Message: After (a few days short of) 21 years, revert 1.25, which did nothing except make the -e option to "fc" fail to work (the commit message was about some other changes entirely, so I an only assume this was committed by mistake). It says a lot about the use of the fc command that no-one noticed that this did not work properly for all this time. Internally in sh, it is possible for built in commands to use either getopt(3) (from libc) or the much simpler internal shell nextopt() routine for option (flag) parsing.However it makes no sense to use getopt() and then access a global variable set only by nextopt() instead of the one getopt() sets (which is what the code had used previously, forever). Use the correct variable again. XXX pullup -9 -8 (-7 -6 -5 ...) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/histedit.c diff -u src/bin/sh/histedit.c:1.59 src/bin/sh/histedit.c:1.60 --- src/bin/sh/histedit.c:1.59 Mon Jan 31 18:15:45 2022 +++ src/bin/sh/histedit.c Wed Feb 2 01:21:34 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $ */ +/* $NetBSD: histedit.c,v 1.60 2022/02/02 01:21:34 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $"); +__RCSID("$NetBSD: histedit.c,v 1.60 2022/02/02 01:21:34 kre Exp $"); #endif #endif /* not lint */ @@ -318,7 +318,7 @@ histcmd(volatile int argc, char ** volat (ch = getopt(argc, argv, ":e:lnrs")) != -1) switch ((char)ch) { case 'e': - editor = optionarg; + editor = optarg; break; case 'l': lflg = 1;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Wed Feb 2 01:21:34 UTC 2022 Modified Files: src/bin/sh: histedit.c Log Message: After (a few days short of) 21 years, revert 1.25, which did nothing except make the -e option to "fc" fail to work (the commit message was about some other changes entirely, so I an only assume this was committed by mistake). It says a lot about the use of the fc command that no-one noticed that this did not work properly for all this time. Internally in sh, it is possible for built in commands to use either getopt(3) (from libc) or the much simpler internal shell nextopt() routine for option (flag) parsing.However it makes no sense to use getopt() and then access a global variable set only by nextopt() instead of the one getopt() sets (which is what the code had used previously, forever). Use the correct variable again. XXX pullup -9 -8 (-7 -6 -5 ...) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/tests/fs/vfs
Date:Wed, 2 Feb 2022 07:11:45 + From:David Holland Message-ID: | v7fs isn't a compat interface for old users, That's sad, I could do with something just for me! | it's a compat interface for old disk images :-) And makefs -t v7fs fits into that purpose how? So maybe it is for us truly old fogies (can we have v6fs as well? Then I'd really feel at home.) Can I have a v7fs as root, and boot from it? Does sysinst support it? kre
Re: CVS commit: src/tests/fs/vfs
Date:Wed, 2 Feb 2022 15:26:21 + From:David Brownlee Message-ID: | So, we just need an optional flag when mounting v7fs to truncate any | looked up filename component to 14 characters That's not, or shouldn't be, necessary - that always happened, the limit was what was stored in the directory, not on the length of the pathname components passed to namei. Further, v7fs (systems of that vintage) had no concept at all of a maximum pathname length (provided there was available ram to store the string). kre
Re: CVS commit: src/etc
A couple of comments about your mount_critical_filesystems_zfs() function in rc.subr It starts: eval _fslist=\$critical_filesystems_zfs I'm not sure what you're attempting to accomplish there. The eval command sees fslist=$critical_filesystems_zfs (the \ having quoted the '$' preventing variable expansion, and was then removed). eval uses that as input, and runs it. But if that was what you wanted, why bother with eval at all, just write it as eval sees it. eval is most useful when some of the arg string is to come from a variable that is expanded before eval sees it, which isn't the case here. Later: _dataset=` (followed by a lengthy command substitution). Please don't use `` command substitutions, they are fragile, and essentially obsolete. The only excuse for ever using them in anything modern is if the script might need to be run by a truly ancient shell. Just use $( ) instead, the semantics are much cleaner. And perhaps more important, near the bottom of the big loop: if [ "$_mount_es" != 0 ]; then _mountcrit_es="$_mount_es" fi which causes the exit status of the function (_mountcrit_es) to be the status of the last mount that failed for some reason, rather than the first (which tends to be more common). Perhaps "zfs mount" only ever does exit(1) for any error, in which case it doesn't matter (1 from any execution is the same thing) but if it returns different exit codes depending upon the error, you usually want the first one, rather than the last - particularly with filesystem mounting, it isn't unusual for later mounts to fail if an earlier one did, if the earlier one was intended to provide the mount points, for example - knowing that the later mounts failed because the directory they intended to mount onto wasn't present is fairly useless, what you want to know is why the earlier one failed. One additional minor point, it might be better to use -ne there instead of != since the values are intended to be integers, rather than strings. But that doesn't really matter (unless $_mount_es might be "" in which case using != is better - that would be 0 for -ne, but not 0 for !=). kre
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Jan 31 18:15:45 UTC 2022 Modified Files: src/bin/sh: histedit.c Log Message: When we initialize libedit (editline) always call ourselves "sh" no matter what $0 is (or is not) set to. This means that editrc(5) lines that start "sh:" are used (in addition to those with no prefix, which will usually be most of them), regardless of the name or manner in which we were invoked. OK christos@ To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Jan 31 18:15:45 UTC 2022 Modified Files: src/bin/sh: histedit.c Log Message: When we initialize libedit (editline) always call ourselves "sh" no matter what $0 is (or is not) set to. This means that editrc(5) lines that start "sh:" are used (in addition to those with no prefix, which will usually be most of them), regardless of the name or manner in which we were invoked. OK christos@ To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/histedit.c diff -u src/bin/sh/histedit.c:1.58 src/bin/sh/histedit.c:1.59 --- src/bin/sh/histedit.c:1.58 Mon Jan 31 16:54:28 2022 +++ src/bin/sh/histedit.c Mon Jan 31 18:15:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $ */ +/* $NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $"); +__RCSID("$NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $"); #endif #endif /* not lint */ @@ -115,7 +115,7 @@ histedit(void) /* * turn editing on */ - char *term, *shname; + char *term; INTOFF; if (el_in == NULL) @@ -151,10 +151,7 @@ histedit(void) setenv("TERM", term, 1); else unsetenv("TERM"); - shname = arg0; - if (shname[0] == '-') -shname++; - el = el_init(shname, el_in, el_out, el_err); + el = el_init("sh", el_in, el_out, el_err); if (el != NULL) { if (hist) el_set(el, EL_HIST, history, hist);
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Jan 31 16:54:28 UTC 2022 Modified Files: src/bin/sh: cd.c histedit.c Log Message: Add some comments explaining accesses to the environment via getenv()/setenv()/unsetenv() which manipulate the envornoment the shell was passed at entry. These are a little odd in sh as that environment is copied into the shell's internal variable data struct at shell startup, and normally never accessed after that - in builtin commands (test. printf, ...) getenv() is #defined to become an internal sh lookup function instead, so even those never use the startup environment). NFCI To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/bin/sh/cd.c cvs rdiff -u -r1.57 -r1.58 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Jan 31 16:54:28 UTC 2022 Modified Files: src/bin/sh: cd.c histedit.c Log Message: Add some comments explaining accesses to the environment via getenv()/setenv()/unsetenv() which manipulate the envornoment the shell was passed at entry. These are a little odd in sh as that environment is copied into the shell's internal variable data struct at shell startup, and normally never accessed after that - in builtin commands (test. printf, ...) getenv() is #defined to become an internal sh lookup function instead, so even those never use the startup environment). NFCI To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/bin/sh/cd.c cvs rdiff -u -r1.57 -r1.58 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/cd.c diff -u src/bin/sh/cd.c:1.52 src/bin/sh/cd.c:1.53 --- src/bin/sh/cd.c:1.52 Tue Nov 16 16:57:15 2021 +++ src/bin/sh/cd.c Mon Jan 31 16:54:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.52 2021/11/16 16:57:15 kre Exp $ */ +/* $NetBSD: cd.c,v 1.53 2022/01/31 16:54:28 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: cd.c,v 1.52 2021/11/16 16:57:15 kre Exp $"); +__RCSID("$NetBSD: cd.c,v 1.53 2022/01/31 16:54:28 kre Exp $"); #endif #endif /* not lint */ @@ -404,6 +404,20 @@ getpwd(int noerror) return; if (first) { + /* + * Note that this happens via the call from initpwd() + * just above, which is called early from main() during + * sh startup, so fetching PWD from the entry environment + * (which is what getenv() does) is acceptable. Here we + * could use normal sh var lookup functions instead, as + * the arriving environment has already been imported before + * we get here, but it makes little difference. + * + * XXX What would be better perhaps would be to move all of + * this into initpwd() instead of here, so we could get rid of + * this "first" static - that function is only ever called once. + * XXX Some other day. + */ first = 0; pwd = getenv("PWD"); if (is_curdir(pwd)) { Index: src/bin/sh/histedit.c diff -u src/bin/sh/histedit.c:1.57 src/bin/sh/histedit.c:1.58 --- src/bin/sh/histedit.c:1.57 Tue Sep 14 15:04:09 2021 +++ src/bin/sh/histedit.c Mon Jan 31 16:54:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.c,v 1.57 2021/09/14 15:04:09 christos Exp $ */ +/* $NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: histedit.c,v 1.57 2021/09/14 15:04:09 christos Exp $"); +__RCSID("$NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $"); #endif #endif /* not lint */ @@ -129,6 +129,23 @@ histedit(void) if (tracefile) el_err = tracefile; #endif + /* + * This odd piece of code doesn't affect the shell + * at all, the environment modified here is the + * stuff accessed via "environ" (the incoming + * envoironment to the shell) which is only ever + * touched at sh startup time (long before we get + * here) and ignored thereafter. + * + * But libedit calls getenv() to discover TERM + * and that searches the "environ" environment, + * not the shell's internal variable data struct, + * so we need to make sure that TERM in there is + * correct. + * + * This sequence copies TERM from the shell into + * the old "environ" environment. + */ term = lookupvar("TERM"); if (term) setenv("TERM", term, 1);
Re: CVS commit: src/tests/fs/vfs
Date:Sat, 5 Feb 2022 22:20:16 + From:David Brownlee Message-ID: | Oops, my earliest unix experience was on a BSD4.3 variant, so I was | spoiled by ffs and didn't realise the (in this context) helpful v7fs | behaviour with overlong filename components. To clarify ... I meant7th edition (and earlier) filesystems, not necessarily the thing we have called v7fs about which I know nothing ... thiugh I wondered when I saw your PR whether a name length problem might be what caused that. kre
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Jan 22 22:53:58 UTC 2022 Modified Files: src/bin/sh: version.h Log Message: After 3 and a bit years, it is time... To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/bin/sh/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/version.h diff -u src/bin/sh/version.h:1.3 src/bin/sh/version.h:1.4 --- src/bin/sh/version.h:1.3 Wed Dec 12 12:16:42 2018 +++ src/bin/sh/version.h Sat Jan 22 22:53:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.3 2018/12/12 12:16:42 kre Exp $ */ +/* $NetBSD: version.h,v 1.4 2022/01/22 22:53:58 kre Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -33,4 +33,4 @@ * when a new (shell only) release is to be exported. This should not be * updated just because a new NetBSD release is to include this code. */ -#define NETBSD_SHELL "20181212" +#define NETBSD_SHELL "20220122"
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Jan 22 22:53:58 UTC 2022 Modified Files: src/bin/sh: version.h Log Message: After 3 and a bit years, it is time... To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/bin/sh/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Thu Apr 7 13:57:44 UTC 2022 Modified Files: src/sbin/gpt: gpt.8 Log Message: Note that biosboot without -A clears the PMBR "active" flag. While here, fix some grammar and make the selection options for biosboot a little clearer. Ride nia@'s Dd bump. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sbin/gpt/gpt.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Thu Apr 7 13:57:44 UTC 2022 Modified Files: src/sbin/gpt: gpt.8 Log Message: Note that biosboot without -A clears the PMBR "active" flag. While here, fix some grammar and make the selection options for biosboot a little clearer. Ride nia@'s Dd bump. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sbin/gpt/gpt.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/gpt/gpt.8 diff -u src/sbin/gpt/gpt.8:1.75 src/sbin/gpt/gpt.8:1.76 --- src/sbin/gpt/gpt.8:1.75 Thu Apr 7 09:06:01 2022 +++ src/sbin/gpt/gpt.8 Thu Apr 7 13:57:44 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpt.8,v 1.75 2022/04/07 09:06:01 nia Exp $ +.\" $NetBSD: gpt.8,v 1.76 2022/04/07 13:57:44 kre Exp $ .\" .\" Copyright (c) 2002 Marcel Moolenaar .\" All rights reserved. @@ -263,28 +263,43 @@ primary bootstrap program, used during The .Fl A options sets the PMBR partition active. +This should not normally be necessary, +but some firmware might require it. +If +.Fl A +is omitted, the active flag will be cleared from the PMBR label. .Pp The .Fl c -option allows the user to specify the filename that +option allows the user to specify the filename from which .Nm -should read the bootcode from. +should read the bootcode. The default is to read from .Pa /usr/mdec/gptmbr.bin . .Pp +The partition that should contain the primary bootstrap code, +.Pq similar to that installed via Xr installboot 8 +is selected using the +.Fl i , +.Fl L +and +.Fl b +options. +One of these three options is required. The .Fl i -option selects the partition that should contain the primary -bootstrap code, as installed via -.Xr installboot 8 . +option selects the partition given by the +.Ar index . The .Fl L -option selects the partition by label. -If there are multiple partitions with the same label, the -first one found will be used. +option selects the partition by +.Ar label . +If there are multiple partitions with the same label, +the first one found will be used. The .Fl b -options selects the partition by start block. +option selects the partition starting at block +.Ar startsec . .\" create .It Nm Ic create Oo Fl AfP Oc Oo Fl p Ar partitions Oc The
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Sep 1 01:57:54 UTC 2023 Modified Files: src/bin/sh: sh.1 Log Message: At the request of bad@ enhance the synopsis of the set built-in command to include explicit mention of the -o opt and +o opt forms. Fix the synopsis to have the 4 forms that the description of the utility discusses, rather than expecting users to understand that the 3rd and 4th forms of the command were combined into the 3rd synopsis format. After doing that, the options in the 3rd format no longer need to be optional, so now all 4 formats are distinct (previously, the third, omitting everything that was optional, and the first, could not be distinguished). While here, some wording and formatting "improvements" as well (nothing too serious). To generate a diff of this commit: cvs rdiff -u -r1.256 -r1.257 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Sep 1 01:57:54 UTC 2023 Modified Files: src/bin/sh: sh.1 Log Message: At the request of bad@ enhance the synopsis of the set built-in command to include explicit mention of the -o opt and +o opt forms. Fix the synopsis to have the 4 forms that the description of the utility discusses, rather than expecting users to understand that the 3rd and 4th forms of the command were combined into the 3rd synopsis format. After doing that, the options in the 3rd format no longer need to be optional, so now all 4 formats are distinct (previously, the third, omitting everything that was optional, and the first, could not be distinguished). While here, some wording and formatting "improvements" as well (nothing too serious). To generate a diff of this commit: cvs rdiff -u -r1.256 -r1.257 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.256 src/bin/sh/sh.1:1.257 --- src/bin/sh/sh.1:1.256 Fri Aug 4 15:31:40 2023 +++ src/bin/sh/sh.1 Fri Sep 1 01:57:54 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.256 2023/08/04 15:31:40 jschauma Exp $ +.\" $NetBSD: sh.1,v 1.257 2023/09/01 01:57:54 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -3725,9 +3725,10 @@ command instead, if you want to return f your shell. .\" .Pp -.It set -.It set { Fl o | Cm +o } -.It Ic set Oo { Fl options | Cm +options } ... Oc Oo Cm \-\|\- Oc Oo Ar arg ... Oc +.It Ic set +.It Ic set No { Fl o | Cm +o No } +.It Ic set No { Fl options | Cm +options | Fl o Ar opt | Cm +o Ar opt } ... Oo Cm \-\|\- Oc Oo Ar arg ... Oc +.It Ic set \-\|\- Oo Ar arg ... Oc .Pp The .Ic set @@ -3751,8 +3752,10 @@ In the form, the shell outputs a string that can later be used as a command to reset all options to their current values. .Pp -If options are given, it sets the specified option -flags, or clears them as described in the +If options are given, +.Nm +sets the specified option flags, +or clears them as described in the .Sx Argument List Processing section. Note that not all options available on the command @@ -3762,6 +3765,7 @@ built-in command. However, in addition to the options listed there, when the .Dq "option name" +.Pq Ar opt given to .Ic set Fl o is @@ -3786,20 +3790,41 @@ parameters with no possibility of changi .Dq \-\|\- as the first argument to .Ic set . -If no following arguments are present, the +If no following +.Ar arg Ns s +are present, the .Ic set command will clear all the positional parameters (equivalent to executing .Dq Li shift $# . ) -Otherwise the following arguments become +Otherwise the following +.Ar arg Ns s +become .Li \&$1 , .Li \&$2 , \&..., and .Li \&$# -is set to the number of arguments present. +is set to the number of +.Ar arg Ns s +present. The third and fourth forms may be combined, to set options, -and the argument list, in one operation. +and the positional parameters, in one operation. +Note that if it is possible that no +.Ar arg Ns uments +might be present, +or if the first +.Ar arg +might begin with a minus +.Pq Sq \&\- +then the +.Dq \-\|\- +is required to distinguish this case from the first +and third variants of this command, and an +.Ar arg +beginning with +.Sq \&\- +from being an attempt to set options. .\" .Pp .It Ic setvar Ar variable Ar value
Re: CVS commit: src/sbin/gpt
Date:Wed, 27 Sep 2023 09:44:10 + From:"Taylor R Campbell" Message-ID: <20230927094410.b9257f...@cvs.netbsd.org> | gpt(8): Make gpt type array and enum match again. Thanks, and apologies for not checking that better - I did test that it recognised the new one properly... kre
CVS commit: src/tests/sbin/fsck_ffs
Module Name:src Committed By: kre Date: Tue Sep 26 12:15:45 UTC 2023 Modified Files: src/tests/sbin/fsck_ffs: quotas_common.sh t_check_quotas.sh t_enable_quotas.sh t_extattr.sh Log Message: Perform quoting of variable expansions, etc correctly. That includes (some) removing of quotes from where they're useless (superstition). This should be NFC for these tests, as the data being quoted doesn't happen to require it, but depending upon the data not altering, or the code not being copied to a different environment is unwise, when it is so easy to simply do it correctly. A few line wrapping and white space changes as well. Nothing changed here is intended to alter the way that the tests run, or results generated. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/sbin/fsck_ffs/quotas_common.sh \ src/tests/sbin/fsck_ffs/t_check_quotas.sh cvs rdiff -u -r1.3 -r1.4 src/tests/sbin/fsck_ffs/t_enable_quotas.sh cvs rdiff -u -r1.4 -r1.5 src/tests/sbin/fsck_ffs/t_extattr.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/sbin/fsck_ffs
Module Name:src Committed By: kre Date: Tue Sep 26 12:15:45 UTC 2023 Modified Files: src/tests/sbin/fsck_ffs: quotas_common.sh t_check_quotas.sh t_enable_quotas.sh t_extattr.sh Log Message: Perform quoting of variable expansions, etc correctly. That includes (some) removing of quotes from where they're useless (superstition). This should be NFC for these tests, as the data being quoted doesn't happen to require it, but depending upon the data not altering, or the code not being copied to a different environment is unwise, when it is so easy to simply do it correctly. A few line wrapping and white space changes as well. Nothing changed here is intended to alter the way that the tests run, or results generated. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/sbin/fsck_ffs/quotas_common.sh \ src/tests/sbin/fsck_ffs/t_check_quotas.sh cvs rdiff -u -r1.3 -r1.4 src/tests/sbin/fsck_ffs/t_enable_quotas.sh cvs rdiff -u -r1.4 -r1.5 src/tests/sbin/fsck_ffs/t_extattr.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/sbin/fsck_ffs/quotas_common.sh diff -u src/tests/sbin/fsck_ffs/quotas_common.sh:1.2 src/tests/sbin/fsck_ffs/quotas_common.sh:1.3 --- src/tests/sbin/fsck_ffs/quotas_common.sh:1.2 Sun Mar 6 17:08:41 2011 +++ src/tests/sbin/fsck_ffs/quotas_common.sh Tue Sep 26 12:15:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: quotas_common.sh,v 1.2 2011/03/06 17:08:41 bouyer Exp $ +# $NetBSD: quotas_common.sh,v 1.3 2023/09/26 12:15:44 kre Exp $ create_with_quotas() { @@ -7,13 +7,13 @@ create_with_quotas() local uid=$(id -u) local gid=$(id -g) - atf_check -o ignore -e ignore newfs -B ${endian} -O ${vers} \ - -s 4000 -F ${IMG} - atf_check -o ignore -e ignore tunefs -q user -q group -F ${IMG} + atf_check -o ignore -e ignore newfs -B "${endian}" -O "${vers}" \ + -s 4000 -F "${IMG}" + atf_check -o ignore -e ignore tunefs -q user -q group -F "${IMG}" atf_check -s exit:0 -o 'match:NO USER QUOTA INODE \(CREATED\)' \ - -o 'match:USER QUOTA MISMATCH FOR ID '${uid}': 0/0 SHOULD BE 1/1' \ - -o 'match:GROUP QUOTA MISMATCH FOR ID '${gid}': 0/0 SHOULD BE 1/1' \ - fsck_ffs -p -F ${IMG} + -o "match:USER QUOTA MISMATCH FOR ID ${uid}: 0/0 SHOULD BE 1/1" \ + -o "match:GROUP QUOTA MISMATCH FOR ID ${gid}: 0/0 SHOULD BE 1/1" \ + fsck_ffs -p -F "${IMG}" } # from tests/ipf/h_common.sh via tests/sbin/resize_ffs @@ -25,20 +25,23 @@ test_case() atf_test_case "${name}" - eval "${name}_head() { \ - atf_set "descr" "Checks ${descr} quotas inodes" + eval "${name}_head() { + atf_set descr 'Checks ${descr} quotas inodes' }" - eval "${name}_body() { \ - ${check_function} " "${@}" "; \ + eval "${name}_body() { + ${check_function} $* }" - tests="${tests} ${name}" + tests="${tests} '${name}'" } atf_init_test_cases() { IMG=fsimage DIR=target - for i in ${tests}; do - atf_add_test_case $i + + eval "set -- ${tests}" + for i + do + atf_add_test_case "$i" done } Index: src/tests/sbin/fsck_ffs/t_check_quotas.sh diff -u src/tests/sbin/fsck_ffs/t_check_quotas.sh:1.2 src/tests/sbin/fsck_ffs/t_check_quotas.sh:1.3 --- src/tests/sbin/fsck_ffs/t_check_quotas.sh:1.2 Sun Mar 6 17:08:41 2011 +++ src/tests/sbin/fsck_ffs/t_check_quotas.sh Tue Sep 26 12:15:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_check_quotas.sh,v 1.2 2011/03/06 17:08:41 bouyer Exp $ +# $NetBSD: t_check_quotas.sh,v 1.3 2023/09/26 12:15:44 kre Exp $ # # Copyright (c) 2011 Manuel Bouyer # All rights reserved. @@ -27,27 +27,29 @@ for e in le be; do for v in 1 2; do -test_case corrupt_list_${e}_${v} corrupt_list \ - "recovery of corrupted free list in" ${e} ${v} -test_case expand1_list_${e}_${v} expand_list \ - "allocation of direct block in" 40 ${e} ${v} -test_case expand2_list_${e}_${v} expand_list \ - "allocation of indirect block in" 1000 ${e} ${v} +test_case "corrupt_list_${e}_${v}" corrupt_list \ + "recovery of corrupted free list in" "${e}" "${v}" +test_case "expand1_list_${e}_${v}" expand_list \ + "allocation of direct block in" 40 "${e}" "${v}" +test_case "expand2_list_${e}_${v}" expand_list \ + "allocation of indirect block in" 1000 "${e}" "${v}" done done corrupt_list() { - create_with_quotas $* - local blkno=$(printf "inode 3\nblks\n" | /sbin/fsdb -nF -f ${IMG} | awk '$1 == "0:" {print $2}') + create_with_quotas "$@" + local blkno=$(printf "inode 3\nblks\n" | + /sbin/fsdb -nF -f "${IMG}" | + awk '$1 == "0:" {print $2}') blkno=$(($blkno * 512 + 104)) #clear the free list - atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} bs=1 \ - count=8 seek=${blkno} conv=notrunc + atf_check -o ignore -e ignore dd if=/dev/zero "of=${IMG}" bs=1 \ + count=8 "seek=${blkno}" conv=notrunc atf_check -s exit:0 \ -o "match:QUOTA ENTRY NOT IN LIST \(FIXED\)" \ - fsck_ffs -fp -F ${IMG} - atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf
CVS commit: src/sys/sys
Module Name:src Committed By: kre Date: Tue Sep 26 15:47:11 UTC 2023 Modified Files: src/sys/sys: disklabel_gpt.h Log Message: Add the GUID for Microsoft Recovery partitions. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/sys/disklabel_gpt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/sys
Module Name:src Committed By: kre Date: Tue Sep 26 15:47:11 UTC 2023 Modified Files: src/sys/sys: disklabel_gpt.h Log Message: Add the GUID for Microsoft Recovery partitions. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/sys/disklabel_gpt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/disklabel_gpt.h diff -u src/sys/sys/disklabel_gpt.h:1.15 src/sys/sys/disklabel_gpt.h:1.16 --- src/sys/sys/disklabel_gpt.h:1.15 Sun Aug 28 13:50:50 2022 +++ src/sys/sys/disklabel_gpt.h Tue Sep 26 15:47:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel_gpt.h,v 1.15 2022/08/28 13:50:50 riastradh Exp $ */ +/* $NetBSD: disklabel_gpt.h,v 1.16 2023/09/26 15:47:11 kre Exp $ */ /* * Copyright (c) 2002 Marcel Moolenaar @@ -147,6 +147,8 @@ struct gpt_ent { {0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}} #define GPT_ENT_TYPE_MS_BASIC_DATA \ {0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}} +#define GPT_ENT_TYPE_MS_RECOVERY \ + {0xde94bba4,0x06d1,0x4d40,0xa1,0x6a,{0xbf,0xd5,0x01,0x79,0xd6,0xac}} #define GPT_ENT_TYPE_MS_LDM_METADATA \ {0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}} #define GPT_ENT_TYPE_MS_LDM_DATA \
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Tue Sep 26 15:48:31 UTC 2023 Modified Files: src/sbin/gpt: gpt_uuid.c Log Message: Recognise Windows Recovery partitions. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Tue Sep 26 15:48:31 UTC 2023 Modified Files: src/sbin/gpt: gpt_uuid.c Log Message: Recognise Windows Recovery partitions. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/gpt/gpt_uuid.c diff -u src/sbin/gpt/gpt_uuid.c:1.19 src/sbin/gpt/gpt_uuid.c:1.20 --- src/sbin/gpt/gpt_uuid.c:1.19 Mon Mar 30 10:41:53 2020 +++ src/sbin/gpt/gpt_uuid.c Tue Sep 26 15:48:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $ */ +/* $NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include #ifdef __RCSID -__RCSID("$NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $"); +__RCSID("$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $"); #endif #include @@ -80,6 +80,7 @@ static const struct { { GPT_ENT_TYPE_LINUX_LVM, "linux-lvm", "Linux LVM" }, { GPT_ENT_TYPE_MS_BASIC_DATA, "windows", "Windows basic data" }, { GPT_ENT_TYPE_MS_RESERVED, "windows-reserved", "Windows reserved" }, + { GPT_ENT_TYPE_MS_RECOVERY, "windows-recovery", "Windows recovery" }, { GPT_ENT_TYPE_NETBSD_CCD, "ccd", "NetBSD ccd component" }, { GPT_ENT_TYPE_NETBSD_CGD, "cgd", "NetBSD Cryptographic Disk" }, { GPT_ENT_TYPE_NETBSD_FFS, "ffs", "NetBSD FFSv1/FFSv2" },
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Tue Sep 26 15:55:46 UTC 2023 Modified Files: src/sbin/gpt: gpt.c Log Message: When extracting the attributes (to printable form), avoid simply ignoring any attribute bits which are unknown, print them as a hex value. This avoids "Attributes: " for most windows filesystem types, which all seem to have but 63 set (which is supposed to mean "don't assign a drive letter" which is akin to "noauto" in fstab - except it is set even on partitions which do get mounted, so must mean something subtly different). These upper 16 attribute bits are supposed to be file system type speficic (in practice, they seem to be common to all filesystem types from one vendor) but we don't have the info (yet anyway) to treat them like that. ChromeOS seems to treat some of the bits as bit fields containing numeric values - add #if 0'd (but compile tested) code to deal with those (maybe, compile tested - but not execution tested) should someone ever get an environment where these things occur, and could add the missing definitions to actually test this. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/gpt/gpt.c diff -u src/sbin/gpt/gpt.c:1.84 src/sbin/gpt/gpt.c:1.85 --- src/sbin/gpt/gpt.c:1.84 Tue Nov 22 00:25:52 2022 +++ src/sbin/gpt/gpt.c Tue Sep 26 15:55:46 2023 @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: gpt.c,v 1.84 2022/11/22 00:25:52 mlelstv Exp $"); +__RCSID("$NetBSD: gpt.c,v 1.85 2023/09/26 15:55:46 kre Exp $"); #endif #include @@ -1239,13 +1239,62 @@ const char * gpt_attr_list(char *buf, size_t len, uint64_t attributes) { size_t i; + /* + * a uint64_t (attributes) has at most 16 hex digits + * in its representation, add 2 for "0x", and 2 more + * for surrounding [ ], plus one for a trailing \0, + * and we need 21 bytes, round that up to 24 + */ + char xbuf[24]; + strlcpy(buf, "", len); - for (i = 0; i < __arraycount(gpt_attr); i++) + for (i = 0; i < __arraycount(gpt_attr); i++) { + /* + * if the attribute is specified in one of bits + * 48..63, it should depend upon the defining + * partition type for that attribute. Currently + * we have no idea what that is, so... + * + * Also note that for some partition types, these + * fields are not a single bit boolean, but several + * bits to form a numeric value. That we could handle. + */ + if (attributes & gpt_attr[i].mask) { strlcat(buf, buf[0] ? ", " : "", len); strlcat(buf, gpt_attr[i].name, len); +#if 0 + /* + * there are none currently defined, so this is untestable + * (it does build however). + */ + if (gpt_attr[i].mask & (gpt_attr[i].mask - 1)) { +/* This only happens in bits 46..63 */ + +/* + * xbuf is big enough for "=65535\0" + * which is the biggest possible value + */ +snprintf(xbuf, sizeof xbuf, "=%ju", +(uintmax_t) ( + (attributes & gpt_attr[i].mask) >> + (ffs((int)(gpt_attr[i].mask >> 48)) + 47) +)); + +strlcat(buf, xbuf, len); + } +#endif + attributes &=~ gpt_attr[i].mask; } + } + + if (attributes != 0) { + snprintf(xbuf, sizeof xbuf, "[%#jx]", (uintmax_t)attributes); + strlcat(buf, buf[0] ? ", " : "", len); + strlcat(buf, xbuf, len); + } + return buf; }
CVS commit: src/sbin/gpt
Module Name:src Committed By: kre Date: Tue Sep 26 15:55:46 UTC 2023 Modified Files: src/sbin/gpt: gpt.c Log Message: When extracting the attributes (to printable form), avoid simply ignoring any attribute bits which are unknown, print them as a hex value. This avoids "Attributes: " for most windows filesystem types, which all seem to have but 63 set (which is supposed to mean "don't assign a drive letter" which is akin to "noauto" in fstab - except it is set even on partitions which do get mounted, so must mean something subtly different). These upper 16 attribute bits are supposed to be file system type speficic (in practice, they seem to be common to all filesystem types from one vendor) but we don't have the info (yet anyway) to treat them like that. ChromeOS seems to treat some of the bits as bit fields containing numeric values - add #if 0'd (but compile tested) code to deal with those (maybe, compile tested - but not execution tested) should someone ever get an environment where these things occur, and could add the missing definitions to actually test this. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Oct 5 20:33:31 UTC 2023 Modified Files: src/bin/sh: miscbltin.c Log Message: If the read builtin is told to read into IFS, we must avoid doing that until all current uses of IFS are complete (as we have IFS's value cached in ifs - if IFS alters, ifs might point anywhere). Handle this by deferring assignments to IFS until everything is done. This makes us appear to comply with the (currently) proposed requirement for read by POSIX that field splitting complete before vars are assigned. (Other shells, like dash, ksh93, yash, bosh behave like this) That might end up being unspecified though, as other shells (bosh, mksh) assign each field to its var as it is delimited (though bosh appears to have bugs). If we wanted to go that route, the issue here could have been handled by re-doing the init of ifs after every setvar() that is performed here (except the last, after which it is no longer needed). XXX pullup -10 To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/bin/sh/miscbltin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/miscbltin.c diff -u src/bin/sh/miscbltin.c:1.53 src/bin/sh/miscbltin.c:1.54 --- src/bin/sh/miscbltin.c:1.53 Sun Dec 11 08:23:10 2022 +++ src/bin/sh/miscbltin.c Thu Oct 5 20:33:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: miscbltin.c,v 1.53 2022/12/11 08:23:10 kre Exp $ */ +/* $NetBSD: miscbltin.c,v 1.54 2023/10/05 20:33:31 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: miscbltin.c,v 1.53 2022/12/11 08:23:10 kre Exp $"); +__RCSID("$NetBSD: miscbltin.c,v 1.54 2023/10/05 20:33:31 kre Exp $"); #endif #endif /* not lint */ @@ -102,6 +102,8 @@ readcmd(int argc, char **argv) int is_ifs; int saveall = 0; ptrdiff_t wordlen = 0; + char *newifs = NULL; + struct stackmark mk; end = '\n';/* record delimiter */ rflag = 0; @@ -132,6 +134,7 @@ readcmd(int argc, char **argv) if ((ifs = bltinlookup("IFS", 1)) == NULL) ifs = " \t\n"; + setstackmark(); status = 0; startword = 2; STARTSTACKSTR(p); @@ -198,8 +201,22 @@ readcmd(int argc, char **argv) continue; } - STACKSTRNUL(p); - setvar(*ap, stackblock(), 0); + if (equal(*ap, "IFS")) { + /* + * we must not alter the value of IFS, as our + * local "ifs" var is (perhaps) pointing at it, + * at best we would be using data after free() + * the next time we reference ifs - but that mem + * may have been reused for something different. + * + * note that this might occur several times + */ + STPUTC('\0', p); + newifs = grabstackstr(p); + } else { + STACKSTRNUL(p); + setvar(*ap, stackblock(), 0); + } ap++; STARTSTACKSTR(p); wordlen = 0; @@ -217,11 +234,25 @@ readcmd(int argc, char **argv) /* Don't remove non-whitespace unless it was naked */ break; } + + /* + * If IFS was one of the variables named, we can finally set it now + * (no further references to ifs will be made) + */ + if (newifs != NULL) + setvar("IFS", newifs, 0); + + /* + * Now we can assign to the final variable (which might + * also be IFS, hence the ordering here) + */ setvar(*ap, stackblock(), 0); /* Set any remaining args to "" */ while (*++ap != NULL) setvar(*ap, nullstr, 0); + + popstackmark(); return status; }
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Oct 5 20:33:31 UTC 2023 Modified Files: src/bin/sh: miscbltin.c Log Message: If the read builtin is told to read into IFS, we must avoid doing that until all current uses of IFS are complete (as we have IFS's value cached in ifs - if IFS alters, ifs might point anywhere). Handle this by deferring assignments to IFS until everything is done. This makes us appear to comply with the (currently) proposed requirement for read by POSIX that field splitting complete before vars are assigned. (Other shells, like dash, ksh93, yash, bosh behave like this) That might end up being unspecified though, as other shells (bosh, mksh) assign each field to its var as it is delimited (though bosh appears to have bugs). If we wanted to go that route, the issue here could have been handled by re-doing the init of ifs after every setvar() that is performed here (except the last, after which it is no longer needed). XXX pullup -10 To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/bin/sh/miscbltin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Oct 20 22:08:52 UTC 2023 Modified Files: src/bin/sh: parser.c Log Message: Work around a probably gcc12 bug in detecting "potentially clobbered" variables after longjmp() for some architectures (sh3 at least). This should allow the workaround to disable those warnings for this file to be removed. In the affected function the extra var & assignment added should simply be deleted by any good optimiser, but if not, it doesn't matter, as performance of this function (expandonstack()) is almost irrelevant. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Oct 20 22:08:52 UTC 2023 Modified Files: src/bin/sh: parser.c Log Message: Work around a probably gcc12 bug in detecting "potentially clobbered" variables after longjmp() for some architectures (sh3 at least). This should allow the workaround to disable those warnings for this file to be removed. In the affected function the extra var & assignment added should simply be deleted by any good optimiser, but if not, it doesn't matter, as performance of this function (expandonstack()) is almost irrelevant. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/parser.c diff -u src/bin/sh/parser.c:1.180 src/bin/sh/parser.c:1.181 --- src/bin/sh/parser.c:1.180 Fri Apr 7 10:34:13 2023 +++ src/bin/sh/parser.c Fri Oct 20 22:08:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.180 2023/04/07 10:34:13 kre Exp $ */ +/* $NetBSD: parser.c,v 1.181 2023/10/20 22:08:52 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; #else -__RCSID("$NetBSD: parser.c,v 1.180 2023/04/07 10:34:13 kre Exp $"); +__RCSID("$NetBSD: parser.c,v 1.181 2023/10/20 22:08:52 kre Exp $"); #endif #endif /* not lint */ @@ -2689,6 +2689,7 @@ expandonstack(char *ps, int cmdsub, int struct jmploc jmploc; struct jmploc *const savehandler = handler; struct parsefile *const savetopfile = getcurrentfile(); + char * const save_ps = ps; const int save_x = xflag; const int save_e_s = errors_suppressed; struct parse_state new_state = init_parse_state; @@ -2740,7 +2741,7 @@ expandonstack(char *ps, int cmdsub, int errors_suppressed = save_e_s; if (result == NULL) - result = ps; + result = save_ps; return result; }
CVS commit: src/libexec/mail.local
Module Name:src Committed By: kre Date: Tue May 17 11:18:58 UTC 2022 Modified Files: src/libexec/mail.local: mail.local.c Log Message: fix local privilege escalation due to a race condition NetBSD-SA2016-006 included an incomplete fix for CVE-2016-6253, a local privilege escalation vulnerability in mail.local(8). mail.local(8) attempts to open(2) a user's existing mailbox file to append to it. If that call fails, mail.local(8) will then issue a second open(2) call to create the file (O_CREAT). An attacker had the opportunity to create the file in question (as a symlink, or link to some other file) in between these two open(2) calls. Fix this by using O_EXCL in the 2nd open call, if the file exists when that one happens, something is going wrong, so just abort. Also, only attempt that 2nd open if the reason the first failed was that the file did not exist (this doesn't fix the issue, but it potentially saves some cycles). Thanks to Jan Schaumann for bringing this to our attention. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/libexec/mail.local/mail.local.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/mail.local
Module Name:src Committed By: kre Date: Tue May 17 11:18:58 UTC 2022 Modified Files: src/libexec/mail.local: mail.local.c Log Message: fix local privilege escalation due to a race condition NetBSD-SA2016-006 included an incomplete fix for CVE-2016-6253, a local privilege escalation vulnerability in mail.local(8). mail.local(8) attempts to open(2) a user's existing mailbox file to append to it. If that call fails, mail.local(8) will then issue a second open(2) call to create the file (O_CREAT). An attacker had the opportunity to create the file in question (as a symlink, or link to some other file) in between these two open(2) calls. Fix this by using O_EXCL in the 2nd open call, if the file exists when that one happens, something is going wrong, so just abort. Also, only attempt that 2nd open if the reason the first failed was that the file did not exist (this doesn't fix the issue, but it potentially saves some cycles). Thanks to Jan Schaumann for bringing this to our attention. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/libexec/mail.local/mail.local.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/mail.local/mail.local.c diff -u src/libexec/mail.local/mail.local.c:1.28 src/libexec/mail.local/mail.local.c:1.29 --- src/libexec/mail.local/mail.local.c:1.28 Thu Jul 21 12:29:37 2016 +++ src/libexec/mail.local/mail.local.c Tue May 17 11:18:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mail.local.c,v 1.28 2016/07/21 12:29:37 shm Exp $ */ +/* $NetBSD: mail.local.c,v 1.29 2022/05/17 11:18:58 kre Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)mail.local.c 8.22 (Berkeley) 6/21/95"; #else -__RCSID("$NetBSD: mail.local.c,v 1.28 2016/07/21 12:29:37 shm Exp $"); +__RCSID("$NetBSD: mail.local.c,v 1.29 2022/05/17 11:18:58 kre Exp $"); #endif #endif /* not lint */ @@ -217,11 +217,12 @@ deliver(int fd, char *name, int lockfile return(EX_OSERR); } - if ((mbfd = open(path, O_APPEND|O_WRONLY|O_EXLOCK, + if ((mbfd = open(path, O_APPEND|O_WRONLY|O_EXLOCK|O_NOFOLLOW, S_IRUSR|S_IWUSR)) == -1) { /* create file */ - if ((mbfd = open(path, O_APPEND|O_CREAT|O_WRONLY|O_EXLOCK, - S_IRUSR|S_IWUSR)) == -1) { + if (errno != ENOENT || + (mbfd = open(path, O_APPEND|O_CREAT|O_WRONLY|O_EXLOCK|O_EXCL, + S_IRUSR|S_IWUSR)) == -1) { logwarn("%s: %s", path, strerror(errno)); rval = EX_OSERR; goto bad;
Re: CVS commit: src/sbin/cgdconfig
Please test it. In HEAD today, and last week, and for probably a long time back into the past, /sbin/cgdconfig has threads, and /rescue/cgdconfig does not. I don"t know when argon2 support was added, or how to use it, but if you do, it should be simple to create an cgd in vnd using one, and then attempt to access it using the other. Let us know the results. kre
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Mon May 16 10:53:14 UTC 2022 Modified Files: src/bin/kill: kill.c Log Message: Alter error messages so they no longer claim that bad input is illegal. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/bin/kill/kill.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.c diff -u src/bin/kill/kill.c:1.32 src/bin/kill/kill.c:1.33 --- src/bin/kill/kill.c:1.32 Sun Aug 30 19:35:09 2020 +++ src/bin/kill/kill.c Mon May 16 10:53:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kill.c,v 1.32 2020/08/30 19:35:09 kre Exp $ */ +/* $NetBSD: kill.c,v 1.33 2022/05/16 10:53:14 kre Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: kill.c,v 1.32 2020/08/30 19:35:09 kre Exp $"); +__RCSID("$NetBSD: kill.c,v 1.33 2022/05/16 10:53:14 kre Exp $"); #endif #endif /* not lint */ @@ -181,7 +181,7 @@ main(int argc, char *argv[]) if (*argv[0] == '%') { pid = getjobpgrp(*argv); if (pid == 0) { -warnx("illegal job id: %s", *argv); +warnx("bad job id: %s", *argv); errors = 1; continue; } @@ -221,7 +221,7 @@ signum(const char *sn) /* check for correctly parsed number */ if (*ep || n <= INT_MIN || n >= INT_MAX ) - errx(EXIT_FAILURE, "illegal signal number: %s", sn); + errx(EXIT_FAILURE, "bad signal number: %s", sn); /* NOTREACHED */ return (int)n; @@ -239,7 +239,7 @@ processnum(const char *s, pid_t *pid) /* check for correctly parsed number */ if (ep == s || *ep || n == INTMAX_MIN || n == INTMAX_MAX || (pid_t)n != n || errno != 0) { - warnx("illegal process%s id: '%s'", (n < 0 ? " group" : ""), s); + warnx("bad process%s id: '%s'", (n < 0 ? " group" : ""), s); return -1; }
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Mon May 16 10:53:14 UTC 2022 Modified Files: src/bin/kill: kill.c Log Message: Alter error messages so they no longer claim that bad input is illegal. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/bin/kill/kill.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sbin/cgdconfig
Date:Mon, 16 May 2022 09:10:40 + From:Taylor R Campbell Message-ID: <20220516090946.a3c4660...@jupiter.mumble.net> | > Please re-enable threads. They influence the output hash | > so by disabling threads you stop people from being able | > to decrypt their disks. | | Surely `disabling threads' just means cgdconfig can't take advantage | of parallelism to compute the same function in less time, not that | cgdconfig computes a different function or fails to compute the same | function, no? I agree, the issue, whatever it was that nia saw, is far more likely caused by the namespace changes influencing just what functions are getting called, in an unintended way, than by anything related to threading. Can we have threads back the way they were last week? That is not race around adding -lpthread to every static link that exists, most likely breaking some size limits along the way. Then, once things build again, if there is a problem, we can debug it, rather than just guessing. kre
CVS commit: src/bin/ksh
Module Name:src Committed By: kre Date: Sun Jul 3 06:30:31 UTC 2022 Modified Files: src/bin/ksh: expr.c Log Message: Fix core dump caused by ksh -c '(i=10; echo $((++-+++i)))' reported by Steffen Nurpmeso (not on a NetBSD list or PR). Seems pointless to fix just one of the bugs in this thing, but this one was easy enough (and stupid enough). (The "i=10" part is unimportant, as is the sub-shell). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/expr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ksh/expr.c diff -u src/bin/ksh/expr.c:1.12 src/bin/ksh/expr.c:1.13 --- src/bin/ksh/expr.c:1.12 Tue May 8 16:37:59 2018 +++ src/bin/ksh/expr.c Sun Jul 3 06:30:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $ */ +/* $NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $ */ /* * Korn expression evaluation @@ -9,7 +9,7 @@ #include #ifndef lint -__RCSID("$NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $"); +__RCSID("$NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $"); #endif @@ -311,6 +311,8 @@ evalexpr(es, prec) token(es); } else if (op == O_PLUSPLUS || op == O_MINUSMINUS) { token(es); + if (es->tok != VAR) +evalerr(es, ET_LVALUE, opinfo[(int) op].name); vl = do_ppmm(es, op, es->val, true); token(es); } else if (op == VAR || op == LIT) {
CVS commit: src/bin/ksh
Module Name:src Committed By: kre Date: Sun Jul 3 06:30:31 UTC 2022 Modified Files: src/bin/ksh: expr.c Log Message: Fix core dump caused by ksh -c '(i=10; echo $((++-+++i)))' reported by Steffen Nurpmeso (not on a NetBSD list or PR). Seems pointless to fix just one of the bugs in this thing, but this one was easy enough (and stupid enough). (The "i=10" part is unimportant, as is the sub-shell). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/expr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/shutdown
Module Name:src Committed By: kre Date: Fri Jul 1 16:45:13 UTC 2022 Modified Files: src/sbin/shutdown: shutdown.8 shutdown.c Log Message: Bring shutdown(8) into the 21st century. I found this juxtaposition in the shutdown man page kind of interesting: time Time is the time at which shutdown will bring the system down and may be the word now or a future time in one of two formats: ... [2nd format:] [cc]yy]mm]dd]hh]mm, ... If the century [cc] is not specified, it defaults to 1900 for years [yy] between 69 and 99, ... In that, all the "[text]" except the one "["(etc) sequence are my interjections, The ellipses ("...") represent where I omitted irrelevant (for here) text. Interesting yes, bizarre also. Requiring a future time, and then defaulting to the (long gone) 20th century (for any random year) makes no sense at all.So I fixed it. In another hundred years or so, anytime from 2100 onwards, but best left at least a decade into the new century, it will need altering again. [One could write the code to automate this adjustment, but the man page would still need updating.] More significant changes will be needed as the 101st century approaches (years 1 and beyond), as then a 2 digit century will no longer be adequate. Call me then, and if I'm able, I'll fix it. If someone really has a need to schedule a shutdown for sometime between 1969 and 1999 that can still be done by explicitly giving the "19" cc value. It is just no longer ever the default. Otherwise, now, years 20..90 mean the 21st century (2020..2099) (the first 2 of those are already unusable, but, IMO, that's OK) and years 00..19 mean the 22nd century (2100..2119) (except that 00, 2100, is still technically the final year of the 21st century). This is advance planning for near the end of the 21st century when someone wants to schedule a shutdown for early in the following century, and can't be bothered typing the 2 century digits. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sbin/shutdown/shutdown.8 cvs rdiff -u -r1.57 -r1.58 src/sbin/shutdown/shutdown.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/shutdown/shutdown.8 diff -u src/sbin/shutdown/shutdown.8:1.33 src/sbin/shutdown/shutdown.8:1.34 --- src/sbin/shutdown/shutdown.8:1.33 Wed Sep 14 00:16:31 2016 +++ src/sbin/shutdown/shutdown.8 Fri Jul 1 16:45:12 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: shutdown.8,v 1.33 2016/09/14 00:16:31 kre Exp $ +.\" $NetBSD: shutdown.8,v 1.34 2022/07/01 16:45:12 kre Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95 .\" -.Dd September 12, 2016 +.Dd July 1, 2022 .Dt SHUTDOWN 8 .Os .Sh NAME @@ -148,17 +148,22 @@ or a future time in one of two formats: .Ar +number , or .Ar [cc]yy]mm]dd]hh]mm , -where the century, year, month, day, and hour may be defaulted +where the century, year, month, day, and hour are two digit decimal +values, which may be defaulted to the current system values. +The two digit (decimal, even with a leading zero) minute field is +required in this form. The first form brings the system down .Ar number minutes from the current time; the second brings the system down at the absolute time specified. -If the century is not specified, it defaults to 1900 for years between 69 -and 99, or 2000 for years between 0 and 68. +If the century is not specified, but the year is, +the century defaults to 2000 (cc==20, the 21st century) +for years between 20 and 99, +or 2100 for years between 0 and 19. A leading zero in the .Dq yy -value is +value (as with all the others) is .Em not optional. .It Ar message ... Index: src/sbin/shutdown/shutdown.c diff -u src/sbin/shutdown/shutdown.c:1.57 src/sbin/shutdown/shutdown.c:1.58 --- src/sbin/shutdown/shutdown.c:1.57 Mon Aug 7 22:08:12 2017 +++ src/sbin/shutdown/shutdown.c Fri Jul 1 16:45:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $ */ +/* $NetBSD: shutdown.c,v 1.58 2022/07/01 16:45:12 kre Exp $ */ /* * Copyright (c) 1988, 1990, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $"); +__RCSID("$NetBSD: shutdown.c,v 1.58 2022/07/01 16:45:12 kre Exp $"); #endif #endif /* not lint */ @@ -486,10 +486,10 @@ getoffset(char *timearg) lt->tm_year += ATOI2(timearg); } else { yearset = ATOI2(timearg); - if (yearset < 69) -lt->tm_year = yearset + 2000 - TM_YEAR_BASE; + if (yearset < 20) +lt->tm_year = yearset + 2100 - TM_YEAR_BASE; else -lt->tm_year = yearset + 1900 - TM_YEAR_BASE; +lt->tm_year = yearset + 2000 -
CVS commit: src/sbin/shutdown
Module Name:src Committed By: kre Date: Fri Jul 1 16:45:13 UTC 2022 Modified Files: src/sbin/shutdown: shutdown.8 shutdown.c Log Message: Bring shutdown(8) into the 21st century. I found this juxtaposition in the shutdown man page kind of interesting: time Time is the time at which shutdown will bring the system down and may be the word now or a future time in one of two formats: ... [2nd format:] [cc]yy]mm]dd]hh]mm, ... If the century [cc] is not specified, it defaults to 1900 for years [yy] between 69 and 99, ... In that, all the "[text]" except the one "["(etc) sequence are my interjections, The ellipses ("...") represent where I omitted irrelevant (for here) text. Interesting yes, bizarre also. Requiring a future time, and then defaulting to the (long gone) 20th century (for any random year) makes no sense at all.So I fixed it. In another hundred years or so, anytime from 2100 onwards, but best left at least a decade into the new century, it will need altering again. [One could write the code to automate this adjustment, but the man page would still need updating.] More significant changes will be needed as the 101st century approaches (years 1 and beyond), as then a 2 digit century will no longer be adequate. Call me then, and if I'm able, I'll fix it. If someone really has a need to schedule a shutdown for sometime between 1969 and 1999 that can still be done by explicitly giving the "19" cc value. It is just no longer ever the default. Otherwise, now, years 20..90 mean the 21st century (2020..2099) (the first 2 of those are already unusable, but, IMO, that's OK) and years 00..19 mean the 22nd century (2100..2119) (except that 00, 2100, is still technically the final year of the 21st century). This is advance planning for near the end of the 21st century when someone wants to schedule a shutdown for early in the following century, and can't be bothered typing the 2 century digits. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sbin/shutdown/shutdown.8 cvs rdiff -u -r1.57 -r1.58 src/sbin/shutdown/shutdown.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc/root
Module Name:src Committed By: kre Date: Sat Jul 9 09:43:52 UTC 2022 Modified Files: src/etc/root: dot.profile Log Message: If /rescue is at the head of $PATH (which is how it starts out in /rescue/sh unless changed by something - and has been since NetBSD 3) don't blindly simply change it to a PATH that doesn't have /rescue in it at all. This doesn't solve the "/rescue/tar execs /usr/bin/gzip" problem completely, as if PATH is in the environment when /rescue/sh is started, that one will override the shell's built in PATH, but this is better than nothing. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/etc/root/dot.profile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/root/dot.profile diff -u src/etc/root/dot.profile:1.32 src/etc/root/dot.profile:1.33 --- src/etc/root/dot.profile:1.32 Mon Aug 24 12:46:57 2020 +++ src/etc/root/dot.profile Sat Jul 9 09:43:51 2022 @@ -1,7 +1,11 @@ -# $NetBSD: dot.profile,v 1.32 2020/08/24 12:46:57 nia Exp $ +# $NetBSD: dot.profile,v 1.33 2022/07/09 09:43:51 kre Exp $ -export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin -export PATH=${PATH}:/usr/X11R7/bin:/usr/local/sbin:/usr/local/bin +case "${PATH}" in +/rescue:*) ;; # leave it alone, user can change manually (if required) +*) export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin + export PATH=${PATH}:/usr/X11R7/bin:/usr/local/sbin:/usr/local/bin + ;; +esac # Uncomment the following line(s) to install binary packages # from cdn.NetBSD.org via pkg_add. (See also pkg_install.conf)
CVS commit: src/etc/root
Module Name:src Committed By: kre Date: Sat Jul 9 09:43:52 UTC 2022 Modified Files: src/etc/root: dot.profile Log Message: If /rescue is at the head of $PATH (which is how it starts out in /rescue/sh unless changed by something - and has been since NetBSD 3) don't blindly simply change it to a PATH that doesn't have /rescue in it at all. This doesn't solve the "/rescue/tar execs /usr/bin/gzip" problem completely, as if PATH is in the environment when /rescue/sh is started, that one will override the shell's built in PATH, but this is better than nothing. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/etc/root/dot.profile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/stat
Module Name:src Committed By: kre Date: Fri Jun 24 13:11:45 UTC 2022 Modified Files: src/usr.bin/stat: stat.1 Log Message: Remove the notge (I added a day or so ago) about IFS interfering with -s output (potentially) - it is almost certainly wrong. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.bin/stat/stat.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.