Commit graph

332 commits

Author SHA1 Message Date
Cy Schubert f1ab799927 rc: fix rc script parsing
77e1ccbee3 introduced a bug whereby
rc scripts in etc/rc.d and $local_startup failed to parse output
from called commands because IFS was set to " " instead of the
default " \t\n". This caused parsing of output that contains any
whitespace character, such as tabs and newlines, not matching just a
space to fail.

PR:		249192
MFC after:	3 weeks
X-MFC with:	77e1ccbee3
2021-02-25 11:47:56 -08:00
Cy Schubert 6e822e9957 rc: fix parse of $local_startup
77e1ccbee3 introduced parallel execution
of rc. It separated groups with line feeds (\n) and elements within
groups using spaces. This is a natural separation due to rcorder
using spaces and lines to separate elements within groups with groups
of services separated by line feeds.

77e1ccbee3 parses the output from rcorder
by setting $IFS. However it failed to reset $IFS to default ' \t\n'
prior to calling find_local_scripts_new(), causing find_local_scripts_new()
to fail parsing $local_startup for site-specific local rc scripts, i.e.
${LOCALBASE}/etc/rc.d. This caused daemons from ports and packages such
as postfix, dovecot, nut, and others in ${LOCALBASE} not to be started.

PR:		249192
MFC after:	3 week
X-MFC with:	77e1ccbee3
2021-02-23 21:12:49 -08:00
Chris Rees d27999e513 Create dhclient pid directory if it doesn't exist
- Upgrading from older FreeBSD versions can result in errors

 - /var/run can be a tmpfs, and this should be handled correctly

Approved by:		markj
Differential Revision:	https://reviews.freebsd.org/D28843
MFC after:		2 weeks
2021-02-23 13:19:44 +00:00
Rick Parrish 77e1ccbee3 rc: implement parallel boot
take advantage of the rcorder -p argument to implement parallel
booting in rc.

According to the author non scientific tests:
on a Core 2 Duo with spinning disk:

| Services enabled | before | after | saving |
| 0                | 8s     | 8s    | 0      |
| 1                | 13s    | 13s   | 0      |
| 2                | 17s    | 13s   | 5      |
| 3                | 23s    | 13s   | 10     |
| 4                | 28s    | 13s   | 15     |
| 5                | 33s    | 13s   | 20     |

PR:		249192
MFC after:	3 weeks
2021-02-23 11:16:53 +01:00
Cy Schubert e2ad10e847 Remove the redundant ipfilter IPv6 rc rules load.
As of ipfilter 5.1.2 the IPv4 and IPv6 rules tables have been merged.
The ipf(8) -6 option has been a NOP since then. Currently the additional
ipf -6 load statement in rc.d/ipfilter simply added the second ipfilter
rules file to the table already populated by the previous ipf command.
Plenty of time has passed since ipfilter 5.1.2 was imported. It is time to
remove the option from rc.conf and the rc script.

Differential Revision:	https://reviews.freebsd.org/D28615
2021-02-22 11:20:18 -08:00
Rick Macklem 2f48313ab2 nfs-over-tls: add rc scripts for rpc.tlsclntd and rpc.tlsservd
Add rc.d scripts that control the recently committed rpc.tlsclntd(8)
and rpc.tlsservd(8) daemons.

Reviewed by:	gbe
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D28432
2021-02-18 14:38:01 -08:00
Edward Tomasz Napierala 07cac176fb Don't check compat.linux.emul_path before loading linux(4)
Fix e40787f900 to make libexec/rc/rc.d/linux retrieve the sysctl
after loading the kernel module which provides it, not before.

Reported By:	jkim
Sponsored By:	The FreeBSD Foundation
2021-02-08 22:00:25 +00:00
Edward Tomasz Napierala e40787f900 Use compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux
In /etc/rc.d/linux the mounting paths of procfs, sysfs and devfs
are hardcoded to "/compat/linux".  Switching to the content of
compat.linux.emul_path sysctl would allow to switch linuxulator
to different place.

Submitted by:	freebsdnewbie_freenet.de
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27807
2021-02-02 14:40:58 +00:00
Alex Richardson bcc5b24456 rc.d/auditd: set pidfile
auditd creates a pidfile so we should use it for status checks.
This also seems to speed up the frequent onestatus checks used in
tests/sys/audit.

Reviewed By:	asomers
Differential Revision: https://reviews.freebsd.org/D28389
2021-01-28 17:24:24 +00:00
Stefan Eßer 24f44a445c Remove dependency on files in /usr/bin
In order to reduce the pre-requisites of this file, implement the
pattern matching and creation of a temporary test directory without
use of grep respectively mktemp.

The new version makes it possible to provide a writable /tmp in any
case and independently of other local or remote file systems (except /
and /dev) being mounted.

The use of "dd if=/dev/random" has the same dependency on /dev/random
being operational as the previous version that used "mktemp". If this
is found to be an issue on platforms that do not have gathered
sufficient entropy at the time when this scriot is run, I suggest to
replace the "dd" command with "ps lauxww" to get a somewhat random
test directory name.

Approved by:	rgrimes, glebius, cy
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D28209
2021-01-19 12:56:23 +01:00
Marius Strobl 33b486472e bluetooth: remove support for bt3c(4)
The latter has been removed in 23e124c78b.
2021-01-16 23:53:13 +01:00
Gleb Smirnoff 4f48fd7c56 Add 'tmp' to the list of FILESYSTEMS dependencies. Some scripts that
depend on FILESYSTEMS run mktemp(1).  For systems that have read-only
root this is broken until memory disk based /tmp is instantiated.  At
least 'os-release' and 'motd' are subject to this problem.

Reviewed by:		ngie
Differential Revision:	https://reviews.freebsd.org/D28097
2021-01-15 12:44:06 -08:00
Gleb Smirnoff 7e4eca7136 Revert 97ec6eba65. There shouldn't be a dependency of 'tmp' on
remote filesystems.  Discussed this with Brooks and he can't find
evidence that provoked the change in 2005.  If anything gets broken
I will fix it in a different way, not via rc sequence change.

Discussed with:		brooks
Reviewed by:		ngie
Differential Revision:	https://reviews.freebsd.org/D28097
2021-01-15 12:44:06 -08:00
Gleb Smirnoff 425f68e6ce Follow-up on 51da4b19be. When booting a system with WITHOUT_IPFILTER
the following warning printed at boot time:

  rcorder: requirement `ipfs' in file `/etc/rc.d/netif' has no providers.

Close that using BEFORE rather than REQUIRE for writing down
dependencies of optional components.
2021-01-11 12:36:54 -08:00
Gleb Smirnoff 2903606b60 Add missing rcvar name for os-release. 2021-01-11 08:36:37 -08:00
Emmanuel Vadot e3ff9a1f2e pkgbase: Put the last rc files in the rc package
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D27718
2021-01-04 16:21:13 +01:00
Mark Johnston 5120612664 Fix the ipfw service status output when ipfw.ko isn't loaded
Reported by:	lme
Reviewed by:	lme
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27657
2020-12-18 16:02:28 +00:00
Rick Macklem 31b29217ab Make mountcritremote dependent upon nfscbd.
Although it is not often needed, the nfscbd(8) should be running when
NFSv4 mounts are done if callback functionality is required.
Callback functionality is required for the NFSv4 server to issue
delegations or pNFS layouts.

