|
Lines 90-95
Link Here
|
| 90 |
#include <machine/cpu.h> |
90 |
#include <machine/cpu.h> |
| 91 |
|
91 |
|
| 92 |
#include <security/audit/audit.h> |
92 |
#include <security/audit/audit.h> |
|
|
93 |
#include <sys/libkern.h> |
| 93 |
|
94 |
|
| 94 |
#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ |
95 |
#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ |
| 95 |
|
96 |
|
|
Lines 3205-3240
Link Here
|
| 3205 |
} |
3206 |
} |
| 3206 |
|
3207 |
|
| 3207 |
/* |
3208 |
/* |
| 3208 |
* We only have 1 character for the core count in the format |
3209 |
* We limit the number of core files |
| 3209 |
* string, so the range will be 0-9 |
|
|
| 3210 |
*/ |
3210 |
*/ |
| 3211 |
#define MAX_NUM_CORE_FILES 10 |
|
|
| 3212 |
#ifndef NUM_CORE_FILES |
3211 |
#ifndef NUM_CORE_FILES |
| 3213 |
#define NUM_CORE_FILES 5 |
3212 |
#define NUM_CORE_FILES 5 |
| 3214 |
#endif |
3213 |
#endif |
| 3215 |
CTASSERT(NUM_CORE_FILES >= 0 && NUM_CORE_FILES <= MAX_NUM_CORE_FILES); |
3214 |
static unsigned int num_cores = NUM_CORE_FILES; |
| 3216 |
static int num_cores = NUM_CORE_FILES; |
3215 |
SYSCTL_UINT(_debug, OID_AUTO, ncores, CTLFLAG_RW, &num_cores, 0, ""); |
| 3217 |
|
3216 |
|
| 3218 |
static int |
|
|
| 3219 |
sysctl_debug_num_cores_check (SYSCTL_HANDLER_ARGS) |
| 3220 |
{ |
| 3221 |
int error; |
| 3222 |
int new_val; |
| 3223 |
|
| 3224 |
new_val = num_cores; |
| 3225 |
error = sysctl_handle_int(oidp, &new_val, 0, req); |
| 3226 |
if (error != 0 || req->newptr == NULL) |
| 3227 |
return (error); |
| 3228 |
if (new_val > MAX_NUM_CORE_FILES) |
| 3229 |
new_val = MAX_NUM_CORE_FILES; |
| 3230 |
if (new_val < 0) |
| 3231 |
new_val = 0; |
| 3232 |
num_cores = new_val; |
| 3233 |
return (0); |
| 3234 |
} |
| 3235 |
SYSCTL_PROC(_debug, OID_AUTO, ncores, CTLTYPE_INT|CTLFLAG_RW, |
| 3236 |
0, sizeof(int), sysctl_debug_num_cores_check, "I", ""); |
| 3237 |
|
| 3238 |
#define GZ_SUFFIX ".gz" |
3217 |
#define GZ_SUFFIX ".gz" |
| 3239 |
|
3218 |
|
| 3240 |
#ifdef GZIO |
3219 |
#ifdef GZIO |
|
Lines 3293-3299
Link Here
|
| 3293 |
struct sbuf sb; |
3272 |
struct sbuf sb; |
| 3294 |
const char *format; |
3273 |
const char *format; |
| 3295 |
char *hostname, *name; |
3274 |
char *hostname, *name; |
| 3296 |
int indexpos, i, error, cmode, flags, oflags; |
3275 |
int error, cmode, flags, oflags; |
|
|
3276 |
unsigned int i, j, indexpos, endnamelen, slotthreshold, remainder; |
| 3297 |
|
3277 |
|
| 3298 |
hostname = NULL; |
3278 |
hostname = NULL; |
| 3299 |
format = corefilename; |
3279 |
format = corefilename; |
|
Lines 3368-3376
Link Here
|
| 3368 |
* non-existing core file name to use. |
3348 |
* non-existing core file name to use. |
| 3369 |
*/ |
3349 |
*/ |
| 3370 |
if (indexpos != -1) { |
3350 |
if (indexpos != -1) { |
|
|
3351 |
slotthreshold = 10; |
| 3352 |
endnamelen = strlen(name + indexpos) + 1; |
| 3371 |
for (i = 0; i < num_cores; i++) { |
3353 |
for (i = 0; i < num_cores; i++) { |
|
|
3354 |
if (i >= slotthreshold) { |
| 3355 |
if (indexpos + 2 + endnamelen > MAXPATHLEN) { |
| 3356 |
error = 1; |
| 3357 |
goto out; |
| 3358 |
} |
| 3359 |
|
| 3360 |
memmove(name + indexpos + 1, name + indexpos, endnamelen); |
| 3361 |
indexpos++; |
| 3362 |
slotthreshold *= 10; |
| 3363 |
} |
| 3364 |
remainder = i; |
| 3365 |
for (j = 0; remainder; ++j) { |
| 3366 |
name[indexpos - j] = '0' + (remainder % 10); |
| 3367 |
remainder /= 10; |
| 3368 |
} |
| 3369 |
|
| 3372 |
flags = O_CREAT | O_EXCL | FWRITE | O_NOFOLLOW; |
3370 |
flags = O_CREAT | O_EXCL | FWRITE | O_NOFOLLOW; |
| 3373 |
name[indexpos] = '0' + i; |
|
|
| 3374 |
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); |
3371 |
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); |
| 3375 |
error = vn_open_cred(&nd, &flags, cmode, oflags, |
3372 |
error = vn_open_cred(&nd, &flags, cmode, oflags, |
| 3376 |
td->td_ucred, NULL); |
3373 |
td->td_ucred, NULL); |