/* * MODULE_AUTH.pike: Skeleton module for Roxen. * * Written by: Bill Welliver * 30 July 1997 * * for more information about auth modules, see userdb.pike. * */ /* * * Load all of the headers and inherited procedures. * */ #include inherit "module"; inherit "roxenlib"; // Inheriting roxenlib may not be nessecary for all modules. // See server/base_server/roxenlib.pike for provided functions. /* * * register_module() is required. * * return elements: * * [1]: Module type (see module.h) may be bitwise or'd (|) for hybrid modules. * [2]: Module name. * [3]: Documentation for module. * [4]: Reserved for future use. * [5]: 0 to allow multiple copies per vserver, 1 to allow only 1 per vserver. * */ array register_module(){ return( { MODULE_AUTH, "sample authorization module", "This is a sample skeleton module of type auth.", 0, 0|1 } ); } /* * * create() sets up module configuration variables * */ void create(){ /* * * defvar() defines configurable variables. * * arguments: * * [1]: variable name * [2]: default value for variable * [3]: longer variable name * [4]: variable type (see module.h for types) * [5]: documentation for variable * [6]: optional, not used. * * */ defvar( "varname", "value", "long variable name", VARIABLE_TYPE, "documentation string for variable", ({ "choice1", "choice2", "choice3" }) ); } /* * * check_variable(): check validity of config variables... * * check conf interface variables for sanity. * * variable is the name of the variable we're checking * set_to is the value being tested * */ string|void check_variable(string variable, mixed set_to){ // find out what variable we're checking... if(variable=="variable1"){ // find out if it's a value we'll accept... if so, then just return if(set_to=="whatevervalueweaccept") return; // if it's not, return an error message. else return ("Sorry, we don't accept that value...\n"); } } /* * * start(): set up shop... * * do anything required before we are able to service requests * */ void start(){ } /* * * stop(): close up shop... * * tidy up before the module is terminated * */ void stop(){ } /* * * status(): how's the module doing? * * return a string suitable for inclusion in a
tag. * * */ void status(){ return ("Everything's A-OK!\n"); } /* * * info(): what's this module used for? * * return a string that describes this module. * if absent, Roxen will use element 3 of register_module(). * * */ string info(){ return ("Module that doesn't do anything.\n"); } /* * * auth(): authorize users * * returns an array if user provides proper authentication. * */ array auth(array from){ return ({"",""}); } /* * * userlist(): list users * * returns an array of users known by the server. * */ array userlist(){ return ({"tom","dick","harry"}); } /* * * user_from_uid(): get username from uid * * returns an array, element 0 contains username. * */ array auth(int uid){ return ({"tom"}); } /* * * userinfo(): user information * * returns an array of information about user. * */ array userinfo(string username){ return ({"tom","tom q. public"}); }