This patch adds nfscbd to the mountcritremote's REQUIRED line
to ensure it is started before NFS mounts specified in /etc/fstab
are done.

Reviewed by:	0mp
Differential Revision:	https://reviews.freebsd.org/D27506
2020-12-17 00:20:57 +00:00
Cy Schubert 353ce81687 Revert r366857.
r366857 created a number of problems, tearing down interfaces too
early in shutdown. This resulted in:

- hung ssh sessions when shutting down or rebooting remotely using
  shutdown (I've used exec shutdown, for years, as apposed to simply
  shutdown).

- NFS mounted filesystems "disappear" prior to unmount.

- dhclient attached to a VLAN on an interface who's parent interface
  has already shut down prints errors.

The path forward is to teach lagg(4) and vlan(4) about WOL.

PR:		251531, 251540
PR:		158734, 109980 are broken again
Reported by:	jhb, emaste, jtl, Helge Oldach<freebsd_oldach.net>
		Martin Birgmeier <d8zNeCFG_aon.at>
MFC after:      Immediately
Discussion at:	https://reviews.freebsd.org/D27459
2020-12-04 19:31:16 +00:00
Bjoern A. Zeeb dd4d5a5ffb IPv6: set ifdisabled in the kernel rather than in rc
Enable ND6_IFF_IFDISABLED when the interface is created in the
kernel before return to user space.

This avoids a race when an interface is create by a program which
also calls ifconfig IF inet6 -ifdisabled and races with the
devd -> /etc/pccard_ether -> .. netif start IF -> ifdisabled
calls (the devd/rc framework disabling IPv6 again after the program
had enabled it already).

In case the global net.inet6.ip6.accept_rtadv was turned on,
we also default to enabling IPv6 on the interfaces, rather than
disabling them.

PR:		248172
Reported by:	Gert Doering (gert greenie.muc.de)
Reviewed by:	glebius (, phk)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27324
2020-11-25 20:58:01 +00:00
Mateusz Piotrowski e5912dcf20 Revert r367291 (KEYWORD: shutdown for rc.d/zfs)
The problem is that zfs is asked to stop too early in the shutdown
sequence. Other services, such as syslog may still be running and have some
files open (e.g., under /var/log). This of course causes the messages like:

  cannot unmount '/var/run': umount failed
  cannot unmount '/var/log': umount failed
  cannot unmount '/var': umount failed
  cannot unmount '/usr/home': umount failed
  cannot unmount '/usr': umount failed
  cannot unmount '/': umount failed

For now, let's remove the shutdown KEYWORD from the zfs service, as people are
reporting problems in their setups:
https://lists.freebsd.org/pipermail/freebsd-current/2020-November/077559.html

In the future, we may think of stopping zfs on shutdown after all the other
services and just before init(8) exits. Another interesting option might be to
a new rcorder(8) KEYWORD like "shutdownjail", but this idea would need to be
discussed a bit.

Reported by:	Johan Hendriks <joh.hendriks gmail.com>
Reported by:	Yasuhiro KIMURA <yasu utahime.org>
Reported by:	Tomoaki AOKI <junchoon dec.sakura.ne.jp>
Approved by:	kevans (src)
MFC:		3 days
Differential Revision:	https://reviews.freebsd.org/D27263
2020-11-20 14:37:07 +00:00
Rick Macklem 01b139f212 Fix startup of gssd when /usr is a separately mounted local file system.
meowthink@gmail.com reported that the gssd daemon was not
starting, because /etc/rc.d/gssd was executed before his local
/usr file system was mounted.
He fixed the problem by adding mountcritlocal to the REQUIRED
line.

This fix seems safe and works for a separately mounted /usr file
system on a local disk.
The case of a separately mounted remote /usr file system (such as
NFS) is still broken, but there is no obvious solution for that.
Adding mountcritremote would fix the problem, but it would
cause a POLA violation, because all kerberized NFS mounts
in /etc/fstab would need the "late" option specified to work.

Submitted by:	meowthink@gmail.com
Reported by:	meowthink@gmail.com
Reviewed by:	0mp
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D27203
2020-11-14 01:49:49 +00:00
Rick Macklem 4389a56610 Add support for the new mountd -R option.
r376026 added a new "-R" option to mountd, which tells it to
not support the Mount protocol (not used by NFSv4) and not
register with rpcbind.
Rpcbind is considered a security issue by some sites now.

This patch adds a new yes/no variable called nfsv4_server_only.
When that is set, make vfs.nfsd.server_min_vers=4 and set "=R"
for mountd.
Setting vfs.nfsd.server_min_vers=4 tells nfsd to not register with rpcbind.
While here, add a check for "load_kld nfsd" failing to nfsd.

Reviewed by:	0mp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26938
2020-11-06 16:33:42 +00:00
Stefan Eßer 08867050c9 Replace literal uses of /usr/local with a variable
The variable defaults to "/usr/local", unless sysctl returns some other
value for "user.localbase".

The value of user.localbase defaults to _PATH_LOCALBASE as defined in
paths.h and thus this commit has no immediate effect.

The purpose of this change is to make /etc/defaults/rc.conf automatically
use the value of _PATH_LOCALBASE when not set to the default value.

Reviewed by:	imp, scottl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D27014
2020-11-03 12:29:10 +00:00
Mateusz Piotrowski 0cadbd6cd2 rc.d/zfs: Add shutdown to KEYWORDS
The problem is that Without walling /etc/rc.d/zfs on shutdown, resources
associated with ZFS mounts are not freed and the jails will remain in dying
state. In addition, the dataset is now in a dangling state, as the jail it
is attached to is dying.

A known workaround for jails was to add the following lines
to /etc/jail.conf, to make sure that "service zfs stop" is run
when the jail is stopped:

    exec.stop = "/bin/sh /etc/rc.shutdown";
    exec.stop += "/usr/sbin/service zfs stop || /usr/bin/true";

While the workaround seems to be okay-ish for the jail situation, it is
still unclean. However, for physical hosts this may wreak havoc with the
pool if shared spares are used, as "zfs unshare" is never invoked on
shutdown.

PR:		147444
Submitted by:	Markus Stoff <markus__stoffdv_at>
Reported by:	Mykah <mburkhardt__exavault_com>
Reviewed by:	cy
Approved by:	cy (src)
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D27039
2020-11-03 10:02:52 +00:00
Ed Maste 98b04ac359 rc.d/syscons: remove spaces before tab 2020-10-25 18:27:21 +00:00
Cy Schubert bd0e0447cb Destroy cloned interfaces at netif stop, netif restart and shutdown.
This is especially important during shutdown because a child interface
of lagg with WOL enabled will not enable WOL at interface shutdown and
thus no WOL to wake up the device (and machine).

