Back to index

im-sdk  12.3.91
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes
IMSvrXMLConf Class Reference

#include <IMSvrXMLConf.hh>

Inheritance diagram for IMSvrXMLConf:
Inheritance graph
[legend]
Collaboration diagram for IMSvrXMLConf:
Collaboration graph
[legend]

List of all members.

Public Types

enum  IMSvrCfgOpt {
  IMDIR = 0, BASICLOCALE, IFPATHNAME, IFNAME,
  PORT, HOSTNAME, NSMAP_CFG_FILE, CONFIGFILE,
  LECONFFILE, CONVERSIONKEYS, LABEL, SETTRIGGEROFFKEYS,
  IMCONFIG, DIRECT_XSUNIM, LOG_FACILITY, LOG_LEVEL,
  MESSAGE_LOCALE, LOOKUPROW, LOOKUPCOL, NODAEMON,
  DEBUGFLAG, USER, VARDIR, DESKTOP,
  PREFERRED_LOADING, CFGOPT_LAST
}

Public Member Functions

virtual bool configure (IMSvr *pimsvr)
 IMSvrXMLConf (IMSvrCfg *pbase, const char *conffile)
virtual ~IMSvrXMLConf ()
bool get_boolval (enum IMSvrCfgOpt opt) const
int get_numval (enum IMSvrCfgOpt opt) const
const char * get_strval (enum IMSvrCfgOpt opt) const
void showall () const
const char * get_command_name ()

Protected Types

enum  CfgType {
  ARG_UNINIT = 0, ARG_INVALID, ARG_BOOL, ARG_NUMBER,
  ARG_STRING
}

Protected Member Functions

enum CfgType get_type (enum IMSvrCfgOpt opt)
const string & get_description (enum IMSvrCfgOpt opt)
void setbool (enum IMSvrCfgOpt opt, bool boolval)
void setnum (enum IMSvrCfgOpt opt, int numval)
void setstr (enum IMSvrCfgOpt opt, const char *strval)
bool get_process_user (string &user)
bool get_home_dir (string &dir)
IMUserMgrget_usermgr (IMSvr *pimsvr)
bool config_lepath (IMSvr *pimsvr, const char *lepath)
bool config_listenaddress (IMSvr *pimsvr, IMSocketAddressVec &addrvec)
bool config_le (IMSvr *pimsvr, const char *lepath, IIIMLEXMLConf &xml, bool preferred_loading)
bool set_nsmap_config (IMSvr *pimsvr, IMNsMapStruct *nsm, int num_entries)

Private Member Functions

IMAuth::access_type get_access_type (xmlChar *key)
string parse_text_node (xmlNodePtr &node)
string parse_hostname_node (xmlNodePtr &node)
string parse_port_node (xmlNodePtr &node)
string parse_file_node (xmlNodePtr &node)
void parse_listen_tcp_node (xmlNodePtr &node, bool ssl)
void parse_listen_unix_node (xmlNodePtr &node, bool ssl)
void parse_acl_node (xmlNodePtr &node)
void parse_acls_node (xmlNodePtr &node)
void parse_system_node (xmlNodePtr &node)
void parse_user_node (xmlNodePtr &node)
void parse_auth_node (xmlNodePtr &node)
void parse_ssl_node (xmlNodePtr &node)
void parse_server_node (xmlNodePtr &node)
bool load (void)

Private Attributes

IMSvrptarget
string filename
IMSocketAddressVec listenaddrvec

Detailed Description

Definition at line 9 of file IMSvrXMLConf.hh.


Member Enumeration Documentation

enum IMSvrCfg::CfgType [protected, inherited]
Enumerator:
ARG_UNINIT 
ARG_INVALID 
ARG_BOOL 
ARG_NUMBER 
ARG_STRING 

Definition at line 46 of file IMSvrCfg.hh.

enum IMSvrCfg::IMSvrCfgOpt [inherited]
Enumerator:
IMDIR 
BASICLOCALE 
IFPATHNAME 
IFNAME 
PORT 
HOSTNAME 
NSMAP_CFG_FILE 
CONFIGFILE 
LECONFFILE 
CONVERSIONKEYS 
LABEL 
SETTRIGGEROFFKEYS 
IMCONFIG 
DIRECT_XSUNIM 
LOG_FACILITY 
LOG_LEVEL 
MESSAGE_LOCALE 
LOOKUPROW 
LOOKUPCOL 
NODAEMON 
DEBUGFLAG 
USER 
VARDIR 
DESKTOP 
PREFERRED_LOADING 
CFGOPT_LAST 

Definition at line 13 of file IMSvrCfg.hh.


Constructor & Destructor Documentation

IMSvrXMLConf::IMSvrXMLConf ( IMSvrCfg pbase,
const char *  conffile 
)

Definition at line 709 of file IMSvrXMLConf.cpp.

                                              : IMSvrCfg(*pbase), filename(conffile)
{
}

Definition at line 714 of file IMSvrXMLConf.cpp.

{
}

Member Function Documentation

bool IMSvrCfg::config_le ( IMSvr pimsvr,
const char *  lepath,
IIIMLEXMLConf &  xml,
bool  preferred_loading 
) [inline, protected, inherited]

Definition at line 120 of file IMSvrCfg.hh.

       { return pimsvr->config_le(lepath, xml, preferred_loading); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrCfg::config_lepath ( IMSvr pimsvr,
const char *  lepath 
) [inline, protected, inherited]

Definition at line 116 of file IMSvrCfg.hh.

    { return pimsvr->config_lepath(lepath); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrCfg::config_listenaddress ( IMSvr pimsvr,
IMSocketAddressVec addrvec 
) [inline, protected, inherited]

Definition at line 118 of file IMSvrCfg.hh.

    { return pimsvr->config_listenaddress(addrvec); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrXMLConf::configure ( IMSvr pimsvr) [virtual]

Implements IMSvrCfg.

Definition at line 656 of file IMSvrXMLConf.cpp.

{
    string prefix = SOCKETDIR "/.iiimp-unix";

    ptarget = pimsvr;
    if (!load())
       return false;

#ifdef HAVE_TLS
    IMTLS::get_instance()->setup();
#endif
    /* config listen address if it has not been configured yet. */
    if (listenaddrvec.empty()) {
        if (get_boolval(USER)) {
            // when iiimd run as a per-user daemon.
            // listens to /tmp/.iiimp-unix-${USER}/${PORT}
            string user_name;
            if (get_process_user(user_name)) {
              string sf;
              IM_unix_domain_socket_file_dir(user_name, sf);
              if (0 < sf.size()) {
                  listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN_PER_USER,
                                                     sf,
                                                     get_strval(IMSvrCfg::PORT)));
              }
#if 0
                listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN_PER_USER,
                                                 string("/tmp/.iiimp-unix-") + user_name,
                                                 get_strval(IMSvrCfg::PORT)));
#endif
           }
       } else if (string(get_strval(IMSvrCfg::UDSFILE)).size() != 0) {
           listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN,
                                              get_strval(IMSvrCfg::UDSFILE), ""));
        } else {
            // by default, iiimd listens to
            // localhost:9010, /var/run/iiim/.iiimp-unix/${PORT}
           /* disable tcp listening by default */
#if 0
           listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::INET,
                                              get_strval(IMSvrCfg::HOSTNAME),
                                         get_strval(IMSvrCfg::PORT)));
#endif
            listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN,
                                         prefix,
                                              get_strval(IMSvrCfg::PORT)));
        }
    }
    config_listenaddress(pimsvr, listenaddrvec);

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IMAuth::access_type IMSvrXMLConf::get_access_type ( xmlChar *  key) [private]

