From 1d42fb941af17a29346b2af03338f8e18470f009 Mon Sep 17 00:00:00 2001 From: Michal Ruprich Date: Tue, 22 Nov 2022 12:38:05 +0100 Subject: [PATCH] tools: Enable start of FRR for non-root user There might be use cases when this would make sense, for example running FRR in a container as a designated user. Signed-off-by: Michal Ruprich --- tools/etc/frr/daemons | 5 +++++ tools/frrcommon.sh.in | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons index 8aa08871e3..2427bfff77 100644 --- a/tools/etc/frr/daemons +++ b/tools/etc/frr/daemons @@ -91,6 +91,11 @@ pathd_options=" -A 127.0.0.1" # #MAX_FDS=1024 +# Uncomment this option if you want to run FRR as a non-root user. Note that +# you should know what you are doing since most of the daemons need root +# to work. This could be useful if you want to run FRR in a container +# for instance. +# FRR_NO_ROOT="yes" # For any daemon, you can specify a "wrap" command to start instead of starting # the daemon directly. This will simply be prepended to the daemon invocation. diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in index 3c16c27c6d..4f095a176e 100755 --- a/tools/frrcommon.sh.in +++ b/tools/frrcommon.sh.in @@ -43,6 +43,10 @@ RELOAD_SCRIPT="$D_PATH/frr-reload.py" # is_user_root () { + if [[ ! -z $FRR_NO_ROOT && "${FRR_NO_ROOT}" == "yes" ]]; then + return 0 + fi + [ "${EUID:-$(id -u)}" -eq 0 ] || { log_failure_msg "Only users having EUID=0 can start/stop daemons" return 1 -- 2.39.5