1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
*/
/*
* rpcsec_gss.h, RPCSEC_GSS security service interface.
*/
#ifndef _RPCSEC_GSS_H
#define _RPCSEC_GSS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <rpc/auth.h>
#include <rpc/clnt.h>
#include <gssapi/gssapi.h>
/*
* Interface definitions.
*/
#define MAX_NAME_LEN 64
#define MAX_GSS_MECH 128
#define MAX_GSS_NAME 128
typedef enum {
rpc_gss_svc_default = 0,
rpc_gss_svc_none = 1,
rpc_gss_svc_integrity = 2,
rpc_gss_svc_privacy = 3
} rpc_gss_service_t;
/*
* GSS-API based security mechanism type specified as
* object identifiers (OIDs).
* This type is derived from gss_OID_desc/gss_OID.
*/
#define rpc_gss_OID_s gss_OID_desc_struct
typedef struct rpc_gss_OID_s rpc_gss_OID_desc, *rpc_gss_OID;
/*
* Interface data.
* This is already suitable for both LP64 and ILP32.
*/
typedef struct rpc_gss_principal {
int len;
char name[1];
} *rpc_gss_principal_t;
typedef struct {
int req_flags;
int time_req;
gss_cred_id_t my_cred;
gss_channel_bindings_t input_channel_bindings;
} rpc_gss_options_req_t;
typedef struct {
int major_status;
int minor_status;
uint_t rpcsec_version;
int ret_flags;
int time_ret;
gss_ctx_id_t gss_context;
#ifdef _KERNEL
rpc_gss_OID actual_mechanism;
#else
char actual_mechanism[MAX_GSS_MECH];
#endif
} rpc_gss_options_ret_t;
/*
* raw credentials
*/
typedef struct {
uint_t version;
#ifdef _KERNEL
rpc_gss_OID mechanism;
uint_t qop;
#else
char *mechanism;
char *qop;
#endif
rpc_gss_principal_t client_principal;
char *svc_principal; /* service@server, e.g. nfs@caribe */
rpc_gss_service_t service;
} rpc_gss_rawcred_t;
/*
* unix credentials
*/
typedef struct {
uid_t uid;
gid_t gid;
short gidlen;
gid_t *gidlist;
} rpc_gss_ucred_t;
/*
* for callback routine
*/
typedef struct {
uint_t program;
uint_t version;
bool_t (*callback)();
} rpc_gss_callback_t;
/*
* lock used for the callback routine
*/
typedef struct {
bool_t locked;
rpc_gss_rawcred_t *raw_cred;
} rpc_gss_lock_t;
/*
* This is for user RPC applications.
* Structure used to fetch the error code when one of
* the rpc_gss_* routines fails.
*/
typedef struct {
int rpc_gss_error;
int system_error;
} rpc_gss_error_t;
#define RPC_GSS_ER_SUCCESS 0 /* no error */
#define RPC_GSS_ER_SYSTEMERROR 1 /* system error */
#ifdef _SYSCALL32
struct gss_clnt_data32 {
gss_OID_desc32 mechanism;
rpc_gss_service_t service;
char uname[MAX_NAME_LEN]; /* server's service name */
char inst[MAX_NAME_LEN]; /* server's instance name */
char realm[MAX_NAME_LEN]; /* server's realm */
uint_t qop;
};
#endif
/*
* This is for Kernel RPC applications.
* RPCSEC_GSS flavor specific data in sec_data opaque field.
*/
typedef struct gss_clnt_data {
rpc_gss_OID_desc mechanism;
rpc_gss_service_t service;
char uname[MAX_NAME_LEN]; /* server's service name */
char inst[MAX_NAME_LEN]; /* server's instance name */
char realm[MAX_NAME_LEN]; /* server's realm */
uint_t qop;
} gss_clntdata_t;
struct svc_req;
/*
* KERNEL rpc_gss_* interfaces.
*/
#ifdef _KERNEL
int rpc_gss_secget(CLIENT *, char *, rpc_gss_OID,
rpc_gss_service_t, uint_t, rpc_gss_options_req_t *,
rpc_gss_options_ret_t *, void *, cred_t *, AUTH **);
void rpc_gss_secfree(AUTH *);
int rpc_gss_seccreate(CLIENT *, char *, rpc_gss_OID,
rpc_gss_service_t, uint_t, rpc_gss_options_req_t *,
rpc_gss_options_ret_t *, cred_t *, AUTH **);
int rpc_gss_revauth(uid_t, rpc_gss_OID);
void rpc_gss_secpurge(void *);
enum auth_stat __svcrpcsec_gss(struct svc_req *,
struct rpc_msg *, bool_t *);
bool_t rpc_gss_set_defaults(AUTH *, rpc_gss_service_t, uint_t);
rpc_gss_service_t rpc_gss_get_service_type(AUTH *);
#else
/*
* USER rpc_gss_* public interfaces
*/
AUTH *
rpc_gss_seccreate(
CLIENT *clnt, /* associated client handle */
char *principal, /* server service principal */
char *mechanism, /* security mechanism */
rpc_gss_service_t service_type, /* security service */
char *qop, /* requested QOP */
rpc_gss_options_req_t *options_req, /* requested options */
rpc_gss_options_ret_t *options_ret /* returned options */
);
bool_t
rpc_gss_get_principal_name(
rpc_gss_principal_t *principal,
char *mechanism,
char *user_name,
char *node,
char *secdomain
);
char **rpc_gss_get_mechanisms();
char **rpc_gss_get_mech_info(
char *mechanism,
rpc_gss_service_t *service
);
bool_t
rpc_gss_is_installed(
char *mechanism
);
bool_t
rpc_gss_mech_to_oid(
char *mech,
rpc_gss_OID *oid
);
bool_t
rpc_gss_qop_to_num(
char *qop,
char *mech,
uint_t *num
);
bool_t
rpc_gss_set_svc_name(
char *principal,
char *mechanism,
uint_t req_time,
uint_t program,
uint_t version
);
bool_t
rpc_gss_set_defaults(
AUTH *auth,
rpc_gss_service_t service,
char *qop
);
void
rpc_gss_get_error(
rpc_gss_error_t *error
);
/*
* User level private interfaces
*/
enum auth_stat __svcrpcsec_gss();
bool_t __rpc_gss_wrap();
bool_t __rpc_gss_unwrap();
#endif
/*
* USER and KERNEL rpc_gss_* interfaces.
*/
bool_t
rpc_gss_set_callback(
rpc_gss_callback_t *cb
);
bool_t
rpc_gss_getcred(
struct svc_req *req,
rpc_gss_rawcred_t **rcred,
rpc_gss_ucred_t **ucred,
void **cookie
);
int
rpc_gss_max_data_length(
AUTH *rpcgss_handle,
int max_tp_unit_len
);
int
rpc_gss_svc_max_data_length(
struct svc_req *req,
int max_tp_unit_len
);
bool_t
rpc_gss_get_versions(
uint_t *vers_hi,
uint_t *vers_lo
);
#define RPCSEC_GSS_REFRESH_ATTEMPTS 20
/*
* Protocol data.
*
* The reason to put these definition in this header file
* is for 2.6 snoop to handle the RPCSEC_GSS protocol
* interpretation.
*/
#define RPCSEC_GSS_DATA 0
#define RPCSEC_GSS_INIT 1
#define RPCSEC_GSS_CONTINUE_INIT 2
#define RPCSEC_GSS_DESTROY 3
#define RPCSEC_GSS_VERSION 1
#ifdef __cplusplus
}
#endif
#endif /* !_RPCSEC_GSS_H */
|