It's more consistent and, uhm, easier to type.
## Process this file with automake to produce Makefile.in
-SUBDIRS = libpolkit libpolkit-dbus libpolkit-grant modules doc tools policy
-
-pamdir = $(sysconfdir)/pam.d
-pam_DATA = polkit
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libpolkit.pc libpolkit-dbus.pc libpolkit-grant.pc
-
-DISTCLEANFILES = libpolkit.pc libpolkit-dbus.pc libpolkit-grant.pc
+SUBDIRS = data polkit polkit-dbus polkit-grant modules doc tools policy
# Creating ChangeLog from git log (taken from cairo/Makefile.am):
ChangeLog: $(srcdir)/ChangeLog
.PHONY: ChangeLog $(srcdir)/ChangeLog
-EXTRA_DIST = HACKING polkit.in libpolkit.pc.in libpolkit-dbus.pc.in libpolkit-grant.pc.in mkinstalldirs ChangeLog
+EXTRA_DIST = HACKING mkinstalldirs ChangeLog
clean-local :
rm -f *~
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
-# libtool versioning - this applies to libpolkit
+# libtool versioning - this applies to all libraries in this package
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_SESSION, "$PAM_FILE_INCLUDE_SESSION", [pam file session])
AC_OUTPUT([
-libpolkit.pc
-libpolkit-dbus.pc
-libpolkit-grant.pc
Makefile
-polkit
-libpolkit/Makefile
-libpolkit-dbus/Makefile
-libpolkit-grant/Makefile
+data/Makefile
+data/polkit
+data/polkit.pc
+data/polkit-dbus.pc
+data/polkit-grant.pc
+polkit/Makefile
+polkit-dbus/Makefile
+polkit-grant/Makefile
tools/Makefile
doc/Makefile
doc/api/Makefile
-doc/api/libpolkit/Makefile
-doc/api/libpolkit/version.xml
-doc/api/libpolkit-dbus/Makefile
-doc/api/libpolkit-dbus/version.xml
-doc/api/libpolkit-grant/Makefile
-doc/api/libpolkit-grant/version.xml
+doc/api/polkit/Makefile
+doc/api/polkit/version.xml
+doc/api/polkit-dbus/Makefile
+doc/api/polkit-dbus/version.xml
+doc/api/polkit-grant/Makefile
+doc/api/polkit-grant/version.xml
doc/spec/Makefile
doc/spec/polkit-spec.xml.in
doc/man/Makefile
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+pamdir = $(sysconfdir)/pam.d
+pam_DATA = polkit
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = polkit.pc polkit-dbus.pc polkit-grant.pc
+
+DISTCLEANFILES = polkit.pc polkit-dbus.pc polkit-grant.pc
+
+EXTRA_DIST = polkit.in polkit.pc.in polkit-dbus.pc.in polkit-grant.pc.in
+
+clean-local :
+ rm -f *~
## Process this file with automake to create Makefile.in.
-SUBDIRS = libpolkit libpolkit-dbus libpolkit-grant
+SUBDIRS = polkit polkit-dbus polkit-grant
MAINTAINERCLEANFILES = \
*~ \
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
-DOC_MODULE=libpolkit
+DOC_MODULE=polkit-dbus
# The top-level SGML file.
-DOC_MAIN_SGML_FILE=libpolkit-docs.xml
+DOC_MAIN_SGML_FILE=polkit-dbus-docs.xml
# Extra options to supply to gtkdoc-scan
#SCAN_OPTIONS=--deprecated-guards="CAIRO_DISABLE_DEPRECATED"
# The directory containing the source code. Relative to $(srcdir)
-DOC_SOURCE_DIR=../../../libpolkit
+DOC_SOURCE_DIR=../../../polkit-dbus
# Used for dependencies
-HFILE_GLOB=$(top_srcdir)/libpolkit/*.h
-CFILE_GLOB=$(top_srcdir)/libpolkit/*.c
+HFILE_GLOB=$(top_srcdir)/polkit-dbus/*.h
+CFILE_GLOB=$(top_srcdir)/polkit-dbus/*.c
# Headers to ignore
IGNORE_HFILES= \
GTKDOC_LIBS = \
$(GLIB_LIBS) \
- $(top_builddir)/libpolkit/libpolkit.la \
+ $(top_builddir)/polkit-dbus/libpolkit-dbus.la \
$(NULL)
# Extra options to supply to gtkdoc-mkdb
MAINTAINERCLEANFILES = \
*~ \
Makefile.in \
- libpolkit.types \
- libpolkit-*.txt \
+ polkit-dbus.types \
+ polkit-dbus-*.txt \
$(NULL)
include $(top_srcdir)/gtk-doc.make
PolicyKit D-Bus helper library.
</para>
</partintro>
- <xi:include href="xml/libpolkit-dbus.xml"/>
+ <xi:include href="xml/polkit-dbus.xml"/>
</reference>
<index>
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
-DOC_MODULE=libpolkit-grant
+DOC_MODULE=polkit-grant
# The top-level SGML file.
-DOC_MAIN_SGML_FILE=libpolkit-grant-docs.xml
+DOC_MAIN_SGML_FILE=polkit-grant-docs.xml
# Extra options to supply to gtkdoc-scan
#SCAN_OPTIONS=--deprecated-guards="CAIRO_DISABLE_DEPRECATED"
# The directory containing the source code. Relative to $(srcdir)
-DOC_SOURCE_DIR=../../../libpolkit-grant
+DOC_SOURCE_DIR=../../../polkit-grant
# Used for dependencies
-HFILE_GLOB=$(top_srcdir)/libpolkit-grant/*.h
-CFILE_GLOB=$(top_srcdir)/libpolkit-grant/*.c
+HFILE_GLOB=$(top_srcdir)/polkit-grant/*.h
+CFILE_GLOB=$(top_srcdir)/polkit-grant/*.c
# Headers to ignore
IGNORE_HFILES= \
GTKDOC_LIBS = \
$(GLIB_LIBS) \
- $(top_builddir)/libpolkit-grant/libpolkit-grant.la \
+ $(top_builddir)/polkit-grant/libpolkit-grant.la \
$(NULL)
# Extra options to supply to gtkdoc-mkdb
MAINTAINERCLEANFILES = \
*~ \
Makefile.in \
- libpolkit-grant.types \
- libpolkit-grant-*.txt \
+ polkit-grant.types \
+ polkit-grant-*.txt \
$(NULL)
include $(top_srcdir)/gtk-doc.make
PolicyKit granting helper library.
</para>
</partintro>
- <xi:include href="xml/libpolkit-grant.xml"/>
+ <xi:include href="xml/polkit-grant.xml"/>
</reference>
<index>
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
-DOC_MODULE=libpolkit-dbus
+DOC_MODULE=polkit
# The top-level SGML file.
-DOC_MAIN_SGML_FILE=libpolkit-dbus-docs.xml
+DOC_MAIN_SGML_FILE=polkit-docs.xml
# Extra options to supply to gtkdoc-scan
#SCAN_OPTIONS=--deprecated-guards="CAIRO_DISABLE_DEPRECATED"
# The directory containing the source code. Relative to $(srcdir)
-DOC_SOURCE_DIR=../../../libpolkit-dbus
+DOC_SOURCE_DIR=../../../polkit
# Used for dependencies
-HFILE_GLOB=$(top_srcdir)/libpolkit-dbus/*.h
-CFILE_GLOB=$(top_srcdir)/libpolkit-dbus/*.c
+HFILE_GLOB=$(top_srcdir)/polkit/*.h
+CFILE_GLOB=$(top_srcdir)/polkit/*.c
# Headers to ignore
IGNORE_HFILES= \
GTKDOC_LIBS = \
$(GLIB_LIBS) \
- $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la \
+ $(top_builddir)/polkit/libpolkit.la \
$(NULL)
# Extra options to supply to gtkdoc-mkdb
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=
-MAINTAINERCLEANFILES = \
- *~ \
- Makefile.in \
- libpolkit-dbus.types \
- libpolkit-dbus-*.txt \
+MAINTAINERCLEANFILES = \
+ *~ \
+ Makefile.in \
+ polkit.types \
+ polkit-*.txt \
$(NULL)
include $(top_srcdir)/gtk-doc.make
PolicyKit library.
</para>
</partintro>
- <xi:include href="xml/libpolkit-types.xml"/>
- <xi:include href="xml/libpolkit-error.xml"/>
- <xi:include href="xml/libpolkit-result.xml"/>
- <xi:include href="xml/libpolkit-context.xml"/>
- <xi:include href="xml/libpolkit-action.xml"/>
- <xi:include href="xml/libpolkit-policy-file.xml"/>
- <xi:include href="xml/libpolkit-policy-file-entry.xml"/>
- <xi:include href="xml/libpolkit-policy-default.xml"/>
- <xi:include href="xml/libpolkit-policy-cache.xml"/>
- <xi:include href="xml/libpolkit-resource.xml"/>
- <xi:include href="xml/libpolkit-seat.xml"/>
- <xi:include href="xml/libpolkit-session.xml"/>
- <xi:include href="xml/libpolkit-caller.xml"/>
- <xi:include href="xml/libpolkit-module.xml"/>
- <xi:include href="xml/libpolkit-debug.xml"/>
- <xi:include href="xml/libpolkit-utils.xml"/>
+ <xi:include href="xml/polkit-types.xml"/>
+ <xi:include href="xml/polkit-error.xml"/>
+ <xi:include href="xml/polkit-result.xml"/>
+ <xi:include href="xml/polkit-context.xml"/>
+ <xi:include href="xml/polkit-action.xml"/>
+ <xi:include href="xml/polkit-policy-file.xml"/>
+ <xi:include href="xml/polkit-policy-file-entry.xml"/>
+ <xi:include href="xml/polkit-policy-default.xml"/>
+ <xi:include href="xml/polkit-policy-cache.xml"/>
+ <xi:include href="xml/polkit-resource.xml"/>
+ <xi:include href="xml/polkit-seat.xml"/>
+ <xi:include href="xml/polkit-session.xml"/>
+ <xi:include href="xml/polkit-caller.xml"/>
+ <xi:include href="xml/polkit-module.xml"/>
</reference>
<index>
+++ /dev/null
-## Process this file with automake to produce Makefile.in
-
-INCLUDES = \
- -I$(top_builddir) -I$(top_srcdir) \
- -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
- -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
- -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
- -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
- -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
- -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
- -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
- -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
- -DPOLKIT_COMPILATION \
- @GLIB_CFLAGS@
-
-lib_LTLIBRARIES=libpolkit.la
-
-libpolkitincludedir=$(includedir)/PolicyKit/libpolkit
-
-libpolkitinclude_HEADERS = \
- libpolkit.h \
- libpolkit-types.h \
- libpolkit-error.h \
- libpolkit-result.h \
- libpolkit-context.h \
- libpolkit-action.h \
- libpolkit-resource.h \
- libpolkit-seat.h \
- libpolkit-session.h \
- libpolkit-caller.h \
- libpolkit-policy-file-entry.h \
- libpolkit-policy-file.h \
- libpolkit-policy-cache.h \
- libpolkit-policy-default.h \
- libpolkit-module.h
-
-libpolkit_la_SOURCES = \
- libpolkit.h \
- libpolkit-types.h \
- libpolkit-error.h libpolkit-error.c \
- libpolkit-result.h libpolkit-result.c \
- libpolkit-context.h libpolkit-context.c \
- libpolkit-action.h libpolkit-action.c \
- libpolkit-resource.h libpolkit-resource.c \
- libpolkit-seat.h libpolkit-seat.c \
- libpolkit-session.h libpolkit-session.c \
- libpolkit-caller.h libpolkit-caller.c \
- libpolkit-policy-file-entry.h libpolkit-policy-file-entry.c \
- libpolkit-policy-file.h libpolkit-policy-file.c \
- libpolkit-policy-cache.h libpolkit-policy-cache.c \
- libpolkit-policy-default.h libpolkit-policy-default.c \
- libpolkit-debug.h libpolkit-debug.c \
- libpolkit-utils.h libpolkit-utils.c \
- libpolkit-module.h libpolkit-module.c
-
-libpolkit_la_LIBADD = @GLIB_LIBS@ -ldl
-
-libpolkit_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-
-clean-local :
- rm -f *~ $(BUILT_SOURCES)
-
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * libpolkit-caller.h : callers
- *
- * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef LIBPOLKIT_CALLER_H
-#define LIBPOLKIT_CALLER_H
-
-#include <libpolkit/libpolkit-types.h>
-#include <libpolkit/libpolkit-session.h>
-#include <sys/types.h>
-
-struct PolKitCaller;
-typedef struct PolKitCaller PolKitCaller;
-
-PolKitCaller *libpolkit_caller_new (void);
-PolKitCaller *libpolkit_caller_ref (PolKitCaller *caller);
-void libpolkit_caller_unref (PolKitCaller *caller);
-polkit_bool_t libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name);
-polkit_bool_t libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid);
-polkit_bool_t libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid);
-polkit_bool_t libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context);
-polkit_bool_t libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session);
-polkit_bool_t libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name);
-polkit_bool_t libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid);
-polkit_bool_t libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid);
-polkit_bool_t libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context);
-polkit_bool_t libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session);
-
-void libpolkit_caller_debug (PolKitCaller *caller);
-polkit_bool_t libpolkit_caller_validate (PolKitCaller *caller);
-
-#endif /* LIBPOLKIT_H */
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * libpolkit-result.h : result codes from PolicyKit
- *
- * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef LIBPOLKIT_RESULT_H
-#define LIBPOLKIT_RESULT_H
-
-#include <libpolkit/libpolkit-types.h>
-
-/**
- * PolKitResult:
- * @LIBPOLKIT_RESULT_UNKNOWN_ACTION: The passed action is unknown.
- * @LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW: The caller of libpolkit is not sufficiently privilege to know the answer.
- * @LIBPOLKIT_RESULT_NO: Access denied.
- * @LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH: Access denied, but authentication of the caller as
- * root will grant access to the resource... but the access isn't permanent
- * @LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
- * root will grant access to the resource for the remainder of the session
- * @LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
- * root will grant access to the resource in the future.
- * @LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH: Access denied, but authentication of the caller as
- * himself will grant access to the resource... but the access isn't permanent
- * @LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
- * himself will grant access to the resource for the remainder of the session
- * @LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
- * himself will grant access to the resource in the future.
- * @LIBPOLKIT_RESULT_YES: Access granted.
- * @LIBPOLKIT_RESULT_N_RESULTS: Number of result codes
- *
- * Result codes from queries to PolicyKit. These are ordered and we
- * say that a result A is "more strict" than a result B, if A has a
- * lower numerical value. (e.g. #LIBPOLKIT_RESULT_NO is more strict
- * than #LIBPOLKIT_RESULT_YES).
- */
-typedef enum
-{
- LIBPOLKIT_RESULT_UNKNOWN_ACTION,
- LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
- LIBPOLKIT_RESULT_NO,
-
- LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH,
- LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION,
- LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS,
-
- LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH,
- LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION,
- LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS,
-
- LIBPOLKIT_RESULT_YES,
- LIBPOLKIT_RESULT_N_RESULTS
-} PolKitResult;
-
-const char *
-libpolkit_result_to_string_representation (PolKitResult result);
-
-polkit_bool_t
-libpolkit_result_from_string_representation (const char *string, PolKitResult *out_result);
-
-#endif /* LIBPOLKIT_RESULT_H */
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * libpolkit-session.h : sessions
- *
- * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef LIBPOLKIT_SESSION_H
-#define LIBPOLKIT_SESSION_H
-
-#include <libpolkit/libpolkit-types.h>
-#include <libpolkit/libpolkit-seat.h>
-
-#include <sys/types.h>
-
-struct PolKitSession;
-typedef struct PolKitSession PolKitSession;
-
-PolKitSession *libpolkit_session_new (void);
-PolKitSession *libpolkit_session_ref (PolKitSession *session);
-void libpolkit_session_unref (PolKitSession *session);
-polkit_bool_t libpolkit_session_set_uid (PolKitSession *session, uid_t uid);
-polkit_bool_t libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat);
-polkit_bool_t libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref);
-polkit_bool_t libpolkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_active);
-polkit_bool_t libpolkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_local);
-polkit_bool_t libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host);
-polkit_bool_t libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid);
-polkit_bool_t libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat);
-polkit_bool_t libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref);
-polkit_bool_t libpolkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_is_active);
-polkit_bool_t libpolkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is_local);
-polkit_bool_t libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host);
-
-void libpolkit_session_debug (PolKitSession *session);
-polkit_bool_t libpolkit_session_validate (PolKitSession *session);
-
-#endif /* LIBPOLKIT_SESSION_H */
polkit_module_allow_all_la_SOURCES = polkit-module-allow-all.c
polkit_module_allow_all_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_allow_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
+polkit_module_allow_all_la_LIBADD = $(top_builddir)/polkit/libpolkit.la
clean-local :
rm -f *~
#endif
#include <stddef.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
-/* The symbol that libpolkit looks up when loading this module */
-polkit_bool_t libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+/* The symbol that polkit looks up when loading this module */
+polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
static polkit_bool_t
_module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
PolKitResource *resource,
PolKitSession *session)
{
- return LIBPOLKIT_RESULT_YES;
+ return POLKIT_RESULT_YES;
}
static PolKitResult
PolKitResource *resource,
PolKitCaller *caller)
{
- return LIBPOLKIT_RESULT_YES;
+ return POLKIT_RESULT_YES;
}
polkit_bool_t
-libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
+polkit_module_set_functions (PolKitModuleInterface *module_interface)
{
polkit_bool_t ret;
if (module_interface == NULL)
goto out;
- libpolkit_module_set_func_initialize (module_interface, _module_init);
- libpolkit_module_set_func_shutdown (module_interface, _module_shutdown);
- libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
- libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
+ polkit_module_set_func_initialize (module_interface, _module_init);
+ polkit_module_set_func_shutdown (module_interface, _module_shutdown);
+ polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
+ polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
ret = TRUE;
out:
polkit_module_default_la_SOURCES = polkit-module-default.c
polkit_module_default_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_default_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
+polkit_module_default_la_LIBADD = $(top_builddir)/polkit/libpolkit.la
clean-local :
rm -f *~
#endif
#include <stddef.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
-/* The symbol that libpolkit looks up when loading this module */
-polkit_bool_t libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+/* The symbol that polkit looks up when loading this module */
+polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
static polkit_bool_t
_module_init (PolKitModuleInterface *module_interface,
PolKitPolicyCache *cache;
PolKitPolicyFileEntry *pfe;
- result = LIBPOLKIT_RESULT_NO;
- cache = libpolkit_context_get_policy_cache (pk_context);
- pfe = libpolkit_policy_cache_get_entry (cache, action);
- return libpolkit_policy_default_can_session_access_resource (
- libpolkit_policy_file_entry_get_default (pfe),
+ result = POLKIT_RESULT_NO;
+ cache = polkit_context_get_policy_cache (pk_context);
+ pfe = polkit_policy_cache_get_entry (cache, action);
+ return polkit_policy_default_can_session_access_resource (
+ polkit_policy_file_entry_get_default (pfe),
action,
resource,
session);
PolKitPolicyCache *cache;
PolKitPolicyFileEntry *pfe;
- result = LIBPOLKIT_RESULT_NO;
- cache = libpolkit_context_get_policy_cache (pk_context);
- pfe = libpolkit_policy_cache_get_entry (cache, action);
- return libpolkit_policy_default_can_caller_access_resource (
- libpolkit_policy_file_entry_get_default (pfe),
+ result = POLKIT_RESULT_NO;
+ cache = polkit_context_get_policy_cache (pk_context);
+ pfe = polkit_policy_cache_get_entry (cache, action);
+ return polkit_policy_default_can_caller_access_resource (
+ polkit_policy_file_entry_get_default (pfe),
action,
resource,
caller);
}
polkit_bool_t
-libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
+polkit_module_set_functions (PolKitModuleInterface *module_interface)
{
polkit_bool_t ret;
if (module_interface == NULL)
goto out;
- libpolkit_module_set_func_initialize (module_interface, _module_init);
- libpolkit_module_set_func_shutdown (module_interface, _module_shutdown);
- libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
- libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
+ polkit_module_set_func_initialize (module_interface, _module_init);
+ polkit_module_set_func_shutdown (module_interface, _module_shutdown);
+ polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
+ polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
ret = TRUE;
out:
polkit_module_deny_all_la_SOURCES = polkit-module-deny-all.c
polkit_module_deny_all_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_deny_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
+polkit_module_deny_all_la_LIBADD = $(top_builddir)/polkit/libpolkit.la
clean-local :
rm -f *~
#endif
#include <stddef.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
-/* The symbol that libpolkit looks up when loading this module */
-polkit_bool_t libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+/* The symbol that polkit looks up when loading this module */
+polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
static polkit_bool_t
_module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
PolKitResource *resource,
PolKitSession *session)
{
- return LIBPOLKIT_RESULT_NO;
+ return POLKIT_RESULT_NO;
}
static PolKitResult
PolKitResource *resource,
PolKitCaller *caller)
{
- return LIBPOLKIT_RESULT_NO;
+ return POLKIT_RESULT_NO;
}
polkit_bool_t
-libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
+polkit_module_set_functions (PolKitModuleInterface *module_interface)
{
polkit_bool_t ret;
if (module_interface == NULL)
goto out;
- libpolkit_module_set_func_initialize (module_interface, _module_init);
- libpolkit_module_set_func_shutdown (module_interface, _module_shutdown);
- libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
- libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
+ polkit_module_set_func_initialize (module_interface, _module_init);
+ polkit_module_set_func_shutdown (module_interface, _module_shutdown);
+ polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
+ polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
ret = TRUE;
out:
polkit_module_grant_la_SOURCES = polkit-module-grant.c
polkit_module_grant_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_grant_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la @GLIB_LIBS@
+polkit_module_grant_la_LIBADD = $(top_builddir)/polkit/libpolkit.la @GLIB_LIBS@
clean-local :
rm -f *~
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
#include <glib.h>
-/* The symbol that libpolkit looks up when loading this module */
-polkit_bool_t libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+/* The symbol that polkit looks up when loading this module */
+polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
static polkit_bool_t
_module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
PolKitResource *resource,
PolKitSession *session)
{
- return LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ return POLKIT_RESULT_UNKNOWN_ACTION;
}
static PolKitResult
PolKitSession *session;
PolKitResult result;
- result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ result = POLKIT_RESULT_UNKNOWN_ACTION;
/* file format:
*
char *dbus_name;
guint resource_hash;
- if (!libpolkit_action_get_action_id (action, &action_name))
+ if (!polkit_action_get_action_id (action, &action_name))
goto out;
- if (!libpolkit_caller_get_uid (caller, &invoking_user_id))
+ if (!polkit_caller_get_uid (caller, &invoking_user_id))
goto out;
if (resource == NULL)
goto out;
- if (!libpolkit_resource_get_resource_type (resource, &resource_type))
+ if (!polkit_resource_get_resource_type (resource, &resource_type))
goto out;
- if (!libpolkit_resource_get_resource_id (resource, &resource_id))
+ if (!polkit_resource_get_resource_id (resource, &resource_id))
goto out;
session_name = NULL;
- if (!libpolkit_caller_get_ck_session (caller, &session))
+ if (!polkit_caller_get_ck_session (caller, &session))
goto out;
- if (!libpolkit_caller_get_dbus_name (caller, &dbus_name))
+ if (!polkit_caller_get_dbus_name (caller, &dbus_name))
goto out;
- if (!libpolkit_session_get_ck_objref (session, &session_objpath))
+ if (!polkit_session_get_ck_objref (session, &session_objpath))
goto out;
session_name = g_basename (session_objpath);
/* TODO: FIXME: XXX: this format of storing granted privileges needs be redone
*
* this concerns these two files
- * - libpolkit-grant/polkit-grant-helper.c
+ * - polkit-grant/polkit-grant-helper.c
* - modules/grant/polkit-module-grant.c
*/
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/dbus_%s_%d_%s_%u.grant",
dbus_name, invoking_user_id, action_name, resource_hash);
if (g_file_test (grant_file, G_FILE_TEST_EXISTS)) {
- result = LIBPOLKIT_RESULT_YES;
+ result = POLKIT_RESULT_YES;
g_free (grant_file);
goto out;
}
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/session_%s_%d_%s_%u.grant",
session_name, invoking_user_id, action_name, resource_hash);
if (g_file_test (grant_file, G_FILE_TEST_EXISTS)) {
- result = LIBPOLKIT_RESULT_YES;
+ result = POLKIT_RESULT_YES;
g_free (grant_file);
goto out;
}
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/lib/PolicyKit/uid_%d_%s_%u.grant",
invoking_user_id, action_name, resource_hash);
if (g_file_test (grant_file, G_FILE_TEST_EXISTS)) {
- result = LIBPOLKIT_RESULT_YES;
+ result = POLKIT_RESULT_YES;
g_free (grant_file);
goto out;
}
}
polkit_bool_t
-libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
+polkit_module_set_functions (PolKitModuleInterface *module_interface)
{
polkit_bool_t ret;
if (module_interface == NULL)
goto out;
- libpolkit_module_set_func_initialize (module_interface, _module_init);
- libpolkit_module_set_func_shutdown (module_interface, _module_shutdown);
- libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
- libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
+ polkit_module_set_func_initialize (module_interface, _module_init);
+ polkit_module_set_func_shutdown (module_interface, _module_shutdown);
+ polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
+ polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
ret = TRUE;
out:
polkit_module_run_program_la_SOURCES = polkit-module-run-program.c
polkit_module_run_program_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_run_program_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la @GLIB_LIBS@
+polkit_module_run_program_la_LIBADD = $(top_builddir)/polkit/libpolkit.la @GLIB_LIBS@
clean-local :
rm -f *~
# include <config.h>
#endif
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
#include <glib.h>
-/* The symbol that libpolkit looks up when loading this module */
-polkit_bool_t libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+/* The symbol that polkit looks up when loading this module */
+polkit_bool_t polkit_module_set_functions (PolKitModuleInterface *module_interface);
typedef struct {
int program_argc;
if (user_data->program_argv == NULL)
goto error;
- libpolkit_module_set_user_data (module_interface, user_data);
+ polkit_module_set_user_data (module_interface, user_data);
return TRUE;
error:
_module_shutdown (PolKitModuleInterface *module_interface)
{
UserData *user_data;
- user_data = libpolkit_module_get_user_data (module_interface);
+ user_data = polkit_module_get_user_data (module_interface);
if (user_data != NULL) {
if (user_data->program_argv != NULL)
g_strfreev (user_data->program_argv);
_add_action_to_env (PolKitAction *action, GPtrArray *envp)
{
char *p_id;
- if (!libpolkit_action_get_action_id (action, &p_id))
+ if (!polkit_action_get_action_id (action, &p_id))
goto error;
g_ptr_array_add (envp, g_strdup_printf ("POLKIT_ACTION_ID=%s", p_id));
return TRUE;
{
char *r_type;
char *r_id;
- if (!libpolkit_resource_get_resource_type (resource, &r_type))
+ if (!polkit_resource_get_resource_type (resource, &r_type))
goto error;
- if (!libpolkit_resource_get_resource_id (resource, &r_id))
+ if (!polkit_resource_get_resource_id (resource, &r_id))
goto error;
g_ptr_array_add (envp, g_strdup_printf ("POLKIT_RESOURCE_TYPE=%s", r_type));
g_ptr_array_add (envp, g_strdup_printf ("POLKIT_RESOURCE_ID=%s", r_id));
_add_seat_to_env (PolKitSeat *seat, GPtrArray *envp)
{
char *s_ck_objref;
- if (!libpolkit_seat_get_ck_objref (seat, &s_ck_objref))
+ if (!polkit_seat_get_ck_objref (seat, &s_ck_objref))
goto error;
g_ptr_array_add (envp, g_strdup_printf ("POLKIT_SEAT_CK_OBJREF=%s", s_ck_objref));
return TRUE;
char *s_ck_remote_host;
PolKitSeat *s_seat;
- if (!libpolkit_session_get_uid (session, &s_uid))
+ if (!polkit_session_get_uid (session, &s_uid))
goto error;
- if (!libpolkit_session_get_ck_objref (session, &s_ck_objref))
+ if (!polkit_session_get_ck_objref (session, &s_ck_objref))
goto error;
- if (!libpolkit_session_get_ck_is_active (session, &s_ck_is_active))
+ if (!polkit_session_get_ck_is_active (session, &s_ck_is_active))
goto error;
- if (!libpolkit_session_get_ck_is_local (session, &s_ck_is_local))
+ if (!polkit_session_get_ck_is_local (session, &s_ck_is_local))
goto error;
if (!s_ck_is_local)
- if (!libpolkit_session_get_ck_remote_host (session, &s_ck_remote_host))
+ if (!polkit_session_get_ck_remote_host (session, &s_ck_remote_host))
goto error;
- if (!libpolkit_session_get_seat (session, &s_seat))
+ if (!polkit_session_get_seat (session, &s_seat))
goto error;
if (!_add_seat_to_env (s_seat, envp))
char *c_dbus_name;
PolKitSession *c_session;
- if (!libpolkit_caller_get_uid (caller, &c_uid))
+ if (!polkit_caller_get_uid (caller, &c_uid))
goto error;
- if (!libpolkit_caller_get_pid (caller, &c_pid))
+ if (!polkit_caller_get_pid (caller, &c_pid))
goto error;
- if (!libpolkit_caller_get_dbus_name (caller, &c_dbus_name))
+ if (!polkit_caller_get_dbus_name (caller, &c_dbus_name))
goto error;
- if (!libpolkit_caller_get_selinux_context (caller, &c_selinux_context)) /* SELinux may not be available */
+ if (!polkit_caller_get_selinux_context (caller, &c_selinux_context)) /* SELinux may not be available */
c_selinux_context = NULL;
- if (!libpolkit_caller_get_ck_session (caller, &c_session)) /* Caller may not originate from a session */
+ if (!polkit_caller_get_ck_session (caller, &c_session)) /* Caller may not originate from a session */
c_session = NULL;
if (c_session != NULL)
;
prog_stdout[n] = '\0';
- if (!libpolkit_result_from_string_representation (prog_stdout, result)) {
+ if (!polkit_result_from_string_representation (prog_stdout, result)) {
g_warning ("malformed result '%s' from program", prog_stdout);
goto error;
}
GPtrArray *envp;
envp = NULL;
- result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ result = POLKIT_RESULT_UNKNOWN_ACTION;
- user_data = libpolkit_module_get_user_data (module_interface);
+ user_data = polkit_module_get_user_data (module_interface);
envp = g_ptr_array_new ();
GPtrArray *envp;
envp = NULL;
- result = LIBPOLKIT_RESULT_NO;
- user_data = libpolkit_module_get_user_data (module_interface);
+ result = POLKIT_RESULT_NO;
+ user_data = polkit_module_get_user_data (module_interface);
envp = g_ptr_array_new ();
if (!_add_action_to_env (action, envp))
}
polkit_bool_t
-libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
+polkit_module_set_functions (PolKitModuleInterface *module_interface)
{
polkit_bool_t ret;
if (module_interface == NULL)
goto out;
- libpolkit_module_set_func_initialize (module_interface, _module_init);
- libpolkit_module_set_func_shutdown (module_interface, _module_shutdown);
- libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
- libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
+ polkit_module_set_func_initialize (module_interface, _module_init);
+ polkit_module_set_func_shutdown (module_interface, _module_shutdown);
+ polkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
+ polkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
ret = TRUE;
out:
lib_LTLIBRARIES=libpolkit-dbus.la
-libpolkit_dbusincludedir=$(includedir)/PolicyKit/libpolkit-dbus
+libpolkit_dbusincludedir=$(includedir)/PolicyKit/polkit-dbus
libpolkit_dbusinclude_HEADERS = \
- libpolkit-dbus.h
+ polkit-dbus.h
libpolkit_dbus_la_SOURCES = \
- libpolkit-dbus.h libpolkit-dbus.c
+ polkit-dbus.h polkit-dbus.c
-libpolkit_dbus_la_LIBADD = @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
+libpolkit_dbus_la_LIBADD = @DBUS_LIBS@ $(top_builddir)/polkit/libpolkit.la
libpolkit_dbus_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-dbus.h : helper library for obtaining seat, session and
+ * polkit-dbus.h : helper library for obtaining seat, session and
* caller information via D-Bus and ConsoleKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
**************************************************************************/
/**
- * SECTION:libpolkit-dbus
+ * SECTION:polkit-dbus
* @short_description: Helper library for obtaining seat, session and caller information via D-Bus and ConsoleKit.
*
* Helper library for obtaining seat, session and caller information
#include <glib.h>
#include <string.h>
-#include "libpolkit-dbus.h"
+#include "polkit-dbus.h"
/**
- * libpolkit_session_new_from_objpath:
+ * polkit_session_new_from_objpath:
* @con: D-Bus system bus connection
* @objpath: object path of ConsoleKit session object
* @uid: the user owning the session or -1 if unknown
* @error will be set)
**/
PolKitSession *
-libpolkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error)
+polkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error)
{
PolKitSeat *seat;
PolKitSession *session;
dbus_message_unref (reply);
}
- session = libpolkit_session_new ();
+ session = polkit_session_new ();
if (session == NULL) {
goto out;
}
- if (!libpolkit_session_set_ck_objref (session, objpath)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_set_ck_objref (session, objpath)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- if (!libpolkit_session_set_ck_is_active (session, is_active)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_set_ck_is_active (session, is_active)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- if (!libpolkit_session_set_ck_is_local (session, is_local)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_set_ck_is_local (session, is_local)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
if (!is_local) {
- if (!libpolkit_session_set_ck_remote_host (session, remote_host)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_set_ck_remote_host (session, remote_host)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
}
- seat = libpolkit_seat_new ();
+ seat = polkit_seat_new ();
if (seat == NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- if (!libpolkit_seat_set_ck_objref (seat, seat_path)) {
- libpolkit_seat_unref (seat);
+ if (!polkit_seat_set_ck_objref (seat, seat_path)) {
+ polkit_seat_unref (seat);
seat = NULL;
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- if (!libpolkit_seat_validate (seat)) {
- libpolkit_seat_unref (seat);
+ if (!polkit_seat_validate (seat)) {
+ polkit_seat_unref (seat);
seat = NULL;
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- if (!libpolkit_session_set_seat (session, seat)) {
- libpolkit_seat_unref (seat);
+ if (!polkit_session_set_seat (session, seat)) {
+ polkit_seat_unref (seat);
seat = NULL;
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
goto out;
}
- libpolkit_seat_unref (seat); /* session object now owns this object */
+ polkit_seat_unref (seat); /* session object now owns this object */
seat = NULL;
- if (!libpolkit_session_validate (session)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_validate (session)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
}
/**
- * libpolkit_session_new_from_cookie:
+ * polkit_session_new_from_cookie:
* @con: D-Bus system bus connection
* @cookie: a ConsoleKit XDG_SESSION_COOKIE
* @error: D-Bus error
* @error will be set)
**/
PolKitSession *
-libpolkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error)
+polkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error)
{
PolKitSession *session;
DBusMessage *message;
dbus_message_unref (message);
dbus_message_unref (reply);
- session = libpolkit_session_new_from_objpath (con, objpath, -1, error);
+ session = polkit_session_new_from_objpath (con, objpath, -1, error);
out:
g_free (objpath);
/**
- * libpolkit_caller_new_from_dbus_name:
+ * polkit_caller_new_from_dbus_name:
* @con: D-Bus system bus connection
* @dbus_name: unique system bus connection name
* @error: D-Bus error
* @error will be set)
**/
PolKitCaller *
-libpolkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, DBusError *error)
+polkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, DBusError *error)
{
PolKitCaller *caller;
pid_t pid;
dbus_message_unref (message);
dbus_message_unref (reply);
- session = libpolkit_session_new_from_objpath (con, ck_session_objpath, uid, error);
+ session = polkit_session_new_from_objpath (con, ck_session_objpath, uid, error);
if (session == NULL) {
g_warning ("Got a session objpath but couldn't construct session object!");
goto out;
}
- if (!libpolkit_session_validate (session)) {
- libpolkit_session_unref (session);
+ if (!polkit_session_validate (session)) {
+ polkit_session_unref (session);
session = NULL;
goto out;
}
not_in_session:
- caller = libpolkit_caller_new ();
+ caller = polkit_caller_new ();
if (caller == NULL) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
goto out;
}
- if (!libpolkit_caller_set_dbus_name (caller, dbus_name)) {
+ if (!polkit_caller_set_dbus_name (caller, dbus_name)) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
- libpolkit_caller_unref (caller);
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
- if (!libpolkit_caller_set_uid (caller, uid)) {
+ if (!polkit_caller_set_uid (caller, uid)) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
- libpolkit_caller_unref (caller);
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
- if (!libpolkit_caller_set_pid (caller, pid)) {
+ if (!polkit_caller_set_pid (caller, pid)) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
- libpolkit_caller_unref (caller);
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
if (selinux_context != NULL) {
- if (!libpolkit_caller_set_selinux_context (caller, selinux_context)) {
+ if (!polkit_caller_set_selinux_context (caller, selinux_context)) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
- libpolkit_caller_unref (caller);
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
}
if (session != NULL) {
- if (!libpolkit_caller_set_ck_session (caller, session)) {
+ if (!polkit_caller_set_ck_session (caller, session)) {
if (session != NULL) {
- libpolkit_session_unref (session);
+ polkit_session_unref (session);
session = NULL;
}
- libpolkit_caller_unref (caller);
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
- libpolkit_session_unref (session); /* caller object now own this object */
+ polkit_session_unref (session); /* caller object now own this object */
session = NULL;
}
- if (!libpolkit_caller_validate (caller)) {
- libpolkit_caller_unref (caller);
+ if (!polkit_caller_validate (caller)) {
+ polkit_caller_unref (caller);
caller = NULL;
goto out;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-dbus.h : helper library for obtaining seat, session and
+ * polkit-dbus.h : helper library for obtaining seat, session and
* caller information via D-Bus and ConsoleKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
-#ifndef LIBPOLKIT_DBUS_H
-#define LIBPOLKIT_DBUS_H
+#ifndef POLKIT_DBUS_H
+#define POLKIT_DBUS_H
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
#include <dbus/dbus.h>
-PolKitSession *libpolkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error);
-PolKitSession *libpolkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error);
+PolKitSession *polkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error);
+PolKitSession *polkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error);
-PolKitCaller *libpolkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, DBusError *error);
+PolKitCaller *polkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, DBusError *error);
-#endif /* LIBPOLKIT_DBUS_H */
+#endif /* POLKIT_DBUS_H */
lib_LTLIBRARIES=libpolkit-grant.la
-libpolkit_grantincludedir=$(includedir)/PolicyKit/libpolkit-grant
+libpolkit_grantincludedir=$(includedir)/PolicyKit/polkit-grant
libpolkit_grantinclude_HEADERS = \
- libpolkit-grant.h
+ polkit-grant.h
libpolkit_grant_la_SOURCES = \
- libpolkit-grant.h libpolkit-grant.c
+ polkit-grant.h polkit-grant.c
-libpolkit_grant_la_LIBADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
+libpolkit_grant_la_LIBADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/polkit/libpolkit.la
libpolkit_grant_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libexec_PROGRAMS = polkit-grant-helper
polkit_grant_helper_SOURCES = polkit-grant-helper.c
-polkit_grant_helper_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @AUTH_LIBS@ $(top_builddir)/libpolkit/libpolkit.la $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la
+polkit_grant_helper_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @AUTH_LIBS@ $(top_builddir)/polkit/libpolkit.la $(top_builddir)/polkit-dbus/libpolkit-dbus.la
polkit_grant_alwaysdir = $(localstatedir)/lib/PolicyKit
dist_polkit_grant_always_DATA =
#include <glib.h>
-#include <libpolkit-dbus/libpolkit-dbus.h>
+#include <polkit-dbus/polkit-dbus.h>
static int
conversation_function (int n,
goto out;
}
- action = libpolkit_action_new ();
- libpolkit_action_set_action_id (action, action_name);
+ action = polkit_action_new ();
+ polkit_action_set_action_id (action, action_name);
if (resource_type != NULL && resource_name != NULL) {
- resource = libpolkit_resource_new ();
- libpolkit_resource_set_resource_type (resource, resource_type);
- libpolkit_resource_set_resource_id (resource, resource_name);
+ resource = polkit_resource_new ();
+ polkit_resource_set_resource_type (resource, resource_type);
+ polkit_resource_set_resource_id (resource, resource_name);
} else {
resource = NULL;
}
- caller = libpolkit_caller_new_from_dbus_name (bus, dbus_name, &error);
+ caller = polkit_caller_new_from_dbus_name (bus, dbus_name, &error);
if (caller == NULL) {
fprintf (stderr, "cannot get caller from dbus name\n");
goto out;
}
- if (!libpolkit_caller_get_ck_session (caller, &session)) {
+ if (!polkit_caller_get_ck_session (caller, &session)) {
fprintf (stderr, "caller is not in a session\n");
goto out;
}
- if (!libpolkit_session_get_ck_objref (session, &str)) {
+ if (!polkit_session_get_ck_objref (session, &str)) {
fprintf (stderr, "cannot get session ck objpath\n");
goto out;
}
if (*out_session_objpath == NULL)
goto out;
- //libpolkit_caller_debug (caller);
+ //polkit_caller_debug (caller);
- pol_ctx = libpolkit_context_new ();
- if (!libpolkit_context_init (pol_ctx, NULL)) {
+ pol_ctx = polkit_context_new ();
+ if (!polkit_context_init (pol_ctx, NULL)) {
fprintf (stderr, "cannot init polkit\n");
goto out;
}
- *result = libpolkit_context_can_caller_access_resource (pol_ctx, action, resource, caller);
+ *result = polkit_context_can_caller_access_resource (pol_ctx, action, resource, caller);
- if (*result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- *result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
- *result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS &&
- *result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
- *result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION &&
- *result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS) {
+ if (*result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
+ *result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
+ *result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS &&
+ *result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
+ *result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION &&
+ *result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS) {
fprintf (stderr, "given auth type is bogus\n");
goto out;
}
fprintf (stderr, "User said '%s'\n", buf);
- if (!libpolkit_result_from_string_representation (buf, &desired_result))
+ if (!polkit_result_from_string_representation (buf, &desired_result))
goto error;
fprintf (stderr, "Testing for voluntarily downgrade from '%s' to '%s'\n",
- libpolkit_result_to_string_representation (*result),
- libpolkit_result_to_string_representation (desired_result));
+ polkit_result_to_string_representation (*result),
+ polkit_result_to_string_representation (desired_result));
/* See the huge comment in main() below...
*
*
*/
switch (*result) {
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH)
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH)
goto error;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION)
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION)
goto error;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS)
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS)
goto error;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH)
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH)
goto error;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION)
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION)
goto error;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- if (desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION &&
- desired_result != LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS)
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS)
goto error;
break;
if (*result != desired_result) {
fprintf (stderr, "Voluntarily downgrading from '%s' to '%s'\n",
- libpolkit_result_to_string_representation (*result),
- libpolkit_result_to_string_representation (desired_result));
+ polkit_result_to_string_representation (*result),
+ polkit_result_to_string_representation (desired_result));
}
*result = desired_result;
goto out;
/* tell user about the grant details; e.g. whether it's auth_self_keep_always or auth_self etc. */
- fprintf (stdout, "POLKIT_GRANT_HELPER_TELL_TYPE %s\n", libpolkit_result_to_string_representation (result));
+ fprintf (stdout, "POLKIT_GRANT_HELPER_TELL_TYPE %s\n", polkit_result_to_string_representation (result));
fflush (stdout);
/* figure out what user to auth */
- if (result == LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH ||
- result == LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION ||
- result == LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS) {
+ if (result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH ||
+ result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION ||
+ result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS) {
user_to_auth = "root";
} else {
user_to_auth = invoking_user_name;
* See docs for the PolKitGrantOverrideGrantType callback type for use cases.
*/
fprintf (stdout, "POLKIT_GRANT_HELPER_ASK_OVERRIDE_GRANT_TYPE %s\n",
- libpolkit_result_to_string_representation (result));
+ polkit_result_to_string_representation (result));
fflush (stdout);
if (!get_and_validate_override_details (&result))
/* TODO: FIXME: XXX: this format of storing granted privileges needs be redone
*
* this concerns these two files
- * - libpolkit-grant/polkit-grant-helper.c
+ * - polkit-grant/polkit-grant-helper.c
* - modules/grant/polkit-module-grant.c
*/
g_free (resource_str_to_hash);
switch (result) {
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/dbus_%s_%d_%s_%u.grant",
dbus_name, invoking_user_id, action_name, resource_hash);
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/session_%s_%d_%s_%u.grant",
session_name, invoking_user_id, action_name, resource_hash);
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/lib/PolicyKit/uid_%d_%s_%u.grant",
invoking_user_id, action_name, resource_hash);
break;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-grant.c : library for obtaining privileges
+ * polkit-grant.c : library for obtaining privileges
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <sys/wait.h>
#include <glib.h>
-#include "libpolkit-grant.h"
+#include "polkit-grant.h"
/**
- * SECTION:libpolkit-grant
+ * SECTION:polkit-grant
* @short_description: Obtain privileges through authentication.
*
* These functions are used to obtain privileges for a user that is
};
/**
- * libpolkit_grant_new:
+ * polkit_grant_new:
* @void:
*
* Creates a #PolKitGrant object.
* Returns: the new object or #NULL on error.
**/
PolKitGrant *
-libpolkit_grant_new (void)
+polkit_grant_new (void)
{
PolKitGrant *polkit_grant;
polkit_grant = g_new0 (PolKitGrant, 1);
}
/**
- * libpolkit_grant_ref:
+ * polkit_grant_ref:
* @polkit_grant: the object
*
* Increase reference count.
* Returns: the object.
**/
PolKitGrant *
-libpolkit_grant_ref (PolKitGrant *polkit_grant)
+polkit_grant_ref (PolKitGrant *polkit_grant)
{
g_return_val_if_fail (polkit_grant != NULL, NULL);
}
/**
- * libpolkit_grant_unref:
+ * polkit_grant_unref:
* @polkit_grant: the object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_grant_unref (PolKitGrant *polkit_grant)
+polkit_grant_unref (PolKitGrant *polkit_grant)
{
g_return_if_fail (polkit_grant != NULL);
}
/**
- * libpolkit_grant_set_functions:
+ * polkit_grant_set_functions:
* @polkit_grant: the object
* @func_add_io_watch: Callback function
* @func_add_child_watch: Callback function
* Set callback functions used for authentication.
**/
void
-libpolkit_grant_set_functions (PolKitGrant *polkit_grant,
+polkit_grant_set_functions (PolKitGrant *polkit_grant,
PolKitGrantAddIOWatch func_add_io_watch,
PolKitGrantAddChildWatch func_add_child_watch,
PolKitGrantRemoveWatch func_remove_watch,
/**
- * libpolkit_grant_child_func:
+ * polkit_grant_child_func:
* @polkit_grant: the object
* @pid: pid of the child
* @exit_code: exit code of the child
* #PolKitGrantAddChildWatch terminates.
**/
void
-libpolkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code)
+polkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code)
{
g_return_if_fail (polkit_grant != NULL);
g_return_if_fail (polkit_grant->auth_in_progress);
/**
- * libpolkit_grant_io_func:
+ * polkit_grant_io_func:
* @polkit_grant: the object
* @fd: the file descriptor passed to the supplied function of type #PolKitGrantAddIOWatch.
*
* type #PolKitGrantAddIOWatch.
**/
void
-libpolkit_grant_io_func (PolKitGrant *polkit_grant, int fd)
+polkit_grant_io_func (PolKitGrant *polkit_grant, int fd)
{
char *line = NULL;
size_t line_len = 0;
if (g_str_has_prefix (line, id)) {
PolKitResult result;
id_len = strlen (id);
- if (!libpolkit_result_from_string_representation (line + id_len, &result)) {
+ if (!polkit_result_from_string_representation (line + id_len, &result)) {
/* TODO: danger will robinson */
}
polkit_grant->func_type (polkit_grant,
PolKitResult override;
PolKitResult result;
id_len = strlen (id);
- if (!libpolkit_result_from_string_representation (line + id_len, &result)) {
+ if (!polkit_result_from_string_representation (line + id_len, &result)) {
/* TODO: danger will robinson */
}
override = polkit_grant->func_override_grant_type (polkit_grant,
result,
polkit_grant->user_data);
- response = g_strdup (libpolkit_result_to_string_representation (override));
+ response = g_strdup (polkit_result_to_string_representation (override));
goto processed;
}
}
/**
- * libpolkit_grant_cancel_auth:
+ * polkit_grant_cancel_auth:
* @polkit_grant: the object
*
* Cancel an authentication in progress
**/
void
-libpolkit_grant_cancel_auth (PolKitGrant *polkit_grant)
+polkit_grant_cancel_auth (PolKitGrant *polkit_grant)
{
GPid pid;
g_return_if_fail (polkit_grant != NULL);
}
/**
- * libpolkit_grant_initiate_auth:
+ * polkit_grant_initiate_auth:
* @polkit_grant: the object
* @action: Action requested by caller
* @resource: Resource in question
* Initiate authentication to obtain the privilege for the given
* @caller to perform the specified @action on the given
* @resource. The caller of this method must have setup callback
- * functions using the method libpolkit_grant_set_functions() prior to
+ * functions using the method polkit_grant_set_functions() prior to
* calling this method.
*
* Implementation-wise, this class uses a secure (e.g. as in that it
* Returns: #TRUE only if authentication have been initiated.
**/
polkit_bool_t
-libpolkit_grant_initiate_auth (PolKitGrant *polkit_grant,
+polkit_grant_initiate_auth (PolKitGrant *polkit_grant,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller)
/* check that callback functions have been properly set up */
g_return_val_if_fail (polkit_grant->func_done != NULL, FALSE);
- if (!libpolkit_caller_get_dbus_name (caller, &dbus_name))
+ if (!polkit_caller_get_dbus_name (caller, &dbus_name))
goto error;
- if (!libpolkit_action_get_action_id (action, &action_id))
+ if (!polkit_action_get_action_id (action, &action_id))
goto error;
- if (!libpolkit_resource_get_resource_type (resource, &resource_type))
+ if (!polkit_resource_get_resource_type (resource, &resource_type))
goto error;
- if (!libpolkit_resource_get_resource_id (resource, &resource_id))
+ if (!polkit_resource_get_resource_id (resource, &resource_id))
goto error;
/* TODO: verify incoming args */
- //helper_argv[0] = "/home/davidz/Hacking/PolicyKit/libpolkit-grant/.libs/polkit-grant-helper";
+ //helper_argv[0] = "/home/davidz/Hacking/PolicyKit/polkit-grant/.libs/polkit-grant-helper";
helper_argv[0] = PACKAGE_LIBEXEC_DIR "/polkit-grant-helper";
helper_argv[1] = dbus_name;
helper_argv[2] = action_id;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-grant.h : library for obtaining privileges
+ * polkit-grant.h : library for obtaining privileges
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
*
**************************************************************************/
-#ifndef LIBPOLKIT_GRANT_H
-#define LIBPOLKIT_GRANT_H
+#ifndef POLKIT_GRANT_H
+#define POLKIT_GRANT_H
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
struct PolKitGrant;
typedef struct PolKitGrant PolKitGrant;
* PolKitGrantType:
* @polkit_grant: the grant object
* @grant_type: the current type of what privilege to obtain
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that describes to what extent the
* privilege can be obtained; e.g. whether the user can keep it
* PolKitGrantConversationPromptEchoOff:
* @polkit_grant: the grant object
* @prompt: prompt passed by the authentication layer; do not free this string
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that is invoked when the authentication
* layer needs to ask the user a secret and the UI should NOT echo what
* PolKitGrantConversationPromptEchoOn:
* @polkit_grant: the grant object
* @prompt: prompt passed by the authentication layer; do not free this string
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that is invoked when the authentication
* layer needs to ask the user a secret and the UI should echo what
* PolKitGrantConversationErrorMessage:
* @polkit_grant: the grant object
* @error_message: error message passed by the authentication layer; do not free this string
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that is invoked when the authentication
* layer produces an error message that should be displayed in the UI.
* PolKitGrantConversationTextInfo:
* @polkit_grant: the grant object
* @text_info: information passed by the authentication layer; do not free this string
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that is invoked when the authentication
* layer produces an informational message that should be displayed in
* @polkit_grant: the grant object
* @grant_type: the current type of what privilege to obtain; this is
* the same value as passed to the callback of type #PolKitGrantType.
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* Type for callback function that enables the UI to request a lesser
* privilege than is obtainable. This callback is invoked when the
* </programlisting>
*
* This dialog assumes that @grant_type passed was
- * #LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS. By ticking the
+ * #POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS. By ticking the
* check boxes in the dialog, the user can override this to either
- * #LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION or
- * #LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH. Thus, the user can
+ * #POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION or
+ * #POLKIT_RESULT_ONLY_VIA_SELF_AUTH. Thus, the user can
* voluntarily choose to obtain a lesser privilege.
*
* Another example, would be that the @grant_type passed was
- * #LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION. Then the dialog
+ * #POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION. Then the dialog
* should look like this:
*
* <programlisting>
* </programlisting>
*
* Finally, if the @grant_type value passed is
- * e.g. #LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH, there are no options to
+ * e.g. #POLKIT_RESULT_ONLY_VIA_SELF_AUTH, there are no options to
* click.:
*
* <programlisting>
* </programlisting>
*
* Of course, these examples also applies to
- * #LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH and friends.
+ * #POLKIT_RESULT_ONLY_VIA_ROOT_AUTH and friends.
*
* Returns: the desired type of what privilege to obtain; note that it
* won't work asking for more privileges than what @grant_type
* specifies; the passed value is properly checked in the secure
* setgid granting helper mentioned in
- * libpolkit_grant_initiate_auth().
+ * polkit_grant_initiate_auth().
**/
typedef PolKitResult (*PolKitGrantOverrideGrantType) (PolKitGrant *polkit_grant,
PolKitResult grant_type,
* PolKitGrantDone:
* @polkit_grant: the grant object
* @gained_privilege: whether the privilege was obtained
- * @user_data: user data pointed as passed into libpolkit_grant_set_functions()
+ * @user_data: user data pointed as passed into polkit_grant_set_functions()
*
* This function is called when the granting process ends; either if
* successful or if it was canceled using
- * e.g. libpolkit_grant_cancel_auth().
+ * e.g. polkit_grant_cancel_auth().
**/
typedef void (*PolKitGrantDone) (PolKitGrant *polkit_grant,
polkit_bool_t gained_privilege,
*
* Type for function supplied by the application to integrate a watch
* on a child process into the applications main loop. The
- * application must call libpolkit_grant_child_func() when the
+ * application must call polkit_grant_child_func() when the
* child dies
*
* For glib mainloop, the function will typically look like this:
* gpointer user_data)
* {
* PolKitGrant *polkit_grant = user_data;
- * libpolkit_grant_child_func (polkit_grant, pid, WEXITSTATUS (status));
+ * polkit_grant_child_func (polkit_grant, pid, WEXITSTATUS (status));
* }
*
* static int
*
* Type for function supplied by the application to integrate a watch
* on a file descriptor into the applications main loop. The
- * application must call libpolkit_grant_io_func() when there is data
+ * application must call polkit_grant_io_func() when there is data
* to read from the file descriptor.
*
* For glib mainloop, the function will typically look like this:
* int fd;
* PolKitGrant *polkit_grant = user_data;
* fd = g_io_channel_unix_get_fd (channel);
- * libpolkit_grant_io_func (polkit_grant, fd);
+ * polkit_grant_io_func (polkit_grant, fd);
* return TRUE;
* }
*
typedef void (*PolKitGrantRemoveWatch) (PolKitGrant *polkit_grant,
int watch_id);
-PolKitGrant *libpolkit_grant_new (void);
-PolKitGrant *libpolkit_grant_ref (PolKitGrant *polkit_grant);
-void libpolkit_grant_unref (PolKitGrant *polkit_grant);
-void libpolkit_grant_set_functions (PolKitGrant *polkit_grant,
- PolKitGrantAddIOWatch func_add_io_watch,
- PolKitGrantAddChildWatch func_add_child_watch,
- PolKitGrantRemoveWatch func_remove_watch,
- PolKitGrantType func_type,
- PolKitGrantConversationPromptEchoOff func_prompt_echo_off,
- PolKitGrantConversationPromptEchoOn func_prompt_echo_on,
- PolKitGrantConversationErrorMessage func_error_message,
- PolKitGrantConversationTextInfo func_text_info,
- PolKitGrantOverrideGrantType func_override_grant_type,
- PolKitGrantDone func_done,
- void *user_data);
-polkit_bool_t libpolkit_grant_initiate_auth (PolKitGrant *polkit_grant,
- PolKitAction *action,
- PolKitResource *resource,
- PolKitCaller *caller);
+PolKitGrant *polkit_grant_new (void);
+PolKitGrant *polkit_grant_ref (PolKitGrant *polkit_grant);
+void polkit_grant_unref (PolKitGrant *polkit_grant);
+void polkit_grant_set_functions (PolKitGrant *polkit_grant,
+ PolKitGrantAddIOWatch func_add_io_watch,
+ PolKitGrantAddChildWatch func_add_child_watch,
+ PolKitGrantRemoveWatch func_remove_watch,
+ PolKitGrantType func_type,
+ PolKitGrantConversationPromptEchoOff func_prompt_echo_off,
+ PolKitGrantConversationPromptEchoOn func_prompt_echo_on,
+ PolKitGrantConversationErrorMessage func_error_message,
+ PolKitGrantConversationTextInfo func_text_info,
+ PolKitGrantOverrideGrantType func_override_grant_type,
+ PolKitGrantDone func_done,
+ void *user_data);
+polkit_bool_t polkit_grant_initiate_auth (PolKitGrant *polkit_grant,
+ PolKitAction *action,
+ PolKitResource *resource,
+ PolKitCaller *caller);
-void libpolkit_grant_cancel_auth (PolKitGrant *polkit_grant);
+void polkit_grant_cancel_auth (PolKitGrant *polkit_grant);
-void libpolkit_grant_io_func (PolKitGrant *polkit_grant, int fd);
-void libpolkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code);
+void polkit_grant_io_func (PolKitGrant *polkit_grant, int fd);
+void polkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code);
-#endif /* LIBPOLKIT_GRANT_H */
+#endif /* POLKIT_GRANT_H */
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+INCLUDES = \
+ -I$(top_builddir) -I$(top_srcdir) \
+ -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
+ -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
+ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+ -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
+ -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
+ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
+ -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
+ -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
+ -DPOLKIT_COMPILATION \
+ @GLIB_CFLAGS@
+
+lib_LTLIBRARIES=libpolkit.la
+
+libpolkitincludedir=$(includedir)/PolicyKit/polkit
+
+libpolkitinclude_HEADERS = \
+ polkit.h \
+ polkit-types.h \
+ polkit-error.h \
+ polkit-result.h \
+ polkit-context.h \
+ polkit-action.h \
+ polkit-resource.h \
+ polkit-seat.h \
+ polkit-session.h \
+ polkit-caller.h \
+ polkit-policy-file-entry.h \
+ polkit-policy-file.h \
+ polkit-policy-cache.h \
+ polkit-policy-default.h \
+ polkit-module.h
+
+libpolkit_la_SOURCES = \
+ polkit.h \
+ polkit-types.h \
+ polkit-error.h polkit-error.c \
+ polkit-result.h polkit-result.c \
+ polkit-context.h polkit-context.c \
+ polkit-action.h polkit-action.c \
+ polkit-resource.h polkit-resource.c \
+ polkit-seat.h polkit-seat.c \
+ polkit-session.h polkit-session.c \
+ polkit-caller.h polkit-caller.c \
+ polkit-policy-file-entry.h polkit-policy-file-entry.c \
+ polkit-policy-file.h polkit-policy-file.c \
+ polkit-policy-cache.h polkit-policy-cache.c \
+ polkit-policy-default.h polkit-policy-default.c \
+ polkit-debug.h polkit-debug.c \
+ polkit-utils.h polkit-utils.c \
+ polkit-module.h polkit-module.c
+
+libpolkit_la_LIBADD = @GLIB_LIBS@ -ldl
+
+libpolkit_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+
+clean-local :
+ rm -f *~ $(BUILT_SOURCES)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-action.c : action
+ * polkit-action.c : action
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-action.h"
-#include "libpolkit-utils.h"
+#include "polkit-debug.h"
+#include "polkit-action.h"
+#include "polkit-utils.h"
/**
- * SECTION:libpolkit-action
+ * SECTION:polkit-action
* @short_description: Actions.
*
* This class is used to represent an action. TODO: describe what a action really is.
};
/**
- * libpolkit_action_new:
+ * polkit_action_new:
*
* Create a new #PolKitAction object.
*
* Returns: the new object
**/
PolKitAction *
-libpolkit_action_new (void)
+polkit_action_new (void)
{
PolKitAction *action;
action = g_new0 (PolKitAction, 1);
}
/**
- * libpolkit_action_ref:
+ * polkit_action_ref:
* @action: the action object
*
* Increase reference count.
* Returns: the object
**/
PolKitAction *
-libpolkit_action_ref (PolKitAction *action)
+polkit_action_ref (PolKitAction *action)
{
g_return_val_if_fail (action != NULL, action);
action->refcount++;
}
/**
- * libpolkit_action_unref:
+ * polkit_action_unref:
* @action: the action object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_action_unref (PolKitAction *action)
+polkit_action_unref (PolKitAction *action)
{
g_return_if_fail (action != NULL);
action->refcount--;
}
/**
- * libpolkit_action_set_action_id:
+ * polkit_action_set_action_id:
* @action: the action object
* @action_id: action identifier
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_action_set_action_id (PolKitAction *action, const char *action_id)
+polkit_action_set_action_id (PolKitAction *action, const char *action_id)
{
g_return_val_if_fail (action != NULL, FALSE);
g_return_val_if_fail (_pk_validate_identifier (action_id), FALSE);
}
/**
- * libpolkit_action_get_action_id:
+ * polkit_action_get_action_id:
* @action: the action object
* @out_action_id: Returns the action identifier. The caller shall not free this string.
*
* Returns: TRUE iff the value was returned.
**/
polkit_bool_t
-libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id)
+polkit_action_get_action_id (PolKitAction *action, char **out_action_id)
{
g_return_val_if_fail (action != NULL, FALSE);
g_return_val_if_fail (out_action_id != NULL, FALSE);
}
/**
- * libpolkit_action_debug:
+ * polkit_action_debug:
* @action: the object
*
* Print debug details
**/
void
-libpolkit_action_debug (PolKitAction *action)
+polkit_action_debug (PolKitAction *action)
{
g_return_if_fail (action != NULL);
_pk_debug ("PolKitAction: refcount=%d id=%s", action->refcount, action->id);
}
/**
- * libpolkit_action_validate:
+ * polkit_action_validate:
* @action: the object
*
* Validate the object
* Returns: #TRUE iff the object is valid.
**/
polkit_bool_t
-libpolkit_action_validate (PolKitAction *action)
+polkit_action_validate (PolKitAction *action)
{
g_return_val_if_fail (action != NULL, FALSE);
g_return_val_if_fail (action->id != NULL, FALSE);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-action.h : actions
+ * polkit-action.h : actions
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_ACTION_H
-#define LIBPOLKIT_ACTION_H
+#ifndef POLKIT_ACTION_H
+#define POLKIT_ACTION_H
-#include <libpolkit/libpolkit-types.h>
+#include <polkit/polkit-types.h>
struct PolKitAction;
typedef struct PolKitAction PolKitAction;
-PolKitAction *libpolkit_action_new (void);
-PolKitAction *libpolkit_action_ref (PolKitAction *action);
-void libpolkit_action_unref (PolKitAction *action);
-polkit_bool_t libpolkit_action_set_action_id (PolKitAction *action, const char *action_id);
-polkit_bool_t libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id);
+PolKitAction *polkit_action_new (void);
+PolKitAction *polkit_action_ref (PolKitAction *action);
+void polkit_action_unref (PolKitAction *action);
+polkit_bool_t polkit_action_set_action_id (PolKitAction *action, const char *action_id);
+polkit_bool_t polkit_action_get_action_id (PolKitAction *action, char **out_action_id);
-void libpolkit_action_debug (PolKitAction *action);
-polkit_bool_t libpolkit_action_validate (PolKitAction *action);
+void polkit_action_debug (PolKitAction *action);
+polkit_bool_t polkit_action_validate (PolKitAction *action);
-#endif /* LIBPOLKIT_ACTION_H */
+#endif /* POLKIT_ACTION_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-caller.c : callers
+ * polkit-caller.c : callers
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
/**
- * SECTION:libpolkit-caller
+ * SECTION:polkit-caller
* @short_description: Callers on the system message bus.
*
* This class is used to represent a caller in another process connected to the system message bus.
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-caller.h"
-#include "libpolkit-utils.h"
+#include "polkit-debug.h"
+#include "polkit-caller.h"
+#include "polkit-utils.h"
/**
* PolKitCaller:
};
/**
- * libpolkit_caller_new:
+ * polkit_caller_new:
*
* Creates a new #PolKitCaller object.
*
* Returns: the new object
**/
PolKitCaller *
-libpolkit_caller_new (void)
+polkit_caller_new (void)
{
PolKitCaller *caller;
caller = g_new0 (PolKitCaller, 1);
}
/**
- * libpolkit_caller_ref:
+ * polkit_caller_ref:
* @caller: The caller object
*
* Increase reference count.
* Returns: the object
**/
PolKitCaller *
-libpolkit_caller_ref (PolKitCaller *caller)
+polkit_caller_ref (PolKitCaller *caller)
{
g_return_val_if_fail (caller != NULL, caller);
caller->refcount++;
/**
- * libpolkit_caller_unref:
+ * polkit_caller_unref:
* @caller: The caller object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_caller_unref (PolKitCaller *caller)
+polkit_caller_unref (PolKitCaller *caller)
{
g_return_if_fail (caller != NULL);
caller->refcount--;
g_free (caller->dbus_name);
g_free (caller->selinux_context);
if (caller->session != NULL)
- libpolkit_session_unref (caller->session);
+ polkit_session_unref (caller->session);
g_free (caller);
}
/**
- * libpolkit_caller_set_dbus_name:
+ * polkit_caller_set_dbus_name:
* @caller: The caller object
* @dbus_name: unique system bus connection name
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
+polkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (_pk_validate_unique_bus_name (dbus_name), FALSE);
}
/**
- * libpolkit_caller_set_uid:
+ * polkit_caller_set_uid:
* @caller: The caller object
* @uid: UNIX user id
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
+polkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
{
g_return_val_if_fail (caller != NULL, FALSE);
caller->uid = uid;
}
/**
- * libpolkit_caller_set_pid:
+ * polkit_caller_set_pid:
* @caller: The caller object
* @pid: UNIX process id
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid)
+polkit_caller_set_pid (PolKitCaller *caller, pid_t pid)
{
g_return_val_if_fail (caller != NULL, FALSE);
caller->pid = pid;
}
/**
- * libpolkit_caller_set_selinux_context:
+ * polkit_caller_set_selinux_context:
* @caller: The caller object
* @selinux_context: SELinux security context
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context)
+polkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context)
{
g_return_val_if_fail (caller != NULL, FALSE);
/* TODO: probably should have a separate validation function for SELinux contexts */
}
/**
- * libpolkit_caller_set_ck_session:
+ * polkit_caller_set_ck_session:
* @caller: The caller object
* @session: a session object
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
+polkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
{
g_return_val_if_fail (caller != NULL, FALSE);
- g_return_val_if_fail (libpolkit_session_validate (session), FALSE);
+ g_return_val_if_fail (polkit_session_validate (session), FALSE);
if (caller->session != NULL)
- libpolkit_session_unref (caller->session);
- caller->session = session != NULL ? libpolkit_session_ref (session) : NULL;
+ polkit_session_unref (caller->session);
+ caller->session = session != NULL ? polkit_session_ref (session) : NULL;
return TRUE;
}
/**
- * libpolkit_caller_get_dbus_name:
+ * polkit_caller_get_dbus_name:
* @caller: The caller object
* @out_dbus_name: Returns the unique system bus connection name. The caller shall not free this string.
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name)
+polkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (out_dbus_name != NULL, FALSE);
}
/**
- * libpolkit_caller_get_uid:
+ * polkit_caller_get_uid:
* @caller: The caller object
* @out_uid: Returns the UNIX user id
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
+polkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (out_uid != NULL, FALSE);
}
/**
- * libpolkit_caller_get_pid:
+ * polkit_caller_get_pid:
* @caller: The caller object
* @out_pid: Returns the UNIX process id
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid)
+polkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (out_pid != NULL, FALSE);
}
/**
- * libpolkit_caller_get_selinux_context:
+ * polkit_caller_get_selinux_context:
* @caller: The caller object
* @out_selinux_context: Returns the SELinux security context. The caller shall not free this string.
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context)
+polkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (out_selinux_context != NULL, FALSE);
}
/**
- * libpolkit_caller_get_ck_session:
+ * polkit_caller_get_ck_session:
* @caller: The caller object
* @out_session: Returns the session object. Caller shall not unref it.
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
+polkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (out_session != NULL, FALSE);
}
/**
- * libpolkit_caller_debug:
+ * polkit_caller_debug:
* @caller: the object
*
* Print debug details
**/
void
-libpolkit_caller_debug (PolKitCaller *caller)
+polkit_caller_debug (PolKitCaller *caller)
{
g_return_if_fail (caller != NULL);
_pk_debug ("PolKitCaller: refcount=%d dbus_name=%s uid=%d pid=%d selinux_context=%s",
caller->refcount, caller->dbus_name, caller->uid, caller->pid, caller->selinux_context);
if (caller->session != NULL)
- libpolkit_session_debug (caller->session);
+ polkit_session_debug (caller->session);
}
/**
- * libpolkit_caller_validate:
+ * polkit_caller_validate:
* @caller: the object
*
* Validate the object
* Returns: #TRUE iff the object is valid.
**/
polkit_bool_t
-libpolkit_caller_validate (PolKitCaller *caller)
+polkit_caller_validate (PolKitCaller *caller)
{
g_return_val_if_fail (caller != NULL, FALSE);
g_return_val_if_fail (caller->pid > 0, FALSE);
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * polkit-caller.h : callers
+ *
+ * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ **************************************************************************/
+
+#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef POLKIT_CALLER_H
+#define POLKIT_CALLER_H
+
+#include <polkit/polkit-types.h>
+#include <polkit/polkit-session.h>
+#include <sys/types.h>
+
+struct PolKitCaller;
+typedef struct PolKitCaller PolKitCaller;
+
+PolKitCaller *polkit_caller_new (void);
+PolKitCaller *polkit_caller_ref (PolKitCaller *caller);
+void polkit_caller_unref (PolKitCaller *caller);
+polkit_bool_t polkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name);
+polkit_bool_t polkit_caller_set_uid (PolKitCaller *caller, uid_t uid);
+polkit_bool_t polkit_caller_set_pid (PolKitCaller *caller, pid_t pid);
+polkit_bool_t polkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context);
+polkit_bool_t polkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session);
+polkit_bool_t polkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name);
+polkit_bool_t polkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid);
+polkit_bool_t polkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid);
+polkit_bool_t polkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context);
+polkit_bool_t polkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session);
+
+void polkit_caller_debug (PolKitCaller *caller);
+polkit_bool_t polkit_caller_validate (PolKitCaller *caller);
+
+#endif /* POLKIT_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-context.c : context for PolicyKit
+ * polkit-context.c : context for PolicyKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-context.h"
-#include "libpolkit-policy-cache.h"
-#include "libpolkit-module.h"
+#include "polkit-debug.h"
+#include "polkit-context.h"
+#include "polkit-policy-cache.h"
+#include "polkit-module.h"
/**
- * SECTION:libpolkit
+ * SECTION:polkit
* @short_description: Centralized policy management.
*
- * libpolkit is a C library for centralized policy management.
+ * polkit is a C library for centralized policy management.
**/
/**
- * SECTION:libpolkit-context
+ * SECTION:polkit-context
* @short_description: Context.
*
* This class is used to represent the interface to PolicyKit.
};
/**
- * libpolkit_context_new:
+ * polkit_context_new:
*
* Create a new context
*
* Returns: the object
**/
PolKitContext *
-libpolkit_context_new (void)
+polkit_context_new (void)
{
PolKitContext *pk_context;
pk_context = g_new0 (PolKitContext, 1);
GSList *i;
for (i = pk_context->modules; i != NULL; i = g_slist_next (i)) {
PolKitModuleInterface *module_interface = i->data;
- libpolkit_module_interface_unref (module_interface);
+ polkit_module_interface_unref (module_interface);
}
g_slist_free (pk_context->modules);
pk_context->modules = NULL;
g_strfreev (tokens);
continue;
}
- if (!libpolkit_module_control_from_string_representation (tokens[0], &module_control)) {
+ if (!polkit_module_control_from_string_representation (tokens[0], &module_control)) {
_pk_debug ("Unknown module_control '%s' at line %d - skipping line", tokens[0], line_number);
g_strfreev (tokens);
continue;
module_path = g_strdup_printf (PACKAGE_LIB_DIR "/PolicyKit/modules/%s", module_name);
_pk_debug ("MODULE: number=%d control=%d name=%s argc=%d",
mod_number, module_control, module_name, argc - 1);
- module_interface = libpolkit_module_interface_load_module (module_path,
+ module_interface = polkit_module_interface_load_module (module_path,
module_control,
argc - 1,
tokens + 1);
/* mark cache of policy files as stale.. (will be populated on-demand, see _get_cache()) */
if (pk_context->priv_cache != NULL) {
_pk_debug ("Something happened in %s - invalidating cache", pk_context->policy_dir);
- libpolkit_policy_cache_unref (pk_context->priv_cache);
+ polkit_policy_cache_unref (pk_context->priv_cache);
pk_context->priv_cache = NULL;
}
}
/**
- * libpolkit_context_init:
+ * polkit_context_init:
* @pk_context: the context object
* @error: return location for error
*
* Returns: #FALSE if @error was set, otherwise #TRUE
**/
polkit_bool_t
-libpolkit_context_init (PolKitContext *pk_context, PolKitError **error)
+polkit_context_init (PolKitContext *pk_context, PolKitError **error)
{
const char *dirname;
return TRUE;
error:
if (pk_context != NULL)
- libpolkit_context_unref (pk_context);
+ polkit_context_unref (pk_context);
return FALSE;
}
/**
- * libpolkit_context_ref:
+ * polkit_context_ref:
* @pk_context: the context object
*
* Increase reference count.
* Returns: the object
**/
PolKitContext *
-libpolkit_context_ref (PolKitContext *pk_context)
+polkit_context_ref (PolKitContext *pk_context)
{
g_return_val_if_fail (pk_context != NULL, pk_context);
pk_context->refcount++;
}
/**
- * libpolkit_context_unref:
+ * polkit_context_unref:
* @pk_context: the context object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_context_unref (PolKitContext *pk_context)
+polkit_context_unref (PolKitContext *pk_context)
{
g_return_if_fail (pk_context != NULL);
}
/**
- * libpolkit_context_set_config_changed:
+ * polkit_context_set_config_changed:
* @pk_context: the context object
* @cb: the callback to invoke
* @user_data: user data to pass to the callback
* timeframe.
**/
void
-libpolkit_context_set_config_changed (PolKitContext *pk_context,
+polkit_context_set_config_changed (PolKitContext *pk_context,
PolKitContextConfigChangedCB cb,
void *user_data)
{
}
/**
- * libpolkit_context_set_file_monitor:
+ * polkit_context_set_file_monitor:
* @pk_context: the context object
* @add_watch_func: the function that the PolicyKit library can invoke to start watching a file
* @remove_watch_func: the function that the PolicyKit library can invoke to stop watching a file
* Register a functions that PolicyKit can use for watching files.
**/
void
-libpolkit_context_set_file_monitor (PolKitContext *pk_context,
+polkit_context_set_file_monitor (PolKitContext *pk_context,
PolKitContextFileMonitorAddWatch add_watch_func,
PolKitContextFileMonitorRemoveWatch remove_watch_func)
{
/**
- * libpolkit_context_get_policy_cache:
+ * polkit_context_get_policy_cache:
* @pk_context: the context
*
* Get the #PolKitPolicyCache object that holds all the defined policies as well as their defaults.
* Returns: the #PolKitPolicyCache object. Caller shall not unref it.
**/
PolKitPolicyCache *
-libpolkit_context_get_policy_cache (PolKitContext *pk_context)
+polkit_context_get_policy_cache (PolKitContext *pk_context)
{
g_return_val_if_fail (pk_context != NULL, NULL);
_pk_debug ("Populating cache from directory %s", pk_context->policy_dir);
error = NULL;
- pk_context->priv_cache = libpolkit_policy_cache_new (pk_context->policy_dir, &error);
+ pk_context->priv_cache = polkit_policy_cache_new (pk_context->policy_dir, &error);
if (pk_context->priv_cache == NULL) {
g_warning ("Error loading policy files from %s: %s",
pk_context->policy_dir, polkit_error_get_error_message (error));
polkit_error_free (error);
} else {
- libpolkit_policy_cache_debug (pk_context->priv_cache);
+ polkit_policy_cache_debug (pk_context->priv_cache);
}
}
/**
- * libpolkit_context_get_seat_resource_association:
+ * polkit_context_get_seat_resource_association:
* @pk_context: the PolicyKit context
* @visitor: visitor function
* @user_data: user data
* available to any local seat.
*
* Returns: A #PolKitResult - can only be one of
- * #LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW or
- * #LIBPOLKIT_RESULT_YES (if the callback was invoked)
+ * #POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW or
+ * #POLKIT_RESULT_YES (if the callback was invoked)
*/
PolKitResult
-libpolkit_context_get_seat_resource_association (PolKitContext *pk_context,
+polkit_context_get_seat_resource_association (PolKitContext *pk_context,
PolKitSeatVisitorCB visitor,
void *user_data)
{
- return LIBPOLKIT_RESULT_YES;
+ return POLKIT_RESULT_YES;
}
/**
- * libpolkit_context_is_resource_associated_with_seat:
+ * polkit_context_is_resource_associated_with_seat:
* @pk_context: the PolicyKit context
* @resource: the resource in question
* @seat: the seat
*
* Determine if a given resource is associated with a given seat. The
- * same comments noted in libpolkit_get_seat_resource_association() about the
+ * same comments noted in polkit_get_seat_resource_association() about the
* source purely being user configuration applies here as well.
*
* Returns: A #PolKitResult - can only be one of
- * #LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
- * #LIBPOLKIT_RESULT_YES, #LIBPOLKIT_RESULT_NO.
+ * #POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
+ * #POLKIT_RESULT_YES, #POLKIT_RESULT_NO.
*/
PolKitResult
-libpolkit_context_is_resource_associated_with_seat (PolKitContext *pk_context,
+polkit_context_is_resource_associated_with_seat (PolKitContext *pk_context,
PolKitResource *resource,
PolKitSeat *seat)
{
- return LIBPOLKIT_RESULT_NO;
+ return POLKIT_RESULT_NO;
}
/**
- * libpolkit_context_can_session_access_resource:
+ * polkit_context_can_session_access_resource:
* @pk_context: the PolicyKit context
* @action: the type of access to check for
* @resource: the resource in question or #NULL to test for all resources
* Determine if a given session can access a given resource in a given way.
*
* Returns: A #PolKitResult - can only be one of
- * #LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
- * #LIBPOLKIT_RESULT_YES, #LIBPOLKIT_RESULT_NO.
+ * #POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
+ * #POLKIT_RESULT_YES, #POLKIT_RESULT_NO.
*/
PolKitResult
-libpolkit_context_can_session_access_resource (PolKitContext *pk_context,
+polkit_context_can_session_access_resource (PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitSession *session)
PolKitModuleControl current_control;
GSList *i;
- current_result = LIBPOLKIT_RESULT_NO;
+ current_result = POLKIT_RESULT_NO;
g_return_val_if_fail (pk_context != NULL, current_result);
/* resource may actually by NULL */
/* now validate the incoming objects */
- if (!libpolkit_action_validate (action))
+ if (!polkit_action_validate (action))
goto out;
if (resource == NULL)
- if (!libpolkit_resource_validate (resource))
+ if (!polkit_resource_validate (resource))
goto out;
- if (!libpolkit_session_validate (session))
+ if (!polkit_session_validate (session))
goto out;
- cache = libpolkit_context_get_policy_cache (pk_context);
+ cache = polkit_context_get_policy_cache (pk_context);
if (cache == NULL)
goto out;
- _pk_debug ("entering libpolkit_can_session_access_resource()");
- libpolkit_action_debug (action);
+ _pk_debug ("entering polkit_can_session_access_resource()");
+ polkit_action_debug (action);
if (resource != NULL)
- libpolkit_resource_debug (resource);
- libpolkit_session_debug (session);
+ polkit_resource_debug (resource);
+ polkit_session_debug (session);
- pfe = libpolkit_policy_cache_get_entry (cache, action);
+ pfe = polkit_policy_cache_get_entry (cache, action);
if (pfe == NULL) {
char *action_name;
- if (!libpolkit_action_get_action_id (action, &action_name)) {
+ if (!polkit_action_get_action_id (action, &action_name)) {
g_warning ("given action has no name");
} else {
g_warning ("no action with name '%s'", action_name);
}
- current_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ current_result = POLKIT_RESULT_UNKNOWN_ACTION;
goto out;
}
- libpolkit_policy_file_entry_debug (pfe);
+ polkit_policy_file_entry_debug (pfe);
- current_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
- current_control = LIBPOLKIT_MODULE_CONTROL_ADVISE; /* start with advise */
+ current_result = POLKIT_RESULT_UNKNOWN_ACTION;
+ current_control = POLKIT_MODULE_CONTROL_ADVISE; /* start with advise */
/* visit modules */
for (i = pk_context->modules; i != NULL; i = g_slist_next (i)) {
PolKitModuleInterface *module_interface = i->data;
PolKitModuleCanSessionAccessResource func;
- func = libpolkit_module_get_func_can_session_access_resource (module_interface);
+ func = polkit_module_get_func_can_session_access_resource (module_interface);
if (func != NULL) {
PolKitModuleControl module_control;
PolKitResult module_result;
- _pk_debug ("Asking module '%s'", libpolkit_module_get_name (module_interface));
+ _pk_debug ("Asking module '%s'", polkit_module_get_name (module_interface));
- module_control = libpolkit_module_interface_get_control (module_interface);
+ module_control = polkit_module_interface_get_control (module_interface);
- if (libpolkit_module_interface_check_builtin_confinement_for_session (
+ if (polkit_module_interface_check_builtin_confinement_for_session (
module_interface,
pk_context,
action,
resource,
session)) {
/* module is confined by built-in options */
- module_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ module_result = POLKIT_RESULT_UNKNOWN_ACTION;
_pk_debug ("Module '%s' confined by built-in's",
- libpolkit_module_get_name (module_interface));
+ polkit_module_get_name (module_interface));
} else {
module_result = func (module_interface,
pk_context,
* will return this if it's confined to only consider certain actions
* or certain users.
*/
- if (module_result != LIBPOLKIT_RESULT_UNKNOWN_ACTION) {
+ if (module_result != POLKIT_RESULT_UNKNOWN_ACTION) {
- if (current_control == LIBPOLKIT_MODULE_CONTROL_ADVISE &&
- module_control == LIBPOLKIT_MODULE_CONTROL_ADVISE) {
+ if (current_control == POLKIT_MODULE_CONTROL_ADVISE &&
+ module_control == POLKIT_MODULE_CONTROL_ADVISE) {
/* take the less strict result */
if (current_result < module_result) {
current_result = module_result;
}
- } else if (current_control == LIBPOLKIT_MODULE_CONTROL_ADVISE &&
- module_control == LIBPOLKIT_MODULE_CONTROL_MANDATORY) {
+ } else if (current_control == POLKIT_MODULE_CONTROL_ADVISE &&
+ module_control == POLKIT_MODULE_CONTROL_MANDATORY) {
/* here we just override */
current_result = module_result;
/* we are now in mandatory mode */
- current_control = LIBPOLKIT_MODULE_CONTROL_MANDATORY;
+ current_control = POLKIT_MODULE_CONTROL_MANDATORY;
}
}
}
}
/* Never return UNKNOWN_ACTION to user */
- if (current_result == LIBPOLKIT_RESULT_UNKNOWN_ACTION)
- current_result = LIBPOLKIT_RESULT_NO;
+ if (current_result == POLKIT_RESULT_UNKNOWN_ACTION)
+ current_result = POLKIT_RESULT_NO;
out:
- _pk_debug ("... result was %s", libpolkit_result_to_string_representation (current_result));
+ _pk_debug ("... result was %s", polkit_result_to_string_representation (current_result));
return current_result;
}
/**
- * libpolkit_context_can_caller_access_resource:
+ * polkit_context_can_caller_access_resource:
* @pk_context: the PolicyKit context
* @action: the type of access to check for
* @resource: the resource in question or #NULL to test for all resources
* access the resource in the given way
*/
PolKitResult
-libpolkit_context_can_caller_access_resource (PolKitContext *pk_context,
+polkit_context_can_caller_access_resource (PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller)
PolKitModuleControl current_control;
GSList *i;
- current_result = LIBPOLKIT_RESULT_NO;
+ current_result = POLKIT_RESULT_NO;
g_return_val_if_fail (pk_context != NULL, current_result);
/* resource may actually by NULL */
if (action == NULL || caller == NULL)
goto out;
- cache = libpolkit_context_get_policy_cache (pk_context);
+ cache = polkit_context_get_policy_cache (pk_context);
if (cache == NULL)
goto out;
/* now validate the incoming objects */
- if (!libpolkit_action_validate (action))
+ if (!polkit_action_validate (action))
goto out;
if (resource == NULL)
- if (!libpolkit_resource_validate (resource))
+ if (!polkit_resource_validate (resource))
goto out;
- if (!libpolkit_caller_validate (caller))
+ if (!polkit_caller_validate (caller))
goto out;
- _pk_debug ("entering libpolkit_can_caller_access_resource()");
- libpolkit_action_debug (action);
+ _pk_debug ("entering polkit_can_caller_access_resource()");
+ polkit_action_debug (action);
if (resource != NULL)
- libpolkit_resource_debug (resource);
- libpolkit_caller_debug (caller);
+ polkit_resource_debug (resource);
+ polkit_caller_debug (caller);
- pfe = libpolkit_policy_cache_get_entry (cache, action);
+ pfe = polkit_policy_cache_get_entry (cache, action);
if (pfe == NULL) {
char *action_name;
- if (!libpolkit_action_get_action_id (action, &action_name)) {
+ if (!polkit_action_get_action_id (action, &action_name)) {
g_warning ("given action has no name");
} else {
g_warning ("no action with name '%s'", action_name);
}
- current_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ current_result = POLKIT_RESULT_UNKNOWN_ACTION;
goto out;
}
- libpolkit_policy_file_entry_debug (pfe);
+ polkit_policy_file_entry_debug (pfe);
- current_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
- current_control = LIBPOLKIT_MODULE_CONTROL_ADVISE; /* start with advise */
+ current_result = POLKIT_RESULT_UNKNOWN_ACTION;
+ current_control = POLKIT_MODULE_CONTROL_ADVISE; /* start with advise */
/* visit modules */
for (i = pk_context->modules; i != NULL; i = g_slist_next (i)) {
PolKitModuleInterface *module_interface = i->data;
PolKitModuleCanCallerAccessResource func;
- func = libpolkit_module_get_func_can_caller_access_resource (module_interface);
+ func = polkit_module_get_func_can_caller_access_resource (module_interface);
if (func != NULL) {
PolKitModuleControl module_control;
PolKitResult module_result;
- _pk_debug ("Asking module '%s'", libpolkit_module_get_name (module_interface));
+ _pk_debug ("Asking module '%s'", polkit_module_get_name (module_interface));
- module_control = libpolkit_module_interface_get_control (module_interface);
+ module_control = polkit_module_interface_get_control (module_interface);
- if (libpolkit_module_interface_check_builtin_confinement_for_caller (
+ if (polkit_module_interface_check_builtin_confinement_for_caller (
module_interface,
pk_context,
action,
resource,
caller)) {
/* module is confined by built-in options */
- module_result = LIBPOLKIT_RESULT_UNKNOWN_ACTION;
+ module_result = POLKIT_RESULT_UNKNOWN_ACTION;
_pk_debug ("Module '%s' confined by built-in's",
- libpolkit_module_get_name (module_interface));
+ polkit_module_get_name (module_interface));
} else {
module_result = func (module_interface,
pk_context,
* will return this if it's confined to only consider certain actions
* or certain users.
*/
- if (module_result != LIBPOLKIT_RESULT_UNKNOWN_ACTION) {
+ if (module_result != POLKIT_RESULT_UNKNOWN_ACTION) {
- if (current_control == LIBPOLKIT_MODULE_CONTROL_ADVISE &&
- module_control == LIBPOLKIT_MODULE_CONTROL_ADVISE) {
+ if (current_control == POLKIT_MODULE_CONTROL_ADVISE &&
+ module_control == POLKIT_MODULE_CONTROL_ADVISE) {
/* take the less strict result */
if (current_result < module_result) {
current_result = module_result;
}
- } else if (current_control == LIBPOLKIT_MODULE_CONTROL_ADVISE &&
- module_control == LIBPOLKIT_MODULE_CONTROL_MANDATORY) {
+ } else if (current_control == POLKIT_MODULE_CONTROL_ADVISE &&
+ module_control == POLKIT_MODULE_CONTROL_MANDATORY) {
/* here we just override */
current_result = module_result;
/* we are now in mandatory mode */
- current_control = LIBPOLKIT_MODULE_CONTROL_MANDATORY;
+ current_control = POLKIT_MODULE_CONTROL_MANDATORY;
}
}
}
}
/* Never return UNKNOWN_ACTION to user */
- if (current_result == LIBPOLKIT_RESULT_UNKNOWN_ACTION)
- current_result = LIBPOLKIT_RESULT_NO;
+ if (current_result == POLKIT_RESULT_UNKNOWN_ACTION)
+ current_result = POLKIT_RESULT_NO;
out:
- _pk_debug ("... result was %s", libpolkit_result_to_string_representation (current_result));
+ _pk_debug ("... result was %s", polkit_result_to_string_representation (current_result));
return current_result;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-context.h : PolicyKit context
+ * polkit-context.h : PolicyKit context
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_CONTEXT_H
-#define LIBPOLKIT_CONTEXT_H
+#ifndef POLKIT_CONTEXT_H
+#define POLKIT_CONTEXT_H
-#include <libpolkit/libpolkit-types.h>
-#include <libpolkit/libpolkit-error.h>
-#include <libpolkit/libpolkit-result.h>
-#include <libpolkit/libpolkit-context.h>
-#include <libpolkit/libpolkit-action.h>
-#include <libpolkit/libpolkit-resource.h>
-#include <libpolkit/libpolkit-seat.h>
-#include <libpolkit/libpolkit-session.h>
-#include <libpolkit/libpolkit-caller.h>
-#include <libpolkit/libpolkit-policy-cache.h>
+#include <polkit/polkit-types.h>
+#include <polkit/polkit-error.h>
+#include <polkit/polkit-result.h>
+#include <polkit/polkit-context.h>
+#include <polkit/polkit-action.h>
+#include <polkit/polkit-resource.h>
+#include <polkit/polkit-seat.h>
+#include <polkit/polkit-session.h>
+#include <polkit/polkit-caller.h>
+#include <polkit/polkit-policy-cache.h>
struct PolKitContext;
typedef struct PolKitContext PolKitContext;
int watch_id);
-PolKitContext *libpolkit_context_new (void);
-void libpolkit_context_set_config_changed (PolKitContext *pk_context,
+PolKitContext *polkit_context_new (void);
+void polkit_context_set_config_changed (PolKitContext *pk_context,
PolKitContextConfigChangedCB cb,
void *user_data);
-void libpolkit_context_set_file_monitor (PolKitContext *pk_context,
+void polkit_context_set_file_monitor (PolKitContext *pk_context,
PolKitContextFileMonitorAddWatch add_watch_func,
PolKitContextFileMonitorRemoveWatch remove_watch_func);
-polkit_bool_t libpolkit_context_init (PolKitContext *pk_context,
+polkit_bool_t polkit_context_init (PolKitContext *pk_context,
PolKitError **error);
-PolKitContext *libpolkit_context_ref (PolKitContext *pk_context);
-void libpolkit_context_unref (PolKitContext *pk_context);
+PolKitContext *polkit_context_ref (PolKitContext *pk_context);
+void polkit_context_unref (PolKitContext *pk_context);
-PolKitPolicyCache *libpolkit_context_get_policy_cache (PolKitContext *pk_context);
+PolKitPolicyCache *polkit_context_get_policy_cache (PolKitContext *pk_context);
/**
* PolKitSeatVisitorCB:
* @resources_associated_with_seat: A NULL terminated array of resources associated with the seat
* @user_data: user data
*
- * Visitor function for libpolkit_get_seat_resource_association(). The caller should _not_ unref the passed objects.
+ * Visitor function for polkit_get_seat_resource_association(). The caller should _not_ unref the passed objects.
*/
typedef void (*PolKitSeatVisitorCB) (PolKitSeat *seat,
PolKitResource **resources_associated_with_seat,
void *user_data);
PolKitResult
-libpolkit_context_get_seat_resource_association (PolKitContext *pk_context,
+polkit_context_get_seat_resource_association (PolKitContext *pk_context,
PolKitSeatVisitorCB visitor,
void *user_data);
PolKitResult
-libpolkit_context_is_resource_associated_with_seat (PolKitContext *pk_context,
+polkit_context_is_resource_associated_with_seat (PolKitContext *pk_context,
PolKitResource *resource,
PolKitSeat *seat);
PolKitResult
-libpolkit_context_can_session_access_resource (PolKitContext *pk_context,
+polkit_context_can_session_access_resource (PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitSession *session);
PolKitResult
-libpolkit_context_can_caller_access_resource (PolKitContext *pk_context,
+polkit_context_can_caller_access_resource (PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller);
-#endif /* LIBPOLKIT_CONTEXT_H */
+#endif /* POLKIT_CONTEXT_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit.c : library for querying system-wide policy
+ * polkit.c : library for querying system-wide policy
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
/**
- * SECTION:libpolkit-debug
- * @short_description: Internal debug functions for libpolkit.
+ * SECTION:polkit-debug
+ * @short_description: Internal debug functions for polkit.
*
* These functions are used for debug purposes
**/
#include <sys/time.h>
#include <time.h>
-#include "libpolkit-types.h"
-#include "libpolkit-debug.h"
+#include "polkit-types.h"
+#include "polkit-debug.h"
/**
* pk_debug:
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-debug.h : debug infrastructure for libpolkit
+ * polkit-debug.h : debug infrastructure for polkit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
*
**************************************************************************/
-#ifndef LIBPOLKIT_DEBUG_H
-#define LIBPOLKIT_DEBUG_H
+#ifndef POLKIT_DEBUG_H
+#define POLKIT_DEBUG_H
void _pk_debug (const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
-#endif /* LIBPOLKIT_DEBUG_H */
+#endif /* POLKIT_DEBUG_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-error.c : GError error codes from PolicyKit
+ * polkit-error.c : GError error codes from PolicyKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
/**
- * SECTION:libpolkit-error
+ * SECTION:polkit-error
* @short_description: Error codes from PolicyKit.
*
* Error codes from PolicyKit.
#include <glib.h>
-#include "libpolkit-types.h"
-#include "libpolkit-error.h"
+#include "polkit-types.h"
+#include "polkit-error.h"
/**
* PolKitError:
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-error.h : error reporting from PolicyKit
+ * polkit-error.h : error reporting from PolicyKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_ERROR_H
-#define LIBPOLKIT_ERROR_H
+#ifndef POLKIT_ERROR_H
+#define POLKIT_ERROR_H
/**
* PolKitErrorCode:
void polkit_error_free (PolKitError *error);
void polkit_error_set_error (PolKitError **error, PolKitErrorCode error_code, const char *format, ...) __attribute__((__format__ (__printf__, 3, 4)));
-#endif /* LIBPOLKIT_ERROR_H */
+#endif /* POLKIT_ERROR_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-module.c : PolicyKit loadable module interface
+ * polkit-module.c : PolicyKit loadable module interface
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
/**
- * SECTION:libpolkit-module
+ * SECTION:polkit-module
* @short_description: PolicyKit loadable module interface
*
* These functions are used by loadable PolicyKit modules.
#include <glib.h>
#include <unistd.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-module.h"
+#include "polkit-debug.h"
+#include "polkit-module.h"
/**
* PolKitModuleInterface:
}
/**
- * libpolkit_module_interface_load_module:
+ * polkit_module_interface_load_module:
* @name: name of module, e.g. "polkit-module-default.so"
* @module_control: the module control; from the configuration file
* @argc: number arguments to pass
* Returns: A #PolKitModuleInterface object on success; #NULL on failure.
**/
PolKitModuleInterface *
-libpolkit_module_interface_load_module (const char *name, PolKitModuleControl module_control, int argc, char *argv[])
+polkit_module_interface_load_module (const char *name, PolKitModuleControl module_control, int argc, char *argv[])
{
void *handle;
PolKitModuleInterface *mi;
goto error;
}
- func = dlsym (handle, "libpolkit_module_set_functions");
+ func = dlsym (handle, "polkit_module_set_functions");
if (func == NULL) {
- _pk_debug ("Cannot get symbol 'libpolkit_module_set_functions' in module '%s'", name);
+ _pk_debug ("Cannot get symbol 'polkit_module_set_functions' in module '%s'", name);
goto error;
}
_pk_debug ("func = %p", func);
- mi = libpolkit_module_interface_new ();
+ mi = polkit_module_interface_new ();
if (!func (mi)) {
_pk_debug ("Module '%s' returned FALSE when asked to set functions", name);
goto error;
return mi;
error:
if (mi != NULL)
- libpolkit_module_interface_unref (mi);
+ polkit_module_interface_unref (mi);
if (handle != NULL)
dlclose (handle);
return NULL;
}
/**
- * libpolkit_module_get_name:
+ * polkit_module_get_name:
* @module_interface: the module interface
*
* Get the name of the module
* Returns: name or #NULL if an error occured
**/
const char *
-libpolkit_module_get_name (PolKitModuleInterface *module_interface)
+polkit_module_get_name (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->name;
/**
- * libpolkit_module_interface_new:
+ * polkit_module_interface_new:
*
* Create a new #PolKitModuleInterface object.
*
* Returns: the new object
**/
PolKitModuleInterface *
-libpolkit_module_interface_new (void)
+polkit_module_interface_new (void)
{
PolKitModuleInterface *module_interface;
module_interface = g_new0 (PolKitModuleInterface, 1);
}
/**
- * libpolkit_module_interface_ref:
+ * polkit_module_interface_ref:
* @module_interface: the module_interface object
*
* Increase reference count.
* Returns: the object
**/
PolKitModuleInterface *
-libpolkit_module_interface_ref (PolKitModuleInterface *module_interface)
+polkit_module_interface_ref (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, module_interface);
module_interface->refcount++;
}
/**
- * libpolkit_module_interface_unref:
+ * polkit_module_interface_unref:
* @module_interface: the module_interface object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_module_interface_unref (PolKitModuleInterface *module_interface)
+polkit_module_interface_unref (PolKitModuleInterface *module_interface)
{
g_return_if_fail (module_interface != NULL);
module_interface->refcount--;
}
/**
- * libpolkit_module_set_func_initialize:
+ * polkit_module_set_func_initialize:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
void
-libpolkit_module_set_func_initialize (PolKitModuleInterface *module_interface,
+polkit_module_set_func_initialize (PolKitModuleInterface *module_interface,
PolKitModuleInitialize func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_set_func_shutdown:
+ * polkit_module_set_func_shutdown:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
void
-libpolkit_module_set_func_shutdown (PolKitModuleInterface *module_interface,
+polkit_module_set_func_shutdown (PolKitModuleInterface *module_interface,
PolKitModuleShutdown func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_set_func_get_seat_resource_association:
+ * polkit_module_set_func_get_seat_resource_association:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
void
-libpolkit_module_set_func_get_seat_resource_association (PolKitModuleInterface *module_interface,
+polkit_module_set_func_get_seat_resource_association (PolKitModuleInterface *module_interface,
PolKitModuleGetSeatResourceAssociation func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_set_func_is_resource_associated_with_seat:
+ * polkit_module_set_func_is_resource_associated_with_seat:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
-void libpolkit_module_set_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface,
PolKitModuleIsResourceAssociatedWithSeat func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_set_func_can_session_access_resource:
+ * polkit_module_set_func_can_session_access_resource:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
-void libpolkit_module_set_func_can_session_access_resource (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_can_session_access_resource (PolKitModuleInterface *module_interface,
PolKitModuleCanSessionAccessResource func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_set_func_can_caller_access_resource:
+ * polkit_module_set_func_can_caller_access_resource:
* @module_interface: the module interface
* @func: the function pointer
*
* Set the function pointer.
**/
-void libpolkit_module_set_func_can_caller_access_resource (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_can_caller_access_resource (PolKitModuleInterface *module_interface,
PolKitModuleCanCallerAccessResource func)
{
g_return_if_fail (module_interface != NULL);
}
/**
- * libpolkit_module_get_func_initialize:
+ * polkit_module_get_func_initialize:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleInitialize
-libpolkit_module_get_func_initialize (PolKitModuleInterface *module_interface)
+polkit_module_get_func_initialize (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_initialize;
}
/**
- * libpolkit_module_get_func_shutdown:
+ * polkit_module_get_func_shutdown:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleShutdown
-libpolkit_module_get_func_shutdown (PolKitModuleInterface *module_interface)
+polkit_module_get_func_shutdown (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_shutdown;
}
/**
- * libpolkit_module_get_func_get_seat_resource_association:
+ * polkit_module_get_func_get_seat_resource_association:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleGetSeatResourceAssociation
-libpolkit_module_get_func_get_seat_resource_association (PolKitModuleInterface *module_interface)
+polkit_module_get_func_get_seat_resource_association (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_get_seat_resource_association;
}
/**
- * libpolkit_module_get_func_is_resource_associated_with_seat:
+ * polkit_module_get_func_is_resource_associated_with_seat:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleIsResourceAssociatedWithSeat
-libpolkit_module_get_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface)
+polkit_module_get_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_is_resource_associated_with_seat;
}
/**
- * libpolkit_module_get_func_can_session_access_resource:
+ * polkit_module_get_func_can_session_access_resource:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleCanSessionAccessResource
-libpolkit_module_get_func_can_session_access_resource (PolKitModuleInterface *module_interface)
+polkit_module_get_func_can_session_access_resource (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_can_session_access_resource;
}
/**
- * libpolkit_module_get_func_can_caller_access_resource:
+ * polkit_module_get_func_can_caller_access_resource:
* @module_interface: the module interface
*
* Get the function pointer.
* Returns: Function pointer or #NULL if it's unavailable or an error occured
**/
PolKitModuleCanCallerAccessResource
-libpolkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *module_interface)
+polkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->func_can_caller_access_resource;
/**
- * libpolkit_module_interface_get_control:
+ * polkit_module_interface_get_control:
* @module_interface: the module interface
*
* Get the control for this module.
* Returns: A #PolKitModuleControl value.
**/
PolKitModuleControl
-libpolkit_module_interface_get_control (PolKitModuleInterface *module_interface)
+polkit_module_interface_get_control (PolKitModuleInterface *module_interface)
{
/* hmm, should we have UNKNOWN? */
- g_return_val_if_fail (module_interface != NULL, LIBPOLKIT_MODULE_CONTROL_MANDATORY);
+ g_return_val_if_fail (module_interface != NULL, POLKIT_MODULE_CONTROL_MANDATORY);
return module_interface->module_control;
}
const char *str;
} mapping[] =
{
- {LIBPOLKIT_MODULE_CONTROL_ADVISE, "advise"},
- {LIBPOLKIT_MODULE_CONTROL_MANDATORY, "mandatory"},
+ {POLKIT_MODULE_CONTROL_ADVISE, "advise"},
+ {POLKIT_MODULE_CONTROL_MANDATORY, "mandatory"},
{0, NULL}
};
/**
- * libpolkit_module_control_to_string_representation:
+ * polkit_module_control_to_string_representation:
* @module_control: the given value
*
* Gives a textual representation of a #PolKitModuleControl object.
* Returns: The textual representation or #NULL if the value passed is invalid
**/
const char *
-libpolkit_module_control_to_string_representation (PolKitModuleControl module_control)
+polkit_module_control_to_string_representation (PolKitModuleControl module_control)
{
- if (module_control < 0 || module_control >= LIBPOLKIT_MODULE_CONTROL_N_CONTROLS) {
+ if (module_control < 0 || module_control >= POLKIT_MODULE_CONTROL_N_CONTROLS) {
g_warning ("The passed module control identifier, %d, is not valid", module_control);
return NULL;
}
}
/**
- * libpolkit_module_control_from_string_representation:
+ * polkit_module_control_from_string_representation:
* @string: the textual representation
* @out_module_control: return location for the value
*
* Returns: TRUE if the textual representation was valid, otherwise FALSE
**/
polkit_bool_t
-libpolkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control)
+polkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control)
{
int n;
g_return_val_if_fail (out_module_control != NULL, FALSE);
- for (n = 0; n < LIBPOLKIT_MODULE_CONTROL_N_CONTROLS; n++) {
+ for (n = 0; n < POLKIT_MODULE_CONTROL_N_CONTROLS; n++) {
if (mapping[n].str == NULL)
break;
if (g_ascii_strcasecmp (mapping[n].str, string) == 0) {
/**
- * libpolkit_module_set_user_data:
+ * polkit_module_set_user_data:
* @module_interface: module interface
* @user_data: user data to set
*
* instantiated at the same time.
**/
void
-libpolkit_module_set_user_data (PolKitModuleInterface *module_interface, void *user_data)
+polkit_module_set_user_data (PolKitModuleInterface *module_interface, void *user_data)
{
g_return_if_fail (module_interface != NULL);
module_interface->module_user_data = user_data;
}
/**
- * libpolkit_module_get_user_data:
+ * polkit_module_get_user_data:
* @module_interface: module interface
*
* Get user data.
*
- * Returns: The user data set with libpolkit_module_set_user_data()
+ * Returns: The user data set with polkit_module_set_user_data()
**/
void *
-libpolkit_module_get_user_data (PolKitModuleInterface *module_interface)
+polkit_module_get_user_data (PolKitModuleInterface *module_interface)
{
g_return_val_if_fail (module_interface != NULL, NULL);
return module_interface->module_user_data;
if (module_interface->builtin_have_action_regex) {
char *action_name;
- if (libpolkit_action_get_action_id (action, &action_name)) {
+ if (polkit_action_get_action_id (action, &action_name)) {
if (regexec (&module_interface->builtin_action_regex_compiled,
action_name, 0, NULL, 0) == 0) {
ret = TRUE;
return TRUE;
if (session == NULL)
return FALSE;
- if (!libpolkit_session_get_uid (session, &uid))
+ if (!polkit_session_get_uid (session, &uid))
return FALSE;
return _check_uid_in_list (list, uid);
}
return TRUE;
if (caller == NULL)
return FALSE;
- if (!libpolkit_caller_get_uid (caller, &uid))
+ if (!polkit_caller_get_uid (caller, &uid))
return FALSE;
return _check_uid_in_list (list, uid);
}
/**
- * libpolkit_module_interface_check_builtin_confinement_for_session:
+ * polkit_module_interface_check_builtin_confinement_for_session:
* @module_interface: the given module
* @pk_context: the PolicyKit context
* @action: the type of access to check for
* Returns: TRUE if, and only if, the module is confined from handling the request
**/
polkit_bool_t
-libpolkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
+polkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
}
/**
- * libpolkit_module_interface_check_builtin_confinement_for_caller:
+ * polkit_module_interface_check_builtin_confinement_for_caller:
* @module_interface: the given module
* @pk_context: the PolicyKit context
* @action: the type of access to check for
* Returns: TRUE if, and only if, the module is confined from handling the request
**/
polkit_bool_t
-libpolkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
+polkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-module.h : PolicyKit loadable module interface
+ * polkit-module.h : PolicyKit loadable module interface
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_MODULE_H
-#define LIBPOLKIT_MODULE_H
+#ifndef POLKIT_MODULE_H
+#define POLKIT_MODULE_H
-#include <libpolkit/libpolkit-types.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit-types.h>
+#include <polkit/polkit.h>
struct PolKitModuleInterface;
typedef struct PolKitModuleInterface PolKitModuleInterface;
* @visitor: visitor function
* @user_data: user data
*
- * Type of PolicyKit module function to implement libpolkit_get_seat_resource_association().
+ * Type of PolicyKit module function to implement polkit_get_seat_resource_association().
*
* Returns: the #PolKitResult
**/
* @resource: the resource in question
* @seat: the seat
*
- * Type of PolicyKit module function to implement libpolkit_is_resource_associated_with_seat().
+ * Type of PolicyKit module function to implement polkit_is_resource_associated_with_seat().
*
* Returns: the #PolKitResult
**/
* @resource: the resource in question
* @session: the session in question
*
- * Type of PolicyKit module function to implement libpolkit_can_session_access_resource().
+ * Type of PolicyKit module function to implement polkit_can_session_access_resource().
*
* Returns: the #PolKitResult
**/
* @resource: the resource in question
* @caller: the resource in question
*
- * Type of PolicyKit module function to implement libpolkit_can_caller_access_resource().
+ * Type of PolicyKit module function to implement polkit_can_caller_access_resource().
*
* Returns: the #PolKitResult
**/
PolKitResource *resource,
PolKitCaller *caller);
-PolKitModuleInterface *libpolkit_module_interface_new (void);
-PolKitModuleInterface *libpolkit_module_interface_ref (PolKitModuleInterface *module_interface);
-void libpolkit_module_interface_unref (PolKitModuleInterface *module_interface);
-const char *libpolkit_module_get_name (PolKitModuleInterface *module_interface);
+PolKitModuleInterface *polkit_module_interface_new (void);
+PolKitModuleInterface *polkit_module_interface_ref (PolKitModuleInterface *module_interface);
+void polkit_module_interface_unref (PolKitModuleInterface *module_interface);
+const char *polkit_module_get_name (PolKitModuleInterface *module_interface);
-void libpolkit_module_set_user_data (PolKitModuleInterface *module_interface, void *user_data);
-void *libpolkit_module_get_user_data (PolKitModuleInterface *module_interface);
+void polkit_module_set_user_data (PolKitModuleInterface *module_interface, void *user_data);
+void *polkit_module_get_user_data (PolKitModuleInterface *module_interface);
-void libpolkit_module_set_func_initialize (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_initialize (PolKitModuleInterface *module_interface,
PolKitModuleInitialize func);
-void libpolkit_module_set_func_shutdown (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_shutdown (PolKitModuleInterface *module_interface,
PolKitModuleShutdown func);
-void libpolkit_module_set_func_get_seat_resource_association (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_get_seat_resource_association (PolKitModuleInterface *module_interface,
PolKitModuleGetSeatResourceAssociation func);
-void libpolkit_module_set_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface,
PolKitModuleIsResourceAssociatedWithSeat func);
-void libpolkit_module_set_func_can_session_access_resource (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_can_session_access_resource (PolKitModuleInterface *module_interface,
PolKitModuleCanSessionAccessResource func);
-void libpolkit_module_set_func_can_caller_access_resource (PolKitModuleInterface *module_interface,
+void polkit_module_set_func_can_caller_access_resource (PolKitModuleInterface *module_interface,
PolKitModuleCanCallerAccessResource func);
-PolKitModuleInitialize libpolkit_module_get_func_initialize (PolKitModuleInterface *module_interface);
-PolKitModuleShutdown libpolkit_module_get_func_shutdown (PolKitModuleInterface *module_interface);
-PolKitModuleGetSeatResourceAssociation libpolkit_module_get_func_get_seat_resource_association (PolKitModuleInterface *module_interface);
-PolKitModuleIsResourceAssociatedWithSeat libpolkit_module_get_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface);
-PolKitModuleCanSessionAccessResource libpolkit_module_get_func_can_session_access_resource (PolKitModuleInterface *module_interface);
-PolKitModuleCanCallerAccessResource libpolkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *module_interface);
+PolKitModuleInitialize polkit_module_get_func_initialize (PolKitModuleInterface *module_interface);
+PolKitModuleShutdown polkit_module_get_func_shutdown (PolKitModuleInterface *module_interface);
+PolKitModuleGetSeatResourceAssociation polkit_module_get_func_get_seat_resource_association (PolKitModuleInterface *module_interface);
+PolKitModuleIsResourceAssociatedWithSeat polkit_module_get_func_is_resource_associated_with_seat (PolKitModuleInterface *module_interface);
+PolKitModuleCanSessionAccessResource polkit_module_get_func_can_session_access_resource (PolKitModuleInterface *module_interface);
+PolKitModuleCanCallerAccessResource polkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *module_interface);
/**
* PolKitModuleControl:
- * @LIBPOLKIT_MODULE_CONTROL_ADVISE: Allow modules, marked with #LIBPOLKIT_MODULE_CONTROL_MANDATORY, down the
+ * @POLKIT_MODULE_CONTROL_ADVISE: Allow modules, marked with #POLKIT_MODULE_CONTROL_MANDATORY, down the
* stack to override results from this module. Modules down the stack that are also marked with
- * the #LIBPOLKIT_MODULE_CONTROL_ADVISE control will only take effect it they change the result to be "less strict".
- * @LIBPOLKIT_MODULE_CONTROL_MANDATORY: Always use results (unless it returns
- * #LIBPOLKIT_RESULT_UNKNOWN_ACTION for a given request) from this module, even if it changes whether the
+ * the #POLKIT_MODULE_CONTROL_ADVISE control will only take effect it they change the result to be "less strict".
+ * @POLKIT_MODULE_CONTROL_MANDATORY: Always use results (unless it returns
+ * #POLKIT_RESULT_UNKNOWN_ACTION for a given request) from this module, even if it changes whether the
* result to be "more strict". . If a later module also uses this control, results from that module will override it.
- * @LIBPOLKIT_MODULE_CONTROL_N_CONTROLS: Number of control stanzas
+ * @POLKIT_MODULE_CONTROL_N_CONTROLS: Number of control stanzas
*
* The control stanza for a PolicyKit module. This is read from the
* PolicyKit configuration file (/etc/PolicyKit/PolicyKit.conf) that
**/
typedef enum
{
- LIBPOLKIT_MODULE_CONTROL_ADVISE,
- LIBPOLKIT_MODULE_CONTROL_MANDATORY,
- LIBPOLKIT_MODULE_CONTROL_N_CONTROLS
+ POLKIT_MODULE_CONTROL_ADVISE,
+ POLKIT_MODULE_CONTROL_MANDATORY,
+ POLKIT_MODULE_CONTROL_N_CONTROLS
} PolKitModuleControl;
const char *
-libpolkit_module_control_to_string_representation (PolKitModuleControl module_control);
+polkit_module_control_to_string_representation (PolKitModuleControl module_control);
polkit_bool_t
-libpolkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control);
+polkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control);
-PolKitModuleInterface *libpolkit_module_interface_load_module (const char *name,
+PolKitModuleInterface *polkit_module_interface_load_module (const char *name,
PolKitModuleControl module_control,
int argc, char *argv[]);
-PolKitModuleControl libpolkit_module_interface_get_control (PolKitModuleInterface *module_interface);
+PolKitModuleControl polkit_module_interface_get_control (PolKitModuleInterface *module_interface);
polkit_bool_t
-libpolkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
+polkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitSession *session);
polkit_bool_t
-libpolkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
+polkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
PolKitContext *pk_context,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller);
-#endif /* LIBPOLKIT_MODULE_H */
+#endif /* POLKIT_MODULE_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-cache.c : policy cache
+ * polkit-policy-cache.c : policy cache
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-policy-file.h"
-#include "libpolkit-policy-cache.h"
+#include "polkit-debug.h"
+#include "polkit-policy-file.h"
+#include "polkit-policy-cache.h"
/**
- * SECTION:libpolkit-policy-cache
+ * SECTION:polkit-policy-cache
* @short_description: Class for holding all policy objects.
*
* This class is used to hold all policy objects (stemming from policy
{
PolKitPolicyCache *policy_cache = user_data;
- libpolkit_policy_file_entry_ref (policy_file_entry);
+ polkit_policy_file_entry_ref (policy_file_entry);
policy_cache->priv_entries = g_slist_append (policy_cache->priv_entries, policy_file_entry);
}
/**
- * libpolkit_policy_cache_new:
+ * polkit_policy_cache_new:
* @dirname: directory containing policy files
* @error: location to return error
*
* Returns: #NULL if @error was set, otherwise the #PolKitPolicyCache object
**/
PolKitPolicyCache *
-libpolkit_policy_cache_new (const char *dirname, PolKitError **error)
+polkit_policy_cache_new (const char *dirname, PolKitError **error)
{
const char *file;
GDir *dir;
path = g_strdup_printf ("%s/%s", dirname, file);
_pk_debug ("Loading %s", path);
- pf = libpolkit_policy_file_new (path, error);
+ pf = polkit_policy_file_new (path, error);
g_free (path);
if (pf == NULL) {
}
/* steal entries */
- libpolkit_policy_file_entry_foreach (pf, _append_entry, pc);
- libpolkit_policy_file_unref (pf);
+ polkit_policy_file_entry_foreach (pf, _append_entry, pc);
+ polkit_policy_file_unref (pf);
}
g_dir_close (dir);
return pc;
out:
if (pc != NULL)
- libpolkit_policy_cache_ref (pc);
+ polkit_policy_cache_ref (pc);
return NULL;
}
/**
- * libpolkit_policy_cache_ref:
+ * polkit_policy_cache_ref:
* @policy_cache: the policy cache object
*
* Increase reference count.
* Returns: the object
**/
PolKitPolicyCache *
-libpolkit_policy_cache_ref (PolKitPolicyCache *policy_cache)
+polkit_policy_cache_ref (PolKitPolicyCache *policy_cache)
{
g_return_val_if_fail (policy_cache != NULL, policy_cache);
policy_cache->refcount++;
}
/**
- * libpolkit_policy_cache_unref:
+ * polkit_policy_cache_unref:
* @policy_cache: the policy cache object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_policy_cache_unref (PolKitPolicyCache *policy_cache)
+polkit_policy_cache_unref (PolKitPolicyCache *policy_cache)
{
GSList *i;
for (i = policy_cache->priv_entries; i != NULL; i = g_slist_next (i)) {
PolKitPolicyFileEntry *pfe = i->data;
- libpolkit_policy_file_entry_unref (pfe);
+ polkit_policy_file_entry_unref (pfe);
}
if (policy_cache->priv_entries != NULL)
g_slist_free (policy_cache->priv_entries);
}
/**
- * libpolkit_policy_cache_debug:
+ * polkit_policy_cache_debug:
* @policy_cache: the cache
*
* Print debug information about object
**/
void
-libpolkit_policy_cache_debug (PolKitPolicyCache *policy_cache)
+polkit_policy_cache_debug (PolKitPolicyCache *policy_cache)
{
GSList *i;
g_return_if_fail (policy_cache != NULL);
for (i = policy_cache->priv_entries; i != NULL; i = g_slist_next (i)) {
PolKitPolicyFileEntry *pfe = i->data;
- libpolkit_policy_file_entry_debug (pfe);
+ polkit_policy_file_entry_debug (pfe);
}
}
/**
- * libpolkit_policy_cache_get_entry:
+ * polkit_policy_cache_get_entry:
* @policy_cache: the cache
* @action: the action
*
* this object.
**/
PolKitPolicyFileEntry*
-libpolkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache,
+polkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache,
PolKitAction *action)
{
char *priv_id;
g_return_val_if_fail (policy_cache != NULL, NULL);
g_return_val_if_fail (action != NULL, NULL);
- if (!libpolkit_action_get_action_id (action, &priv_id))
+ if (!polkit_action_get_action_id (action, &priv_id))
goto out;
for (i = policy_cache->priv_entries; i != NULL; i = g_slist_next (i)) {
pfe = i->data;
- if (strcmp (libpolkit_policy_file_entry_get_id (pfe), priv_id) == 0) {
+ if (strcmp (polkit_policy_file_entry_get_id (pfe), priv_id) == 0) {
goto out;
}
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-cache.h : policy cache
+ * polkit-policy-cache.h : policy cache
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_POLICY_CACHE_H
-#define LIBPOLKIT_POLICY_CACHE_H
+#ifndef POLKIT_POLICY_CACHE_H
+#define POLKIT_POLICY_CACHE_H
-#include <libpolkit/libpolkit-error.h>
-#include <libpolkit/libpolkit-action.h>
-#include <libpolkit/libpolkit-policy-file-entry.h>
+#include <polkit/polkit-error.h>
+#include <polkit/polkit-action.h>
+#include <polkit/polkit-policy-file-entry.h>
struct PolKitPolicyCache;
typedef struct PolKitPolicyCache PolKitPolicyCache;
-PolKitPolicyCache *libpolkit_policy_cache_new (const char *dirname, PolKitError **error);
-PolKitPolicyCache *libpolkit_policy_cache_ref (PolKitPolicyCache *policy_cache);
-void libpolkit_policy_cache_unref (PolKitPolicyCache *policy_cache);
-void libpolkit_policy_cache_debug (PolKitPolicyCache *policy_cache);
+PolKitPolicyCache *polkit_policy_cache_new (const char *dirname, PolKitError **error);
+PolKitPolicyCache *polkit_policy_cache_ref (PolKitPolicyCache *policy_cache);
+void polkit_policy_cache_unref (PolKitPolicyCache *policy_cache);
+void polkit_policy_cache_debug (PolKitPolicyCache *policy_cache);
-PolKitPolicyFileEntry* libpolkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache,
+PolKitPolicyFileEntry* polkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache,
PolKitAction *action);
-#endif /* LIBPOLKIT_POLICY_CACHE_H */
+#endif /* POLKIT_POLICY_CACHE_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-default.c : policy definition for the defaults
+ * polkit-policy-default.c : policy definition for the defaults
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-error.h"
-#include "libpolkit-policy-default.h"
+#include "polkit-debug.h"
+#include "polkit-error.h"
+#include "polkit-policy-default.h"
/**
- * SECTION:libpolkit-policy-default
+ * SECTION:polkit-policy-default
* @short_description: Defaults policy.
*
* This class records the default policy of an action.
{
gboolean ret;
- ret = libpolkit_result_from_string_representation (s, target);
+ ret = polkit_result_from_string_representation (s, target);
if (!ret) {
int n;
char *s2;
GString *str;
str = g_string_new (NULL);
- for (n = 0; n < LIBPOLKIT_RESULT_N_RESULTS; n++) {
- if (n == LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW)
+ for (n = 0; n < POLKIT_RESULT_N_RESULTS; n++) {
+ if (n == POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW)
continue;
if (str->len > 0) {
g_string_append (str, ", ");
}
- g_string_append (str, libpolkit_result_to_string_representation (n));
+ g_string_append (str, polkit_result_to_string_representation (n));
}
s2 = g_string_free (str, FALSE);
return ret;
}
-extern PolKitPolicyDefault *_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
+extern PolKitPolicyDefault *_polkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
PolKitPolicyDefault *
-_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error)
+_polkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error)
{
const char *key;
const char *group;
}
if (pd != NULL)
- libpolkit_policy_default_ref (pd);
+ polkit_policy_default_ref (pd);
return NULL;
}
/**
- * libpolkit_policy_default_ref:
+ * polkit_policy_default_ref:
* @policy_default: the policy object
*
* Increase reference count.
* Returns: the object
**/
PolKitPolicyDefault *
-libpolkit_policy_default_ref (PolKitPolicyDefault *policy_default)
+polkit_policy_default_ref (PolKitPolicyDefault *policy_default)
{
g_return_val_if_fail (policy_default != NULL, policy_default);
policy_default->refcount++;
}
/**
- * libpolkit_policy_default_unref:
+ * polkit_policy_default_unref:
* @policy_default: the object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_policy_default_unref (PolKitPolicyDefault *policy_default)
+polkit_policy_default_unref (PolKitPolicyDefault *policy_default)
{
g_return_if_fail (policy_default != NULL);
policy_default->refcount--;
}
/**
- * libpolkit_policy_default_debug:
+ * polkit_policy_default_debug:
* @policy_default: the object
*
* Print debug details
**/
void
-libpolkit_policy_default_debug (PolKitPolicyDefault *policy_default)
+polkit_policy_default_debug (PolKitPolicyDefault *policy_default)
{
g_return_if_fail (policy_default != NULL);
_pk_debug ("PolKitPolicyDefault: refcount=%d\n"
" default_local_inactive=%s\n"
" default_local_active=%s",
policy_default->refcount,
- libpolkit_result_to_string_representation (policy_default->default_remote_inactive),
- libpolkit_result_to_string_representation (policy_default->default_remote_active),
- libpolkit_result_to_string_representation (policy_default->default_local_inactive),
- libpolkit_result_to_string_representation (policy_default->default_local_active));
+ polkit_result_to_string_representation (policy_default->default_remote_inactive),
+ polkit_result_to_string_representation (policy_default->default_remote_active),
+ polkit_result_to_string_representation (policy_default->default_local_inactive),
+ polkit_result_to_string_representation (policy_default->default_local_active));
}
/**
- * libpolkit_policy_default_can_session_access_resource:
+ * polkit_policy_default_can_session_access_resource:
* @policy_default: the object
* @action: the type of access to check for
* @resource: the resource in question
* session can access a given resource in a given way.
*
* Returns: A #PolKitResult - can only be one of
- * #LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
- * #LIBPOLKIT_RESULT_YES, #LIBPOLKIT_RESULT_NO.
+ * #POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
+ * #POLKIT_RESULT_YES, #POLKIT_RESULT_NO.
**/
PolKitResult
-libpolkit_policy_default_can_session_access_resource (PolKitPolicyDefault *policy_default,
+polkit_policy_default_can_session_access_resource (PolKitPolicyDefault *policy_default,
PolKitAction *action,
PolKitResource *resource,
PolKitSession *session)
polkit_bool_t is_active;
PolKitResult ret;
- ret = LIBPOLKIT_RESULT_NO;
+ ret = POLKIT_RESULT_NO;
g_return_val_if_fail (policy_default != NULL, ret);
g_return_val_if_fail (action != NULL, ret);
g_return_val_if_fail (session != NULL, ret);
- if (!libpolkit_session_get_ck_is_local (session, &is_local))
+ if (!polkit_session_get_ck_is_local (session, &is_local))
goto out;
- if (!libpolkit_session_get_ck_is_active (session, &is_active))
+ if (!polkit_session_get_ck_is_active (session, &is_active))
goto out;
if (is_local) {
}
/**
- * libpolkit_policy_default_can_caller_access_resource:
+ * polkit_policy_default_can_caller_access_resource:
* @policy_default: the object
* @action: the type of access to check for
* @resource: the resource in question
* access the resource in the given way
**/
PolKitResult
-libpolkit_policy_default_can_caller_access_resource (PolKitPolicyDefault *policy_default,
+polkit_policy_default_can_caller_access_resource (PolKitPolicyDefault *policy_default,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller)
PolKitSession *session;
PolKitResult ret;
- ret = LIBPOLKIT_RESULT_NO;
+ ret = POLKIT_RESULT_NO;
g_return_val_if_fail (policy_default != NULL, ret);
g_return_val_if_fail (action != NULL, ret);
g_return_val_if_fail (caller != NULL, ret);
- if (!libpolkit_caller_get_ck_session (caller, &session))
+ if (!polkit_caller_get_ck_session (caller, &session))
goto out;
if (session == NULL)
goto out;
- if (!libpolkit_session_get_ck_is_local (session, &is_local))
+ if (!polkit_session_get_ck_is_local (session, &is_local))
goto out;
- if (!libpolkit_session_get_ck_is_active (session, &is_active))
+ if (!polkit_session_get_ck_is_active (session, &is_active))
goto out;
if (is_local) {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-default.h : policy definition for the defaults
+ * polkit-policy-default.h : policy definition for the defaults
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_POLICY_DEFAULT_H
-#define LIBPOLKIT_POLICY_DEFAULT_H
+#ifndef POLKIT_POLICY_DEFAULT_H
+#define POLKIT_POLICY_DEFAULT_H
-#include <libpolkit/libpolkit-result.h>
-#include <libpolkit/libpolkit-action.h>
-#include <libpolkit/libpolkit-resource.h>
-#include <libpolkit/libpolkit-session.h>
-#include <libpolkit/libpolkit-caller.h>
-#include <libpolkit/libpolkit-error.h>
+#include <polkit/polkit-result.h>
+#include <polkit/polkit-action.h>
+#include <polkit/polkit-resource.h>
+#include <polkit/polkit-session.h>
+#include <polkit/polkit-caller.h>
+#include <polkit/polkit-error.h>
struct PolKitPolicyDefault;
typedef struct PolKitPolicyDefault PolKitPolicyDefault;
-PolKitPolicyDefault *libpolkit_policy_default_ref (PolKitPolicyDefault *policy_default);
-void libpolkit_policy_default_unref (PolKitPolicyDefault *policy_default);
-void libpolkit_policy_default_debug (PolKitPolicyDefault *policy_default);
+PolKitPolicyDefault *polkit_policy_default_ref (PolKitPolicyDefault *policy_default);
+void polkit_policy_default_unref (PolKitPolicyDefault *policy_default);
+void polkit_policy_default_debug (PolKitPolicyDefault *policy_default);
-PolKitResult libpolkit_policy_default_can_session_access_resource (PolKitPolicyDefault *policy_default,
+PolKitResult polkit_policy_default_can_session_access_resource (PolKitPolicyDefault *policy_default,
PolKitAction *action,
PolKitResource *resource,
PolKitSession *session);
-PolKitResult libpolkit_policy_default_can_caller_access_resource (PolKitPolicyDefault *policy_default,
+PolKitResult polkit_policy_default_can_caller_access_resource (PolKitPolicyDefault *policy_default,
PolKitAction *action,
PolKitResource *resource,
PolKitCaller *caller);
/* TODO: export knobs for "default policy" */
-#endif /* LIBPOLKIT_POLICY_DEFAULT_H */
+#endif /* POLKIT_POLICY_DEFAULT_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-file-entry.c : entries in policy files
+ * polkit-policy-file-entry.c : entries in policy files
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-error.h"
-#include "libpolkit-result.h"
-#include "libpolkit-policy-file-entry.h"
+#include "polkit-debug.h"
+#include "polkit-error.h"
+#include "polkit-result.h"
+#include "polkit-policy-file-entry.h"
/**
- * SECTION:libpolkit-policy-file-entry
+ * SECTION:polkit-policy-file-entry
* @short_description: Policy files entries.
*
* This class is used to represent a entries in policy files.
};
PolKitPolicyFileEntry *
-_libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error);
+_polkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error);
-extern PolKitPolicyDefault *_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
+extern PolKitPolicyDefault *_polkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
extern PolKitPolicyFileEntry *
-_libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error)
+_polkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error)
{
PolKitPolicyFileEntry *pfe;
pfe->refcount = 1;
pfe->action = g_strdup (action);
- pfe->defaults = _libpolkit_policy_default_new (key_file, action, error);
+ pfe->defaults = _polkit_policy_default_new (key_file, action, error);
if (pfe->defaults == NULL)
goto error;
return pfe;
error:
if (pfe != NULL)
- libpolkit_policy_file_entry_unref (pfe);
+ polkit_policy_file_entry_unref (pfe);
return NULL;
}
/**
- * libpolkit_policy_file_entry_ref:
+ * polkit_policy_file_entry_ref:
* @policy_file_entry: the policy file object
*
* Increase reference count.
* Returns: the object
**/
PolKitPolicyFileEntry *
-libpolkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry)
+polkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry)
{
g_return_val_if_fail (policy_file_entry != NULL, policy_file_entry);
policy_file_entry->refcount++;
}
/**
- * libpolkit_policy_file_entry_unref:
+ * polkit_policy_file_entry_unref:
* @policy_file_entry: the policy file object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry)
+polkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry)
{
g_return_if_fail (policy_file_entry != NULL);
policy_file_entry->refcount--;
return;
g_free (policy_file_entry->action);
if (policy_file_entry->defaults != NULL)
- libpolkit_policy_default_unref (policy_file_entry->defaults);
+ polkit_policy_default_unref (policy_file_entry->defaults);
g_free (policy_file_entry);
}
/**
- * libpolkit_policy_file_entry_debug:
+ * polkit_policy_file_entry_debug:
* @policy_file_entry: the entry
*
* Print debug information about object
**/
void
-libpolkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry)
+polkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry)
{
g_return_if_fail (policy_file_entry != NULL);
_pk_debug ("PolKitPolicyFileEntry: refcount=%d action=%s",
policy_file_entry->refcount,
policy_file_entry->action);
- libpolkit_policy_default_debug (policy_file_entry->defaults);
+ polkit_policy_default_debug (policy_file_entry->defaults);
}
/**
- * libpolkit_policy_file_entry_get_id:
+ * polkit_policy_file_entry_get_id:
* @policy_file_entry: the file entry
*
* Get the action identifier.
* Returns: A string - caller shall not free this string.
**/
const char *
-libpolkit_policy_file_entry_get_id (PolKitPolicyFileEntry *policy_file_entry)
+polkit_policy_file_entry_get_id (PolKitPolicyFileEntry *policy_file_entry)
{
g_return_val_if_fail (policy_file_entry != NULL, NULL);
return policy_file_entry->action;
}
/**
- * libpolkit_policy_file_entry_get_default:
+ * polkit_policy_file_entry_get_default:
* @policy_file_entry: the file entry
*
* Get the the default policy for this policy.
* Returns: A #PolKitPolicyDefault object - caller shall not unref this object.
**/
PolKitPolicyDefault *
-libpolkit_policy_file_entry_get_default (PolKitPolicyFileEntry *policy_file_entry)
+polkit_policy_file_entry_get_default (PolKitPolicyFileEntry *policy_file_entry)
{
g_return_val_if_fail (policy_file_entry != NULL, NULL);
return policy_file_entry->defaults;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-file-entry.h : entries in policy files
+ * polkit-policy-file-entry.h : entries in policy files
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_POLICY_FILE_ENTRY_H
-#define LIBPOLKIT_POLICY_FILE_ENTRY_H
+#ifndef POLKIT_POLICY_FILE_ENTRY_H
+#define POLKIT_POLICY_FILE_ENTRY_H
-#include <libpolkit/libpolkit-result.h>
-#include <libpolkit/libpolkit-policy-default.h>
+#include <polkit/polkit-result.h>
+#include <polkit/polkit-policy-default.h>
struct PolKitPolicyFileEntry;
typedef struct PolKitPolicyFileEntry PolKitPolicyFileEntry;
-PolKitPolicyFileEntry *libpolkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry);
-void libpolkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry);
-void libpolkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry);
+PolKitPolicyFileEntry *polkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry);
+void polkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry);
+void polkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry);
-const char *libpolkit_policy_file_entry_get_id (PolKitPolicyFileEntry *policy_file_entry);
-PolKitPolicyDefault *libpolkit_policy_file_entry_get_default (PolKitPolicyFileEntry *policy_file_entry);
+const char *polkit_policy_file_entry_get_id (PolKitPolicyFileEntry *policy_file_entry);
+PolKitPolicyDefault *polkit_policy_file_entry_get_default (PolKitPolicyFileEntry *policy_file_entry);
-#endif /* LIBPOLKIT_POLICY_FILE_ENTRY_H */
+#endif /* POLKIT_POLICY_FILE_ENTRY_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-file.c : policy files
+ * polkit-policy-file.c : policy files
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-error.h"
-#include "libpolkit-result.h"
-#include "libpolkit-policy-file.h"
-#include "libpolkit-policy-file-entry.h"
+#include "polkit-error.h"
+#include "polkit-result.h"
+#include "polkit-policy-file.h"
+#include "polkit-policy-file-entry.h"
/**
- * SECTION:libpolkit-policy-file
+ * SECTION:polkit-policy-file
* @short_description: Policy files.
*
* This class is used to represent a policy files.
GSList *entries;
};
-extern PolKitPolicyFileEntry *_libpolkit_policy_file_entry_new (GKeyFile *keyfile,
+extern PolKitPolicyFileEntry *_polkit_policy_file_entry_new (GKeyFile *keyfile,
const char *action,
PolKitError **error);
/**
- * libpolkit_policy_file_new:
+ * polkit_policy_file_new:
* @path: path to policy file
* @error: return location for error
*
* Returns: the new object or #NULL if error is set
**/
PolKitPolicyFile *
-libpolkit_policy_file_new (const char *path, PolKitError **error)
+polkit_policy_file_new (const char *path, PolKitError **error)
{
GKeyFile *key_file;
PolKitPolicyFile *pf;
goto error;
}
- pfe = _libpolkit_policy_file_entry_new (key_file, action, error);
+ pfe = _polkit_policy_file_entry_new (key_file, action, error);
if (pfe == NULL)
goto error;
pf->entries = g_slist_prepend (pf->entries, pfe);
if (key_file != NULL)
g_key_file_free (key_file);
if (pf != NULL)
- libpolkit_policy_file_unref (pf);
+ polkit_policy_file_unref (pf);
return NULL;
}
/**
- * libpolkit_policy_file_ref:
+ * polkit_policy_file_ref:
* @policy_file: the policy file object
*
* Increase reference count.
* Returns: the object
**/
PolKitPolicyFile *
-libpolkit_policy_file_ref (PolKitPolicyFile *policy_file)
+polkit_policy_file_ref (PolKitPolicyFile *policy_file)
{
g_return_val_if_fail (policy_file != NULL, policy_file);
policy_file->refcount++;
}
/**
- * libpolkit_policy_file_unref:
+ * polkit_policy_file_unref:
* @policy_file: the policy file object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_policy_file_unref (PolKitPolicyFile *policy_file)
+polkit_policy_file_unref (PolKitPolicyFile *policy_file)
{
GSList *i;
g_return_if_fail (policy_file != NULL);
if (policy_file->refcount > 0)
return;
for (i = policy_file->entries; i != NULL; i = g_slist_next (i)) {
- libpolkit_policy_file_entry_unref (i->data);
+ polkit_policy_file_entry_unref (i->data);
}
if (policy_file->entries != NULL)
g_slist_free (policy_file->entries);
}
/**
- * libpolkit_policy_file_entry_foreach:
+ * polkit_policy_file_entry_foreach:
* @policy_file: the policy file object
* @cb: callback to invoke for each entry
* @user_data: user data
* Visits all entries in a policy file.
**/
void
-libpolkit_policy_file_entry_foreach (PolKitPolicyFile *policy_file,
+polkit_policy_file_entry_foreach (PolKitPolicyFile *policy_file,
PolKitPolicyFileEntryForeachFunc cb,
void *user_data)
{
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-policy-file.h : policy files
+ * polkit-policy-file.h : policy files
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_POLICY_FILE_H
-#define LIBPOLKIT_POLICY_FILE_H
+#ifndef POLKIT_POLICY_FILE_H
+#define POLKIT_POLICY_FILE_H
-#include <libpolkit/libpolkit-error.h>
-#include <libpolkit/libpolkit-policy-file-entry.h>
+#include <polkit/polkit-error.h>
+#include <polkit/polkit-policy-file-entry.h>
struct PolKitPolicyFile;
typedef struct PolKitPolicyFile PolKitPolicyFile;
* @policy_file_entry: the entry
* @user_data: user data
*
- * Type for function used in libpolkit_policy_file_entry_foreach().
+ * Type for function used in polkit_policy_file_entry_foreach().
**/
typedef void (*PolKitPolicyFileEntryForeachFunc) (PolKitPolicyFile *policy_file,
PolKitPolicyFileEntry *policy_file_entry,
void *user_data);
-PolKitPolicyFile *libpolkit_policy_file_new (const char *path, PolKitError **error);
-PolKitPolicyFile *libpolkit_policy_file_ref (PolKitPolicyFile *policy_file);
-void libpolkit_policy_file_unref (PolKitPolicyFile *policy_file);
-void libpolkit_policy_file_entry_foreach (PolKitPolicyFile *policy_file,
+PolKitPolicyFile *polkit_policy_file_new (const char *path, PolKitError **error);
+PolKitPolicyFile *polkit_policy_file_ref (PolKitPolicyFile *policy_file);
+void polkit_policy_file_unref (PolKitPolicyFile *policy_file);
+void polkit_policy_file_entry_foreach (PolKitPolicyFile *policy_file,
PolKitPolicyFileEntryForeachFunc cb,
void *user_data);
-#endif /* LIBPOLKIT_POLICY_FILE_H */
+#endif /* POLKIT_POLICY_FILE_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-resource.c : resources
+ * polkit-resource.c : resources
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-resource.h"
-#include "libpolkit-utils.h"
+#include "polkit-debug.h"
+#include "polkit-resource.h"
+#include "polkit-utils.h"
/**
- * SECTION:libpolkit-resource
+ * SECTION:polkit-resource
* @short_description: Resources.
*
* This class is used to represent a resource. TODO: describe what a resource really is.
};
/**
- * libpolkit_resource_new:
+ * polkit_resource_new:
*
* Create a new #PolKitResource object.
*
* Returns: the new object
**/
PolKitResource *
-libpolkit_resource_new (void)
+polkit_resource_new (void)
{
PolKitResource *resource;
resource = g_new0 (PolKitResource, 1);
}
/**
- * libpolkit_resource_ref:
+ * polkit_resource_ref:
* @resource: the resource object
*
* Increase reference count
* Returns: the object
**/
PolKitResource *
-libpolkit_resource_ref (PolKitResource *resource)
+polkit_resource_ref (PolKitResource *resource)
{
g_return_val_if_fail (resource != NULL, resource);
resource->refcount++;
/**
- * libpolkit_resource_unref:
+ * polkit_resource_unref:
* @resource: the resource object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_resource_unref (PolKitResource *resource)
+polkit_resource_unref (PolKitResource *resource)
{
g_return_if_fail (resource != NULL);
/**
- * libpolkit_resource_set_resource_type:
+ * polkit_resource_set_resource_type:
* @resource: the resource object
* @resource_type: type of resource
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_resource_set_resource_type (PolKitResource *resource, const char *resource_type)
+polkit_resource_set_resource_type (PolKitResource *resource, const char *resource_type)
{
g_return_val_if_fail (resource != NULL, FALSE);
g_return_val_if_fail (_pk_validate_identifier (resource_type), FALSE);
}
/**
- * libpolkit_resource_set_resource_id:
+ * polkit_resource_set_resource_id:
* @resource: the resource object
* @resource_id: identifier of resource
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_resource_set_resource_id (PolKitResource *resource, const char *resource_id)
+polkit_resource_set_resource_id (PolKitResource *resource, const char *resource_id)
{
g_return_val_if_fail (resource != NULL, FALSE);
g_return_val_if_fail (_pk_validate_identifier (resource_id), FALSE);
}
/**
- * libpolkit_resource_get_resource_type:
+ * polkit_resource_get_resource_type:
* @resource: the resource object
* @out_resource_type: Returns the resource type. The caller shall not free this string.
*
* Returns: TRUE iff the value was returned.
**/
polkit_bool_t
-libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type)
+polkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type)
{
g_return_val_if_fail (resource != NULL, FALSE);
g_return_val_if_fail (out_resource_type != NULL, FALSE);
}
/**
- * libpolkit_resource_get_resource_id:
+ * polkit_resource_get_resource_id:
* @resource: the resource object
* @out_resource_id: Returns the resource identifier. The caller shall not free this string.
*
* Returns: TRUE iff the value was returned.
**/
polkit_bool_t
-libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
+polkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
{
g_return_val_if_fail (resource != NULL, FALSE);
g_return_val_if_fail (out_resource_id != NULL, FALSE);
}
/**
- * libpolkit_resource_debug:
+ * polkit_resource_debug:
* @resource: the object
*
* Print debug details
**/
void
-libpolkit_resource_debug (PolKitResource *resource)
+polkit_resource_debug (PolKitResource *resource)
{
g_return_if_fail (resource != NULL);
_pk_debug ("PolKitResource: refcount=%d type=%s id=%s", resource->refcount, resource->type, resource->id);
}
/**
- * libpolkit_resource_validate:
+ * polkit_resource_validate:
* @resource: the object
*
* Validate the object
* Returns: #TRUE iff the object is valid.
**/
polkit_bool_t
-libpolkit_resource_validate (PolKitResource *resource)
+polkit_resource_validate (PolKitResource *resource)
{
g_return_val_if_fail (resource != NULL, FALSE);
g_return_val_if_fail (resource->type != NULL, FALSE);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-resource.h : resources
+ * polkit-resource.h : resources
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_RESOURCE_H
-#define LIBPOLKIT_RESOURCE_H
+#ifndef POLKIT_RESOURCE_H
+#define POLKIT_RESOURCE_H
-#include <libpolkit/libpolkit-types.h>
+#include <polkit/polkit-types.h>
struct PolKitResource;
typedef struct PolKitResource PolKitResource;
-PolKitResource *libpolkit_resource_new (void);
-PolKitResource *libpolkit_resource_ref (PolKitResource *resource);
-void libpolkit_resource_unref (PolKitResource *resource);
-polkit_bool_t libpolkit_resource_set_resource_type (PolKitResource *resource, const char *resource_type);
-polkit_bool_t libpolkit_resource_set_resource_id (PolKitResource *resource, const char *resource_id);
-polkit_bool_t libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type);
-polkit_bool_t libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id);
+PolKitResource *polkit_resource_new (void);
+PolKitResource *polkit_resource_ref (PolKitResource *resource);
+void polkit_resource_unref (PolKitResource *resource);
+polkit_bool_t polkit_resource_set_resource_type (PolKitResource *resource, const char *resource_type);
+polkit_bool_t polkit_resource_set_resource_id (PolKitResource *resource, const char *resource_id);
+polkit_bool_t polkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type);
+polkit_bool_t polkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id);
-void libpolkit_resource_debug (PolKitResource *resource);
+void polkit_resource_debug (PolKitResource *resource);
-polkit_bool_t libpolkit_resource_validate (PolKitResource *resource);
+polkit_bool_t polkit_resource_validate (PolKitResource *resource);
-#endif /* LIBPOLKIT_RESOURCE_H */
+#endif /* POLKIT_RESOURCE_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-result.c : result codes from PolicyKit
+ * polkit-result.c : result codes from PolicyKit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
/**
- * SECTION:libpolkit-result
+ * SECTION:polkit-result
* @short_description: Result of PolicyKit queries
*
* These functions are used to manipulate PolicyKit results.
#include <errno.h>
#include <glib.h>
-#include "libpolkit-result.h"
+#include "polkit-result.h"
static const struct {
const char *str;
} mapping[] =
{
- {LIBPOLKIT_RESULT_UNKNOWN_ACTION, "unknown"},
- {LIBPOLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW, "not_authorized"},
- {LIBPOLKIT_RESULT_NO, "no"},
- {LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH, "auth_root"},
- {LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION, "auth_root_keep_session"},
- {LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS, "auth_root_keep_always"},
- {LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH, "auth_self"},
- {LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION, "auth_self_keep_session"},
- {LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS, "auth_self_keep_always"},
- {LIBPOLKIT_RESULT_YES, "yes"},
+ {POLKIT_RESULT_UNKNOWN_ACTION, "unknown"},
+ {POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW, "not_authorized"},
+ {POLKIT_RESULT_NO, "no"},
+ {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH, "auth_root"},
+ {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION, "auth_root_keep_session"},
+ {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS, "auth_root_keep_always"},
+ {POLKIT_RESULT_ONLY_VIA_SELF_AUTH, "auth_self"},
+ {POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION, "auth_self_keep_session"},
+ {POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS, "auth_self_keep_always"},
+ {POLKIT_RESULT_YES, "yes"},
{0, NULL}
};
/**
- * libpolkit_result_to_string_representation:
+ * polkit_result_to_string_representation:
* @result: the given result to get a textual representation of
*
* Gives a textual representation of a #PolKitResult object.
* Returns: string representing the result (do not free) or #NULL if the given result is invalid
**/
const char *
-libpolkit_result_to_string_representation (PolKitResult result)
+polkit_result_to_string_representation (PolKitResult result)
{
- if (result < 0 || result >= LIBPOLKIT_RESULT_N_RESULTS) {
+ if (result < 0 || result >= POLKIT_RESULT_N_RESULTS) {
g_warning ("The passed result code, %d, is not valid", result);
return NULL;
}
}
/**
- * libpolkit_result_from_string_representation:
+ * polkit_result_from_string_representation:
* @string: textual representation of a #PolKitResult object
* @out_result: return location for #PolKitResult
*
* Returns: TRUE if the textual representation was valid, otherwise FALSE
**/
polkit_bool_t
-libpolkit_result_from_string_representation (const char *string, PolKitResult *out_result)
+polkit_result_from_string_representation (const char *string, PolKitResult *out_result)
{
int n;
g_return_val_if_fail (out_result != NULL, FALSE);
- for (n = 0; n < LIBPOLKIT_RESULT_N_RESULTS; n++) {
+ for (n = 0; n < POLKIT_RESULT_N_RESULTS; n++) {
if (mapping[n].str == NULL)
break;
if (strcmp (mapping[n].str, string) == 0) {
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * polkit-result.h : result codes from PolicyKit
+ *
+ * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ **************************************************************************/
+
+#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef POLKIT_RESULT_H
+#define POLKIT_RESULT_H
+
+#include <polkit/polkit-types.h>
+
+/**
+ * PolKitResult:
+ * @POLKIT_RESULT_UNKNOWN_ACTION: The passed action is unknown.
+ * @POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW: The caller of polkit is not sufficiently privilege to know the answer.
+ * @POLKIT_RESULT_NO: Access denied.
+ * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH: Access denied, but authentication of the caller as
+ * root will grant access to the resource... but the access isn't permanent
+ * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
+ * root will grant access to the resource for the remainder of the session
+ * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
+ * root will grant access to the resource in the future.
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH: Access denied, but authentication of the caller as
+ * himself will grant access to the resource... but the access isn't permanent
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
+ * himself will grant access to the resource for the remainder of the session
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
+ * himself will grant access to the resource in the future.
+ * @POLKIT_RESULT_YES: Access granted.
+ * @POLKIT_RESULT_N_RESULTS: Number of result codes
+ *
+ * Result codes from queries to PolicyKit. These are ordered and we
+ * say that a result A is "more strict" than a result B, if A has a
+ * lower numerical value. (e.g. #POLKIT_RESULT_NO is more strict
+ * than #POLKIT_RESULT_YES).
+ */
+typedef enum
+{
+ POLKIT_RESULT_UNKNOWN_ACTION,
+ POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
+ POLKIT_RESULT_NO,
+
+ POLKIT_RESULT_ONLY_VIA_ROOT_AUTH,
+ POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION,
+ POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS,
+
+ POLKIT_RESULT_ONLY_VIA_SELF_AUTH,
+ POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION,
+ POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS,
+
+ POLKIT_RESULT_YES,
+ POLKIT_RESULT_N_RESULTS
+} PolKitResult;
+
+const char *
+polkit_result_to_string_representation (PolKitResult result);
+
+polkit_bool_t
+polkit_result_from_string_representation (const char *string, PolKitResult *out_result);
+
+#endif /* POLKIT_RESULT_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-seat.c : seat
+ * polkit-seat.c : seat
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-seat.h"
-#include "libpolkit-utils.h"
+#include "polkit-debug.h"
+#include "polkit-seat.h"
+#include "polkit-utils.h"
/**
- * SECTION:libpolkit-seat
+ * SECTION:polkit-seat
* @short_description: Seats.
*
* This class is used to represent a seat. TODO: describe seat.
};
/**
- * libpolkit_seat_new:
+ * polkit_seat_new:
*
* Creates a new #PolKitSeat object.
*
* Returns: the new object
**/
PolKitSeat *
-libpolkit_seat_new (void)
+polkit_seat_new (void)
{
PolKitSeat *seat;
seat = g_new0 (PolKitSeat, 1);
}
/**
- * libpolkit_seat_ref:
+ * polkit_seat_ref:
* @seat: the seat object
*
* Increase reference count.
* Returns: the object
**/
PolKitSeat *
-libpolkit_seat_ref (PolKitSeat *seat)
+polkit_seat_ref (PolKitSeat *seat)
{
g_return_val_if_fail (seat != NULL, seat);
seat->refcount++;
}
/**
- * libpolkit_seat_unref:
+ * polkit_seat_unref:
* @seat: the seat object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_seat_unref (PolKitSeat *seat)
+polkit_seat_unref (PolKitSeat *seat)
{
g_return_if_fail (seat != NULL);
seat->refcount--;
}
/**
- * libpolkit_seat_set_ck_objref:
+ * polkit_seat_set_ck_objref:
* @seat: the seat object
* @ck_objref: the D-Bus object path to the ConsoleKit seat object
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
+polkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
{
g_return_val_if_fail (seat != NULL, FALSE);
g_return_val_if_fail (_pk_validate_identifier (ck_objref), FALSE);
}
/**
- * libpolkit_seat_get_ck_objref:
+ * polkit_seat_get_ck_objref:
* @seat: the seat object
* @out_ck_objref: Returns the D-Bus object path to the ConsoleKit seat object. The caller shall not free this string.
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref)
+polkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref)
{
g_return_val_if_fail (seat != NULL, FALSE);
g_return_val_if_fail (out_ck_objref != NULL, FALSE);
}
/**
- * libpolkit_seat_debug:
+ * polkit_seat_debug:
* @seat: the object
*
* Print debug details
**/
void
-libpolkit_seat_debug (PolKitSeat *seat)
+polkit_seat_debug (PolKitSeat *seat)
{
g_return_if_fail (seat != NULL);
_pk_debug ("PolKitSeat: refcount=%d objpath=%s", seat->refcount, seat->ck_objref);
}
/**
- * libpolkit_seat_validate:
+ * polkit_seat_validate:
* @seat: the object
*
* Validate the object
* Returns: #TRUE iff the object is valid.
**/
polkit_bool_t
-libpolkit_seat_validate (PolKitSeat *seat)
+polkit_seat_validate (PolKitSeat *seat)
{
g_return_val_if_fail (seat != NULL, FALSE);
g_return_val_if_fail (seat->ck_objref != NULL, FALSE);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-seat.h : seats
+ * polkit-seat.h : seats
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_SEAT_H
-#define LIBPOLKIT_SEAT_H
+#ifndef POLKIT_SEAT_H
+#define POLKIT_SEAT_H
-#include <libpolkit/libpolkit-types.h>
+#include <polkit/polkit-types.h>
struct PolKitSeat;
typedef struct PolKitSeat PolKitSeat;
-PolKitSeat *libpolkit_seat_new (void);
-PolKitSeat *libpolkit_seat_ref (PolKitSeat *seat);
-void libpolkit_seat_unref (PolKitSeat *seat);
-polkit_bool_t libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref);
-polkit_bool_t libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref);
+PolKitSeat *polkit_seat_new (void);
+PolKitSeat *polkit_seat_ref (PolKitSeat *seat);
+void polkit_seat_unref (PolKitSeat *seat);
+polkit_bool_t polkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref);
+polkit_bool_t polkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref);
-void libpolkit_seat_debug (PolKitSeat *seat);
-polkit_bool_t libpolkit_seat_validate (PolKitSeat *seat);
+void polkit_seat_debug (PolKitSeat *seat);
+polkit_bool_t polkit_seat_validate (PolKitSeat *seat);
-#endif /* LIBPOLKIT_SEAT_H */
+#endif /* POLKIT_SEAT_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-session.c : sessions
+ * polkit-session.c : sessions
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <errno.h>
#include <glib.h>
-#include "libpolkit-debug.h"
-#include "libpolkit-session.h"
-#include "libpolkit-utils.h"
+#include "polkit-debug.h"
+#include "polkit-session.h"
+#include "polkit-utils.h"
/**
- * SECTION:libpolkit-session
+ * SECTION:polkit-session
* @short_description: Sessions.
*
* This class is used to represent a session. TODO: describe session.
};
/**
- * libpolkit_session_new:
+ * polkit_session_new:
*
* Creates a new #PolKitSession object.
*
* Returns: the new object
**/
PolKitSession *
-libpolkit_session_new (void)
+polkit_session_new (void)
{
PolKitSession *session;
session = g_new0 (PolKitSession, 1);
}
/**
- * libpolkit_session_ref:
+ * polkit_session_ref:
* @session: The session object
*
* Increase reference count.
* Returns: the object
**/
PolKitSession *
-libpolkit_session_ref (PolKitSession *session)
+polkit_session_ref (PolKitSession *session)
{
g_return_val_if_fail (session != NULL, session);
session->refcount++;
/**
- * libpolkit_session_unref:
+ * polkit_session_unref:
* @session: The session object
*
* Decreases the reference count of the object. If it becomes zero,
* objects are decresed by one.
**/
void
-libpolkit_session_unref (PolKitSession *session)
+polkit_session_unref (PolKitSession *session)
{
g_return_if_fail (session != NULL);
session->refcount--;
g_free (session->ck_objref);
g_free (session->remote_host);
if (session->seat != NULL)
- libpolkit_seat_unref (session->seat);
+ polkit_seat_unref (session->seat);
g_free (session);
}
/**
- * libpolkit_session_set_uid:
+ * polkit_session_set_uid:
* @session: The session object
* @uid: UNIX user id
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
+polkit_session_set_uid (PolKitSession *session, uid_t uid)
{
g_return_val_if_fail (session != NULL, FALSE);
session->uid = uid;
}
/**
- * libpolkit_session_set_ck_objref:
+ * polkit_session_set_ck_objref:
* @session: The session object
* @ck_objref: D-Bus object path
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref)
+polkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (_pk_validate_identifier (ck_objref), FALSE);
}
/**
- * libpolkit_session_set_ck_is_active:
+ * polkit_session_set_ck_is_active:
* @session: The session object
* @is_active: whether ConsoleKit reports the session as active
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_active)
+polkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_active)
{
g_return_val_if_fail (session != NULL, FALSE);
session->is_active = is_active;
}
/**
- * libpolkit_session_set_ck_is_local:
+ * polkit_session_set_ck_is_local:
* @session: The session object
* @is_local: whether ConsoleKit reports the session as local
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_local)
+polkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_local)
{
g_return_val_if_fail (session != NULL, FALSE);
session->is_local = is_local;
}
/**
- * libpolkit_session_set_ck_remote_host:
+ * polkit_session_set_ck_remote_host:
* @session: The session object
* @remote_host: hostname of the host/display that ConsoleKit reports
* the session to occur at
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host)
+polkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host)
{
g_return_val_if_fail (session != NULL, FALSE);
/* TODO: FIXME: probably need to allow a lot more here */
}
/**
- * libpolkit_session_set_seat:
+ * polkit_session_set_seat:
* @session: The session object
* @seat: a #PolKitSeat object
*
* Returns: #TRUE only if the value validated and was set
**/
polkit_bool_t
-libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat)
+polkit_session_set_seat (PolKitSession *session, PolKitSeat *seat)
{
g_return_val_if_fail (session != NULL, FALSE);
- g_return_val_if_fail (libpolkit_seat_validate (seat), FALSE);
+ g_return_val_if_fail (polkit_seat_validate (seat), FALSE);
if (session->seat != NULL)
- libpolkit_seat_unref (session->seat);
- session->seat = seat != NULL ? libpolkit_seat_ref (seat) : NULL;
+ polkit_seat_unref (session->seat);
+ session->seat = seat != NULL ? polkit_seat_ref (seat) : NULL;
return TRUE;
}
/**
- * libpolkit_session_get_uid:
+ * polkit_session_get_uid:
* @session: The session object
* @out_uid: UNIX user id
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
+polkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_uid != NULL, FALSE);
}
/**
- * libpolkit_session_get_ck_objref:
+ * polkit_session_get_ck_objref:
* @session: The session object
* @out_ck_objref: D-Bus object path. Shall not be freed by the caller.
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
+polkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_ck_objref != NULL, FALSE);
}
/**
- * libpolkit_session_get_ck_is_active:
+ * polkit_session_get_ck_is_active:
* @session: The session object
* @out_is_active: whether ConsoleKit reports the session as active
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_is_active)
+polkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_is_active)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_is_active != NULL, FALSE);
}
/**
- * libpolkit_session_get_ck_is_local:
+ * polkit_session_get_ck_is_local:
* @session: The session object
* @out_is_local: whether ConsoleKit reports the session as local
*
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is_local)
+polkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is_local)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_is_local != NULL, FALSE);
}
/**
- * libpolkit_session_get_ck_remote_host:
+ * polkit_session_get_ck_remote_host:
* @session: The session object
* @out_remote_host: hostname of the host/display that ConsoleKit
* reports the session to occur at. Shall not be freed by the caller.
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host)
+polkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_remote_host != NULL, FALSE);
}
/**
- * libpolkit_session_get_seat:
+ * polkit_session_get_seat:
* @session: The session object
* @out_seat: Returns the seat the session belongs to. Shall not
* be unreffed by the caller.
* Returns: TRUE iff the value is returned
**/
polkit_bool_t
-libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat)
+polkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat)
{
g_return_val_if_fail (session != NULL, FALSE);
g_return_val_if_fail (out_seat != NULL, FALSE);
}
/**
- * libpolkit_session_debug:
+ * polkit_session_debug:
* @session: the object
*
* Print debug details
**/
void
-libpolkit_session_debug (PolKitSession *session)
+polkit_session_debug (PolKitSession *session)
{
g_return_if_fail (session != NULL);
_pk_debug ("PolKitSession: refcount=%d uid=%d objpath=%s is_active=%d is_local=%d remote_host=%s",
session->refcount, session->uid,
session->ck_objref, session->is_active, session->is_local, session->remote_host);
if (session->seat != NULL)
- libpolkit_seat_debug (session->seat);
+ polkit_seat_debug (session->seat);
}
/**
- * libpolkit_session_validate:
+ * polkit_session_validate:
* @session: the object
*
* Validate the object
* Returns: #TRUE iff the object is valid.
**/
polkit_bool_t
-libpolkit_session_validate (PolKitSession *session)
+polkit_session_validate (PolKitSession *session)
{
polkit_bool_t ret;
g_return_val_if_fail (session != NULL, FALSE);
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * polkit-session.h : sessions
+ *
+ * Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ **************************************************************************/
+
+#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef POLKIT_SESSION_H
+#define POLKIT_SESSION_H
+
+#include <polkit/polkit-types.h>
+#include <polkit/polkit-seat.h>
+
+#include <sys/types.h>
+
+struct PolKitSession;
+typedef struct PolKitSession PolKitSession;
+
+PolKitSession *polkit_session_new (void);
+PolKitSession *polkit_session_ref (PolKitSession *session);
+void polkit_session_unref (PolKitSession *session);
+polkit_bool_t polkit_session_set_uid (PolKitSession *session, uid_t uid);
+polkit_bool_t polkit_session_set_seat (PolKitSession *session, PolKitSeat *seat);
+polkit_bool_t polkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref);
+polkit_bool_t polkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_active);
+polkit_bool_t polkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_local);
+polkit_bool_t polkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host);
+polkit_bool_t polkit_session_get_uid (PolKitSession *session, uid_t *out_uid);
+polkit_bool_t polkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat);
+polkit_bool_t polkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref);
+polkit_bool_t polkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_is_active);
+polkit_bool_t polkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is_local);
+polkit_bool_t polkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host);
+
+void polkit_session_debug (PolKitSession *session);
+polkit_bool_t polkit_session_validate (PolKitSession *session);
+
+#endif /* POLKIT_SESSION_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-types.h : fundamental types such as polkit_bool_t
+ * polkit-types.h : fundamental types such as polkit_bool_t
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
**************************************************************************/
#if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <libpolkit/libpolkit.h> can be included directly, this file may disappear or change contents."
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef LIBPOLKIT_TYPES_H
-#define LIBPOLKIT_TYPES_H
+#ifndef POLKIT_TYPES_H
+#define POLKIT_TYPES_H
/**
- * SECTION:libpolkit-types
+ * SECTION:polkit-types
* @short_description: Basic types.
*
* Typedefs for common primitive types.
# define FALSE 0
#endif
-#endif /* LIBPOLKIT_TYPES_H */
+#endif /* POLKIT_TYPES_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-utils.c : internal utilities used in libpolkit
+ * polkit-utils.c : internal utilities used in polkit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
#include <glib.h>
#include <string.h>
-#include "libpolkit-utils.h"
-#include "libpolkit-debug.h"
+#include "polkit-utils.h"
+#include "polkit-debug.h"
/**
- * SECTION:libpolkit-utils
- * @short_description: Internal utility functions for libpolkit.
+ * SECTION:polkit-utils
+ * @short_description: Internal utility functions for polkit.
*
- * Internal utility functions for libpolkit.
+ * Internal utility functions for polkit.
**/
/**
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit-utils.h : internal utilities used in libpolkit
+ * polkit-utils.h : internal utilities used in polkit
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
*
**************************************************************************/
-#ifndef LIBPOLKIT_UTILS_H
-#define LIBPOLKIT_UTILS_H
+#ifndef POLKIT_UTILS_H
+#define POLKIT_UTILS_H
-#include <libpolkit/libpolkit-types.h>
+#include <polkit/polkit-types.h>
polkit_bool_t _pk_validate_identifier (const char *identifier);
polkit_bool_t _pk_validate_unique_bus_name (const char *unique_bus_name);
-#endif /* LIBPOLKIT_UTILS_H */
+#endif /* POLKIT_UTILS_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
- * libpolkit.h : library for querying system-wide policy
+ * polkit.h : library for querying system-wide policy
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
*
**************************************************************************/
-#ifndef LIBPOLKIT_H
-#define LIBPOLKIT_H
+#ifndef POLKIT_H
+#define POLKIT_H
#define _POLKIT_INSIDE_POLKIT_H 1
-#include <libpolkit/libpolkit-types.h>
-#include <libpolkit/libpolkit-error.h>
-#include <libpolkit/libpolkit-result.h>
-#include <libpolkit/libpolkit-context.h>
-#include <libpolkit/libpolkit-action.h>
-#include <libpolkit/libpolkit-resource.h>
-#include <libpolkit/libpolkit-seat.h>
-#include <libpolkit/libpolkit-session.h>
-#include <libpolkit/libpolkit-caller.h>
-#include <libpolkit/libpolkit-policy-file-entry.h>
-#include <libpolkit/libpolkit-policy-file.h>
-#include <libpolkit/libpolkit-policy-cache.h>
-#include <libpolkit/libpolkit-policy-default.h>
-#include <libpolkit/libpolkit-module.h>
+#include <polkit/polkit-types.h>
+#include <polkit/polkit-error.h>
+#include <polkit/polkit-result.h>
+#include <polkit/polkit-context.h>
+#include <polkit/polkit-action.h>
+#include <polkit/polkit-resource.h>
+#include <polkit/polkit-seat.h>
+#include <polkit/polkit-session.h>
+#include <polkit/polkit-caller.h>
+#include <polkit/polkit-policy-file-entry.h>
+#include <polkit/polkit-policy-file.h>
+#include <polkit/polkit-policy-cache.h>
+#include <polkit/polkit-policy-default.h>
+#include <polkit/polkit-module.h>
#undef _POLKIT_INSIDE_POLKIT_H
-#endif /* LIBPOLKIT_H */
+#endif /* POLKIT_H */
bin_PROGRAMS = polkit-check-caller polkit-check-session polkit-policy-file-validate polkit-grant
polkit_check_caller_SOURCES = polkit-check-caller.c
-polkit_check_caller_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la
+polkit_check_caller_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/polkit/libpolkit.la $(top_builddir)/polkit-dbus/libpolkit-dbus.la
polkit_check_session_SOURCES = polkit-check-session.c
-polkit_check_session_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la
+polkit_check_session_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/polkit/libpolkit.la $(top_builddir)/polkit-dbus/libpolkit-dbus.la
polkit_policy_file_validate_SOURCES = polkit-policy-file-validate.c
-polkit_policy_file_validate_LDADD = $(top_builddir)/libpolkit/libpolkit.la
+polkit_policy_file_validate_LDADD = $(top_builddir)/polkit/libpolkit.la
polkit_grant_SOURCES = polkit-grant.c
-polkit_grant_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la $(top_builddir)/libpolkit-grant/libpolkit-grant.la $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la
+polkit_grant_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/polkit/libpolkit.la $(top_builddir)/polkit-grant/libpolkit-grant.la $(top_builddir)/polkit-dbus/libpolkit-dbus.la
clean-local :
rm -f *~
#include <unistd.h>
#include <errno.h>
-#include <libpolkit-dbus/libpolkit-dbus.h>
+#include <polkit-dbus/polkit-dbus.h>
#include <glib.h>
}
p_error = NULL;
- pol_ctx = libpolkit_context_new ();
- if (!libpolkit_context_init (pol_ctx, &p_error)) {
- fprintf (stderr, "error: libpolkit_context_init: %s\n", polkit_error_get_error_message (p_error));
+ pol_ctx = polkit_context_new ();
+ if (!polkit_context_init (pol_ctx, &p_error)) {
+ fprintf (stderr, "error: polkit_context_init: %s\n", polkit_error_get_error_message (p_error));
polkit_error_free (p_error);
return 1;
}
- action = libpolkit_action_new ();
- libpolkit_action_set_action_id (action, action_id);
+ action = polkit_action_new ();
+ polkit_action_set_action_id (action, action_id);
- resource = libpolkit_resource_new ();
- libpolkit_resource_set_resource_type (resource, resource_type);
- libpolkit_resource_set_resource_id (resource, resource_id);
+ resource = polkit_resource_new ();
+ polkit_resource_set_resource_type (resource, resource_type);
+ polkit_resource_set_resource_id (resource, resource_id);
- caller = libpolkit_caller_new_from_dbus_name (bus, dbus_name, &error);
+ caller = polkit_caller_new_from_dbus_name (bus, dbus_name, &error);
if (caller == NULL) {
if (dbus_error_is_set (&error)) {
- fprintf (stderr, "error: libpolkit_caller_new_from_dbus_name(): %s: %s\n",
+ fprintf (stderr, "error: polkit_caller_new_from_dbus_name(): %s: %s\n",
error.name, error.message);
return 1;
}
}
- allowed = libpolkit_context_can_caller_access_resource (pol_ctx, action, resource, caller);
+ allowed = polkit_context_can_caller_access_resource (pol_ctx, action, resource, caller);
if (allowed)
return 0;
#include <unistd.h>
#include <errno.h>
-#include <libpolkit-dbus/libpolkit-dbus.h>
+#include <polkit-dbus/polkit-dbus.h>
#include <glib.h>
}
p_error = NULL;
- pol_ctx = libpolkit_context_new ();
- if (!libpolkit_context_init (pol_ctx, &p_error)) {
- fprintf (stderr, "error: libpolkit_context_init: %s\n", polkit_error_get_error_message (p_error));
+ pol_ctx = polkit_context_new ();
+ if (!polkit_context_init (pol_ctx, &p_error)) {
+ fprintf (stderr, "error: polkit_context_init: %s\n", polkit_error_get_error_message (p_error));
polkit_error_free (p_error);
return 1;
}
if (session_id != NULL) {
- session = libpolkit_session_new_from_objpath (bus, session_id, -1, &error);
+ session = polkit_session_new_from_objpath (bus, session_id, -1, &error);
} else {
if (cookie == NULL) {
fprintf (stderr, "Not part of a session. Try --session instead.\n");
return 1;
}
- session = libpolkit_session_new_from_cookie (bus, cookie, &error);
+ session = polkit_session_new_from_cookie (bus, cookie, &error);
}
if (session == NULL) {
- fprintf (stderr, "error: libpolkit_session_new_from_objpath: %s: %s\n", error.name, error.message);
+ fprintf (stderr, "error: polkit_session_new_from_objpath: %s: %s\n", error.name, error.message);
return 1;
}
- action = libpolkit_action_new ();
- libpolkit_action_set_action_id (action, action_id);
+ action = polkit_action_new ();
+ polkit_action_set_action_id (action, action_id);
- resource = libpolkit_resource_new ();
- libpolkit_resource_set_resource_type (resource, resource_type);
- libpolkit_resource_set_resource_id (resource, resource_id);
+ resource = polkit_resource_new ();
+ polkit_resource_set_resource_type (resource, resource_type);
+ polkit_resource_set_resource_id (resource, resource_id);
- allowed = libpolkit_context_can_session_access_resource (pol_ctx, action, resource, session);
+ allowed = polkit_context_can_session_access_resource (pol_ctx, action, resource, session);
if (allowed)
return 0;
#include <errno.h>
#include <termios.h>
-#include <libpolkit-dbus/libpolkit-dbus.h>
-#include <libpolkit-grant/libpolkit-grant.h>
+#include <polkit-dbus/polkit-dbus.h>
+#include <polkit-grant/polkit-grant.h>
#include <glib.h>
conversation_type (PolKitGrant *polkit_grant, PolKitResult auth_type, void *user_data)
{
switch (auth_type) {
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
printf ("Authentication as root is required.\n");
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
printf ("Authentication is required.\n");
break;
PolKitResult overridden_auth_type;
switch (auth_type) {
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
printf ("Keep this privilege for the session? [no/session]?\n");
getline (&lineptr, &linelen, stdin);
if (g_str_has_prefix (lineptr, "no")) {
}
free (lineptr);
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
printf ("Keep this privilege for the session or always? [no/session/always]?\n");
getline (&lineptr, &linelen, stdin);
if (g_str_has_prefix (lineptr, "no")) {
}
switch (auth_type) {
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH;
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH;
if (keep_session)
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION;
else if (keep_always)
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS;
break;
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH;
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_SELF_AUTH;
if (keep_session)
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION;
else if (keep_always)
- overridden_auth_type = LIBPOLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS;
break;
default:
gpointer user_data)
{
PolKitGrant *polkit_grant = user_data;
- libpolkit_grant_child_func (polkit_grant, pid, WEXITSTATUS (status));
+ polkit_grant_child_func (polkit_grant, pid, WEXITSTATUS (status));
}
static int
int fd;
PolKitGrant *polkit_grant = user_data;
fd = g_io_channel_unix_get_fd (channel);
- libpolkit_grant_io_func (polkit_grant, fd);
+ polkit_grant_io_func (polkit_grant, fd);
return TRUE;
}
}
p_error = NULL;
- pol_ctx = libpolkit_context_new ();
- if (!libpolkit_context_init (pol_ctx, &p_error)) {
- fprintf (stderr, "error: libpolkit_context_init: %s\n", polkit_error_get_error_message (p_error));
+ pol_ctx = polkit_context_new ();
+ if (!polkit_context_init (pol_ctx, &p_error)) {
+ fprintf (stderr, "error: polkit_context_init: %s\n", polkit_error_get_error_message (p_error));
polkit_error_free (p_error);
goto error;
}
- action = libpolkit_action_new ();
- libpolkit_action_set_action_id (action, action_id);
+ action = polkit_action_new ();
+ polkit_action_set_action_id (action, action_id);
- resource = libpolkit_resource_new ();
- libpolkit_resource_set_resource_type (resource, resource_type);
- libpolkit_resource_set_resource_id (resource, resource_id);
+ resource = polkit_resource_new ();
+ polkit_resource_set_resource_type (resource, resource_type);
+ polkit_resource_set_resource_id (resource, resource_id);
- caller = libpolkit_caller_new_from_dbus_name (bus, dbus_bus_get_unique_name (bus), &error);
+ caller = polkit_caller_new_from_dbus_name (bus, dbus_bus_get_unique_name (bus), &error);
if (caller == NULL) {
if (dbus_error_is_set (&error)) {
- fprintf (stderr, "error: libpolkit_caller_new_from_dbus_name(): %s: %s\n",
+ fprintf (stderr, "error: polkit_caller_new_from_dbus_name(): %s: %s\n",
error.name, error.message);
goto error;
}
}
- polkit_grant = libpolkit_grant_new ();
- libpolkit_grant_set_functions (polkit_grant,
+ polkit_grant = polkit_grant_new ();
+ polkit_grant_set_functions (polkit_grant,
add_io_watch,
add_child_watch,
remove_watch,
conversation_done,
&ud);
- if (!libpolkit_grant_initiate_auth (polkit_grant,
+ if (!polkit_grant_initiate_auth (polkit_grant,
action,
resource,
caller)) {
goto error;
}
g_main_loop_run (ud.loop);
- libpolkit_grant_unref (polkit_grant);
+ polkit_grant_unref (polkit_grant);
printf ("Privilege grant done.. result=%d\n", ud.gained_privilege);
#include <unistd.h>
#include <errno.h>
-#include <libpolkit/libpolkit.h>
+#include <polkit/polkit.h>
static void
usage (int argc, char *argv[])
PolKitError *error;
error = NULL;
- priv_file = libpolkit_policy_file_new (file, &error);
+ priv_file = polkit_policy_file_new (file, &error);
if (priv_file == NULL) {
printf ("%s did not validate: %s\n", file, polkit_error_get_error_message (error));
polkit_error_free (error);
return FALSE;
}
- libpolkit_policy_file_unref (priv_file);
+ polkit_policy_file_unref (priv_file);
return TRUE;
}