/* take a group name and return a filled struct group */
static struct group *wb_aix_getgrnam(const char *name)
{
	struct winbindd_response response;
	struct winbindd_request request;
	NSS_STATUS ret;
	struct group *grp;

	if (*name == WB_AIX_ENCODED) {
		return wb_aix_getgrgid(decode_id(name));
	}

	logit("getgrnam '%s'\n", name);

	ZERO_STRUCT(response);
	ZERO_STRUCT(request);

	STRCPY_RETNULL(request.data.groupname, name);

	ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
	
	HANDLE_ERRORS(ret);

	grp = fill_grent(&response.data.gr, response.extra_data.data);

	winbindd_free_response(&response);

	return grp;
}
Esempio n. 2
0
/* this call doesn't have to fill in the gr_mem, but we do anyway
   for simplicity */
static struct group *wb_aix_getgracct(void *id, int type)
{
	if (type == 1) {
		return wb_aix_getgrnam((char *)id);
	}
	if (type == 0) {
		return wb_aix_getgrgid(*(int *)id);
	}
	errno = EINVAL;
	return NULL;
}
Esempio n. 3
0
static attrval_t pwd_to_group(struct passwd *pwd)
{
	attrval_t r;
	struct group *grp = wb_aix_getgrgid(pwd->pw_gid);

	if (!grp) {
		r.attr_flag = EINVAL;
	} else {
		r.attr_flag = 0;
		r.attr_un.au_char = strdup(grp->gr_name);
		free_grp(grp);
	}

	return r;
}