external next up previous contents index
Next: 8.11 MOO softwareLevel0 Up: 8.10 Permissions and Generic Previous: A generic ``holder''

Adding security to the holder

 

Another problem is security, as you can see anybody will be able to write something onto your ``holder'' or worse, erase it. This is something else you will have to learn if you feel getting into serious MOO programming. At some point you also should read the section on security (11.2 on page gif).

Verbs on objects need security if the verb could alter either the state of the object or if information should remain confidential. In the list of verbs you have on your ``holder'', the following ones are strong candidates for security:

 #2108:add                   MooBoy (#1324)       r d 
 #2108:clear                 MooBoy (#1324)       r d
 #2108:erase                 MooBoy (#1324)       r d

Those need only securtiy if you don't want other people to show its contents:

 #2108:dump                  MooBoy (#1324)       r d
 #2108:show                  MooBoy (#1324)       r d

Basically as explained in section 11.2 security differs from command verbs (typically ``rd'' permissions) and verbs that are callable by other verbs (typically ``rxd'' permissions)

In the holder we only have command verbs (i.e. no verb calls any other verb on the same object), to make a verb secure from execution by other people we only have to add the following lines at the beginning of your verb:

if (!$perm_utils:controls(player, this))
  player:tell("Sorry you are not the owner of this
               object and can't clear it");
return;
The $perm_utils:control(<user>,<object>) function returns true if the user is the person owning the object. The (!$perm_utils:controls(player, this)) returns true if the user does not control the object, i.e. the ``!'' negates the previous expressions. So if we are in the situation where a non-owner activates the verb, we simply exit from the function and before that print out a message to the user.



Daniel K. Schneider
Thu Apr 17 12:43:52 MET DST 1997