Commit Graph

3298 Commits

Author SHA1 Message Date
Andrey A. Chernov
2aa6b16f74 Implement multibyte encoding support for -v with fallback
MFC after:      7 days
2016-09-15 17:24:39 +00:00
Enji Cooper
637cce3a32 MFhead @ r305314 2016-09-03 00:50:18 +00:00
Jilles Tjoelker
681e94f4d0 sh: Add some tests for non-standard features of the echo builtin.
MFC after:	1 week
2016-09-02 21:13:46 +00:00
Enji Cooper
f8fd1a95d9 MFhead @ r305170 2016-09-01 02:57:15 +00:00
Conrad Meyer
246ef54f15 df(1): Allow duplicate -l flags gracefully
Rather than producing a misleading error message when duplicate -l flags are
provided to df(1), simply ignore extra flags and proceed as if only one was
specified.  This seems most reasonable given the usage for -l:

     -l      Only display information about locally-mounted file systems.

l and t flags still conflict, as before.

PR:		208169
Reported by:	by at reorigin.com
Reviewed by:	allanjude
2016-08-31 18:10:41 +00:00
Enji Cooper
ed04e0c3dc MFhead @ r304815 2016-08-25 20:02:51 +00:00
Alex Kozlov
c650c2f355 Remove last remnants of acd(4), mcd(4), and scd(4) drivers.
Approved by:	jhb
2016-08-25 19:36:58 +00:00
Julio Merino
647672e21f Skip ls tests that use sparse files if these are not supported.
Some of the ls(1) tests create really large sparse files to validate
the number formatting features of ls(1).  Unfortunately, those tests fail
if the underlying test file system does not support sparse files, as is the
case when /tmp is mounted on tmpfs.

Before running these tests, check if the test file system supports sparse
files by using getconf(1) and skip them if not.  Note that the support for
this query was just added to getconf(1) in r304694.

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D7609
2016-08-24 10:10:26 +00:00
Enji Cooper
569e901835 MFhead @ r304038 2016-08-13 06:16:38 +00:00
Enji Cooper
fbc71595f0 Hack around output differences between FreeBSD and other BSDs
with cat(1)

cat -be on FreeBSD doesn't align the $ with the start of the line
like NetBSD, et al's cat -be does

PR:		210607
Sponsored by:	EMC / Isilon Storage Division
2016-08-13 02:53:02 +00:00
John Baldwin
563e703714 Remove description of P_FOLLOWFORK as this flag was removed. 2016-08-12 16:13:50 +00:00
Warren Block
15919690b5 Correct the history of where ps first appeared.
PR:		211741
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
MFC after:	1 week
2016-08-12 14:10:11 +00:00
Enji Cooper
640235e2c2 Checkpoint initial integration work
- Some of the lib/libc and lib/thr tests fail
- lib/msun/exp_test:exp2_values now passes with clang 3.8.0

The Makefiles in contrib/netbsd-tests were pruned as they have no value

Sponsored by: EMC / Isilon Storage Division
2016-08-12 08:50:05 +00:00
Enji Cooper
014db25b98 Update ^/vendor/NetBSD/tests/dist to a more recent snapshot
Pulled on "Thu Aug 11 18:01:19 PDT 2016"
2016-08-12 01:05:07 +00:00
Mariusz Zaborski
e628189fd8 uuid_to_string(3) is allocating memory and can fail on that.
Check if any error accrued.
2016-08-03 18:04:08 +00:00
Jilles Tjoelker
3bb6ada261 sh: Fix a clang warning.
Submitted by:	bdrewery
2016-07-31 13:11:34 +00:00
Konstantin Belousov
b7a25e63b6 When a debugger attaches to the process, SIGSTOP is sent to the
target.  Due to a way issignal() selects the next signal to deliver
and report, if the simultaneous or already pending another signal
exists, that signal might be reported by the next waitpid(2) call.
This causes minor annoyance for debuggers, which must be prepared to
take any signal as the first event, then filter SIGSTOP later.

More importantly, for tools like gcore(1), which attach and then
detach without processing events, SIGSTOP might leak to be delivered
after PT_DETACH.  This results in the process being unintentionally
stopped after detach, which is fatal for automatic tools.

The solution is to force SIGSTOP to be the first signal reported after
the attach.  Attach code is modified to set P2_PTRACE_FSTP to indicate
that the attaching ritual was not yet finished, and issignal() prefers
SIGSTOP in that condition.  Also, the thread which handles
P2_PTRACE_FSTP is made to guarantee to own p_xthread during the first
waitpid(2).  All that ensures that SIGSTOP is consumed first.

Additionally, if P2_PTRACE_FSTP is still set on detach, which means
that waitpid(2) was not called at all, SIGSTOP is removed from the
queue, ensuring that the process is resumed on detach.

In issignal(), when acting on STOPing signals, remove the signal from
queue before suspending.  Otherwise parallel attach could result in
ptracestop() acting on that STOP as if it was the STOP signal from the
attach.  Then SIGSTOP from attach leaks again.

As a minor refactoring, some bits of the common attach code is moved
to new helper proc_set_traced().

Reported by:	markj
Reviewed by:	jhb, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D7256
2016-07-28 08:41:13 +00:00
Konstantin Belousov
81fc45fc23 Addm missed required call to xo_finish() when only header is printed.
Reported by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-07-23 06:30:00 +00:00
Andrey A. Chernov
143d321a30 Path generation was not according to collate
Approved by:    jilles
2016-07-16 13:26:18 +00:00
Andrey A. Chernov
fa93fc659f Back out non-collating [a-z] ranges.
Instead of changing the whole course to another POSIX-permitted way
for consistency and uniformity I decide to completely ignore missing
regex fucntionality and focus on fixing bugs in what we have now,
too many small obstacles we have choicing other way, counting ports.
Corresponding libc changes are backed out in r302824.
2016-07-14 09:34:42 +00:00
Andrey A. Chernov
3ea37deb6c After removing collation for [a-z] ranges in r302512, do it here too.
Approved by:    jilles
2016-07-13 08:13:09 +00:00
Conrad Meyer
b156d221c9 dd(1): Enable access to SIZE_T_MAX character devices
On machines where SIZE_T_MAX exceeds OFF_MAX (signed 64-bit), permit seeking
character devices to negative off_t values.  This enables dd(1) to interact
with kernel KVA in /dev/kmem on amd64, for example.

Sponsored by:	EMC / Isilon Storage Division
2016-07-09 17:11:54 +00:00
Bryan Drewery
45e1479f95 WITH_META_MODE: Fix bin/csh rebuilding tc.const.h
This is the same issue as r297997, but was missed in it.

The WARNS value changes between 'build-tools' (MK_WARNS=no) and
'everything' resulting in a rebuild of this file.

Approved by:	re (implicit)
Sponsored by:	EMC / Isilon Storage Division
2016-06-14 16:19:49 +00:00
Don Lewis
4af86fb4f9 Explicitly NUL terminate the buffer filled by fread().
The fix in r300649 was not sufficient to convince Coverity that the
buffer was NUL terminated, even with the buffer pre-zeroed.  Swap
the size and nmemb arguments to fread() so that a valid lenght is
returned, which we can use to terminate the string in the buffer
at the correct location.  This should also quiet the complaint about
the return value of fread() not being checked.

Reported by:	Coverity
CID:		1019054, 1009614
MFC after:	1 week
2016-06-08 05:32:39 +00:00
Jilles Tjoelker
535c8d9372 sh: Improve descriptions in 'ulimit -a' output.
The format limits descriptions to 18 characters and is not changed, so
the descriptions do not describe the limits exactly.
2016-06-05 16:09:31 +00:00
Bryan Drewery
92edc96667 WITH_META_MODE: Don't expect meta files for side-effect generated files.
The first file in these lists will generate everything else so only
it should be getting a .meta file.  With bmake's missing=yes meta
feature these would otherwise cause a rebuild without the
.NOMETA hint.

Sponsored by:	EMC / Isilon Storage Division
2016-06-03 19:25:41 +00:00
Conrad Meyer
45ed675344 ps(1): Expand variables to match expanded fields
ki_flag and ki_tdflag have been 'long', not 'int', since 2000 and 2005,
respectively.

Submitted by:	Shawn Wills <swills at isilon dot com>
Sponsored by:	EMC / Isilon Storage Division
2016-06-01 19:54:05 +00:00
Don Lewis
eaf2e1e6f7 The (i < PROMPTLEN - 1) test added by r300442 in the code for the default
case of \c in the prompt format string is a no-op.  We already passed
this test at the top of the loop, and i has not yet been incremented in
this path.  Change this test to (i < PROMPTLEN - 2).

