Commit Graph

16893 Commits

Author SHA1 Message Date
cy
5222bd5bcd Fix up grammar.
MFC after:	3 days
2017-01-01 10:37:10 +00:00
ngie
7617377ac5 Call snmp_pdu_free on req/resp with a consistent, correct pattern
- snmp_pdu_free should be called before snmp_pdu_create is called
  again
- snmp_pdu_free should be called on the resp to snmp_dialog when
  successful

Tested with the following bsnmp commands:

  % export SNMPUSER=bsnmp SNMPPASSWD=bsnmptest
  % SNMP_ARGS="-A proto=sha -C context='' -K -P proto=des -v 3 -r 0"
  % bsnmpset $SNMP_ARGS sysLocation="MyAgent"
  % bsnmpget $SNMP_ARGS sysLocation
  % bsnmpwalk $SNMP_ARGS

MFC after:	12 days
X-MFC with:	r310729, r310892, r310894
2017-01-01 00:23:43 +00:00
ngie
20e0110624 snmp_output_err_resp, snmp_output_resp: allocate object using calloc, not
on the stack

Some of the callers try to determine whether or not `object` is valid by
testing the value for NULL, which will never be true if it's a stack value,
so in order to be clear and correct down the call stack, use a heap
allocated object.

This also addresses a Coverity issue by initializing all of `object` via
calloc

MFC after:	1 week
Reported by:	Coverity
CID:		1006392
2016-12-31 22:46:17 +00:00
ngie
1f505979e6 snmp_output_resp: style(9): sort variables by alignment
MFC after:	3 days
2016-12-31 22:18:33 +00:00
hrs
343a31e4d8 - Use more descriptive names for variables.
- Set O_CLOEXEC to the signal pipe and /dev/klog.
- Use a single signal handler to catch both SIGHUP and SIGCHLD.
- Fix a bug which did FD_SET() the writer-end of the pipe.
2016-12-31 13:15:52 +00:00
ngie
3aa12a8345 Set value->v.octetstring.len to a correct value on malloc success/failure
The previous code always set value->v.octetstring.len to len, regardless
of the result from the malloc call. This misleads the caller on malloc
failure. Set .len to len on success and 0 on failure.

MFC after:	1 week
Reported by:	Coverity
CID:		1007590
2016-12-31 12:14:25 +00:00
hrs
a8b00414bd - Add static for symbols which need not to be exported.
- Clean up warnings to the WARNS=6 level.
2016-12-31 11:03:34 +00:00
ngie
f467e93aee snmp_pdu_free the right object at the right time in snmptool_walk
r310892 was on the right track, but unfortunately it was resolving
the problem incorrectly and accidentally leaking memory in the
process.

- Call snmp_pdu_free on req before calling snmp_pdu_create on it
  at the bottom of the outer while loop
- Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create
  in the inner loop

MFC after:	12 days
X-MFC with:	r310729, r310892
Reported by:	valgrind
2016-12-31 10:01:25 +00:00
hrs
648d10d168 Remove extra NULL-check before free(3). 2016-12-31 09:52:00 +00:00
ngie
e302a523e6 Don't call snmp_pdu_free(..) until finished with the pdu and when ready to
allocate a new one via snmp_pdu_create(..)

This fixes bsnmpwalk, so it no longer crashes after r310729

X-MFC with:	r310729
MFC after:	12 days
2016-12-31 09:43:35 +00:00
hrs
0509b89e5c Replace two fat signal handlers with function calls in
the main I/O multiplex loop.  select() now watches
a pipe which is written by the new skinny signal
handlers and the received signals are handled inside
the loop sequencially.

This eliminates a complex signal mask to guarantee
async-signal safety.
2016-12-31 06:23:05 +00:00
hrs
a6a7801a09 Retry to open an F_PIPE process when it dies unexpectedly.
Reported by:	Eugene Grosbein
PR:		215335
2016-12-31 03:07:48 +00:00
ngie
70e3404e70 Don't explicitly build tcp wrappers support into bsnmpd; make it conditional
on MK_TCP_WRAPPERS != "no"

This likely fixes an issue seen where some of the USE_TCPWRAPPERS code didn't
work as advertised

MFC after:	1 week
2016-12-28 16:34:49 +00:00
ngie
945aa9528c Fix the build by moving the initializers for len/nswapdev down below the
declarations

MFC after:	3 days
Pointyhat to:	ngie
2016-12-28 08:11:41 +00:00
ngie
37debd5a95 style(9): clean up whitespace
MFC after:	3 days
2016-12-28 06:10:58 +00:00
ngie
51f89910c9 style(9) fixes: clean up leading whitespace
MFC after:	3 days
2016-12-28 05:43:14 +00:00
ngie
7120e9967e style(9) fixes: clean up leading whitespace
MFC after:	3 days
2016-12-28 05:42:41 +00:00
ngie
a4a83e9690 style(9) fixes
- Clean up trailing whitespace
- Fix variable type alignment in storage_OS_get_swap(..)

MFC after:	3 days
2016-12-28 05:41:53 +00:00
ngie
82c12f5e81 Only build/install usr.sbin/bsnmpd/modules/snmp_hast if MK_HAST != no
MFC after:	1 week
2016-12-28 05:21:22 +00:00
ngie
35041d3932 Only build/install usr.sbin/bsnmpd/modules/snmp_wlan if MK_WIRELESS != no
MFC after:	1 week
2016-12-28 05:16:41 +00:00
ngie
80601634ab Install snmpmod.3 as all of the bsnmpd APIs it documents
MFC after:	3 days
2016-12-28 03:56:25 +00:00
ngie
6a228a1b19 style(9): clean up trailing whitespace
MFC after:	3 weeks
2016-12-27 23:32:54 +00:00
mav
1e1d920eb6 Add MAX_LUNS overflow safety checks.
While this MAX_LUNS limitation is too synthetic and should be removed,
it is better to enforce it while it is here.

