src/os/bsd/vm/attachListener_bsd.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5499
195ff07bc7f6
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "runtime/interfaceSupport.hpp"
aoqi@0 27 #include "runtime/os.hpp"
aoqi@0 28 #include "services/attachListener.hpp"
aoqi@0 29 #include "services/dtraceAttacher.hpp"
aoqi@0 30
aoqi@0 31 #include <unistd.h>
aoqi@0 32 #include <signal.h>
aoqi@0 33 #include <sys/types.h>
aoqi@0 34 #include <sys/socket.h>
aoqi@0 35 #include <sys/un.h>
aoqi@0 36 #include <sys/stat.h>
aoqi@0 37
aoqi@0 38 #ifndef UNIX_PATH_MAX
aoqi@0 39 #define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
aoqi@0 40 #endif
aoqi@0 41
aoqi@0 42 // The attach mechanism on Bsd uses a UNIX domain socket. An attach listener
aoqi@0 43 // thread is created at startup or is created on-demand via a signal from
aoqi@0 44 // the client tool. The attach listener creates a socket and binds it to a file
aoqi@0 45 // in the filesystem. The attach listener then acts as a simple (single-
aoqi@0 46 // threaded) server - it waits for a client to connect, reads the request,
aoqi@0 47 // executes it, and returns the response to the client via the socket
aoqi@0 48 // connection.
aoqi@0 49 //
aoqi@0 50 // As the socket is a UNIX domain socket it means that only clients on the
aoqi@0 51 // local machine can connect. In addition there are two other aspects to
aoqi@0 52 // the security:
aoqi@0 53 // 1. The well known file that the socket is bound to has permission 400
aoqi@0 54 // 2. When a client connect, the SO_PEERCRED socket option is used to
aoqi@0 55 // obtain the credentials of client. We check that the effective uid
aoqi@0 56 // of the client matches this process.
aoqi@0 57
aoqi@0 58 // forward reference
aoqi@0 59 class BsdAttachOperation;
aoqi@0 60
aoqi@0 61 class BsdAttachListener: AllStatic {
aoqi@0 62 private:
aoqi@0 63 // the path to which we bind the UNIX domain socket
aoqi@0 64 static char _path[UNIX_PATH_MAX];
aoqi@0 65 static bool _has_path;
aoqi@0 66
aoqi@0 67 // the file descriptor for the listening socket
aoqi@0 68 static int _listener;
aoqi@0 69
aoqi@0 70 static void set_path(char* path) {
aoqi@0 71 if (path == NULL) {
aoqi@0 72 _has_path = false;
aoqi@0 73 } else {
aoqi@0 74 strncpy(_path, path, UNIX_PATH_MAX);
aoqi@0 75 _path[UNIX_PATH_MAX-1] = '\0';
aoqi@0 76 _has_path = true;
aoqi@0 77 }
aoqi@0 78 }
aoqi@0 79
aoqi@0 80 static void set_listener(int s) { _listener = s; }
aoqi@0 81
aoqi@0 82 // reads a request from the given connected socket
aoqi@0 83 static BsdAttachOperation* read_request(int s);
aoqi@0 84
aoqi@0 85 public:
aoqi@0 86 enum {
aoqi@0 87 ATTACH_PROTOCOL_VER = 1 // protocol version
aoqi@0 88 };
aoqi@0 89 enum {
aoqi@0 90 ATTACH_ERROR_BADVERSION = 101 // error codes
aoqi@0 91 };
aoqi@0 92
aoqi@0 93 // initialize the listener, returns 0 if okay
aoqi@0 94 static int init();
aoqi@0 95
aoqi@0 96 static char* path() { return _path; }
aoqi@0 97 static bool has_path() { return _has_path; }
aoqi@0 98 static int listener() { return _listener; }
aoqi@0 99
aoqi@0 100 // write the given buffer to a socket
aoqi@0 101 static int write_fully(int s, char* buf, int len);
aoqi@0 102
aoqi@0 103 static BsdAttachOperation* dequeue();
aoqi@0 104 };
aoqi@0 105
aoqi@0 106 class BsdAttachOperation: public AttachOperation {
aoqi@0 107 private:
aoqi@0 108 // the connection to the client
aoqi@0 109 int _socket;
aoqi@0 110
aoqi@0 111 public:
aoqi@0 112 void complete(jint res, bufferedStream* st);
aoqi@0 113
aoqi@0 114 void set_socket(int s) { _socket = s; }
aoqi@0 115 int socket() const { return _socket; }
aoqi@0 116
aoqi@0 117 BsdAttachOperation(char* name) : AttachOperation(name) {
aoqi@0 118 set_socket(-1);
aoqi@0 119 }
aoqi@0 120 };
aoqi@0 121
aoqi@0 122 // statics
aoqi@0 123 char BsdAttachListener::_path[UNIX_PATH_MAX];
aoqi@0 124 bool BsdAttachListener::_has_path;
aoqi@0 125 int BsdAttachListener::_listener = -1;
aoqi@0 126
aoqi@0 127 // Supporting class to help split a buffer into individual components
aoqi@0 128 class ArgumentIterator : public StackObj {
aoqi@0 129 private:
aoqi@0 130 char* _pos;
aoqi@0 131 char* _end;
aoqi@0 132 public:
aoqi@0 133 ArgumentIterator(char* arg_buffer, size_t arg_size) {
aoqi@0 134 _pos = arg_buffer;
aoqi@0 135 _end = _pos + arg_size - 1;
aoqi@0 136 }
aoqi@0 137 char* next() {
aoqi@0 138 if (*_pos == '\0') {
aoqi@0 139 return NULL;
aoqi@0 140 }
aoqi@0 141 char* res = _pos;
aoqi@0 142 char* next_pos = strchr(_pos, '\0');
aoqi@0 143 if (next_pos < _end) {
aoqi@0 144 next_pos++;
aoqi@0 145 }
aoqi@0 146 _pos = next_pos;
aoqi@0 147 return res;
aoqi@0 148 }
aoqi@0 149 };
aoqi@0 150
aoqi@0 151
aoqi@0 152 // atexit hook to stop listener and unlink the file that it is
aoqi@0 153 // bound too.
aoqi@0 154 extern "C" {
aoqi@0 155 static void listener_cleanup() {
aoqi@0 156 static int cleanup_done;
aoqi@0 157 if (!cleanup_done) {
aoqi@0 158 cleanup_done = 1;
aoqi@0 159 int s = BsdAttachListener::listener();
aoqi@0 160 if (s != -1) {
aoqi@0 161 ::close(s);
aoqi@0 162 }
aoqi@0 163 if (BsdAttachListener::has_path()) {
aoqi@0 164 ::unlink(BsdAttachListener::path());
aoqi@0 165 }
aoqi@0 166 }
aoqi@0 167 }
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 // Initialization - create a listener socket and bind it to a file
aoqi@0 171
aoqi@0 172 int BsdAttachListener::init() {
aoqi@0 173 char path[UNIX_PATH_MAX]; // socket file
aoqi@0 174 char initial_path[UNIX_PATH_MAX]; // socket file during setup
aoqi@0 175 int listener; // listener socket (file descriptor)
aoqi@0 176
aoqi@0 177 // register function to cleanup
aoqi@0 178 ::atexit(listener_cleanup);
aoqi@0 179
aoqi@0 180 int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d",
aoqi@0 181 os::get_temp_directory(), os::current_process_id());
aoqi@0 182 if (n < (int)UNIX_PATH_MAX) {
aoqi@0 183 n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path);
aoqi@0 184 }
aoqi@0 185 if (n >= (int)UNIX_PATH_MAX) {
aoqi@0 186 return -1;
aoqi@0 187 }
aoqi@0 188
aoqi@0 189 // create the listener socket
aoqi@0 190 listener = ::socket(PF_UNIX, SOCK_STREAM, 0);
aoqi@0 191 if (listener == -1) {
aoqi@0 192 return -1;
aoqi@0 193 }
aoqi@0 194
aoqi@0 195 // bind socket
aoqi@0 196 struct sockaddr_un addr;
aoqi@0 197 addr.sun_family = AF_UNIX;
aoqi@0 198 strcpy(addr.sun_path, initial_path);
aoqi@0 199 ::unlink(initial_path);
aoqi@0 200 int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
aoqi@0 201 if (res == -1) {
aoqi@0 202 ::close(listener);
aoqi@0 203 return -1;
aoqi@0 204 }
aoqi@0 205
aoqi@0 206 // put in listen mode, set permissions, and rename into place
aoqi@0 207 res = ::listen(listener, 5);
aoqi@0 208 if (res == 0) {
aoqi@0 209 RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
aoqi@0 210 if (res == 0) {
aoqi@0 211 // make sure the file is owned by the effective user and effective group
aoqi@0 212 // (this is the default on linux, but not on mac os)
aoqi@0 213 RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
aoqi@0 214 if (res == 0) {
aoqi@0 215 res = ::rename(initial_path, path);
aoqi@0 216 }
aoqi@0 217 }
aoqi@0 218 }
aoqi@0 219 if (res == -1) {
aoqi@0 220 ::close(listener);
aoqi@0 221 ::unlink(initial_path);
aoqi@0 222 return -1;
aoqi@0 223 }
aoqi@0 224 set_path(path);
aoqi@0 225 set_listener(listener);
aoqi@0 226
aoqi@0 227 return 0;
aoqi@0 228 }
aoqi@0 229
aoqi@0 230 // Given a socket that is connected to a peer we read the request and
aoqi@0 231 // create an AttachOperation. As the socket is blocking there is potential
aoqi@0 232 // for a denial-of-service if the peer does not response. However this happens
aoqi@0 233 // after the peer credentials have been checked and in the worst case it just
aoqi@0 234 // means that the attach listener thread is blocked.
aoqi@0 235 //
aoqi@0 236 BsdAttachOperation* BsdAttachListener::read_request(int s) {
aoqi@0 237 char ver_str[8];
aoqi@0 238 sprintf(ver_str, "%d", ATTACH_PROTOCOL_VER);
aoqi@0 239
aoqi@0 240 // The request is a sequence of strings so we first figure out the
aoqi@0 241 // expected count and the maximum possible length of the request.
aoqi@0 242 // The request is:
aoqi@0 243 // <ver>0<cmd>0<arg>0<arg>0<arg>0
aoqi@0 244 // where <ver> is the protocol version (1), <cmd> is the command
aoqi@0 245 // name ("load", "datadump", ...), and <arg> is an argument
aoqi@0 246 int expected_str_count = 2 + AttachOperation::arg_count_max;
aoqi@0 247 const int max_len = (sizeof(ver_str) + 1) + (AttachOperation::name_length_max + 1) +
aoqi@0 248 AttachOperation::arg_count_max*(AttachOperation::arg_length_max + 1);
aoqi@0 249
aoqi@0 250 char buf[max_len];
aoqi@0 251 int str_count = 0;
aoqi@0 252
aoqi@0 253 // Read until all (expected) strings have been read, the buffer is
aoqi@0 254 // full, or EOF.
aoqi@0 255
aoqi@0 256 int off = 0;
aoqi@0 257 int left = max_len;
aoqi@0 258
aoqi@0 259 do {
aoqi@0 260 int n;
aoqi@0 261 RESTARTABLE(read(s, buf+off, left), n);
aoqi@0 262 if (n == -1) {
aoqi@0 263 return NULL; // reset by peer or other error
aoqi@0 264 }
aoqi@0 265 if (n == 0) {
aoqi@0 266 break;
aoqi@0 267 }
aoqi@0 268 for (int i=0; i<n; i++) {
aoqi@0 269 if (buf[off+i] == 0) {
aoqi@0 270 // EOS found
aoqi@0 271 str_count++;
aoqi@0 272
aoqi@0 273 // The first string is <ver> so check it now to
aoqi@0 274 // check for protocol mis-match
aoqi@0 275 if (str_count == 1) {
aoqi@0 276 if ((strlen(buf) != strlen(ver_str)) ||
aoqi@0 277 (atoi(buf) != ATTACH_PROTOCOL_VER)) {
aoqi@0 278 char msg[32];
aoqi@0 279 sprintf(msg, "%d\n", ATTACH_ERROR_BADVERSION);
aoqi@0 280 write_fully(s, msg, strlen(msg));
aoqi@0 281 return NULL;
aoqi@0 282 }
aoqi@0 283 }
aoqi@0 284 }
aoqi@0 285 }
aoqi@0 286 off += n;
aoqi@0 287 left -= n;
aoqi@0 288 } while (left > 0 && str_count < expected_str_count);
aoqi@0 289
aoqi@0 290 if (str_count != expected_str_count) {
aoqi@0 291 return NULL; // incomplete request
aoqi@0 292 }
aoqi@0 293
aoqi@0 294 // parse request
aoqi@0 295
aoqi@0 296 ArgumentIterator args(buf, (max_len)-left);
aoqi@0 297
aoqi@0 298 // version already checked
aoqi@0 299 char* v = args.next();
aoqi@0 300
aoqi@0 301 char* name = args.next();
aoqi@0 302 if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
aoqi@0 303 return NULL;
aoqi@0 304 }
aoqi@0 305
aoqi@0 306 BsdAttachOperation* op = new BsdAttachOperation(name);
aoqi@0 307
aoqi@0 308 for (int i=0; i<AttachOperation::arg_count_max; i++) {
aoqi@0 309 char* arg = args.next();
aoqi@0 310 if (arg == NULL) {
aoqi@0 311 op->set_arg(i, NULL);
aoqi@0 312 } else {
aoqi@0 313 if (strlen(arg) > AttachOperation::arg_length_max) {
aoqi@0 314 delete op;
aoqi@0 315 return NULL;
aoqi@0 316 }
aoqi@0 317 op->set_arg(i, arg);
aoqi@0 318 }
aoqi@0 319 }
aoqi@0 320
aoqi@0 321 op->set_socket(s);
aoqi@0 322 return op;
aoqi@0 323 }
aoqi@0 324
aoqi@0 325
aoqi@0 326 // Dequeue an operation
aoqi@0 327 //
aoqi@0 328 // In the Bsd implementation there is only a single operation and clients
aoqi@0 329 // cannot queue commands (except at the socket level).
aoqi@0 330 //
aoqi@0 331 BsdAttachOperation* BsdAttachListener::dequeue() {
aoqi@0 332 for (;;) {
aoqi@0 333 int s;
aoqi@0 334
aoqi@0 335 // wait for client to connect
aoqi@0 336 struct sockaddr addr;
aoqi@0 337 socklen_t len = sizeof(addr);
aoqi@0 338 RESTARTABLE(::accept(listener(), &addr, &len), s);
aoqi@0 339 if (s == -1) {
aoqi@0 340 return NULL; // log a warning?
aoqi@0 341 }
aoqi@0 342
aoqi@0 343 // get the credentials of the peer and check the effective uid/guid
aoqi@0 344 // - check with jeff on this.
aoqi@0 345 uid_t puid;
aoqi@0 346 gid_t pgid;
aoqi@0 347 if (::getpeereid(s, &puid, &pgid) != 0) {
aoqi@0 348 ::close(s);
aoqi@0 349 continue;
aoqi@0 350 }
aoqi@0 351 uid_t euid = geteuid();
aoqi@0 352 gid_t egid = getegid();
aoqi@0 353
aoqi@0 354 if (puid != euid || pgid != egid) {
aoqi@0 355 ::close(s);
aoqi@0 356 continue;
aoqi@0 357 }
aoqi@0 358
aoqi@0 359 // peer credential look okay so we read the request
aoqi@0 360 BsdAttachOperation* op = read_request(s);
aoqi@0 361 if (op == NULL) {
aoqi@0 362 ::close(s);
aoqi@0 363 continue;
aoqi@0 364 } else {
aoqi@0 365 return op;
aoqi@0 366 }
aoqi@0 367 }
aoqi@0 368 }
aoqi@0 369
aoqi@0 370 // write the given buffer to the socket
aoqi@0 371 int BsdAttachListener::write_fully(int s, char* buf, int len) {
aoqi@0 372 do {
aoqi@0 373 int n = ::write(s, buf, len);
aoqi@0 374 if (n == -1) {
aoqi@0 375 if (errno != EINTR) return -1;
aoqi@0 376 } else {
aoqi@0 377 buf += n;
aoqi@0 378 len -= n;
aoqi@0 379 }
aoqi@0 380 }
aoqi@0 381 while (len > 0);
aoqi@0 382 return 0;
aoqi@0 383 }
aoqi@0 384
aoqi@0 385 // Complete an operation by sending the operation result and any result
aoqi@0 386 // output to the client. At this time the socket is in blocking mode so
aoqi@0 387 // potentially we can block if there is a lot of data and the client is
aoqi@0 388 // non-responsive. For most operations this is a non-issue because the
aoqi@0 389 // default send buffer is sufficient to buffer everything. In the future
aoqi@0 390 // if there are operations that involves a very big reply then it the
aoqi@0 391 // socket could be made non-blocking and a timeout could be used.
aoqi@0 392
aoqi@0 393 void BsdAttachOperation::complete(jint result, bufferedStream* st) {
aoqi@0 394 JavaThread* thread = JavaThread::current();
aoqi@0 395 ThreadBlockInVM tbivm(thread);
aoqi@0 396
aoqi@0 397 thread->set_suspend_equivalent();
aoqi@0 398 // cleared by handle_special_suspend_equivalent_condition() or
aoqi@0 399 // java_suspend_self() via check_and_wait_while_suspended()
aoqi@0 400
aoqi@0 401 // write operation result
aoqi@0 402 char msg[32];
aoqi@0 403 sprintf(msg, "%d\n", result);
aoqi@0 404 int rc = BsdAttachListener::write_fully(this->socket(), msg, strlen(msg));
aoqi@0 405
aoqi@0 406 // write any result data
aoqi@0 407 if (rc == 0) {
aoqi@0 408 BsdAttachListener::write_fully(this->socket(), (char*) st->base(), st->size());
aoqi@0 409 ::shutdown(this->socket(), 2);
aoqi@0 410 }
aoqi@0 411
aoqi@0 412 // done
aoqi@0 413 ::close(this->socket());
aoqi@0 414
aoqi@0 415 // were we externally suspended while we were waiting?
aoqi@0 416 thread->check_and_wait_while_suspended();
aoqi@0 417
aoqi@0 418 delete this;
aoqi@0 419 }
aoqi@0 420
aoqi@0 421
aoqi@0 422 // AttachListener functions
aoqi@0 423
aoqi@0 424 AttachOperation* AttachListener::dequeue() {
aoqi@0 425 JavaThread* thread = JavaThread::current();
aoqi@0 426 ThreadBlockInVM tbivm(thread);
aoqi@0 427
aoqi@0 428 thread->set_suspend_equivalent();
aoqi@0 429 // cleared by handle_special_suspend_equivalent_condition() or
aoqi@0 430 // java_suspend_self() via check_and_wait_while_suspended()
aoqi@0 431
aoqi@0 432 AttachOperation* op = BsdAttachListener::dequeue();
aoqi@0 433
aoqi@0 434 // were we externally suspended while we were waiting?
aoqi@0 435 thread->check_and_wait_while_suspended();
aoqi@0 436
aoqi@0 437 return op;
aoqi@0 438 }
aoqi@0 439
aoqi@0 440
aoqi@0 441 // Performs initialization at vm startup
aoqi@0 442 // For BSD we remove any stale .java_pid file which could cause
aoqi@0 443 // an attaching process to think we are ready to receive on the
aoqi@0 444 // domain socket before we are properly initialized
aoqi@0 445
aoqi@0 446 void AttachListener::vm_start() {
aoqi@0 447 char fn[UNIX_PATH_MAX];
aoqi@0 448 struct stat st;
aoqi@0 449 int ret;
aoqi@0 450
aoqi@0 451 int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
aoqi@0 452 os::get_temp_directory(), os::current_process_id());
aoqi@0 453 assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
aoqi@0 454
aoqi@0 455 RESTARTABLE(::stat(fn, &st), ret);
aoqi@0 456 if (ret == 0) {
aoqi@0 457 ret = ::unlink(fn);
aoqi@0 458 if (ret == -1) {
aoqi@0 459 debug_only(warning("failed to remove stale attach pid file at %s", fn));
aoqi@0 460 }
aoqi@0 461 }
aoqi@0 462 }
aoqi@0 463
aoqi@0 464 int AttachListener::pd_init() {
aoqi@0 465 JavaThread* thread = JavaThread::current();
aoqi@0 466 ThreadBlockInVM tbivm(thread);
aoqi@0 467
aoqi@0 468 thread->set_suspend_equivalent();
aoqi@0 469 // cleared by handle_special_suspend_equivalent_condition() or
aoqi@0 470 // java_suspend_self() via check_and_wait_while_suspended()
aoqi@0 471
aoqi@0 472 int ret_code = BsdAttachListener::init();
aoqi@0 473
aoqi@0 474 // were we externally suspended while we were waiting?
aoqi@0 475 thread->check_and_wait_while_suspended();
aoqi@0 476
aoqi@0 477 return ret_code;
aoqi@0 478 }
aoqi@0 479
aoqi@0 480 // Attach Listener is started lazily except in the case when
aoqi@0 481 // +ReduseSignalUsage is used
aoqi@0 482 bool AttachListener::init_at_startup() {
aoqi@0 483 if (ReduceSignalUsage) {
aoqi@0 484 return true;
aoqi@0 485 } else {
aoqi@0 486 return false;
aoqi@0 487 }
aoqi@0 488 }
aoqi@0 489
aoqi@0 490 // If the file .attach_pid<pid> exists in the working directory
aoqi@0 491 // or /tmp then this is the trigger to start the attach mechanism
aoqi@0 492 bool AttachListener::is_init_trigger() {
aoqi@0 493 if (init_at_startup() || is_initialized()) {
aoqi@0 494 return false; // initialized at startup or already initialized
aoqi@0 495 }
aoqi@0 496 char path[PATH_MAX + 1];
aoqi@0 497 int ret;
aoqi@0 498 struct stat st;
aoqi@0 499
aoqi@0 500 snprintf(path, PATH_MAX + 1, "%s/.attach_pid%d",
aoqi@0 501 os::get_temp_directory(), os::current_process_id());
aoqi@0 502 RESTARTABLE(::stat(path, &st), ret);
aoqi@0 503 if (ret == 0) {
aoqi@0 504 // simple check to avoid starting the attach mechanism when
aoqi@0 505 // a bogus user creates the file
aoqi@0 506 if (st.st_uid == geteuid()) {
aoqi@0 507 init();
aoqi@0 508 return true;
aoqi@0 509 }
aoqi@0 510 }
aoqi@0 511 return false;
aoqi@0 512 }
aoqi@0 513
aoqi@0 514 // if VM aborts then remove listener
aoqi@0 515 void AttachListener::abort() {
aoqi@0 516 listener_cleanup();
aoqi@0 517 }
aoqi@0 518
aoqi@0 519 void AttachListener::pd_data_dump() {
aoqi@0 520 os::signal_notify(SIGQUIT);
aoqi@0 521 }
aoqi@0 522
aoqi@0 523 AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
aoqi@0 524 return NULL;
aoqi@0 525 }
aoqi@0 526
aoqi@0 527 jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
aoqi@0 528 out->print_cr("flag '%s' cannot be changed", op->arg(0));
aoqi@0 529 return JNI_ERR;
aoqi@0 530 }
aoqi@0 531
aoqi@0 532 void AttachListener::pd_detachall() {
aoqi@0 533 // do nothing for now
aoqi@0 534 }

mercurial