Definition at line 23 of file IMSvrXMLConf.cpp.

{
    if (key == NULL) {
       return IMAuth::UNKNOWN;
    } else if (xmlStrcasecmp(key, (xmlChar *)"permit") == 0) {
       return IMAuth::PERMIT;
    } else if (xmlStrcasecmp(key, (xmlChar *)"checkuser") == 0) {
       return IMAuth::CHECKUSER;
    } else if (xmlStrcasecmp(key, (xmlChar *)"password") == 0) {
       return IMAuth::PASSWORD;
    } else if (xmlStrcasecmp(key, (xmlChar *)"deny") == 0) {
       return IMAuth::DENY;
    }

    return IMAuth::UNKNOWN;
}

Here is the caller graph for this function:

bool IMSvrCfg::get_boolval ( enum IMSvrCfgOpt  opt) const [inherited]

Definition at line 221 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_BOOL)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.b;
}

Here is the caller graph for this function:

const char* IMSvrCfg::get_command_name ( ) [inline, inherited]

Definition at line 138 of file IMSvrCfg.hh.

    { return command_name.c_str(); }

Here is the caller graph for this function:

const string& IMSvrCfg::get_description ( enum IMSvrCfgOpt  opt) [inline, protected, inherited]

Definition at line 71 of file IMSvrCfg.hh.

    { return popts[opt].description; }
bool IMSvrCfg::get_home_dir ( string &  dir) [protected, inherited]

Definition at line 18 of file IMSvrCfg.cpp.

{

#ifdef HAVE_PWENT
    struct passwd *pass;
#  if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
#ifndef NSS_BUFLEN_PASSWD
#define NSS_BUFLEN_PASSWD 1024
#endif
    struct passwd pass_buf;
    char buf[NSS_BUFLEN_PASSWD];

#    ifdef HAVE_POSIX_GETPWUID_R
    if (getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD, &pass) != 0) {
        return false;
    }
#else
    if ((pass = getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD))
       != NULL) {
        return false;
    }
#endif
#else /* !HAVE_GETPWUID_R || !HAVE_NONPOSIX_GETPWUID_R */
    if ((pass = getpwuid(geteuid())) == NULL) {
        return false;
    } 
#endif
    dir = string(pass->pw_dir);
    return true;
#else
    return false;
#endif
}

Here is the caller graph for this function:

int IMSvrCfg::get_numval ( enum IMSvrCfgOpt  opt) const [inherited]

Definition at line 235 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_NUMBER)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.n;
}
bool IMSvrCfg::get_process_user ( string &  user) [protected, inherited]

Definition at line 54 of file IMSvrCfg.cpp.

{

#ifdef HAVE_PWENT
    struct passwd *pass;
#  if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
#ifndef NSS_BUFLEN_PASSWD
#define NSS_BUFLEN_PASSWD 1024
#endif
    struct passwd pass_buf;
    char buf[NSS_BUFLEN_PASSWD];

#    ifdef HAVE_POSIX_GETPWUID_R
    if (getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD, &pass) != 0) {
        return false;
    }
#else
    if ((pass = getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD))
       != NULL) {
        return false;
    }
#endif
#else /* !HAVE_GETPWUID_R || !HAVE_NONPOSIX_GETPWUID_R */
    if ((pass = getpwuid(geteuid())) == NULL) {
        return false;
    } 
#endif
    username = string(pass->pw_name);
    return true;
#else
    return false;
#endif
}

Here is the caller graph for this function:

const char * IMSvrCfg::get_strval ( enum IMSvrCfgOpt  opt) const [inherited]

Definition at line 249 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_STRING)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.s.c_str();
}

Here is the caller graph for this function:

enum CfgType IMSvrCfg::get_type ( enum IMSvrCfgOpt  opt) [inline, protected, inherited]

Definition at line 69 of file IMSvrCfg.hh.

    { return popts[opt].type; }

Here is the caller graph for this function:

IMUserMgr* IMSvrCfg::get_usermgr ( IMSvr pimsvr) [inline, protected, inherited]

Definition at line 114 of file IMSvrCfg.hh.

    { return &pimsvr->usermgr; }

Here is the caller graph for this function:

bool IMSvrXMLConf::load ( void  ) [private]

Definition at line 593 of file IMSvrXMLConf.cpp.

{
#ifdef HAVE_XMLCTXTREAD
    xmlParserCtxtPtr parser = NULL;
#endif
    xmlDocPtr doc = NULL;
    xmlNodePtr root = NULL, node, topnode = NULL;
    bool retval = false;

    if (filename.size() == 0)
       return false;

#ifdef HAVE_XMLCTXTREAD
    parser = xmlNewParserCtxt();
    if ((doc = xmlCtxtReadFile(parser, filename.c_str(), "UTF-8", 0)) == NULL) {
#else
    if ((doc = xmlParseFile(filename.c_str())) == NULL) {
#endif
       goto ensure;
#ifdef HAVE_XMLCTXTREAD
    }
#else
    }
#endif
    if ((root = xmlDocGetRootElement(doc)) == NULL)
       goto ensure;
    if (xmlStrcmp(root->name, (xmlChar *)"iiimf") != 0) {
       LOG_ERROR("invalid configuration file `%s'", filename.c_str());
       goto ensure;
    }

    node = root->xmlChildrenNode;
    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"server") == 0) {
           topnode = node;
           node = node->xmlChildrenNode;
           parse_server_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "iiimf");
           node = node->next;
       }
    }
    retval = true;

  ensure:
    if (doc != NULL)
       xmlFreeDoc(doc);
#ifdef HAVE_XMLCTXTREAD
    if (parser != NULL)
       xmlFreeParserCtxt(parser);
#endif

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_acl_node ( xmlNodePtr &  node) [private]

Definition at line 268 of file IMSvrXMLConf.cpp.

{
    xmlChar *type = NULL;
    IMAuth::access_type at;
    string hostname;

    type = xmlGetProp(node, (xmlChar *)"type");
    at = get_access_type(type);
    node = node->xmlChildrenNode;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"hostname") == 0) {
           if (hostname.size() > 0) {
              DUPLICATED_NODE_ERROR("hostname", "acl");
           } else {
              hostname = parse_hostname_node(node->xmlChildrenNode);
           }
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "acl");
           node = node->next;
       }
    }

    /* validate the given directives */
    if (hostname.size() == 0) {
       MISSING_NODE_ERROR("hostname", "acl");
    } else if (at != IMAuth::UNKNOWN) {
       get_usermgr(ptarget)->set_entry(hostname.c_str(), at);
       LOG_DEBUG("<acl type=\"%s\"><hostname>%s</hostname></acl>", type, hostname.c_str());
    } else {
       LOG_ERROR("<acl> needs `type' attribute.");
    }

    if (type != NULL)
       xmlFree(type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_acls_node ( xmlNodePtr &  node) [private]

Definition at line 312 of file IMSvrXMLConf.cpp.

{
    xmlNodePtr topnode = NULL;
    xmlChar *type = NULL;
    IMAuth::access_type at;

    type = xmlGetProp(node, (xmlChar *)"default");
    at = get_access_type(type);
    if (at != IMAuth::UNKNOWN) {
       get_usermgr(ptarget)->set_default_entry(at);
       LOG_DEBUG("<acls default=\"%s\">", type);
    } else {
       LOG_WARNING("no default permission.");
    }
    if (type != NULL)
       xmlFree(type);

    node = node->xmlChildrenNode;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"acl") == 0) {
           topnode = node;
           parse_acl_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "acls");
           node = node->next;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_auth_node ( xmlNodePtr &  node) [private]

Definition at line 399 of file IMSvrXMLConf.cpp.

