Commit 54431b31 authored by Rob Swindell's avatar Rob Swindell 💬

Fix issue with jsexec being used for CGI scripts

If jsexec is used for a CGI script and the SBBSCTRL env var was not
set, a warning would be printed (to stderr), even if the -c option
was used to specify the path to the ctrl dir.

get_ctrl_dir() now accepts a boolean argument to specify whether to
print a warning when the default value ("/sbbs/ctrl") is used.
Pass FALSE for jsexec, TRUE for other callers (currently).
parent 0cd3081e
......@@ -729,7 +729,7 @@ int main(int argc, char **argv)
return(1);
}
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */true);
memset(&scfg,0,sizeof(scfg));
scfg.size=sizeof(scfg);
......
......@@ -117,7 +117,7 @@ int main(int argc, char **argv)
return(0);
}
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */TRUE);
memset(&cfg, 0, sizeof(cfg));
cfg.size=sizeof(cfg);
......
......@@ -59,7 +59,7 @@ main(int argc, char **argv)
if (argc > 1) {
SAFECOPY(path, argv[1]);
} else {
SAFECOPY(path, get_ctrl_dir());
SAFECOPY(path, get_ctrl_dir(/* warn: */TRUE));
}
backslash(path);
......
......@@ -77,7 +77,7 @@ int main(int argc,char **argv)
fprintf(stderr,"\nDUPEFIND Version %s (%s) - Synchronet Duplicate File "
"Finder\n", DUPEFIND_VER, PLATFORM_DESC);
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */TRUE);
if(argc>1 && (!stricmp(argv[1],"/?") || !stricmp(argv[1],"?") || !stricmp(argv[1],"-?"))) {
fprintf(stderr,"\n");
......
......@@ -708,7 +708,7 @@ int main(int argc, char **argv)
SAFECOPY(str,argv[i]);
}
if(str[0]==0) {
SAFECOPY(cfg.cfgfile, get_ctrl_dir());
SAFECOPY(cfg.cfgfile, get_ctrl_dir(/* warn: */true));
backslash(cfg.cfgfile);
SAFECAT(cfg.cfgfile, "sbbsecho.ini");
} else {
......
......@@ -156,7 +156,7 @@ int main(int argc, char **argv)
memset(&scfg,0,sizeof(scfg));
scfg.size=sizeof(scfg);
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir());
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
if(chdir(scfg.ctrl_dir)!=0)
fprintf(stderr,"!ERROR changing directory to: %s", scfg.ctrl_dir);
......
......@@ -1196,7 +1196,7 @@ int main(int argc, char **argv, char** env)
return(do_bail(2));
#ifndef JSDOOR
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir());
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir(/* warn: */FALSE));
iniFileName(ini_fname, sizeof(ini_fname), scfg.ctrl_dir, "jsexec.ini");
if((fp = iniOpenFile(ini_fname, /* create: */FALSE)) != NULL) {
ini = iniReadFile(fp);
......
......@@ -105,7 +105,7 @@ int main(int argc, char **argv)
if(strcspn(argv[first_arg],"/\\")!=strlen(argv[first_arg]))
p=argv[first_arg++];
else
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */TRUE);
memset(&scfg,0,sizeof(scfg));
scfg.size=sizeof(scfg);
......
......@@ -1196,7 +1196,7 @@ int main(int argc, char** argv)
loginAttemptListInit(&login_attempt_list);
ctrl_dir = get_ctrl_dir();
ctrl_dir = get_ctrl_dir(/* warn: */true);
sbbs_get_ini_fname(ini_file, ctrl_dir, NULL /* auto-host_name */);
......
......@@ -252,7 +252,7 @@ int main(int argc, char **argv)
}
cfg.size=sizeof(cfg);
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir());
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
if(!load_cfg(&cfg, NULL, TRUE, str)) {
printf("\7\n%s\n",str);
......
......@@ -1225,7 +1225,7 @@ extern "C" {
DLLEXPORT BOOL str_is_ascii(const char*);
DLLEXPORT char * utf8_to_cp437_str(char* str);
DLLEXPORT char * subnewsgroupname(scfg_t*, sub_t*, char*, size_t);
DLLEXPORT char * get_ctrl_dir(void);
DLLEXPORT char * get_ctrl_dir(BOOL warn);
/* msg_id.c */
DLLEXPORT char * DLLCALL ftn_msgid(sub_t*, smbmsg_t*, char* msgid, size_t);
......
......@@ -1413,7 +1413,7 @@ int main(int argc, char** argv)
loginAttemptListInit(&login_attempt_list);
atexit(cleanup);
ctrl_dir = get_ctrl_dir();
ctrl_dir = get_ctrl_dir(/* warn: */true);
if(!winsock_startup())
return(-1);
......
......@@ -6215,7 +6215,7 @@ int main(int argc, char **argv)
if(!opt_import_echomail && !opt_import_netmail)
opt_import_packets = false;
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir());
SAFECOPY(scfg.ctrl_dir, get_ctrl_dir(/* warn: */true));
backslash(scfg.ctrl_dir);
......
......@@ -176,7 +176,7 @@ int main(int argc, char **argv)
cfg.size=sizeof(cfg);
memset(&uifc,0,sizeof(uifc));
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir());
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
uifc.esc_delay=25;
......
......@@ -84,7 +84,7 @@ int main(int argc, char **argv)
"or less\n");
return(0); }
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */TRUE);
memset(&cfg,0,sizeof(cfg));
cfg.size=sizeof(cfg);
......
......@@ -720,11 +720,12 @@ char* subnewsgroupname(scfg_t* cfg, sub_t* sub, char* str, size_t size)
return str;
}
char* get_ctrl_dir(void)
char* get_ctrl_dir(BOOL warn)
{
char* p = getenv("SBBSCTRL");
if(p == NULL || *p == '\0') {
fprintf(stderr, "!SBBSCTRL environment variable not set, using default value: " SBBSCTRL_DEFAULT "\n\n");
if(warn)
fprintf(stderr, "!SBBSCTRL environment variable not set, using default value: " SBBSCTRL_DEFAULT "\n\n");
p = SBBSCTRL_DEFAULT;
}
return p;
......
......@@ -167,7 +167,7 @@ int main(int argc, char **argv)
FILE *text_js;
FILE *text_defaults_c;
p = get_ctrl_dir();
p = get_ctrl_dir(/* warn: */TRUE);
SAFEPRINTF(path,"%s/text.dat",p);
if((text_dat=fopen(path,"r"))==NULL) {
perror(path);
......
......@@ -1917,7 +1917,7 @@ int main(int argc, char** argv) {
printf("\nSynchronet User Editor %s-%s Copyright %s "
"Rob Swindell\n",revision,PLATFORM_DESC,&__DATE__[7]);
SAFECOPY(ctrl_dir, get_ctrl_dir());
SAFECOPY(ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
gethostname(str,sizeof(str)-1);
......
......@@ -834,7 +834,7 @@ int main(int argc, char** argv) {
printf("\nSynchronet UNIX Monitor %s-%s Copyright %s "
"Rob Swindell\n",revision,PLATFORM_DESC,&__DATE__[7]);
SAFECOPY(ctrl_dir, get_ctrl_dir());
SAFECOPY(ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
backslash(ctrl_dir);
gethostname(str,sizeof(str)-1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment