]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Add privilidge checking to sendpassword/requestpassword.
authorChris Porter <redacted>
Sun, 9 Mar 2008 17:55:36 +0000 (17:55 +0000)
committerChris Porter <redacted>
Sun, 9 Mar 2008 17:55:36 +0000 (17:55 +0000)
Move sendpassword to authcmds.
Fix bug in findnearestmaildomain.

chanserv/authcmds/Makefile
chanserv/authcmds/commandlist.c
chanserv/authcmds/requestpassword.c
chanserv/authcmds/sendpassword.c [moved from chanserv/usercmds/sendpassword.c with 76% similarity]
chanserv/chanserv.h
chanserv/database/chanservdb_hash.c
chanserv/database/chanservdb_messages.c
chanserv/usercmds/Makefile
chanserv/usercmds/commandlist.c

index a26bc2f347a5a38b8c1e1bc73e9ad1fbe5567e37..8a755959077fed4b7d6fd72771683825ded06448 100644 (file)
@@ -6,5 +6,5 @@ all: Makefile chanserv_authcmds.so
 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 $@ $^ 
index f4f9e78c1a96bb14a5831b9205de0fb4993abfc0..79fbf48a3b49a964f39d9b598eff8a3543f6fd2e 100644 (file)
@@ -14,6 +14,7 @@ int csa_dohello(void *source, int cargc, char **cargv);
 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);
 
@@ -29,6 +30,7 @@ void _init() {
   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.", "");
 }
@@ -45,6 +47,7 @@ void _fini() {
   chanservremovecommand("login", csa_doauth);
   chanservremovecommand("newpass", csa_donewpw);
   chanservremovecommand("requestpassword", csa_doreqpw);
+  chanservremovecommand("sendpassword", csa_dosendpw);
   chanservremovecommand("setemail", csa_dosetmail);
   chanservremovecommand("setpassword", csa_dosetpw);
 }
index 11670f2dcc686ffc34ad361c766e4488543a107d..ddb8af59176fb7d1b7d07df3f4f7ff6b7225ea76 100644 (file)
@@ -31,6 +31,12 @@ int csa_doreqpw(void *source, int cargc, char **cargv) {
   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]);
similarity index 76%
rename from chanserv/usercmds/sendpassword.c
rename to chanserv/authcmds/sendpassword.c
index e38b28016c52a390cf05157c7a287381257d5dcb..526c189afc618f1234f9ab745cb41f1534043130 100644 (file)
@@ -5,8 +5,8 @@
  * 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.
  */
@@ -17,7 +17,7 @@
 #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;
 
@@ -29,6 +29,12 @@ int csu_dosendpw(void *source, int cargc, char **cargv) {
   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);
index 4f9885ad8f9c3cc5b4fe3e2d2d58d57948925881..ede6ea2727314ee30f3f01f77898071a65abe1dd 100644 (file)
 #define QM_ADDRESSLIMIT            158
 #define QM_DOMAINBANNED            159
 #define QM_TYPEHELPFORHELP         160
+#define QM_REQUESTPASSPRIVUSER     161
 
 /* List of privileged operations */
 
index bbae18a6fcc0dc235abc90ebc2ab77378275ba88..9f934c7cae6455c33221a4f1379414717e16a4b5 100644 (file)
@@ -213,6 +213,8 @@ maildomain *findnearestmaildomain(char *domain) {
 
   if(!m && (p=strchr(domain, '.')))
     return findnearestmaildomain(++p);
+
+  return NULL;
 }
 
 maildomain *findmaildomainbyemail(char *email) {
@@ -229,7 +231,7 @@ 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;
index ce821ff9c5bc4664d9309a49885d2f897849aab0..e035d5d7b86a14a865be06d7c85a6f7c763420dd 100644 (file)
@@ -168,7 +168,8 @@ char *defaultmessages[MAXMESSAGES] = {
   /* 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() {
index 1d8fbba0ac9438fd99bdfc3e789b806f84c93813..d50bdc81c9d6d0e38619212dccf538fc0378b45e 100644 (file)
@@ -6,5 +6,5 @@ all: Makefile chanserv_usercmds.so
 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 $@ $^ 
index 3e9f348bc62d80ec8603a5b301d1b9cfd7337155..4fe179a2cdb77bec3da64974df9e61eace20ea1f 100644 (file)
@@ -11,7 +11,6 @@ int csu_doinfo(void *source, int cargc, char **cargv);
 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);
@@ -33,7 +32,6 @@ void _init() {
   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.", "");
@@ -56,7 +54,6 @@ void _fini() {
   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);