From 2f176dd84f4b0c5701d46da039c06ec54e2f22a9 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Wed, 11 Nov 2020 17:58:11 -0800 Subject: [PATCH] Clean-up and optimize the pre/post exec xtrn modules Don't load() things unnecessarily (use require() instead). Fix the X-restriction issue (is not supposed to limit the execution of programs configured to run as logon events). --- exec/postxtrn.js | 27 +++++++++++---------------- exec/prextrn.js | 43 ++++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/exec/postxtrn.js b/exec/postxtrn.js index 1634164392..6f602bfc9c 100644 --- a/exec/postxtrn.js +++ b/exec/postxtrn.js @@ -1,29 +1,25 @@ // postxtrn.js -// External Program Post Module +// External Program Post-execution Module // These actions execute after an external program is launched via bbs.exec_xtrn() "use strict"; -load("sbbsdefs.js"); - -/* text.dat entries */ -load("text.js"); - -var options, program; - -if((options=load({}, "modopts.js","xtrn_sec")) == null) - options = {}; // default values - -if(options.clear_screen === undefined) - options.clear_screen = true; - function exec_xtrn_post(program) { + var options; + + if ((options = load({}, "modopts.js","xtrn:" + program.code)) == null) { + if ((options = load({}, "modopts.js","xtrn_sec")) == null) + options = {}; // default values + } + + require("nodedefs.js", "NODE_LOGN"); if ((options.disable_post_on_logon_event) && (bbs.node_action == NODE_LOGN)) { exit(1); } + require("cga_defs.js", "LIGHTGRAY"); console.attributes = 0; console.attributes = LIGHTGRAY; @@ -34,8 +30,7 @@ function exec_xtrn_post(program) } } - /* main: */ { - exec_xtrn_post(xtrn_area.prog[argv[0].toLowerCase()] ); + exec_xtrn_post(xtrn_area.prog[argv[0].toLowerCase()]); } diff --git a/exec/prextrn.js b/exec/prextrn.js index 07d16322bd..07957ceef0 100644 --- a/exec/prextrn.js +++ b/exec/prextrn.js @@ -1,34 +1,34 @@ // prextrn.js -// External Program Pre Module +// External Program Pre-execution Module // These actions execute before an external program is launched via bbs.exec_xtrn() "use strict"; -load("sbbsdefs.js"); - -/* text.dat entries */ -load("text.js"); - -var options, program; - -if((options=load({}, "modopts.js","xtrn_sec")) == null) - options = {}; // default values - - function exec_xtrn_pre(program) { - if ((options.disable_pre_on_logon_event) && (bbs.node_action == NODE_LOGN)) { - exit(1); - } - - if (options.restricted_user_msg === undefined) { - options.restricted_user_msg = bbs.text(R_ExternalPrograms); + var options; + + if ((options = load({}, "modopts.js","xtrn:" + program.code)) == null) { + if ((options = load({}, "modopts.js","xtrn_sec")) == null) + options = {}; // default values } - if (user.security.restrictions&UFLAG_X) { - write(options.restricted_user_msg); - exit(1); + require("nodedefs.js", "NODE_LOGN"); + if (bbs.node_action == NODE_LOGN) { + if (options.disable_pre_on_logon_event) { + exit(1); + } + } else { + if (options.restricted_user_msg === undefined) { + require("text.js", "R_ExternalPrograms"); + options.restricted_user_msg = bbs.text(R_ExternalPrograms); + } + require("userdefs.js", "UFLAG_X"); + if (user.security.restrictions&UFLAG_X) { + write(options.restricted_user_msg); + exit(1); + } } if (bbs.menu_exists("xtrn/" + program.code)) { @@ -37,6 +37,7 @@ function exec_xtrn_pre(program) console.line_counter=0; } + require("cga_defs.js", "LIGHTGRAY"); console.attributes = LIGHTGRAY; if (options.clear_screen_on_exec) { -- GitLab