コード例 #1
0
ファイル: ldappr-dns.c プロジェクト: mikess/illumos-gate
static int
prldap_switch_gethostbyname_r(const char *name,
                              struct hostent *result, char *buffer, int buflen,
                              int *h_errnop)
{
    nss_XbyY_args_t arg;
    nss_status_t    res;
    struct hostent	*resp;

    /*
     * Log the information indicating that we are trying to
     * resolve the LDAP server name.
     */
    syslog(LOG_INFO, "libldap: Resolving server name \"%s\"", name);

    NSS_XbyY_INIT(&arg, result, buffer, buflen, str2hostent);

    arg.key.name = name;
    arg.stayopen = 0;

    res = nss_search(&db_root_hosts, prldap_initf_hosts,
                     NSS_DBOP_HOSTS_BYNAME, &arg);
    arg.status = res;
    *h_errnop = arg.h_errno;
    resp = (struct hostent *)NSS_XbyY_FINI(&arg);

    return (resp != NULL ? PR_SUCCESS : PR_FAILURE);
}
コード例 #2
0
/*
 * BSD-compatible getgrouplist(3) using nss_search(3)
 */
int
getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
{
    struct nss_groupsbymem gbm;
    static DEFINE_NSS_DB_ROOT(db_root);

    /* We support BSD semantics where the first element is the base gid */
    if (*ngroupsp <= 0)
	return -1;
    groups[0] = basegid;

    memset(&gbm, 0, sizeof(gbm));
    gbm.username = name;
    gbm.gid_array = groups;
    gbm.maxgids = *ngroupsp;
    gbm.numgids = 1; /* for basegid */
    gbm.force_slow_way = 1;
    gbm.str2ent = str2grp;
    gbm.process_cstr = process_cstr;

    /*
     * Can't use nss_search return value since it may return NSS_UNAVAIL
     * when no nsswitch.conf entry (e.g. compat mode).
     */
    (void)nss_search(&db_root, _nss_initf_group, NSS_DBOP_GROUP_BYMEMBER, &gbm);

    if (gbm.numgids <= gbm.maxgids) {
        *ngroupsp = gbm.numgids;
        return 0;
    }
    *ngroupsp = gbm.maxgids;
    return -1;
}
コード例 #3
0
ファイル: getpwnam_r.c プロジェクト: jasonbking/illumos-gate
/*
 * POSIX.1c Draft-6 version of the function getpwuid_r.
 * It was implemented by Solaris 2.3.
 */
struct passwd *
getpwuid_r(uid_t uid, struct passwd *result, char *buffer, int buflen)
{
	nss_XbyY_args_t arg;

	NSS_XbyY_INIT(&arg, result, buffer, buflen, str2passwd);
	arg.key.uid = uid;
	(void) nss_search(&db_root, _nss_initf_passwd, NSS_DBOP_PASSWD_BYUID,
	    &arg);
	return ((struct passwd *)NSS_XbyY_FINI(&arg));
}
コード例 #4
0
ファイル: getpwnam_r.c プロジェクト: jasonbking/illumos-gate
struct passwd *
_uncached_getpwnam_r(const char *name, struct passwd *result, char *buffer,
	int buflen)
{
	nss_XbyY_args_t arg;

	NSS_XbyY_INIT(&arg, result, buffer, buflen, str2passwd);
	arg.key.name = name;
	(void) nss_search(&db_root, _nss_initf_passwd, NSS_DBOP_PASSWD_BYNAME,
	    &arg);
	return ((struct passwd *)NSS_XbyY_FINI(&arg));
}
コード例 #5
0
ファイル: getauthattr.c プロジェクト: apprisi/illumos-gate
authstr_t *
_getauthnam(const char *name, authstr_t *result, char *buffer, int buflen,
    int *errnop)
{
	nss_XbyY_args_t arg;
	nss_status_t    res;

	NSS_XbyY_INIT(&arg, result, buffer, buflen, str2authattr);
	arg.key.name = name;
	arg.stayopen = authattr_stayopen;
	res = nss_search(&db_root, _nss_initf_authattr,
	    NSS_DBOP_AUTHATTR_BYNAME, &arg);
	arg.status = res;
	*errnop = arg.h_errno;
	return ((authstr_t *)NSS_XbyY_FINI(&arg));
}
コード例 #6
0
ファイル: getauuser.c プロジェクト: apprisi/illumos-gate
au_user_str_t *
_getauusernam(const char *name, au_user_str_t *result, char *buffer,
    int buflen, int *errnop)
{
	nss_XbyY_args_t arg;
	nss_status_t    res;

	if (result == NULL) {
		*errnop = AUDITUSER_PARSE_ERANGE;
		return (NULL);
	}
	NSS_XbyY_INIT(&arg, result, buffer, buflen, str2auuser);
	arg.key.name = name;
	arg.stayopen = auuser_stayopen;
	arg.h_errno = AUDITUSER_NOT_FOUND;
	res = nss_search(&db_root, _nss_initf_auuser,
	    NSS_DBOP_AUDITUSER_BYNAME, &arg);
	arg.status = res;
	*errnop = arg.h_errno;
	return ((au_user_str_t *)NSS_XbyY_FINI(&arg));
}
コード例 #7
0
ファイル: netmasks.c プロジェクト: apprisi/illumos-gate
/*
 * Given a 32 bit key look it up in the netmasks database
 * based on the "netmasks" policy in /etc/nsswitch.conf.
 * If the key is a network number with the trailing zero's removed
 * (e.g. "192.9.200") this routine can't use inet_ntoa to convert
 * the address to the string key.
 * Returns zero if successful, non-zero otherwise.
 */
static int
getnetmaskbykey(const struct in_addr addr, struct in_addr *mask)
{
	nss_XbyY_args_t arg;
	nss_status_t	res;
	char		tmp[NSS_LINELEN_NETMASKS];

	/*
	 * let the backend do the allocation to store stuff for parsing.
	 * To simplify things, we put the dotted internet address form of
	 * the network address in the 'name' field as a filter to speed
	 * up the lookup.
	 */
	if (inet_nettoa(addr, tmp, NSS_LINELEN_NETMASKS) == NULL)
		return (NSS_NOTFOUND);

	NSS_XbyY_INIT(&arg, mask, NULL, 0, str2addr);
	arg.key.name = tmp;
	res = nss_search(&db_root, _nss_initf_netmasks,
			NSS_DBOP_NETMASKS_BYNET, &arg);
	(void) NSS_XbyY_FINI(&arg);
	return (arg.status = res);
}