Commit Graph

3633 Commits

Author SHA1 Message Date
Chris Rees
64e8790d7e Add a note that the use of -B option does not guarantee a size of fragment
if -z option also used.

Recommend the use of zip(1) if compressed files of predictable size needed.

PR:			docs/41089
Submitted by:		Sevan Janiyan
Reported by:		areilly@bigpond.net.au

While here, pet igor

Reviewed by:		bcr
Differential Revision:	https://reviews.freebsd.org/D18686
2018-12-29 23:08:59 +00:00
Edward Tomasz Napierala
20c9381c98 Make sh(1) collapse $HOME into "~" in PS1.
Reviewed by:	jilles
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18663
2018-12-28 17:51:40 +00:00
George V. Neville-Neil
53fc043d41 Remove, the now very outdated, timed.
Submitted by:	Kyle Spiers ksspiers at gmail
Reviewed by:	bcr,brooks,bz,sbruno
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D18505
2018-12-15 21:34:40 +00:00
Jilles Tjoelker
1becbc64f8 sh(1): Remove -c string from set builtin documentation
Altering the -c string at run time does not make sense and is not possible.

MFC after:	1 week
2018-12-08 12:49:19 +00:00
Sevan Janiyan
d7a570379b Clarify that /dev/kmem is not used.
Move cross ref to right place while here.

Submitted by:	kib
MFC after:	7 days
2018-12-03 20:01:51 +00:00
Sevan Janiyan
9588059256 Note these tools use kvm(3) and not procfs as in Solaris.
Obtained from:	NetBSD
MFC after:	7 days
2018-12-03 18:00:46 +00:00
Guangyuan Yang
e4c7371cef Clarify that patterns are extended regular expressions in pkill(1) manual page.
PR:		231060
Submitted by:	naddy
MFC after:	3 days
2018-12-01 05:58:33 +00:00
Maxim Sobolev
dead7b5e47 Replace hand-crafted naive byte-by-byte zero block detection routine
with macro based around memcmp(). The latter is expected to be some
8 times faster on a modern 64-bit architectures.

In practice, throughput of doing conv=sparse from /dev/zero to /dev/null
went up some 5-fold here from 1.9GB/sec to 9.7GB/sec with this change
(bs=128k).

MFC after:	2 weeks
2018-11-29 19:28:01 +00:00
Jilles Tjoelker
468ed39612 sh: Fix ${param?} default error message
If word in ${param?word} is missing, the shell shall write a default error
message. So expanding ${param?} when param is not set should write an error
message like

sh: param: parameter not set

This was broken by r316417.

PR:		233585
2018-11-28 20:03:53 +00:00
Jilles Tjoelker
77da4a95e8 sh: Use 126 and 127 exit status for failures opening a script
This affects scripts named on the command line, named with a '.' special
builtin and found via the PATH %func autoloading mechanism.

PR:		231986
2018-11-27 21:49:59 +00:00
Conrad Meyer
900c4ed3ca rm(1): Formalize non-functional status of -P flag
-P was introduced in 4.4BSD-Lite2 around 1994.  It overwrote file contents
with a pass of 0xff, 0x00, then 0xff, in a low effort attempt to "really
delete" files.

It has no user-visible effect; at the end of the day, the file is unlinked via
the filesystem.  Furthermore, the utility of overwriting files with patterned
data is extremely limited due to caveats at every layer of the stack[0] and
therefore mostly futile.  At the least, three passes is likely wasteful on
modern hardware[1].  It could also be seen as a violation of the "Unix
Philosophy" to do one thing per tiny, composable program.

Since 1994, FreeBSD has left it alone; OpenBSD replaced it with a single
pass of arc4random(3) output in 2012[2]; and NetBSD implemented partial, but
explicitly incomplete support for U.S. DoD 5220.22-M, "National Industrial
Security Program Operating Manual" in 2004[3].

NetBSD's enhanced comment above rm_overwrite makes a strong case for removing
the flag entirely:

> This is an expensive way to keep people from recovering files from your
> non-snapshotted FFS filesystems using fsdb(8).  Really.  No more.
>
> It is impossible to actually conform to the exact procedure given in
> [NISPOM] if one is overwriting a file, not an entire disk, because the
> procedure requires examination and comparison of the disk's defect lists.
> Any program that claims to securely erase *files* while conforming to the
> standard, then, is not correct.
>
> Furthermore, the presence of track caches, disk and controller write
> caches, and so forth make it extremely difficult to ensure that data have
> actually been written to the disk, particularly when one tries to repeatedly
> overwrite the same sectors in quick succession.  We call fsync(), but
> controllers with nonvolatile cache, as well as IDE disks that just plain lie
> about the stable storage of data, will defeat this.
>
> [NISPOM] requires physical media destruction, rather than any technique of
> the sort attempted here, for secret data.

As a first step towards evental removal, make it a placebo.  It's not like
it was serving any security function.  It is not defined in or mentioned by
POSIX.

If you are security conscious and need to erase your files, use a
woodchipper.  At a minimum, the entire disk needs to be overwritten, not
just one file.

[0]: https://www.ru.nl/publish/pages/909282/draft-paper.pdf
[1]: https://commons.erau.edu/cgi/viewcontent.cgi?article=1131&context=jdfsl
[2]: https://github.com/openbsd/src/commit/7c5c57ba81b5fe8ff2d4899ff643af18c
[3]: https://github.com/NetBSD/src/commit/fdf0a7a25e59af958fca1e2159921562cd

Reviewed by:	markj, Daniel O'Connor <darius AT dons.net.au> (previous version)
Differential Revision:	https://reviews.freebsd.org/D17906
2018-11-10 20:26:55 +00:00
Jilles Tjoelker
bb324af62a sh: Unify EXERROR and EXEXEC
The difference between EXERROR and EXEXEC was that EXEXEC passed along
exitstatus and EXERROR set exitstatus to 2 in the handling code.

By changing the places that raised EXERROR to set exitstatus to 2, the
handling of EXERROR and EXEXEC becomes the same.
2018-11-09 14:58:24 +00:00
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Conrad Meyer
d83db3fb6a Drop ed(1) "crypto"
You should not be using DES.  You should not have been using DES for the
past 30 years.

The ed DES-CBC scheme lacked several desirable properties of a sealed
document system, even ignoring DES itself.  In particular, it did not
provide the "integrity" cryptographic property (detection of tampering), and
it treated ASCII passwords as 64-bit keys (instead of using a KDF like
scrypt or PBKDF2).

Some general approaches ed(1) users might consider to replace the removed
DES mode:

1. Full disk encryption with something like AES-XTS.  This is easy to
conceptualize, design, and implement, and it provides confidentiality for
data at rest.  Like CBC, it lacks tampering protection.  Examples include
GELI, LUKS, FileVault2.

2. Encrypted overlay ("stackable") filesystems (EncFS, PEFS?, CryptoFS,
others).

3. Native encryption at the filesystem layer.  Ext4/F2FS, ZFS, APFS, and
NTFS all have some flavor of this.

4. Storing your files unencrypted.  It's not like DES was doing you much
good.

If you have DES-CBC scrambled files produced by ed(1) prior to this change,
you may decrypt them with:

  openssl des-cbc -d -iv 0 -K <key in hex> -in <inputfile> -out <plaintext>

Reviewed by:	allanjude, bapt, emaste
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D17829
2018-11-04 17:56:16 +00:00
Mark Johnston
49618eacb2 Avoid copying a struct stat for acl_from_stat() calls.
CID:		1375584
MFC after:	2 weeks
2018-11-01 17:45:29 +00:00
Mateusz Piotrowski
f11e51a920 ps(1): Pet mandoc and igor
- Use Xr to reference other manual pages.
- Reference execve(2) instead of exec(2) as exec(2) does not exist.
- Remove the deprecated "Tn" macro.
- Improve the formatting of the etime description.

Reviewed by:	bcr
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D17780
2018-10-31 17:47:08 +00:00
Mateusz Piotrowski
c97c08de8a ps(1): Add a standard exit status section
Reviewed by:	bcr, eadler
Approved by:	krion (mentor)
MFC after:      3 days
Differential Revision:	https://reviews.freebsd.org/D17146
2018-10-31 16:10:04 +00:00
Jilles Tjoelker
b5532964e7 sh: Use exitstatus instead of exerrno to pass EXEXEC status
No functional change is intended.
2018-10-27 20:17:57 +00:00
Mark Johnston
15e594351a Don't set NFSv4 ACL inheritance flags on non-directories.
They only make sense in the context of directory ACLs, and attempting
to set them on regular files results in errors, causing a recursive
setfacl invocation to abort.

This is derived from patches by Shawn Webb <shawn.webb@hardenedbsd.org>
and Mitchell Horne <mhorne063@gmail.com>.

PR:		155163
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D15061
2018-10-26 21:17:06 +00:00
Mark Johnston
10cb5344fd Don't print pathconf() errors if the target file doesn't exist.
The subsequent acl_get_file(3) call will simply echo the same error.

PR:		229930
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-26 19:01:52 +00:00
Mark Johnston
f024dd3bf0 Avoid leaking memory in error paths.
CID:		1390906
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-26 18:56:58 +00:00
Conrad Meyer
93806cf9e5 stty.1: Document kern.tty_info_kstacks behavior (r339471)
Reported by:	bdrewery
Reviewed by:	bdrewery
Sponsored by:	Dell EMC Isilon
2018-10-20 18:53:32 +00:00
Kyle Evans
ac5d5b054f dd(1): Correct padding in status=progress
Output padding is specified via outlen, which is set using the return value
of fprintf. Because it's printing that padding plus a trailing byte, it
grows by one each iteration rather than reflecting actual length.

Additionally, iec was sized improperly for scaling up similarly to si.
Fixing this revealed that the humanize_number(3) call to populate persec
was using the wrong width.

Submitted by:	Thomas Hurst <tom@hur.st>
Reviewed by:	imp
Approved by:	re (kib)
Differential Revision:	https://reviews.freebsd.org/D16960
2018-09-13 14:54:46 +00:00
Ed Maste
19b4f0dca0 Fix unlink(1) for files starting with -
Restore the original behavior of unlink(1), passing the provided filename
directly to unlink(2), handling the first argument being "--" correctly.

This fixes "unlink -foo", broken in r97533.

PR:		228448
Submitted by:	Brennan Vincent <brennan@umanwizard.com> (original version)
Submitted by:	Yuri Pankov
Reported by:	Brennan Vincent <brennan@umanwizard.com>
Reviewed by:	emaste, kevans, vangyzen, 0mp
Approved by:	re (delphij)
Differential Revision: https://reviews.freebsd.org/D17132
2018-09-12 19:41:16 +00:00
Jilles Tjoelker
4269bba2eb sh: Fix formal overflow in pointer arithmetic
The intention is to lower the value of the pointer, which according to ubsan
cannot be done by adding an unsigned quantity.

Reported by:	kevans
Approved by:	re (kib)
MFC after:	1 week
2018-09-05 19:16:09 +00:00
Brad Davis
94ec7ec758 Finish moving dot.cshrc and dot.profile to bin/csh/ and bin/sh/.
Approved by:	re (gjb), will (mentor)
Differential Revision:	https://reviews.freebsd.org/D16770
2018-08-29 16:59:19 +00:00
Brad Davis
b4d1ec6c69 Fix the install of /root/.login missed as part of r337849.
Approved by:	re (rgrimes)
2018-08-28 22:51:45 +00:00
Kyle Evans
517d0a9043 ls(1): Gate the do_color_* definitions behind COLORLS
Pointy hat to:	me
2018-08-18 21:03:19 +00:00
Kyle Evans
041e6eb1c5 ls(1): Support other aliases for --color arguments used by GNU ls(1)
These aliases are supported and documented in the man page. For now, they
will not be mentioned in the error when an invalid argument is encountered,
instead keeping that list to the shorter 'preferred' names of each argument.

Reported by:	rgrimes
2018-08-18 20:55:20 +00:00
Kyle Evans
e10ba80063 ls(1): Add --color=when
--color may be set to one of: 'auto', 'always', and 'never'.

'auto' is the default behavior- output colors only if -G or COLORTERM are
set, and only if stdout is a tty.

'always' is a new behavior- output colors always. termcap(5) will be
consulted unless TERM is unset or not a recognized terminal, in which case
ls(1) will fall back to explicitly outputting ANSI escape sequences.

'never' to turn off any environment variable and -G usage.

