11#include "wvstringlist.h"
14#include "wvlinkerhack.h"
30 assert(gen &&
"Moniker doesn't get us a generator!");
66void UniPermGen::setperm(
const UniConfKey &path, Level level,
70 type2str(type)), val);
74bool UniPermGen::getperm(
const UniConfKey &path,
const Credentials &cred,
81 if (!!owner && cred.user == owner) level = USER;
82 else if (!!
group && cred.groups[
group]) level = GROUP;
85 bool perm = getoneperm(path, level, type);
96bool UniPermGen::getoneperm(
const UniConfKey &path, Level level, Type type)
99 type2str(type))), -1);
107 case READ:
return false;
108 case WRITE:
return false;
109 case EXEC:
return false;
113 return getoneperm(path.
removelast(), level, type);
120 unsigned int user,
unsigned int group,
123 static const int r = 4;
124 static const int w = 2;
125 static const int x = 1;
127 setperm(path, USER, READ, (user & r));
128 setperm(path, USER, WRITE, (user & w));
129 setperm(path, USER, EXEC, (user & x));
131 setperm(path, GROUP, READ, (
group & r));
132 setperm(path, GROUP, WRITE, (
group & w));
133 setperm(path, GROUP, EXEC, (
group & x));
135 setperm(path, WORLD, READ, (world & r));
136 setperm(path, WORLD, WRITE, (world & w));
137 setperm(path, WORLD, EXEC, (world & x));
143 unsigned int user = (mode & 0700) >> 6;
144 unsigned int group = (mode & 0070) >> 3;
145 unsigned int world = (mode & 0007);
151WvString UniPermGen::level2str(Level level)
155 case USER:
return "user";
156 case GROUP:
return "group";
157 case WORLD:
return "world";
159 assert(
false &&
"Something in the Level enum wasn't covered");
160 return WvString::null;
164WvString UniPermGen::type2str(Type type)
168 case READ:
return "read";
169 case WRITE:
return "write";
170 case EXEC:
return "exec";
172 assert(
false &&
"Something in the Type enum wasn't covered");
173 return WvString::null;
An abstract data container that backs a UniConf tree.
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
virtual void set(const UniConfKey &key, WvStringParm value)=0
Stores a string value for a key into the registry.
virtual int str2int(WvStringParm s, int defvalue) const
Converts a string to an integer.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
bool isempty() const
Returns true if this path has zero segments (also known as root).
A UniConfGen that delegates all requests to an inner generator.
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
IUniConfGen * inner() const
Returns the inner generator.
UniPermGen wraps a tree encoding Unix-style permissions, and provides an API for setting and checking...
void setowner(const UniConfKey &path, WvStringParm owner)
get and set the owner for a path
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 setgroup(const UniConfKey &path, WvStringParm group)
get and set the group for a path
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
WvString is an implementation of a simple and efficient printable-string class.
Functions to handle "tcl-style" strings and lists.