ReactOS 0.4.15-dev-8058-ga7cbb60
rpcb_clnt.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <sys/types.h>
#include <rpc/rpc.h>
#include <rpc/rpcb_prot.h>
#include <rpc/nettype.h>
#include <netconfig.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "rpc_com.h"
Include dependency graph for rpcb_clnt.c:

Go to the source code of this file.

Classes

struct  address_cache
 

Macros

#define RPCB_OWNER_STRING   "libtirpc"
 
#define CACHESIZE   6
 
#define CLCR_GET_RPCB_TIMEOUT   1
 
#define CLCR_SET_RPCB_TIMEOUT   2
 
#define IN4_LOCALHOST_STRING   "127.0.0.1"
 
#define IN6_LOCALHOST_STRING   "::1"
 

Functions

bool_t xdr_wrapstring (XDR *, char **)
 
static struct address_cachecheck_cache (const char *, const char *)
 
static void delete_cache (struct netbuf *)
 
static void add_cache (const char *, const char *, struct netbuf *, char *)
 
static CLIENTgetclnthandle (const char *, const struct netconfig *, char **)
 
static CLIENTlocal_rpcb (void)
 
bool_t __rpc_control (int request, void *info)
 
static struct address_cachecheck_cache (char *host, char *netid) const
 
static void add_cache (char *host, char *netid, struct netbuf *taddr, char *uaddr) const
 
static CLIENTgetclnthandle (char *host, const struct netconfig *nconf, char **targaddr) const
 
bool_t rpcb_set (rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, const struct netbuf *address)
 
bool_t rpcb_unset (rpcprog_t program, rpcvers_t version, const struct netconfig *nconf)
 
bool_t __rpcbind_is_up ()
 
struct netbuf__rpcb_findaddr_timed (rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, const char *host, CLIENT **clpp, struct timeval *tp)
 
int rpcb_getaddr (rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, struct netbuf *address, const char *host)
 
rpcblistrpcb_getmaps (struct netconfig *nconf, const char *host) const
 
enum clnt_stat rpcb_rmtcall (struct netconfig *nconf, const char *host, rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xdrargs, caddr_t argsp, xdrproc_t xdrres, caddr_t resp, struct timeval tout, const struct netbuf *addr_ptr) const
 
bool_t rpcb_gettime (char *host, time_t *timep) const
 
charrpcb_taddr2uaddr (struct netconfig *nconf, struct netbuf *taddr)
 
struct netbufrpcb_uaddr2taddr (struct netconfig *nconf, char *uaddr)
 

Variables

static struct timeval tottimeout = { 60, 0 }
 
static const struct timeval rmttimeout = { 3, 0 }
 
static struct timeval rpcbrmttime = { 15, 0 }
 
static const char nullstring [] = "\000"
 
static struct address_cachefront
 
static int cachesize
 
int __rpc_lowvers
 
rwlock_t rpcbaddr_cache_lock
 

Macro Definition Documentation

◆ CACHESIZE

#define CACHESIZE   6

Definition at line 73 of file rpcb_clnt.c.

◆ CLCR_GET_RPCB_TIMEOUT

#define CLCR_GET_RPCB_TIMEOUT   1

Definition at line 86 of file rpcb_clnt.c.

◆ CLCR_SET_RPCB_TIMEOUT

#define CLCR_SET_RPCB_TIMEOUT   2

Definition at line 87 of file rpcb_clnt.c.

◆ IN4_LOCALHOST_STRING

#define IN4_LOCALHOST_STRING   "127.0.0.1"

Definition at line 412 of file rpcb_clnt.c.

◆ IN6_LOCALHOST_STRING

#define IN6_LOCALHOST_STRING   "::1"

Definition at line 413 of file rpcb_clnt.c.

◆ RPCB_OWNER_STRING

#define RPCB_OWNER_STRING   "libtirpc"

Definition at line 71 of file rpcb_clnt.c.

Function Documentation

◆ __rpc_control()

bool_t __rpc_control ( int  request,
void info 
)

Definition at line 108 of file rpcb_clnt.c.

111{
112 switch (request) {
114 *(struct timeval *)info = tottimeout;
115 break;
117 tottimeout = *(struct timeval *)info;
118 break;
119 case CLCR_SET_LOWVERS:
120 __rpc_lowvers = *(int *)info;
121 break;
122 case CLCR_GET_LOWVERS:
123 *(int *)info = __rpc_lowvers;
124 break;
125 default:
126 return (FALSE);
127 }
128 return (TRUE);
129}
#define CLCR_GET_LOWVERS
Definition: clnt.h:177
#define CLCR_SET_LOWVERS
Definition: clnt.h:176
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int __rpc_lowvers
static struct timeval tottimeout
Definition: rpcb_clnt.c:63
#define CLCR_SET_RPCB_TIMEOUT
Definition: rpcb_clnt.c:87
#define CLCR_GET_RPCB_TIMEOUT
Definition: rpcb_clnt.c:86
Definition: tftpd.h:86

◆ __rpcb_findaddr_timed()

struct netbuf * __rpcb_findaddr_timed ( rpcprog_t  program,
rpcvers_t  version,
const struct netconfig nconf,
const char host,
CLIENT **  clpp,
struct timeval tp 
)

Definition at line 709 of file rpcb_clnt.c.

