$OpenBSD: patch-hotspot_src_os_bsd_vm_attachListener_bsd_cpp,v 1.1.1.1 2007/05/08 17:06:18 kurt Exp $
--- hotspot/src/os/bsd/vm/attachListener_bsd.cpp.orig	Mon Apr 16 08:42:36 2007
+++ hotspot/src/os/bsd/vm/attachListener_bsd.cpp	Mon Apr 16 08:42:38 2007
@@ -333,6 +333,15 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
 
     // get the credentials of the peer and check the effective uid/guid
     // - check with jeff on this.
+#ifdef _ALLBSD_SOURCE
+    uid_t puid;
+    gid_t pgid;
+    if (::getpeereid(s, &puid, &pgid) != 0) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    }
+#else
     struct ucred cred_info;
     socklen_t optlen = sizeof(cred_info);
     if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
@@ -340,10 +349,13 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
       RESTARTABLE(::close(s), res);
       continue;
     }
+    uid_t puid = cred_info.uid;
+    gid_t pgid = cred_info.gid;
+#endif
     uid_t euid = geteuid();
     gid_t egid = getegid();
 
-    if (cred_info.uid != euid || cred_info.gid != egid) {
+    if (puid != euid || pgid != egid) {
       int res;
       RESTARTABLE(::close(s), res);
       continue;
@@ -466,11 +478,11 @@ bool AttachListener::is_init_trigger() {
   char fn[32];
   sprintf(fn, ".attach_pid%d", os::current_process_id());
   int ret;
-  struct stat64 st;
-  RESTARTABLE(::stat64(fn, &st), ret);
+  struct stat st;
+  RESTARTABLE(::stat(fn, &st), ret);
   if (ret == -1) {
     sprintf(fn, "/tmp/.attach_pid%d", os::current_process_id());
-    RESTARTABLE(::stat64(fn, &st), ret);
+    RESTARTABLE(::stat(fn, &st), ret);
   }
   if (ret == 0) {
     // simple check to avoid starting the attach mechanism when
