22 #include <stringprep.h>
25 #define LIBRARY_DIR "."
41 char mod_fullpath[
PATH_MAX], *modules_path;
48 if (modules_path != NULL)
49 log_write(c2s->
log, LOG_NOTICE,
"modules search path: %s", modules_path);
51 log_write(c2s->
log, LOG_NOTICE,
"modules search path undefined, using default: "LIBRARY_DIR);
53 log_write(c2s->
log, LOG_INFO,
"loading '%s' authreg module", name);
55 if (modules_path != NULL)
56 snprintf(mod_fullpath,
PATH_MAX,
"%s/authreg_%s.so", modules_path, name);
58 snprintf(mod_fullpath,
PATH_MAX,
"%s/authreg_%s.so", LIBRARY_DIR, name);
59 handle = dlopen(mod_fullpath, RTLD_LAZY);
61 init_fn = dlsym(handle,
"ar_init");
63 if (modules_path != NULL)
64 snprintf(mod_fullpath,
PATH_MAX,
"%s\\authreg_%s.dll", modules_path, name);
66 snprintf(mod_fullpath,
PATH_MAX,
"authreg_%s.dll", name);
67 handle = (
void*) LoadLibrary(mod_fullpath);
72 if (handle != NULL && init_fn != NULL) {
73 log_debug(
ZONE,
"preloaded module '%s' (not initialized yet)", name);
76 log_write(c2s->
log, LOG_ERR,
"failed loading authreg module '%s' (%s)", name, dlerror());
80 log_write(c2s->
log, LOG_ERR,
"failed loading authreg module '%s' (errcode: %x)", name, GetLastError());
82 FreeLibrary((HMODULE) handle);
93 if((init_fn)(ar) != 0)
95 log_write(c2s->
log, LOG_ERR,
"failed to initialize auth module '%s'", name);
103 log_write(c2s->
log, LOG_ERR,
"auth module '%s' has no check for user existence", name);
109 log_write(c2s->
log, LOG_NOTICE,
"initialized auth module '%s'", name);
117 if(ar->
free != NULL) (ar->
free)(ar);
124 log_write(c2s->
log, LOG_NOTICE,
"[%d] %s authentication %s: %s@%s/%s %s:%d%s%s",
125 sess->
s->
tag, method, success ?
"succeeded" :
"failed",
135 char username[1024],
id[128];
157 if(stringprep_xmpp_nodeprep(username, 1024) != 0) {
158 log_debug(
ZONE,
"auth get username failed nodeprep, bouncing it");
220 int ns, elem, attr, authd = 0;
221 char username[1024], resource[1024], str[1024], hash[280];
244 if(stringprep_xmpp_nodeprep(username, 1024) != 0) {
245 log_debug(
ZONE,
"auth set username failed nodeprep, bouncing it");
262 if(stringprep_xmpp_resourceprep(resource, 1024) != 0) {
263 log_debug(
ZONE,
"auth set resource failed resourceprep, bouncing it");
269 if (sess->
s->
ssf > 0)
292 snprintf(hash, 280,
"%s%s", sess->
s->
id, str);
315 _authreg_auth_log(c2s, sess,
"traditional.plain(compare)", username, resource, TRUE);
436 int ns = 0, elem, attr;
437 char username[1024], password[1024];
502 log_debug(
ZONE,
"register set with no username, bouncing it");
508 if(stringprep_xmpp_nodeprep(username, 1024) != 0) {
509 log_debug(
ZONE,
"register set username failed nodeprep, bouncing it");
517 log_debug(
ZONE,
"register set with no password, bouncing it");
543 log_debug(
ZONE,
"attempt to register %s, but they already exist", username);
627 int ns, query, type, authreg = -1, getset = -1;
674 }
else if(getset == 1) {
684 }
else if(getset == 1) {