From 558349630c00f9d89ebb9236c3d3b807c27c428d Mon Sep 17 00:00:00 2001 From: Andreas Hrubak Date: Wed, 31 Jul 2024 10:45:39 +0200 Subject: [PATCH] add diagnostics mostly --- root-tools/noshellinject | 12 +++++++++++- tabdata/td-add-headers | 2 +- tabdata/td-alter | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/root-tools/noshellinject b/root-tools/noshellinject index 3f44d74..292ad49 100755 --- a/root-tools/noshellinject +++ b/root-tools/noshellinject @@ -24,7 +24,8 @@ set -e # where to save (bind-mount) read shell executables from /bin real_shells_dir=/var/lib/notashell -# may extend if the neglegent program calls something else as shell +# may extend if the neglegent program calls something else as shell. +# all are presumed to be in /bin. shellnames=(sh dash bash) propagtype() @@ -51,6 +52,8 @@ bind_mount_symlink() if [ "$1" = --inner ] then + echo "$0: creating private bind-mount on $real_shells_dir to save real shells" >&2 + mkdir -p "$real_shells_dir" # bind-mount this dir over itself to be able to make private mounts under it mount --bind "$real_shells_dir" "$real_shells_dir" @@ -64,9 +67,13 @@ then mount --bind /bin/$shell "$real_shells_dir/real-$shell" done + echo "$0: umount $real_shells_dir from the parent namespace" >&2 # after sub-mounts are mounted, clean up the parent mount from the parent namespace nsenter -t $PPID -m umount -l "$real_shells_dir" + + echo "$0: creating private bind-mount on /bin to intercept shells" >&2 + # bind-mount this dir over itself to be able to make private mounts under it bind_mount_symlink /bin /bin mount --make-private /bin @@ -77,6 +84,7 @@ then bind_mount_symlink /usr/tool/notashell /bin/$shell done + echo "$0: umount /bin from the parent namespace" >&2 # after sub-mounts are mounted, clean up the parent mount from the parent namespace nsenter -t $PPID -m umount -l /bin @@ -91,5 +99,7 @@ else exit 1 fi + echo "$0: creating new mount-namespace to intercept shell executions" >&2 + exec unshare --mount --propagation=shared -- "$0" --inner "$@" fi diff --git a/tabdata/td-add-headers b/tabdata/td-add-headers index ef72a85..926262b 100755 --- a/tabdata/td-add-headers +++ b/tabdata/td-add-headers @@ -36,7 +36,7 @@ Do not add more columns than specified in the command parameters. =head1 EXAMPLE -who | tr-trans | td-add-headers USER TTY DATE TIME COMMENT + who | td-trans | td-add-headers USER TTY DATE TIME COMMENT =cut diff --git a/tabdata/td-alter b/tabdata/td-alter index 209e442..74cd550 100755 --- a/tabdata/td-alter +++ b/tabdata/td-alter @@ -31,7 +31,7 @@ IS_BIGFILE depends on previously defined TYPE field. ls -l | td-trans-ls | td-alter TYPE='substr MODE,0,1' IS_BIGFILE='SIZE>10000000 && TYPE ne "d" ? "yes" : "no"' -Strip sub-seconds and timezone from DATETIME field. +Strip sub-seconds and timezone from DATETIME field: TIME_STYLE=full-iso ls -l | td-trans-ls | td-alter DATETIME='s/\..*//; $_' -- 2.11.4.GIT