1*22687596Schristos /* $NetBSD: clnt_generic.c,v 1.33 2014/05/28 14:45:19 christos Exp $ */
29e15c989Scgd
363d7b677Scgd /*
447c0e0c3Stron * Copyright (c) 2010, Oracle America, Inc.
563d7b677Scgd *
647c0e0c3Stron * Redistribution and use in source and binary forms, with or without
747c0e0c3Stron * modification, are permitted provided that the following conditions are
847c0e0c3Stron * met:
963d7b677Scgd *
1047c0e0c3Stron * * Redistributions of source code must retain the above copyright
1147c0e0c3Stron * notice, this list of conditions and the following disclaimer.
1247c0e0c3Stron * * Redistributions in binary form must reproduce the above
1347c0e0c3Stron * copyright notice, this list of conditions and the following
1447c0e0c3Stron * disclaimer in the documentation and/or other materials
1547c0e0c3Stron * provided with the distribution.
1647c0e0c3Stron * * Neither the name of the "Oracle America, Inc." nor the names of its
1747c0e0c3Stron * contributors may be used to endorse or promote products derived
1847c0e0c3Stron * from this software without specific prior written permission.
1963d7b677Scgd *
2047c0e0c3Stron * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2147c0e0c3Stron * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2247c0e0c3Stron * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2347c0e0c3Stron * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
2447c0e0c3Stron * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
2547c0e0c3Stron * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2647c0e0c3Stron * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
2747c0e0c3Stron * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2847c0e0c3Stron * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2947c0e0c3Stron * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3047c0e0c3Stron * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3147c0e0c3Stron * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3263d7b677Scgd */
3363d7b677Scgd /*
347df0ccbaSfvdl * Copyright (c) 1986-1991 by Sun Microsystems Inc.
3563d7b677Scgd */
3646e6c5e8Slukem
377df0ccbaSfvdl /* #ident "@(#)clnt_generic.c 1.20 94/05/03 SMI" */
387df0ccbaSfvdl
395c945215Sitojun #include <sys/cdefs.h>
405c945215Sitojun #if defined(LIBC_SCCS) && !defined(lint)
417df0ccbaSfvdl #if 0
427df0ccbaSfvdl static char sccsid[] = "@(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro";
435c945215Sitojun #else
44*22687596Schristos __RCSID("$NetBSD: clnt_generic.c,v 1.33 2014/05/28 14:45:19 christos Exp $");
457df0ccbaSfvdl #endif
467df0ccbaSfvdl #endif
477df0ccbaSfvdl
487df0ccbaSfvdl #include "namespace.h"
497df0ccbaSfvdl #include "reentrant.h"
5046e6c5e8Slukem #include <sys/types.h>
51ce147c1cSlukem #include <sys/socket.h>
527df0ccbaSfvdl #include <netinet/in.h>
530e8cfd8fSlukem #include <assert.h>
547df0ccbaSfvdl #include <stdio.h>
5546e6c5e8Slukem #include <errno.h>
5646e6c5e8Slukem #include <rpc/rpc.h>
57deb154d2Schristos #include <rpc/nettype.h>
587df0ccbaSfvdl #include <string.h>
597df0ccbaSfvdl #include <stdlib.h>
607df0ccbaSfvdl #include <unistd.h>
612dec884dSchristos
622dec884dSchristos #include "svc_fdset.h"
6379d5b270Sfvdl #include "rpc_internal.h"
6463d7b677Scgd
6543fa6fe3Sjtc #ifdef __weak_alias
__weak_alias(clnt_create_vers,_clnt_create_vers)667df0ccbaSfvdl __weak_alias(clnt_create_vers,_clnt_create_vers)
6760549036Smycroft __weak_alias(clnt_create,_clnt_create)
687df0ccbaSfvdl __weak_alias(clnt_tp_create,_clnt_tp_create)
697df0ccbaSfvdl __weak_alias(clnt_tli_create,_clnt_tli_create)
7043fa6fe3Sjtc #endif
7143fa6fe3Sjtc
7263d7b677Scgd /*
737df0ccbaSfvdl * Generic client creation with version checking the value of
747df0ccbaSfvdl * vers_out is set to the highest server supported value
757df0ccbaSfvdl * vers_low <= vers_out <= vers_high AND an error results
767df0ccbaSfvdl * if this can not be done.
7763d7b677Scgd */
7863d7b677Scgd CLIENT *
79adb74221Smatt clnt_create_vers(
80adb74221Smatt const char * hostname,
81adb74221Smatt rpcprog_t prog,
82adb74221Smatt rpcvers_t * vers_out,
83adb74221Smatt rpcvers_t vers_low,
84adb74221Smatt rpcvers_t vers_high,
85adb74221Smatt const char * nettype)
8663d7b677Scgd {
877df0ccbaSfvdl CLIENT *clnt;
887df0ccbaSfvdl struct timeval to;
897df0ccbaSfvdl enum clnt_stat rpc_stat;
907df0ccbaSfvdl struct rpc_err rpcerr;
9163d7b677Scgd
920e8cfd8fSlukem _DIAGASSERT(hostname != NULL);
930e8cfd8fSlukem _DIAGASSERT(vers_out != NULL);
940e8cfd8fSlukem /* XXX: nettype appears to support being NULL */
950e8cfd8fSlukem
967df0ccbaSfvdl clnt = clnt_create(hostname, prog, vers_high, nettype);
977df0ccbaSfvdl if (clnt == NULL) {
9863d7b677Scgd return (NULL);
9963d7b677Scgd }
1007df0ccbaSfvdl to.tv_sec = 10;
1017df0ccbaSfvdl to.tv_usec = 0;
1027df0ccbaSfvdl rpc_stat = clnt_call(clnt, NULLPROC, (xdrproc_t) xdr_void,
103c9cdc302Schristos NULL, (xdrproc_t) xdr_void, NULL, to);
1047df0ccbaSfvdl if (rpc_stat == RPC_SUCCESS) {
1057df0ccbaSfvdl *vers_out = vers_high;
1067df0ccbaSfvdl return (clnt);
1077df0ccbaSfvdl }
1087df0ccbaSfvdl if (rpc_stat == RPC_PROGVERSMISMATCH) {
1097df0ccbaSfvdl unsigned long minvers, maxvers;
1107df0ccbaSfvdl
1117df0ccbaSfvdl clnt_geterr(clnt, &rpcerr);
1127df0ccbaSfvdl minvers = rpcerr.re_vers.low;
1137df0ccbaSfvdl maxvers = rpcerr.re_vers.high;
1147df0ccbaSfvdl if (maxvers < vers_high)
115deb154d2Schristos vers_high = (rpcvers_t)maxvers;
1167df0ccbaSfvdl if (minvers > vers_low)
117deb154d2Schristos vers_low = (rpcvers_t)minvers;
1187df0ccbaSfvdl if (vers_low > vers_high) {
1197df0ccbaSfvdl goto error;
1207df0ccbaSfvdl }
121deb154d2Schristos CLNT_CONTROL(clnt, CLSET_VERS, (char *)(void *)&vers_high);
1227df0ccbaSfvdl rpc_stat = clnt_call(clnt, NULLPROC, (xdrproc_t) xdr_void,
123c9cdc302Schristos NULL, (xdrproc_t) xdr_void, NULL, to);
1247df0ccbaSfvdl if (rpc_stat == RPC_SUCCESS) {
1257df0ccbaSfvdl *vers_out = vers_high;
1267df0ccbaSfvdl return (clnt);
1277df0ccbaSfvdl }
1287df0ccbaSfvdl }
1297df0ccbaSfvdl clnt_geterr(clnt, &rpcerr);
1307df0ccbaSfvdl
1317df0ccbaSfvdl error:
1327df0ccbaSfvdl rpc_createerr.cf_stat = rpc_stat;
1337df0ccbaSfvdl rpc_createerr.cf_error = rpcerr;
1347df0ccbaSfvdl clnt_destroy(clnt);
1357df0ccbaSfvdl return (NULL);
1367df0ccbaSfvdl }
1377df0ccbaSfvdl
13863d7b677Scgd /*
1397df0ccbaSfvdl * Top level client creation routine.
1407df0ccbaSfvdl * Generic client creation: takes (servers name, program-number, nettype) and
1417df0ccbaSfvdl * returns client handle. Default options are set, which the user can
1427df0ccbaSfvdl * change using the rpc equivalent of ioctl()'s.
1437df0ccbaSfvdl *
1447df0ccbaSfvdl * It tries for all the netids in that particular class of netid until
1457df0ccbaSfvdl * it succeeds.
1467df0ccbaSfvdl * XXX The error message in the case of failure will be the one
1477df0ccbaSfvdl * pertaining to the last create error.
1487df0ccbaSfvdl *
1497df0ccbaSfvdl * It calls clnt_tp_create();
15063d7b677Scgd */
1517df0ccbaSfvdl CLIENT *
clnt_create(const char * hostname,rpcprog_t prog,rpcvers_t vers,const char * nettype)152adb74221Smatt clnt_create(
153adb74221Smatt const char * hostname, /* server name */
154adb74221Smatt rpcprog_t prog, /* program number */
155adb74221Smatt rpcvers_t vers, /* version number */
156adb74221Smatt const char * nettype) /* net type */
1577df0ccbaSfvdl {
1587df0ccbaSfvdl struct netconfig *nconf;
1597df0ccbaSfvdl CLIENT *clnt = NULL;
1607df0ccbaSfvdl void *handle;
1617df0ccbaSfvdl enum clnt_stat save_cf_stat = RPC_SUCCESS;
1627df0ccbaSfvdl struct rpc_err save_cf_error;
1637df0ccbaSfvdl
1640e8cfd8fSlukem _DIAGASSERT(hostname != NULL);
1650e8cfd8fSlukem /* XXX: nettype appears to support being NULL */
1667df0ccbaSfvdl
167deb154d2Schristos if ((handle = __rpc_setconf(nettype)) == NULL) {
16863d7b677Scgd rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
169deb154d2Schristos return (NULL);
17063d7b677Scgd }
1717df0ccbaSfvdl rpc_createerr.cf_stat = RPC_SUCCESS;
172deb154d2Schristos while (clnt == NULL) {
1737df0ccbaSfvdl if ((nconf = __rpc_getconf(handle)) == NULL) {
1747df0ccbaSfvdl if (rpc_createerr.cf_stat == RPC_SUCCESS)
1757df0ccbaSfvdl rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
17663d7b677Scgd break;
17763d7b677Scgd }
1787df0ccbaSfvdl #ifdef CLNT_DEBUG
1797df0ccbaSfvdl printf("trying netid %s\n", nconf->nc_netid);
1807df0ccbaSfvdl #endif
1817df0ccbaSfvdl clnt = clnt_tp_create(hostname, prog, vers, nconf);
1827df0ccbaSfvdl if (clnt)
1837df0ccbaSfvdl break;
1847df0ccbaSfvdl else
1857df0ccbaSfvdl /*
1867df0ccbaSfvdl * Since we didn't get a name-to-address
1877df0ccbaSfvdl * translation failure here, we remember
1887df0ccbaSfvdl * this particular error. The object of
1897df0ccbaSfvdl * this is to enable us to return to the
1907df0ccbaSfvdl * caller a more-specific error than the
1917df0ccbaSfvdl * unhelpful ``Name to address translation
1927df0ccbaSfvdl * failed'' which might well occur if we
1937df0ccbaSfvdl * merely returned the last error (because
1947df0ccbaSfvdl * the local loopbacks are typically the
1957df0ccbaSfvdl * last ones in /etc/netconfig and the most
1967df0ccbaSfvdl * likely to be unable to translate a host
1977df0ccbaSfvdl * name).
1987df0ccbaSfvdl */
1997df0ccbaSfvdl if (rpc_createerr.cf_stat != RPC_N2AXLATEFAILURE) {
2007df0ccbaSfvdl save_cf_stat = rpc_createerr.cf_stat;
2017df0ccbaSfvdl save_cf_error = rpc_createerr.cf_error;
2027df0ccbaSfvdl }
2037df0ccbaSfvdl }
2047df0ccbaSfvdl
2057df0ccbaSfvdl /*
2067df0ccbaSfvdl * Attempt to return an error more specific than ``Name to address
2077df0ccbaSfvdl * translation failed''
2087df0ccbaSfvdl */
2097df0ccbaSfvdl if ((rpc_createerr.cf_stat == RPC_N2AXLATEFAILURE) &&
2107df0ccbaSfvdl (save_cf_stat != RPC_SUCCESS)) {
2117df0ccbaSfvdl rpc_createerr.cf_stat = save_cf_stat;
2127df0ccbaSfvdl rpc_createerr.cf_error = save_cf_error;
2137df0ccbaSfvdl }
2147df0ccbaSfvdl __rpc_endconf(handle);
2157df0ccbaSfvdl return (clnt);
2167df0ccbaSfvdl }
2177df0ccbaSfvdl
2187df0ccbaSfvdl /*
2197df0ccbaSfvdl * Generic client creation: takes (servers name, program-number, netconf) and
2207df0ccbaSfvdl * returns client handle. Default options are set, which the user can
2217df0ccbaSfvdl * change using the rpc equivalent of ioctl()'s : clnt_control()
2227df0ccbaSfvdl * It finds out the server address from rpcbind and calls clnt_tli_create()
2237df0ccbaSfvdl */
2247df0ccbaSfvdl CLIENT *
clnt_tp_create(const char * hostname,rpcprog_t prog,rpcvers_t vers,const struct netconfig * nconf)225adb74221Smatt clnt_tp_create(
226adb74221Smatt const char * hostname, /* server name */
227adb74221Smatt rpcprog_t prog, /* program number */
228adb74221Smatt rpcvers_t vers, /* version number */
229adb74221Smatt const struct netconfig *nconf) /* net config struct */
2307df0ccbaSfvdl {
2317df0ccbaSfvdl struct netbuf *svcaddr; /* servers address */
2327df0ccbaSfvdl CLIENT *cl = NULL; /* client handle */
2337df0ccbaSfvdl
2340e8cfd8fSlukem _DIAGASSERT(hostname != NULL);
2350e8cfd8fSlukem /* nconf is handled below */
2360e8cfd8fSlukem
237deb154d2Schristos if (nconf == NULL) {
2387df0ccbaSfvdl rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
239deb154d2Schristos return (NULL);
2407df0ccbaSfvdl }
2417df0ccbaSfvdl
2427df0ccbaSfvdl /*
2437df0ccbaSfvdl * Get the address of the server
2447df0ccbaSfvdl */
2457df0ccbaSfvdl if ((svcaddr = __rpcb_findaddr(prog, vers, nconf, hostname,
2467df0ccbaSfvdl &cl)) == NULL) {
2477df0ccbaSfvdl /* appropriate error number is set by rpcbind libraries */
248deb154d2Schristos return (NULL);
2497df0ccbaSfvdl }
250deb154d2Schristos if (cl == NULL) {
2517df0ccbaSfvdl cl = clnt_tli_create(RPC_ANYFD, nconf, svcaddr,
2527df0ccbaSfvdl prog, vers, 0, 0);
2537df0ccbaSfvdl } else {
2547df0ccbaSfvdl /* Reuse the CLIENT handle and change the appropriate fields */
2557df0ccbaSfvdl if (CLNT_CONTROL(cl, CLSET_SVC_ADDR, (void *)svcaddr) == TRUE) {
256c9cdc302Schristos if (cl->cl_netid == NULL) {
2577df0ccbaSfvdl cl->cl_netid = strdup(nconf->nc_netid);
258c9cdc302Schristos if (cl->cl_netid == NULL)
259c9cdc302Schristos goto out;
260c9cdc302Schristos }
261c9cdc302Schristos if (cl->cl_tp == NULL) {
2627df0ccbaSfvdl cl->cl_tp = strdup(nconf->nc_device);
263c9cdc302Schristos if (cl->cl_tp == NULL)
264c9cdc302Schristos goto out;
265c9cdc302Schristos }
2667df0ccbaSfvdl (void) CLNT_CONTROL(cl, CLSET_PROG, (void *)&prog);
2677df0ccbaSfvdl (void) CLNT_CONTROL(cl, CLSET_VERS, (void *)&vers);
2687df0ccbaSfvdl } else {
2697df0ccbaSfvdl CLNT_DESTROY(cl);
2707df0ccbaSfvdl cl = clnt_tli_create(RPC_ANYFD, nconf, svcaddr,
2717df0ccbaSfvdl prog, vers, 0, 0);
2727df0ccbaSfvdl }
2737df0ccbaSfvdl }
2747df0ccbaSfvdl free(svcaddr->buf);
2757df0ccbaSfvdl free(svcaddr);
2767df0ccbaSfvdl return (cl);
277c9cdc302Schristos out:
278c9cdc302Schristos clnt_destroy(cl);
279c9cdc302Schristos return NULL;
2807df0ccbaSfvdl }
2817df0ccbaSfvdl
2827df0ccbaSfvdl /*
2837df0ccbaSfvdl * Generic client creation: returns client handle.
2847df0ccbaSfvdl * Default options are set, which the user can
2857df0ccbaSfvdl * change using the rpc equivalent of ioctl()'s : clnt_control().
2867df0ccbaSfvdl * If fd is RPC_ANYFD, it will be opened using nconf.
2877df0ccbaSfvdl * It will be bound if not so.
2887df0ccbaSfvdl * If sizes are 0; appropriate defaults will be chosen.
2897df0ccbaSfvdl */
2907df0ccbaSfvdl CLIENT *
clnt_tli_create(int fd,const struct netconfig * nconf,const struct netbuf * svcaddr,rpcprog_t prog,rpcvers_t vers,u_int sendsz,u_int recvsz)291adb74221Smatt clnt_tli_create(
292adb74221Smatt int fd, /* fd */
293adb74221Smatt const struct netconfig *nconf, /* netconfig structure */
294adb74221Smatt const struct netbuf *svcaddr, /* servers address */
295adb74221Smatt rpcprog_t prog, /* program number */
296adb74221Smatt rpcvers_t vers, /* version number */
297adb74221Smatt u_int sendsz, /* send size */
298adb74221Smatt u_int recvsz) /* recv size */
2997df0ccbaSfvdl {
3007df0ccbaSfvdl CLIENT *cl; /* client handle */
3017df0ccbaSfvdl bool_t madefd = FALSE; /* whether fd opened here */
3027df0ccbaSfvdl long servtype;
3037df0ccbaSfvdl struct __rpc_sockinfo si;
3047df0ccbaSfvdl
3050e8cfd8fSlukem /* nconf is handled below */
3060e8cfd8fSlukem _DIAGASSERT(svcaddr != NULL);
3070e8cfd8fSlukem
3087df0ccbaSfvdl if (fd == RPC_ANYFD) {
309deb154d2Schristos if (nconf == NULL) {
3107df0ccbaSfvdl rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
311deb154d2Schristos return (NULL);
3127df0ccbaSfvdl }
3137df0ccbaSfvdl
3147df0ccbaSfvdl fd = __rpc_nconf2fd(nconf);
3157df0ccbaSfvdl
3167df0ccbaSfvdl if (fd == -1)
3177df0ccbaSfvdl goto err;
3187df0ccbaSfvdl
3197df0ccbaSfvdl madefd = TRUE;
3207df0ccbaSfvdl servtype = nconf->nc_semantics;
3217df0ccbaSfvdl if (!__rpc_fd2sockinfo(fd, &si))
3227df0ccbaSfvdl goto err;
323737db7eeSfvdl
324e05a011bSchristos (void)bindresvport(fd, NULL);
3257df0ccbaSfvdl } else {
3267df0ccbaSfvdl if (!__rpc_fd2sockinfo(fd, &si))
3277df0ccbaSfvdl goto err;
3287df0ccbaSfvdl servtype = __rpc_socktype2seman(si.si_socktype);
3297df0ccbaSfvdl if (servtype == -1) {
3307df0ccbaSfvdl rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
3317df0ccbaSfvdl return NULL;
3327df0ccbaSfvdl }
3337df0ccbaSfvdl
3347df0ccbaSfvdl }
3357df0ccbaSfvdl
3367df0ccbaSfvdl if (si.si_af != ((struct sockaddr *)svcaddr->buf)->sa_family) {
3377df0ccbaSfvdl rpc_createerr.cf_stat = RPC_UNKNOWNHOST; /* XXX */
3387df0ccbaSfvdl goto err1;
3397df0ccbaSfvdl }
3407df0ccbaSfvdl
3417df0ccbaSfvdl switch (servtype) {
3427df0ccbaSfvdl case NC_TPI_COTS_ORD:
3437df0ccbaSfvdl cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz);
3447df0ccbaSfvdl if (!nconf || !cl)
3457df0ccbaSfvdl break;
346*22687596Schristos (void)__rpc_setnodelay(fd, &si);
3477df0ccbaSfvdl break;
3487df0ccbaSfvdl case NC_TPI_CLTS:
3497df0ccbaSfvdl cl = clnt_dg_create(fd, svcaddr, prog, vers, sendsz, recvsz);
35063d7b677Scgd break;
35163d7b677Scgd default:
3527df0ccbaSfvdl goto err;
35363d7b677Scgd }
3547df0ccbaSfvdl
355deb154d2Schristos if (cl == NULL)
3567df0ccbaSfvdl goto err1; /* borrow errors from clnt_dg/vc creates */
3577df0ccbaSfvdl if (nconf) {
3587df0ccbaSfvdl cl->cl_netid = strdup(nconf->nc_netid);
359c9cdc302Schristos if (cl->cl_netid == NULL)
360c9cdc302Schristos goto err0;
3617df0ccbaSfvdl cl->cl_tp = strdup(nconf->nc_device);
362c9cdc302Schristos if (cl->cl_tp == NULL)
363c9cdc302Schristos goto err0;
3647df0ccbaSfvdl } else {
365c9d01e68Syamt cl->cl_netid = __UNCONST("");
366c9d01e68Syamt cl->cl_tp = __UNCONST("");
3677df0ccbaSfvdl }
3687df0ccbaSfvdl if (madefd) {
369deb154d2Schristos (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL);
370c9cdc302Schristos /* (void) CLNT_CONTROL(cl, CLSET_POP_TIMOD, NULL); */
3717df0ccbaSfvdl };
3727df0ccbaSfvdl
3737df0ccbaSfvdl return (cl);
3747df0ccbaSfvdl
375c9cdc302Schristos err0:
376c9cdc302Schristos clnt_destroy(cl);
3777df0ccbaSfvdl err:
3787df0ccbaSfvdl rpc_createerr.cf_stat = RPC_SYSTEMERROR;
3797df0ccbaSfvdl rpc_createerr.cf_error.re_errno = errno;
3807df0ccbaSfvdl err1: if (madefd)
3817df0ccbaSfvdl (void) close(fd);
382deb154d2Schristos return (NULL);
38363d7b677Scgd }
3841eb9e03aSchristos
3851eb9e03aSchristos /*
3861eb9e03aSchristos * Don't block thse so interactive programs don't get stuck in lalaland.
3871eb9e03aSchristos * (easier to do this than making connect(2) non-blocking..)
3881eb9e03aSchristos */
3891eb9e03aSchristos int
__clnt_sigfillset(sigset_t * ss)3901eb9e03aSchristos __clnt_sigfillset(sigset_t *ss) {
3911eb9e03aSchristos static const int usersig[] = {
3921eb9e03aSchristos SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGTSTP
3931eb9e03aSchristos };
3941eb9e03aSchristos if (sigfillset(ss) == -1)
3951eb9e03aSchristos return -1;
3961eb9e03aSchristos for (size_t i = 0; i < __arraycount(usersig); i++)
3971eb9e03aSchristos if (sigdelset(ss, usersig[i]) == -1)
3981eb9e03aSchristos return -1;
3991eb9e03aSchristos return 0;
4001eb9e03aSchristos }
401