Mailing List Archive

[PATCH]: Port of openssh-2.1.0p3 to Cygwin environment
Hi all,

I have just successfully ported openssh-2.1.0p3 to Cygwin. As you
may know, Cygwin is a GPLed POSIX layer for Windows OSes.
To be serious: I don't _like_ Windows systems and sometimes I
really hate that STUPID concessions which are necessary when
trying to get U*X software working on Windoze but for some
reason that's exactly the reason, why I love to work on Cygwin!

Porting to Cygwin has two major goals:

- Care for all file access to differ `text mode' (files may have
\n or \r\n line endings) from `binary mode' (files are always
read as they are like in U*X).
- Care for Windows NT password authentication method.

Another problem is the usage of the filename `aux.c'. Windows
has some special files (devices) called NUL, AUX, PRN, LPT, CON
and as a holdover from `those good ol' DOS days' :-( it's not
possible to name a regular file eg. "aux", "aux.foo", "foo.aux".
To get rid of that problem, I have renamed the file `aux.c' to
`aux_funcs.c'. You can't see this file name change in my patch
only in `Makefile.in', unfortunately.

With that port, you can use sshd either as service which enables
NT password authentication for each user or as a user bound
daemon which allows RSA/DSA authentication only for exactly that
user due to the NT/W2K authentication restrictions. No such
restriction exists when running sshd under (geez) W95/W98.
Which works.

I would be very glad if it's possible to integrate the patch and
to add Cygwin to the development targets of the portable OpenSSH.

The gzip'd patch file related to 2.1.0p3 is attached.

Please reply to my personal mail address, because I'm not subscribed
to the mailing list.

Thanks in advance,
Corinna


ChangeLog:
20000607
- Change name of `aux.c' to `aux_funcs.c'.
- [auth-password.c auth1.c auth2.c session.c] Include Windows NT
password authentication.
- [auth1.c auth2.c] Disable empty password authentication for Cygwin.
- [Various files] Care for binary versus text mode in file open calls.
- Disable some file permission checks for Cygwin to
allow working on FAT file systems.
- [.bsd-daemon.c} When working in daemon mode, let parent process
sleep a second to avoid a race condition in Cygwin.
- [defines.h] typedef the types `n_short', `n_long' and `n_time'
instead of including netinet/in_systm.h for Cygwin.
- [includes.h] include getopt.h for Cygwin. Define O_BINARY as far as
it's not already defined.
- [login.c] Cast -1 to uid_t to avoid compiler warnings.
- [packet.c] IPTOS_LOWDELAY and IPTOS_THROUGHPUT are defined in Cygwin
but result in error on W2K.
- [pty.c] pushing streams modules isn't functional on Windows.
- [rsa.c] Don't call seed_rng() in Cygwin to avoid race condition in
daemon mode.
- [scp.c] Call `tcgetpgrp()' instead of `ioctl(, TIOCGPGRP,) in Cygwin.
- [session.c] Rearrange environment handling for woring under Windows.
Close xauthfile imediately to avoid permission problems under
Windows.
Don't send the `$DISPLAY/unix' stuff to the Cygwin xauth program.
- [ssh.c] Try more variations of the own name in Cygwin.
- [ssh.h] Disable declaration of auth_password for Cygwin here.

--
Corinna Vinschen
Cygwin Developer
Cygnus Solutions, a Red Hat company
Re: [PATCH]: Port of openssh-2.1.0p3 to Cygwin environment [ In reply to ]
On Wed, 7 Jun 2000, Corinna Vinschen wrote:

> Hi all,
>
> I have just successfully ported openssh-2.1.0p3 to Cygwin. As you
> may know, Cygwin is a GPLed POSIX layer for Windows OSes.
> To be serious: I don't _like_ Windows systems and sometimes I
> really hate that STUPID concessions which are necessary when
> trying to get U*X software working on Windoze but for some
> reason that's exactly the reason, why I love to work on Cygwin!

Thanks for the patch!

Cygwin does make working with nt a little more endurable :)

> Porting to Cygwin has two major goals:
>
> - Care for all file access to differ `text mode' (files may have
> \n or \r\n line endings) from `binary mode' (files are always
> read as they are like in U*X).

This is the main problem with integrating the patch - it touched
just about every open and fopen in the source. This make it more
difficult to stay synched with the OpenBSD CVS tree (i.e lots more
manual patching).

Is there any way to decrease the volume of these changes or isolate
them to a one-off #define?

