diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 5 | ||||
-rw-r--r-- | common/sysutils.c | 37 | ||||
-rw-r--r-- | common/sysutils.h | 1 |
3 files changed, 36 insertions, 7 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index 8e81baa0c..a39f17aaa 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,8 @@ +2004-05-11 Werner Koch <[email protected]> + + * sysutils.c (disable_core_dumps): Only set the current limit. + (enable_core_dumps): New. + 2004-04-13 Werner Koch <[email protected]> * simple-pwquery.c (copy_and_escape): Relaxed quoting. diff --git a/common/sysutils.c b/common/sysutils.c index 4948af57f..97fa23d95 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -70,21 +70,44 @@ trap_unaligned(void) int disable_core_dumps (void) { - #ifdef HAVE_DOSISH_SYSTEM +#ifdef HAVE_DOSISH_SYSTEM return 0; - #else - #ifdef HAVE_SETRLIMIT +#else +# ifdef HAVE_SETRLIMIT struct rlimit limit; + /* We only set the current limit unless we were not able to + retrieve the old value. */ + if (getrlimit (RLIMIT_CORE, &limit)) + limit.rlim_max = 0; limit.rlim_cur = 0; - limit.rlim_max = 0; - if( !setrlimit( RLIMIT_CORE, &limit ) ) + if( !setrlimit (RLIMIT_CORE, &limit) ) return 0; if( errno != EINVAL && errno != ENOSYS ) log_fatal (_("can't disable core dumps: %s\n"), strerror(errno) ); - #endif +#endif + return 1; +#endif +} + +int +enable_core_dumps (void) +{ +#ifdef HAVE_DOSISH_SYSTEM + return 0; +#else +# ifdef HAVE_SETRLIMIT + struct rlimit limit; + + if (getrlimit (RLIMIT_CORE, &limit)) + return 1; + limit.rlim_cur = limit.rlim_max; + setrlimit (RLIMIT_CORE, &limit); + return 1; /* We always return true because trhis function is + merely a debugging aid. */ +#endif return 1; - #endif +#endif } diff --git a/common/sysutils.h b/common/sysutils.h index f2054d468..66f714acd 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -23,6 +23,7 @@ void trap_unaligned (void); int disable_core_dumps (void); +int enable_core_dumps (void); const unsigned char *get_session_marker (size_t *rlen); int check_permissions (const char *path,int extension,int checkonly); |