X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_oper.c;h=c820fe95907c2573194b3026fb903c7bb2e7d92b;hb=refs%2Fheads%2Fupstream-ssl;hp=8de332648edbf5f7e236963f1d22fe1edd58009c;hpb=36ab1bb01f9a0f5f630f3098b1afdc5ccc937fa6;p=ircu2.10.12-pk.git diff --git a/ircd/m_oper.c b/ircd/m_oper.c index 8de3326..c820fe9 100644 --- a/ircd/m_oper.c +++ b/ircd/m_oper.c @@ -79,21 +79,17 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "client.h" #include "hash.h" #include "ircd.h" +#include "ircd_alloc.h" +#include "ircd_features.h" #include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" -#include "ircd_xopen.h" +#include "ircd_crypt.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" @@ -101,37 +97,36 @@ #include "s_conf.h" #include "s_debug.h" #include "s_user.h" +#include "s_misc.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include -#ifdef CRYPT_OPER_PASSWORD int oper_password_match(const char* to_match, const char* passwd) { + char *crypted; + int res; /* * use first two chars of the password they send in as salt * * passwd may be NULL. Head it off at the pass... */ - if (to_match && passwd) { - char salt[3]; - const char* encr; - salt[0] = passwd[0]; - salt[1] = passwd[1]; - salt[2] = '\0'; - encr = ircd_crypt(to_match, salt); - return (0 == strcmp(encr, passwd)); - } - return 0; -} -#else -int oper_password_match(const char* to_match, const char* passwd) -{ - return (to_match && passwd) ? (0 == strcmp(to_match, passwd)) : 0; + if (!to_match || !passwd) + return 0; + + /* we no longer do a CRYPT_OPER_PASSWORD check because a clear + text passwords just handled by a fallback mechanism called + crypt_clear if it's enabled -- hikari */ + crypted = ircd_crypt(to_match, passwd); + + if (!crypted) + return 0; + res = strcmp(crypted, passwd); + MyFree(crypted); + return 0 == res; } -#endif /* * m_oper - generic message handler @@ -151,66 +146,57 @@ int m_oper(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (EmptyString(name) || EmptyString(password)) return need_more_params(sptr, "OPER"); - aconf = find_conf_exact(name, sptr->username, sptr->sockhost, CONF_OPS); - if (!aconf) - aconf = find_conf_exact(name, sptr->username, - ircd_ntoa((const char*) &cptr->ip), CONF_OPS); - - if (!aconf || IsIllegal(aconf)) { + aconf = find_conf_exact(name, sptr, CONF_OPERATOR); + if (!aconf || IsIllegal(aconf)) + { send_reply(sptr, ERR_NOOPERHOST); sendto_opmask_butone(0, SNO_OLDREALOP, "Failed OPER attempt by %s (%s@%s)", - parv[0], sptr->user->username, sptr->sockhost); + parv[0], cli_user(sptr)->username, cli_sockhost(sptr)); return 0; } - assert(0 != (aconf->status & CONF_OPS)); + assert(0 != (aconf->status & CONF_OPERATOR)); - if (oper_password_match(password, aconf->passwd)) { - unsigned int old_mode = (sptr->flags & ALL_UMODES); + if (oper_password_match(password, aconf->passwd)) + { + struct Flags old_mode = cli_flags(sptr); if (ACR_OK != attach_conf(sptr, aconf)) { send_reply(sptr, ERR_NOOPERHOST); sendto_opmask_butone(0, SNO_OLDREALOP, "Failed OPER attempt by %s " - "(%s@%s)", parv[0], sptr->user->username, - sptr->sockhost); + "(%s@%s)", parv[0], cli_user(sptr)->username, + cli_sockhost(sptr)); return 0; } - if (CONF_LOCOP == aconf->status) { - ClearOper(sptr); - SetLocOp(sptr); - } - else { - /* - * prevent someone from being both oper and local oper - */ + SetLocOp(sptr); + client_set_privs(sptr, aconf); + if (HasPriv(sptr, PRIV_PROPAGATE)) + { ClearLocOp(sptr); SetOper(sptr); ++UserStats.opers; } - cptr->handler = OPER_HANDLER; + cli_handler(cptr) = OPER_HANDLER; + SetFlag(sptr, FLAG_WALLOP); + SetFlag(sptr, FLAG_SERVNOTICE); + SetFlag(sptr, FLAG_DEBUG); - sptr->flags |= (FLAGS_WALLOP | FLAGS_SERVNOTICE | FLAGS_DEBUG); - set_snomask(sptr, SNO_OPERDEFAULT, SNO_ADD); - send_umode_out(cptr, sptr, old_mode); + cli_max_sendq(sptr) = 0; /* Get the sendq from the oper's class */ + send_umode_out(cptr, sptr, &old_mode, HasPriv(sptr, PRIV_PROPAGATE)); send_reply(sptr, RPL_YOUREOPER); sendto_opmask_butone(0, SNO_OLDSNO, "%s (%s@%s) is now operator (%c)", - parv[0], sptr->user->username, sptr->sockhost, + parv[0], cli_user(sptr)->username, cli_sockhost(sptr), IsOper(sptr) ? 'O' : 'o'); - ircd_log(L_INFO, "OPER (%s) by (%s!%s@%s)", - name, parv[0], sptr->user->username, sptr->sockhost); -#ifdef FNAME_OPERLOG - if (IsUser(sptr)) - write_log(FNAME_OPERLOG, - "%s OPER (%s) by (%#C)\n", myctime(CurrentTime), name, sptr); -#endif + log_write(LS_OPER, L_INFO, 0, "OPER (%s) by (%#C)", name, sptr); } - else { + else + { send_reply(sptr, ERR_PASSWDMISMATCH); sendto_opmask_butone(0, SNO_OLDREALOP, "Failed OPER attempt by %s (%s@%s)", - parv[0], sptr->user->username, sptr->sockhost); + parv[0], cli_user(sptr)->username, cli_sockhost(sptr)); } return 0; } @@ -225,9 +211,10 @@ int ms_oper(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* * if message arrived from server, trust it, and set to oper */ - if (!IsServer(sptr) && !IsOper(sptr)) { + if (!IsServer(sptr) && !IsOper(sptr)) + { ++UserStats.opers; - sptr->flags |= FLAGS_OPER; + SetFlag(sptr, FLAG_OPER); sendcmdto_serv_butone(sptr, CMD_MODE, cptr, "%s :+o", parv[0]); } return 0; @@ -243,121 +230,3 @@ int mo_oper(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_YOUREOPER); return 0; } - -#if 0 -/* - * m_oper - * parv[0] = sender prefix - * parv[1] = oper name - * parv[2] = oper password - */ -int m_oper(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct ConfItem* aconf; - char* name; - char* password; - const char* encr; -#ifdef CRYPT_OPER_PASSWORD - char salt[3]; -#endif /* CRYPT_OPER_PASSWORD */ - - name = parc > 1 ? parv[1] : 0; - password = parc > 2 ? parv[2] : 0; - - if (!IsServer(cptr) && (EmptyString(name) || EmptyString(password))) - return need_more_params(sptr, "OPER"); - - /* if message arrived from server, trust it, and set to oper */ - - if (IsServer(cptr) && !IsOper(sptr)) { - ++UserStats.opers; - sptr->flags |= FLAGS_OPER; - sendto_serv_butone(cptr, "%s%s " TOK_MODE " %s :+o", NumNick(sptr), parv[0]); /* XXX DEAD */ - return 0; - } - else if (IsAnOper(sptr)) { - if (MyConnect(sptr)) - sendto_one(sptr, rpl_str(RPL_YOUREOPER), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - assert(cptr == sptr); - aconf = find_conf_exact(name, sptr->username, sptr->sockhost, CONF_OPS); - if (!aconf) - aconf = find_conf_exact(name, sptr->username, - ircd_ntoa((const char*) &cptr->ip), CONF_OPS); - - if (!aconf || IsIllegal(aconf)) { - sendto_one(sptr, err_str(ERR_NOOPERHOST), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - return 0; - } - assert(0 != (aconf->status & CONF_OPS)); - -#ifdef CRYPT_OPER_PASSWORD - /* use first two chars of the password they send in as salt */ - - /* passwd may be NULL. Head it off at the pass... */ - salt[0] = '\0'; - if (password && aconf->passwd) - { - salt[0] = aconf->passwd[0]; - salt[1] = aconf->passwd[1]; - salt[2] = '\0'; - encr = ircd_crypt(password, salt); - } - else - encr = ""; -#else - encr = password; -#endif /* CRYPT_OPER_PASSWORD */ - - if (0 == strcmp(encr, aconf->passwd)) { - int old = (sptr->flags & ALL_UMODES); - - if (ACR_OK != attach_conf(sptr, aconf)) { - sendto_one(sptr, err_str(ERR_NOOPERHOST), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - return 0; - } -#ifdef OPER_REMOTE - if (aconf->status == CONF_LOCOP) { -#else - if (!IsLocal(sptr)) || aconf->status == CONF_LOCOP) { -#endif - ClearOper(sptr); - SetLocOp(sptr); - } - else { - /* prevent someone from being both oper and local oper */ - ClearLocOp(sptr); - SetOper(sptr); - ++UserStats.opers; - } - cptr->handler = OPER_HANDLER; - sendto_ops("%s (%s@%s) is now operator (%c)", parv[0], /* XXX DEAD */ - sptr->user->username, sptr->sockhost, IsOper(sptr) ? 'O' : 'o'); - - sptr->flags |= (FLAGS_WALLOP | FLAGS_SERVNOTICE | FLAGS_DEBUG); - set_snomask(sptr, SNO_OPERDEFAULT, SNO_ADD); - send_umode_out(cptr, sptr, old); - sendto_one(sptr, rpl_str(RPL_YOUREOPER), me.name, parv[0]); /* XXX DEAD */ - - ircd_log(L_INFO, "OPER (%s) by (%s!%s@%s)", - name, parv[0], sptr->user->username, sptr->sockhost); -#ifdef FNAME_OPERLOG - if (IsUser(sptr)) - write_log(FNAME_OPERLOG, - "%s OPER (%s) by (%s!%s@%s)\n", myctime(CurrentTime), - name, parv[0], sptr->user->username, sptr->sockhost); -#endif - } - else { - sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - } - return 0; -} -#endif /* 0 */