...
 
Commits (3)
  • Rob Swindell's avatar
    Only over-ride (lower the severity) of the cryptlib log msg for a single case · 20393557
    Rob Swindell authored
    Add another "get cryptlib error string" (at least, that's what I assume GCES
    stands for) that allows the log level to be specified, rather than derived
    from Cryptlib thinks the log level should be. Do this rather than adding one
    (lowering the severity) of every cryptlib log message as I did in the previous
    commit to this file.
    20393557
  • Rob Swindell's avatar
    Previous commit fixed issue with JS_GC before JS_ENDREQUEST · 25625186
    Rob Swindell authored
    So revert the order back to the way it was in aa2bcd61
    (don't you love these git references?).
    
    Also, the previous fix for js_execfile() calls for global hot-key events also
    fixed the EX_JS_CX feature I was working on (js_execmodule)!
    25625186
  • Rob Swindell's avatar
    External program "use shell" option can be used to use a new JS context · 1decdc69
    Rob Swindell authored
    Rather than introduce yet-another-external-program/config flag to enable
    the "new JS run-time/context" per invocation of any particular JS command,
    I'm using the XTRN/EX_SH ("Use Shell") option as it had no function for
    JavaScript command-lines and the concept is similar.
    
    So if you want to invoke a JS external program/timed-event in its own
    "sandbox", enable the "Use Shell / New Context" option for that
    program/command in SCFG. There may be performance penalties when running
    JS mods in this way, but you get the benefit of isolating one JS module
    from all others, if/when necessary.
    1decdc69
......@@ -725,29 +725,25 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco
JS_RemoveValueRoot(js_cx, &old_js_argc);
}
JS_ENDREQUEST(js_cx);
JS_GC(js_cx);
JS_ENDREQUEST(js_cx);
return(result);
}
// Execute a JS Module in its own runtime and context
// Experimental and currently broken
long sbbs_t::js_execmodule(const char *cmd, long mode, const char* startup_dir)
// Execute a JS Module in its own temporary JS runtime and context
long sbbs_t::js_execxtrn(const char *cmd, const char* startup_dir)
{
if(!(mode&EX_JS_CX))
return js_execfile(cmd, startup_dir);
JSRuntime* js_runtime;
JSObject* js_glob;
JSContext* js_cx = js_init(&js_runtime, &js_glob, "XtrnModule");
js_create_user_objects(js_cx, js_glob);
long result = js_execfile(cmd, startup_dir, js_glob, js_cx);
long result = js_execfile(cmd, startup_dir, js_glob, js_cx, js_glob);
JS_BEGINREQUEST(js_cx);
JS_RemoveObjectRoot(js_cx, &js_glob);
JS_ENDREQUEST(js_cx);
JS_DestroyContext(js_cx);
lprintf(LOG_DEBUG,"JavaScript: Destroying runtime");
jsrt_Release(js_runtime);
return result;
}
......
......@@ -150,7 +150,7 @@ typedef struct {
int GCES_level; \
get_crypt_error_string(status, sess, &GCES_estr, action, &GCES_level); \
if (GCES_estr) { \
lprintf(GCES_level + 1, "%04d %s %s", sock, server, GCES_estr); \
lprintf(GCES_level, "%04d %s %s", sock, server, GCES_estr); \
free_crypt_attrstr(GCES_estr); \
} \
} while(0)
......@@ -160,7 +160,17 @@ typedef struct {
int GCES_level; \
get_crypt_error_string(status, sess, &GCES_estr, action, &GCES_level); \
if (GCES_estr) { \
lprintf(GCES_level + 1, "%04d %s [%s] %s", sock, server, host, GCES_estr); \
lprintf(GCES_level, "%04d %s [%s] %s", sock, server, host, GCES_estr); \
free_crypt_attrstr(GCES_estr); \
} \
} while(0)
#define GCESHL(status, server, sock, host, log_level, sess, action) do { \
char *GCES_estr; \
int GCES_level; \
get_crypt_error_string(status, sess, &GCES_estr, action, &GCES_level); \
if (GCES_estr) { \
lprintf(log_level, "%04d %s [%s] %s", sock, server, host, GCES_estr); \
free_crypt_attrstr(GCES_estr); \
} \
} while(0)
......@@ -5351,7 +5361,7 @@ static SOCKET sendmail_negotiate(CRYPT_SESSION *session, smb_t *smb, smbmsg_t *m
}
if ((status=cryptSetAttribute(*session, CRYPT_SESSINFO_ACTIVE, 1)) != CRYPT_OK) {
unlock_ssl_cert();
GCESH(status, prot, sock, server, *session, "setting session active");
GCESHL(status, prot, sock, server, LOG_WARNING, *session, "setting session active");
continue;
}
unlock_ssl_cert();
......
......@@ -407,7 +407,7 @@ public:
JSObject* js_hotkey_glob;
js_callback_t js_callback;
long js_execfile(const char *fname, const char* startup_dir, JSObject* scope = NULL, JSContext* cx = NULL, JSObject* glob = NULL);
long js_execmodule(const char *fname, long mode, const char* startup_dir);
long js_execxtrn(const char *fname, const char* startup_dir);
JSContext* js_init(JSRuntime**, JSObject**, const char* desc);
void js_cleanup(void);
bool js_create_user_objects(JSContext*, JSObject* glob);
......
......@@ -40,6 +40,21 @@
char *daystr(char days);
static void hotkey_cfg(void);
static char* use_shell_opt = "Use Shell / New Context";
static char* use_shell_help =
"`Use System Shell or New JavaScript Context to Execute:`\n"
"\n"
"If this command-line requires the system command shell to execute\n"
"(e.g. uses pipes/redirection or invokes a Unix shell script or\n"
"DOS/Windows batch/command file), then set this option to ~Yes~.\n"
"\n"
"If this command-line is invoking a Synchronet JavaScript module\n"
"(e.g. it begins with a '`?`' character), then setting this option to ~Yes~\n"
"will enable the creation and initialization of a new JavaScript run-time\n"
"context for it to execute within, for every invocation."
;
static char* use_shell_prompt = "Use System Shell or New JavaScript Context to Execute";
#define CUT_XTRNSEC_NUM USHRT_MAX
static bool new_timed_event(unsigned new_event_num)
......@@ -509,7 +524,7 @@ void tevents_cfg()
,cfg.event[i]->misc&EVENT_FORCE ? "Yes":"No");
sprintf(opt[k++],"%-32.32s%s","Native Executable"
,cfg.event[i]->misc&EX_NATIVE ? "Yes" : "No");
sprintf(opt[k++],"%-32.32s%s","Use Shell to Execute"
sprintf(opt[k++],"%-32.32s%s",use_shell_opt
,cfg.event[i]->misc&XTRN_SH ? "Yes" : "No");
sprintf(opt[k++],"%-32.32s%s","Background Execution"
,cfg.event[i]->misc&EX_BG ? "Yes" : "No");
......@@ -798,14 +813,9 @@ void tevents_cfg()
case 12:
k=(cfg.event[i]->misc&XTRN_SH) ? 0:1;
uifc.helpbuf=
"`Use Shell to Execute Command:`\n"
"\n"
"If this command-line requires the system command shell to execute (Unix\n"
"shell script or DOS/Windows batch/command file), set this option to ~Yes~.\n"
;
uifc.helpbuf = use_shell_help;
k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
,"Use System Command Shell",uifcYesNoOpts);
,use_shell_prompt, uifcYesNoOpts);
if(!k && !(cfg.event[i]->misc&XTRN_SH)) {
cfg.event[i]->misc|=XTRN_SH;
uifc.changes=TRUE;
......@@ -1006,7 +1016,7 @@ void xtrn_cfg(uint section)
==(XTRN_STDIO|XTRN_NOECHO) ? ", No Echo" : nulstr);
sprintf(opt[k++],"%-27.27s%s","Native Executable"
,cfg.xtrn[i]->misc&XTRN_NATIVE ? "Yes" : "No");
sprintf(opt[k++],"%-27.27s%s","Use Shell to Execute"
sprintf(opt[k++],"%-27.27s%s",use_shell_opt
,cfg.xtrn[i]->misc&XTRN_SH ? "Yes" : "No");
sprintf(opt[k++],"%-27.27s%s","Modify User Data"
,cfg.xtrn[i]->misc&MODUSERDAT ? "Yes" : "No");
......@@ -1055,6 +1065,9 @@ void xtrn_cfg(uint section)
"`Online Program Configuration:`\n"
"\n"
"This menu is for configuring the selected online program.\n"
"\n"
"For detailed instructions for configuring BBS doors, see\n"
"`http://wiki.synchro.net/howto:door:index`"
;
switch(uifc.list(WIN_SAV|WIN_ACT|WIN_MID,0,0,60,&opt_dflt,&sub_bar,cfg.xtrn[i]->name
,opt)) {
......@@ -1266,14 +1279,9 @@ void xtrn_cfg(uint section)
break;
case 11:
k=(cfg.xtrn[i]->misc&XTRN_SH) ? 0:1;
uifc.helpbuf=
"`Use Shell to Execute Command:`\n"
"\n"
"If this command-line requires the system command shell to execute, (Unix\n"
"shell script or DOS batch file), set this option to ~Yes~.\n"
;
uifc.helpbuf = use_shell_help;
k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
,"Use Shell",uifcYesNoOpts);
,use_shell_prompt,uifcYesNoOpts);
if(!k && !(cfg.xtrn[i]->misc&XTRN_SH)) {
cfg.xtrn[i]->misc|=XTRN_SH;
uifc.changes=TRUE;
......@@ -1667,7 +1675,7 @@ void xedit_cfg()
==(XTRN_STDIO|WWIVCOLOR) ? ", WWIV Color" : nulstr);
sprintf(opt[k++],"%-32.32s%s","Native Executable"
,cfg.xedit[i]->misc&XTRN_NATIVE ? "Yes" : "No");
sprintf(opt[k++],"%-32.32s%s","Use Shell to Execute"
sprintf(opt[k++],"%-32.32s%s",use_shell_opt
,cfg.xedit[i]->misc&XTRN_SH ? "Yes" : "No");
sprintf(opt[k++],"%-32.32s%s","Record Terminal Width"
,cfg.xedit[i]->misc&SAVECOLUMNS ? "Yes" : "No");
......@@ -1852,14 +1860,9 @@ void xedit_cfg()
break;
case 6:
k=(cfg.xedit[i]->misc&XTRN_SH) ? 0:1;
uifc.helpbuf=
"`Use Shell to Execute Command:`\n"
"\n"
"If this command-line requires the system command shell to execute, (Unix \n"
"shell script or DOS batch file), set this option to ~Yes~.\n"
;
uifc.helpbuf = use_shell_help;
k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
,"Use Shell",uifcYesNoOpts);
,use_shell_prompt, uifcYesNoOpts);
if(!k && !(cfg.xedit[i]->misc&XTRN_SH)) {
cfg.xedit[i]->misc|=XTRN_SH;
uifc.changes=TRUE;
......
......@@ -264,8 +264,10 @@ static bool native_executable(scfg_t* cfg, const char* cmdline, long mode)
return(exec_bin(cmdline+1,&main_csi,startup_dir))
#ifdef JAVASCRIPT
#define XTRN_LOADABLE_JS_MODULE(cmdline,mode,startup_dir) \
if(cmdline[0]=='?') /* JavaScript */ \
return(js_execmodule(cmdline+1,mode,startup_dir))
if(cmdline[0]=='?' && (mode&EX_SH)) \
return(js_execxtrn(cmdline+1, startup_dir)) \
if(cmdline[0]=='?') \
return(js_execfile(cmdline+1,startup_dir))
#else
#define XTRN_LOADABLE_JS_MODULE
#endif
......
......@@ -1598,7 +1598,7 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
mode|=EX_STDIO;
else if(cfg.xtrn[xtrnnum]->misc&XTRN_CONIO)
mode|=EX_CONIO;
mode|=(cfg.xtrn[xtrnnum]->misc&(XTRN_CHKTIME|XTRN_NATIVE|XTRN_NOECHO|WWIVCOLOR|XTRN_JS_CX));
mode|=(cfg.xtrn[xtrnnum]->misc&(XTRN_CHKTIME|XTRN_NATIVE|XTRN_NOECHO|WWIVCOLOR));
if(cfg.xtrn[xtrnnum]->misc&MODUSERDAT) { /* Delete MODUSER.DAT */
SAFEPRINTF(str,"%sMODUSER.DAT",dropdir); /* if for some weird */
removecase(str); /* reason it's there */
......