head/sys/rpc/authunix_prot.c
/*
 * XDR for unix authentication parameters.
 */
XDR for unix authentication parameters.
XDR for unix authentication parameters .
bool_t
xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred)
{
	uint32_t namelen;
	uint32_t ngroups, i;
	uint32_t junk;
	char hostbuf[MAXHOSTNAMELEN];
	if (xdrs->x_op == XDR_ENCODE) {
		getcredhostname(NULL, hostbuf, sizeof(hostbuf));
		namelen = strlen(hostbuf);
		if (namelen > 255)
			namelen = 255;
	} else {
		namelen = 0;
	}
	junk = 0;
	if (!xdr_uint32_t(xdrs, time)
	    || !xdr_uint32_t(xdrs, &namelen))
		return (FALSE);
	if (xdrs->x_op == XDR_ENCODE) {
		if (!xdr_opaque(xdrs, hostbuf, namelen))
			return (FALSE);
	} else {
		xdr_setpos(xdrs, xdr_getpos(xdrs) + RNDUP(namelen));
	}
	if (!xdr_uint32_t(xdrs, &cred->cr_uid))
		return (FALSE);
	if (!xdr_uint32_t(xdrs, &cred->cr_groups[0]))
		return (FALSE);
	if (xdrs->x_op == XDR_ENCODE) {
		ngroups = cred->cr_ngroups - 1;
		if (ngroups > NGRPS)
			ngroups = NGRPS;
	}
	if (!xdr_uint32_t(xdrs, &ngroups))
		return (FALSE);
	for (i = 0; i < ngroups; i++) {
		if (i + 1 < ngroups_max + 1) {
			if (!xdr_uint32_t(xdrs, &cred->cr_groups[i + 1]))
				return (FALSE);
		} else {
			if (!xdr_uint32_t(xdrs, &junk))
				return (FALSE);
		}
	}
	if (xdrs->x_op == XDR_DECODE) {
		if (ngroups + 1 > ngroups_max + 1)
			cred->cr_ngroups = ngroups_max + 1;
		else
			cred->cr_ngroups = ngroups + 1;
	}
	return (TRUE);
}
bool_t xdr_authunix_parms ( XDR * xdrs , uint32_t * time , struct xucred * cred ) { uint32_t namelen ; uint32_t ngroups , i ; uint32_t junk ; char hostbuf [ MAXHOSTNAMELEN ] ; if ( xdrs -> x_op == XDR_ENCODE ) { getcredhostname ( NULL , hostbuf , sizeof ( hostbuf ) ) ; namelen = strlen ( hostbuf ) ; if ( namelen > 255 ) namelen = 255 ; } else { namelen = 0 ; } junk = 0 ; if ( ! xdr_uint32_t ( xdrs , time ) || ! xdr_uint32_t ( xdrs , & namelen ) ) return ( FALSE ) ; if ( xdrs -> x_op == XDR_ENCODE ) { if ( ! xdr_opaque ( xdrs , hostbuf , namelen ) ) return ( FALSE ) ; } else { xdr_setpos ( xdrs , xdr_getpos ( xdrs ) + RNDUP ( namelen ) ) ; } if ( ! xdr_uint32_t ( xdrs , & cred -> cr_uid ) ) return ( FALSE ) ; if ( ! xdr_uint32_t ( xdrs , & cred -> cr_groups [ 0 ] ) ) return ( FALSE ) ; if ( xdrs -> x_op == XDR_ENCODE ) { ngroups = cred -> cr_ngroups - 1 ; if ( ngroups > NGRPS ) ngroups = NGRPS ; } if ( ! xdr_uint32_t ( xdrs , & ngroups ) ) return ( FALSE ) ; for ( i = 0 ; i < ngroups ; i ++ ) { if ( i + 1 < ngroups_max + 1 ) { if ( ! xdr_uint32_t ( xdrs , & cred -> cr_groups [ i + 1 ] ) ) return ( FALSE ) ; } else { if ( ! xdr_uint32_t ( xdrs , & junk ) ) return ( FALSE ) ; } } if ( xdrs -> x_op == XDR_DECODE ) { if ( ngroups + 1 > ngroups_max + 1 ) cred -> cr_ngroups = ngroups_max + 1 ; else cred -> cr_ngroups = ngroups + 1 ; } return ( TRUE ) ; }
XDR for unix authentication parameters.
XDR for unix authentication parameters .
/*
		 * Restrict name length to 255 according to RFC 1057.
		 */ /*
	 * Ignore the hostname on decode.
	 */