PR:		158734, 109980
Reported by:	Antonio Huete Jimenez <tuxillo at quantumachine.net>
		Marat N.Afanasyev <marat at zealot.ksu.ru>
reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26797
2020-10-19 20:37:38 +00:00
Pawel Biernacki 9ef9175912 [pf] /etc/rc.d/pf should REQUIRE routing
When a system with pf_enable="YES" in /etc/rc.conf uses hostnames in
/etc/pf.conf, these hostnames cannot be resolved via external nameservers
because the default route is not yet set. This results in an empty
(all open) ruleset.

Since r195026 already put netif back to REQUIRE, this change does not affect
the issue that the firewall should rather have been setup before any
network traffic can occur.

PR:		211928
Submitted by:	Robert Schulze
Reported by:	Robert Schulze
Tested by:	Mateusz Kwiatkowski
No objections from:	kp
MFC after:	3 days
2020-10-08 11:45:10 +00:00
Toomas Soome e307eb94ae loader: zfs should support bootonce an nextboot
bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25512
2020-09-21 09:01:10 +00:00
Xin LI 90802d88a5 Declare dependency relationship once instead of twice for zpool
and zvol.
2020-09-05 00:45:46 +00:00
Xin LI 0cd669785d Make zpool on GELI work again.
After OpenZFS import, zpool auto import behavior was moved to an
explicit "zpool import -a", and the zpool rc.d script was added
as a prerequisite of zvol.

However, in r299839, zvol was added as a prerequisite of dumpon,
making it to start very early and before all 'disks' providers.
At this time, dumping on a zvol is not supported, so remove this
requirement and make zpool depend on disks to allow zpool on
full disk encryption work.

Reviewed by:		allanjude
Differential Revision:	https://reviews.freebsd.org/D26333
2020-09-04 23:36:43 +00:00
Cy Schubert a784185078 /etc/zfs/zpool.cache is the preferred (and new) location of zpool.cache.
Check for it first. Only use /boot/zfs/zpool.cache if the /etc/zfs
version is not found and good.

Reported by:	avg
Suggested by:	avg, kevans
2020-08-27 14:33:46 +00:00
Cy Schubert f1602aff80 To avoid breakage for those who build/install without ZFS only
rely on rc.d/zpool's BEFORE specification.

Reported by:	rpokala
2020-08-26 20:30:00 +00:00
Cy Schubert 74e2b24f2c As of r364746 (OpenZFS import) existing ZPOOLs are not imported
prior to zvol and mountcritlocal resulting in ZVOLs (swap and
virtual machine UFS filesystems) being unavailable, leading to
boot failures.

We move the zpool import from zfs to a new zpool script, with the
-N option to avoid mounting datasets while making the ZPOOL's
datasets available for "legacy" mount (mountpoint=legacy) and ZVOLs
available for subsequent use for swap (in the zvol rc sript) or
for UFS or other filesystems in fstab(5), mounted by mountcritlocal.

Reviewed by:		freqlabs (previous version)
Differential Revision:	https://reviews.freebsd.org/D26185
2020-08-26 13:13:57 +00:00
Matt Macy 9e5787d228 Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.

I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.

Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.

Improvements include:
  project quotas, encrypted datasets,
  allocation classes, vectorized raidz,
  vectorized checksums, various command line
  improvements, zstd compression.

Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.

Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
Cy Schubert 51da4b19be When booting a system with WITHOUT_IPFILTER the following errors
are encountered at boot time:

rcorder: requirement `ipfs' in file `/etc/rc.d/netif' has no providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/netif' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/netwait' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/net_watchdog' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/securelevel' has no
providers.

Listing its own requrements in BEFORE rather than use REQUIRE of
non-optional scripts resolves this issue.

The issue was discovered and patched by glebius at Netflix.

Submitted by:	glebius
Reported by:	glebius
MFC after:	1 week
2020-08-11 23:36:38 +00:00
Cy Schubert 795be686d8 Load ipfilter, ipnat, and ippool rules, and start ipmon in a vnet jail.
PR:		248109
Reported by:	joeb1@a1poweruser.com
MFC after:	2 weeks
2020-07-23 17:39:45 +00:00
Mark Johnston 7df88b9ddd rc.firewall: Merge two identical conditions into one.
No functional change intended.

PR:		247949
Submitted by:	Jose Luis Duran <jlduran@gmail.com>
MFC after:	1 week
2020-07-23 15:03:28 +00:00
Simon J. Gerraty f2be828f97 Revert that! 2020-07-19 23:56:19 +00:00
Simon J. Gerraty e17f5b1d30 Oops missed Makefile.config 2020-07-19 23:54:00 +00:00
Allan Jude fb6b5cd016 Remove excess spaces from rc.d scripts
The space between words is already being echoed by the space between quoted strings:

    % echo 'foo' 'bar'
    foo bar

    % echo 'foo' ' baz'
    foo  baz

Found in `ipfw` and `mountlate` messages.

PR:		247948
Submitted by:	Jose Luis Duran <jlduran@gmail.com>
MFC after:	2 weeks
Sponsored by:	Klara Inc.
2020-07-13 13:44:54 +00:00
Edward Tomasz Napierala 6ef8f9d28a Make the linux rc script use linrdlnk by default.
This fixes Linux gettyname(3), with caveats (see PR).

PR:		kern/240767
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25558
2020-07-04 18:01:29 +00:00
Mateusz Piotrowski e1cd6f7986 Remove ldconfig_paths_aout from rc.conf after r362543
Approved by:	imp
Differential Revision:	https://reviews.freebsd.org/D25415
2020-06-23 18:35:00 +00:00
Ed Maste aa5e1b42e6 ldconfig: remove i386 aout invocation
aout support in ldconfig hasn't been required since FreeBSD 2.x.

Anyone still using FreeBSD 2 shared libraries can use a FreeBSD 2
ldconfig to generate aout ldconfig hints.

Reviewed by:	dim, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24883
2020-06-23 15:36:05 +00:00
Eugene Grosbein 064dde3efe network.subr: unobsolete gif_interfaces
There are cases when gif_interfaces cannot be replaced
with cloned_interfaces, such as tunnels with external IPv6 addresses
and internal IPv4 or vice versa. Such configuration requires
extra invocation of ifconfig(8) and supported with gif_interfaces only.

MFC after:	1 week
2020-06-22 17:25:21 +00:00
Colin Percival 3cc620328f Move the devmatch rc.d script before netif in the boot process.
Prior to this change, using lagg to aggregate wired and wireless networks
was broken in the (relatively common) case where wifi drivers + firmware
are loaded by devmatch, since the interface didn't exist at the time when
the lagg interface was being created.

Suggested by:	imp
MFC after:	3 days
2020-05-16 18:37:48 +00:00
Cy Schubert 12de77b3db Due to popular demand, revert r360102.
Reported by:	many
2020-04-19 21:38:03 +00:00
Cy Schubert 4574585e8f Conditionally install Kerberos rc files based on MK_KERBEROS_SCRIPTS
instead of MK_KERBEROS. The reason for this change is some users
prefer to build FreeBSD WITHOUT_KERBEROS, wanting to retain the
Kerberos rc scripts to start/stop MIT Kerberos or Heimdal from ports.

