Changeset 745 for trunk/server/source3/lib/fault.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/lib/fault.c
r454 r745 20 20 21 21 #include "includes.h" 22 #include "system/filesys.h" 22 23 23 24 #ifdef HAVE_SYS_SYSCTL_H … … 56 57 #ifndef __OS2__ /* don't use the built in signal capture stuff - prefer native handling of errors */ 57 58 #ifdef SIGSEGV 58 CatchSignal(SIGSEGV, SIGNAL_CASTSIG_DFL);59 CatchSignal(SIGSEGV, SIG_DFL); 59 60 #endif 60 61 #ifdef SIGBUS 61 CatchSignal(SIGBUS, SIGNAL_CASTSIG_DFL);62 CatchSignal(SIGBUS, SIG_DFL); 62 63 #endif 63 64 #ifdef SIGABRT 64 CatchSignal(SIGABRT, SIGNAL_CASTSIG_DFL);65 CatchSignal(SIGABRT, SIG_DFL); 65 66 #endif 66 67 #endif … … 87 88 #ifndef __OS2__ /* don't use the built in signal capture stuff - prefer native handling of errors */ 88 89 #ifdef SIGSEGV 89 CatchSignal(SIGSEGV, SIGNAL_CASTsig_fault);90 CatchSignal(SIGSEGV, sig_fault); 90 91 #endif 91 92 #ifdef SIGBUS 92 CatchSignal(SIGBUS, SIGNAL_CASTsig_fault);93 CatchSignal(SIGBUS, sig_fault); 93 94 #endif 94 95 #ifdef SIGABRT 95 CatchSignal(SIGABRT, SIGNAL_CASTsig_fault);96 CatchSignal(SIGABRT, sig_fault); 96 97 #endif 97 98 #endif … … 197 198 #endif 198 199 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 */ 208 static 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 199 246 /** 200 247 * Try getting system-specific corepath if one exists. … … 205 252 { 206 253 #if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME)) 207 208 /* @todo: Add support for the linux corepath. */209 210 254 char *tmp_corepath = NULL; 211 255 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(); 212 266 213 267 /* If this has been set correctly, we're done. */ … … 271 325 #endif 272 326 273 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)274 /* On Linux we lose the ability to dump core when we change our user275 * ID. We know how to dump core safely, so let's make sure we have our276 * dumpable flag set.277 */278 prctl(PR_SET_DUMPABLE, 1);279 #endif280 281 327 /* FIXME: if we have a core-plus-pid facility, configurably set 282 328 * this up here. … … 309 355 * file to the corepath. There must not be an unbecome_root() before 310 356 * we call abort(). */ 311 if (geteuid() != 0) {357 if (geteuid() != sec_initial_uid()) { 312 358 become_root(); 313 359 } … … 334 380 dbgflush(); 335 381 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 336 390 /* Ensure we don't have a signal handler for abort. */ 337 391 #ifdef SIGABRT 338 CatchSignal(SIGABRT, SIGNAL_CASTSIG_DFL);392 CatchSignal(SIGABRT, SIG_DFL); 339 393 #endif 340 394
Note:
See TracChangeset
for help on using the changeset viewer.