Commit Graph

12536 Commits

Author SHA1 Message Date
Allan Jude
76723b39ca Capsicumize bspatch
Move all of the fopen() and open() calls to the top of main()

Restrict each FD to least privilege (read/seek only, write only, etc)

cap_enter(), and make all except the output FD read/seek only.

Reviewed by:	emaste, ed, oshogbo, delphij
Approved by:	so
MFC after:	3 days
Relnotes:	yes
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D7358
2016-08-25 15:08:33 +00:00
Navdeep Parhar
97b84d344d Make the iSCSI parameter negotiation more flexible.
Decouple the send and receive limits on the amount of data in a single
iSCSI PDU.  MaxRecvDataSegmentLength is declarative, not negotiated, and
is direction-specific so there is no reason for both ends to limit
themselves to the same min(initiator, target) value in both directions.

Allow iSCSI drivers to report their send, receive, first burst, and max
burst limits explicitly instead of using hardcoded values or trying to
derive all of them from the receive limit (which was the only limit
reported by the drivers prior to this change).

Display the send and receive limits separately in the userspace iSCSI
utilities.

Reviewed by:	jpaetzel@ (earlier version), trasz@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7279
2016-08-25 05:22:53 +00:00
Enji Cooper
bb323b9e7b Add support for _PC_ACL_NFS4 as TRUSTEDBSD_ACL_NFS4
The TRUSTEDBSD prefix was chosen for consistency with the other
related `_PC_ACL*` prefixed variables.

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-08-23 19:41:49 +00:00
Enji Cooper
de7b37e618 Add MIN_HOLE_SIZE pathconf(2) support to getconf
This allows shell programs to programmatically determine whether
or not a filesystem supports sparse files

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-08-23 19:28:01 +00:00
Enji Cooper
11b0c200fb Clean up trailing whitespace
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-08-23 19:15:01 +00:00
Ed Maste
ce437beff1 bspatch: apply style(9)
Make style changes (and trivial refactoring of open calls) now in order
to reduce noise in diffs for future capsicum changes.

Reviewed by:	oshogbo
No objection:	cperciva
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7610
2016-08-23 17:42:03 +00:00
Pedro F. Giffuni
bf140447ba indent(1): have the memset invocation somewhat more canonical.
While correct, the previous invocation was somewhat more error prone.

Pointed out by:	delphij, bde
2016-08-23 15:49:31 +00:00
Pedro F. Giffuni
38359266c5 indent(1): remove dead assignments.
Taken from:	Piotr Sephaniak
2016-08-23 15:46:20 +00:00
Pedro F. Giffuni
8e7c1235ce indent(1): Fix off-by-one in control flow leading dead code.
Coverity correctly reported that it's impossible for /comparison/ to be 0
here, because the only way for the for loop to end is by /comparison/
being < 0.

Fortunately the consequences of this bug weren't severe; for duplicated
entries in the typedef names file it would unnecessarily duplicate strings
with strdup(), but pointers to those would replace existing ones. So this
was a memory leak at worst.

CID:	 1361477
Obtained from:	 Piotr Stephaniak
2016-08-23 02:07:08 +00:00
Pedro F. Giffuni
16c2e36059 indent(1): add some comments to quiet down Coverity.
Hopefully adding comments should help explain the code to both static
checkers and humans.

CID:	976543, 976544, 976545
Obtained from:	Piotr Stephaniak
2016-08-23 01:58:02 +00:00
Pedro F. Giffuni
f3c23ec321 indent(1): Fix memory leaks pointed out by clang-analyzer.
Shift the responsibility of allocating memory for the string duplicate
from the caller (set_option, add_typedefs_from_file) to the callee
(add_typename) as it has more knowledge about when the duplication
actually needs to occur.

Taken from:	Piotr Stefaniak
2016-08-23 01:40:45 +00:00
Ed Schouten
a5c3c5b14f Import the new automatically generated system call table for CloudABI.
Now that we've switched over to using the vDSO on CloudABI, it becomes a
lot easier for us to phase out old features. System call numbering is no
longer something that's part of the ABI. It's fully based on names. As
long as the numbering used by the kernel and the vDSO is consistent
(which it always is), it's all right.

Let's put this to the test by removing a system call (thread_tcb_set())
that's already unused for quite some time now, but was only left intact
to serve as a placeholder. Sync in the new system call table that uses
alphabetic sorting of system calls.

