FreeBSD Bugzilla – Attachment 239759 Details for
Bug 269198
dns/blocky: running daemon as non-root user is not supported
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch with improved rc.d script
0001-dns-blocky-Improve-rc.d-script.patch (text/plain), 3.09 KB, created by
Benjamin Spiegel
on 2023-01-28 08:28:03 UTC
(
hide
)
Description:
Patch with improved rc.d script
Filename:
MIME Type:
Creator:
Benjamin Spiegel
Created:
2023-01-28 08:28:03 UTC
Size:
3.09 KB
patch
obsolete
>From 2ac983c25cd5b25daf9aee0782849de2eb29b921 Mon Sep 17 00:00:00 2001 >From: Benjamin Spiegel <bspiegel100@gmail.com> >Date: Sat, 28 Jan 2023 07:54:49 +0000 >Subject: [PATCH] dns/blocky: Improve rc.d script > >- Don't override start_cmd function so that blocky_user and other > standard rc.conf options are checked >- Create pidfile and set permissions before start to support running > the service as a non-root user >- Add optional blocky_group setting to specify pidfile ownership >- Document blocky_flags option; correct default path in comments; > minor changes for more consistent quoting, variable use, and style >--- > dns/blocky/Makefile | 2 +- > dns/blocky/files/blocky.in | 36 +++++++++++++++++++++++++++--------- > 2 files changed, 28 insertions(+), 10 deletions(-) > >diff --git a/dns/blocky/Makefile b/dns/blocky/Makefile >index d17daad65956..5035aaffca74 100644 >--- a/dns/blocky/Makefile >+++ b/dns/blocky/Makefile >@@ -1,7 +1,7 @@ > PORTNAME= blocky > DISTVERSIONPREFIX= v > DISTVERSION= 0.20 >-PORTREVISION= 2 >+PORTREVISION= 3 > CATEGORIES= dns > MASTER_SITES= https://raw.githubusercontent.com/${GH_ACCOUNT}/${GH_PROJECT}/${DISTVERSIONFULL}/:gomod > DISTFILES= go.mod:gomod >diff --git a/dns/blocky/files/blocky.in b/dns/blocky/files/blocky.in >index 24a92028836a..2b625f8be55d 100644 >--- a/dns/blocky/files/blocky.in >+++ b/dns/blocky/files/blocky.in >@@ -7,9 +7,15 @@ > # Add the following to /etc/rc.conf[.local] to enable this service > # > # blocky_enable (bool): Set to NO by default. >-# Set it to YES to enable blocky. >-# blocky_config (str): Set to /usr/local/etc/blocky/config.yml by default. >-# >+# Set it to YES to enable blocky. >+# blocky_config (str): Set to /usr/local/etc/blocky-config.yml by default. >+# Set it to a path to use that config file. >+# blocky_user (str): Services run as root by default. Set to a user name >+# to run blocky as that user. Note: non-root users >+# might need permission to bind to ports. >+# blocky_group (str): Set to the user's primary group by default. >+# Set it to a group name for daemon file ownership. >+# blocky_flags (str): Enter extra flags to append to the blocky command. > > . /etc/rc.subr > >@@ -20,17 +26,29 @@ load_rc_config ${name} > > : ${blocky_enable:=NO} > : ${blocky_config:="%%PREFIX%%/etc/blocky-config.yml"} >+: ${blocky_group:=} > : ${blocky_flags:=} > >-pidfile=/var/run/blocky.pid >-command="%%PREFIX%%/sbin/blocky" >+if [ -n "${blocky_user}" ] && [ -z "${blocky_group}" ]; then >+ # Detect the daemon user's primary group >+ blocky_group=$(id -gn "${blocky_user}") >+fi >+ >+pidfile="/var/run/${name}.pid" >+blocky_path="%%PREFIX%%/sbin/blocky" >+ >+command="/usr/sbin/daemon" >+procname="/usr/local/sbin/blocky" >+command_args="-c -f -p ${pidfile} ${blocky_path} \ >+ -c ${blocky_config} ${blocky_flags}" > >-start_cmd="${name}_start" >+start_precmd="blocky_precmd" > >-blocky_start() >+# Sets up a pidfile the daemon user can access >+blocky_precmd() > { >- echo -n "Starting ${name}." >- /usr/sbin/daemon -p ${pidfile} -f ${command} -c ${blocky_config} ${blocky_flags} >+ install -o "${blocky_user:-root}" -g "${blocky_group:-wheel}" \ >+ -m 0600 /dev/null "${pidfile}" > } > > run_rc_command "$1" >-- >2.39.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 269198
: 239759 |
239817