Skip to content

Commit

Permalink
Added -q option to execsnoop to quote individual arguments. This help…
Browse files Browse the repository at this point in the history
…s when working with arguments that contain spaces.
  • Loading branch information
Bastian Reitemeier committed Apr 8, 2018
1 parent 18d3814 commit 79ce51c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/execsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
help="include timestamp on output")
parser.add_argument("-x", "--fails", action="store_true",
help="include failed exec()s")
parser.add_argument("-q", "--quote", action="store_true",
help="Add quotemarks (\") around arguments."
)
parser.add_argument("-n", "--name",
type=ArgString,
help="only print commands matching this name (regex), any arg")
Expand Down Expand Up @@ -192,6 +195,11 @@ def print_event(cpu, data, size):
skip = True
if args.name and not re.search(bytes(args.name), event.comm):
skip = True
if args.quote:
argv[event.pid] = [
"\"" + arg.replace("\"", "\\\"") + "\""
for arg in argv[event.pid]
]
if args.line and not re.search(bytes(args.line),
b' '.join(argv[event.pid])):
skip = True
Expand Down

0 comments on commit 79ce51c

Please sign in to comment.