{
    xmlNodePtr topnode = NULL;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"system") == 0) {
           topnode = node;
           parse_system_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"user") == 0) {
           topnode = node;
           parse_user_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "auth");
           node = node->next;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string IMSvrXMLConf::parse_file_node ( xmlNodePtr &  node) [private]

Definition at line 104 of file IMSvrXMLConf.cpp.

{
    string retval;

    if (node->name == NULL || xmlStrlen(node->name) == 0) {
       EMPTY_NODE_ERROR("file");
       return retval;
    } else {
       retval = parse_text_node(node);
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string IMSvrXMLConf::parse_hostname_node ( xmlNodePtr &  node) [private]

Definition at line 62 of file IMSvrXMLConf.cpp.

{
    string retval;

    if (node->name == NULL || xmlStrlen(node->name) == 0) {
       EMPTY_NODE_ERROR("hostname");
       return retval;
    } else {
       retval = parse_text_node(node);
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_listen_tcp_node ( xmlNodePtr &  node,
bool  ssl 
) [private]

Definition at line 119 of file IMSvrXMLConf.cpp.

{
    string hostname;
    string port;

#if defined(HAVE_UNIX_SOCKET)
    if (string(get_strval(IMSvrCfg::UDSFILE)).size() != 0) return;
#endif /* HAVE_UNIX_SOCKET */

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"hostname") == 0) {
           if (hostname.size() > 0) {
              DUPLICATED_NODE_ERROR("hostname", "listen");
           } else {
              hostname = parse_hostname_node(node->xmlChildrenNode);
           }
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"port") == 0) {
           if (port.size() > 0) {
              DUPLICATED_NODE_ERROR("port", "listen");
           } else {
              port = parse_port_node(node->xmlChildrenNode);
           }
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "listen");
           node = node->next;
       }
    }

    /* validate the given directives */
    if (hostname.size() == 0)
       MISSING_NODE_ERROR("hostname", "listen");
    if (port.size() == 0)
       MISSING_NODE_ERROR("port", "listen");
    if (hostname.size() > 0 && port.size() > 0) {
       if (!get_boolval(USER)) {
           if (ssl) {
#ifdef HAVE_TLS
              listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::INET, IMSocketAddress::TLS,
                                                 hostname, port));
              LOG_DEBUG("<ssl><listen type=\"tcp\"><hostname>%s</hostname><port>%s</port></listen></ssl>",
                       hostname.c_str(), port.c_str());
#else
              LOG_WARNING("it was compiled without SSL support.");
#endif /* HAVE_TLS */
           } else {
              listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::INET, hostname, port));
              LOG_DEBUG("<listen type=\"tcp\"><hostname>%s</hostname><port>%s</port></listen>",
                       hostname.c_str(), port.c_str());
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_listen_unix_node ( xmlNodePtr &  node,
bool  ssl 
) [private]

Definition at line 180 of file IMSvrXMLConf.cpp.

{
#ifdef HAVE_UNIX_SOCKET
    string file;
    string prefix = SOCKETDIR "/.iiimp-unix";
    char *p;

    if (string(get_strval(IMSvrCfg::UDSFILE)).size() != 0) return;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"file") == 0) {
           if (file.size() > 0) {
              DUPLICATED_NODE_ERROR("file", "listen");
           } else {
              file = parse_file_node(node->xmlChildrenNode);
           }
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "listen");
           node = node->next;
       }
    }

    /* drop path in order to not allow ../path/to say */
    p = new char[file.size() + 1];
    strncpy(p, file.c_str(), file.size());
    p[file.size()] = 0;
    file = basename(p);
    delete[] p;

    /* validate the given directives */
    if (file.size() == 0) {
       MISSING_NODE_ERROR("file", "listen");
    } else {
       if (get_boolval(IMSvrCfg::USER)) {
           string user_name;

           if (get_process_user(user_name)) {
              if (ssl) {
#ifdef HAVE_TLS
                  listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN_PER_USER,
                                                     IMSocketAddress::TLS,
                                                     prefix + string("-") + user_name,
                                                     file));
#else
                  LOG_WARNING("it was compiled without SSL support.");
#endif /* HAVE_TLS */
              } else {
                  listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN_PER_USER,
                                                     prefix + string("-") + user_name,
                                                     file));
              }
           }
       } else {
           if (ssl) {
#ifdef HAVE_TLS
              listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN,
                                                 IMSocketAddress::TLS,
                                                 prefix, file));
