bsd-cygwin_util.c (124208) | bsd-cygwin_util.c (128456) |
---|---|
1/* 2 * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> 3 * 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. --- 15 unchanged lines hidden (view full) --- 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 30#include "includes.h" 31 | 1/* 2 * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> 3 * 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. --- 15 unchanged lines hidden (view full) --- 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 30#include "includes.h" 31 |
32RCSID("$Id: bsd-cygwin_util.c,v 1.11 2003/08/07 06:23:43 dtucker Exp $"); | 32RCSID("$Id: bsd-cygwin_util.c,v 1.12 2004/04/18 11:15:45 djm Exp $"); |
33 34#ifdef HAVE_CYGWIN 35 36#include <fcntl.h> 37#include <stdlib.h> 38#include <sys/utsname.h> 39#include <sys/vfs.h> 40#include <windows.h> --- 31 unchanged lines hidden (view full) --- 72 setmode(fd[0], O_BINARY); 73 setmode(fd[1], O_BINARY); 74 } 75 return (ret); 76} 77 78#define HAS_CREATE_TOKEN 1 79#define HAS_NTSEC_BY_DEFAULT 2 | 33 34#ifdef HAVE_CYGWIN 35 36#include <fcntl.h> 37#include <stdlib.h> 38#include <sys/utsname.h> 39#include <sys/vfs.h> 40#include <windows.h> --- 31 unchanged lines hidden (view full) --- 72 setmode(fd[0], O_BINARY); 73 setmode(fd[1], O_BINARY); 74 } 75 return (ret); 76} 77 78#define HAS_CREATE_TOKEN 1 79#define HAS_NTSEC_BY_DEFAULT 2 |
80#define HAS_CREATE_TOKEN_WO_NTSEC 3 |
|
80 81static int 82has_capability(int what) 83{ 84 static int inited; 85 static int has_create_token; 86 static int has_ntsec_by_default; | 81 82static int 83has_capability(int what) 84{ 85 static int inited; 86 static int has_create_token; 87 static int has_ntsec_by_default; |
88 static int has_create_token_wo_ntsec; |
|
87 88 /* 89 * has_capability() basically calls uname() and checks if 90 * specific capabilities of Cygwin can be evaluated from that. 91 * This simplifies the calling functions which only have to ask 92 * for a capability using has_capability() instead of having 93 * to figure that out by themselves. 94 */ --- 13 unchanged lines hidden (view full) --- 108 &api_minor_version); 109 } 110 if (major_high > 1 || 111 (major_high == 1 && (major_low > 3 || 112 (major_low == 3 && minor >= 2)))) 113 has_create_token = 1; 114 if (api_major_version > 0 || api_minor_version >= 56) 115 has_ntsec_by_default = 1; | 89 90 /* 91 * has_capability() basically calls uname() and checks if 92 * specific capabilities of Cygwin can be evaluated from that. 93 * This simplifies the calling functions which only have to ask 94 * for a capability using has_capability() instead of having 95 * to figure that out by themselves. 96 */ --- 13 unchanged lines hidden (view full) --- 110 &api_minor_version); 111 } 112 if (major_high > 1 || 113 (major_high == 1 && (major_low > 3 || 114 (major_low == 3 && minor >= 2)))) 115 has_create_token = 1; 116 if (api_major_version > 0 || api_minor_version >= 56) 117 has_ntsec_by_default = 1; |
118 if (major_high > 1 || 119 (major_high == 1 && major_low >= 5)) 120 has_create_token_wo_ntsec = 1; |
|
116 inited = 1; 117 } 118 } 119 switch (what) { 120 case HAS_CREATE_TOKEN: 121 return (has_create_token); 122 case HAS_NTSEC_BY_DEFAULT: 123 return (has_ntsec_by_default); | 121 inited = 1; 122 } 123 } 124 switch (what) { 125 case HAS_CREATE_TOKEN: 126 return (has_create_token); 127 case HAS_NTSEC_BY_DEFAULT: 128 return (has_ntsec_by_default); |
129 case HAS_CREATE_TOKEN_WO_NTSEC: 130 return (has_create_token_wo_ntsec); |
|
124 } 125 return (0); 126} 127 128int 129check_nt_auth(int pwd_authenticated, struct passwd *pw) 130{ 131 /* --- 14 unchanged lines hidden (view full) --- 146 if (is_winnt) { 147 if (has_create_token < 0) { 148 char *cygwin = getenv("CYGWIN"); 149 150 has_create_token = 0; 151 if (has_capability(HAS_CREATE_TOKEN) && 152 (ntsec_on(cygwin) || 153 (has_capability(HAS_NTSEC_BY_DEFAULT) && | 131 } 132 return (0); 133} 134 135int 136check_nt_auth(int pwd_authenticated, struct passwd *pw) 137{ 138 /* --- 14 unchanged lines hidden (view full) --- 153 if (is_winnt) { 154 if (has_create_token < 0) { 155 char *cygwin = getenv("CYGWIN"); 156 157 has_create_token = 0; 158 if (has_capability(HAS_CREATE_TOKEN) && 159 (ntsec_on(cygwin) || 160 (has_capability(HAS_NTSEC_BY_DEFAULT) && |
154 !ntsec_off(cygwin)))) | 161 !ntsec_off(cygwin)) || 162 has_capability(HAS_CREATE_TOKEN_WO_NTSEC))) |
155 has_create_token = 1; 156 } 157 if (has_create_token < 1 && 158 !pwd_authenticated && geteuid() != pw->pw_uid) 159 return (0); 160 } 161 return (1); 162} --- 69 unchanged lines hidden --- | 163 has_create_token = 1; 164 } 165 if (has_create_token < 1 && 166 !pwd_authenticated && geteuid() != pw->pw_uid) 167 return (0); 168 } 169 return (1); 170} --- 69 unchanged lines hidden --- |