void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &password = params[0]; User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) { source.Reply(_("No oper block for your nickname.")); return; } if (o->GetPassword().empty()) { source.Reply(_("Your oper block doesn't require logging in.")); return; } if (u->HasExtOK("os_login")) { source.Reply(_("You are already logged in.")); return; } if (o->GetPassword() != password) { source.Reply(_("Password incorrect.")); u->BadPassword(); return; } Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; u->Extend<bool>("os_login", true); source.Reply(_("Password accepted.")); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) { source.Reply(_("No oper block for your nick.")); return; } if (o->GetPassword().empty()) { source.Reply(_("Your oper block doesn't require logging in.")); return; } if (!u->HasExtOK("os_login")) { source.Reply(_("You are not identified.")); return; } Log(LOG_ADMIN, source, this); u->ShrinkOK<bool>("os_login"); source.Reply(_("You have been logged out.")); }
int InstrPrint::execute(Stack &s) { Oper last = s.last(); if (last->getType() != INT8) throw Not8bitIntError(); std::cout << static_cast<char>(std::stoi((*last).toString())) << std::endl; return 1; }
void computeReduceGold( T* out, const T* idata, const unsigned int len) { Oper op; T sum = op.identity(); for (unsigned int i = 0; i < len; i++) { sum = op(sum, idata[i]); } *out = sum; }
void Deoper() { Oper *oper = user->Account()->GetOper(); if (oper != nullptr) { oper->Delete(); Log(this->owner) << "Removed services operator from " << user->nick << " (" << user->Account()->GetDisplay() << ")"; user->RemoveMode(Config->GetClient("OperServ"), "OPER"); // Probably not set, just incase } }
Node * methodPathJoin(Location loc, Evaluator * ex, Function * fn, Node * self, NodeArray args) { M_ASSERT(args.size() == 2); String * base = args[0]->requireString(); Oper * paths = args[1]->requireOper(); SmallString<64> result(base->value()); for (Oper::const_iterator it = paths->begin(), itEnd = paths->end(); it != itEnd; ++it) { path::combine(result, (*it)->requireString()->value()); } // if (path::isAbsolute(newpath->value())) { // // join does this too, but this saves creating a string. // return newpath; // } return String::create(result); }
void OnResult(const SQL::Result &r) override { SQLOperResultDeleter d(this); if (!user || !user->Account()) return; if (r.Rows() == 0) { Log(LogType::DEBUG) << "m_sql_oper: Got 0 rows for " << user->nick; Deoper(); return; } Anope::string opertype; try { opertype = r.Get(0, "opertype"); } catch (const SQL::Exception &) { Log(this->owner) << "Expected column named \"opertype\" but one was not found"; return; } Log(LogType::DEBUG) << "m_sql_oper: Got result for " << user->nick << ", opertype " << opertype; Anope::string modes; try { modes = r.Get(0, "modes"); } catch (const SQL::Exception &) { } ServiceBot *OperServ = Config->GetClient("OperServ"); if (opertype.empty()) { Deoper(); return; } OperType *ot = OperType::Find(opertype); if (ot == NULL) { Log(this->owner) << "m_sql_oper: Oper " << user->nick << " has type " << opertype << ", but this opertype does not exist?"; return; } Oper *oper = user->Account()->GetOper(); if (oper == nullptr || oper->GetType() != ot) { Log(this->owner) << "m_sql_oper: Tieing oper " << user->nick << " to type " << opertype; if (oper) oper->Delete(); oper = Serialize::New<Oper *>(); oper->SetName(user->Account()->GetDisplay()); oper->SetType(ot); user->Account()->SetOper(oper); } if (!user->HasMode("OPER")) { IRCD->SendOper(user); if (!modes.empty()) user->SetModes(OperServ, "%s", modes.c_str()); } }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &subcommand = params[0]; if (subcommand.equals_ci("ADD") && params.size() > 2) { const Anope::string &oper = params[1]; const Anope::string &otype = params[2]; if (!source.HasPriv("operserv/oper/modify")) { source.Reply(_("Access denied. You do not have the operator privilege \002{0}\002."), "operserv/oper/modify"); return; } NickServ::Nick *na = NickServ::FindNick(oper); if (na == NULL) { source.Reply(_("\002{0}\002 isn't currently online."), oper); return; } OperType *ot = OperType::Find(otype); if (ot == NULL) { source.Reply(_("Oper type \002{0}\002 has not been configured."), otype); return; } if (!HasPrivs(source, ot)) { source.Reply(_("Access denied.")); return; } Oper *o = na->GetAccount()->GetOper(); if (o != nullptr) { o->Delete(); } o = Serialize::New<Oper *>(); o->SetName(na->GetAccount()->GetDisplay()); o->SetType(ot); o->SetRequireOper(true); na->GetAccount()->SetOper(o); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); Log(LOG_ADMIN, source, this) << "ADD " << na->GetNick() << " as type " << ot->GetName(); source.Reply("\002{0}\002 (\002{1}\002) added to the \002{2}\002 list.", na->GetNick(), na->GetAccount()->GetDisplay(), ot->GetName()); } else if (subcommand.equals_ci("DEL") && params.size() > 1) { const Anope::string &oper = params[1]; if (!source.HasPriv("operserv/oper/modify")) { source.Reply(_("Access denied. You do not have the operator privilege \002{0}\002."), "operserv/oper/modify"); return; } NickServ::Nick *na = NickServ::FindNick(oper); if (na == nullptr || na->GetAccount() == nullptr) { source.Reply(_("\002{0}\002 isn't registered."), oper); return; } Oper *o = na->GetAccount()->GetOper(); if (o == nullptr) { source.Reply(_("Nick \002{0}\002 is not a Services Operator."), oper); return; } if (!HasPrivs(source, o->GetType())) { source.Reply(_("Access denied.")); return; } o->Delete(); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); Log(LOG_ADMIN, source, this) << "DEL " << na->GetNick(); source.Reply(_("Oper privileges removed from \002{0}\002 (\002{1}\002)."), na->GetNick(), na->GetAccount()->GetDisplay()); } else if (subcommand.equals_ci("LIST")) { source.Reply(_("Name Type")); for (NickServ::Account *nc : NickServ::service->GetAccountList()) { Oper *oper = nc->GetOper(); if (oper == nullptr) continue; source.Reply(Anope::printf("%-8s %s", oper->GetName().c_str(), oper->GetType()->GetName().c_str())); for (User *u : nc->users) source.Reply(_(" \002{0}\002 is online using this oper block."), u->nick); } } else if (subcommand.equals_ci("INFO")) { if (params.size() < 2) { source.Reply(_("Available opertypes:")); for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i) { OperType *ot = Config->MyOperTypes[i]; source.Reply("%s", ot->GetName().c_str()); } return; } Anope::string fulltype = params[1]; if (params.size() > 2) fulltype += " " + params[2]; OperType *ot = OperType::Find(fulltype); if (ot == NULL) { source.Reply(_("Oper type \002{0}\002 has not been configured."), fulltype); return; } if (ot->GetCommands().empty()) { source.Reply(_("Opertype \002{0}\002 has no allowed commands."), ot->GetName()); } else { source.Reply(_("Available commands for \002{0}\002:"), ot->GetName()); Anope::string buf; std::list<Anope::string> cmds = ot->GetCommands(); for (std::list<Anope::string>::const_iterator it = cmds.begin(), it_end = cmds.end(); it != it_end; ++it) { buf += *it + " "; if (buf.length() > 400) { source.Reply("%s", buf.c_str()); buf.clear(); } } if (!buf.empty()) { source.Reply("%s", buf.c_str()); buf.clear(); } } if (ot->GetPrivs().empty()) { source.Reply(_("Opertype \002{0}\002 has no allowed privileges."), ot->GetName()); } else { source.Reply(_("Available privileges for \002{0}\002:"), ot->GetName()); Anope::string buf; std::list<Anope::string> privs = ot->GetPrivs(); for (std::list<Anope::string>::const_iterator it = privs.begin(), it_end = privs.end(); it != it_end; ++it) { buf += *it + " "; if (buf.length() > 400) { source.Reply("%s", buf.c_str()); buf.clear(); } } if (!buf.empty()) { source.Reply("%s", buf.c_str()); buf.clear(); } } if (!ot->modes.empty()) source.Reply(_("Opertype \002{0}\002 receives modes \002{1}\002 once identified."), ot->GetName(), ot->modes); } else { this->OnSyntaxError(source, subcommand); } }