svc_rpcsec_gss.c (194133) | svc_rpcsec_gss.c (194239) |
---|---|
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 --- 47 unchanged lines hidden (view full) --- 56 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 60 $Id: svc_auth_gss.c,v 1.27 2002/01/15 15:43:00 andros Exp $ 61 */ 62 63#include <sys/cdefs.h> | 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 --- 47 unchanged lines hidden (view full) --- 56 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 60 $Id: svc_auth_gss.c,v 1.27 2002/01/15 15:43:00 andros Exp $ 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c 194133 2009-06-13 23:16:40Z rmacklem $"); | 64__FBSDID("$FreeBSD: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c 194239 2009-06-15 14:44:55Z rmacklem $"); |
65 66#include <sys/param.h> 67#include <sys/systm.h> | 65 66#include <sys/param.h> 67#include <sys/systm.h> |
68#include <sys/jail.h> |
|
68#include <sys/kernel.h> 69#include <sys/kobj.h> 70#include <sys/lock.h> 71#include <sys/malloc.h> 72#include <sys/mbuf.h> 73#include <sys/mutex.h> | 69#include <sys/kernel.h> 70#include <sys/kobj.h> 71#include <sys/lock.h> 72#include <sys/malloc.h> 73#include <sys/mbuf.h> 74#include <sys/mutex.h> |
75#include <sys/proc.h> |
|
74#include <sys/sx.h> 75#include <sys/ucred.h> 76 77#include <rpc/rpc.h> 78#include <rpc/rpcsec_gss.h> 79 80#include "rpcsec_gss_int.h" 81 --- 34 unchanged lines hidden (view full) --- 116 CLIENT_NEW, /* still authenticating */ 117 CLIENT_ESTABLISHED, /* context established */ 118 CLIENT_STALE /* garbage to collect */ 119}; 120 121#define SVC_RPC_GSS_SEQWINDOW 128 122 123struct svc_rpc_gss_clientid { | 76#include <sys/sx.h> 77#include <sys/ucred.h> 78 79#include <rpc/rpc.h> 80#include <rpc/rpcsec_gss.h> 81 82#include "rpcsec_gss_int.h" 83 --- 34 unchanged lines hidden (view full) --- 118 CLIENT_NEW, /* still authenticating */ 119 CLIENT_ESTABLISHED, /* context established */ 120 CLIENT_STALE /* garbage to collect */ 121}; 122 123#define SVC_RPC_GSS_SEQWINDOW 128 124 125struct svc_rpc_gss_clientid { |
124 uint32_t ci_hostid; | 126 unsigned long ci_hostid; |
125 uint32_t ci_boottime; 126 uint32_t ci_id; 127}; 128 129struct svc_rpc_gss_client { 130 TAILQ_ENTRY(svc_rpc_gss_client) cl_link; 131 TAILQ_ENTRY(svc_rpc_gss_client) cl_alllink; 132 volatile u_int cl_refs; --- 367 unchanged lines hidden (view full) --- 500 } 501} 502 503static struct svc_rpc_gss_client * 504svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) 505{ 506 struct svc_rpc_gss_client *client; 507 struct svc_rpc_gss_client_list *list; | 127 uint32_t ci_boottime; 128 uint32_t ci_id; 129}; 130 131struct svc_rpc_gss_client { 132 TAILQ_ENTRY(svc_rpc_gss_client) cl_link; 133 TAILQ_ENTRY(svc_rpc_gss_client) cl_alllink; 134 volatile u_int cl_refs; --- 367 unchanged lines hidden (view full) --- 502 } 503} 504 505static struct svc_rpc_gss_client * 506svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) 507{ 508 struct svc_rpc_gss_client *client; 509 struct svc_rpc_gss_client_list *list; |
510 unsigned long hostid; |
|
508 509 rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); 510 | 511 512 rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); 513 |
514 getcredhostid(curthread->td_ucred, &hostid); |
|
511 if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) 512 return (NULL); 513 514 list = &svc_rpc_gss_client_hash[id->ci_id % CLIENT_HASH_SIZE]; 515 sx_xlock(&svc_rpc_gss_lock); 516 TAILQ_FOREACH(client, list, cl_link) { 517 if (client->cl_id.ci_id == id->ci_id) { 518 /* --- 12 unchanged lines hidden (view full) --- 531 return (client); 532} 533 534static struct svc_rpc_gss_client * 535svc_rpc_gss_create_client(void) 536{ 537 struct svc_rpc_gss_client *client; 538 struct svc_rpc_gss_client_list *list; | 515 if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) 516 return (NULL); 517 518 list = &svc_rpc_gss_client_hash[id->ci_id % CLIENT_HASH_SIZE]; 519 sx_xlock(&svc_rpc_gss_lock); 520 TAILQ_FOREACH(client, list, cl_link) { 521 if (client->cl_id.ci_id == id->ci_id) { 522 /* --- 12 unchanged lines hidden (view full) --- 535 return (client); 536} 537 538static struct svc_rpc_gss_client * 539svc_rpc_gss_create_client(void) 540{ 541 struct svc_rpc_gss_client *client; 542 struct svc_rpc_gss_client_list *list; |
543 unsigned long hostid; |
|
539 540 rpc_gss_log_debug("in svc_rpc_gss_create_client()"); 541 542 client = mem_alloc(sizeof(struct svc_rpc_gss_client)); 543 memset(client, 0, sizeof(struct svc_rpc_gss_client)); 544 refcount_init(&client->cl_refs, 1); 545 sx_init(&client->cl_lock, "GSS-client"); | 544 545 rpc_gss_log_debug("in svc_rpc_gss_create_client()"); 546 547 client = mem_alloc(sizeof(struct svc_rpc_gss_client)); 548 memset(client, 0, sizeof(struct svc_rpc_gss_client)); 549 refcount_init(&client->cl_refs, 1); 550 sx_init(&client->cl_lock, "GSS-client"); |
551 getcredhostid(curthread->td_ucred, &hostid); |
|
546 client->cl_id.ci_hostid = hostid; 547 client->cl_id.ci_boottime = boottime.tv_sec; 548 client->cl_id.ci_id = svc_rpc_gss_next_clientid++; 549 list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; 550 sx_xlock(&svc_rpc_gss_lock); 551 TAILQ_INSERT_HEAD(list, client, cl_link); 552 TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink); 553 svc_rpc_gss_client_count++; --- 932 unchanged lines hidden --- | 552 client->cl_id.ci_hostid = hostid; 553 client->cl_id.ci_boottime = boottime.tv_sec; 554 client->cl_id.ci_id = svc_rpc_gss_next_clientid++; 555 list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; 556 sx_xlock(&svc_rpc_gss_lock); 557 TAILQ_INSERT_HEAD(list, client, cl_link); 558 TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink); 559 svc_rpc_gss_client_count++; --- 932 unchanged lines hidden --- |