OPNSense/core 9e67434src/opnsense/mvc/app/library/OPNsense/Backup Base.php

system: replace exec() in config encrypt/decrypt #9325

Although these are very safe the calls are much more portable now
and this was also the last exec() in the MVC code.  Plus, Shell
class was already being used elsewhere here.
DeltaFile
+21-25src/opnsense/mvc/app/library/OPNsense/Backup/Base.php
+21-251 files

OPNSense/core 7fcfa98src/opnsense/mvc/app/library/OPNsense/System/Status LiveMediaStatus.php

system: replace exec() in live banner SSH probe
DeltaFile
+4-3src/opnsense/mvc/app/library/OPNsense/System/Status/LiveMediaStatus.php
+4-31 files

OPNSense/core 0251e29src/opnsense/mvc/app/library/OPNsense/OpenVPN ViscosityVisz.php ArchiveOpenVPN.php

openvpn: replace exec() in MVC code #9325
DeltaFile
+3-5src/opnsense/mvc/app/library/OPNsense/OpenVPN/ViscosityVisz.php
+2-5src/opnsense/mvc/app/library/OPNsense/OpenVPN/ArchiveOpenVPN.php
+5-102 files

OPNSense/core 97347afsrc/opnsense/mvc/app/controllers/OPNsense/Core/Api BackupController.php

system: replace history diff exec with shell_safe #9325
DeltaFile
+2-2src/opnsense/mvc/app/controllers/OPNsense/Core/Api/BackupController.php
+2-21 files

OPNSense/core ddcb381src/etc/inc filter.inc

firewall: remove mutes from 3 execution calls

Mute is used when we know the operation could fail but these don't
look like it and shouldn't.  In the shaper case the script even ends
using exit 0 without a set -e so that's going to be fine all the time.
DeltaFile
+3-3src/etc/inc/filter.inc
+3-31 files

OPNSense/core 685aecdsrc/etc/inc console.inc, src/opnsense/scripts/shell password.php

backend: all core now avoids direct shell_exec() calls
DeltaFile
+9-8src/opnsense/scripts/shell/password.php
+5-5src/etc/inc/console.inc
+14-132 files

OPNSense/core f6ebeeesrc/etc/inc interfaces.inc

interfaces: stop command in variable usage in wlan code

Actually transforms unsafe commands either run or embedded into the
script.  Pretty cool that we can also secure script generation with
exec_safe() ;)
DeltaFile
+5-14src/etc/inc/interfaces.inc
+5-141 files

OPNSense/core 8aa9db1. plist, src/etc/inc util.inc

backend: move exec_safe, pass_safe and shell_safe to a class #9325

Do a clean cut to a class for these functions first.  We need them in the
MVC code and this is a good opportunity to try and add them to the legacy
code via the wrappers.

The others should follow but let's settle on better names first perhaps.
DeltaFile
+71-0src/opnsense/mvc/app/library/OPNsense/Core/Safe.php
+12-32src/etc/inc/util.inc
+1-0plist
+84-323 files

OPNSense/core fbfe542src/etc/inc interfaces.inc

interfaces: clear instances of mwexec() #9325
DeltaFile
+51-43src/etc/inc/interfaces.inc
+51-431 files

OPNSense/core 42d15e4src/etc/inc/plugins.inc.d dnsmasq.inc openvpn.inc

plugins: minor mwexec(f) safety #9325
DeltaFile
+2-2src/etc/inc/plugins.inc.d/dnsmasq.inc
+1-1src/etc/inc/plugins.inc.d/openvpn.inc
+1-1src/etc/inc/plugins.inc.d/unbound.inc
+4-43 files

OPNSense/core 22b003csrc/etc/inc util.inc

backend: extend exec_safe() to allow array of format strings #9325

For years this has bothered me and the last couple of weeks I've tried
and failed to introduce something reasonable into $args handling that
can better do dynamic command generation paired with ease of use.

The irony is the solution was already in the code: $args supports arrays
and join(' ', $cmds) was used in caller code to construct the final
format string which is safe by default.

By making $format an array we can keep the separation of format and args
and are otherwise totally flexible in providing these to arrays and avoiding
any sort of ordering problems a number of other failed attempts at extending
this suffered from.
DeltaFile
+5-1src/etc/inc/util.inc
+5-11 files

OPNSense/core ceaafdbsrc/opnsense/mvc/app/controllers/OPNsense/Core/Api FirmwareController.php, src/opnsense/mvc/app/library/OPNsense/Backup Base.php

mvc: shell_safe use where needed
DeltaFile
+2-1src/opnsense/mvc/app/library/OPNsense/Backup/Base.php
+2-1src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php
+1-1src/opnsense/mvc/app/views/OPNsense/IPsec/tunnels.volt
+5-33 files

OPNSense/core 503ef42src/etc rc.routing_configure, src/etc/inc util.inc

backend: also introduce pass_safe()

All these functions are bound to take a dynamic argument at some point.
Add a few callers although by no means complete for now.
DeltaFile
+6-0src/etc/inc/util.inc
+2-2src/opnsense/scripts/shell/banner.php
+1-1src/opnsense/scripts/shell/ping.php
+1-1src/etc/rc.routing_configure
+10-44 files

OPNSense/core 4239749src/etc/inc util.inc

backend: comment
DeltaFile
+1-1src/etc/inc/util.inc
+1-11 files

OPNSense/core 1b6d23esrc/etc/inc system.inc util.inc, src/etc/inc/plugins.inc.d dhcpd.inc

backend: switch the previously touched join()s to implode()s
DeltaFile
+4-4src/etc/inc/system.inc
+2-2src/etc/inc/plugins.inc.d/dhcpd.inc
+1-1src/etc/inc/util.inc
+7-73 files

