Mercurial > illumos > illumos-gate
changeset 14128:615580eeb3d8
3984 savecore erroneously claims you must be root to use it
4021 savecore getbounds() should try harder
Reviewed by: Dave Pacheco <dap@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | Bill Pijewski <wdp@joyent.com> |
---|---|
date | Thu, 08 Aug 2013 14:17:55 -0700 |
parents | 8d9ae184cc0d |
children | 790945ad7848 |
files | usr/src/cmd/savecore/savecore.c |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/savecore/savecore.c Tue Jul 23 21:24:17 2013 +0000 +++ b/usr/src/cmd/savecore/savecore.c Thu Aug 08 14:17:55 2013 -0700 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* * Copyright 2012 Nexenta Systems, Inc. All rights reserved. @@ -1506,7 +1507,14 @@ 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); } @@ -1640,6 +1648,7 @@ struct rlimit rl; long filebounds = -1; char namelist[30], corefile[30], boundstr[30]; + dumpfile = NULL; startts = gethrtime(); @@ -1680,7 +1689,11 @@ } } - 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);