FreeBSD/usr.sbin/mountd/mountd.c
/*
 * Scan for a host match in a directory tree.
 */
Scan for a host match in a directory tree.
Scan for a host match in a directory tree .
static int
chk_host(struct dirlist *dp, struct sockaddr *saddr, int *defsetp,
	int *hostsetp, int *numsecflavors, int **secflavorsp)
{
	struct hostlist *hp;
	struct grouplist *grp;
	struct addrinfo *ai;
	if (dp) {
		if (dp->dp_flag & DP_DEFSET)
			*defsetp = dp->dp_flag;
		hp = dp->dp_hosts;
		while (hp) {
			grp = hp->ht_grp;
			switch (grp->gr_type) {
			case GT_HOST:
				ai = grp->gr_ptr.gt_addrinfo;
				for (; ai; ai = ai->ai_next) {
					if (!sacmp(ai->ai_addr, saddr, NULL)) {
						*hostsetp =
						    (hp->ht_flag | DP_HOSTSET);
						if (numsecflavors != NULL) {
							*numsecflavors =
							    grp->gr_numsecflavors;
							*secflavorsp =
							    grp->gr_secflavors;
						}
						return (1);
					}
				}
				break;
			case GT_NET:
				if (!sacmp(saddr, (struct sockaddr *)
				    &grp->gr_ptr.gt_net.nt_net,
				    (struct sockaddr *)
				    &grp->gr_ptr.gt_net.nt_mask)) {
					*hostsetp = (hp->ht_flag | DP_HOSTSET);
					if (numsecflavors != NULL) {
						*numsecflavors =
						    grp->gr_numsecflavors;
						*secflavorsp =
						    grp->gr_secflavors;
					}
					return (1);
				}
				break;
			}
			hp = hp->ht_next;
		}
	}
	return (0);
}
static int chk_host ( struct dirlist * dp , struct sockaddr * saddr , int * defsetp , int * hostsetp , int * numsecflavors , int * * secflavorsp ) { struct hostlist * hp ; struct grouplist * grp ; struct addrinfo * ai ; if ( dp ) { if ( dp -> dp_flag & DP_DEFSET ) * defsetp = dp -> dp_flag ; hp = dp -> dp_hosts ; while ( hp ) { grp = hp -> ht_grp ; switch ( grp -> gr_type ) { case GT_HOST : ai = grp -> gr_ptr . gt_addrinfo ; for ( ; ai ; ai = ai -> ai_next ) { if ( ! sacmp ( ai -> ai_addr , saddr , NULL ) ) { * hostsetp = ( hp -> ht_flag | DP_HOSTSET ) ; if ( numsecflavors != NULL ) { * numsecflavors = grp -> gr_numsecflavors ; * secflavorsp = grp -> gr_secflavors ; } return ( 1 ) ; } } break ; case GT_NET : if ( ! sacmp ( saddr , ( struct sockaddr * ) & grp -> gr_ptr . gt_net . nt_net , ( struct sockaddr * ) & grp -> gr_ptr . gt_net . nt_mask ) ) { * hostsetp = ( hp -> ht_flag | DP_HOSTSET ) ; if ( numsecflavors != NULL ) { * numsecflavors = grp -> gr_numsecflavors ; * secflavorsp = grp -> gr_secflavors ; } return ( 1 ) ; } break ; } hp = hp -> ht_next ; } } return ( 0 ) ; }
Scan for a host match in a directory tree.
Scan for a host match in a directory tree .