Move sendpassword to authcmds.
Fix bug in findnearestmaildomain.
Makefile:
../mkcommandlist.pl chanserv_authcmds.so
-chanserv_authcmds.so: auth.o authhistory.o challenge.o challengeauth.o checkhashpass.o email.o getpassword.o hello.o login.o newpass.o requestpassword.o setemail.o setpassword.o commandlist.o
+chanserv_authcmds.so: auth.o authhistory.o challenge.o challengeauth.o checkhashpass.o email.o getpassword.o hello.o login.o newpass.o requestpassword.o sendpassword.o setemail.o setpassword.o commandlist.o
ld -shared -Bdynamic -o $@ $^
int csa_doauth(void *source, int cargc, char **cargv);
int csa_donewpw(void *source, int cargc, char **cargv);
int csa_doreqpw(void *source, int cargc, char **cargv);
+int csa_dosendpw(void *source, int cargc, char **cargv);
int csa_dosetmail(void *source, int cargc, char **cargv);
int csa_dosetpw(void *source, int cargc, char **cargv);
chanservaddcommand("login", QCMD_SECURE | QCMD_NOTAUTHED | QCMD_ALIAS, 2, csa_doauth, "Authenticates you on the bot.", "Usage: LOGIN <username> <password>\nAuthenticates you on the bot, where:\nusername - your username\npassword - your password\nIf you do not have a username and password, see HELLO.\nNote: due to the sensitive nature of this command, you must send the message\nto Q@CServe.quakenet.org when using it.\nNote: the preferred way to authenticate is to use the /AUTH command.\n");
chanservaddcommand("newpass", QCMD_SECURE | QCMD_AUTHED, 3, csa_donewpw, "Change your password.", "Usage: NEWPASS <oldpassword> <newpassword> <newpassword>\nChanges your account password. Your new password must be at least 6 characters\nlong, contain at least one number and one letter, and may not contain sequences\nof letters or numbers. Your new password will be sent to your registered email\naddress. Where:\noldpassword - your existing account password\nnewpassword - your desired new password. Must be entered the same both times.\nNote: due to the sensitive nature of this command, you must send the message to\nQ@CServe.quakenet.org when using it.\n");
chanservaddcommand("requestpassword", QCMD_NOTAUTHED, 2, csa_doreqpw, "Requests the current password by email.", "Usage: REQUESTPASSWORD <username> <email>\nSends your current password to your registered email address, where:\nusername - your username\nemail - your registered email address\n");
+ chanservaddcommand("sendpassword", QCMD_OPER, 1, csa_dosendpw, "Sends the users current password by email.", "Usage: SENDPASSWORD <username>\nSends the password for the specified account to the specified users email address.\n");
chanservaddcommand("setemail", QCMD_OPER, 2, csa_dosetmail, "Set the email address.", "");
chanservaddcommand("setpassword", QCMD_OPER, 2, csa_dosetpw, "Set a new password.", "");
}
chanservremovecommand("login", csa_doauth);
chanservremovecommand("newpass", csa_donewpw);
chanservremovecommand("requestpassword", csa_doreqpw);
+ chanservremovecommand("sendpassword", csa_dosendpw);
chanservremovecommand("setemail", csa_dosetmail);
chanservremovecommand("setpassword", csa_dosetpw);
}
if (!(rup=findreguser(sender, cargv[0])))
return CMD_ERROR;
+ if(UHasHelperPriv(rup)) {
+ chanservstdmessage(sender, QM_REQUESTPASSPRIVUSER);
+ cs_log(sender,"REQUESTPASSWORD FAIL privilidged user %s",rup->username);
+ return CMD_ERROR;
+ }
+
if (strcasecmp(cargv[1],rup->email->content)) {
chanservstdmessage(sender, QM_BADEMAIL, rup->username);
cs_log(sender,"REQUESTPASSWORD FAIL wrong email, username %s email %s",rup->username,cargv[1]);
* CMDLEVEL: QCMD_OPER
* CMDARGS: 1
* CMDDESC: Sends the users current password by email.
- * CMDFUNC: csu_dosendpw
- * CMDPROTO: int csu_dosendpw(void *source, int cargc, char **cargv);
+ * CMDFUNC: csa_dosendpw
+ * CMDPROTO: int csa_dosendpw(void *source, int cargc, char **cargv);
* CMDHELP: Usage: SENDPASSWORD <username>
* CMDHELP: Sends the password for the specified account to the specified users email address.
*/
#include <stdio.h>
#include <string.h>
-int csu_dosendpw(void *source, int cargc, char **cargv) {
+int csa_dosendpw(void *source, int cargc, char **cargv) {
reguser *rup;
nick *sender=source;
if (!(rup=findreguser(sender, cargv[0])))
return CMD_ERROR;
+ if(UHasHelperPriv(rup)) {
+ chanservstdmessage(sender, QM_REQUESTPASSPRIVUSER);
+ cs_log(sender,"REQUESTPASSWORD FAIL privilidged user %s",rup->username);
+ return CMD_ERROR;
+ }
+
/* we don't reset the throttling timer
rup->lastemailchange=time(NULL);
csdb_updateuser(rup);
#define QM_ADDRESSLIMIT 158
#define QM_DOMAINBANNED 159
#define QM_TYPEHELPFORHELP 160
+#define QM_REQUESTPASSPRIVUSER 161
/* List of privileged operations */
if(!m && (p=strchr(domain, '.')))
return findnearestmaildomain(++p);
+
+ return NULL;
}
maildomain *findmaildomainbyemail(char *email) {
maildomain *findorcreatemaildomain(char *email) {
unsigned int hash;
char *domain,*pdomain;
- maildomain *mdp, *pmdp;
+ maildomain *mdp;
if (!(domain=strchr(email, '@')))
domain=email;
/* 157*/ "Sorry, the registration service is unavailable to you at this time. Please try again later.", /* a deliberately vague message */
/* 158*/ "Too many accounts exist from this email address.",
/* 159*/ "That email address has been blocked.",
- /* 160*/ "For more information, type HELP %s."
+ /* 160*/ "For more information, type HELP %s.",
+ /* 161*/ "Cannot send password for that account.",
};
void initmessages() {
Makefile:
../mkcommandlist.pl chanserv_usercmds.so
-chanserv_usercmds.so: accounthistory.o cleanupdb.o deluser.o domainmode.o info.o language.o listflags.o rollbackaccount.o sendpassword.o spewdb.o spewdomain.o spewemail.o spewpass.o suspenduser.o suspenduserlist.o unsuspenduser.o usercomment.o userflags.o whoami.o whois.o commandlist.o
+chanserv_usercmds.so: accounthistory.o cleanupdb.o deluser.o domainmode.o info.o language.o listflags.o rollbackaccount.o spewdb.o spewdomain.o spewemail.o spewpass.o suspenduser.o suspenduserlist.o unsuspenduser.o usercomment.o userflags.o whoami.o whois.o commandlist.o
ld -shared -Bdynamic -o $@ $^
int csu_dolanguage(void *source, int cargc, char **cargv);
int csu_dolistflags(void *source, int cargc, char **cargv);
int csa_dorollbackaccount(void *source, int cargc, char **cargv);
-int csu_dosendpw(void *source, int cargc, char **cargv);
int csu_dospewdb(void *source, int cargc, char **cargv);
int csu_dospewdomain(void *source, int cargc, char **cargv);
int csu_dospewemail(void *source, int cargc, char **cargv);
chanservaddcommand("language", QCMD_AUTHED | QCMD_OPER, 1, csu_dolanguage, "Shows or changes your current language.", "");
chanservaddcommand("listflags", QCMD_OPER, 1, csu_dolistflags, "List users with the specified user flags.", "");
chanservaddcommand("rollbackaccount", QCMD_OPER, 2, csa_dorollbackaccount, "Roll back password/email changes on an account.", "");
- chanservaddcommand("sendpassword", QCMD_OPER, 1, csu_dosendpw, "Sends the users current password by email.", "Usage: SENDPASSWORD <username>\nSends the password for the specified account to the specified users email address.\n");
chanservaddcommand("spewdb", QCMD_OPER, 1, csu_dospewdb, "Search for a user in the database.", "");
chanservaddcommand("spewdomain", QCMD_OPER, 1, csu_dospewdomain, "Spew Mail Domains.", "");
chanservaddcommand("spewemail", QCMD_OPER, 1, csu_dospewemail, "Search for an e-mail in the database.", "");
chanservremovecommand("language", csu_dolanguage);
chanservremovecommand("listflags", csu_dolistflags);
chanservremovecommand("rollbackaccount", csa_dorollbackaccount);
- chanservremovecommand("sendpassword", csu_dosendpw);
chanservremovecommand("spewdb", csu_dospewdb);
chanservremovecommand("spewdomain", csu_dospewdomain);
chanservremovecommand("spewemail", csu_dospewemail);