5396 Commits

Author SHA1 Message Date
Franco Fichtner
b7f34d02eb ipsec: mute ipsec.conf related load errors
PR: https://forum.opnsense.org/index.php?topic=33126.0
2023-11-15 20:45:04 +01:00
Franco Fichtner
29d456e877 interfaces: uasort() is required, key was binding address 2023-11-11 09:22:09 +01:00
Franco Fichtner
0adf8a2bb0 interfaces: prefer GUAs over ULAs when returning addresses
The concept is a bit convoluted, but apparently better than
ignoring the fact that a ULA cannot replace a GUA ever.

PR: https://forum.opnsense.org/index.php?topic=36893.0
2023-11-10 13:37:08 +01:00
Franco Fichtner
239ec1a382 interfaces: comma 2023-11-09 12:20:37 +01:00
Stephan de Wit
af3c8669e6 interfaces: add wireguard to list of virtual interfaces 2023-11-09 11:12:10 +01:00
Franco Fichtner
89f8807515 interfaces: code style 2023-11-08 15:19:31 +01:00
Ad Schellevis
b25ea1c4b8 Kea / Dhcp - DHCPv4 replacement, missing service validation for https://github.com/opnsense/core/issues/6971 2023-11-07 16:13:40 +01:00
Franco Fichtner
b787a35c8e plugins: allow special selector for plugins_configure()
Since pluginctl tells us which plugins are hooking into the
configure facilities allow us to select the plugin directly
like so:

    # pluginctl vpn:wireguard

We use the delimiter ":" here as the configure already uses
it in the function end and it's unlikely used in a file name.
Both plugins_configure() and plugctl have no room to stuff
an optional argument somewhere, but the good thing is pluginctl
does not even need support for this and the PHP code could
use it too.

Make sure nobody gets the idea to do path traversal so strip
all "." and "/" characters.
2023-11-07 12:48:14 +01:00
Franco Fichtner
1b10075eb8 system: provide mismatching logic without reboot
Also push through the locking in this case to be able to audit.
2023-11-07 11:04:46 +01:00
Franco Fichtner
f0c7f0439c system: extend restore to be able to migrate 2023-11-07 11:04:46 +01:00
Franco Fichtner
303e5958a2 system: add SHA-512 password hash compliance switch; closes #6966
While here increase the cost of BCRYPT and align the auth_log()
function a bit to be used in auth.inc where it should have lived
in the first place.
2023-11-07 10:00:45 +01:00
Ad Schellevis
ebc8e34b15 Gateways: Single: Migrate to MVC - rework datastorage layer.
This commit moves the default logic into the model so we can reflect current values into virtual fields.
For all relevant "dpinger" fields, we reflect the current value in a field named current_$field, which means we can always query the active value without touching the stored one. Determination of current is as easy as `!empty(model_value) ? model_value : default`.

