summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rpcbind/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Follow up to r300932ngie2016-05-291-1/+2
| | | | | | | | | | | | | | | In the event MK_INET6 != no in userspace, but is disabled in the kernel, or if there aren't any IPv6 addresses configured in userspace (for lo0 and all physical interfaces), rpcbind would terminate immediately instead of silently failing on Skip over the IPv6 block to its respective cleanup with freeifaddrs if creating the socket failed instead of terminating rpcbind immediately MFC after: 6 days X-MFC with: r300932 Reported by: O. Hartmann <ohartman@zedat.fu-berlin.de> Sponsored by: EMC / Isilon Storage Division
* Fix rpcbind init after r300941.markj2016-05-291-1/+2
| | | | | | | | | | - getaddrinfo() sets res = NULL on failure and freeaddrinfo() always dereferences its argument, so we should only free the address list after a successful call. - Address a second potential leak caused by getaddrinfo(AF_INET6) overwriting the address list returned by getaddrinfo(AF_INET). X-MFC-With: r300941
* Remove unnecessary caller_uaddr != NULL test before calling free on itngie2016-05-291-2/+1
| | | | | MFC after: 3 days Sponsored by: EMC / Isilon Storage Division
* Don't leak res in network_init(..)ngie2016-05-291-0/+1
| | | | | | | | | Call freeaddrinfo on it after it's been used MFC after: 1 week Reported by: Coverity CID: 1225050 Sponsored by: EMC / Isilon Storage Division
* Plug leak with ifp by calling freeifaddrs after calling getifaddrsngie2016-05-291-0/+1
| | | | | | MFC after: 1 week Obtained from: NetBSD v1.18 Sponsored by: EMC / Isilon Storage Division
* Catch malloc(3) errors and socket(2) errorsngie2016-05-291-0/+7
| | | | | | | | | | | - malloc failing will result in a delayed segfault - socket failing will result in delayed failures with setsockopt Exit in the event that either of these high-level conditions are met. Reported by: Coverity CID: 976288, 976321, 976858 Sponsored by: EMC / Isilon Storage Division
* Only expose `hint_uaddr` in the ND_DEBUG casengie2016-05-271-0/+6
| | | | | | | | This fixes a -Wunused-but-set-variable warning with gcc MFC after: 1 week Reported by: gcc 5 Sponsored by: EMC / Isilon Storage Division
* "source routing" in rpcbindasomers2016-01-061-44/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a bug in rpcbind for multihomed hosts. If the server had interfaces on two separate subnets, and a client on the first subnet contacted rpcbind at the address on the second subnet, rpcbind would advertise addresses on the first subnet. This is a bug, because it should prefer to advertise the address where it was contacted. The requested service might be firewalled off from the address on the first subnet, for example. usr.sbin/rpcbind/check_bound.c If the address on which a request was received is known, pass that to addrmerge as the clnt_uaddr parameter. That is what addrmerge's comment indicates the parameter is supposed to mean. The previous behavior is that clnt_uaddr would contain the address from which the client sent the request. usr.sbin/rpcbind/util.c Modify addrmerge to prefer to use an IP that is equal to clnt_uaddr, if one is found. Refactor the relevant portion of the function for clarity, and to reduce the number of ifdefs. etc/mtree/BSD.tests.dist usr.sbin/rpcbind/tests/Makefile usr.sbin/rpcbind/tests/addrmerge_test.c Add unit tests for usr.sbin/rpcbind/util.c:addrmerge. usr.sbin/rpcbind/check_bound.c usr.sbin/rpcbind/rpcbind.h usr.sbin/rpcbind/util.c Constify some function arguments Reviewed by: imp MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D4690
* Fill sin6_scope_id in sockaddr_in6 before passing it from the kernel tohrs2012-11-171-24/+0
| | | | | | | | | | | | userland via routing socket or sysctl. This eliminates the following KAME-specific sin6_scope_id handling routine from each userland utility: sin6.sin6_scope_id = ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]); This behavior can be controlled by net.inet6.ip6.deembed_scopeid. This is set to 1 by default (sin6_scope_id will be filled in the kernel). Reviewed by: bz
* Use prototype. While I'm there, add a pair of parenthesis to mark an ifdelphij2011-07-141-1/+1
| | | | | | statment's border. MFC after: 1 month
* Fix typos - remove duplicate "the".brucec2011-02-211-1/+1
| | | | | | PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days
* Revert bogus change that snuck into r203972.imp2010-02-171-2/+0
|
* The NetBSD Foundation has given permission to remove clause 3 and 4imp2010-02-161-7/+2
| | | | | | from their liceense. Obtained from: NetBSD
* When you have multiple addresses on the same network on differentimp2010-02-091-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | interfaces (such as when you are part of a carp pool), and you run rpcbind -h to restrict which interfaces have rpc services, rpcbind can none-the-less return addresses that aren't in the -h list. This patch enforces the rule that when you specify -h on the command line, then services returned from rpcbind must be to one of the addresses listed in -h, or be a loopback address (since localhost is implicit when running -h). The root cause of this is the assumption in addrmerge that there can be only one interface that matches a given network IP address. This turns out not to be the case. To retain historical behavior, I didn't try to fix the routine to prefer the address that the request came into, since I didn't know the side effects that might cause in the normal case. My quick analysis suggests that it wouldn't be a problem, but since this code is tricky I opted for the more conservative patch of only restricting the reply when -h is in effect. Hence, this change will have no effect when you are running rpcbind without -h. Reviewed by: alfred@ Sponsored by: iX Systems MFC after: 2 weeks
* Cleanup of userland __P usekevlo2007-11-071-2/+2
|
* WARNS=3 safety (mostly), use __unused for unused params and unsigned wherealfred2002-10-071-1/+2
| | | | needed to avoid warnings about comparing signed and unsigned values.
* Simplify to bitmaskcmp() to use the obvious approach instead ofiedowse2001-07-141-22/+19
| | | | | | | | | | | | comparing bit by bit. Make the logic in in6_fillscopeid() match that in our ifconfig(8): only set the scope ID if there is one in the address and none in sin6_scope_id. Correct a comment in network_init() that didn't make sense; it was probably never updated after it was pasted from similar code in addrmerge().
* Clean up the addrmerge() function, which was over-complicated andiedowse2001-06-241-136/+120
| | | | | | | | | | | | | | | | | contained a number of memory leaks. The changes include: - Add a comment describing what addrmerge() does. - Deal with 0.0.0.0./::. or AF_LOCAL callers correctly. - Use rpcbind_get_conf() instead of getnetconfigent() so we don't have to remember to free the returned netconfig struct. - Make just one pass through the ifaddrs list; we can pick up a fallback interface address in the same pass as the netmask comparison. - Define and use SA2SIN* macros to avoid the need for loads of protocol-specific local variables. - Use mostly protocol-independent code for building the netbuf version of the address to be returned. - Use the common cleanup code for virtually all error and non-error cases, fixing a number of memory leaks.
* Bring in some bugfixes from NetBSD. I'm going to make a moreiedowse2001-04-261-17/+37
| | | | | | | | | | | | | | | extensive pass through the rpcbind code soon, but I might as well bring these in now. - (NetBSD util.c r1.5) Move the initialisation of `tbuf' to avoid a case where it could end up containing junk from the stack. This should address the issue in PR bin/26806. - (NetBSD util.c r1.6) Don't `merge' AF_LOCAL addresses, fix a few memory leaks. PR: bin/26806 Submitted by: Martin Blapp <mb@imp.ch> Obtained from: NetBSD
* Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) andalfred2001-03-191-0/+381
associated changes that had to happen to make this possible as well as bugs fixed along the way. Bring in required TLI library routines to support this. Since we don't support TLI we've essentially copied what NetBSD has done, adding a thin layer to emulate direct the TLI calls into BSD socket calls. This is mostly from Sun's tirpc release that was made in 1994, however some fixes were backported from the 1999 release (supposedly only made available after this porting effort was underway). The submitter has agreed to continue on and bring us up to the 1999 release. Several key features are introduced with this update: Client calls are thread safe. (1999 code has server side thread safe) Updated, a more modern interface. Many userland updates were done to bring the code up to par with the recent RPC API. There is an update to the pthreads library, a function pthread_main_np() was added to emulate a function of Sun's threads library. While we're at it, bring in NetBSD's lockd, it's been far too long of a wait. New rpcbind(8) replaces portmap(8) (supporting communication over an authenticated Unix-domain socket, and by default only allowing set and unset requests over that channel). It's much more secure than the old portmapper. Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded to support TI-RPC and to support IPV6. Umount(8) is also fixed to unmount pathnames longer than 80 chars, which are currently truncated by the Kernel statfs structure. Submitted by: Martin Blapp <mb@imp.ch> Manpage review: ru Secure RPC implemented by: wpaul
OpenPOWER on IntegriCloud