Lines Matching +full:system +full:- +full:auth
3 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
11 * - Redistributions of source code must retain the above copyright notice,
13 * - Redistributions in binary form must reproduce the above copyright notice,
16 * - Neither the name of Sun Microsystems, Inc. nor the names of its
39 * The system is very weak. The client uses no encryption for it's
59 #include <rpc/auth.h>
65 static void authunix_nextverf (AUTH *);
66 static bool_t authunix_marshal (AUTH *, uint32_t, XDR *, struct mbuf *);
67 static bool_t authunix_validate (AUTH *, uint32_t, struct opaque_auth *,
69 static bool_t authunix_refresh (AUTH *, void *);
70 static void authunix_destroy (AUTH *);
71 static void marshal_new_auth (AUTH *);
94 AUTH *au_auth; /* link back to AUTH */
97 #define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) argument
120 * Returns an auth handle with the given stuff in it.
122 AUTH *
129 AUTH *auth; in authunix_create() local
139 th = HASHSTEP(HASHINIT, tau->au_xcred.cr_uid) in authunix_create()
143 auth_unix_count--; in authunix_create()
145 AUTH_DESTROY(tau->au_auth); in authunix_create()
150 * Hash the uid to see if we already have an AUTH with this cred. in authunix_create()
152 h = HASHSTEP(HASHINIT, cred->cr_uid) % AUTH_UNIX_HASH_SIZE; in authunix_create()
157 if (!memcmp(&xcr, &au->au_xcred, sizeof(xcr))) { in authunix_create()
158 refcount_acquire(&au->au_refs); in authunix_create()
170 return (au->au_auth); in authunix_create()
177 * Allocate and set up auth handle in authunix_create()
180 auth = mem_alloc(sizeof(*auth)); in authunix_create()
182 auth->ah_ops = &authunix_ops; in authunix_create()
183 auth->ah_private = (caddr_t)au; in authunix_create()
184 auth->ah_verf = au->au_shcred = _null_auth; in authunix_create()
185 refcount_init(&au->au_refs, 1); in authunix_create()
186 au->au_xcred = xcr; in authunix_create()
187 au->au_shfaults = 0; in authunix_create()
188 au->au_origcred.oa_base = NULL; in authunix_create()
189 au->au_auth = auth; in authunix_create()
201 au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); in authunix_create()
202 au->au_origcred.oa_flavor = AUTH_UNIX; in authunix_create()
203 au->au_origcred.oa_base = mem_alloc((u_int) len); in authunix_create()
204 memcpy(au->au_origcred.oa_base, mymem, (size_t)len); in authunix_create()
207 * set auth handle to reflect new cred. in authunix_create()
209 auth->ah_cred = au->au_origcred; in authunix_create()
210 marshal_new_auth(auth); in authunix_create()
214 if (!memcmp(&xcr, &tau->au_xcred, sizeof(xcr))) { in authunix_create()
216 * We lost a race to create the AUTH that in authunix_create()
220 AUTH_DESTROY(auth); in authunix_create()
228 refcount_acquire(&au->au_refs); /* one for the cache, one for user */ in authunix_create()
231 return (auth); in authunix_create()
240 authunix_nextverf(AUTH *auth) in authunix_nextverf() argument
246 authunix_marshal(AUTH *auth, uint32_t xid, XDR *xdrs, struct mbuf *args) in authunix_marshal() argument
250 au = AUTH_PRIVATE(auth); in authunix_marshal()
251 if (!XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)) in authunix_marshal()
258 authunix_validate(AUTH *auth, uint32_t xid, struct opaque_auth *verf, in authunix_validate() argument
267 if (verf->oa_flavor == AUTH_SHORT) { in authunix_validate()
268 au = AUTH_PRIVATE(auth); in authunix_validate()
269 xdrmem_create(&txdrs, verf->oa_base, verf->oa_length, in authunix_validate()
272 if (au->au_shcred.oa_base != NULL) { in authunix_validate()
273 mem_free(au->au_shcred.oa_base, in authunix_validate()
274 au->au_shcred.oa_length); in authunix_validate()
275 au->au_shcred.oa_base = NULL; in authunix_validate()
277 if (xdr_opaque_auth(&txdrs, &au->au_shcred)) { in authunix_validate()
278 auth->ah_cred = au->au_shcred; in authunix_validate()
281 (void)xdr_opaque_auth(&txdrs, &au->au_shcred); in authunix_validate()
282 au->au_shcred.oa_base = NULL; in authunix_validate()
283 auth->ah_cred = au->au_origcred; in authunix_validate()
285 marshal_new_auth(auth); in authunix_validate()
292 authunix_refresh(AUTH *auth, void *dummy) in authunix_refresh() argument
294 struct audata *au = AUTH_PRIVATE(auth); in authunix_refresh()
301 if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { in authunix_refresh()
305 au->au_shfaults ++; in authunix_refresh()
308 xdrmem_create(&xdrs, au->au_origcred.oa_base, in authunix_refresh()
309 au->au_origcred.oa_length, XDR_DECODE); in authunix_refresh()
323 auth->ah_cred = au->au_origcred; in authunix_refresh()
324 marshal_new_auth(auth); in authunix_refresh()
331 authunix_destroy(AUTH *auth) in authunix_destroy() argument
335 au = AUTH_PRIVATE(auth); in authunix_destroy()
337 if (!refcount_release(&au->au_refs)) in authunix_destroy()
340 mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); in authunix_destroy()
342 if (au->au_shcred.oa_base != NULL) in authunix_destroy()
343 mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); in authunix_destroy()
345 mem_free(auth->ah_private, sizeof(struct audata)); in authunix_destroy()
347 if (auth->ah_verf.oa_base != NULL) in authunix_destroy()
348 mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); in authunix_destroy()
350 mem_free(auth, sizeof(*auth)); in authunix_destroy()
354 * Marshals (pre-serializes) an auth struct.
358 marshal_new_auth(AUTH *auth) in marshal_new_auth() argument
364 au = AUTH_PRIVATE(auth); in marshal_new_auth()
365 xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); in marshal_new_auth()
366 if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || in marshal_new_auth()
367 (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) in marshal_new_auth()
368 printf("auth_none.c - Fatal marshalling problem"); in marshal_new_auth()
370 au->au_mpos = XDR_GETPOS(xdrs); in marshal_new_auth()