Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execnsnoop - not all cat have -v #64

Open
vanhauser-thc opened this issue Jan 12, 2018 · 0 comments
Open

execnsnoop - not all cat have -v #64

vanhauser-thc opened this issue Jan 12, 2018 · 0 comments

Comments

@vanhauser-thc
Copy link

busybox and other cat tools do not have -v, added a check if the option is present

--- bin/execsnoop
+++ bin/execsnoop
@@ -58,6 +58,7 @@ tracing=/sys/kernel/debug/tracing
 flock=/var/tmp/.ftrace-lock; wroteflock=0
 opt_duration=0; duration=; opt_name=0; name=; opt_time=0; opt_reexec=0
 opt_argc=0; argc=8; max_argc=16; ftext=
+VOPT=-v
 trap ':' INT QUIT TERM PIPE HUP        # sends execution to end tracing section

 function usage {
@@ -156,6 +157,9 @@ else
        fi
 fi

+# not all cat have -v, e.g busybox
+echo test | cat -v 2> /dev/null | grep -q test || VOPT=
+
 ### check permissions
 cd $tracing || die "ERROR: accessing tracing. Root user? Kernel has FTRACE?
     debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)"
@@ -224,10 +228,10 @@ warn "echo > trace"
 ( if (( opt_duration )); then
        # wait then dump buffer
        sleep $duration
-       cat -v trace
+       cat $VOPT trace
 else
        # print buffer live
-       cat -v trace_pipe
+       cat $VOPT trace_pipe
 fi ) | $awk -v o=$offset -v opt_name=$opt_name -v name=$name \
     -v opt_duration=$opt_duration -v opt_time=$opt_time -v kname=$kname \
     -v opt_reexec=$opt_reexec '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant