Skip to contentSkip to conversation

trace-cmd: Add option to execute traced process as given user

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 1 message Jul 11, 2019 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 trace-cmd: Add option to execute traced process as given user

A new trace-cmd record option is added: "--user". When it is set with combination of option -F, the traced process is executed in the context of the specified user.

---
[
v4 changes:
- Added check for strdup() failure.
- Made input user string argument of change_user() and run_cmd() constant.
v3 changes:
"--user" does not depend on option -F, it works with any command,
specified as trace-cmd argument.
v2 changes:
- Check for errors in change_user(). If an error occurs while changing the user, the message is printed and the traced process is not executed.
]

 Documentation/trace-cmd-record.1.txt |  4 +++
 tracecmd/trace-record.c              | 49 ++++++++++++++++++++++++++--
 tracecmd/trace-usage.c               |  1 +
 3 files changed, 51 insertions(+), 3 deletions(-)
Documentation/trace-cmd-record.1.txt +4 -0
index 4a59de9..6a0f975 100644
@@ -122,6 +122,10 @@ OPTIONS
 *--mmap*::
      Used with either *-F* or *-P*, save the traced process memory map into
      the trace.dat file.
+
+*--user*::
+     Execute the specified *command* as given user.
+
 *-C* 'clock'::
      Set the trace clock to "clock".
 
tracecmd/trace-record.c +46 -3

109 lines not on this page · raw message

tracecmd/trace-usage.c +1 -0
index c658ede..e3e8186 100644
@@ -58,6 +58,7 @@ static struct usage_help usage_help[] = {
 		"          --max-graph-depth limit function_graph depth\n"
 		"          --no-filter include trace-cmd threads in the trace\n"
 		"          --mmap used with -F or -P, save the traced process memory map into the trace.dat file\n"
+		"          --user execute the specified [command ...] as given user\n"
 	},
 	{
 		"start",
Signature · 1 line
2.21.0