Commit Graph

12717 Commits

Author SHA1 Message Date
Hiroki Sato
8f14a1af12 Fix gcc build.
Spotted by:	lidl
2016-12-24 22:51:02 +00:00
Hiroki Sato
39bb7275fb mdoc fixes. 2016-12-23 04:38:27 +00:00
Hiroki Sato
a04667ab17 - Add -S option to specify the source address/port for UDP communication.
- Document -S option.
- Document that -h option supports AF_LOCAL.
- Split preparation of UDP sockets in logmessage() into socksetup().
2016-12-22 23:39:11 +00:00
Simon J. Gerraty
45447996a0 Merge bmake-20161212 2016-12-19 23:38:07 +00:00
Conrad Meyer
1ea1b27578 ident(1): Capsicumify
Preopen input file list before entering Capsicum capability mode.

Feedback by:	allanjude@, bapt@, emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7918
2016-12-16 02:09:48 +00:00
Conrad Meyer
280dd9fc2e iconv(1): Capsicumify
This takes the usual shortcut of only sandboxing the last input file.
It's a first cut and this program will be easy to adapt to sandbox all
files in the future.

iconv(1) has been changed to only open the conversion descriptor once,
since the input and output encodings are fixed over all inputs.
Instead, the descriptor is simply reset after each use (documented in
iconv(3) API).

Reviewed by:	no one, unfortunately
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7917
2016-12-16 02:06:34 +00:00
Conrad Meyer
327240c75f hexdump(1): First cut capsicumification
For now, only enter the sandbox for the last file processed (including
stdin for zero-argument mode).

Sandboxing all inputs will require a little restructuring of the
program.

Feedback by:	emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7915
2016-12-16 02:03:40 +00:00
Conrad Meyer
208a859459 ktrdump(8): Capsicumify
We restrict the (optional) input file and output files. It would be
nice to restrict the KVM files, but that's up to libkvm.

We wait until after kvm_nlist() is invoked to cap_enter() because
kldsym() isn't supported in the Capsicum sandbox.

Feedback from:	emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7921
2016-12-16 01:59:28 +00:00
Conrad Meyer
20502a13a0 ministat(1): Capsicumify
Separate dataset opening from reading/parsing. The number of input
files is already capped to a small number, so just open all input files
before sandboxing.

Feedback from:	allanjude@ (earlier version), emaste@ (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7925
2016-12-16 01:51:12 +00:00
Conrad Meyer
941e22d17d Capsicumify last(1)
Reviewed by:	ed (earlier version), emaste (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8001
2016-12-16 01:47:08 +00:00
Eric van Gyzen
3d32d4a7c9 Export the whole thread name in kinfo_proc
kinfo_proc::ki_tdname is three characters shorter than
thread::td_name.  Add a ki_moretdname field for these three
extra characters.  Add the new field to kinfo_proc32, as well.
Update all in-tree consumers to read the new field and assemble
the full name, except for lldb's HostThreadFreeBSD.cpp, which
I will handle separately.  Bump __FreeBSD_version.

Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D8722
2016-12-07 15:04:22 +00:00
Eric van Gyzen
b54d51ac86 locale: fix the powerpc build
Reported by:	markj (and bde, in a way)
MFC after:	3 days
X-MFC with:	r309364
Sponsored by:	Dell EMC
2016-12-06 15:42:18 +00:00
John Baldwin
1175b23f77 Rework syscall structure lookups.
Avoid always using an O(n^2) loop over known syscall structures with
strcmp() on each system call.  Instead, use a per-ABI cache indexed by
the system call number. The first 1024 system calls (which should cover
all of the normal system calls in currently-supported ABIs) use a flat array
indexed by the system call number to find system call structure.  For other
system calls, a linked list of structures storing an integer to structure
mapping is stored in the ABI.  The linked list isn't very smart, but it
should only be used by buggy applications invoking unknown system calls.

This also fixes handling of unknown system calls which currently trigger
a NULL pointer dereference.

Reviewed by:	kib
MFC after:	2 weeks
2016-12-06 00:39:00 +00:00
Sevan Janiyan
0e922aa308 Fix error in the example section
Adjust formatting highlighted by igor.

PR:		214683
Submitted by:	Anindya Mukherjee <anindya49 AT hotmail DOT com>
Reviewed by:	jilles
Approved by:	bcr (mentor)
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D8591
2016-12-05 13:23:22 +00:00
Pedro F. Giffuni
bde60d7544 indent(1): remove unneeded comma.
It is not a good practice to start a newline with a comma anyways.

Discussed with:	 bjk
Differential Revision:	https://reviews.freebsd.org/D8690
2016-12-04 03:10:25 +00:00
Pedro F. Giffuni
86bd08e9ee Document undocumented indent(1) options badp/nbadp, bs/nbs, and lc.
Submitted by:	 Piotr Stefaniak
Differential Revision:	https://reviews.freebsd.org/D8690
2016-12-03 00:24:34 +00:00
Pedro F. Giffuni
488f148604 indent(1): Avoid out-of-bound accesses of array ps.p_stack.
Submitted by:	 Piotr Stefaniak
2016-12-02 16:42:45 +00:00
Pedro F. Giffuni
0bae80a336 indent(1): Avoid out-of-bound accesses of arrays.
ps.paren_indents:
When ps.paren_level was 0, this was accessing paren_indents[-1].

in_buffer:
This fragment checks if "*/" was read, but there's no guarantee that there
is more than one byte in the array (actually, this happens frequently for
the "{" in things like "int main(void) {").

Submitted by:	 Piotr Stefaniak
2016-12-02 16:41:08 +00:00
Pedro F. Giffuni
df54a266d3 indent(1): Remove an extra newline added in a previous commit.
It doesn't math the remaining of the case statement.
2016-12-02 16:32:14 +00:00
Pedro F. Giffuni
b30bb755da indent(1): Optimize parser stack usage.
When special else-if processing is enabled (-ei), we can assume "else if"
and "if" to be equivalent for indentation purposes.
This reduction saves a lot of stack space in case of a long "if-else-if
... else-if" sequence;  with this change,
Postgres/src/bin/psql/tab-complete.c as of 9.6beta3
requires minimum of the stack length to be 31 instead of 444.

Submitted by:	 Piotr Sephaniak
2016-12-02 16:28:18 +00:00
Pedro F. Giffuni
cba6bdf9bc indent(1): Do not define opchar unless it will be used.
"opchar" is only used once depending on "undef" macro being defined.
Conditionalize it in the same way.

Submitted by:	Piotr Sephaniak
2016-12-02 01:52:32 +00:00
Pedro F. Giffuni
f171328eaa indent(1): Fix indent's confusion about custom FreeBSD macros.
Teach indent(1) about storage-class specifiers. Don't assume
"in_parameter_declaration" state if "in_decl" hasn't been set. Don't set
"in_decl" for storage-class specifiers.

That set of changes helps with recognizing the difference between file
scope declarations like this:

static LIST_HEAD(, alq) ald_active;
static int ald_shuttingdown = 0;
struct thread *ald_thread;

and old style function declarators like this:

static int
do_execve(td, args, mac_p)
	struct thread *td;
	struct image_args *args;
	struct mac *mac_p;
{

Unfortunately, at the same time this change makes indent(1) require
explicit int in declarations like "static a;", in order to understand that
it's part of a declaration. On the other hand, declarations like in the
first example are no longer indented as if ald_shuttingdown and ald_thread
were parameters of a function named LIST_HEAD.

Submitted by:	 Piotr Stefaniak
2016-12-02 01:25:51 +00:00
Eric van Gyzen
b28fd8ce86 locale: enable more warnings; fix them
Do not set WARNS, so it gets the current default of 6.
Fix the warnings by sprinkling static, const, or strdup.
Make some constant data tables const.  Fix whitespace.

MFC after:	1 week
Sponsored by:	Dell EMC
2016-12-01 17:36:31 +00:00
Eric van Gyzen
71500aab3e locale: fix buffer management
Also, handle signed and unsigned chars, and more gracefully handle
invalid input.

Submitted by:	bde in response to r309331
MFC after:	1 week
Sponsored by:	Dell EMC
2016-12-01 16:54:02 +00:00
Pedro F. Giffuni
909f007fb8 indent(1): Don't unnecessarily add a blank before a comment ends.
pr_comment() did avoid adding surplus space character when a comment
contained it at the end. Now it's also paying attention to tabs.

Taken from:	 Piotr Stefaniak
2016-12-01 01:56:34 +00:00
Pedro F. Giffuni
67b7daecf7 indent(1): Don't ignore newlines after comments that follow braces.
indent.c has a special loop that stores tokens from between an if () and
the next statement into a buffer. The loop ignored all newlines, but that
resulted in not calling dump_line() when it was needed to produce the
final line of the buffered up comment.

Taken from:	 Piotr Stefaniak
2016-12-01 01:48:56 +00:00
Pedro F. Giffuni
458051a57b indent(1): Avoid out of bound access of array in_buffer
Work-around a somewhat complex interaction within the code. From
Piotr's commit [1]:

When pr_comment() calls dump_line() for the first line of a multiline
comment, it doesn't include any indentation - it starts with the "/*".
This is consistent for both boxed and not boxed comments. Where the logic
diverges is in how it treats the rest of the lines of the comment. For box
comments indent assumes that it must not change anything, so lines are
dumped as they were, including the indentation where it exists. For the
rest of comments, it will first remove the indentation to store plain text
of the comment and then add it again where indent thinks it's appropriate
-- this is part of comment re-indenting process.

For continuations of multi-line comments, the code that handles comments
in dump_line() will use pad_output() to create indentation from the
beginning of the line (what indent calls the first column) and then write
string pointed by s_com afterwards. But if it's a box comment, the string
will include original indentation, unless it's the first line of the
comment. This is why tab characters from s_com have to be considered when
calculating how much padding is needed and the "while (*com_st == '\t')
com_st++, target += 8;" does that.

In dump_line(), /target/ is initially set to ps.com_col, so it always
assumes that indentation needs to be produced in this function, regardless
of which line of a box comment it is. But for the first line of a box
comment it is not true, so pr_comment() signals it by setting
ps.n_comment_delta, the negative comment delta, to a negative number which
is then added to /target/ in dump_line() on all lines except the first
one, so that the function produces adequate indentation in this special
case.

The bug was in how that negative offset was calculated: pr_comment() used
count_spaces() on in_buffer, which pr_comment() expected to contain
non-null terminated sequence of characters, originating from whatever
originally was on the left side of the comment. Understanding that
count_spaces() requires a string, pr_comment() temporarily set buf_ptr[-2]
to 0 in hope that it would nul-terminate the right thing in in_buffer and
calling count_spaces() would be safe and do the expected thing. This was
false whenever buf_ptr would point into save_com, an entirely different
char array than in_buffer.

The short-term fix is to recognize whether buf_ptr points into in_buffer
or save_com.

Reference:
[1]
ea486a2aa3

Taken from:	 Piotr Stefaniak
2016-12-01 01:32:13 +00:00
Eric van Gyzen
dc521a5840 Include limits.h for CHAR_MAX
This was needed on stable/10.  Apparently, sys/param.h supplies CHAR_MAX
on head.  Include limits.h anyway, for consistency, and because C says so.

Sponsored by:	Dell EMC
2016-11-30 18:34:40 +00:00
Robert Watson
f534f01f1a Clarify warning message when failing to configure audit on user login:
when au_user_mask() fails, it's not a failure to set the audit mask,
but to calculate the audit mask -- and hence a condfiguration-file
issue (of some sort).

MFC after:	3 days
Sponsored by:	DARPA, AFRL
2016-11-30 14:02:36 +00:00
Dimitry Andric
8930262bce Fix packaging for clang, lldb and lld 3.9.0
During the upgrade of clang/llvm etc to 3.9.0 in r309124, the PACKAGE
directive in the usr.bin/clang/*.mk files got dropped accidentally.

Restore it, with a few minor changes and additions:
* Correct license in clang.ucl to NCSA
* Add PACKAGE=clang for clang and most of the "ll" tools
* Put lldb in its own package
* Put lld in its own package

Reviewed by:	gjb, jmallett
X-MFC-With:	309124
Differential Revision: https://reviews.freebsd.org/D8666
2016-11-28 20:13:56 +00:00
Xin LI
3611de44ef pages and psize are always assigned, so there is no need to initialize
them as zero.

MFC after:	2 weeks
2016-11-28 06:38:41 +00:00
Xin LI
c514c3ed4f Eliminate variables that are computed, assigned but never
used.

MFC after:	2 weeks
2016-11-28 06:36:10 +00:00
Xin LI
665d2db378 Fix an obvious typo.
MFC after:	2 weeks
2016-11-28 06:32:05 +00:00
Pedro F. Giffuni
350fcdd5df indent(1): Properly handle the wide string literal and wide char constant L.
indent(1) treated the "L" in "L'a'" as if it were an identifier and forced
a space character after it, breaking valid code.

PR:		143090
MFC after:	2 weeks
2016-11-27 20:38:14 +00:00
Pedro F. Giffuni
6daffe6ebf indent(1): fix regression introduced in r303596.
Multi-line comments are always block comments in KNF. Restore properly,
handling the case when a long one-liner gets wrapped and becomes a
multi-line comment.

Obtained from:	Piotr Stefaniak
2016-11-27 20:30:09 +00:00
Pedro F. Giffuni
743210efd6 indent(1): minor off-by-one error.
This was introduced in r303571.

Obtianed from:	Piotr Stefaniak
2016-11-27 20:11:55 +00:00
Rick Macklem
1616a51df4 Use November instead of the abbreviation.
Requested by:	Ed Shouten
MFC after:	2 weeks
2016-11-26 20:58:05 +00:00
Rick Macklem
332b7722bc Document the -E flag for nfsstat.
This is a content change.

Reviewed by:	bcr
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8626
2016-11-26 20:53:22 +00:00
Rick Macklem
0744a2b00e Add a -E flag to nfsstat.c so that it prints out the NFSv4.1
procedure/operation counts.
It also avoids clipping the counts at 9 digits.

Reviewed by:	bcr (doc parts)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8626
2016-11-26 20:47:11 +00:00
Raphael Kubo da Costa
be5d5a33e6 fdt: Expect strchr() to return a const char*
In C, strchr(3) returns a char*, whereas C++ defines two overloads:
* const char *strchr(const char*, int)
* char *strchr(char*, int)

Building fdt.cc (with the WITHOUT_GPL_DTC knob set) with libc++ 3.9.0 (imported
in r309124) was failing because libc++ r260377 added the first overload to
string.h, leading to failures such as:

    fdt.cc:1638:8: error: cannot initialize a variable of type 'char *' with an
    rvalue of type 'const char *'

Just define val as a const char* to fix it.

Upstreamed in https://github.com/davidchisnall/dtc/pull/14

Reviewed by:	emaste
Approved by:	emaste
2016-11-26 12:36:11 +00:00
Xin LI
104b0f4a1c style(9) indent changes, no actual code change.
MFC after:	2 weeks
2016-11-26 07:02:44 +00:00
Ed Maste
0aa5466e7d Add WITH_LLD_AS_LD build knob
If set it installs LLD as /usr/bin/ld.  LLD (as of version 3.9) is not
capable of linking the world and kernel, but can self-host and link many
substantial applications. GNU ld continues to be used for the world and
kernel build, regardless of how this knob is set.

It is on by default for arm64, and off for all other CPU architectures.

Sponsored by:	The FreeBSD Foundation
2016-11-25 13:15:28 +00:00
Ed Maste
28a116bab4 Correct lld llvm-tblgen dependency file name 2016-11-25 01:24:35 +00:00
Dimitry Andric
67bc8c8b9e Merge ^/head r308491 through r308841. 2016-11-19 16:05:55 +00:00
Eric van Gyzen
54068d184c locale: fix display of "grouping" and "mon_grouping" values
The "grouping" and "mon_grouping" values are arrays of one-byte
integers, not arrays of ASCII characters.  Display them in a format
similar to GNU and MacOS.

MFC after:	3 days
Sponsored by:	Dell EMC
2016-11-19 02:09:58 +00:00
Hajimu UMEMOTO
454d904a0e We need to lookup locale when command line arguments
are specified, as well.
MFC after:	1 week
2016-11-18 17:18:05 +00:00
Hajimu UMEMOTO
bfe9db5816 Lookup locale when print all keywords as well.
Reported by:	dumbbell
Reviewed by:	dumbbell
MFC after:	1 week
2016-11-18 16:48:37 +00:00
Bryan Drewery
9952941dd9 Cleanup some leftovers from '-s' removal in r302792.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-17 23:16:56 +00:00
Gleb Smirnoff
5dba303d01 Use bogus_page to properly reduce number of I/Os in sendfile(2). The new
sendfile_swapin() loop works this way:

- Find first invalid page in the request.
- Do vm_pager_has_page() and get count of pages, that can be taken in
  single I/O.
- Trim valid pages from the end of the request.
- Cycle through the request and substitute to bogus_page all valid
  pages that are in the middle of the request.
- After I/O launched (pager copies array of pages into buf(9), it
  is important to restore proper page pointers with help vm_page_lookup().

Count bogus pages used and report them in sendfile stats.
2016-11-17 21:02:55 +00:00
Tony Finch
3997df0cde More robust handling of whois referrals from RIRs.
An example problem case is 163.1.0.0 (University of Oxford)
which is in an APNIC ERX address range. Previously we assumed
that ARIN has the correct information for all ERX allocations,
but in this case ARIN refers back to APNIC, rather than referring
to RIPE. This caused whois to loop.

Whois will no longer loop back and forth forever between two RIRs
that don't have an answer, but instead try the other RIRs in turn.
2016-11-17 15:19:06 +00:00