#else
              LOG_WARNING("it was compiled without SSL support.");
#endif /* HAVE_TLS */
           } else {
              listenaddrvec.push_back(IMSocketAddress(IMSocketAddress::UNIX_DOMAIN,
                                                 prefix, file));
           }
       }
       if (ssl) {
#ifdef HAVE_TLS
           LOG_DEBUG("<ssl><listen type=\"unix\"><file>%s</file></listen></ssl>", file.c_str());
#else
           /* not supported */
#endif /* HAVE_TLS */
       } else {
           LOG_DEBUG("<listen type=\"unix\"><file>%s</file></listen>", file.c_str());
       }
    }
#else
    LOG_WARNING("it was compiled without Unix domain socket support.")
#endif /* HAVE_UNIX_SOCKET */
}

Here is the call graph for this function:

Here is the caller graph for this function:

string IMSvrXMLConf::parse_port_node ( xmlNodePtr &  node) [private]

Definition at line 77 of file IMSvrXMLConf.cpp.

{
    string retval;

    if (node->name == NULL || xmlStrlen(node->name) == 0) {
       EMPTY_NODE_ERROR("port");
       return retval;
    } else {
       retval = parse_text_node(node);
    }

#if 0
    if (retval.size() > 0) {
       for (int i = 0; i < retval.size(); i++) {
           if (!(retval.c_str()[i] >= '0' && retval.c_str()[i] <= '9')) {
              INVALID_NODE_ERROR("port", retval.c_str());
              retval = "";
              break;
           }
       }
    }
#endif

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_server_node ( xmlNodePtr &  node) [private]

Definition at line 536 of file IMSvrXMLConf.cpp.

{
    xmlNodePtr topnode = NULL;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"listen") == 0) {
           xmlChar *type = NULL;

           type = xmlGetProp(node, (xmlChar *)"type");
           if (xmlStrcmp(type, (xmlChar *)"tcp") == 0) {
              topnode = node;
              node = node->xmlChildrenNode;
              parse_listen_tcp_node(node, false);
              node = topnode->next;
              topnode = NULL;
           } else if (xmlStrcmp(type, (xmlChar *)"unix") == 0) {
              topnode = node;
              node = node->xmlChildrenNode;
              parse_listen_unix_node(node, false);
              node = topnode->next;
              topnode = NULL;
           } else {
              /* ignore the unknown nodes */
              LOG_WARNING("unknown listen type `%s'. ignoring...", type);
              node = node->next;
           }
           if (type != NULL)
              xmlFree(type);
       } else if (xmlStrcmp(node->name, (xmlChar *)"acls") == 0) {
           topnode = node;
           parse_acls_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"auth") == 0) {
           topnode = node;
           node = node->xmlChildrenNode;
           parse_auth_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"ssl") == 0) {
           topnode = node;
           parse_ssl_node(node);
           node = topnode->next;
           topnode = NULL;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "server");
           node = node->next;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_ssl_node ( xmlNodePtr &  node) [private]

Definition at line 427 of file IMSvrXMLConf.cpp.

