From cab3c5a1a0f81eaac3cb8d4f54f0515b065160ea Mon Sep 17 00:00:00 2001 From: V Date: Sat, 10 Jul 2021 20:17:48 +0200 Subject: ripple: move tools to their own directory Change-Id: I693b9b9c5b9aff8c96b1b81f1ff7b7f2b92eabcb --- ripple/driver.pl | 69 ------------------------------- ripple/fakefakeroot/.gitignore | 5 --- ripple/fakefakeroot/PKGBUILD | 17 -------- ripple/fakefakeroot/fakefakeroot.sh | 17 -------- ripple/tools/driver.pl | 69 +++++++++++++++++++++++++++++++ ripple/tools/fakefakeroot/.gitignore | 5 +++ ripple/tools/fakefakeroot/PKGBUILD | 17 ++++++++ ripple/tools/fakefakeroot/fakefakeroot.sh | 17 ++++++++ 8 files changed, 108 insertions(+), 108 deletions(-) delete mode 100755 ripple/driver.pl delete mode 100644 ripple/fakefakeroot/.gitignore delete mode 100644 ripple/fakefakeroot/PKGBUILD delete mode 100755 ripple/fakefakeroot/fakefakeroot.sh create mode 100755 ripple/tools/driver.pl create mode 100644 ripple/tools/fakefakeroot/.gitignore create mode 100644 ripple/tools/fakefakeroot/PKGBUILD create mode 100755 ripple/tools/fakefakeroot/fakefakeroot.sh (limited to 'ripple') diff --git a/ripple/driver.pl b/ripple/driver.pl deleted file mode 100755 index 7a8d164..0000000 --- a/ripple/driver.pl +++ /dev/null @@ -1,69 +0,0 @@ -#! /usr/bin/perl -# SPDX-FileCopyrightText: edef -# SPDX-License-Identifier: OSL-3.0 - -use strict; -use POSIX qw(mkfifo); - -@ARGV or die "Usage: $0 PROGRAM [ARG]... 2> [LOG FILE]"; -die "bpftrace does not support spaces in argv" if grep {/ /} @ARGV; - -unlink(my $fifo = "tracepipe"); -mkfifo($fifo, 0600) or die; - -my $script = do { local $/; }; -defined(my $pid = fork) or die; - -if (!$pid) { - open(STDERR, ">&", STDOUT) or die; - exec( - 'systemd-run', '--user', '--scope', '--', - # NOTE: this expects bpftrace to be SUID-root, - # and relies on shells dropping euid - 'bpftrace', '-o', $fifo, '-e', $script, '-c', - join(' ', @ARGV) - ) or die; -} - -my %count; - -# TODO(edef): if bpftrace fails, the FIFO will never open -open(TRACE, '<', $fifo) or die; -while () { - chomp; - next if /^Attaching \d+ probes[.][.][.]$/ or /^$/; - /^@\[tracepoint:syscalls:sys_enter_(\w+), (.+)\]: (\d+)$/ or die $_; - $count{$1}{$2} += $3; -} - -waitpid $pid, 0; - -foreach my $comm (sort keys %count) { - die "unhandled: $comm" if $comm =~ /\s/; - my $comm_count = $count{$comm}; - foreach my $sys (sort keys %$comm_count) { - my $n = $comm_count->{$sys}; - print STDERR "$comm\t$sys\t$n\n"; - } -} - -__DATA__ -BEGIN { - @cgroup = cgroup; - @self = pid; -} - -tracepoint:syscalls:sys_enter_* /cgroup == @cgroup && pid != @self/ { - @[probe, comm] = count(); -} - -interval:s:1 { - print(@); - clear(@); -} - -tracepoint:sched:sched_process_exit /tid == cpid/ { - clear(@cgroup); - clear(@self); - exit(); -} diff --git a/ripple/fakefakeroot/.gitignore b/ripple/fakefakeroot/.gitignore deleted file mode 100644 index b91c0cb..0000000 --- a/ripple/fakefakeroot/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-FileCopyrightText: edef -# SPDX-License-Identifier: OSL-3.0 -/*.pkg.tar.* -/src/ -/pkg/ diff --git a/ripple/fakefakeroot/PKGBUILD b/ripple/fakefakeroot/PKGBUILD deleted file mode 100644 index 22cdb41..0000000 --- a/ripple/fakefakeroot/PKGBUILD +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-FileCopyrightText: edef -# SPDX-License-Identifier: OSL-3.0 -pkgname=fakefakeroot -pkgver=0 -pkgrel=0 -pkgdesc='fakeroot shim' -arch=('any') -license=('OSL-3.0') -depends=('bash') -provides=('fakeroot') -conflicts=('fakeroot') -source=('./fakefakeroot.sh') -b2sums=('SKIP') - -package() { - install -Dm 0755 fakefakeroot.sh $pkgdir/usr/bin/fakeroot -} diff --git a/ripple/fakefakeroot/fakefakeroot.sh b/ripple/fakefakeroot/fakefakeroot.sh deleted file mode 100755 index 0f6ca7c..0000000 --- a/ripple/fakefakeroot/fakefakeroot.sh +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/bash -# SPDX-FileCopyrightText: edef -# SPDX-License-Identifier: OSL-3.0 - -if [ "$*" = "-v" ]; then - echo fakefakeroot - exit 0 -fi - -if [ "$1" != "--" ]; then - echo "usage: $0 -- PROGRAM [ARG]..." >&2 - exit 255 -fi - -export FAKEROOTKEY="double-fake-root" - -shift; exec "$@" diff --git a/ripple/tools/driver.pl b/ripple/tools/driver.pl new file mode 100755 index 0000000..7a8d164 --- /dev/null +++ b/ripple/tools/driver.pl @@ -0,0 +1,69 @@ +#! /usr/bin/perl +# SPDX-FileCopyrightText: edef +# SPDX-License-Identifier: OSL-3.0 + +use strict; +use POSIX qw(mkfifo); + +@ARGV or die "Usage: $0 PROGRAM [ARG]... 2> [LOG FILE]"; +die "bpftrace does not support spaces in argv" if grep {/ /} @ARGV; + +unlink(my $fifo = "tracepipe"); +mkfifo($fifo, 0600) or die; + +my $script = do { local $/; }; +defined(my $pid = fork) or die; + +if (!$pid) { + open(STDERR, ">&", STDOUT) or die; + exec( + 'systemd-run', '--user', '--scope', '--', + # NOTE: this expects bpftrace to be SUID-root, + # and relies on shells dropping euid + 'bpftrace', '-o', $fifo, '-e', $script, '-c', + join(' ', @ARGV) + ) or die; +} + +my %count; + +# TODO(edef): if bpftrace fails, the FIFO will never open +open(TRACE, '<', $fifo) or die; +while () { + chomp; + next if /^Attaching \d+ probes[.][.][.]$/ or /^$/; + /^@\[tracepoint:syscalls:sys_enter_(\w+), (.+)\]: (\d+)$/ or die $_; + $count{$1}{$2} += $3; +} + +waitpid $pid, 0; + +foreach my $comm (sort keys %count) { + die "unhandled: $comm" if $comm =~ /\s/; + my $comm_count = $count{$comm}; + foreach my $sys (sort keys %$comm_count) { + my $n = $comm_count->{$sys}; + print STDERR "$comm\t$sys\t$n\n"; + } +} + +__DATA__ +BEGIN { + @cgroup = cgroup; + @self = pid; +} + +tracepoint:syscalls:sys_enter_* /cgroup == @cgroup && pid != @self/ { + @[probe, comm] = count(); +} + +interval:s:1 { + print(@); + clear(@); +} + +tracepoint:sched:sched_process_exit /tid == cpid/ { + clear(@cgroup); + clear(@self); + exit(); +} diff --git a/ripple/tools/fakefakeroot/.gitignore b/ripple/tools/fakefakeroot/.gitignore new file mode 100644 index 0000000..b91c0cb --- /dev/null +++ b/ripple/tools/fakefakeroot/.gitignore @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: edef +# SPDX-License-Identifier: OSL-3.0 +/*.pkg.tar.* +/src/ +/pkg/ diff --git a/ripple/tools/fakefakeroot/PKGBUILD b/ripple/tools/fakefakeroot/PKGBUILD new file mode 100644 index 0000000..22cdb41 --- /dev/null +++ b/ripple/tools/fakefakeroot/PKGBUILD @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: edef +# SPDX-License-Identifier: OSL-3.0 +pkgname=fakefakeroot +pkgver=0 +pkgrel=0 +pkgdesc='fakeroot shim' +arch=('any') +license=('OSL-3.0') +depends=('bash') +provides=('fakeroot') +conflicts=('fakeroot') +source=('./fakefakeroot.sh') +b2sums=('SKIP') + +package() { + install -Dm 0755 fakefakeroot.sh $pkgdir/usr/bin/fakeroot +} diff --git a/ripple/tools/fakefakeroot/fakefakeroot.sh b/ripple/tools/fakefakeroot/fakefakeroot.sh new file mode 100755 index 0000000..0f6ca7c --- /dev/null +++ b/ripple/tools/fakefakeroot/fakefakeroot.sh @@ -0,0 +1,17 @@ +#! /bin/bash +# SPDX-FileCopyrightText: edef +# SPDX-License-Identifier: OSL-3.0 + +if [ "$*" = "-v" ]; then + echo fakefakeroot + exit 0 +fi + +if [ "$1" != "--" ]; then + echo "usage: $0 -- PROGRAM [ARG]..." >&2 + exit 255 +fi + +export FAKEROOTKEY="double-fake-root" + +shift; exec "$@" -- cgit 1.4.1