permissions utilities #42

Parent #72Owner #361Flags obsolete1, readSource hellcore/hellcore.db

Aliases: Generic Utilities Package

5 verbs · 11 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
controlsthis none thisrxd#423
applythis none thisrxd#4222
callerthis none thisrxd#428
controls_prop*erty controls_verbthis none thisrxd#427
_chparentthis none thisrxd#4223

Properties

PropertyDefinerFlagsOwnerValue
help_msg#72rc#361
list of 16{"Miscellaneous routines for permissions checking", "", "For a complete description of a given verb, do `help $perm_utils:verbname'", "", ":controls(who,what) -- can who write on object what", ":controls_property(who,what,propname) -- can who write on what.propname", "These routines check write flags and also the wizardliness of `who'.", "", "(these last two probably belong on $code_utils)", "", ":apply(permstring,mods)", " -- used by @chmod to apply changes (e.g., +x) ", " to a given permissions string", "", ":caller()", " -- returns the first caller in the callers() stack distinct from `this'"}
aliases#1rc#361<clear>
description#1rc#361{"This is the permissions utilities utility package. See `help $perm_utils' for more details."}
object_size#1r#29{4402, 1298433815}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n42_4 #42:_chparent n42_0 #42:controls n42_4->n42_0 n51_55 #51:dflag_on n42_4->n51_55

Source

controls

Spec this none thisFlags rxdOwner #361Definer #42

Referenced by

Source

1"$perm_utils:controls(who, what)";
2"Is WHO allowed to hack on WHAT?";
3return (args[1] == args[2].owner) || args[1].wizard;

apply

Spec this none thisFlags rxdOwner #29Definer #42

Referenced by

Source

1":apply(permstring,mods) => new permstring.";
2"permstring is a permissions string, mods is a concatenation of strings of the form +<letters>, !<letters>, or -<letters>, where <letters> is a string of letters as might appear in a permissions string (`+' adds the specified permissions, `-' or `!' removes them; `-' and `!' are entirely equivalent).";
3{perms, mods} = args;
4if ((!mods) || (!index("!-+", mods[1])))
5return mods;
6endif
7i = 1;
8while (i <= length(mods))
9if (mods[i] == "+")
10while (((i = i + 1) <= length(mods)) && (!index("!-+", mods[i])))
11if (!index(perms, mods[i]))
12perms = perms + mods[i];
13endif
14endwhile
15else
16"mods[i] must be ! or -";
17while (((i = i + 1) <= length(mods)) && (!index("!-+", mods[i])))
18perms = strsub(perms, mods[i], "");
19endwhile
20endif
21endwhile
22return perms;

caller

Spec this none thisFlags rxdOwner #361Definer #42

Referenced by

none

Source

1":caller([include line numbers])";
2"  -- returns the first caller in the callers() stack distinct from `this'";
3{?lineno = 0} = args;
4c = callers(lineno);
5{stage, lc, nono} = {1, length(c), {c[1][1], $nothing}};
6while (((stage = stage + 1) <= lc) && (c[stage][1] in nono))
7endwhile
8return c[stage];

controls_prop*erty controls_verb

Spec this none thisFlags rxdOwner #361Definer #42

Referenced by

none

Source

1"Syntax:  controls_prop(OBJ who, OBJ what, STR propname)   => 0 | 1";
2"         controls_verb(OBJ who, OBJ what, STR verbname)   => 0 | 1";
3"";
4"Is WHO allowed to hack on WHAT's PROPNAME? Or VERBNAME?";
5{who, what, name} = args;
6bi = (verb == "controls_verb") ? "verb_info" | "property_info";
7return who.wizard || (who == call_function(bi, what, name)[1]);

_chparent

Spec this none thisFlags rxdOwner #361Definer #42

Referenced by

Source

1"chparent(object, new-parent) -- see help on the builtin";
2who = caller_perms();
3{what, papa} = args;
4if (typeof(what) != OBJ)
5retval = E_TYPE;
6elseif (!valid(what))
7retval = E_INVARG;
8elseif (typeof(papa) != OBJ)
9retval = E_TYPE;
10elseif ((!valid(papa)) && (papa != #-1))
11retval = E_INVARG;
12elseif (!this:controls(who, what))
13retval = E_PERM;
14elseif ((is_player(what) && (!is_a(papa, $player_class))) && (!who.wizard))
15retval = E_PERM;
16elseif ((is_player(what) && (!is_a(what, $player_class))) && (!who.wizard))
17retval = E_PERM;
18elseif ((!valid(papa)) || (this:controls(who, papa) || papa.f))
19retval = `chparent(@args) ! ANY';
20else
21retval = E_PERM;
22endif
23return ((typeof(retval) == ERR) && $code_utils:dflag_on()) ? raise(retval) | retval;