Refactor the dpinger process to use the current_ fields, since "dpinger_status()" retrieves all instances including the ones not stored, safeguard the config properties to exclude status determination (as loss and latency fields don't exist).

Previously the validation messages seemed to miss some gettext(), re-add these as well and cleanup validation. By calling isFieldChanged() on the array type, we know the gateway object has changed, but not exactly which field, this might lead to some noise, but if we implement a fix for https://github.com/opnsense/core/issues/6978 , we should be able to avoid real issues with the bonus of needing less code.

The calculateCurrent() on the GatewayField ensures we can insert/update the current values after an update as these are nog aware of modifications automatically.

Finally, respect the 120 character screen limit.
2023-11-04 17:47:58 +01:00
Stephan de Wit
2fb2ae85fd Gateways: Single: Migrate to MVC - part 2: Do not persist dpinger defaults 2023-11-02 11:29:25 +01:00
Franco Fichtner
a55b4c8b22 firmware: invalidate caches earlier since certctl blocks this longer now 2023-11-02 09:39:20 +01:00
Stephan de Wit
f213bf2833
Gateways: Single: Migrate to MVC - part 2 (#6808)
Where the first stage primarily aims to keep the legacy handling of gateways intact, this stage does the conversion to MVC.

As part of the migration strategy, configured gateways will not be touched if the migration fails. This allows users to repair the gateways in the new situation.
2023-11-02 09:32:27 +01:00
Ad Schellevis
f90f16fc09 Kea / Dhcp - DHCPv4 replacement, initial minimal for https://github.com/opnsense/core/issues/6971
This commit contains the basic features of our new DHCPv4 server, it certainly needs additional testing as currently we only validated the configuration format is valid. The aim is to keep the json templates as simple as possible.

For now we keep the kea-control-agent disabled, we probably need it later, but we don't want to expose a listener without using it.
2023-11-01 21:24:34 +01:00
Ad Schellevis
8c2aa5d6bd util.inc - get_single_sysctl : only return '' when value not found. for https://github.com/opnsense/core/issues/6969 2023-10-31 14:28:38 +01:00
Franco Fichtner
11e76b6373 wireguard: closelog() for good measure 2023-10-31 11:31:38 +01:00
Franco Fichtner
07545a94d5 wireguard: use syncconf in newwanip event
setconf can fail for DNS resolution reasons.  It is being considered
a configuration parsing error so nothing gets set on the instance.
However, our code remembers that the instance was fully set up although
that is not the case.  The newwanip event was handling DNS renew but
does not understand that the configuration is not complete.

Replacing reresolve-dns.py by doing syncconf works, but this is used
as a cron-based script and likely does the job it is intended for.

Instead rehook the newwanip event into a simple syncconf invoke which
takes "more" time (according to the man page) but won't touch existing
peers being connected while still fixing any configuration mismatch
in the (possibly stale) instance.
2023-10-31 11:27:45 +01:00
Ad Schellevis
b966ab652f VPN: WireGuard - Some improvements in carp event handing for https://github.com/opnsense/plugins/issues/3579
This commit addresses a couple of possible issues.

1. When a sequence of carp events is being processed and these processes lock eachother, its possible that collected interface state via legacy_interfaces_details() doesn't match the active one anymore. To prevent this from happening, only fetch the wireguard interface we're interested in inside the lock.

2. To limit the number of events being handled in wg-service-control.php it's likely cleaner to push the vhid as well when we're handling carp events. This means that we should switch between server id (current parameter) and vhid by looking at its format.

3. In case the target (wg) interface doesn't exist, make sure to create it. Although in practice this shouldn't happen (as the stat file is being removed on boot), dropping an interface manually should preferably lead to a funcitonal setup anyway (otherwise it will crash trying to pull it up)

4. When a vhid is passed and affects the interface in question, log relevant information to syslog.
2023-10-30 18:48:01 +01:00
Franco Fichtner
b2b2c4133b firmware: clear more pkg garbage
While here serialize the background script into one as that
may be less straining on the system since we need to clean up
more now.
2023-10-30 11:37:38 +01:00
Stephan de Wit
d560e84934 dpinger: bring in remainder from gateways model conversion 2023-10-27 10:09:44 +02:00
Franco Fichtner
96b47255be firmware: fix slowness in applying firmware settings
We don't even need the full rc.configure_firmware script as that
is for after a core package was updated.  Rather we just want the
actual firmware settings to reload so we add a different path for
it.  Now it is faster than it ever was.
2023-10-26 08:56:56 +02:00
Franco Fichtner
56fdab4e0d system: make a note about rcons integration 2023-10-25 08:50:19 +02:00
Franco Fichtner
c225e122eb interfaces: more consistent naming in wireguard 2023-10-24 14:34:43 +02:00
Franco Fichtner
8228f5de5f system: need to detect a password shift from off <=> on
This doesn't check a shifting password for other technical
reasons but is more correct and fixes toggling disabled
authentication on my end.

PR: https://forum.opnsense.org/index.php?topic=36528.0
2023-10-23 11:25:45 +02:00
Franco Fichtner
845ba727c8 firmware: fix forward compat with pkg 1.20 being backwards incompatible
Ok, so now we work with 1.20 but cannot use it because we can't render
the repo file before pkg updates itself and causes it to malfunction.
That means we cannot add 1.20 before 24.1.1.

Even if we fixed our mirror to be SRV compatible two facts remain:

1. We cannot control third party mirrors which will likely all be
   plain HTTP(S).

2. pkg 1.20.x from FreeBSD will still break firewall operation and
   upgrades if left on the system so we make the situation better now
   to bite the user later on.
2023-10-20 11:59:06 +02:00
Franco Fichtner
9e9be4351f system: add trad. Chinese
It's already over 30% but needs to be vetted first.  Language
pack that includes this is 23.7.7.
2023-10-19 11:49:10 +02:00
Stephan de Wit
eecc882825 openvpn: do not flush state table on linkdown
This has the effect of killing valid states possibly unrelated to
openvpn that are propagated via pfsync
2023-10-19 09:59:47 +02:00
Franco Fichtner
7c052881fa interfaces: numbering is hard 2023-10-18 15:06:29 +02:00
Franco Fichtner
4b932622dd system: use unified style for "return preg_match" idiom so the caller receives a boolean 2023-10-18 09:52:32 +02:00
Franco Fichtner
89ee4109bc interfaces: ignore ULAs for primary IPv6 detection #6939 2023-10-18 09:49:14 +02:00
Franco Fichtner
1e86114a05 system: change wait time to 1 second per round in console
Sync both prompts to 7 seconds.  It will reduce boot wait time
from 9 + 2.5 * 5 = 21.5 seconds to 7 + 7 = 14 seconds.
2023-10-17 11:10:00 +02:00
Franco Fichtner
a224ff4a2b dhcp: sort this a little better, loosely refs #6942 2023-10-17 08:15:46 +02:00
Franco Fichtner
e0e1401f87 interfaces: add no_dad to staticv6; closes #6913 2023-10-16 15:10:03 +02:00
Franco Fichtner
0785e337e9 wireguard: different approach to bootup handling
Since we used to allow IP configuration ands VIPs are
a possibility we can avoid checking for missing IPs
and simply delete the status hash file which will
force an eventual reconfiguration.

While here avoid wireguard_prepare() from creating spurious
devices when there is no need for it as it happens with
manual invoke through "pluginctl -d wgX".  wg-service-control
uses the same logic.
2023-10-16 13:40:10 +02:00
Franco Fichtner
f0f7f6de78 system: make our certs easier to find 2023-10-13 15:06:13 +02:00
Franco Fichtner
55204f9d77 src: style sweep 2023-10-13 08:42:08 +02:00
Ad Schellevis
1bec000c1e Interfaces/neighbor - implement new neighbor configuration for arp/ndp entries closes https://github.com/opnsense/core/issues/6917
This commit adds a new component linked in Interfaces/Neighbors which offers the ability to manually register static leases and provides application control from other modules such as dhcpd. To minimize the risk, we're reusing the existing interfaces_staticarp_configure() hooks while only adjusting how static arp entries are being attached to the interface (match on addresses assigned when triggering with an interface).

Entries registered via dhcp will be visible from the ui as well together with its origin.
The previous version didn't cleanup old static entries, this version triggers a cleanup when executed for all interfaces using all earlier modifications processed via the same function (interfaces_neighbors_configure()).
2023-10-12 16:23:57 +02:00
Franco Fichtner
02b6085023 interfaces: enable IPv6 early on trackers for #6855
This seems to be required nowadays to prevent missing link-local
address until an IPv6 is assigned, then it magically works anyway.
2023-10-10 13:42:23 +02:00
Franco Fichtner
abb24e1c86 system: rewrite trust integration for certctl use
Since OPNsense 22.1 we are using FreeBSD 13 and it comes with a
base trust store which is also maintained there.  In order to be
user-configurable there is also a tool called certctl which will
manage blocking and filling the OpenSSL trust store location
/etc/ssl/certs.  The idea is to make this implicit and faster.

This, however, pseudo-obsoletes the trust bundle handling which
we mainly operate through /etc/ssl/cert.pem.  By pseudo I mean
that ports will still want the real bundles and/or know/guess
this location at complile time.  curl has such overrides for
example.

ca_root_nss's bundle is also pulled in thorough certctl so we
are going to have to jump through a few hoops now in order to
add our certificates cleanly and "prevent" breakage of the
resulting trust store.

Therefore now we write our CA content into separate files because
certctl only hashes the first certificate found in the file.
This is already a bit problematic for ca_root_nss having a
larage number of files in it...  And against all odds the
first certificate I wrote for our bundle is blacklisted by
FreeBSD which made certctl discard all OPNsense authorities
added from the GUI.

To avoid further issues with certclt as a broker here I have
added it in passthru() mode to see eventual errors clearly.

Now when certcl is done all the files are linked in the
/etc/ssl/certs directory but we actually have to build the
full bundle for compatibility with old ports requiring one
of the locations that ca_root_nss ETCSYMLINK option provides.

A shortcoming of certctl is the lack of a bundle mode for
compatibility's sake which is causing a number of problems in
the ports tree at the moment (which is why we do this work now
and take a closer look before this is rolled out in full in
FreeBSD ports).

The bundle is created by iterating over all files in /etc/ssl/certs
and putting them in the expected locations.  One caveat is that
this bloats the bundles to 1.5MB from previously 750KB.  The whole
process is a lot slower, especially certctl doing the rehash.

Long story short: this is going to cause issues in the long run,
but for now we know how it is supposed to work and are ready
for FreeBSD ports to drop support for bundles in individual ports.
But that being said we will probably drag the bundles on for
a few years anyway.
2023-10-10 08:53:46 +02:00
Franco Fichtner
f4a37d9455 interfaces: prevent sleep on pending development release
This can slow down reconfiguration of a system with many
VLAN children on a single interface down/up.  We likely
have to refactor rc.linkup to coalesce the interface
reload into a safer reload facility.
2023-10-09 19:16:39 +02:00
Franco Fichtner
6657404d93 interfaces: prevent array data from being passed 2023-10-09 12:12:03 +02:00
Franco Fichtner
4fff50b4aa interfaces: fix warning, variable not assigned 2023-10-09 11:55:11 +02:00
Franco Fichtner
fb336e334a interfaces: DAD sleep on $reload; closes #6913
This is called through rc.linkup exhibiting the issue.
Sidestep the complexity of the situation by fixing the
issue first making it testable and easy to ship in a
stable relese.

For anyone not liking this net.inet6.ip6.dad_count can
be set to "0" to disable the sleep behaviour.  This
needs to be extended one way or another.  More soon.
2023-10-09 11:47:53 +02:00
Ad Schellevis
70df688a9b VPN: WireGuard - hook wireguard empty devices during bootup, using wireguard_devices() plugin system. This should make sure services and components, such as the firewall, are able to use the device before being setup. closes https://github.com/opnsense/core/issues/6909
A minor modification was needed in wg-service-control.php to make sure a configure would be executed if wgX exists without configuration
2023-10-04 18:13:15 +02:00
Franco Fichtner
0942687097 system: fix monitor services disappearing after 1c890b8cce666 2023-10-04 07:26:02 +02:00
Franco Fichtner
1fe5395d6a system: refactor dpinger_status() 2023-10-03 21:46:51 +02:00
Franco Fichtner
c7320df459 system: fix former mishap, better to copy required values for later 2023-10-03 16:29:26 +02:00
Ad Schellevis
1c890b8cce Gateways: Single: Migrate to MVC - Import first part of https://github.com/opnsense/core/pull/6808
This commit imports part of the changes from @swhite2 which will keep the legacy handling intact for the first stage of the migration. It should be backwards compatible with the previous (23.7.x) code.

Changes new in this commit which where not in the original PR:

1) dpinger_status() missed $gwitem which rendered gateways statusses down
2) Model version number set to 0.0.1 so we can use the migration later to step into 1.0.0
3) Gateways->gatewayIterator() do not yield MVC records ensuring we are still using legacy config data when being called.
2023-10-03 15:06:22 +02:00