From 4a7e0598a56e986b9cbd57b9f517c7c312b9f63b Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Sat, 26 Jul 2025 11:41:24 +0100
Subject: Don't use a dummy owner when building with --disable-ownership.
---
make/configure.pm | 8 ++++++++
make/template/inspircd.openrc | 2 +-
make/template/inspircd.service | 5 +++--
make/template/logrotate | 2 +-
make/template/org.inspircd.plist | 8 ++++----
5 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/make/configure.pm b/make/configure.pm
index 0904752fd..1f7f9eb6a 100644
--- a/make/configure.pm
+++ b/make/configure.pm
@@ -298,6 +298,14 @@ sub parse_templates($$$) {
} else {
push @lines, "#${indent}undef $value";
}
+ } elsif ($name eq 'ifdef') {
+ if ($name =~ /^(\S+)\s+(.+)/ && $settings{$1}) {
+ push @lines, $indent . $2;
+ }
+ } elsif ($name eq 'ifndef') {
+ if ($3 =~ /^(\S+)\s+(.+)/ && !$settings{$1}) {
+ push @lines, $indent . $2;
+ }
} elsif ($name eq 'mode') {
$mode = oct $value;
} elsif ($name eq 'platform') {
diff --git a/make/template/inspircd.openrc b/make/template/inspircd.openrc
index 8f755bb91..30b15edfa 100644
--- a/make/template/inspircd.openrc
+++ b/make/template/inspircd.openrc
@@ -24,7 +24,7 @@ description="InspIRCd - Internet Relay Chat Daemon"
command="@BINARY_DIR@/inspircd"
command_args="--nofork --nopid"
-command_user="@USER@:@GROUP@"
+%ifndef DISABLE_OWNERSHIP command_user="@USER@:@GROUP@"
pidfile="@RUNTIME_DIR@/${RC_SVCNAME}.pid"
supervisor="supervise-daemon"
diff --git a/make/template/inspircd.service b/make/template/inspircd.service
index c92206e0a..bc8cdc14e 100644
--- a/make/template/inspircd.service
+++ b/make/template/inspircd.service
@@ -32,8 +32,9 @@ ExecReload=/bin/kill -HUP $MAINPID
ExecStart=@BINARY_DIR@/inspircd --nofork --nopid
Restart=on-failure
Type=simple
-User=@USER@
-Group=@GROUP@
+%ifdef DISABLE_OWNERSHIP DynamicUser=yes
+%ifndef DISABLE_OWNERSHIP User=@USER@
+%ifndef DISABLE_OWNERSHIP Group=@GROUP@
[Install]
WantedBy=multi-user.target
diff --git a/make/template/logrotate b/make/template/logrotate
index 65cb4c8d7..345824e52 100644
--- a/make/template/logrotate
+++ b/make/template/logrotate
@@ -21,7 +21,7 @@
@LOG_DIR@/*.log {
compress
- create 0644 @USER@ @GROUP@
+ %ifndef DISABLE_OWNERSHIP create 0644 @USER@ @GROUP@
dateext
delaycompress
missingok
diff --git a/make/template/org.inspircd.plist b/make/template/org.inspircd.plist
index ae4e90916..6375573bb 100644
--- a/make/template/org.inspircd.plist
+++ b/make/template/org.inspircd.plist
@@ -26,9 +26,9 @@
@LOG_DIR@/launchd-stdout.log
StandardErrorPath
@LOG_DIR@/launchd-stderr.log
- UserName
- @USER@
- GroupName
- @GROUP@
+ %ifndef DISABLE_OWNERSHIP UserName
+ %ifndef DISABLE_OWNERSHIP @USER@
+ %ifndef DISABLE_OWNERSHIP GroupName
+ %ifndef DISABLE_OWNERSHIP @GROUP@
--
cgit v1.3.1-10-gc9f91