$NetBSD: patch-aq,v 1.6 2013/04/19 22:21:41 prlw1 Exp $ --- gio/gsocket.c.orig 2013-03-13 13:39:09.000000000 +0000 +++ gio/gsocket.c @@ -37,6 +37,9 @@ #include #include #include +#ifdef __NetBSD__ +#include +#endif #ifndef G_OS_WIN32 # include @@ -4349,7 +4352,7 @@ g_socket_get_credentials (GSocket *soc ret = NULL; -#if defined(__linux__) || defined(__OpenBSD__) +#if defined(__linux__) || (defined(__OpenBSD__) && !defined(__MirBSD__)) { socklen_t optlen; #if defined(__linux__) @@ -4384,6 +4387,35 @@ g_socket_get_credentials (GSocket *soc &native_creds); } } +#elif defined(__NetBSD__) && defined(LOCAL_PEEREID) + { + struct unpcbid cred; + socklen_t len = sizeof(cred); + if (getsockopt(socket->priv->fd, 0, LOCAL_PEEREID, &cred, &len) < 0) + { + int errsv = get_socket_errno (); + g_set_error (error, + G_IO_ERROR, + socket_io_error_from_errno (errsv), + _("Unable to get pending error: %s"), + socket_strerror (errsv)); + } + else + { + struct { + pid_t pid; + uid_t uid; + gid_t gid; + } native_creds; + native_creds.uid = cred.unp_euid; + native_creds.gid = cred.unp_egid; + native_creds.pid = cred.unp_pid; + ret = g_credentials_new (); + g_credentials_set_native (ret, + G_CREDENTIALS_TYPE_LINUX_UCRED, + &native_creds); + } + } #else g_set_error_literal (error, G_IO_ERROR,