716{
717#ifdef NOTUSED
718 static bool_t check_rpcbind = TRUE;
719#endif
720 CLIENT *client = NULL;
721 RPCB parms;
722 enum clnt_stat clnt_st;
723 char *ua = NULL;
724 rpcvers_t vers;
725 struct netbuf *address = NULL;
726 rpcvers_t start_vers = RPCBVERS4;
727 struct netbuf servaddr;
728
729 /* parameter checking */
730 if (nconf == NULL) {
732 return (NULL);
733 }
734
735 parms.r_addr = NULL;
736
737 /*
738 * Use default total timeout if no timeout is specified.
739 */
740 if (tp == NULL)
741 tp = &tottimeout;
742
743#ifdef PORTMAP
744 /* Try version 2 for TCP or UDP */
745 if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
746 u_short port = 0;
747 struct netbuf remote;
748 rpcvers_t pmapvers = 2;
749 struct pmap pmapparms;
750
751 /*
752 * Try UDP only - there are some portmappers out
753 * there that use UDP only.
754 */
755 if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
756 struct netconfig *newnconf;
757
758 if ((newnconf = getnetconfigent("udp")) == NULL) {
760 return (NULL);
761 }
762 client = getclnthandle(host, newnconf, &parms.r_addr);
763 freenetconfigent(newnconf);
764 } else if (strcmp(nconf->nc_proto, NC_UDP) == 0)
765 client = getclnthandle(host, nconf, &parms.r_addr);
766 else
767 goto try_rpcbind;
768 if (client == NULL)
769 return (NULL);
770
771 /*
772 * Set version and retry timeout.
773 */
775 CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
776
777 pmapparms.pm_prog = program;
778 pmapparms.pm_vers = version;
779 pmapparms.pm_prot = strcmp(nconf->nc_proto, NC_TCP) ?
781 pmapparms.pm_port = 0; /* not needed */
783 (xdrproc_t) xdr_pmap, (caddr_t)(void *)&pmapparms,
784 (xdrproc_t) xdr_u_short, (caddr_t)(void *)&port,
785 *tp);
786 if (clnt_st != RPC_SUCCESS) {
787 if ((clnt_st == RPC_PROGVERSMISMATCH) ||
788 (clnt_st == RPC_PROGUNAVAIL))
789 goto try_rpcbind;
792 goto error;
793 } else if (port == 0) {
794 address = NULL;
796 goto error;
797 }
798 port = htons(port);
799 CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote);
800 if (((address = (struct netbuf *)
801 malloc(sizeof (struct netbuf))) == NULL) ||
802 ((address->buf = (char *)
803 malloc(remote.len)) == NULL)) {
806 if (address) {
807 free(address);
808 address = NULL;
809 }
810 goto error;
811 }
812 memcpy(address->buf, remote.buf, remote.len);
813 memcpy(&((char *)address->buf)[sizeof (short)],
814 (char *)(void *)&port, sizeof (short));
815 address->len = address->maxlen = remote.len;
816 goto done;
817 }
818
819try_rpcbind:
820#endif /* PORTMAP */
821
822 parms.r_prog = program;
823 parms.r_vers = version;
824 parms.r_netid = nconf->nc_netid;
825
826 /*
827 * rpcbind ignores the r_owner field in GETADDR requests, but we
828 * need to give xdr_rpcb something to gnaw on. Might as well make
829 * it something human readable for when we see these in captures.
830 */
832
833 /* Now the same transport is to be used to get the address */
834 if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
835 (nconf->nc_semantics == NC_TPI_COTS))) {
836 /* A CLTS type of client - destroy it */
838 client = NULL;
839 free(parms.r_addr);
840 parms.r_addr = NULL;
841 }
842
843 if (client == NULL) {
844 client = getclnthandle(host, nconf, &parms.r_addr);
845 if (client == NULL) {
846 goto error;
847 }
848 }
849 if (parms.r_addr == NULL) {
850 /*LINTED const castaway*/
851 parms.r_addr = (char *) &nullstring[0];
852 }
853
854 /* First try from start_vers(4) and then version 3 (RPCBVERS) */
855
857 for (vers = start_vers; vers >= RPCBVERS; vers--) {
858 /* Set the version */
859 CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers);
861 (xdrproc_t) xdr_rpcb, (char *)(void *)&parms,
862 (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp);
863 if (clnt_st == RPC_SUCCESS) {
864 if ((ua == NULL) || (ua[0] == 0)) {
865 /* address unknown */
867 goto error;
868 }
869 address = uaddr2taddr(nconf, ua);
870#ifdef ND_DEBUG
871 fprintf(stderr, "\tRemote address is [%s]\n", ua);
872 if (!address)
874 "\tCouldn't resolve remote address!\n");
875#endif
877 (char *)(void *)&ua);
878
879 if (! address) {
880 /* We don't know about your universal address */
882 goto error;
883 }
885 (char *)(void *)&servaddr);
886 __rpc_fixup_addr(address, &servaddr);
887 goto done;
888 } else if (clnt_st == RPC_PROGVERSMISMATCH) {
889 struct rpc_err rpcerr;
890 clnt_geterr(client, &rpcerr);
891 if (rpcerr.re_vers.low > RPCBVERS4)
892 goto error; /* a new version, can't handle */
893 } else if (clnt_st != RPC_PROGUNAVAIL) {
894 /* Cant handle this error */
895 rpc_createerr.cf_stat = clnt_st;
897 goto error;
898 }
899 }
900
901 if ((address == NULL) || (address->len == 0)) {
904 }
905
906error:
907 if (client) {
909 client = NULL;
910 }
911done:
912 if (nconf->nc_semantics != NC_TPI_CLTS) {
913 /* This client is the connectionless one */
914 if (client) {
916 client = NULL;
917 }
918 }
919 if (clpp) {
920 *clpp = client;
921 } else if (client) {
923 }
924 if (parms.r_addr != NULL && parms.r_addr != nullstring)
925 free(parms.r_addr);
926 return (address);
927}
bool_t xdr_u_short(XDR *xdrs, u_short *usp)
Definition: xdr.c:300
void xdr_free(xdrproc_t proc, void *objp)
Definition: xdr.c:78
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define CLSET_VERS
Definition: clnt.h:256
#define CLSET_RETRY_TIMEOUT
Definition: clnt.h:265
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)
Definition: clnt.h:199
#define CLNT_CONTROL(cl, rq, in)
Definition: clnt.h:240
#define clnt_geterr(rh, errp)
Definition: clnt.h:220
#define CLGET_SVC_ADDR
Definition: clnt.h:250
#define CLNT_DESTROY(rh)
Definition: clnt.h:275
#define RPC_PMAPFAILURE
Definition: clnt_stat.h:57
clnt_stat
Definition: clnt_stat.h:21
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_PROGNOTREGISTERED
Definition: clnt_stat.h:58
@ RPC_PROGUNAVAIL
Definition: clnt_stat.h:39
@ RPC_N2AXLATEFAILURE
Definition: clnt_stat.h:59
@ RPC_UNKNOWNPROTO
Definition: clnt_stat.h:49
@ RPC_PROGVERSMISMATCH
Definition: clnt_stat.h:40
@ RPC_SYSTEMERROR
Definition: clnt_stat.h:43
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
int32_t bool_t
Definition: types.h:101
unsigned short u_short
Definition: types.h:81
u_int32_t rpcvers_t
Definition: types.h:105
u_int32_t rpcproc_t
Definition: types.h:106
static const WCHAR version[]
Definition: asmname.c:66
USHORT port
Definition: uri.c:228
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
#define IPPROTO_TCP
Definition: ip.h:196
#define IPPROTO_UDP
Definition: ip.h:197
void freenetconfigent(struct netconfig *netconfigp)
Definition: getnetconfig.c:530
struct netconfig * getnetconfigent(char *netid) const
Definition: getnetconfig.c:432
GLuint address
Definition: glext.h:9393
GLuint program
Definition: glext.h:6723
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define htons(x)
Definition: module.h:215
#define NC_TPI_COTS
Definition: netconfig.h:36
#define NC_TPI_CLTS
Definition: netconfig.h:35
#define NC_TPI_COTS_ORD
Definition: netconfig.h:37
#define NC_TCP
Definition: netconfig.h:79
#define NC_INET
Definition: netconfig.h:52
#define NC_UDP
Definition: netconfig.h:80
bool_t xdr_pmap(XDR *xdrs, struct pmap *regs)
Definition: pmap_prot.c:45
#define PMAPPROC_GETPORT
Definition: pmap_prot.h:84
char * caddr_t
Definition: rosdhcp.h:36
struct netbuf * uaddr2taddr(const struct netconfig *nconf, const char *uaddr)
Definition: rpc_generic.c:619
static const char nullstring[]
Definition: rpcb_clnt.c:69
static CLIENT * getclnthandle(const char *, const struct netconfig *, char **)
static struct timeval rpcbrmttime
Definition: rpcb_clnt.c:65
#define RPCB_OWNER_STRING
Definition: rpcb_clnt.c:71
bool_t xdr_wrapstring(XDR *, char **)
Definition: xdr.c:772
bool_t xdr_rpcb(XDR *xdrs, RPCB *objp)
Definition: rpcb_prot.c:50
#define RPCBPROC_GETADDR
Definition: rpcb_prot.h:688
#define RPCBVERS4
Definition: rpcb_prot.h:707
#define RPCBVERS
Definition: rpcb_prot.h:627
static FILE * client
Definition: client.c:41
int __rpc_fixup_addr(struct netbuf *, const struct netbuf *)
Definition: rpc_generic.c:883
Definition: types.h:144
unsigned long nc_semantics
Definition: netconfig.h:17
char * nc_netid
Definition: netconfig.h:16
char * nc_protofmly
Definition: netconfig.h:19
char * nc_proto
Definition: netconfig.h:20
Definition: pmap_prot.h:88
struct rpc_err cf_error
Definition: clnt.h:497
enum clnt_stat cf_stat
Definition: clnt.h:496
Definition: clnt.h:95
char * r_netid
Definition: rpcb_prot.h:143
rpcvers_t r_vers
Definition: rpcb_prot.h:142
char * r_owner
Definition: rpcb_prot.h:145
rpcprog_t r_prog
Definition: rpcb_prot.h:141
char * r_addr
Definition: rpcb_prot.h:144
char * host
Definition: whois.c:55
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144

