Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
polkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zbigniew Jędrzejewski-Szmek
polkit
Commits
2d0ef52d
Commit
2d0ef52d
authored
Jul 30, 2010
by
David Zeuthen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nuke eggdbus usage
Signed-off-by:
David Zeuthen
<
davidz@redhat.com
>
parent
d04cd425
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
312 additions
and
844 deletions
+312
-844
configure.ac
configure.ac
+1
-5
src/polkit/Makefile.am
src/polkit/Makefile.am
+0
-38
src/polkit/polkitactiondescription.c
src/polkit/polkitactiondescription.c
+89
-108
src/polkit/polkitauthorizationresult.c
src/polkit/polkitauthorizationresult.c
+8
-58
src/polkit/polkitdetails.c
src/polkit/polkitdetails.c
+1
-8
src/polkit/polkitidentity.c
src/polkit/polkitidentity.c
+0
-74
src/polkit/polkitprivate.h
src/polkit/polkitprivate.h
+12
-22
src/polkit/polkitsubject.c
src/polkit/polkitsubject.c
+0
-101
src/polkit/polkitsystembusname.c
src/polkit/polkitsystembusname.c
+77
-113
src/polkit/polkittemporaryauthorization.c
src/polkit/polkittemporaryauthorization.c
+24
-62
src/polkit/polkitunixsession.c
src/polkit/polkitunixsession.c
+83
-222
src/polkitagent/Makefile.am
src/polkitagent/Makefile.am
+0
-4
src/polkitbackend/Makefile.am
src/polkitbackend/Makefile.am
+0
-4
src/polkitbackend/polkitbackendactionpool.c
src/polkitbackend/polkitbackendactionpool.c
+16
-22
src/polkitbackend/polkitbackendinteractiveauthority.c
src/polkitbackend/polkitbackendinteractiveauthority.c
+1
-1
src/polkitbackend/polkitbackendprivate.h
src/polkitbackend/polkitbackendprivate.h
+0
-2
No files found.
configure.ac
View file @
2d0ef52d
...
...
@@ -120,14 +120,10 @@ if test "x$GCC" = "xyes"; then
changequote([,])dnl
fi
PKG_CHECK_MODULES(GLIB, [g
lib-2.0 >= 2.21.4 gio-2.0 >= 2.21.4
])
PKG_CHECK_MODULES(GLIB, [g
io-2.0 >= 2.25.11
])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(EGG_DBUS, [eggdbus-1 >= 0.6])
AC_SUBST(EGG_DBUS_CFLAGS)
AC_SUBST(EGG_DBUS_LIBS)
EXPAT_LIB=""
AC_ARG_WITH(expat, [ --with-expat=<dir> Use expat from here],
[
...
...
src/polkit/Makefile.am
View file @
2d0ef52d
...
...
@@ -12,11 +12,9 @@ INCLUDES = \
-DPACKAGE_LIB_DIR
=
\"
"
$(libdir)
"
\"
\
-D_POSIX_PTHREAD_SEMANTICS
\
-D_REENTRANT
\
-DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE
\
$(NULL)
BUILT_SOURCES
=
\
polkit-built-sources.stamp
\
polkitenumtypes.c polkitenumtypes.h
\
$(NULL)
...
...
@@ -32,37 +30,6 @@ polkitenumtypes.c: $(enum_headers) polkitenumtypes.c.template
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
#
polkit-built-sources.stamp
:
Makefile.am $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml $(top_srcdir)/data/org.freedesktop.PolicyKit1.AuthenticationAgent.xml
eggdbus-binding-tool
\
--namespace
"_Polkit"
\
--dbus-namespace
"org.freedesktop.PolicyKit1"
\
--introspection-xml
$(top_srcdir)
/data/org.freedesktop.PolicyKit1.Authority.xml
\
--introspection-xml
$(top_srcdir)
/data/org.freedesktop.PolicyKit1.AuthenticationAgent.xml
\
--stamp-file
polkit-built-sources.stamp
\
$(NULL)
# keep in sync with contents of polkit-built-sources.stamp (Thanks autotools)
#
polkit_built_sources
=
_polkitactiondescription.c _polkitactiondescription.h _polkitauthenticationagent.c _polkitauthenticationagent.h _polkitauthority.c _polkitauthority.h _polkitauthorizationresult.c _polkitauthorizationresult.h _polkitbindings.c _polkitbindings.h _polkitbindingsmarshal.c _polkitbindingsmarshal.h _polkitbindingstypes.h _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h _polkiterror.c _polkiterror.h _polkitidentity.c _polkitidentity.h _polkitimplicitauthorization.c _polkitimplicitauthorization.h _polkitsubject.c _polkitsubject.h _polkittemporaryauthorization.c _polkittemporaryauthorization.h docbook-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.xml docbook-interface-org.freedesktop.PolicyKit1.Authority.xml _polkitbindingsmarshal.list _polkitauthorityfeatures.h _polkitauthorityfeatures.c
noinst_LTLIBRARIES
=
libpolkit-private.la
libpolkit_private_la_SOURCES
=
$(polkit_built_sources)
libpolkit_private_la_CFLAGS
=
\
-D_POLKIT_COMPILATION
\
$(GLIB_CFLAGS)
\
$(EGG_DBUS_CFLAGS)
\
$(NULL)
libpolkit_private_la_LIBADD
=
\
$(GLIB_LIBS)
\
$(EGG_DBUS_LIBS)
\
$(NULL)
lib_LTLIBRARIES
=
libpolkit-gobject-1.la
libpolkit_gobject_1includedir
=
$(includedir)
/polkit-1/polkit
...
...
@@ -114,13 +81,10 @@ libpolkit_gobject_1_la_SOURCES = \
libpolkit_gobject_1_la_CFLAGS
=
\
-D_POLKIT_COMPILATION
\
$(GLIB_CFLAGS)
\
$(EGG_DBUS_CFLAGS)
\
$(NULL)
libpolkit_gobject_1_la_LIBADD
=
\
$(GLIB_LIBS)
\
$(EGG_DBUS_LIBS)
\
libpolkit-private.la
\
$(NULL)
libpolkit_gobject_1_la_LDFLAGS
=
-export-symbols-regex
'(^polkit_.*)'
...
...
@@ -143,10 +107,8 @@ Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am
--pkg
=
gobject-2.0
\
--pkg
=
gio-2.0
\
--libtool
=
$(top_builddir)
/libtool
\
$(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
\
...
...
src/polkit/polkitactiondescription.c
View file @
2d0ef52d
...
...
@@ -26,7 +26,6 @@
#include <string.h>
#include "polkitimplicitauthorization.h"
#include "polkitactiondescription.h"
#include "_polkitactiondescription.h"
#include "polkitprivate.h"
...
...
@@ -46,9 +45,16 @@
struct
_PolkitActionDescription
{
GObject
parent_instance
;
_PolkitActionDescription
*
real
;
gchar
*
action_id
;
gchar
*
description
;
gchar
*
message
;
gchar
*
vendor_name
;
gchar
*
vendor_url
;
gchar
*
icon_name
;
PolkitImplicitAuthorization
implicit_any
;
PolkitImplicitAuthorization
implicit_inactive
;
PolkitImplicitAuthorization
implicit_active
;
GHashTable
*
annotations
;
gchar
**
annotation_keys
;
};
...
...
@@ -62,6 +68,10 @@ G_DEFINE_TYPE (PolkitActionDescription, polkit_action_description, G_TYPE_OBJECT
static
void
polkit_action_description_init
(
PolkitActionDescription
*
action_description
)
{
action_description
->
annotations
=
g_hash_table_new_full
(
g_str_hash
,
g_str_equal
,
g_free
,
g_free
);
}
static
void
...
...
@@ -71,9 +81,13 @@ polkit_action_description_finalize (GObject *object)
action_description
=
POLKIT_ACTION_DESCRIPTION
(
object
);
if
(
action_description
->
real
!=
NULL
)
g_object_unref
(
action_description
->
real
);
g_free
(
action_description
->
action_id
);
g_free
(
action_description
->
description
);
g_free
(
action_description
->
message
);
g_free
(
action_description
->
vendor_name
);
g_free
(
action_description
->
vendor_url
);
g_free
(
action_description
->
icon_name
);
g_hash_table_unref
(
action_description
->
annotations
);
g_strfreev
(
action_description
->
annotation_keys
);
if
(
G_OBJECT_CLASS
(
polkit_action_description_parent_class
)
->
finalize
!=
NULL
)
...
...
@@ -84,27 +98,9 @@ static void
polkit_action_description_class_init
(
PolkitActionDescriptionClass
*
klass
)
{
GObjectClass
*
gobject_class
=
G_OBJECT_CLASS
(
klass
);
gobject_class
->
finalize
=
polkit_action_description_finalize
;
}
PolkitActionDescription
*
polkit_action_description_new_for_real
(
_PolkitActionDescription
*
real
)
{
PolkitActionDescription
*
action_description
;
action_description
=
POLKIT_ACTION_DESCRIPTION
(
g_object_new
(
POLKIT_TYPE_ACTION_DESCRIPTION
,
NULL
));
action_description
->
real
=
g_object_ref
(
real
);
return
action_description
;
}
_PolkitActionDescription
*
polkit_action_description_get_real
(
PolkitActionDescription
*
action_description
)
{
return
g_object_ref
(
action_description
->
real
);
}
/**
* polkit_action_description_get_action_id:
* @action_description: A #PolkitActionDescription.
...
...
@@ -116,7 +112,7 @@ polkit_action_description_get_real (PolkitActionDescription *action_description)
const
gchar
*
polkit_action_description_get_action_id
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_action_id
(
action_description
->
real
)
;
return
action_description
->
action_id
;
}
/**
...
...
@@ -130,7 +126,7 @@ polkit_action_description_get_action_id (PolkitActionDescription *action_descrip
const
gchar
*
polkit_action_description_get_description
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_description
(
action_description
->
real
)
;
return
action_description
->
description
;
}
/**
...
...
@@ -144,7 +140,7 @@ polkit_action_description_get_description (PolkitActionDescription *action_descr
const
gchar
*
polkit_action_description_get_message
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_message
(
action_description
->
real
)
;
return
action_description
->
message
;
}
/**
...
...
@@ -159,7 +155,7 @@ polkit_action_description_get_message (PolkitActionDescription *action_descripti
const
gchar
*
polkit_action_description_get_vendor_name
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_vendor_name
(
action_description
->
real
)
;
return
action_description
->
vendor_name
;
}
/**
...
...
@@ -174,7 +170,7 @@ polkit_action_description_get_vendor_name (PolkitActionDescription *action_descr
const
gchar
*
polkit_action_description_get_vendor_url
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_vendor_url
(
action_description
->
real
)
;
return
action_description
->
vendor_url
;
}
/**
...
...
@@ -189,7 +185,7 @@ polkit_action_description_get_vendor_url (PolkitActionDescription *action_descri
PolkitImplicitAuthorization
polkit_action_description_get_implicit_any
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_implicit_any
(
action_description
->
real
)
;
return
action_description
->
implicit_any
;
}
/**
...
...
@@ -204,7 +200,7 @@ polkit_action_description_get_implicit_any (PolkitActionDescription *action_desc
PolkitImplicitAuthorization
polkit_action_description_get_implicit_inactive
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_implicit_inactive
(
action_description
->
real
)
;
return
action_description
->
implicit_inactive
;
}
/**
...
...
@@ -219,7 +215,7 @@ polkit_action_description_get_implicit_inactive (PolkitActionDescription *action
PolkitImplicitAuthorization
polkit_action_description_get_implicit_active
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_implicit_active
(
action_description
->
real
)
;
return
action_description
->
implicit_active
;
}
...
...
@@ -235,7 +231,7 @@ polkit_action_description_get_implicit_active (PolkitActionDescription *action_d
const
gchar
*
polkit_action_description_get_icon_name
(
PolkitActionDescription
*
action_description
)
{
return
_polkit_action_description_get_icon_name
(
action_description
->
real
)
;
return
action_description
->
icon_name
;
}
/**
...
...
@@ -252,27 +248,9 @@ const gchar *
polkit_action_description_get_annotation
(
PolkitActionDescription
*
action_description
,
const
gchar
*
key
)
{
EggDBusHashMap
*
annotations
;
annotations
=
_polkit_action_description_get_annotations
(
action_description
->
real
);
return
egg_dbus_hash_map_lookup
(
annotations
,
key
);
}
static
gboolean
collect_keys
(
EggDBusHashMap
*
hash_map
,
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
GPtrArray
*
p
=
user_data
;
g_ptr_array_add
(
p
,
g_strdup
(
key
));
return
FALSE
;
return
g_hash_table_lookup
(
action_description
->
annotations
,
key
);
}
/**
* polkit_action_description_get_annotation_keys:
* @action_description: A #PolkitActionDescription.
...
...
@@ -284,106 +262,109 @@ collect_keys (EggDBusHashMap *hash_map,
const
gchar
*
const
*
polkit_action_description_get_annotation_keys
(
PolkitActionDescription
*
action_description
)
{
EggDBusHashMap
*
annotations
;
GPtrArray
*
p
;
GHashTableIter
iter
;
const
gchar
*
key
;
if
(
action_description
->
annotation_keys
!=
NULL
)
goto
out
;
annotations
=
_polkit_action_description_get_annotations
(
action_description
->
real
);
p
=
g_ptr_array_new
();
egg_dbus_hash_map_foreach
(
annotations
,
collect_keys
,
p
);
g_hash_table_iter_init
(
&
iter
,
action_description
->
annotations
);
while
(
g_hash_table_iter_next
(
&
iter
,
(
gpointer
)
&
key
,
NULL
))
g_ptr_array_add
(
p
,
g_strdup
(
key
));
g_ptr_array_add
(
p
,
NULL
);
action_description
->
annotation_keys
=
(
gchar
**
)
g_ptr_array_free
(
p
,
FALSE
);
out:
return
(
const
gchar
*
const
*
)
action_description
->
annotation_keys
;
}
PolkitActionDescription
*
polkit_action_description_new
(
const
gchar
*
action_id
,
const
gchar
*
description
,
const
gchar
*
message
,
const
gchar
*
vendor_name
,
const
gchar
*
vendor_url
,
const
gchar
*
icon_name
,
PolkitImplicitAuthorization
implicit_any
,
PolkitImplicitAuthorization
implicit_inactive
,
PolkitImplicitAuthorization
implicit_active
,
GHashTable
*
annotations
)
{
PolkitActionDescription
*
ret
;
ret
=
POLKIT_ACTION_DESCRIPTION
(
g_object_new
(
POLKIT_TYPE_ACTION_DESCRIPTION
,
NULL
));
ret
->
action_id
=
g_strdup
(
action_id
);
ret
->
description
=
g_strdup
(
description
);
ret
->
message
=
g_strdup
(
message
);
ret
->
vendor_name
=
g_strdup
(
vendor_name
);
ret
->
vendor_url
=
g_strdup
(
vendor_url
);
ret
->
icon_name
=
g_strdup
(
icon_name
);
ret
->
implicit_any
=
implicit_any
;
ret
->
implicit_inactive
=
implicit_inactive
;
ret
->
implicit_active
=
implicit_active
;
ret
->
annotations
=
g_hash_table_ref
(
annotations
);
return
ret
;
}
PolkitActionDescription
*
polkit_action_description_new_for_gvariant
(
GVariant
*
value
)
{
PolkitActionDescription
*
action_description
;
GVariantIter
iter
;
const
gchar
*
action_id
;
const
gchar
*
description
;
const
gchar
*
message
;
const
gchar
*
vendor_name
;
const
gchar
*
vendor_url
;
const
gchar
*
icon_name
;
PolkitImplicitAuthorization
implicit_any
;
PolkitImplicitAuthorization
implicit_inactive
;
PolkitImplicitAuthorization
implicit_active
;
GVariant
*
annotations_dict
;
gchar
*
a_key
;
gchar
*
a_value
;
EggDBusHashMap
*
hm
;
action_description
=
POLKIT_ACTION_DESCRIPTION
(
g_object_new
(
POLKIT_TYPE_ACTION_DESCRIPTION
,
NULL
));
g_variant_get
(
value
,
"(
&s&s&s&s&s&
suuu@a{ss})"
,
&
action_id
,
&
description
,
&
message
,
&
vendor_name
,
&
vendor_url
,
&
icon_name
,
&
implicit_any
,
&
implicit_inactive
,
&
implicit_active
,
"(
sssss
suuu@a{ss})"
,
&
action_
description
->
action_
id
,
&
action_description
->
description
,
&
action_description
->
message
,
&
action_description
->
vendor_name
,
&
action_description
->
vendor_url
,
&
action_description
->
icon_name
,
&
action_description
->
implicit_any
,
&
action_description
->
implicit_inactive
,
&
action_description
->
implicit_active
,
&
annotations_dict
);
hm
=
egg_dbus_hash_map_new
(
G_TYPE_STRING
,
g_free
,
G_TYPE_STRING
,
g_free
);
g_variant_iter_init
(
&
iter
,
annotations_dict
);
while
(
g_variant_iter_next
(
&
iter
,
"{ss}"
,
&
a_key
,
&
a_value
))
egg_dbus_hash_map_insert
(
hm
,
a_key
,
a_value
);
g_hash_table_insert
(
action_description
->
annotations
,
a_key
,
a_value
);
/* adopts a_key and a_value */
g_variant_unref
(
annotations_dict
);
action_description
->
real
=
_polkit_action_description_new
(
action_id
,
description
,
message
,
vendor_name
,
vendor_url
,
icon_name
,
implicit_any
,
implicit_inactive
,
implicit_active
,
hm
);
g_object_unref
(
hm
);
return
action_description
;
}
static
gboolean
add_annotation
(
EggDBusHashMap
*
hash_map
,
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
GVariantBuilder
*
builder
=
user_data
;
g_variant_builder_add
(
builder
,
"{ss}"
,
key
,
value
);
return
FALSE
;
}
GVariant
*
polkit_action_description_to_gvariant
(
PolkitActionDescription
*
action_description
)
{
GVariant
*
value
;
GVariantBuilder
builder
;
GHashTableIter
iter
;
const
gchar
*
a_key
;
const
gchar
*
a_value
;
g_variant_builder_init
(
&
builder
,
G_VARIANT_TYPE
(
"a{ss}"
));
egg_dbus_hash_map_foreach
(
_polkit_action_description_get_annotations
(
action_description
->
real
),
add_annotation
,
&
builder
);
g_hash_table_iter_init
(
&
iter
,
action_description
->
annotations
);
while
(
g_hash_table_iter_next
(
&
iter
,
(
gpointer
)
&
a_key
,
(
gpointer
)
&
a_value
))
g_variant_builder_add
(
&
builder
,
"{ss}"
,
a_key
,
a_value
);
/* TODO: note 'foo ? : ""' is a gcc specific extension (it's a short-hand for 'foo ? foo : ""') */
value
=
g_variant_new
(
"(ssssssuuua{ss})"
,
_polkit_action_description_get_action_id
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_description
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_message
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_vendor_name
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_vendor_url
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_icon_name
(
action_description
->
real
)
?
:
""
,
_polkit_action_description_get_implicit_any
(
action_description
->
real
)
,
_polkit_action_description_get_implicit_inactive
(
action_description
->
real
)
,
_polkit_action_description_get_implicit_active
(
action_description
->
real
)
,
action_description
->
action_id
?
:
""
,
action_description
->
description
?
:
""
,
action_description
->
message
?
:
""
,
action_description
->
vendor_name
?
:
""
,
action_description
->
vendor_url
?
:
""
,
action_description
->
icon_name
?
:
""
,
action_description
->
implicit_any
,
action_description
->
implicit_inactive
,
action_description
->
implicit_active
,
&
builder
);
return
value
;
...
...
src/polkit/polkitauthorizationresult.c
View file @
2d0ef52d
...
...
@@ -45,7 +45,8 @@ struct _PolkitAuthorizationResult
{
GObject
parent_instance
;
_PolkitAuthorizationResult
*
real
;
gboolean
is_authorized
;
gboolean
is_challenge
;
PolkitDetails
*
details
;
};
...
...
@@ -69,7 +70,6 @@ polkit_authorization_result_finalize (GObject *object)
authorization_result
=
POLKIT_AUTHORIZATION_RESULT
(
object
);
g_object_unref
(
authorization_result
->
real
);
if
(
authorization_result
->
details
!=
NULL
)
g_object_unref
(
authorization_result
->
details
);
...
...
@@ -85,24 +85,6 @@ polkit_authorization_result_class_init (PolkitAuthorizationResultClass *klass)
gobject_class
->
finalize
=
polkit_authorization_result_finalize
;
}
PolkitAuthorizationResult
*
polkit_authorization_result_new_for_real
(
_PolkitAuthorizationResult
*
real
)
{
PolkitAuthorizationResult
*
authorization_result
;
authorization_result
=
POLKIT_AUTHORIZATION_RESULT
(
g_object_new
(
POLKIT_TYPE_AUTHORIZATION_RESULT
,
NULL
));
authorization_result
->
real
=
g_object_ref
(
real
);
return
authorization_result
;
}
_PolkitAuthorizationResult
*
polkit_authorization_result_get_real
(
PolkitAuthorizationResult
*
authorization_result
)
{
return
g_object_ref
(
authorization_result
->
real
);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
...
...
@@ -123,33 +105,11 @@ polkit_authorization_result_new (gboolean is_authorized,
PolkitDetails
*
details
)
{
PolkitAuthorizationResult
*
authorization_result
;
_PolkitAuthorizationResult
*
real
;
EggDBusHashMap
*
real_details
;
real_details
=
egg_dbus_hash_map_new
(
G_TYPE_STRING
,
g_free
,
G_TYPE_STRING
,
g_free
);
if
(
details
!=
NULL
)
{
GHashTable
*
hash
;
GHashTableIter
iter
;
gpointer
key
,
value
;
hash
=
polkit_details_get_hash
(
details
);
if
(
hash
!=
NULL
)
{
g_hash_table_iter_init
(
&
iter
,
hash
);
while
(
g_hash_table_iter_next
(
&
iter
,
&
key
,
&
value
))
{
egg_dbus_hash_map_insert
(
real_details
,
g_strdup
(
key
),
g_strdup
(
value
));
}
}
}
real
=
_polkit_authorization_result_new
(
is_authorized
,
is_challenge
,
real_details
);
g_object_unref
(
real_details
);
authorization_result
=
polkit_authorization_result_new_for_real
(
real
);
g_object_unref
(
real
);
authorization_result
=
POLKIT_AUTHORIZATION_RESULT
(
g_object_new
(
POLKIT_TYPE_AUTHORIZATION_RESULT
,
NULL
));
authorization_result
->
is_authorized
=
is_authorized
;
authorization_result
->
is_challenge
=
is_challenge
;
authorization_result
->
details
=
g_object_ref
(
details
);
return
authorization_result
;
}
...
...
@@ -168,7 +128,7 @@ polkit_authorization_result_new (gboolean is_authorized,
gboolean
polkit_authorization_result_get_is_authorized
(
PolkitAuthorizationResult
*
result
)
{
return
_polkit_authorization_result_get_is_authorized
(
result
->
real
)
;
return
result
->
is_authorized
;
}
/**
...
...
@@ -182,7 +142,7 @@ polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result
gboolean
polkit_authorization_result_get_is_challenge
(
PolkitAuthorizationResult
*
result
)
{
return
_polkit_authorization_result_get_is_challenge
(
result
->
real
)
;
return
result
->
is_challenge
;
}
/**
...
...
@@ -197,16 +157,6 @@ polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result)
PolkitDetails
*
polkit_authorization_result_get_details
(
PolkitAuthorizationResult
*
result
)
{
EggDBusHashMap
*
real_details
;
if
(
result
->
details
!=
NULL
)
goto
out
;
real_details
=
_polkit_authorization_result_get_details
(
result
->
real
);
if
(
real_details
!=
NULL
)
result
->
details
=
result
->
details
=
polkit_details_new_for_hash
(
real_details
->
data
);
out:
return
result
->
details
;
}
...
...
src/polkit/polkitdetails.c
View file @
2d0ef52d
...
...
@@ -102,7 +102,7 @@ polkit_details_new (void)
}
/* private */
PolkitDetails
*
static
PolkitDetails
*
polkit_details_new_for_hash
(
GHashTable
*
hash
)
{
PolkitDetails
*
details
;
...
...
@@ -114,13 +114,6 @@ polkit_details_new_for_hash (GHashTable *hash)
return
details
;
}
/* private */
GHashTable
*
polkit_details_get_hash
(
PolkitDetails
*
details
)
{
return
details
->
hash
;
}
/**
* polkit_details_lookup:
* @details: A #PolkitDetails.
...
...
src/polkit/polkitidentity.c
View file @
2d0ef52d
...
...
@@ -185,80 +185,6 @@ polkit_identity_from_string (const gchar *str,
return
identity
;
}
PolkitIdentity
*
polkit_identity_new_for_real
(
_PolkitIdentity
*
real
)
{
PolkitIdentity
*
s
;
const
gchar
*
kind
;
EggDBusHashMap
*
details
;
EggDBusVariant
*
variant
;
s
=
NULL
;
kind
=
_polkit_identity_get_identity_kind
(
real
);
details
=
_polkit_identity_get_identity_details
(
real
);
if
(
strcmp
(
kind
,
"unix-user"
)
==
0
)
{
variant
=
egg_dbus_hash_map_lookup
(
details
,
"uid"
);
if
(
variant
!=
NULL
)
s
=
polkit_unix_user_new
(
egg_dbus_variant_get_uint
(
variant
));
}
else
if
(
strcmp
(
kind
,
"unix-group"
)
==
0
)
{
variant
=
egg_dbus_hash_map_lookup
(
details
,
"gid"
);
if
(
variant
!=
NULL
)
s
=
polkit_unix_group_new
(
egg_dbus_variant_get_uint
(
variant
));
}
else
{
g_warning
(
"Unknown identity kind %s:"
,
kind
);
}
return
s
;
}
_PolkitIdentity
*
polkit_identity_get_real
(
PolkitIdentity
*
identity
)
<