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.
27 #define is_winnt (GetVersion() < 0x80000000)
29 #if defined(open) && open == binary_open
32 #if defined(pipe) && open == binary_pipe
36 int binary_open(const char *filename, int flags, ...)
42 mode = va_arg(ap, mode_t);
44 return open(filename, flags | O_BINARY, mode);
47 int binary_pipe(int fd[2])
52 setmode (fd[0], O_BINARY);
53 setmode (fd[1], O_BINARY);
58 int check_nt_auth(int pwd_authenticated, uid_t uid)
61 * The only authentication which is able to change the user
62 * context on NT systems is the password authentication. So
63 * we deny all requsts for changing the user context if another
64 * authentication method is used.
65 * This may change in future when a special openssh
66 * subauthentication package is available.
68 if (is_winnt && !pwd_authenticated && geteuid() != uid)
74 int check_ntsec(const char *filename)
81 /* Windows 95/98/ME don't support file system security at all. */
85 /* Evaluate current CYGWIN settings. */
86 if ((cygwin = getenv("CYGWIN")) != NULL) {
87 if (strstr(cygwin, "ntea") && !strstr(cygwin, "nontea"))
89 if (strstr(cygwin, "ntsec") && !strstr(cygwin, "nontsec"))
94 * `ntea' is an emulation of POSIX attributes. It doesn't support
95 * real file level security as ntsec on NTFS file systems does
96 * but it supports FAT filesystems. `ntea' is minimum requirement
97 * for security checks.
103 * Retrieve file system flags. In Cygwin, file system flags are
104 * copied to f_type which has no meaning in Win32 itself.
106 if (statfs(filename, &fsstat))
110 * Only file systems supporting ACLs are able to set permissions.
111 * `ntsec' is the setting in Cygwin which switches using of NTFS
112 * ACLs to support POSIX permissions on files.
114 if (fsstat.f_type & FS_PERSISTENT_ACLS)
120 #endif /* HAVE_CYGWIN */