Deleted Added
full compact
gss_impl.c (225617) gss_impl.c (244370)
1/*-
2 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3 * Authors: Doug Rabson <dfr@rabson.org>
4 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3 * Authors: Doug Rabson <dfr@rabson.org>
4 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/kgssapi/gss_impl.c 225617 2011-09-16 13:58:51Z kmacy $");
29__FBSDID("$FreeBSD: head/sys/kgssapi/gss_impl.c 244370 2012-12-18 00:25:48Z rmacklem $");
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/kobj.h>
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/kobj.h>
34#include <sys/lock.h>
34#include <sys/malloc.h>
35#include <sys/module.h>
35#include <sys/malloc.h>
36#include <sys/module.h>
37#include <sys/mutex.h>
36#include <sys/priv.h>
37#include <sys/syscall.h>
38#include <sys/sysent.h>
39#include <sys/sysproto.h>
40
41#include <kgssapi/gssapi.h>
42#include <kgssapi/gssapi_impl.h>
43#include <rpc/rpc.h>

--- 10 unchanged lines hidden (view full) ---

54 */
55static int gssd_syscall_offset = SYS_gssd_syscall;
56static struct sysent gssd_syscall_prev_sysent;
57MAKE_SYSENT(gssd_syscall);
58static bool_t gssd_syscall_registered = FALSE;
59
60struct kgss_mech_list kgss_mechs;
61CLIENT *kgss_gssd_handle;
38#include <sys/priv.h>
39#include <sys/syscall.h>
40#include <sys/sysent.h>
41#include <sys/sysproto.h>
42
43#include <kgssapi/gssapi.h>
44#include <kgssapi/gssapi_impl.h>
45#include <rpc/rpc.h>

--- 10 unchanged lines hidden (view full) ---

