From f9d70f1621950b491ba81528fbb7fdbf7906930e Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Fri, 1 Dec 2017 12:39:56 +0000 Subject: [PATCH] ctf: allow dwarf2ctf to run as root but produce no output This leads to no CTF file writes (and thus no writes) at all, which is as safe as we can get as root: this is treated by the makefiles as an empty CTF file. The resulting module will appear to DTrace to have no types. The warning is still emitted (rephrased slightly). Signed-off-by: Nick Alcock Reviewed-by: Dhaval Giani Orabug: 27205676 --- scripts/dwarf2ctf/dwarf2ctf.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/dwarf2ctf/dwarf2ctf.c b/scripts/dwarf2ctf/dwarf2ctf.c index 516812dbb944..e33d519962f7 100644 --- a/scripts/dwarf2ctf/dwarf2ctf.c +++ b/scripts/dwarf2ctf/dwarf2ctf.c @@ -808,13 +808,18 @@ int main(int argc, char *argv[]) { char *output; - trace = getenv("DWARF2CTF_TRACE"); - if (getuid() == 0 || geteuid() == 0) { - fprintf(stderr, "dwarf2ctf: run as a regular user, not root.\n"); - exit(1); + fprintf(stderr, "dwarf2ctf: root run: doing nothing.\n"); + fprintf(stderr, "CTF type information will not be produced.\n"); + fprintf(stderr, "Please run as a non-root user.\n"); + /* + * Refuse to produce any output. + */ + exit(0); } + trace = getenv("DWARF2CTF_TRACE"); + if ((argc != 4 && argc != 7) || (argc == 4 && strcmp(argv[2], "-e") != 0)) { fprintf(stderr, "Syntax: dwarf2ctf output-file srcdir " -- 2.50.1