diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/savecore/savecore.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr/src/cmd/savecore/savecore.c b/usr/src/cmd/savecore/savecore.c index 1315893f0d..4042d8f3ab 100644 --- a/usr/src/cmd/savecore/savecore.c +++ b/usr/src/cmd/savecore/savecore.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ #include <stdio.h> @@ -1501,7 +1502,14 @@ getbounds(const char *f) long b = -1; const char *p = strrchr(f, '/'); - (void) sscanf(p ? p + 1 : f, "vmdump.%ld", &b); + if (p == NULL || strncmp(p, "vmdump", 6) != 0) + p = strstr(f, "vmdump"); + + if (p != NULL && *p == '/') + p++; + + (void) sscanf(p ? p : f, "vmdump.%ld", &b); + return (b); } @@ -1635,6 +1643,7 @@ main(int argc, char *argv[]) struct rlimit rl; long filebounds = -1; char namelist[30], corefile[30], boundstr[30]; + dumpfile = NULL; startts = gethrtime(); @@ -1675,7 +1684,11 @@ main(int argc, char *argv[]) } } - if (geteuid() != 0 && filebounds < 0) { + /* + * If doing something other than extracting an existing dump (i.e. + * dumpfile has been provided as an option), the user must be root. + */ + if (geteuid() != 0 && dumpfile == NULL) { (void) fprintf(stderr, "%s: %s %s\n", progname, gettext("you must be root to use"), progname); exit(1); |