From 40995ce1868fdb8cdbacf2a6dec5852a85593681 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows)" <rob@synchro.net>
Date: Tue, 8 Aug 2023 17:06:00 -0700
Subject: [PATCH] Insure the exec_dir is *always* prepped (fix for Windows
 upgrade to v3.20)

A "prepped" means directory means a relative path from the configuration files
(or default settings) has been converted to a full/absolute path with proper
slashes for the platform (i.e. backslashes instead of forward-slashes on
Windows).

JSexec doesn't require that the new v3.20 ctrl/*.ini files exist to run; this
was necessary to be able to run 'jsexec update -> upgrade_to_v320.js' which
does the ctrl/*.cnf to .ini file conversion (egg not required to build
chicken). When JSexec failed to load ctrl/msgs.ini
(e.g. "!ERROR loading configuration files: 2 (No such file or directory)
opening /sbbs/ctrl\msgs.ini"), it would continue to run, but not "prep" any
of the "path" settings (e.g. exec_dir).

The first run of 'jsexec update.js' would fail to run upgrade_to_v320.exe
(which does the v3.20 user base conversion) and a bunch of other (but not as
important) update steps because Windows couldn't execute "../exec/*".

Multiple errors would be displayed in this case, but the most important (as
reported by Ree in #synchronet of irc.synchro.net) was:
  '..' is not recognized as an internal or external command

right after the status output:
  No v3.20 user base found, running ../exec/upgrade_to_v320

Notice the "../exec/" prefix, which is not support by Windows when specifying
a file path to execute.

A second run of 'jsexec update' would work fine because the new v3.20 .ini
files would be successfully created after the first run (though the user base
was not).

This is likely the same issue that MRO reported recently when upgrading a
Windows SBBS v3.19 install to v3.20 and not having the user base upgraded
the first time.
---
 src/sbbs3/jsexec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/sbbs3/jsexec.c b/src/sbbs3/jsexec.c
index fe029b269a..00087df6e0 100644
--- a/src/sbbs3/jsexec.c
+++ b/src/sbbs3/jsexec.c
@@ -1472,6 +1472,7 @@ int main(int argc, char **argv, char** env)
 		fprintf(errfp,"!ERROR loading configuration files: %s\n",error);
 		if(require_cfg)
 			return(do_bail(1));
+		prep_dir(scfg.ctrl_dir, scfg.exec_dir, sizeof(scfg.exec_dir));
 	}
 	SAFECOPY(scfg.temp_dir,"../temp");
 #endif
-- 
GitLab