diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-23 15:32:37 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-23 15:32:37 +0100 |
commit | c8d1c17976b27cba9bd079424cf94642e931e851 (patch) | |
tree | 81611939542296b4386c1669a0e60fd3f70c8856 /FICS/comproc.c | |
parent | e18e57100bd8f8e542b51aeee637b2754afcb59d (diff) |
Reformatted com_password()
Diffstat (limited to 'FICS/comproc.c')
-rw-r--r-- | FICS/comproc.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index c2dba1b..c27b787 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -532,33 +532,41 @@ com_stats(int p, param_list param) return COM_OK; } -PUBLIC int com_password(int p, param_list param) +PUBLIC int +com_password(int p, param_list param) { - char *oldpassword = param[0].val.word; - char *newpassword = param[1].val.word; - char salt[3]; + char *oldpassword = param[0].val.word; + char *newpassword = param[1].val.word; + char salt[3]; - if (!parray[p].registered) { - pprintf(p, "Setting a password is only for registered players.\n"); - return COM_OK; - } - if (parray[p].passwd) { - salt[0] = parray[p].passwd[0]; - salt[1] = parray[p].passwd[1]; - salt[2] = '\0'; - if (strcmp(crypt(oldpassword, salt), parray[p].passwd)) { - pprintf(p, "Incorrect password, password not changed!\n"); - return COM_OK; - } - rfree(parray[p].passwd); - parray[p].passwd = NULL; - } - salt[0] = 'a' + rand() % 26; - salt[1] = 'a' + rand() % 26; - salt[2] = '\0'; - parray[p].passwd = xstrdup(crypt(newpassword, salt)); - pprintf(p, "Password changed to \"%s\".\n", newpassword); - return COM_OK; + if (!parray[p].registered) { + pprintf(p, "Setting a password is only for registered players." + "\n"); + return COM_OK; + } + + if (parray[p].passwd) { + salt[0] = parray[p].passwd[0]; + salt[1] = parray[p].passwd[1]; + salt[2] = '\0'; + + if (strcmp(crypt(oldpassword, salt), parray[p].passwd)) { + pprintf(p, "Incorrect password, password not changed!" + "\n"); + return COM_OK; + } + + rfree(parray[p].passwd); + parray[p].passwd = NULL; + } + + salt[0] = ('a' + rand() % 26); + salt[1] = ('a' + rand() % 26); + salt[2] = '\0'; + parray[p].passwd = xstrdup(crypt(newpassword, salt)); + + pprintf(p, "Password changed to \"%s\".\n", newpassword); + return COM_OK; } PUBLIC int com_uptime(int p, param_list param) |