[DTrace-devel] [PATCH 3/7] Generate clearer error message when dtrace is run not as root

eugene.loh at oracle.com eugene.loh at oracle.com
Tue Mar 12 01:00:53 UTC 2024


From: Eugene Loh <eugene.loh at oracle.com>

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 <eugene.loh at oracle.com>
---
 libdtrace/dt_bpf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index 56b342e8..7b491f3d 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -65,6 +65,10 @@ dt_bpf_error(dtrace_hdl_t *dtp, const char *fmt, ...)
 int
 dt_bpf_lockmem_error(dtrace_hdl_t *dtp, const char *msg)
 {
+	if (getuid() != 0)
+		return dt_bpf_error(dtp, "%s:\n"
+				    "\tMost DTrace uses require root permission.\n"
+				    , msg);
 	return dt_bpf_error(dtp, "%s:\n"
 			    "\tThe kernel locked-memory limit is possibly too low.  Set a\n"
 			    "\thigher limit with the DTrace option '-xlockmem=N'.  Or, use\n"
-- 
2.18.4




More information about the DTrace-devel mailing list