Subject: Cygwin patch for 2002c1

From: "Abraham Backus" <[email-masked]>
Date: Fri, 25 Apr 2003 13:35:03 -0700

Hello,

This is my first attempt at trying to get the imap toolkit version 2002 to
work under cygwin.  With the sources that I downloaded, I had a couple of
problems:

1) the toolkit was putting my INBOX in the windows system directory
2) tmail would give an error having to do with masters, slaves, and append

For #1, I discovered that the toolkit wasn't doing anything with pw_dir, and
therefore was thinking the user's home directory isn't available.  Thus the
change to src/osdep/unix/ckp_cyg.c.

I didn't quite understand the reasoning behind prepending a colon character
to the username.  There may be a reason for it, but it seems to work when I
commented out the stuff that adds it.  Thus the changes to
src/osdep/unix/ckp_cyg.c and src/osdep/unix/log_cyg.c.

src/osdep/unix/os_cyg.c was including "tz_nul.c", which doesn't do
anything...  In an earlier Cygwin port, I noticed that a tz_cyg.c file was
created and used.  This is the change to src/osdep/unix/Makefile,
src/osdep/unix/os_cyg.c, and the addition of src/osdep/unix/tz_cyg.c.

And finally, for problem #2, I found that once a stream was fed to tmail (I
use fetchmail, then inject my messages with the tmail utility), the EOF that
tmail would get is propagated to the "slave" used in the flocksim code.
This involved quite a bit of my ferry commute time tracking down what the
heck was going on in the cygwin dll and learning a little about what's going
on.  It turns out that if I use the freopen API to re-open stdin, it works
fine.  I don't know the behavior of other platforms, so I added a
DEV_STDIN_REOPEN macro.  In the Cygwin case, I define this in
src/osdep/unix/os_cyg.h as "/dev/conin".  Then there's a conditional block
in flocksim.c to use this macro as a string to use for re-opening stdin.  I
don't know much about devices, but a google search shows that "/dev/conin"
is probably specific to Cygwin.  I assume the equivalent on other platforms
is "/dev/stdin".

thanks!
-Abe

---

From: Mark Crispin <[email-masked]>
Date: Fri, 25 Apr 2003 17:10:39 -0700 (Pacific Daylight Time)

On Fri, 25 Apr 2003, Abraham Backus wrote:
> commented out the stuff that adds it.

It took me a while (this was contributed code)), but I figured out why
it's doing the colon.  The UNIX modules assume that they can log in
without the password, and there are paths by which this can be done.
This can't be done under Cygwin, because the NT LogonUser() call requires
the password and you can't impersonate without having that token.  Thus
you have to disallow logins that didn't go through passwords.

This isn't a good way of doing that.  I'll replace it with a better
mechanism.

> created and used.

That change is pointless; it simply duplicates what has already been
generated in the date string, e.g. you'd end up with something like:
	Fri, 25 Apr 2003 16:51:01 -0700 (-0700)

The only meaningful thing for a tz_???.c routine to do is to generate a
symbolic timezone string for human purposes.

> tmail would get is propagated to the "slave" used in the flocksim code.

Well, it turns out that fcntl() locking on Cygwin does not have the nasty
bug that is on SVR4 systems, so it isn't necessary to use that slave hack.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.