I will give the diff a try over the weekend on our poor NT machine :)

Regards,
Damien Miller

--
| "Bombay is 250ms from New York in the new world order" - Alan Cox
| Damien Miller - http://www.mindrot.org/
| Email: djm@mindrot.org (home) -or- djm@ibs.com.au (work)
Re: [PATCH]: Port of openssh-2.1.0p3 to Cygwin environment [ In reply to ]
Damien Miller wrote:
> > - Care for all file access to differ `text mode' (files may have
> > \n or \r\n line endings) from `binary mode' (files are always
> > read as they are like in U*X).
>
> This is the main problem with integrating the patch - it touched
> just about every open and fopen in the source. This make it more
> difficult to stay synched with the OpenBSD CVS tree (i.e lots more
> manual patching).
>
> Is there any way to decrease the volume of these changes or isolate
> them to a one-off #define?

The problem is, that some files has to be opened as `text files'
(motd, sshd_config, etc) and some files has to be opened
as `binary files' (utmp, identity, etc) so there's no chance to
generalize the open mode.

You may have seen, that there's a difference in the implementation:

open(2) calls in OpenSSH are in general with mode O_BINARY so
this is in fact a generalization which should be easy to handle
in the ported version. For all OSes, which hasn't defined
O_BINARY, O_BINARY is set to 0 (includes.h).

The difficulty is given in the fopen(3) calls. I don't have
a generalization yet instantly. Has somebody else an idea?

> I will give the diff a try over the weekend on our poor NT machine :)

Fine.

Corinna

--
Corinna Vinschen
Cygwin Developer
Cygnus Solutions, a Red Hat company
Re: [PATCH]: Port of openssh-2.1.0p3 to Cygwin environment [ In reply to ]
Damien Miller wrote:
> > Porting to Cygwin has two major goals:
> >
> > - Care for all file access to differ `text mode' (files may have
> > \n or \r\n line endings) from `binary mode' (files are always
> > read as they are like in U*X).
>
> This is the main problem with integrating the patch - it touched
> just about every open and fopen in the source. This make it more
> difficult to stay synched with the OpenBSD CVS tree (i.e lots more
> manual patching).
>
> Is there any way to decrease the volume of these changes or isolate
> them to a one-off #define?

What do you think of something like

#ifdef __CYGWIN__
#define FOPEN_READ_TEXT "rt"
#define FOPEN_READ_BINARY "rb"
#else
#define FOPEN_READ_TEXT "r"
#define FOPEN_READ_BINARY "r"
#endif

and use FOPEN_READ_* throughout. That still touches every single
fopen but it reduces the number of lines.

Corinna



>
> I will give the diff a try over the weekend on our poor NT machine :)
>
> Regards,
> Damien Miller
>
> --
> | "Bombay is 250ms from New York in the new world order" - Alan Cox
> | Damien Miller - http://www.mindrot.org/
> | Email: djm@mindrot.org (home) -or- djm@ibs.com.au (work)

--
Corinna Vinschen
Cygwin Developer
Cygnus Solutions, a Red Hat company
Re: [PATCH]: Port of openssh-2.1.0p3 to Cygwin environment [ In reply to ]
> #ifdef __CYGWIN__
> #define FOPEN_READ_TEXT "rt"
> #define FOPEN_READ_BINARY "rb"
> #else
> #define FOPEN_READ_TEXT "r"
> #define FOPEN_READ_BINARY "r"
> #endif

I know nothing about Cygwin, but is it ANSI C comformant? K&R2 does not
mention the option of including "t" in the mode. It says you can either
have a "b" or not have one.

It should be perfectly safe to use "b" for binary files on all
platforms, so I see no need to use the preprocessor.

AMC
Re: [PATCH]: Port of openssh-2.1.0p3 to Cygwin environment [ In reply to ]
Circa 2000-Jun-11 20:04:53 +0000 schrieb Adam M. Costello:

: I know nothing about Cygwin, but is it ANSI C comformant? K&R2 does not
: mention the option of including "t" in the mode. It says you can either
: have a "b" or not have one.

Plauger ("The Standard C Library") confirms this: fopen(... "r" ...)
means text mode, while fopen(... "rb" ...) means binary.

: It should be perfectly safe to use "b" for binary files on all
: platforms, so I see no need to use the preprocessor.

Agreed. Use of "b" with fopen() ought to get folded back into
OpenBSD's OpenSSH code.

--
jim knoble | jmknoble@jmknoble.cx | http://www.jmknoble.cx/