Project

General

Profile

Bug #3984

savecore erroneously claims you must be root to use it

Added by Robert Mustacchi over 6 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
cmd - userland programs
Start date:
2013-08-04
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

When trying to extract crash dumps on "stuff", savecore sometimes erroneously bombs out saying "you must be root to use savecore":

[stuff@bh1-autobuild ~/cores/HVM-698]$ savecore -f ./46VY9R1-vmdump.2 .
savecore: you must be root to use savecore

That's wrong. You shouldn't need to be root to extract an existing crash dump, and I know I've done this successfully before.

The problem is here:

1678         if (geteuid() != 0 && filebounds < 0) {
1679                 (void) fprintf(stderr, "%s: %s %s\\n", progname,
1680                     gettext("you must be root to use"), progname);
1681                 exit(1);
1682         }

filebounds comes from the getopt call:

1669                 case 'f':
1670                         dumpfile = optarg;
1671                         filebounds = getbounds(dumpfile);

which comes from getbounds():

1498 static long
1499 getbounds(const char *f)
1500 {
1501         long b = -1;
1502         const char *p = strrchr(f, '/');
1503                 
1504         (void) sscanf(p ? p + 1 : f, "vmdump.%ld", &b);
1505         return (b);
1506 }

Note that if the basename of the filename doesn't start with vmdump, sscanf will fail and this function will return -1. Then savecore bombs out.

If you rename the crash dump or even just symlink it, it works fine:

[stuff@bh1-autobuild ~/cores/HVM-698]$ ln -s 46VY9R1-vmdump.2 vmdump.2
[stuff@bh1-autobuild ~/cores/HVM-698]$ savecore -f ./vmdump.2 .
savecore: System dump time: Mon Nov 21 16:42:34 2011

savecore: saving system crash dump in ./{unix,vmcore}.2
Constructing namelist ./unix.2
Constructing corefile ./vmcore.2
 0:29 100% done: 1931201 of 1931201 pages saved

There are two distinct problems fixed as part of this change:

1. The getbounds() function will try harder to find the dump number if the dump is not exactly named 'vmdump.N'.
2. The check for whether the effective UID is 0 now takes into account whether the user wants to read a dump from the dump device, take a live crash dump, or extract an existing crash dump. If the user is trying to do something other than extract an existing crash dump, savecore will continue to report that only the root user can perform those operations.

History

#1

Updated by Robert Mustacchi over 6 years ago

  • Status changed from Pending RTI to Resolved

Resolved in ae449904a90a5ea664537524927d1e6c0c1b11cd.

Also available in: Atom PDF