56 */
57static int gssd_syscall_offset = SYS_gssd_syscall;
58static struct sysent gssd_syscall_prev_sysent;
59MAKE_SYSENT(gssd_syscall);
60static bool_t gssd_syscall_registered = FALSE;
61
62struct kgss_mech_list kgss_mechs;
63CLIENT *kgss_gssd_handle;
64struct mtx kgss_gssd_lock;
62
63static void
64kgss_init(void *dummy)
65{
66 int error;
67
68 LIST_INIT(&kgss_mechs);
69 error = syscall_register(&gssd_syscall_offset, &gssd_syscall_sysent,

--- 17 unchanged lines hidden (view full) ---

87
88int
89sys_gssd_syscall(struct thread *td, struct gssd_syscall_args *uap)
90{
91 struct sockaddr_un sun;
92 struct netconfig *nconf;
93 char path[MAXPATHLEN];
94 int error;
65
66static void
67kgss_init(void *dummy)
68{
69 int error;
70
71 LIST_INIT(&kgss_mechs);
72 error = syscall_register(&gssd_syscall_offset, &gssd_syscall_sysent,

--- 17 unchanged lines hidden (view full) ---

90
91int
92sys_gssd_syscall(struct thread *td, struct gssd_syscall_args *uap)
93{
94 struct sockaddr_un sun;
95 struct netconfig *nconf;
96 char path[MAXPATHLEN];
97 int error;
98 CLIENT *cl, *oldcl;
95
96 error = priv_check(td, PRIV_NFS_DAEMON);
97 if (error)
98 return (error);
99
99
100 error = priv_check(td, PRIV_NFS_DAEMON);
101 if (error)
102 return (error);
103
100 if (kgss_gssd_handle)
101 CLNT_DESTROY(kgss_gssd_handle);
102
103 error = copyinstr(uap->path, path, sizeof(path), NULL);
104 if (error)
105 return (error);
106
107 sun.sun_family = AF_LOCAL;
108 strcpy(sun.sun_path, path);
109 sun.sun_len = SUN_LEN(&sun);
110
111 nconf = getnetconfigent("local");
104 error = copyinstr(uap->path, path, sizeof(path), NULL);
105 if (error)
106 return (error);
107
108 sun.sun_family = AF_LOCAL;
109 strcpy(sun.sun_path, path);
110 sun.sun_len = SUN_LEN(&sun);
111
112 nconf = getnetconfigent("local");
112 kgss_gssd_handle = clnt_reconnect_create(nconf,
113 cl = clnt_reconnect_create(nconf,
113 (struct sockaddr *) &sun, GSSD, GSSDVERS,
114 RPC_MAXDATASIZE, RPC_MAXDATASIZE);
115
114 (struct sockaddr *) &sun, GSSD, GSSDVERS,
115 RPC_MAXDATASIZE, RPC_MAXDATASIZE);
116
117 mtx_lock(&kgss_gssd_lock);
118 oldcl = kgss_gssd_handle;
119 kgss_gssd_handle = cl;
120 mtx_unlock(&kgss_gssd_lock);
121
122 if (oldcl != NULL) {
123 CLNT_CLOSE(oldcl);
124 CLNT_RELEASE(oldcl);
125 }
126
116 return (0);
117}
118
119int
120kgss_oid_equal(const gss_OID oid1, const gss_OID oid2)
121{
122
123 if (oid1 == oid2)

--- 120 unchanged lines hidden (view full) ---

244 to->value = malloc(from->length, M_GSSAPI, M_WAITOK);
245 bcopy(from->value, to->value, from->length);
246 } else {
247 to->value = NULL;
248 }
249}
250
251/*
127 return (0);
128}
129
130int
131kgss_oid_equal(const gss_OID oid1, const gss_OID oid2)
132{
133
134 if (oid1 == oid2)

--- 120 unchanged lines hidden (view full) ---

255 to->value = malloc(from->length, M_GSSAPI, M_WAITOK);
256 bcopy(from->value, to->value, from->length);
257 } else {
258 to->value = NULL;
259 }
260}
261
262/*
263 * Acquire the kgss_gssd_handle and return it with a reference count,
264 * if it is available.
265 */
266CLIENT *
267kgss_gssd_client(void)
268{
269 CLIENT *cl;
270
271 mtx_lock(&kgss_gssd_lock);
272 cl = kgss_gssd_handle;
273 if (cl != NULL)
274 CLNT_ACQUIRE(cl);
275 mtx_unlock(&kgss_gssd_lock);
276 return (cl);
277}
278
279/*
252 * Kernel module glue
253 */
254static int
255kgssapi_modevent(module_t mod, int type, void *data)
256{
257 int error = 0;
258
259 switch (type) {

--- 15 unchanged lines hidden (view full) ---

275 rpc_gss_entries.rpc_gss_clear_svc_name = rpc_gss_clear_svc_name;
276 rpc_gss_entries.rpc_gss_getcred = rpc_gss_getcred;
277 rpc_gss_entries.rpc_gss_set_callback = rpc_gss_set_callback;
278 rpc_gss_entries.rpc_gss_clear_callback = rpc_gss_clear_callback;
279 rpc_gss_entries.rpc_gss_get_principal_name =
280 rpc_gss_get_principal_name;
281 rpc_gss_entries.rpc_gss_svc_max_data_length =
282 rpc_gss_svc_max_data_length;
280 * Kernel module glue
281 */
282static int
283kgssapi_modevent(module_t mod, int type, void *data)
284{
285 int error = 0;
286
287 switch (type) {

--- 15 unchanged lines hidden (view full) ---

303 rpc_gss_entries.rpc_gss_clear_svc_name = rpc_gss_clear_svc_name;
304 rpc_gss_entries.rpc_gss_getcred = rpc_gss_getcred;
305 rpc_gss_entries.rpc_gss_set_callback = rpc_gss_set_callback;
306 rpc_gss_entries.rpc_gss_clear_callback = rpc_gss_clear_callback;
307 rpc_gss_entries.rpc_gss_get_principal_name =
308 rpc_gss_get_principal_name;
309 rpc_gss_entries.rpc_gss_svc_max_data_length =
310 rpc_gss_svc_max_data_length;
311 mtx_init(&kgss_gssd_lock, "kgss_gssd_lock", NULL, MTX_DEF);
283 break;
284 case MOD_UNLOAD:
285 /*
286 * Unloading of the kgssapi module is not currently supported.
287 * If somebody wants this, we would need to keep track of
288 * currently executing threads and make sure the count is 0.
289 */
290 /* FALLTHROUGH */

--- 13 unchanged lines hidden ---
312 break;
313 case MOD_UNLOAD:
314 /*
315 * Unloading of the kgssapi module is not currently supported.
316 * If somebody wants this, we would need to keep track of
317 * currently executing threads and make sure the count is 0.
318 */
319 /* FALLTHROUGH */

--- 13 unchanged lines hidden ---