globus_xio_gsi_driver  4.4
 All Files Functions Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_xio_gsi.h
1 
2 #ifndef GLOBUS_I_XIO_GSI_H
3 #define GLOBUS_I_XIO_GSI_H
4 
5 #include <assert.h>
6 #include "globus_xio_driver.h"
7 #include "globus_xio_load.h"
8 #include "globus_common.h"
9 #include "globus_xio_gsi.h"
10 #include "gssapi.h"
11 #include "globus_gss_assist.h"
12 #include "globus_error_gssapi.h"
13 
14 #define GLOBUS_XIO_GSI_DRIVER_MODULE GlobusXIOMyModule(gsi)
15 
16 /* create/calculate a token header */
17 
18 #define GlobusLXIOGSICreateHeader(__iovec, __length) \
19  { \
20  *(((unsigned char *) (__iovec).iov_base)) = \
21  (unsigned char) (((__length) >> 24) & 0xff); \
22  *(((unsigned char *) (__iovec).iov_base)+1) = \
23  (unsigned char) (((__length) >> 16) & 0xff); \
24  *(((unsigned char *) (__iovec).iov_base)+2) = \
25  (unsigned char) (((__length) >> 8) & 0xff); \
26  *(((unsigned char *) (__iovec).iov_base)+3) = \
27  (unsigned char) (((__length) ) & 0xff); \
28  }
29 
30 /* get the token length from a wrapped token */
31 
32 #define GlobusLXIOGSIGetTokenLength(__iovec, __length) \
33  { \
34  globus_byte_t * c; \
35  c = (__iovec).iov_base; \
36  (__length) = ((globus_size_t) (*((c)++))) << 24; \
37  (__length) |= ((globus_size_t) (*((c)++))) << 16; \
38  (__length) |= ((globus_size_t) (*((c)++))) << 8; \
39  (__length) |= ((globus_size_t) (*((c)++))); \
40  }
41 
42 
43 /* macro for wrapping gssapi errors */
44 
45 #define GlobusXIOErrorWrapGSSFailed(failed_func, major_status, minor_status) \
46  globus_error_put( \
47  globus_error_wrap_gssapi_error( \
48  GLOBUS_XIO_GSI_DRIVER_MODULE, \
49  (major_status), \
50  (minor_status), \
51  GLOBUS_XIO_GSI_ERROR_WRAP_GSSAPI, \
52  __FILE__, \
53  _xio_name, \
54  __LINE__, \
55  _XIOSL("%s failed."), \
56  (failed_func)))
57 
58 
59 #define GlobusXioGSIErrorBadProtectionLevel() \
60  globus_error_put( \
61  globus_error_construct_error( \
62  GLOBUS_XIO_GSI_DRIVER_MODULE, \
63  GLOBUS_NULL, \
64  GLOBUS_XIO_GSI_ERROR_INVALID_PROTECTION_LEVEL, \
65  __FILE__, \
66  _xio_name, \
67  __LINE__, \
68  _XIOSL("Peer specified lower protection level")))
69 
70 #define GlobusXioGSIErrorTokenTooBig() \
71  globus_error_put( \
72  globus_error_construct_error( \
73  GLOBUS_XIO_GSI_DRIVER_MODULE, \
74  GLOBUS_NULL, \
75  GLOBUS_XIO_GSI_ERROR_TOKEN_TOO_BIG, \
76  __FILE__, \
77  _xio_name, \
78  __LINE__, \
79  _XIOSL("Token size exceeds limit. Usually happens when someone tries to establish a insecure connection with a secure endpoint, e.g. when someone sends plain HTTP to a HTTPS endpoint without first establishing a SSL session.")))
80 
81 #define GlobusXioGSIErrorEmptyTargetName() \
82  globus_error_put( \
83  globus_error_construct_error( \
84  GLOBUS_XIO_GSI_DRIVER_MODULE, \
85  GLOBUS_NULL, \
86  GLOBUS_XIO_GSI_ERROR_EMPTY_TARGET_NAME, \
87  __FILE__, \
88  _xio_name, \
89  __LINE__, \
90  _XIOSL("Identity authorization requested, but no target name set")))
91 
92 #define GlobusXioGSIErrorEmptyHostName() \
93  globus_error_put( \
94  globus_error_construct_error( \
95  GLOBUS_XIO_GSI_DRIVER_MODULE, \
96  GLOBUS_NULL, \
97  GLOBUS_XIO_GSI_ERROR_EMPTY_HOST_NAME, \
98  __FILE__, \
99  _xio_name, \
100  __LINE__, \
101  _XIOSL("Host authorization requested, but no host name set")))
102 
103 #define GlobusXioGSIAuthorizationFailed(_peer_name, _expected_name) \
104  globus_error_put( \
105  globus_error_construct_error( \
106  GLOBUS_XIO_GSI_DRIVER_MODULE, \
107  GLOBUS_NULL, \
108  GLOBUS_XIO_GSI_AUTHORIZATION_FAILED, \
109  __FILE__, \
110  _xio_name, \
111  __LINE__, \
112  _XIOSL("The peer authenticated as %s. Expected the peer " \
113  "to authenticate as %s"), (_peer_name), (_expected_name)))
114 
115 
116 /* XIO debug stuff */
117 
118 GlobusDebugDeclare(GLOBUS_XIO_GSI);
119 
120 #define GLOBUS_XIO_GSI_DEBUG_TRACE 4
121 #define GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE 8
122 
123 #define GlobusXIOGSIDebugPrintf(level, message) \
124  GlobusDebugPrintf(GLOBUS_XIO_GSI, level, message)
125 
126 #define GlobusXIOGSIDebugEnter() \
127  GlobusXIOGSIDebugPrintf( \
128  GLOBUS_XIO_GSI_DEBUG_TRACE, \
129  (_XIOSL("[%s] Entering\n"), _xio_name))
130 
131 #define GlobusXIOGSIDebugExit() \
132  GlobusXIOGSIDebugPrintf( \
133  GLOBUS_XIO_GSI_DEBUG_TRACE, \
134  (_XIOSL("[%s] Exiting\n"), _xio_name))
135 
136 #define GlobusXIOGSIDebugExitWithError() \
137  GlobusXIOGSIDebugPrintf( \
138  GLOBUS_XIO_GSI_DEBUG_TRACE, \
139  (_XIOSL("[%s] Exiting with error\n"), _xio_name))
140 
141 #define GlobusXIOGSIDebugInternalEnter() \
142  GlobusXIOGSIDebugPrintf( \
143  GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
144  (_XIOSL("[%s] I Entering\n"), _xio_name))
145 
146 #define GlobusXIOGSIDebugInternalExit() \
147  GlobusXIOGSIDebugPrintf( \
148  GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
149  (_XIOSL("[%s] I Exiting\n"), _xio_name))
150 
151 #define GlobusXIOGSIDebugInternalExitWithError() \
152  GlobusXIOGSIDebugPrintf( \
153  GLOBUS_XIO_GSI_DEBUG_INTERNAL_TRACE, \
154  (_XIOSL("[%s] I Exiting with error\n"), _xio_name))
155 
156 /*
157  * attribute structure
158  */
159 typedef struct
160 {
161  gss_cred_id_t credential;
162  OM_uint32 req_flags;
163  OM_uint32 time_req;
164  gss_OID mech_type;
165  gss_channel_bindings_t channel_bindings;
166  globus_bool_t wrap_tokens;
167  globus_size_t buffer_size;
169  gss_name_t target_name;
170  globus_bool_t init;
172  char * credentials_dir;
173  unsigned char * alpn_list;
174  size_t alpn_list_len;
175 } globus_l_attr_t;
176 
177 /*
178  * driver handle structure
179  */
180 
181 typedef struct
182 {
183  globus_l_attr_t * attr;
184  OM_uint32 ret_flags;
185  OM_uint32 time_rec;
186  OM_uint32 max_wrap_size;
187  gss_ctx_id_t context;
188  gss_cred_id_t delegated_cred;
189  gss_cred_id_t credential;
190  gss_OID mech_used;
191  gss_name_t peer_name;
192  gss_name_t local_name;
193  size_t write_iovec_count;
194  globus_xio_iovec_t * write_iovec;
195  globus_bool_t frame_writes;
196  size_t write_header_count;
197  unsigned char * write_headers;
198  globus_size_t bytes_written;
199  globus_xio_iovec_t read_iovec[2];
200  unsigned char header[4];
201  unsigned char * read_buffer;
202  globus_size_t bytes_read;
203  globus_xio_iovec_t * user_iovec;
204  size_t user_iovec_count;
205  size_t user_iovec_index;
206  size_t user_iovec_offset;
207  unsigned char * unwrapped_buffer;
208  globus_size_t unwrapped_buffer_length;
209  globus_size_t unwrapped_buffer_offset;
210  globus_size_t bytes_returned;
211  globus_bool_t done;
212  globus_object_t * result_obj;
213  globus_bool_t eof;
214  int connection_id;
215  globus_xio_driver_handle_t xio_driver_handle;
216  char * host_name;
217  gss_cred_id_t *cred_array;
218  size_t cred_array_length;
219 } globus_l_handle_t;
220 
221 /*
222  * Structure used for passing information needed for the init/accept delegation
223  * operations
224  */
225 
226 typedef struct
227 {
228  globus_l_handle_t * xio_handle;
229  void * user_arg;
231  init_callback;
233  accept_callback;
234  gss_cred_id_t cred;
235  gss_OID_set restriction_oids;
236  gss_buffer_set_t restriction_buffers;
237  OM_uint32 time_req;
238  OM_uint32 time_rec;
239  globus_xio_iovec_t iovec[2];
240  unsigned char header[4];
241  globus_bool_t done;
242  globus_object_t * result_obj;
243  globus_bool_t reading_header;
244 } globus_l_delegation_handle_t;
245 
246 typedef struct
247 {
248  globus_bool_t done;
249  globus_result_t result;
250  globus_mutex_t mutex;
251  globus_cond_t cond;
252  OM_uint32 * time_rec;
253  gss_cred_id_t * cred;
254 } globus_l_xio_gsi_delegation_arg_t;
255 
256 #endif
257 
XIO GSI Driver.
void(* globus_xio_gsi_delegation_init_callback_t)(globus_result_t result, void *user_arg)
Definition: globus_xio_gsi.h:363
globus_xio_gsi_authorization_mode_t
Definition: globus_xio_gsi.h:341
globus_xio_gsi_protection_level_t
Definition: globus_xio_gsi.h:296
void(* globus_xio_gsi_delegation_accept_callback_t)(globus_result_t result, gss_cred_id_t delegated_cred, OM_uint32 time_rec, void *user_arg)
Definition: globus_xio_gsi.h:371