int do_getpass(User * u) { char *chan = strtok(NULL, " "); char tmp_pass[PASSMAX]; ChannelInfo *ci; if (!chan) { syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX); } else if (!(ci = cs_findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); } else if (ci->flags & CI_VERBOTEN) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); } else if (CSRestrictGetPass && !is_services_root(u)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX)==1) { alog("%s: %s!%s@%s used GETPASS on %s", s_ChanServ, u->nick, u->username, u->host, ci->name); if (WallGetpass) { xanadu_cmd_global(s_ChanServ, "\2%s\2 used GETPASS on channel \2%s\2", u->nick, chan); } notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS, chan, ci->founderpass); } else { notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE); } } return MOD_CONT; }
static int do_saset_password(User * u, NickCore * nc, char *param) { int len = strlen(param); char tmp_pass[PASSMAX]; if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc) && !is_services_root(u)) { notice_lang(s_NickServ, u, PERMISSION_DENIED); return MOD_CONT; } else if (stricmp(nc->display, param) == 0 || (StrictPasswords && len < 5)) { notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); return MOD_CONT; } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) { notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); return MOD_CONT; } if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) { memset(param, 0, len); alog("%s: Failed to encrypt password for %s (set)", s_NickServ, nc->display); notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_FAILED, nc->display); return MOD_CONT; } memset(param, 0, len); if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) { notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display, tmp_pass); } else { notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display); } alog("%s: %s!%s@%s used SASET PASSWORD on %s (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, nc->display, (nc->email ? nc->email : "none")); if (WallSetpass) anope_cmd_global(s_NickServ, "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick, nc->display); return MOD_CONT; }
/** * The /ns getpass command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_getpass(User * u) { char *nick = strtok(NULL, " "); char tmp_pass[PASSMAX]; NickAlias *na; NickRequest *nr = NULL; if (!nick) { syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX); } else if (!(na = findnick(nick))) { if ((nr = findrequestnick(nick))) { alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, u->username, u->host, nick); if (WallGetpass) xanadu_cmd_global(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick, nick); notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick, nr->passcode); } else { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } } else if (na->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); } else if (NSSecureAdmins && nick_is_services_admin(na->nc) && !is_services_root(u)) { notice_lang(s_NickServ, u, PERMISSION_DENIED); } else if (NSRestrictGetPass && !is_services_root(u)) { notice_lang(s_NickServ, u, PERMISSION_DENIED); } else { if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX)==1) { alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, u->username, u->host, nick); if (WallGetpass) xanadu_cmd_global(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick, nick); notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick, na->nc->pass); } else { notice_lang(s_NickServ, u, NICK_GETPASS_UNAVAILABLE); } } return MOD_CONT; }
static void ATHEME_CONVERT_write_accounts(void) { int i, ii; NickCore *nc; NickAlias *na, *na2; time_t registered; int athemeflags; #if VERSION_BUILD >= 1185 char decr_pass[PASSMAX * 3 + 1]; #endif char passwdbuf[PASSMAX * 3 + 1]; char *passwd; const char *encmod; #if VERSION_BUILD >= 1489 encmod = EncModule; #else encmod = "enc_old"; #endif if (!f) return; alog("[convert to atheme] converting accounts..."); /* NickCore is myuser_t, NickAlias is mynick_t */ for (i = 0; i < 1024; i++) { for (nc = nclists[i]; nc; nc = nc->next) { athemeflags = 0; if (nc->aliases.count == 0) continue; na = nc->aliases.list[0]; registered = na->time_registered; for (ii = 1; ii < nc->aliases.count; ii++) { na2 = nc->aliases.list[ii]; if (na2->status & NS_NO_EXPIRE) athemeflags |= 0x1; /* MU_HOLD */ if (na2->last_seen > na->last_seen) na = na2; if (na2->time_registered < registered) registered = na2->time_registered; } if (na->status & NS_VERBOTEN) continue; if (nc->flags & NI_HIDE_EMAIL) athemeflags |= 0x10; /* MU_HIDEMAIL */ #ifdef CONVERT_AUTOOP #ifdef NI_AUTOOP if (!(nc->flags & NI_AUTOOP)) athemeflags |= 0x4; /* MU_NOOP */ #endif #endif #if VERSION_BUILD >= 1185 if (enc_decrypt(nc->pass,decr_pass,PASSMAX)!=1) #else if (nc->flags & NI_ENCRYPTEDPW) #endif { #ifdef CONVERT_CRYPTPASS athemeflags |= 0x100; /* MU_CRYPTPASS */ /* this stuff may contain '\0' and other * garbage, encode it -- jilles */ if (!strcmp(encmod, "enc_old")) { strcpy(passwdbuf, "$ircservices$"); /* the encrypted password is 16 bytes long, * but the last 8 bytes are constant, * omit them */ for (ii = 0; ii <= 7; ii++) sprintf(passwdbuf + 13 + 2 * ii, "%02x", 255 & (int)na->nc->pass[ii]); } else if (!strcmp(encmod, "enc_md5")) { strcpy(passwdbuf, "$rawmd5$"); for (ii = 0; ii <= 15; ii++) sprintf(passwdbuf + 8 + 2 * ii, "%02x", 255 & (int)na->nc->pass[ii]); } else if (!strcmp(encmod, "enc_sha1")) { strcpy(passwdbuf, "$rawsha1$"); for (ii = 0; ii <= 19; ii++) sprintf(passwdbuf + 9 + 2 * ii, "%02x", 255 & (int)na->nc->pass[ii]); } else { /* unknown encryption module, hmm */ sprintf(passwdbuf, "$%s$", encmod); passwd = passwdbuf + strlen(passwdbuf); for (ii = 0; ii <= 19; ii++) sprintf(passwd + 2 * ii, "%02x", 255 & (int)na->nc->pass[ii]); } passwd = passwdbuf; #else passwd = nc->display; #endif } else #if VERSION_BUILD >= 1185 passwd = decr_pass; #else passwd = nc->pass; #endif if (nc->memos.memomax == 0) athemeflags |= 0x40; /* MU_NOMEMO */ fprintf(f, "MU %s %s %s %lu %lu %d\n", nc->display, passwd, nc->email, (unsigned long)registered, (unsigned long)na->last_seen, athemeflags); if (na->last_usermask != NULL) { /*fprintf(f, "MDU %s private:host:actual %s", nc->display, na->last_usermask);*/ fprintf(f, "MDU %s private:host:vhost %s\n", nc->display, na->last_usermask); } if (nc->greet) fprintf(f, "MDU %s greet %s\n", nc->display, nc->greet); if (nc->icq) fprintf(f, "MDU %s icq %u\n", nc->display, (unsigned int)nc->icq); if (nc->url) fprintf(f, "MDU %s url %s\n", nc->display, nc->url); if (nc->flags & NI_SERVICES_ROOT) fprintf(f, "SO %s %s 0\n", nc->display, OPERCLASS_ROOT); else if (nc->flags & NI_SERVICES_ADMIN) fprintf(f, "SO %s %s 0\n", nc->display, OPERCLASS_ADMIN); else if (nc->flags & NI_SERVICES_OPER) fprintf(f, "SO %s %s 0\n", nc->display, OPERCLASS_OPER); for (ii = 0; ii < nc->accesscount; ii++) fprintf(f, "AC %s %s\n", nc->display, nc->access[ii]); for (ii = 0; ii < nc->aliases.count; ii++) { na = nc->aliases.list[ii]; fprintf(f, "MN %s %s %ld %ld\n", nc->display, na->nick, (unsigned long)na->time_registered, (unsigned long)na->last_seen); } muout++; } } }
/** * The /cs register command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_register(User * u) { char *chan = strtok(NULL, " "); char *pass = strtok(NULL, " "); char *desc = strtok(NULL, ""); NickCore *nc; Channel *c; ChannelInfo *ci; struct u_chaninfolist *uc; int is_servadmin = is_services_admin(u); char founderpass[PASSMAX + 1]; char tmp_pass[PASSMAX]; if (readonly) { notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED); return MOD_CONT; } if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) { notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED); return MOD_CONT; } if (!desc) { syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX); } else if (*chan == '&') { notice_lang(s_ChanServ, u, CHAN_REGISTER_NOT_LOCAL); } else if (*chan != '#') { notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED); } else if (!xanadu_valid_chan(chan)) { notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan); } else if (!u->na || !(nc = u->na->nc)) { notice_lang(s_ChanServ, u, CHAN_MUST_REGISTER_NICK, s_NickServ); } else if (!nick_recognized(u)) { notice_lang(s_ChanServ, u, CHAN_MUST_IDENTIFY_NICK, s_NickServ, s_NickServ); } else if (!(c = findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_REGISTER_NONE_CHANNEL, chan); } else if ((ci = cs_findchan(chan)) != NULL) { if (ci->flags & CI_VERBOTEN) { alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, u->host); notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); } else { notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan); } } else if (!stricmp(chan, "#")) { notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); } else if (!chan_has_user_status(c, u, CUS_OP)) { notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP); } else if (!is_servadmin && nc->channelmax > 0 && nc->channelcount >= nc->channelmax) { notice_lang(s_ChanServ, u, nc->channelcount > nc-> channelmax ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, nc->channelmax); } else if (stricmp(u->nick, pass) == 0 || (StrictPasswords && strlen(pass) < 5)) { notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD); } else if (!(ci = makechan(chan))) { alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan); notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); } else if (strscpy(founderpass, pass, PASSMAX + 1), enc_encrypt_in_place(founderpass, PASSMAX) < 0) { alog("%s: Couldn't encrypt password for %s (REGISTER)", s_ChanServ, chan); notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); delchan(ci); } else { c->ci = ci; ci->c = c; ci->bantype = CSDefBantype; ci->flags = CSDefFlags; ci->mlock_on = ircd->defmlock; ci->memos.memomax = MSMaxMemos; ci->last_used = ci->time_registered; ci->founder = nc; if (strlen(pass) > PASSMAX) notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX); memset(pass, 0, strlen(pass)); memcpy(ci->founderpass, founderpass, PASSMAX); ci->desc = sstrdup(desc); if (c->topic) { ci->last_topic = sstrdup(c->topic); strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX); ci->last_topic_time = c->topic_time; } else { /* Set this to something, otherwise it will maliform the topic */ strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX); } ci->bi = NULL; ci->botflags = BSDefFlags; ci->founder->channelcount++; alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan, u->nick, u->username, u->host); notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick); if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX) == 1) { notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, ci->founderpass); } uc = scalloc(sizeof(*uc), 1); uc->next = u->founder_chans; uc->prev = NULL; if (u->founder_chans) u->founder_chans->prev = uc; u->founder_chans = uc; uc->chan = ci; /* Implement new mode lock */ check_modes(c); /* On most ircds you do not receive the admin/owner mode till its registered */ if (ircd->admin) { xanadu_cmd_mode(s_ChanServ, chan, "%s %s", ircd->adminset, u->nick); } if (ircd->owner && ircd->ownerset) { xanadu_cmd_mode(s_ChanServ, chan, "%s %s", ircd->ownerset, u->nick); } send_event(EVENT_CHAN_REGISTERED, 1, chan); } return MOD_CONT; }