Reviewed by:	cem, 0mp (both modulo last-minute manpage changes
Differential Revision:	https://reviews.freebsd.org/D16741
2018-08-17 04:15:51 +00:00
Kyle Evans
7db2f1fe08 ls(1): Fix color env var checking
CLICOLOR will behavior as always- if present at all in the environment,
allow colors.

COLORTERM, recently enforced, will have to be both present and not empty.

Submitted by:	imp
2018-08-16 01:27:16 +00:00
Brad Davis
3349f8bb8f Revert parts of r337849 and r337857
This fixes the build and I will redo these changes as part of a future review
that organizes them differently.  The way I tried to do it here could be done
better.  Sorry for the noise.

Approved by:	will (mentor)
Differential Revision:	https://reviews.freebsd.org/D16737
2018-08-15 23:18:34 +00:00
Kyle Evans
eceaf4e3c6 dd(1): Kill off duplicate progress definition following r337865
Reported by:	mmacy
2018-08-15 20:50:38 +00:00
Kyle Evans
8acbb227d9 dd: Incorporate some changes from imp for status=progress
Notable changes from what landed in r337505:
- sigalarm handler isn't setup unless we're actually using it
- Humanized versions of the amount of data transferred in the progress
  update

Submitted by:	imp
Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16642
2018-08-15 19:46:13 +00:00
Brad Davis
1da0bddb6d Fix build after r337849
This moves the symlink creation to after where the files are installed.

This also inverts the shell change so that it only happens if MK_TCSH is on.

Approved by:	will (mentor)
Differential Revision:	https://reviews.freebsd.org/D16725
2018-08-15 16:22:12 +00:00
Brad Davis
b26c7f7fee Move all sh and csh files into bin/sh/ or bin/csh/
This simplifies pkgbase by migrating these to CONFS so they are properly
tagged as config files.

Approved by:	will (mentor)
Differential Revision:	https://reviews.freebsd.org/D16708
2018-08-15 14:41:24 +00:00
Kyle Evans
33ce7acbb0 ls(1): Enable colors with COLORTERM is set in the environment
COLORTERM is the de facto standard, while CLICOLOR is generally specific to
FreeBSD and ls(1).

PR:		230101
Submitted by:	D Green <dfrg@xsmail.com> (with manpage additions by myself)
Reviewed by:	cem ("LGTM" in PR; pre-manpage changes)
MFC after:	1 week
2018-08-08 21:51:19 +00:00
Kyle Evans
4767c42c11 dd: add status=progress support
This reports the current status on a single line every second, mirroring
similar functionality in GNU dd, and carefully interacts with SIGINFO.

PR:		229615
Submitted by:	Thomas Hurst <tom@hur.st> (modified for style(9) nits by me)
MFC after:	1 week
2018-08-08 21:37:02 +00:00
Conrad Meyer
2c77ec5419 date(1): Add ISO 8601 formatting option
The new flag is named '-I'.  It is documented in the manual page and covered
by basic unit tests.
2018-08-04 21:54:30 +00:00
Mateusz Piotrowski
17e98da88e Describe how to prevent *.core files from being created using ulimit.
While here, pet mandoc.

Reviewed by:	eadler (previous revision), jilles (previous revision), mat (mentor)
Approved by:	manpages (jilles), mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D15609
2018-07-19 13:09:29 +00:00
Jilles Tjoelker
4600b569bb sh: Don't treat % specially in CDPATH 2018-07-15 21:55:17 +00:00
Jilles Tjoelker
7d6f6a3532 sh: Don't use padvance() for MAIL/MAILPATH
Using padvance() requires undoing its append of '/' and prevents adjusting
its '%' logic to allow most directories with '%' in PATH.

No functional change is intended.
2018-07-15 09:14:30 +00:00
Bryan Drewery
d717a1d4bc Stop building intermediate .o files.
These are not used to link the final tool anymore.  At some point in the past
the suffix rules changed to not link these in.  The original reason for this in
r19176 is unclear but seems to be related to mkdep.  The .depend handling is
still broken here as it is for all build tool patterns like this.

Sponsored by:	Dell EMC
2018-06-27 21:36:49 +00:00
Bryan Drewery
96a0acc4ce Don't use CCACHE for linking.
MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-06-27 19:29:15 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Eitan Adler
377da67109 pwd: mark usage as dead 2018-06-17 05:14:50 +00:00
Eitan Adler
c6a5ff7153 ps(1): fix some nits
- fracmem and mempages are double. ki_rssize should be too
- remove default case that is fully covered by all existing cases
- mark usage as dead
2018-06-13 00:45:35 +00:00
Edward Tomasz Napierala
bc0d110222 Add an example to the chflags(1) man page.
MFC after:	2 weeks
2018-06-12 16:44:13 +00:00
Conrad Meyer
3181398b92 Update other man pages to match leap second reality
Missed these in r334501; see justification there:

https://svnweb.freebsd.org/base?view=revision&revision=334501

Sponsored by:	Dell EMC Isilon
2018-06-01 22:37:59 +00:00
Jilles Tjoelker
dc0dbd74c4 sh: Split CNL syntax category to avoid a check on state[level].syntax
No functional change is intended.
2018-05-21 21:52:48 +00:00
Jilles Tjoelker
29988d0ef0 sh: Allow unquoted newlines in word in ${param+word} etc.
POSIX requires accepting unquoted newlines in word in parameter expansions
like ${param+word}, ${param#word}, although the Bourne shell did not support
it, it is not commonly used and might make it harder to find a missing
closing brace.

It was also strange that something like

foo="${bar#
}"

was rejected.

Reported by:	Martijn Dekker via Robert Elz
2018-05-20 17:25:52 +00:00
Jilles Tjoelker
0c6c134f79 sh: Test that backslash-newline within single-quotes is not special
This works correctly, but the test may be helpful when modifying the parser.
2018-05-11 21:56:01 +00:00
Jilles Tjoelker
4d7f36eea5 sh: Don't have [ match any [[:class:]]
Submitted by:	Robert Elz
MFC after:	3 days
2018-04-29 17:46:08 +00:00
Ed Maste
b79f74cc64 setfacl: style and break main() into manageable pieces
Submitted by:	Mitchell Horne
MFC with:	r332396
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D15060
2018-04-27 15:25:24 +00:00
Conrad Meyer
41bd31e656 expr(1): Fix overflow detection when operand is INTMAX_MIN
PR:		227329
Submitted by:	Tobias Stoeckmann <tobias AT stoeckmann.org>
2018-04-14 04:35:10 +00:00
Ed Maste
21c5f7dec5 setfacl: minor man page edit to appease igor(1) 2018-04-11 13:33:12 +00:00
Ed Maste
0629b15276 setfacl: add recursive functionality
Add a -R option to setfacl to operate recursively on directories, along
with the accompanying flags -H, -L, and -P (whose behaviour mimics
chmod).

A patch was submitted with PR 155163, but this is a new implementation
based on comments raised in the Phabricator review for that patch
(review D9096).

PR:		155163
Submitted by:	Mitchell Horne <mhorne063@gmail.com>
Reviewed by:	jilles
MFC after:	2 weeks
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14934
2018-04-10 23:29:57 +00:00
John Baldwin
2f5a9b7661 Add a "jail" keyword to list the name of a jail rather than its ID.
Inspired by:	mwlucas
Reviewed by:	jamie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14683
2018-03-13 18:30:26 +00:00
Mike Karels
30417f2cd4 Change ps(1) output width to unlimited if not interactive
Apply patch submitted with PR 217159 to make ps use unlimited
width when not associated with a terminal (i.e., none of stdout, stdin,
or stderr is a tty). Update comments and man page correspondingly.
This change was requested to work around lack of -ww in scripts from
third-party packages, including Hadoop, and adds a small measure of
Linux compatibility. Hopefully few if any non-interactive scripts
depend on the old default of 79.

PR:		217159
Submitted by:	n.deepak at gmail.com
Reviewed by:	vangyzen jhb
Differential Revision:	https://reviews.freebsd.org/D14614
2018-03-10 00:10:47 +00:00
Bryan Drewery
fdee29d7d5 chflags: Add SIGINFO support.
This is copied from chmod r311668.

MFC after:	2 weeks
2018-03-07 01:55:38 +00:00
Bryan Drewery
25d90d5c97 chflags: Add -x option to not traverse mount points.
MFC after:	2 weeks
2018-03-05 01:56:07 +00:00
Edward Tomasz Napierala
7a467312ef .Xr pstat(8), so that people have a chance to learn how to get a list
of terminal devices using "pstat -t".

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-03-02 14:16:19 +00:00
Mike Karels
b93bb974cc Revert r314685 in ps
Revert r314685, and add a comment describing the original
behavior and the intent.

Reviewed by:	dab@ vangyzen@ jhb@
Differential Revision:	https://reviews.freebsd.org/D14530
2018-02-28 00:17:08 +00:00
Mariusz Zaborski
2ad275d20f Capsicumize uuidgen. 2018-02-17 12:32:53 +00:00
Bryan Drewery
3cdd74bb3c Allow overriding VTABSIZE at compile-time.
Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D14339
2018-02-13 16:48:57 +00:00
Brooks Davis
e3e9432478 Add a deprecation warning when using the feature which mounts devices
to see how much space it on them.

Adjust MOUNT_CHAR_DEVS to allow the free space of already mounted
devices to be displayed and report an appropriate error if the
device isn't mounted.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D8801
2018-02-10 00:22:25 +00:00
Alex Richardson
fb1df20368 Don't hardcode /usr/bin as the path for mktemp in build tools
It won't work e.g. when crossbuilding from Ubuntu Linux as mktemp is in
/bin there.

Reviewed By:	bdrewery
Approved By:	jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D13937
2018-02-06 15:41:35 +00:00
Jilles Tjoelker
190bc94a67 sh: Refactor job status printing, preparing for -o pipefail and similar
No functional change is intended.
2018-02-02 22:53:58 +00:00
Pedro F. Giffuni
7aee7c6293 pax(1): Honour the restrict in sigaction().
Use a setup_sig() helper and make it fail when either of sigaction fails.

While there, do not leak fds for "." + minor cleanup.

Obtained from:	OpenBSD (through DragonFly git eca362d0f9bd086cc56d6b5bc4f03f09e040b9db)
2018-01-27 18:24:13 +00:00
Eitan Adler
44e0a832f2 dd(1): Use a local swapbytes() function.
swab(3) has restrict qualifiers for src and dst.
Avoid relying on undefined overlapping swab behavior.

Obtained From: OpenBSD
2018-01-26 03:30:05 +00:00
John Baldwin
faf5dd873e Remove some KSE references from ps(1).
- Simplify the description of -H to assume 1:1 threading.
- Drop 'process' from description of 'lwp' field and the corresponding
  XO field name.
- Do add an expansion of LWP in the description of 'lwp' and 'nlwps'.
- Add 'tid' as an alias for the 'lwp' field.

Reviewed by:	imp, kib (older version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14021
2018-01-23 22:48:06 +00:00
Warner Losh
dfb1d80f64 Fill in ut_id. While it's not relevant to the {OLD,NEW}_TIME entries,
we shouldn't leak stack garbage into the field.

Sponsored by: Netflix
2018-01-23 15:34:34 +00:00
Conrad Meyer
0fdf7fa846 Convert ls(1) to not use libxo(3)
libxo imposes a large burden on system utilities. In the case of ls, that
burden is difficult to justify -- any language that can interact with json
output can use readdir(3) and stat(2).

Logically, this reverts r291607, r285857, r285803, r285734, r285425,
r284494, r284489, r284252, and r284198.

Kyua tests continue to pass (libxo integration was entirely untested).

Reported by:	many
Reviewed by:	imp
Discussed with:	manu, bdrewery
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D13959
2018-01-17 22:47:34 +00:00
Xin LI
6d5343e38e stddef.h is not used by cat.c, remove the include. 2018-01-07 07:08:59 +00:00
Warner Losh
ca23e64eb4 Sanity check sysconf return value to ensure it's positive before we
use it. Use proper cast to convert long to size_t (instead of
blksize_t) to preclude sign extension issues.

CID: 1193754
2018-01-06 12:45:59 +00:00
Jilles Tjoelker
b0125116ca sh: Move various structs from jobs.h to jobs.c
These implementation details of jobs.c need not be exposed.
2018-01-01 22:31:52 +00:00
Eitan Adler
6b35d82c34 Fix a few speelling errors
- man pages
- bin/sh

Reviewed by:		jilles
2017-12-28 08:22:26 +00:00
Eitan Adler
dae3a64fb9 userland: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:01 +00:00
Jilles Tjoelker
c8a5f66527 sh: Don't leak wait* implementation details from jobs.c 2017-12-26 16:23:18 +00:00
Jilles Tjoelker
6986f58f53 sh(1): Markup and spelling fixes 2017-12-23 22:58:19 +00:00
Benjamin Kaduk
f3aff7c91b Fix mandoc -Tlint warnings in bin/
Many style-level issues are still reported.

Submitted by:	Yuri Pankov <yuripv@gmx.com>
Reviewed by:	jilles (previous revision)
Differential Revision:	https://reviews.freebsd.org/D13334
2017-12-07 01:57:27 +00:00
Edward Tomasz Napierala
536062099a Add "vmaddr" ps(1) keyword.
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-12-01 11:32:05 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Dag-Erling Smørgrav
6fd07539f0 Add a -r option to print the running kernel version.
MFC after:	1 week
2017-11-14 10:15:17 +00:00
Enji Cooper
6f74a1c952 Fix cosmetic nit when printing out "override $mode" and "$owner/$group ..."
The wrong index was being checked for == ' ' in the resulting stringified
mode from strmode(3) -- it should have been the 11th value, not the 10th.

MFC after:	3 days
PR:		76711
Submitted by:	Vasil Dimov <vd@datamax.bg>
2017-11-05 21:43:26 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery
3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Edward Tomasz Napierala
4363782bc3 Undocument "tdnam" (leaving it as an alias), and rename the column
to TDNAME.

Suggested by:	bde
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 13:53:41 +00:00
Edward Tomasz Napierala
42ee5c3342 Fix long name (used by libxo) for the "tdnam" ps(1) keyword.
Reported by:	pluknet
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 13:48:10 +00:00
Edward Tomasz Napierala
a8373a7c1f Document "tdnam" keyword to ps(1), and add "tdname" alias.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 10:24:06 +00:00
Edward Tomasz Napierala
d7026b9671 Fix kvm_getprocs(3) error reporting in ps(1).
Previously it just didn't work at all - kvm_getprocs(3) doesn't update
the &nentries when it returns NULL.  The end result was that ps(1) showed
garbage data instead of reporting kinfo_proc size mismatch.

Reviewed by:	cem
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D12414
2017-10-06 15:09:28 +00:00
Jeremie Le Hen
e415aa2846 Remove rcmds.
If they are still needed, you can find them in the net/bsdrcmds port.

This was proposed June, 20th and approved by various committers [1].
They have been marked as deprecated on CURRENT in r320644 [2] on July, 4th.
Both stable/11 and release/11.1 contain the deprecation notice (thanks to
allanjude@).

Note that ruptime(1)/rwho(1)/rwhod(8) were initially thought to be part of
rcmds but this was a mistake and those are therefore NOT removed.

[1] https://lists.freebsd.org/pipermail/freebsd-arch/2017-June/018239.html
[2] https://svnweb.freebsd.org/base?view=revision&revision=320644

Reviewed by:	bapt, brooks
Differential Revision:	https://reviews.freebsd.org/D12573
2017-10-06 08:43:14 +00:00
Alan Somers
931329f89b Fix Makefile entries from r323275
Reported by:		Vladimir Zakharov <zakharov.vv@gmail.com>
Reviewed by:		ngie
MFC after:		3 weeks
X-MFC-With:		323275
2017-09-29 23:47:23 +00:00
Sevan Janiyan
6d2e5f3ddf Ammend bin/cat/cat.c so the output is the same aside
from blank lines being numbered or unnumbered, depending on whether cat
was invoked with -ne or -be.

At present, when cat is invoked with -be, there is an aditional
difference that the '$' on blank lines is placed on the far left of the
output.

Discussed in bug 210607.

While here, revert the workaround from r304035 which skipped the unit test for
this issue previously.

PR:		210607
Submitted by:	myself
Reviewed by:	bdrewery
Obtained from:	NetBSD
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D12432
2017-09-21 14:14:49 +00:00
Alan Somers
014404db1a Add basic tests for chflags, mkdir, rcp, and rmdir
Add basic command line parsing test coverage for these utilities.  The tests
were automatically generated based on their man pages.  These tests can be
expanded by hand for more thorough coverage.  The aim is to generate very
basic amount of test coverage for all the utilities in the base system.

Submitted by:	shivansh
Reviewed by:	asomers, brooks
MFC after:	3 weeks
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D12036
2017-09-07 16:54:47 +00:00
Edward Tomasz Napierala
cde94a423f Hint that the "-o emul" option for ps(1) shows the ABI.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-07 10:56:50 +00:00
Edward Tomasz Napierala
6f47d67bfe Make ps(1) flag processes in capsicum(4) capability mode with "C".
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-06 16:34:42 +00:00
Edward Tomasz Napierala
e4d52dfd1b Reflect realtime and idle priorities in ps(1) state flags, same like
we do for the usual nice values.  It could be argued that they should
use another set of indicators, since the underlying mechanism is
different, but they match the description in the manual page, and so
I think it's ok to not overcomplicate things.

PR:		81757
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-06 16:18:06 +00:00
Alan Somers
5ad496a252 Pacify GCC on mips32 after r322893
Though technically correct, GCC complains about usingi a "%zd" format
specifier for a long.

Reported by:	cem
MFC after:	3 weeks
X-MFC-With:	322893
Sponsored by:	Spectra Logic
2017-08-25 18:51:10 +00:00
Alan Somers
77a798b30a dd(1): 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 is not correct, and causes problems with boundary cases, for example
when count is SSIZE_MAX-1.

PR:		191263
Submitted by:	will@worrbase.com
Reviewed by:	pi, asomers
MFC after:	3 weeks
2017-08-25 15:31:55 +00:00
Lawrence Stewart
cf182be5e2 Only emit the trailing new line added in r322613 when not operating in quiet
mode.

Reported by:	pho
MFC after:	1 week
X-MFC-with:	r322210
2017-08-24 08:20:23 +00:00
Lawrence Stewart
1e781c6f96 The r322210 change to pgrep's PID delimiting behaviour causes pgrep's default
output to not include a trailing new line, which is a potential POLA violation
for existing consumers. Change pgrep to always emit a trailing new line on
completion of its output, regardless of the delimeter in use (which technically
is also a potential POLA violation for existing consumers that rely on the
pre-r322210 buggy behaviour, but a line has to be drawn somewhere).

PR:	221534
Submitted by:	kdrakehp zoho com
Reported by:	kdrakehp zoho com
MFC after:	1 week
X-MFC-with:	r322210
2017-08-17 06:36:21 +00:00
Enji Cooper
188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Jilles Tjoelker
413bf7b083 sh: Add test for sh -c with missing command string.
This already works correctly.
2017-08-13 14:36:10 +00:00
Jilles Tjoelker
2cc32af06f sh: Add tests for sh -c that already pass.
PR:		220587
Submitted by:	Ryan Moeller
2017-08-12 19:17:48 +00:00
Ed Maste
4be62405c0 cat: fix build with -DNO_UDOM_SUPPORT
Sponsored by:	The FreeBSD Foundation
2017-08-09 18:23:46 +00:00
Kyle Evans
d0bc27e435 df(1): Add --si as an alias for -H
Reviewed by:	cem (earlier version), emaste
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D11749
2017-08-09 01:24:52 +00:00
Lawrence Stewart
27181846bb pgrep naively appends the delimiter to all PIDs including the last
e.g. "pgrep -d, getty" outputs "1399,1386,1309,1308,1307,1306,1305,1302,"
Ensure the list is correctly delimited by suppressing the emission of the
delimiter after the final PID.

Reviewed by:	imp, kib
MFC after:	1 week
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D8537
2017-08-08 00:31:10 +00:00
Enji Cooper
3783c851d7 Don't check result of chflags in f_flag_cleanup()
This will prevent false positives from occurring if the test is run on
ZFS since ZFS doesn't support fflags throbbing like UFS.

PR:	221189
MFC after:	4 days
MFC with:	r321949
2017-08-05 16:58:02 +00:00
Enji Cooper
86cc58dc96 MFhead@r321960 2017-08-02 22:28:12 +00:00
Enji Cooper
3e46b70f38 Always use first parameter passed to get_filesystem(..) instead of discarding it
and using `.` instead.

MFC after:	1 week
MFC with:	r321949
PR:	221189 [1], 221188 [2]
2017-08-02 21:20:49 +00:00
Enji Cooper
2d3e9c25f1 Add expected failures for ZFS
- :f_flag fails on ZFS because UF_IMMUTABLE isn't supported [1].
- :v_flag fails on ZFS because the mode for foo is [always] updated
  unnecessarily.

get_filesystem(..) (supporting function that was added to the test script)
is based on equivalent logic in usr.bin/extattr/tests/extattr_test.sh .

MFC after:	1 week
PR:	221189 [1], 221188 [2]
2017-08-02 21:18:54 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
46b37aa2c4 MFhead@r321912 2017-08-02 08:38:36 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Enji Cooper
8c09935728 Add HAS_TESTS to all Makefiles that use the SUBDIR.${MK_TESTS}+= tests idiom 2017-08-02 08:14:06 +00:00
Edward Tomasz Napierala
4162d13907 Use the "tree" word in ps(1) -d option description, to make it easier
to find.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-07-22 10:38:44 +00:00
Ed Maste
819129649d date: avoid crash on invalid time
localtime(3) returns NULL when passed an invalid time_t but date(1)
previously did not handle it. Exit with an error in that case.

PR:		220828
Reported by:	Vinícius Zavam
Reviewed by:	cem, kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11660
2017-07-20 15:28:48 +00:00
Jilles Tjoelker
93c3eab50c sh: Remove broken #ifdef NOHACK code (related to sh -c).
Apart from the fact that subtle syntactic changes make a poor compile-time
option, the NOHACK case has been obviously broken since it was added,
because it uses q uninitialized if (*p != '\0').

No functional change is intended.
2017-07-18 19:00:15 +00:00
Enji Cooper
8aea3ca0a7 Remove unnecessary make logic added in r319339
This makes the change cleaner and easier to backport to ^/stable/10.

MFC after:	now
2017-07-18 17:29:12 +00:00
Enji Cooper
01df7d10a5 Remove SUBDIR ordering/uniquifying in *bin/Makefile
After the addition of SUBDIR.yes, uniquifying/ordering the SUBDIRs doesn't
make a whole lot of sense, and it's in effect a half measure.

Ordering SUBDIR (after adding SUBDIR.yes to it) in bsd.subdir.mk is a
separate change that warrants more discussion/testing, because while
the SUBDIR_PARALLEL work largely fixed dependency ordering for SUBDIRs,
there might be downstream FreeBSD consumers that rely on the SUBDIR
ordering.

MFC after:	2 months
Reviewed by:	bdrewery
Differential Revision:	D11398
2017-07-06 04:15:30 +00:00
Allan Jude
1f3f7ac7ba Add deprecation notices for all rcmd tools
Submitted by:	bcr
Reviewed by:	emaste, bapt, jhl
MFC after:	immediate
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D11471
2017-07-04 15:44:30 +00:00
Pedro F. Giffuni
be9e8bfaea ed(1): Allow the omission of one address in (.,.) and (.;.) address ranges
With this patch, ",n" is an abbreviation for "1,n", ";n" abbreviates
".;n". The "n," and "n;" variants mean "n,n" and "n;n", respectively.
Also, piping to a shell command does not count as a save, so don't reset
the modified flag.

Obtained from:	OpenBSD (CVS Rev. 1.58, 1.59)
2017-07-03 15:54:44 +00:00
Jilles Tjoelker
6f49cd266b sh: Ignore error when cd writes the directory actually switched to.
If CDPATH is used non-trivially or the operand is "-", cd writes the
directory actually switched to. (We currently do this only in interactive
shells, but POSIX requires this in non-interactive shells as well.)

As mentioned in Austin group bug #1045, cd shall not return an error while
leaving the current directory changed. Therefore, ignore any write error.
2017-06-25 21:53:08 +00:00
Alan Somers
f01753c151 style fixes in bin/echo/tests
Submitted by:	shivansh
Reviewed by:	asomers
MFC after:	2 weeks
X-MFC-With:	319626
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11318
2017-06-23 15:02:49 +00:00
Enji Cooper
00bc472686 Don't expect :sF_flag to fail anymore
While here, also add a check to verify that the link target
is updated in the testcase

MFC after:	1 month
MFC with:	r320172
PR:		219943
Differential Revision:	D11167
Submitted by:	shivansh
Sponsored by:	Google (GSoC 2017)
2017-06-20 20:50:54 +00:00
Enji Cooper
63bd650f4b ln(1): fix -F behavior
When '-F' option is used, the target directory needs to be unlinked.
Currently, the modified target ("target/source") is being unlinked, and
since it doesn't yet exist, the original target isn't removed.
This is fixed by skipping the block where target is modified to
"target/source" when '-F' option is set.
Hence, a symbolic link (with the same name as of the original target) to
the source_file is produced.

Update the test for ln(1) to reflect fix for option '-F'

MFC after:	1 month
PR:		219943
Differential Revision:	D11167
Submitted by:	shivansh
Sponsored by:	Google (GSoC 2017)
2017-06-20 20:46:08 +00:00
Phil Shafer
dfde8e4b54 Use {T:Capacity} for header so html output looks tidy
Submitted by:	phil
Approved by:	sjg
2017-06-13 05:38:40 +00:00
Enji Cooper
0773ff183a Style fixes: clean up leading whitespace (8 single column spaces -> \t)
MFC after:	1 month
MFC with:	r319714, r319854, r319855, r319856
2017-06-12 16:53:42 +00:00
Enji Cooper
b01fe519c3 ln(1): wordsmith -F option description
MFC after:	1 month
2017-06-12 16:43:29 +00:00
Enji Cooper
ed66391a6e Add a testcase for ln -sF
The testcase fails today, so mark it with atf_expect_fail: in
particular, the target (B) isn't being unlinked and the documentation
doesn't suggest special handling for directories. Thus, there's either
a doc or an implementation bug in ln(1) that needs to be resolved.

MFC after:	1 month
MFC with:	r319714, r319854, r319855
PR:		219943
Reviewed by:	ngie
Submitted by:	shivansh
Differential Revision:	D11159 (part of a larger diff)
Sponsored by:	Google, Inc (GSoC 2017)
2017-06-12 16:38:37 +00:00
Enji Cooper
07b984360c Use readlink(1)/stat(1) to query symlinks instead of file(1)
file(1) can be compiled out of the system via MK_FILE == no, and the
output isn't guaranteed to be stable. It's better to use stat(1)/readlink(1)
instead to query symlink/file paths.

MFC after:	1 month
MFC with:	r319714, r319854
Reported by:	ngie
Submitted by:	shivansh
Differential Revision:	D11159 (part of a larger diff)
Sponsored by:	Google, Inc (GSoC 2017)
2017-06-12 16:31:32 +00:00
Alan Somers
e61b0afc1c bin/ln: Set umask appropriately before creating files for testing
These changes were missed in D11084

Submitted by:	shivansh
Reviewed by:	asomers
MFC after:	1 month
X-MFC-With:	319714
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11158
2017-06-12 14:54:59 +00:00
Jilles Tjoelker
55c2cd6f48 sh: Enable interrupts before executing EXIT trap and doing final flush. 2017-06-11 16:54:04 +00:00
Alan Somers
670f178299 Add tests for ln(1)
* Verify that when creating a hard link to a symbolic link, '-L' option
  creates a hard link to the target of the symbolic link
* Verify that when creating a hard link to a symbolic link, '-P' option
  creates a hard link to the symbolic link itself
* Verify that if the target file already exists, '-f' option unlinks it so
  that link may occur
* Verify that if the target file or directory is a symbolic link, '-shf'
  option prevents following the link
* Verify that if the target file or directory is a symbolic link, '-snf'
  option prevents following the link
* Verify that '-s' option creates a symbolic link
* Verify that '-w' option produces a warning if the source of a symbolic
  link does not currently exist

Submitted by:	shivansh
Reviewed by:	asomers, ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11084
2017-06-08 19:09:55 +00:00
Enji Cooper
245e210cc6 Add some basic tests for chmod(1)
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-07 05:33:56 +00:00
Enji Cooper
7c91b65f54 Add testcases for cat -b
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-06 21:50:00 +00:00
Jilles Tjoelker
79fb1e455e sh: Call fc -e editor with interrupts enabled.
Starting the fc -e editor can execute arbitrary script, and executing
arbitrary script with INTOFF in effect may cause unexpected results.

This change (together with other changes) serves mainly to allow asserting
that INTOFF is not in effect when starting the evaluation of a node.
2017-06-06 21:08:05 +00:00
Enji Cooper
9086e0e068 Add additional testcases for cat(1)
Verify the following additional cases:
- -s (in isolation, in addition to the -se testcase obtained via the
      NetBSD test).
- -vt

Submitted by:	shivansh
Reviewed by:	asomers (earlier diff), ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11020
2017-06-06 21:03:43 +00:00
Enji Cooper
2d15c3cb12 Add basic tests for echo(1)
Verify that echo(1) does not...
- ... print the trailing newline character with option '-n'.
- ... print the trailing newline character when '\c' is appended to
      the end of the string.

Submitted by:	shivansh
Reviewed by:	asomers, ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11036
2017-06-06 16:04:27 +00:00
Bryan Drewery
231ad771d9 Clarify -q is only for pgrep.
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-06-05 16:00:10 +00:00
Jilles Tjoelker
8d4cde8e6d sh: Make sure to process SIGINT if SETINTON re-enables processing.
If INTON re-enables interrupts, it processes any interrupt that occurred
while interrupts were disabled. Make SETINTON do the same.
2017-06-04 21:58:02 +00:00
Bryan Drewery
3ecb77f014 Allow defining nofork builtins from builtins.def and move always-safe ones there.
The generated code remains the same.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D11042
2017-06-04 21:02:48 +00:00
Jilles Tjoelker
eab4998278 sh: Fix INTOFF leak when a redirection on a compound command fails.
Reported by:	bdrewery
2017-06-04 20:52:55 +00:00
Alan Somers
07c19c27d3 Fix bin/dd/dd2_tests:seek_overflow on UFS and TMPFS
Split the postive and negative parts into separate test cases.  The positive
test case can only run on ZFS, because only ZFS supports files that large.

PR:		219757
Reported by:	ngie
MFC after:	18 days
X-MFC-with:	319339
2017-06-03 18:29:18 +00:00
Enji Cooper
141173eb9f Mark :seek_overflow as an expected failure
MFC after:	18 days
MFC with:	r319339
PR:		219757
Sponsored by:	Dell EMC Isilon
2017-06-03 17:59:10 +00:00
Enji Cooper
5f0aff893e Stylistic tweaks
Move opening braces of functions from the last column to column 0.

MFC after:	18 days
MFC with:	r319339
Sponsored by:	Dell EMC Isilon
2017-06-03 17:56:31 +00:00
Alan Somers
af2b6af393 Fix integer overflow detection in dd
dd(1) tried to detect whether the seek offset would overflow, but it failed
to account for the case where the provided argument was negative and the
file was a regular file (negative seeks are allowed for character devices).
I fixed it, and added a regression test.

Reported by:	Coverity
CID:		1368659
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-05-31 16:07:32 +00:00
Jilles Tjoelker
29717eb029 sh: Keep output buffer across builtins.
Allocating and deallocating repeatedly the 1024-byte buffer for stdout from
builtins costs CPU time for little or no benefit.

A simple loop containing builtins that write to a file descriptor, such as
  i=0; while [ "$i" -lt 1000000 ]; do printf .; i=$((i+1)); done >/dev/null
is over 10% faster in a simple benchmark on an amd64 virtual machine.
2017-05-18 22:10:04 +00:00