]> jfr.im git - solanum.git/blobdiff - extensions/m_mkpasswd.c
s_user: clean up return types and can YES/NO.
[solanum.git] / extensions / m_mkpasswd.c
index 4207cea1569858487ed95927daf7d6e514f86846..7b9352cec260aab0cfc77e0790d26586290e1d10 100644 (file)
 #include "s_conf.h"
 #include "modules.h"
 #include "messages.h"
+#include "send.h"
 
 #include <string.h>
 
-static int m_mkpasswd(struct Client *client_p, struct Client *source_p,
+static int m_mkpasswd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
                      int parc, const char *parv[]);
-static int mo_mkpasswd(struct Client *client_p, struct Client *source_p,
+static int mo_mkpasswd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
                       int parc, const char *parv[]);
 
 static char *make_md5_salt(int);
@@ -29,21 +30,23 @@ static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno
        /* 0 .. 63, ascii - 64 */
 
 struct Message mkpasswd_msgtab = {
-       "MKPASSWD", 0, 0, 0, MFLG_SLOW,
+       "MKPASSWD", 0, 0, 0, 0,
        {mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
 };
 
 mapi_clist_av1 mkpasswd_clist[] = { &mkpasswd_msgtab, NULL };
 
-DECLARE_MODULE_AV1(mkpasswd, NULL, NULL, mkpasswd_clist, NULL, NULL, "$Revision$");
+const char mkpasswd_desc[] = "Hash a password for use in ircd.conf";
 
+DECLARE_MODULE_AV2(mkpasswd, NULL, NULL, mkpasswd_clist, NULL, NULL, NULL, NULL, mkpasswd_desc);
 
-/* m_mkpasswd - mkpasswd messages.handler
+
+/* m_mkpasswd - mkpasswd message handler
  *     parv[1] = password
  *     parv[2] = type
  */
 static int
-m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_mkpasswd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        static time_t last_used = 0;
        char *salt;
@@ -89,12 +92,12 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha
        return 0;
 }
 
-/* mo_mkpasswd - mkpasswd messages.handler
+/* mo_mkpasswd - mkpasswd message handler
  *     parv[1] = password
  *     parv[2] = type
  */
 static int
-mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mo_mkpasswd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        char *salt;
        const char *crypted;
@@ -209,6 +212,7 @@ generate_random_salt(char *salt, int length)
        if(read(fd, buf, length) != length)
        {
                free(buf);
+               close(fd);
                return (generate_poor_salt(salt, length));
        }
 
@@ -217,5 +221,6 @@ generate_random_salt(char *salt, int length)
                salt[i] = saltChars[abs(buf[i]) % 64];
        }
        free(buf);
+       close(fd);
        return (salt);
 }