From: Gonzalo A. <ga...@us...> - 2006-11-06 19:49:55
|
Update of /cvsroot/mod-c/ehtml/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23720/src Modified Files: DefaultSessionDriver.h DefaultSessionDriver.cpp DefaultSessionIDDriver.cpp DiskSessionDriver.cpp Session.cpp Log Message: * Session fixes: the 'Location' based session configuration works now. Basically, we added 'checkargs' on ehtml session side. Index: DefaultSessionDriver.h =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/DefaultSessionDriver.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DefaultSessionDriver.h 12 Oct 2006 21:10:36 -0000 1.2 --- DefaultSessionDriver.h 6 Nov 2006 19:49:43 -0000 1.3 *************** *** 48,51 **** --- 48,52 ---- ~DefaultSessionDriver(); virtual bool SetArgs(const std::string& arg); + virtual bool CheckArgs(const std::string& arg); virtual bool Connect(); virtual bool Disconnect(); Index: DefaultSessionDriver.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/DefaultSessionDriver.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DefaultSessionDriver.cpp 12 Oct 2006 21:10:36 -0000 1.4 --- DefaultSessionDriver.cpp 6 Nov 2006 19:49:43 -0000 1.5 *************** *** 86,89 **** --- 86,124 ---- } + bool DefaultSessionDriver::CheckArgs(const string& arg) { + ProfileMe(); + istringstream s(arg); + string opt; + while (s >> opt) { + if (!strncmp("addr=",opt.c_str(),5)) { + string _addr(opt.c_str()+5); + if (!strncmp("unix://",_addr.c_str(),7)) { + ; + } else if (!_addr[0] == '/') { + ; + } else if (!strncmp("inet://",_addr.c_str(),7)) { + char host[16]; + unsigned short port; + if (sscanf(_addr.c_str()+7, "%[.0-9]:%hu", host, &port) != 2) { + errno = EINVAL; + return false; + } + struct sockaddr_in _addr; + if (!inet_aton(host, &_addr.sin_addr)) { + errno = EINVAL; + return false; + } + } else { + errno = EINVAL; + return false; + } + } else { + errno = EINVAL; + return false; + } + } + return true; + } + void DefaultSessionDriver::init() { Index: DefaultSessionIDDriver.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/DefaultSessionIDDriver.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DefaultSessionIDDriver.cpp 12 Oct 2006 21:10:36 -0000 1.3 --- DefaultSessionIDDriver.cpp 6 Nov 2006 19:49:43 -0000 1.4 *************** *** 90,93 **** --- 90,94 ---- DefaultSessionIDDriver(): extra_entropy(0) { ; } virtual bool SetArgs(const string& id); + virtual bool CheckArgs(const string& id); virtual bool ValidID(SessionID& id); virtual SessionID GenerateID(); *************** *** 97,100 **** --- 98,103 ---- ProfileMe(); bool dev = true; + if (!arg[0]) + return true; if (!strncmp(arg.c_str(), "extra_entropy=", 14)) extra_entropy = xatoul(arg.c_str()+14); *************** *** 106,109 **** --- 109,126 ---- } + bool DefaultSessionIDDriver::CheckArgs(const string& arg) { + ProfileMe(); + bool dev = true; + if (!arg[0]) + return true; + if (!strncmp(arg.c_str(), "extra_entropy=", 14)) + ; + else { + errno = EINVAL; + dev = false; + } + return dev; + } + bool DefaultSessionIDDriver::ValidID(SessionID& id) { ProfileMe(); Index: Session.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/Session.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Session.cpp 12 Oct 2006 21:10:36 -0000 1.19 --- Session.cpp 6 Nov 2006 19:49:43 -0000 1.20 *************** *** 219,222 **** --- 219,231 ---- } + int checkSessionDriver(const char* name, const char* arg) { + SessionDriver* selected = SessionDriver::getByName(name); + if (selected == NULL) { + errno = ENOENT; + return -1; + } + return selected->CheckArgs(arg) ? 0 : -1; + } + int useSessionDriver(const char* name, const char* arg) { SessionDriver* selected = SessionDriver::getByName(name); *************** *** 259,262 **** --- 268,280 ---- } + int checkSessionIDDriver(const char* name, const char* arg) { + SessionIDDriver* selected = SessionIDDriver::getByName(name); + if (selected == NULL) { + errno = ENOENT; + return -1; + } + return selected->CheckArgs(arg) ? 0 : -1; + } + int useSessionIDDriver(const char* name, const char* arg) { SessionIDDriver* selected = SessionIDDriver::getByName(name); Index: DiskSessionDriver.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/DiskSessionDriver.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DiskSessionDriver.cpp 3 Nov 2006 20:34:53 -0000 1.9 --- DiskSessionDriver.cpp 6 Nov 2006 19:49:43 -0000 1.10 *************** *** 54,57 **** --- 54,58 ---- virtual ~DiskSessionDriver() { ; } virtual bool SetArgs(const std::string& arg); + virtual bool CheckArgs(const std::string& arg); virtual bool Connect(); virtual bool Disconnect(); *************** *** 125,128 **** --- 126,151 ---- } + bool DiskSessionDriver::CheckArgs(const string& arg) { + ProfileMe(); + istringstream i(arg.c_str()); + string _arg; + while (i >> _arg) { + if (!strncmp(_arg.c_str(),"spool=",6)) { + ; + } else if (!strncmp(_arg.c_str(), "collect_prob=", 13)) { + double p = xatod(_arg.c_str()+13); + if (p > 1 || p < 0) + return false; + } else if (!strncmp(_arg.c_str(), "old_enough=", 11)) { + char* end; + strtoul(_arg.c_str()+11, &end, 10); + if (*end) + return false; + } else + return false; + } + return true; + } + bool DiskSessionDriver::Connect() { ProfileMe(); |