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
32 #include "irc_string.h"
35 #include "s_newconf.h"
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},
64 mapi_clist_av1 makepass_clist
[] =
70 /* {{{ DECLARE_MODULE_AV1(...) */
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");
102 else if ((last_used
+ ConfigFileEntry
.pace_wait
) > CurrentTime
)
104 sendto_one(source_p
, form_str(RPL_LOAD2HI
), me
.name
, parv
[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()));
117 /* {{{ make_md5_salt()
119 * Create random salt to be used with MD5-based crypt(3).
124 static char salt
[13];
132 salt
[i
++] = salt_chars
[random() % 64];
142 * vim: ts=8 sw=8 noet fdm=marker tw=80