Blame SOURCES/0008-frr-non-root-user.patch

8eca10
From 1d42fb941af17a29346b2af03338f8e18470f009 Mon Sep 17 00:00:00 2001
8eca10
From: Michal Ruprich <michalruprich@gmail.com>
8eca10
Date: Tue, 22 Nov 2022 12:38:05 +0100
8eca10
Subject: [PATCH] tools: Enable start of FRR for non-root user
8eca10
8eca10
There might be use cases when this would make sense, for example
8eca10
running FRR in a container as a designated user.
8eca10
8eca10
Signed-off-by: Michal Ruprich <mruprich@redhat.com>
8eca10
---
8eca10
 tools/etc/frr/daemons | 5 +++++
8eca10
 tools/frrcommon.sh.in | 4 ++++
8eca10
 2 files changed, 9 insertions(+)
8eca10
8eca10
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
8eca10
index 8aa08871e35..2427bfff777 100644
8eca10
--- a/tools/etc/frr/daemons
8eca10
+++ b/tools/etc/frr/daemons
8eca10
@@ -91,6 +91,12 @@ pathd_options="  -A 127.0.0.1"
8eca10
 # say BGP.
8eca10
 #MAX_FDS=1024
8eca10
 
8eca10
+# Uncomment this option if you want to run FRR as a non-root user. Note that
8eca10
+# you should know what you are doing since most of the daemons need root
8eca10
+# to work. This could be useful if you want to run FRR in a container
8eca10
+# for instance.
8eca10
+# FRR_NO_ROOT="yes"
8eca10
+
8eca10
 # The list of daemons to watch is automatically generated by the init script.
8eca10
 #watchfrr_options=""
8eca10
 
8eca10
diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in
8eca10
index 3c16c27c6df..4f095a176e4 100755
8eca10
--- a/tools/frrcommon.sh.in
8eca10
+++ b/tools/frrcommon.sh.in
8eca10
@@ -43,6 +43,10 @@ RELOAD_SCRIPT="$D_PATH/frr-reload.py"
8eca10
 #
8eca10
 
8eca10
 is_user_root () {
8eca10
+	if [[ ! -z $FRR_NO_ROOT  &&  "${FRR_NO_ROOT}" == "yes" ]]; then
8eca10
+		return 0
8eca10
+	fi
8eca10
+
8eca10
 	[ "${EUID:-$(id -u)}" -eq 0 ] || {
8eca10
 		log_failure_msg "Only users having EUID=0 can start/stop daemons"
8eca10
 		return 1
8eca10
diff --git a/doc/user/setup.rst b/doc/user/setup.rst
8eca10
index 25934df..51ffd32 100644
8eca10
--- a/doc/user/setup.rst
8eca10
+++ b/doc/user/setup.rst
8eca10
@@ -114,6 +114,16 @@ most operating systems is 1024.  If the operator plans to run bgp with
8eca10
 several thousands of peers than this is where we would modify FRR to
8eca10
 allow this to happen.
8eca10
 
8eca10
+::
8eca10
+
8eca10
+  FRR_NO_ROOT="yes"
8eca10
+
8eca10
+This option allows you to run FRR as a non-root user. Use this option
8eca10
+only when you know what you are doing since most of the daemons
8eca10
+in FRR will not be able to run under a regular user. This option
8eca10
+is useful for example when you run FRR in a container with a designated
8eca10
+user instead of root.
8eca10
+
8eca10
 ::
8eca10
 
8eca10
    zebra_options=" -s 90000000 --daemon -A 127.0.0.1"