diff options
author | Damien Miller <djm@mindrot.org> | 2000-09-16 16:25:12 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-09-16 16:25:12 +1100 |
commit | b70b61f5fecf37d95e031414849745030fa8a420 (patch) | |
tree | 33a92aca5fde66bde1c3bb3cdabfc5a4c27e24ab /cygwin_util.c | |
parent | 52cbcbf0bb5ee685f77449f68c59926320bfe85f (diff) |
- (djm) Update CygWin support from Corinna Vinschen <vinschen@cygnus.com>
Diffstat (limited to 'cygwin_util.c')
-rw-r--r-- | cygwin_util.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cygwin_util.c b/cygwin_util.c index 13bd66347..88748c4fb 100644 --- a/cygwin_util.c +++ b/cygwin_util.c | |||
@@ -18,6 +18,10 @@ | |||
18 | #ifdef HAVE_CYGWIN | 18 | #ifdef HAVE_CYGWIN |
19 | #include <fcntl.h> | 19 | #include <fcntl.h> |
20 | #include <io.h> | 20 | #include <io.h> |
21 | #include <stdlib.h> | ||
22 | #include <sys/vfs.h> | ||
23 | #include <windows.h> | ||
24 | #define is_winnt (GetVersion() < 0x80000000) | ||
21 | 25 | ||
22 | int binary_open(const char *filename, int flags, mode_t mode) | 26 | int binary_open(const char *filename, int flags, mode_t mode) |
23 | { | 27 | { |
@@ -31,5 +35,67 @@ int binary_pipe(int fd[2]) | |||
31 | setmode (fd[0], O_BINARY); | 35 | setmode (fd[0], O_BINARY); |
32 | setmode (fd[1], O_BINARY); | 36 | setmode (fd[1], O_BINARY); |
33 | } | 37 | } |
38 | return ret; | ||
39 | } | ||
40 | |||
41 | int check_nt_auth (int pwd_authenticated, uid_t uid) | ||
42 | { | ||
43 | /* | ||
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. | ||
50 | */ | ||
51 | if (is_winnt && !pwd_authenticated && geteuid() != uid) | ||
52 | return 0; | ||
53 | return 1; | ||
54 | } | ||
55 | |||
56 | int check_ntsec (const char *filename) | ||
57 | { | ||
58 | char *cygwin; | ||
59 | int allow_ntea = 0; | ||
60 | int allow_ntsec = 0; | ||
61 | struct statfs fsstat; | ||
62 | |||
63 | /* Windows 95/98/ME don't support file system security at all. */ | ||
64 | if (!is_winnt) | ||
65 | return 0; | ||
66 | |||
67 | /* Evaluate current CYGWIN settings. */ | ||
68 | if ((cygwin = getenv("CYGWIN")) != NULL) { | ||
69 | if (strstr(cygwin, "ntea") && !strstr(cygwin, "nontea")) | ||
70 | allow_ntea = 1; | ||
71 | if (strstr(cygwin, "ntsec") && !strstr(cygwin, "nontsec")) | ||
72 | allow_ntsec = 1; | ||
73 | } | ||
74 | |||
75 | /* | ||
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. | ||
80 | */ | ||
81 | if (allow_ntea) | ||
82 | return 1; | ||
83 | |||
84 | /* | ||
85 | * Retrieve file system flags. In Cygwin, file system flags are | ||
86 | * copied to f_type which has no meaning in Win32 itself. | ||
87 | */ | ||
88 | if (statfs(filename, &fsstat)) | ||
89 | return 1; | ||
90 | |||
91 | /* | ||
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. | ||
95 | */ | ||
96 | if (fsstat.f_type & FS_PERSISTENT_ACLS) | ||
97 | return allow_ntsec; | ||
98 | |||
99 | return 0; | ||
34 | } | 100 | } |
35 | #endif | 101 | #endif |