Skip to content

Commit 52a5a6a

Browse files
committed
Merge branch 'L1' of https://github.com/PowerShell/Win32-OpenSSH into L1
2 parents 88f4c54 + f3c8418 commit 52a5a6a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

session.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ FIXME: GFPZR: Function stat() may be undeclared.
117117
#include <Userenv.h>
118118
#include <shlobj.h>
119119

120+
#ifdef WIN32_PRAGMA_REMCON
121+
#include <shlwapi.h>
122+
#endif
120123
extern char HomeDirLsaW[MAX_PATH];
121124

122125
#endif
@@ -599,9 +602,17 @@ do_exec_no_pty(Session *s, const char *command)
599602
#ifndef WIN32_PRAGMA_REMCON
600603
exec_command = s->pw->pw_shell;
601604
#else
602-
snprintf(exec_command_str, sizeof(exec_command_str),
603-
"\\program files\\pragma\\shared files\\cmdserver.exe SSHD %d %d",
604-
s->row, s->col );
605+
if ( PathFileExists("\\program files\\pragma\\shared files\\cmdserver.exe") )
606+
snprintf(exec_command_str, sizeof(exec_command_str),
607+
"\\program files\\pragma\\shared files\\cmdserver.exe SSHD %d %d", s->row, s->col );
608+
else {
609+
// find base path of our executable
610+
char basepath[MAX_PATH];
611+
strcpy_s(basepath, MAX_PATH, __progname);
612+
PathRemoveFileSpec(basepath); // get the full dir part of the name
613+
snprintf(exec_command_str, sizeof(exec_command_str),
614+
"%s\\cmdserver.exe SSHD %d %d", basepath,s->row, s->col);
615+
}
605616
exec_command = exec_command_str;
606617
#endif
607618
}

0 commit comments

Comments
 (0)