Natanael Copa [Wed, 22 Apr 2015 16:17:33 +0000 (12:17 -0400)]
Provide getrpcbynumber and getrpcbyname if those are missing
We enable the config.h again and check if getrpcbynumber and
getrpcbyname exists on the building patform. If it does not exist, then
provide those functions.
This is needed for musl libc.
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Steve Dickson <steved@redhat.com>
Olaf Kirch [Tue, 16 Dec 2014 19:02:39 +0000 (14:02 -0500)]
libtirpc: fix crash with tuntap devices
Linux tuntap devices and other virtual network devices, if not
configured, will be reported by getifaddrs() with a NULL ifa_addr
pointer. __rpc_getifaddrs would trip over that, because it derefenced
the ifa_addr pointer without checking.
Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Thorsten Kukuk [Tue, 16 Dec 2014 19:00:12 +0000 (14:00 -0500)]
tirpc: fix taddr2uaddr for AF_LOCAL
taddr2uaddr would return trailing garbage for AF_LOCAL addresses
taddr2uaddr assumed that the sun_path field of an AF_LOCAL address
was always NULL terminated, but that is not necessarily the case,
especially if the buffer was allocated using the correct SUN_LEN().
Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Olaf Kirch [Tue, 16 Dec 2014 18:48:52 +0000 (13:48 -0500)]
Fix a crash in clntunix_create
Programs using clntunix_create would abort because glibc detected an
attempt to free a bad pointer. It turns out that clntunix_create
has two bugs:
- it sets up a struct netbuf to hold the sockaddr_un passed
into the function, but instead of copying the data, it
just assigns the sockaddr pointer - and eventually tries to
free that pointer.
- when setting up the netbuf, it uses sizeof(raddr) instead
of sizeof(*raddr).
Instead of doing the trivial fixes, I changed the function to use
the __rpc_set_netbuf utility function. While I was at it, I removed
an unused local variable.
Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Olaf Kirch [Tue, 16 Dec 2014 18:38:33 +0000 (13:38 -0500)]
Fix a bug in clnt broadcast
Before calling the replyproc function on a broadcast reply,
we convert the server-provided address using uaddr2taddr.
This may fail (eg if the server provided a garbage address),
and return NULL. In this case, we should not call the replyproc
function - because the caller expects the address netbuf to
be a valid pointer, rather than NULL.
Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Bodo Stroesser [Thu, 6 Nov 2014 18:26:00 +0000 (13:26 -0500)]
write_vc: fix write retry loop for nonblocking mode
This is a simple fix for the write retry loop that is used on
non-blocking connections if write() failed with -EAGAIN.
Additionally it removes a redundant if () {}
Erroneously at each cycle of the loop the length of the data
to send is incremented and the buffer pointer is decremented.
Thus, it might happen that:
* the application crashes
* data from the memory before the buffer is sent
Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Steve Dickson [Mon, 14 Jul 2014 13:21:11 +0000 (09:21 -0400)]
print_rpc_gss_sec: Make sure logging to stderr is enabled.
It does not make sense to try an covert this routine to
used the new debugging macro. So just insure the correct
debugging level and printing to stderr is enabled.
Steve Dickson [Mon, 14 Jul 2014 13:02:10 +0000 (09:02 -0400)]
gss_log: Replace gss_log_debug with LIBTIRPC_DEBUG macros
A couple gss_log_debug() calls are reporting errors.
To allow errors to be logged with the least amount
of debugging on, replace those calls the LIBTIRPC_DEBUG
macro
Steve Dickson [Mon, 14 Jul 2014 17:05:35 +0000 (13:05 -0400)]
libtirpc: New configurable debugging routines
This patch added new configurable debugging interface that
will allow existing debugging statements to be enabled
and disabled by the calling application.
libtirpc_set_debug(char *name, int level, int use_stderr)
* This called by the application to set the debugging level.
If use_stderr is set, all message will go to stderr,
otherwise syslog() will be used.
LIBTIRPC_DEBUG(level, msg)
* This is the macro called by functions within the library.
libtirpc_log_dbg(char *fmt, ...)
* This is the routine the LIBTIRPC_DEBUG macro uses to
log the messages and can be called directly by internal
routines
vlibtirpc_log_dbg(int level, const char *fmt, va_list args)
* This routine is used by existing debugging routines
that have already obtained their arguments using
stdarg(3) macros.
Chuck Lever [Wed, 9 Apr 2014 18:00:56 +0000 (14:00 -0400)]
Pre-register server side RPCSEC GSS support
When --enable-gss is specified on the ./configure command line,
have the library automatically register server-side support for the
RPCSEC_GSS auth flavor.
The complication is that specific interaction is required with the
RPC client if GSS authentication fails. GSS authentication sometimes
has to squelch the normal reply done by svc_getreq(), and substitute
its own.
_svcauth_gss() already has a boolean argument to do this. But
_authenticate() is an official API (see rpc/svc_auth.h). We can't
alter its synopsis.
Instead of adding a "no_dispatch" argument to our existing
_authenticate() API, preserve its synopsis for backwards
compatibility, and introduce a second external authentication API
for the dispatcher.
This matches a similar API change done in the Solaris libtirpc.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 23 Jan 2014 16:24:24 +0000 (11:24 -0500)]
man: Organize man/Makefile.am
Clean up man/Makefile.
Document man pages we maintain upstream but that are typically not
installed by distributions.
Finally, restore the man page which describes the libtirpc rpcbind
client API. This includes rpcb_getmaps(3t), rpcb_getaddr(3t),
rpcb_gettime(3t), rpcb_rmtcall(3t), rpcb_set(3t), and
rpcb_unset(3t).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 23 Jan 2014 16:21:29 +0000 (11:21 -0500)]
Clean up forward declarations in src/svc_auth_gss.c
Address some sparse complaints
Bring the forward declarations for the auth_ops defined in
svc_auth_gss.c up to recent C standards. These should match the
function prototypes used to declare the auth_ops structure.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 23 Jan 2014 16:19:55 +0000 (11:19 -0500)]
Clean up forward declarations in src/auth_gss.c
Address some sparse complaints
Bring the forward declarations for the auth_ops defined in auth_gss.c
up to recent C standards. These should match the function prototypes
used to declare the auth_ops structure.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 23 Jan 2014 16:17:09 +0000 (11:17 -0500)]
Add a pthread key initializer constant
Clean up: replace the naked "-1" with a symbolic constant that helps
document what is going on. The name matches the name of the other
pthread initializer constants.
Also, since pthread_key_t is an unsigned integer, use a type cast to
eliminate the implicit cast that occurs every time foo_key is
compared to -1. This eliminates a number of compiler warnings.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 23 Jan 2014 16:13:51 +0000 (11:13 -0500)]
configure: permanently enable maintainer mode
I noticed that "make" doesn't run configure again when a patch is
applied that changes the build environment. Maintainer mode appears
to be disabled by default.
Section 27.2 of the Automake manual suggests that disabling
Maintainer Mode causes unreliable builds because it removes the
guarantee that the build environment is up to date.
Remove the configure.ac macro to disable or enable maintainer mode.
This leaves Maintainer Mode enabled all the time.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
The function clnt_create is *not* thread safe. Race conditions in the
function clnt_vc_create that accesses static data disrupt, which is
*not* protected by any mutex. When more than one thread access it
it has become a nonlocal side effect . This race conditions can lead to
undesired behaviour . By introducing the mutex disrupt_lock
the function clnt_vc_create is serialized
Signed-off-by: Susant Sahani <ssahani@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
The function clnt_create is *not* thread safe . Race conditions in
the function bindresvport that accesses static data port and startport,
which are *not* protected by any mutex. When more than one thread
access them the variables become a nonlocal side effect. These race
conditions
can lead to undesired behaviour . By introducing the mutex port_lock
the function bindresvport is serialized.
Signed-off-by: Susant Sahani <ssahani@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
The clnt_* functions are *not* thread safe. Race conditions are caused
by the functions setnetconfig , getnetconfig, endnetconfig and
getnetconfigent that accesses global static data nc_file and ni which
are defined in the file getnetconfig are *not* protected by any mutex.
When more than one thread access them the variables become a nonlocal
side effect . These race conditions causing process to give undesired
behavior and leading to crash on file operations mostly on fclose. By
introducing the mutex nc_db_lock the netconfig database is synchronized
and prevented from crash.
Signed-off-by: Susant Sahani <ssahani@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Mon, 1 Jul 2013 13:40:02 +0000 (09:40 -0400)]
Remove variadic macro invocation
Commit f8104ba9 "Fix debugging reference from non-GSS to optional"
GSS code.", Thu Apr 26 15:12:08 2012, introduces a variadic macro
invocation (a GNU C extension) in the rpc/auth.h header.
An attempt was made to hide the extension behind #ifdef __GNUC__
but the #else arm also uses the same synopsis, so the variadic macro
is visible for non-GNU C compiles as well.
With gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8) on Fedora 18, I
see:
/usr/include/tirpc/rpc/auth.h:255:32: warning: ISO C does not permit
named variadic macros [-Wvariadic-macros]
I imagine this warning is produced by the "-pedantic" gcc option,
which I use in various projects that depend on libtirpc headers.
Rather than further cluttering the code in auth.h, we can live
without this debugging message.
Cc: Nick Alcock <nick.alcock@oracle.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Steve Dickson [Thu, 18 Apr 2013 18:29:58 +0000 (14:29 -0400)]
svc_getargs(): Should not be freeing arg pointers on failures
commit 82cc2e61 (SVCAUTH_WRAP/SVCAUTH_UNWRAP) introduce a regression
that causes callers of svc_getargs() to crash when svc_freeargs() frees
args points that are allocated on the stack.
svc_getargs() should let the callers do the freeing and not make any
assumptions on the type of memory passed in.
Also see:
https://bugzilla.redhat.com/show_bug.cgi?id=948378
and
CVE-2013-1950 EMBARGOED rpcbind: invalid pointer free leads to crash
Simo Sorce [Wed, 10 Apr 2013 15:38:14 +0000 (11:38 -0400)]
gss: Fix private data giveaway
When the private data is given away the gss context also needs to go,
because the caller may destroy it, such as when the context is exported
into a lucid context to hand it to the kernel.
Signed-off-by: Simo Sorce <simo@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Simo Sorce [Tue, 26 Mar 2013 15:13:05 +0000 (11:13 -0400)]
Switch to use standard GSSAPI by default
Make libgssglue configurable still but disabled by default.
There is no reason to use libgssglue anymore, and modern gssapi
supports all needed features for libtirpc and its dependencies.
NeilBrown [Tue, 12 Feb 2013 14:43:45 +0000 (09:43 -0500)]
Add authgss_free_private_data interface.
This is a necessary partner to authgss_get_private_data, so that
the caller can free the data when needed (and not before).
The previous practice of leaving the private data where it was resulted
in authgss_destroy_context() attempting to destroy the context on the
server which was incorrect, and fortunately fails for other reasons.
An application which uses authgss_get_private_data() but does not call
authgss_free_private_data() will be as correct as, or slightly more
correct than, it was, but will suffer a slight memory leak.
When compiled on rhel 5.5, the build fails due to a missing
SOCK_CLOEXEC flag that is not available in the downstream kernel.
This patch corrects this error by checking to see if the flag is
present before using it
Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Nick Alcock [Thu, 26 Apr 2012 19:42:42 +0000 (15:42 -0400)]
Fix debugging-related namespace pollution.
From: Nick Alcock <nick.alcock@oracle.com>
When GSS is compiled in, libtirpc exports three symbols, 'log_debug',
'log_status', and 'log_hexdump', which do nothing unless DEBUG is #defined
at libtirpc compile time. This is a pretty abominable piece of namespace
pollution: these symbols are quite likely to be used for local debugging
routines by other binaries and shared libraries, and those local calls
are now likely to go astray into libtirpc's do-nothing versions instead.
So this changes the names of these functions. This is technically an ABI
break, but since these symbols are undocumented and useless (with variable
behaviour depending on whether DEBUG was #defined, and only present at
all if GSS was compiled in) anything using those symbols was broken anyway.
(A quick grep of my local sources shows numerous other local users of
the name log_debug() in particular, including LVM, libassuan, GnuPG, gvfs,
and dhcp. If you include binaries as well as intra-shared-library calls,
the count goes much higher.)
Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Nick Alcock [Thu, 26 Apr 2012 19:38:56 +0000 (15:38 -0400)]
No longer require NIS.
From: Nick Alcock <nick.alcock@oracle.com>
NIS is deader than the proverbial dodo, and eglibc allows you to compile
it out entirely. Though libtirpc can work with NIS, it works perfectly
well if NIS is not in the libc, thanks to nsswitch (acting as if NIS
is there but empty).
However, when NIS is not compiled into eglibc, libnsl is not present.
So check for it at configure time, and include it via LIBS if available.
(I suspect this LIBS-inclusion will have no effect, and we don't even
need to check for NIS at compile time, but I have no NIS-capable systems to
test this on.)
Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Nick Alcock [Thu, 26 Apr 2012 19:12:08 +0000 (15:12 -0400)]
Fix debugging reference from non-GSS to optional GSS code.
From: Nick Alcock <nick.alcock@oracle.com>
AUTH_DESTROY() and auth_destroy() are pulling in log_debug() from
authgss_prot.c, but are used from outside the GSS code, thus preventing
libtirpc
from being used if compiled without GSS support.
The (somewhat ugly) fix here defines a new macro to do the job. Because
we're
not compiling as C99, I use the GNU C variadic macro extension: if we
mean to
be compiled with other compilers, this needs to change.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Mike Frysinger [Mon, 20 Jun 2011 17:52:14 +0000 (13:52 -0400)]
Revert "Include des_crypt in build"
The des_crypt code requires the crypt_client code (which wasn't
added), and that code requires a currently undefined function
(namely xdr_desresp). Since I have no idea what that's about,
and this change ends up breaking some systems, just revert it.
Once we have a patch that improves portability without breaking
existing systems, we can revisit this.
Matthew N. Dodd [Mon, 20 Jun 2011 17:42:18 +0000 (13:42 -0400)]
Reference count AUTHs
RPCSEC GSSv3 has the concept of a parent and a compound credential. As
the normal course of operation involves using multiple AUTHs per client
connection, and providing parent and compounds AUTHs when creating a
GSSv3 AUTH, we need a way of reference counting them so that
AUTH_DESTROY does not free them out from under a GSSv3 AUTH that is
using them.
Matthew N. Dodd [Mon, 20 Jun 2011 17:33:35 +0000 (13:33 -0400)]
Use of lseek() in xdr_rec.c:xdrrec_getpos().
The use of lseek() in xdr_rec.c:xdrrec_getpos() without checking for
ESPIPE will fail to handle the common case, resulting in poor behavior
in calling code. (In particular auth_gss.c:authgss_marshal() calls
gss_get_mic() with rpcbuf.length set to -1, with spectacular results.)
The original MIT Krb5 RPC code lacks this addition, which I'm unclear of
the utility of in the first place.
Reverting to the MIT code permits correct function of a trivial RPC
client using GSS.
Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Matthew N. Dodd [Mon, 20 Jun 2011 17:32:58 +0000 (13:32 -0400)]
PCSEC_GSS_SVC_PRIVACY failure.
in authgss_prot.c:xdr_rpc_gss_wrap_data(), gss_wrap() is called in the
svc == RPCSEC_GSS_SVC_PRIVACY conditional block with databuf.length
uninitialized.
Initialization performed in the svc == RPCSEC_GSS_SVC_INTEGRITY
conditional block should be moved.
Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Steve Dickson [Sat, 18 Jun 2011 13:49:40 +0000 (09:49 -0400)]
Do not skip records with nonblocking connections
With non-blocking connections, do not skip records when receiving
the streams since entire value messages can be ignored which
in cause the entire stream to become out of sync.
For example, two mounts simultaneously send two unmaps
commands. The first one is read, then the second thrown
away due to skipping the record. Skipping this record
will cause XDR error later in processing of the stream.
Olaf Kirch [Wed, 2 Mar 2011 15:09:24 +0000 (10:09 -0500)]
Try to ensure datagram replies come from the address requests were sent to.
On multi-homed servers it is currently possible for a reply to be sent
from a different address to the one the request was received from. This
is because there is no strong connection between the request and the
reply as there is with stream.
This causes problems with some clients, particularly those that uses
connected datagram sockets.
So use IP_PKTINFO or IP6_PKTINFO to create the necessary connection,
recording the destination of the request, and setting the source of
the reply.
Note that we clear the interface index (ifindex) as it is not necessary
(and is sometimes wrong) to set the reply out on the same interface that
the request arrived on.
Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Mike Frysinger [Wed, 9 Feb 2011 15:13:19 +0000 (10:13 -0500)]
Include des_crypt in build
Some C libraries (like glibc) provide cbc_crypt and ecb_crypt and
friends, but others may not. So build the local des_crypt.c file
that is already in libtirpc.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Steve Dickson <steved@redhat.com>