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
......@@ -394,9 +394,29 @@ case "$host_os" in
;;
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])
......@@ -448,6 +468,7 @@ echo "
cflags: ${CFLAGS}
cppflags: ${CPPFLAGS}
xsltproc: ${XSLTPROC}
introspection: ${enable_introspection}
Distribution/OS: ${with_os_type}
user for PolicyKit: ${POLKIT_USER}
......
......@@ -139,6 +139,7 @@ polkit_unix_process_new_full
polkit_unix_process_get_pid
polkit_unix_process_get_start_time
polkit_unix_process_set_pid
polkit_unix_process_get_owner
<SUBSECTION Standard>
PolkitUnixProcessClass
POLKIT_UNIX_PROCESS
......
......@@ -17,8 +17,21 @@ INCLUDES = \
BUILT_SOURCES = \
polkit-built-sources.stamp \
polkitenumtypes.c polkitenumtypes.h \
$(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
# only in the daemon for agent interaction
#
......@@ -43,6 +56,7 @@ libpolkit_gobject_1include_HEADERS = \
polkit.h \
polkitprivate.h \
polkittypes.h \
polkitenumtypes.h \
polkitactiondescription.h \
polkitdetails.h \
polkitauthority.h \
......@@ -92,6 +106,55 @@ libpolkit_gobject_1_la_LIBADD = \
$(EGG_DBUS_LIBS) \
$(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 :
(for i in $(polkit_built_sources) $(BUILT_SOURCES) ; do rm -f $(distdir)/$$i ; done)
......
......@@ -24,6 +24,8 @@
#define _POLKIT_INSIDE_POLKIT_H 1
#include <polkit/polkittypes.h>
#include <polkit/polkitenumtypes.h>
#include <polkit/polkitimplicitauthorization.h>
#include <polkit/polkitactiondescription.h>
#include <polkit/polkiterror.h>
......
......@@ -26,10 +26,4 @@
#include "polkitcheckauthorizationflags.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)
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,
&endptr,
10);
if (*endptr == '\0')
identity = polkit_unix_user_new ((uid_t) val);
identity = polkit_unix_user_new ((gint) val);
else
identity = polkit_unix_user_new_for_name (str + sizeof "unix-user:" - 1,
error);
......@@ -166,7 +166,7 @@ polkit_identity_from_string (const gchar *str,
&endptr,
10);
if (*endptr == '\0')
identity = polkit_unix_group_new ((gid_t) val);
identity = polkit_unix_group_new ((gint) val);
else
identity = polkit_unix_group_new_for_name (str + sizeof "unix-group:" - 1,
error);
......
......@@ -36,12 +36,6 @@
* Possible implicit authorizations.
*/
GType
polkit_implicit_authorization_get_type (void)
{
return _polkit_implicit_authorization_get_type ();
}
gboolean
polkit_implicit_authorization_from_string (const gchar *string,
PolkitImplicitAuthorization *out_implicit_authorization)
......
......@@ -225,7 +225,7 @@ polkit_subject_from_string (const gchar *str,
10);
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)
{
g_object_unref (subject);
......
......@@ -48,7 +48,7 @@ struct _PolkitUnixGroup
{
GObject parent_instance;
gid_t gid;
gint gid;
};
struct _PolkitUnixGroupClass
......@@ -84,7 +84,7 @@ polkit_unix_group_get_property (GObject *object,
switch (prop_id)
{
case PROP_GID:
g_value_set_uint (value, unix_group->gid);
g_value_set_int (value, unix_group->gid);
break;
default:
......@@ -104,7 +104,7 @@ polkit_unix_group_set_property (GObject *object,
switch (prop_id)
{
case PROP_GID:
unix_group->gid = g_value_get_uint (value);
unix_group->gid = g_value_get_int (value);
break;
default:
......@@ -128,11 +128,11 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass)
*/
g_object_class_install_property (gobject_class,
PROP_GID,
g_param_spec_uint ("gid",
g_param_spec_int ("gid",
"Group ID",
"The UNIX group ID",
0,
G_MAXUINT,
G_MAXINT,
0,
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE |
......@@ -150,7 +150,7 @@ polkit_unix_group_class_init (PolkitUnixGroupClass *klass)
*
* Returns: A UNIX group id.
*/
gid_t
gint
polkit_unix_group_get_gid (PolkitUnixGroup *group)
{
return group->gid;
......@@ -165,7 +165,7 @@ polkit_unix_group_get_gid (PolkitUnixGroup *group)
*/
void
polkit_unix_group_set_gid (PolkitUnixGroup *group,
gid_t gid)
gint gid)
{
group->gid = gid;
}
......@@ -179,7 +179,7 @@ polkit_unix_group_set_gid (PolkitUnixGroup *group,
* Returns: A #PolkitUnixGroup object. Free with g_object_unref().
*/
PolkitIdentity *
polkit_unix_group_new (gid_t gid)
polkit_unix_group_new (gint gid)
{
return POLKIT_IDENTITY (g_object_new (POLKIT_TYPE_UNIX_GROUP,
"gid", gid,
......
......@@ -47,12 +47,12 @@ typedef struct _PolkitUnixGroup PolkitUnixGroup;
typedef struct _PolkitUnixGroupClass PolkitUnixGroupClass;
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,
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,
gid_t gid);
gint gid);
G_END_DECLS
......
......@@ -33,6 +33,8 @@
#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "polkitunixprocess.h"
#include "polkitsubject.h"
#include "polkitprivate.h"
......@@ -59,7 +61,7 @@ struct _PolkitUnixProcess
{
GObject parent_instance;
pid_t pid;
gint pid;
guint64 start_time;
};
......@@ -77,11 +79,11 @@ enum
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);
#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
G_DEFINE_TYPE_WITH_CODE (PolkitUnixProcess, polkit_unix_process, G_TYPE_OBJECT,
......@@ -104,7 +106,7 @@ polkit_unix_process_get_property (GObject *object,
switch (prop_id)
{
case PROP_PID:
g_value_set_uint (value, unix_process->pid);
g_value_set_int (value, unix_process->pid);
break;
case PROP_START_TIME:
......@@ -128,7 +130,7 @@ polkit_unix_process_set_property (GObject *object,
switch (prop_id)
{
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;
default:
......@@ -152,11 +154,11 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass)
*/
g_object_class_install_property (gobject_class,
PROP_PID,
g_param_spec_uint ("pid",
g_param_spec_int ("pid",
"Process ID",
"The UNIX process ID",
0,
G_MAXUINT,
G_MAXINT,
0,
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE |
......@@ -192,48 +194,67 @@ polkit_unix_process_class_init (PolkitUnixProcessClass *klass)
*
* Returns: The process id for @process.
*/
pid_t
gint
polkit_unix_process_get_pid (PolkitUnixProcess *process)
{
return process->pid;
}
/**
* polkit_unix_pid_get_uid:
* @pid: A process ID.
* @uid: A pointer to a uid_t.
* polkit_unix_process_get_owner:
* @process: A #PolkitUnixProcess.
* @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.
*/
int
polkit_unix_pid_get_uid (pid_t pid, uid_t *uid)
* Returns: The UNIX user id of the owner for @process or 0 if @error is set.
**/
gint
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;
char procbuf[32];
#else
struct kinfo_proc p;
#endif
g_return_val_if_fail (uid != NULL, -1);
g_return_val_if_fail (pid > 0, -1);
result = 0;
#ifndef HAVE_FREEBSD
g_snprintf (procbuf, sizeof procbuf, "/proc/%d", pid);
if (stat (procbuf, &statbuf) != 0)
return -1;
#ifdef HAVE_FREEBSD
if (get_kinfo_proc (process->pid, &p) == 0)
{
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
if (! get_kinfo_proc (pid, &p))
return -1;
g_snprintf (procbuf, sizeof procbuf, "/proc/%d", process->pid);
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
return 0;
out:
return result;
}
/**
......@@ -259,10 +280,10 @@ polkit_unix_process_get_start_time (PolkitUnixProcess *process)
*/
void
polkit_unix_process_set_pid (PolkitUnixProcess *process,
pid_t pid)
gint pid)
{
process->pid = pid;
if (pid != (pid_t) -1)
if (pid != (gint) -1)
process->start_time = get_start_time_for_pid (pid, NULL);
}
......@@ -278,7 +299,7 @@ polkit_unix_process_set_pid (PolkitUnixProcess *process,
* Returns: A #PolkitSubject. Free with g_object_unref().
*/
PolkitSubject *
polkit_unix_process_new (pid_t pid)
polkit_unix_process_new (gint pid)
{
return POLKIT_SUBJECT (g_object_new (POLKIT_TYPE_UNIX_PROCESS,
"pid", pid,
......@@ -295,12 +316,12 @@ polkit_unix_process_new (pid_t pid)
* Returns: A #PolkitSubject. Free with g_object_unref().
*/
PolkitSubject *
polkit_unix_process_new_full (pid_t pid,
polkit_unix_process_new_full (gint pid,
guint64 start_time)
{
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;
process->start_time = start_time;
......
......@@ -47,16 +47,16 @@ typedef struct _PolkitUnixProcess PolkitUnixProcess;
typedef struct _PolkitUnixProcessClass PolkitUnixProcessClass;
GType polkit_unix_process_get_type (void) G_GNUC_CONST;
PolkitSubject *polkit_unix_process_new (pid_t pid);
PolkitSubject *polkit_unix_process_new_full (pid_t pid,
PolkitSubject *polkit_unix_process_new (gint pid);
PolkitSubject *polkit_unix_process_new_full (gint pid,
guint64 start_time);
pid_t polkit_unix_process_get_pid (PolkitUnixProcess *process);
int polkit_unix_pid_get_uid (pid_t pid, uid_t *uid);
gint polkit_unix_process_get_pid (PolkitUnixProcess *process);
guint64 polkit_unix_process_get_start_time (PolkitUnixProcess *process);
void polkit_unix_process_set_pid (PolkitUnixProcess *process,
pid_t pid);
gint pid);
gint polkit_unix_process_get_owner (PolkitUnixProcess *process,
GError **error);
G_END_DECLS
......
......@@ -50,7 +50,7 @@ struct _PolkitUnixSession
gchar *session_id;
pid_t pid;
gint pid;
};
struct _PolkitUnixSessionClass
......@@ -126,7 +126,7 @@ polkit_unix_session_set_property (GObject *object,
break;
case PROP_PID:
session->pid = g_value_get_uint (value);
session->pid = g_value_get_int (value);
break;
default:
......@@ -169,11 +169,11 @@ polkit_unix_session_class_init (PolkitUnixSessionClass *klass)
*/
g_object_class_install_property (gobject_class,
PROP_PID,
g_param_spec_uint ("pid",
g_param_spec_int ("pid",
"Process ID",
"Process ID to use for looking up the session",
0,
G_MAXUINT,
G_MAXINT,
0,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_WRITABLE |
......@@ -247,7 +247,7 @@ polkit_unix_session_new (const gchar *session_id)
* use polkit_unix_session_new_for_process_sync().
**/
void
polkit_unix_session_new_for_process (pid_t pid,
polkit_unix_session_new_for_process (gint pid,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
......@@ -307,7 +307,7 @@ polkit_unix_session_new_for_process_finish (GAsyncResult *res,
* Returns: A #PolkitUnixSession for @pid or %NULL if @error is set. Free with g_object_unref().
**/
PolkitSubject *
polkit_unix_session_new_for_process_sync (pid_t pid,
polkit_unix_session_new_for_process_sync (gint pid,
GCancellable *cancellable,
GError **error)
{
......
......@@ -46,13 +46,13 @@ typedef struct _PolkitUnixSessionClass PolkitUnixSessionClass;
GType polkit_unix_session_get_type (void) G_GNUC_CONST;
PolkitSubject *polkit_unix_session_new (const gchar *session_id);
void polkit_unix_session_new_for_process (pid_t pid,
void polkit_unix_session_new_for_process (gint pid,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
PolkitSubject *polkit_unix_session_new_for_process_finish (GAsyncResult *res,
GError **error);
PolkitSubject *polkit_unix_session_new_for_process_sync (pid_t pid,
PolkitSubject *polkit_unix_session_new_for_process_sync (gint pid,
GCancellable *cancellable,
GError **error);
const gchar *polkit_unix_session_get_session_id (PolkitUnixSession *session);
......
......@@ -48,7 +48,7 @@ struct _PolkitUnixUser
{
GObject parent_instance;
uid_t uid;
gint uid;
};
struct _PolkitUnixUserClass
......@@ -84,7 +84,7 @@ polkit_unix_user_get_property (GObject *object,
switch (prop_id)
{
case PROP_UID:
g_value_set_uint (value, unix_user->uid);
g_value_set_int (value, unix_user->uid);
break;
default:
......@@ -104,7 +104,7 @@ polkit_unix_user_set_property (GObject *object,
switch (prop_id)
{
case PROP_UID:
unix_user->uid = g_value_get_uint (value);
unix_user->uid = g_value_get_int (value);
break;
default:
......@@ -128,11 +128,11 @@ polkit_unix_user_class_init (PolkitUnixUserClass *klass)
*/
g_object_class_install_property (gobject_class,
PROP_UID,
g_param_spec_uint ("uid",
g_param_spec_int ("uid",
"User ID",
"The UNIX user ID",
0,
G_MAXUINT,
G_MAXINT,
0,
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE |
......@@ -150,7 +150,7 @@ polkit_unix_user_class_init (PolkitUnixUserClass *klass)
*
* Returns: A UNIX user id.
*/
uid_t
gint
polkit_unix_user_get_uid (PolkitUnixUser *user)
{
return user->uid;
......@@ -165,7 +165,7 @@ polkit_unix_user_get_uid (PolkitUnixUser *user)
*/
void
polkit_unix_user_set_uid (PolkitUnixUser *user,
uid_t uid)
gint uid)
{
user->uid = uid;
}
......@@ -179,7 +179,7 @@ polkit_unix_user_set_uid (PolkitUnixUser *user,
* Returns: A #PolkitUnixUser object. Free with g_object_unref().
*/
PolkitIdentity *
polkit_unix_user_new (uid_t uid)
polkit_unix_user_new (gint uid)
{
return POLKIT_IDENTITY (g_object_new (POLKIT_TYPE_UNIX_USER,
"uid", uid,
......
......@@ -47,12 +47,12 @@ typedef struct _PolkitUnixUser PolkitUnixUser;
typedef struct _PolkitUnixUserClass PolkitUnixUserClass;
GType polkit_unix_user_get_type (void) G_GNUC_CONST;
PolkitIdentity *polkit_unix_user_new (uid_t uid);
PolkitIdentity *polkit_unix_user_new (gint uid);
PolkitIdentity *polkit_unix_user_new_for_name (const gchar *name,
GError **error);
uid_t polkit_unix_user_get_uid (PolkitUnixUser *user);
gint polkit_unix_user_get_uid (PolkitUnixUser *user);
void polkit_unix_user_set_uid (PolkitUnixUser *user,
uid_t uid);
gint uid);
G_END_DECLS
......
......@@ -418,17 +418,14 @@ polkit_backend_session_monitor_get_user_for_subject (PolkitBackendSessionMonitor
if (POLKIT_IS_UNIX_PROCESS (subject))
{
pid_t pid;
pid = polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject));
GError *local_error;
if (polkit_unix_pid_get_uid (pid, &uid) != 0)
local_error = NULL;
uid = polkit_unix_process_get_owner (POLKIT_UNIX_PROCESS (subject), &local_error);
if (local_error != NULL)
{
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,
"Cannot get user for pid %d",
pid);
g_propagate_error (error, local_error);
g_error_free (local_error);
goto out;
}
user = polkit_unix_user_new (uid);
......
......@@ -351,10 +351,22 @@ main (int argc, char *argv[])
pid_of_caller = getpgrp ();
}
subject = polkit_unix_process_new (pid_of_caller);
if (subject == NULL)
{
g_printerr ("No such process for pid %d: %s\n", (gint) pid_of_caller, error->message);
g_error_free (error);
goto out;
}