Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/fault.c

    r414 r740  
    2020
    2121#include "includes.h"
     22#include "system/filesys.h"
    2223
    2324#ifdef HAVE_SYS_SYSCTL_H
     
    5556                cont_fn(NULL);
    5657#ifdef SIGSEGV
    57                 CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
     58                CatchSignal(SIGSEGV, SIG_DFL);
    5859#endif
    5960#ifdef SIGBUS
    60                 CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
     61                CatchSignal(SIGBUS, SIG_DFL);
    6162#endif
    6263#ifdef SIGABRT
    63                 CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
     64                CatchSignal(SIGABRT, SIG_DFL);
    6465#endif
    6566                return; /* this should cause a core dump */
     
    8485
    8586#ifdef SIGSEGV
    86         CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
     87        CatchSignal(SIGSEGV, sig_fault);
    8788#endif
    8889#ifdef SIGBUS
    89         CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
     90        CatchSignal(SIGBUS, sig_fault);
    9091#endif
    9192#ifdef SIGABRT
    92         CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
     93        CatchSignal(SIGABRT, sig_fault);
    9394#endif
    9495}
     
    193194#endif
    194195
     196#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
     197
     198/**
     199 * Get the Linux corepath.
     200 *
     201 * On Linux the contents of /proc/sys/kernel/core_pattern indicates the
     202 * location of the core path.
     203 */
     204static char *get_linux_corepath(void)
     205{
     206        char *end;
     207        int fd;
     208        char *result;
     209
     210        fd = open("/proc/sys/kernel/core_pattern", O_RDONLY, 0);
     211        if (fd == -1) {
     212                return NULL;
     213        }
     214
     215        result = afdgets(fd, NULL, 0);
     216        close(fd);
     217
     218        if (result == NULL) {
     219                return NULL;
     220        }
     221
     222        if (result[0] != '/') {
     223                /*
     224                 * No absolute path, use the default (cwd)
     225                 */
     226                TALLOC_FREE(result);
     227                return NULL;
     228        }
     229        /* Strip off the common filename expansion */
     230
     231        end = strrchr_m(result, '/');
     232
     233        if ((end != result) /* this would be the only / */
     234            && (end != NULL)) {
     235                *end = '\0';
     236        }
     237        return result;
     238}
     239#endif
     240
     241
    195242/**
    196243 * Try getting system-specific corepath if one exists.
     
    201248{
    202249#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
    203 
    204         /* @todo: Add support for the linux corepath. */
    205 
    206250        char *tmp_corepath = NULL;
    207251        tmp_corepath = get_freebsd_corepath();
     252
     253        /* If this has been set correctly, we're done. */
     254        if (tmp_corepath) {
     255                return tmp_corepath;
     256        }
     257#endif
     258
     259#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
     260        char *tmp_corepath = NULL;
     261        tmp_corepath = get_linux_corepath();
    208262
    209263        /* If this has been set correctly, we're done. */
     
    267321#endif
    268322
    269 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
    270         /* On Linux we lose the ability to dump core when we change our user
    271          * ID. We know how to dump core safely, so let's make sure we have our
    272          * dumpable flag set.
    273          */
    274         prctl(PR_SET_DUMPABLE, 1);
    275 #endif
    276 
    277323        /* FIXME: if we have a core-plus-pid facility, configurably set
    278324         * this up here.
     
    305351         * file to the corepath.  There must not be an unbecome_root() before
    306352         * we call abort(). */
    307         if (geteuid() != 0) {
     353        if (geteuid() != sec_initial_uid()) {
    308354                become_root();
    309355        }
     
    330376        dbgflush();
    331377
     378#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
     379        /* On Linux we lose the ability to dump core when we change our user
     380         * ID. We know how to dump core safely, so let's make sure we have our
     381         * dumpable flag set.
     382         */
     383        prctl(PR_SET_DUMPABLE, 1);
     384#endif
     385
    332386        /* Ensure we don't have a signal handler for abort. */
    333387#ifdef SIGABRT
    334         CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
     388        CatchSignal(SIGABRT, SIG_DFL);
    335389#endif
    336390
Note: See TracChangeset for help on using the changeset viewer.