488 // or /tmp then this is the trigger to start the attach mechanism 489 bool AttachListener::is_init_trigger() { 490 if (init_at_startup() || is_initialized()) { 491 return false; // initialized at startup or already initialized 492 } 493 char fn[PATH_MAX+1]; 494 sprintf(fn, ".attach_pid%d", os::current_process_id()); 495 int ret; 496 struct stat64 st; 497 RESTARTABLE(::stat64(fn, &st), ret); 498 if (ret == -1) { 499 snprintf(fn, sizeof(fn), "%s/.attach_pid%d", 500 os::get_temp_directory(), os::current_process_id()); 501 RESTARTABLE(::stat64(fn, &st), ret); 502 } 503 if (ret == 0) { 504 // simple check to avoid starting the attach mechanism when 505 // a bogus user creates the file 506 if (st.st_uid == geteuid()) { 507 init(); 508 return true; 509 } 510 } 511 return false; 512 } 513 514 // if VM aborts then remove listener 515 void AttachListener::abort() { 516 listener_cleanup(); 517 } 518 519 void AttachListener::pd_data_dump() { 520 os::signal_notify(SIGQUIT); 521 } 522 523 AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) { 524 return NULL; 525 } 526 527 jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) { 528 out->print_cr("flag '%s' cannot be changed", op->arg(0)); | 488 // or /tmp then this is the trigger to start the attach mechanism 489 bool AttachListener::is_init_trigger() { 490 if (init_at_startup() || is_initialized()) { 491 return false; // initialized at startup or already initialized 492 } 493 char fn[PATH_MAX+1]; 494 sprintf(fn, ".attach_pid%d", os::current_process_id()); 495 int ret; 496 struct stat64 st; 497 RESTARTABLE(::stat64(fn, &st), ret); 498 if (ret == -1) { 499 snprintf(fn, sizeof(fn), "%s/.attach_pid%d", 500 os::get_temp_directory(), os::current_process_id()); 501 RESTARTABLE(::stat64(fn, &st), ret); 502 } 503 if (ret == 0) { 504 // simple check to avoid starting the attach mechanism when 505 // a bogus user creates the file 506 if (st.st_uid == geteuid()) { 507 init(); 508 log_trace(attach)("Attach trigerred by %s", fn); 509 return true; 510 } 511 else { 512 log_debug(attach)("File %s has wrong user id %d (vs %d). Attach is not trigerred", fn, st.st_uid, geteuid()); 513 } 514 } 515 return false; 516 } 517 518 // if VM aborts then remove listener 519 void AttachListener::abort() { 520 listener_cleanup(); 521 } 522 523 void AttachListener::pd_data_dump() { 524 os::signal_notify(SIGQUIT); 525 } 526 527 AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) { 528 return NULL; 529 } 530 531 jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) { 532 out->print_cr("flag '%s' cannot be changed", op->arg(0)); |