diff --git a/src/ircd.c b/src/ircd.c index 6622ba027..11acfd83e 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -626,43 +626,6 @@ int InitUnrealIRCd(int argc, char *argv[]) safe_strdup(configfile, p); convert_to_absolute_path(&configfile, CONFDIR); break; -#ifndef _WIN32 - case 'P':{ - short type; - const char *result; - srandom(TStime()); - type = Auth_FindType(NULL, p); - if (type == -1) - { - type = AUTHTYPE_ARGON2; - } else { - p = *++argv; - argc--; - } - if (BadPtr(p)) - { -#ifndef _WIN32 - p = getpass("Enter password to hash: "); -#else - printf("ERROR: You should specify a password to hash"); - exit(1); -#endif - } - if ((type == AUTHTYPE_UNIXCRYPT) && (strlen(p) > 8)) - { - /* Hmmm.. is this warning really still true (and always) ?? */ - printf("WARNING: Password truncated to 8 characters due to 'crypt' algorithm. " - "You are suggested to use the 'argon2' algorithm instead."); - p[8] = '\0'; - } - if (!(result = Auth_Hash(type, p))) { - printf("Failed to generate password. Deprecated method? Try 'argon2' instead.\n"); - exit(0); - } - printf("Encrypted password is: %s\n", result); - exit(0); - } -#endif #if 0 case 'S': charsys_dump_table(p ? p : "*"); diff --git a/src/unrealircdctl.c b/src/unrealircdctl.c index 7a1109d2b..f2b029a00 100644 --- a/src/unrealircdctl.c +++ b/src/unrealircdctl.c @@ -71,6 +71,44 @@ void unrealircdctl_status(void) exit(1); } +void unrealircdctl_mkpasswd(int argc, char *argv[]) +{ + AuthenticationType type; + const char *result; + char *p = argv[2]; + + srandom(TStime()); + type = Auth_FindType(NULL, p); + if (type == -1) + { + type = AUTHTYPE_ARGON2; + } else { + p = argv[3]; + } + if (BadPtr(p)) + { +#ifndef _WIN32 + p = getpass("Enter password to hash: "); +#else + printf("ERROR: You should specify a password to hash"); + exit(1); +#endif + } + if ((type == AUTHTYPE_UNIXCRYPT) && (strlen(p) > 8)) + { + /* Hmmm.. is this warning really still true (and always) ?? */ + printf("WARNING: Password truncated to 8 characters due to 'crypt' algorithm. " + "You are suggested to use the 'argon2' algorithm instead."); + p[8] = '\0'; + } + if (!(result = Auth_Hash(type, p))) { + printf("Failed to generate password. Deprecated method? Try 'argon2' instead.\n"); + exit(0); + } + printf("Encrypted password is: %s\n", result); + exit(0); +} + int main(int argc, char *argv[]) { dbuf_init(); @@ -87,7 +125,9 @@ int main(int argc, char *argv[]) unrealircdctl_reloadtls(); else if (!strcmp(argv[1], "status")) unrealircdctl_status(); + else if (!strcmp(argv[1], "mkpasswd")) + unrealircdctl_mkpasswd(argc, argv); else - printf("Hai frienz: %d\n", argc); + unrealircdctl_usage(argv[0]); exit(0); } diff --git a/unrealircd.in b/unrealircd.in index 4158a3363..6e562621e 100644 --- a/unrealircd.in +++ b/unrealircd.in @@ -114,7 +114,7 @@ elif [ "$1" = "module" ] ; then shift @BINDIR@/unrealircd -m $* elif [ "$1" = "mkpasswd" ] ; then - @BINDIR@/unrealircd -P $2 $3 + $UNREALIRCDCTL mkpasswd $2 $3 elif [ "$1" = "version" ] ; then @BINDIR@/unrealircd -v elif [ "$1" = "gencloak" ] ; then