5 * Author: Corinna Vinschen <vinschen@cygnus.com>
7 * Copyright (c) 2000 Corinna Vinschen <vinschen@cygnus.com>, Duisburg, Germany
10 * Created: Sat Sep 02 12:17:00 2000 cv
12 * This file contains functions for forcing opened file descriptors to
13 * binary mode on Windows systems.
24 #define is_winnt (GetVersion() < 0x80000000)
26 int binary_open(const char *filename, int flags, mode_t mode)
28 return open(filename, flags | O_BINARY, mode);
31 int binary_pipe(int fd[2])
35 setmode (fd[0], O_BINARY);
36 setmode (fd[1], O_BINARY);
41 int check_nt_auth (int pwd_authenticated, uid_t uid)
44 * The only authentication which is able to change the user
45 * context on NT systems is the password authentication. So
46 * we deny all requsts for changing the user context if another
47 * authentication method is used.
48 * This may change in future when a special openssh
49 * subauthentication package is available.
51 if (is_winnt && !pwd_authenticated && geteuid() != uid)
56 int check_ntsec (const char *filename)
63 /* Windows 95/98/ME don't support file system security at all. */
67 /* Evaluate current CYGWIN settings. */
68 if ((cygwin = getenv("CYGWIN")) != NULL) {
69 if (strstr(cygwin, "ntea") && !strstr(cygwin, "nontea"))
71 if (strstr(cygwin, "ntsec") && !strstr(cygwin, "nontsec"))
76 * `ntea' is an emulation of POSIX attributes. It doesn't support
77 * real file level security as ntsec on NTFS file systems does
78 * but it supports FAT filesystems. `ntea' is minimum requirement
79 * for security checks.
85 * Retrieve file system flags. In Cygwin, file system flags are
86 * copied to f_type which has no meaning in Win32 itself.
88 if (statfs(filename, &fsstat))
92 * Only file systems supporting ACLs are able to set permissions.
93 * `ntsec' is the setting in Cygwin which switches using of NTFS
94 * ACLs to support POSIX permissions on files.
96 if (fsstat.f_type & FS_PERSISTENT_ACLS)