Referenced by clnt_tp_create_timed(), and rpcb_getaddr().

◆ __rpcbind_is_up()

bool_t __rpcbind_is_up ( )

Definition at line 655 of file rpcb_clnt.c.

656{
657 struct netconfig *nconf;
658 struct sockaddr_un sun;
659 void *localhandle;
660 SOCKET sock;
661
662 nconf = NULL;
663 localhandle = setnetconfig();
664 while ((nconf = getnetconfig(localhandle)) != NULL) {
665 if (nconf->nc_protofmly != NULL &&
666 strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
667 break;
668 }
669 if (nconf == NULL)
670 return (FALSE);
671
672 endnetconfig(localhandle);
673
674 memset(&sun, 0, sizeof sun);
676 if (sock == INVALID_SOCKET)
677 return (FALSE);
678 sun.sun_family = AF_UNIX;
679 strncpy(sun.sun_path, _PATH_RPCBINDSOCK, sizeof(sun.sun_path));
680
681 if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) == SOCKET_ERROR) {
683 return (FALSE);
684 }
685
687 return (TRUE);
688}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define SOCK_STREAM
Definition: tcpip.h:118
int endnetconfig(void *handlep)
Definition: getnetconfig.c:373
struct netconfig * getnetconfig(void *handlep)
Definition: getnetconfig.c:253
void * setnetconfig()
Definition: getnetconfig.c:217
#define closesocket
Definition: ncftp.h:477
#define NC_LOOPBACK
Definition: netconfig.h:51
#define _PATH_RPCBINDSOCK
Definition: rpcb_prot.h:485
#define memset(x, y, z)
Definition: compat.h:39
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
Definition: tcpcore.h:1455
#define AF_UNIX
Definition: winsock.h:345
#define INVALID_SOCKET
Definition: winsock.h:332
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCKET_ERROR
Definition: winsock.h:333

◆ add_cache() [1/2]

static void add_cache ( char host,
char netid,
struct netbuf taddr,
char uaddr 
) const
static

Definition at line 198 of file rpcb_clnt.c.

