From 36ba7623cfe2e297c1693c9ba27613da0ae6a526 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Mon, 11 Jun 2007 18:36:05 +0000 Subject: [PATCH] - Removed anything involving portnum global variable. Not proper in newconf world - #0002920 reported by aquanight, regarding command line mkpasswd, patched by BuHHunyx. Syntax: wircd.exe -P|-p authmethod password. If it is -p, it will get shown in a MessageBox, -P it will get copied to clipboard --- Changes | 6 ++++ src/ircd.c | 61 ++++++++++++++++++++++++++++++++++------- src/s_bsd.c | 2 +- u4modules/Velcro.module | 3 +- wircd.def | 1 - 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 4fe811c0c..b402b9152 100644 --- a/Changes +++ b/Changes @@ -1760,3 +1760,9 @@ MOTDs matches the umode for now) - #0002695 reported by w00t regarding unused check_registered and check_registered_user calls in s_misc.c +- Removed anything involving portnum global variable. Not proper in + newconf world +- #0002920 reported by aquanight, regarding command line mkpasswd, + patched by BuHHunyx. Syntax: wircd.exe -P|-p authmethod password. + If it is -p, it will get shown in a MessageBox, -P it will get copied + to clipboard. diff --git a/src/ircd.c b/src/ircd.c index 5308d87b1..7bd85557e 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -186,7 +186,6 @@ MODVAR char **myargv; #else LPCSTR cmdLine; #endif -int portnum = -1; /* Server port number, listening this */ char *configfile = CONFIGFILE; /* Server configuration file */ int debuglevel = 10; /* Server debug level */ int bootopt = 0; /* Server boot option flags */ @@ -807,13 +806,13 @@ static int bad_command(void) { #ifndef _WIN32 (void)printf - ("Usage: ircd [-f config] [-h servername] [-p portnumber] [-x loglevel] [-t] [-H]\n"); + ("Usage: ircd [-f config] [-h servername] [-x loglevel] [-t] [-H]\n"); (void)printf("Server not started\n\n"); #else if (!IsService) { MessageBox(NULL, - "Usage: wircd [-h servername] [-p portnumber] [-x loglevel]\n", + "Usage: wircd [-h servername] [-x loglevel]\n", "UnrealIRCD/32", MB_OK); } #endif @@ -1217,6 +1216,7 @@ int InitwIRCD(int argc, char *argv[]) break; #endif #ifndef _WIN32 + case 'p': case 'P': { short type; @@ -1245,12 +1245,55 @@ int InitwIRCD(int argc, char *argv[]) printf("Encrypted password is: %s\n", result); exit(0); } +#else /* _WIN32 */ + case 'p': + case 'P':{ + short type; + char *result; + srand(TStime()); + if ((type = Auth_FindType(p)) == -1) { + MessageBox(NULL, p, "No such auth type", MB_ICONERROR | MB_OK); + return 0; + } + p = *++argv; + argc--; +#ifdef AUTHENABLE_UNIXCRYPT + if ((type == AUTHTYPE_UNIXCRYPT) && (strlen(p) > 8)) + { + MessageBox(NULL, "Password truncated to 8 characters due to 'crypt' algorithm. " + "You are suggested to use the 'md5' algorithm instead.", "WARNING", MB_ICONWARNING | MB_OK); + p[8] = '\0'; + } +#endif + if (!(result = Auth_Make(type, p))) { + MessageBox(NULL, "Authentication failed\n", "ERROR", MB_ICONERROR | MB_OK); + return 0; + } + + if (flag == 'p') + MessageBox(NULL, result, "Encrypted password", MB_ICONINFORMATION | MB_OK);*/ + else + if (OpenClipboard(NULL)) + { + LPTSTR lptstrCopy; + HGLOBAL hglbCopy; + hglbCopy = GlobalAlloc(GMEM_MOVEABLE, lstrlen(result) + 1); + if(hglbCopy != NULL) + { + lptstrCopy = GlobalLock(hglbCopy); + lstrcpy(lptstrCopy, result); + GlobalUnlock(hglbCopy); + EmptyClipboard(); + SetClipboardData(CF_TEXT, hglbCopy); + MessageBox(NULL, "Encrypted password copied to the clipboard", + "Encrypted password", MB_ICONINFORMATION | MB_OK); + } + CloseClipboard(); + } + exit 0; + } #endif - case 'p': - if ((portarg = atoi(p)) > 0) - portnum = portarg; - break; case 's': (void)printf("sizeof(aClient) == %ld\n", (long)sizeof(aClient)); @@ -1506,9 +1549,6 @@ int InitwIRCD(int argc, char *argv[]) #else /* ifndef NEW_IO */ #endif /* ifndef NEW_IO */ #endif - if (portnum < 0) - portnum = PORTNUM; - me.port = portnum; #ifndef NEW_IO /* Is that have to be in s_bsd.c huh? */ (void)init_sys(); @@ -1530,6 +1570,7 @@ int InitwIRCD(int argc, char *argv[]) * We accept the first listen record */ portnum = conf_listen->port; + me.port = portnum; /* * This is completely unneeded-Sts me.ip.S_ADDR = diff --git a/src/s_bsd.c b/src/s_bsd.c index 89fa6b28a..9e3fbac46 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -2098,7 +2098,7 @@ static struct SOCKADDR *connect_inet(ConfigItem_link * aconf, aClient *cptr, bcopy((char *)&aconf->ipnum, (char *)&server.SIN_ADDR, sizeof(struct IN_ADDR)); bcopy((char *)&aconf->ipnum, (char *)&cptr->ip, sizeof(struct IN_ADDR)); - server.SIN_PORT = htons(((aconf->port > 0) ? aconf->port : portnum)); + server.SIN_PORT = htons(aconf->port); *lenp = sizeof(server); return (struct SOCKADDR *)&server; } diff --git a/u4modules/Velcro.module b/u4modules/Velcro.module index 82159e16f..7865e1d2c 100644 --- a/u4modules/Velcro.module +++ b/u4modules/Velcro.module @@ -136,7 +136,7 @@ DLLFUNC int h_velcro_configrun(ConfigFile *cf, ConfigEntry *ce, int type, int *e if(!strcmp(ce->ce_varname, "loadmodule4")) { config_status("%s:%i: loadmodule4: %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata); - Velcro::instanceOf().dependsOnModule("Velcro", ce->ce_vardata); + Velcro::instanceOf().dependsOnModule(".conf", ce->ce_vardata); return 1; } return 0; @@ -317,3 +317,4 @@ bool Velcro::isModuleLoading(const char *moduleName) } return false; } + diff --git a/wircd.def b/wircd.def index e59075ba7..c5140dff7 100644 --- a/wircd.def +++ b/wircd.def @@ -667,7 +667,6 @@ EXPORTS parse_netmask place_host_ban port_range - portnum pretty_mask pretty_time_val proceed_normal_client_handshake