PR:		197337
Reported by:	Adam McDougall <ebay at looksharp.net>
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D24252
2020-04-19 17:01:21 +00:00
Mateusz Piotrowski 3e58608634 sshd: Warn about missing ssh-keygen only when necessary
The sshd service is using ssh-keygen to generate missing SSH keys.
If ssh-keygen is missing, it prints the following message:

> /etc/rc.d/sshd: WARNING: /usr/bin/ssh-keygen does not exist.

It makes sense when the key is not generated yet and
cannot be created because ssh-keygen is missing.

The problem is that even if the key is present on the host,
the sshd service would still warn about missing ssh-keygen
(even though it does not need it).

Reviewed by:	emaste
Approved by:	emaste (src)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D23911
2020-04-15 14:07:33 +00:00
Baptiste Daroussin fdf46c24f0 Revert r359294 per manu's request
It breaks etcupdate

Reported by:	cy
2020-03-25 08:35:55 +00:00
Emmanuel Vadot 77f0f1df8b pkgbase: Stop threating rc files as config files
rc scripts arent configuration files so use FILES instead of CONFS.
While here put rc scripts into related package (sendmail in the FreeBSD-sendmail
package, wpa_supplicant in the FreeBSD-wpa etc ...)

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D24177
2020-03-25 01:36:23 +00:00
Alexander V. Chernikov 7119cdc225 Make ICMP redirect processing depend on routing daemon.
Submitted by:	 lutz at donnerhacke.de
Reviewed by:	melifaro,rgrimes
Differential Revision:	https://reviews.freebsd.org/D23329
2020-03-23 15:27:10 +00:00
Leandro Lupori e9f87d29a8 Add fsck_flags config option
On UFS with SU+J, sometimes fsck's default recovery from journal marks the
filesystem as clean but some errors remain.

With SU only, default fsck in preen mode sometimes thinks all errors have
been fixed but some still remain.

To address the issues above, this change adds a new config option:
fsck_flags.  By default it's set to -p, but the user may change it to -y
or -f -y, for instance, to force a full fsck after a system crash.

Submitted by:	jhibbits@ (original version)
Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D24087
2020-03-18 13:09:47 +00:00
Hiroki Sato d80eccfc98 Remove /etc/host.conf, which was automatically generated from
nsswitch.conf for backward compatibility.  This file was used
over 19 years ago, before introducing nsdispatch() in the
name-service lookup APIs.

MFC after:	3 days
2020-03-18 08:17:24 +00:00
Ed Maste 13f7dbe822 retire amd(8)
autofs was introduced with FreeBSD 10.1 and is the supported method for
automounting filesystems.  As of r296194 the amd man page claimed that it
is deprecated.  Remove it from base now; the sysutils/am-utils port is
still available if necessary.

Discussed with:	cy
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2020-03-09 20:46:43 +00:00
Ryan Libby 28c0abcebb auditd_stop: wait_for_pids instead of sleeping
It's faster and more reliable to wait_for_pids than to sleep 1.

cem@ suggested just to remove auditd_stop() and use the rc.subr default
stop action (SIGTERM instead of audit -t), which has a built-in
wait_for_pids.  That may be a better solution.

Discussed with:	cem
Reviewed by:	asomers
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23223
2020-02-06 08:32:30 +00:00
Eugene Grosbein 4c6076088a libexec/rc/rc.d/ipfw: style fix after r356943
Also, make sure it does not break for systems without ipfw code loaded.

MFC after:	1 months
X-MFC-with:	356943
2020-01-21 17:16:02 +00:00
Eugene Grosbein 7d82194866 Correct "service ipfw status" for INET6-only systems.
MFC after:	1 month
2020-01-21 17:02:57 +00:00
Bjoern A. Zeeb 1459a8eb24 Run netoptions startup script in vnet jails.
People use rc.conf inside vnet jails to configure networking setups.
Presumably because some sysctl were not virtualised up until r356527 the
script was not run for vnet jails leaving the rc.conf options without
effect for non-obvious reasons.  Run the netoptions startup script also
for VNET jails now to make the rc.conf options work.

PR:		243193
MFC after:	2 weeks
2020-01-08 23:34:50 +00:00
Ed Maste 7424699c9f rc.shutdown: kill shutdown process after logging message
Move the kill -KILL $$ back to the pre-r354446 location at the end of
the shutdown timeout handler.

MFC with:	r354446
2019-12-07 00:33:08 +00:00
Warner Losh f86e60008b Regularize my copyright notice
o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
  All Rights Reserved on same line as other copyright holders (but not
  me). Other such holders are also listed last where it's clear.
2019-12-04 16:56:11 +00:00
Mateusz Guzik 9da3dfff9a ldconfig: fetch hw.machine_arch only once
This happens to be of significance with poudriere which runs the script a lot
when installing packages.
2019-11-30 17:30:01 +00:00
Ian Lepore 735c001b6b Allow opt-out of automatic ntpd leapfile checking/fetching.
When a system has no internet connection, or when it is configured to obtain
ntpd leapfiles from some source other than the internet, or even when the
sysadmin has decided for some reason to customize ntp.conf to eliminate use
of the leapfile, the rc.d/ntpd script emits various error messages related
to the file.

This change allows setting the rc var ntp_db_leapfile to NONE to disable all
automatic processing related to that file in rc.d/ntpd.

Differential Revision:	https://reviews.freebsd.org/D22461
2019-11-25 19:59:53 +00:00
Warner Losh 6467506baf Create /etc/os-release file.
Each boot, regenerate /var/run/os-release based on the currently running
system. Create a /etc/os-release symlink pointing to this file (so that this
doesn't create a new reason /etc can not be mounted read-only).

This is compatible with what other systems do and is what the sysutil/os-release
port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
implement this natively as well. The complete standard can be found at
https://www.freedesktop.org/software/systemd/man/os-release.html

Moving this to the base solves both the non-standard location problem with the
port, as well as the lack of update of this file on system update.

Bump __FreeBSD_version to 1300060

PR: 238953
Differential Revision:  https://reviews.freebsd.org/D22271
2019-11-20 23:45:31 +00:00
Edward Tomasz Napierala 5dece9b25a Add 'linux_mounts_enable' rc.conf(5) variable, to make it possible
to disable mounting Linux-specific filesystems under /compat/linux
when 'linux_enable' is set to YES.

Reviewed by:	netchild, ian (earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22320
2019-11-13 20:27:38 +00:00
Edward Tomasz Napierala c13f19c0cf Extend the linux rc script to mount the neccessary file systems,
set ELF fallback brand, and load pty(4).

Reviewed by:	emaste (earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21874
2019-11-07 18:15:24 +00:00
Ed Maste 4a76bd99ac rc.shutdown: print a newline before watchdog timeout message
Previously the watchdog timeout message was appended to the last entry
in the "Waiting for PIDS" list, resulting in a message like

    Waiting for PIDS: 31299 31296 90201 9020090 second watchdog timeout
    expired. Shutdown terminated.

Print a newline to separate the watchdog timeout message.  Also perform
the kill before logging or echoing the message.

PR:		241072
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2019-11-07 15:48:46 +00:00
Cy Schubert e5f2f48e62 Remove trailing tab.
MFC after:	3 days
2019-10-27 18:27:25 +00:00
Edward Tomasz Napierala ee0ee18c9c Add rcvar back to the linux rc script. Without it it was enabled
unconditionally.

Reported by:	Michael Butler <imb at protected-networks dot net>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-10-03 16:38:44 +00:00
Andriy Gapon 5fda0d60c1 add ability to set watchdog timeout for a shutdown
This change allows to specify a watchdog(9) timeout for a system
shutdown.  The timeout is activated when the watchdogd daemon is
stopped.  The idea is to a prevent any indefinite hang during late
stages of the shutdown.  The feature is implemented in rc.d/watchdogd,
it builds upon watchdogd -x option.

Note that the shutdown timeout is not actiavted when the watchdogd
service is individually stopped by an operator.  It is also not
activated for the 'shutdown' to the single-user mode.  In those cases it
is assumed that the operator knows what they are doing and they have
means to recover the system should it hang.

Significant subchanges and implementation details:
- the argument to rc.shutdown, completely unused before, is assigned to
  rc_shutdown variable that can be inspected by rc scripts
- init(8) passes "single" or "reboot" as the argument, this is not
  changed
- the argument is not mandatory and if it is not set then rc_shutdown is
  set to "unspecified"
- however, the default jail management scripts and jail configuration
  examples have been updated to pass "jail" to rc.shutdown, just in case
- the new timeout can be set via watchdogd_shutdown_timeout rc option
- for consistency, the regular timeout can now be set via
  watchdogd_timeout rc option
- watchdogd_shutdown_timeout and watchdogd_timeout override timeout
  specifications in watchdogd_flags
- existing configurations, where the new rc options are not set, should
  keep working as before

I am not particularly wed to any of the implementation specifics.
I am open to changing or removing any of them as long as the provided
functionality is the same (or very close) to the proposed one.
For example, I think it can be implemented without using watchdogd -x,
by means of watchdog(1) alone.  In that case there would be a small
window between stopping watchdogd and running watchdog, but I think that
that is acceptable.

Reviewed by:	bcr (man page changes)
MFC after:	5 weeks
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D21221
2019-10-03 11:23:10 +00:00
Edward Tomasz Napierala 028af4ae67 Rename etc/rc.d/abi to etc/rc.d/linux; after moving out the SysV IPC stuff
it's entirely linux-specific.

Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21830
2019-10-02 11:40:40 +00:00
Edward Tomasz Napierala c97588b451 Move the SysV IPC stuff out of the 'abi' rc script, into a new one:
'sysvipc' - it has nothing to do with ABIs, and I'd like to later
rename 'abi' to 'linux', which better describes its purpose and also
matches the rcvar name.

Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21615
2019-09-28 09:12:41 +00:00
John-Mark Gurney 3ed737eb91 fix the article to be correct... 2019-09-16 22:48:40 +00:00
Mateusz Piotrowski d15e810db9 rc: Honor ${name}_env when a custom *_cmd is defined (e.g., start_cmd)
A user may set ${name}_env variable in rc.conf(5) in order to set additional
environment variables for a service command.  Unfortunately, at the moment
this variable is only honored when the command is specified via the command
variable. Those additional environment variables coming from ${name}_env
are never set if the service is started via the ${rc_arg}_cmd variable (for
example start_cmd).

PR:		239692
Reviewed by:	bcr, jilles
Approved by:	src (jilles)
Differential Revision:	https://reviews.freebsd.org/D21228
2019-09-05 14:52:22 +00:00
Emmanuel Vadot 8c15be73b6 pkgbase: Move rc scripts and related files to their own packages
It doesn't need to be in runtime and might help people who want to
experiment with other rc system or don't use one (like in small
embedded mfsroot).

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D21499
2019-09-05 14:08:45 +00:00
Conrad Meyer 2826da432c motd: Generate from template to /var/run
Update login(1), its manual pages, similar utilities, and motd.5 to refer to
the new location.

Suggested by:	delphij@ (re: r349256)
Reviewed by:	bcr (manpages), delphij
Differential Revision:	https://reviews.freebsd.org/D20721
2019-07-20 20:56:31 +00:00
Emmanuel Vadot 9553ea80a8 pkgbase: Add a FreeBSD-bluetooth package
Move the bluetooth related files from FreeBSD-runtime to a new package named
FreeBSD-bluetooth
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and bluetooth isn't needed for that.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20959
2019-07-19 15:10:03 +00:00
Ian Lepore 1e121c3ef1 Limit access to system accounting files.
In 2013 the security chapter of the Handbook was updated in r42501 to
suggest limiting access to the system accounting file [*1] by creating the
initial file with a mode of 0600. This was in part based on a discussion in
the forums [*2]. Unfortunately, this advice is overridden by the fact that a
new file is created as part of periodic daily processing, and the file mode
is set by the rc.d/accounting script.

These changes update the accounting script to create the directory with mode
0750 if it doesn't already exist, and to create the daily file with mode
0640. This limits write access to root only, read access to root and members
of wheel, and eliminates world access completely. For admins who want to
prevent even members of wheel from accessing the files, the mode of the
/var/account directory can be manually changed to 0700, because the script
never creates or changes that directory if it already exists.

The accounting_rotate_log() function now also handles the error cases of no
existing log file to rotate, and attempting to rotate the file multiple
times (.0 file already exists).

Another small change here eliminates the complexity of the mktemp/chmod/mv
sequence for creating a new acct file by using install(1) with the flags
needed to directly create the file with the desired ownership and
modes. That allows coalescing two separate if checkyesno accounting_enable
blocks into one.

These changes were inspired by my investigation of PR 202203.

[1] https://www.freebsd.org/doc/handbook/security-accounting.html
[2] http://forums.freebsd.org/showthread.php?t=41059

PR:		202203
Differential Revision:	https://reviews.freebsd.org/D20876
2019-07-13 16:07:38 +00:00
Conrad Meyer cd07b6eddc rc.d/motd: Update motd more robustly
Use appropriate fsyncs to persist the rewritten /etc/motd file, when a
rewrite is performed.

Reported by:	Jonathan Walton <jonathan AT isilon.com>
Reviewed by:	allanjude, vangyzen
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20701
2019-06-21 02:37:54 +00:00
Cy Schubert 2b951e9c6d Allow the hostapd program to be specified. This allows users to use
hostapd from ports instead of the one in base. The default is the hostapd
in base.

PR:		238571
MFC after:	1 week
2019-06-17 20:11:02 +00:00
Conrad Meyer f0e5d3ff8e /etc/rc.d/local: Fix typo in description
PR:		238448
Submitted by:	Marián Černý <majo-bugs.freebsd.org AT cerny.sk>
2019-06-10 13:34:18 +00:00
Emmanuel Vadot 39fb10372c pkgbase: Remove etc/zfs from being packaged
This is an empty directory and it cause a FreeBSD-zfs package to
be created when we don't need one.

Reviewed by:	bapt
2019-05-23 06:53:59 +00:00
Ian Lepore 9c6dc2fec5 Remove accidentally-added blank line; the style throughout this file
is to use no whitespace between a comment block and the code it describes.
2019-05-23 01:49:08 +00:00
Ian Lepore a2119d62c0 Handle the driftfile option correctly when ntpd_flags is empty.
The logic I originally wrote to detect whether a driftfile option was in the
set of flags was based on the result of removing the pattern *flag* being an
empty string.  That didn't handle the case where the string was empty to
begin with.  Doh!  So now it also specifically checks for an empty string.

The result of the bad check was that ntpd would run without a driftfile, but
it would do so only if it was running as root instead of the non-priveleged
ntpd user, which isn't a typical case.  Ntpd runs fine without a driftfile,
although it does take it longer to stabilize the clock frequency at startup.

Reported by:	avg@
Pointy hat:	ian@
MFC after:	some testing
2019-05-23 01:41:49 +00:00
Conrad Meyer 26c4978843 save-entropy(8), rc.d/random: Set nodump flag
Tag saved entropy files as "nodump," to signal that the files should not be
backed up by dump(8) or other automated backup software that honors the file
flag.

Do not produce an error if the target file resides on a filesystem that does
not support file flags (e.g., msdos /boot).

Reviewed by:	delphij
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20358
2019-05-22 21:47:17 +00:00
Emmanuel Vadot 19dad0edbe pkgbase: Really move rc.sendmail
Messed up with git->svn in r348100
2019-05-22 07:40:39 +00:00
Emmanuel Vadot 410304e347 pkgbase: Really move rc.bsdextended
Messed up with git->svn in r348099
2019-05-22 07:39:59 +00:00
Emmanuel Vadot 5d8c2d4c4f pkgbase: Really move rc.firewall
Messed up with git->svn in r348098
2019-05-22 07:38:54 +00:00
Emmanuel Vadot 424383210b pkgbase: Move rc.sendmail to libexec/rc
Reviewed by:	bapt
2019-05-22 07:22:08 +00:00
Emmanuel Vadot f4022639ae pkgbase: Move rc.bsdextended to libexec/rc
Reviewed by:	bapt
2019-05-22 07:21:39 +00:00
Emmanuel Vadot f0f0053abc pkgbase: Move rc.firewall to libexec/rc
Put it with all the other rc files

Reviewed by:	bapt
2019-05-22 07:21:05 +00:00
Brooks Davis ffda67901e Change ed(4), ep(4), and fxp(4) examples to em(4).
ed(4) and ep(4) have been removed. fxp(4) remains popular in older
systems, but isn't as future proof as em(4).

Reviewed by:	bz, jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D20311
2019-05-18 21:01:36 +00:00
Andrey V. Elsukov 51d97e1b23 Add ipsec.ko to required_modules for rc.d/ipsec script.
Thus it can be automatically loaded if ipsec_enable="YES" and option IPSEC
is not in the kernel config.

MFC after:	1 week
2019-05-06 08:30:53 +00:00
Lev A. Serebryakov 26e8ed624e Make mdmfs verbose if diskless boot is verbose.
Approved by:	ian@
Differential Revision:	D17104
2019-04-26 14:44:50 +00:00
Chris Rees b11974c250 Revert r346017 pending compiled-in zfs fix
PR:		237172
Approved by:	jilles
Differential Revision:	https://reviews.freebsd.org/D18670
2019-04-10 07:51:13 +00:00
Chris Rees f5dfe75da5 Remove now unnecessary kldstat check before attempting to load modules.
Since r233109, kldload has the -n option, which silently ignores options
that are already loaded.

https://lists.freebsd.org/pipermail/freebsd-rc/2018-December/003899.html

Note that this script no longer reports if the module is already loaded,
but it could be argued this wasn't particularly useful information.

PR:			docs/234248
Reviewed by:		bcr (docs), kib, rgrimes (visual)
Approved by:		jilles
Differential Revision:	https://reviews.freebsd.org/D18670
2019-04-07 18:31:45 +00:00
Andrey V. Elsukov 577640dcbc Add firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf
Reported by:	Andrey Fesenko
X-MFC after:	r345450
2019-04-06 17:21:05 +00:00
Eugene Grosbein 734b726d80 network.subr: improve configuration of cloned gif(4) interfaces
ifconfig(8) syntax allows to specify only single address_family,
so we need additional invocation of ifconfig to support configuration
of cloned gif interface that may use different address families
for its internal and external addresses.

Also, ifconfig(8) does not allow to omit "inet6" keyword for address family
specifying IPv6 addresses as outer addresses of the interface.

Also, address_family is not "parameter" and it has to go before parameters
including "tunnel" keyword, so "ifconfig gif0 tunnel inet6 $oip1 $oip2" would be
wrong syntax and only "ifconfig gif0 inet6 tunnel $oip1 $oip2" is right.

With this change, the following works:

gifconfig_gif0="inet6 2a00::1 2a01::1"
ifconfig_gif0="inet 10.0.0.1 10.0.0.2 netmask 255.255.255.252"

MFC after:	2 weeks
2019-04-05 22:45:08 +00:00
Conrad Meyer c849485d90 random(4): Attempt to persist entropy promptly
The goal of saving entropy in Fortuna is two-fold: (1) to provide early
availability of the random device (unblocking) on next boot; and (2), to
have known, high-quality entropy available for that initial seed.  We know
it is high quality because it's output taken from Fortuna.

The FS&K paper makes it clear that Fortuna unblocks when enough bits have
been input that the output //may// be safely seeded.  But they emphasize
that the quality of various entropy sources is unknown, and a saved entropy
file is essential for both availability and ensuring initial
unpredictability.

In FreeBSD we persist entropy using two mechanisms:

1. The /etc/rc.d/random shutdown() function, which is used for ordinary
   shutdowns and reboots; and,

2. A cron job that runs every dozen minutes or so to persist new entropy, in
   case the system suffers from power loss or a crash (bypassing the
   ordinary shutdown path).

Filesystems are free to cache dirty data indefinitely, with arbitrary flush
policy.  Fsync must be used to ensure the data is persisted, especially for
the cron job save-entropy, whose entire goal is power loss and crash safe
entropy persistence.

Ordinary shutdown may not need the fsync because unmount should flush out
the dirty entropy file shortly afterwards.  But it is always possible power
loss or crash occurs during the short window after rc.d/random shutdown runs
and before the filesystem is unmounted, so the additional fsync there seems
harmless.

PR:		230876
Reviewed by:	delphij, markj, markm
Approved by:	secteam (delphij)
Differential Revision:	https://reviews.freebsd.org/D19742
2019-03-31 04:57:50 +00:00
Andrey V. Elsukov 0bd4858ed3 Add ability to automatically load ipfw_nat64, ipfw_nptv6 and ipfw_pmod
modules by declaring corresponding variables in rc.conf. Also document
them in rc.conf(5).

Submitted by:	Dries Michiels
Differential Revision:	https://reviews.freebsd.org/D19673
2019-03-23 15:41:32 +00:00
Cy Schubert 817c58e3ac The check for $ippool_rules in start_cmd is tautological.
Reported by:	hrs@
MFC after:	13 days
X-MFC with:	r345400
2019-03-23 04:32:10 +00:00
Cy Schubert 299173580f Use internal command variables for consistent style.
Reported by:	rgrimes@
MFC after:	13 days
X-MFC with:	r345400
2019-03-22 11:46:35 +00:00
Cy Schubert c297300196 From r345400, connect ippool to the build/install.
PR:		218433
MFC after:	2 weeks
X-MFC with:	r345400
2019-03-22 01:42:27 +00:00
Cy Schubert d8f9371044 Add rc.d support for ippool(8).
I've been using ippool at my site for approximately two years. It's
about time this was committed.

PR:		218433
MFC after:	2 weeks
2019-03-22 01:30:51 +00:00
Bjoern A. Zeeb 76d32f047a Fix legacy IP autoconfiguration.
It seems my subconcious plan in r345088 to not only prefer IPv6 autoconf
but to also slowly deteriorate legacy IP auto-configuration was uncovered
way too early.

In case IPv6 is a thing yet ipv6_autoconfif was not true, we would not
bring up the interface yet tell the follow-up DHCPv4 configuration in
ifconfig_up() that we did.  So unless you were doing SYNCDHCP or IPv6
you would not get legacy-IP DHCPv4 configuration.

I see multiple problems here: (a) people not yet using IPv6 (obviously a
problem), and (b) the dhclient startup script not running dhclient in
that case despite configured to do so (needs to be investigated seperately).

Reported by:	Pawel Biernacki (pawel.biernacki gmail.com)
Tested by:	Pawel Biernacki
Differential Revision:	https://reviews.freebsd.org/D19488
Pointyhat to:	bz (not sure if it is for breaking or
		for letting them notice it so easily)
2019-03-17 09:31:09 +00:00
Bjoern A. Zeeb 1b5be7204e Enhance IPv6 autoconf startup.
Before this change we would only run rtsol on an interface which was
set to accept_rtadv and did not have rtsold enabled.  This change
removes the latter condition and always runs rtsol (rather than the
deferred rtsold) to reduce the delay until we send the first RS.

This change will also handle the accept_rtadv before dhcp hence
starting IPv6 auto-configuration before IPV4 DHCP.

This change is intended for FreeBSD 13 and later only and will not be MFCed.

Reviewed by:		hrs
Differential Revision:	https://reviews.freebsd.org/D19488
2019-03-13 17:00:15 +00:00
Benedict Reuschling 1b35da5af7 Extend descriptions and comments about the need to create /etc/pf.conf.
FreeBSD removed the default /etc/pf.conf file in previous releases, but
the documentation kept mentioning it like any other file present in the
system.  Change pf.conf(5) to mention in the description of the default
ruleset location that this file needs to be created manually. Also, the
default rc.conf file had it's comment extended a bit to let people know
that this file does not exist by default.

PR:		    231977
Submitted by:	    koobs@
Reviewed by:	    kp@, 0mp@
Approved by:	    kp@
MFC after:	    10 days
Differential Revision:	https://reviews.freebsd.org/D19530
2019-03-12 20:08:37 +00:00
Cy Schubert 77e6f9282e Fix still installing ipfilter rc.d files even when WITHOUT_IPFILTER
is specified.

When WITHOUT_IPFILTER is specified, delete-old-files fails to delete
the optional rc.d files from above. Fix this.

WITHOUT_IPFILTER fails to delete the ipfilter.5 optional file during
delete-old-files. Fix this.

Reported by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2019-03-12 19:34:33 +00:00
Kurt Lidl c65b552f89 Remove an unneeded 'tail -n 1' from a pipeline
When piping to awk, it's almost always an anti-pattern to use 'grep'
first.

When not in a pipeline, sometimes it is faster to use tail, as awk
must process all the lines in the input stream, and won't 'seek'.
In a pipeline, both grep and awk must process all lines, so we might
as well skip the extra process creation for tail and just use awk
for all the processing.

Reviewed by:	jilles
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19441
2019-03-11 13:33:03 +00:00
Sean Eric Fagan 025816d9ce Add support for a virtual hostname to nfsd
Specifically, this allows (via "-V vhostname") telling nfsd what principal
to use, instead of the hostname.  This is used at iXsystems for fail-over in
HA systems.

Reviewed by:	macklem
Sponsored by:	iXsystems Inc.
Differential Revision:	https://reviews.freebsd.org/D19191
2019-02-16 00:15:54 +00:00
Colin Percival efed7c6db7 Teach /etc/rc.d/growfs how to handle systems running ZFS.
There are many cases which this code does not handle (e.g. ZFS mirrors)
but the code can handle the single-disk case -- so it's enough to take
care of the "disk image which gets booted into a VM with a larger than
expected disk" case for which this firstboot script was created.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D19095
2019-02-08 19:19:31 +00:00
Andriy Voskoboinyk 1a7c1b2cbc rc(8): do not stop dhclient(8) when wpa_supplicant(8) / hostapd(8) is used
They will stop it automatically ('Interface wlan0 is down,
dhclient exiting'); use /etc/rc.d/dhclient stop command only when
none of them is used.

MFC after:	5 days
2019-01-27 15:55:31 +00:00
Kyle Evans 478e7696ff rc.subr: Fix typo
Originally intended as 'in case in needs to be re-invoked', but it was later
decided (by myself) that 're-invoke itself' makes it more clear that the
script is expected to use this in a way.

Reported by:	Jose Luis Duran (jlduran @ github)
X-MFC-With:	r342792
2019-01-06 01:39:01 +00:00
Kyle Evans ac102a2a63 rc.subr: Provide rc_service variable for service scripts
Some rc scripts in ports (e.g. uwsgi, apache, openvpn) allow for
'application profiles' that usually require the rc script to be invoked
again for each active profile. Because there's no consistent way to
determine the path because it differs between manual/service(8) invocations
and /etc/rc invocations, this leads to patterns like these:

- www/uwsgi hardcodes the script path
- security/openvpn guesses either $_file or $0 based on $0 = /etc/rc

Instead of forcing rc scripts to guess, provide an rc_service variable to
the scripts that gets set appropriately both for direct execution or when a
script is being executed via run_rc_script (e.g. /etc/rc).

This is our analog of an OpenRC variable with the same name, different case
(RC_SERVICE).

PR:		234614
Reported by:	koobs
Reviewed by:	dteske, jilles
MFC after:	3 days
2019-01-05 21:23:25 +00:00
Mateusz Guzik 405c3050f1 Remove iBCS2, part1: userspace
iBCS2 was disconnected from the build in 2015 (see r291419)

bsdconfig parts submitted by dteske.

Reviewed by:	kib (previous version)
Sponsored by:	The FreeBSD Foundation
2018-12-19 21:56:54 +00:00
Alan Somers 738ea87196 Conditionally install /etc/rc.d/audit* based on ${MK_AUDIT}
/usr/sbin/audit(dist)?d are only installed if ${MK_AUDIT} == yes. Their
supporting scripts should only be installed in those instances as well.

Submitted by:	ngie
Reviewed by:	emaste
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd/pull/242
2018-12-16 23:38:46 +00:00
George V. Neville-Neil 53fc043d41 Remove, the now very outdated, timed.
Submitted by:	Kyle Spiers ksspiers at gmail
Reviewed by:	bcr,brooks,bz,sbruno
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D18505
2018-12-15 21:34:40 +00:00
Conrad Meyer b2b1708d59 rc.subr: Implement list_vars without using 'read'
'read' pessimistically read(2)s one byte at a time, which can be quite
silly for large environments in slow emulators.

In my boring user environment, truss shows that the number of read()
syscalls to source rc.subr and invoke list_vars is reduced by something like
3400 to 60.  ministat(1) shows a significant time difference of about -71%
for my environment.

Suggested by:	jilles
Discussed with:	dteske, jhb, jilles
Differential Revision:	https://reviews.freebsd.org/D18481
2018-12-11 01:38:50 +00:00
Cy Schubert d19c1c8ec2 Allow forced start of ipmon in special cases where testing is desired
(or other special cases) and when ipfilter is disabled in rc.conf but
started by other means.

MFC after:	1 week
2018-11-22 04:48:27 +00:00
Eugene Grosbein 7b3c65ba1c Move definition of $jail_conf variable to /etc/defaults/rc.conf
from jail startup script so it can be successfully queried
with the command "sysrc jail_conf".

MFC after:	1 month
2018-11-10 14:11:54 +00:00
Dag-Erling Smørgrav caa0408fa8 Run unbound-anchor when root.key is empty, not just when it is absent.
PR:		232555
Submitted by:	Ari Suutari <ari@stonepile.fi>
MFC after:	3 days
2018-11-01 14:24:12 +00:00
Devin Teske da45b4da83 Add new rc keywords: enable, disable, delete
This adds new keywords to rc/service to enable/disable a service's
rc.conf(5) variable and "delete" to remove the variable.

When the "service_delete_empty" variable in rc.conf(5) is set to "YES"
(default is "NO") an rc.conf.d file (in /etc/ or /usr/local/etc) is
deleted if empty after modification using "service $foo delete".

Submitted by:	lme (modified)
Reviewed by:	0mp (previous version), lme, bcr
Relnotes:	yes
Sponsored by:	Smule, Inc.
Differential Revision:	https://reviews.freebsd.org/D17113
2018-10-31 20:37:12 +00:00
Eugene Grosbein b25a469f94 rcorder(8): add support for /etc/rc.resume, so it calls "rcorder -k resume"
and runs scripts containing "KEYWORD: resume" with single "resume" argument.

Working example is the port sysutils/cpupdate that defines
extra_commands="resume" to reload CPU microcode cleared
by suspend/resume sequence.

This change does nothing for a system having no scripts with KEYWORD: resume.

MFC after:		1 month
Differential Revision:	https://reviews.freebsd.org/D15247
2018-10-27 17:21:13 +00:00
Dag-Erling Smørgrav 59c38254d7 Add default value for local_unbound_tls + fix nearby style bugs.
Reported by:	bcran@
MFC after:	3 days
2018-10-27 09:34:33 +00:00
Gleb Smirnoff 90809c673e Remove code that is dead since r287197. Today wlan(4) interfaces aren't
children of some other interface. Creation happens only in wlan_up().
2018-10-24 20:49:51 +00:00
Eugene Grosbein 707a657cbf rc.initdiskless: fix commentary grammar after r339465
MFC after:	1 month
2018-10-20 18:46:36 +00:00
Eugene Grosbein b4d24263c2 rc.initdiskless: add support for auxiliary NVRAM.
Currently, rc.inidiskless assumes that local system configuration
changes are kept in some mountable file system. For example,
nanobsd uses dedicated partition mounted as /cfg for this.

However, small embedded devices like MIPS routers may have no enough flash
space to keep full-blown file system but have only one or couple
small flash blocks to keep persistent local configuration overrides.

This change extends rc.initdiskless and introduces ability to run auxiliary
command /conf/T/M/extract that is supposed to extract configuration overrides
from such local storage.

For example, the command /conf/default/etc/extract may contain something like:

cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

bsdcpio command extracts compressed archive from the storage to /etc
assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

PR:		204215
MFC after:	1 month
2018-10-20 18:13:51 +00:00
Eugene Grosbein 3c36368a15 Make upgrade from previous FreeBSD versions less painful
and make previously working configuration like this work again:

gif_interfaces="gif0"
gifconfig_gif0="1.1.1.1 2.2.2.2"
ifconfig_gif0="inet 192.168.1.1 192.168.1.2 netmask 255.255.255.252"

PR:		204700
MFC after:	1 month
2018-10-20 18:01:48 +00:00
Dag-Erling Smørgrav c51198361b The local_unbound service will configure and bootstrap itself, but only
if a network connection is available.  This is not an issue when running
'service local_unbound setup' interactively, but can be on a diskless
system where local_unbound self-configures on every boot.  To address
this, add explicit dependencies on netwait and defaultroute.

Submitted by:	eugen
Approved by:	re (gjb)
2018-10-18 18:33:44 +00:00
Dag-Erling Smørgrav d0d49703a5 Add support for DNS-over-TLS to the local_unbound service.
Approved by:	re (kib)
2018-10-18 15:35:13 +00:00
Bjoern A. Zeeb c35b07d1cb While preparing to move init(8) to its own package as indicated
in r339413, a current pkgbase update problem came up.  For users
testing pkgbase at the moment there is no (automatic) way to pick
up new base packages (yet).
As a result rather than also moving init(8) to its own package,
back out the part of the change in r339413 that moved rc* to its
own package and defer creating new packages until the
infrastructure is in place to handle these cases.
Both init and rc* are considered too problematic to be lost by
early adaptors at this stage.

Discussed with:		brd
Reviewed by:		brd
Approved by:		re (gjb)
2018-10-18 02:07:30 +00:00
Bjoern A. Zeeb 0696600c41 Move the rc framework out of sbin/init into libexec/rc.
The reasons for this are forward looking to pkgbase:
 * /sbin/init is a special binary; try not to replace it with
   every package update because an rc script was touched.
   (a follow-up commit will make init its own package)
 * having rc in its own place will allow more easy replacement
   of the rc framework with alternatives, such as openrc.

Discussed with:		brd (during BSDCam), kmoore
Requested by:		cem, bz
PR:			231522
Approved by:		re (gjb)
2018-10-17 16:49:11 +00:00