From 36c1b7725fcb2339fcf9a87f5e5c984ef5be17cb Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Tue, 17 Apr 2007 01:41:09 -0400 Subject: [PATCH] rename libpolkit to polkit It's more consistent and, uhm, easier to type. --- Makefile.am | 12 +- configure.in | 29 +-- data/Makefile.am | 14 ++ .../polkit-dbus.pc.in | 0 .../polkit-grant.pc.in | 0 polkit.in => data/polkit.in | 0 libpolkit.pc.in => data/polkit.pc.in | 0 doc/api/Makefile.am | 2 +- .../{libpolkit => polkit-dbus}/Makefile.am | 16 +- .../polkit-dbus-docs.xml} | 2 +- .../polkit-dbus.types} | 0 .../version.xml.in | 0 .../Makefile.am | 16 +- .../polkit-grant-docs.xml} | 2 +- .../polkit-grant.types} | 0 .../version.xml.in | 0 .../{libpolkit-dbus => polkit}/Makefile.am | 22 +- .../polkit-docs.xml} | 30 ++- .../libpolkit.types => polkit/polkit.types} | 0 doc/api/{libpolkit => polkit}/version.xml.in | 0 libpolkit/Makefile.am | 62 ----- libpolkit/libpolkit-caller.h | 57 ----- libpolkit/libpolkit-result.h | 84 ------- libpolkit/libpolkit-session.h | 60 ----- modules/allow-all/Makefile.am | 2 +- modules/allow-all/polkit-module-allow-all.c | 20 +- modules/default/Makefile.am | 2 +- modules/default/polkit-module-default.c | 36 +-- modules/deny-all/Makefile.am | 2 +- modules/deny-all/polkit-module-deny-all.c | 20 +- modules/grant/Makefile.am | 2 +- modules/grant/polkit-module-grant.c | 42 ++-- modules/run-program/Makefile.am | 2 +- .../run-program/polkit-module-run-program.c | 60 ++--- {libpolkit-dbus => polkit-dbus}/Makefile.am | 8 +- .../polkit-dbus.c | 112 ++++----- .../polkit-dbus.h | 16 +- {libpolkit-grant => polkit-grant}/Makefile.am | 10 +- .../polkit-grant-helper.c | 108 ++++----- .../polkit-grant.c | 56 ++--- .../polkit-grant.h | 92 ++++---- {libpolkit => polkit}/.gitignore | 0 polkit/Makefile.am | 61 +++++ .../polkit-action.c | 38 ++-- .../polkit-action.h | 26 +-- .../polkit-caller.c | 80 +++---- polkit/polkit-caller.h | 57 +++++ .../polkit-context.c | 212 +++++++++--------- .../polkit-context.h | 54 ++--- .../polkit-debug.c | 10 +- .../polkit-debug.h | 8 +- .../polkit-error.c | 8 +- .../polkit-error.h | 10 +- .../polkit-module.c | 130 +++++------ .../polkit-module.h | 86 +++---- .../polkit-policy-cache.c | 48 ++-- .../polkit-policy-cache.h | 26 +-- .../polkit-policy-default.c | 70 +++--- .../polkit-policy-default.h | 32 +-- .../polkit-policy-file-entry.c | 46 ++-- .../polkit-policy-file-entry.h | 24 +- .../polkit-policy-file.c | 36 +-- .../polkit-policy-file.h | 24 +- .../polkit-resource.c | 46 ++-- .../polkit-resource.h | 30 +-- .../polkit-result.c | 38 ++-- polkit/polkit-result.h | 84 +++++++ .../libpolkit-seat.c => polkit/polkit-seat.c | 38 ++-- .../libpolkit-seat.h => polkit/polkit-seat.h | 26 +-- .../polkit-session.c | 88 ++++---- polkit/polkit-session.h | 60 +++++ .../polkit-types.h | 12 +- .../polkit-utils.c | 12 +- .../polkit-utils.h | 10 +- libpolkit/libpolkit.h => polkit/polkit.h | 36 +-- tools/Makefile.am | 8 +- tools/polkit-check-caller.c | 24 +- tools/polkit-check-session.c | 26 +-- tools/polkit-grant.c | 84 +++---- tools/polkit-policy-file-validate.c | 6 +- 80 files changed, 1358 insertions(+), 1354 deletions(-) create mode 100644 data/Makefile.am rename libpolkit-dbus.pc.in => data/polkit-dbus.pc.in (100%) rename libpolkit-grant.pc.in => data/polkit-grant.pc.in (100%) rename polkit.in => data/polkit.in (100%) rename libpolkit.pc.in => data/polkit.pc.in (100%) rename doc/api/{libpolkit => polkit-dbus}/Makefile.am (81%) rename doc/api/{libpolkit-dbus/libpolkit-dbus-docs.xml => polkit-dbus/polkit-dbus-docs.xml} (98%) rename doc/api/{libpolkit-dbus/libpolkit-dbus.types => polkit-dbus/polkit-dbus.types} (100%) rename doc/api/{libpolkit-dbus => polkit-dbus}/version.xml.in (100%) rename doc/api/{libpolkit-grant => polkit-grant}/Makefile.am (79%) rename doc/api/{libpolkit-grant/libpolkit-grant-docs.xml => polkit-grant/polkit-grant-docs.xml} (98%) rename doc/api/{libpolkit-grant/libpolkit-grant.types => polkit-grant/polkit-grant.types} (100%) rename doc/api/{libpolkit-grant => polkit-grant}/version.xml.in (100%) rename doc/api/{libpolkit-dbus => polkit}/Makefile.am (76%) rename doc/api/{libpolkit/libpolkit-docs.xml => polkit/polkit-docs.xml} (79%) rename doc/api/{libpolkit/libpolkit.types => polkit/polkit.types} (100%) rename doc/api/{libpolkit => polkit}/version.xml.in (100%) delete mode 100644 libpolkit/Makefile.am delete mode 100644 libpolkit/libpolkit-caller.h delete mode 100644 libpolkit/libpolkit-result.h delete mode 100644 libpolkit/libpolkit-session.h rename {libpolkit-dbus => polkit-dbus}/Makefile.am (79%) rename libpolkit-dbus/libpolkit-dbus.c => polkit-dbus/polkit-dbus.c (83%) rename libpolkit-dbus/libpolkit-dbus.h => polkit-dbus/polkit-dbus.h (68%) rename {libpolkit-grant => polkit-grant}/Makefile.am (87%) rename {libpolkit-grant => polkit-grant}/polkit-grant-helper.c (79%) rename libpolkit-grant/libpolkit-grant.c => polkit-grant/polkit-grant.c (91%) rename libpolkit-grant/libpolkit-grant.h => polkit-grant/polkit-grant.h (77%) rename {libpolkit => polkit}/.gitignore (100%) create mode 100644 polkit/Makefile.am rename libpolkit/libpolkit-action.c => polkit/polkit-action.c (85%) rename libpolkit/libpolkit-action.h => polkit/polkit-action.h (60%) rename libpolkit/libpolkit-caller.c => polkit/polkit-caller.c (80%) create mode 100644 polkit/polkit-caller.h rename libpolkit/libpolkit-context.c => polkit/polkit-context.c (76%) rename libpolkit/libpolkit-context.h => polkit/polkit-context.h (79%) rename libpolkit/libpolkit-debug.c => polkit/polkit-debug.c (91%) rename libpolkit/libpolkit-debug.h => polkit/polkit-debug.h (89%) rename libpolkit/libpolkit-error.c => polkit/polkit-error.c (95%) rename libpolkit/libpolkit-error.h => polkit/polkit-error.h (88%) rename libpolkit/libpolkit-module.c => polkit/polkit-module.c (81%) rename libpolkit/libpolkit-module.h => polkit/polkit-module.h (64%) rename libpolkit/libpolkit-policy-cache.c => polkit/polkit-policy-cache.c (83%) rename libpolkit/libpolkit-policy-cache.h => polkit/polkit-policy-cache.h (60%) rename libpolkit/libpolkit-policy-default.c => polkit/polkit-policy-default.c (79%) rename libpolkit/libpolkit-policy-default.h => polkit/polkit-policy-default.h (64%) rename libpolkit/libpolkit-policy-file-entry.c => polkit/polkit-policy-file-entry.c (72%) rename libpolkit/libpolkit-policy-file-entry.h => polkit/polkit-policy-file-entry.h (58%) rename libpolkit/libpolkit-policy-file.c => polkit/polkit-policy-file.c (87%) rename libpolkit/libpolkit-policy-file.h => polkit/polkit-policy-file.h (69%) rename libpolkit/libpolkit-resource.c => polkit/polkit-resource.c (83%) rename libpolkit/libpolkit-resource.h => polkit/polkit-resource.h (52%) rename libpolkit/libpolkit-result.c => polkit/polkit-result.c (69%) create mode 100644 polkit/polkit-result.h rename libpolkit/libpolkit-seat.c => polkit/polkit-seat.c (85%) rename libpolkit/libpolkit-seat.h => polkit/polkit-seat.h (62%) rename libpolkit/libpolkit-session.c => polkit/polkit-session.c (80%) create mode 100644 polkit/polkit-session.h rename libpolkit/libpolkit-types.h => polkit/polkit-types.h (83%) rename libpolkit/libpolkit-utils.c => polkit/polkit-utils.c (94%) rename libpolkit/libpolkit-utils.h => polkit/polkit-utils.h (86%) rename libpolkit/libpolkit.h => polkit/polkit.h (61%) diff --git a/Makefile.am b/Makefile.am index cf1dbb7..2214028 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,14 +1,6 @@ ## 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 @@ -29,7 +21,7 @@ $(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 *~ diff --git a/configure.in b/configure.in index 126b9b1..ae55f16 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ AM_INIT_AUTOMAKE(PolicyKit, 0.3) 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 # @@ -325,23 +325,24 @@ AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_PASSWORD, "$PAM_FILE_INCLUDE_PASSWORD", [pam AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_SESSION, "$PAM_FILE_INCLUDE_SESSION", [pam file session]) AC_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 diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..0de382e --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,14 @@ +## 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 *~ diff --git a/libpolkit-dbus.pc.in b/data/polkit-dbus.pc.in similarity index 100% rename from libpolkit-dbus.pc.in rename to data/polkit-dbus.pc.in diff --git a/libpolkit-grant.pc.in b/data/polkit-grant.pc.in similarity index 100% rename from libpolkit-grant.pc.in rename to data/polkit-grant.pc.in diff --git a/polkit.in b/data/polkit.in similarity index 100% rename from polkit.in rename to data/polkit.in diff --git a/libpolkit.pc.in b/data/polkit.pc.in similarity index 100% rename from libpolkit.pc.in rename to data/polkit.pc.in diff --git a/doc/api/Makefile.am b/doc/api/Makefile.am index 46809b2..81fbf84 100644 --- a/doc/api/Makefile.am +++ b/doc/api/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in. -SUBDIRS = libpolkit libpolkit-dbus libpolkit-grant +SUBDIRS = polkit polkit-dbus polkit-grant MAINTAINERCLEANFILES = \ *~ \ diff --git a/doc/api/libpolkit/Makefile.am b/doc/api/polkit-dbus/Makefile.am similarity index 81% rename from doc/api/libpolkit/Makefile.am rename to doc/api/polkit-dbus/Makefile.am index 6c3d6f9..6427986 100644 --- a/doc/api/libpolkit/Makefile.am +++ b/doc/api/polkit-dbus/Makefile.am @@ -5,20 +5,20 @@ NULL = 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= \ @@ -34,7 +34,7 @@ INCLUDES = \ GTKDOC_LIBS = \ $(GLIB_LIBS) \ - $(top_builddir)/libpolkit/libpolkit.la \ + $(top_builddir)/polkit-dbus/libpolkit-dbus.la \ $(NULL) # Extra options to supply to gtkdoc-mkdb @@ -57,8 +57,8 @@ FIXXREF_OPTIONS= MAINTAINERCLEANFILES = \ *~ \ Makefile.in \ - libpolkit.types \ - libpolkit-*.txt \ + polkit-dbus.types \ + polkit-dbus-*.txt \ $(NULL) include $(top_srcdir)/gtk-doc.make diff --git a/doc/api/libpolkit-dbus/libpolkit-dbus-docs.xml b/doc/api/polkit-dbus/polkit-dbus-docs.xml similarity index 98% rename from doc/api/libpolkit-dbus/libpolkit-dbus-docs.xml rename to doc/api/polkit-dbus/polkit-dbus-docs.xml index 9dcf978..ed64c6d 100644 --- a/doc/api/libpolkit-dbus/libpolkit-dbus-docs.xml +++ b/doc/api/polkit-dbus/polkit-dbus-docs.xml @@ -64,7 +64,7 @@ PolicyKit D-Bus helper library. - + diff --git a/doc/api/libpolkit-dbus/libpolkit-dbus.types b/doc/api/polkit-dbus/polkit-dbus.types similarity index 100% rename from doc/api/libpolkit-dbus/libpolkit-dbus.types rename to doc/api/polkit-dbus/polkit-dbus.types diff --git a/doc/api/libpolkit-dbus/version.xml.in b/doc/api/polkit-dbus/version.xml.in similarity index 100% rename from doc/api/libpolkit-dbus/version.xml.in rename to doc/api/polkit-dbus/version.xml.in diff --git a/doc/api/libpolkit-grant/Makefile.am b/doc/api/polkit-grant/Makefile.am similarity index 79% rename from doc/api/libpolkit-grant/Makefile.am rename to doc/api/polkit-grant/Makefile.am index f65956e..b0a3bab 100644 --- a/doc/api/libpolkit-grant/Makefile.am +++ b/doc/api/polkit-grant/Makefile.am @@ -5,20 +5,20 @@ NULL = 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= \ @@ -34,7 +34,7 @@ INCLUDES = \ 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 @@ -57,8 +57,8 @@ FIXXREF_OPTIONS= MAINTAINERCLEANFILES = \ *~ \ Makefile.in \ - libpolkit-grant.types \ - libpolkit-grant-*.txt \ + polkit-grant.types \ + polkit-grant-*.txt \ $(NULL) include $(top_srcdir)/gtk-doc.make diff --git a/doc/api/libpolkit-grant/libpolkit-grant-docs.xml b/doc/api/polkit-grant/polkit-grant-docs.xml similarity index 98% rename from doc/api/libpolkit-grant/libpolkit-grant-docs.xml rename to doc/api/polkit-grant/polkit-grant-docs.xml index 0ca0f9f..41204c4 100644 --- a/doc/api/libpolkit-grant/libpolkit-grant-docs.xml +++ b/doc/api/polkit-grant/polkit-grant-docs.xml @@ -64,7 +64,7 @@ PolicyKit granting helper library. - + diff --git a/doc/api/libpolkit-grant/libpolkit-grant.types b/doc/api/polkit-grant/polkit-grant.types similarity index 100% rename from doc/api/libpolkit-grant/libpolkit-grant.types rename to doc/api/polkit-grant/polkit-grant.types diff --git a/doc/api/libpolkit-grant/version.xml.in b/doc/api/polkit-grant/version.xml.in similarity index 100% rename from doc/api/libpolkit-grant/version.xml.in rename to doc/api/polkit-grant/version.xml.in diff --git a/doc/api/libpolkit-dbus/Makefile.am b/doc/api/polkit/Makefile.am similarity index 76% rename from doc/api/libpolkit-dbus/Makefile.am rename to doc/api/polkit/Makefile.am index c539267..0b8d70a 100644 --- a/doc/api/libpolkit-dbus/Makefile.am +++ b/doc/api/polkit/Makefile.am @@ -5,20 +5,20 @@ NULL = 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= \ @@ -34,7 +34,7 @@ INCLUDES = \ GTKDOC_LIBS = \ $(GLIB_LIBS) \ - $(top_builddir)/libpolkit-dbus/libpolkit-dbus.la \ + $(top_builddir)/polkit/libpolkit.la \ $(NULL) # Extra options to supply to gtkdoc-mkdb @@ -54,11 +54,11 @@ HTML_IMAGES = # 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 diff --git a/doc/api/libpolkit/libpolkit-docs.xml b/doc/api/polkit/polkit-docs.xml similarity index 79% rename from doc/api/libpolkit/libpolkit-docs.xml rename to doc/api/polkit/polkit-docs.xml index b0f538f..6ed6222 100644 --- a/doc/api/libpolkit/libpolkit-docs.xml +++ b/doc/api/polkit/polkit-docs.xml @@ -64,22 +64,20 @@ PolicyKit library. - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/doc/api/libpolkit/libpolkit.types b/doc/api/polkit/polkit.types similarity index 100% rename from doc/api/libpolkit/libpolkit.types rename to doc/api/polkit/polkit.types diff --git a/doc/api/libpolkit/version.xml.in b/doc/api/polkit/version.xml.in similarity index 100% rename from doc/api/libpolkit/version.xml.in rename to doc/api/polkit/version.xml.in diff --git a/libpolkit/Makefile.am b/libpolkit/Makefile.am deleted file mode 100644 index 457f07a..0000000 --- a/libpolkit/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -## 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) - diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h deleted file mode 100644 index bb91f6e..0000000 --- a/libpolkit/libpolkit-caller.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/*************************************************************************** - * - * libpolkit-caller.h : callers - * - * Copyright (C) 2007 David Zeuthen, - * - * 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 can be included directly, this file may disappear or change contents." -#endif - -#ifndef LIBPOLKIT_CALLER_H -#define LIBPOLKIT_CALLER_H - -#include -#include -#include - -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 */ diff --git a/libpolkit/libpolkit-result.h b/libpolkit/libpolkit-result.h deleted file mode 100644 index 74da794..0000000 --- a/libpolkit/libpolkit-result.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- 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, - * - * 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 can be included directly, this file may disappear or change contents." -#endif - -#ifndef LIBPOLKIT_RESULT_H -#define LIBPOLKIT_RESULT_H - -#include - -/** - * 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 */ diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h deleted file mode 100644 index 2ee4bda..0000000 --- a/libpolkit/libpolkit-session.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/*************************************************************************** - * - * libpolkit-session.h : sessions - * - * Copyright (C) 2007 David Zeuthen, - * - * 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 can be included directly, this file may disappear or change contents." -#endif - -#ifndef LIBPOLKIT_SESSION_H -#define LIBPOLKIT_SESSION_H - -#include -#include - -#include - -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 */ diff --git a/modules/allow-all/Makefile.am b/modules/allow-all/Makefile.am index a833468..316f3a6 100644 --- a/modules/allow-all/Makefile.am +++ b/modules/allow-all/Makefile.am @@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = \ 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 *~ diff --git a/modules/allow-all/polkit-module-allow-all.c b/modules/allow-all/polkit-module-allow-all.c index 3da56c2..0d32478 100644 --- a/modules/allow-all/polkit-module-allow-all.c +++ b/modules/allow-all/polkit-module-allow-all.c @@ -28,10 +28,10 @@ #endif #include -#include +#include -/* 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[]) @@ -51,7 +51,7 @@ _module_can_session_access_resource (PolKitModuleInterface *module_interface, PolKitResource *resource, PolKitSession *session) { - return LIBPOLKIT_RESULT_YES; + return POLKIT_RESULT_YES; } static PolKitResult @@ -61,11 +61,11 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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; @@ -73,10 +73,10 @@ libpolkit_module_set_functions (PolKitModuleInterface *module_interface) 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: diff --git a/modules/default/Makefile.am b/modules/default/Makefile.am index 91f49d4..ec20eed 100644 --- a/modules/default/Makefile.am +++ b/modules/default/Makefile.am @@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = \ 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 *~ diff --git a/modules/default/polkit-module-default.c b/modules/default/polkit-module-default.c index 86a0635..7b73388 100644 --- a/modules/default/polkit-module-default.c +++ b/modules/default/polkit-module-default.c @@ -28,10 +28,10 @@ #endif #include -#include +#include -/* 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, @@ -57,11 +57,11 @@ _module_can_session_access_resource (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); @@ -78,18 +78,18 @@ _module_can_caller_access_resource (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_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; @@ -97,10 +97,10 @@ libpolkit_module_set_functions (PolKitModuleInterface *module_interface) 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: diff --git a/modules/deny-all/Makefile.am b/modules/deny-all/Makefile.am index 345dcf4..732d929 100644 --- a/modules/deny-all/Makefile.am +++ b/modules/deny-all/Makefile.am @@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = \ 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 *~ diff --git a/modules/deny-all/polkit-module-deny-all.c b/modules/deny-all/polkit-module-deny-all.c index e2eb517..0306e19 100644 --- a/modules/deny-all/polkit-module-deny-all.c +++ b/modules/deny-all/polkit-module-deny-all.c @@ -28,10 +28,10 @@ #endif #include -#include +#include -/* 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[]) @@ -51,7 +51,7 @@ _module_can_session_access_resource (PolKitModuleInterface *module_interface, PolKitResource *resource, PolKitSession *session) { - return LIBPOLKIT_RESULT_NO; + return POLKIT_RESULT_NO; } static PolKitResult @@ -61,11 +61,11 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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; @@ -73,10 +73,10 @@ libpolkit_module_set_functions (PolKitModuleInterface *module_interface) 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: diff --git a/modules/grant/Makefile.am b/modules/grant/Makefile.am index 0b7c5f1..6306ac5 100644 --- a/modules/grant/Makefile.am +++ b/modules/grant/Makefile.am @@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = \ 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 *~ diff --git a/modules/grant/polkit-module-grant.c b/modules/grant/polkit-module-grant.c index 15a06c0..d49c5a6 100644 --- a/modules/grant/polkit-module-grant.c +++ b/modules/grant/polkit-module-grant.c @@ -31,11 +31,11 @@ #include #include #include -#include +#include #include -/* 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[]) @@ -57,7 +57,7 @@ _module_can_session_access_resource (PolKitModuleInterface *module_interface, PolKitResource *resource, PolKitSession *session) { - return LIBPOLKIT_RESULT_UNKNOWN_ACTION; + return POLKIT_RESULT_UNKNOWN_ACTION; } static PolKitResult @@ -71,7 +71,7 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, PolKitSession *session; PolKitResult result; - result = LIBPOLKIT_RESULT_UNKNOWN_ACTION; + result = POLKIT_RESULT_UNKNOWN_ACTION; /* file format: * @@ -101,24 +101,24 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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); @@ -129,7 +129,7 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, /* 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 */ @@ -145,7 +145,7 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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; } @@ -154,7 +154,7 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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; } @@ -163,7 +163,7 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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; } @@ -175,7 +175,7 @@ out: } polkit_bool_t -libpolkit_module_set_functions (PolKitModuleInterface *module_interface) +polkit_module_set_functions (PolKitModuleInterface *module_interface) { polkit_bool_t ret; @@ -183,10 +183,10 @@ libpolkit_module_set_functions (PolKitModuleInterface *module_interface) 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: diff --git a/modules/run-program/Makefile.am b/modules/run-program/Makefile.am index 057c996..61d1ad5 100644 --- a/modules/run-program/Makefile.am +++ b/modules/run-program/Makefile.am @@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = \ 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 *~ diff --git a/modules/run-program/polkit-module-run-program.c b/modules/run-program/polkit-module-run-program.c index f0189f7..e08235f 100644 --- a/modules/run-program/polkit-module-run-program.c +++ b/modules/run-program/polkit-module-run-program.c @@ -27,11 +27,11 @@ # include #endif -#include +#include #include -/* 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; @@ -75,7 +75,7 @@ _module_init (PolKitModuleInterface *module_interface, int argc, char *argv[]) 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: @@ -89,7 +89,7 @@ static void _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); @@ -101,7 +101,7 @@ static polkit_bool_t _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; @@ -114,9 +114,9 @@ _add_resource_to_env (PolKitResource *resource, GPtrArray *envp) { 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)); @@ -129,7 +129,7 @@ static polkit_bool_t _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; @@ -147,18 +147,18 @@ _add_session_to_env (PolKitSession *session, GPtrArray *envp) 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)) @@ -183,15 +183,15 @@ _add_caller_to_env (PolKitCaller *caller, GPtrArray *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) @@ -244,7 +244,7 @@ _run_program (UserData *user_data, char **envp, PolKitResult *result) ; 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; } @@ -268,9 +268,9 @@ _module_can_session_access_resource (PolKitModuleInterface *module_interface, 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 (); @@ -308,8 +308,8 @@ _module_can_caller_access_resource (PolKitModuleInterface *module_interface, 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)) @@ -334,7 +334,7 @@ error: } polkit_bool_t -libpolkit_module_set_functions (PolKitModuleInterface *module_interface) +polkit_module_set_functions (PolKitModuleInterface *module_interface) { polkit_bool_t ret; @@ -342,10 +342,10 @@ libpolkit_module_set_functions (PolKitModuleInterface *module_interface) 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: diff --git a/libpolkit-dbus/Makefile.am b/polkit-dbus/Makefile.am similarity index 79% rename from libpolkit-dbus/Makefile.am rename to polkit-dbus/Makefile.am index 3a51c3a..0cee725 100644 --- a/libpolkit-dbus/Makefile.am +++ b/polkit-dbus/Makefile.am @@ -14,15 +14,15 @@ INCLUDES = \ 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) diff --git a/libpolkit-dbus/libpolkit-dbus.c b/polkit-dbus/polkit-dbus.c similarity index 83% rename from libpolkit-dbus/libpolkit-dbus.c rename to polkit-dbus/polkit-dbus.c index 6c4995a..8609aac 100644 --- a/libpolkit-dbus/libpolkit-dbus.c +++ b/polkit-dbus/polkit-dbus.c @@ -1,7 +1,7 @@ /* -*- 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, @@ -25,7 +25,7 @@ **************************************************************************/ /** - * 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 @@ -44,11 +44,11 @@ #include #include -#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 @@ -64,7 +64,7 @@ * @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; @@ -198,67 +198,67 @@ libpolkit_session_new_from_objpath (DBusConnection *con, const char *objpath, ui 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; } @@ -270,7 +270,7 @@ 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 @@ -284,7 +284,7 @@ out: * @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; @@ -324,7 +324,7 @@ libpolkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBus 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); @@ -333,7 +333,7 @@ out: /** - * 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 @@ -348,7 +348,7 @@ out: * @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; @@ -453,82 +453,82 @@ libpolkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, 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; } diff --git a/libpolkit-dbus/libpolkit-dbus.h b/polkit-dbus/polkit-dbus.h similarity index 68% rename from libpolkit-dbus/libpolkit-dbus.h rename to polkit-dbus/polkit-dbus.h index dd8d019..39c00cb 100644 --- a/libpolkit-dbus/libpolkit-dbus.h +++ b/polkit-dbus/polkit-dbus.h @@ -1,7 +1,7 @@ /* -*- 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, @@ -24,18 +24,18 @@ * **************************************************************************/ -#ifndef LIBPOLKIT_DBUS_H -#define LIBPOLKIT_DBUS_H +#ifndef POLKIT_DBUS_H +#define POLKIT_DBUS_H -#include +#include #include -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 */ diff --git a/libpolkit-grant/Makefile.am b/polkit-grant/Makefile.am similarity index 87% rename from libpolkit-grant/Makefile.am rename to polkit-grant/Makefile.am index 01ebcfe..17f07e5 100644 --- a/libpolkit-grant/Makefile.am +++ b/polkit-grant/Makefile.am @@ -14,22 +14,22 @@ INCLUDES = \ 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 = diff --git a/libpolkit-grant/polkit-grant-helper.c b/polkit-grant/polkit-grant-helper.c similarity index 79% rename from libpolkit-grant/polkit-grant-helper.c rename to polkit-grant/polkit-grant-helper.c index cd48810..8b90107 100644 --- a/libpolkit-grant/polkit-grant-helper.c +++ b/polkit-grant/polkit-grant-helper.c @@ -39,7 +39,7 @@ #include -#include +#include static int conversation_function (int n, @@ -197,28 +197,28 @@ verify_with_polkit (const char *dbus_name, 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; } @@ -226,22 +226,22 @@ verify_with_polkit (const char *dbus_name, 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; } @@ -266,12 +266,12 @@ get_and_validate_override_details (PolKitResult *result) 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... * @@ -279,35 +279,35 @@ get_and_validate_override_details (PolKitResult *result) * */ 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; @@ -318,8 +318,8 @@ get_and_validate_override_details (PolKitResult *result) 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; @@ -427,13 +427,13 @@ main (int argc, char *argv[]) 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; @@ -449,7 +449,7 @@ main (int argc, char *argv[]) * 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)) @@ -458,7 +458,7 @@ main (int argc, char *argv[]) /* 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 */ @@ -481,20 +481,20 @@ main (int argc, char *argv[]) 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; diff --git a/libpolkit-grant/libpolkit-grant.c b/polkit-grant/polkit-grant.c similarity index 91% rename from libpolkit-grant/libpolkit-grant.c rename to polkit-grant/polkit-grant.c index d15f8a0..0197aa9 100644 --- a/libpolkit-grant/libpolkit-grant.c +++ b/polkit-grant/polkit-grant.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -36,10 +36,10 @@ #include #include -#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 @@ -81,7 +81,7 @@ struct PolKitGrant }; /** - * libpolkit_grant_new: + * polkit_grant_new: * @void: * * Creates a #PolKitGrant object. @@ -89,7 +89,7 @@ struct PolKitGrant * 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); @@ -98,7 +98,7 @@ libpolkit_grant_new (void) } /** - * libpolkit_grant_ref: + * polkit_grant_ref: * @polkit_grant: the object * * Increase reference count. @@ -106,7 +106,7 @@ libpolkit_grant_new (void) * 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); @@ -115,7 +115,7 @@ libpolkit_grant_ref (PolKitGrant *polkit_grant) } /** - * libpolkit_grant_unref: + * polkit_grant_unref: * @polkit_grant: the object * * Decreases the reference count of the object. If it becomes zero, @@ -123,7 +123,7 @@ libpolkit_grant_ref (PolKitGrant *polkit_grant) * 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); @@ -154,7 +154,7 @@ libpolkit_grant_unref (PolKitGrant *polkit_grant) } /** - * libpolkit_grant_set_functions: + * polkit_grant_set_functions: * @polkit_grant: the object * @func_add_io_watch: Callback function * @func_add_child_watch: Callback function @@ -171,7 +171,7 @@ libpolkit_grant_unref (PolKitGrant *polkit_grant) * 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, @@ -209,7 +209,7 @@ libpolkit_grant_set_functions (PolKitGrant *polkit_grant, /** - * libpolkit_grant_child_func: + * polkit_grant_child_func: * @polkit_grant: the object * @pid: pid of the child * @exit_code: exit code of the child @@ -219,7 +219,7 @@ libpolkit_grant_set_functions (PolKitGrant *polkit_grant, * #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); @@ -230,7 +230,7 @@ libpolkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code) /** - * libpolkit_grant_io_func: + * polkit_grant_io_func: * @polkit_grant: the object * @fd: the file descriptor passed to the supplied function of type #PolKitGrantAddIOWatch. * @@ -239,7 +239,7 @@ libpolkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code) * 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; @@ -299,7 +299,7 @@ libpolkit_grant_io_func (PolKitGrant *polkit_grant, int fd) 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, @@ -313,13 +313,13 @@ libpolkit_grant_io_func (PolKitGrant *polkit_grant, int fd) 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; } @@ -341,13 +341,13 @@ libpolkit_grant_io_func (PolKitGrant *polkit_grant, int fd) } /** - * 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); @@ -360,7 +360,7 @@ libpolkit_grant_cancel_auth (PolKitGrant *polkit_grant) } /** - * libpolkit_grant_initiate_auth: + * polkit_grant_initiate_auth: * @polkit_grant: the object * @action: Action requested by caller * @resource: Resource in question @@ -369,7 +369,7 @@ libpolkit_grant_cancel_auth (PolKitGrant *polkit_grant) * 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 @@ -383,7 +383,7 @@ libpolkit_grant_cancel_auth (PolKitGrant *polkit_grant) * 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) @@ -399,21 +399,21 @@ libpolkit_grant_initiate_auth (PolKitGrant *polkit_grant, /* 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; diff --git a/libpolkit-grant/libpolkit-grant.h b/polkit-grant/polkit-grant.h similarity index 77% rename from libpolkit-grant/libpolkit-grant.h rename to polkit-grant/polkit-grant.h index 0ba8925..0339f3d 100644 --- a/libpolkit-grant/libpolkit-grant.h +++ b/polkit-grant/polkit-grant.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -23,10 +23,10 @@ * **************************************************************************/ -#ifndef LIBPOLKIT_GRANT_H -#define LIBPOLKIT_GRANT_H +#ifndef POLKIT_GRANT_H +#define POLKIT_GRANT_H -#include +#include struct PolKitGrant; typedef struct PolKitGrant PolKitGrant; @@ -35,7 +35,7 @@ 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 @@ -53,7 +53,7 @@ typedef void (*PolKitGrantType) (PolKitGrant *polkit_grant, * 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 @@ -70,7 +70,7 @@ typedef char* (*PolKitGrantConversationPromptEchoOff) (PolKitGrant *polkit_grant * 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 @@ -87,7 +87,7 @@ typedef char* (*PolKitGrantConversationPromptEchoOn) (PolKitGrant *polkit_grant, * 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. @@ -100,7 +100,7 @@ typedef void (*PolKitGrantConversationErrorMessage) (PolKitGrant *polkit_grant, * 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 @@ -115,7 +115,7 @@ typedef void (*PolKitGrantConversationTextInfo) (PolKitGrant *polkit_grant, * @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 @@ -141,14 +141,14 @@ typedef void (*PolKitGrantConversationTextInfo) (PolKitGrant *polkit_grant, * * * 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: * * @@ -165,7 +165,7 @@ typedef void (*PolKitGrantConversationTextInfo) (PolKitGrant *polkit_grant, * * * 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.: * * @@ -180,13 +180,13 @@ typedef void (*PolKitGrantConversationTextInfo) (PolKitGrant *polkit_grant, * * * 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, @@ -196,11 +196,11 @@ typedef PolKitResult (*PolKitGrantOverrideGrantType) (PolKitGrant *polkit_grant, * 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, @@ -213,7 +213,7 @@ typedef void (*PolKitGrantDone) (PolKitGrant *polkit_grant, * * 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: @@ -225,7 +225,7 @@ typedef void (*PolKitGrantDone) (PolKitGrant *polkit_grant, * 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 @@ -248,7 +248,7 @@ typedef int (*PolKitGrantAddChildWatch) (PolKitGrant *polkit_grant, * * 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: @@ -260,7 +260,7 @@ typedef int (*PolKitGrantAddChildWatch) (PolKitGrant *polkit_grant, * 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; * } * @@ -313,32 +313,32 @@ typedef int (*PolKitGrantAddIOWatch) (PolKitGrant *polkit_grant, 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 */ diff --git a/libpolkit/.gitignore b/polkit/.gitignore similarity index 100% rename from libpolkit/.gitignore rename to polkit/.gitignore diff --git a/polkit/Makefile.am b/polkit/Makefile.am new file mode 100644 index 0000000..0b3bbb1 --- /dev/null +++ b/polkit/Makefile.am @@ -0,0 +1,61 @@ +## 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) diff --git a/libpolkit/libpolkit-action.c b/polkit/polkit-action.c similarity index 85% rename from libpolkit/libpolkit-action.c rename to polkit/polkit-action.c index f0a0a8c..d9ad78a 100644 --- a/libpolkit/libpolkit-action.c +++ b/polkit/polkit-action.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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. @@ -61,14 +61,14 @@ struct PolKitAction }; /** - * 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); @@ -81,7 +81,7 @@ libpolkit_action_new (void) } /** - * libpolkit_action_ref: + * polkit_action_ref: * @action: the action object * * Increase reference count. @@ -89,7 +89,7 @@ libpolkit_action_new (void) * Returns: the object **/ PolKitAction * -libpolkit_action_ref (PolKitAction *action) +polkit_action_ref (PolKitAction *action) { g_return_val_if_fail (action != NULL, action); action->refcount++; @@ -97,7 +97,7 @@ libpolkit_action_ref (PolKitAction *action) } /** - * libpolkit_action_unref: + * polkit_action_unref: * @action: the action object * * Decreases the reference count of the object. If it becomes zero, @@ -105,7 +105,7 @@ libpolkit_action_ref (PolKitAction *action) * objects are decresed by one. **/ void -libpolkit_action_unref (PolKitAction *action) +polkit_action_unref (PolKitAction *action) { g_return_if_fail (action != NULL); action->refcount--; @@ -117,7 +117,7 @@ libpolkit_action_unref (PolKitAction *action) } /** - * libpolkit_action_set_action_id: + * polkit_action_set_action_id: * @action: the action object * @action_id: action identifier * @@ -126,7 +126,7 @@ libpolkit_action_unref (PolKitAction *action) * 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); @@ -137,7 +137,7 @@ libpolkit_action_set_action_id (PolKitAction *action, const char *action_id) } /** - * 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. * @@ -146,7 +146,7 @@ libpolkit_action_set_action_id (PolKitAction *action, const char *action_id) * 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); @@ -157,20 +157,20 @@ libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id) } /** - * 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 @@ -178,7 +178,7 @@ libpolkit_action_debug (PolKitAction *action) * 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); diff --git a/libpolkit/libpolkit-action.h b/polkit/polkit-action.h similarity index 60% rename from libpolkit/libpolkit-action.h rename to polkit/polkit-action.h index e266c2d..af89f81 100644 --- a/libpolkit/libpolkit-action.h +++ b/polkit/polkit-action.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,26 +24,26 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 +#include 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 */ diff --git a/libpolkit/libpolkit-caller.c b/polkit/polkit-caller.c similarity index 80% rename from libpolkit/libpolkit-caller.c rename to polkit/polkit-caller.c index c9808ae..e096d0b 100644 --- a/libpolkit/libpolkit-caller.c +++ b/polkit/polkit-caller.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,7 +24,7 @@ **************************************************************************/ /** - * 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. @@ -44,9 +44,9 @@ #include #include -#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: @@ -65,14 +65,14 @@ struct 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); @@ -81,7 +81,7 @@ libpolkit_caller_new (void) } /** - * libpolkit_caller_ref: + * polkit_caller_ref: * @caller: The caller object * * Increase reference count. @@ -89,7 +89,7 @@ libpolkit_caller_new (void) * Returns: the object **/ PolKitCaller * -libpolkit_caller_ref (PolKitCaller *caller) +polkit_caller_ref (PolKitCaller *caller) { g_return_val_if_fail (caller != NULL, caller); caller->refcount++; @@ -98,7 +98,7 @@ libpolkit_caller_ref (PolKitCaller *caller) /** - * libpolkit_caller_unref: + * polkit_caller_unref: * @caller: The caller object * * Decreases the reference count of the object. If it becomes zero, @@ -106,7 +106,7 @@ libpolkit_caller_ref (PolKitCaller *caller) * objects are decresed by one. **/ void -libpolkit_caller_unref (PolKitCaller *caller) +polkit_caller_unref (PolKitCaller *caller) { g_return_if_fail (caller != NULL); caller->refcount--; @@ -115,12 +115,12 @@ libpolkit_caller_unref (PolKitCaller *caller) 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 * @@ -129,7 +129,7 @@ libpolkit_caller_unref (PolKitCaller *caller) * 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); @@ -140,7 +140,7 @@ libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name) } /** - * libpolkit_caller_set_uid: + * polkit_caller_set_uid: * @caller: The caller object * @uid: UNIX user id * @@ -149,7 +149,7 @@ libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name) * 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; @@ -157,7 +157,7 @@ libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid) } /** - * libpolkit_caller_set_pid: + * polkit_caller_set_pid: * @caller: The caller object * @pid: UNIX process id * @@ -166,7 +166,7 @@ libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid) * 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; @@ -174,7 +174,7 @@ libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid) } /** - * libpolkit_caller_set_selinux_context: + * polkit_caller_set_selinux_context: * @caller: The caller object * @selinux_context: SELinux security context * @@ -183,7 +183,7 @@ libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid) * 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 */ @@ -196,7 +196,7 @@ libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_ } /** - * libpolkit_caller_set_ck_session: + * polkit_caller_set_ck_session: * @caller: The caller object * @session: a session object * @@ -207,18 +207,18 @@ libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_ * 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. * @@ -227,7 +227,7 @@ libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session) * 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); @@ -236,7 +236,7 @@ libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name) } /** - * libpolkit_caller_get_uid: + * polkit_caller_get_uid: * @caller: The caller object * @out_uid: Returns the UNIX user id * @@ -245,7 +245,7 @@ libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name) * 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); @@ -254,7 +254,7 @@ libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid) } /** - * libpolkit_caller_get_pid: + * polkit_caller_get_pid: * @caller: The caller object * @out_pid: Returns the UNIX process id * @@ -263,7 +263,7 @@ libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid) * 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); @@ -272,7 +272,7 @@ libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid) } /** - * 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. * @@ -282,7 +282,7 @@ libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid) * 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); @@ -291,7 +291,7 @@ libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_c } /** - * 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. * @@ -301,7 +301,7 @@ libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_c * 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); @@ -310,24 +310,24 @@ libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_sessi } /** - * 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 @@ -335,7 +335,7 @@ libpolkit_caller_debug (PolKitCaller *caller) * 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); diff --git a/polkit/polkit-caller.h b/polkit/polkit-caller.h new file mode 100644 index 0000000..86643d9 --- /dev/null +++ b/polkit/polkit-caller.h @@ -0,0 +1,57 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ +/*************************************************************************** + * + * polkit-caller.h : callers + * + * Copyright (C) 2007 David Zeuthen, + * + * 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 can be included directly, this file may disappear or change contents." +#endif + +#ifndef POLKIT_CALLER_H +#define POLKIT_CALLER_H + +#include +#include +#include + +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 */ diff --git a/libpolkit/libpolkit-context.c b/polkit/polkit-context.c similarity index 76% rename from libpolkit/libpolkit-context.c rename to polkit/polkit-context.c index de9aad8..a1248fd 100644 --- a/libpolkit/libpolkit-context.c +++ b/polkit/polkit-context.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,20 +37,20 @@ #include #include -#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. @@ -79,14 +79,14 @@ struct PolKitContext }; /** - * 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); @@ -100,7 +100,7 @@ unload_modules (PolKitContext *pk_context) 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; @@ -192,7 +192,7 @@ load_modules (PolKitContext *pk_context, PolKitError **error) 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; @@ -202,7 +202,7 @@ load_modules (PolKitContext *pk_context, PolKitError **error) 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); @@ -251,7 +251,7 @@ _policy_dir_events (PolKitContext *pk_context, /* 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; } @@ -262,7 +262,7 @@ _policy_dir_events (PolKitContext *pk_context, } /** - * libpolkit_context_init: + * polkit_context_init: * @pk_context: the context object * @error: return location for error * @@ -273,7 +273,7 @@ _policy_dir_events (PolKitContext *pk_context, * 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; @@ -316,13 +316,13 @@ libpolkit_context_init (PolKitContext *pk_context, PolKitError **error) 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. @@ -330,7 +330,7 @@ error: * 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++; @@ -338,7 +338,7 @@ libpolkit_context_ref (PolKitContext *pk_context) } /** - * libpolkit_context_unref: + * polkit_context_unref: * @pk_context: the context object * * Decreases the reference count of the object. If it becomes zero, @@ -346,7 +346,7 @@ libpolkit_context_ref (PolKitContext *pk_context) * 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); @@ -360,7 +360,7 @@ libpolkit_context_unref (PolKitContext *pk_context) } /** - * 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 @@ -379,7 +379,7 @@ libpolkit_context_unref (PolKitContext *pk_context) * timeframe. **/ void -libpolkit_context_set_config_changed (PolKitContext *pk_context, +polkit_context_set_config_changed (PolKitContext *pk_context, PolKitContextConfigChangedCB cb, void *user_data) { @@ -389,7 +389,7 @@ libpolkit_context_set_config_changed (PolKitContext *pk_context, } /** - * 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 @@ -397,7 +397,7 @@ libpolkit_context_set_config_changed (PolKitContext *pk_context, * 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) { @@ -408,7 +408,7 @@ libpolkit_context_set_file_monitor (PolKitContext *pk_con /** - * 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. @@ -416,7 +416,7 @@ libpolkit_context_set_file_monitor (PolKitContext *pk_con * 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); @@ -426,13 +426,13 @@ libpolkit_context_get_policy_cache (PolKitContext *pk_context) _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); } } @@ -441,7 +441,7 @@ libpolkit_context_get_policy_cache (PolKitContext *pk_context) /** - * libpolkit_context_get_seat_resource_association: + * polkit_context_get_seat_resource_association: * @pk_context: the PolicyKit context * @visitor: visitor function * @user_data: user data @@ -460,41 +460,41 @@ libpolkit_context_get_policy_cache (PolKitContext *pk_context) * 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 @@ -503,11 +503,11 @@ libpolkit_context_is_resource_associated_with_seat (PolKitContext *pk_context, * 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) @@ -518,7 +518,7 @@ libpolkit_context_can_session_access_resource (PolKitContext *pk_context, 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 */ @@ -527,65 +527,65 @@ libpolkit_context_can_session_access_resource (PolKitContext *pk_context, /* 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, @@ -599,40 +599,40 @@ libpolkit_context_can_session_access_resource (PolKitContext *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 @@ -644,7 +644,7 @@ out: * 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) @@ -655,73 +655,73 @@ libpolkit_context_can_caller_access_resource (PolKitContext *pk_context, 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, @@ -735,33 +735,33 @@ libpolkit_context_can_caller_access_resource (PolKitContext *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; } diff --git a/libpolkit/libpolkit-context.h b/polkit/polkit-context.h similarity index 79% rename from libpolkit/libpolkit-context.h rename to polkit/polkit-context.h index cf0f2c4..5963abe 100644 --- a/libpolkit/libpolkit-context.h +++ b/polkit/polkit-context.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,22 +24,22 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include struct PolKitContext; typedef struct PolKitContext PolKitContext; @@ -133,19 +133,19 @@ typedef void (*PolKitContextFileMonitorRemoveWatch) (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: @@ -153,34 +153,34 @@ PolKitPolicyCache *libpolkit_context_get_policy_cache (PolKitContext *pk_context * @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 */ diff --git a/libpolkit/libpolkit-debug.c b/polkit/polkit-debug.c similarity index 91% rename from libpolkit/libpolkit-debug.c rename to polkit/polkit-debug.c index d81b7e7..50c1491 100644 --- a/libpolkit/libpolkit-debug.c +++ b/polkit/polkit-debug.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,8 +24,8 @@ **************************************************************************/ /** - * 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 **/ @@ -40,8 +40,8 @@ #include #include -#include "libpolkit-types.h" -#include "libpolkit-debug.h" +#include "polkit-types.h" +#include "polkit-debug.h" /** * pk_debug: diff --git a/libpolkit/libpolkit-debug.h b/polkit/polkit-debug.h similarity index 89% rename from libpolkit/libpolkit-debug.h rename to polkit/polkit-debug.h index d6c51f2..7177e7e 100644 --- a/libpolkit/libpolkit-debug.h +++ b/polkit/polkit-debug.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -23,11 +23,11 @@ * **************************************************************************/ -#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 */ diff --git a/libpolkit/libpolkit-error.c b/polkit/polkit-error.c similarity index 95% rename from libpolkit/libpolkit-error.c rename to polkit/polkit-error.c index e6cf33b..cec8cc4 100644 --- a/libpolkit/libpolkit-error.c +++ b/polkit/polkit-error.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,7 +24,7 @@ **************************************************************************/ /** - * SECTION:libpolkit-error + * SECTION:polkit-error * @short_description: Error codes from PolicyKit. * * Error codes from PolicyKit. @@ -45,8 +45,8 @@ #include -#include "libpolkit-types.h" -#include "libpolkit-error.h" +#include "polkit-types.h" +#include "polkit-error.h" /** * PolKitError: diff --git a/libpolkit/libpolkit-error.h b/polkit/polkit-error.h similarity index 88% rename from libpolkit/libpolkit-error.h rename to polkit/polkit-error.h index d5d5e8e..ec0f19a 100644 --- a/libpolkit/libpolkit-error.h +++ b/polkit/polkit-error.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,11 +24,11 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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: @@ -51,4 +51,4 @@ const char *polkit_error_get_error_message (PolKitError *error); 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 */ diff --git a/libpolkit/libpolkit-module.c b/polkit/polkit-module.c similarity index 81% rename from libpolkit/libpolkit-module.c rename to polkit/polkit-module.c index 7e1440f..aab1fc4 100644 --- a/libpolkit/libpolkit-module.c +++ b/polkit/polkit-module.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,7 +24,7 @@ **************************************************************************/ /** - * SECTION:libpolkit-module + * SECTION:polkit-module * @short_description: PolicyKit loadable module interface * * These functions are used by loadable PolicyKit modules. @@ -40,8 +40,8 @@ #include #include -#include "libpolkit-debug.h" -#include "libpolkit-module.h" +#include "polkit-debug.h" +#include "polkit-module.h" /** * PolKitModuleInterface: @@ -172,7 +172,7 @@ error: } /** - * 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 @@ -183,7 +183,7 @@ error: * 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; @@ -199,15 +199,15 @@ libpolkit_module_interface_load_module (const char *name, PolKitModuleControl mo 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; @@ -239,14 +239,14 @@ libpolkit_module_interface_load_module (const char *name, PolKitModuleControl mo 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 @@ -254,7 +254,7 @@ error: * 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; @@ -262,14 +262,14 @@ libpolkit_module_get_name (PolKitModuleInterface *module_interface) /** - * 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); @@ -278,7 +278,7 @@ libpolkit_module_interface_new (void) } /** - * libpolkit_module_interface_ref: + * polkit_module_interface_ref: * @module_interface: the module_interface object * * Increase reference count. @@ -286,7 +286,7 @@ libpolkit_module_interface_new (void) * 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++; @@ -294,7 +294,7 @@ libpolkit_module_interface_ref (PolKitModuleInterface *module_interface) } /** - * 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, @@ -302,7 +302,7 @@ libpolkit_module_interface_ref (PolKitModuleInterface *module_interface) * 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--; @@ -325,14 +325,14 @@ libpolkit_module_interface_unref (PolKitModuleInterface *module_interface) } /** - * 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); @@ -340,14 +340,14 @@ libpolkit_module_set_func_initialize (PolKitModuleInterface *module_interface, } /** - * 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); @@ -355,14 +355,14 @@ libpolkit_module_set_func_shutdown (PolKitModuleInterface *module_interface, } /** - * 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); @@ -370,13 +370,13 @@ libpolkit_module_set_func_get_seat_resource_association (PolKitModuleInterface } /** - * 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); @@ -384,13 +384,13 @@ void libpolkit_module_set_func_is_resource_associated_with_seat (PolKitModuleInt } /** - * 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); @@ -398,13 +398,13 @@ void libpolkit_module_set_func_can_session_access_resource (PolKitModuleInterfac } /** - * 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); @@ -412,7 +412,7 @@ void libpolkit_module_set_func_can_caller_access_resource (PolKitModuleInterface } /** - * libpolkit_module_get_func_initialize: + * polkit_module_get_func_initialize: * @module_interface: the module interface * * Get the function pointer. @@ -420,14 +420,14 @@ void libpolkit_module_set_func_can_caller_access_resource (PolKitModuleInterface * 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. @@ -435,14 +435,14 @@ libpolkit_module_get_func_initialize (PolKitModuleInterface *module_interface) * 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. @@ -450,14 +450,14 @@ libpolkit_module_get_func_shutdown (PolKitModuleInterface *module_interface) * 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. @@ -465,14 +465,14 @@ libpolkit_module_get_func_get_seat_resource_association (PolKitModuleInterface * * 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. @@ -480,14 +480,14 @@ libpolkit_module_get_func_is_resource_associated_with_seat (PolKitModuleInterfac * 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. @@ -495,7 +495,7 @@ libpolkit_module_get_func_can_session_access_resource (PolKitModuleInterface *mo * 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; @@ -503,7 +503,7 @@ libpolkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *mod /** - * libpolkit_module_interface_get_control: + * polkit_module_interface_get_control: * @module_interface: the module interface * * Get the control for this module. @@ -511,10 +511,10 @@ libpolkit_module_get_func_can_caller_access_resource (PolKitModuleInterface *mod * 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; } @@ -523,13 +523,13 @@ static const struct { 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. @@ -537,9 +537,9 @@ static const struct { * 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; } @@ -548,7 +548,7 @@ libpolkit_module_control_to_string_representation (PolKitModuleControl module_co } /** - * libpolkit_module_control_from_string_representation: + * polkit_module_control_from_string_representation: * @string: the textual representation * @out_module_control: return location for the value * @@ -557,13 +557,13 @@ libpolkit_module_control_to_string_representation (PolKitModuleControl module_co * 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) { @@ -579,7 +579,7 @@ found: /** - * libpolkit_module_set_user_data: + * polkit_module_set_user_data: * @module_interface: module interface * @user_data: user data to set * @@ -588,22 +588,22 @@ found: * 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; @@ -618,7 +618,7 @@ _check_action (PolKitModuleInterface *module_interface, PolKitAction *action) 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; @@ -655,7 +655,7 @@ _check_users_for_session (PolKitModuleInterface *module_interface, PolKitSession 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); } @@ -669,14 +669,14 @@ _check_users_for_caller (PolKitModuleInterface *module_interface, PolKitCaller * 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 @@ -689,7 +689,7 @@ _check_users_for_caller (PolKitModuleInterface *module_interface, PolKitCaller * * 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, @@ -712,7 +712,7 @@ out: } /** - * 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 @@ -725,7 +725,7 @@ out: * 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, diff --git a/libpolkit/libpolkit-module.h b/polkit/polkit-module.h similarity index 64% rename from libpolkit/libpolkit-module.h rename to polkit/polkit-module.h index bb4bbc9..3e6fed7 100644 --- a/libpolkit/libpolkit-module.h +++ b/polkit/polkit-module.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,14 +24,14 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include +#include +#include struct PolKitModuleInterface; typedef struct PolKitModuleInterface PolKitModuleInterface; @@ -65,7 +65,7 @@ typedef void (*PolKitModuleShutdown) (PolKitModuleInterface *module_interface); * @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 **/ @@ -81,7 +81,7 @@ typedef PolKitResult (*PolKitModuleGetSeatResourceAssociation) (PolKitModuleInte * @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 **/ @@ -98,7 +98,7 @@ typedef PolKitResult (*PolKitModuleIsResourceAssociatedWithSeat) (PolKitModuleIn * @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 **/ @@ -116,7 +116,7 @@ typedef PolKitResult (*PolKitModuleCanSessionAccessResource) (PolKitModuleInterf * @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 **/ @@ -126,43 +126,43 @@ typedef PolKitResult (*PolKitModuleCanCallerAccessResource) (PolKitModuleInterfa 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 @@ -172,36 +172,36 @@ PolKitModuleCanCallerAccessResource libpolkit_module_get_func_can_caller_access_ **/ 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 */ diff --git a/libpolkit/libpolkit-policy-cache.c b/polkit/polkit-policy-cache.c similarity index 83% rename from libpolkit/libpolkit-policy-cache.c rename to polkit/polkit-policy-cache.c index f5549d0..dc9a93a 100644 --- a/libpolkit/libpolkit-policy-cache.c +++ b/polkit/polkit-policy-cache.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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 @@ -70,12 +70,12 @@ _append_entry (PolKitPolicyFile *policy_file, { 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 * @@ -84,7 +84,7 @@ _append_entry (PolKitPolicyFile *policy_file, * 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; @@ -117,7 +117,7 @@ libpolkit_policy_cache_new (const char *dirname, PolKitError **error) 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) { @@ -125,20 +125,20 @@ libpolkit_policy_cache_new (const char *dirname, PolKitError **error) } /* 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. @@ -146,7 +146,7 @@ out: * 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++; @@ -154,7 +154,7 @@ libpolkit_policy_cache_ref (PolKitPolicyCache *policy_cache) } /** - * 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, @@ -162,7 +162,7 @@ libpolkit_policy_cache_ref (PolKitPolicyCache *policy_cache) * objects are decresed by one. **/ void -libpolkit_policy_cache_unref (PolKitPolicyCache *policy_cache) +polkit_policy_cache_unref (PolKitPolicyCache *policy_cache) { GSList *i; @@ -173,7 +173,7 @@ libpolkit_policy_cache_unref (PolKitPolicyCache *policy_cache) 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); @@ -182,13 +182,13 @@ libpolkit_policy_cache_unref (PolKitPolicyCache *policy_cache) } /** - * 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); @@ -199,12 +199,12 @@ libpolkit_policy_cache_debug (PolKitPolicyCache *policy_cache) 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 * @@ -217,7 +217,7 @@ libpolkit_policy_cache_debug (PolKitPolicyCache *policy_cache) * this object. **/ PolKitPolicyFileEntry* -libpolkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache, +polkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache, PolKitAction *action) { char *priv_id; @@ -231,12 +231,12 @@ libpolkit_policy_cache_get_entry (PolKitPolicyCache *policy_cache, 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; } } diff --git a/libpolkit/libpolkit-policy-cache.h b/polkit/polkit-policy-cache.h similarity index 60% rename from libpolkit/libpolkit-policy-cache.h rename to polkit/polkit-policy-cache.h index 12cf00e..7ed7e4d 100644 --- a/libpolkit/libpolkit-policy-cache.h +++ b/polkit/polkit-policy-cache.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,27 +24,27 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include -#include +#include +#include +#include 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 */ diff --git a/libpolkit/libpolkit-policy-default.c b/polkit/polkit-policy-default.c similarity index 79% rename from libpolkit/libpolkit-policy-default.c rename to polkit/polkit-policy-default.c index 1cba253..8ab2110 100644 --- a/libpolkit/libpolkit-policy-default.c +++ b/polkit/polkit-policy-default.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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. @@ -68,21 +68,21 @@ parse_default (const char *key, char *s, const char *group, PolKitResult* target { 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); @@ -101,10 +101,10 @@ parse_default (const char *key, char *s, const char *group, PolKitResult* target 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; @@ -151,12 +151,12 @@ error: } 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. @@ -164,7 +164,7 @@ error: * 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++; @@ -172,7 +172,7 @@ libpolkit_policy_default_ref (PolKitPolicyDefault *policy_default) } /** - * libpolkit_policy_default_unref: + * polkit_policy_default_unref: * @policy_default: the object * * Decreases the reference count of the object. If it becomes zero, @@ -180,7 +180,7 @@ libpolkit_policy_default_ref (PolKitPolicyDefault *policy_default) * 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--; @@ -190,13 +190,13 @@ libpolkit_policy_default_unref (PolKitPolicyDefault *policy_default) } /** - * 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" @@ -205,15 +205,15 @@ libpolkit_policy_default_debug (PolKitPolicyDefault *policy_default) " 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 @@ -223,11 +223,11 @@ libpolkit_policy_default_debug (PolKitPolicyDefault *policy_default) * 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) @@ -236,15 +236,15 @@ libpolkit_policy_default_can_session_access_resource (PolKitPolicyDefault *polic 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) { @@ -265,7 +265,7 @@ out: } /** - * 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 @@ -278,7 +278,7 @@ out: * 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) @@ -288,20 +288,20 @@ libpolkit_policy_default_can_caller_access_resource (PolKitPolicyDefault *policy 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) { diff --git a/libpolkit/libpolkit-policy-default.h b/polkit/polkit-policy-default.h similarity index 64% rename from libpolkit/libpolkit-policy-default.h rename to polkit/polkit-policy-default.h index 19cce21..2dda732 100644 --- a/libpolkit/libpolkit-policy-default.h +++ b/polkit/polkit-policy-default.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,37 +24,37 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include 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 */ diff --git a/libpolkit/libpolkit-policy-file-entry.c b/polkit/polkit-policy-file-entry.c similarity index 72% rename from libpolkit/libpolkit-policy-file-entry.c rename to polkit/polkit-policy-file-entry.c index e07f46e..8e5c172 100644 --- a/libpolkit/libpolkit-policy-file-entry.c +++ b/polkit/polkit-policy-file-entry.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,13 +37,13 @@ #include #include -#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. @@ -63,12 +63,12 @@ struct PolKitPolicyFileEntry }; 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; @@ -76,19 +76,19 @@ _libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKit 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. @@ -96,7 +96,7 @@ error: * 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++; @@ -104,7 +104,7 @@ libpolkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry) } /** - * 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, @@ -112,7 +112,7 @@ libpolkit_policy_file_entry_ref (PolKitPolicyFileEntry *policy_file_entry) * 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--; @@ -120,28 +120,28 @@ libpolkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry) 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. @@ -149,14 +149,14 @@ libpolkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry) * 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. @@ -164,7 +164,7 @@ libpolkit_policy_file_entry_get_id (PolKitPolicyFileEntry *policy_file_entry) * 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; diff --git a/libpolkit/libpolkit-policy-file-entry.h b/polkit/polkit-policy-file-entry.h similarity index 58% rename from libpolkit/libpolkit-policy-file-entry.h rename to polkit/polkit-policy-file-entry.h index f9aeb01..1fd11b5 100644 --- a/libpolkit/libpolkit-policy-file-entry.h +++ b/polkit/polkit-policy-file-entry.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,26 +24,26 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include +#include +#include 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 */ diff --git a/libpolkit/libpolkit-policy-file.c b/polkit/polkit-policy-file.c similarity index 87% rename from libpolkit/libpolkit-policy-file.c rename to polkit/polkit-policy-file.c index 57b6bf8..04b23dc 100644 --- a/libpolkit/libpolkit-policy-file.c +++ b/polkit/polkit-policy-file.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,13 +37,13 @@ #include #include -#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. @@ -61,12 +61,12 @@ struct PolKitPolicyFile 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 * @@ -77,7 +77,7 @@ extern PolKitPolicyFileEntry *_libpolkit_policy_file_entry_new (GKeyFile *keyf * 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; @@ -134,7 +134,7 @@ libpolkit_policy_file_new (const char *path, PolKitError **error) 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); @@ -149,12 +149,12 @@ error: 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. @@ -162,7 +162,7 @@ error: * 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++; @@ -170,7 +170,7 @@ libpolkit_policy_file_ref (PolKitPolicyFile *policy_file) } /** - * 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, @@ -178,7 +178,7 @@ libpolkit_policy_file_ref (PolKitPolicyFile *policy_file) * 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); @@ -186,7 +186,7 @@ libpolkit_policy_file_unref (PolKitPolicyFile *policy_file) 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); @@ -194,7 +194,7 @@ libpolkit_policy_file_unref (PolKitPolicyFile *policy_file) } /** - * 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 @@ -202,7 +202,7 @@ libpolkit_policy_file_unref (PolKitPolicyFile *policy_file) * 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) { diff --git a/libpolkit/libpolkit-policy-file.h b/polkit/polkit-policy-file.h similarity index 69% rename from libpolkit/libpolkit-policy-file.h rename to polkit/polkit-policy-file.h index cdd9096..3e1baf0 100644 --- a/libpolkit/libpolkit-policy-file.h +++ b/polkit/polkit-policy-file.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,14 +24,14 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 -#include +#include +#include struct PolKitPolicyFile; typedef struct PolKitPolicyFile PolKitPolicyFile; @@ -42,19 +42,19 @@ 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 */ diff --git a/libpolkit/libpolkit-resource.c b/polkit/polkit-resource.c similarity index 83% rename from libpolkit/libpolkit-resource.c rename to polkit/polkit-resource.c index dd68b72..70d7d53 100644 --- a/libpolkit/libpolkit-resource.c +++ b/polkit/polkit-resource.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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. @@ -62,14 +62,14 @@ struct PolKitResource }; /** - * 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); @@ -78,7 +78,7 @@ libpolkit_resource_new (void) } /** - * libpolkit_resource_ref: + * polkit_resource_ref: * @resource: the resource object * * Increase reference count @@ -86,7 +86,7 @@ libpolkit_resource_new (void) * Returns: the object **/ PolKitResource * -libpolkit_resource_ref (PolKitResource *resource) +polkit_resource_ref (PolKitResource *resource) { g_return_val_if_fail (resource != NULL, resource); resource->refcount++; @@ -95,7 +95,7 @@ libpolkit_resource_ref (PolKitResource *resource) /** - * libpolkit_resource_unref: + * polkit_resource_unref: * @resource: the resource object * * Decreases the reference count of the object. If it becomes zero, @@ -103,7 +103,7 @@ libpolkit_resource_ref (PolKitResource *resource) * objects are decresed by one. **/ void -libpolkit_resource_unref (PolKitResource *resource) +polkit_resource_unref (PolKitResource *resource) { g_return_if_fail (resource != NULL); @@ -118,7 +118,7 @@ libpolkit_resource_unref (PolKitResource *resource) /** - * libpolkit_resource_set_resource_type: + * polkit_resource_set_resource_type: * @resource: the resource object * @resource_type: type of resource * @@ -127,7 +127,7 @@ libpolkit_resource_unref (PolKitResource *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); @@ -138,7 +138,7 @@ libpolkit_resource_set_resource_type (PolKitResource *resource, const char *res } /** - * libpolkit_resource_set_resource_id: + * polkit_resource_set_resource_id: * @resource: the resource object * @resource_id: identifier of resource * @@ -147,7 +147,7 @@ libpolkit_resource_set_resource_type (PolKitResource *resource, const char *res * 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); @@ -158,7 +158,7 @@ libpolkit_resource_set_resource_id (PolKitResource *resource, const char *resou } /** - * 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. * @@ -167,7 +167,7 @@ libpolkit_resource_set_resource_id (PolKitResource *resource, const char *resou * 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); @@ -180,7 +180,7 @@ libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resou } /** - * 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. * @@ -189,7 +189,7 @@ libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resou * 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); @@ -202,20 +202,20 @@ libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resourc } /** - * 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 @@ -223,7 +223,7 @@ libpolkit_resource_debug (PolKitResource *resource) * 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); diff --git a/libpolkit/libpolkit-resource.h b/polkit/polkit-resource.h similarity index 52% rename from libpolkit/libpolkit-resource.h rename to polkit/polkit-resource.h index 427b6e7..636e730 100644 --- a/libpolkit/libpolkit-resource.h +++ b/polkit/polkit-resource.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,29 +24,29 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 +#include 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 */ diff --git a/libpolkit/libpolkit-result.c b/polkit/polkit-result.c similarity index 69% rename from libpolkit/libpolkit-result.c rename to polkit/polkit-result.c index 05d787e..9193c73 100644 --- a/libpolkit/libpolkit-result.c +++ b/polkit/polkit-result.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,7 +24,7 @@ **************************************************************************/ /** - * SECTION:libpolkit-result + * SECTION:polkit-result * @short_description: Result of PolicyKit queries * * These functions are used to manipulate PolicyKit results. @@ -44,7 +44,7 @@ #include #include -#include "libpolkit-result.h" +#include "polkit-result.h" static const struct { @@ -52,22 +52,22 @@ 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. @@ -75,9 +75,9 @@ static const struct { * 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; } @@ -86,7 +86,7 @@ libpolkit_result_to_string_representation (PolKitResult result) } /** - * libpolkit_result_from_string_representation: + * polkit_result_from_string_representation: * @string: textual representation of a #PolKitResult object * @out_result: return location for #PolKitResult * @@ -95,13 +95,13 @@ libpolkit_result_to_string_representation (PolKitResult result) * 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) { diff --git a/polkit/polkit-result.h b/polkit/polkit-result.h new file mode 100644 index 0000000..475154e --- /dev/null +++ b/polkit/polkit-result.h @@ -0,0 +1,84 @@ +/* -*- 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, + * + * 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 can be included directly, this file may disappear or change contents." +#endif + +#ifndef POLKIT_RESULT_H +#define POLKIT_RESULT_H + +#include + +/** + * 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 */ diff --git a/libpolkit/libpolkit-seat.c b/polkit/polkit-seat.c similarity index 85% rename from libpolkit/libpolkit-seat.c rename to polkit/polkit-seat.c index 8a51991..507a1d4 100644 --- a/libpolkit/libpolkit-seat.c +++ b/polkit/polkit-seat.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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. @@ -61,14 +61,14 @@ struct PolKitSeat }; /** - * 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); @@ -77,7 +77,7 @@ libpolkit_seat_new (void) } /** - * libpolkit_seat_ref: + * polkit_seat_ref: * @seat: the seat object * * Increase reference count. @@ -85,7 +85,7 @@ libpolkit_seat_new (void) * Returns: the object **/ PolKitSeat * -libpolkit_seat_ref (PolKitSeat *seat) +polkit_seat_ref (PolKitSeat *seat) { g_return_val_if_fail (seat != NULL, seat); seat->refcount++; @@ -93,7 +93,7 @@ libpolkit_seat_ref (PolKitSeat *seat) } /** - * libpolkit_seat_unref: + * polkit_seat_unref: * @seat: the seat object * * Decreases the reference count of the object. If it becomes zero, @@ -101,7 +101,7 @@ libpolkit_seat_ref (PolKitSeat *seat) * objects are decresed by one. **/ void -libpolkit_seat_unref (PolKitSeat *seat) +polkit_seat_unref (PolKitSeat *seat) { g_return_if_fail (seat != NULL); seat->refcount--; @@ -112,7 +112,7 @@ libpolkit_seat_unref (PolKitSeat *seat) } /** - * 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 * @@ -121,7 +121,7 @@ libpolkit_seat_unref (PolKitSeat *seat) * 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); @@ -132,7 +132,7 @@ libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref) } /** - * 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. * @@ -141,7 +141,7 @@ libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref) * 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); @@ -150,20 +150,20 @@ libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref) } /** - * 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 @@ -171,7 +171,7 @@ libpolkit_seat_debug (PolKitSeat *seat) * 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); diff --git a/libpolkit/libpolkit-seat.h b/polkit/polkit-seat.h similarity index 62% rename from libpolkit/libpolkit-seat.h rename to polkit/polkit-seat.h index 7de9fe9..5a01714 100644 --- a/libpolkit/libpolkit-seat.h +++ b/polkit/polkit-seat.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,26 +24,26 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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 +#include 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 */ diff --git a/libpolkit/libpolkit-session.c b/polkit/polkit-session.c similarity index 80% rename from libpolkit/libpolkit-session.c rename to polkit/polkit-session.c index c93019c..4a1d118 100644 --- a/libpolkit/libpolkit-session.c +++ b/polkit/polkit-session.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -37,12 +37,12 @@ #include #include -#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. @@ -66,14 +66,14 @@ struct PolKitSession }; /** - * 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); @@ -82,7 +82,7 @@ libpolkit_session_new (void) } /** - * libpolkit_session_ref: + * polkit_session_ref: * @session: The session object * * Increase reference count. @@ -90,7 +90,7 @@ libpolkit_session_new (void) * Returns: the object **/ PolKitSession * -libpolkit_session_ref (PolKitSession *session) +polkit_session_ref (PolKitSession *session) { g_return_val_if_fail (session != NULL, session); session->refcount++; @@ -99,7 +99,7 @@ libpolkit_session_ref (PolKitSession *session) /** - * libpolkit_session_unref: + * polkit_session_unref: * @session: The session object * * Decreases the reference count of the object. If it becomes zero, @@ -107,7 +107,7 @@ libpolkit_session_ref (PolKitSession *session) * objects are decresed by one. **/ void -libpolkit_session_unref (PolKitSession *session) +polkit_session_unref (PolKitSession *session) { g_return_if_fail (session != NULL); session->refcount--; @@ -116,12 +116,12 @@ libpolkit_session_unref (PolKitSession *session) 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 * @@ -130,7 +130,7 @@ libpolkit_session_unref (PolKitSession *session) * 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; @@ -138,7 +138,7 @@ libpolkit_session_set_uid (PolKitSession *session, uid_t uid) } /** - * libpolkit_session_set_ck_objref: + * polkit_session_set_ck_objref: * @session: The session object * @ck_objref: D-Bus object path * @@ -147,7 +147,7 @@ libpolkit_session_set_uid (PolKitSession *session, uid_t uid) * 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); @@ -158,7 +158,7 @@ libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref) } /** - * 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 * @@ -167,7 +167,7 @@ libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref) * 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; @@ -175,7 +175,7 @@ libpolkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_act } /** - * 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 * @@ -184,7 +184,7 @@ libpolkit_session_set_ck_is_active (PolKitSession *session, polkit_bool_t is_act * 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; @@ -192,7 +192,7 @@ libpolkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_loca } /** - * 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 @@ -203,7 +203,7 @@ libpolkit_session_set_ck_is_local (PolKitSession *session, polkit_bool_t is_loca * 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 */ @@ -215,7 +215,7 @@ libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote } /** - * libpolkit_session_set_seat: + * polkit_session_set_seat: * @session: The session object * @seat: a #PolKitSeat object * @@ -227,18 +227,18 @@ libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote * 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 * @@ -247,7 +247,7 @@ libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat) * 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); @@ -256,7 +256,7 @@ libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid) } /** - * 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. * @@ -265,7 +265,7 @@ libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid) * 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); @@ -274,7 +274,7 @@ libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref) } /** - * 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 * @@ -283,7 +283,7 @@ libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref) * 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); @@ -292,7 +292,7 @@ libpolkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_i } /** - * 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 * @@ -301,7 +301,7 @@ libpolkit_session_get_ck_is_active (PolKitSession *session, polkit_bool_t *out_i * 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); @@ -310,7 +310,7 @@ libpolkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is } /** - * 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. @@ -321,7 +321,7 @@ libpolkit_session_get_ck_is_local (PolKitSession *session, polkit_bool_t *out_is * 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); @@ -330,7 +330,7 @@ libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_ } /** - * 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. @@ -340,7 +340,7 @@ libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_ * 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); @@ -349,25 +349,25 @@ libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat) } /** - * 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 @@ -375,7 +375,7 @@ libpolkit_session_debug (PolKitSession *session) * 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); diff --git a/polkit/polkit-session.h b/polkit/polkit-session.h new file mode 100644 index 0000000..3fb4ca0 --- /dev/null +++ b/polkit/polkit-session.h @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ +/*************************************************************************** + * + * polkit-session.h : sessions + * + * Copyright (C) 2007 David Zeuthen, + * + * 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 can be included directly, this file may disappear or change contents." +#endif + +#ifndef POLKIT_SESSION_H +#define POLKIT_SESSION_H + +#include +#include + +#include + +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 */ diff --git a/libpolkit/libpolkit-types.h b/polkit/polkit-types.h similarity index 83% rename from libpolkit/libpolkit-types.h rename to polkit/polkit-types.h index 75b4679..c344161 100644 --- a/libpolkit/libpolkit-types.h +++ b/polkit/polkit-types.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -24,14 +24,14 @@ **************************************************************************/ #if !defined (POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) -#error "Only can be included directly, this file may disappear or change contents." +#error "Only 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. @@ -51,6 +51,6 @@ typedef int polkit_bool_t; # define FALSE 0 #endif -#endif /* LIBPOLKIT_TYPES_H */ +#endif /* POLKIT_TYPES_H */ diff --git a/libpolkit/libpolkit-utils.c b/polkit/polkit-utils.c similarity index 94% rename from libpolkit/libpolkit-utils.c rename to polkit/polkit-utils.c index c0aca7d..9b51a53 100644 --- a/libpolkit/libpolkit-utils.c +++ b/polkit/polkit-utils.c @@ -1,7 +1,7 @@ /* -*- 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, * @@ -35,14 +35,14 @@ #include #include -#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. **/ /** diff --git a/libpolkit/libpolkit-utils.h b/polkit/polkit-utils.h similarity index 86% rename from libpolkit/libpolkit-utils.h rename to polkit/polkit-utils.h index 00512c6..5dee853 100644 --- a/libpolkit/libpolkit-utils.h +++ b/polkit/polkit-utils.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -23,15 +23,15 @@ * **************************************************************************/ -#ifndef LIBPOLKIT_UTILS_H -#define LIBPOLKIT_UTILS_H +#ifndef POLKIT_UTILS_H +#define POLKIT_UTILS_H -#include +#include 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 */ diff --git a/libpolkit/libpolkit.h b/polkit/polkit.h similarity index 61% rename from libpolkit/libpolkit.h rename to polkit/polkit.h index 889b00d..3ce6947 100644 --- a/libpolkit/libpolkit.h +++ b/polkit/polkit.h @@ -1,7 +1,7 @@ /* -*- 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, * @@ -23,26 +23,26 @@ * **************************************************************************/ -#ifndef LIBPOLKIT_H -#define LIBPOLKIT_H +#ifndef POLKIT_H +#define POLKIT_H #define _POLKIT_INSIDE_POLKIT_H 1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #undef _POLKIT_INSIDE_POLKIT_H -#endif /* LIBPOLKIT_H */ +#endif /* POLKIT_H */ diff --git a/tools/Makefile.am b/tools/Makefile.am index 4524d70..eddca37 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -14,16 +14,16 @@ INCLUDES = \ 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 *~ diff --git a/tools/polkit-check-caller.c b/tools/polkit-check-caller.c index 304a282..bfb3ffa 100644 --- a/tools/polkit-check-caller.c +++ b/tools/polkit-check-caller.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include @@ -149,30 +149,30 @@ main (int argc, char *argv[]) } 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; diff --git a/tools/polkit-check-session.c b/tools/polkit-check-session.c index 609e8db..b232737 100644 --- a/tools/polkit-check-session.c +++ b/tools/polkit-check-session.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include @@ -152,35 +152,35 @@ main (int argc, char *argv[]) } 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; diff --git a/tools/polkit-grant.c b/tools/polkit-grant.c index d993b5f..0c5181d 100644 --- a/tools/polkit-grant.c +++ b/tools/polkit-grant.c @@ -37,8 +37,8 @@ #include #include -#include -#include +#include +#include #include @@ -71,15 +71,15 @@ static void 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; @@ -154,11 +154,11 @@ conversation_override_grant_type (PolKitGrant *polkit_grant, PolKitResult auth_t 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")) { @@ -171,8 +171,8 @@ conversation_override_grant_type (PolKitGrant *polkit_grant, PolKitResult auth_t } 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")) { @@ -193,24 +193,24 @@ conversation_override_grant_type (PolKitGrant *polkit_grant, PolKitResult auth_t } 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: @@ -238,7 +238,7 @@ child_watch_func (GPid pid, 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 @@ -253,7 +253,7 @@ io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_d 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; } @@ -368,31 +368,31 @@ main (int argc, char *argv[]) } 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, @@ -405,7 +405,7 @@ main (int argc, char *argv[]) conversation_done, &ud); - if (!libpolkit_grant_initiate_auth (polkit_grant, + if (!polkit_grant_initiate_auth (polkit_grant, action, resource, caller)) { @@ -414,7 +414,7 @@ main (int argc, char *argv[]) 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); diff --git a/tools/polkit-policy-file-validate.c b/tools/polkit-policy-file-validate.c index 3d2353d..4bd1d76 100644 --- a/tools/polkit-policy-file-validate.c +++ b/tools/polkit-policy-file-validate.c @@ -36,7 +36,7 @@ #include #include -#include +#include static void usage (int argc, char *argv[]) @@ -61,13 +61,13 @@ validate_file (const char *file) 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; } -- GitLab