Commit Graph

3506 Commits

Author SHA1 Message Date
Glen Barber
49dae58b28 Fix including Kyuafile in packaged base system.
Fix a related typo while here.

Note, this change results in the Kyuafile inclusion in the runtime
package, which needs to be fixed, however addresses the PR as far
as I can tell in my tests.

PR:		209114
Submitted by:	ngie
Sponsored by:	The FreeBSD Foundation
2016-04-29 05:28:40 +00:00
Pedro F. Giffuni
8123f597e9 ed(1): switch two statements so we check the index before dereferencing.
This is related to r270256 but was missed in that occasion.

MFC after:	3 days
2016-04-26 14:31:48 +00:00
Andrew Turner
6487f78716 Stop using sbrk in csh. This is a legacy interface and its use within csh
is invalid. It is used to find the size of allocated memory. As malloc may
allocate memory with mmap it will fail to take this memory into account.

Obtained from:	brooks
2016-04-26 11:39:32 +00:00
Marcelo Araujo
ec23a76360 Use NULL instead of 0 for pointers.
kvm_open(3) will return NULL when it cannot access kernel virtual memory.

MFC after:	2 weeks.
2016-04-19 00:40:43 +00:00
Marcelo Araujo
172c3b0b5f Use NULL for pointers instead of 0.
MFC after:	2 weeks.
2016-04-19 00:38:07 +00:00
Jilles Tjoelker
7696368682 sh: Write LINENO value to stack string directly. 2016-04-16 12:14:44 +00:00
Glen Barber
0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
Bryan Drewery
d1dd034d07 META_MODE: Don't rebuild build-tools targets during normal build.
This avoids 'build command changed' due to CFLAGS/CC changes during the
normal build.  Without this the build-tools targets end up rebuilding
for the *target* rather than keeping the native versions built in
build-tools.

Sponsored by:	EMC / Isilon Storage Division
2016-04-14 21:06:10 +00:00
Jilles Tjoelker
d72505899b sh: Simplify code by removing variable bracketed_name. 2016-04-13 20:32:35 +00:00
Glen Barber
a123f26e92 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-12 17:00:13 +00:00
Pedro F. Giffuni
3b7175bdc7 rcp(1): replace 0 with NULL for pointers.
Found with devel/coccinelle.
2016-04-11 17:24:26 +00:00
Glen Barber
876d357fa7 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-11 15:24:59 +00:00
Pedro F. Giffuni
74136dc300 sh(1): replace 0 with NULL for pointers.
Found with devel/coccinelle.

Reviewed by:	jilles
2016-04-09 20:05:39 +00:00
Jilles Tjoelker
4a9f41ec82 sh: Fix some unquoted variables in tests.
The builtins/getopts1.0 test failed if a single-character file existed in
the current directory.
2016-04-09 16:06:13 +00:00
Mark Peek
c8a8eb16e0 Revert r296416 by removing SAVESIGVEC and switching to fork instead. This
fixes usage with system libraries which maintain their own signal state.

PR:             208132
Obtained from:  kib
MFC after:	3 days
2016-04-07 14:25:15 +00:00
Glen Barber
d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Jilles Tjoelker
f30e8c7e71 sh: Fix use-after-free if a trap replaces itself.
MFC after:	1 week
2016-03-28 18:58:40 +00:00
Edward Tomasz Napierala
225636dccb Fix bunch of .Xrs.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-28 16:48:28 +00:00
Bryan Drewery
46a0387a46 CCACHE_BUILD: Don't use ccache when generating some files with CC -E.
At least for ncurses this fixes a build error due to it trying to run
'ccache --version' to work around a gcc 5 bug using the fix in r287205.

Sponsored by:	EMC / Isilon Storage Division
2016-03-24 21:48:13 +00:00
Glen Barber
538354481e MFH
Sponsored by:	The FreeBSD Foundation
2016-03-14 18:54:29 +00:00
Jilles Tjoelker
7d980385e8 sh: Fix copying uninitialized field 'special'.
This just copied uninitialized data and did not depend on it later, so it
should not be dangerous.

Found by:	clang static analyzer
2016-03-13 22:54:14 +00:00
Konstantin Belousov
250d9fd8aa Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add
login.conf(5) support.

Reviewed by:	jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D5610
2016-03-12 14:54:34 +00:00
Glen Barber
7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Jilles Tjoelker
6dbe471130 sh: Add test for 'set -o nolog'.
The option does not do anything so check that the output of 'set +o' is
different.
2016-03-09 21:05:21 +00:00
Jilles Tjoelker
c94a041f43 sh: Avoid out-of-bounds access in setoptionbyindex() for 'set -o nolog'.
Reported by:	hrs
2016-03-09 21:00:57 +00:00
Glen Barber
7e2d468315 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-07 15:44:54 +00:00
Jilles Tjoelker
acb4eada18 sh: Fix some dead stores.
Found by:	clang static analyzer
2016-03-06 17:24:02 +00:00
Glen Barber
b655ec9752 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-06 04:13:17 +00:00
Mark Peek
26526cb970 Signal handling within tcsh vfork code path will conflict with some system
libraries (such as libthr) which maintain their own signal state. This
change adds the tcsh SAVESIGVEC option to save and restore the sigvecs for
the signals the child modifies before it execs.

Reviewed by:	kib, rwatson
Reported by:	kib
2016-03-05 19:55:42 +00:00
Glen Barber
42d27ee343 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 23:53:08 +00:00
Jilles Tjoelker
2efd8c0a6c sh: Remove a redundant STPUTC check. 2016-03-02 22:52:54 +00:00
Jilles Tjoelker
90a2c7ea86 sh: Don't trust that signal descriptions fit within 49 bytes. 2016-03-02 21:24:46 +00:00
Glen Barber
52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Edward Tomasz Napierala
3ea98e058d dump(1) -> dump(8).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 17:17:10 +00:00
Konstantin Belousov
1bdbd70599 Implement process-shared locks support for libthr.so.3, without
breaking the ABI.  Special value is stored in the lock pointer to
indicate shared lock, and offline page in the shared memory is
allocated to store the actual lock.

Reviewed by:	vangyzen (previous version)
Discussed with:	deischen, emaste, jhb, rwatson,
	Martin Simmons <martin@lispworks.com>
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-02-28 17:52:33 +00:00
Edward Tomasz Napierala
75e5511214 Add speed limit to dd(1). This is useful for testing RCTL disk io limits
(when they actually get committed, that is), and might also come in handy
in other situations.

Reviewed by:	wblock@ (man page)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-28 10:27:12 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Glen Barber
aef2f6ad2e MFH
Sponsored by:	The FreeBSD Foundation
2016-02-24 03:08:58 +00:00
Jilles Tjoelker
84f1891033 sh: Fix set -v and multiline history after r295825.
r295825 erroneously dropped the newline from the input data for 'set -v'
output and multiline history.

Reported by:	vangyzen
2016-02-23 22:44:01 +00:00
Glen Barber
317cec3c43 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-22 12:28:23 +00:00
Jilles Tjoelker
2ece338651 sh: Don't hash alias name when there are no aliases. 2016-02-21 20:58:24 +00:00
Jilles Tjoelker
c39f3bac71 sh: Optimize setprompt(0).
Avoid doing work to print an empty prompt (such as when reading scripts).
2016-02-21 18:54:17 +00:00
Jilles Tjoelker
3b3c9ccf08 sh: Remove unnecessary flushouts while reading script.
Output is flushed when a builtin is done or immediately after writing it
(error messages, set -v output, prompts).
2016-02-21 16:48:37 +00:00
Edward Tomasz Napierala
674677bd08 Make the "invalid numeric value" error message actually displayable
(was a dead code before).

Submitted by:	bde@ (earlier version)
Reviewed by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-21 14:36:50 +00:00
Jilles Tjoelker
dcd95d8a01 sh: Rework code to remove '\0' from shell input.
This fixes bugs where '\0' was not removed correctly and speeds up the
parser.
2016-02-19 21:53:12 +00:00
Jilles Tjoelker
a3ec59c20a sh: Add tests for comments in sh -c. 2016-02-19 16:56:07 +00:00
Thomas Quinot
cd1832fe92 Reorganize the handling all-zeroes terminal block in sparse mode
The intent of the previous code in that case was to force
an explicit write, but the implementation was incorrect, and
as a result the write was never performed. This new implementation
instead uses ftruncate(2) to extend the file with a trailing hole.

Also introduce regression tests for these cases.

PR: 189284
(original PR whose fix introduced this bug)

PR: 207092

Differential Revision:	D5248
Reviewed by:	sobomax,kib
MFC after:	2 weeks
2016-02-18 08:44:16 +00:00
Glen Barber
72c3aa02dc MFH
Sponsored by:	The FreeBSD Foundation
2016-02-18 00:37:58 +00:00
Bryan Drewery
d3157f0915 Test directories can build in parallel fine.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:13:59 +00:00
Glen Barber
30922917c8 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-10 04:20:39 +00:00
Glen Barber
ac2875fa16 Explicitly add unmarked bin/ binaries to the runtime package.
Note: tcsh(1) has a MK_TCSH=no test, so this should be a separate
package, which requires pre-install/post-install scripts, to be
added later.

