polkit: Fix build on SunOS
This commit is contained in:
parent
461a08f390
commit
7e07e2ada3
5 changed files with 208 additions and 30 deletions
|
@ -4,11 +4,12 @@ SHA1 (polkit-0.113.tar.gz) = ef855c2d04184dceb38e0940dc7bec9cc3da415c
|
|||
RMD160 (polkit-0.113.tar.gz) = 661b0a678f7c770c213404db3af604935fdb25bc
|
||||
SHA512 (polkit-0.113.tar.gz) = ab177c89a20eeb2978ddbe28afb205d3619f9c5defe833eb68a85e71a0f2c905367f1295cbbfb85da5eafdd661bce474d5d84aca9195cd425a18c9b4170eb5f9
|
||||
Size (polkit-0.113.tar.gz) = 1448865 bytes
|
||||
SHA1 (patch-src_polkit_polkitunixprocess.c) = 347ce2b4093a126eedb5dd2168d70cf636a30236
|
||||
SHA1 (patch-src_polkit_polkitunixprocess.c) = 214541bcb012892b4fc2416897424bce8ed95518
|
||||
SHA1 (patch-src_polkitbackend_polkitbackendinteractiveauthority.c) = d8b7cbcd0db26969bc4b83c32a731ae920c2e87b
|
||||
SHA1 (patch-src_polkitbackend_polkitbackendjsauthority.c) = fec046c7776d81bee5641868e5ab790cb00d07ec
|
||||
SHA1 (patch-src_polkitbackend_polkitbackendjsauthority.c) = 88ed2d42208743db4013399e9ece4cf24a3eaf62
|
||||
SHA1 (patch-src_polkitbackend_polkitd.c) = a567b31131f63f92f8e2967c3aabfa7f3d41f627
|
||||
SHA1 (patch-src_programs_pkexec.c) = 2c1191d5e5246b62d7bfac144ad2f23eb122efec
|
||||
SHA1 (patch-src_programs_pkttyagent.c) = 72a1c3750e6b496b981eb5479201946da80b6d15
|
||||
SHA1 (patch-test_mocklib_src_netdb.c) = 7d378cd31577c63a336bad4714ac30f87b892e6f
|
||||
SHA1 (patch-test_mocklibc_src_grp.c) = 1ad61ca043e0586ded84c3157d0271a1e3af2b9e
|
||||
SHA1 (patch-test_mocklibc_src_netdb.c) = f1b36025b8f574b68b46f20e269c520a82934e9f
|
||||
SHA1 (patch-test_mocklibc_src_pwd.c) = 8f2b35cb90f96a115f7621a8751b9e64cba0a106
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
$NetBSD: patch-src_polkit_polkitunixprocess.c,v 1.3 2015/04/02 14:55:36 bsiegert Exp $
|
||||
|
||||
* NetBSD support
|
||||
* SunOS support
|
||||
|
||||
--- src/polkit/polkitunixprocess.c.orig 2014-01-14 22:42:25.000000000 +0000
|
||||
--- src/polkit/polkitunixprocess.c.orig 2014-01-14 22:42:25.000000000 +0000
|
||||
+++ src/polkit/polkitunixprocess.c
|
||||
@@ -29,6 +29,10 @@
|
||||
@@ -29,10 +29,19 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
@ -15,20 +16,59 @@ $NetBSD: patch-src_polkit_polkitunixprocess.c,v 1.3 2015/04/02 14:55:36 bsiegert
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -89,6 +93,9 @@ static gint _polkit_unix_process_get_own
|
||||
#include <stdio.h>
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
+#ifdef HAVE_SOLARIS
|
||||
+#include <procfs.h>
|
||||
+#endif
|
||||
|
||||
#include "polkitunixprocess.h"
|
||||
#include "polkitsubject.h"
|
||||
@@ -80,7 +89,7 @@ enum
|
||||
|
||||
static void subject_iface_init (PolkitSubjectIface *subject_iface);
|
||||
|
||||
-static guint64 get_start_time_for_pid (gint pid,
|
||||
+static guint64 get_start_time_for_pid (pid_t pid,
|
||||
GError **error);
|
||||
|
||||
static gint _polkit_unix_process_get_owner (PolkitUnixProcess *process,
|
||||
@@ -89,6 +98,9 @@ static gint _polkit_unix_process_get_own
|
||||
#ifdef HAVE_FREEBSD
|
||||
static gboolean get_kinfo_proc (gint pid, struct kinfo_proc *p);
|
||||
#endif
|
||||
+#if defined(__NetBSD__)
|
||||
+static gboolean get_kinfo_proc (gint pid, struct kinfo_proc2 *p);
|
||||
+#endif
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (PolkitUnixProcess, polkit_unix_process, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (POLKIT_TYPE_SUBJECT, subject_iface_init)
|
||||
@@ -554,12 +561,38 @@ get_kinfo_proc (pid_t pid, struct kinfo_
|
||||
@@ -514,17 +526,17 @@ subject_iface_init (PolkitSubjectIface *
|
||||
|
||||
#ifdef HAVE_SOLARIS
|
||||
static int
|
||||
-get_pid_psinfo (pid_t pid, struct psinfo *ps)
|
||||
+get_pid_psinfo (pid_t pid, psinfo_t *ps)
|
||||
{
|
||||
char pname[32];
|
||||
int procfd;
|
||||
|
||||
- (void) snprintf(pname, sizeof(pname), "/proc/%d/psinfo", pid);
|
||||
+ (void) snprintf(pname, sizeof(pname), "/proc/%lu/psinfo", pid);
|
||||
if ((procfd = open(pname, O_RDONLY)) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
- if (read(procfd, ps, sizeof(struct psinfo)) < 0)
|
||||
+ if (read(procfd, ps, sizeof(psinfo_t)) < 0)
|
||||
{
|
||||
(void) close(procfd);
|
||||
return -1;
|
||||
@@ -554,12 +566,38 @@ get_kinfo_proc (pid_t pid, struct kinfo_
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+#ifdef __NetBSD__
|
||||
+static gboolean
|
||||
+get_kinfo_proc (pid_t pid, struct kinfo_proc2 *p)
|
||||
|
@ -65,14 +105,36 @@ $NetBSD: patch-src_polkit_polkitunixprocess.c,v 1.3 2015/04/02 14:55:36 bsiegert
|
|||
gchar *filename;
|
||||
gchar *contents;
|
||||
size_t length;
|
||||
@@ -631,6 +664,26 @@ get_start_time_for_pid (pid_t pid,
|
||||
@@ -571,7 +609,7 @@ get_start_time_for_pid (pid_t pid,
|
||||
start_time = 0;
|
||||
contents = NULL;
|
||||
|
||||
- filename = g_strdup_printf ("/proc/%d/stat", pid);
|
||||
+ filename = g_strdup_printf ("/proc/%lu/stat", pid);
|
||||
|
||||
if (!g_file_get_contents (filename, &contents, &length, error))
|
||||
goto out;
|
||||
@@ -631,8 +669,8 @@ get_start_time_for_pid (pid_t pid,
|
||||
out:
|
||||
g_free (filename);
|
||||
g_free (contents);
|
||||
-#else
|
||||
- struct kinfo_proc p;
|
||||
+#elif defined(__NetBSD__)
|
||||
+ struct kinfo_proc2 p;
|
||||
|
||||
start_time = 0;
|
||||
|
||||
@@ -647,9 +685,43 @@ get_start_time_for_pid (pid_t pid,
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ start_time = (guint64) p.p_ustart_sec;
|
||||
+
|
||||
+ start_time = 0;
|
||||
+out:
|
||||
+
|
||||
+#elif HAVE_FREEBSD
|
||||
+ struct kinfo_proc p;
|
||||
+
|
||||
+ if (! get_kinfo_proc (pid, &p))
|
||||
+ {
|
||||
|
@ -85,40 +147,69 @@ $NetBSD: patch-src_polkit_polkitunixprocess.c,v 1.3 2015/04/02 14:55:36 bsiegert
|
|||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ start_time = (guint64) p.p_ustart_sec;
|
||||
+
|
||||
start_time = (guint64) p.ki_start.tv_sec;
|
||||
|
||||
out:
|
||||
+#elif HAVE_SOLARIS
|
||||
+ psinfo_t p;
|
||||
+ if (!get_pid_psinfo (pid, &p))
|
||||
+ {
|
||||
+ g_set_error (error,
|
||||
+ POLKIT_ERROR,
|
||||
+ POLKIT_ERROR_FAILED,
|
||||
+ "Error obtaining start time for %d (%s)",
|
||||
+ (gint) pid,
|
||||
+ g_strerror (errno));
|
||||
+ goto out;
|
||||
+ }
|
||||
+ start_time = (guint64) p.pr_start.tv_sec;
|
||||
+out:
|
||||
+
|
||||
#else
|
||||
struct kinfo_proc p;
|
||||
|
||||
@@ -664,6 +717,8 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
+#else
|
||||
+#warning Your system is not supported
|
||||
#endif
|
||||
|
||||
return start_time;
|
||||
@@ -664,6 +736,10 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
gchar **lines;
|
||||
#ifdef HAVE_FREEBSD
|
||||
struct kinfo_proc p;
|
||||
+#elif defined(__NetBSD__)
|
||||
+ struct kinfo_proc2 p;
|
||||
+#elif HAVE_SOLARIS
|
||||
+ psinfo_t p;
|
||||
#else
|
||||
gchar filename[64];
|
||||
guint n;
|
||||
@@ -676,7 +731,7 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
@@ -676,7 +752,7 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
lines = NULL;
|
||||
contents = NULL;
|
||||
|
||||
|
||||
-#ifdef HAVE_FREEBSD
|
||||
+#if defined(HAVE_FREEBSD) || defined(__NetBSD__)
|
||||
if (get_kinfo_proc (process->pid, &p) == 0)
|
||||
{
|
||||
g_set_error (error,
|
||||
@@ -688,7 +743,11 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
@@ -688,7 +764,23 @@ _polkit_unix_process_get_owner (PolkitUn
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
+#ifdef __NetBSD__
|
||||
+ result = p.p_uid;
|
||||
+#else
|
||||
result = p.ki_uid;
|
||||
+#endif
|
||||
+#elif HAVE_SOLARIS
|
||||
+ if (!get_pid_psinfo (process->pid, &p))
|
||||
+ {
|
||||
+ g_set_error (error,
|
||||
+ POLKIT_ERROR,
|
||||
+ POLKIT_ERROR_FAILED,
|
||||
+ "get_pid_psinfo() failed for pid %d: %s",
|
||||
+ process->pid,
|
||||
+ g_strerror (errno));
|
||||
+ goto out;
|
||||
+ }
|
||||
+ result = p.pr_uid;
|
||||
#else
|
||||
|
||||
|
||||
/* see 'man proc' for layout of the status file
|
||||
|
|
|
@ -3,8 +3,9 @@ $NetBSD: patch-src_polkitbackend_polkitbackendjsauthority.c,v 1.3 2015/04/02 14:
|
|||
* for *BSD netgroup functions
|
||||
* for no SIGPOLL
|
||||
* Fix a memory leak
|
||||
* Add getgrouplist for SunOS
|
||||
|
||||
--- src/polkitbackend/polkitbackendjsauthority.c.orig 2015-06-19 20:39:58.000000000 +0000
|
||||
--- src/polkitbackend/polkitbackendjsauthority.c.orig 2015-06-19 20:39:58.000000000 +0000
|
||||
+++ src/polkitbackend/polkitbackendjsauthority.c
|
||||
@@ -24,7 +24,12 @@
|
||||
#include <errno.h>
|
||||
|
@ -49,5 +50,58 @@ $NetBSD: patch-src_polkitbackend_polkitbackendjsauthority.c,v 1.3 2015/04/02 14:
|
|||
char *netgroup;
|
||||
+#endif
|
||||
JSBool is_in_netgroup = JS_FALSE;
|
||||
|
||||
|
||||
if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str))
|
||||
@@ -1913,3 +1923,52 @@ utils_spawn_finish (GAsyncResult *res,
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
+
|
||||
+#ifdef __sun__
|
||||
+#include <string.h>
|
||||
+int
|
||||
+getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
|
||||
+{
|
||||
+ const struct group *grp;
|
||||
+ int i, maxgroups, ngroups, ret;
|
||||
+
|
||||
+ ret = 0;
|
||||
+ ngroups = 0;
|
||||
+ maxgroups = *grpcnt;
|
||||
+ /*
|
||||
+ * When installing primary group, duplicate it;
|
||||
+ * the first element of groups is the effective gid
|
||||
+ * and will be overwritten when a setgid file is executed.
|
||||
+ */
|
||||
+ groups ? groups[ngroups++] = agroup : ngroups++;
|
||||
+ if (maxgroups > 1)
|
||||
+ groups ? groups[ngroups++] = agroup : ngroups++;
|
||||
+ /*
|
||||
+ * Scan the group file to find additional groups.
|
||||
+ */
|
||||
+ setgrent();
|
||||
+ while ((grp = getgrent()) != NULL) {
|
||||
+ if (groups) {
|
||||
+ for (i = 0; i < ngroups; i++) {
|
||||
+ if (grp->gr_gid == groups[i])
|
||||
+ goto skip;
|
||||
+ }
|
||||
+ }
|
||||
+ for (i = 0; grp->gr_mem[i]; i++) {
|
||||
+ if (!strcmp(grp->gr_mem[i], uname)) {
|
||||
+ if (ngroups >= maxgroups) {
|
||||
+ ret = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+ groups ? groups[ngroups++] = grp->gr_gid : ngroups++;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+skip:
|
||||
+ ;
|
||||
+ }
|
||||
+ endgrent();
|
||||
+ *grpcnt = ngroups;
|
||||
+ return (ret);
|
||||
+}
|
||||
+#endif
|
||||
|
|
24
polkit/patches/patch-src_programs_pkexec.c
Normal file
24
polkit/patches/patch-src_programs_pkexec.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
$NetBSD$
|
||||
|
||||
Avoid conflict with SunOS function.
|
||||
|
||||
--- src/programs/pkexec.c.orig 2015-06-18 20:20:50.000000000 +0000
|
||||
+++ src/programs/pkexec.c
|
||||
@@ -247,7 +247,7 @@ set_close_on_exec (gint fd,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
-fdwalk (FdCallback callback,
|
||||
+gfdwalk (FdCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint fd;
|
||||
@@ -922,7 +922,7 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* set close_on_exec on all file descriptors except stdin, stdout, stderr */
|
||||
- if (!fdwalk (set_close_on_exec, GINT_TO_POINTER (3)))
|
||||
+ if (!gfdwalk (set_close_on_exec, GINT_TO_POINTER (3)))
|
||||
{
|
||||
g_printerr ("Error setting close-on-exec for file desriptors\n");
|
||||
goto out;
|
|
@ -1,22 +1,30 @@
|
|||
$NetBSD$
|
||||
|
||||
Darwin has setnetgrent.
|
||||
SunOS has endnetgrent.
|
||||
|
||||
--- test/mocklibc/src/netdb.c.orig 2014-01-14 22:42:25.000000000 +0000
|
||||
--- test/mocklibc/src/netdb.c.orig 2014-01-14 22:42:25.000000000 +0000
|
||||
+++ test/mocklibc/src/netdb.c
|
||||
@@ -36,6 +36,7 @@ static struct netgroup_iter global_iter;
|
||||
|
||||
|
||||
// REMEMBER: 1 means success, 0 means failure for netgroup methods
|
||||
|
||||
|
||||
+#ifndef __APPLE__
|
||||
int setnetgrent(const char *netgroup) {
|
||||
if (!global_netgroup_head)
|
||||
global_netgroup_head = netgroup_parse_all();
|
||||
@@ -50,6 +51,7 @@ int setnetgrent(const char *netgroup) {
|
||||
@@ -50,11 +51,14 @@ int setnetgrent(const char *netgroup) {
|
||||
netgroup_iter_init(&global_iter, group);
|
||||
return 1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
|
||||
+#ifndef __sun__
|
||||
void endnetgrent(void) {
|
||||
netgroup_free_all(global_netgroup_head);
|
||||
global_netgroup_head = NULL;
|
||||
}
|
||||
+#endif
|
||||
|
||||
int getnetgrent(char **host, char **user, char **domain) {
|
||||
if (!global_netgroup_head)
|
Loading…
Reference in a new issue