fred-mod-whoisd-3.10.1
|
Module implementing whois service. More...
#include "httpd.h"
#include "http_log.h"
#include "http_config.h"
#include "http_connection.h"
#include "apr.h"
#include "apr_buckets.h"
#include "apr_file_io.h"
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_pools.h"
#include "apr_strings.h"
#include "apr_time.h"
#include "apr_hash.h"
#include "apr_getopt.h"
#include "apr_want.h"
#include "scoreboard.h"
#include "util_filter.h"
#include "whois-client.h"
Data Structures | |
struct | whoisd_server_conf |
Configuration structure of whoisd module. More... | |
Defines | |
#define | CORE_PRIVATE |
#define | APR_FOPEN_READ APR_READ |
#define | APR_WANT_STRFUNC |
#define | client_ip(r) ((r)->remote_ip) |
#define | ap_unixd_set_global_mutex_perms unixd_set_global_mutex_perms |
#define | DEFAULT_DISCLAIMER "Domain Information over Whois protocol\n" |
This default disclaimer should never be used in production release. | |
#define | INT_ERROR_MSG "Internal error occured when processing your \request.\nPlease try again later.\n" |
Message displayed bellow disclaimer when query cannot be answered becauseof an error. | |
#define | MAXARGS 20 |
Maximal number of whois arguments. | |
#define | MAXTYPELEN 15 |
Maximal length of object type identifier. | |
#define | MAXAXELEN 15 |
Maximal length of search axe identifier. | |
#define | MAXQPARLEN 15 |
Maximal length of -q parameter. | |
#define | MIN_WHOIS_REQUEST_LENGTH 1 |
Minimal length of input line. | |
#define | MAX_WHOIS_REQUEST_LENGTH 1000 |
Maximal length of input line. | |
#define | ap_log_cerror(mark, level, status, c,...) ap_log_error(mark, level, status, (c)->base_server, __VA_ARGS__) |
This is wrapper function for compatibility reason. | |
#define | IS_SEARCH_SET(wr) ((wr)->axe || (wr)->norecursion || (wr)->type) |
checks if there is any kind of search set in the query | |
#define | SAFE_PRINTF(fmt, str) if (str != NULL) apr_brigade_printf(bb, NULL, NULL, fmt, str); |
#define | SAFE_PRINTF(fmt, str) if (str != NULL) apr_brigade_printf(bb, NULL, NULL, fmt, str); |
#define | SAFE_PRINTF(fmt, str) if (str != NULL) apr_brigade_printf(bb, NULL, NULL, fmt, str); |
#define | SAFE_PRINTF(fmt, str) if (str != NULL) apr_brigade_printf(bb, NULL, NULL, fmt, str); |
#define | SAFE_PRINTF(fmt, str) if (str != NULL) apr_brigade_printf(bb, NULL, NULL, fmt, str); |
Functions | |
void | whois_log_status (conn_rec *c, service_Logger service, const char *content, ccReg_RequestProperties *properties, ccReg_TID log_entry_id, CORBA_long result_code) |
static void | print_intro (apr_bucket_brigade *bb, conn_rec *c, const char *disclaimer, const char *timestamp) |
Print whois disclaimer into the bucket brigade. | |
static void | send_error (conn_rec *c, const char *disclaimer, int nerr) |
Routine trigerred upon error. | |
static void | print_domain_object (apr_bucket_brigade *bb, obj_domain *d) |
Function prints domain information to bucket brigade. | |
static void | print_nsset_object (apr_bucket_brigade *bb, obj_nsset *n) |
Function prints nsset information to bucket brigade. | |
static void | print_keyset_object (apr_bucket_brigade *bb, obj_keyset *k) |
Function prints keyset information to bucket brigade. | |
static void | print_contact_object (apr_bucket_brigade *bb, obj_contact *c) |
Function prints contact information to bucket brigade. | |
static void | print_registrar_object (apr_bucket_brigade *bb, obj_registrar *r) |
Function prints registrar information to bucket brigade. | |
static void * | get_corba_service (conn_rec *c, char *name) |
* Get a reference to the CORBA service with the given name * * | |
static apr_status_t | process_whois_query (conn_rec *c, whoisd_server_conf *sc, whois_request *wr, ccReg_TID log_entry_id) |
Whois request processor. | |
static char * | read_request (conn_rec *c, int *http_status) |
This will read whois request (one line of text). | |
static int | getobjtype (int *bittype, const char *strtype) |
Function converts object type from string form to bit form. | |
static char * | wrap_str (const char *str) |
Function wraps strings passed from XML parser into strings accepted by CORBA. | |
static apr_status_t | log_whois_request (whois_request *wr, conn_rec *c, char *content, whoisd_server_conf *sc, ccReg_TID *log_entry_id) |
Call fred-logd now it mostly returns APR_SUCCESS because logger failure isn't fatal to whois itself only if memory allocation fails, it returns HTTP_INTERNAL_SERVER_ERROR. | |
static int | process_whois_connection (conn_rec *c) |
Connection handler of mod_whoisd module. | |
static apr_status_t | whois_output_filter (ap_filter_t *f, apr_bucket_brigade *bb) |
Whois output filter inserts in front of every <LF>, which is not preceeded by <CR>, <CR>. | |
static int | whois_postconfig_hook (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) |
Postconfig hook is a good occasion to check consistency of mod_whoisd configuration and to initialize CORBA component. | |
static const char * | set_whois_protocol (cmd_parms *cmd, void *dummy, int flag) |
Routine disables or enables the operation of mod_whois. | |
static const char * | set_disclaimer_file (cmd_parms *cmd, void *dummy, const char *a1) |
Routine accepts name of file with disclaimer, it also reads the file and stores disclaimer in server configuration struct. | |
static const char * | set_logger_object (cmd_parms *cmd, void *dummy, const char *name) |
Routine sets name under which logger object is registered by nameservice. | |
static const char * | set_whois_object (cmd_parms *cmd, void *dummy, const char *name) |
Routine sets name under which is registered whois object by nameservice. | |
static void * | create_whoisd_config (apr_pool_t *p, server_rec *s) |
Create server configuration for whoisd module. | |
static void | register_hooks (apr_pool_t *p) |
Function registering hooks of whoisd module. | |
Variables | |
module AP_MODULE_DECLARE_DATA | whoisd_module |
Whois module declaration. | |
static const char * | usagestr |
Error message in case of incorrect usage. | |
static const char * | indexlist |
List of attributes which can be used in search, this is displayed with -q indexes. | |
static const char * | templatelist |
List of templates for all five object types. | |
static const command_rec | whoisd_cmds [] |
Structure defining configuration options for whoisd module. |
Module implementing whois service.
Whois daemon accepts requests containing object name and returns information about that object. The only object, which this server serves information about, is currently a domain.
The module serves only as a proxy, translating whois requests to CORBA requests and back. CORBA functionality is implemented in whois-client.c.
#define ap_log_cerror | ( | mark, | |
level, | |||
status, | |||
c, | |||
... | |||
) | ap_log_error(mark, level, status, (c)->base_server, __VA_ARGS__) |
This is wrapper function for compatibility reason.
Apache 2.0 does not have ap_log_cerror, instead we will use ap_log_error.
Referenced by get_corba_service(), log_whois_request(), process_whois_connection(), process_whois_query(), read_request(), and send_error().
#define DEFAULT_DISCLAIMER "Domain Information over Whois protocol\n" |
This default disclaimer should never be used in production release.
Referenced by whois_postconfig_hook().
#define MAX_WHOIS_REQUEST_LENGTH 1000 |
Maximal length of input line.
Referenced by process_whois_connection(), and read_request().
#define MAXARGS 20 |
Maximal number of whois arguments.
Referenced by process_whois_connection().
#define MAXAXELEN 15 |
Maximal length of search axe identifier.
Referenced by process_whois_connection().
#define MAXQPARLEN 15 |
Maximal length of -q parameter.
Referenced by process_whois_connection().
#define MAXTYPELEN 15 |
Maximal length of object type identifier.
#define MIN_WHOIS_REQUEST_LENGTH 1 |
Minimal length of input line.
Referenced by read_request().
static void* create_whoisd_config | ( | apr_pool_t * | p, |
server_rec * | s | ||
) | [static] |
Create server configuration for whoisd module.
p | Pool used for allocations. |
s | Server structure. |
static void* get_corba_service | ( | conn_rec * | c, |
char * | name | ||
) | [static] |
* Get a reference to the CORBA service with the given name * *
c | Connection. * |
name | Name of the service. |
References ap_log_cerror.
Referenced by log_whois_request(), and process_whois_query().
static int getobjtype | ( | int * | bittype, |
const char * | strtype | ||
) | [static] |
Function converts object type from string form to bit form.
If the object type is not recognized the bit array is unchanged.
bittype | Number where each object type has its own bit. |
strtype | Object type token. |
Referenced by process_whois_connection().
static apr_status_t log_whois_request | ( | whois_request * | wr, |
conn_rec * | c, | ||
char * | content, | ||
whoisd_server_conf * | sc, | ||
ccReg_TID * | log_entry_id | ||
) | [static] |
Call fred-logd now it mostly returns APR_SUCCESS because logger failure isn't fatal to whois itself only if memory allocation fails, it returns HTTP_INTERNAL_SERVER_ERROR.
wr | Request data. |
c | Incomnig connection. |
content | Request string. |
sc | Server config. |
log_entry_id | Output of entry ID from event logger. |
References ap_log_cerror, whois_request::axe, CORBA_OK, CORBA_OK_LIMIT, get_corba_service(), whoisd_server_conf::logger_object, MAX_ERROR_MSG_LEN, whois_request::norecursion, whois_request::type, whois_request::value, whois_log_new_message(), and wrap_str().
Referenced by process_whois_connection().
static void print_contact_object | ( | apr_bucket_brigade * | bb, |
obj_contact * | c | ||
) | [static] |
Function prints contact information to bucket brigade.
bb | Bucket brigade. |
c | Contact object. |
References obj_contact::address, obj_contact::changed, obj_contact::contact, obj_contact::created, obj_contact::disclose, obj_contact::e_mail, obj_contact::fax_no, obj_contact::name, obj_contact::org, obj_contact::phone, and obj_contact::registrar.
Referenced by process_whois_query().
static void print_domain_object | ( | apr_bucket_brigade * | bb, |
obj_domain * | d | ||
) | [static] |
Function prints domain information to bucket brigade.
bb | Bucket brigade. |
d | Domain object. |
References obj_domain::admin_c, obj_domain::changed, obj_domain::domain, obj_domain::expire, obj_domain::keyset, obj_domain::nsset, obj_domain::registered, obj_domain::registrant, obj_domain::registrar, obj_domain::status, obj_domain::temp_c, and obj_domain::validated_to.
Referenced by process_whois_query().
static void print_keyset_object | ( | apr_bucket_brigade * | bb, |
obj_keyset * | k | ||
) | [static] |
Function prints keyset information to bucket brigade.
bb | Bucket brigade. |
k | Keyset object. |
References keyset_dsrecord::alg, keyset_dnskey::alg, obj_keyset::changed, obj_keyset::created, keyset_dsrecord::digest, keyset_dsrecord::digest_type, obj_keyset::ds, keyset_dnskey::flags, keyset_dsrecord::key_tag, obj_keyset::keys, obj_keyset::keyset, keyset_dsrecord::max_sig_life, keyset_dnskey::protocol, keyset_dnskey::public_key, obj_keyset::registrar, and obj_keyset::tech_c.
Referenced by process_whois_query().
static void print_nsset_object | ( | apr_bucket_brigade * | bb, |
obj_nsset * | n | ||
) | [static] |
Function prints nsset information to bucket brigade.
bb | Bucket brigade. |
n | Nsset object. |
References obj_nsset::changed, obj_nsset::created, obj_nsset::nserver, obj_nsset::nserver_addrs, obj_nsset::nsset, obj_nsset::registrar, and obj_nsset::tech_c.
Referenced by process_whois_query().
static void print_registrar_object | ( | apr_bucket_brigade * | bb, |
obj_registrar * | r | ||
) | [static] |
Function prints registrar information to bucket brigade.
bb | Bucket brigade. |
r | Registrar object. |
References obj_registrar::address, obj_registrar::org, obj_registrar::phone, obj_registrar::registrar, and obj_registrar::url.
Referenced by process_whois_query().
static int process_whois_connection | ( | conn_rec * | c | ) | [static] |
Connection handler of mod_whoisd module.
If mod_whoisd is for server enabled, the request is read (assuming it is whois request) and processed in request handler, which is called from inside of this function.
c | Incomming connection. |
References ap_log_cerror, whois_request::axe, whoisd_server_conf::disclaimer, getobjtype(), indexlist, IS_SEARCH_SET, log_whois_request(), MAX_WHOIS_REQUEST_LENGTH, MAXARGS, MAXAXELEN, MAXQPARLEN, whois_request::norecursion, print_intro(), process_whois_query(), read_request(), send_error(), templatelist, whois_request::type, whois_request::value, whoisd_server_conf::whoisd_enabled, and whoisd_module.
Referenced by register_hooks().
static apr_status_t process_whois_query | ( | conn_rec * | c, |
whoisd_server_conf * | sc, | ||
whois_request * | wr, | ||
ccReg_TID | log_entry_id | ||
) | [static] |
Whois request processor.
This function is called from connection handler. It performs a CORBA call through CORBA backend and then processes data and sends a whois answer.
c | Connection. |
sc | Server configuration. |
wr | Whois request data |
log_entry_id | Entry ID from event logger |
References ap_log_cerror, CORBA_INTERNAL_ERROR, CORBA_OK, CORBA_OK_LIMIT, CORBA_SERVICE_FAILED, whoisd_server_conf::disclaimer, get_corba_service(), whoisd_server_conf::logger_object, MAX_ERROR_MSG_LEN, MAX_OBJECT_COUNT, whoisd_server_conf::object, print_contact_object(), print_domain_object(), print_intro(), print_keyset_object(), print_nsset_object(), print_registrar_object(), send_error(), TIME_BUFFER_LENGTH, whois_request::value, whois_corba_call(), and whois_release_data().
Referenced by process_whois_connection().
static char* read_request | ( | conn_rec * | c, |
int * | http_status | ||
) | [static] |
This will read whois request (one line of text).
c | Connection structure. |
http_status | HTTP error code. |
References ap_log_cerror, MAX_WHOIS_REQUEST_LENGTH, and MIN_WHOIS_REQUEST_LENGTH.
Referenced by process_whois_connection().
static void register_hooks | ( | apr_pool_t * | p | ) | [static] |
Function registering hooks of whoisd module.
p | Pool used for allocations. |
References process_whois_connection(), whois_output_filter(), and whois_postconfig_hook().
static void send_error | ( | conn_rec * | c, |
const char * | disclaimer, | ||
int | nerr | ||
) | [static] |
Routine trigerred upon error.
c | Connection. |
disclaimer | Disclaimer. |
nerr | Number of error. |
References ap_log_cerror, print_intro(), and usagestr.
Referenced by process_whois_connection(), and process_whois_query().
static const char* set_disclaimer_file | ( | cmd_parms * | cmd, |
void * | dummy, | ||
const char * | a1 | ||
) | [static] |
Routine accepts name of file with disclaimer, it also reads the file and stores disclaimer in server configuration struct.
cmd | Command. |
dummy | Not used arg. |
a1 | The value. |
References whoisd_server_conf::disclaimer, whoisd_server_conf::disclaimer_filename, and whoisd_module.
static const char* set_logger_object | ( | cmd_parms * | cmd, |
void * | dummy, | ||
const char * | name | ||
) | [static] |
Routine sets name under which logger object is registered by nameservice.
cmd | Command. |
dummy | Not used arg. |
name | The value. |
References whoisd_server_conf::logger_object, and whoisd_module.
static const char* set_whois_object | ( | cmd_parms * | cmd, |
void * | dummy, | ||
const char * | name | ||
) | [static] |
Routine sets name under which is registered whois object by nameservice.
cmd | Command. |
dummy | Not used arg. |
name | The value. |
References whoisd_server_conf::object, and whoisd_module.
static const char* set_whois_protocol | ( | cmd_parms * | cmd, |
void * | dummy, | ||
int | flag | ||
) | [static] |
Routine disables or enables the operation of mod_whois.
cmd | Command. |
dummy | Not used arg. |
flag | The value. |
References whoisd_server_conf::whoisd_enabled, and whoisd_module.
static apr_status_t whois_output_filter | ( | ap_filter_t * | f, |
apr_bucket_brigade * | bb | ||
) | [static] |
Whois output filter inserts in front of every <LF>, which is not preceeded by <CR>, <CR>.
f | Chain of filters. |
bb | Bucket brigade to be filtered. |
Referenced by register_hooks().
static int whois_postconfig_hook | ( | apr_pool_t * | p, |
apr_pool_t * | plog, | ||
apr_pool_t * | ptemp, | ||
server_rec * | s | ||
) | [static] |
Postconfig hook is a good occasion to check consistency of mod_whoisd configuration and to initialize CORBA component.
p | Pool to allocate from. |
plog | Pool used for logging. |
ptemp | Temporary pool. |
s | Server struct. |
References DEFAULT_DISCLAIMER, whoisd_server_conf::disclaimer, whoisd_server_conf::disclaimer_filename, whoisd_server_conf::object, whoisd_server_conf::whoisd_enabled, and whoisd_module.
Referenced by register_hooks().
static char* wrap_str | ( | const char * | str | ) | [static] |
Function wraps strings passed from XML parser into strings accepted by CORBA.
Null strings are transformed to empty strings. The resulting string must be freed with CORBA_free().
str | Input string. |
Referenced by log_whois_request().
const char* indexlist [static] |
"% The folowing object types can be looked up in whois database:\n\ % domain, nsset, keyset, contact, registrar.\n\ % \n\ % If you don't specify -i option the object is looked up by its primary key.\n\ % Specify object type by -T option, if you want to narrow the search.\n\ % \n\ % List of attribute names which can be used with -i option. Use only the part\n\ % following the colon. The part preceeding the colon is object type, which is\n\ % associated with the attribute.\n\ % \n\ % domain:registrant\n\ % domain:admin-c\n\ % domain:temp-c\n\ % domain:nsset\n\ % domain:keyset\n\ % nsset:nserver\n\ % nsset:tech-c\n\ % keyset:tech-c\n\ "
List of attributes which can be used in search, this is displayed with -q indexes.
Referenced by process_whois_connection().
const char* usagestr [static] |
"% Usage: whois [options] [[type] value]\n\ % \n\ % Options:\n\ % -r Switch off recursion. Only the object which is primary target\n\ % of query is returned.\n\ % -T type Type of object to lookup (domain, nsset, keyset, contact, registrar).\n\ % There may be more types separated by comma without spaces\n\ % between them. The types are case-insensitive.\n\ % -i attr Lookup object by its attribute. Attribute can be any of\n\ % attributes from object templates marked by flag \"inverse key\".\n\ % Attribute name is case-insensitive.\n\ % -q version Returns version of whois server.\n\ % -q indexes Returns list of attributes which can be used in search. The\n\ % attributes have form object:attribute.\n\ % -q templates Returns templates for all five object types.\n\ % \n\ % There's yet another way how to specify a type of object to lookup. Just\n\ % prefix the object's identifier with the name of a type. The following two\n\ % examples are equivalent:\n\ % \n\ % $ whois -T domain nic.cz\n\ % \n\ % $ whois \"domain nic.cz\"\n\ % \n\ % The -q parameter can be used only once and not in combination with any\n\ % other option. The -i parameter can be used only once.\n\ % \n\ % More information about this implementation of whois server can be found at\n\ % http://www.nic.cz/whois/manual\n\ "
Error message in case of incorrect usage.
Referenced by send_error().
const command_rec whoisd_cmds[] [static] |
{ AP_INIT_FLAG("WhoisProtocol", set_whois_protocol, NULL, RSRC_CONF, "Whether this server is serving the whois protocol"), AP_INIT_TAKE1("WhoisDisclaimer", set_disclaimer_file, NULL, RSRC_CONF, "File name with disclaimer which is standard part" "of every whois response"), AP_INIT_TAKE1("WhoisObject", set_whois_object, NULL, RSRC_CONF, "Name under which the whois object is known to " "nameserver. Default is \"Whois\"."), AP_INIT_TAKE1("WhoisLogdObject", set_logger_object, NULL, RSRC_CONF, "Name under which the fred-logd object is known to " "nameserver. Default is \"Logger\"."), { NULL } }
Structure defining configuration options for whoisd module.
module AP_MODULE_DECLARE_DATA whoisd_module |
{ STANDARD20_MODULE_STUFF, NULL, NULL, create_whoisd_config, NULL, whoisd_cmds, register_hooks }
Whois module declaration.
Definition of whoisd module.
Referenced by process_whois_connection(), set_disclaimer_file(), set_logger_object(), set_whois_object(), set_whois_protocol(), and whois_postconfig_hook().