]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ctf: allow dwarf2ctf to run as root but produce no output
authorNick Alcock <nick.alcock@oracle.com>
Fri, 1 Dec 2017 12:39:56 +0000 (12:39 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 4 Dec 2017 23:15:45 +0000 (23:15 +0000)
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 <nick.alcock@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
Orabug: 27205676

scripts/dwarf2ctf/dwarf2ctf.c

index 516812dbb944b5df5a7d85af2725f6191cae2df9..e33d519962f77cb1e29925745d74bf9e1f27661d 100644 (file)
@@ -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 "