Obtained from:	https://github.com/NuxiNL/cloudabi
2016-08-19 17:49:35 +00:00
Andrey A. Chernov
4e78ecd2c9 Fix TAB replaced with spaces in prev. commit. 2016-08-18 10:18:11 +00:00
Michael Tuexen
5ad497eead Fix the output for scope statistics.
MFC after: 3 days
2016-08-17 16:56:20 +00:00
Michael Tuexen
e0694d2f0a Use names for SCTP and UDPLite when reporting the input histogram.
MFC after: 3 days
2016-08-17 14:44:47 +00:00
Marcelo Araujo
4b61b26b28 Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-08-16 15:53:05 +00:00
Marcelo Araujo
4c59a8860a Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-08-16 15:52:10 +00:00
Sofian Brabez
80a2905883 tty: Use proper definition of exit status code and stdin macro
Reviewed by:	bapt, bdrewery
Differential Revision:	https://reviews.freebsd.org/D6828
2016-08-16 14:15:09 +00:00
Rick Macklem
684d18c9ae Fix r304026 so that it builds for gcc.
Reported by:	np
Tested by:	np
MFC after:	1 month
2016-08-16 00:48:13 +00:00
Mark Johnston
da974ed4ab nfsstat depends on libdevstat as of r304058.
X-MFC-With:	r304058
2016-08-14 00:24:00 +00:00
Greg Lehey
7430368a0e Correct date ov VJ day (1945-08-15, about 03:00 UTC). 2016-08-13 23:35:20 +00:00
Rick Macklem
50f3f9f909 Update the man page to descibe the "-d" option added by r304058.
This is a content change.

Submitted by:	will (earlier version)
Reviewed by:	ken, wblock
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D1626
2016-08-13 20:21:32 +00:00
Rick Macklem
693957f886 Update nfsstat.c to use the new kernel nfsstat structure and
add the new "-d" flag from D1626.
The man page will be updated in a subsequent commit.

Submitted by:	will (earlier version)
Reviewed by:	ken
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D1626
2016-08-13 20:14:44 +00:00
Konstantin Belousov
6bdee22607 Remove unused prototypes.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-08-12 07:52:13 +00:00
John Baldwin
c357102c5b Remove files unused after pulling system call names from libsysdecode. 2016-08-11 05:18:09 +00:00
Bryan Drewery
cca89ee385 Fix sorting in r303934.
Reported by:	jhb
X-MFC-With:	r303934
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 21:59:59 +00:00
Bryan Drewery
6178f8e8a6 Use proper argument length for rmdir(2) for r303934.
Reported by:	kib
X-MFC-With:	r303934
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:45:26 +00:00
Bryan Drewery
c870956d72 Support rmdir(2).
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:19:17 +00:00
Bryan Drewery
c8a8570cdb Squelch a false-positive Clang static analyzer warning.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:19:14 +00:00
Bryan Drewery
4a4768d948 Fix -b failure not restoring flags on the destination file.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:19:11 +00:00
Bryan Drewery
89ad63ad2d Fix -S with -l not being atomic.
It was unlinking the target even though it uses rename(2) which already
effectively does that.  -S is intended to not unlink(2) the target first.

MFC after:	1 week
Reviewed by:	jhb
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D7452
2016-08-10 18:19:08 +00:00
Bryan Drewery
49cfff9131 Support -v for -l.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:19:05 +00:00
Bryan Drewery
b81ddc83c9 Fix -S with -b not atomically updating the destination file.
With both of these flags, the backup was created via rename(dest, backup)
followed by rename(tmp, dest).  This left the destination file missing
for a moment which contradicts the point of -S.

This fixes a race with installworld where PRECIOUSPROG and PRECIOUSLIB
files (which use -S for installation) would briefly be missing.  In the
case of installing rtld with parallel installworld it could render an
error due to not having rtld present to run install/cp in another
process.

Reported by:	jhb
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D7451
2016-08-10 18:19:02 +00:00
Bryan Drewery
e9a4487309 Trim out excessive / with -v when target directory ends with a trailing '/'.
This is a minor nit after r289391 made all installations to a directory always
end in a trailing '/'.

MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:18:51 +00:00
Enji Cooper
bfa4e93d35 Remove vestigal references to __alpha__
Replace alpha reference in getconf(1) with amd64 [*]

MFC after:	1 week
PR:	 	211300 [*]
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk> [*]
Sponsored by:	EMC / Isilon Storage Division
2016-08-08 07:19:30 +00:00
Enji Cooper
06fd1dab30 Fix building usr.bin/tar/tests with PIE symbol building enabled by
removing CFLAGS+= -static

`CFLAGS+= -static` was a carryover from pre-r289195 with
usr.bin/tar/test/Makefile that should have been specified in LDFLAGS
There doesn't seem to be an apparent need for static compilation
of the test binaries.

Differential Revision:	https://reviews.freebsd.org/D7430
MFC after:	1 week
Obtained-from:	opBSD (418a491eed20d2603ddd1f1bd92c2c0d95094002)
Submitted by:	op
Sponsored by:	EMC / Isilon Storage Division
2016-08-06 19:05:01 +00:00
Baptiste Daroussin
9dc3843e67 sdiff: remove non finish/function code
2 extra options not available neither on other BSD nor in GNU sdiff:
--diff-pid and --pipe-fd were present in the SoC code, none were usable

