Generate clearer error message when dtrace is run not as root
PATCH v2 3/7 Generate clearer error message when dtrace is run not as root
From: Eugene Loh <[email protected]>
It is a relatively simple mistake to run dtrace not as root, but the resulting error message is not very clear. Specifically, it currently reports a very specific -xlockmem=unlimited message that is no longer a common failure. Generate a clearer message.
Signed-off-by Eugene Loh <[email protected]>
--- cmd/dtrace.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
cmd/dtrace.c +15 -0
@@ -1036,6 +1036,21 @@ main(int argc, char *argv[]) } } +/* +* Generate a helpful error message if the user forgets to run as root. +* +* Note that DMODE_VERS has already been handled, and DMODE_HEADER and +* DMODE_LINK are okay without root. +* +* Insist on root for tracing, but also for DMODE_LIST and even for +* DMODE_EXEC with g_exec==0, since otherwise too many probes will +* simply not be recognized, likely causing puzzling behavior. +*/ +if (getuid () !=0 && (g_mode ==DMODE_LIST || g_mode ==DMODE_EXEC )) { +fprintf (stderr,"%s: run as root for tracing and listing probes\n" , g_pname); +return E_USAGE ; + } +/* * If we're in linker mode and the data model hasn't been specified, * we try to guess the appropriate setting by examining the object
Signature · 1 line
2.43.5
Quoted 8 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
It is a relatively simple mistake to run dtrace not as root, but the resulting error message is not very clear. Specifically, it currently reports a very specific -xlockmem=unlimited message that is no longer a common failure. Generate a clearer message.
Signed-off-by Eugene Loh <[email protected]>
Reviewed-by Kris Van Hees <[email protected]>
Quoted 38 lines
--- cmd/dtrace.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)cmd/dtrace.c +15
-0@@ -1036,6 +1036,21 @@ main(int argc, char *argv[]) } } +/* +* Generate a helpful error message if the user forgets to run as root. +* +* Note that DMODE_VERS has already been handled, and DMODE_HEADER and +* DMODE_LINK are okay without root. +* +* Insist on root for tracing, but also for DMODE_LIST and even for +* DMODE_EXEC with g_exec==0, since otherwise too many probes will +* simply not be recognized, likely causing puzzling behavior. +*/ +if (getuid () !=0 && (g_mode ==DMODE_LIST || g_mode ==DMODE_EXEC )) { +fprintf (stderr,"%s: run as root for tracing and listing probes\n" , g_pname); +return E_USAGE ; + } +/* * If we're in linker mode and the data model hasn't been specified, * we try to guess the appropriate setting by examining the object Signature · 7 lines
2.43.5 _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel