diff options
author | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2018-12-05 05:04:13 +0000 |
---|---|---|
committer | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2018-12-05 05:04:13 +0000 |
commit | 143a20ac9ee58c51234b359ce6f42938f423369b (patch) | |
tree | d36a4c933355d54a3de914d24c925d61176e654e | |
parent | 55192cce0c149c14ad0365295d39e6869555e42d (diff) |
Unbreak "savecore -c". Also add missing unveil(2) for the raw device.
ok mestre
-rw-r--r-- | sbin/savecore/savecore.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 53257574006..b72a474c2e5 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savecore.c,v 1.59 2018/09/28 14:03:14 mestre Exp $ */ +/* $OpenBSD: savecore.c,v 1.60 2018/12/05 05:04:12 yasuoka Exp $ */ /* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */ /*- @@ -171,20 +171,24 @@ main(int argc, char *argv[]) (void)time(&now); kmem_setup(); - if (unveil(dirn, "rwc") == -1) { - syslog(LOG_ERR, "unveil: %m"); - exit(1); - } - if (unveil(kernel ? kernel : _PATH_UNIX, "r") == -1) { - syslog(LOG_ERR, "unveil: %m"); - exit(1); - } - if (pledge("stdio rpath wpath cpath", NULL) == -1) { - syslog(LOG_ERR, "pledge: %m"); - exit(1); - } - - if (clear) { + if (!clear) { + if (unveil(dirn, "rwc") == -1) { + syslog(LOG_ERR, "unveil: %m"); + exit(1); + } + if (unveil(kernel ? kernel : _PATH_UNIX, "r") == -1) { + syslog(LOG_ERR, "unveil: %m"); + exit(1); + } + if (unveil(rawname(ddname), "r") == -1) { + syslog(LOG_ERR, "unveil: %m"); + exit(1); + } + if (pledge("stdio rpath wpath cpath", NULL) == -1) { + syslog(LOG_ERR, "pledge: %m"); + exit(1); + } + } else { clear_dump(); return (0); } @@ -375,6 +379,11 @@ dump_exists(void) void clear_dump(void) { + if (pledge("stdio", NULL) == -1) { + syslog(LOG_ERR, "pledge: %m"); + exit(1); + } + if (kvm_dump_inval(kd_dump) == -1) syslog(LOG_ERR, "%s: kvm_clear_dump: %s", ddname, kvm_geterr(kd_dump)); |