lib/libutil/gr_util.c
int
gr_equal(const struct group *gr1, const struct group *gr2)
{
	int gr1_ndx;
	int gr2_ndx;
	bool found;

	/* Check that the non-member information is the same. */
	if (gr1->gr_name == NULL || gr2->gr_name == NULL) {
		if (gr1->gr_name != gr2->gr_name)
			return (false);
	} else if (strcmp(gr1->gr_name, gr2->gr_name) != 0)
		return (false);
	if (gr1->gr_passwd == NULL || gr2->gr_passwd == NULL) {
		if (gr1->gr_passwd != gr2->gr_passwd)
			return (false);
	} else if (strcmp(gr1->gr_passwd, gr2->gr_passwd) != 0)
		return (false);
	if (gr1->gr_gid != gr2->gr_gid)
		return (false);

	/* Check all members in both groups. */
	if (gr1->gr_mem == NULL || gr2->gr_mem == NULL) {
		if (gr1->gr_mem != gr2->gr_mem)
			return (false);
	} else {
		for (found = false, gr1_ndx = 0; gr1->gr_mem[gr1_ndx] != NULL;
		    gr1_ndx++) {
			for (gr2_ndx = 0; gr2->gr_mem[gr2_ndx] != NULL;
			    gr2_ndx++)
				if (strcmp(gr1->gr_mem[gr1_ndx],
				    gr2->gr_mem[gr2_ndx]) == 0) {
					found = true;
					break;
				}
			if (!found)
				return (false);
		}

		/* Check that group2 does not have more members than group1. */
		if (gr2->gr_mem[gr1_ndx] != NULL)
			return (false);
	}

	return (true);
}
/*
 * Compares two struct group's.
 */
Compares two struct group's.
Compares two struct group ' s .
int
gr_equal(const struct group *gr1, const struct group *gr2)
{
	int gr1_ndx;
	int gr2_ndx;
	bool found;
	if (gr1->gr_name == NULL || gr2->gr_name == NULL) {
		if (gr1->gr_name != gr2->gr_name)
			return (false);
	} else if (strcmp(gr1->gr_name, gr2->gr_name) != 0)
		return (false);
	if (gr1->gr_passwd == NULL || gr2->gr_passwd == NULL) {
		if (gr1->gr_passwd != gr2->gr_passwd)
			return (false);
	} else if (strcmp(gr1->gr_passwd, gr2->gr_passwd) != 0)
		return (false);
	if (gr1->gr_gid != gr2->gr_gid)
		return (false);
	if (gr1->gr_mem == NULL || gr2->gr_mem == NULL) {
		if (gr1->gr_mem != gr2->gr_mem)
			return (false);
	} else {
		for (found = false, gr1_ndx = 0; gr1->gr_mem[gr1_ndx] != NULL;
		    gr1_ndx++) {
			for (gr2_ndx = 0; gr2->gr_mem[gr2_ndx] != NULL;
			    gr2_ndx++)
				if (strcmp(gr1->gr_mem[gr1_ndx],
				    gr2->gr_mem[gr2_ndx]) == 0) {
					found = true;
					break;
				}
			if (!found)
				return (false);
		}
		if (gr2->gr_mem[gr1_ndx] != NULL)
			return (false);
	}
	return (true);
}
int gr_equal ( const struct group * gr1 , const struct group * gr2 ) { int gr1_ndx ; int gr2_ndx ; bool found ; if ( gr1 -> gr_name == NULL || gr2 -> gr_name == NULL ) { if ( gr1 -> gr_name != gr2 -> gr_name ) return ( false ) ; } else if ( strcmp ( gr1 -> gr_name , gr2 -> gr_name ) != 0 ) return ( false ) ; if ( gr1 -> gr_passwd == NULL || gr2 -> gr_passwd == NULL ) { if ( gr1 -> gr_passwd != gr2 -> gr_passwd ) return ( false ) ; } else if ( strcmp ( gr1 -> gr_passwd , gr2 -> gr_passwd ) != 0 ) return ( false ) ; if ( gr1 -> gr_gid != gr2 -> gr_gid ) return ( false ) ; if ( gr1 -> gr_mem == NULL || gr2 -> gr_mem == NULL ) { if ( gr1 -> gr_mem != gr2 -> gr_mem ) return ( false ) ; } else { for ( found = false , gr1_ndx = 0 ; gr1 -> gr_mem [ gr1_ndx ] != NULL ; gr1_ndx ++ ) { for ( gr2_ndx = 0 ; gr2 -> gr_mem [ gr2_ndx ] != NULL ; gr2_ndx ++ ) if ( strcmp ( gr1 -> gr_mem [ gr1_ndx ] , gr2 -> gr_mem [ gr2_ndx ] ) == 0 ) { found = true ; break ; } if ( ! found ) return ( false ) ; } if ( gr2 -> gr_mem [ gr1_ndx ] != NULL ) return ( false ) ; } return ( true ) ; }
Compares two struct group's.
Compares two struct group ' s .
/* Check that the non-member information is the same. */ /* Check all members in both groups. */ /* Check that group2 does not have more members than group1. */