@@ -541,6 +541,65 @@ technitium_service_user() {
541541 printf ' %s' " $user "
542542}
543543
544+ ensure_technitium_systemd_cert_access () {
545+ [ -n " ${TECH_SERVICE:- } " ] || return 0
546+ has_systemctl || return 0
547+
548+ local tech_user=" "
549+ tech_user=" $( technitium_service_user) "
550+ [ -n " $tech_user " ] || return 0
551+ [ " $tech_user " != " root" ] || return 0
552+
553+ local dropin_dir=" /etc/systemd/system/${TECH_SERVICE} .d"
554+ local dropin_file=" ${dropin_dir} /local-https.conf"
555+ local tmp=" "
556+
557+ tmp=" $( mktemp) "
558+ cat > " $tmp " << EOF
559+ # Managed by local-https: Technitium certificate access
560+ [Service]
561+ ReadOnlyPaths=$SERVER_PFX
562+ EOF
563+
564+ if [ -f " $dropin_file " ] && cmp -s " $tmp " " $dropin_file " ; then
565+ rm -f " $tmp " > /dev/null 2>&1 || true
566+ return 0
567+ fi
568+
569+ install -d -m 755 " $dropin_dir " > /dev/null 2>&1 || {
570+ rm -f " $tmp " > /dev/null 2>&1 || true
571+ die " Failed to create Technitium systemd drop-in directory: $dropin_dir "
572+ }
573+
574+ install -m 644 " $tmp " " $dropin_file " > /dev/null 2>&1 || {
575+ rm -f " $tmp " > /dev/null 2>&1 || true
576+ die " Failed to configure Technitium read-only certificate access: $dropin_file "
577+ }
578+ rm -f " $tmp " > /dev/null 2>&1 || true
579+
580+ systemctl daemon-reload > /dev/null 2>&1 || die " systemctl daemon-reload failed after Technitium certificate access update."
581+
582+ TECH_CERT_ACCESS_CHANGED=1
583+ out " \033[32m[✓]\033[0m Configured Technitium read-only access to: $SERVER_PFX "
584+ }
585+
586+ remove_technitium_systemd_cert_access () {
587+ has_systemctl || return 0
588+
589+ detect_technitium_service_name
590+ [ -n " ${TECH_SERVICE:- } " ] || return 0
591+
592+ local dropin_dir=" /etc/systemd/system/${TECH_SERVICE} .d"
593+ local dropin_file=" ${dropin_dir} /local-https.conf"
594+
595+ [ -f " $dropin_file " ] || return 0
596+ grep -qF " # Managed by local-https: Technitium certificate access" " $dropin_file " 2> /dev/null || return 0
597+
598+ rm -f " $dropin_file " > /dev/null 2>&1 || true
599+ rmdir " $dropin_dir " > /dev/null 2>&1 || true
600+ systemctl daemon-reload > /dev/null 2>&1 || true
601+ }
602+
544603wait_for_technitium () {
545604 local i=0
546605
@@ -1537,12 +1596,12 @@ configure_technitium_required_install() {
15371596 if [ " ${TECH_CERT_ACCESS_CHANGED:- 0} " -eq 1 ]; then
15381597 if [ -n " ${TECH_SERVICE:- } " ]; then
15391598 out " \033[34m[i]\033[0m Activating Technitium certificate access..."
1540- restart_or_warn " $TECH_SERVICE " " Technitium DNS" || die " Technitium restart failed after certificate permission update."
1599+ restart_or_warn " $TECH_SERVICE " " Technitium DNS" || die " Technitium restart failed after certificate access update."
15411600 wait_for_technitium || die " Technitium did not become reachable after restart."
15421601 TECH_CERT_ACCESS_CHANGED=0
15431602 out " \033[32m[✓]\033[0m Technitium certificate access is active."
15441603 else
1545- die " Technitium service user permissions changed, but service name was not detected."
1604+ die " Technitium certificate access changed, but service name was not detected."
15461605 fi
15471606 fi
15481607
@@ -1747,6 +1806,8 @@ apply_permissions() {
17471806 [ -f " $SERVER_PFX " ] && chmod 640 " $SERVER_PFX " > /dev/null 2>&1 || true
17481807 [ -f " $PFX_PASS_FILE " ] && chmod 600 " $PFX_PASS_FILE " > /dev/null 2>&1 || true
17491808
1809+ ensure_technitium_systemd_cert_access
1810+
17501811 out " \033[32m[✓]\033[0m Permissions applied."
17511812}
17521813
@@ -2070,6 +2131,7 @@ uninstall() {
20702131 fi
20712132
20722133 if [ " $UNINSTALL_PURGE " -eq 1 ]; then
2134+ remove_technitium_systemd_cert_access
20732135 rm -rf " $SSL_DIR " > /dev/null 2>&1 || true
20742136 fi
20752137
0 commit comments