X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Fmod_sample.cpp;h=276e5b1a8565cf1014deafeaa8de89024914051a;hp=1ed36b25219be3d11e89ec2cca3311cc3c22541b;hb=9c4af9d938abac93a949d756353c1bd89b769012;hpb=654c4c47282bad586232db5e5cfbfa97035f1bad diff --git a/src/mod_sample.cpp b/src/mod_sample.cpp index 1ed36b2..276e5b1 100644 --- a/src/mod_sample.cpp +++ b/src/mod_sample.cpp @@ -1,7 +1,7 @@ -/* $Id: mod_sample.cpp,v 1.3 2005-06-10 22:54:22 adam Exp $ - Copyright (c) 1998-2005, Index Data. +/* $Id: mod_sample.cpp,v 1.6 2006-03-30 10:31:53 adam Exp $ + Copyright (c) 1998-2006, Index Data. -This file is part of the yaz-proxy. +This file is part of the yazproxy. YAZ proxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -44,9 +44,10 @@ void my_destroy(void *p) } int my_authenticate(void *user_handle, - const char *target_name, - void *element_ptr, - const char *user, const char *group, const char *password) + const char *target_name, + void *element_ptr, + const char *user, const char *group, const char *password, + const char *peer_IP) { // see if we have an "args" attribute const char *args = 0; @@ -56,24 +57,26 @@ int my_authenticate(void *user_handle, for (attr = ptr->properties; attr; attr = attr->next) { - if (!strcmp((const char *) attr->name, "args") && - attr->children && attr->children->type == XML_TEXT_NODE) - args = (const char *) attr->children->content; + if (!strcmp((const char *) attr->name, "args") && + attr->children && attr->children->type == XML_TEXT_NODE) + args = (const char *) attr->children->content; } #endif // args holds args (or NULL if none is provided) - sleep(1); - fprintf(stderr, "my_authenticate: target=%s user=%s group=%s args=%s\n", - target_name ? target_name : "none", - user ? user : "none", group ? group : "none", - args ? args : "none"); + sleep(2); + fprintf(stderr, "my_authenticate: target=%s user=%s group=%s args=%s IP=%s" + "\n", + target_name ? target_name : "none", + user ? user : "none", group ? group : "none", + args ? args : "none", + peer_IP); // authentication handler if (!user && !group && !password) - return YAZPROXY_RET_OK; // OK if anonymous + return YAZPROXY_RET_OK; // OK if anonymous if (user && !strcmp(user, "guest") - && password && !strcmp(password, "guest")) // or guest guest - return YAZPROXY_RET_OK; + && password && !strcmp(password, "guest")) // or guest guest + return YAZPROXY_RET_OK; return YAZPROXY_RET_PERM; // fail otherwise } @@ -89,3 +92,11 @@ Yaz_ProxyModule_entry yazproxy_module = { "Sample Module for YAZ Proxy",// description &interface0 }; +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +