Commit Graph

16775 Commits

Author SHA1 Message Date
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