Ejemplo n.º 1
0
int do_sendmail(User * u, NickAlias * na)
{
    MailInfo *mail = NULL;
    char buf[BUFSIZE];

    if (!(na || u)) {
        return -1;
    }
    snprintf(buf, sizeof(buf), "SwiftIRC password change request for %s", na->nick);
    mail = MailBegin(u, na->nc, buf, s_NickServ);
    if (!mail) {
        return -1;
    }
    
    fprintf(mail->pipe, "Hi");
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "You or someone else has requested to reset the password for the account \"%s\" on the SwiftIRC network.  If you did not request this action or no longer require it then please ignore this e-mail.", na->nc->display);
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "To complete your password reset, please execute the following command in your IRC/Chat client:");
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "/ns confirmreset %s %s", na->nc->display,  moduleGetData(&na->nc->moduleData, MODULEDATAKEY));
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "Upon doing this, you will be automatically e-mailed a new password for your account."); 
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "Kind regards, ");
    fprintf(mail->pipe, "\n\n");
    fprintf(mail->pipe, "The SwiftIRC administration"); 
    fprintf(mail->pipe, "\n.\n");
    MailEnd(mail);
    
    return 0;
}
Ejemplo n.º 2
0
void csav_save_db(void)
{
    ChannelInfo *ci;
    int i = 0;
    char *data;
	char *filename;
    FILE *fp;

	if (CSAVoiceDBName) {
		filename = CSAVoiceDBName;
	} else {
		filename = DEFAULT_DB_NAME;
	}
	fp = fopen(filename, "w");
	if (!fp) {
		alog("cs_autovoice: Unable to open database ('%s') for writing!", filename);
		return;
	} else {
		for (i = 0; i < 256; i++) {
            for (ci = chanlists[i]; ci; ci = ci->next) {
                if ((data = moduleGetData(&ci->moduleData, "avoice"))) {
                    if (stricmp(data, "REG") == 0) {
                        fprintf(fp, "%s %s \n", "REG", ci->name);
                    } else if (stricmp(data, "ALL") == 0) {
                        fprintf(fp, "%s %s \n", "ALL", ci->name);
                    } else {
                        alog("cs_autovoice: Invalid avoice setting for channel [%s] not saving this record!", ci->name);
                    }
                    free(data);
                }
            }
        }        
    }
	fclose(fp);    
}
Ejemplo n.º 3
0
int do_resendcode(User * u)
{
    char *buffer = NULL;
    char *nick = NULL;
    NickAlias *na = NULL;

    buffer = moduleGetLastBuffer();
    if (buffer)
        nick = myStrGetToken(buffer, ' ', 0);

    if (!nick) {
        moduleNoticeLang(s_NickServ, u, RESENDCODE_SYNTAX);
    } else if (!anope_valid_nick(nick)) {
        notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
    } else if (!(na = findnick(nick))) {
        notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
    } else if (nick_identified(na->u)) {
        notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED);
    } else if (!(moduleGetData(&na->nc->moduleData, MODULEDATAKEY))) {
        moduleNoticeLang(s_NickServ, u, RESETPASS_NOT_REQUESTED, u->nick);
    } else {
        if (do_sendmail(u, na) != 0) {
            alog(LOG_COULDNT_SENDMAIL, MYNAME, na->nick);
        } else {
            moduleNoticeLang(s_NickServ, u, RESETPASS_SUCCESS, na->nick);
            moduleNoticeLang(s_NickServ, u, RESETPASS_INSTRUC);
        }
    }

    return MOD_CONT;
}
Ejemplo n.º 4
0
/**
* Called when user does /ns qlist
**/
int mQList(User * u) {
	NickCore *nc = NULL;
	int count = 0;
	char *data;
	int i;

	for (i = 0; i < 1024; i++) {
		for (nc = nclists[i]; nc; nc = nc->next) {
			/* If we have any info on this user */
			if ((data = moduleGetData(&nc->moduleData, "qdbban"))) {
				if (count == 0) {
					notice_user(s_NickServ, u, "Users who are banned from submitting to the QDB:");
				}

				notice_user(s_NickServ, u, nc->display);

				count++;
				free(data);
			}
		}
	}

	if (count == 0) {
		notice_user(s_NickServ, u, "No users are banned from submitting to the QDB");
	}

	return MOD_CONT;
}
Ejemplo n.º 5
0
/**
* Called after an svsadmin does a /ns info nick
* @param u The user who requested info
* @return MOD_CONT to continue processing commands or MOD_STOP to stop
**/
int myNickInfo(User * u)
{
	char *text;
	char *nick;
	char *data;
	NickCore *nc;
	NickAlias *na;

	if (is_services_oper(u)) {
		text = moduleGetLastBuffer();
		if (text) {
			nick = myStrGetToken(text, ' ', 0);
			if (nick) {
				if ((na = findnick(nick))) {
					nc = na->nc;

					if ((data = moduleGetData(&nc->moduleData, "qdbban"))) {
						notice_user(s_NickServ, u, "%s is banned from submitting to the QDB", na->nick);
					}

					if (data)
						free(data);
				}
				free(nick);
			}
		}
	}

	return MOD_CONT;
}
Ejemplo n.º 6
0
/**
* Save all our data to our db file
* @return 0 for success
**/
int mSaveData(int argc, char **argv)
{
	NickCore *nc = NULL;
	int i = 0;
	int ret = 0;
	FILE *out;
	FILE *xmlout;
	char *data;

	if (argc >= 1) {
		if (!stricmp(argv[0], EVENT_START)) {
			/* Regular Database */
			if ((out = fopen(qdbBanDBName, "w")) == NULL) {
				alog("ns_qdbban: ERROR: can not open the regular database file!");
				anope_cmd_global(s_OperServ, "ns_qdbban: ERROR: can not open the regular database file!");
				ret = 1;
			} else {
				/* XML Database */
				if ((xmlout = fopen(qdbBanXMLDBName, "w")) == NULL) {
					alog("ns_qdbban: ERROR: can not open the XML database file!");
					anope_cmd_global(s_OperServ, "ns_qdbban.c: ERROR: can not open the XML database file!");
					ret = 1;
				} else {
					fprintf(xmlout, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>\n");
					fprintf(xmlout, "<qdbbanlist>\n");

					for (i = 0; i < 1024; i++) {
						for (nc = nclists[i]; nc; nc = nc->next) {
							/* If we have any info on this user */
							if ((data = moduleGetData(&nc->moduleData, "qdbban"))) {
								fprintf(out, "%s\n", nc->display);
								fprintf(xmlout, "\t<qdbban>\n");

								char *nickEnt = html_entities(nc->display);

								fprintf(xmlout, "\t\t<nick>%s</nick>\n", nickEnt);
								fprintf(xmlout, "\t</qdbban>\n");

								free(nickEnt);
								free(data);
							}
						}
					}

					fprintf(xmlout, "</qdbbanlist>\n");

					fclose(out);
					fclose(xmlout);
				}
			}
		} else {
			ret = 0;
		}
	}

	return ret;
}
Ejemplo n.º 7
0
int do_confirm(User * u)
{
    char *buffer = NULL;
    char *nick = NULL;
    char *passcode = NULL;
    char *moduledata = NULL;
    NickAlias *na = NULL;

    buffer = moduleGetLastBuffer();

    if (buffer)
    {
        nick = myStrGetToken(buffer, ' ', 0);
        passcode = myStrGetToken(buffer, ' ', 1);
    }

    if (!nick) {
        moduleNoticeLang(s_NickServ, u, ENTERCODE_SYNTAX);
    } else if (!anope_valid_nick(nick)) {
        notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
    } else if (!(na = findnick(nick))) {
        notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
    } else if (nick_identified(na->u)) {
        notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED);
    } else if (!passcode) {
        moduleNoticeLang(s_NickServ, u, ENTERCODE_SYNTAX);
    } else {
        if (!(moduledata = moduleGetData(&na->nc->moduleData, MODULEDATAKEY))) {
            moduleNoticeLang(s_NickServ, u, RESETPASS_NOT_REQUESTED, nick);
        } else if (strcmp(passcode, moduledata) != 0) {
            moduleNoticeLang(s_NickServ, u, ENTERCODE_WRONG_PASSCODE);
            free(moduledata);
        } else {
            ns_setpassword(u, na->nc);
            moduleDelData(&na->nc->moduleData, MODULEDATAKEY);
            free(moduledata);
        }
    }

    return MOD_CONT;
}
Ejemplo n.º 8
0
int mEventJoin(int argc, char **argv)
{
    ChannelInfo *ci;
    User *u;
	NickAlias *na;
	char *data = NULL;
	if (argc != 3) {
        return MOD_CONT;
	}
	if (!(u = finduser(argv[1]))) {
		return MOD_CONT;
	}
    if (strcmp(argv[0], EVENT_STOP) == 0) {
        if (u) {
			if ((ci = cs_findchan(argv[2]))) {
				if ((data = moduleGetData(&ci->moduleData, "avoice"))) {
                    if (stricmp(data, "REG") == 0) {
						if ((na = findnick(u->nick))) {
							if (!check_access(na->u, ci, CA_AUTOVOICE) && nick_identified(u) && 
								!(na->nc->flags & NI_AUTOOP)) {
									anope_cmd_mode(whosends(ci), ci->name, "+v %s", na->nick);
									chan_set_user_status(ci->c, u, CUS_VOICE);
							}
						}
					} else if (stricmp(data, "ALL") == 0) {
						if (!check_access(u, ci, CA_AUTOVOICE)) {
							anope_cmd_mode(whosends(ci), ci->name, "+v %s", u->nick);
							chan_set_user_status(ci->c, u, CUS_VOICE);
						}
					}
					free(data);
				}
			}
		}
    }
    return MOD_CONT;
}
Ejemplo n.º 9
0
int do_resetpass(User * u)
{
    char *buffer = NULL;
    char *nick = NULL;
    char *email = NULL;

    char passcode[PASSCODELEN];
    char *callBackinfo[1];
    NickAlias *na = NULL;

    if ((RestrictReset == 1) && !(is_oper(u))) {
        notice_lang(s_NickServ, u, ACCESS_DENIED);
        return MOD_CONT;
    }

    buffer = moduleGetLastBuffer();
    nick = myStrGetToken(buffer, ' ', 0);
    email = myStrGetToken(buffer, ' ', 1);

    if (!nick) {
        moduleNoticeLang(s_NickServ, u, RESETPASS_SYNTAX);
    } else if (!anope_valid_nick(nick)) {
        notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
    } else if (!(na = findnick(nick))) {
        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 (na->nc->flags & NI_SUSPENDED) {
        notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
    } else if (!na->nc->email) {
         notice_user(s_NickServ, u, "%s has no email associated with their account.", na->nick);
    } else if (moduleGetData(&na->nc->moduleData, MODULEDATAKEY)) {
        moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED1,
                         na->nick);
        moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED2); 
    } else if (!email && !is_oper(u) && !is_helpop(u)) {
	notice(s_NickServ, u->nick, "You need to provide the e-mail address associated with the account you are trying to reset the password on.");
	notice(s_NickServ, u->nick, "Syntax: /ns resetpass <nickname> <e-mail>");
    } else if (!is_oper(u) && !is_helpop(u) && strcasecmp(email, na->nc->email)) {
	notice(s_NickServ, u->nick, "The e-mail address %s does not match the one associated with account %s.", email, na->nc->display);
    } else {
        generatePassCode(passcode);
        moduleAddData(&na->nc->moduleData, MODULEDATAKEY, passcode);
        if (do_sendmail(u, na) != 0) {
            alog(LOG_COULDNT_SENDMAIL, MYNAME, na->nick);
            moduleDelData(&na->nc->moduleData, MODULEDATAKEY);
        } else {
            callBackinfo[0] = na->nick;
            moduleAddCallback(MYNAME, time(NULL) + ExpirePassCode, expirePassCode, 1, callBackinfo);
            alog(LOG_RESETPASS_REQUESTED, MYNAME, u->nick, na->nick);
            moduleNoticeLang(s_NickServ, u, RESETPASS_SUCCESS, na->nick);
            moduleNoticeLang(s_NickServ, u, RESETPASS_INSTRUC);
        }
    }

    if (nick)
    	free(nick);
    if (email)
	free(email);

    return MOD_CONT;
}
Ejemplo n.º 10
0
int do_avoice(User *u)
{
	char *buf = moduleGetLastBuffer();
    char *chan = myStrGetToken(buf, ' ', 0);
    char *option = myStrGetTokenRemainder(buf, ' ', 1);
	char *data;
    ChannelInfo *ci;
    if (!chan) {
		moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SYNTAX);
		return MOD_CONT;
    }
    if ((ci = cs_findchan(chan))) {
        if (!check_access(u, ci, CA_PROTECT)) {
            notice_lang(s_ChanServ, u, PERMISSION_DENIED);
			if (chan) free(chan);
			if (option) free(option);
            return MOD_CONT;
        }
		if (!option) {
			if ((data = moduleGetData(&ci->moduleData, "avoice"))) {
				if (stricmp(data, "REG") == 0) {
					moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_REG, chan);
				} else if (stricmp(data, "ALL") == 0) {
					moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_ALL, chan);
				}
				free(data);
			} else {
				moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_OFF, chan);
			}
		} else {
			if (stricmp(option, "REG") == 0) {
				moduleAddData(&ci->moduleData, "avoice", "REG");
				moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_REG, chan);
			} else if (stricmp(option, "ALL") == 0) {
				moduleAddData(&ci->moduleData, "avoice", "ALL");
				moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_ALL, chan);
			} else if (stricmp(option, "OFF") == 0) {
				moduleDelData(&ci->moduleData, "avoice");
				moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_OFF, chan);
			} else if (stricmp(option, "STATUS") == 0) {
				if ((data = moduleGetData(&ci->moduleData, "avoice"))) {
					if (stricmp(data, "REG") == 0) {
						moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_REG, chan);
					} else if (stricmp(data, "ALL") == 0) {
						moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_ALL, chan);
					}
					free(data);
				} else {
					moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_OFF, chan);
				}
			} else {
				moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SYNTAX);
			}
		}
	} else {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
    }
	if (chan)
		free(chan);
	if (option)
		free(option);
    return MOD_CONT;
}