Remove cruft left behind by removed stats_p_hook.
[seven-1.x.git] / modules / m_makepass.c
blobfa2e7d73479b6e6f30e4f9d87a9849de82bd3c4f
1 /* {{{ irc-seven: Cows like it.
3 * Copyright (C) 2002 W. Campbell and the ircd-ratbox development team.
5 * Based on mkpasswd.c, originally by Nelson Minar (minar@reed.edu).
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to:
20 * Free Software Foundation, Inc.
21 * 51 Franklin St - Fifth Floor
22 * Boston, MA 02110-1301
23 * USA
25 * }}} */
27 /* {{{ Includes. */
28 #include "stdinc.h"
29 #include "client.h"
30 #include "common.h"
31 #include "ircd.h"
32 #include "irc_string.h"
33 #include "numeric.h"
34 #include "patricia.h"
35 #include "s_newconf.h"
36 #include "s_conf.h"
37 #include "s_log.h"
38 #include "s_serv.h"
39 #include "send.h"
40 #include "msg.h"
41 #include "parse.h"
42 #include "modules.h"
43 /* }}} */
45 extern char *crypt();
47 static int m_makepass (struct Client *, struct Client *, int, const char **);
49 static char *make_md5_salt (void);
51 static char salt_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
53 /* {{{ static struct Message makepass_msgtab = { ... } */
54 struct Message makepass_msgtab =
56 "MKPASSWD", 0, 0, 0, MFLG_SLOW,
58 mg_unreg, {m_makepass, 0}, mg_ignore,
59 mg_ignore, mg_ignore, {m_makepass, 0},
62 /* }}} */
64 mapi_clist_av1 makepass_clist[] =
66 &makepass_msgtab,
67 NULL,
70 /* {{{ DECLARE_MODULE_AV1(...) */
71 DECLARE_MODULE_AV1
73 makepass,
74 NULL,
75 NULL,
76 makepass_clist,
77 NULL,
78 NULL,
79 "1.1"
81 /* }}} */
83 /* {{{ m_makepass()
85 * Usage:
86 * MAKEPASS <password>
88 * parv[0] - prefix
89 * parv[1] - password
91 static int
92 m_makepass (struct Client *client_p, struct Client *source_p, int parc, const char **parv)
94 static time_t last_used = 0;
96 if (parc < 2 || EmptyString(parv[1]))
98 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name,
99 source_p->name, "MAKEPASS");
100 return 0;
102 else if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
104 sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
105 return 0;
108 last_used = CurrentTime;
109 sendto_one(source_p, ":%s NOTICE %s :Encryption for [ %s ] is [ %s ]",
110 me.name, source_p->name, parv[1],
111 crypt(parv[1], make_md5_salt()));
113 return 0;
115 /* }}} */
117 /* {{{ make_md5_salt()
119 * Create random salt to be used with MD5-based crypt(3).
121 static char *
122 make_md5_salt(void)
124 static char salt[13];
125 int i = 0;
127 salt[i++] = '$';
128 salt[i++] = '1';
129 salt[i++] = '$';
131 while (i < 11)
132 salt[i++] = salt_chars[random() % 64];
134 salt[i++] = '$';
135 salt[i++] = '\0';
137 return salt;
139 /* }}} */
142 * vim: ts=8 sw=8 noet fdm=marker tw=80