All pastes #41492 Raw Edit

puzzled

public text v1 · immutable
#41492 ·published 2006-02-13 22:48 UTC
rendered paste body
> Added prctl() to set dumpable again, which is removed when using
> setuid() and friends. So now coredumps are produced again.
> 
> 
> Modified: openpbx/trunk/corelib/openpbx.c
> ===================================================================
> --- openpbx/trunk/corelib/openpbx.c   2006-02-13 15:29:09 UTC (rev 1370)
> +++ openpbx/trunk/corelib/openpbx.c   2006-02-13 15:47:38 UTC (rev 1371)
> @@ -72,6 +72,7 @@
>  #include <grp.h>
>  #include <pwd.h>
>  #include <sys/stat.h>
> +#include <sys/prctl.h>
>  #include <regex.h>
>  
>  #if  defined(__FreeBSD__) || defined( __NetBSD__ ) || defined(SOLARIS)
> @@ -2138,6 +2139,14 @@
>  
>  #endif
>  
> +     /* after set*id() the dumpable flag is deleted,
> +        so we set it again to get core dumps */
> +     if (option_dumpcore) {
> +             if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
> +                     opbx_log(LOG_ERROR, "Unable to set dumpable flag: %s\n", strerror(errno));
> +             }
> +     }
> +
>       opbx_term_init();
>       printf(opbx_term_end());
>       fflush(stdout);