Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP3:Update
frr.35834
0010-tools-Run-as-FRR_USER-install-chown-comman...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0010-tools-Run-as-FRR_USER-install-chown-commands-to-avoi.patch of Package frr.35834
From 28d8089bc5e8652dd6026abdf13b04f45e425830 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis <donatas@opensourcerouting.org> Date: Thu, 20 Oct 2022 09:10:22 +0300 References: bsc#1204124,CVE-2022-42917 Upstream: yes Subject: [PATCH 2/2] tools: Run as FRR_USER `install/chown` commands to avoid race conditions This is due to CVE-2022-42917: https://bugzilla.suse.com/show_bug.cgi?id=1204124 install/chown is in most cases (as I tested) is enough, but still, can be racy. Tested on Linux/OpenBSD/NetBSD/FreeBSD, seems a unified way to do this. For Linux `runuser` can be used, but *BSD do not have this command. Proof of concept: ``` % sudo su - frr [sudo] password for donatas: su: warning: cannot change directory to /nonexistent: No such file or directory frr@donatas-laptop:/home/donatas$ cd /etc/frr/ frr@donatas-laptop:/etc/frr$ rm -f zebra.conf; inotifywait -e CREATE .; rm -f zebra.conf; ln -s /etc/shadow zebra.conf Setting up watches. Watches established. ./ CREATE zebra.conf frr@donatas-laptop:/etc/frr$ ls -la zebra.conf lrwxrwxrwx 1 frr frr 11 spal. 20 09:25 zebra.conf -> /etc/shadow frr@donatas-laptop:/etc/frr$ cat zebra.conf cat: zebra.conf: Permission denied frr@donatas-laptop:/etc/frr$ ``` On the other terminal do: ``` /usr/lib/frr/frrinit.sh restart ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> diff --git a/tools/frr.in b/tools/frr.in index b1de179b48..67a3161622 100755 --- a/tools/frr.in +++ b/tools/frr.in @@ -96,10 +96,10 @@ check_daemon() # check for config file if [ -n "$2" ]; then if [ ! -r "$C_PATH/$1-$2.conf" ]; then - install -g "$FRR_GROUP" -o "$FRR_USER" -m "$FRR_CONFIG_MODE" /dev/null "$C_PATH/$1-$2.conf" + su - "${FRR_USER}" -c "install -g \"$FRR_GROUP\" -o \"$FRR_USER\" -m \"$FRR_CONFIG_MODE\" /dev/null \"$C_PATH/$1-$2.conf\"" fi elif [ ! -r "$C_PATH/$1.conf" ]; then - install -g "$FRR_GROUP" -o "$FRR_USER" -m "$FRR_CONFIG_MODE" /dev/null "$C_PATH/$1.conf" + su - "${FRR_USER}" -c "install -g \"$FRR_GROUP\" -o \"$FRR_USER\" -m \"$FRR_CONFIG_MODE\" /dev/null \"$C_PATH/$1.conf\"" fi fi return 0 @@ -524,7 +524,7 @@ convert_daemon_prios if [ ! -d $V_PATH ]; then echo "Creating $V_PATH" - install -g "$FRR_GROUP" -o "$FRR_USER" -m "$FRR_CONFIG_MODE" -d /proc "$V_PATH" + su - "${FRR_USER}" -c "install -g \"$FRR_GROUP\" -o \"$FRR_USER\" -m \"$FRR_CONFIG_MODE\" -d \"$V_PATH\"" chmod gu+x "${V_PATH}" fi diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in index 62fde00394..5af2252294 100644 --- a/tools/frrcommon.sh.in +++ b/tools/frrcommon.sh.in @@ -126,7 +126,7 @@ daemon_prep() { cfg="$C_PATH/$daemon${inst:+-$inst}.conf" if [ ! -r "$cfg" ]; then - install -g "$FRR_GROUP" -o "$FRR_USER" -m "$FRR_CONFIG_MODE" /dev/null "$cfg" + su - "${FRR_USER}" -c "install -g \"$FRR_GROUP\" -o \"$FRR_USER\" -m \"$FRR_CONFIG_MODE\" /dev/null \"$cfg\"" fi return 0 } @@ -138,7 +138,7 @@ daemon_start() { ulimit -n $MAX_FDS > /dev/null 2> /dev/null daemon_prep "$daemon" "$inst" || return 1 if test ! -d "$V_PATH"; then - install -g "$FRR_GROUP" -o "$FRR_USER" -m "$FRR_CONFIG_MODE" -d /proc "$V_PATH" + su - "${FRR_USER}" -c "install -g \"$FRR_GROUP\" -o \"$FRR_USER\" -m \"$FRR_CONFIG_MODE\" -d \"$V_PATH\"" chmod gu+x "${V_PATH}" fi -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor