The changes necessary to support visual studio fall into 2 basic groups.
1) reordering of header files, and 2) changes to support syntax
differences between mingw and visual studio and 3). All changes are
conditional upon the definition of the macro __VS_BUILD__ .
The visual studio errno.h file is conflicting with no-machine errno
constants. Force the constants we need and define
_CRT_NO_POSIX_ERROR_CODES to avoid redefining them. This fixes port
forwarding for visual studio implementation.
Builds all x64 64bit and x86 32 bit openssh binaries Release and Debug
versions from the single Win32-OpenSSH.sln file.
1. Open a MSbuild cmd prompt for Visual Studio 2015
2. cd Win32-OpenSSH\contrib\win32\openssh directory.
3. openssh_build_cmd
For now we avoid sending the 4 arrow keys to the shell or echo it to the
remote side. as cmd.exe or powershell does not process it correctly in
stream output device mode we run win32 sshd server.
This is needed so that sftp running after a ssh session from a Linux
client does not see two lines for each line typed. CRLF is set by win32
sshd server but we have to set mode to the previous way in the client
when an interactive session has ended.
Add a utility upon which every other project is dependent, to copy the
config.h.vs file to the source root config.h. Because the target may
have changed outside of visual studio, I have disabled the dependency
check so the file will be copied with every build..
Doing so will allow sshd.exe to be launched from any directory - thereby
enabling sshd to be launched from SCM. With this change - following
works:
- sshd.exe install
- net start sshd
- net stop sshd
- sshd.exe uninstall
Use new compile flag WIN32_VS to add/change logic of sftp client and
sftp server codes so that MS Visual Studio 2015 compiler and runtime can
be used. opendir(), readdir(), closedir() directory APIs and basename()
API of Unix/Linux are implemented in Windows as they are not available
in Windows/VisualStudio C-runtime. win32_dirent.c and win32_dirent.h
files added as dirent.c and dirent.h are not available in Windows and we
do not want to affect mingW/gcc builds for Windows which have those
files available.
The mingw make files build the umac source twice with different options.
Under visual studio, its easier if we just make a separate copy with
it's own build rules.
Missing a prototype can cause a problem if we are 64-bit and the
function is returning a pointer. Add a prototype to stop the return
value from being corrupted.
The sfds code blindly uses _get_osfhandle on values that may be file
descriptors, sockets or io handles. Under visual studio, _get_osfhandle
will call the invalid parameter handler for items that are not file
descriptors. Adding the handler allows us to call this in the same way
that mingw does. We will still get an assertion, but a prior change
sends those to stdiout instead of making the user click through a
dialog.
Functions not declared before use, are define as returning an int.
Under 64-bit this can result in corrupted pointers being returned.
Also, Visual studio doesn't like it when you use variables to declare
array sizes, static values always work though.
The original code had host file entries pointing to static memory. This
memory is freed in tilde_expand_paths. Better to xstrdup like the
original openssh code did.
Negative of an unsigned value should just be the two's complement. Add
code to change code with negative unsigned values to two's compliment
values if compiling under visual studio.
sshd server keeps count of characters typed on a line and will not send
backspace erase to the client if no character is there to erase on the
line even if the users is typing backspaces. This avoids erase of shell
prompt characters for visual user friendliness.
MS Win32 port & build date added in text part of version id ssh client
send to the remote sshd. sshd also shows this string via environment
variable "SSH_CLIENT_ID" . All these are allowed and encouraged by the
SSH RFC and improves usability and assists users to know what ssh
versions and vendor build they are running.
version.h file retains non win32 original code as it should; feature
added for win32 for ssh.exe to show build and date like sshd.exe rather
than a fixed date we had inserted before in version.h file.
sshd.exe uses SSHD_REMSOC env var as private IPC for remote socket
handle passing. The env var is deleted and the handle is made not
inheritable by sshd so that shell and subsystem do not see it or have
access to the handle.