Commit a7aacbb5 authored by David Zeuthen's avatar David Zeuthen

Generate GI gir and typelibs for libpolkit-gobject-1

This includes changing from POSIX types (uid_t, gid_t, pid_t) to
gint. Won't affect much since the size is the same. And we want this
anyway since it is needed to build the library on non-POSIX platforms.
parent f1e31265
...@@ -381,7 +381,7 @@ AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_PASSWORD, "$PAM_FILE_INCLUDE_PASSWORD", [pam ...@@ -381,7 +381,7 @@ AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_PASSWORD, "$PAM_FILE_INCLUDE_PASSWORD", [pam
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_SESSION, "$PAM_FILE_INCLUDE_SESSION", [pam file session]) AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_SESSION, "$PAM_FILE_INCLUDE_SESSION", [pam file session])
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl - check OS dnl - check OS
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
case "$host_os" in case "$host_os" in
*linux*) *linux*)
...@@ -394,9 +394,29 @@ case "$host_os" in ...@@ -394,9 +394,29 @@ case "$host_os" in
;; ;;
esac esac
# GObject introspection
#
AC_ARG_ENABLE([introspection],
AS_HELP_STRING([--enable-introspection], [enable GObject introspection]),
[], [enable_introspection=yes])
if test "x$enable_introspection" = xyes; then
PKG_CHECK_MODULES([INTROSPECTION], [gobject-introspection-1.0 >= 0.6.2])
AC_DEFINE([ENABLE_INTROSPECTION], [1], [enable GObject introspection support])
AC_SUBST([G_IR_SCANNER], [$($PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0)])
AC_SUBST([G_IR_COMPILER], [$($PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0)])
AC_SUBST([G_IR_GENERATE], [$($PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0)])
#AC_SUBST([GIRDIR], [$($PKG_CONFIG --variable=girdir gobject-introspection-1.0)])
#AC_SUBST([GIRTYPELIBDIR], [$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)])
GIRDIR=${datadir}/gir-1.0
GIRTYPELIBDIR=${libdir}/girepository-1.0
AC_SUBST(GIRDIR)
AC_SUBST(GIRTYPELIBDIR)
fi
AM_CONDITIONAL([ENABLE_INTROSPECTION], [test "x$enable_introspection" = xyes])
# ******************** # ********************
# Internationalisation # Internationalization
# ******************** # ********************
IT_PROG_INTLTOOL([0.40.0]) IT_PROG_INTLTOOL([0.40.0])
...@@ -448,6 +468,7 @@ echo " ...@@ -448,6 +468,7 @@ echo "
cflags: ${CFLAGS} cflags: ${CFLAGS}
cppflags: ${CPPFLAGS} cppflags: ${CPPFLAGS}
xsltproc: ${XSLTPROC} xsltproc: ${XSLTPROC}
introspection: ${enable_introspection}
Distribution/OS: ${with_os_type} Distribution/OS: ${with_os_type}
user for PolicyKit: ${POLKIT_USER} user for PolicyKit: ${POLKIT_USER}
......
...@@ -139,6 +139,7 @@ polkit_unix_process_new_full ...@@ -139,6 +139,7 @@ polkit_unix_process_new_full
polkit_unix_process_get_pid polkit_unix_process_get_pid
polkit_unix_process_get_start_time polkit_unix_process_get_start_time
polkit_unix_process_set_pid polkit_unix_process_set_pid
polkit_unix_process_get_owner
<SUBSECTION Standard> <SUBSECTION Standard>
PolkitUnixProcessClass PolkitUnixProcessClass
POLKIT_UNIX_PROCESS POLKIT_UNIX_PROCESS
......
...@@ -17,8 +17,21 @@ INCLUDES = \ ...@@ -17,8 +17,21 @@ INCLUDES = \
BUILT_SOURCES = \ BUILT_SOURCES = \
polkit-built-sources.stamp \ polkit-built-sources.stamp \
polkitenumtypes.c polkitenumtypes.h \
$(NULL) $(NULL)
enum_headers = polkitcheckauthorizationflags.h polkiterror.h polkitimplicitauthorization.h
polkitenumtypes.h: $(enum_headers) polkitenumtypes.h.template
( top_builddir=`cd $(top_builddir) && pwd`; \
cd $(srcdir) && glib-mkenums --template polkitenumtypes.h.template $(enum_headers)) > \
polkitenumtypes.h.tmp && mv polkitenumtypes.h.tmp polkitenumtypes.h
polkitenumtypes.c: $(enum_headers) polkitenumtypes.c.template
( top_builddir=`cd $(top_builddir) && pwd`; \
cd $(srcdir) && glib-mkenums --template polkitenumtypes.c.template $(enum_headers)) > \
polkitenumtypes.c.tmp && mv polkitenumtypes.c.tmp polkitenumtypes.c
# Build all the PolicyKit D-Bus code here, even the code we # Build all the PolicyKit D-Bus code here, even the code we
# only in the daemon for agent interaction # only in the daemon for agent interaction
# #
...@@ -43,6 +56,7 @@ libpolkit_gobject_1include_HEADERS = \ ...@@ -43,6 +56,7 @@ libpolkit_gobject_1include_HEADERS = \
polkit.h \ polkit.h \
polkitprivate.h \ polkitprivate.h \
polkittypes.h \ polkittypes.h \
polkitenumtypes.h \
polkitactiondescription.h \ polkitactiondescription.h \
polkitdetails.h \ polkitdetails.h \
polkitauthority.h \ polkitauthority.h \
...@@ -92,6 +106,55 @@ libpolkit_gobject_1_la_LIBADD = \ ...@@ -92,6 +106,55 @@ libpolkit_gobject_1_la_LIBADD = \
$(EGG_DBUS_LIBS) \ $(EGG_DBUS_LIBS) \
$(NULL) $(NULL)
if ENABLE_INTROSPECTION
girdir = $(GIRDIR)
gir_DATA = Polkit-1.0.gir
typelibsdir = $(GIRTYPELIBDIR)
typelibs_DATA = Polkit-1.0.typelib
Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am
$(G_IR_SCANNER) -v \
--namespace Polkit \
--nsversion=1.0 \
--include=Gio-2.0 \
--library=polkit-gobject-1 \
--output $@ \
--pkg=glib-2.0 \
--pkg=gobject-2.0 \
--pkg=gio-2.0 \
$(EGG_DBUS_CFLAGS) \
-I$(top_srcdir)/src \
-D_POLKIT_COMPILATION \
-DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(srcdir)/polkit.h \
$(srcdir)/polkittypes.h \
$(srcdir)/polkitactiondescription.h \
$(srcdir)/polkitauthority.h \
$(srcdir)/polkitauthorizationresult.h \
$(srcdir)/polkitcheckauthorizationflags.h \
$(srcdir)/polkitdetails.h \
$(builddir)/polkitenumtypes.h \
$(srcdir)/polkiterror.h \
$(srcdir)/polkitidentity.h \
$(srcdir)/polkitimplicitauthorization.h \
$(srcdir)/polkitsubject.h \
$(srcdir)/polkitsystembusname.h \
$(srcdir)/polkittemporaryauthorization.h \
$(srcdir)/polkitunixgroup.h \
$(srcdir)/polkitunixprocess.h \
$(srcdir)/polkitunixsession.h \
$(srcdir)/polkitunixuser.h \
$(NULL)
Polkit-1.0.typelib: Polkit-1.0.gir $(G_IR_COMPILER)
$(G_IR_COMPILER) $< -o $@
endif # ENABLE_INTROSPECTION
EXTRA_DIST = Polkit-1.0.gir polkitenumtypes.h.template polkitenumtypes.c.template
CLEANFILES = $(gir_DATA) $(typelibs_DATA)
dist-hook : dist-hook :
(for i in $(polkit_built_sources) $(BUILT_SOURCES) ; do rm -f $(distdir)/$$i ; done) (for i in $(polkit_built_sources) $(BUILT_SOURCES) ; do rm -f $(distdir)/$$i ; done)
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#define _POLKIT_INSIDE_POLKIT_H 1 #define _POLKIT_INSIDE_POLKIT_H 1
#include <polkit/polkittypes.h>
#include <polkit/polkitenumtypes.h>
#include <polkit/polkitimplicitauthorization.h> #include <polkit/polkitimplicitauthorization.h>
#include <polkit/polkitactiondescription.h> #include <polkit/polkitactiondescription.h>
#include <polkit/polkiterror.h> #include <polkit/polkiterror.h>
......
...@@ -26,10 +26,4 @@ ...@@ -26,10 +26,4 @@
#include "polkitcheckauthorizationflags.h" #include "polkitcheckauthorizationflags.h"
#include "polkitprivate.h" #include "polkitprivate.h"
GType
polkit_check_authorization_flags_get_type (void)
{
return _polkit_check_authorization_flags_get_type ();
}
/*** BEGIN file-header ***/
#include <polkit/polkit.h>
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_define_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/*** END value-tail ***/
/*** BEGIN file-tail ***/
/*** END file-tail ***/
/*** BEGIN file-header ***/
#ifndef __POLKIT_ENUM_TYPES_H__
#define __POLKIT_ENUM_TYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __POLKIT_ENUM_TYPES_H__ */
/*** END file-tail ***/
...@@ -40,9 +40,3 @@ polkit_error_quark (void) ...@@ -40,9 +40,3 @@ polkit_error_quark (void)
return _polkit_error_quark (); return _polkit_error_quark ();
} }
GType
polkit_error_get_type (void)
{
return _polkit_error_get_type ();
}
...@@ -155,7 +155,7 @@ polkit_identity_from_string (const gchar *str, ...@@ -155,7 +155,7 @@ polkit_identity_from_string (const gchar *str,
&endptr, &endptr,
10); 10);
if (*endptr == '\0') if (*endptr == '\0')
identity = polkit_unix_user_new ((uid_t) val); identity = polkit_unix_user_new ((gint) val);
else else
identity = polkit_unix_user_new_for_name (str + sizeof "unix-user:" - 1, identity = polkit_unix_user_new_for_name (str + sizeof "unix-user:" - 1,
error); error);
...@@ -166,7 +166,7 @@ polkit_identity_from_string (const gchar *str, ...@@ -166,7 +166,7 @@ polkit_identity_from_string (const gchar *str,
&endptr, &endptr,
10); 10);
if (*endptr == '\0') if (*endptr == '\0')
identity = polkit_unix_group_new ((gid_t) val); identity = polkit_unix_group_new ((gint) val);
else else
identity = polkit_unix_group_new_for_name (str + sizeof "unix-group:" - 1, identity = polkit_unix_group_new_for_name (str + sizeof "unix-group:" - 1,
error); error);
......
...@@ -36,12 +36,6 @@ ...@@ -36,12 +36,6 @@
* Possible implicit authorizations. * Possible implicit authorizations.
*/ */
GType
polkit_implicit_authorization_get_type (void)
{
return _polkit_implicit_authorization_get_type ();
}
gboolean gboolean
polkit_implicit_authorization_from_string (const gchar *string, polkit_implicit_authorization_from_string (const gchar *string,
PolkitImplicitAuthorization *out_implicit_authorization) PolkitImplicitAuthorization *out_implicit_authorization)
......
...@@ -225,7 +225,7 @@ polkit_subject_from_string (const gchar *str, ...@@ -225,7 +225,7 @@ polkit_subject_from_string (const gchar *str,
10); 10);
if (*endptr == '\0') if (*endptr == '\0')
{ {
subject = polkit_unix_process_new ((pid_t) val); subject = polkit_unix_process_new ((gint) val);
if (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) == 0) if (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) == 0)
{ {
g_object_unref (subject); g_object_unref (subject);
......
...@@ -48,7 +48,7 @@ struct _PolkitUnixGroup ...@@ -48,7 +48,7 @@ struct _PolkitUnixGroup
{ {
GObject parent_instance; GObject parent_instance;
gid_t gid; gint gid;
}; };
struct _PolkitUnixGroupClass struct _PolkitUnixGroupClass
...@@ -75,16 +75,16 @@ polkit_unix_group_init (PolkitUnixGroup *unix_group) ...@@ -75,16 +75,16 @@ polkit_unix_group_init (PolkitUnixGroup *unix_group)
static void static void
polkit_unix_group_get_property (GObject *object, polkit_unix_group_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
PolkitUnixGroup *unix_group = POLKIT_UNIX_GROUP (object); PolkitUnixGroup *unix_group = POLKIT_UNIX_GROUP (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_GID: case PROP_GID:
g_value_set_uint (value, unix_group->gid); g_value_set_int (value, unix_group->gid);
break; break;
default: default:
...@@ -104,7 +104,7 @@ polkit_unix_group_set_property (GObject *object, ...@@ -104,7 +104,7 @@ polkit_unix_group_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_GID: case PROP_GID:
unix_group->gid = g_value_get_uint (value); unix_group->gid = g_value_get_int (value);
break; break;
default: default:
...@@ -128,17 +128,17 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass) ...@@ -128,17 +128,17 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass)
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_GID, PROP_GID,
g_param_spec_uint ("gid", g_param_spec_int ("gid",
"Group ID", "Group ID",
"The UNIX group ID", "The UNIX group ID",
0, 0,
G_MAXUINT, G_MAXINT,
0, 0,
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_BLURB | G_PARAM_STATIC_BLURB |
G_PARAM_STATIC_NICK)); G_PARAM_STATIC_NICK));
} }
...@@ -150,7 +150,7 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass) ...@@ -150,7 +150,7 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass)
* *
* Returns: A UNIX group id. * Returns: A UNIX group id.
*/ */
gid_t gint
polkit_unix_group_get_gid (PolkitUnixGroup *group) polkit_unix_group_get_gid (PolkitUnixGroup *group)
{ {
return group->gid; return group->gid;
...@@ -165,7 +165,7 @@ polkit_unix_group_get_gid (PolkitUnixGroup *group) ...@@ -165,7 +165,7 @@ polkit_unix_group_get_gid (PolkitUnixGroup *group)
*/ */
void void
polkit_unix_group_set_gid (PolkitUnixGroup *group, polkit_unix_group_set_gid (PolkitUnixGroup *group,
gid_t gid) gint gid)
{ {
group->gid = gid; group->gid = gid;
} }
...@@ -179,7 +179,7 @@ polkit_unix_group_set_gid (PolkitUnixGroup *group, ...@@ -179,7 +179,7 @@ polkit_unix_group_set_gid (PolkitUnixGroup *group,
* Returns: A #PolkitUnixGroup object. Free with g_object_unref(). * Returns: A #PolkitUnixGroup object. Free with g_object_unref().
*/ */
PolkitIdentity * PolkitIdentity *
polkit_unix_group_new (gid_t gid) polkit_unix_group_new (gint gid)
{ {
return POLKIT_IDENTITY (g_object_new (POLKIT_TYPE_UNIX_GROUP, return POLKIT_IDENTITY (g_object_new (POLKIT_TYPE_UNIX_GROUP,
"gid", gid, "gid", gid,
......
...@@ -47,12 +47,12 @@ typedef struct _PolkitUnixGroup PolkitUnixGroup; ...@@ -47,12 +47,12 @@ typedef struct _PolkitUnixGroup PolkitUnixGroup;
typedef struct _PolkitUnixGroupClass PolkitUnixGroupClass; typedef struct _PolkitUnixGroupClass PolkitUnixGroupClass;
GType polkit_unix_group_get_type (void) G_GNUC_CONST; GType polkit_unix_group_get_type (void) G_GNUC_CONST;
PolkitIdentity *polkit_unix_group_new (gid_t gid); PolkitIdentity *polkit_unix_group_new (gint gid);
PolkitIdentity *polkit_unix_group_new_for_name (const gchar *name, PolkitIdentity *polkit_unix_group_new_for_name (const gchar *name,
GError **error); GError **error);
gid_t polkit_unix_group_get_gid (PolkitUnixGroup *group); gint polkit_unix_group_get_gid (PolkitUnixGroup *group);
void polkit_unix_group_set_gid (PolkitUnixGroup *group, void polkit_unix_group_set_gid (PolkitUnixGroup *group,
gid_t gid); gint gid);
G_END_DECLS G_END_DECLS
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include "polkitunixprocess.h" #include "polkitunixprocess.h"
#include "polkitsubject.h" #include "polkitsubject.h"
#include "polkitprivate.h" #include "polkitprivate.h"
...@@ -59,7 +61,7 @@ struct _PolkitUnixProcess ...@@ -59,7 +61,7 @@ struct _PolkitUnixProcess
{ {
GObject parent_instance; GObject parent_instance;
pid_t pid; gint pid;
guint64 start_time; guint64 start_time;
}; };
...@@ -77,11 +79,11 @@ enum ...@@ -77,11 +79,11 @@ enum
static void subject_iface_init (PolkitSubjectIface *subject_iface); static void subject_iface_init (PolkitSubjectIface *subject_iface);
static guint64 get_start_time_for_pid (pid_t pid, static guint64 get_start_time_for_pid (gint pid,
GError **error); GError **error);
#ifdef HAVE_FREEBSD #ifdef HAVE_FREEBSD
static gboolean get_kinfo_proc (pid_t pid, struct kinfo_proc *p); static gboolean get_kinfo_proc (gint pid, struct kinfo_proc *p);
#endif #endif
G_DEFINE_TYPE_WITH_CODE (PolkitUnixProcess, polkit_unix_process, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (PolkitUnixProcess, polkit_unix_process, G_TYPE_OBJECT,
...@@ -104,7 +106,7 @@ polkit_unix_process_get_property (GObject *object, ...@@ -104,7 +106,7 @@ polkit_unix_process_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_PID: case PROP_PID:
g_value_set_uint (value, unix_process->pid); g_value_set_int (value, unix_process->pid);
break; break;
case PROP_START_TIME: case PROP_START_TIME:
...@@ -128,7 +130,7 @@ polkit_unix_process_set_property (GObject *object, ...@@ -128,7 +130,7 @@ polkit_unix_process_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_PID: case PROP_PID:
polkit_unix_process_set_pid (unix_process, g_value_get_uint (value)); polkit_unix_process_set_pid (unix_process, g_value_get_int (value));
break; break;
default: default:
...@@ -152,17 +154,17 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass) ...@@ -152,17 +154,17 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass)
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_PID, PROP_PID,
g_param_spec_uint ("pid", g_param_spec_int ("pid",
"Process ID", "Process ID",
"The UNIX process ID", "The UNIX process ID",
0, 0,
G_MAXUINT, G_MAXINT,
0, 0,
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_BLURB | G_PARAM_STATIC_BLURB |
G_PARAM_STATIC_NICK)); G_PARAM_STATIC_NICK));
/** /**
* PolkitUnixProcess:start-time: * PolkitUnixProcess:start-time:
...@@ -192,48 +194,67 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass) ...@@ -192,48 +194,67 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass)
* *
* Returns: The process id for @process. * Returns: The process id for @process.
*/ */
pid_t gint
polkit_unix_process_get_pid (PolkitUnixProcess *process) polkit_unix_process_get_pid (PolkitUnixProcess *process)
{ {
return process->pid; return process->pid;
} }
/** /**
* polkit_unix_pid_get_uid: * polkit_unix_process_get_owner:
* @pid: A process ID. * @process: A #PolkitUnixProcess.
* @uid: A pointer to a uid_t. * @error: Return location for error or %NULL.
* *
* Gets the uid for a given @pid. * Gets the uid of the owner of @process.
* *
* Returns: 0 on success, -1 on failure. * Returns: The UNIX user id of the owner for @process or 0 if @error is set.
*/ **/
int gint
polkit_unix_pid_get_uid (pid_t pid, uid_t *uid) polkit_unix_process_get_owner (PolkitUnixProcess *process,
GError **error)
{ {
#ifndef HAVE_FREEBSD gint result;
#ifdef HAVE_FREEBSD
struct kinfo_proc p;
#else
struct stat statbuf; struct stat statbuf;
char procbuf[32]; char procbuf[32];
#else
struct kinfo_proc p;
#endif #endif
g_return_val_if_fail (uid != NULL, -1); result = 0;
g_return_val_if_fail (pid > 0, -1);
#ifndef HAVE_FREEBSD #ifdef HAVE_FREEBSD
g_snprintf (procbuf, sizeof procbuf, "/proc/%d", pid); if (get_kinfo_proc (process->pid, &p) == 0)
if (stat (procbuf, &statbuf) != 0) {
return -1; g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,
"get_kinfo_proc() failed for pid %d: %s",
process->pid,
g_strerror (errno));
goto out;
}
*uid = statbuf.st_uid; result = p.ki_uid;
#else #else
if (! get_kinfo_proc (pid, &p)) g_snprintf (procbuf, sizeof procbuf, "/proc/%d", process->pid);
return -1; if (stat (procbuf, &statbuf) != 0)
{
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,
"stat() failed for /proc/%d: %s",
process->pid,
g_strerror (errno));
goto out;
}
*uid = p.ki_uid; result = statbuf.st_uid;
#endif #endif
return 0; out:
return result;
} }
/** /**
...@@ -259,10 +280,10 @@ polkit_unix_process_get_start_time (PolkitUnixProcess *process) ...@@ -259,10 +280,10 @@ polkit_unix_process_get_start_time (PolkitUnixProcess *process)
*/ */
void void
polkit_unix_process_set_pid (PolkitUnixProcess *process, polkit_unix_process_set_pid (PolkitUnixProcess *process,
pid_t pid) gint pid)
{ {
process->pid = pid; process->pid = pid;
if (pid != (pid_t) -1) if (pid != (gint) -1)
process->start_time = get_start_time_for_pid (pid, NULL); process->start_time = get_start_time_for_pid (pid, NULL);
} }
...@@ -278,7 +299,7 @@ polkit_unix_process_set_pid (PolkitUnixProcess *process, ...@@ -278,7 +299,7 @@ polkit_unix_process_set_pid (PolkitUnixProcess *process,
* Returns: A #PolkitSubject. Free with g_object_unref(). * Returns: A #PolkitSubject. Free with g_object_unref().
*/ */
PolkitSubject * PolkitSubject *
polkit_unix_process_new (pid_t pid) polkit_unix_process_new (gint pid)
{ {
return POLKIT_SUBJECT (g_object_new (POLKIT_TYPE_UNIX_PROCESS, return POLKIT_SUBJECT (g_object_new (POLKIT_TYPE_UNIX_PROCESS,
"pid", pid, "pid", pid,
...@@ -295,12 +316,12 @@ polkit_unix_process_new (pid_t pid) ...@@ -295,12 +316,12 @@ polkit_unix_process_new (pid_t pid)
* Returns: A #PolkitSubject. Free with g_object_unref(). * Returns: A #PolkitSubject. Free with g_object_unref().
*/ */
PolkitSubject * PolkitSubject *
polkit_unix_process_new_full (pid_t pid, polkit_unix_process_new_full (gint pid,
guint64 start_time) guint64 start_time)
{ {
PolkitUnixProcess *process; PolkitUnixProcess *process;
process = POLKIT_UNIX_PROCESS (polkit_unix_process_new ((pid_t) -1)); process = POLKIT_UNIX_PROCESS (polkit_unix_process_new ((gint) -1));
process->pid = pid;