3c2848 | 2000-08-28 | Johan Sundström | | #include <module.h>
inherit "module";
|
79ca87 | 2000-11-24 | Per Hedbor | |
#define LOCALE(X,Y) _DEF_LOCALE("mod_auth",X,Y)
|
4d082b | 2000-12-02 | Per Hedbor | | constant cvs_version = "$Id: auth.pike,v 1.5 2000/12/02 19:26:10 per Exp $";
|
3c2848 | 2000-08-28 | Johan Sundström | | constant module_type = MODULE_AUTH;
|
de9ca8 | 2000-11-27 | Per Hedbor | | LocaleString module_name_locale = LOCALE(1,"RefDoc for MODULE_AUTH");
|
79ca87 | 2000-11-24 | Per Hedbor | | LocaleString module_doc_locale =
|
de9ca8 | 2000-11-27 | Per Hedbor | | LOCALE(2,"This module does nothing, but its inlined documentation "
|
79ca87 | 2000-11-24 | Per Hedbor | | "gets imported into the roxen programmer manual. You definetely "
"don't want to use this module in your virtual servers, since "
"anybody with access to your admin interface or server configuration "
" file automatically gains access to all yourpasswords. For a "
" budding roxen programmer, the module however does show the "
" basics of making an authentication module.");
|
3c2848 | 2000-08-28 | Johan Sundström | |
void create()
{
|
79ca87 | 2000-11-24 | Per Hedbor | | defvar("users", Variable.StringList(({}), VAR_INITIAL,
|
de9ca8 | 2000-11-27 | Per Hedbor | | LOCALE(3,"Users and Passwords"),
LOCALE(4,"A list of username:password "
|
79ca87 | 2000-11-24 | Per Hedbor | | "pairs the module should grant "
|
4d082b | 2000-12-02 | Per Hedbor | | "access for.")));
|
3c2848 | 2000-08-28 | Johan Sundström | | }
array|int auth(array(string) auth, RequestID id)
{
sscanf(auth[1], "%s:%s", string user, string password);
int successful_auth = has_value(query("users"), auth[1]);
return ({
successful_auth,
user,
!successful_auth && password
});
}
string user_from_uid(int uid, RequestID|void id)
{
return uid->digits(256);
}
array(string) userlist(RequestID|void id)
{
return Array.transpose(map(query("users"), `/, ":"))[0][0];
}
array(string|int) userinfo(string user, RequestID|void id)
{
|
99e48d | 2000-11-21 | Per Hedbor | | string passwd, name = "J. Random Hacker", homedir, shell = "/bin/zsh";
|
3c2848 | 2000-08-28 | Johan Sundström | | int uid, gid;
array(string) matching_users = glob(user + ":*", query("users"));
if(!sizeof(matching_users))
return 0;
sscanf(matching_users[0], "%*s:%s", passwd);
sscanf(user, "%"+sizeof(user)+"c", uid);
gid = uid;
homedir = "/home/" + user;
return ({ user, crypt(passwd), uid, gid, name, homedir, shell });
}
|