MFC after:	2 weeks
2016-12-27 17:13:31 +00:00
delphij
0809c4bc3c Don't assign rtjp twice.
Reported by:	clang static analyzer
MFC after:	2 weeks
2016-12-26 19:27:12 +00:00
delphij
1a03bcfc9e - pstat(8) does not accept any arguments other than getopt() args,
so don't bother to adjust argc/argv after getopt() loop.
 - Make a string pointer constant.

MFC after:	2 weeks
2016-12-26 17:34:27 +00:00
jamie
a1ed386acb Improve IP address list representation in libxo output.
Extract decision-making about special-case printing of certain
jail parameters into a function.

Refactor emitting of IPv4 and IPv6 address lists into a function.

Resulting user-facing changes:

XO_VERSION is bumped to 2.

In verbose mode (-v), IPv4 and IPv6-Addresses are now properly emitted
as separate lists.
This only affects the output in encoding styles, i.e. xml and json.

{                                    {
  "__version": "1",                    "__version": "2",
  "jail-information": {                "jail-information": {
    "jail": [                            "jail": [
      {                                    {
        "jid": 166,                          "jid": 166,
        "hostname": "foo.com",               "hostname": "foo.com",
        "path": "/var/jail/foo",             "path": "/var/jail/foo",
        "name": "foo",                       "name": "foo",
        "state": "ACTIVE",                   "state": "ACTIVE",
        "cpusetid": 2,                       "cpusetid": 2,
        "ipv4_addrs": [                      "ipv4_addrs": [
          "10.1.1.1",                          "10.1.1.1",
          "10.1.1.2",                          "10.1.1.2",
          "10.1.1.3",              |           "10.1.1.3"
                                   >         ],
                                   >         "ipv6_addrs": [
          "fe80::1000:1",                      "fe80::1000:1",
          "fe80::1000:2"                       "fe80::1000:2"
        ]                                    ]
      }                                    }
    ]                                    ]
  }                                    }
}                                    }

In -n mode, ip4.addr and ip6.addr are formatted in the encoding styles'
native list types, e.g. instead of comma-separated lists, JSON arrays
are printed.

jls -n all --libxo json
 ...
 "ip4.addr": [
    "10.1.1.1",
    "10.1.1.2",
    "10.1.1.3"
  ],
  "ip4.saddrsel": true,
  "ip6.addr": [
    "fe80::1000:1",
    "fe80::1000:2"
  ],
  ...

jls -n all --libxo xml
  ...
  <ip4.addr>10.1.1.1</ip4.addr>
  <ip4.addr>10.1.1.2</ip4.addr>
  <ip4.addr>10.1.1.3</ip4.addr>
  <ip4.saddrsel>true</ip4.saddrsel>
  <ip6.addr>fe80::1000:1</ip6.addr>
  <ip6.addr>fe80::1000:2</ip6.addr>
  ...

PR:		215008
Submitted by:	Christian Schwarz <me@cschwarz.com>
Differential Revision:	https://reviews.freebsd.org/D8766
2016-12-24 23:51:27 +00:00
hrs
93f074228f - Fix -N flag (NoBind) for AF_LOCAL sockets.
- Do setsockopt(SO_RCVBUF) for AF_LOCAL sockets regardless of -s flag.
2016-12-24 23:29:50 +00:00
ngie
e9becac72d Unbreak syslogd after r310494
Don't close all file descriptors greater than STDERR_FILENO (2) in
waitdaemon(..) -- only close fd (file descriptor for /dev/null used in
subsequent calls to dup2) if it's greater than STDERR_FILENO.

Reported by:	subbsd@gmail.com, danny@cs.huji.ac.il
Pointyhat to:	hrs
X-MFC with:	r310494
2016-12-24 12:50:17 +00:00
ngie
c885311193 Warning message cleanup
- Use warn instead of warnx + strerror(errno)
- Remove unnecessary trailing newline from a warnx call
- Add missing spaces following "," in syslog and warn* calls

MFC after:	2 weeks
2016-12-24 11:22:28 +00:00
hrs
733e7b5b6c - Remove unused code.
- Use closefrom().
2016-12-24 07:13:33 +00:00
hrs
3175084d4e - More ifdef INET and INET6.
- Use STDERR_FILENO + 1 instead of "3".
- Fix dprintf() in cvthname().
2016-12-23 06:29:24 +00:00
hrs
2a7e366589 mdoc and style fixes. 2016-12-23 04:59:22 +00:00
hrs
a5feb675ec - Fix a use-after-free bug when dq_timeout == 1 and
sending SIGTERM to the process failed.  It is an
  unusual situation but it can happen.
- Split deadq_remove() into deadq_remove() and
  deadq_removebypid().
- Normalize variable names of struct deadq_entry *.
2016-12-22 13:46:17 +00:00
hrs
8471fe0d61 Add a missing "default:" case. 2016-12-22 05:57:45 +00:00
hrs
552a44a16d Initialize a structure by using a compound literal to avoid forgetting
to zero unspecified members.
2016-12-22 05:55:44 +00:00
hrs
3fafa4ed6d Fix debug log in the case of AF_INET6. 2016-12-22 05:28:30 +00:00
hrs
64b1664fc0 - Simplify masklen->netmask conversion for AF_INET6.
- Use iov[N] by array index instead of using pointer v = &iov[0] to
  make the compiler catch an out-of-range access of the array.