Sponsored by:	The FreeBSD Foundation
2016-02-09 16:58:50 +00:00
Glen Barber
406009982a Add rcp(1) to the rcmds package.
Sponsored by:	The FreeBSD Foundation
2016-02-09 16:56:35 +00:00
Glen Barber
ee76423597 Add rmail to the sendmail package
Sponsored by:	The FreeBSD Foundation
2016-02-09 16:54:04 +00:00
Konstantin Belousov
db57c70a5b Rename P_KTHREAD struct proc p_flag to P_KPROC.
I left as is an apparent bug in ntoskrnl_var.h:AT_PASSIVE_LEVEL()
definition.

Suggested by:	jhb
Sponsored by:	The FreeBSD Foundation
2016-02-09 16:30:16 +00:00
Edward Tomasz Napierala
c075c8bb77 Improve comment to reflect recent changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:38:05 +00:00
Edward Tomasz Napierala
f30414423a Use a proper type for return value of postfix_to_mult(); the way it's
being used wouldn't work if the value returned didn't fit in intmax_t.

Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:37:04 +00:00
Edward Tomasz Napierala
d819236121 Use proper functions for parsing the numeric values.
Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:32:10 +00:00
Glen Barber
bbb51924bb MFH
Sponsored by:	The FreeBSD Foundation
2016-02-08 12:16:01 +00:00
Edward Tomasz Napierala
e53d0abf73 Add 't' and 'p' postfixes to dd(1).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:21:01 +00:00
Edward Tomasz Napierala
66d082c84b Reduce code duplication.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:10:08 +00:00
Bryan Drewery
f408f6043a Don't link /usr/share/nls/de_DE.UTF-8/tcsh.cat to itself.
Sponsored by:	EMC / Isilon Storage Division
2016-02-03 23:37:24 +00:00
Glen Barber
1f4bcc459a More 'tests' packaging fixes.
Sponsored by:	The FreeBSD Foundation
2016-02-03 19:08:45 +00:00
Glen Barber
c4429c7e7c Fix build.
Sponsored by:	The FreeBSD Foundation
2016-02-03 18:06:58 +00:00
Hajimu UMEMOTO
e4b59b10f8 The charset of NLS catalogs were converted to UTF-8
since r231990.
2016-02-03 11:44:43 +00:00
Glen Barber
221b349912 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:27:48 +00:00
Glen Barber
43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Hajimu UMEMOTO
46c57c6794 Make dynamic link of libiconv from ports work again.
The symbols of libiconv from ports were changed to
have prefixed.
Since we have iconv in our libc these days, we don't
need it on 10.X and later.  However, 9.X still need
this.

Spotted by:	Yoshihiko Sarumaru
MFC after:	1 days
2016-02-02 11:51:18 +00:00
Jilles Tjoelker
bd9b38d1f7 sh: Don't allocate a redirtab if there are no redirections.
Builtins (including variable assignments without command word), function
calls and redirected compound commands need to restore file descriptors
to their original state after execution. This is handled by allocating a
redirtab structure. These mallocs and frees show up heavily in pmcstat.

Only allocate a redirtab if there are actually redirections and maintain a
count of how many levels of REDIR_PUSH there are without redirtabs.

A simple loop without external programs like

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    i=$((i+1)); done'

is over 25% faster on an amd64 bhyve VM.
2016-01-30 21:21:25 +00:00
Jilles Tjoelker
7b6779b66b sh(1): Document 'cd -'.
This reflects the changes in r294649 and can therefore not be MFCed by
itself.
2016-01-30 20:10:20 +00:00
Jilles Tjoelker
f1602fa511 test: Optimize operator lookup.
The linear search using strcmp() shows up in pmcstat for several percent.

Split the operators into lengths and whether they start with '-' and compare
bytes using == instead of strcmp().

A simple test

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    v=$(printf %sx%s "$w" "$w"); i=$((i+1)); done'

is over 4% faster on an amd64 bhyve VM.
2016-01-30 19:59:58 +00:00
Glen Barber
f9421853ad MFH
Sponsored by:	The FreeBSD Foundation
2016-01-25 14:13:28 +00:00
Jilles Tjoelker
52d5897d50 sh: Constify internal representation in expand.c.
Forbid (temporary or permanent) modifications of the strings in NARG nodes
during expansion.

Tilde expansion now needs to copy the username for the terminating '\0'.
2016-01-24 22:26:25 +00:00
Jilles Tjoelker
d5119a2a9a sh: Remove a global variable from cd.c. 2016-01-24 17:01:34 +00:00
Jilles Tjoelker
7b40c6df95 sh: Use OLDPWD shell variable for 'cd -'.
Per POSIX, 'cd -' should use the OLDPWD shell variable, not internal state.
This variable is normally exported.

Also, if OLDPWD is not set, fail 'cd -' instead of changing to the current
directory.
2016-01-23 23:00:38 +00:00
Edward Tomasz Napierala
fe819ced32 Don't mention the "canonical six" in setfacl(1); it describes semantics
that's long gone.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-01-23 12:19:37 +00:00
Jilles Tjoelker
a9bdd616f9 sh: Clean a readonly local, even if the variable does not exist outside.
If a local variable has been made read-only, this should not prevent its
removal when the function returns.
2016-01-22 20:10:08 +00:00
Jilles Tjoelker
cce13d6539 sh: Add already working test for local-readonly interaction. 2016-01-22 18:10:36 +00:00
Glen Barber
2971191a94 Create a rcmds package.
Sponsored by:	The FreeBSD Foundation
2016-01-21 17:33:31 +00:00
Jilles Tjoelker
6b8e48f45e sh: Simplify some code related to positional parameters. 2016-01-19 22:41:26 +00:00
Jilles Tjoelker
cf45f1240d sh: Update associated state when restoring locals while leaving a function.
Some variables like PATH call a function when modified. Make sure to call
this also when leaving a function where such a variable was made local.

Make sure to restore local variables before shellparam, so getopts state is
not clobbered.
2016-01-10 16:31:28 +00:00
Jilles Tjoelker
3da40d4a6b sh: Reduce size of options table. 2016-01-07 23:13:20 +00:00
Jilles Tjoelker
0e50eefbd5 sh: Add a test for 'cd -'.
Redirect 'cd -' output to /dev/null since POSIX requires it to write the new
directory name even if not interactive, but we currently only write it if
interactive.
2016-01-07 21:46:07 +00:00
Jilles Tjoelker
adba77a62e sh: Ensure OPTIND=1 in subshell without forking does not affect outer env.
Command substitutions containing a single simple command and here-document
expansion are performed in a subshell environment, but may not fork. Any
modified state of the shell environment should be restored afterward.

The state that OPTIND=1 had been done was not saved and restored here.

Note that the other parts of shellparam need not be saved and restored,
since they are not modified in these situations (a fork is done before such
modifications).
2016-01-07 20:48:24 +00:00
Jilles Tjoelker
ac4ecc78c1 sh: Link tests/builtins/getopts9.0 to the build.
This was forgotten in r273700.
2016-01-03 22:16:27 +00:00
Jilles Tjoelker
d3fa2c78f2 sh: Reduce size of builtins table. 2016-01-03 21:30:22 +00:00
Jilles Tjoelker
bc57b4d469 sh: Remove redundant CTLQUOTEMARK checks.
With the new expand.c code, the intermediate representation passed to the
pathname generation code only contains CTLESC, not CTLQUOTEMARK.

CTLQUOTEMARK now only occurs in the text of NARG nodes (output of the
parser).
2015-12-31 20:15:57 +00:00
Jilles Tjoelker
ee97d8648c sh: Reindent expandmeta(). 2015-12-31 18:56:11 +00:00
Jilles Tjoelker
0e39c931e2 sh: Perform pathname generation during the first expansion phases.
This avoids the need to add and remove CTLESC bytes if pathname generation
will not be performed (set -f).

Side effect: the order of operations is slightly different: pathname
generation in ${$+* $(CMD)} will not see filesystem changes from CMD.
2015-12-31 18:47:54 +00:00
Jilles Tjoelker
47d8814c7f sh: Perform IFS splitting during the first expansion phases.
This simplifies the code and should be faster in some cases.

Side effect: the order of operations is different so that the value of IFS
used when IFS is modified during expansion (${IFS:=...}, ${IFS=...} or
$((...IFS=...))) may be different. Note that this order is highly unportable
between shells.
2015-12-31 17:51:15 +00:00
Jilles Tjoelker
4f2f5faa62 sh: Split subevalvar() in #/##/%/%% and =/? parts. 2015-12-29 20:51:29 +00:00
Pedro F. Giffuni
1e00885aec pax: prevent possible buffer overflow
Or at least quiet down some static analyzers about it.