202{
203 struct address_cache *ad_cache, *cptr, *prevptr;
204
205 ad_cache = (struct address_cache *)
206 malloc(sizeof (struct address_cache));
207 if (!ad_cache) {
208 return;
209 }
210 ad_cache->ac_host = strdup(host);
211 ad_cache->ac_netid = strdup(netid);
212 ad_cache->ac_uaddr = uaddr ? strdup(uaddr) : NULL;
213 ad_cache->ac_taddr = (struct netbuf *)malloc(sizeof (struct netbuf));
214 if (!ad_cache->ac_host || !ad_cache->ac_netid || !ad_cache->ac_taddr ||
215 (uaddr && !ad_cache->ac_uaddr)) {
216 return;
217 }
218 ad_cache->ac_taddr->len = ad_cache->ac_taddr->maxlen = taddr->len;
219 ad_cache->ac_taddr->buf = (char *) malloc(taddr->len);
220 if (ad_cache->ac_taddr->buf == NULL) {
221 return;
222 }
223 memcpy(ad_cache->ac_taddr->buf, taddr->buf, taddr->len);
224#ifdef ND_DEBUG
225 fprintf(stderr, "Added to cache: %s : %s\n", host, netid);
226#endif
227
228/* VARIABLES PROTECTED BY rpcbaddr_cache_lock: cptr */
229
231 if (cachesize < CACHESIZE) {
232 ad_cache->ac_next = front;
233 front = ad_cache;
234 cachesize++;
235 } else {
236 /* Free the last entry */
237 cptr = front;
238 prevptr = NULL;
239 while (cptr->ac_next) {
240 prevptr = cptr;
241 cptr = cptr->ac_next;
242 }
243
244#ifdef ND_DEBUG
245 fprintf(stderr, "Deleted from cache: %s : %s\n",
246 cptr->ac_host, cptr->ac_netid);
247#endif
248 free(cptr->ac_host);
249 free(cptr->ac_netid);
250 free(cptr->ac_taddr->buf);
251 free(cptr->ac_taddr);
252 if (cptr->ac_uaddr)
253 free(cptr->ac_uaddr);
254
255 if (prevptr) {
256 prevptr->ac_next = NULL;
257 ad_cache->ac_next = front;
258 front = ad_cache;
259 } else {
260 front = ad_cache;
261 ad_cache->ac_next = NULL;
262 }
263 free(cptr);
264 }
266}
#define rwlock_wrlock(l)
Definition: reentrant.h:140
#define rwlock_unlock(l)
Definition: reentrant.h:142
rwlock_t rpcbaddr_cache_lock
Definition: mt_misc.c:25
#define CACHESIZE
Definition: rpcb_clnt.c:73
static struct address_cache * front
Definition: rpcb_clnt.c:83
static int cachesize
Definition: rpcb_clnt.c:84
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
char * ac_netid
Definition: rpcb_clnt.c:77
struct netbuf * ac_taddr
Definition: rpcb_clnt.c:79
char * ac_host
Definition: rpcb_clnt.c:76
char * ac_uaddr
Definition: rpcb_clnt.c:78
struct address_cache * ac_next
Definition: rpcb_clnt.c:80
void * buf
Definition: types.h:147
unsigned int len
Definition: types.h:146

◆ add_cache() [2/2]

static void add_cache ( const char ,
const char ,
struct netbuf ,
char  
)
static

Referenced by getclnthandle().

◆ check_cache() [1/2]

static struct address_cache * check_cache ( char host,
char netid 
) const
static

Definition at line 150 of file rpcb_clnt.c.

152{
153 struct address_cache *cptr;
154
155 /* READ LOCK HELD ON ENTRY: rpcbaddr_cache_lock */
156
157 for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
158 if (!strcmp(cptr->ac_host, host) &&
159 !strcmp(cptr->ac_netid, netid)) {
160#ifdef ND_DEBUG
161 fprintf(stderr, "Found cache entry for %s: %s\n",
162 host, netid);
163#endif
164 return (cptr);
165 }
166 }
167 return ((struct address_cache *) NULL);
168}

◆ check_cache() [2/2]

static struct address_cache * check_cache ( const char ,
const char  
)
static

Referenced by getclnthandle().

◆ delete_cache()

static void delete_cache ( struct netbuf addr)
static

Definition at line 171 of file rpcb_clnt.c.

173{
174 struct address_cache *cptr, *prevptr = NULL;
175
176 /* WRITE LOCK HELD ON ENTRY: rpcbaddr_cache_lock */
177 for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
178 if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) {
179 free(cptr->ac_host);
180 free(cptr->ac_netid);
181 free(cptr->ac_taddr->buf);
182 free(cptr->ac_taddr);
183 if (cptr->ac_uaddr)
184 free(cptr->ac_uaddr);
185 if (prevptr)
186 prevptr->ac_next = cptr->ac_next;
187 else
188 front = cptr->ac_next;
189 free(cptr);
190 cachesize--;
191 break;
192 }
193 prevptr = cptr;
194 }
195}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by getclnthandle(), and FindProgramDlg::Refresh().

◆ getclnthandle() [1/2]

static CLIENT * getclnthandle ( char host,
const struct netconfig nconf,
char **  targaddr 
) const
static

Definition at line 276 of file rpcb_clnt.c.