2016-12-22 05:23:38 +00:00
mav
f54dc5b676 Add support for locally assigned RFC 4122 UUID LUN identifiers.
MFC after:	2 weeks
2016-12-21 09:05:30 +00:00
ed
73327b50a1 Add a Prometheus exporter for sysctl values.
Now that we have our sysctl tree annotated with aggregation labels,
let's go ahead and provide a very simple utility for exporting the
sysctl tree in Prometheus' format. It can either be used in conjunction
with the Prometheus node exporter or run through inetd(8).

The reason why I'm opting for having it in the base system is because it
has a pretty strong integration with some of sysctl's innards, such as
access to iterators, name lookups, metadata and type information. As I
am investigating whether we can add histograms as native types to sysctl
as well, this integration will only get stronger as we go along. That's
why it would be safer to oversee the development of this exporter
ourselves, as opposed to having it as an external project.

This exporter is remarkably compact, especially when compared to the
official Linux binary of the Prometheus node exporter (16 KB vs 12 MB).
I guess this could be an interesting aspect for monitoring embedded
FreeBSD-based systems.

Differential Revision:	https://reviews.freebsd.org/D8792
2016-12-21 08:29:44 +00:00
hrs
4931f7c9eb Simplify type casting of struct sockaddr_in. 2016-12-21 07:05:34 +00:00
hrs
85fbbe71fe - Initialize deadq_head statically.
- Fix indent.
- Add missing -S flag into usage().
- Use nitems() for an iov array instead of a macro.
2016-12-21 06:49:21 +00:00
hrs
8a3b755fff - Add fklog into struct socklist. Files and local/remote sockets are
now processed in struct socklist in a consistent manner.
- Add helper functions to add a new entry of struct socklist, filed, or peer.
- Use the same routine for -l, -p, and -S.
- Close /dev/klog when read(2) failed.
2016-12-21 06:42:30 +00:00
hrs
558fb217fd - Use fnmatch(3) for domanname matching of -a options.
- Document the patten matching.
- Document -S flag in SYNOPSIS.
2016-12-21 05:45:59 +00:00
cem
5e70075048 Add a 'force' option for non-interactive crontab removal
Add a '-f' option to force crontab '-r' to be non-interactive.