Just remove it
2016-08-05 19:14:55 +00:00
Pedro F. Giffuni
a6bcfda487 indent(1): Use bsearch() for looking up type keywords.
Reference:
f3b8e6e57f

Submitted by:	Piotr Stefaniak
Differential Revision: https://reviews.freebsd.org/D6966
2016-08-04 15:27:09 +00:00
Pedro F. Giffuni
771aff0aa5 indent(1): add new -sac and -U options.
Add -sac (space after cast) and -nsac options.
These control whether space character is put after a cast operator or not.
Default is -nsac.

Add -U option for providing a file containing list of types.
This is needed for properly deciding which asterisks denote unary
operation and which denote binary.

These come from PostgreSQL.

Reference:
84b00e3d46
49c52cf383

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-08-03 22:08:07 +00:00
Pedro F. Giffuni
b4939677e8 indent(1): accept offsetof(3) as a keyword.
Reference:
c470e5e2c9

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-08-03 16:33:34 +00:00
Baptiste Daroussin
0f21f5285b truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall
trussinfo->curthread must be initialized before calling enter_syscall(),
it is used by t->proc->abi->fetch_args().
Without that truss is segfaulting and the attached program also crash.

Submitted by:	Nikita Kozlov (nikita@gandi.net)
Reviewed by:	jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D7399
2016-08-02 22:47:06 +00:00
Dimitry Andric
00f060000f Fix a segfault in bsdgrep when parsing the invalid extended regexps "?"
or "+" (these are invalid, because there is no preceding operand).

When bsdgrep attempts to emulate GNU grep in discarding and ignoring the
invalid ? or + operators, some later logic in tre_compile_fast() goes
beyond the end of the buffer, leading to a crash.

Fix this by bailing out, and reporting a bad pattern instead.

Reported by:	Steve Kargl
MFC after:	1 week
2016-08-02 20:25:22 +00:00
Pedro F. Giffuni
249a8a8003 sed(1): Revert r303047 "cleanup" and therefore r303572.
While big, the change was meant to have no effect on behavior and instead
so far we have found two regressions: one in the etcupdate tests and
another one in the games/openttd port[1].

Revert to a known working state. We will likely have to split the patch in
functional parts before bringing back the changes.

PR:		195929
Reported by:	danfe, madpilot [1]
2016-08-02 15:35:53 +00:00
Pedro F. Giffuni
707e8dae2d indent: Avoid using values of pointers that refer to deallocated space.
For now maintain the local style in this file.

Reviewed by:	jilles

Reference:
9099a9f17b

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-08-01 19:24:01 +00:00
Pedro F. Giffuni
70a3049ea5 indent(1): Use a dash in the license headers.
Use of the canonical dash avoids indent(1) from reformatting the
license headers.
2016-08-01 16:40:42 +00:00
Pedro F. Giffuni
e725fe4b06 indent(1): Rearrange option parsing code to squelch clang's static analyzer.
clang-analyzer complained that eqin() sets file-scoped pointer param_start
to point into char buffer defined in scan_profile(), and once
scan_profile() exits, param_start is a "dangling reference". param_start
was never used afterwards, but it's cleaner to move it to set_option()
which is the only branch where param_start is needed.

Reference:
ab0e44e5da

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-07-31 21:43:43 +00:00
Pedro F. Giffuni
efc12d78f7 indent(1): replace function call to bzero with memset.
Reference:
7422f42f80

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-07-31 21:36:40 +00:00
Pedro F. Giffuni
f7adee2314 indent(1): Don't newline on cpp lines like #endif unless -bacc is on.
Reference:
01f36f4141

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-07-31 21:29:10 +00:00
Pedro F. Giffuni
69e66b43bc indent(1): Untangle the connection between pr_comment.c and io.c.
It's pr_comment.c that should decide whether to put a "star comment
continuation" or not. This duplicates code a bit, but it simplifies
pr_comment() at the same time since pr_comment() no longer has to "signal"
whether a star continuation is needed or not.

This change requires indent(1) to not wrap comment lines that lack a blank
character, but I think it's for the better if you look at cases when that
happens (mostly long URIs and file system paths, which arguably shouldn't
be wrapped).

It also fixes two bugs:

1. Cases where asterisk is a part of the comment's content (like in "*we*
are the champions") and happens to appear at the beginning of the line,
misleading dump_line() into thinking that this is part of the star comment
continuation, leading to misalignment.

2. Cases where blank starred lines had three too many characters on the
line when wrapped.

Reference:
3b41ee78aa

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-07-31 21:09:22 +00:00
Pedro F. Giffuni
8ad92a65e4 indent(1): Fix wrapping of some lines in comments.
After a blank line was printed (to separate paragraphs in comments), the
next line was sometimes wrapped to the column at which the previous
non-empty line ended. The fix is to reset the last blank pointer (last_bl)
on newline.

References:
345663c07a

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Submitted by:	Piotr Stefaniak
2016-07-31 20:13:00 +00:00