{
#ifdef HAVE_TLS
    xmlNodePtr topnode = NULL;
    xmlChar *verify, *depth;
    string v;

    verify = xmlGetProp(node, (xmlChar *)"verify");
    depth = xmlGetProp(node, (xmlChar *)"depth");
    if (verify != NULL) {
       v = (const char *)verify;
       IMTLS::get_instance()->set_verify_client(v);
    }
    if (depth != NULL) {
       v = (const char *)depth;
       IMTLS::get_instance()->set_verify_depth(v);
    }
    LOG_DEBUG("<ssl verify=\"%s\" depth=\"%s\">", verify, depth);

    node = node->xmlChildrenNode;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"listen") == 0) {
           xmlChar *type = NULL;

           type = xmlGetProp(node, (xmlChar *)"type");
           if (xmlStrcmp(type, (xmlChar *)"tcp") == 0) {
              topnode = node;
              node = node->xmlChildrenNode;
              parse_listen_tcp_node(node, true);
              node = topnode->next;
              topnode = NULL;
           } else if (xmlStrcmp(type, (xmlChar *)"unix") == 0) {
              topnode = node;
              node = node->xmlChildrenNode;
              parse_listen_unix_node(node, true);
              node = topnode->next;
              topnode = NULL;
           } else {
              /* ignore the unknown nodes */
              LOG_WARNING("unknown listen type `%s'. ignoring...", type);
              node = node->next;
           }
           if (type != NULL)
              xmlFree(type);
       } else if (xmlStrcmp(node->name, (xmlChar *)"CACertificate") == 0) {
           xmlChar *path, *file;
           string v;

           path = xmlGetProp(node, (xmlChar *)"path");
           file = xmlGetProp(node, (xmlChar *)"file");

           if (path != NULL) {
              v = (const char *)path;
              IMTLS::get_instance()->set_cacertificate_path(v);
           }
           if (file != NULL) {
              v = (const char *)file;
              IMTLS::get_instance()->set_cacertificate_file(v);
           }
           LOG_DEBUG("<CACertificate path=\"%s\" file=\"%s\"/>", path, file);
           if (path != NULL)
              xmlFree(path);
           if (file != NULL)
              xmlFree(file);
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"Certificate") == 0) {
           xmlChar *file, *key;
           string v;

           file = xmlGetProp(node, (xmlChar *)"file");
           key = xmlGetProp(node, (xmlChar *)"key");

           if (file != NULL) {
              v = (const char *)file;
              IMTLS::get_instance()->set_certificate_file(v);
           }
           if (key != NULL) {
              v = (const char *)key;
              IMTLS::get_instance()->set_certificate_key_file(v);
           }
           LOG_DEBUG("<Certificate key=\"%s\" file=\"%s\"/>", key, file);
           if (file != NULL)
              xmlFree(file);
           if (key != NULL)
              xmlFree(key);
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"text") == 0
                 || xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore text and comment node */
           node = node->next;
       } else {
           /* ignore the unknown nodes */
           UNKNOWN_NODE_ERROR(node->name, "ssl");
           node = node->next;
       }
    }
    LOG_DEBUG("</ssl>");

    if (verify != NULL)
       xmlFree(verify);
    if (depth != NULL)
       xmlFree(depth);
#else
    LOG_WARNING("it was compiled without SSL support.");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrXMLConf::parse_system_node ( xmlNodePtr &  node) [private]

Definition at line 350 of file IMSvrXMLConf.cpp.

