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
38 * The system is very weak. The client uses no encryption for it's
58 #include <rpc/auth.h>
60 #include "un-namespace.h"
64 static void authunix_nextverf (AUTH *);
65 static bool_t authunix_marshal (AUTH *, XDR *);
66 static bool_t authunix_validate (AUTH *, struct opaque_auth *);
67 static bool_t authunix_refresh (AUTH *, void *);
68 static void authunix_destroy (AUTH *);
69 static void marshal_new_auth (AUTH *);
82 #define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) argument
86 * Returns an auth handle with the given stuff in it.
88 AUTH *
95 AUTH *auth; in authunix_create() local
99 * Allocate and set up auth handle in authunix_create()
102 auth = mem_alloc(sizeof(*auth)); in authunix_create()
104 if (auth == NULL) { in authunix_create()
116 auth->ah_ops = authunix_ops(); in authunix_create()
117 auth->ah_private = (caddr_t)au; in authunix_create()
118 auth->ah_verf = au->au_shcred = _null_auth; in authunix_create()
119 au->au_shfaults = 0; in authunix_create()
120 au->au_origcred.oa_base = NULL; in authunix_create()
139 au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); in authunix_create()
140 au->au_origcred.oa_flavor = AUTH_UNIX; in authunix_create()
142 au->au_origcred.oa_base = mem_alloc((u_int) len); in authunix_create()
144 if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { in authunix_create()
149 memmove(au->au_origcred.oa_base, mymem, (size_t)len); in authunix_create()
152 * set auth handle to reflect new cred. in authunix_create()
154 auth->ah_cred = au->au_origcred; in authunix_create()
155 marshal_new_auth(auth); in authunix_create()
156 return (auth); in authunix_create()
159 if (auth) in authunix_create()
160 mem_free(auth, sizeof(*auth)); in authunix_create()
162 if (au->au_origcred.oa_base) in authunix_create()
163 mem_free(au->au_origcred.oa_base, (u_int)len); in authunix_create()
171 * Returns an auth handle with parameters determined by doing lots of
174 AUTH *
177 AUTH *auth; in authunix_create_default() local
190 if (gethostname(machname, sizeof machname) == -1) in authunix_create_default()
192 machname[sizeof(machname) - 1] = 0; in authunix_create_default()
200 auth = authunix_create(machname, uid, gid, ngids, gids); in authunix_create_default()
202 return (auth); in authunix_create_default()
211 authunix_nextverf(AUTH *auth) in authunix_nextverf() argument
217 authunix_marshal(AUTH *auth, XDR *xdrs) in authunix_marshal() argument
221 assert(auth != NULL); in authunix_marshal()
224 au = AUTH_PRIVATE(auth); in authunix_marshal()
225 return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); in authunix_marshal()
229 authunix_validate(AUTH *auth, struct opaque_auth *verf) in authunix_validate() argument
234 assert(auth != NULL); in authunix_validate()
237 if (verf->oa_flavor == AUTH_SHORT) { in authunix_validate()
238 au = AUTH_PRIVATE(auth); in authunix_validate()
239 xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, in authunix_validate()
242 if (au->au_shcred.oa_base != NULL) { in authunix_validate()
243 mem_free(au->au_shcred.oa_base, in authunix_validate()
244 au->au_shcred.oa_length); in authunix_validate()
245 au->au_shcred.oa_base = NULL; in authunix_validate()
247 if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { in authunix_validate()
248 auth->ah_cred = au->au_shcred; in authunix_validate()
251 (void)xdr_opaque_auth(&xdrs, &au->au_shcred); in authunix_validate()
252 au->au_shcred.oa_base = NULL; in authunix_validate()
253 auth->ah_cred = au->au_origcred; in authunix_validate()
255 marshal_new_auth(auth); in authunix_validate()
261 authunix_refresh(AUTH *auth, void *dummy) in authunix_refresh() argument
263 struct audata *au = AUTH_PRIVATE(auth); in authunix_refresh()
269 assert(auth != NULL); in authunix_refresh()
271 if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { in authunix_refresh()
275 au->au_shfaults ++; in authunix_refresh()
280 xdrmem_create(&xdrs, au->au_origcred.oa_base, in authunix_refresh()
281 au->au_origcred.oa_length, XDR_DECODE); in authunix_refresh()
294 auth->ah_cred = au->au_origcred; in authunix_refresh()
295 marshal_new_auth(auth); in authunix_refresh()
305 authunix_destroy(AUTH *auth) in authunix_destroy() argument
309 assert(auth != NULL); in authunix_destroy()
311 au = AUTH_PRIVATE(auth); in authunix_destroy()
312 mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); in authunix_destroy()
314 if (au->au_shcred.oa_base != NULL) in authunix_destroy()
315 mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); in authunix_destroy()
317 mem_free(auth->ah_private, sizeof(struct audata)); in authunix_destroy()
319 if (auth->ah_verf.oa_base != NULL) in authunix_destroy()
320 mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); in authunix_destroy()
322 mem_free(auth, sizeof(*auth)); in authunix_destroy()
326 * Marshals (pre-serializes) an auth struct.
330 marshal_new_auth(AUTH *auth) in marshal_new_auth() argument
336 assert(auth != NULL); in marshal_new_auth()
338 au = AUTH_PRIVATE(auth); in marshal_new_auth()
339 xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); in marshal_new_auth()
340 if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || in marshal_new_auth()
341 (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) in marshal_new_auth()
342 warnx("auth_none.c - Fatal marshalling problem"); in marshal_new_auth()
344 au->au_mpos = XDR_GETPOS(xdrs); in marshal_new_auth()