280{
281 CLIENT *client;
282 struct netbuf *addr, taddr;
283 struct netbuf addr_to_delete;
284 struct __rpc_sockinfo si;
285 struct addrinfo hints, *res, *tres;
286 struct address_cache *ad_cache;
287 char *tmpaddr;
288
289/* VARIABLES PROTECTED BY rpcbaddr_cache_lock: ad_cache */
290
291 /* Get the address of the rpcbind. Check cache first */
292 client = NULL;
293 addr_to_delete.len = 0;
295 ad_cache = NULL;
296 if (host != NULL)
297 ad_cache = check_cache(host, nconf->nc_netid);
298 if (ad_cache != NULL) {
299 addr = ad_cache->ac_taddr;
302 if (client != NULL) {
303 if (targaddr)
304 *targaddr = strdup(ad_cache->ac_uaddr);
306 return (client);
307 }
308 addr_to_delete.len = addr->len;
309 addr_to_delete.buf = (char *)malloc(addr->len);
310 if (addr_to_delete.buf == NULL) {
311 addr_to_delete.len = 0;
312 } else {
313 memcpy(addr_to_delete.buf, addr->buf, addr->len);
314 }
315 }
317 if (addr_to_delete.len != 0) {
318 /*
319 * Assume this may be due to cache data being
320 * outdated
321 */
323 delete_cache(&addr_to_delete);
325 free(addr_to_delete.buf);
326 }
327 if (!__rpc_nconf2sockinfo(nconf, &si)) {
329 return NULL;
330 }
331
332 memset(&hints, 0, sizeof hints);
333 hints.ai_family = si.si_af;
334 hints.ai_socktype = si.si_socktype;
335 hints.ai_protocol = si.si_proto;
336
337#ifdef CLNT_DEBUG
338 printf("trying netid %s family %d proto %d socktype %d\n",
339 nconf->nc_netid, si.si_af, si.si_proto, si.si_socktype);
340#endif
341
342 if (nconf->nc_protofmly != NULL && strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) {
343 client = local_rpcb();
344 if (! client) {
345#ifdef ND_DEBUG
346 clnt_pcreateerror("rpcbind clnt interface");
347#endif
348 return (NULL);
349 } else {
350 struct sockaddr_un sun;
351
352 *targaddr = malloc(sizeof(sun.sun_path));
353 strncpy(*targaddr, _PATH_RPCBINDSOCK,
354 sizeof(sun.sun_path));
355 return (client);
356 }
357 } else {
358 if (getaddrinfo(host, "sunrpc", &hints, &res) != 0) {
360 return NULL;
361 }
362 }
363
364 for (tres = res; tres != NULL; tres = tres->ai_next) {
365 taddr.buf = tres->ai_addr;
366 taddr.len = taddr.maxlen = tres->ai_addrlen;
367
368#ifdef ND_DEBUG
369 {
370 char *ua;
371
372 ua = taddr2uaddr(nconf, &taddr);
373 fprintf(stderr, "Got it [%s]\n", ua);
374 free(ua);
375 }
376#endif
377
378#ifdef ND_DEBUG
379 {
380 int i;
381
382 fprintf(stderr, "\tnetbuf len = %d, maxlen = %d\n",
383 taddr.len, taddr.maxlen);
384 fprintf(stderr, "\tAddress is ");
385 for (i = 0; i < taddr.len; i++)
386 fprintf(stderr, "%u.", ((char *)(taddr.buf))[i]);
387 fprintf(stderr, "\n");
388 }
389#endif
390 client = clnt_tli_create(RPC_ANYFD, nconf, &taddr,
392#ifdef ND_DEBUG
393 if (! client) {
394 clnt_pcreateerror("rpcbind clnt interface");
395 }
396#endif
397
398 if (client) {
399 tmpaddr = targaddr ? taddr2uaddr(nconf, &taddr) : NULL;
400 add_cache(host, nconf->nc_netid, &taddr, tmpaddr);
401 if (targaddr)
402 *targaddr = tmpaddr;
403 break;
404 }
405 }
406 if (res)
408 return (client);
409}
CLIENT * clnt_tli_create(const SOCKET fd_in, const struct netconfig *nconf, struct netbuf *svcaddr, const rpcprog_t prog, const rpcvers_t vers, const uint sendsz, const uint recvsz, int(*callback_xdr)(void *, void *), int(*callback_function)(void *, void *, void **), void *callback_args)
Definition: clnt_generic.c:347
void clnt_pcreateerror(char *s) const
Definition: clnt_perror.c:307
@ RPC_UNKNOWNHOST
Definition: clnt_stat.h:48
#define RPC_ANYFD
Definition: svc.h:328
u_int32_t rpcprog_t
Definition: types.h:104
#define printf
Definition: freeldr.h:97
GLuint res
Definition: glext.h:9613
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define rwlock_rdlock(l)
Definition: reentrant.h:139
char * taddr2uaddr(const struct netconfig *nconf, const struct netbuf *nbuf)
Definition: rpc_generic.c:609
int __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:540
static void add_cache(const char *, const char *, struct netbuf *, char *)
static struct address_cache * check_cache(const char *, const char *)
static void delete_cache(struct netbuf *)
Definition: rpcb_clnt.c:171
static CLIENT * local_rpcb(void)
Definition: rpcb_clnt.c:420
#define RPCBPROG
Definition: rpcb_prot.h:626
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
size_t ai_addrlen
Definition: ws2def.h:669
struct sockaddr * ai_addr
Definition: ws2def.h:671
struct addrinfo * ai_next
Definition: ws2def.h:672
unsigned int maxlen
Definition: types.h:145
#define getaddrinfo
Definition: wspiapi.h:44
#define freeaddrinfo
Definition: wspiapi.h:46

◆ getclnthandle() [2/2]

static CLIENT * getclnthandle ( const char ,
const struct netconfig ,
char **   
)
static

◆ local_rpcb()

static CLIENT * local_rpcb ( void  )
static

Definition at line 420 of file rpcb_clnt.c.

421{
422 CLIENT *client;
423 static struct netconfig *loopnconf;
424 static char *hostname;
425 extern mutex_t loopnconf_lock;
426 SOCKET sock;
427 size_t tsize;
428 struct netbuf nbuf;
429 struct sockaddr_un sun;
430
431 /*
432 * Try connecting to the local rpcbind through a local socket
433 * first. If this doesn't work, try all transports defined in
434 * the netconfig file.
435 */
436 memset(&sun, 0, sizeof sun);
438 if (sock == INVALID_SOCKET)
439 goto try_nconf;
440 sun.sun_family = AF_UNIX;
441 strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
442 nbuf.len = SUN_LEN(&sun);
443 nbuf.maxlen = sizeof (struct sockaddr_un);
444 nbuf.buf = &sun;
445
446 tsize = __rpc_get_t_size(AF_UNIX, 0, 0);
448 (rpcvers_t)RPCBVERS, (u_int)tsize, (u_int)tsize,
449 NULL, NULL, NULL);
450
451 if (client != NULL) {
452 /* Mark the socket to be closed in destructor */
454 return client;
455 }
456
457 /* Nobody needs this socket anymore; free the descriptor. */
459
460try_nconf:
461
462/* VARIABLES PROTECTED BY loopnconf_lock: loopnconf */
464 if (loopnconf == NULL) {
465 struct netconfig *nconf, *tmpnconf = NULL;
466 void *nc_handle;
467 SOCKET fd;
468
469 nc_handle = setnetconfig();
470 if (nc_handle == NULL) {
471 /* fails to open netconfig file */
472 //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
475 return (NULL);
476 }
477 while ((nconf = getnetconfig(nc_handle)) != NULL) {
478#ifdef INET6
479 if ((strcmp(nconf->nc_protofmly, NC_INET6) == 0 ||
480#else
481 if ((
482#endif
483 strcmp(nconf->nc_protofmly, NC_INET) == 0) &&
484 (nconf->nc_semantics == NC_TPI_COTS ||
485 nconf->nc_semantics == NC_TPI_COTS_ORD)) {
486 fd = __rpc_nconf2fd(nconf);
487 /*
488 * Can't create a socket, assume that
489 * this family isn't configured in the kernel.
490 */
491 if (fd == SOCKET_ERROR)
492 continue;
493 closesocket(fd);
494 tmpnconf = nconf;
495 if (!strcmp(nconf->nc_protofmly, NC_INET))
496 hostname = IN4_LOCALHOST_STRING;
497 else
498 hostname = IN6_LOCALHOST_STRING;
499 }
500 }
501 if (tmpnconf == NULL) {
504 return (NULL);
505 }
506 loopnconf = getnetconfigent(tmpnconf->nc_netid);
507 /* loopnconf is never freed */
508 endnetconfig(nc_handle);
509 }
511 client = getclnthandle(hostname, loopnconf, NULL);
512 return (client);
513}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * hostname
Definition: ftp.c:88
#define CLSET_FD_CLOSE
Definition: clnt.h:251
CLIENT * clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog, const rpcvers_t vers, u_int sendsz, u_int recvsz, int *cb_xdr, int *cb_fn, void *cb_args)
Definition: clnt_vc.c:324
UINT32 u_int
Definition: types.h:82
if(dx< 0)
Definition: linetemp.h:194
mutex_t loopnconf_lock
Definition: mt_misc.c:68
#define NC_INET6
Definition: netconfig.h:53
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
u_int __rpc_get_t_size(int af, int proto, int size)
Definition: rpc_generic.c:139
static int fd
Definition: io.c:51
Definition: module.h:456
#define SUN_LEN(ptr)
Definition: wintirpc.h:94

Referenced by getclnthandle(), rpcb_set(), rpcb_taddr2uaddr(), rpcb_uaddr2taddr(), and rpcb_unset().

◆ rpcb_getaddr()

int rpcb_getaddr ( rpcprog_t  program,
rpcvers_t  version,
const struct netconfig nconf,
struct netbuf address,
const char host 
)

Definition at line 939 of file rpcb_clnt.c.

945{
946 struct netbuf *na;
947
949 (struct netconfig *) nconf, (char *) host,
950 (CLIENT **) NULL, (struct timeval *) NULL)) == NULL)
951 return (FALSE);
952
953 if (na->len > address->maxlen) {
954 /* Too long address */
955 free(na->buf);
956 free(na);
958 return (FALSE);
959 }
960 memcpy(address->buf, na->buf, (size_t)na->len);
961 address->len = na->len;
962 free(na->buf);
963 free(na);
964 return (TRUE);
965}
@ RPC_FAILED
Definition: clnt_stat.h:68
struct netbuf * __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, const char *host, CLIENT **clpp, struct timeval *tp)
Definition: rpcb_clnt.c:709

◆ rpcb_getmaps()

rpcblist * rpcb_getmaps ( struct netconfig nconf,
const char host 
) const

Definition at line 975 of file rpcb_clnt.c.

978{
980 CLIENT *client;
981 enum clnt_stat clnt_st;
982 rpcvers_t vers = 0;
983
984 client = getclnthandle(host, nconf, NULL);
985 if (client == NULL) {
986 return (head);
987 }
990 (char *)(void *)&head, tottimeout);
991 if (clnt_st == RPC_SUCCESS)
992 goto done;
993
994 if ((clnt_st != RPC_PROGVERSMISMATCH) &&
995 (clnt_st != RPC_PROGUNAVAIL)) {
998 goto done;
999 }
1000
1001 /* fall back to earlier version */
1002 CLNT_CONTROL(client, CLGET_VERS, (char *)(void *)&vers);
1003 if (vers == RPCBVERS4) {
1004 vers = RPCBVERS;
1005 CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers);
1008 (char *)(void *)&head, tottimeout) == RPC_SUCCESS)
1009 goto done;
1010 }
1013
1014done:
1016 return (head);
1017}
bool_t xdr_void(void)
Definition: xdr.c:92
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define CLGET_VERS
Definition: clnt.h:255
@ RPC_RPCBFAILURE
Definition: clnt_stat.h:56
bool_t xdr_rpcblist_ptr(XDR *xdrs, rpcblist_ptr *rp)
Definition: rpcb_prot.c:108
#define RPCBPROC_DUMP
Definition: rpcb_prot.h:691

◆ rpcb_gettime()

bool_t rpcb_gettime ( char host,
time_t timep 
) const

Definition at line 1109 of file rpcb_clnt.c.