CID:	978835
MFC after:	1 week
Obtained from:	OpenBSD
2015-12-29 16:31:28 +00:00
Jilles Tjoelker
cf1330bef9 sh: Add tests for #/##/%/%% on $* and $@.
Although POSIX leaves things like ${*#X} unspecified, it occasionally occurs
in practice. Add some tests that seem to work sensibly.
2015-12-26 22:27:48 +00:00
Jilles Tjoelker
cc684f839e sh/mknodes: Close files and check for errors when writing.
This is a build tool only and does not affect run time.

PR:		204951
MFC after:	1 week
2015-12-20 16:40:36 +00:00
Pedro F. Giffuni
6e8ef9cbb0 ed(1): Prevent possible string overflows
Use strlcpy instead of strncpy to guarantee NULL termination.

Pointed out by:	imp
CID:		1007252
X-MFC with:	r292454
2015-12-18 23:05:36 +00:00
Pedro F. Giffuni
bebd99b272 ed(1): Prevent possible string overflows
CID:		1007252
MFC after:	2 weeks
2015-12-18 21:58:42 +00:00
Jilles Tjoelker
d41b2be159 sh: Fix use-after-free when attempting to modify a read-only variable.
Reported by:	bapt
MFC after:	1 week
2015-12-16 20:33:47 +00:00
Baptiste Daroussin
be90c1c6b5 Fix ls -l alignement with new locales
Latest update of locales introduced abbreviated month that follows the regionale
rules meaning that they can be of variable length instead of being arbitrary
truncated to top 3 characters.

To fix alignement, ls now computes the visible length of the abbreviated month,
pads the shorter month with spaces in order to make sure everything is properly
aligned

Reviewed by:	ache, ed, jilles
Differential Revision:	https://reviews.freebsd.org/D4239
2015-12-07 20:48:28 +00:00
Bryan Drewery
4d293dd8dc Add missing CLEANFILES.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2015-12-07 16:08:13 +00:00
Enji Cooper
7b0d44bcba Enable bin/ls testcases disabled previously because of issues with how
kyua 0.11's version of report-junit was rendering non-printable characters

Upgrade to kyua 0.12 to obtain a fixed version of the command

Output verified with python 2.7.10's xml.dom.minidom module

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-12-07 04:03:01 +00:00
Jilles Tjoelker
d253cfe3b2 sh: Add limited test for ${#@} and ${#*}.
POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure
it is numeric.
2015-12-06 14:09:31 +00:00
Jilles Tjoelker
fb6fa0a785 sh: Link tests/parameters/positional8.0 to the build.
This was forgotten in r291025.
2015-12-05 12:55:34 +00:00
Craig Rodrigues
5ef011150c Fix spelling, as recommended by igor tool. 2015-12-01 19:20:38 +00:00
Craig Rodrigues
06691045ba Add more text to explain --libxo flag. 2015-12-01 19:18:53 +00:00
Bryan Drewery
cf990407e1 Update dependencies after r291406 added libelf to libkvm.
Unfortunately filemon/meta mode tracks all indirect dependencies here
since ld(1) is reading libelf when linking in libkvm.  Churn would be
reduced if this was able to be limited to direct dependencies.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:18:48 +00:00
Bryan Drewery
b791fbe630 META MODE: Don't create .meta files when symlinking sources into the obj directory.
Tracking these leads to situations where meta mode will consider the
file to be out of date if /bin/sh or /bin/ln are newer than the source
file.  There's no reason for meta mode to do this as make is already
handling the rebuild dependency fine.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:44:43 +00:00
Jilles Tjoelker
a83f6e1ad9 sh: Remove global state from nodes.c.
No functional change is intended.
2015-11-24 22:47:19 +00:00
Bryan Drewery
6a270e17f3 Remove unneeded libutil dependency for sendmail.
It included libutil.h for setproctitle(3), which was moved from libutil to libc
in r65353 in 2000.

Reviewed by:	gshapiro [sendmail change]
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D4261
2015-11-24 04:19:55 +00:00
Jilles Tjoelker
a5cb58abc8 sh: Fix ""$@, which should not use the special case for "$@".
"$@" should expand to no words if there are no positional parameters, but
""$@ should always expand to at least an empty word.
2015-11-18 21:09:03 +00:00
Baptiste Daroussin
8e5c71e2d6 Protecting against rm -rf / is now POSIXLY_CORRECT per posix 1003.1
edition 2013. No need anymore to disable the protection if one set
the POXILY_CORRECT environment variable.

Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D4092
2015-11-07 02:18:19 +00:00
Jilles Tjoelker
046bfe5240 sh: Avoid copying argv for simple commands.
Add dummy entries before and after so arglist's array is directly usable as
argv.
2015-11-01 22:07:40 +00:00
Ed Maste
8e5bdf761c Update ls -l tests to use mtime, not birthtime
PR:		204155
Reviewed by:	ngie, rodrigc
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4040
2015-10-30 20:14:32 +00:00
Eitan Adler
463a577b27 Fix a ton of speelling errors
arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
2015-10-21 05:37:09 +00:00
Enji Cooper
550d2b80ec Make libxo depend on libutil because it uses humanize_number after r287111
Remove overlinking in lib/libxo/tests, sbin/savecore, and
usr.bin/{iscsictl,wc,xo}

PR: 203673
Sponsored by: EMC / Isilon Storage Division
2015-10-18 07:30:50 +00:00
Enji Cooper
fb9fb4d390 Clean up trailing whitespace
MFC after: 3 days
2015-10-18 05:51:44 +00:00
Enji Cooper
36ace8a0d3 Integrate contrib/netbsd-tests/bin/dd into the FreeBSD test suite as
bin/dd/tests

Ensure fdescfs is mounted on /dev/fd/ for the length testcase as it's used
in validating the characters read from /dev/zero

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-10-18 05:49:58 +00:00
Bryan Drewery
aa92269e46 Add more SUBDIR_PARALLEL.
MFC after:	3 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-10-15 22:55:08 +00:00
Enji Cooper
b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Jilles Tjoelker
8ef0ae8a8f sh: Make struct arglist an array instead of a linked list.
This simplifies the code (e.g. allowing use of qsort(3) instead of a
hand-rolled mergesort) and should have better cache properties.

The waste of unused args arrays after resizes is approximately the same as
the savings from getting rid of the next pointers.

At the same time, remove a piece of global state and move some duplicated
code into a function.
2015-10-11 21:33:00 +00:00
Enji Cooper
c62b746339 Remove all of the syncs
They're unnecessary as shown by further testing on my VM

Requested by: jhb
2015-10-10 01:31:39 +00:00
Enji Cooper
20dbf8ef41 Call sync consistently using atf_check
Remove superfluous sync's
2015-10-06 01:00:12 +00:00
Enji Cooper
910be139a2 Explicitly set BLOCKSIZE to 512 in the environment 2015-10-06 00:55:31 +00:00
Enji Cooper
f46d1be662 Add some more syncs to quiesce the filesystem after creating the
files to see if this fixes deterministic Jenkin failures
2015-10-06 00:23:50 +00:00
Warner Losh
3a845236df Start using the fact that SUBDIR.yes is added to SUBDIR
and move from the pattern of:

.if ${MK_FOO} != "no"
SUBDIR+= bar
.endif

to

SUBDIR.${MK_FOO}+= bar

since we know that MK_FOO is always either yes or no and the latter
form is easier to follow and much shorter. Various exception to this
pattern dealt with on an ah-hoc basis.

Discussed on arch@ a while ago.
2015-10-05 21:41:55 +00:00
Enji Cooper
a0abe9cd7e Merge additional testcases and improvements to bin/ls/ls_tests from
^/user/ngie/more-tests.

- Additional testcases added:
-- ls -D
-- ls -F
-- ls -H
-- ls -L
-- ls -R
-- ls -S
-- ls -T
-- ls -b
-- ls -d
-- ls -f
-- ls -g
-- ls -h
-- ls -i
-- ls -k
-- ls -l
-- ls -m
-- ls -n
-- ls -o
-- ls -p
-- ls -q/ls -w
-- ls -r
-- ls -s
-- ls -t
-- ls -u
-- ls -y
- Socket file creation is limited to the ls -F testcase, greatly speeding up
  the test process
- The ls -C testcase was made more robust by limiting the number of columns
  via COLUMNS and by dynamically formulating the columns/lines.
- Add `atf_test_case` before all testcase `head` functions.

X-MFC with: r284388, r288330, r288423
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-10-05 00:33:57 +00:00
Sean Bruno
64c7af10a7 Initialize fd to -1 so that gcc doesn't emit an unitialized warning. 2015-10-04 01:56:11 +00:00
Bryan Drewery
19271eb4c9 Make GCC happy 2015-10-03 20:24:23 +00:00
Hiroki Sato
1c9fbb5a26 Use getaddrinfo() to fill struct sockaddr_un. It now supports
SOCK_DGRAM and SOCK_SEQPACKET in addition to SOCK_STREAM.
2015-10-03 12:49:05 +00:00
Jilles Tjoelker
d358fa780b wordexp: Rewrite to make WRDE_NOCMD reliable.
Shell syntax is too complicated to detect command substitution and unquoted
operators reliably without implementing much of sh's parser. Therefore, have
sh do this detection.

While changing sh's support anyway, also read input from a pipe instead of
arguments to avoid {ARG_MAX} limits and improve privacy, and output count
and length using 16 instead of 8 digits.

The basic concept is:
execl("/bin/sh", "sh", "-c", "freebsd_wordexp ${1:+\"$1\"} -f "$2",
    "", flags & WRDE_NOCMD ? "-p" : "", <pipe with words>);

The WRDE_BADCHAR error is still implemented in libc. POSIX requires us to
fail strings containing unquoted braces with code WRDE_BADCHAR. Since this
is normally not a syntax error in sh, there is still a need for checking
code in libc, we_check().

The new we_check() is an optimistic check that all the characters
  <newline> | & ; < > ( ) { }
are quoted. To avoid duplicating too much sh logic, such characters are
permitted when quoting characters are seen, even if the quoting characters
may themselves be quoted. This code reports all WRDE_BADCHAR errors; bad
characters that get past it and are a syntax error in sh return WRDE_SYNTAX.

Although many implementations of WRDE_NOCMD erroneously allow some command
substitutions (and ours even documented this), there appears to be code that
relies on its security (codesearch.debian.net shows quite a few uses).
Passing untrusted data to wordexp() still exposes a denial of service
possibility and a fairly large attack surface.

Reviewed by:	wblock (man page only)
MFC after:	2 weeks
Relnotes:	yes
Security:	fixes command execution with wordexp(untrusted, WRDE_NOCMD)
2015-09-30 21:32:29 +00:00
Enji Cooper
14044e16bc Skip the B_flag testcase to stop blowing up freebsd-current@ with
"test failure emails" because kyua report-jenkins doesn't properly
escape non-printable chars
2015-09-30 17:43:02 +00:00
Enji Cooper
c36a2f462d Add initial testcases for bin/ls
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-09-28 03:36:15 +00:00
Allan Jude
62a1a5f751 Fix whitespace error in ls(1) detected by igor
Approved by:	bcr (mentor)
Sponsored by:	EuroBSDCon DevSummit
2015-09-27 22:05:20 +00:00
Allan Jude
141af3c6ab Use one fewer made up words in the ls(1) man page
PR:		203337
Submitted by:	Mike Dame <damemi@gmail.com>
Approved by:	bcr (mentor)
Sponsored by:	EuroBSDCon DevSummit
2015-09-27 22:02:46 +00:00
Bryan Drewery
42c4cf86d4 Update META_MODE dependencies. 2015-09-17 05:06:34 +00:00
Xin LI
28ffe927c2 Expose an interface to determine if an ACE is inherited.
Submitted by:	sef
Reviewed by:	trasz
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D3540
2015-09-04 00:14:20 +00:00
Jilles Tjoelker
92fe71faae sh: Allow empty << EOF markers. 2015-09-02 19:49:55 +00:00
Jilles Tjoelker
f0688a48d2 sh: Fix read with escaped IFS characters at the end.
Characters escaped with a backslash must be treated as if they were not in
IFS. This includes stripping trailing IFS characters.
2015-08-30 17:24:22 +00:00
Jilles Tjoelker
62c3711632 sh: Add set -o nolog.
POSIX requires this to prevent entering function definitions in history but
this implementation does nothing except retain the option's value. In ksh88,
function definitions were usually entered in the history file, even when
they came from ~/.profile and the $ENV file, to allow displaying their
definitions.

This is also the first option that does not have a letter.
2015-08-29 19:41:47 +00:00
Xin LI
b81cd10773 Respect locale settings.
MFC after:	2 weeks
2015-08-28 00:49:30 +00:00
Xin LI
d518359452 Use exit() instead of return in main().
MFC after:	2 weeks
2015-08-28 00:44:58 +00:00
Jilles Tjoelker
4a4867d667 sh: Fix out of bounds read when there is no ] after a [:class:].
The initial check for a matching ] was incorrect if a ] may be consumed by a
[:class:]. The subsequent loop assumed that there must be a ].

