Commit Graph

100 Commits

Author SHA1 Message Date
tb edb24a371b Savecore uses its own private copy of compress, so it should
not include <zlib.h>

discussed with deraadt
2022-03-25 16:14:55 +00:00
deraadt b7041c0781 For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert
2021-10-24 21:24:15 +00:00
deraadt df69c215c7 When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
2019-06-28 13:32:41 +00:00
deraadt 7aa9f692dc dev_t is signed to permit passing -1 as an invalid condition, but the
decomposition into major and minor is unsigned, so we should print them
with %u instead of %d.
ok guenther
2019-02-05 02:17:32 +00:00
yasuoka 1e6179e5e9 Unbreak "savecore -c". Also add missing unveil(2) for the raw device.
ok mestre
2018-12-05 05:04:12 +00:00
mestre b1ce0718ea add missing unveil(2) of an arbitrary kernel (when -N is used), or _PATH_UNIX by
default, with read permissions.

report and fix provided by semarie@
OK deraadt@
2018-09-28 14:03:14 +00:00
deraadt e18d1965d1 After opening required descriptors, savecore only plays in one directory
so use unveil(2).
2018-09-24 21:26:38 +00:00
krw 85b33b0351 tedu@ didn't take the getcode() prototype with the getcode() implementation.
Restore gcc's equanimity by tedu@'ing the prototype.
2017-01-22 01:55:08 +00:00
tedu 141245ff1b chop out the zread code since we only write files 2016-09-04 15:45:27 +00:00
tedu df5aa7dacf unifdef SAVECORE now that we're done sharing 2016-09-04 15:43:51 +00:00
tedu 96dc1bb701 proving once again my commit and somebody will test strategy works,
deraadt found that savecore also uses a source file from compress.
add (6.0 versions) of the needed files to permit progress elsewhere.
2016-09-03 13:05:08 +00:00
tedu 6c5fbaeafe make the version symbol a fixed size (512) to reduce the potential for
bad effects when savecore reads beyond it
ok deraadt (and thanks to bluhm for remembering that this happens)
2016-09-01 14:12:07 +00:00
guenther 001de9cd55 Drop support for the undocumented second argument (same as -N option)
ok deraadt@
2016-07-04 04:05:29 +00:00
deraadt 9454a018db after kmem is open and setup, pledge "stdio rpath wpath cpath"
seems to be working.  commiting to get feedback from people who crash.
2015-10-18 03:17:48 +00:00
deraadt b4d2277740 Collapse some strange programmer style with too much abstraction. 2015-10-18 03:13:07 +00:00
guenther ccc73f79b0 Fix glitches in previous commit: strip the \n and only complain on failure
ok deraadt@
2015-04-26 01:23:19 +00:00
deraadt a47b6461a1 Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
2015-04-18 18:28:36 +00:00
millert f7055df57d tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time.  This makes the
tree safe for /usr/include/tzfile.h removal.  The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree.  Actual removal of tzfile.h is pending
a ports build.  Based on a diff from deraadt@
2015-03-15 00:41:27 +00:00
deraadt b9fc9a728f Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
2015-01-16 06:39:28 +00:00
jmc 73d4fc9bd5 no longer any need to quote macro lines with >9 args;
From: Jan Stary
2013-08-14 06:32:26 +00:00
tedu 5e607bd640 dependent clause requires a subject (comment grammar) 2013-06-03 02:49:42 +00:00
deraadt 043fbe51c1 rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms
2009-10-27 23:59:19 +00:00
millert e5764fd94a If the user didn't specify a kernel, pass in NULL to kvm_openfiles()
so it can try /dev/ksyms.  The first call to kvm_openfiles()
was already correct.
2009-06-20 00:15:14 +00:00
miod bfeb76b5e2 Use different variables for the dump offset in blocks and the dump offset
in bytes; this allows us to get rid of many off_t casts, and ensures
proper operation on very large swap partitions on 32 bit machines.

From Pierre Riteau.
2009-01-17 13:48:50 +00:00
miod 0bf9ded8ec Handle kernel core files larger than 2GB; ok dlg@ 2009-01-02 16:17:53 +00:00
sobrado 85b719f4d2 sync synopsis and usage; documentation tweaks.
ok jmc@
2008-09-10 22:17:33 +00:00
jmc aaaa14ed3c +.Xr crash 8 ,
from Stephan A. Rickauer
2008-07-18 22:44:21 +00:00
chl efba6f5083 remove some warnings:
unused variable `variable'
`variable' might be used uninitialized in this function

ok gilles@ ray@
2007-09-14 14:29:20 +00:00
gilles 712678dfc6 use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
2007-09-11 15:21:05 +00:00
jmc 9490d37cb6 convert to new .Dd format; 2007-05-31 19:19:00 +00:00
kettenis 67e336db69 Add -DSAVECORE to CFLAGS instead of overriding it.
ok miod@, deraadt@
2006-06-16 23:49:00 +00:00
otto d35fceb546 There's a dependency on the compress API that changed 2005-06-26 18:21:25 +00:00
millert 3db3aa692d Use fstatfs(), not statfs() to determine free space so if /var/crash
is a link we follow it.  OK deraadt@ jcs@
2005-01-07 21:57:10 +00:00
deraadt 4d06cdbc41 removed unused; avoid aliasing to libc functions 2004-09-15 18:52:29 +00:00
tholo 78e31c9e11 Use "time_second" instead of "time" now that time handling in the kernel
has changed.

ok art@ millert@ marc@
2004-07-02 13:09:04 +00:00
otto 4a2546bcfe Use correct type for magic number.
ok marc@ millert@
2004-01-13 21:03:34 +00:00
espie 63aea25978 zap bizarre log() prototype.
Doesn't even change the resulting binary (thank Ian Darwin for that idea)
2003-12-28 04:09:13 +00:00
marc 9bd0c10ab1 fix savecore on big endian 64 bit arches. OK millert@ 2003-11-15 20:25:17 +00:00
deraadt b5e17218f0 spaces 2003-07-29 18:38:35 +00:00
deraadt 9fb93924fa boring cleanups 2003-06-10 16:41:28 +00:00
jmc 2b65e200c8 - section reorder
- some mdoc fixes
2003-06-03 13:16:07 +00:00
millert 1ef0d7102c Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.
2003-06-02 20:06:14 +00:00
mickey 946ed80b20 fix null deref in error syslogging 2003-04-08 00:12:00 +00:00
deraadt 926fcf91f9 strlcat, and it counted srclen, not dstlen; ok millert 2003-04-07 23:04:06 +00:00
deraadt bc52e260ac ansi 2002-07-03 22:32:32 +00:00
deraadt 790f545111 oops, backwards length check; moritz@jodeit.org 2002-05-22 20:09:36 +00:00
deraadt dcab0d1619 strcpy, sprintf death; mpech ok 2002-05-22 08:21:01 +00:00
millert c72b5b24e1 Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically. 2002-02-16 21:27:05 +00:00
mpech e073c79dd8 kill more registers;
millert@ ok
2001-11-05 07:39:16 +00:00
deraadt a4df03212d major -Wall cleanup, almost complete 2001-07-07 18:26:09 +00:00