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

Better native vs. DOS cmd-line detection in cmdstr()

Always check the command-line for a '*' or '?' prefix and compare the executed filename against the native program list. For DOSEMU magic drive/path name command-line specifier substitution, but only when invoking DOS programs. Reported by bobrob via IRC.
parent d8cb42f8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #895 passed
/* Synchronet class (sbbs_t) definition and exported function prototypes */ /* Synchronet class (sbbs_t) definition and exported function prototypes */
// vi: tabstop=4
/* $Id: sbbs.h,v 1.583 2020/08/17 00:48:28 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
...@@ -15,21 +13,9 @@ ...@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -675,7 +661,7 @@ public: ...@@ -675,7 +661,7 @@ public:
bool inputnstime32(time32_t *dt); bool inputnstime32(time32_t *dt);
bool inputnstime(time_t *dt); bool inputnstime(time_t *dt);
bool chkpass(char *pass, user_t* user, bool unique); bool chkpass(char *pass, user_t* user, bool unique);
char * cmdstr(const char *instr, const char *fpath, const char *fspec, char *outstr, long mode = EX_UNSPECIFIED); char * cmdstr(const char *instr, const char *fpath, const char *fspec, char *outstr, long mode = 0);
char cmdstr_output[512]; char cmdstr_output[512];
void subinfo(uint subnum); void subinfo(uint subnum);
......
...@@ -842,7 +842,6 @@ enum { /* readmail and delmailidx which types */ ...@@ -842,7 +842,6 @@ enum { /* readmail and delmailidx which types */
#define EX_JS_CX (1<<24) /* New JavaScript context */ #define EX_JS_CX (1<<24) /* New JavaScript context */
#define EX_NOLOG (1<<30) /* Don't log intercepted stdio */ #define EX_NOLOG (1<<30) /* Don't log intercepted stdio */
#define EX_CONIO (1<<31) /* Intercept Windows console I/O (doorway) */ #define EX_CONIO (1<<31) /* Intercept Windows console I/O (doorway) */
#define EX_UNSPECIFIED -1
#if defined(__unix__) #if defined(__unix__)
#define EX_WILDCARD EX_SH /* Expand wildcards using 'sh' on Unix */ #define EX_WILDCARD EX_SH /* Expand wildcards using 'sh' on Unix */
......
...@@ -226,7 +226,10 @@ static bool native_executable(scfg_t* cfg, const char* cmdline, long mode) ...@@ -226,7 +226,10 @@ static bool native_executable(scfg_t* cfg, const char* cmdline, long mode)
unsigned i; unsigned i;
if(mode&EX_NATIVE) if(mode&EX_NATIVE)
return(TRUE); return true;
if(*cmdline == '?' || *cmdline == '*')
return true;
SAFECOPY(str,cmdline); /* Set str to program name only */ SAFECOPY(str,cmdline); /* Set str to program name only */
truncstr(str," "); truncstr(str," ");
...@@ -1839,9 +1842,6 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1839,9 +1842,6 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
char str[MAX_PATH+1],*cmd; char str[MAX_PATH+1],*cmd;
int i,j,len; int i,j,len;
if(mode == EX_UNSPECIFIED && (*instr == '?' || *instr == '*'))
mode = EX_NATIVE;
if(outstr==NULL) if(outstr==NULL)
cmd=cmdstr_output; cmd=cmdstr_output;
else else
...@@ -1874,7 +1874,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1874,7 +1874,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'F': /* File path */ case 'F': /* File path */
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE) if(!native_executable(&cfg, instr, mode)
&& strncmp(fpath, cfg.node_dir, strlen(cfg.node_dir)) == 0) { && strncmp(fpath, cfg.node_dir, strlen(cfg.node_dir)) == 0) {
strncat(cmd, DOSEMU_NODE_DIR, avail); strncat(cmd, DOSEMU_NODE_DIR, avail);
strncat(cmd, fpath + strlen(cfg.node_dir), avail); strncat(cmd, fpath + strlen(cfg.node_dir), avail);
...@@ -1885,7 +1885,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1885,7 +1885,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'G': /* Temp directory */ case 'G': /* Temp directory */
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode))
strncat(cmd, DOSEMU_TEMP_DIR, avail); strncat(cmd, DOSEMU_TEMP_DIR, avail);
else else
#endif #endif
...@@ -1899,7 +1899,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1899,7 +1899,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'J': case 'J':
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode))
strncat(cmd, DOSEMU_DATA_DIR, avail); strncat(cmd, DOSEMU_DATA_DIR, avail);
else else
#endif #endif
...@@ -1907,7 +1907,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1907,7 +1907,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'K': case 'K':
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode)))
strncat(cmd, DOSEMU_CTRL_DIR, avail); strncat(cmd, DOSEMU_CTRL_DIR, avail);
else else
#endif #endif
...@@ -1921,7 +1921,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1921,7 +1921,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'N': /* Node Directory (same as SBBSNODE environment var) */ case 'N': /* Node Directory (same as SBBSNODE environment var) */
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode))
strncat(cmd, DOSEMU_NODE_DIR, avail); strncat(cmd, DOSEMU_NODE_DIR, avail);
else else
#endif #endif
...@@ -1966,7 +1966,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1966,7 +1966,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case 'Z': case 'Z':
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode))
strncat(cmd, DOSEMU_TEXT_DIR, avail); strncat(cmd, DOSEMU_TEXT_DIR, avail);
else else
#endif #endif
...@@ -1984,7 +1984,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch ...@@ -1984,7 +1984,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break; break;
case '!': /* EXEC Directory */ case '!': /* EXEC Directory */
#if defined(__linux__) && defined(USE_DOSEMU) #if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)) if(!native_executable(&cfg, instr, mode))
strncat(cmd, DOSEMU_EXEC_DIR, avail); strncat(cmd, DOSEMU_EXEC_DIR, avail);
else else
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment