Ejemplo n.º 1
0
void
nis_ping(nis_name name, uint32_t mtime, nis_object *obj)
{
	nis_server	**srvs;
	nis_server	*s, *list;
	int		i, ns;
	nis_name	thishost = nis_local_host();

	if (obj) {
		if (name == 0)
			name = obj->DI_data.do_name;
		list = obj->DI_data.do_servers.do_servers_val;
		ns = obj->DI_data.do_servers.do_servers_len;

		for (i = 0, s = &(list[0]); i < ns; i++, s = &(list[i])) {

			if (nis_dir_cmp(s->name, thishost) == SAME_NAME) {
				continue;
			}

			__nis_pingproc(s, name, mtime);
		}
	} else {
		srvs = nis_getservlist(name);
		if (! srvs)
			return;

		for (i = 0, s = srvs[0]; s; i++, s = srvs[i]) {

			if (nis_dir_cmp(s->name, thishost) == SAME_NAME) {
				continue;
			}
			__nis_pingproc(s, name, mtime);

		}
		nis_freeservlist(srvs);
	}
}
Ejemplo n.º 2
0
fd_result *
__nis_finddirectory (directory_obj *dir, const_nis_name name)
{
  nis_error status;
  fd_args fd_args;
  fd_result *fd_res;

  fd_args.dir_name = (char *)name;
  fd_args.requester = nis_local_host();
  fd_res = calloc (1, sizeof (fd_result));
  if (fd_res == NULL)
    return NULL;

  status = __do_niscall2 (dir->do_servers.do_servers_val,
			  dir->do_servers.do_servers_len,
			  NIS_FINDDIRECTORY, (xdrproc_t) _xdr_fd_args,
			  (caddr_t) &fd_args, (xdrproc_t) _xdr_fd_result,
			  (caddr_t) fd_res, NO_AUTHINFO|USE_DGRAM, NULL);
  if (status != NIS_SUCCESS)
    fd_res->status = status;

  return fd_res;
}
Ejemplo n.º 3
0
/*
 * Convert host to network-name
 * This routine returns following netnames given the host and domain
 * arguments defined below: (domainname=y.z)
 *	  Arguments
 *	host	domain		netname
 *	----	------		-------
 *	-	-		[email protected] (hostname=m)
 *	-	a.b		[email protected] (hostname=m)
 *	-	-		[email protected] (hostname=m.w.x)
 *	-	a.b		[email protected] (hostname=m.w.x)
 *	h	-		[email protected]
 *	h	a.b		[email protected]
 *	h.w.x	-		[email protected]
 *	h.w.x	a.b		[email protected]
 */
int
host2netname(char netname[MAXNETNAMELEN + 1], const char *host,
							const char *domain)
{
	char *p;
	char hostname[MAXHOSTNAMELEN + 1];
	char domainname[MAXHOSTNAMELEN + 1];
	char *dot_in_host;
	int i;
	size_t len;

	netname[0] = '\0';  /* make null first (no need for memset) */

	if (host == NULL) {
		(void) strncpy(hostname, nis_local_host(), sizeof (hostname));
		p = (char *)strchr(hostname, '.');
		if (p) {
			*p++ = '\0';
			/* if no domain passed, use tail of nis_local_host() */
			if (domain == NULL) {
				domain = p;
			}
		}
	} else {
		len = strlen(host);
		if (len >= sizeof (hostname)) {
			return (0);
		}
		(void) strcpy(hostname, host);
	}

	dot_in_host = (char *)strchr(hostname, '.');
	if (domain == NULL) {
		p = dot_in_host;
		if (p) {
			p = (char *)nis_domain_of(hostname);
			len = strlen(p);
			if (len >= sizeof (domainname)) {
				return (0);
			}
			(void) strcpy(domainname, p);
		} else {
			domainname[0] = NULL;
			if (getdomainname(domainname, MAXHOSTNAMELEN) < 0)
				return (0);
		}
	} else {
		len = strlen(domain);
		if (len >= sizeof (domainname)) {
			return (0);
		}
		(void) strcpy(domainname, domain);
	}

	i = strlen(domainname);
	if (i == 0)
		/* No domainname */
		return (0);
	if (domainname[i - 1] == '.')
		domainname[i - 1] = 0;

	if (dot_in_host) {  /* strip off rest of name */
		*dot_in_host = '\0';
	}

	if ((strlen(domainname) + strlen(hostname) + OPSYS_LEN + 3)
	    > (size_t)MAXNETNAMELEN) {
		return (0);
	}

	(void) snprintf(netname, MAXNETNAMELEN + 1,
	    "%s.%s@%s", OPSYS, hostname, domainname);
	return (1);
}