forked from atheme/atheme-contrib-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathns_generatehash.c
58 lines (46 loc) · 1.44 KB
/
ns_generatehash.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 2010 Atheme development group
* Rights to this code are as documented in doc/LICENSE.
*
* Generates a hash for use as a operserv "password".
*
*/
#include "atheme-compat.h"
DECLARE_MODULE_V1
(
"contrib/ns_generatehash", false, _modinit, _moddeinit,
PACKAGE_STRING,
"Atheme development group"
);
static void ns_cmd_generatehash(sourceinfo_t *si, int parc, char *parv[]);
command_t ns_generatehash = { "GENERATEHASH", "Generates a hash for SOPER.",
AC_NONE, 1, ns_cmd_generatehash, { .path = "contrib/generatehash" } };
void _modinit(module_t *m)
{
service_named_bind_command("nickserv", &ns_generatehash);
}
void _moddeinit(module_unload_intent_t intent)
{
service_named_unbind_command("nickserv", &ns_generatehash);
}
static void ns_cmd_generatehash(sourceinfo_t *si, int parc, char *parv[])
{
char *pass = parv[0];
if (parc < 1)
{
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "GENERATEHASH");
command_fail(si, fault_needmoreparams, _("Syntax: GENERATEHASH <password>"));
return;
}
const char *const hash = crypt_string(pass, NULL);
if (hash)
command_success_string(si, hash, "Hash is: %s", hash);
else
command_fail(si, fault_internalerror, _("Hash generation failure -- is a crypto module loaded?"));
logcommand(si, CMDLOG_GET, "GENERATEHASH");
}
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
* vim:ts=8
* vim:sw=8
* vim:noexpandtab
*/