void session_sid::clear(session_interface &session) { std::string id; if(valid_sid(session.get_session_cookie(),id)) storage_->remove(id); session.clear_session_cookie(); }
bool session_sid::load(session_interface &session,std::string &data,time_t &timeout) { string id; if(!valid_sid(session.get_session_cookie(),id)) return false; std::string tmp_data; if(!storage_->load(id,timeout,data)) return false; if(time(0) > timeout) { storage_->remove(id); return false; } return true; }
void session_sid::save(session_interface &session,std::string const &data,time_t timeout,bool new_data,bool /*unused*/) { std::string id; if(valid_sid(session.get_session_cookie(),id)) { if(new_data) { storage_->remove(id); id = get_new_sid(); } } else { id = get_new_sid(); } storage_->save(id,timeout,data); session.set_session_cookie("I"+id); // Renew cookie or set new one }
void session_sid::save(session_interface &session,std::string const &data,time_t timeout,bool new_data,bool unused) { string id; if(!new_data) { if(!valid_sid(session.get_session_cookie(),id)) { impl::sid_generator generator; id=generator.get(); // if id not valid create new one } } else { impl::sid_generator generator; id=generator.get(); } storage_->save(id,timeout,data); session.set_session_cookie("I"+id); // Renew cookie or set new one }
/* * m_pass() - Added Sat, 4 March 1989 * * * mr_pass - PASS message handler * parv[0] = sender prefix * parv[1] = password * parv[2] = optional extra version information */ static void mr_pass(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { char *password = parv[1]; if (EmptyString(password)) { sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name, EmptyString(parv[0]) ? "*" : parv[0], "PASS"); return; } MyFree(client_p->localClient->passwd); if (strlen(password) > PASSWDLEN) password[PASSWDLEN] = '\0'; DupString(client_p->localClient->passwd, password); if (parc > 2) { /* It looks to me as if orabidoo wanted to have more * than one set of option strings possible here... * i.e. ":AABBTS" as long as TS was the last two chars * however, as we are now using CAPAB, I think we can * safely assume if there is a ":TS" then its a TS server * -Dianora */ if (!irccmp(parv[2], "TS") && client_p->tsinfo == 0) client_p->tsinfo = TS_DOESTS; } /* only do this stuff if we are doing ts6 */ if (parc > 4 && me.id[0]) { if (atoi(parv[3]) >= 6 && valid_sid(parv[4])) { strlcpy(client_p->id, parv[4], sizeof(client_p->id)); SetCapable(client_p, CAP_TS6); } } }
/*! \brief PASS command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = password * - parv[2] = unused * - parv[3] = TS protocol version * - parv[4] = server ID (SID) */ static int mr_pass(struct Client *source_p, int parc, char *parv[]) { assert(MyConnect(source_p)); if (EmptyString(parv[1])) { sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "PASS"); return 0; } MyFree(source_p->connection->password); source_p->connection->password = xstrndup(parv[1], IRCD_MIN(strlen(parv[1]), PASSWDLEN)); /* Only do this stuff if we are doing ts6 */ if (parc > 4) if (atoi(parv[3]) >= 6 && valid_sid(parv[4])) strlcpy(source_p->id, parv[4], sizeof(source_p->id)); return 0; }
/*! \brief PASS command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = password * - parv[2] = optional extra version information * - parv[3] = TS protocol version * - parv[4] = server ID (SID) */ static int mr_pass(struct Client *source_p, int parc, char *parv[]) { assert(MyConnect(source_p)); if (EmptyString(parv[1])) { sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "PASS"); return 0; } MyFree(source_p->connection->password); source_p->connection->password = xstrndup(parv[1], IRCD_MIN(strlen(parv[1]), PASSWDLEN)); if (parc > 2) { /* * It looks to me as if orabidoo wanted to have more * than one set of option strings possible here... * i.e. ":AABBTS" as long as TS was the last two chars * however, as we are now using CAPAB, I think we can * safely assume if there is a ":TS" then it's a TS server * -Dianora */ if (!irccmp(parv[2], "TS") && source_p->tsinfo == 0) source_p->tsinfo = TS_DOESTS; } /* Only do this stuff if we are doing ts6 */ if (parc > 4) { if (atoi(parv[3]) >= 6 && valid_sid(parv[4])) { strlcpy(source_p->id, parv[4], sizeof(source_p->id)); SetCapable(source_p, CAP_TS6); } } return 0; }