OPNSense/core 1fa97c5src/etc/inc filter.inc

firewall: mwexecf() stuff #9325

mwexecfn() is actually really good to for grepping and therefore future
audits.  Two weird spots marked anyway.
DeltaFile
+8-8src/etc/inc/filter.inc
+8-81 files

OPNSense/core 9962c5bsrc/etc/inc system.inc

system: mark these mwexec() as safe by switching to mwexecf() and a minor simplification #9325

We still have join() in there but arguments are properly fed from exec_safe().
We can clean this up later.  Historically, these parts have had a few
regressions and problems so glossing over them is not the best idea.
DeltaFile
+12-13src/etc/inc/system.inc
+12-131 files

OPNSense/core c9f4717src/opnsense/mvc/app/library/OPNsense/Core Shell.php

backend: rearrange functions in Shell class
DeltaFile
+30-28src/opnsense/mvc/app/library/OPNsense/Core/Shell.php
+30-281 files

OPNSense/core ffeea1asrc/etc/inc util.inc

system: mwexecf() for legacy service controls #9325
DeltaFile
+3-3src/etc/inc/util.inc
+3-31 files

OPNSense/core c0bfea3src/etc/inc system.inc util.inc, src/etc/inc/plugins.inc.d ipsec.inc

backend: actually do a mwexecfm() #9325

Do not do a mwexefm_bg(). Reason in the next commit.
DeltaFile
+9-9src/etc/inc/system.inc
+7-2src/etc/inc/util.inc
+3-3src/etc/inc/plugins.inc.d/ipsec.inc
+2-2src/etc/inc/auth.inc
+1-2src/sbin/carp_service_status
+1-1src/opnsense/scripts/dhcp/prefixes.php
+23-195 files not shown
+28-2411 files

OPNSense/core 4a783dfsrc/etc/inc/plugins.inc.d dhcrelay.inc

dhcrelay: use the new mwexecf() $format support #9325
DeltaFile
+12-6src/etc/inc/plugins.inc.d/dhcrelay.inc
+12-61 files

OPNSense/core f7951ffsrc/etc/inc interfaces.inc

interfaces: transform this existing change using new exec_safe() magic #9325
DeltaFile
+10-6src/etc/inc/interfaces.inc
+10-61 files

OPNSense/core b2482cbsrc/etc/inc/plugins.inc.d ipsec.inc

ipsec: mwexecf() switch audit thing #9325
DeltaFile
+6-6src/etc/inc/plugins.inc.d/ipsec.inc
+6-61 files

OPNSense/core 6e91715src/etc/inc system.inc

system: fix previous; a downside of mwexecf's parameter list ordering #9325

Maybe we should introduce a mwexecfm() for making this shorter.
DeltaFile
+4-4src/etc/inc/system.inc
+4-41 files

OPNSense/core 4e7d6c1src/etc/inc/plugins.inc.d radvd.inc

radvd: make a few security simplifications #9325
DeltaFile
+14-9src/etc/inc/plugins.inc.d/radvd.inc
+14-91 files

OPNSense/core 630816csrc/etc/inc util.inc, src/opnsense/mvc/app/library/OPNsense/Core Shell.php

backend: introduce Shell::run_safe and use it instead
DeltaFile
+31-68src/opnsense/mvc/app/library/OPNsense/Core/Shell.php
+1-16src/etc/inc/util.inc
+4-7src/opnsense/mvc/app/library/OPNsense/Trust/Store.php
+36-913 files

OPNSense/core 85e02a1. plist, src/etc/inc util.inc

backend: move Safe to Shell class

Migrate the one user in the Monit migration to shell_safe() because
that is the most appropriate here (no error code needed, just output).
DeltaFile
+0-71src/opnsense/mvc/app/library/OPNsense/Core/Safe.php
+40-0src/opnsense/mvc/app/library/OPNsense/Core/Shell.php
+4-6src/opnsense/mvc/app/models/OPNsense/Monit/Migrations/M1_0_0.php
+4-4src/etc/inc/util.inc
+0-1plist
+48-825 files

OPNSense/core 2f58a86src/opnsense/scripts/firmware/repos OPNsense.php

firmware: replace joined command with new apporach #9325
DeltaFile
+8-5src/opnsense/scripts/firmware/repos/OPNsense.php
+8-51 files

OPNSense/core 28483e4src/etc/inc interfaces.inc util.inc, src/etc/inc/plugins.inc.d dpinger.inc ipsec.inc

backend: fiddle with mwexecf_bg for #9325

Never mute a background action, also because it is used nowhere and
I cannot recall an instance where we had to mute it either.  Debug
output for backgrounding action failure is likely valuable information.
DeltaFile
+20-9src/etc/inc/plugins.inc.d/dpinger.inc
+6-4src/etc/inc/interfaces.inc
+3-6src/etc/inc/plugins.inc.d/ipsec.inc
+2-1src/etc/inc/util.inc
+31-204 files

OPNSense/core 211bc41src/etc/inc interfaces.inc system.inc, src/etc/inc/plugins.inc.d ipsec.inc dpinger.inc

backend: switch to mwexecfb() #9325
DeltaFile
+2-2src/etc/inc/plugins.inc.d/ipsec.inc
+1-1src/etc/inc/plugins.inc.d/dpinger.inc
+1-1src/etc/inc/interfaces.inc
+1-1src/etc/inc/plugins.inc.d/ntpd.inc
+1-1src/etc/inc/plugins.inc.d/unbound.inc
+1-1src/etc/inc/system.inc
+7-76 files