Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/lib/fault.c

    r454 r745  
    2020
    2121#include "includes.h"
     22#include "system/filesys.h"
    2223
    2324#ifdef HAVE_SYS_SYSCTL_H
     
    5657#ifndef __OS2__ /* don't use the built in signal capture stuff - prefer native handling of errors */
    5758#ifdef SIGSEGV
    58                 CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
     59                CatchSignal(SIGSEGV, SIG_DFL);
    5960#endif
    6061#ifdef SIGBUS
    61                 CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
     62                CatchSignal(SIGBUS, SIG_DFL);
    6263#endif
    6364#ifdef SIGABRT
    64                 CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
     65                CatchSignal(SIGABRT, SIG_DFL);
    6566#endif
    6667#endif
     
    8788#ifndef __OS2__ /* don't use the built in signal capture stuff - prefer native handling of errors */
    8889#ifdef SIGSEGV
    89         CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
     90        CatchSignal(SIGSEGV, sig_fault);
    9091#endif
    9192#ifdef SIGBUS
    92         CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
     93        CatchSignal(SIGBUS, sig_fault);
    9394#endif
    9495#ifdef SIGABRT
    95         CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
     96        CatchSignal(SIGABRT, sig_fault);
    9697#endif
    9798#endif
     
    197198#endif
    198199
     200#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
     201
     202/**
     203 * Get the Linux corepath.
     204 *
     205 * On Linux the contents of /proc/sys/kernel/core_pattern indicates the
     206 * location of the core path.
     207 */
     208static char *get_linux_corepath(void)
     209{
     210        char *end;
     211        int fd;
     212        char *result;
     213
     214        fd = open("/proc/sys/kernel/core_pattern", O_RDONLY, 0);
     215        if (fd == -1) {
     216                return NULL;
     217        }
     218
     219        result = afdgets(fd, NULL, 0);
     220        close(fd);
     221
     222        if (result == NULL) {
     223                return NULL;
     224        }
     225
     226        if (result[0] != '/') {
     227                /*
     228                 * No absolute path, use the default (cwd)
     229                 */
     230                TALLOC_FREE(result);
     231                return NULL;
     232        }
     233        /* Strip off the common filename expansion */
     234
     235        end = strrchr_m(result, '/');
     236
     237        if ((end != result) /* this would be the only / */
     238            && (end != NULL)) {
     239                *end = '\0';
     240        }
     241        return result;
     242}
     243#endif
     244
     245
    199246/**
    200247 * Try getting system-specific corepath if one exists.
     
    205252{
    206253#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
    207 
    208         /* @todo: Add support for the linux corepath. */
    209 
    210254        char *tmp_corepath = NULL;
    211255        tmp_corepath = get_freebsd_corepath();
     256
     257        /* If this has been set correctly, we're done. */
     258        if (tmp_corepath) {
     259                return tmp_corepath;
     260        }
     261#endif
     262
     263#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
     264        char *tmp_corepath = NULL;
     265        tmp_corepath = get_linux_corepath();
    212266
    213267        /* If this has been set correctly, we're done. */
     
    271325#endif
    272326
    273 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
    274         /* On Linux we lose the ability to dump core when we change our user
    275          * ID. We know how to dump core safely, so let's make sure we have our
    276          * dumpable flag set.
    277          */
    278         prctl(PR_SET_DUMPABLE, 1);
    279 #endif
    280 
    281327        /* FIXME: if we have a core-plus-pid facility, configurably set
    282328         * this up here.
     
    309355         * file to the corepath.  There must not be an unbecome_root() before
    310356         * we call abort(). */
    311         if (geteuid() != 0) {
     357        if (geteuid() != sec_initial_uid()) {
    312358                become_root();
    313359        }
     
    334380        dbgflush();
    335381
     382#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
     383        /* On Linux we lose the ability to dump core when we change our user
     384         * ID. We know how to dump core safely, so let's make sure we have our
     385         * dumpable flag set.
     386         */
     387        prctl(PR_SET_DUMPABLE, 1);
     388#endif
     389
    336390        /* Ensure we don't have a signal handler for abort. */
    337391#ifdef SIGABRT
    338         CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
     392        CatchSignal(SIGABRT, SIG_DFL);
    339393#endif
    340394
Note: See TracChangeset for help on using the changeset viewer.