Remove the initial check and make the loop cope with a missing ].

Found with afl-fuzz.

MFC after:	1 week
2015-08-25 21:55:15 +00:00
Marcel Moolenaar
d1a0d267b7 Upgrade libxo to 0.4.5.
Local changes incorporated by 0.4.5: r284340
Local changes retained: r276260, r282117

Obtained from:	https://github.com/Juniper/libxo
2015-08-24 16:26:20 +00:00
Jilles Tjoelker
d0b0ac182d sh: Don't create bad parse result when postponing a bad substitution error.
An invalid substitution like ${var@} does not cause a parse error but is
stored in the intermediate representation, to be written as part of the
error message. If there is a CTL* byte in the stored part, this confuses
some code such as the code to skip an unused alternative such as in
${var-alternative}.

To keep things simple, do not store CTL* bytes.

Found with afl-fuzz.

MFC after:	1 week
2015-08-23 20:44:53 +00:00
Jamie Gritton
c4f0631f19 Make pkill/pgrep -j ARG take jname, not just jid.
PR:		201588
Submitted by:	Daniel Shahaf <danielsh at apache.org>
MFC after:	3 days
2015-08-22 05:04:36 +00:00
Jilles Tjoelker
5e03b81fd4 sh: Avoid negative character values from $'\Uffffffff' etc.
The negative value was not expected and generated the low 8 bits as a byte,
which may be an invalid character encoding.

The final shift in creating the negative value was undefined as well.

Make the temporary variable unsigned to fix this.
2015-08-20 22:05:55 +00:00
Jilles Tjoelker
f84460dded sh: Add test for $'\u' without any digits.
It is likely that $'\uXXXX' and $'\UXXXXXXXX' will allow fewer digits in
future. However, no digits at all should still be disallowed.
2015-08-20 21:31:36 +00:00
Jilles Tjoelker
4b6578dc8c sh: Backslash-newline should not affect field splitting in read builtin.
This was originally broken in r212339 in 2010.
2015-08-16 12:57:17 +00:00
Jilles Tjoelker
58bbcdb183 sh: When setting option via long name, don't go via letter.
Looking up the letter makes no sense and prevents adding options that only
have a long name, no letter.
2015-08-14 21:44:15 +00:00
Allan Jude
e9eed90c39 Cast uid and gid to the correct type for display to solve segfault in ls(1) on 32bit arches
Correctly escape literal % for display

This fixes segfaults in 32bit arches caused by r285734

Reviewed by:	ngie
Approved by:	dim
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D3191
2015-07-24 20:20:59 +00:00
Allan Jude
ddaf675fc8 Remove an excess space accidently introduced in the output in ls(1) by r285734
Spotted by:	dim
Approved by:	eadler (mentor)
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D3152
2015-07-22 19:58:21 +00:00
Allan Jude
e5542be424 Fix some issues with the application of libxo to ls(1)
* Add whitespace trimming to some fields (username, group, size, inode, blocks) to avoid whitespace in JSON strings
* fix -m mode, was invalid JSON (repeated keys), and was missing outer array container
* in -n mode, numeric uids and gids were returned as strings

Approved by:	eadler (mentor)
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D2854
2015-07-21 05:03:59 +00:00
David E. O'Brien
e6588b178c Mention the dd-like recoverdisk(1) to help folks find this great BSD command. 2015-07-16 23:38:12 +00:00
Joel Dahl
169a18552e mdoc: minor Xr fixes 2015-07-14 19:45:35 +00:00
Baptiste Daroussin
6f7c45c9d5 Prevent potential integer overflow
PR:		192971
Submitted by:	David Carlier <david.carlier@hardenedbsd.org>
2015-07-13 05:59:41 +00:00
Baptiste Daroussin
d4bf4151a5 Prevent potential integer overflow
PR:		192971
Submitted by:	David Carlier <david.carlier@hardenedbsd.org>
2015-07-13 05:56:27 +00:00
Marius Strobl
6bee009f79 Since r284198, ls(1) just always depends libxo(3), not only in case of
MK_LS_COLORS or !RELEASE_CRUNCH.
2015-07-12 18:40:31 +00:00
Jilles Tjoelker
8956c4ec63 sh(1): libedit has supported multibyte encodings for a while. 2015-07-11 13:07:26 +00:00
Jilles Tjoelker
7bb3697b4e mv: Improve message when moving two or more files to non-directory.
The message text is from cp, which has had a nicer message for this since
2007 (PR bin/50656).

As with cp, the exit status changes from 64 to 1.

PR:		201083
MFC after:	1 week
2015-06-28 21:36:00 +00:00
Jilles Tjoelker
c3c85727d0 sh: Fix some arithmetic undefined behaviour.
Fix shifts of possibly negative numbers found with ubsan and avoid signed
integer overflow when hashing an extremely long command name.

MFC after:	1 week
2015-06-24 20:51:48 +00:00
Alexander Kabaev
0d5beab5be Continue ubreaking ``env LANG=ru_RU.KOI8-R ls -l''.
File names are in current locale as well.
2015-06-17 04:26:48 +00:00
Marcel Moolenaar
284e2b82b2 Unbreak ``env LANG=ru_RU.KOI8-R ls -l''.
Time strings are in the current locale.
2015-06-17 03:12:08 +00:00
Simon J. Gerraty
2ef6d5a7b9 new depends 2015-06-16 23:37:19 +00:00
Simon J. Gerraty
4c46adf174 removed extra keyword 2015-06-13 19:53:24 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Sean Bruno
a0be738b20 r284198 seems to have left a null format string printf that gcc does *not*
like breaking mips builds.

Submitted by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Obtained from:	HardenedBSD
2015-06-11 02:29:39 +00:00
Marcel Moolenaar
52e4a08c45 Convert ls(1) to use libxo(3).
Obtained from:	Phil Shafer <phil@juniper.net>
Sponsored by:	Juniper Networks, Inc.
2015-06-10 01:27:38 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Bryan Drewery
724fd44827 Cleanup some style(9) issues.
- Whitespace.
- Comments.
- Wrap long lines.

MFC after:	2 weeks
X-MFC-with:	r284105,r284106
Sponsored by:	EMC / Isilon Storage Division
2015-06-08 19:24:18 +00:00
Xin LI
183714f3f7 It has been long time that when doing 'ls -G /path/to/a/symlink', instead of
using the color of symbolic link, the color is determined by the link target.
This behavior was quite confusing.

Looking at the file history, it looks like that r203665 intends to fix this
but the issue was never actually fixed.

Fix this by not setting FTS_COMFOLLOW when color is requested like what was
done in r203665.

MFC after:	2 weeks
2015-06-08 19:13:04 +00:00
Bryan Drewery
7ea2450f42 Implement '-s' to copy as symlink, similar to the current -l link(2) handling.
This is also implemented in at least GNU coreutils cp.

While here also improve the '-l' handling to not open(2) the source file as
it does not actually need the descriptor.

Sponsored by:	EMC / Isilon Storage Division
2015-06-07 06:30:25 +00:00
Bryan Drewery
14376e1f21 Cleanup some indentation issues. 2015-06-07 03:49:41 +00:00
Sergey Kandaurov
db1a93d4fe Change directory permissions in pre-order.
In this order, it won't try to recurse into a directory for which
it doesn't have permission, before changing that permission.
This follows an existing behavior in other BSDs, linux, OS X.

Obtained from:	NetBSD
2015-06-04 19:18:58 +00:00
Marcelo Araujo
16eb357647 Remove unused variable, this variable fmtstr was introduced at revision r225868
and it is not used anymore after the convertion to use libxo at revision r283304.

Differential Revision:	D2678
Reviewed by:		marcel
2015-06-01 06:00:04 +00:00
Sergey Kandaurov
e8d89b8442 Document recent p_flag2 additions. 2015-05-27 10:08:31 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Marcel Moolenaar
8beb1a2fdc Convert to use libxo. Document use of libxo as well.
Obtained from:  Phil Shafer <phil@juniper.net>
Sponsored by:   Juniper Networks, Inc.
2015-05-22 23:07:55 +00:00
Xin LI
94bdf5cfcc Eliminate unneeded includes.
MFC after:	2 weeks
2015-05-21 18:29:36 +00:00
Xin LI
8b45db8ee2 date(1): Make -r behave like GNU's version when the option can not be
interpreted as a number, which checks the file's modification time and
use that as the date/time value.

This improves compatibility with GNU coreutils's version of time(1).

MFC after:	2 weeks
2015-05-07 20:54:38 +00:00
Jilles Tjoelker
c633f8dc04 cp: Remove fts sorting.
In an attempt to improve performance, cp reordered directories first
(although the comment says directories last). This is not effective with new
UFS layout policies.

The sorting reorders multiple arguments passed to cp, which may be
undesirable.

Additionally, the comparison function does not induce a total order. Per
POSIX, this causes undefined behaviour in qsort().

NetBSD removed the sorting in 2009.

On filesystems that return directory entries in hash/btree order, sorting by
d_fileno before statting improves performance on large directories. However,
this can only be implemented in fts(3).

PR:		53475
Reviewed by:	bde (in 2004)
MFC after:	1 week
2015-05-05 13:23:03 +00:00
Steven Hartland
ad34cace15 Standardise chmod, chflags, chown and chgrp recursive symlink processing
chmod, chflags, chgrp, chmod and chown now affect symlinks in -R mode as
defined in symlink(7); previously symlinks were silently ignored.

Differential Revision:	https://reviews.freebsd.org/D2316
Reviewed by:	jilles
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Multiplay
2015-04-29 00:49:00 +00:00
Baptiste Daroussin
dc814fa48b Pet manlint 2015-04-26 10:38:26 +00:00
Baptiste Daroussin
ef2a65a8bd Use mdoc(7) macros for curly braces 2015-04-26 10:09:26 +00:00
Baptiste Daroussin
1517e5649b mdoc: escape Re 2015-04-26 10:03:05 +00:00
Jilles Tjoelker
cad3cc1310 sh: Pass along SIGINT from a child if job control is enabled, even when not
interactive.

I added the interactive check in r208881 to be safe, but in actual use
(scripts in set -m mode) passing along SIGINT seems best.

Discussed with:	bdrewery
2015-04-25 13:34:25 +00:00
Eitan Adler
7d00295b1b ed(1): Fix [-Werror=logical-not-parentheses]
/usr/src/bin/ed/glbl.c:64:36: error: logical not is only applied to
	theleft hand side of comparison [-Werror=logical-not-parentheses]

Obtained from:	Dragonfly (1fff89cbaeaa43af720a1f23d9c466b756dd8a58)
MFC After:	1 month
2015-04-20 02:07:57 +00:00
Eitan Adler
e6743d31d3 bin/ed: use correct type in multiplication
The result is line_t** so the multiplication should be size *
	sizeof(line_t*)

MFC After:	1 month
2015-04-18 23:56:04 +00:00
Bryan Drewery
a59f817491 sh: Fix the trap builtin to be POSIX-compliant for 'trap exit SIG' and 'trap n n...'.
The parser considered 'trap exit INT' to reset the default for both EXIT and
INT. This beahvior is not POSIX compliant. This was avoided if a value was
specified for 'exit', but then disallows exiting with the signal received. A
possible workaround is using ' exit'.

However POSIX does allow this type of behavior if the parameters are all
integers. Fix the handling for this and clarify its support in the manpage
since it is specifically allowed by POSIX.

Differential Revision:	https://reviews.freebsd.org/D2325
Reviewed by:	jilles
MFC after:	2 weeks
2015-04-18 23:49:57 +00:00
Tijl Coosemans
969dfbc7f3 Fix build after r281550 when WITHOUT_ICONV is defined.
Reported by:	adrian
MFC after:	2 weeks
2015-04-16 07:17:00 +00:00
Tijl Coosemans
1243a98e38 Remove the const qualifier from iconv(3) to comply with POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html

Adjust all code that calls iconv.

PR:		199099
Exp-run by:	antoine
MFC after:	2 weeks
2015-04-15 09:09:20 +00:00
Jilles Tjoelker
739d568935 sh: Add more tests for exotic IFS splitting. 2015-03-31 20:59:37 +00:00
Jilles Tjoelker
347b9f6de0 cp,mv: Use futimens() instead of utimensat() if possible. 2015-03-23 17:35:05 +00:00
Dimitry Andric
c969922258 Build expr with -fwrapv, since it relies on signed integer wrapping
having defined behavior.

Reported by:	rodrigc
MFC after:	3 days
2015-03-22 22:40:32 +00:00
Eitan Adler
d6e1f8d70c Implement pax -O option to permit limiting a PAX archive to a single volume.
-O Force the archive to be one volume.  If a volume ends prematurely, pax will
not prompt for a new volume.

PR:		198481
Submitted by:	Sevan Janiyan
Reviewed by:	allanjude (doc)
2015-03-18 05:48:05 +00:00
Mark Felder
c2290ff6b8 Use 24h timestamps in the ps(1) STARTED column
The previous 12h AM/PM format was perplexing as it didn't follow the
locale of the user and was a minor annoyance to FreeBSD users coming
from Linux. Additionally, the man page was incorrect about the strftime
format.

There are three time formats that may be displayed in the STARTED
column depending on the age of the process. Below is an example.

For a process started at 14:30 on Monday 16 March 2015, the following
formats may be used:

14:30 for process < 24h old (24h Timestamp)
Mon14 for process > 24h, < 1 week old (Weekday Hour)
16Mar15 for process > 1 week old (Day Month Year)

