summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOBATA Akio <obache@outlook.com>2015-09-19 18:09:05 +0900
committerMiloslav Trmač <mitr@redhat.com>2015-10-01 21:38:40 +0200
commitabe07b26dab95e24ad8b55a6297ca4e10b13fb40 (patch)
tree3d22cd556ff53e5298c1c1404cba787cfb29ba05
parent5a7e3b76aa45eea43e4bdc403ddd4c6e1a4c6542 (diff)
downloadpolkit-abe07b26dab95e24ad8b55a6297ca4e10b13fb40.tar.gz
Add support for NetBSD
https://bugs.freedesktop.org/show_bug.cgi?id=92046
-rw-r--r--configure.ac18
-rw-r--r--src/polkit/polkitunixprocess.c36
-rw-r--r--src/polkitbackend/polkitbackendinteractiveauthority.c2
3 files changed, 46 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 85f26b9..97d4222 100644
--- a/configure.ac
+++ b/configure.ac
@@ -421,7 +421,7 @@ fi
AC_SUBST(PAM_MODULE_DIR)
-AC_ARG_WITH(os-type, [ --with-os-type=<os> distribution or OS (redhat/suse/gentoo/pardus/solaris)])
+AC_ARG_WITH(os-type, [ --with-os-type=<os> distribution or OS (redhat/suse/gentoo/pardus/solaris/netbsd)])
#### Check our operating system (distro-tweaks required)
if test "z$with_os_type" = "z"; then
@@ -450,8 +450,17 @@ if test x$with_os_type = x; then
with_os_type=solaris
elif test x$operating_system = xfreebsd ; then
with_os_type=freebsd
+ elif test x$operating_system = xnetbsd ; then
+ with_os_type=netbsd
else
- with_os_type=unknown
+ case "$host_os" in
+ *netbsd*)
+ with_os_type=netbsd
+ ;;
+ *)
+ with_os_type=unknown
+ ::
+ esac
fi
fi
@@ -482,7 +491,7 @@ elif test x$with_os_type = xsuse -o x$with_os_type = xsolaris ; then
PAM_FILE_INCLUDE_ACCOUNT=common-account
PAM_FILE_INCLUDE_PASSWORD=common-password
PAM_FILE_INCLUDE_SESSION=common-session
-elif test x$with_os_type = xfreebsd ; then
+elif test x$with_os_type = xfreebsd -o x$with_os_type = xnetbsd; then
PAM_FILE_INCLUDE_AUTH=system
PAM_FILE_INCLUDE_ACCOUNT=system
PAM_FILE_INCLUDE_PASSWORD=system
@@ -515,6 +524,9 @@ case "$host_os" in
*freebsd*)
AC_DEFINE([HAVE_FREEBSD], 1, [Is this a FreeBSD system?])
;;
+ *netbsd*)
+ AC_DEFINE([HAVE_NETBSD], 1, [Is this an NetBSD system?])
+ ;;
*openbsd*)
AC_DEFINE([HAVE_OPENBSD], 1, [Is this an OpenBSD system?])
;;
diff --git a/src/polkit/polkitunixprocess.c b/src/polkit/polkitunixprocess.c
index 61790b0..d4ebf50 100644
--- a/src/polkit/polkitunixprocess.c
+++ b/src/polkit/polkitunixprocess.c
@@ -29,6 +29,10 @@
#include <sys/sysctl.h>
#include <sys/user.h>
#endif
+#ifdef HAVE_NETBSD
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
#ifdef HAVE_OPENBSD
#include <sys/sysctl.h>
#endif
@@ -89,8 +93,13 @@ static guint64 get_start_time_for_pid (gint pid,
static gint _polkit_unix_process_get_owner (PolkitUnixProcess *process,
GError **error);
-#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
-static gboolean get_kinfo_proc (gint pid, struct kinfo_proc *p);
+#if defined(HAVE_FREEBSD) || defined(HAVE_NETBSD) || defined(HAVE_OPENBSD)
+static gboolean get_kinfo_proc (gint pid,
+#if defined(HAVE_NETBSD)
+ struct kinfo_proc2 *p);
+#else
+ struct kinfo_proc *p);
+#endif
#endif
G_DEFINE_TYPE_WITH_CODE (PolkitUnixProcess, polkit_unix_process, G_TYPE_OBJECT,
@@ -557,9 +566,14 @@ get_kinfo_proc (pid_t pid, struct kinfo_proc *p)
}
#endif
-#ifdef HAVE_OPENBSD
+#if defined(HAVE_NETBSD) || defined(HAVE_OPENBSD)
static gboolean
-get_kinfo_proc (gint pid, struct kinfo_proc *p)
+get_kinfo_proc (gint pid,
+#ifdef HAVE_NETBSD
+ struct kinfo_proc2 *p)
+#else
+ struct kinfo_proc *p)
+#endif
{
int name[6];
u_int namelen;
@@ -568,7 +582,11 @@ get_kinfo_proc (gint pid, struct kinfo_proc *p)
sz = sizeof(*p);
namelen = 0;
name[namelen++] = CTL_KERN;
+#ifdef HAVE_NETBSD
+ name[namelen++] = KERN_PROC2;
+#else
name[namelen++] = KERN_PROC;
+#endif
name[namelen++] = KERN_PROC_PID;
name[namelen++] = pid;
name[namelen++] = sz;
@@ -586,7 +604,7 @@ get_start_time_for_pid (pid_t pid,
GError **error)
{
guint64 start_time;
-#if !defined(HAVE_FREEBSD) && !defined(HAVE_OPENBSD)
+#if !defined(HAVE_FREEBSD) && !defined(HAVE_NETBSD) && !defined(HAVE_OPENBSD)
gchar *filename;
gchar *contents;
size_t length;
@@ -659,7 +677,11 @@ get_start_time_for_pid (pid_t pid,
g_free (filename);
g_free (contents);
#else
+#ifdef HAVE_NETBSD
+ struct kinfo_proc2 p;
+#else
struct kinfo_proc p;
+#endif
start_time = 0;
@@ -695,6 +717,8 @@ _polkit_unix_process_get_owner (PolkitUnixProcess *process,
gchar **lines;
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
struct kinfo_proc p;
+#elif defined(HAVE_NETBSD)
+ struct kinfo_proc2 p;
#else
gchar filename[64];
guint n;
@@ -707,7 +731,7 @@ _polkit_unix_process_get_owner (PolkitUnixProcess *process,
lines = NULL;
contents = NULL;
-#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
+#if defined(HAVE_FREEBSD) || defined(HAVE_NETBSD) || defined(HAVE_OPENBSD)
if (get_kinfo_proc (process->pid, &p) == 0)
{
g_set_error (error,
diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 0be60c7..967b764 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -2240,7 +2240,7 @@ get_users_in_net_group (PolkitIdentity *group,
for (;;)
{
-#if defined HAVE_OPENBSD
+#if defined(HAVE_NETBSD) || defined(HAVE_OPENBSD)
const char *hostname, *username, *domainname;
#else
char *hostname, *username, *domainname;