Skip to content
Snippets Groups Projects
Commit 195bf802 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add per-server JavaScript and Failed Login Attempst sub-menus

Add -host=<name> option to set the hostname to use for alternative sbbs.ini
file.
parent 798f1d05
No related branches found
No related tags found
No related merge requests found
Pipeline #5075 passed
......@@ -373,6 +373,14 @@ void display_filename(BOOL force)
SAFECOPY(last, fname);
}
void set_cfg_filename(const char* hostname)
{
if(hostname == NULL)
sbbs_get_ini_fname(cfg.filename, cfg.ctrl_dir);
else
snprintf(cfg.filename, sizeof cfg.filename, "%ssbbs.%s.ini", cfg.ctrl_dir, hostname);
}
int main(int argc, char **argv)
{
char* p;
......@@ -400,12 +408,16 @@ int main(int argc, char **argv)
const char* import = NULL;
const char* grpname = NULL;
const char* hostname = NULL;
int grpnum = 0;
faddr_t faddr = {0};
uint32_t misc = 0;
for(i=1;i<argc;i++) {
if(argv[i][0]=='-'
) {
if(argv[i][0] == '-') {
if(strncmp(argv[i], "-host=", 6) == 0) {
hostname = argv[i] + 6;
continue;
}
if(strncmp(argv[i], "-import=", 8) == 0) {
import = argv[i] + 8;
continue;
......@@ -415,7 +427,7 @@ int main(int argc, char **argv)
continue;
}
if(strncmp(argv[i], "-misc=", 6) == 0) {
misc = strtoul(argv[i] + 7, NULL, 0);
misc = strtoul(argv[i] + 6, NULL, 0);
continue;
}
if(strcmp(argv[i], "-insert") == 0) {
......@@ -505,21 +517,22 @@ int main(int argc, char **argv)
USAGE:
printf("\nusage: scfg [ctrl_dir] [options]"
"\n\noptions:\n\n"
"-w = run initial setup wizard\n"
"-f = force save of configuration files\n"
"-a = update all message base status headers\n"
"-h = don't update message base status headers\n"
"-u# = set file creation permissions mask (in octal)\n"
"-k = keyboard mode only (no mouse support)\n"
"-c = force color mode\n"
"-m = force monochrome mode\n"
"-e# = set escape delay to #msec\n"
"-insert = enable keyboard insert mode by default\n"
"-import=<filename> = import a message area list file\n"
"-faddr=<addr> = specify your FTN address for imported subs\n"
"-misc=<value> = specify option flags for imported subs\n"
"-g# = set group number (or name) to import into\n"
"-iX = set interface mode to X (default=auto) where X is one of:\n"
"-w run initial setup wizard\n"
"-f force save of configuration files\n"
"-a update all message base status headers\n"
"-h don't update message base status headers\n"
"-u# set file creation permissions mask (in octal)\n"
"-k keyboard mode only (no mouse support)\n"
"-c force color mode\n"
"-m force monochrome mode\n"
"-e# set escape delay to #msec\n"
"-insert enable keyboard insert mode by default\n"
"-import=<fname> import a message area list file\n"
"-faddr=<addr> specify your FTN address for imported subs\n"
"-misc=<value> specify option flags for imported subs\n"
"-g# set group number (or name) to import into\n"
"-host=<name> set hostname to use for alternate sbbs.ini file\n"
"-iX set interface mode to X (default=auto) where X is one of:\n"
#ifdef __unix__
" X = X11 mode\n"
" C = Curses mode\n"
......@@ -530,10 +543,10 @@ int main(int argc, char **argv)
#endif
" A = ANSI mode\n"
" D = standard input/output/door mode\n"
"-A = use alternate (ASCII) characters for arrow symbols\n"
"-v# = set video mode to # (default=auto)\n"
"-l# = set screen lines to # (default=auto-detect)\n"
"-y = automatically save changes (don't ask)\n"
"-A use alternate (ASCII) characters for arrow symbols\n"
"-v# set video mode to # (default=auto)\n"
"-l# set screen lines to # (default=auto-detect)\n"
"-y automatically save changes (don't ask)\n"
);
exit(0);
}
......@@ -722,6 +735,7 @@ int main(int argc, char **argv)
uifc.msg(errormsg);
break;
}
set_cfg_filename(hostname);
node_menu();
free_main_cfg(&cfg);
break;
......@@ -741,6 +755,7 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 2:
set_cfg_filename(hostname);
server_cfg();
break;
case 3:
......@@ -2485,8 +2500,7 @@ void bail(int code)
save_chat_cfg(&cfg);
save_xtrn_cfg(&cfg);
sbbs_get_ini_fname(cfg.filename, cfg.ctrl_dir);
if(*cfg.filename) {
fp = iniOpenFile(cfg.filename, /* for_modify? */true);
if(fp == NULL)
uifc.msgf("Error opening %s", cfg.filename);
......@@ -2524,6 +2538,7 @@ void bail(int code)
uifc.msgf("Error writing %s", cfg.filename);
iniCloseFile(fp);
}
}
uifc.pop(NULL);
}
......
......@@ -32,22 +32,20 @@ static char* node_path_help =
void adjust_last_node()
{
char ini_fname[MAX_PATH + 1];
const char* section = "bbs";
const char* key = "LastNode";
sbbs_get_ini_fname(ini_fname, cfg.ctrl_dir);
FILE* fp = iniOpenFile(ini_fname, /* modify */false);
FILE* fp = iniOpenFile(cfg.filename, /* modify */false);
str_list_t ini = iniReadFile(fp);
iniCloseFile(fp);
uint last_node = iniGetUInteger(ini, section, key, cfg.sys_nodes);
char prompt[128];
SAFEPRINTF(prompt, "Update Terminal Server 'LastNode' value to %u", cfg.sys_nodes);
if(last_node < cfg.sys_nodes && uifc.confirm(prompt)) {
fp = iniOpenFile(ini_fname, /* modify */true);
fp = iniOpenFile(cfg.filename, /* modify */true);
if(fp == NULL)
uifc.msgf("Error %d opening %s", errno, ini_fname);
uifc.msgf("Error %d opening %s", errno, cfg.filename);
else {
iniSetUInteger(&ini, section, key, cfg.sys_nodes, NULL);
iniWriteFile(fp, ini);
......
......@@ -392,6 +392,8 @@ static void termsrvr_cfg(void)
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Execute QWK-related Events"
,startup.options & BBS_OPT_NO_EVENTS ? "N/A" : startup.options & BBS_OPT_NO_QWK_EVENTS ? "No" : "Yes");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Lookup Client Hostname", startup.options & BBS_OPT_NO_HOST_LOOKUP ? "No" : "Yes");
strcpy(opt[i++], "JavaScript Settings...");
strcpy(opt[i++], "Failed Login Attempts...");
opt[i][0] = '\0';
uifc.helpbuf=
......@@ -531,6 +533,12 @@ static void termsrvr_cfg(void)
case 27:
startup.options ^= BBS_OPT_NO_HOST_LOOKUP;
break;
case 28:
js_startup_cfg(&startup.js);
break;
case 29:
login_attempt_cfg(&startup.login_attempt);
break;
default:
if(memcmp(&saved_startup, &startup, sizeof(startup)) != 0)
uifc.changes = true;
......@@ -634,14 +642,13 @@ static void websrvr_cfg(void)
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Authentication Methods", startup.default_auth_list);
snprintf(opt[i++], MAX_OPLN, "%-30s%u ms", "Output Buffer Drain Timeout", startup.outbuf_drain_timeout);
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Lookup Client Hostname", startup.options & BBS_OPT_NO_HOST_LOOKUP ? "No" : "Yes");
bool cgi_enabled = !(startup.options & WEB_OPT_NO_CGI);
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI Support", cgi_enabled ? "Yes" : "No");
if(cgi_enabled) {
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI Support", startup.options & WEB_OPT_NO_CGI ? "No" : "Yes");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI Directory", startup.cgi_dir);
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI File Extensions", strListCombine(startup.cgi_ext, tmp, sizeof(tmp), ", "));
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI Default Content-Type", startup.default_cgi_content);
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "CGI Max Inactivity", vduration(startup.max_cgi_inactivity));
}
strcpy(opt[i++], "JavaScript Settings...");
strcpy(opt[i++], "Failed Login Attempts...");
opt[i][0] = '\0';
uifc.helpbuf=
......@@ -792,6 +799,12 @@ static void websrvr_cfg(void)
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Maximum CGI Inactivity", str, 10, K_EDIT) > 0)
startup.max_cgi_inactivity = (uint16_t)parse_duration(str);
break;
case 27:
js_startup_cfg(&startup.js);
break;
case 28:
login_attempt_cfg(&startup.login_attempt);
break;
default:
if(memcmp(&saved_startup, &startup, sizeof(startup)) != 0)
uifc.changes = true;
......@@ -885,6 +898,8 @@ static void ftpsrvr_cfg(void)
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Sysop File System Access", startup.options & FTP_OPT_NO_LOCAL_FSYS ? "No" : "Yes");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Allow Bounce Transfers", startup.options & FTP_OPT_ALLOW_BOUNCE ? "Yes" : "No");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Lookup Client Hostname", startup.options & BBS_OPT_NO_HOST_LOOKUP ? "No" : "Yes");
strcpy(opt[i++], "Failed Login Attempts...");
opt[i][0] = '\0';
uifc.helpbuf=
......@@ -986,6 +1001,9 @@ static void ftpsrvr_cfg(void)
case 14:
startup.options ^= BBS_OPT_NO_HOST_LOOKUP;
break;
case 15:
login_attempt_cfg(&startup.login_attempt);
break;
default:
if(memcmp(&saved_startup, &startup, sizeof(startup)) != 0)
uifc.changes = true;
......@@ -1225,6 +1243,8 @@ static void mailsrvr_cfg(void)
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Hash DNS-Blacklisted Msgs", startup.options & MAIL_OPT_DNSBL_SPAMHASH ? "Yes" : "No");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Kill SPAM When Read", startup.options & MAIL_OPT_KILL_READ_SPAM ? "Yes": "No");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "SendMail Thread...", startup.options & MAIL_OPT_NO_SENDMAIL ? strDisabled : "");
strcpy(opt[i++], "JavaScript Settings...");
strcpy(opt[i++], "Failed Login Attempts...");
opt[i][0] = '\0';
uifc.helpbuf=
......@@ -1400,6 +1420,12 @@ static void mailsrvr_cfg(void)
case 30:
sendmail_cfg(&startup);
break;
case 31:
js_startup_cfg(&startup.js);
break;
case 32:
login_attempt_cfg(&startup.login_attempt);
break;
default:
if(memcmp(&saved_startup, &startup, sizeof(startup)) != 0)
uifc.changes = true;
......@@ -1482,6 +1508,8 @@ static void services_cfg(void)
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Network Interfaces", strListCombine(startup.interfaces, tmp, sizeof(tmp), ", "));
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Lookup Client Hostname", startup.options & BBS_OPT_NO_HOST_LOOKUP ? "No" : "Yes");
snprintf(opt[i++], MAX_OPLN, "%-30s%s", "Configuration File", startup.services_ini);
strcpy(opt[i++], "JavaScript Settings...");
strcpy(opt[i++], "Failed Login Attempts...");
opt[i][0] = '\0';
uifc.helpbuf=
......@@ -1513,6 +1541,12 @@ static void services_cfg(void)
case 4:
uifc.input(WIN_MID|WIN_SAV, 0, 0, "Services Configuration File", startup.services_ini, sizeof(startup.services_ini)-1, K_EDIT);
break;
case 5:
js_startup_cfg(&startup.js);
break;
case 6:
login_attempt_cfg(&startup.login_attempt);
break;
default:
if(memcmp(&saved_startup, &startup, sizeof(startup)) != 0)
uifc.changes = true;
......@@ -1560,8 +1594,6 @@ void server_cfg(void)
static int srvr_dflt;
BOOL run_bbs, run_ftp, run_web, run_mail, run_services;
sbbs_get_ini_fname(cfg.filename, cfg.ctrl_dir);
while(1) {
FILE* fp = iniOpenFile(cfg.filename, /* for_modify? */false);
if(fp == NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment