mirror of
https://github.com/matrix-construct/construct
synced 2024-09-08 17:55:47 +02:00
-- nenolod 2006/09/27 16:39:14 UTC (20060927-2178) Log: - remove "Processing connection to foobar.net" message Changes: Modified: +0 -3 trunk/src/s_auth.c (File Modified) nenolod 2006/09/27 16:34:26 UTC (20060927-2176) Log: - missed the processing connection one (actually, we can probably nuke this one) Changes: Modified: +1 -2 trunk/src/s_auth.c (File Modified) river 2006/09/27 16:33:05 UTC (20060927-2174) Log: get_client_name = stupid Changes: Modified: +10 -7 trunk/modules/core/m_kill.c (File Modified) nenolod 2006/09/27 16:32:37 UTC (20060927-2172) Log: - remove excessive arguments Changes: Modified: +1 -2 trunk/src/s_conf.c (File Modified) +1 -1 trunk/src/s_user.c (File Modified) nenolod 2006/09/27 16:30:59 UTC (20060927-2170) Log: - use sendto_one_notice() for on-connect notices too. Changes: Modified: +10 -10 trunk/src/s_auth.c (File Modified) nenolod 2006/09/27 16:27:01 UTC (20060927-2168) Log: - use sendto_one_notice() in the core, too. Changes: Modified: +2 -2 trunk/src/chmode.c (File Modified) +8 -15 trunk/src/modules.c (File Modified) +3 -5 trunk/src/s_conf.c (File Modified) +1 -2 trunk/src/s_newconf.c (File Modified) +20 -57 trunk/src/s_user.c (File Modified) river 2006/09/27 16:19:25 UTC (20060927-2166) Log: the KILL command will use get_client_name(, SHOW_IP) instead of target->name, and will show a more useful error for local opers Changes: Modified: +6 -4 trunk/modules/core/m_kill.c (File Modified) nenolod 2006/09/27 16:09:48 UTC (20060927-2164) Log: - fix bugs in sendto_one_notice()/sendto_one_numeric() where a client identifier won't be sent to unregistered clients Changes: Modified: +4 -2 trunk/src/send.c (File Modified) nenolod 2006/09/27 16:05:46 UTC (20060927-2161) Log: - back out r2159 Changes: Modified: +1 -1 trunk/include/client.h (File Modified) nenolod 2006/09/27 16:04:05 UTC (20060927-2159) Log: - get_id(): fall back to "*" if client has no known name Changes: Modified: +1 -1 trunk/include/client.h (File Modified) nenolod 2006/09/27 16:01:29 UTC (20060927-2157) Log: - convert to sendto_one_notice(). Changes: Modified: +2 -3 trunk/unsupported/m_clearchan.c (File Modified) +4 -6 trunk/unsupported/m_force.c (File Modified) nenolod 2006/09/27 15:57:11 UTC (20060927-2155) Log: - use sendto_one_notice() in many places instead of sendto_one(source_p, ":%s NOTICE %s :", ...); Changes: Modified: +10 -25 trunk/extensions/example_module.c (File Modified) +5 -14 trunk/extensions/hurt.c (File Modified) +1 -2 trunk/extensions/m_42.c (File Modified) +7 -12 trunk/extensions/m_mkpasswd.c (File Modified) +1 -2 trunk/extensions/m_ojoin.c (File Modified) +1 -2 trunk/extensions/m_opme.c (File Modified) +3 -3 trunk/extensions/spy_whois_notice.c (File Modified) +3 -3 trunk/extensions/spy_whois_notice_global.c (File Modified) +3 -7 trunk/modules/core/m_die.c (File Modified) +2 -4 trunk/modules/core/m_kill.c (File Modified) +2 -2 trunk/modules/core/m_squit.c (File Modified) +1 -2 trunk/modules/m_challenge.c (File Modified) +11 -15 trunk/modules/m_connect.c (File Modified) +20 -28 trunk/modules/m_dline.c (File Modified) +2 -2 trunk/modules/m_etrace.c (File Modified) +11 -21 trunk/modules/m_gline.c (File Modified) +2 -4 trunk/modules/m_kline.c (File Modified) +1 -2 trunk/modules/m_rehash.c (File Modified) +3 -7 trunk/modules/m_restart.c (File Modified) +31 -45 trunk/modules/m_set.c (File Modified) +2 -4 trunk/modules/m_testmask.c (File Modified) +5 -8 trunk/modules/m_unreject.c (File Modified) +2 -5 trunk/modules/m_xline.c (File Modified) --
164 lines
3.6 KiB
C
164 lines
3.6 KiB
C
/*
|
|
* m_mkpasswd.c: Encrypts a password online, DES or MD5.
|
|
*
|
|
* Copyright 2002 W. Campbell and the ircd-ratbox development team
|
|
* Based on mkpasswd.c, originally by Nelson Minar (minar@reed.edu)
|
|
*
|
|
* You can use this code in any way as long as these names remain.
|
|
*
|
|
* $Id: m_mkpasswd.c 3161 2007-01-25 07:23:01Z nenolod $
|
|
*/
|
|
|
|
/* List of ircd includes from ../include/ */
|
|
#include "stdinc.h"
|
|
#include "client.h"
|
|
#include "common.h" /* FALSE bleah */
|
|
#include "ircd.h"
|
|
#include "irc_string.h"
|
|
#include "numeric.h"
|
|
#include "patricia.h"
|
|
#include "s_newconf.h"
|
|
#include "s_conf.h"
|
|
#include "s_log.h"
|
|
#include "s_serv.h"
|
|
#include "send.h"
|
|
#include "msg.h"
|
|
#include "parse.h"
|
|
#include "modules.h"
|
|
|
|
#include <string.h>
|
|
|
|
extern char *crypt();
|
|
|
|
static int m_mkpasswd(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,
|
|
int parc, const char *parv[]);
|
|
static char *make_salt(void);
|
|
static char *make_md5_salt(void);
|
|
|
|
static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
|
|
|
|
|
|
struct Message mkpasswd_msgtab = {
|
|
"MKPASSWD", 0, 0, 0, MFLG_SLOW,
|
|
{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: 3161 $");
|
|
|
|
|
|
static int
|
|
m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
{
|
|
static time_t last_used = 0;
|
|
int is_md5 = 0;
|
|
|
|
if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
|
|
{
|
|
/* safe enough to give this on a local connect only */
|
|
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0]);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
last_used = CurrentTime;
|
|
}
|
|
|
|
if(parc == 3)
|
|
{
|
|
if(!irccmp(parv[2], "MD5"))
|
|
{
|
|
is_md5 = 1;
|
|
}
|
|
else if(!irccmp(parv[2], "DES"))
|
|
{
|
|
/* Not really needed, but we may want to have a default encryption
|
|
* setting somewhere down the road
|
|
*/
|
|
is_md5 = 0;
|
|
}
|
|
else
|
|
{
|
|
sendto_one_notice(source_p, ":MKPASSWD syntax error: MKPASSWD pass [DES|MD5]");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if(parc == 1)
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "MKPASSWD");
|
|
else
|
|
sendto_one_notice(source_p, ":Encryption for [%s]: %s",
|
|
parv[1], crypt(parv[1],
|
|
is_md5 ? make_md5_salt() :
|
|
make_salt()));
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
** mo_test
|
|
** parv[0] = sender prefix
|
|
** parv[1] = parameter
|
|
*/
|
|
static int
|
|
mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
{
|
|
int is_md5 = 0;
|
|
|
|
if(parc == 3)
|
|
{
|
|
if(!irccmp(parv[2], "MD5"))
|
|
{
|
|
is_md5 = 1;
|
|
}
|
|
else if(!irccmp(parv[2], "DES"))
|
|
{
|
|
/* Not really needed, but we may want to have a default encryption
|
|
* setting somewhere down the road
|
|
*/
|
|
is_md5 = 0;
|
|
}
|
|
else
|
|
{
|
|
sendto_one_notice(source_p,
|
|
":MKPASSWD syntax error: MKPASSWD pass [DES|MD5]");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if(parc == 1)
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "MKPASSWD");
|
|
else
|
|
sendto_one_notice(source_p, ":Encryption for [%s]: %s",
|
|
parv[1], crypt(parv[1], is_md5 ? make_md5_salt() : make_salt()));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static char *
|
|
make_salt(void)
|
|
{
|
|
static char salt[3];
|
|
salt[0] = saltChars[random() % 64];
|
|
salt[1] = saltChars[random() % 64];
|
|
salt[2] = '\0';
|
|
return salt;
|
|
}
|
|
|
|
static char *
|
|
make_md5_salt(void)
|
|
{
|
|
static char salt[13];
|
|
int i;
|
|
salt[0] = '$';
|
|
salt[1] = '1';
|
|
salt[2] = '$';
|
|
for(i = 3; i < 11; i++)
|
|
salt[i] = saltChars[random() % 64];
|
|
salt[11] = '$';
|
|
salt[12] = '\0';
|
|
return salt;
|
|
}
|