Add support for MSYS / MinGW
hansfn opened this issue · 6 comments
I use MSYS in stead of CygWin. If I run ssh-pageant.exe in MSYS it (of course) complains about missing cygwin1.dll
Is it possible to compile ssh-pageant with MinGW so it can be used under MSYS too? If it is possible, could it be made part of this project - to have binaries prebuild fot MSYS / MinGW too.
Well, it doesn't immediately compile, neither as a "native" MinGW build nor an MSYS build (which would depend on msys-1.0.dll
). At first glance:
- MSYS is missing
err.h
andlibgen.h
. - MinGW is missing
arpa/inet.h
,err.h
,sys/select.h
,sys/socket.h
,sys/un.h
, andsys/wait.h
.
Some of these might be solvable with Gnulib modules. But missing sys/un.h
reveals the total lack of AF_UNIX
sockets in native Windows, which is fundamental to making an SSH_AUTH_SOCK
, so I think it will only be possible to port ssh-pageant to the MSYS runtime.
Thx for the quick reply.
I'm fine with using ssh-pageant only in the MSYS runtime - getting a build that depends on msys-1.0.dll.
I haven't compiled anything with MinGW earlier so I'm probably can't help you even if I really want to.
PS! I noticed that mingwrt package (mingw-runtime) includes errno.h (not err.h) and libgen.h. Some random Googling revealed similar problems with err.h - see atomicobject/heatshrink#7
Some further notes as I started attempting a compat layer:
- Missing
libgen.h
is easily worked around, as I was just using it forbasename(argv[0])
. I think I'll change that toprogram_invocation_short_name
regardless, which is a GNU-ism that Cygwin does support. Of course, MSYS doesn't support this variable either, but that can hardcode it to "ssh-pageant" instead. - Missing
err.h
functions are easily emulated, no problem. - MSYS's
ntohl()
takesunsigned long
instead ofuint32_t
, and in fact they have nostdint.h
oruint32_t
at all. I could add a compatibility typedef of my own. - MSYS has no
SOCK_CLOEXEC
flag. I could instead use a separatefcntl(fd, F_SETFD, FD_CLOEXEC)
. - MSYS has no
accept4()
, butaccept()
is fine if CLOEXEC is done separately. - MSYS has no
mkdtemp()
. It's possible to usemktemp()
andmkdir()
instead, which is racy but probably good enough. - MSYS has no
strlcpy()
. I could probably implement this as a wrapper onstrncpy()
.
So these things are all possible to deal with, assuming nothing else comes up, but honestly MSYS is leaving a bad taste in my mouth. I'm not sure so many compatibility changes are worth it for such an old platform base. MSYS gcc 3.4.4 is nearly 10 years old! And Cygwin's newlib has really progressed since MSYS forked away.
Are you sure you can't just use Cygwin? :) Even just use a minimal install for ssh-pageant only, and reportedly things like MSYS git can talk to a Cygwin ssh-pageant just fine.
Pardon my earlier grumbling -- I think I got it to work anyway. :)
Source changes are on the msys
branch, or here's a prebuilt MSYS ssh-pageant:
https://dl.dropboxusercontent.com/u/15293294/ssh-pageant-msys-test.zip
Please let me know if that works for you!
It worked - yes! Introducing a compatibility header was a nice solution.
Regarding MSYS vs Cygwin: At some point in time I considered MSYS to be much smaller/leaner than Cygwin - I just need a proper shell (Bash) with a limited set of standard Unix tools, but that might not be true anymore? I hope that you will build ssh-pageant for both MSYS and Cygwin in the future.
PS! I would be more than happy to give you a contribution for your swift solution. Do you have PayPal account that I can send some money to?
My impression is that MSYS exists mostly just to supplement a MinGW compilation environment, and this is why they don't really worry that the tools for MSYS itself are so old. And it is basically just an old fork of Cygwin. If you're looking for a Unix-y environment for day-to-day use, that's Cygwin's primary mission, and it's actively updated too.
Anyway, yes, I'll try to make a new release sometime soon, and I will include a prebuilt for MSYS. The changes are now in master, at least.
As for a contribution, I appreciate the thought, but I'll decline. This is just a hobby project for me, and I don't even want to think about tax implications and such "fun". It's enough for me to know that people find ssh-pageant genuinely useful. :)