Differential Revision:	https://reviews.freebsd.org/D1620
Reviewed by:	brd
Approved by:	trasz
2015-03-17 12:40:33 +00:00
Baptiste Daroussin
8ae63aa054 r* commands are not precious anymore 2015-03-04 22:01:44 +00:00
Jilles Tjoelker
58bdb0761c sh: Fix more compiler warnings related to variable declarations. 2015-03-03 21:21:43 +00:00
Jilles Tjoelker
22afca9b67 sh: Fix more compiler warnings. 2015-03-01 22:32:23 +00:00
Jilles Tjoelker
22ea47ec90 sh: Fix compiler warnings related to duplicate or missing declarations. 2015-03-01 21:46:55 +00:00
Nathan Whitehorn
c4b725f42a Fix unitialized variable that broke sh on PowerPC starting with r278826. 2015-02-26 20:59:18 +00:00
Jilles Tjoelker
4445af212c sh: Add details about importing the environment and initializing OPTIND. 2015-02-22 21:32:57 +00:00
Enji Cooper
7a2065efd7 Disguising stderr from jls generally considered harmful
Undisguising it dumps out the following logspew:

jls: unknown parameter: allow

PR: 191019
2015-02-21 23:39:43 +00:00
Jilles Tjoelker
e63db0d3e5 symlink(7): Mention chflagsat() (can take AT_SYMLINK_NOFOLLOW).
MFC after:	1 week
2015-02-16 12:56:55 +00:00
Jilles Tjoelker
7034d8df04 sh: Various cleanups to expand.c:
* Remove some gotos.
* Remove unused parameter.
* Remove duplicate code.
2015-02-15 22:38:00 +00:00
Jilles Tjoelker
781bfb5a53 sh: Prefer "" to nullstr where possible. 2015-02-15 21:47:43 +00:00
Jilles Tjoelker
a4652c280b sh: Add stsavestr(), like savestr() but allocates using stalloc(). 2015-02-15 21:41:29 +00:00
Jilles Tjoelker
8c6cc7dad5 sh: Add simple tests for globbing/splitting command substitution. 2015-02-15 19:48:29 +00:00
Enji Cooper
bacc28cea1 Refactor pkill-j_test to reflect the relevant changes done to pgrep-j_test
r278742:

Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
the jail ID (poll up to 10 times for the jail IDs to become available)

If the scan fails, the code will fall through and fail as it does with Jenkins
today

r278636:

Parameterize out the amount of sleep done in each test

Set the value in each test to a different amount to avoid potential
side-effects with other instances of the test (or lingering processes) still
being present on the system

r278633:

Refactor the tests

1. `id -u` -> 0 is now only checked once; the entire test script is now skipped
   if this assertion is violated
2. De-dent whitespace, based on 1.
3. Only setup the symlink for $sleep once at the top of the script, and tear it
   down once at the bottom of the script
2015-02-14 19:21:04 +00:00
Enji Cooper
8edd0e3040 Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
the jail ID (poll up to 10 times for the jail IDs to become available)

If the scan fails, the code will fall through and fail as it does with Jenkins
today
2015-02-14 06:19:24 +00:00
Enji Cooper
01f66c0831 Call wait to ensure that background processes have died
This is being done to establish parity with pgrep-j_test
2015-02-13 01:07:12 +00:00
Enji Cooper
18f4d1079e Parameterize out the amount of sleep done in each test
Set the value in each test to a different amount to avoid potential
side-effects with other instances of the test (or lingering processes) still
being present on the system
2015-02-12 21:10:32 +00:00
Enji Cooper
b8b9865304 Refactor the tests
1. `id -u` -> 0 is now only checked once; the entire test script is now skipped
   if this assertion is violated
2. De-dent whitespace, based on 1.
3. Only setup the symlink for $sleep once at the top of the script, and tear it
   down once at the bottom of the script
2015-02-12 20:57:57 +00:00
Enji Cooper
24f1069ab4 Add debugging output to help track down the recent Jenkins failures 2015-02-12 07:22:46 +00:00
Pedro F. Giffuni
484f578134 Prevent access to an uninitialized variable
The "-h" option may access an uninitialized value. Prevent it
by properly initializing the value.

CID:	1006559
2015-01-31 15:41:01 +00:00
Jilles Tjoelker
edebe56497 sh: Abort a wait builtin on any trapped signal.
This is required by POSIX.

PR:		197210
Reported by:	ache
MFC after:	2 weeks
2015-01-31 13:53:29 +00:00
Stefan Eßer
8da97f0057 Fix overflow check for multiplication:
- Add special test to detect the case of -1 * INTMAX_MIN
- Protect against elimination of the test division by the optimizer

Garrett Cooper noticed that the overflow checks were incomplete, and Bruce
Evans suggested the use of the "volatile" qualifier to counter the effect
of the undefined behaviour, when the prior multiplication caused overflow,
and he also suggested improvements to the comments.

Reviewed by:	bde
MFC after:	1 week
2015-01-27 18:04:41 +00:00
Jilles Tjoelker
5faf2ae160 cp,mv,touch: Set timestamps with nanosecond precision.
This uses utimensat().
2015-01-24 13:50:13 +00:00
Jilles Tjoelker
2205e0d1bd Add futimens and utimensat system calls.
The core kernel part is patch file utimes.2008.4.diff from
pluknet@FreeBSD.org. I updated the code for API changes, added the manual
page and added compatibility code for old kernels. There is also audit and
Capsicum support.

A new UTIME_* constant might allow setting birthtimes in future.

Differential Revision:	https://reviews.freebsd.org/D1426
Submitted by:	pluknet (partially)
Reviewed by:	delphij, pluknet, rwatson
Relnotes:	yes
2015-01-23 21:07:08 +00:00
Hajimu UMEMOTO
f79998c8fc Don't include newvers.sh into freebsd-version. 2015-01-22 17:13:43 +00:00
Enji Cooper
e15138e574 Integrate contrib/netbsd-tests/bin/expr into the build/kyua as bin/expr/tests
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-01-19 06:13:07 +00:00
Will Andrews
7a37b5fc17 Add a ${CP} alias for copying files in the build.
Some users build FreeBSD as non-root in Perforce workspaces.  By default,
Perforce sets files read-only unless they're explicitly being edited.
As a result, the -f argument must be used to cp in order to override the
read-only flag when copying source files to object directories.  Bare use of
'cp' should be avoided in the future.

Update all current users of 'cp' in the src tree.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Spectra Logic
2015-01-16 21:39:08 +00:00
Enji Cooper
a9c218da80 Install d_align.{in,out} for the :align test
X-MFC with: r276669
Pointyhat to: me
2015-01-05 20:38:47 +00:00
Enji Cooper
dd2b763aa5 Integrate bin/cat/tests from NetBSD into atf/kyua
Sponsored by: EMC / Isilon Storage Division
2015-01-04 22:37:44 +00:00
Jilles Tjoelker
df30ae985d symlink(7): Note that stat(1) does not follow symlinks by default.
MFC after:	1 week
2014-12-29 13:02:03 +00:00
Jilles Tjoelker
85052e7b56 sh: Move some code from onint() to onsig(), making onint() noreturn.
As a result, the INTON macro which is used many times generates fewer
bytes of code.
2014-12-21 23:09:59 +00:00
Jilles Tjoelker
f649ab8b15 sh: Remove EXP_REDIR.
EXP_REDIR was supposed to generate pathnames in redirection if exactly one
file matches, as permitted but not required by POSIX in interactive mode. It
is unlikely this will be implemented.

No functional change is intended.

MFC after:	1 week
2014-12-21 22:18:30 +00:00
Jilles Tjoelker
88ef06f3a9 sh: Make sure output suitable as shell input is also printable.
Commands like 'export -p', 'set' and 'trap', and tracing enabled via 'set
-x' generate output suitable as shell input by adding quotes as necessary.

If there are control characters other than newline or invalid UTF-8
sequences, use $'...' and \OOO to display them safely.

The resulting output is not parsable by a strict POSIX.1-2008 shell but sh
from FreeBSD 9.0 and newer and many other shells can parse it.
2014-12-14 16:26:19 +00:00
Konstantin Belousov
6ddcc23386 Add facility to stop all userspace processes. The supposed use of the
feature is to quisce the system before suspend.

Stop is implemented by reusing the thread_single(9) with the special
mode SINGLE_ALLPROC.  SINGLE_ALLPROC differs from the existing
single-threading modes by allowing (requiring) caller to operate on
other process.  Interruptible sleeps for !TDF_SBDRY threads are
suspended like SIGSTOP does it, instead of aborting the sleep, like
SINGLE_NO_EXIT, to avoid spurious EINTRs on resume.

Provide debugging sysctl debug.stop_all_proc, which causes total stop
and suspends syncer, while waiting for variable reset for resume.  It
is used for debugging; should be removed after the real use of the
interface is added.

