Project

General

Profile

Feature #176 » nss-mdns-dyson.patch

Port nss-mdns to Illumos - Justin Maggard, 2014-06-09 07:53 PM

View differences:

nss-mdns-0.10/configure.ac
*-freebsd*) freebsd="yes" ;;
esac
# Solaris has a slightly different NSS interface
case ${host} in
*-solaris*) solaris="yes" ;;
esac
AM_CONDITIONAL([FREEBSD_NSS], [test "x$freebsd" = "xyes"])
AM_CONDITIONAL([SOLARIS_NSS], [test "x$solaris" = "xyes"])
if test "x$solaris" = "xyes" ; then
AC_DEFINE(SOLARIS_NSS, [1], [Add support for the Solaris NSS interface])
fi
# If using GCC specify some additional parameters
if test "x$GCC" = "xyes" ; then
-- nss-mdns-0.10.orig/src/Makefile.am
++ nss-mdns-0.10/src/Makefile.am
......
nss_mdns4_minimal.la \
nss_mdns6_minimal.la
else
if SOLARIS_NSS
lib_LTLIBRARIES += \
nss_mdns.la \
nss_mdns4.la \
nss_mdns6.la \
nss_mdns_minimal.la \
nss_mdns4_minimal.la \
nss_mdns6_minimal.la
else
lib_LTLIBRARIES += \
libnss_mdns.la \
libnss_mdns4.la \
......
libnss_mdns4_minimal.la \
libnss_mdns6_minimal.la
endif
endif
noinst_PROGRAMS = nss-test
sources = util.c util.h
......
libnss_mdns6_minimal_la_LDFLAGS=$(libnss_mdns_la_LDFLAGS)
# FreeBSD
if FREEBSD_NSS
nss_mdns_la_SOURCES=$(sources) bsdnss.c
else
nss_mdns_la_SOURCES= $(sources) nss.c
endif
nss_mdns_la_CFLAGS=$(AM_CFLAGS)
nss_mdns_la_LDFLAGS=$(AM_LDFLAGS) -shrext .so.1
-- nss-mdns-0.10.orig/src/nss.c
++ nss-mdns-0.10/src/nss.c
......
return status;
}
#ifdef SOLARIS_NSS
#include <nss_dbdefs.h>
#if defined(NSS_IPV4_ONLY) && ! defined(MDNS_MINIMAL)
#define _nss_mdns_hosts_constr _nss_mdns4_hosts_constr
#elif defined(NSS_IPV4_ONLY) && defined(MDNS_MINIMAL)
#define _nss_mdns_hosts_constr _nss_mdns4_minimal_hosts_constr
#elif defined(NSS_IPV6_ONLY) && ! defined(MDNS_MINIMAL)
#define _nss_mdns_hosts_constr _nss_mdns6_hosts_constr
#elif defined(NSS_IPV6_ONLY) && defined(MDNS_MINIMAL)
#define _nss_mdns_hosts_constr _nss_mdns6_minimal_hosts_constr
#elif defined(MDNS_MINIMAL)
#define _nss_mdns_hosts_constr _nss_mdns_minimal_hosts_constr
#endif
typedef struct mdns_backend *mdns_backend_ptr_t;
static nss_status_t getbyname(mdns_backend_ptr_t be, void *a)
{
nss_XbyY_args_t *args = (nss_XbyY_args_t *)a;
const char *name = args->key.name;
struct hostent *he = (struct hostent *)args->buf.result;
int errnop;
args->status = _nss_mdns_gethostbyname_r(name, he, args->buf.buffer, args->buf.buflen, &errnop, &args->h_errno);
if (args->status == NSS_SUCCESS)
{
args->returnval = he;
args->returnlen = 1;
}
return args->status;
}
static nss_status_t _nss_unavail(mdns_backend_ptr_t be, void *dummy)
{
return NSS_UNAVAIL;
}
static nss_status_t _nss_mdns_hosts_destr(mdns_backend_ptr_t be, void *dummy)
{
free(be);
return NSS_SUCCESS;
}
typedef nss_status_t (*mdns_backend_op_t)(mdns_backend_ptr_t, void *);
struct mdns_backend {
mdns_backend_op_t *ops;
nss_dbop_t n_ops;
};
static mdns_backend_op_t host_ops[] = {
_nss_mdns_hosts_destr,
_nss_unavail,
_nss_unavail,
_nss_unavail,
getbyname,
};
nss_backend_t *
_nss_mdns_hosts_constr(const char *dummy1, const char *dummy2, const char *dummy3)
{
mdns_backend_ptr_t be;
if ((be = (mdns_backend_ptr_t)calloc(1, sizeof (*be))) == NULL)
return (NULL);
be->ops = host_ops;
be->n_ops = sizeof(host_ops) / sizeof(mdns_backend_ptr_t);
return ((nss_backend_t *)be);
}
#endif
    (1-1/1)