#include <unipermgen.h>
Inherits UniFilterGen.
Collaboration diagram for UniPermGen:
read permission allows you to read the value of a key, write allows you to set it (duh). exec allows you to get subkeys. You cannot iterate on a key unless you have exec permission. (This is badly named, but it's inherited from Unix.)
Permissions for 'key' are stored in the subkeys key/owner, key/group, and key/user-read through key/world-write. owner and group store arbitrary text strings, and the remainder are boolean values.
UniPermGen cannot be created with a moniker due to all the extra methods. Instead, just create one with new and mount it with UniConf::mountgen. (Of course, in most cases it will be passed to a UniSecureGen's constructor anyway.)
Definition at line 29 of file unipermgen.h.
Public Types | |
enum | Level { USER = 0, GROUP, WORLD } |
enum | Type { READ = 0, WRITE, EXEC } |
Public Member Functions | |
UniPermGen (UniConfGen *_gen) | |
UniPermGen (WvStringParm moniker) | |
void | setowner (const UniConfKey &path, WvStringParm owner) |
get and set the owner for a path | |
WvString | getowner (const UniConfKey &path) |
void | setgroup (const UniConfKey &path, WvStringParm group) |
get and set the group for a path | |
WvString | getgroup (const UniConfKey &path) |
bool | getread (const UniConfKey &path, const Credentials &cred) |
Return true if a user with the given credentials is allowed to read/write/exec the given path. | |
bool | getwrite (const UniConfKey &path, const Credentials &cred) |
bool | getexec (const UniConfKey &path, const Credentials &cred) |
bool | getperm (const UniConfKey &path, const Credentials &cred, Type type) |
void | setread (const UniConfKey &path, Level level, bool read) |
void | setwrite (const UniConfKey &path, Level level, bool write) |
void | setexec (const UniConfKey &path, Level level, bool exec) |
void | setperm (const UniConfKey &path, Level level, Type type, bool val) |
void | chmod (const UniConfKey &path, unsigned int owner, unsigned int group, unsigned int world) |
Set permissions for path using Unix style chmod (with the second form, be sure to use octal). | |
void | chmod (const UniConfKey &path, unsigned int mode) |
UniConfGen * | inner () const |
Returns the inner generator. | |
virtual void | commit () |
Commits any changes. | |
virtual bool | refresh () |
Refreshes information about a key recursively. | |
virtual WvString | get (const UniConfKey &key) |
Fetches a string value for a key from the registry. | |
virtual void | set (const UniConfKey &key, WvStringParm value) |
Stores a string value for a key into the registry. | |
virtual bool | exists (const UniConfKey &key) |
Without fetching its value, returns true if a key exists. | |
virtual bool | haschildren (const UniConfKey &key) |
Returns true if a key has children. | |
virtual bool | isok () |
Determines if the generator is usable and working properly. | |
virtual Iter * | iterator (const UniConfKey &key) |
Returns an iterator over the children of the specified key. | |
void | setcallback (const UniConfGenCallback &callback, void *userdata) |
Sets the callback for change notification. | |
void | dispatch_delta (const UniConfKey &key, WvStringParm value) |
Immediately sends notification that a key has possibly changed. | |
void | hold_delta () |
Pauses notifications until matched with a call to unhold_delta(). | |
void | unhold_delta () |
Resumes notifications when each hold_delta() has been matched. | |
void | clear_delta () |
Clears the list of pending notifications without sending them. | |
void | flush_delta () |
Flushes the list of pending notifications by sending them. | |
void | delta (const UniConfKey &key, WvStringParm value) |
Call this when a key's value or children have possibly changed. | |
virtual int | str2int (WvStringParm s, int defvalue) const |
Converts a string to an integer. | |
virtual unsigned int | addRef () |
virtual unsigned int | release () |
Static Public Member Functions | |
WvString | level2str (Level l) |
WvString | type2str (Type t) |
Protected Member Functions | |
void | setinner (UniConfGen *inner) |
Rebinds the inner generator and prepares its callback. | |
virtual void | gencallback (const UniConfKey &key, WvStringParm value, void *userdata) |
Called by inner generator when a key changes. | |
void | seterror (WvStringParm error) |
Raises an error condition. |
|
Definition at line 36 of file unipermgen.h. Referenced by getperm(). |
|
Definition at line 39 of file unipermgen.h. |
|
Definition at line 17 of file unipermgen.cc. References UniPermGen(). Referenced by UniPermGen(). |
|
Definition at line 23 of file unipermgen.cc. References UniPermGen(), and WvStringParm. |
|
Implements IObject. |
|
Definition at line 127 of file unipermgen.cc. References chmod(). |
|
Set permissions for path using Unix style chmod (with the second form, be sure to use octal).
Definition at line 106 of file unipermgen.cc. References chmod(), EXEC, GROUP, READ, setperm(), USER, WORLD, and WRITE. Referenced by chmod(). |
|
Clears the list of pending notifications without sending them. Does not affect the hold nesting count. Definition at line 38 of file uniconfgen.cc. |
|
Commits any changes. The default implementation does nothing. Reimplemented from UniConfGen. Definition at line 35 of file unifiltergen.cc. References UniConfGen::commit(). |
|
Call this when a key's value or children have possibly changed. If the hold nesting count is 0, the notification is sent immediately. Otherwise it is added to a pending list for later. Definition at line 69 of file uniconfgen.cc. References UniConfGen::delta(), UniConfGen::dispatch_delta(), UniConfGen::hold_delta(), and UniConfGen::unhold_delta(). Referenced by UniConfGen::delta(). |
|
Immediately sends notification that a key has possibly changed. Takes care of the details of invoking the callback. Note: You probably want to be using delta() instead. Definition at line 62 of file uniconfgen.cc. References UniConfGen::dispatch_delta(), and WvStringParm. Referenced by UniConfGen::delta(), UniConfGen::dispatch_delta(), and UniConfGen::flush_delta(). |
|
Without fetching its value, returns true if a key exists. This is provided because it is often more efficient to test existance than to actually retrieve the value. The default implementation returns !get(key).isnull(). Reimplemented from UniConfGen. Reimplemented in UniSecureGen. Definition at line 59 of file unifiltergen.cc. References UniConfGen::exists(), and UniFilterGen::exists(). Referenced by UniFilterGen::exists(). |
|
Flushes the list of pending notifications by sending them. Does not affect the hold nesting count. Definition at line 44 of file uniconfgen.cc. References UniConfGen::dispatch_delta(). Referenced by UniConfGen::unhold_delta(). |
|
Called by inner generator when a key changes. The default implementation calls delta(key). Definition at line 83 of file unifiltergen.cc. References UniFilterGen::gencallback(). Referenced by UniFilterGen::gencallback(), and UniFilterGen::setinner(). |
|
Fetches a string value for a key from the registry. If the key doesn't exist, the return value is WvString::null. Implements UniConfGen. Reimplemented in UniDefGen, and UniSecureGen. Definition at line 47 of file unifiltergen.cc. References UniConfGen::get(), and UniFilterGen::get(). Referenced by UniFilterGen::get(). |
|
Definition at line 67 of file unipermgen.h. References EXEC, getexec(), and getperm(). Referenced by getexec(). |
|
Definition at line 53 of file unipermgen.cc. References UniConfGen::get(), getgroup(), UniFilterGen::inner(), UniConfKey::isempty(), WvFastString::isnull(), and UniConfKey::removelast(). Referenced by getgroup(), and getperm(). |
|
Definition at line 38 of file unipermgen.cc. References UniConfGen::get(), getowner(), UniFilterGen::inner(), UniConfKey::isempty(), WvFastString::isnull(), and UniConfKey::removelast(). Referenced by getowner(), and getperm(). |
|
Definition at line 68 of file unipermgen.cc. References getgroup(), getowner(), getperm(), GROUP, UniPermGen::Credentials::groups, Level, USER, UniPermGen::Credentials::user, and WORLD. Referenced by getexec(), getperm(), getread(), and getwrite(). |
|
Return true if a user with the given credentials is allowed to read/write/exec the given path.
Definition at line 63 of file unipermgen.h. References getperm(), getread(), and READ. Referenced by getread(). |
|
Definition at line 65 of file unipermgen.h. References getperm(), getwrite(), and WRITE. Referenced by getwrite(). |
|
Returns true if a key has children. This is provided because it is often more efficient to test existance than to actually retrieve the keys. The default implementation uses the iterator returned by iterator() to test whether the child has any keys. Subclasses are strongly encouraged to provide a better implementation. Reimplemented from UniConfGen. Reimplemented in UniSecureGen. Definition at line 65 of file unifiltergen.cc. References UniConfGen::haschildren(), and UniFilterGen::haschildren(). Referenced by UniFilterGen::haschildren(). |
|
Pauses notifications until matched with a call to unhold_delta(). While paused, notification events are placed into a pending list. Redundant notifications may be discarded. Use this to safeguard non-reentrant code. Definition at line 23 of file uniconfgen.cc. Referenced by UniMountTreeGen::commit(), UniMountGen::commit(), UniConfGen::delta(), UniClientGen::deltacb(), UniMountTreeGen::exists(), UniMountTreeGen::get(), UniMountTreeGen::haschildren(), UniConfGen::haschildren(), UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniMountTreeGen::refresh(), UniMountGen::refresh(), UniIniGen::refresh(), UniMountTreeGen::KeyIter::rewind(), UniTempGen::set(), UniClientGen::set(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniMountTreeGen::whichmount(). |
|
Returns the inner generator.
Definition at line 36 of file unifiltergen.h. Referenced by getgroup(), getowner(), setgroup(), setowner(), and setperm(). |
|
Determines if the generator is usable and working properly. The default implementation always returns true. Reimplemented from UniConfGen. Definition at line 71 of file unifiltergen.cc. References UniConfGen::isok(). |
|
Returns an iterator over the children of the specified key. Must not return NULL; consider returning a NullIter instead. The caller takes ownership of the returned iterator and is responsible for deleting it when finished. Implements UniConfGen. Reimplemented in UniSecureGen. Definition at line 77 of file unifiltergen.cc. References UniConfGen::iterator(), and UniFilterGen::iterator(). Referenced by UniFilterGen::iterator(). |
|
Definition at line 137 of file unipermgen.cc. References GROUP, level2str(), USER, and WORLD. Referenced by level2str(), and setperm(). |
|
Refreshes information about a key recursively. May discard uncommitted data. The default implementation always returns true. Reimplemented from UniConfGen. Definition at line 41 of file unifiltergen.cc. References UniConfGen::refresh(). |
|
Implements IObject. |
|
Stores a string value for a key into the registry. If the value is WvString::null, the key is deleted. Returns true on success. Implements UniConfGen. Reimplemented in UniReadOnlyGen, and UniSecureGen. Definition at line 53 of file unifiltergen.cc. References UniConfGen::set(), UniFilterGen::set(), and WvStringParm. Referenced by UniFilterGen::set(). |
|
Sets the callback for change notification. Must not be reimplemented by subclasses. Definition at line 137 of file uniconfgen.cc. References UniConfGen::setcallback(). Referenced by UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniConfGen::setcallback(), UniFilterGen::setinner(), UniCacheGen::UniCacheGen(), UniConfRoot::UniConfRoot(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniConfRoot::~UniConfRoot(). |
|
Raises an error condition.
Definition at line 57 of file uniconfgen.h. References UniConfGen::seterror(). Referenced by UniConfGen::seterror(). |
|
Definition at line 76 of file unipermgen.h. References EXEC, setexec(), and setperm(). Referenced by setexec(). |
|
get and set the group for a path
Definition at line 47 of file unipermgen.cc. References UniFilterGen::inner(), UniConfGen::set(), and setgroup(). Referenced by setgroup(). |
|
Rebinds the inner generator and prepares its callback. The previous generator is NOT destroyed. "inner" must not be null. Definition at line 24 of file unifiltergen.cc. References UniFilterGen::gencallback(), UniConfGen::setcallback(), UniFilterGen::setinner(), and UniConfGenCallback. Referenced by UniFilterGen::setinner(), and UniFilterGen::UniFilterGen(). |
|
get and set the owner for a path
Definition at line 32 of file unipermgen.cc. References UniFilterGen::inner(), UniConfGen::set(), and setowner(). Referenced by setowner(). |
|
Definition at line 62 of file unipermgen.cc. References UniFilterGen::inner(), level2str(), UniConfGen::set(), setperm(), and type2str(). Referenced by chmod(), setexec(), setperm(), setread(), and setwrite(). |
|
Definition at line 72 of file unipermgen.h. References READ, setperm(), and setread(). Referenced by setread(). |
|
Definition at line 74 of file unipermgen.h. References setperm(), setwrite(), and WRITE. Referenced by setwrite(). |
|
Converts a string to an integer. If the string is null or not recognized, return defvalue. This is here to support the common str2int(get(key)). The default implementation recognizes the booleans 'true', 'yes', 'on' and 'enabled' as 1, and 'false', 'no', 'off' and 'disabled' as 0. Definition at line 105 of file uniconfgen.cc. References WvFastString::cstr(), WvFastString::isnull(), and UniConfGen::str2int(). Referenced by UniConfGen::str2int(). |
|
Definition at line 150 of file unipermgen.cc. References EXEC, READ, type2str(), and WRITE. Referenced by setperm(), and type2str(). |
|
Resumes notifications when each hold_delta() has been matched. On resumption, dispatches all pending notifications except those that were destined to watches that were removed. Use this to safeguard non-reentrant code. Definition at line 29 of file uniconfgen.cc. References UniConfGen::flush_delta(). Referenced by UniMountTreeGen::commit(), UniMountGen::commit(), UniConfGen::delta(), UniClientGen::deltacb(), UniMountTreeGen::exists(), UniMountTreeGen::get(), UniMountTreeGen::haschildren(), UniConfGen::haschildren(), UniMountTreeGen::mountgen(), UniMountGen::mountgen(), UniMountTreeGen::refresh(), UniMountGen::refresh(), UniIniGen::refresh(), UniMountTreeGen::KeyIter::rewind(), UniTempGen::set(), UniClientGen::set(), UniMountTreeGen::unmount(), UniMountGen::unmount(), and UniMountTreeGen::whichmount(). |