| 1 |
/* |
| 2 |
* Copyright (c) 2005 Greg Feigenson |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* Generates a new password, either n digits long (w/ nickserv arg), or 7 digits |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "atheme-compat.h" |
| 9 |
|
| 10 |
static void |
| 11 |
ns_cmd_generatepass(sourceinfo_t *si, int parc, char *parv[]) |
| 12 |
{ |
| 13 |
int n = 0; |
| 14 |
char *newpass; |
| 15 |
|
| 16 |
if (parc >= 1) |
| 17 |
n = atoi(parv[0]); |
| 18 |
|
| 19 |
if (n <= 0 || n > 127) |
| 20 |
n = 7; |
| 21 |
|
| 22 |
newpass = random_string(n); |
| 23 |
|
| 24 |
command_success_string(si, newpass, "Randomly generated password: %s", newpass); |
| 25 |
sfree(newpass); |
| 26 |
logcommand(si, CMDLOG_GET, "GENERATEPASS"); |
| 27 |
} |
| 28 |
|
| 29 |
static command_t ns_generatepass = { |
| 30 |
.name = "GENERATEPASS", |
| 31 |
.desc = N_("Generates a random password."), |
| 32 |
.access = AC_NONE, |
| 33 |
.maxparc = 1, |
| 34 |
.cmd = &ns_cmd_generatepass, |
| 35 |
.help = { .path = "contrib/generatepass" }, |
| 36 |
}; |
| 37 |
|
| 38 |
static void |
| 39 |
mod_init(module_t *const restrict m) |
| 40 |
{ |
| 41 |
service_named_bind_command("nickserv", &ns_generatepass); |
| 42 |
} |
| 43 |
|
| 44 |
static void |
| 45 |
mod_deinit(const module_unload_intent_t intent) |
| 46 |
{ |
| 47 |
service_named_unbind_command("nickserv", &ns_generatepass); |
| 48 |
} |
| 49 |
|
| 50 |
VENDOR_DECLARE_MODULE_V1("contrib/ns_generatepass", MODULE_UNLOAD_CAPABILITY_OK, CONTRIB_VENDOR_EPIPHANIC) |