summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2015-10-21 19:09:12 +0300
committerEric Koegel <eric.koegel@gmail.com>2015-10-21 19:09:12 +0300
commit324b5e9eef9e4a50d634bc6403d8b7ceeba211b0 (patch)
tree531f69f1d4d9ffa2a9e450413be4a225c65fc533
parent0772a99444a5aa897ac58a830820a937b5931591 (diff)
parent0369263e937c2c341136d78b4db9839a85b20d44 (diff)
downloadConsoleKit2-324b5e9eef9e4a50d634bc6403d8b7ceeba211b0.tar.gz
Merge pull request #52 from obache/neatsrc/netbsd-support
Imporve NetBSD support
-rw-r--r--src/ck-sysdeps-netbsd.c28
-rw-r--r--src/ck-sysdeps-unix.c20
-rw-r--r--tools/ck-get-x11-display-device.c4
3 files changed, 30 insertions, 22 deletions
diff --git a/src/ck-sysdeps-netbsd.c b/src/ck-sysdeps-netbsd.c
index cb81c8c..bc8eb13 100644
--- a/src/ck-sysdeps-netbsd.c
+++ b/src/ck-sysdeps-netbsd.c
@@ -90,8 +90,6 @@ struct _CkProcessStat
int exit_signal; /* stat might not be SIGCHLD */
int processor; /* stat current (or most recent?) CPU */
uintptr_t penv; /* stat address of initial environment vector */
- char tty_text[16]; /* stat device name */
-
};
pid_t
@@ -115,7 +113,11 @@ ck_process_stat_get_tty (CkProcessStat *stat)
{
g_return_val_if_fail (stat != NULL, NULL);
- return g_strdup (stat->tty_text);
+ if (stat->tty != NODEV){
+ return NULL;
+ }
+
+ return g_strdup(devname (stat->tty, S_IFCHR));
}
static gboolean
@@ -147,10 +149,7 @@ stat2proc (pid_t pid,
CkProcessStat *P)
{
struct kinfo_proc2 p;
- char *ttname;
int num;
- int tty_maj;
- int tty_min;
if (! get_kinfo_proc2 (pid, &p)) {
return FALSE;
@@ -178,22 +177,7 @@ stat2proc (pid_t pid,
P->tpgid = p.p_tpgid;
P->processor = p.p_cpuid;
P->nlwp = p.p_nlwps;
-
- /* we like it Linux-encoded :-) */
- tty_maj = major (p.p_tdev);
- tty_min = minor (p.p_tdev);
- P->tty = DEV_ENCODE (tty_maj,tty_min);
-
- snprintf (P->tty_text, sizeof(P->tty_text), "%3d,%-3d", tty_maj, tty_min);
-
- if (p.p_tdev != NODEV && (ttname = devname (p.p_tdev, S_IFCHR)) != NULL) {
- memcpy (P->tty_text, ttname, sizeof(P->tty_text));
- }
-
- if (p.p_tdev == NODEV) {
- /* XXX how do we associate X with its tty? */
- memcpy (P->tty_text, "/dev/ttyE4", sizeof(P->tty_text));
- }
+ P->tty = p.p_tdev;
if (P->pid != pid) {
return FALSE;
diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c
index cf79525..c24a0e1 100644
--- a/src/ck-sysdeps-unix.c
+++ b/src/ck-sysdeps-unix.c
@@ -40,6 +40,10 @@
#include <dev/wscons/wsdisplay_usl_io.h>
#endif
+#if defined(__NetBSD__)
+#include <sys/un.h>
+#endif
+
#ifdef HAVE_SYS_VT_H
#include <sys/vt.h>
#endif
@@ -108,6 +112,22 @@ ck_get_socket_peer_credentials (int socket_fd,
if (ucred != NULL) {
ucred_free (ucred);
}
+#elif defined(LOCAL_PEEREID)
+ struct unpcbid cr;
+ socklen_t cr_len;
+
+ cr_len = sizeof (cr);
+
+ if (getsockopt (socket_fd, 0, LOCAL_PEEREID, &cr, &cr_len) == 0 && cr_len == sizeof (cr)) {
+ pid_read = cr.unp_pid;
+ uid_read = cr.unp_euid;
+ ret = TRUE;
+ } else {
+ g_warning ("Failed to getsockopt() credentials, returned len %d/%d: %s\n",
+ cr_len,
+ (int) sizeof (cr),
+ g_strerror (errno));
+ }
#elif defined(HAVE_GETPEEREID)
gid_t dummy;
diff --git a/tools/ck-get-x11-display-device.c b/tools/ck-get-x11-display-device.c
index ba8c9d7..19e47cc 100644
--- a/tools/ck-get-x11-display-device.c
+++ b/tools/ck-get-x11-display-device.c
@@ -138,7 +138,11 @@ get_tty_for_display (Display *xdisplay)
goto out;
}
+#if defined(__NetBSD__)
+ display = g_strdup_printf ("/dev/ttyE%ld", vt - 1);
+#else
display = g_strdup_printf ("/dev/tty%ld", vt);
+#endif
out:
if (return_value != NULL) {