From fb00719069dc790f2a5d01249fefd5e56bf50162 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 23 Aug 2024 08:53:24 +0200 Subject: [PATCH] package/klish: bump for droprivs refactor of script plugin As of KernelKit Klish @ 710a631 the script plugin has been refactored to run all commands as the logged in user instead of as root. The default admin user is member of the wheel group, which allows access to sysrepo and sudo access to containers thanks to NOPASSWD rights. The doas script is a dummy wrapper to silence 'sudo -n' output for users without any privileges. As of this commit, unprivileged users can no longer copy, show, or in any other way manipulate the system configuraiton. Signed-off-by: Joachim Wiberg --- board/common/rootfs/usr/bin/doas | 5 +++ package/klish/klish.hash | 2 +- package/klish/klish.mk | 2 +- src/klish-plugin-infix/xml/containers.xml | 46 +++++++++++------------ 4 files changed, 30 insertions(+), 25 deletions(-) create mode 100755 board/common/rootfs/usr/bin/doas diff --git a/board/common/rootfs/usr/bin/doas b/board/common/rootfs/usr/bin/doas new file mode 100755 index 00000000..ca55870a --- /dev/null +++ b/board/common/rootfs/usr/bin/doas @@ -0,0 +1,5 @@ +#!/bin/sh +# Silly wrapper around sudo to prevent it from printing an error for +# unprivileged users: sudo: a password is required + +id -nG $LOGNAME | grep -qw wheel && sudo -n $@ diff --git a/package/klish/klish.hash b/package/klish/klish.hash index 893f65ae..faf03545 100644 --- a/package/klish/klish.hash +++ b/package/klish/klish.hash @@ -1,3 +1,3 @@ # Locally calculated sha256 9d9d33b873917ca5d0bdcc47a36d2fd385971ab0c045d1472fcadf95ee5bcf5b LICENCE -sha256 d4f6ab771579defb7295e596b259ff8713fe26e85b6e79fb83789cd63be12dbb klish-894b0ba24ffcb5072b4b18f3b5aee3500d05cd86-br1.tar.gz +sha256 4293851b355285be3564873fc1f92ce5a3f4386fe8ce1195f18a79b55b5c99ac klish-710a6314c00bc0485221769d73a5b5d6897c1d81-br1.tar.gz diff --git a/package/klish/klish.mk b/package/klish/klish.mk index f55dae1b..9cf8311b 100644 --- a/package/klish/klish.mk +++ b/package/klish/klish.mk @@ -4,7 +4,7 @@ # ################################################################################ -KLISH_VERSION = 894b0ba24ffcb5072b4b18f3b5aee3500d05cd86 +KLISH_VERSION = 710a6314c00bc0485221769d73a5b5d6897c1d81 KLISH_SITE = https://github.com/kernelkit/klish.git #KLISH_VERSION = tags/3.0.0 #KLISH_SITE = https://src.libcode.org/pkun/klish.git diff --git a/src/klish-plugin-infix/xml/containers.xml b/src/klish-plugin-infix/xml/containers.xml index aca03459..b48918fd 100644 --- a/src/klish-plugin-infix/xml/containers.xml +++ b/src/klish-plugin-infix/xml/containers.xml @@ -37,7 +37,7 @@ - podman system prune + doas podman system prune @@ -45,7 +45,7 @@ - container shell $KLISH_PARAM_name + doas container shell $KLISH_PARAM_name @@ -61,7 +61,7 @@ echo "Missing container name." else cmd=${KLISH_PARAM_command:-sh} - container exec $KLISH_PARAM_name $cmd + doas container exec $KLISH_PARAM_name $cmd fi @@ -79,7 +79,7 @@ creds=${KLISH_PARAM_creds:+-c $KLISH_PARAM_creds} cd /var/lib/containers/oci - container $creds load $KLISH_PARAM_url $KLISH_PARAM_name + doas container $creds load $KLISH_PARAM_url $KLISH_PARAM_name @@ -92,21 +92,21 @@ creds=${KLISH_PARAM_creds:+--creds=$KLISH_PARAM_creds} - container pull $creds $KLISH_PARAM_image + doas container pull $creds $KLISH_PARAM_image - container remove $KLISH_PARAM_name + doas container remove $KLISH_PARAM_name - container restart $KLISH_PARAM_name + doas container restart $KLISH_PARAM_name @@ -122,12 +122,12 @@ port=${KLISH_PARAM_port:+-p $KLISH_PARAM_port} - container $port run $KLISH_PARAM_image ${KLISH_PARAM_command} + doas container $port run $KLISH_PARAM_image ${KLISH_PARAM_command} - container -d $port run $KLISH_PARAM_image ${KLISH_PARAM_command} + doas container -d $port run $KLISH_PARAM_image ${KLISH_PARAM_command} @@ -142,69 +142,69 @@ cd /var/lib/containers/oci - container save $KLISH_PARAM_name $KLISH_PARAM_file + doas container save $KLISH_PARAM_name $KLISH_PARAM_file - container shell $KLISH_PARAM_name + doas container shell $KLISH_PARAM_name - container start $KLISH_PARAM_name + doas container start $KLISH_PARAM_name - container stop $KLISH_PARAM_name + doas container stop $KLISH_PARAM_name - container upgrade $KLISH_PARAM_name + doas container upgrade $KLISH_PARAM_name - container show + doas container show - container -a show + doas container -a show - cat /log/container + doas -u $USER cat /log/container - container show images + doas container show images - container -a show images + doas container -a show images - container list oci + doas container list oci - container stat + doas container stat - podman system df -v + doas podman system df -v - container show volumes + doas container show volumes