Submitted by:	Sam Gwydir <sam at samgwydir.com>
Reviewed by:	me, wblock (previous version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8815
2016-12-20 17:12:17 +00:00
hrs
18e1337260 Escape punctuation characters. 2016-12-20 08:49:13 +00:00
hrs
1a837765c8 Add a NULL check. 2016-12-20 04:05:21 +00:00
hrs
ee680228b1 Add a default socket bound to *:514 when no -b option is specified.
This was accidentally removed at r309933.

Spotted by:	Michael Butler
2016-12-20 03:41:40 +00:00
hrs
64f20e6425 Add a missing STAILQ_INSERT_TAIL() for allowaddr rule. 2016-12-19 17:10:30 +00:00
ngie
477b92b662 Clean up parse_ip(..)
- Clean up trailing whitespace
- Fix variable alignment

MFC after:	1 week
2016-12-18 05:36:04 +00:00
ngie
c0892cf220 Fix some minor typos with begemotBridgeTpLearnedEntryDiscards and
begemotBridgeTpMaxAddresses

Bump LAST-UPDATED for the MIB, per the change

MFC after:	1 week
2016-12-18 00:44:43 +00:00
cperciva
c9b82c3a4c Avoid division by zero in the rare case that portsnap needs to fetch
zero patches.  (This avoids two "dc: divide by zero" warnings.)

MFC after:	3 days
2016-12-16 22:37:16 +00:00
dteske
afc7443a35 Revert r309918 -- modern POSIX has deprecated -<#>/+<#> syntax
Special thanks to:	jilles
2016-12-13 22:31:49 +00:00
hrs
35dafbdd67 Remove an extra "break" which could incorrectly terminate an
STAILQ_FOREACH() loop when an AF_INET6 rule matched.

Spotted by:	cem
2016-12-13 20:55:46 +00:00
dteske
ee335e51e1 It's completely pointless to replace newlines with space
(this is done automatically for you upon shell expansion)
2016-12-13 02:56:52 +00:00
dteske
7665f7ac67 The flags of a WLAN need to be quoted (they contain things like brackets) 2016-12-13 02:54:44 +00:00
dteske
d208501dc8 Simplify single-line if statements 2016-12-13 02:48:14 +00:00
dteske
21f47b71cd Simplify loop by moving predicate to clause 2016-12-13 02:47:39 +00:00
dteske
66dc7693d3 Wordsmithing 2016-12-13 02:46:36 +00:00
dteske
aea80b05f3 Why test $? when you can test the command 2016-12-13 02:45:52 +00:00
dteske
4e07ba017a Restore previous comment 2016-12-13 02:45:07 +00:00
dteske
4c7fbd1f3b Both simplify bringup of interface after changes and catch errors in debug 2016-12-13 02:44:33 +00:00
dteske
a35c1dd28a Calculate proper size of menu list dialog 2016-12-13 02:42:10 +00:00
dteske
8e2e3ae3dd There's an API function for catching errors and displaying them or
logging them to debug output
2016-12-13 02:40:54 +00:00
dteske
397585b6bb There's an API function for displaying pauses 2016-12-13 02:30:24 +00:00
dteske
52245df7f6 There's an API function for displaying yes/no dialogs 2016-12-13 02:29:20 +00:00
dteske
b2bffd29c0 There's an API function for displaying errors 2016-12-13 02:27:38 +00:00
dteske
ace145d56c Comment 2016-12-13 02:25:23 +00:00
dteske
b37902302b Whitespace alignment 2016-12-13 02:23:48 +00:00
dteske
04ee6d2bc0 Relying on dialog auto-sizing (width/height/rows = 0) is a mistake
Use the provided API for calculating the appropriate size of menus
2016-12-13 02:22:21 +00:00
dteske
ae195a31a8 Remove unnecessary quotes 2016-12-13 02:16:00 +00:00
dteske
cbd36b071a Add missing quotes 2016-12-13 02:15:36 +00:00
dteske
d811f94e7f In awk, if you're going to append a newline to your printf
AND you're going to print only the argument, just use print
2016-12-13 02:14:40 +00:00
dteske
8179d41c00 This statement has too many backslashes 2016-12-13 02:13:20 +00:00
dteske
970dd61e8b Neither printf (and as is commonly known) nor print need parens in awk 2016-12-13 02:12:00 +00:00
dteske
caa88d1b07 Whitespace and alignment 2016-12-13 02:11:09 +00:00
dteske
071e4a0235 You don't need parentheses for awk's printf 2016-12-13 02:07:12 +00:00
dteske
4442ea7869 Continued resolution of conveluted statement
We shouldn't be coding things like "x || (x && x) || x || x || x ..."
2016-12-13 02:04:50 +00:00
dteske
3af2400435 These two error messages have always been backwards since inception 2016-12-13 02:02:14 +00:00
dteske
e9c0e67f16 Why use $? when you can use the command itself 2016-12-13 01:59:35 +00:00
dteske
466c31033e If the first ping succeeded, why on Earth should we ping it again? 2016-12-13 01:56:28 +00:00
dteske
89fc8acc2d Start deconstructing a conveluted hunk of code 2016-12-13 01:54:44 +00:00
dteske
8216db0e54 Remove completely unnecesary parentheses 2016-12-13 01:52:10 +00:00
dteske
69fc9cb69a Why repeat yourself when you can send stderr to the same place as stdout? 2016-12-13 01:50:22 +00:00
dteske
7940685748 Properly quote variable 2016-12-13 01:44:18 +00:00
dteske
d302140ee4 Use more generic f_yesno() from provided API 2016-12-13 01:42:13 +00:00
dteske
c52826dc16 The output of dialog needs to be sanitized
for portability/compatibility requirements
2016-12-13 01:41:06 +00:00
dteske
c610b42d0f Whitespace alignment 2016-12-13 01:39:09 +00:00
dteske
63213c08fe Sort the domains 2016-12-13 01:36:46 +00:00
dteske
49fdf75f47 The --no-items and --stdout options are non-standard and should be avoided
From the dialog(1) manual:
using [--stdout] in portable scripts is not recommended
2016-12-13 01:35:26 +00:00
dteske
b80642d373 More efficiently make use of the exit status 2016-12-13 00:27:56 +00:00
dteske
8a66e75e41 Stop repeating strings (centralize prompt string)
NB: Changes to strings now only affect a single line
2016-12-13 00:22:01 +00:00
dteske
eb83f20492 Add missing backslash (no real effect; it's pedantic and correct for
the interpolation level)
2016-12-13 00:18:51 +00:00
dteske
7d793e70e3 Use the oft-neglected awk syntax "startcondition, stopcondition { ... }" to
process the range of country labels which appear as columnar list from the
"ifconfig DEV list countries" command. Not only improving maintainability,
but also properly encapsulating arguments in single-quotes instead of
trying to escape whitespace. It is also completely unnecessary to collapse
newlines into whitespace (shell will do this for you automatically upon
expansion of the contents where necessary).

NB: This also changes the sorting algorithm to sort on the country code,
not the country name. The type-ahead feature of dialog is destroyed if the
tags are not sorted properly.
2016-12-13 00:02:59 +00:00
dteske
8544084830 Quote WLAN_IFACE (pedantic) 2016-12-12 22:57:07 +00:00
dteske
6e5a839b01 In awk, casting a variable as a boolean condition is the same as testing if
the length of the variable contents is greater than zero

This allows us to also move the secondary condition into the action clause
2016-12-12 21:29:48 +00:00
dteske
70f01cabaf Remove an unnecessary call to f_dialog_title_restore() 2016-12-12 21:27:29 +00:00
dteske
d2d70042b1 Whitespace 2016-12-12 21:26:36 +00:00
dteske
7b0075c12b Utilize provided i18n strings 2016-12-12 21:23:47 +00:00
dteske
b3ba09ad44 Remove incomplete and unnecessary creation of fd3
The provided API already provides a passthru descriptor and even
gives you a varaible for referring to it.
2016-12-12 21:20:56 +00:00
dteske
1f72b9ecd2 Remove unnecessary semi-colons 2016-12-12 21:18:24 +00:00
dteske
81a43c15a2 Use awk the following (more succinct) awk syntax:
condition1 { action1 }
	condition2 { action2 }

instead of the following syntax:

	{
		if (condition1) { action1 }
		else if (condition2) { action2 }
	}
2016-12-12 21:16:37 +00:00
dteske
a2137139d3 1 is the default descriptor for redirects without an fd prefix 2016-12-12 21:11:55 +00:00
dteske
9474c4bc00 Fix invalid parameter expansion (change $@ to "$@")
Without quotes, $@ loses its special meanining (see below)

% sh -c 'echo $@' /bin/sh "   1   " "   2   "
1 2
% sh -c 'echo "$@"' /bin/sh "   1   " "   2   "
   1       2

The quotes are required to get ARGV to be unperterped
2016-12-12 21:04:11 +00:00
dteske
d5fa50b840 Allow the script path to contain whitespace and special characters 2016-12-12 21:01:20 +00:00
dteske
132073e3d3 Use provided API to centralize dialog title strings 2016-12-12 21:00:09 +00:00
dteske
aec8b5b0d1 Reorder dialog parameters based on commonality for readability 2016-12-12 20:54:20 +00:00
dteske
4cbb470510 Fix incorrect use of provided API
The result of which was incorrectly sized menu dialogs
2016-12-12 20:49:49 +00:00
dteske
73a6483723 Use provided API (change "dialog" to "$DIALOG") 2016-12-12 20:43:09 +00:00
dteske
f36072e86a Whitespace (dialog options separated to minimize diffs) 2016-12-12 20:41:27 +00:00
dteske
7a906cbddf Consolidate redirects into here documents, with proper code indentation 2016-12-12 19:46:49 +00:00
hrs
fc29dcf63c - Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.
2016-12-12 19:33:40 +00:00
dteske
8deaf769ad Remove an unnecessary "return $?" at end of function 2016-12-12 19:26:55 +00:00
hrs
a92b987411 Temporarily backout the previous commit because it was totally broken due to
unresolved merge conflicts.

Pointy hat to:	hrs
2016-12-12 19:24:52 +00:00
dteske
66586c3cda Use ternary operator 2016-12-12 19:24:32 +00:00
dteske
0d3fb22f07 If you're not going to make use of the products of a match() in awk
(e.g., RSTART and RLENGTH variables) then use ~ instead of match()
2016-12-12 19:12:31 +00:00
dteske
5b403b7aab Now that these variables do not contain the --default-item flag itself,
change the name of the variable from $def_item_... to $default_...
2016-12-12 19:10:39 +00:00
hrs
72a9e76712 - Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.
2016-12-12 19:10:14 +00:00
dteske
7186d17fc0 Always pass --default-item parameter to dialog 2016-12-12 19:09:17 +00:00
dteske
6ac73bdcd8 There is zero harm in always passing --default-item to dialog 2016-12-12 19:07:42 +00:00
dteske
6895a533a9 Centralize backtitle string 2016-12-12 19:01:04 +00:00
dteske
85088f1091 Use provided API instead of hard-coded status integers 2016-12-12 18:55:41 +00:00
dteske
65dd648795 Whitespace 2016-12-12 18:52:22 +00:00
dteske
eb2a4fb667 Remove unnecessary `-n' parameter to head/tail 2016-12-12 18:48:00 +00:00
dteske
c523ed6ee1 awk(1) match() takes a regex, use /.../ to remind ourselves of this
NB: The difference between "..." and /.../ for a regex in awk is that
quoted strings go through escape expansion first (e.g., \\ becomes \)
2016-12-12 18:45:52 +00:00
dteske
827f6676dc Be internally consistent (": > ..." is used elsewhere in this file) 2016-12-12 18:43:42 +00:00
dteske
a86c55d3d1 "echo | sed | sed | awk" is silly (changed to "echo | awk") 2016-12-12 18:42:55 +00:00
dteske
74e48b359f Add missing `-e' parameter to sed invocations 2016-12-12 18:39:26 +00:00
dteske
2abc445326 Allow $BSDINSTALL_TMPETC to contain whitespace or special chars 2016-12-12 18:38:18 +00:00
dteske
544da66b52 Group fallbacks together 2016-12-12 18:34:21 +00:00
dteske
fa756bc185 Remove unnecessary quotes around number in test 2016-12-12 18:33:40 +00:00
dteske
53f48a2373 Change "[ ! ... ] && ..." to "[ ... ] || ..." 2016-12-12 18:29:24 +00:00
dteske
5d63bb6317 Collapse tiny if statements 2016-12-12 18:28:20 +00:00
dteske
a848623c29 Replace funny block with something easy to digest 2016-12-12 18:24:41 +00:00
dteske
1390aaa722 Consolidate locals 2016-12-12 18:21:56 +00:00
dteske
0d737976f5 Remove unnecessary local initializers 2016-12-12 18:20:56 +00:00
dteske
ced2b90567 Change "[ ! -z ... ]" => "[ ... ]" and "[ -z ... ]" => "[ ! ... ]" 2016-12-12 18:17:30 +00:00
dteske
eaa4d342d8 Use $( ... ) instead of ... 2016-12-12 18:10:33 +00:00
dteske
889cd4165d Comments 2016-12-12 18:05:54 +00:00
bapt
1fd84d9b40 Fix pkg groupshow <gid>
PR:		204676
Submitted by:	longwitz@incore.de
MFC after:	2 days
2016-12-10 12:48:48 +00:00
rmacklem
fea344561b Patch the nfsd so that it doesn't register with rpcbind for an NFSv4 only
server.

This patch uses the sysctl vfs.nfsd.server_min_nfsvers to determine
if/what versions of NFS service should be registered with rpcbind.
For NFSv4 only, it does not register at all, since NFSv4 always uses 2049
and does not require rpcbind.
For NFSv3 minimum, it registers NFSv3 but not NFSv2.

Tested by:	jmader2@gmu.edu
Submitted by:	jmader2@gmu.edu (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8696
2016-12-08 23:29:56 +00:00
dteske
8a7a41fe62 Functions in their own section 2016-12-08 19:28:12 +00:00
dteske
4efe9f28d0 Remove unnecessary trailing backslashes 2016-12-08 19:26:22 +00:00
dteske
66cde2d5d3 Add support for "hidden" Wi-Fi networks
PR:		bin/214933
Submitted by:	Maxim Filimonov <che@bein.link>
Reviewed by:	dteske, allanjude, adrian
MFC after:	6 days
X-MFC-with:	Follow-up commit for style
2016-12-08 16:41:18 +00:00
n_hibma
48de74606e More typos in strings.
Submitted by:	bde
MFC after:	3 days
2016-12-02 11:30:21 +00:00
araujo
dcae55d955 Use memset(3) instead of bzero(3).
Obtained from:	OpenBSD (r1.12, r1.20, r1.18 and r1.37)
2016-12-02 06:07:27 +00:00
araujo
359d465f28 String terminators are called NUL, not NULL, also the variable
mentioned in the comment is p and not u.

Obtained from:	OpenBSD (r1.34)
2016-12-02 05:49:22 +00:00
n_hibma
1a31db3cf4 Speling fixes and fix line endings for err_msg output.
In some cases there was not \n, in other cases there was.
2016-12-01 09:14:58 +00:00
avg
4596354565 bhyve: stability and performance improvement for dbgport
The TCP server implementation in dbgport does not track clients, so it
may try to write to a disconected socket resulting in SIGPIPE.
Avoid that by setting SO_NOSIGPIPE socket option.

Because dbgport emulates an I/O port to guest, the communication is done
byte by byte.  Reduce latency of the TCP/IP transfers by using
TCP_NODELAY option.  In my tests that change improves performance of
kgdb commands with lots of output (e.g. info threads) by two orders of
magnitude.

A general note.  Since we have a uart emulation in bhyve, that can be
used for the console and gdb access to guests.  So, bvmconsole and bvmdebug
could be de-orbited now.  But there are many existing deployments that
still dependend on those.

Discussed with:	julian, jhb
MFC after:	2 weeks
Sponsored by:	Panzura
2016-11-29 13:11:00 +00:00
delphij
fbc8d8de2c Plug another leak with malformed IPv6 address.
MFC after:	2 weeks
2016-11-28 07:41:01 +00:00
delphij
2059af8c9f Don't leak 'str' when we see a malformed IPv6 address.
MFC after:	2 weeks
2016-11-28 07:33:26 +00:00
bapt
add8fe4b90 Properly initialize nextp
MFC after:	1 day
2016-11-27 19:27:13 +00:00
bapt
7fc09585c4 initialize *nextp which could be left uninitialized in case the configuration
file cannot be open/read

Reported by:	Coverity via cem
MFC after:	2 days
CID:		1365665
2016-11-26 15:49:59 +00:00
sevan
d42b4777f9 Fix null dereference when running out of nodes during rename.
PR:		212370
Submitted by:	Sascha Wildner <swildner AT gmail>
Reviewed by:	bcr (mentor)
Approved by:	bapt
Obtained from:	NetBSD
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8643
2016-11-26 13:26:29 +00:00
jceel
65feaeaf88 virtio_console: handle short writes to an Unix domain socket gracefully.
writev() can do a short write.  Retrying it results in a very convoluted
and complex code, so we iterate over iovec and do regular stream_write()
instead.

Approved by:	trasz
Sponsored by:	iXsystems, Inc.
2016-11-24 22:16:18 +00:00
jceel
5673d8fe28 Allow opening virtio-console ports from the host side before guest
enumerates them.

Approved by:	trasz
Sponsored by:	iXsystems, Inc.
2016-11-24 21:53:42 +00:00
phk
d140423023 Pass the correct size argument to ioctl(DIOCGSECTORSIZE) 2016-11-22 22:10:58 +00:00
delphij
3298f99b19 MFV r308954:
ntp 4.2.8p9.

Approved by:	so
2016-11-22 08:27:49 +00:00
asomers
9e66c6e8f0 Speed up pw operations that edit /etc/group or /etc/passwd
r285050 fixed a bug in pw that could lead to /etc/passwd or /etc/group
corruption on power loss. However, it fixed it by opening those files with
O_SYNC, which is very slow, especially on ZFS. This change replaces O_SYNC
with appropriately placed fsync()s instead, which is much faster. Using a
ZFS tmpdir, the time to run pw's kyua tests drops from 245s to 35s.

Reviewed by:	allanjude, bapt, vangyzen, garga
Tested on pfSense by:	garga
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D8319
2016-11-18 16:07:08 +00:00
emaste
27b84ca828 crunchide: report explicit error for combined string table
Some tools produce objects with a combined strtab and shstrtab.
These objects are not supported by crunchide since it rewrites the
symtab and strtab to "hide" symbols. This invalidates section header
offsets into a combined strtab/shstrtab.

In the future we could support these objects (by ensuring that we retain
unmodified section name strings in the output .strtab, and then rewriting
each section header's sh_name).

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-11-17 18:12:17 +00:00
sephe
928d6c8777 hyperv/vss: Install the userland daemon to /usr/sbin instead of /
Submitted by:	markj
Reported by:	markj
MFC after:	3 weeks
Sponsored by:	Microsoft
2016-11-17 03:02:35 +00:00
emaste
729f930f60 crunchide: remove obsolete a.out header and comment
crunchide(1) gained ELF support in r39172, and lost the unused a.out
and non-functional ECOFF suport in r281655.

Sponsored by:	The FreeBSD Foundation
2016-11-16 16:39:51 +00:00
sephe
cf8bc16b1e hyperv/vss: Add driver and tools for VSS
VSS stands for "Volume Shadow Copy Service".  Unlike virtual machine
snapshot, it only takes snapshot for the virtual disks, so both
filesystem and applications have to aware of it, and cooperate the
whole VSS process.

This driver exposes two device files to the userland:

    /dev/hv_fsvss_dev

    Normally userland programs should _not_ mess with this device file.
    It is currently used by the hv_vss_daemon(8), which freezes and
    thaws the filesystem.  NOTE: currently only UFS is supported, if
    the system mounts _any_ other filesystems, the hv_vss_daemon(8)
    will veto the VSS process.

    If hv_vss_daemon(8) was disabled, then this device file must be
    opened, and proper ioctls must be issued to keep the VSS working.

    /dev/hv_appvss_dev

    Userland application can opened this device file to receive the
    VSS freeze notification, hold the VSS for a while (mainly to flush
    application data to filesystem), release the VSS process, and
    receive the VSS thaw notification i.e. applications can run again.

    The VSS will still work, even if this device file is not opened.
    However, only filesystem consistency is promised, if this device
    file is not opened or is not operated properly.

hv_vss_daemon(8) is started by devd(8) by default.  It can be disabled
by editting /etc/devd/hyperv.conf.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reviewed by:	kib, mckusick
MFC after:	3 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8224
2016-11-15 02:36:12 +00:00
tuexen
e1f68915de Fix typo.
MFC after: 1 month
Sponsored by: Netflix
2016-11-13 17:55:27 +00:00
bdrewery
fa5e66f74b DIRDEPS_BUILD: Update dependencies.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:30 +00:00
bdrewery
d54a46a6a5 DIRDEPS_BUILD: Connect new dependencies.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:23 +00:00
gavin
f1983589e8 Correct spelling in syslog: getttimeofday -> gettimeofday 2016-11-11 21:53:38 +00:00
avg
54bc313672 smbmsg: use a more convenient way of accessing data read from a slave
Developers writing code for accessing /dev/smb may use this base utility
as an example.  Now that SMB_READB, SMB_READW, SMB_PCALL behave as
documented, wwe can use them in a more convenient way than before.

MFC after:	4 weeks
X-MFC after:	r308527
2016-11-11 15:00:13 +00:00
cy
ec84251864 MFV r305100: Update amd from am-utils 6.1.5 to 6.2.
Used extensively on my network over the past month.

Reviewed by:	pfg, brooks
Suggested by:	pfg
Obtained from:	ftp://ftp.am-utils.org/pub/am-utils/
MFC after:	6 weeks
Relnotes:	yes
Differential Revision:	D8405
2016-11-11 02:42:53 +00:00
avg
42837ed746 fix a watchdogd regression introduced in r308040
The code assumed that 'timeout' and 'timeout_sec' are in sync
which they weren't if no '-t' option was passed to watchdogd.

Reported by:	Olivier Smedts <olivier@gid0.org>,
		Alex Deiter <alex.deiter@gmail.com>
Tested by:	Olivier Smedts <olivier@gid0.org>,
		Alex Deiter <alex.deiter@gmail.com>
MFC after:	5 days
X-MFC with:	r308040
2016-11-10 10:45:12 +00:00
araujo
553799668b Add flag -B which does the same like batch mode but without exiting after
print. Also add a new flag -s that add blocks size to statistics.

PR:		198347, 212726
Submitted by:	Ben RUBSON <ben.rubson@gmail.com>
Tested by:	pi
MFC After:	2 weeks.
2016-11-09 07:31:39 +00:00
bdrewery
30f99dbeef Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
hrs
d7fae5d82f Add link-layer address option in RA even for IFT_L2VLAN and IFT_BRIDGE.
Reported by:	philip
MFC after:	3 days
2016-11-05 19:51:13 +00:00
hrs
c5bff35f2d Fix an infinite loop at an non-responding hop when other echo replies
are kept arriving in the waittime time window.

Submitted by:	Denny Page
PR:		210286
MFC after:	3 days
2016-11-05 18:00:36 +00:00
marcel
6e98c7ae89 Assign a random number to di_gen (for FFS), instead of extracting it
from struct stat.  We don't necessarily have permissions to see the
generation number and the host OS may not have st_gen in struct stat
anyway.  Since the kernel assigns random numbers, there's nothing
meaningful about the generation that requires us to preserve it when
the file system image is created.  With this change, all generation
numbers come from random() and that makes it easier to add support
for reproducible builds at some time in the future (i.e. by adding
an argument to makefs that changes the behaviour of random() so that
it always returns 0 or some predictable sequence).

Differential Revision:	https://reviews.freebsd.org/D8418
2016-11-05 16:23:33 +00:00
emaste
a9ccbd410e vidcontrol: use calloc where appropriate
Reported by:	kib
2016-11-05 11:19:55 +00:00
emaste
11b1ab4d35 vidcontrol: improve error handling in vt(4) font loading
PR:		209078
Reported by:	ecturt@gmail.com
Reviewed by:	Oliver Pinter
Differential Revision:	https://reviews.freebsd.org/D8176
2016-11-04 20:32:49 +00:00
avg
34fc8742e2 Add support for microcode update on newer AMD CPUs (10h+)
This includes new code for parsing microcode files as well as
the kernel-side change to apply the update on all processors
at the same time.

Developed with help from Borislav Petkov, formerly bp@amd64.org.

Tested using Athlon II X2 processor on a system where BIOS does
not have the latest microcode version:
/boot/firmware/microcode_amd.bin: updating cpu /dev/cpuctl0 to revision 0x10000c7... done.

The microcode file is taken from here:
https://web.archive.org/web/20160528230514/http://www.amd64.org/microcode.html
(note that the original site seems to be down at the moment)
It can also be found here:
https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/amd-ucode

Reviewed by:	kib, stas
MFC after:	2 weeks
Relnotes:	maybe
Differential Revision: https://reviews.freebsd.org/D8384
2016-11-02 16:15:49 +00:00
fabient
db07decd67 In rtadvd, interface lookup calls if_indextoname() many times in a loop,
(it takes a long time on systems with many interfaces)
without reason and without checking its return value.

Reviewed by: cem
Obtained from: Maryse Levavasseur <maryse.levavasseur@stormshield.eu>
MFC after: 1 month
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D6979
2016-11-02 15:11:23 +00:00
trasz
8381908c9b Make autounmountd(8) not die when traced with "truss -p".
MFC after:	1 month
2016-11-02 08:12:37 +00:00
bapt
b40644e15d syslogd(8): add an 'include' keyword
All the '.conf' files not beginning with a '.' contained int he directory
following the keyword will be included.

This keyword can only be used in the first level configuration files.

Modify the default syslogd.conf to 'include' /etc/syslog.d and
/usr/local/etc/syslog.d

It simplify a lot handling of syslog from automation tools.

Reviewed by:	markj, kib (via irc)
Approved by:	markj
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D8402
2016-11-01 01:41:24 +00:00
bapt
666d013985 Allow symlinks to be followed in cron.d directories and fix detection of
regular files on NFS

Reported by:	jilles
2016-10-31 23:40:04 +00:00
bapt
3fba679a27 Fix typo in cron(8) date
Reported by:	jilles
2016-10-31 23:32:38 +00:00
bapt
547c42fa4a cron(8): add support for /etc/cron.d and /usr/local/etc/cron.d
For automation tools it is way easier to maintain files in directories rather
than modifying /etc/crontab.

The files in those directories are in the same format as /etc/crontab

Reviewed by:	adrian
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Gandi.net
Differential Revision:	https://reviews.freebsd.org/D8400
2016-10-31 18:20:12 +00:00
mav
3c5f3f503b There appeared to be even more copy/pastes. :)
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2016-10-31 16:06:57 +00:00
mav
3c8a54a8e5 Fix wrong copy/paste in error message.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2016-10-31 16:01:22 +00:00
avg
d8bbab0cdc nap time between pats is forced to be at most half of the timeout
Previously, if the timeout was less than 10 seconds, for example, about
8 seconds, then the watchdog timer would be let to expire before patting
the watchdog.

MFC after:	2 weeks
2016-10-28 14:49:54 +00:00
marcel
56b1b663ba Allow config to be compiled from another source directory, such as one
for building tools. This boils down to replacing ${.CURDIR} with
${SRCDIR}, where the latter is the directory in which this makefile
lives.

Also allow overriding where file2c comes from using ${FILE2C}.
2016-10-26 15:58:41 +00:00
glebius
ebc9866803 Fix unchecked array reference in the VGA device emulation code.
Submitted by:   Ilja Van Sprundel <ivansprundel@ioactive.com>
Patch by:	tychon
Security:       SA-16:32
2016-10-25 17:13:58 +00:00
marcel
f238e6d92d Be more precise when including headers so that we're less likely to
depend on namespace pollution and as such become more portable. This
means including headers like <sys/types.h> or <stdlib.h>, but also
making sure we include system/host headers before local headers.

While here: define ENOATTR as ENOMSG in mtree.c. There is no ENOATTR
on Linux.

With this, makefs is ready for compilation on macOS and Linux.
2016-10-25 16:29:15 +00:00
marcel
6d43ad44ce Allow building makefs(8) from another Makefile (such as one in
a seperate directory hierarchy used to build tools). This boils
down to replacing the use of ${.CURDIR} with either ${SRCDIR}
or ${SRCTOP}. SRCDIR is defined as the directory in which the
Makefile lives that bmake(1) is currently reading. Use SRCTOP
when reaching outside of makefs's directory.
2016-10-25 16:21:38 +00:00
bapt
b606610ad8 accept4 actually expect SOCK_NONBLOCK and not O_NONBLOCK
Reported by:	jhb
Pointyhat to:	bapt
2016-10-25 15:20:06 +00:00
rmacklem
6946fcda45 Fix the man page to reflect the change done by r307890 to mountd.c
so that the "-n" option uses the sysctl for the new NFS server.
This is a content change.

PR:		213450
Submitted by:	rs@bytecamp.net
MFC after:	2 weeks
2016-10-25 00:59:23 +00:00
rmacklem
98386c04cf mountd(8) was erroneously setting the sysctl for the old NFS server
when the new/default NFS server was running, for the "-n" option.

This patch fixes the problem for head and stable/11. For stable/10 the
patch will need to be modified when MFC'd, since the stable/10 mountd.c
handles both old and new NFS servers.
Since the new NFS server uses vfs.nfsd.nfs_privport == 0 by default,
there wouldn't have been many users affected by the code not setting
it to 0 when the "-n" option was specified.

PR:		213450
Submitted by:	rs@bytecamp.net
MFC after:	2 weeks
2016-10-25 00:52:42 +00:00
bapt
951eb1b47f Fix build of tzsetup when WITHOUT_DIALOG is set
Hide dialog specific code behind HAVE_DIALOG. It allows to build a stripped
down version (missing the dialog UI) but perfectly function tzsetup when
world is built WITHOUT_DIALOG

Reorganise a bit the code to limit the number of blocks under HAVE_DIALOG

Reviewed by:	emaste
Sponsored by:	https://reviews.freebsd.org/D8325
2016-10-22 22:35:39 +00:00
cy
dd8716061b Align whitespace.
MFC after:	2 weeks
X-MFC with:	r307800
2016-10-22 22:29:03 +00:00
cy
f6f2cc22e9 Sources from the "current" build tree and generated sources in the
object tree should be used instead of sources and headers from the
already installed source tree on the build host.

This was noticed while addressing issues in the upcoming amd update.

MFC after:	2 weeks
2016-10-22 22:27:51 +00:00
jilles
0808a69a8d daemon: Allow logging daemon stdout/stderr to file or syslog.
There are various new options, documented in the man page, to send the
daemon's standard output and/or standard error to a file or to syslog.

Submitted by:	ank at iki.fi
Reviewed by:	wblock (man page only)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D7993
2016-10-22 11:26:22 +00:00
jhibbits
40c4c3de40 Create a new MACHINE_ARCH for Freescale PowerPC e500v2
Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU.  The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive.  Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement.  setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).

Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.

Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.

Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used.  However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.

Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI.  Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.

Reviewed By:	bdrewery, imp
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D5683
2016-10-22 01:57:15 +00:00
asomers
5e03799fd4 Close some file descriptor leaks in pw
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D8245
2016-10-21 20:17:19 +00:00
mav
50b1df2a7c Add names for some DASP devices.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2016-10-21 15:23:54 +00:00