rpcsec_gss.h (e57c2b130f2cd40967cf20698d376cc5ada95871) | rpcsec_gss.h (7e7fd7d177c641879ad881c0d9011220fc384845) |
---|---|
1/*- 2 * Copyright (c) 2008 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 127 unchanged lines hidden (view full) --- 136 * Values for rpc_gss_error 137 */ 138#define RPC_GSS_ER_SUCCESS 0 /* no error */ 139#define RPC_GSS_ER_SYSTEMERROR 1 /* system error */ 140 141__BEGIN_DECLS 142 143#ifdef _KERNEL | 1/*- 2 * Copyright (c) 2008 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 127 unchanged lines hidden (view full) --- 136 * Values for rpc_gss_error 137 */ 138#define RPC_GSS_ER_SUCCESS 0 /* no error */ 139#define RPC_GSS_ER_SYSTEMERROR 1 /* system error */ 140 141__BEGIN_DECLS 142 143#ifdef _KERNEL |
144/* 145 * Set up a structure of entry points for the kgssapi module and inline 146 * functions named rpc_gss_XXX_call() to use them, so that the kgssapi 147 * module doesn't need to be loaded for the NFS modules to work using 148 * AUTH_SYS. The kgssapi modules will be loaded by the gssd(8) daemon 149 * when it is started up and the entry points will then be filled in. 150 */ 151typedef AUTH *rpc_gss_secfind_ftype(CLIENT *clnt, struct ucred *cred, 152 const char *principal, gss_OID mech_oid, 153 rpc_gss_service_t service); 154typedef void rpc_gss_secpurge_ftype(CLIENT *clnt); 155typedef AUTH *rpc_gss_seccreate_ftype(CLIENT *clnt, struct ucred *cred, 156 const char *principal, const char *mechanism, 157 rpc_gss_service_t service, const char *qop, 158 rpc_gss_options_req_t *options_req, 159 rpc_gss_options_ret_t *options_ret); 160typedef bool_t rpc_gss_set_defaults_ftype(AUTH *auth, 161 rpc_gss_service_t service, const char *qop); 162typedef int rpc_gss_max_data_length_ftype(AUTH *handle, 163 int max_tp_unit_len); 164typedef void rpc_gss_get_error_ftype(rpc_gss_error_t *error); 165typedef bool_t rpc_gss_mech_to_oid_ftype(const char *mech, gss_OID *oid_ret); 166typedef bool_t rpc_gss_oid_to_mech_ftype(gss_OID oid, const char **mech_ret); 167typedef bool_t rpc_gss_qop_to_num_ftype(const char *qop, const char *mech, 168 u_int *num_ret); 169typedef const char **rpc_gss_get_mechanisms_ftype(void); 170typedef bool_t rpc_gss_get_versions_ftype(u_int *vers_hi, u_int *vers_lo); 171typedef bool_t rpc_gss_is_installed_ftype(const char *mech); 172typedef bool_t rpc_gss_set_svc_name_ftype(const char *principal, 173 const char *mechanism, u_int req_time, u_int program, 174 u_int version); 175typedef void rpc_gss_clear_svc_name_ftype(u_int program, u_int version); 176typedef bool_t rpc_gss_getcred_ftype(struct svc_req *req, 177 rpc_gss_rawcred_t **rcred, 178 rpc_gss_ucred_t **ucred, void **cookie); 179typedef bool_t rpc_gss_set_callback_ftype(rpc_gss_callback_t *cb); 180typedef void rpc_gss_clear_callback_ftype(rpc_gss_callback_t *cb); 181typedef bool_t rpc_gss_get_principal_name_ftype(rpc_gss_principal_t *principal, 182 const char *mech, const char *name, const char *node, 183 const char *domain); 184typedef int rpc_gss_svc_max_data_length_ftype(struct svc_req *req, 185 int max_tp_unit_len); 186 187struct rpc_gss_entries { 188 rpc_gss_secfind_ftype *rpc_gss_secfind; 189 rpc_gss_secpurge_ftype *rpc_gss_secpurge; 190 rpc_gss_seccreate_ftype *rpc_gss_seccreate; 191 rpc_gss_set_defaults_ftype *rpc_gss_set_defaults; 192 rpc_gss_max_data_length_ftype *rpc_gss_max_data_length; 193 rpc_gss_get_error_ftype *rpc_gss_get_error; 194 rpc_gss_mech_to_oid_ftype *rpc_gss_mech_to_oid; 195 rpc_gss_oid_to_mech_ftype *rpc_gss_oid_to_mech; 196 rpc_gss_qop_to_num_ftype *rpc_gss_qop_to_num; 197 rpc_gss_get_mechanisms_ftype *rpc_gss_get_mechanisms; 198 rpc_gss_get_versions_ftype *rpc_gss_get_versions; 199 rpc_gss_is_installed_ftype *rpc_gss_is_installed; 200 rpc_gss_set_svc_name_ftype *rpc_gss_set_svc_name; 201 rpc_gss_clear_svc_name_ftype *rpc_gss_clear_svc_name; 202 rpc_gss_getcred_ftype *rpc_gss_getcred; 203 rpc_gss_set_callback_ftype *rpc_gss_set_callback; 204 rpc_gss_clear_callback_ftype *rpc_gss_clear_callback; 205 rpc_gss_get_principal_name_ftype *rpc_gss_get_principal_name; 206 rpc_gss_svc_max_data_length_ftype *rpc_gss_svc_max_data_length; 207}; 208extern struct rpc_gss_entries rpc_gss_entries; 209 210/* Functions to access the entry points. */ 211static __inline AUTH * 212rpc_gss_secfind_call(CLIENT *clnt, struct ucred *cred, const char *principal, 213 gss_OID mech_oid, rpc_gss_service_t service) 214{ 215 AUTH *ret = NULL; 216 217 if (rpc_gss_entries.rpc_gss_secfind != NULL) 218 ret = (*rpc_gss_entries.rpc_gss_secfind)(clnt, cred, principal, 219 mech_oid, service); 220 return (ret); 221} 222 223static __inline void 224rpc_gss_secpurge_call(CLIENT *clnt) 225{ 226 227 if (rpc_gss_entries.rpc_gss_secpurge != NULL) 228 (*rpc_gss_entries.rpc_gss_secpurge)(clnt); 229} 230 231static __inline AUTH * 232rpc_gss_seccreate_call(CLIENT *clnt, struct ucred *cred, const char *principal, 233 const char *mechanism, rpc_gss_service_t service, const char *qop, 234 rpc_gss_options_req_t *options_req, rpc_gss_options_ret_t *options_ret) 235{ 236 AUTH *ret = NULL; 237 238 if (rpc_gss_entries.rpc_gss_seccreate != NULL) 239 ret = (*rpc_gss_entries.rpc_gss_seccreate)(clnt, cred, 240 principal, mechanism, service, qop, options_req, 241 options_ret); 242 return (ret); 243} 244 245static __inline bool_t 246rpc_gss_set_defaults_call(AUTH *auth, rpc_gss_service_t service, 247 const char *qop) 248{ 249 bool_t ret = 1; 250 251 if (rpc_gss_entries.rpc_gss_set_defaults != NULL) 252 ret = (*rpc_gss_entries.rpc_gss_set_defaults)(auth, service, 253 qop); 254 return (ret); 255} 256 257static __inline int 258rpc_gss_max_data_length_call(AUTH *handle, int max_tp_unit_len) 259{ 260 int ret = 0; 261 262 if (rpc_gss_entries.rpc_gss_max_data_length != NULL) 263 ret = (*rpc_gss_entries.rpc_gss_max_data_length)(handle, 264 max_tp_unit_len); 265 return (ret); 266} 267 268static __inline void 269rpc_gss_get_error_call(rpc_gss_error_t *error) 270{ 271 272 if (rpc_gss_entries.rpc_gss_get_error != NULL) 273 (*rpc_gss_entries.rpc_gss_get_error)(error); 274} 275 276static __inline bool_t 277rpc_gss_mech_to_oid_call(const char *mech, gss_OID *oid_ret) 278{ 279 bool_t ret = 1; 280 281 if (rpc_gss_entries.rpc_gss_mech_to_oid != NULL) 282 ret = (*rpc_gss_entries.rpc_gss_mech_to_oid)(mech, oid_ret); 283 return (ret); 284} 285 286static __inline bool_t 287rpc_gss_oid_to_mech_call(gss_OID oid, const char **mech_ret) 288{ 289 bool_t ret = 1; 290 291 if (rpc_gss_entries.rpc_gss_oid_to_mech != NULL) 292 ret = (*rpc_gss_entries.rpc_gss_oid_to_mech)(oid, mech_ret); 293 return (ret); 294} 295 296static __inline bool_t 297rpc_gss_qop_to_num_call(const char *qop, const char *mech, u_int *num_ret) 298{ 299 bool_t ret = 1; 300 301 if (rpc_gss_entries.rpc_gss_qop_to_num != NULL) 302 ret = (*rpc_gss_entries.rpc_gss_qop_to_num)(qop, mech, num_ret); 303 return (ret); 304} 305 306static __inline const char ** 307rpc_gss_get_mechanisms_call(void) 308{ 309 const char **ret = NULL; 310 311 if (rpc_gss_entries.rpc_gss_get_mechanisms != NULL) 312 ret = (*rpc_gss_entries.rpc_gss_get_mechanisms)(); 313 return (ret); 314} 315 316static __inline bool_t 317rpc_gss_get_versions_call(u_int *vers_hi, u_int *vers_lo) 318{ 319 bool_t ret = 1; 320 321 if (rpc_gss_entries.rpc_gss_get_versions != NULL) 322 ret = (*rpc_gss_entries.rpc_gss_get_versions)(vers_hi, vers_lo); 323 return (ret); 324} 325 326static __inline bool_t 327rpc_gss_is_installed_call(const char *mech) 328{ 329 bool_t ret = 1; 330 331 if (rpc_gss_entries.rpc_gss_is_installed != NULL) 332 ret = (*rpc_gss_entries.rpc_gss_is_installed)(mech); 333 return (ret); 334} 335 336static __inline bool_t 337rpc_gss_set_svc_name_call(const char *principal, const char *mechanism, 338 u_int req_time, u_int program, u_int version) 339{ 340 bool_t ret = 1; 341 342 if (rpc_gss_entries.rpc_gss_set_svc_name != NULL) 343 ret = (*rpc_gss_entries.rpc_gss_set_svc_name)(principal, 344 mechanism, req_time, program, version); 345 return (ret); 346} 347 348static __inline void 349rpc_gss_clear_svc_name_call(u_int program, u_int version) 350{ 351 352 if (rpc_gss_entries.rpc_gss_clear_svc_name != NULL) 353 (*rpc_gss_entries.rpc_gss_clear_svc_name)(program, version); 354} 355 356static __inline bool_t 357rpc_gss_getcred_call(struct svc_req *req, rpc_gss_rawcred_t **rcred, 358 rpc_gss_ucred_t **ucred, void **cookie) 359{ 360 bool_t ret = 1; 361 362 if (rpc_gss_entries.rpc_gss_getcred != NULL) 363 ret = (*rpc_gss_entries.rpc_gss_getcred)(req, rcred, ucred, 364 cookie); 365 return (ret); 366} 367 368static __inline bool_t 369rpc_gss_set_callback_call(rpc_gss_callback_t *cb) 370{ 371 bool_t ret = 1; 372 373 if (rpc_gss_entries.rpc_gss_set_callback != NULL) 374 ret = (*rpc_gss_entries.rpc_gss_set_callback)(cb); 375 return (ret); 376} 377 378static __inline void 379rpc_gss_clear_callback_call(rpc_gss_callback_t *cb) 380{ 381 382 if (rpc_gss_entries.rpc_gss_clear_callback != NULL) 383 (*rpc_gss_entries.rpc_gss_clear_callback)(cb); 384} 385 386static __inline bool_t 387rpc_gss_get_principal_name_call(rpc_gss_principal_t *principal, 388 const char *mech, const char *name, const char *node, const char *domain) 389{ 390 bool_t ret = 1; 391 392 if (rpc_gss_entries.rpc_gss_get_principal_name != NULL) 393 ret = (*rpc_gss_entries.rpc_gss_get_principal_name)(principal, 394 mech, name, node, domain); 395 return (ret); 396} 397 398static __inline int 399rpc_gss_svc_max_data_length_call(struct svc_req *req, int max_tp_unit_len) 400{ 401 int ret = 0; 402 403 if (rpc_gss_entries.rpc_gss_svc_max_data_length != NULL) 404 ret = (*rpc_gss_entries.rpc_gss_svc_max_data_length)(req, 405 max_tp_unit_len); 406 return (ret); 407} 408 |
|
144AUTH *rpc_gss_secfind(CLIENT *clnt, struct ucred *cred, 145 const char *principal, gss_OID mech_oid, rpc_gss_service_t service); 146void rpc_gss_secpurge(CLIENT *clnt); 147#endif 148AUTH *rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred, 149 const char *principal, const char *mechanism, rpc_gss_service_t service, 150 const char *qop, rpc_gss_options_req_t *options_req, 151 rpc_gss_options_ret_t *options_ret); --- 38 unchanged lines hidden --- | 409AUTH *rpc_gss_secfind(CLIENT *clnt, struct ucred *cred, 410 const char *principal, gss_OID mech_oid, rpc_gss_service_t service); 411void rpc_gss_secpurge(CLIENT *clnt); 412#endif 413AUTH *rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred, 414 const char *principal, const char *mechanism, rpc_gss_service_t service, 415 const char *qop, rpc_gss_options_req_t *options_req, 416 rpc_gss_options_ret_t *options_ret); --- 38 unchanged lines hidden --- |