1112{
1113 CLIENT *client = NULL;
1114 void *handle;
1115 struct netconfig *nconf;
1116 rpcvers_t vers;
1117 enum clnt_stat st;
1118
1119 if ((host == NULL) || (host[0] == 0)) {
1120 time(timep);
1121 return (TRUE);
1122 }
1123
1124 if ((handle = __rpc_setconf("netpath")) == NULL) {
1126 return (FALSE);
1127 }
1129 while (client == NULL) {
1130 if ((nconf = __rpc_getconf(handle)) == NULL) {
1133 break;
1134 }
1135 client = getclnthandle(host, nconf, NULL);
1136 if (client)
1137 break;
1138 }
1140 if (client == (CLIENT *) NULL) {
1141 return (FALSE);
1142 }
1143
1146 (xdrproc_t) xdr_int, (char *)(void *)timep, tottimeout);
1147
1148 if ((st == RPC_PROGVERSMISMATCH) || (st == RPC_PROGUNAVAIL)) {
1149 CLNT_CONTROL(client, CLGET_VERS, (char *)(void *)&vers);
1150 if (vers == RPCBVERS4) {
1151 /* fall back to earlier version */
1152 vers = RPCBVERS;
1153 CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers);
1156 (xdrproc_t) xdr_int, (char *)(void *)timep,
1157 tottimeout);
1158 }
1159 }
1161 return (st == RPC_SUCCESS? TRUE: FALSE);
1162}
bool_t xdr_int(XDR *xdrs, int *ip)
Definition: xdr.c:103
__u16 time
Definition: mkdosfs.c:8
void * __rpc_setconf(char *nettype) const
Definition: rpc_generic.c:305
struct netconfig * __rpc_getconf(void *vhandle)
Definition: rpc_generic.c:348
void __rpc_endconf(void *vhandle)
Definition: rpc_generic.c:425
#define RPCBPROC_GETTIME
Definition: rpcb_prot.h:697

◆ rpcb_rmtcall()

enum clnt_stat rpcb_rmtcall ( struct netconfig nconf,
const char host,
rpcprog_t  prog,
rpcvers_t  vers,
rpcproc_t  proc,
xdrproc_t  xdrargs,
caddr_t  argsp,
xdrproc_t  xdrres,
caddr_t  resp,
struct timeval  tout,
const struct netbuf addr_ptr 
) const

Definition at line 1027 of file rpcb_clnt.c.

1038{
1039 CLIENT *client;
1040 enum clnt_stat stat;
1041 struct r_rpcb_rmtcallargs a;
1042 struct r_rpcb_rmtcallres r;
1043 rpcvers_t rpcb_vers;
1044
1045 stat = 0;
1046 client = getclnthandle(host, nconf, NULL);
1047 if (client == NULL) {
1048 return (RPC_FAILED);
1049 }
1050 /*LINTED const castaway*/
1052 a.prog = prog;
1053 a.vers = vers;
1054 a.proc = proc;
1055 a.args.args_val = argsp;
1056 a.xdr_args = xdrargs;
1057 r.addr = NULL;
1058 r.results.results_val = resp;
1059 r.xdr_res = xdrres;
1060
1061 for (rpcb_vers = RPCBVERS4; rpcb_vers >= RPCBVERS; rpcb_vers--) {
1062 CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&rpcb_vers);
1064 (xdrproc_t) xdr_rpcb_rmtcallargs, (char *)(void *)&a,
1065 (xdrproc_t) xdr_rpcb_rmtcallres, (char *)(void *)&r, tout);
1066 if ((stat == RPC_SUCCESS) && (addr_ptr != NULL)) {
1067 struct netbuf *na;
1068 /*LINTED const castaway*/
1069 na = uaddr2taddr((struct netconfig *) nconf, r.addr);
1070 if (!na) {
1072 /*LINTED const castaway*/
1073 ((struct netbuf *) addr_ptr)->len = 0;
1074 goto error;
1075 }
1076 if (na->len > addr_ptr->maxlen) {
1077 /* Too long address */
1078 stat = RPC_FAILED; /* XXX A better error no */
1079 free(na->buf);
1080 free(na);
1081 /*LINTED const castaway*/
1082 ((struct netbuf *) addr_ptr)->len = 0;
1083 goto error;
1084 }
1085 memcpy(addr_ptr->buf, na->buf, (size_t)na->len);
1086 /*LINTED const castaway*/
1087 ((struct netbuf *)addr_ptr)->len = na->len;
1088 free(na->buf);
1089 free(na);
1090 break;
1091 } else if ((stat != RPC_PROGVERSMISMATCH) &&
1092 (stat != RPC_PROGUNAVAIL)) {
1093 goto error;
1094 }
1095 }
1096error:
1098 if (r.addr)
1099 xdr_free((xdrproc_t) xdr_wrapstring, (char *)(void *)&r.addr);
1100 return (stat);
1101}
#define stat
Definition: acwin.h:99
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
char * prog
Definition: isohybrid.c:47
static HANDLE proc()
Definition: pdb.c:34
static const struct timeval rmttimeout
Definition: rpcb_clnt.c:64
bool_t xdr_rpcb_rmtcallres(XDR *xdrs, struct rpcb_rmtcallres *p)
Definition: rpcb_prot.c:322
bool_t xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *p)
Definition: rpcb_prot.c:270
#define RPCBPROC_CALLIT
Definition: rpcb_prot.h:694
Definition: stat.h:55

◆ rpcb_set()

bool_t rpcb_set ( rpcprog_t  program,
rpcvers_t  version,
const struct netconfig nconf,
const struct netbuf address 
)

Definition at line 520 of file rpcb_clnt.c.

525{
526 CLIENT *client;
527 bool_t rslt = FALSE;
528 RPCB parms;
529 char uidbuf[32];
530
531 /* parameter checking */
532 if (nconf == NULL) {
534 return (FALSE);
535 }
536 if (address == NULL) {
538 return (FALSE);
539 }
540 client = local_rpcb();
541 if (! client) {
542 return (FALSE);
543 }
544
545 /* convert to universal */
546 /*LINTED const castaway*/
547 parms.r_addr = taddr2uaddr((struct netconfig *) nconf,
548 (struct netbuf *)address);
549 if (!parms.r_addr) {
552 return (FALSE); /* no universal address */
553 }
554 parms.r_prog = program;
555 parms.r_vers = version;
556 parms.r_netid = nconf->nc_netid;
557 /*
558 * Though uid is not being used directly, we still send it for
559 * completeness. For non-unix platforms, perhaps some other
560 * string or an empty string can be sent.
561 */
562 (void) snprintf(uidbuf, sizeof uidbuf, "%d", 20010 /*geteuid()*/);
563 parms.r_owner = uidbuf;
564
566 (char *)&parms, (xdrproc_t) xdr_bool,
567 (char *)&rslt, tottimeout);
568
570 free(parms.r_addr);
571 return (rslt);
572}
bool_t xdr_bool(XDR *xdrs, bool_t *bp)
Definition: xdr.c:428
@ RPC_UNKNOWNADDR
Definition: clnt_stat.h:50
#define RPCBPROC_SET
Definition: rpcb_prot.h:682
#define snprintf
Definition: wintirpc.h:48