In collaboration with:	pho
Discussed with:	avg
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-12-13 16:18:29 +00:00
Dag-Erling Smørgrav
cb92abb49c Fix dependency on newvers.sh
Noticed by:	marck
MFC after:	1 week
2014-12-10 03:12:22 +00:00
Jilles Tjoelker
e753a1effb sh: Remove special case for '=' in set -x; always quote it in outqstr().
I plan to make set -x output always printable using $'...'; avoiding quoting
words containing '=' is not worth the extra complexity.
2014-11-30 20:12:47 +00:00
Baptiste Daroussin
12cd1730ee Convert bin/ to LIBADD, reduce overlinking allow to build all components as
static
2014-11-25 11:15:40 +00:00
Jilles Tjoelker
fafeab4393 sh: Prepend "$0: " to error messages if there is no command name. 2014-11-22 23:28:41 +00:00
Jilles Tjoelker
08dc8cf90c sh: Use DQSYNTAX only while expanding, not SQSYNTAX.
Quoting during expansion only cares about CCTL, which is the same for
DQSYNTAX and SQSYNTAX.
2014-11-22 16:03:18 +00:00
Simon J. Gerraty
488c975a1f Updated/new dependencies 2014-11-19 07:10:38 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Jilles Tjoelker
b1f6059232 sh(1): Add/improve information about exit status of commands. 2014-11-14 17:11:28 +00:00
Jilles Tjoelker
945e15624b sh(1): Mention portability issue with shifting zero positional parameters.
Per Austin Group issue #459, shifting zero positional parameters may or may
not be considered an operand error (which causes the shell to exit in most
cases).
2014-11-07 21:30:16 +00:00
Marcel Moolenaar
6fea8dc88f Document that df(1) supports libxo(3). 2014-11-07 03:07:10 +00:00
Marcel Moolenaar
b6ff8745aa Convert to use libxo.
Obtained from:  Phil Shafer <phil@juniper.net>
Sponsored by:   Juniper Networks, Inc.
2014-11-07 03:03:25 +00:00
Jilles Tjoelker
5dff1efc27 sh: Fix corruption of CTL* bytes in positional parameters in redirection.
EXP_REDIR was not being checked for while expanding positional parameters in
redirection, so CTL* bytes were not being prefixed where they should be.

MFC after:	1 week
2014-10-31 22:28:10 +00:00
Jilles Tjoelker
3fb51b3a43 Treat IFS separators in "$*" as quoted.
This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
2014-10-28 22:14:31 +00:00
Kurt Jaeger
f4cfd28bb5 bin/dd: revert 273734, as it fails on 32bit platforms
Revert: insufficient testing on 32bit platforms

PR:		191263
2014-10-27 17:39:37 +00:00
Kurt Jaeger
179eb7112b bin/dd: Fix incorrect casting of arguments
dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
and back again to detect whether or not the original arguments were
negative. This caused wrong behaviour in some boundary cases:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count cannot be negative

After the fix:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count: Result too large

PR:		191263
Submitted by:	will@worrbase.com
Approved by:	cognet@
2014-10-27 11:38:17 +00:00
Jilles Tjoelker
1bc2fdfabf sh: Make getopts memory-safe if with changing arguments.
POSIX does not permit to continuing a getopts loop with different
arguments. For parsing the positional parameters, we handle this case by
resetting the getopts state when the positional parameters are changed in
any way (and the getopts state is local to a function). However, in the
syntax getopts <optstring> <var> <arg...>, changes could lead to invalid
memory access.

