Debian Codegraph @

modules/nickserv/set_password.c

raw
1 /*
2 * Copyright (c) 2005 William Pitcock <nenolod -at- nenolod.net>
3 * Copyright (c) 2007 Jilles Tjoelker
4 * Rights to this code are as documented in doc/LICENSE.
5 *
6 * Changes the password associated with your account.
7 *
8 */
9
10 #include "atheme.h"
11 #include "uplink.h"
12
13 DECLARE_MODULE_V1
14 (
15 "nickserv/set_password", false, _modinit, _moddeinit,
16 PACKAGE_STRING,
17 VENDOR_STRING
18 );
19
20 mowgli_patricia_t **ns_set_cmdtree;
21
22 static void ns_cmd_set_password(sourceinfo_t *si, int parc, char *parv[]);
23
24 command_t ns_set_password = { "PASSWORD", N_("Changes the password associated with your account."), AC_NONE, 1, ns_cmd_set_password, { .path = "nickserv/set_password" } };
25
26 void _modinit(module_t *m)
27 {
28 MODULE_TRY_REQUEST_SYMBOL(m, ns_set_cmdtree, "nickserv/set_core", "ns_set_cmdtree");
29
30 command_add(&ns_set_password, *ns_set_cmdtree);
31 }
32
33 void _moddeinit(module_unload_intent_t intent)
34 {
35 command_delete(&ns_set_password, *ns_set_cmdtree);
36 }
37
38 /* SET PASSWORD <password> */
39 static void ns_cmd_set_password(sourceinfo_t *si, int parc, char *parv[])
40 {
41 char *password = parv[0];
42
43 if (auth_module_loaded)
44 {
45 command_fail(si, fault_noprivs, _("You must change the password in the external system."));
46 return;
47 }
48
49 if (!password)
50 {
51 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "PASSWORD");
52 return;
53 }
54
55 if (strlen(password) >= PASSLEN)
56 {
57 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "PASSWORD");
58 command_fail(si, fault_badparams, _("Registration passwords may not be longer than \2%d\2 characters."), PASSLEN - 1);
59 return;
60 }
61
62 if (!strcasecmp(password, entity(si->smu)->name))
63 {
64 command_fail(si, fault_badparams, _("You cannot use your nickname as a password."));
65 command_fail(si, fault_badparams, _("Syntax: SET PASSWORD <new password>"));
66 return;
67 }
68
69 logcommand(si, CMDLOG_SET, "SET:PASSWORD");
70
71 set_password(si->smu, password);
72
73 command_success_nodata(si, _("The password for \2%s\2 has been changed to \2%s\2."), entity(si->smu)->name, password);
74
75 return;
76 }
77
78 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
79 * vim:ts=8
80 * vim:sw=8
81 * vim:noexpandtab
82 */