Referenced by pmap_set(), and svc_reg().

◆ rpcb_taddr2uaddr()

char * rpcb_taddr2uaddr ( struct netconfig nconf,
struct netbuf taddr 
)

Definition at line 1170 of file rpcb_clnt.c.

1173{
1174 CLIENT *client;
1175 char *uaddr = NULL;
1176
1177
1178 /* parameter checking */
1179 if (nconf == NULL) {
1181 return (NULL);
1182 }
1183 if (taddr == NULL) {
1185 return (NULL);
1186 }
1187 client = local_rpcb();
1188 if (! client) {
1189 return (NULL);
1190 }
1191
1193 (xdrproc_t) xdr_netbuf, (char *)(void *)taddr,
1194 (xdrproc_t) xdr_wrapstring, (char *)(void *)&uaddr, tottimeout);
1196 return (uaddr);
1197}
bool_t xdr_netbuf(XDR *xdrs, struct netbuf *objp)
Definition: rpcb_prot.c:344
#define RPCBPROC_TADDR2UADDR
Definition: rpcb_prot.h:703

◆ rpcb_uaddr2taddr()

struct netbuf * rpcb_uaddr2taddr ( struct netconfig nconf,
char uaddr 
)

Definition at line 1204 of file rpcb_clnt.c.

1207{
1208 CLIENT *client;
1209 struct netbuf *taddr;
1210
1211
1212 /* parameter checking */
1213 if (nconf == NULL) {
1215 return (NULL);
1216 }
1217 if (uaddr == NULL) {
1219 return (NULL);
1220 }
1221 client = local_rpcb();
1222 if (! client) {
1223 return (NULL);
1224 }
1225
1226 taddr = (struct netbuf *)calloc(1, sizeof (struct netbuf));
1227 if (taddr == NULL) {
1229 return (NULL);
1230 }
1232 (xdrproc_t) xdr_wrapstring, (char *)(void *)&uaddr,
1233 (xdrproc_t) xdr_netbuf, (char *)(void *)taddr,
1234 tottimeout) != RPC_SUCCESS) {
1235 free(taddr);
1236 taddr = NULL;
1237 }
1239 return (taddr);
1240}
#define calloc
Definition: rosglue.h:14
#define RPCBPROC_UADDR2TADDR
Definition: rpcb_prot.h:700

◆ rpcb_unset()

bool_t rpcb_unset ( rpcprog_t  program,
rpcvers_t  version,
const struct netconfig nconf 
)

Definition at line 581 of file rpcb_clnt.c.

585{
586 CLIENT *client;
587 bool_t rslt = FALSE;
588 RPCB parms;
589 char uidbuf[32];
590
591 client = local_rpcb();
592 if (! client) {
593 return (FALSE);
594 }
595
596 parms.r_prog = program;
597 parms.r_vers = version;
598 if (nconf)
599 parms.r_netid = nconf->nc_netid;
600 else {
601 /*LINTED const castaway*/
602 parms.r_netid = (char *) &nullstring[0]; /* unsets all */
603 }
604 /*LINTED const castaway*/
605 parms.r_addr = (char *) &nullstring[0];
606 (void) snprintf(uidbuf, sizeof uidbuf, "%d", 20010 /*geteuid()*/);
607 parms.r_owner = uidbuf;
608
610 (char *)(void *)&parms, (xdrproc_t) xdr_bool,
611 (char *)(void *)&rslt, tottimeout);
612
614 return (rslt);
615}
#define RPCBPROC_UNSET
Definition: rpcb_prot.h:685

Referenced by pmap_unset(), rpc_reg(), svc_create(), svc_tp_create(), and svc_unreg().

◆ xdr_wrapstring()

bool_t xdr_wrapstring ( XDR xdrs,
char **  cpp 
)

Definition at line 772 of file xdr.c.

775{
776#ifdef __REACTOS__ // CVE-2017-8779
777 return xdr_string(xdrs, cpp, RPC_MAXDATASIZE);
778#else
779 return xdr_string(xdrs, cpp, LASTUNSIGNED);
780#endif
781}
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
#define LASTUNSIGNED
Definition: xdr.c:65
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51

Referenced by __rpcb_findaddr_timed(), rpcb_taddr2uaddr(), and rpcb_uaddr2taddr().

Variable Documentation

◆ __rpc_lowvers

int __rpc_lowvers
extern

Referenced by __rpc_control(), and rpc_broadcast_exp().

◆ cachesize

int cachesize
static

Definition at line 84 of file rpcb_clnt.c.

Referenced by add_cache(), and delete_cache().

◆ front

◆ nullstring

const char nullstring[] = "\000"
static

Definition at line 69 of file rpcb_clnt.c.

Referenced by __rpcb_findaddr_timed(), and rpcb_unset().

◆ rmttimeout

const struct timeval rmttimeout = { 3, 0 }
static

Definition at line 64 of file rpcb_clnt.c.

◆ rpcbaddr_cache_lock

rwlock_t rpcbaddr_cache_lock
extern

Definition at line 25 of file mt_misc.c.

Referenced by add_cache(), and getclnthandle().

◆ rpcbrmttime

struct timeval rpcbrmttime = { 15, 0 }
static

Definition at line 65 of file rpcb_clnt.c.

Referenced by __rpcb_findaddr_timed().

◆ tottimeout