Skip to content

Commit cad603c

Browse files
authored
fix: add AppArmor override for management socket on Ubuntu 25.04+ (angristan#1469)
## Summary - Ubuntu 25.04+ ships an AppArmor profile (`/etc/apparmor.d/openvpn`) that blocks the management unix socket in `/run/openvpn-server/`, causing OpenVPN to fail to start with `Permission denied` - Add a local AppArmor override (`/etc/apparmor.d/local/openvpn`) during install to permit access - Clean up the override on uninstall Tested on a fresh Ubuntu 25.10 DigitalOcean droplet — install, service start, and uninstall all work correctly. Closes angristan#1467 angristan#1449 angristan#1450
1 parent 8e8aeea commit cad603c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

openvpn-install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,6 +3133,21 @@ verb 3"
31333133
run_cmd "Patching service file (RuntimeDirectory)" sed -i '/\[Service\]/a RuntimeDirectory=openvpn-server' /etc/systemd/system/openvpn-server@.service
31343134
fi
31353135
3136+
# AppArmor: Ubuntu 25.04+ ships an enforcing profile for OpenVPN
3137+
# (/etc/apparmor.d/openvpn) that doesn't allow the management unix socket
3138+
# in /run/openvpn-server/. Add a local override to permit this.
3139+
if [[ -f /etc/apparmor.d/openvpn ]]; then
3140+
log_info "Configuring AppArmor for OpenVPN..."
3141+
mkdir -p /etc/apparmor.d/local
3142+
if [[ ! -f /etc/apparmor.d/local/openvpn ]] || ! grep -q "openvpn-server" /etc/apparmor.d/local/openvpn; then
3143+
{
3144+
echo "# Allow OpenVPN management socket and status files in openvpn-server directory"
3145+
echo "/{,var/}run/openvpn-server/** rw,"
3146+
} >>/etc/apparmor.d/local/openvpn
3147+
fi
3148+
run_cmd "Reloading AppArmor profile" apparmor_parser -r /etc/apparmor.d/openvpn
3149+
fi
3150+
31363151
run_cmd "Reloading systemd" systemctl daemon-reload
31373152
run_cmd "Enabling OpenVPN service" systemctl enable openvpn-server@server
31383153
# In fingerprint mode, delay service start until first client is created
@@ -4487,6 +4502,14 @@ function removeOpenVPN() {
44874502
run_cmd "Removing sysctl config" rm -f /etc/sysctl.d/99-openvpn.conf
44884503
run_cmd "Removing OpenVPN logs" rm -rf /var/log/openvpn
44894504

4505+
# AppArmor local override
4506+
if [[ -f /etc/apparmor.d/local/openvpn ]]; then
4507+
run_cmd "Removing AppArmor local override" rm -f /etc/apparmor.d/local/openvpn
4508+
if [[ -f /etc/apparmor.d/openvpn ]]; then
4509+
run_cmd "Reloading AppArmor profile" apparmor_parser -r /etc/apparmor.d/openvpn 2>/dev/null || true
4510+
fi
4511+
fi
4512+
44904513
# Unbound
44914514
if [[ -e /etc/unbound/unbound.conf.d/openvpn.conf ]]; then
44924515
removeUnbound

0 commit comments

Comments
 (0)