... | ... |
@@ -4471,7 +4471,7 @@ fi |
4471 | 4471 |
done |
4472 | 4472 |
|
4473 | 4473 |
|
4474 |
-for ac_header in arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h utime.h |
|
4474 |
+for ac_header in arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h utime.h sys/prctl.h |
|
4475 | 4475 |
do : |
4476 | 4476 |
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
4477 | 4477 |
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" |
... | ... |
@@ -17,7 +17,7 @@ AC_CHECK_LIB(socket, socket) |
17 | 17 |
AC_CHECK_LIB(nsl, inet_addr) |
18 | 18 |
|
19 | 19 |
# Checks for header files. |
20 |
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h utime.h]) |
|
20 |
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h utime.h sys/prctl.h]) |
|
21 | 21 |
AC_CHECK_HEADERS(openssl/md5.h openssl/blowfish.h,,[AC_MSG_ERROR([Can't found openssl header file])]) |
22 | 22 |
|
23 | 23 |
# Checks for typedefs, structures, and compiler characteristics. |
... | ... |
@@ -33,7 +33,6 @@ |
33 | 33 |
#include <sys/un.h> |
34 | 34 |
#include <sys/time.h> |
35 | 35 |
#include <sys/utsname.h> |
36 |
-#include <sys/prctl.h> |
|
37 | 36 |
#include <sys/resource.h> |
38 | 37 |
#include <arpa/inet.h> |
39 | 38 |
#include <netinet/in.h> |
... | ... |
@@ -278,6 +277,8 @@ typedef struct |
278 | 278 |
int lisocket; |
279 | 279 |
int cryptena; |
280 | 280 |
int comm_ena; |
281 |
+ int core_ena; |
|
282 |
+ int coresize; |
|
281 | 283 |
int commpass; |
282 | 284 |
int ownmatch; |
283 | 285 |
int parallel; |
... | ... |
@@ -285,7 +286,6 @@ typedef struct |
285 | 285 |
int sendsize; |
286 | 286 |
int sendready; |
287 | 287 |
int sendrate; |
288 |
- int coresize; |
|
289 | 288 |
struct utsname uts; |
290 | 289 |
struct sockaddr_in maddr; |
291 | 290 |
struct sockaddr_in iaddr; |
... | ... |
@@ -3,6 +3,9 @@ |
3 | 3 |
* Copyright (C) 2008-2012 KLab Inc. |
4 | 4 |
*/ |
5 | 5 |
#include "makuosan.h" |
6 |
+#ifdef HAVE_SYS_PRCTL_H |
|
7 |
+#include <sys/prctl.h> |
|
8 |
+#endif |
|
6 | 9 |
|
7 | 10 |
static void version_print() |
8 | 11 |
{ |
... | ... |
@@ -311,12 +314,13 @@ static void minit_getopt(int argc, char *argv[]) |
311 | 311 |
int r; |
312 | 312 |
struct option opt[]={ |
313 | 313 |
{"chroot", 0, NULL, 'c'}, |
314 |
+ {"core", 0, NULL, 'C'}, |
|
314 | 315 |
{"help", 0, NULL, 'h'}, |
315 | 316 |
{"version", 0, NULL, 'V'}, |
316 | 317 |
{0, 0, 0, 0} |
317 | 318 |
}; |
318 | 319 |
|
319 |
- while((r=getopt_long(argc, argv, "T:R:S:f:u:g:G:d:b:p:m:i:l:U:k:K:VhnsroOc", opt, NULL)) != -1){ |
|
320 |
+ while((r=getopt_long(argc, argv, "T:R:S:f:u:g:G:d:b:p:m:i:l:U:k:K:VhnsroOcC", opt, NULL)) != -1){ |
|
320 | 321 |
switch(r){ |
321 | 322 |
case 'V': |
322 | 323 |
version_print(); |
... | ... |
@@ -364,6 +368,10 @@ static void minit_getopt(int argc, char *argv[]) |
364 | 364 |
moption.comm_ena = 0; |
365 | 365 |
break; |
366 | 366 |
|
367 |
+ case 'C': |
|
368 |
+ moption.core_ena = 1; |
|
369 |
+ break; |
|
370 |
+ |
|
367 | 371 |
case 'c': |
368 | 372 |
moption.chroot = 1; |
369 | 373 |
break; |
... | ... |
@@ -616,17 +624,21 @@ static void minit_setguid() |
616 | 616 |
|
617 | 617 |
static void minit_enable_core() |
618 | 618 |
{ |
619 |
- struct rlimit r; |
|
620 |
- if(prctl(PR_SET_DUMPABLE, 1) == -1){ |
|
621 |
- fprintf(stderr, "%s: prctl error: %s\n", __func__, strerror(errno)); |
|
622 |
- } |
|
623 |
- r.rlim_cur = 0; |
|
624 |
- r.rlim_max = 0; |
|
619 |
+ struct rlimit r = {0, 0}; |
|
625 | 620 |
if(getrlimit(RLIMIT_CORE, &r) == -1){ |
626 | 621 |
fprintf(stderr, "%s: getrlimit error: %s\n", __func__, strerror(errno)); |
627 | 622 |
exit(1); |
628 | 623 |
} |
629 |
- r.rlim_cur = -1; |
|
624 |
+ moption.coresize = (int)(r.rlim_cur); |
|
625 |
+ if(!moption.core_ena){ |
|
626 |
+ return; |
|
627 |
+ } |
|
628 |
+#ifdef HAVE_SYS_PRCTL_H |
|
629 |
+ if(prctl(PR_SET_DUMPABLE, 1) == -1){ |
|
630 |
+ fprintf(stderr, "%s: prctl error: %s\n", __func__, strerror(errno)); |
|
631 |
+ } |
|
632 |
+#endif |
|
633 |
+ r.rlim_cur = r.rlim_max; |
|
630 | 634 |
if(setrlimit(RLIMIT_CORE, &r) == -1){ |
631 | 635 |
fprintf(stderr, "%s: setrlimit error: %s\n", __func__, strerror(errno)); |
632 | 636 |
exit(1); |
... | ... |
@@ -682,7 +694,7 @@ static void minit_bootlog() |
682 | 682 |
lprintf(0, "makuosan version %s\n", PACKAGE_VERSION); |
683 | 683 |
lprintf(0, "sysname : %s\n", moption.uts.sysname); |
684 | 684 |
lprintf(0, "loglevel : %d\n", moption.loglevel); |
685 |
- if(moption.coresize == -1){ |
|
685 |
+ if(moption.coresize == (int)RLIM_INFINITY){ |
|
686 | 686 |
lprintf(0, "coresize : unlimited\n"); |
687 | 687 |
}else{ |
688 | 688 |
lprintf(0, "coresize : %d\n", moption.coresize); |