Changeset 740 for vendor/current/source3/lib/fault.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/fault.c
r414 r740 20 20 21 21 #include "includes.h" 22 #include "system/filesys.h" 22 23 23 24 #ifdef HAVE_SYS_SYSCTL_H … … 55 56 cont_fn(NULL); 56 57 #ifdef SIGSEGV 57 CatchSignal(SIGSEGV, SIGNAL_CASTSIG_DFL);58 CatchSignal(SIGSEGV, SIG_DFL); 58 59 #endif 59 60 #ifdef SIGBUS 60 CatchSignal(SIGBUS, SIGNAL_CASTSIG_DFL);61 CatchSignal(SIGBUS, SIG_DFL); 61 62 #endif 62 63 #ifdef SIGABRT 63 CatchSignal(SIGABRT, SIGNAL_CASTSIG_DFL);64 CatchSignal(SIGABRT, SIG_DFL); 64 65 #endif 65 66 return; /* this should cause a core dump */ … … 84 85 85 86 #ifdef SIGSEGV 86 CatchSignal(SIGSEGV, SIGNAL_CASTsig_fault);87 CatchSignal(SIGSEGV, sig_fault); 87 88 #endif 88 89 #ifdef SIGBUS 89 CatchSignal(SIGBUS, SIGNAL_CASTsig_fault);90 CatchSignal(SIGBUS, sig_fault); 90 91 #endif 91 92 #ifdef SIGABRT 92 CatchSignal(SIGABRT, SIGNAL_CASTsig_fault);93 CatchSignal(SIGABRT, sig_fault); 93 94 #endif 94 95 } … … 193 194 #endif 194 195 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 */ 204 static 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 195 242 /** 196 243 * Try getting system-specific corepath if one exists. … … 201 248 { 202 249 #if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME)) 203 204 /* @todo: Add support for the linux corepath. */205 206 250 char *tmp_corepath = NULL; 207 251 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(); 208 262 209 263 /* If this has been set correctly, we're done. */ … … 267 321 #endif 268 322 269 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)270 /* On Linux we lose the ability to dump core when we change our user271 * ID. We know how to dump core safely, so let's make sure we have our272 * dumpable flag set.273 */274 prctl(PR_SET_DUMPABLE, 1);275 #endif276 277 323 /* FIXME: if we have a core-plus-pid facility, configurably set 278 324 * this up here. … … 305 351 * file to the corepath. There must not be an unbecome_root() before 306 352 * we call abort(). */ 307 if (geteuid() != 0) {353 if (geteuid() != sec_initial_uid()) { 308 354 become_root(); 309 355 } … … 330 376 dbgflush(); 331 377 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 332 386 /* Ensure we don't have a signal handler for abort. */ 333 387 #ifdef SIGABRT 334 CatchSignal(SIGABRT, SIGNAL_CASTSIG_DFL);388 CatchSignal(SIGABRT, SIG_DFL); 335 389 #endif 336 390
Note:
See TracChangeset
for help on using the changeset viewer.