/[svn]/ircd-hybrid/contrib/m_mkpasswd.c
ViewVC logotype

Diff of /ircd-hybrid/contrib/m_mkpasswd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 577 by adx, Sat Feb 11 23:37:10 2006 UTC revision 578 by michael, Mon May 1 12:39:44 2006 UTC
# Line 19  Line 19 
19  #include "modules.h"  #include "modules.h"
20    
21  static void m_mkpasswd(struct Client *, struct Client *, int, char *[]);  static void m_mkpasswd(struct Client *, struct Client *, int, char *[]);
22  static void mo_mkpasswd(struct Client *, struct Client *, int, char *[]);  static const char *m_mkpasswd_des(void);
23  static char *des(void);  static const char *m_mkpasswd_md5(void);
 static char *md5(void);  
24    
25  static const char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";  static const char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
26    
27  struct Message mkpasswd_msgtab = {  struct Message mkpasswd_msgtab = {
28    "MKPASSWD", 0, 0, 1, 2, MFLG_SLOW, 0,    "MKPASSWD", 0, 0, 1, 2, MFLG_SLOW, 0,
29    { m_unregistered, m_mkpasswd, m_ignore, m_ignore, mo_mkpasswd, m_ignore }    { m_unregistered, m_mkpasswd, m_ignore, m_ignore, m_mkpasswd, m_ignore }
30  };  };
31    
32  INIT_MODULE(m_mkpasswd, "$Revision$")  INIT_MODULE(m_mkpasswd, "$Revision$")
# Line 53  m_mkpasswd(struct Client *client_p, stru Line 52  m_mkpasswd(struct Client *client_p, stru
52      return;      return;
53    }    }
54    
55    if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)    if (!IsOper(source_p))
56    {    {
57      sendto_one(source_p, form_str(RPL_LOAD2HI),      if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
58                 me.name, source_p->name);      {
59      return;        sendto_one(source_p, form_str(RPL_LOAD2HI),
60    }                   me.name, source_p->name);
61          return;
62    last_used = CurrentTime;      }
   
   if (parv[2] == NULL || !irccmp(parv[2], "DES"))  
     sendto_one(source_p, ":%s NOTICE %s :DES Encryption for [%s]: %s",  
                me.name, source_p->name, parv[1], crypt(parv[1],  
                des()));  
   else if (!irccmp(parv[2], "MD5"))  
     sendto_one(source_p, ":%s NOTICE %s :MD5 Encryption for [%s]: %s",  
                me.name, source_p->name, parv[1], crypt(parv[1],  
                md5()));  
   else  
     sendto_one(source_p, ":%s NOTICE %s :Syntax: MKPASSWD pass [DES|MD5]",  
                me.name, source_p->name);  
 }  
63    
64  /*      last_used = CurrentTime;
 ** mo_mkpasswd  
 **      parv[0] = sender prefix  
 **      parv[1] = parameter  
 */  
 static void  
 mo_mkpasswd(struct Client *client_p, struct Client *source_p,  
             int parc, char *parv[])  
 {  
   if (EmptyString(parv[1]))  
   {  
     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),  
                me.name, source_p->name, "MKPASSWD");  
     return;  
65    }    }
66    
67    if (parv[2] == NULL || !irccmp(parv[2], "DES"))    if (parv[2] == NULL || !irccmp(parv[2], "DES"))
68      sendto_one(source_p, ":%s NOTICE %s :DES Encryption for [%s]: %s",      sendto_one(source_p, ":%s NOTICE %s :DES Encryption for [%s]: %s",
69                 me.name, source_p->name, parv[1], crypt(parv[1],                 me.name, source_p->name, parv[1], crypt(parv[1],
70                 des()));                 m_mkpasswd_des()));
71    else if (!irccmp(parv[2], "MD5"))    else if (!irccmp(parv[2], "MD5"))
72      sendto_one(source_p, ":%s NOTICE %s :MD5 Encryption for [%s]: %s",      sendto_one(source_p, ":%s NOTICE %s :MD5 Encryption for [%s]: %s",
73                 me.name, source_p->name, parv[1], crypt(parv[1],                 me.name, source_p->name, parv[1], crypt(parv[1],
74                 md5()));                 m_mkpasswd_md5()));
75    else    else
76      sendto_one(source_p, ":%s NOTICE %s :Syntax: MKPASSWD pass [DES|MD5]",      sendto_one(source_p, ":%s NOTICE %s :Syntax: MKPASSWD pass [DES|MD5]",
77                 me.name, source_p->name);                 me.name, source_p->name);
78  }  }
79    
80  static char *  static const char *
81  des(void)  m_mkpasswd_des(void)
82  {  {
83    static char salt[3];    static char salt[3];
84    
# Line 116  des(void) Line 89  des(void)
89    return salt;    return salt;
90  }  }
91    
92  static char *  static const char *
93  md5(void)  m_mkpasswd_md5(void)
94  {  {
95    static char salt[13];    static char salt[13];
96    int i;    int i;
# Line 126  md5(void) Line 99  md5(void)
99    salt[1] = '1';    salt[1] = '1';
100    salt[2] = '$';    salt[2] = '$';
101    
102    for (i = 3; i < 11; i++)    for (i = 3; i < 11; ++i)
103      salt[i] = saltChars[rand() % 64];      salt[i] = saltChars[rand() % 64];
104    
105    salt[11] = '$';    salt[11] = '$';

Legend:
Removed from v.577  
changed lines
  Added in v.578

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28