Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 1 | /* |
Kevin Steves | eb36302 | 2002-04-15 22:00:51 +0000 | [diff] [blame] | 2 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 3 | * |
Kevin Steves | eb36302 | 2002-04-15 22:00:51 +0000 | [diff] [blame] | 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 23 | * |
| 24 | * Created: Sat Sep 02 12:17:00 2000 cv |
| 25 | * |
| 26 | * This file contains functions for forcing opened file descriptors to |
| 27 | * binary mode on Windows systems. |
| 28 | */ |
| 29 | |
Damien Miller | e9cf357 | 2001-02-09 12:55:35 +1100 | [diff] [blame] | 30 | #include "includes.h" |
| 31 | |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 32 | #ifdef HAVE_CYGWIN |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 33 | |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 34 | #include <fcntl.h> |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 35 | #include <stdlib.h> |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 36 | #include <sys/utsname.h> |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 37 | #include <sys/vfs.h> |
| 38 | #include <windows.h> |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 39 | #include "xmalloc.h" |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 40 | #define is_winnt (GetVersion() < 0x80000000) |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 41 | |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 42 | #define ntsec_on(c) ((c) && strstr((c),"ntsec") && !strstr((c),"nontsec")) |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 43 | #define ntsec_off(c) ((c) && strstr((c),"nontsec")) |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 44 | #define ntea_on(c) ((c) && strstr((c),"ntea") && !strstr((c),"nontea")) |
| 45 | |
Damien Miller | 2deb3f6 | 2001-02-18 12:30:55 +1100 | [diff] [blame] | 46 | #if defined(open) && open == binary_open |
| 47 | # undef open |
| 48 | #endif |
| 49 | #if defined(pipe) && open == binary_pipe |
| 50 | # undef pipe |
| 51 | #endif |
| 52 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 53 | int |
| 54 | binary_open(const char *filename, int flags, ...) |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 55 | { |
Damien Miller | 2deb3f6 | 2001-02-18 12:30:55 +1100 | [diff] [blame] | 56 | va_list ap; |
| 57 | mode_t mode; |
| 58 | |
| 59 | va_start(ap, flags); |
| 60 | mode = va_arg(ap, mode_t); |
| 61 | va_end(ap); |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 62 | return (open(filename, flags | O_BINARY, mode)); |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 63 | } |
| 64 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 65 | int |
| 66 | binary_pipe(int fd[2]) |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 67 | { |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 68 | int ret = pipe(fd); |
| 69 | |
| 70 | if (!ret) { |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 71 | setmode(fd[0], O_BINARY); |
| 72 | setmode(fd[1], O_BINARY); |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 73 | } |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 74 | return (ret); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 75 | } |
| 76 | |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 77 | #define HAS_CREATE_TOKEN 1 |
| 78 | #define HAS_NTSEC_BY_DEFAULT 2 |
Damien Miller | 2eb4236 | 2004-04-18 21:15:43 +1000 | [diff] [blame] | 79 | #define HAS_CREATE_TOKEN_WO_NTSEC 3 |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 80 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 81 | static int |
| 82 | has_capability(int what) |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 83 | { |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 84 | static int inited; |
| 85 | static int has_create_token; |
| 86 | static int has_ntsec_by_default; |
Damien Miller | 2eb4236 | 2004-04-18 21:15:43 +1000 | [diff] [blame] | 87 | static int has_create_token_wo_ntsec; |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 88 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 89 | /* |
| 90 | * has_capability() basically calls uname() and checks if |
| 91 | * specific capabilities of Cygwin can be evaluated from that. |
| 92 | * This simplifies the calling functions which only have to ask |
| 93 | * for a capability using has_capability() instead of having |
| 94 | * to figure that out by themselves. |
| 95 | */ |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 96 | if (!inited) { |
| 97 | struct utsname uts; |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 98 | |
| 99 | if (!uname(&uts)) { |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 100 | int major_high = 0, major_low = 0, minor = 0; |
| 101 | int api_major_version = 0, api_minor_version = 0; |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 102 | char *c; |
| 103 | |
| 104 | sscanf(uts.release, "%d.%d.%d", &major_high, |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 105 | &major_low, &minor); |
| 106 | if ((c = strchr(uts.release, '(')) != NULL) { |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 107 | sscanf(c + 1, "%d.%d", &api_major_version, |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 108 | &api_minor_version); |
| 109 | } |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 110 | if (major_high > 1 || |
| 111 | (major_high == 1 && (major_low > 3 || |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 112 | (major_low == 3 && minor >= 2)))) |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 113 | has_create_token = 1; |
| 114 | if (api_major_version > 0 || api_minor_version >= 56) |
| 115 | has_ntsec_by_default = 1; |
Damien Miller | 2eb4236 | 2004-04-18 21:15:43 +1000 | [diff] [blame] | 116 | if (major_high > 1 || |
| 117 | (major_high == 1 && major_low >= 5)) |
| 118 | has_create_token_wo_ntsec = 1; |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 119 | inited = 1; |
| 120 | } |
| 121 | } |
| 122 | switch (what) { |
| 123 | case HAS_CREATE_TOKEN: |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 124 | return (has_create_token); |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 125 | case HAS_NTSEC_BY_DEFAULT: |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 126 | return (has_ntsec_by_default); |
Damien Miller | 2eb4236 | 2004-04-18 21:15:43 +1000 | [diff] [blame] | 127 | case HAS_CREATE_TOKEN_WO_NTSEC: |
| 128 | return (has_create_token_wo_ntsec); |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 129 | } |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 130 | return (0); |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 133 | int |
| 134 | check_nt_auth(int pwd_authenticated, struct passwd *pw) |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 135 | { |
| 136 | /* |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 137 | * The only authentication which is able to change the user |
| 138 | * context on NT systems is the password authentication. So |
| 139 | * we deny all requsts for changing the user context if another |
| 140 | * authentication method is used. |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 141 | * |
| 142 | * This doesn't apply to Cygwin versions >= 1.3.2 anymore which |
| 143 | * uses the undocumented NtCreateToken() call to create a user |
| 144 | * token if the process has the appropriate privileges and if |
| 145 | * CYGWIN ntsec setting is on. |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 146 | */ |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 147 | static int has_create_token = -1; |
| 148 | |
Damien Miller | 0dea79d | 2001-12-29 14:08:28 +1100 | [diff] [blame] | 149 | if (pw == NULL) |
| 150 | return 0; |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 151 | if (is_winnt) { |
| 152 | if (has_create_token < 0) { |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 153 | char *cygwin = getenv("CYGWIN"); |
| 154 | |
| 155 | has_create_token = 0; |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 156 | if (has_capability(HAS_CREATE_TOKEN) && |
| 157 | (ntsec_on(cygwin) || |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 158 | (has_capability(HAS_NTSEC_BY_DEFAULT) && |
Damien Miller | 2eb4236 | 2004-04-18 21:15:43 +1000 | [diff] [blame] | 159 | !ntsec_off(cygwin)) || |
| 160 | has_capability(HAS_CREATE_TOKEN_WO_NTSEC))) |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 161 | has_create_token = 1; |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 162 | } |
| 163 | if (has_create_token < 1 && |
Damien Miller | 0dea79d | 2001-12-29 14:08:28 +1100 | [diff] [blame] | 164 | !pwd_authenticated && geteuid() != pw->pw_uid) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 165 | return (0); |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 166 | } |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 167 | return (1); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 168 | } |
| 169 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 170 | int |
| 171 | check_ntsec(const char *filename) |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 172 | { |
| 173 | char *cygwin; |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 174 | int allow_ntea = 0, allow_ntsec = 0; |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 175 | struct statfs fsstat; |
| 176 | |
| 177 | /* Windows 95/98/ME don't support file system security at all. */ |
| 178 | if (!is_winnt) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 179 | return (0); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 180 | |
| 181 | /* Evaluate current CYGWIN settings. */ |
Ben Lindstrom | cff94be | 2001-07-18 16:19:48 +0000 | [diff] [blame] | 182 | cygwin = getenv("CYGWIN"); |
| 183 | allow_ntea = ntea_on(cygwin); |
Ben Lindstrom | 224313c | 2002-11-09 15:59:27 +0000 | [diff] [blame] | 184 | allow_ntsec = ntsec_on(cygwin) || |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 185 | (has_capability(HAS_NTSEC_BY_DEFAULT) && !ntsec_off(cygwin)); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 186 | |
| 187 | /* |
| 188 | * `ntea' is an emulation of POSIX attributes. It doesn't support |
| 189 | * real file level security as ntsec on NTFS file systems does |
| 190 | * but it supports FAT filesystems. `ntea' is minimum requirement |
| 191 | * for security checks. |
| 192 | */ |
| 193 | if (allow_ntea) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 194 | return (1); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 195 | |
| 196 | /* |
| 197 | * Retrieve file system flags. In Cygwin, file system flags are |
| 198 | * copied to f_type which has no meaning in Win32 itself. |
| 199 | */ |
| 200 | if (statfs(filename, &fsstat)) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 201 | return (1); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 202 | |
| 203 | /* |
| 204 | * Only file systems supporting ACLs are able to set permissions. |
| 205 | * `ntsec' is the setting in Cygwin which switches using of NTFS |
| 206 | * ACLs to support POSIX permissions on files. |
| 207 | */ |
| 208 | if (fsstat.f_type & FS_PERSISTENT_ACLS) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 209 | return (allow_ntsec); |
Damien Miller | b70b61f | 2000-09-16 16:25:12 +1100 | [diff] [blame] | 210 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 211 | return (0); |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 212 | } |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 213 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 214 | void |
| 215 | register_9x_service(void) |
Tim Rice | fe1d100 | 2001-11-26 17:19:43 -0800 | [diff] [blame] | 216 | { |
| 217 | HINSTANCE kerneldll; |
| 218 | DWORD (*RegisterServiceProcess)(DWORD, DWORD); |
| 219 | |
| 220 | /* The service register mechanism in 9x/Me is pretty different from |
| 221 | * NT/2K/XP. In NT/2K/XP we're using a special service starter |
| 222 | * application to register and control sshd as service. This method |
| 223 | * doesn't play nicely with 9x/Me. For that reason we register here |
| 224 | * as service when running under 9x/Me. This function is only called |
| 225 | * by the child sshd when it's going to daemonize. |
| 226 | */ |
| 227 | if (is_winnt) |
| 228 | return; |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 229 | if (!(kerneldll = LoadLibrary("KERNEL32.DLL"))) |
Tim Rice | fe1d100 | 2001-11-26 17:19:43 -0800 | [diff] [blame] | 230 | return; |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 231 | if (!(RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) |
| 232 | GetProcAddress(kerneldll, "RegisterServiceProcess"))) |
Tim Rice | fe1d100 | 2001-11-26 17:19:43 -0800 | [diff] [blame] | 233 | return; |
| 234 | RegisterServiceProcess(0, 1); |
| 235 | } |
| 236 | |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 237 | #define NL(x) x, (sizeof (x) - 1) |
| 238 | #define WENV_SIZ (sizeof (wenv_arr) / sizeof (wenv_arr[0])) |
| 239 | |
| 240 | static struct wenv { |
| 241 | const char *name; |
| 242 | size_t namelen; |
| 243 | } wenv_arr[] = { |
| 244 | { NL("ALLUSERSPROFILE=") }, |
| 245 | { NL("COMMONPROGRAMFILES=") }, |
| 246 | { NL("COMPUTERNAME=") }, |
| 247 | { NL("COMSPEC=") }, |
Darren Tucker | ae8c91e | 2005-05-25 19:42:10 +1000 | [diff] [blame] | 248 | { NL("CYGWIN=") }, |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 249 | { NL("NUMBER_OF_PROCESSORS=") }, |
| 250 | { NL("OS=") }, |
| 251 | { NL("PATH=") }, |
| 252 | { NL("PATHEXT=") }, |
| 253 | { NL("PROCESSOR_ARCHITECTURE=") }, |
| 254 | { NL("PROCESSOR_IDENTIFIER=") }, |
| 255 | { NL("PROCESSOR_LEVEL=") }, |
| 256 | { NL("PROCESSOR_REVISION=") }, |
| 257 | { NL("PROGRAMFILES=") }, |
| 258 | { NL("SYSTEMDRIVE=") }, |
| 259 | { NL("SYSTEMROOT=") }, |
| 260 | { NL("TMP=") }, |
| 261 | { NL("TEMP=") }, |
Darren Tucker | ae8c91e | 2005-05-25 19:42:10 +1000 | [diff] [blame] | 262 | { NL("WINDIR=") } |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 263 | }; |
| 264 | |
| 265 | char ** |
| 266 | fetch_windows_environment(void) |
| 267 | { |
| 268 | char **e, **p; |
Darren Tucker | 84af615 | 2006-02-12 11:59:08 +1100 | [diff] [blame] | 269 | unsigned int i, idx = 0; |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 270 | |
Darren Tucker | ae8c91e | 2005-05-25 19:42:10 +1000 | [diff] [blame] | 271 | p = xmalloc((WENV_SIZ + 1) * sizeof(char *)); |
Darren Tucker | 14c372d | 2004-08-30 20:42:08 +1000 | [diff] [blame] | 272 | for (e = environ; *e != NULL; ++e) { |
| 273 | for (i = 0; i < WENV_SIZ; ++i) { |
| 274 | if (!strncmp(*e, wenv_arr[i].name, wenv_arr[i].namelen)) |
| 275 | p[idx++] = *e; |
| 276 | } |
| 277 | } |
| 278 | p[idx] = NULL; |
| 279 | return p; |
| 280 | } |
| 281 | |
| 282 | void |
| 283 | free_windows_environment(char **p) |
| 284 | { |
| 285 | xfree(p); |
| 286 | } |
| 287 | |
Damien Miller | 72c9a7e | 2000-09-24 11:10:13 +1100 | [diff] [blame] | 288 | #endif /* HAVE_CYGWIN */ |