In the syntax getopts <optstring> <var> <arg...>, store a copy of the
arguments and continue to use them until getopts is reset.
2014-10-26 17:50:33 +00:00
Jilles Tjoelker
0b4b9c8158 sh: Allow backslash-newline continuation in more places:
* directly after a $
 * directly after ${
 * between the characters of a multi-character operator token
 * within a parameter name
2014-10-19 11:59:15 +00:00
Jilles Tjoelker
334111e2df sh: Add some tests for backslash-newline continuation. 2014-10-17 21:52:57 +00:00
Jilles Tjoelker
3f9b4e9ab8 sh: Make parseredir() a proper function instead of an emulated nested
function.
2014-10-15 21:26:09 +00:00
Jilles Tjoelker
622fdf3236 sh: Remove more gotos. 2014-10-15 21:20:56 +00:00
Jilles Tjoelker
75e1716807 sh: Fix break/continue/return in multiline eval.
Example:
  eval $'return\necho bad'
2014-10-12 13:12:06 +00:00
Enji Cooper
6186fd1857 Integrate bin/sleep/tests from NetBSD into atf/kyua
Sponsored by: EMC / Isilon Storage Division
2014-10-09 01:39:07 +00:00
Jilles Tjoelker
33c5acf038 sh: Eliminate some gotos. 2014-10-05 21:51:36 +00:00
Jilles Tjoelker
068dfa2d43 sh: Fix LINENO and prompt after $'\0 and newline. 2014-10-03 20:24:56 +00:00
Enji Cooper
478290db20 Check in first src/tests snapshot from NetBSD anoncvs
Sources were obtained like so:

% export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
% cvs -z9 co -D "09/30/2014 20:45" -P src/tests
% mv src/tests/* tests/dist/.

'*CVS*' has been added to svn:ignore to ease updating periodically from
upstream

Some line ending issues had to be resolved with test outputs and scripts
via dos2unix and by deleting the eol-style property set in usr.bin/sort

Discussed with: rpaulo
Sponsored by: EMC / Isilon Storage Division
2014-10-01 04:07:17 +00:00
Craig Rodrigues
6677932e5d Fix pkill unit tests.
- use daemon(8) to write out a pid file for processes,
  and check for for the existence of that file after
  killing processes
- use explict named parameters to jail(8)
2014-09-30 15:27:49 +00:00
Jilles Tjoelker
000dda7b47 sh(1): Clarify that assignments before commands do not affect expansions.
PR:		193759
MFC after:	1 week
2014-09-21 20:34:54 +00:00
Will Andrews
76479f1d3f Fix incremental builds involving non-root users with read-only source files.
Makefiles should not assume that source files can be overwritten.  This is the
common case for Perforce source trees.

This is a followup commit to r211243 in the same vein.

MFC after:	1 month
Sponsored by:	Spectra Logic
MFSpectraBSD:	r1036319 on 2014/01/29, r1046711 on 2014/03/06
2014-09-18 14:41:57 +00:00
Jilles Tjoelker
72238faa6a sh: Remove arbitrary length limit on << EOF markers.
This also simplifies the code.
2014-09-14 16:46:30 +00:00
Jilles Tjoelker
671a890e58 sh: Make checkend() a real function instead of an emulated nested function.
No functional change is intended, but the generated code is slightly
different.
2014-09-14 16:27:49 +00:00
Jilles Tjoelker
5545fadd84 sh: Add some const keywords. 2014-09-14 15:59:15 +00:00
Jilles Tjoelker
cd60e2c67d sh: Allow enabling job control without a tty in non-interactive mode.
If no tty is available, 'set -m' is still useful to put jobs in their own
process groups.
2014-09-04 21:48:33 +00:00
Warner Losh
a83c9ec1e5 Update the date for last example.
Sponsored by: Netflix
2014-08-30 02:12:58 +00:00
Warner Losh
56fd128433 Add canonical population of a disk / thumb drive from an image
example.
2014-08-28 21:30:39 +00:00
Mateusz Guzik
8b04bbef31 Return real parent pid in kinfo (used by e.g. ps)
Add a separate field which exports tracer pid and add a new keyword
("tracer") for ps to display it.

This is a follow up to r270444.

Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
2014-08-28 08:41:11 +00:00
Pedro F. Giffuni
0fa46a4231 Always check the limits of array index variables before using them.
Obtained from:	DragonFlyBSD
MFC after:	1 week
2014-08-21 02:40:33 +00:00
Jilles Tjoelker
dd6d480a3e sh: Remove two redundant (uintmax_t) casts.
Submitted by:	jmallett
2014-08-20 20:15:43 +00:00
Bryan Drewery
5608fd23c2 Revert r267233 for now. PIE support needs to be reworked.
1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
   build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
   where it never would work anyhow, such as csu or loader. This suggests
   there may be better ways of adding support to the tree. Many of these
   cases can be fixed such that -fPIE will work but there is really no
   reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
   really building libraries but have been using bsd.prog.mk because the code
   is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
   been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by:	kib
2014-08-19 15:04:32 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Jilles Tjoelker
ef9e61785a sh: Avoid overflow in atoi() when parsing HISTSIZE.
Side effect: a non-numeric HISTSIZE now results in the default size (100)
instead of 0.
2014-08-17 19:36:56 +00:00
Jilles Tjoelker
d53f7f64f7 sh: Reject integer overflow in number and is_number. 2014-08-17 16:40:29 +00:00
Jilles Tjoelker
1c9c6ea481 sh: Don't hardcode relative paths in the tests stderr files.
These paths have had to be adjusted to changes in the testsuite runner
several times, so modify the tests to remove the need for such adjustment.

A cp in functional_test.sh is now unneeded, but this matters little in
performance.
2014-08-17 14:26:12 +00:00
Jilles Tjoelker
d5b14891eb sh: Mask off shift distance (<< and >>) in arithmetic.
In C, shift distances equal to or larger than the number of bits in the
operand result in undefined behaviour. As part of eliminating undefined
behaviour in arithmetic, mask off the distance like Java and JavaScript
specify and C on x86 usually does.

Assumption: conversion from unsigned to signed retains the two's complement
bits.
Assumption: uintmax_t has no padding bits.
2014-08-15 22:36:41 +00:00
Alan Somers
da02ed7331 Skip pgrep-j and pkill-j if jail or jls is not installed.
Even though jail is part of the base system, it can be disabled by src.conf
settings. Therefore, it should be listed as a required program for tests
that use it.

CR:		D603
MFC after:	3 days
Sponsored by:	Spectra Logic
2014-08-14 14:59:40 +00:00
Enji Cooper
9f31240773 Port date/bin/tests to ATF
Phabric: D545
Approved by: jmmv (mentor)
Submitted by: keramida (earlier version)
MFC after: 2 weeks
Sponsored by: Google, Inc
Sponsored by: EMC / Isilon Storage Division
2014-08-13 04:43:29 +00:00
Enji Cooper
12e2df3c36 Convert bin/sh/tests to ATF
The new code uses a "test discovery mechanism" to determine
what tests are available for execution

The test shell can be specified via:

  kyua test -v test_suites.FreeBSD.bin.sh.test_shell=/path/to/test/sh

Sponsored by: EMC / Isilon Storage Division
Approved by: jmmv (mentor)
Reviewed by: jilles (maintainer)
2014-08-13 04:14:50 +00:00
Konstantin Belousov
d735998057 Correct the problems with the ptrace(2) making the debuggee an orphan.
One problem is inferior(9) looping due to the process tree becoming a
graph instead of tree if the parent is traced by child. Another issue
is due to the use of p_oppid to restore the original parent/child
relationship, because real parent could already exited and its pid
reused (noted by mjg).

Add the function proc_realparent(9), which calculates the parent for
given process. It uses the flag P_TREE_FIRST_ORPHAN to detect the head
element of the p_orphan list and than stepping back to its container
to find the parent process. If the parent has already exited, the
init(8) is returned.

Move the P_ORPHAN and the new helper flag from the p_flag* to new
p_treeflag field of struct proc, which is protected by proctree lock
instead of proc lock, since the orphans relationship is managed under
the proctree_lock already.

The remaining uses of p_oppid in ptrace(PT_DETACH) and process
reapping are replaced by proc_realparent(9).

Phabric:	D417
Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-08-07 05:47:53 +00:00
Jilles Tjoelker
4d34663be3 sh: Allow arbitrarily large numbers in break and continue.
The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
2014-07-20 20:29:09 +00:00
Jilles Tjoelker
e61ae4ffc8 sh: Remove prefix() function. Use strncmp() instead. 2014-07-20 12:06:52 +00:00
Jilles Tjoelker
2ef146f14c sh: Deduplicate some code in ulimit builtin. 2014-07-19 14:06:23 +00:00
Brooks Davis
80189b3b09 Replace all uses of libncurses and libtermcap with their wide character
variants.  This allows usable file system images (i.e. those with both a
shell and an editor) to be created with only one copy of the curses library.

Exp-run:	antoine
PR:		189842
Discussed with:	bapt
Sponsored by:	DARPA, AFRL
2014-07-17 18:24:34 +00:00
Jilles Tjoelker
7b9104c0a9 sh: Correctly handle positional parameters beyond INT_MAX on 64-bit systems.
Currently, there can be no more than INT_MAX positional parameters. Make
sure to treat all higher ones as unset to avoid incorrect results and
crashes.

On 64-bit systems, our atoi() takes the low 32 bits of the strtol() and
sign-extends them.

On 32-bit systems, the call to atoi() returned INT_MAX for too high values
and there is not enough address space for so many positional parameters, so
there was no issue.
2014-07-12 21:54:11 +00:00
Jilles Tjoelker
5ddabb8348 sh: Consistently treat ${01} like $1.
Leading zeroes were ignored when checking whether a positional parameter is
set, but not when expanding its value. Ignore leading zeroes in any case.
2014-07-12 10:27:30 +00:00
Jilles Tjoelker
f1058ba09a sh: Add test for ${01} and ${010} that already works.
Although it is probably unwise to use this, POSIX is clear that leading
zeroes are permitted in positional parameters (and do not indicate octal).

Such positional parameters are checked for being unset and/or null
correctly, but their value is incorrectly expanded.
2014-07-08 22:04:44 +00:00
Jilles Tjoelker
725d072732 Don't install locale1.0 if MK_NLS == no.
The test locale1.0 depends on locale support; it is meaningless without a
working LC_MESSAGES.

I added an OptionalObsoleteFiles.inc entry.

PR:		181151
Submitted by:	Garrett Cooper (original version)
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2014-07-08 21:50:13 +00:00
Warner Losh
413a368c90 rm -rf can fail sometimes with an error from fts_read. Make it honor
fflag to ignore fts_read errors, but stop deleting from that directory
because no further progress can be made.

When building a kernel with a high -j value on a high core count
machine, during the cleanobj phase we can wind up doing multiple rm
-rf at the same time for modules that have subdirectories. This
exposed this race (sometimes) as fts_read can return an error if the
directory is removed by another rm -rf. Since the intent of the -f
flag was to ignore errors, even if this was a bug in fts_read, we
should ignore the error like we've been instructed to do.
2014-07-07 23:21:20 +00:00
Jilles Tjoelker
2d70c63720 sh: Fix overflow checking on 'ulimit' operand. 2014-07-05 21:50:59 +00:00
Xin LI
c15455feb3 Check if fchflags() is needed by fstat'ing before and check
the results.

Reviewed by:	jilles
X-MFC-With:	r267977
2014-07-01 22:46:39 +00:00
Xin LI
e6683f19dd Always set UF_ARCHIVE on target (because they are by definition new files
and should be archived) and ignore error when we can't set it (e.g. NFS).

Reviewed by:	ken
MFC after:	2 weeks
2014-06-27 19:57:54 +00:00
Baptiste Daroussin
bd0891ceb3 use .Mt to mark up email addresses consistently (part1)
PR:		191174
Submitted by:	Franco Fichtner  <franco@lastsummer.de>
2014-06-20 09:40:43 +00:00
Joel Dahl
cf20d40493 mdoc: remove superfluous paragraph macros. 2014-06-15 10:43:12 +00:00
Bryan Drewery
864c53ead8 In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.
This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by:		Shawn Webb <lattera@gmail.com>
Discussed between:	des@ and Shawn Webb [2]
2014-06-08 17:29:31 +00:00
Sergey Kandaurov
38d22923f7 Add support for inspecting process flags set in p_flag2.
Reviewed by:	jhb
MFC after:	1 week
2014-06-06 22:52:11 +00:00
Warner Losh
04efeffe99 When building picobsd, define WITHOUT_OPENSSL and WITHOUT_KERBEROS and
remove the now-redundant checks for RELEASE_CRUNCH. This originally
was defined for building smaller sysinstall images, but was later also
used by picobsd builds for a similar purpose. Now that we've moved
away from sysinstall, picobsd is the only remaining consumer of this
interface. Adding these two options reduces the RELEASE_CRUNCH
special cases in the tree by half.
2014-06-06 04:09:07 +00:00
Jilles Tjoelker
b0762e4921 sh: Avoid undefined behaviour shifting negative values left in arithmetic.
With i386 base clang, arith_yacc.o remains unchanged.
2014-06-01 11:25:34 +00:00
Jilles Tjoelker
2ceda70233 sh: Simplify find_command() slightly. 2014-05-31 22:25:45 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Jilles Tjoelker
c8fb3e69d0 sh: In getopts, unset OPTARG where POSIX says we should. 2014-05-10 19:18:49 +00:00
Jilles Tjoelker
8207fd5f81 sh: Add new tests to the Makefile. 2014-05-10 19:06:36 +00:00
Jilles Tjoelker
6e76445cf7 sh: Don't discard getopts state on unknown option or missing argument.
When getopts finds an invalid option or a missing option-argument, it should
not reset its state and should set OPTIND as normal. This is an old ash bug
that was fixed long ago in dash. Our behaviour now matches most other
shells.
2014-05-10 17:42:21 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Jilles Tjoelker
8c4e5fc061 sh: Send getopts error messages to stderr, not stdout.
Adjust a testcase for this change.
2014-05-09 13:32:36 +00:00
Jilles Tjoelker
bc7f6652dd sh: Add more necessary INTOFF/INTON. 2014-05-09 13:27:30 +00:00