Beispiel #1
0
static struct group *nss_getgrgid(gid_t gid)
{
	NSS_STATUS (*_nss_getgrgid_r)(gid_t , struct group *, char *, 
				      size_t , int *) = find_fn("getgrgid_r");
	static struct group grp;
	static char *buf;
	static int buflen = 1000;
	NSS_STATUS status;
	
	if (!_nss_getgrgid_r)
		return NULL;

	if (!buf) 
		buf = SMB_MALLOC(buflen);

again:	
	status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
	if (status == NSS_STATUS_TRYAGAIN) {
		buflen *= 2;
		buf = SMB_REALLOC(buf, buflen);
		if (!buf) {
			return NULL;
		}
		goto again;
	}
	if (status == NSS_STATUS_NOTFOUND) {
		return NULL;
	}
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("getgrgid", status);
		return NULL;
	}
	return &grp;
}
Beispiel #2
0
static struct group *nss_getgrnam(const char *name)
{
	NSS_STATUS (*_nss_getgrnam_r)(const char *, struct group *, char *, 
				      size_t , int *) = find_fn("getgrnam_r");
	static struct group grp;
	static char *buf;
	static int buflen = 1000;
	NSS_STATUS status;

	if (!buf) buf = malloc(buflen);
again:	
	status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
	if (status == NSS_STATUS_TRYAGAIN) {
		buflen *= 2;
		buf = realloc(buf, buflen);
		goto again;
	}
	if (status == NSS_STATUS_NOTFOUND) {
		return NULL;
	}
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("getgrnam", status);
		return NULL;
	}
	return &grp;
}
Beispiel #3
0
static void nss_endgrent(void)
{
	NSS_STATUS (*_nss_endgrent)(void) = find_fn("endgrent");
	NSS_STATUS status;
	status = _nss_endgrent();
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("endgrent", status);
	}
}
Beispiel #4
0
static void nss_setpwent(void)
{
	NSS_STATUS (*_nss_setpwent)(void) = find_fn("setpwent");
	NSS_STATUS status;
	
	if (!_nss_setpwent)
		return;

	status = _nss_setpwent();
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("setpwent", status);
	}
}
Beispiel #5
0
static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *start, long int *size)
{
	NSS_STATUS (*_nss_initgroups)(char *, gid_t , long int *,
				      long int *, gid_t **, long int , int *) = 
		find_fn("initgroups_dyn");
	NSS_STATUS status;

	if (!_nss_initgroups) return NSS_STATUS_UNAVAIL;

	status = _nss_initgroups(user, group, start, size, groups, 0, &nss_errno);
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("initgroups", status);
	}
	return status;
}
Beispiel #6
0
static struct passwd *nss_getpwnam(const char *name)
{
	NSS_STATUS (*_nss_getpwnam_r)(const char *, struct passwd *, char *, 
				      size_t , int *) = find_fn("getpwnam_r");
	static struct passwd pwd;
	static char buf[1000];
	NSS_STATUS status;
	
	status = _nss_getpwnam_r(name, &pwd, buf, sizeof(buf), &nss_errno);
	if (status == NSS_STATUS_NOTFOUND) {
		return NULL;
	}
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("getpwnam", status);
		return NULL;
	}
	return &pwd;
}
Beispiel #7
0
static struct passwd *nss_getpwent(void)
{
	NSS_STATUS (*_nss_getpwent_r)(struct passwd *, char *, 
				      size_t , int *) = find_fn("getpwent_r");
	static struct passwd pwd;
	static char buf[1000];
	NSS_STATUS status;

	if (!_nss_getpwent_r)
		return NULL;

	status = _nss_getpwent_r(&pwd, buf, sizeof(buf), &nss_errno);
	if (status == NSS_STATUS_NOTFOUND) {
		return NULL;
	}
	if (status != NSS_STATUS_SUCCESS) {
		report_nss_error("getpwent", status);
		return NULL;
	}
	return &pwd;
}