Reported by:	Coverity
CID:		1008328
Reviewed by:	cem
MFC after:	1 week
2016-06-01 16:56:29 +00:00
Warren Block
2770ce607c Clarify the explanations for the hostname and FQDN entries.
MFC after:	1 week
2016-05-31 00:23:29 +00:00
Enji Cooper
482537c7a2 Use require.progs with bc instead of require.files with /usr/bin/bc
This will make things more flexible if the program path changes in the future,
and the test in and of itself doesn't call /usr/bin/bc -- it just calls bc

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-29 04:50:49 +00:00
Don Lewis
92a58a9246 Close the input FILE * in read_file() and the output FILE * in write_file()
if read_stream() or write_stream() fails to avoid leaking the FILE.

Reported by:	Coverity
CID:		977702
Reviewed by:	pfg
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6554
2016-05-25 18:38:30 +00:00
Don Lewis
b1b73fc4c9 Fix Coverity CID 1019054 (String not null terminated) in setfacl.
Increase the size of buf[] by one to allow room for a NUL character
at the end.

Reported by:	Coverity
CID:		1019054
MFC after:	1 week
2016-05-25 05:20:34 +00:00
Don Lewis
5912ca59b0 Fix CID 1011370 (Resource leak) in ps.
There is no need to to call strdup() on the value returned by fmt().
The latter calls fmt_argv() which always returns a dynamically
allocated string, and calling strdup() on that leaks the memory
allocated by fmt_argv().  Wave some const magic on ki_args and
ki_env to make the direct assignment happy.  This requires a tweak
to the asprintf() case to avoid a const vs. non-const mismatch.

Reported by:	Coverity
CID:		1011370
MFC after:	1 week
2016-05-25 05:12:56 +00:00
Don Lewis
8dd8cd00e2 Close from_fd if malloc() fails to avoid a file descriptor leak.
Reported by:	Coverity
CID:		1007203
MFC after:	1 week
2016-05-25 02:51:15 +00:00
Don Lewis
ae100660d4 Match the descriptions of the \H and \h prompt string sequences to reality.
They were swapped.

X-Confirmed by:	jilles
MFC after:	1 week
2016-05-25 02:10:30 +00:00
Don Lewis
63a4675d89 Hopefully fix Coverity CID 1008328 (Out-of-bounds write) in /bin/sh.
Replace the magic constant 127 in the loop interation count with
"PROMPTLEN - 1".

gethostname() is not guaranteed to NUL terminate the destination
string if it is too short. Decrease the length passed to gethostname()
by one, and add a NUL at the end of the buffer to make sure the
following loop to find the end of the name properly terminates.

The default: case is the likely cause of Coverity CID 1008328.  If
i is 126 at the top of the loop interation where the default case
is triggered, i will be incremented to 127 by the default case,
then incremented to 128 at the top of the loop before being compared
to 127 (PROMPTLENT - 1) and terminating the loop. Then the NUL
termination code after the loop will write to ps[128].  Fix by
checking for overflow before incrementing the index and storing the
second character in the buffer.

These fixes are not guaranteed to satisfy Coverity. The code that
increments i in the 'h'/'H' and 'w'/'W' cases may be beyond its
capability to analyze, but the code appears to be safe.

Reported by:	Coverity
CID:		1008328
Reviewed by:	jilles, cem
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6482
2016-05-23 01:01:23 +00:00
Pedro F. Giffuni
0745a9c965 ed(1): simplify by using arc4random_buf().
Suggested by:	ed
2016-05-21 00:45:42 +00:00
Pedro F. Giffuni
d972b6d256 ed(1): Cleanups for the DES mode.
- Use arc4random_uniform(3).
- Prevent a segmentation fault when ed receives a signal
  while being in getpass(). [1]

Obtained from:	OpenBSD [1] (CVS Rev. 1.15)
MFC after:	2 weeks
2016-05-20 19:10:29 +00:00
Baptiste Daroussin
a651f2bc6c Rename getline with get_line to avoid collision with getline(3)
When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard

Obtained from:	NetBSD
2016-05-10 11:11:23 +00:00
Bryan Drewery
29df9f6b75 DIRDEPS_BUILD: Run the staged bootstrap-tools version of build-tools.
This avoids running target binaries.

Sponsored by:	EMC / Isilon Storage Division
2016-05-09 22:21:09 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Eric van Gyzen
8e3543eebc sh: Handle empty hostname and $PWD when building prompt
If the hostname is empty and \h is used in $PS1,
the remainder of the prompt following \h will be empty.
Likewise for $PWD and \w.  Fix it.

Reviewed by:	jilles
MFC after:	1 week
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D6188
2016-05-04 02:06:46 +00:00
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