Commit ce556c72 authored by David Zeuthen's avatar David Zeuthen
Browse files

mass renaming of classes

 Privilege -> Action
 PrivilegeFile -> PolicyFile
 PrivilegeFileEntry -> PolicyFileEntry
 PrivilegeCache -> PolicyCache

Hopefully it makes a bit more sense now.
parent 8035e5d1
## Process this file with automake to produce Makefile.in
SUBDIRS = libpolkit modules doc tools privileges
SUBDIRS = libpolkit modules doc tools policy
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libpolkit.pc
......
......@@ -173,7 +173,7 @@ doc/api/libpolkit/version.xml
doc/spec/Makefile
doc/spec/polkit-spec.xml.in
doc/man/Makefile
privileges/Makefile
policy/Makefile
modules/Makefile
modules/default/Makefile
modules/allow-all/Makefile
......
......@@ -67,11 +67,11 @@
<xi:include href="xml/libpolkit-error.xml"/>
<xi:include href="xml/libpolkit-result.xml"/>
<xi:include href="xml/libpolkit-context.xml"/>
<xi:include href="xml/libpolkit-privilege.xml"/>
<xi:include href="xml/libpolkit-privilege-file.xml"/>
<xi:include href="xml/libpolkit-privilege-file-entry.xml"/>
<xi:include href="xml/libpolkit-privilege-cache.xml"/>
<xi:include href="xml/libpolkit-privilege-default.xml"/>
<xi:include href="xml/libpolkit-action.xml"/>
<xi:include href="xml/libpolkit-policy-file.xml"/>
<xi:include href="xml/libpolkit-policy-file-entry.xml"/>
<xi:include href="xml/libpolkit-policy-default.xml"/>
<xi:include href="xml/libpolkit-policy-cache.xml"/>
<xi:include href="xml/libpolkit-resource.xml"/>
<xi:include href="xml/libpolkit-seat.xml"/>
<xi:include href="xml/libpolkit-session.xml"/>
......
if MAN_PAGES_ENABLED
MAN_IN_FILES = polkit-check-caller.1.in polkit-check-session.1.in polkit-privilege-file-validate.1.in PolicyKit.8.in polkit-module-default.8.in polkit-module-allow-all.8.in polkit-module-deny-all.8.in polkit-module-run-program.8.in polkit-module-builtins.8.in
MAN_IN_FILES = polkit-check-caller.1.in polkit-check-session.1.in polkit-policy-file-validate.1.in PolicyKit.8.in polkit-module-default.8.in polkit-module-allow-all.8.in polkit-module-deny-all.8.in polkit-module-run-program.8.in polkit-module-builtins.8.in
man_MANS = $(MAN_IN_FILES:.in=)
......
......@@ -28,8 +28,8 @@ Type of resource.
.I "--resource"
Identifier of resource.
.TP
.I "--privilege"
The privilege to check.
.I "--action"
The action to check.
.TP
.I "--caller"
The caller to check for. Must be the callers unique name on the D-Bus
......
......@@ -28,8 +28,8 @@ Type of resource.
.I "--resource"
Identifier of resource.
.TP
.I "--privilege"
The privilege to check.
.I "--action"
The action to check.
.TP
.I "--session"
The session to check for. Must be a ConsoleKit object path. If
......
......@@ -4,15 +4,15 @@
.\"
.TH POLKIT-MODULE-ALLOW-ALL 8
.SH NAME
polkit-module-allow-all \- grant access to all privileges
polkit-module-allow-all \- permit any action
.SH SYNOPSIS
.PP
.B polkit-module-allow-all.so
.SH DESCRIPTION
.PP
This PolicyKit module will allow access to any privilege regardless of
the entity requesting it, what the requested privilege is and what
resource is involved.
This PolicyKit module will permit any action regardless of the entity
requesting it, what the requested action is and what resource is
involved.
For more information about the big picture refer to the \fIPolicyKit
spec\fP which can be found in
......@@ -43,7 +43,7 @@ on how to subscribe.
\&\fIpolkit-module-default\fR\|(8),
\&\fIpolkit-module-deny-all\fR\|(8),
\&\fIpolkit-module-run-program\fR\|(8),
\&\fI@sysconfdir@/PolicyKit/privileges\fR\|,
\&\fI@sysconfdir@/PolicyKit/policy\fR\|,
\&\fI@sysconfdir@/PolicyKit/PolicyKit.conf\fR\|
.SH AUTHOR
......
......@@ -7,7 +7,7 @@
polkit-module-builtins \- options that apply to any PolicyKit module
.SH SYNOPSIS
.PP
.B any-module.so [privilege=<regexp>] [user=<username> ...]
.B any-module.so [action=<regexp>] [user=<username> ...]
.SH DESCRIPTION
.PP
This manual page describes options that can be used for any PolicyKit
......@@ -21,10 +21,10 @@ depending on the distribution.
.SH OPTIONS
.TP 3n
.B privilege=<regexp>
Only consider requests where the privilege name matches the given
.B action=<regexp>
Only consider requests where the action name matches the given
regular expression. Example:
.B privilege=hal-storage-mount*
.B action=hal-storage-mount*
.TP 3n
.B user=<username>
......@@ -47,7 +47,7 @@ on how to subscribe.
\&\fIPolicyKit\fR\|(8),
\&\fIpolkit-module-default\fR\|(8),
\&\fIpolkit-module-deny-all\fR\|(8),
\&\fI@sysconfdir@/PolicyKit/privileges\fR\|,
\&\fI@sysconfdir@/PolicyKit/policy\fR\|,
\&\fI@sysconfdir@/PolicyKit/PolicyKit.conf\fR\|
.SH AUTHOR
......
......@@ -4,14 +4,14 @@
.\"
.TH POLKIT-MODULE-DEFAULT 8
.SH NAME
polkit-module-default \- use default policy for privileges
polkit-module-default \- use default policy for actions
.SH SYNOPSIS
.PP
.B standard polkit-module-default.so
.SH DESCRIPTION
.PP
This PolicyKit module uses the default policy as specified (and
required) for by the privilege definition file for a given privilege.
required) for by the policy definition file for a given action.
For more information about the big picture refer to the \fIPolicyKit
spec\fP which can be found in
......@@ -30,7 +30,7 @@ on how to subscribe.
\&\fIPolicyKit\fR\|(8),
\&\fIpolkit-module-allow-all\fR\|(8),
\&\fIpolkit-module-deny-all\fR\|(8),
\&\fI@sysconfdir@/PolicyKit/privileges\fR\|,
\&\fI@sysconfdir@/PolicyKit/policy\fR\|,
\&\fI@sysconfdir@/PolicyKit/PolicyKit.conf\fR\|
.SH AUTHOR
......
......@@ -4,15 +4,15 @@
.\"
.TH POLKIT-MODULE-DENY-ALL 8
.SH NAME
polkit-module-deny-all \- grant access to all privileges
polkit-module-deny-all \- deny any action
.SH SYNOPSIS
.PP
.B polkit-module-deny-all.so
.SH DESCRIPTION
.PP
This PolicyKit module will deny access to any privilege regardless of
the entity requesting it, what the requested privilege is and what
resource is involved.
This PolicyKit module will deny any action regardless of the entity
requesting it, what the requested action is and what resource is
involved.
For more information about the big picture refer to the \fIPolicyKit
spec\fP which can be found in
......@@ -42,7 +42,7 @@ on how to subscribe.
\&\fIpolkit-module-default\fR\|(8),
\&\fIpolkit-module-allow-all\fR\|(8),
\&\fIpolkit-module-run-program\fR\|(8),
\&\fI@sysconfdir@/PolicyKit/privileges\fR\|,
\&\fI@sysconfdir@/PolicyKit/policy\fR\|,
\&\fI@sysconfdir@/PolicyKit/PolicyKit.conf\fR\|
.SH AUTHOR
......
......@@ -11,7 +11,7 @@ polkit-module-run-program \- determine policy by running a program
\fBpolkit-module-run-program.so\fR program=\fI<program>\fR
.SH DESCRIPTION
.PP
This PolicyKit module will run a program every time a privilege is
This PolicyKit module will run a program every time an action is
requested. For more information about the big picture refer to the
\fIPolicyKit spec\fP which can be found in
.I "@docdir@/spec/polkit-spec.html"
......@@ -22,9 +22,9 @@ depending on the distribution.
.TP 3n
.B program=<program>
Absolute path to program to run; this is a mandatory option. Examples:
.B privilege=/usr/bin/my-program
.B program=/usr/bin/my-program
or
.B privilege="/path/to/program --foo --bar"
.B program="/path/to/program --foo --bar"
.SH DESCRIPTION
This module will invoke the given program and will export a minimal
......@@ -51,7 +51,7 @@ enumeration):
.I
.TP
.B unknown
The passed privilege is unknown.
The passed action is unknown.
.TP
.B not_authorized
The mechanism / caller (e.g. the program using
......@@ -98,8 +98,8 @@ bus daemon, the environment will contain:
To identify the request to be concerning a decision about a caller on
the system message bus.
.TP
.B POLKIT_PRIVILEGE_ID
Privilege identifier
.B POLKIT_ACTION_ID
An identifier for the action
.TP
.B POLKIT_RESOURCE_ID
Resource identifier
......@@ -142,8 +142,8 @@ contain:
.B POLKIT_REQUEST_SESSION=1
To identify the request to be session-wide.
.TP
.B POLKIT_PRIVILEGE_ID
Privilege identifier
.B POLKIT_ACTION_ID
An identifier for the action
.TP
.B POLKIT_RESOURCE_ID
Resource identifier
......@@ -190,7 +190,7 @@ on how to subscribe.
\&\fIpolkit-module-default\fR\|(8),
\&\fIpolkit-module-allow-all\fR\|(8),
\&\fIpolkit-module-deny-all\fR\|(8),
\&\fI@sysconfdir@/PolicyKit/privileges\fR\|,
\&\fI@sysconfdir@/PolicyKit/policy\fR\|,
\&\fI@sysconfdir@/PolicyKit/PolicyKit.conf\fR\|
.SH AUTHOR
......
.\"
.\" polkit-privilege-file-validate manual page.
.\" polkit-policy-file-validate manual page.
.\" Copyright (C) 2007 David Zeuthen <david@fubar.dk>
.\"
.TH POLKIT-PRIVILEGE-FILE-VALIDATE 1
.TH POLKIT-POLICY-FILE-VALIDATE 1
.SH NAME
polkit-privilege-file-validate \- check access
polkit-policy-file-validate \- check access
.SH SYNOPSIS
.PP
.B polkit-privilege-file-validate
<privilege-files>
.B polkit-policy-file-validate
<policy-files>
.SH DESCRIPTION
\fIpolkit-privilege-file-validate\fP is used to validate PolicyKit
privilege definition files. These are normally stored in the
.I "@sysconfdir@/PolicyKit/privileges"
\fIpolkit-policy-file-validate\fP is used to validate PolicyKit
policy definition files. These are normally stored in the
.I "@sysconfdir@/PolicyKit/policy"
directory. For more information about the big picture
refer to the \fIPolicyKit spec\fP which can be found in
.I "@docdir@/spec/polkit-spec.html"
......
......@@ -21,33 +21,33 @@ libpolkitinclude_HEADERS = \
libpolkit-error.h \
libpolkit-result.h \
libpolkit-context.h \
libpolkit-privilege.h \
libpolkit-action.h \
libpolkit-resource.h \
libpolkit-seat.h \
libpolkit-session.h \
libpolkit-caller.h \
libpolkit-privilege-file-entry.h \
libpolkit-privilege-file.h \
libpolkit-privilege-cache.h \
libpolkit-privilege-default.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-error.h libpolkit-error.c \
libpolkit-result.h libpolkit-result.c \
libpolkit-context.h libpolkit-context.c \
libpolkit-privilege.h libpolkit-privilege.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-privilege-file-entry.h libpolkit-privilege-file-entry.c \
libpolkit-privilege-file.h libpolkit-privilege-file.c \
libpolkit-privilege-cache.h libpolkit-privilege-cache.c \
libpolkit-privilege-default.h libpolkit-privilege-default.c \
libpolkit-debug.h libpolkit-debug.c \
libpolkit-module.h libpolkit-module.c
libpolkit_la_SOURCES = \
libpolkit.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-module.h libpolkit-module.c
libpolkit_la_LIBADD = @GLIB_LIBS@ @DBUS_LIBS@ -ldl
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
* libpolkit-privilege.c : privilege
* libpolkit-action.c : action
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
......@@ -38,123 +38,122 @@
#include <glib.h>
#include "libpolkit-debug.h"
#include "libpolkit-privilege.h"
#include "libpolkit-action.h"
/**
* SECTION:libpolkit-privilege
* @short_description: Privileges.
* SECTION:libpolkit-action
* @short_description: Actions.
*
* This class is used to represent a privilege. TODO: describe what a privilege really is.
* This class is used to represent an action. TODO: describe what a action really is.
**/
/**
* PolKitPrivilege:
* PolKitAction:
*
* Objects of this class are used to record information about a
* privilege.
* Objects of this class are used to record information about an action.
**/
struct PolKitPrivilege
struct PolKitAction
{
int refcount;
char *id;
};
/**
* libpolkit_privilege_new:
* libpolkit_action_new:
*
* Create a new #PolKitPrivilege object.
* Create a new #PolKitAction object.
*
* Returns: the new object
**/
PolKitPrivilege *
libpolkit_privilege_new (void)
PolKitAction *
libpolkit_action_new (void)
{
PolKitPrivilege *privilege;
privilege = g_new0 (PolKitPrivilege, 1);
privilege->refcount = 1;
return privilege;
PolKitAction *action;
action = g_new0 (PolKitAction, 1);
action->refcount = 1;
return action;
}
/**
* libpolkit_privilege_ref:
* @privilege: the privilege object
* libpolkit_action_ref:
* @action: the action object
*
* Increase reference count.
*
* Returns: the object
**/
PolKitPrivilege *
libpolkit_privilege_ref (PolKitPrivilege *privilege)
PolKitAction *
libpolkit_action_ref (PolKitAction *action)
{
g_return_val_if_fail (privilege != NULL, privilege);
privilege->refcount++;
return privilege;
g_return_val_if_fail (action != NULL, action);
action->refcount++;
return action;
}
/**
* libpolkit_privilege_unref:
* @privilege: the privilege object
* libpolkit_action_unref:
* @action: the action object
*
* Decreases the reference count of the object. If it becomes zero,
* the object is freed. Before freeing, reference counts on embedded
* objects are decresed by one.
**/
void
libpolkit_privilege_unref (PolKitPrivilege *privilege)
libpolkit_action_unref (PolKitAction *action)
{
g_return_if_fail (privilege != NULL);
privilege->refcount--;
if (privilege->refcount > 0)
g_return_if_fail (action != NULL);
action->refcount--;
if (action->refcount > 0)
return;
g_free (privilege->id);
g_free (privilege);
g_free (action->id);
g_free (action);
}
/**
* libpolkit_privilege_set_privilege_id:
* @privilege: the privilege object
* @privilege_id: privilege identifier
* libpolkit_action_set_action_id:
* @action: the action object
* @action_id: action identifier
*
* Set the privilege identifier
* Set the action identifier
**/
void
libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char *privilege_id)
libpolkit_action_set_action_id (PolKitAction *action, const char *action_id)
{
g_return_if_fail (privilege != NULL);
if (privilege->id != NULL)
g_free (privilege->id);
privilege->id = g_strdup (privilege_id);
g_return_if_fail (action != NULL);
if (action->id != NULL)
g_free (action->id);
action->id = g_strdup (action_id);
}
/**
* libpolkit_privilege_get_privilege_id:
* @privilege: the privilege object
* @out_privilege_id: Returns the privilege identifier. The caller shall not free this string.
* libpolkit_action_get_action_id:
* @action: the action object
* @out_action_id: Returns the action identifier. The caller shall not free this string.
*
* Get the privilege identifier.
* Get the action identifier.
*
* Returns: TRUE iff the value was returned.
**/
gboolean
libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id)
{
g_return_val_if_fail (privilege != NULL, FALSE);
g_return_val_if_fail (out_privilege_id != NULL, FALSE);
if (privilege->id == NULL)
g_return_val_if_fail (action != NULL, FALSE);
g_return_val_if_fail (out_action_id != NULL, FALSE);
if (action->id == NULL)
return FALSE;
*out_privilege_id = privilege->id;
*out_action_id = action->id;
return TRUE;
}
/**
* libpolkit_privilege_debug:
* @privilege: the object
* libpolkit_action_debug:
* @action: the object
*
* Print debug details
**/
void
libpolkit_privilege_debug (PolKitPrivilege *privilege)
libpolkit_action_debug (PolKitAction *action)
{
g_return_if_fail (privilege != NULL);
_pk_debug ("PolKitPrivilege: refcount=%d id=%s", privilege->refcount, privilege->id);
g_return_if_fail (action != NULL);
_pk_debug ("PolKitAction: refcount=%d id=%s", action->refcount, action->id);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/***************************************************************************
*
* libpolkit-privilege-file.h : privilege files
* libpolkit-action.h : actions
*
* Copyright (C) 2007 David Zeuthen, <david@fubar.dk>
*
......@@ -23,24 +23,25 @@
*
**************************************************************************/
#ifndef LIBPOLKIT_PRIVILEGE_FILE_H
#define LIBPOLKIT_PRIVILEGE_FILE_H
#ifndef LIBPOLKIT_ACTION_H
#define LIBPOLKIT_ACTION_H
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <glib.h>
#include <libpolkit/libpolkit-privilege-file-entry.h>
struct PolKitAction;
typedef struct PolKitAction PolKitAction;
struct PolKitPrivilegeFile;
typedef struct PolKitPrivilegeFile PolKitPrivilegeFile;
PolKitAction *libpolkit_action_new (void);
PolKitAction *libpolkit_action_ref (PolKitAction *action);
void libpolkit_action_unref (PolKitAction *action);
void libpolkit_action_set_action_id (PolKitAction *action, const char *action_id);
gboolean libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id);
PolKitPrivilegeFile *libpolkit_privilege_file_new (const char *path, GError **error);
PolKitPrivilegeFile *libpolkit_privilege_file_ref (PolKitPrivilegeFile *privilege_file);
GSList *libpolkit_privilege_file_get_entries (PolKitPrivilegeFile *privilege_file);
void libpolkit_privilege_file_unref (PolKitPrivilegeFile *privilege_file);
void libpolkit_action_debug (PolKitAction *action);
#endif /* LIBPOLKIT_PRIVILEGE_FILE_H */
#endif /* LIBPOLKIT_ACTION_H */
......@@ -39,7 +39,7 @@
#include <glib.h>
#include "libpolkit-debug.h"
#include "libpolkit-context.h"
#include "libpolkit-privilege-cache.h"
#include "libpolkit-policy-cache.h"
#include "libpolkit-module.h"
/**
......@@ -71,9 +71,9 @@ struct PolKitContext
PolKitContextFileMonitorAddWatch file_monitor_add_watch_func;
PolKitContextFileMonitorRemoveWatch file_monitor_remove_watch_func;
char *priv_dir;
char *policy_dir;
PolKitPrivilegeCache *priv_cache;
PolKitPolicyCache *priv_cache;
GSList *modules;
};
......@@ -83,7 +83,7 @@ struct PolKitContext
*
* Create a new context
*
* Returns: the #PolKitPrivilegeCache object
* Returns: the object
**/
PolKitContext *
libpolkit_context_new (void)
......@@ -236,15 +236,15 @@ _config_file_events (PolKitContext *pk_context,
}
static void
_privilege_dir_events (PolKitContext *pk_context,
_policy_dir_events (PolKitContext *pk_context,
PolKitContextFileMonitorEvent event_mask,
const char *path,
gpointer user_data)
{
/* mark cache of privilege files as stale.. (will be populated on-demand, see _get_cache()) */
/* 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->priv_dir);
libpolkit_privilege_cache_unref (pk_context->priv_cache);
_pk_debug ("Something happened in %s - invalidating cache", pk_context->policy_dir);
libpolkit_policy_cache_unref (pk_context->priv_cache);
pk_context->priv_cache = NULL;
}
......@@ -260,8 +260,8 @@ _privilege_dir_events (PolKitContext *pk_context,
* @error: return location for error
*
* Initializes a new context; loads PolicyKit files from
* /etc/PolicyKit/privileges unless the environment variable
* $POLKIT_PRIVILEGE_DIR points to a location.
* /etc/PolicyKit/policy unless the environment variable
* $POLKIT_POLICY_DIR points to a location.
*
* Returns: #FALSE if @error was set, otherwise #TRUE
**/
......@@ -270,13 +270,13 @@ libpolkit_context_init (PolKitContext *pk_context, GError **error)
{
const char *dirname;
dirname = getenv ("POLKIT_PRIVILEGE_DIR");
dirname = getenv ("POLKIT_POLICY_DIR");
if (dirname != NULL) {
pk_context->priv_dir = g_strdup (dirname);
pk_context->policy_dir = g_strdup (dirname);
} else {
pk_context->priv_dir = g_strdup (PACKAGE_SYSCONF_DIR "/PolicyKit/privileges");