{
    xmlChar *type = NULL;
    IMAuth::access_type at;

    type = xmlGetProp(node, (xmlChar *)"type");
    at = get_access_type(type);
    if (at != IMAuth::UNKNOWN) {
       get_usermgr(ptarget)->set_systemuser_permission(at);
       LOG_DEBUG("<system type=\"%s\"/>", type);
    } else {
       LOG_ERROR("no permission or unknown permission `%s' on <system>.", type);
    }
    if (type != NULL)
       xmlFree(type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string IMSvrXMLConf::parse_text_node ( xmlNodePtr &  node) [private]

Definition at line 41 of file IMSvrXMLConf.cpp.

{
    string retval;

    while (node != NULL) {
       if (xmlStrcmp(node->name, (xmlChar *)"text") == 0) {
           retval = (const char *)node->content;
           node = node->next;
       } else if (xmlStrcmp(node->name, (xmlChar *)"comment") == 0) {
           /* ignore comment node */
           node = node->next;
       } else {
           UNKNOWN_NODE_ERROR(node->name, "text");
           node = node->next;
       }
    }

    return retval;
}

Here is the caller graph for this function:

void IMSvrXMLConf::parse_user_node ( xmlNodePtr &  node) [private]

Definition at line 368 of file IMSvrXMLConf.cpp.

{
    xmlChar *type = NULL, *name = NULL;
    IMAuth::access_type at;
    string password;

    type = xmlGetProp(node, (xmlChar *)"type");
    name = xmlGetProp(node, (xmlChar *)"name");

    at = get_access_type(type);
    if (at != IMAuth::UNKNOWN) {
       if (at == IMAuth::PASSWORD
           && node->xmlChildrenNode != NULL
           && node->xmlChildrenNode->name != NULL) {
           password += parse_text_node(node->xmlChildrenNode);
           get_usermgr(ptarget)->add_user((const char *)name, password.c_str(), at);
       } else {
           get_usermgr(ptarget)->add_user((const char *)name, NULL, at);
       }
       LOG_DEBUG("<user type=\"%s\" name=\"%s\">%s</user>", type, name, password.c_str());
    } else {
       LOG_ERROR("no permission or unknown permission `%s' on <user>.", type);
    }

    if (type != NULL)
       xmlFree(type);
    if (name != NULL)
       xmlFree(name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrCfg::set_nsmap_config ( IMSvr pimsvr,
IMNsMapStruct nsm,
int  num_entries 
) [inline, protected, inherited]

Definition at line 122 of file IMSvrCfg.hh.

    { return pimsvr->set_nsmap_config(nsm, num_entries); }

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrCfg::setbool ( enum IMSvrCfgOpt  opt,
bool  boolval 
) [protected, inherited]

Definition at line 181 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_BOOL) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.b = boolval;
}

Here is the caller graph for this function:

void IMSvrCfg::setnum ( enum IMSvrCfgOpt  opt,
int  numval 
) [protected, inherited]

Definition at line 194 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_NUMBER) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.n = numval;
}

Here is the caller graph for this function:

void IMSvrCfg::setstr ( enum IMSvrCfgOpt  opt,
const char *  strval 
) [protected, inherited]

Definition at line 207 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_STRING) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.s = strval;
}

Here is the caller graph for this function:

void IMSvrCfg::showall ( ) const [inherited]

Definition at line 262 of file IMSvrCfg.cpp.

{
    int i;
    for (i = 0; i < CFGOPT_LAST; i++) {
       switch(popts[i].type) {
         case ARG_BOOL:
          if (popts[i].v.b) {
              LOG_DEBUG("%s[%d]:true", popts[i].description.c_str(), (int)popts[i].opt);
          } else {
              LOG_DEBUG("%s[%d]:false", popts[i].description.c_str(), (int)popts[i].opt);
          }
          break;
         case ARG_NUMBER:
          LOG_DEBUG("%s[%d]:%d", popts[i].description.c_str(), (int)popts[i].opt, popts[i].v.n);
          break;
         case ARG_STRING:
          LOG_DEBUG("%s[%d]:%s", popts[i].description.c_str(), (int)popts[i].opt, popts[i].v.s.c_str());
          break;
         default:
          ERROR_INTERNAL("Invalid arg type.");
          break;
       }
    }

    return;
}

Member Data Documentation

string IMSvrXMLConf::filename [private]

Definition at line 12 of file IMSvrXMLConf.hh.

Definition at line 13 of file IMSvrXMLConf.hh.

Definition at line 11 of file IMSvrXMLConf.hh.


The documentation for this class was generated from the following files: