diff options
author | Bill Pijewski <wdp@joyent.com> | 2012-01-19 17:16:05 -0800 |
---|---|---|
committer | Bill Pijewski <wdp@joyent.com> | 2012-01-19 17:16:05 -0800 |
commit | d146a643cd6cf8be11d8798c24c7f2b22f355449 (patch) | |
tree | d5ccc392a84db785717cc89b65e3080c0225a2bf /usr/src | |
parent | 3c0c7a22cb3d25a40343dbabea38c3fe481213d1 (diff) | |
download | illumos-joyent-d146a643cd6cf8be11d8798c24c7f2b22f355449.tar.gz |
OS-764 savecore erroneously claims you must be root to use it
Reviewed by: Dave Pacheco <dap@joyent.com>
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); |