diff --git a/libtirpc-1.3.1/.gitignore b/libtirpc-1.3.1/.gitignore deleted file mode 100644 index ef97e01..0000000 --- a/libtirpc-1.3.1/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# files generated by autoconf, automake, autoheader and libtoolize -aclocal.m4 -autom4te.cache -compile -config.guess -config.log -config.sub -configure -depcomp -install-sh -libtool -ltmain.sh -Makefile.in -missing -config.h.in -m4/* -libtirpc-*.tar.gz -# files generated by configure -confdefs.h -config.status -conftest -conftest.c -conftest.cpp -conftest.er1 -conftest.err -.deps -Makefile -config.h -stamp-h1 -libtirpc.pc -# file generated during compilation -*.o -.libs -lib*.a -src/libtirpc.la -src/libtirpc_la-*.lo -tirpc/stamp-h2 -tirpc/tirpc-features.h - -# generic editor backup et al -*~ -.stgitmail.txt -# cscope database files -cscope.* -# files generated by patches -*.patch -*.rej -*.orig -# files generated by debugging -.gdb_history -.gdbinit -core diff --git a/libtirpc-1.3.1/AUTHORS b/libtirpc-1.3.1/AUTHORS deleted file mode 100644 index 5cc9b78..0000000 --- a/libtirpc-1.3.1/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Gilles Quillard -Antoine Fraticelli - diff --git a/libtirpc-1.3.1/COPYING b/libtirpc-1.3.1/COPYING deleted file mode 100644 index 8e99af8..0000000 --- a/libtirpc-1.3.1/COPYING +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Copyright (c) Bull S.A. 2005 All Rights Reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - diff --git a/libtirpc-1.3.1/ChangeLog b/libtirpc-1.3.1/ChangeLog deleted file mode 100644 index e9a2aa1..0000000 --- a/libtirpc-1.3.1/ChangeLog +++ /dev/null @@ -1,206 +0,0 @@ -2008-11-19 Steve Dickson - - * Version 0.1.10 released. - -commit 32ec5931e3debf208972d5146578f08dc113a9b6 -Merge: 338af7f... 92cf0dd... -Author: Steve Dickson -Date: Mon Nov 17 12:26:22 2008 -0500 - - Merge branch 'master' of git://git.infradead.org/~steved/libtirpc - -commit 92cf0dde310ca341a2f29ff66b19eeb9994a649a -Author: Ian Kent -Date: Tue Oct 28 11:19:07 2008 -0400 - - Fixed a warings the IPV6 client routines - - Signed-off-by: Steve Dickson - -commit 338af7f9f00e096b65a6d823f885c4eeaf1d1f8c -Author: Steve Dickson -Date: Mon Oct 27 12:46:54 2008 -0400 - - __rpc_taddr2uaddr_af() assumes the netbuf to always have a - non-zero data. This is a bad assumption and can lead to a - seg-fault. This patch adds a check for zero length and returns - NULL when found. - - Signed-off-by: Steve Dickson - -commit d9a5ae7079d001a9e3b9b384f9153f591a7158bd -Author: Olaf Kirch -Date: Tue Sep 30 15:10:43 2008 -0400 - - Fix __rpc_getconfip - - __rpc_getconfip is supposed to return the first netconf - entry supporting tcp or udp, respectively. The code will - currently return the *last* entry, plus it will leak - memory when there is more than one such entry. - - This patch fixes this issue. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit 6c487efe74adb5c29f7bee5bd51b3ebef4968f7d -Author: Olaf Kirch -Date: Tue Sep 30 15:09:06 2008 -0400 - - Fix getpeereid - - getpeereid fails because it uses an incorrect getsockopt call to obtain - the peer credentials on a AF_LOCAL socket. This in turn will cause all - RPC services to be registered with rpcbind to show up as having been - registered by "unknown". - - This has a serious impact on security - a service owned by "unknown" - can essentially be unregistered (and thus replaced) by anyone. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit 851b0f5c6dca22d634603f03f0a5e3e35c6db867 -Author: Olaf Kirch -Date: Tue Sep 30 15:08:07 2008 -0400 - - svc_getcaller_netbuf macro seems broken - - I haven't found any documentation, but the comment in the header - file seems to suggest that svc_getcaller_netbuf should return the - xp_rtaddr netbuf. Returning the address of the socket descripor - seems to be wrong at any rate. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit d94b92d5125242ce595c1baf42a1e6d1004b7756 -Author: Olaf Kirch -Date: Tue Sep 30 15:06:54 2008 -0400 - - Introduce __rpc_set_netbuf helper - - The RPC code contains a number of places where a netbuf - is initialized with some data. All the mem_alloc/memcpy - stuff is open-coded. Introduce a helper function and - convert the code. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit da5f9861ea3bae59c8eead26d38334721caa9f0a -Author: Olaf Kirch -Date: Tue Sep 30 15:05:20 2008 -0400 - - Kill map_ipv4_to_ipv6 - - After the change to svc_vc.c performed in the previous patch, - this function is no longer needed. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit 59c374c4b507aeca957ed0096d98006edf601375 -Author: Olaf Kirch -Date: Tue Sep 30 15:04:17 2008 -0400 - - Fix xp_raddr handling in svc_fd_create etc - - Currently svc_fd_create tries to do some clever tricks - with IPv4/v6 address mapping. - - This is broken for several reasons. - 1. We don't want IPv4 based transport to look like IPv6 - transports. Old applications compiled against tirpc - will expect AF_INET addresses, and are not equipped - to deal with AF_INET6. - 2. There's a buffer overflow. - memcpy(&sin6, &ss, sizeof(ss)); - copies a full struct sockaddr to a sockaddr_in6 on - the stack. Unlikely to be exploitable, but I wonder - if this ever worked.... - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit 628788c1cc84c86ee4cb36ee5d4fe8954e90fca5 -Author: Steve Dickson -Date: Tue Sep 16 11:32:31 2008 -0400 - - - Fixed version-info in src/Makefile.am to reflect the correct version - - Fixed some of warnings in: src/auth_time.c, src/clnt_dg.c and - src/clnt_raw.c - - Added some #ifdef NOTUSED around some code in src/rpbc_clnt.c - that was not being used... - - Signed-off-by: Steve Dickson - -commit 9e7ba0c7a02031294fefadfbca42b3dd5f2d841f -Author: Olaf Kirch -Date: Tue Sep 16 08:46:29 2008 -0400 - - Fix for taddr2addr conversion bug of local addresses - - When converting af_local socket addresses in taddr2uaddr, an incorrect - sizeof() would result in a truncated path string. As a result, - rpcbind will report the local /var/lib/rpcbind address to clients - as "/v" on a 32bit machine. - - Signed-off-by: okir@suse.de - Signed-off-by: Steve Dickson - -commit ea9f048761d0b9a2ab6310bffa07351f0b04d8c5 -Author: Olaf Kirch -Date: Tue Sep 2 12:11:15 2008 -0400 - - Always make IPv6 sockets V6ONLY - - Assume you have a netconfig file looking like this: - - udp tpi_clts v inet udp - - - udp6 tpi_clts v inet6 udp - - - ... - - a call to svc_tli_create(... &someaddr, "udp") will fail to create an - IPv6 server socket. The problem is that on Linux, passive IPv6 sockets - will also accept packets/connections from IPv4, and will simply map - the sender's address to an IPv6 mapped IPv4 address. So if you want to - bind both a UDPv4 and UDPv6 socket to the same port, this will fail with - EADDRINUSE. - - The way to avoid this behavior is to change the socket to V6ONLY, - which tells the kernel to avoid the autmatic mapping. - - The change proposed in the patch below does this. I *think* this is - a good place to do this, as it will also fix applications that do not - use svc_tli_create() - such as rpcbind, which creates the sockets on - its own using __rpc_nconf2fd. - - I think this also improves portability, as BSD code assumes BSD - behavior, where this mapping does not occur either. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -commit 95c8f7227e6b15f2e430d7b87dadc95b2acd4a61 -Author: Olaf Kirch -Date: Tue Sep 2 12:09:39 2008 -0400 - - Fix incorrect sizeof() in __rpc_getbroadifs - - __rpc_getbroadifs returns bad broadcast addresses on 32bit - machines because when copying the broadcast addresses, ite - applies the sizeof() operator to a pointer to a sockaddr, - rather than the sockaddr itself. - - Signed-off-by: Olaf Kirch - Signed-off-by: Steve Dickson - -2004-10-13 Antoine Fraticelli - - * Version 0.1 released. - -2005-01-07 Gilles Quillard - - * Version 0.1.5 Fix problems links to the use of Kerberos. diff --git a/libtirpc-1.3.1/HACKING b/libtirpc-1.3.1/HACKING deleted file mode 100644 index d562427..0000000 --- a/libtirpc-1.3.1/HACKING +++ /dev/null @@ -1,2 +0,0 @@ -Patches can be sent to libtirpc-devel@lists.sourceforge.net with a CC -to linux-nfs@vger.kernel.org diff --git a/libtirpc-1.3.1/INSTALL b/libtirpc-1.3.1/INSTALL deleted file mode 100644 index 2099840..0000000 --- a/libtirpc-1.3.1/INSTALL +++ /dev/null @@ -1,370 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, -Inc. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell command `./configure && make && make install' -should configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented -below. The lack of an optional feature in a given package is not -necessarily a bug. More recommendations for GNU packages can be found -in *note Makefile Conventions: (standards)Makefile Conventions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - - The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package, generally using the just-built uninstalled binaries. - - 4. Type `make install' to install the programs and any data files and - documentation. When installing into a prefix owned by root, it is - recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root - privileges. - - 5. Optionally, type `make installcheck' to repeat any self-tests, but - this time using the binaries in their final installed location. - This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required - root privileges, verifies that the installation completed - correctly. - - 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 7. Often, you can also type `make uninstall' to remove the installed - files again. In practice, not all packages have tested that - uninstallation works correctly, even though it is required by the - GNU Coding Standards. - - 8. Some packages, particularly those that use Automake, provide `make - distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. - This target is generally not run by end users. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an -absolute file name. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory -specifications that were not explicitly provided. - - The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or -both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without -having to reconfigure or recompile. - - The first method involves providing an override variable for each -affected directory. For example, `make install -prefix=/alternate/directory' will choose an alternate location for all -directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and -does not work on platforms that have drive letters. On the other hand, -it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. - -Optional Features -================= - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - - Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure ---enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure ---disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put `/usr/ucb' early in your `PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. - - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: - - CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. diff --git a/libtirpc-1.3.1/Makefile.am b/libtirpc-1.3.1/Makefile.am deleted file mode 100644 index 3f60637..0000000 --- a/libtirpc-1.3.1/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -SUBDIRS = src man doc -ACLOCAL_AMFLAGS = -I m4 - -noinst_HEADERS = tirpc/reentrant.h \ - tirpc/getpeereid.h \ - tirpc/libc_private.h \ - tirpc/un-namespace.h - -nobase_include_HEADERS = tirpc/netconfig.h \ - tirpc/rpcsvc/crypt.x \ - tirpc/rpcsvc/crypt.h \ - tirpc/rpc/xdr.h \ - tirpc/rpc/types.h \ - tirpc/rpc/svc_soc.h \ - tirpc/rpc/svc.h \ - tirpc/rpc/svc_dg.h \ - tirpc/rpc/svc_auth.h \ - tirpc/rpc/svc_mt.h \ - tirpc/rpc/rpc_msg.h \ - tirpc/rpc/rpc.h \ - tirpc/rpc/rpcent.h \ - tirpc/rpc/rpc_com.h \ - tirpc/rpc/rpcb_prot.x \ - tirpc/rpc/rpcb_prot.h \ - tirpc/rpc/rpcb_clnt.h \ - tirpc/rpc/raw.h \ - tirpc/rpc/pmap_rmt.h \ - tirpc/rpc/pmap_prot.h \ - tirpc/rpc/pmap_clnt.h \ - tirpc/rpc/nettype.h \ - tirpc/rpc/key_prot.h \ - tirpc/rpc/des.h \ - tirpc/rpc/des_crypt.h \ - tirpc/rpc/clnt_stat.h \ - tirpc/rpc/clnt_soc.h \ - tirpc/rpc/clnt.h \ - tirpc/rpc/auth_unix.h \ - tirpc/rpc/auth_des.h \ - tirpc/rpc/auth.h - -if GSS -nobase_include_HEADERS += \ - tirpc/rpc/rpcsec_gss.h \ - tirpc/rpc/auth_gss.h \ - tirpc/rpc/svc_auth_gss.h -endif - -pkgconfigdir=$(libdir)/pkgconfig -pkgconfig_DATA = libtirpc.pc - -CLEANFILES = cscope.* *~ -DISTCLEANFILES = Makefile.in libtirpc*.tar.gz diff --git a/libtirpc-1.3.1/NEWS b/libtirpc-1.3.1/NEWS deleted file mode 100644 index 7eef517..0000000 --- a/libtirpc-1.3.1/NEWS +++ /dev/null @@ -1,3 +0,0 @@ -New in 0.1: -* Portage from FreeBSD 5.2.1 (security part to be completed) -* Use autoconf/automake diff --git a/libtirpc-1.3.1/README b/libtirpc-1.3.1/README deleted file mode 100644 index 3b10e0d..0000000 --- a/libtirpc-1.3.1/README +++ /dev/null @@ -1,44 +0,0 @@ -LIBTIRPC 0.1 FROM SUN'S TIRPCSRC 2.3 29 Aug 1994 - -This package contains SunLib's implementation of transport-independent -RPC (TI-RPC) documentation. This library forms a piece of the base of Open Network -Computing (ONC), and is derived directly from the Solaris 2.3 source. - -TI-RPC is an enhanced version of TS-RPC that requires the UNIX System V -Transport Layer Interface (TLI) or an equivalent X/Open Transport Interface -(XTI). TI-RPC is on-the-wire compatible with the TS-RPC, which is supported -by almost 70 vendors on all major operating systems. TS-RPC source code -(RPCSRC 4.0) remains available from several internet sites. - -This release was a native source release, compatible for -building on Solaris 2.3. It had been ported from FreeBSD 5.2.1 to GNU/Linux -in 2004. - -Applications linked with this release's librpc must link with the United -States domestic version of libcrypt in order to resolve the cbc_crypt() and -ecb_crypt() functions. These routines are used with Secure RPC however all -RPC programs that link with this release's librpc will need to link with the -domestic libcrypt. - -WHAT'S NEW IN THIS RELEASE: TIRPCSRC 2.3 FROM SUN - -The previous release was TIRPCSRC 2.0. - -1. This release is based on Solaris 2.3. The previous release was - based on Solaris 2.0. This release contains a siginificant number of - bug fixes and other enhancements over TIRPCSRC 2.0. - -2. The RPC library is thread safe for all client-side interfaces - (clnt_create, clnt_call, etc.). The server-side interfaces - (svc_create, svc_run, etc.) are not thread safe in this release. The - server-side interfaces will be made thread safe in the next release of - TIRPCSRC. Please see the manual pages for details about which - interfaces are thread safe. - -3. As part of the work to make the RPC library thread-safe, rpcgen has - been enhanced to generate thread-safe RPC stubs (the -M option). Note - that this modifies the call-signature for the stub functions; the - procedure calling the RPC stub must now pass to the stub a pointer to - an allocated structure where results will be placed by the stub. See - the rpcgen manual page and the rpcgen Programming Guide for details. - diff --git a/libtirpc-1.3.1/THANKS b/libtirpc-1.3.1/THANKS deleted file mode 100644 index cea8ee3..0000000 --- a/libtirpc-1.3.1/THANKS +++ /dev/null @@ -1,6 +0,0 @@ - Thanks to for - -Aurelien Charbon TI-RPC portage from NetBSD - -BSD Communauty TI-RPC improvement from Sun implementation - diff --git a/libtirpc-1.3.1/TODO b/libtirpc-1.3.1/TODO deleted file mode 100644 index 6f62665..0000000 --- a/libtirpc-1.3.1/TODO +++ /dev/null @@ -1,3 +0,0 @@ -* Support of DES & other security part -* Provide tests -* rpcgen command missing diff --git a/libtirpc-1.3.1/VERSION b/libtirpc-1.3.1/VERSION deleted file mode 100644 index 5ee5442..0000000 --- a/libtirpc-1.3.1/VERSION +++ /dev/null @@ -1,7 +0,0 @@ -# This file is used by configure to get version information -# -PKG_MAJOR=0 -PKG_MINOR=1 -PKG_REVISION=11 -PKG_BUILD=0 - diff --git a/libtirpc-1.3.1/autogen.sh b/libtirpc-1.3.1/autogen.sh deleted file mode 100644 index 1613b6d..0000000 --- a/libtirpc-1.3.1/autogen.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -e - -echo -n cleaning up . - -# Clean up the generated crud -( - for FILE in compile config.guess config.sub depcomp install-sh ltmain.sh missing mkinstalldirs; do - if test -f $FILE; then - rm -f $FILE - fi - echo -n . - done -) - -for FILE in aclocal.m4 configure config.h.in; do - if test -f $FILE; then - rm -f $FILE - fi - echo -n . -done - -for DIR in autom4te.cache; do - if test -d $DIR; then - rm -rf $DIR - fi - echo -n . -done - -find . -type f -name 'Makefile.in' -print0 | xargs -r0 rm -f -- -find . -type f -name 'Makefile' -print0 | xargs -r0 rm -f -- - -echo ' done' - -if test x"${1}" = x"clean"; then - exit -fi - -aclocal -libtoolize --force --copy -autoheader -automake --add-missing --copy --gnu # -Wall -autoconf # -Wall diff --git a/libtirpc-1.3.1/bootstrap b/libtirpc-1.3.1/bootstrap deleted file mode 100755 index 9f35619..0000000 --- a/libtirpc-1.3.1/bootstrap +++ /dev/null @@ -1,12 +0,0 @@ -[ -e Makefile ] && make clean -rm -rf autom4te.cache configure Makefile stamp-h1 -rm -rf src/Makefile src/.deps -rm -rf Makefile.in aclocal.m4 config.log config.h -rm -rf depcomp missing install-sh config.status -mkdir -p m4 -aclocal -I m4 -autoheader -libtoolize --automake --copy -automake --gnu --add-missing -c -autoconf -rm -rf autom4te.cache config.log libtool stamp-h1* diff --git a/libtirpc-1.3.1/configure.ac b/libtirpc-1.3.1/configure.ac deleted file mode 100644 index 8065881..0000000 --- a/libtirpc-1.3.1/configure.ac +++ /dev/null @@ -1,103 +0,0 @@ -AC_INIT(libtirpc, 1.3.1) -AM_INIT_AUTOMAKE([silent-rules]) -AM_SILENT_RULES([yes]) -AC_CONFIG_SRCDIR([src/auth_des.c]) -AC_CONFIG_MACRO_DIR([m4]) -AC_PROG_CC - -# LT_VERSION_INFO="current:revision:age" -# -# From the libtool manual: -# -# 1. Start with version information of 0:0:0 for each libtool library. -# 2. Update the version information only immediately before a public -# release of your software. More frequent updates are unnecessary, -# and only guarantee that the current interface number gets larger faster. -# 3. If the library source code has changed at all since the last update, -# then increment revision (c:r:a becomes c:r+1:a). -# 4. If any interfaces have been added, removed, or changed since the last -# update, increment current, and set revision to 0. -# 5. If any interfaces have been added since the last public release, -# then increment age. -# 6. If any interfaces have been removed since the last public release, -# then set age to 0. -# -# _Never_ try to set the interface numbers so that they correspond to the -# release number of your package. This is an abuse that only fosters -# misunderstanding of the purpose of library versions. -# -# In addition to these rules, symbol versioning is now in effect. soname -# changes should be avoided. -# -LT_VERSION_INFO="3:0:0" -AC_SUBST([LT_VERSION_INFO]) - -AC_CHECK_HEADER([gssapi/gssapi.h], [HAVE_GSSAPI_H=yes], [HAVE_GSSAPI_H=no]) - -AC_ARG_ENABLE(gssapi, - [AC_HELP_STRING([--disable-gssapi], [Disable GSSAPI support @<:@default=no@:>@])], - [],[enable_gssapi=yes]) -AM_CONDITIONAL(GSS, test "x$enable_gssapi" = xyes) - -if test "x$enable_gssapi" = xyes; then - if test "x$HAVE_GSSAPI_H" = xno; then - AC_MSG_ERROR([gssapi.h not found. Use --disable-gssapi, or install GSS-API.]) - fi - AC_CHECK_TOOL([KRB5_CONFIG], [krb5-config], [no]) - if test "x$KRB5_CONFIG" = xno; then - AC_MSG_ERROR([krb5-config tool not found. Use --disable-gssapi, or install Kerberos.]) - fi - GSSAPI_CFLAGS=`${KRB5_CONFIG} --cflags gssapi` - GSSAPI_LIBS=`${KRB5_CONFIG} --libs gssapi` - AC_SUBST([GSSAPI_CFLAGS]) - AC_SUBST([GSSAPI_LIBS]) -fi - -AC_ARG_ENABLE(authdes, - [AC_HELP_STRING([--enable-authdes], [Enable AUTH_DES support @<:@default=no@:>@])], - [],[enable_authdes=no]) -AM_CONDITIONAL(AUTHDES, test "x$enable_authdes" = xyes) -if test "x$enable_authdes" != xno; then - AC_DEFINE(AUTHDES_SUPPORT, 1, [Define if AUTH_DES is support]) -fi - -AC_ARG_ENABLE(ipv6, - [AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support @<:@default=no@:>@])], - [],[enable_ipv6=yes]) -AM_CONDITIONAL(INET6, test "x$disable_ipv6" != xno) -if test "x$enable_ipv6" != xno; then - AC_DEFINE(INET6, 1, [Define to 1 if IPv6 is available]) -fi - -AC_ARG_ENABLE(symvers, - [AC_HELP_STRING([--disable-symvers], [Disable symbol versioning @<:@default=no@:>@])], - [],[enable_symvers=yes]) -AM_CONDITIONAL(SYMVERS, test "x$enable_symvers" = xyes) - -AC_CANONICAL_BUILD -# Check for which host we are on and setup a few things -# specifically based on the host -case $build_os in - linux*) - # Do something specific for linux - LDFLAG_NOUNDEFINED="-Wl,--no-undefined" - AC_SUBST(LDFLAG_NOUNDEFINED) - ;; - *) - #Default Case - ;; -esac - - -AC_CONFIG_HEADERS([config.h]) -AC_PROG_LIBTOOL -AC_HEADER_DIRENT -AC_PREFIX_DEFAULT(/usr) -AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h]) -AC_CHECK_LIB([pthread], [pthread_create]) -AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent]) - -AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile]) -AC_OUTPUT(libtirpc.pc) - - diff --git a/libtirpc-1.3.1/doc/Makefile.am b/libtirpc-1.3.1/doc/Makefile.am deleted file mode 100644 index d42ab90..0000000 --- a/libtirpc-1.3.1/doc/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -dist_sysconf_DATA = netconfig bindresvport.blacklist - -CLEANFILES = cscope.* *~ -DISTCLEANFILES = Makefile.in diff --git a/libtirpc-1.3.1/doc/bindresvport.blacklist b/libtirpc-1.3.1/doc/bindresvport.blacklist deleted file mode 100644 index a7ed193..0000000 --- a/libtirpc-1.3.1/doc/bindresvport.blacklist +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file contains a list of port numbers between 600 and 1024, -# which should not be used by bindresvport. bindresvport is mostly -# called by RPC services. This mostly solves the problem, that a -# RPC service uses a well known port of another service. -# -623 # ASF, used by IPMI on some cards -631 # cups -636 # ldaps -664 # Secure ASF, used by IPMI on some cards -774 # rpasswd -921 # lwresd -993 # imaps -995 # pops diff --git a/libtirpc-1.3.1/doc/netconfig b/libtirpc-1.3.1/doc/netconfig deleted file mode 100644 index effc67e..0000000 --- a/libtirpc-1.3.1/doc/netconfig +++ /dev/null @@ -1,19 +0,0 @@ -# -# The network configuration file. This file is currently only used in -# conjunction with the TI-RPC code in the libtirpc library. -# -# Entries consist of: -# -# \ -# -# -# The and fields are always empty in this -# implementation. -# -udp tpi_clts v inet udp - - -tcp tpi_cots_ord v inet tcp - - -udp6 tpi_clts v inet6 udp - - -tcp6 tpi_cots_ord v inet6 tcp - - -rawip tpi_raw - inet - - - -local tpi_cots_ord - loopback - - - -unix tpi_cots_ord - loopback - - - diff --git a/libtirpc-1.3.1/libtirpc.pc.in b/libtirpc-1.3.1/libtirpc.pc.in deleted file mode 100644 index d2c7878..0000000 --- a/libtirpc-1.3.1/libtirpc.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libtirpc -Description: Transport Independent RPC Library -Requires: -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -ltirpc -Libs.private: -lpthread -Cflags: -I${includedir}/tirpc diff --git a/libtirpc-1.3.1/man/Makefile.am b/libtirpc-1.3.1/man/Makefile.am deleted file mode 100644 index fa43bb4..0000000 --- a/libtirpc-1.3.1/man/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -LOOKUP_MANS = getrpcent.3t getrpcport.3t -NETCONFIG_MANS = getnetconfig.3t getnetpath.3t -BIND_MANS = bindresvport.3t -COMPAT_MANS = des_crypt.3t rpc_soc.3t rpc_secure.3t rtime.3t -CLIENT_MANS = rpc_clnt_auth.3t rpc_clnt_calls.3t rpc_clnt_create.3t \ - rpcbind.3t -SERVER_MANS = rpc_svc_calls.3t rpc_svc_create.3t rpc_svc_err.3t \ - rpc_svc_reg.3t -GENERIC_MANS = rpc.3t rpc_xdr.3t -RPCSEC_MANS = rpcsec_gss.3t rpc_gss_get_error.3t \ - rpc_gss_get_mechanisms.3t rpc_gss_get_mech_info.3t \ - rpc_gss_get_versions.3t rpc_gss_is_installed.3t \ - rpc_gss_mech_to_oid.3t rpc_gss_qop_to_num.3t \ - rpc_gss_max_data_length.3t rpc_gss_seccreate.3t \ - rpc_gss_set_defaults.3t rpc_gss_getcred.3t \ - rpc_gss_get_principal_name.3t rpc_gss_set_callback.3t \ - rpc_gss_set_svc_name.3t rpc_gss_svc_max_data_length.3t - -dist_man5_MANS = netconfig.5 -dist_man3_MANS = $(LOOKUP_MANS) $(NETCONFIG_MANS) \ - $(BIND_MANS) $(GENERIC_MANS) $(COMPAT_MANS) \ - $(CLIENT_MANS) $(SERVER_MANS) -if GSS -dist_man3_MANS += $(RPCSEC_MANS) -endif - -EXTRA_DIST = publickey.3t publickey.5 rpc.5 - -CLEANFILES = cscope.* *~ -DISTCLEANFILES = Makefile.in diff --git a/libtirpc-1.3.1/man/bindresvport.3t b/libtirpc-1.3.1/man/bindresvport.3t deleted file mode 100644 index 476e678..0000000 --- a/libtirpc-1.3.1/man/bindresvport.3t +++ /dev/null @@ -1,102 +0,0 @@ -.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI -.\" -.Dd November 22, 1987 -.Dt BINDRESVPORT 3 -.Os -.Sh NAME -.Nm bindresvport , -.Nm bindresvport_sa -.Nd bind a socket to a privileged IP port -.Sh SYNOPSIS -.In sys/types.h -.In rpc/rpc.h -.Ft int -.Fn bindresvport "int sd" "struct sockaddr_in *sin" -.Ft int -.Fn bindresvport_sa "int sd" "struct sockaddr *sa" -.Sh DESCRIPTION -The -.Fn bindresvport -and -.Fn bindresvport_sa -functions -are used to bind a socket descriptor to a privileged -.Tn IP -port, that is, a -port number in the range 0-1023. -.Pp -If -.Fa sin -is a pointer to a -.Ft "struct sockaddr_in" -then the appropriate fields in the structure should be defined. -Note that -.Fa sin->sin_family -must be initialized to the address family of the socket, passed by -.Fa sd . -If -.Fa sin->sin_port -is -.Sq 0 -then an anonymous port (in the range 600-1023) will be -chosen, and if -.Xr bind 2 -is successful, the -.Fa sin->sin_port -will be updated to contain the allocated port. -.Pp -If -.Fa sin -is the -.Dv NULL -pointer, -an anonymous port will be allocated (as above). -However, there is no way for -.Fn bindresvport -to return the allocated port in this case. -.Pp -Only root can bind to a privileged port; this call will fail for any -other users. -.Pp -Function prototype of -.Fn bindresvport -is biased to -.Dv AF_INET -socket. -The -.Fn bindresvport_sa -function -acts exactly the same, with more neutral function prototype. -Note that both functions behave exactly the same, and -both support -.Dv AF_INET6 -sockets as well as -.Dv AF_INET -sockets. -.Sh RETURN VALUES -.Rv -std bindresvport -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EPFNOSUPPORT -If second argument was supplied, -and address family did not match between arguments. -.El -.Pp -The -.Fn bindresvport -function -may also fail and set -.Va errno -for any of the errors specified for the calls -.Xr bind 2 , -.Xr getsockopt 2 , -or -.Xr setsockopt 2 . -.Sh AVAILABILITY -The -.Fn bindresvport -function is part of libtirpc. -.Sh SEE ALSO -.Xr bind 2 , -.Xr getsockopt 2 , -.Xr setsockopt 2 diff --git a/libtirpc-1.3.1/man/des_crypt.3t b/libtirpc-1.3.1/man/des_crypt.3t deleted file mode 100644 index a2be1bd..0000000 --- a/libtirpc-1.3.1/man/des_crypt.3t +++ /dev/null @@ -1,134 +0,0 @@ -.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI; -.\" -.Dd October 6, 1987 -.Dt DES_CRYPT 3 -.Os -.Sh NAME -.Nm des_crypt , ecb_crypt , cbc_crypt , des_setparity -.Nd "fast DES encryption" -.Sh SYNOPSIS -.In rpc/des_crypt.h -.Ft int -.Fn ecb_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode" -.Ft int -.Fn cbc_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode" "char *ivec" -.Ft void -.Fn des_setparity "char *key" -.Sh DESCRIPTION -The -.Fn ecb_crypt -and -.Fn cbc_crypt -functions -implement the -.Tn NBS -.Tn DES -(Data Encryption Standard). -These routines are faster and more general purpose than -.Xr crypt 3 . -They also are able to utilize -.Tn DES -hardware if it is available. -The -.Fn ecb_crypt -function -encrypts in -.Tn ECB -(Electronic Code Book) -mode, which encrypts blocks of data independently. -The -.Fn cbc_crypt -function -encrypts in -.Tn CBC -(Cipher Block Chaining) -mode, which chains together -successive blocks. -.Tn CBC -mode protects against insertions, deletions and -substitutions of blocks. -Also, regularities in the clear text will -not appear in the cipher text. -.Pp -Here is how to use these routines. -The first argument, -.Fa key , -is the 8-byte encryption key with parity. -To set the key's parity, which for -.Tn DES -is in the low bit of each byte, use -.Fn des_setparity . -The second argument, -.Fa data , -contains the data to be encrypted or decrypted. -The -third argument, -.Fa datalen , -is the length in bytes of -.Fa data , -which must be a multiple of 8. -The fourth argument, -.Fa mode , -is formed by -.Em OR Ns 'ing -together some things. -For the encryption direction -.Em OR -in either -.Dv DES_ENCRYPT -or -.Dv DES_DECRYPT . -For software versus hardware -encryption, -.Em OR -in either -.Dv DES_HW -or -.Dv DES_SW . -If -.Dv DES_HW -is specified, and there is no hardware, then the encryption is performed -in software and the routine returns -.Er DESERR_NOHWDEVICE . -For -.Fn cbc_crypt , -the -.Fa ivec -argument -is the 8-byte initialization -vector for the chaining. -It is updated to the next initialization -vector upon return. -.Sh ERRORS -.Bl -tag -width [DESERR_NOHWDEVICE] -compact -.It Bq Er DESERR_NONE -No error. -.It Bq Er DESERR_NOHWDEVICE -Encryption succeeded, but done in software instead of the requested hardware. -.It Bq Er DESERR_HWERR -An error occurred in the hardware or driver. -.It Bq Er DESERR_BADPARAM -Bad argument to routine. -.El -.Pp -Given a result status -.Va stat , -the macro -.Fn DES_FAILED stat -is false only for the first two statuses. -.Sh AVAILABILITY -The -.Fn ecb_crypt , -.Fn cbc_crypt , -and -.Fn des_setparity -functions are part of libtirpc. -.Sh SEE ALSO -.\" .Xr des 1 , -.Xr crypt 3 -.Sh RESTRICTIONS -These routines are not available in RPCSRC 4.0. -This information is provided to describe the -.Tn DES -interface expected by -Secure RPC. diff --git a/libtirpc-1.3.1/man/getnetconfig.3t b/libtirpc-1.3.1/man/getnetconfig.3t deleted file mode 100644 index 6682319..0000000 --- a/libtirpc-1.3.1/man/getnetconfig.3t +++ /dev/null @@ -1,220 +0,0 @@ -.\" @(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4 -.\" Copyright 1989 AT&T -.Dd April 22, 2000 -.Dt GETNETCONFIG 3 -.Os -.Sh NAME -.Nm getnetconfig , -.Nm setnetconfig , -.Nm endnetconfig , -.Nm getnetconfigent , -.Nm freenetconfigent , -.Nm nc_perror , -.Nm nc_sperror -.Nd get network configuration database entry -.Sh SYNOPSIS -.In netconfig.h -.Ft "struct netconfig *" -.Fn getnetconfig "void *handlep" -.Ft "void *" -.Fn setnetconfig "void" -.Ft int -.Fn endnetconfig "void *handlep" -.Ft "struct netconfig *" -.Fn getnetconfigent "const char *netid" -.Ft void -.Fn freenetconfigent "struct netconfig *netconfigp" -.Ft void -.Fn nc_perror "const char *msg" -.Ft "char *" -.Fn nc_sperror "void" -.Sh DESCRIPTION -The library routines described on this page -provide the application access to -the system network configuration database, -.Pa /etc/netconfig . -The -.Fn getnetconfig -function -returns a pointer to the -current entry in the -netconfig -database, formatted as a -.Ft "struct netconfig" . -Successive calls will return successive netconfig -entries in the netconfig database. -The -.Fn getnetconfig -function -can be used to search the entire netconfig -file. -The -.Fn getnetconfig -function -returns -.Dv NULL -at the end of the file. -The -.Fa handlep -argument -is the handle obtained through -.Fn setnetconfig . -.Pp -A call to -.Fn setnetconfig -has the effect of -.Dq binding -to or -.Dq rewinding -the netconfig database. -The -.Fn setnetconfig -function -must be called before the first call to -.Fn getnetconfig -and may be called at any other time. -The -.Fn setnetconfig -function -need not be called before a call to -.Fn getnetconfigent . -The -.Fn setnetconfig -function -returns a unique handle to be used by -.Fn getnetconfig . -.Pp -The -.Fn endnetconfig -function -should be called when processing is complete to release resources for reuse. -The -.Fa handlep -argument -is the handle obtained through -.Fn setnetconfig . -Programmers should be aware, however, that the last call to -.Fn endnetconfig -frees all memory allocated by -.Fn getnetconfig -for the -.Ft "struct netconfig" -data structure. -The -.Fn endnetconfig -function -may not be called before -.Fn setnetconfig . -.Pp -The -.Fn getnetconfigent -function -returns a pointer -to the netconfig structure corresponding -to -.Fa netid . -It returns -.Dv NULL -if -.Fa netid -is invalid -(that is, does not name an entry in the netconfig database). -.Pp -The -.Fn freenetconfigent -function -frees the netconfig structure pointed to by -.Fa netconfigp -(previously returned by -.Fn getnetconfigent ) . -.Pp -The -.Fn nc_perror -function -prints a message to the standard error indicating why any of the -above routines failed. -The message is prepended with the string -.Fa msg -and a colon. -A newline character is appended at the end of the message. -.Pp -The -.Fn nc_sperror -function -is similar to -.Fn nc_perror -but instead of sending the message -to the standard error, will return a pointer to a string that -contains the error message. -.Pp -The -.Fn nc_perror -and -.Fn nc_sperror -functions -can also be used with the -.Ev NETPATH -access routines defined in -.Xr getnetpath 3 . -.Sh RETURN VALUES -The -.Fn setnetconfig -function -returns a unique handle to be used by -.Fn getnetconfig . -In the case of an error, -.Fn setnetconfig -returns -.Dv NULL -and -.Fn nc_perror -or -.Fn nc_sperror -can be used to print the reason for failure. -.Pp -The -.Fn getnetconfig -function -returns a pointer to the current entry in the netconfig -database, formatted as a -.Ft "struct netconfig" . -The -.Fn getnetconfig -function -returns -.Dv NULL -at the end of the file, or upon failure. -.Pp -The -.Fn endnetconfig -function -returns 0 on success and \-1 on failure -(for example, if -.Fn setnetconfig -was not called previously). -.Pp -On success, -.Fn getnetconfigent -returns a pointer to the -.Ft "struct netconfig" -structure corresponding to -.Fa netid ; -otherwise it returns -.Dv NULL . -.Pp -The -.Fn nc_sperror -function -returns a pointer to a buffer which contains the error message string. -This buffer is overwritten on each call. -In multithreaded applications, this buffer is -implemented as thread-specific data. -.Sh FILES -.Bl -tag -width /etc/netconfig -compact -.It Pa /etc/netconfig -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr getnetpath 3 , -.Xr netconfig 5 diff --git a/libtirpc-1.3.1/man/getnetpath.3t b/libtirpc-1.3.1/man/getnetpath.3t deleted file mode 100644 index 474acf9..0000000 --- a/libtirpc-1.3.1/man/getnetpath.3t +++ /dev/null @@ -1,168 +0,0 @@ -.\" @(#)getnetpath.3n 1.26 93/05/07 SMI; from SVr4 -.\" Copyright 1989 AT&T -.Dd April 22, 2000 -.Dt GETNETPATH 3 -.Os -.Sh NAME -.Nm getnetpath , -.Nm setnetpath , -.Nm endnetpath -.Nd get -.Pa /etc/netconfig -entry corresponding to -.Ev NETPATH -component -.Sh SYNOPSIS -.In netconfig.h -.Ft "struct netconfig *" -.Fn getnetpath "void *handlep" -.Ft "void *" -.Fn setnetpath "void" -.Ft int -.Fn endnetpath "void *handlep" -.Sh DESCRIPTION -The routines described in this page provide the application access to the system -network configuration database, -.Pa /etc/netconfig , -as it is -.Dq filtered -by the -.Ev NETPATH -environment variable (see -.Xr environ 7 ) . -See -.Xr getnetconfig 3 -for other routines that also access the -network configuration database directly. -The -.Ev NETPATH -variable is a list of colon-separated network identifiers. -.Pp -The -.Fn getnetpath -function -returns a pointer to the -netconfig database entry corresponding to the first valid -.Ev NETPATH -component. -The netconfig entry is formatted as a -.Ft "struct netconfig" . -On each subsequent call, -.Fn getnetpath -returns a pointer to the netconfig entry that corresponds to the next -valid -.Ev NETPATH -component. -The -.Fn getnetpath -function -can thus be used to search the netconfig database for all networks -included in the -.Ev NETPATH -variable. -When -.Ev NETPATH -has been exhausted, -.Fn getnetpath -returns -.Dv NULL . -.Pp -A call to -.Fn setnetpath -.Dq binds -to or -.Dq rewinds -.Ev NETPATH . -The -.Fn setnetpath -function -must be called before the first call to -.Fn getnetpath -and may be called at any other time. -It returns a handle that is used by -.Fn getnetpath . -.Pp -The -.Fn getnetpath -function -silently ignores invalid -.Ev NETPATH -components. -A -.Ev NETPATH -component is invalid if there is no corresponding -entry in the netconfig database. -.Pp -If the -.Ev NETPATH -variable is unset, -.Fn getnetpath -behaves as if -.Ev NETPATH -were set to the sequence of -.Dq default -or -.Dq visible -networks in the netconfig database, in the -order in which they are listed. -.\"This proviso holds also for this -.\"whole manpage. -.Pp -The -.Fn endnetpath -function -may be called to -.Dq unbind -from -.Ev NETPATH -when processing is complete, releasing resources for reuse. -Programmers should be aware, however, that -.Fn endnetpath -frees all memory allocated by -.Fn getnetpath -for the struct netconfig data structure. -.Sh RETURN VALUES -The -.Fn setnetpath -function -returns a handle that is used by -.Fn getnetpath . -In case of an error, -.Fn setnetpath -returns -.Dv NULL . -.Pp -The -.Fn endnetpath -function -returns 0 on success and \-1 on failure -(for example, if -.Fn setnetpath -was not called previously). -The -.Fn nc_perror -or -.Fn nc_sperror -function -can be used to print out the reason for failure. -See -.Xr getnetconfig 3 . -.Pp -When first called, -.Fn getnetpath -returns a pointer to the netconfig database entry corresponding to the first -valid -.Ev NETPATH -component. -When -.Ev NETPATH -has been exhausted, -.Fn getnetpath -returns -.Dv NULL . -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr getnetconfig 3 , -.Xr netconfig 5 , -.Xr environ 7 diff --git a/libtirpc-1.3.1/man/getrpcent.3t b/libtirpc-1.3.1/man/getrpcent.3t deleted file mode 100644 index 2796de9..0000000 --- a/libtirpc-1.3.1/man/getrpcent.3t +++ /dev/null @@ -1,105 +0,0 @@ -.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI -.\" -.Dd December 14, 1987 -.Dt GETRPCENT 3 -.Os -.Sh NAME -.Nm getrpcent , -.Nm getrpcbyname , -.Nm getrpcbynumber , -.Nm endrpcent , -.Nm setrpcent -.Nd get RPC entry -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft struct rpcent * -.Fn getrpcent void -.Ft struct rpcent * -.Fn getrpcbyname "char *name" -.Ft struct rpcent * -.Fn getrpcbynumber "int number" -.Ft void -.Fn setrpcent "int stayopen" -.Ft void -.Fn endrpcent void -.Sh DESCRIPTION -The -.Fn getrpcent , -.Fn getrpcbyname , -and -.Fn getrpcbynumber -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the rpc program number data base, -.Pa /etc/rpc : -.Bd -literal -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - long r_number; /* rpc program number */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width r_aliases -offset indent -.It Va r_name -The name of the server for this rpc program. -.It Va r_aliases -A zero terminated list of alternate names for the rpc program. -.It Va r_number -The rpc program number for this service. -.El -.Pp -The -.Fn getrpcent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setrpcent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getrpcent -(either directly, or indirectly through one of -the other -.Dq getrpc -calls). -.Pp -The -.Fn endrpcent -function -closes the file. -.Pp -The -.Fn getrpcbyname -and -.Fn getrpcbynumber -functions -sequentially search from the beginning -of the file until a matching rpc program name or -program number is found, or until end-of-file is encountered. -.Sh FILES -.Bl -tag -width /etc/rpc -compact -.It Pa /etc/rpc -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 5 , -.Xr rpcinfo 8 -.Sh DIAGNOSTICS -A -.Dv NULL -pointer is returned on -.Dv EOF -or error. -.Sh BUGS -All information -is contained in a static area -so it must be copied if it is -to be saved. diff --git a/libtirpc-1.3.1/man/getrpcport.3t b/libtirpc-1.3.1/man/getrpcport.3t deleted file mode 100644 index 1aa5773..0000000 --- a/libtirpc-1.3.1/man/getrpcport.3t +++ /dev/null @@ -1,36 +0,0 @@ -.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI -.\" -.Dd October 6, 1987 -.Dt GETRPCPORT 3 -.Os -.Sh NAME -.Nm getrpcport -.Nd get RPC port number -.Sh SYNOPSIS -.Ft int -.Fn getrpcport "char *host" "int prognum" "int versnum" "int proto" -.Sh DESCRIPTION -The -.Fn getrpcport -function -returns the port number for version -.Fa versnum -of the RPC program -.Fa prognum -running on -.Fa host -and using protocol -.Fa proto . -It returns 0 if it cannot contact the portmapper, or if -.Fa prognum -is not registered. If -.Fa prognum -is registered but not with version -.Fa versnum , -it will still return a port number (for some version of the program) -indicating that the program is indeed registered. -The version mismatch will be detected upon the first call to the service. -.Sh AVAILABILITY -The -.Fn getrpcport -function is part of libtirpc. diff --git a/libtirpc-1.3.1/man/netconfig.5 b/libtirpc-1.3.1/man/netconfig.5 deleted file mode 100644 index e8dcbb2..0000000 --- a/libtirpc-1.3.1/man/netconfig.5 +++ /dev/null @@ -1,123 +0,0 @@ -.Dd November 17, 2000 -.Dt NETCONFIG 5 -.Os -.Sh NAME -.Nm netconfig -.Nd network configuration data base -.Sh SYNOPSIS -.Pa /etc/netconfig -.Sh DESCRIPTION -The -.Nm -file defines a list of -.Dq transport names , -describing their semantics and protocol. -In -.Fx , -this file is only used by the RPC library code. -.Pp -Entries have the following format: -.Pp -.Ar network_id semantics flags family protoname device libraries -.Pp -Entries consist of the following fields: -.Bl -tag -width network_id -.It Ar network_id -The name of the transport described. -.It Ar semantics -Describes the semantics of the transport. -This can be one of: -.Bl -tag -width tpi_cots_ord -offset indent -.It Sy tpi_clts -Connectionless transport. -.It Sy tpi_cots -Connection-oriented transport -.It Sy tpi_cots_ord -Connection-oriented, ordered transport. -.It Sy tpi_raw -A raw connection. -.El -.It Ar flags -This field is either blank (specified by -.Dq Li - ) , -or contains a -.Dq Li v , -meaning visible to the -.Xr getnetconfig 3 -function. -.It Ar family -The protocol family of the transport. -This is currently one of: -.Bl -tag -width loopback -offset indent -.It Sy inet6 -The IPv6 -.Pq Dv PF_INET6 -family of protocols. -.It Sy inet -The IPv4 -.Pq Dv PF_INET -family of protocols. -.It Sy loopback -The -.Dv PF_LOCAL -protocol family. -.El -.It Ar protoname -The name of the protocol used for this transport. -Can currently be either -.Sy udp , -.Sy tcp -or empty. -.It Ar device -This field is always empty in -.Fx . -.It Ar libraries -This field is always empty in -.Fx . -.El -.Pp -The order of entries in this file will determine which transport will -be preferred by the RPC library code, given a match on a specified -network type. -For example, if a sample network config file would look like this: -.Bd -literal -offset indent -udp6 tpi_clts v inet6 udp - - -tcp6 tpi_cots_ord v inet6 tcp - - -udp tpi_clts v inet udp - - -tcp tpi_cots_ord v inet tcp - - -rawip tpi_raw - inet - - - -local tpi_cots_ord - loopback - - - -.Ed -.Pp -then using the network type -.Sy udp -in calls to the RPC library function (see -.Xr rpc 3 ) -will make the code first try -.Sy udp6 , -and then -.Sy udp . -.Pp -.Xr getnetconfig 3 -and associated functions will parse this file and return structures of -the following format: -.Bd -literal -struct netconfig { - char *nc_netid; /* Network ID */ - unsigned long nc_semantics; /* Semantics (see below) */ - unsigned long nc_flag; /* Flags (see below) */ - char *nc_protofmly; /* Protocol family */ - char *nc_proto; /* Protocol name */ - char *nc_device; /* Network device pathname (unused) */ - unsigned long nc_nlookups; /* Number of lookup libs (unused) */ - char **nc_lookups; /* Names of the libraries (unused) */ - unsigned long nc_unused[9]; /* reserved */ -}; -.Ed -.Sh FILES -.Bl -tag -width /etc/netconfig -compact -.It Pa /etc/netconfig -.El -.Sh SEE ALSO -.Xr getnetconfig 3 , -.Xr getnetpath 3 diff --git a/libtirpc-1.3.1/man/publickey.3t b/libtirpc-1.3.1/man/publickey.3t deleted file mode 100644 index 0d4b13f..0000000 --- a/libtirpc-1.3.1/man/publickey.3t +++ /dev/null @@ -1,52 +0,0 @@ -.\" @(#)publickey.3r 2.1 88/08/07 4.0 RPCSRC -.\" -.Dd October 6, 1987 -.Dt PUBLICKEY 3 -.Os -.Sh NAME -.Nm publickey , getpublickey , getsecretkey -.Nd "get public or secret key" -.Sh LIBRARY -.Lb librpcsvc -.Sh SYNOPSIS -.In rpc/rpc.h -.In rpc/key_prot.h -.Ft int -.Fo getpublickey -.Fa "char netname[MAXNETNAMELEN+1]" -.Fa "char publickey[HEXKEYBYTES+1]" -.Fc -.Ft int -.Fo getsecretkey -.Fa "char netname[MAXNETNAMELEN+1]" -.Fa "char secretkey[HEXKEYBYTES+1]" -.Fa "char *passwd" -.Fc -.Sh DESCRIPTION -These routines are used to get public and secret keys from the -.Tn YP -database. -The -.Fn getsecretkey -function -has an extra argument, -.Fa passwd , -which is used to decrypt the encrypted secret key stored in the database. -Both routines return 1 if they are successful in finding the key, 0 otherwise. -The keys are returned as -.Dv NULL Ns \-terminated , -hexadecimal strings. -If the password supplied to -.Fn getsecretkey -fails to decrypt the secret key, the routine will return 1 but the -.Fa secretkey -argument will be a -.Dv NULL -string -.Pq Dq . -.Sh SEE ALSO -.Xr publickey 5 -.Pp -.%T "RPC Programmer's Manual" -in -.Pa /usr/share/doc/psd/23.rpc . diff --git a/libtirpc-1.3.1/man/publickey.5 b/libtirpc-1.3.1/man/publickey.5 deleted file mode 100644 index e0a03f7..0000000 --- a/libtirpc-1.3.1/man/publickey.5 +++ /dev/null @@ -1,41 +0,0 @@ -.\" @(#)publickey.5 2.1 88/08/07 4.0 RPCSRC; from 1.6 88/02/29 SMI; -.Dd October 19, 1987 -.Dt PUBLICKEY 5 -.Os -.Sh NAME -.Nm publickey -.Nd "public key database" -.Sh SYNOPSIS -.Pa /etc/publickey -.Sh DESCRIPTION -.Pa /etc/publickey -is the public key database used for secure -RPC (Remote Procedure Calls). -Each entry in -the database consists of a network user -name (which may either refer to -a user or a hostname), followed by the user's -public key (in hex -notation), a colon, and then the user's -secret key encrypted with -its login password (also in hex notation). -.Pp -This file is altered either by the user through the -.Xr chkey 1 -command or by the system administrator through the -.Xr newkey 8 -command. -The file -.Pa /etc/publickey -should only contain data on the -.Tn NIS -master machine, where it -is converted into the -.Tn NIS -database -.Pa publickey.byname . -.Sh SEE ALSO -.Xr chkey 1 , -.Xr publickey 3 , -.Xr newkey 8 , -.Xr ypupdated 8 diff --git a/libtirpc-1.3.1/man/rpc.3t b/libtirpc-1.3.1/man/rpc.3t deleted file mode 100644 index 9ff7423..0000000 --- a/libtirpc-1.3.1/man/rpc.3t +++ /dev/null @@ -1,515 +0,0 @@ -.\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.Dd May 7, 1993 -.Dt RPC 3 -.Os -.Sh NAME -.Nm rpc -.Nd library routines for remote procedure calls -.Sh SYNOPSIS -.In rpc/rpc.h -.In netconfig.h -.Sh DESCRIPTION -These -routines allow C language programs to make procedure -calls on other machines across a network. -First, the client sends a request to the server. -On receipt of the request, the server calls a dispatch routine -to perform the requested service, and then sends back a reply. -.Pp -All -RPC routines require the header -.In rpc/rpc.h . -Routines that take a -.Vt "struct netconfig" -also require that -.In netconfig.h -be included. -.Sh Nettype -Some of the high-level -RPC interface routines take a -.Fa nettype -string as one of the arguments -(for example, -.Fn clnt_create , -.Fn svc_create , -.Fn rpc_reg , -.Fn rpc_call ) . -This string defines a class of transports which can be used -for a particular application. -.Pp -The -.Fa nettype -argument -can be one of the following: -.Bl -tag -width datagram_v -.It netpath -Choose from the transports which have been -indicated by their token names in the -.Ev NETPATH -environment variable. -.Ev NETPATH -is unset or -.Dv NULL , -it defaults to -.Qq visible . -.Qq netpath -is the default -.Fa nettype . -.It visible -Choose the transports which have the visible flag (v) -set in the -.Pa /etc/netconfig -file. -.It circuit_v -This is same as -.Qq visible -except that it chooses only the connection oriented transports -(semantics -.Qq tpi_cots -or -.Qq tpi_cots_ord ) -from the entries in the -.Pa /etc/netconfig -file. -.It datagram_v -This is same as -.Qq visible -except that it chooses only the connectionless datagram transports -(semantics -.Qq tpi_clts ) -from the entries in the -.Pa /etc/netconfig -file. -.It circuit_n -This is same as -.Qq netpath -except that it chooses only the connection oriented datagram transports -(semantics -.Qq tpi_cots -or -.Qq tpi_cots_ord ) . -.It datagram_n -This is same as -.Qq netpath -except that it chooses only the connectionless datagram transports -(semantics -.Qq tpi_clts ) . -.It udp -This refers to Internet UDP, both version 4 and 6. -.It tcp -This refers to Internet TCP, both version 4 and 6. -.El -.Pp -If -.Fa nettype -is -.Dv NULL , -it defaults to -.Qq netpath . -The transports are tried in left to right order in the -.Ev NETPATH -variable or in top to down order in the -.Pa /etc/netconfig -file. -.Sh Derived Types -The derived types used in the RPC interfaces are defined as follows: -.Bd -literal - typedef u_int32_t rpcprog_t; - typedef u_int32_t rpcvers_t; - typedef u_int32_t rpcproc_t; - typedef u_int32_t rpcprot_t; - typedef u_int32_t rpcport_t; - typedef int32_t rpc_inline_t; -.Ed -.Sh "Data Structures" -Some of the data structures used by the -RPC package are shown below. -.Sh "The AUTH Structure" -.Bd -literal -/* - * Authentication info. Opaque to client. - */ -struct opaque_auth { - enum_t oa_flavor; /* flavor of auth */ - caddr_t oa_base; /* address of more auth stuff */ - u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ -}; - -/* - * Auth handle, interface to client side authenticators. - */ -typedef struct { - struct opaque_auth ah_cred; - struct opaque_auth ah_verf; - struct auth_ops { - void (*ah_nextverf)(\|); - int (*ah_marshal)(\|); /* nextverf & serialize */ - int (*ah_validate)(\|); /* validate verifier */ - int (*ah_refresh)(\|); /* refresh credentials */ - void (*ah_destroy)(\|); /* destroy this structure */ - } *ah_ops; - caddr_t ah_private; -} AUTH; -.Ed -.Sh "The CLIENT Structure" -.Bd -literal -/* - * Client rpc handle. - * Created by individual implementations. - * Client is responsible for initializing auth. - */ - -typedef struct { - AUTH *cl_auth; /* authenticator */ - struct clnt_ops { - enum clnt_stat (*cl_call)(); /* call remote procedure */ - void (*cl_abort)(); /* abort a call */ - void (*cl_geterr)(); /* get specific error code */ - bool_t (*cl_freeres)(); /* frees results */ - void (*cl_destroy)(); /* destroy this structure */ - bool_t (*cl_control)(); /* the ioctl() of rpc */ - } *cl_ops; - caddr_t cl_private; /* private stuff */ - char *cl_netid; /* network identifier */ - char *cl_tp; /* device name */ -} CLIENT; -.Ed -.Sh "The SVCXPRT structure" -.Bd -literal -enum xprt_stat { - XPRT_DIED, - XPRT_MOREREQS, - XPRT_IDLE -}; - -/* - * Server side transport handle - */ -typedef struct { - int xp_fd; /* file descriptor for the server handle */ - u_short xp_port; /* obsolete */ - const struct xp_ops { - bool_t (*xp_recv)(); /* receive incoming requests */ - enum xprt_stat (*xp_stat)(); /* get transport status */ - bool_t (*xp_getargs)(); /* get arguments */ - bool_t (*xp_reply)(); /* send reply */ - bool_t (*xp_freeargs)(); /* free mem allocated for args */ - void (*xp_destroy)(); /* destroy this struct */ - } *xp_ops; - int xp_addrlen; /* length of remote addr. Obsolete */ - struct sockaddr_in xp_raddr; /* Obsolete */ - const struct xp_ops2 { - bool_t (*xp_control)(); /* catch-all function */ - } *xp_ops2; - char *xp_tp; /* transport provider device name */ - char *xp_netid; /* network identifier */ - struct netbuf xp_ltaddr; /* local transport address */ - struct netbuf xp_rtaddr; /* remote transport address */ - struct opaque_auth xp_verf; /* raw response verifier */ - caddr_t xp_p1; /* private: for use by svc ops */ - caddr_t xp_p2; /* private: for use by svc ops */ - caddr_t xp_p3; /* private: for use by svc lib */ - int xp_type /* transport type */ -} SVCXPRT; -.Ed -.Sh "The svc_reg structure" -.Bd -literal -struct svc_req { - rpcprog_t rq_prog; /* service program number */ - rpcvers_t rq_vers; /* service protocol version */ - rpcproc_t rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - caddr_t rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ -}; -.Ed -.Sh "The XDR structure" -.Bd -literal -/* - * XDR operations. - * XDR_ENCODE causes the type to be encoded into the stream. - * XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE=0, - XDR_DECODE=1, - XDR_FREE=2 -}; -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / - BYTES_PER_XDR_UNIT) \e * BYTES_PER_XDR_UNIT) - -/* - * A xdrproc_t exists for each data type which is to be encoded or - * decoded. The second argument to the xdrproc_t is a pointer to - * an opaque pointer. The opaque pointer generally points to a - * structure of the data type to be decoded. If this points to 0, - * then the type routines should allocate dynamic storage of the - * appropriate size and return it. - * bool_t (*xdrproc_t)(XDR *, caddr_t *); - */ -typedef bool_t (*xdrproc_t)(); - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation - */ -typedef struct { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { - bool_t (*x_getlong)(); /* get a long from underlying stream */ - bool_t (*x_putlong)(); /* put a long to underlying stream */ - bool_t (*x_getbytes)(); /* get bytes from underlying stream */ - bool_t (*x_putbytes)(); /* put bytes to underlying stream */ - u_int (*x_getpostn)(); /* returns bytes off from beginning */ - bool_t (*x_setpostn)(); /* lets you reposition the stream */ - long * (*x_inline)(); /* buf quick ptr to buffered data */ - void (*x_destroy)(); /* free privates of this xdr_stream */ - } *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ -} XDR; - -/* - * The netbuf structure. This structure is defined in on SysV - * systems, but NetBSD / FreeBSD do not use XTI. - * - * Usually, buf will point to a struct sockaddr, and len and maxlen - * will contain the length and maximum length of that socket address, - * respectively. - */ -struct netbuf { - unsigned int maxlen; - unsigned int len; - void *buf; -}; - -/* - * The format of the address and options arguments of the XTI t_bind call. - * Only provided for compatibility, it should not be used other than - * as an argument to svc_tli_create(). - */ - -struct t_bind { - struct netbuf addr; - unsigned int qlen; -}; -.Ed -.Sh "Index to Routines" -The following table lists RPC routines and the manual reference -pages on which they are described: -.Pp -.Bl -tag -width "authunix_create_default()" -compact -.It Em "RPC Routine" -.Em "Manual Reference Page" -.Pp -.It Fn auth_destroy -.Xr rpc_clnt_auth 3 -.It Fn authdes_create -.Xr rpc_soc 3 -.It Fn authnone_create -.Xr rpc_clnt_auth 3 -.It Fn authsys_create -.Xr rpc_clnt_auth 3 -.It Fn authsys_create_default -.Xr rpc_clnt_auth 3 -.It Fn authunix_create -.Xr rpc_soc 3 -.It Fn authunix_create_default -.Xr rpc_soc 3 -.It Fn callrpc -.Xr rpc_soc 3 -.It Fn clnt_broadcast -.Xr rpc_soc 3 -.It Fn clnt_call -.Xr rpc_clnt_calls 3 -.It Fn clnt_control -.Xr rpc_clnt_create 3 -.It Fn clnt_create -.Xr rpc_clnt_create 3 -.It Fn clnt_create_timed -.Xr rpc_clnt_create 3 -.It Fn clnt_create_vers -.Xr rpc_clnt_create 3 -.It Fn clnt_create_vers_timed -.Xr rpc_clnt_create 3 -.It Fn clnt_destroy -.Xr rpc_clnt_create 3 -.It Fn clnt_dg_create -.Xr rpc_clnt_create 3 -.It Fn clnt_freeres -.Xr rpc_clnt_calls 3 -.It Fn clnt_geterr -.Xr rpc_clnt_calls 3 -.It Fn clnt_pcreateerror -.Xr rpc_clnt_create 3 -.It Fn clnt_perrno -.Xr rpc_clnt_calls 3 -.It Fn clnt_perror -.Xr rpc_clnt_calls 3 -.It Fn clnt_raw_create -.Xr rpc_clnt_create 3 -.It Fn clnt_spcreateerror -.Xr rpc_clnt_create 3 -.It Fn clnt_sperrno -.Xr rpc_clnt_calls 3 -.It Fn clnt_sperror -.Xr rpc_clnt_calls 3 -.It Fn clnt_tli_create -.Xr rpc_clnt_create 3 -.It Fn clnt_tp_create -.Xr rpc_clnt_create 3 -.It Fn clnt_tp_create_timed -.Xr rpc_clnt_create 3 -.It Fn clnt_udpcreate -.Xr rpc_soc 3 -.It Fn clnt_vc_create -.Xr rpc_clnt_create 3 -.It Fn clntraw_create -.Xr rpc_soc 3 -.It Fn clnttcp_create -.Xr rpc_soc 3 -.It Fn clntudp_bufcreate -.Xr rpc_soc 3 -.It Fn get_myaddress -.Xr rpc_soc 3 -.It Fn pmap_getmaps -.Xr rpc_soc 3 -.It Fn pmap_getport -.Xr rpc_soc 3 -.It Fn pmap_rmtcall -.Xr rpc_soc 3 -.It Fn pmap_set -.Xr rpc_soc 3 -.It Fn pmap_unset -.Xr rpc_soc 3 -.It Fn registerrpc -.Xr rpc_soc 3 -.It Fn rpc_broadcast -.Xr rpc_clnt_calls 3 -.It Fn rpc_broadcast_exp -.Xr rpc_clnt_calls 3 -.It Fn rpc_call -.Xr rpc_clnt_calls 3 -.It Fn rpc_reg -.Xr rpc_svc_calls 3 -.It Fn svc_create -.Xr rpc_svc_create 3 -.It Fn svc_destroy -.Xr rpc_svc_create 3 -.It Fn svc_dg_create -.Xr rpc_svc_create 3 -.It Fn svc_dg_enablecache -.Xr rpc_svc_calls 3 -.It Fn svc_fd_create -.Xr rpc_svc_create 3 -.It Fn svc_fds -.Xr rpc_soc 3 -.It Fn svc_freeargs -.Xr rpc_svc_reg 3 -.It Fn svc_getargs -.Xr rpc_svc_reg 3 -.It Fn svc_getcaller -.Xr rpc_soc 3 -.It Fn svc_getreq -.Xr rpc_soc 3 -.It Fn svc_getreqset -.Xr rpc_svc_calls 3 -.It Fn svc_getrpccaller -.Xr rpc_svc_calls 3 -.It Fn svc_kerb_reg -.Xr kerberos_rpc 3 -.It Fn svc_raw_create -.Xr rpc_svc_create 3 -.It Fn svc_reg -.Xr rpc_svc_calls 3 -.It Fn svc_register -.Xr rpc_soc 3 -.It Fn svc_run -.Xr rpc_svc_reg 3 -.It Fn svc_sendreply -.Xr rpc_svc_reg 3 -.It Fn svc_tli_create -.Xr rpc_svc_create 3 -.It Fn svc_tp_create -.Xr rpc_svc_create 3 -.It Fn svc_unreg -.Xr rpc_svc_calls 3 -.It Fn svc_unregister -.Xr rpc_soc 3 -.It Fn svc_vc_create -.Xr rpc_svc_create 3 -.It Fn svcerr_auth -.Xr rpc_svc_err 3 -.It Fn svcerr_decode -.Xr rpc_svc_err 3 -.It Fn svcerr_noproc -.Xr rpc_svc_err 3 -.It Fn svcerr_noprog -.Xr rpc_svc_err 3 -.It Fn svcerr_progvers -.Xr rpc_svc_err 3 -.It Fn svcerr_systemerr -.Xr rpc_svc_err 3 -.It Fn svcerr_weakauth -.Xr rpc_svc_err 3 -.It Fn svcfd_create -.Xr rpc_soc 3 -.It Fn svcraw_create -.Xr rpc_soc 3 -.It Fn svctcp_create -.Xr rpc_soc 3 -.It Fn svcudp_bufcreate -.Xr rpc_soc 3 -.It Fn svcudp_create -.Xr rpc_soc 3 -.It Fn xdr_accepted_reply -.Xr rpc_xdr 3 -.It Fn xdr_authsys_parms -.Xr rpc_xdr 3 -.It Fn xdr_authunix_parms -.Xr rpc_soc 3 -.It Fn xdr_callhdr -.Xr rpc_xdr 3 -.It Fn xdr_callmsg -.Xr rpc_xdr 3 -.It Fn xdr_opaque_auth -.Xr rpc_xdr 3 -.It Fn xdr_rejected_reply -.Xr rpc_xdr 3 -.It Fn xdr_replymsg -.Xr rpc_xdr 3 -.It Fn xprt_register -.Xr rpc_svc_calls 3 -.It Fn xprt_unregister -.Xr rpc_svc_calls 3 -.El -.Sh FILES -.Bl -tag -width /etc/netconfig -.It Pa /etc/netconfig -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr getnetconfig 3 , -.Xr getnetpath 3 , -.Xr rpcbind 3 , -.Xr rpc_clnt_auth 3 , -.Xr rpc_clnt_calls 3 , -.Xr rpc_clnt_create 3 , -.Xr rpc_svc_calls 3 , -.Xr rpc_svc_create 3 , -.Xr rpc_svc_err 3 , -.Xr rpc_svc_reg 3 , -.Xr rpc_xdr 3 , -.Xr xdr 3 , -.Xr netconfig 5 diff --git a/libtirpc-1.3.1/man/rpc.5 b/libtirpc-1.3.1/man/rpc.5 deleted file mode 100644 index 385c637..0000000 --- a/libtirpc-1.3.1/man/rpc.5 +++ /dev/null @@ -1,57 +0,0 @@ -.\" @(#)rpc.4 1.17 93/08/30 SMI; from SVr4 -.\" Copyright 1989 AT&T -.Dd December 10, 1991 -.Dt RPC 5 -.Os -.Sh NAME -.Nm rpc -.Nd rpc program number data base -.Sh SYNOPSIS -.Pa /etc/rpc -.Sh DESCRIPTION -The -.Nm -file contains user readable names that -can be used in place of RPC program numbers. -For each RPC program a single line should be present -with the following information: -.Pp -.Bl -enum -compact -.It -name of the RPC program -.It -RPC program number -.It -aliases -.El -.Pp -Items are separated by any number of blanks and/or -tab characters. -A hash -.Pq Dq Li # -indicates the beginning of a comment; characters up to the end of -the line are not interpreted by routines which search the file. -.Sh EXAMPLES -Below is an example of an RPC database: -.Bd -literal -# -# rpc -# -rpcbind 100000 portmap sunrpc portmapper -rusersd 100002 rusers -nfs 100003 nfsprog -mountd 100005 mount showmount -walld 100008 rwall shutdown -sprayd 100012 spray -llockmgr 100020 -nlockmgr 100021 -status 100024 -bootparam 100026 -keyserv 100029 keyserver -.Ed -.Sh FILES -.Bl -tag -width /etc/nsswitch.conf -compact -.It Pa /etc/nsswitch.conf -.El -.Sh SEE ALSO -.Xr getrpcent 3 diff --git a/libtirpc-1.3.1/man/rpc_clnt_auth.3t b/libtirpc-1.3.1/man/rpc_clnt_auth.3t deleted file mode 100644 index e20f322..0000000 --- a/libtirpc-1.3.1/man/rpc_clnt_auth.3t +++ /dev/null @@ -1,96 +0,0 @@ -.\" @(#)rpc_clnt_auth.3n 1.21 93/05/07 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_clnt_auth.3,v 1.1 2000/06/03 09:29:50 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_clnt_auth.3,v 1.5 2002/12/19 09:40:23 ru Exp $ -.Dd May 7, 1993 -.Dt RPC_CLNT_AUTH 3 -.Os -.Sh NAME -.Nm auth_destroy , -.Nm authnone_create , -.Nm authsys_create , -.Nm authsys_create_default -.Nd library routines for client side remote procedure call authentication -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft "void" -.Fn auth_destroy "AUTH *auth" -.Ft "AUTH *" -.Fn authnone_create "void" -.Ft "AUTH *" -.Fn authsys_create "const char *host" "const uid_t uid" "const gid_t gid" "const int len" "const gid_t *aup_gids" -.Ft "AUTH *" -.Fn authsys_create_default "void" -.Sh DESCRIPTION -These routines are part of the -RPC library that allows C language programs to make procedure -calls on other machines across the network, -with desired authentication. -.Pp -These routines are normally called after creating the -.Vt CLIENT -handle. -The -.Va cl_auth -field of the -.Vt CLIENT -structure should be initialized by the -.Vt AUTH -structure returned by some of the following routines. -The client's authentication information -is passed to the server when the -RPC -call is made. -.Pp -Only the -.Dv NULL -and the -.Dv SYS -style of authentication is discussed here. -.Sh Routines -.Bl -tag -width authsys_create_default() -.It Fn auth_destroy -A function macro that destroys the authentication -information associated with -.Fa auth . -Destruction usually involves deallocation -of private data structures. -The use of -.Fa auth -is undefined after calling -.Fn auth_destroy . -.It Fn authnone_create -Create and return an RPC -authentication handle that passes nonusable -authentication information with each remote procedure call. -This is the default authentication used by RPC. -.It Fn authsys_create -Create and return an RPC authentication handle that contains -.Dv AUTH_SYS -authentication information. -The -.Fa host -argument -is the name of the machine on which the information was -created; -.Fa uid -is the user's user ID; -.Fa gid -is the user's current group ID; -.Fa len -and -.Fa aup_gids -refer to a counted array of groups to which the user belongs. -.It Fn authsys_create_default -Call -.Fn authsys_create -with the appropriate arguments. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr rpc_clnt_calls 3 , -.Xr rpc_clnt_create 3 diff --git a/libtirpc-1.3.1/man/rpc_clnt_calls.3t b/libtirpc-1.3.1/man/rpc_clnt_calls.3t deleted file mode 100644 index 8c3804b..0000000 --- a/libtirpc-1.3.1/man/rpc_clnt_calls.3t +++ /dev/null @@ -1,316 +0,0 @@ -.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD: src/lib/libc/rpc/rpc_clnt_calls.3,v 1.7 2002/12/19 09:40:23 ru Exp $ -.Dd May 7, 1993 -.Dt RPC_CLNT_CALLS 3 -.Os -.Sh NAME -.Nm rpc_clnt_calls , -.Nm clnt_call , -.Nm clnt_freeres , -.Nm clnt_geterr , -.Nm clnt_perrno , -.Nm clnt_perror , -.Nm clnt_sperrno , -.Nm clnt_sperror , -.Nm rpc_broadcast , -.Nm rpc_broadcast_exp , -.Nm rpc_call -.Nd library routines for client side calls -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft "enum clnt_stat" -.Fn clnt_call "CLIENT *clnt" "const rpcproc_t procnum" "const xdrproc_t inproc" "const caddr_t in" "const xdrproc_t outproc" "caddr_t out" "const struct timeval tout" -.Ft bool_t -.Fn clnt_freeres "CLIENT *clnt" "const xdrproc_t outproc" "caddr_t out" -.Ft void -.Fn clnt_geterr "const CLIENT * clnt" "struct rpc_err * errp" -.Ft void -.Fn clnt_perrno "const enum clnt_stat stat" -.Ft void -.Fn clnt_perror "CLIENT *clnt" "const char *s" -.Ft "char *" -.Fn clnt_sperrno "const enum clnt_stat stat" -.Ft "char *" -.Fn clnt_sperror "CLIENT *clnt" "const char * s" -.Ft "enum clnt_stat" -.Fo rpc_broadcast -.Fa "const rpcprog_t prognum" "const rpcvers_t versnum" -.Fa "const rpcproc_t procnum" "const xdrproc_t inproc" -.Fa "const caddr_t in" "const xdrproc_t outproc" "caddr_t out" -.Fa "const resultproc_t eachresult" "const char *nettype" -.Fc -.Ft "enum clnt_stat" -.Fo rpc_broadcast_exp -.Fa "const rpcprog_t prognum" "const rpcvers_t versnum" -.Fa "const rpcproc_t procnum" "const xdrproc_t xargs" -.Fa "caddr_t argsp" "const xdrproc_t xresults" -.Fa "caddr_t resultsp" "const resultproc_t eachresult" -.Fa "const int inittime" "const int waittime" -.Fa "const char * nettype" -.Fc -.Ft "enum clnt_stat" -.Fo rpc_call -.Fa "const char *host" "const rpcprog_t prognum" -.Fa "const rpcvers_t versnum" "const rpcproc_t procnum" -.Fa "const xdrproc_t inproc" "const char *in" -.Fa "const xdrproc_t outproc" "char *out" "const char *nettype" -.Fc -.Sh DESCRIPTION -RPC library routines allow C language programs to make procedure -calls on other machines across the network. -First, the client calls a procedure to send a request to the server. -Upon receipt of the request, the server calls a dispatch routine -to perform the requested service, and then sends back a reply. -.Pp -The -.Fn clnt_call , -.Fn rpc_call , -and -.Fn rpc_broadcast -routines handle the client side of the procedure call. -The remaining routines deal with error handling in the case of errors. -.Pp -Some of the routines take a -.Vt CLIENT -handle as one of the arguments. -A -.Vt CLIENT -handle can be created by an RPC creation routine such as -.Fn clnt_create -(see -.Xr rpc_clnt_create 3 ) . -.Pp -These routines are safe for use in multithreaded applications. -.Vt CLIENT -handles can be shared between threads, however in this implementation -requests by different threads are serialized (that is, the first request will -receive its results before the second request is sent). -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt CLIENT -data structure. -.Bl -tag -width XXXXX -.It Fn clnt_call -A function macro that calls the remote procedure -.Fa procnum -associated with the client handle, -.Fa clnt , -which is obtained with an RPC -client creation routine such as -.Fn clnt_create -(see -.Xr rpc_clnt_create 3 ) . -The -.Fa inproc -argument -is the XDR function used to encode the procedure's arguments, and -.Fa outproc -is the XDR function used to decode the procedure's results; -.Fa in -is the address of the procedure's argument(s), and -.Fa out -is the address of where to place the result(s). -The -.Fa tout -argument -is the time allowed for results to be returned, which is overridden by -a time-out set explicitly through -.Fn clnt_control , -see -.Xr rpc_clnt_create 3 . -If the remote call succeeds, the status returned is -.Dv RPC_SUCCESS , -otherwise an appropriate status is returned. -.It Fn clnt_freeres -A function macro that frees any data allocated by the -RPC/XDR system when it decoded the results of an RPC call. -The -.Fa out -argument -is the address of the results, and -.Fa outproc -is the XDR routine describing the results. -This routine returns 1 if the results were successfully freed, -and 0 otherwise. -.It Fn clnt_geterr -A function macro that copies the error structure out of the client -handle to the structure at address -.Fa errp . -.It Fn clnt_perrno -Print a message to standard error corresponding -to the condition indicated by -.Fa stat . -A newline is appended. -Normally used after a procedure call fails for a routine -for which a client handle is not needed, for instance -.Fn rpc_call . -.It Fn clnt_perror -Print a message to the standard error indicating why an -RPC call failed; -.Fa clnt -is the handle used to do the call. -The message is prepended with string -.Fa s -and a colon. -A newline is appended. -Normally used after a remote procedure call fails -for a routine which requires a client handle, -for instance -.Fn clnt_call . -.It Fn clnt_sperrno -Take the same arguments as -.Fn clnt_perrno , -but instead of sending a message to the standard error -indicating why an RPC -call failed, return a pointer to a string which contains the message. -The -.Fn clnt_sperrno -function -is normally used instead of -.Fn clnt_perrno -when the program does not have a standard error (as a program -running as a server quite likely does not), or if the programmer -does not want the message to be output with -.Fn printf -(see -.Xr printf 3 ) , -or if a message format different than that supported by -.Fn clnt_perrno -is to be used. -Note: -unlike -.Fn clnt_sperror -and -.Fn clnt_spcreateerror -(see -.Xr rpc_clnt_create 3 ) , -.Fn clnt_sperrno -does not return pointer to static data so the -result will not get overwritten on each call. -.It Fn clnt_sperror -Like -.Fn clnt_perror , -except that (like -.Fn clnt_sperrno ) -it returns a string instead of printing to standard error. -However, -.Fn clnt_sperror -does not append a newline at the end of the message. -Warning: -returns pointer to a buffer that is overwritten -on each call. -.It Fn rpc_broadcast -Like -.Fn rpc_call , -except the call message is broadcast to -all the connectionless transports specified by -.Fa nettype . -If -.Fa nettype -is -.Dv NULL , -it defaults to -.Qq netpath . -Each time it receives a response, -this routine calls -.Fn eachresult , -whose form is: -.Ft bool_t -.Fn eachresult "caddr_t out" "const struct netbuf * addr" "const struct netconfig * netconf" -where -.Fa out -is the same as -.Fa out -passed to -.Fn rpc_broadcast , -except that the remote procedure's output is decoded there; -.Fa addr -points to the address of the machine that sent the results, and -.Fa netconf -is the netconfig structure of the transport on which the remote -server responded. -If -.Fn eachresult -returns 0, -.Fn rpc_broadcast -waits for more replies; -otherwise it returns with appropriate status. -Warning: -broadcast file descriptors are limited in size to the -maximum transfer size of that transport. -For Ethernet, this value is 1500 bytes. -The -.Fn rpc_broadcast -function -uses -.Dv AUTH_SYS -credentials by default (see -.Xr rpc_clnt_auth 3 ) . -.It Fn rpc_broadcast_exp -Like -.Fn rpc_broadcast , -except that the initial timeout, -.Fa inittime -and the maximum timeout, -.Fa waittime -are specified in milliseconds. -The -.Fa inittime -argument -is the initial time that -.Fn rpc_broadcast_exp -waits before resending the request. -After the first resend, the re-transmission interval -increases exponentially until it exceeds -.Fa waittime . -.It Fn rpc_call -Call the remote procedure associated with -.Fa prognum , -.Fa versnum , -and -.Fa procnum -on the machine, -.Fa host . -The -.Fa inproc -argument -is used to encode the procedure's arguments, and -.Fa outproc -is used to decode the procedure's results; -.Fa in -is the address of the procedure's argument(s), and -.Fa out -is the address of where to place the result(s). -The -.Fa nettype -argument -can be any of the values listed on -.Xr rpc 3 . -This routine returns -.Dv RPC_SUCCESS -if it succeeds, -or an appropriate status is returned. -Use the -.Fn clnt_perrno -routine to translate failure status into error messages. -Warning: -.Fn rpc_call -uses the first available transport belonging -to the class -.Fa nettype , -on which it can create a connection. -You do not have control of timeouts or authentication -using this routine. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr printf 3 , -.Xr rpc 3 , -.Xr rpc_clnt_auth 3 , -.Xr rpc_clnt_create 3 diff --git a/libtirpc-1.3.1/man/rpc_clnt_create.3t b/libtirpc-1.3.1/man/rpc_clnt_create.3t deleted file mode 100644 index 95b6fc8..0000000 --- a/libtirpc-1.3.1/man/rpc_clnt_create.3t +++ /dev/null @@ -1,514 +0,0 @@ -.\" @(#)rpc_clnt_create.3n 1.36 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_create 1.5 89/07/24 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_clnt_create.3,v 1.2 2000/06/20 00:53:08 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_clnt_create.3,v 1.12 2003/09/14 13:41:56 ru Exp $ -.Dd May 7, 1993 -.Dt RPC_CLNT_CREATE 3 -.Os -.Sh NAME -.Nm rpc_clnt_create , -.Nm clnt_control , -.Nm clnt_create , -.Nm clnt_create_timed , -.Nm clnt_create_vers , -.Nm clnt_create_vers_timed , -.Nm clnt_destroy , -.Nm clnt_dg_create , -.Nm clnt_pcreateerror , -.Nm clnt_raw_create , -.Nm clnt_spcreateerror , -.Nm clnt_tli_create , -.Nm clnt_tp_create , -.Nm clnt_tp_create_timed , -.Nm clnt_vc_create , -.Nm rpc_createerr -.Nd "library routines for dealing with creation and manipulation of" -.Vt CLIENT -handles -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft bool_t -.Fn clnt_control "CLIENT *clnt" "const u_int req" "char *info" -.Ft "CLIENT *" -.Fn clnt_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" -.Ft "CLIENT *" -.Fn clnt_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" "const struct timeval *timeout" -.Ft "CLIENT *" -.Fn clnt_create_vers "const char * host" "const rpcprog_t prognum" "rpcvers_t *vers_outp" "const rpcvers_t vers_low" "const rpcvers_t vers_high" "const char *nettype" -.Ft "CLIENT *" -.Fn clnt_create_vers_timed "const char * host" "const rpcprog_t prognum" "rpcvers_t *vers_outp" "const rpcvers_t vers_low" "const rpcvers_t vers_high" "char *nettype" "const struct timeval *timeout" -.Ft void -.Fn clnt_destroy "CLIENT *clnt" -.Ft "CLIENT *" -.Fn clnt_dg_create "const int fildes" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "const u_int sendsz" "const u_int recvsz" -.Ft void -.Fn clnt_pcreateerror "const char *s" -.Ft "char *" -.Fn clnt_spcreateerror "const char *s" -.Ft "CLIENT *" -.Fn clnt_raw_create "const rpcprog_t prognum" "const rpcvers_t versnum" -.Ft "CLIENT *" -.Fn clnt_tli_create "const int fildes" "const struct netconfig *netconf" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "const u_int sendsz" "const u_int recvsz" -.Ft "CLIENT *" -.Fn clnt_tp_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" -.Ft "CLIENT *" -.Fn clnt_tp_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "const struct timeval *timeout" -.Ft "CLIENT *" -.Fn clnt_vc_create "const int fildes" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "u_int sendsz" "u_int recvsz" -.Sh DESCRIPTION -RPC library routines allow C language programs to make procedure -calls on other machines across the network. -First a -.Vt CLIENT -handle is created and then the client calls a procedure to send a -request to the server. -On receipt of the request, the server calls a dispatch routine -to perform the requested service, and then sends a reply. -.Sh Routines -.Bl -tag -width YYYYYYY -.It Fn clnt_control -A function macro to change or retrieve various information -about a client object. -The -.Fa req -argument -indicates the type of operation, and -.Fa info -is a pointer to the information. -For both connectionless and connection-oriented transports, -the supported values of -.Fa req -and their argument types and what they do are: -.Bl -column "CLSET_FD_NCLOSE" "struct timeval *" "set total timeout" -.It Dv CLSET_TIMEOUT Ta "struct timeval *" Ta "set total timeout" -.It Dv CLGET_TIMEOUT Ta "struct timeval *" Ta "get total timeout" -.El -.Pp -Note: -if you set the timeout using -.Fn clnt_control , -the timeout argument passed by -.Fn clnt_call -is ignored in all subsequent calls. -.Pp -Note: -If you set the timeout value to 0, -.Fn clnt_control -immediately returns an error -.Pq Dv RPC_TIMEDOUT . -Set the timeout argument to 0 for batching calls. -.Bl -column CLSET_FD_NCLOSE "struct timeval *" "do not close fd on destroy" -.It Dv CLGET_SVC_ADDR Ta "struct netbuf *" Ta "get servers address" -.It Dv CLGET_FD Ta "int *" Ta "get fd from handle" -.It Dv CLSET_FD_CLOSE Ta "void" Ta "close fd on destroy" -.It Dv CLSET_FD_NCLOSE Ta void Ta "don't close fd on destroy" -.It Dv CLGET_VERS Ta "u_int32_t *" Ta "get RPC program version" -.It Dv CLSET_VERS Ta "u_int32_t *" Ta "set RPC program version" -.It Dv CLGET_XID Ta "u_int32_t *" Ta "get XID of previous call" -.It Dv CLSET_XID Ta "u_int32_t *" Ta "set XID of next call" -.El -.Pp -The following operations are valid for connectionless transports only: -.Bl -column CLSET_RETRY_TIMEOUT "struct timeval *" "set total timeout" -.It Dv CLSET_RETRY_TIMEOUT Ta "struct timeval *" Ta "set the retry timeout" -.It Dv CLGET_RETRY_TIMEOUT Ta "struct timeval *" Ta "get the retry timeout" -.It Dv CLSET_CONNECT Ta Vt "int *" Ta use Xr connect 2 -.El -.Pp -The retry timeout is the time that RPC -waits for the server to reply before retransmitting the request. -The -.Fn clnt_control -function -returns -.Dv TRUE -on success and -.Dv FALSE -on failure. -.It Fn clnt_create -Generic client creation routine for program -.Fa prognum -and version -.Fa versnum . -The -.Fa host -argument -identifies the name of the remote host where the server -is located. -The -.Fa nettype -argument -indicates the class of transport protocol to use. -The transports are tried in left to right order in -.Ev NETPATH -environment variable or in top to bottom order in -the netconfig database. -The -.Fn clnt_create -function -tries all the transports of the -.Fa nettype -class available from the -.Ev NETPATH -environment variable and the netconfig database, -and chooses the first successful one. -A default timeout is set and can be modified using -.Fn clnt_control . -This routine returns -.Dv NULL -if it fails. -The -.Fn clnt_pcreateerror -routine can be used to print the reason for failure. -.Pp -Note: -.Fn clnt_create -returns a valid client handle even -if the particular version number supplied to -.Fn clnt_create -is not registered with the -.Xr rpcbind 8 -service. -This mismatch will be discovered by a -.Fn clnt_call -later (see -.Xr rpc_clnt_calls 3 ) . -.It Fn clnt_create_timed -Generic client creation routine which is similar to -.Fn clnt_create -but which also has the additional argument -.Fa timeout -that specifies the maximum amount of time allowed for -each transport class tried. -In all other respects, the -.Fn clnt_create_timed -call behaves exactly like the -.Fn clnt_create -call. -.It Fn clnt_create_vers -Generic client creation routine which is similar to -.Fn clnt_create -but which also checks for the -version availability. -The -.Fa host -argument -identifies the name of the remote host where the server -is located. -The -.Fa nettype -argument -indicates the class transport protocols to be used. -If the routine is successful it returns a client handle created for -the highest version between -.Fa vers_low -and -.Fa vers_high -that is supported by the server. -The -.Fa vers_outp -argument -is set to this value. -That is, after a successful return -.Fa vers_low -<= -.Fa *vers_outp -<= -.Fa vers_high . -If no version between -.Fa vers_low -and -.Fa vers_high -is supported by the server then the routine fails and returns -.Dv NULL . -A default timeout is set and can be modified using -.Fn clnt_control . -This routine returns -.Dv NULL -if it fails. -The -.Fn clnt_pcreateerror -routine can be used to print the reason for failure. -Note: -.Fn clnt_create -returns a valid client handle even -if the particular version number supplied to -.Fn clnt_create -is not registered with the -.Xr rpcbind 8 -service. -This mismatch will be discovered by a -.Fn clnt_call -later (see -.Xr rpc_clnt_calls 3 ) . -However, -.Fn clnt_create_vers -does this for you and returns a valid handle -only if a version within -the range supplied is supported by the server. -.It Fn clnt_create_vers_timed -Generic client creation routine which is similar to -.Fn clnt_create_vers -but which also has the additional argument -.Fa timeout -that specifies the maximum amount of time allowed for -each transport class tried. -In all other respects, the -.Fn clnt_create_vers_timed -call behaves exactly like the -.Fn clnt_create_vers -call. -.It Fn clnt_destroy -A function macro that destroys the client's RPC handle. -Destruction usually involves deallocation -of private data structures, including -.Fa clnt -itself. -Use of -.Fa clnt -is undefined after calling -.Fn clnt_destroy . -If the RPC library opened the associated file descriptor, or -.Dv CLSET_FD_CLOSE -was set using -.Fn clnt_control , -the file descriptor will be closed. -The caller should call -.Fn auth_destroy "clnt->cl_auth" -(before calling -.Fn clnt_destroy ) -to destroy the associated -.Vt AUTH -structure (see -.Xr rpc_clnt_auth 3 ) . -.It Fn clnt_dg_create -This routine creates an RPC client for the remote program -.Fa prognum -and version -.Fa versnum ; -the client uses a connectionless transport. -The remote program is located at address -.Fa svcaddr . -The -.Fa fildes -argument -is an open and bound file descriptor. -This routine will resend the call message in intervals of -15 seconds until a response is received or until the -call times out. -The total time for the call to time out is specified by -.Fn clnt_call -(see -.Fn clnt_call -in -.Xr rpc_clnt_calls 3 ) . -The retry time out and the total time out periods can -be changed using -.Fn clnt_control . -The user may set the size of the send and receive -buffers with the -.Fa sendsz -and -.Fa recvsz -arguments; -values of 0 choose suitable defaults. -This routine returns -.Dv NULL -if it fails. -.It Fn clnt_pcreateerror -Print a message to standard error indicating -why a client RPC handle could not be created. -The message is prepended with the string -.Fa s -and a colon, and appended with a newline. -.It Fn clnt_spcreateerror -Like -.Fn clnt_pcreateerror , -except that it returns a string -instead of printing to the standard error. -A newline is not appended to the message in this case. -Warning: -returns a pointer to a buffer that is overwritten -on each call. -.It Fn clnt_raw_create -This routine creates an RPC -client handle for the remote program -.Fa prognum -and version -.Fa versnum . -The transport used to pass messages to the service is -a buffer within the process's address space, -so the corresponding RPC -server should live in the same address space; -(see -.Fn svc_raw_create -in -.Xr rpc_svc_create 3 ) . -This allows simulation of RPC and measurement of -RPC overheads, such as round trip times, -without any kernel or networking interference. -This routine returns -.Dv NULL -if it fails. -The -.Fn clnt_raw_create -function -should be called after -.Fn svc_raw_create . -.It Fn clnt_tli_create -This routine creates an RPC -client handle for the remote program -.Fa prognum -and version -.Fa versnum . -The remote program is located at address -.Fa svcaddr . -If -.Fa svcaddr -is -.Dv NULL -and it is connection-oriented, it is assumed that the file descriptor -is connected. -For connectionless transports, if -.Fa svcaddr -is -.Dv NULL , -.Dv RPC_UNKNOWNADDR -error is set. -The -.Fa fildes -argument -is a file descriptor which may be open, bound and connected. -If it is -.Dv RPC_ANYFD , -it opens a file descriptor on the transport specified by -.Fa netconf . -If -.Fa fildes -is -.Dv RPC_ANYFD -and -.Fa netconf -is -.Dv NULL , -a -.Dv RPC_UNKNOWNPROTO -error is set. -If -.Fa fildes -is unbound, then it will attempt to bind the descriptor. -The user may specify the size of the buffers with the -.Fa sendsz -and -.Fa recvsz -arguments; -values of 0 choose suitable defaults. -Depending upon the type of the transport (connection-oriented -or connectionless), -.Fn clnt_tli_create -calls appropriate client creation routines. -This routine returns -.Dv NULL -if it fails. -The -.Fn clnt_pcreateerror -routine can be used to print the reason for failure. -The remote rpcbind -service (see -.Xr rpcbind 8 ) -is not consulted for the address of the remote -service. -.It Fn clnt_tp_create -Like -.Fn clnt_create -except -.Fn clnt_tp_create -tries only one transport specified through -.Fa netconf . -The -.Fn clnt_tp_create -function -creates a client handle for the program -.Fa prognum , -the version -.Fa versnum , -and for the transport specified by -.Fa netconf . -Default options are set, -which can be changed using -.Fn clnt_control -calls. -The remote rpcbind service on the host -.Fa host -is consulted for the address of the remote service. -This routine returns -.Dv NULL -if it fails. -The -.Fn clnt_pcreateerror -routine can be used to print the reason for failure. -.It Fn clnt_tp_create_timed -Like -.Fn clnt_tp_create -except -.Fn clnt_tp_create_timed -has the extra argument -.Fa timeout -which specifies the maximum time allowed for -the creation attempt to succeed. -In all other respects, the -.Fn clnt_tp_create_timed -call behaves exactly like the -.Fn clnt_tp_create -call. -.It Fn clnt_vc_create -This routine creates an RPC -client for the remote program -.Fa prognum -and version -.Fa versnum ; -the client uses a connection-oriented transport. -The remote program is located at address -.Fa svcaddr . -The -.Fa fildes -argument -is an open and bound file descriptor. -The user may specify the size of the send and receive buffers -with the -.Fa sendsz -and -.Fa recvsz -arguments; -values of 0 choose suitable defaults. -This routine returns -.Dv NULL -if it fails. -The address -.Fa svcaddr -should not be -.Dv NULL -and should point to the actual address of the remote program. -The -.Fn clnt_vc_create -function -does not consult the remote rpcbind service for this information. -.It Xo -.Vt "struct rpc_createerr" Va rpc_createerr ; -.Xc -A global variable whose value is set by any RPC -client handle creation routine -that fails. -It is used by the routine -.Fn clnt_pcreateerror -to print the reason for the failure. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr rpc_clnt_auth 3 , -.Xr rpc_clnt_calls 3 , -.Xr rpcbind 8 diff --git a/libtirpc-1.3.1/man/rpc_gss_get_error.3t b/libtirpc-1.3.1/man/rpc_gss_get_error.3t deleted file mode 100644 index 2843a71..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_get_error.3t +++ /dev/null @@ -1,55 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GET_ERROR 3 -.Os -.Sh NAME -.Nm rpc_gss_get_error -.Nd "Get error details" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft void -.Fn rpc_gss_get_error "rpc_gss_error_t *error" -.Sh DESCRIPTION -Get details of the last RPCSEC_GSS error. -.Sh PARAMETERS -.Bl -tag -width ".It error" -.It error -A pointer to a structure where the error details will be returned -.El -.Sh AVAILABILITY -The -.Fn rpc_gss_get_error -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_get_mech_info.3t b/libtirpc-1.3.1/man/rpc_gss_get_mech_info.3t deleted file mode 100644 index 44f0df3..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_get_mech_info.3t +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GET_MECH_INFO 3 -.Os -.Sh NAME -.Nm rpc_gss_get_mech_info -.Nd "Get Quality of Protection information for a security mechanism" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft const char ** -.Fn rpc_gss_get_mech_info "const char *mech" "rpc_gss_service_t *service" -.Sh DESCRIPTION -This function returns the list of QOP names supported by the -GSS_API mechanism named "mech". -.Sh PARAMETERS -.Bl -tag -width ".It service" -.It mech -The name of a GSS_API mechanism. -"kerberos_v5" is currently the only supported mechanism. -.It service -Buffer in which maximum service type is planted -.El -.Sh RETURN VALUES -If the named GSS_API mechanism is recognized, -a list of the supported Qualities of Protection is returned. -The maximum supported service type for the mechanism is returned in -.Fa *service . -Otherwise -.Dv NULL -is returned. -.Pp -Note: The returned QOP list is statically allocated memory. -The caller must not free this array. -.Sh AVAILABILITY -The -.Fn rpc_gss_get_mech_info -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_get_mechanisms.3t b/libtirpc-1.3.1/man/rpc_gss_get_mechanisms.3t deleted file mode 100644 index 47af364..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_get_mechanisms.3t +++ /dev/null @@ -1,52 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GET_MECHANISMS 3 -.Os -.Sh NAME -.Nm rpc_gss_get_mechanisms -.Nd "Get installed mechanisms" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft const char ** -.Fn rpc_gss_get_mechanisms "void" -.Sh DESCRIPTION -Return a -.Dv NULL -terminated list of installed security mechanisms. -.Sh AVAILABILITY -The -.Fn rpc_gss_get_mechanisms -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_get_principal_name.3t b/libtirpc-1.3.1/man/rpc_gss_get_principal_name.3t deleted file mode 100644 index ba04239..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_get_principal_name.3t +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GET_PRINCIPAL_NAME 3 -.Os -.Sh NAME -.Nm rpc_gss_get_principal_name -.Nd "Get a principal name" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fo rpc_gss_get_principal_name -.Fa "rpc_gss_principal_t *principal" -.Fa "const char *mech" -.Fa "const char *name" -.Fa "const char *node" -.Fa "const char *domain" -.Fc -.Sh DESCRIPTION -This function can be used to generate a client principal name from -various strings. -.Sh PARAMETERS -.Bl -tag -width ".It principal" -.It principal -If the principal is created successfully, -.Fa *principal -will be set to point at the new principal in GSS-API exported name form -.It mech -The name of the mechanism for this principal -.It name -The name part of the principal -.It node -If non-null, the hostname or instance part of the principal -.It domain -If non-null, the domain or realm part of the principal -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if the principal was created or -.Dv FALSE -otherwise -.Sh AVAILABILITY -The -.Fn rpc_gss_get_principal_name -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr gss_export_name 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_get_versions.3t b/libtirpc-1.3.1/man/rpc_gss_get_versions.3t deleted file mode 100644 index 3230e5e..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_get_versions.3t +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GET_VERSIONS 3 -.Os -.Sh NAME -.Nm rpc_gss_get_versions -.Nd "Get supported protocol version" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fn rpc_gss_get_versions "u_int *vers_hi" "u_int *vers_lo" -.Sh DESCRIPTION -Return the highest and lowest supported versions of the RPCSEC_GSS protocol. -.Sh PARAMETERS -.Bl -tag -width ".It vers_lo" -.It vers_hi -The value of -.Fa *vers_hi -is set to the highest supported protocol version -.It vers_lo -The value of -.Fa *vers_lo -is set to the lowest supported protocol version -.El -.Sh AVAILABILITY -The -.Fn rpc_gss_get_versions -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_getcred.3t b/libtirpc-1.3.1/man/rpc_gss_getcred.3t deleted file mode 100644 index 691df31..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_getcred.3t +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_GETCRED 3 -.Os -.Sh NAME -.Nm rpc_gss_getcred -.Nd "Get authorization information for an RPC request" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft AUTH * -.Fo rpc_gss_getcred -.Fa "struct svc_req *req" -.Fa "rpc_gss_rawcred_t **rcred" -.Fa "rpc_gss_ucred_t **ucred" -.Fa "void **cookie" -.Fc -.Sh DESCRIPTION -This function returns the RPCSEC_GSS authenticated credentials -associated with an RPC request. -.Sh PARAMETERS -.Bl -tag -width ".It cookie" -.It req -The RPC request to query -.It rcred -If non-null, -.Fa *rcred -is set to point at the raw credentials for this request -.It ucred -If non-null, -.Fa *ucred -is set to point at the corresponding unix credentials -.It cookie -If non-null, -.Fa *cookie -is set to the cookie value returned by a callback function registered with -.Fn rpc_gss_set_callback -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if successful, -.Dv FALSE -otherwise. -.Sh AVAILABILITY -The -.Fn rpc_gss_getcred -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpc_gss_set_callback 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_is_installed.3t b/libtirpc-1.3.1/man/rpc_gss_is_installed.3t deleted file mode 100644 index d5f5e44..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_is_installed.3t +++ /dev/null @@ -1,63 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_IS_INSTALLED 3 -.Os -.Sh NAME -.Nm rpc_gss_is_installed -.Nd "Query for the presence of a security mechanism" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fn rpc_gss_is_installed "const char *mech" -.Sh DESCRIPTION -This function indicates whether the GSS_API mechanism named "mech" -is installed and enabled. -.Sh PARAMETERS -.Bl -tag -width ".It mech" -.It mech -The name of a GSS_API mechanism. -"kerberos_v5" is currently the only supported mechanism. -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if the named GSS_API mechanism is installed and enabled, -.Dv FALSE -otherwise. -.Sh AVAILABILITY -The -.Fn rpc_gss_is_installed -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_max_data_length.3t b/libtirpc-1.3.1/man/rpc_gss_max_data_length.3t deleted file mode 100644 index fa7027a..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_max_data_length.3t +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_MAX_DATA_LENGTH 3 -.Os -.Sh NAME -.Nm rpc_gss_max_data_length -.Nd "calculate maximum data size" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft int -.Fn rpc_gss_max_data_length "AUTH *auth" "int max_tp_unit_len" -.Sh DESCRIPTION -Calculate the maximum message size that will fit into a packet of size -.Fa max_tp_unit_len , -given the current service and QoP setting. -.Sh PARAMETERS -.Bl -tag -width ".It max_tp_unit_len" -.It auth -A handle to a RPCSEC_GSS security context -.It max_tp_unit_len -Maximum packet size of the underlying transport protocol -.El -.Sh RETURN VALUES -The maximum message size that can be encoded -.Sh AVAILABILITY -The -.Fn rpc_gss_max_data_length -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_mech_to_oid.3t b/libtirpc-1.3.1/man/rpc_gss_mech_to_oid.3t deleted file mode 100644 index 4a1b25d..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_mech_to_oid.3t +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_MECH_TO_OID 3 -.Os -.Sh NAME -.Nm rpc_gss_mech_to_oid -.Nd "Convert a mechanism name to a GSS-API oid" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fn rpc_gss_mech_to_oid "const char *mech" "gss_OID *oid_ret" -.Sh DESCRIPTION -This function returns the GSS OID associated with the GSS_API -mechanism "mech". -.Sh PARAMETERS -.Bl -tag -width ".It oid_ret" -.It mech -The name of a GSS_API mechanism. -"kerberos_v5" is currently the only supported mechanism. -.It oid_ret -Buffer in which to place the returned OID -.El -.Sh RETURN VALUES -If the GSS_API mechanism name is recognized, -.Dv TRUE -is returned. -The corresponding GSS-API oid is returned in -.Fa *oid_ret . -Otherwise -.Dv FALSE -is returned and -.Fa *oid_ret -is left untouched. -.Sh AVAILABILITY -The -.Fn rpc_gss_mech_to_oid -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_qop_to_num.3t b/libtirpc-1.3.1/man/rpc_gss_qop_to_num.3t deleted file mode 100644 index 7ac1a4c..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_qop_to_num.3t +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_QOP_TO_NUM 3 -.Os -.Sh NAME -.Nm rpc_gss_qop_to_num -.Nd "Convert a Quality of Protection name to number" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fn rpc_gss_qop_to_num "const char *qop" "const char *mech" "u_int *num_ret" -.Sh DESCRIPTION -This function returns the numeric QOP value associated with the -GSS_API QOP "qop" and mechanism "mech." -.Sh PARAMETERS -.Bl -tag -width ".It number_ret" -.It qop -The name of Quality of Protection associated with the -GSS_API mechanism "mech". -"GSS_C_QOP_DEFAULT" is currently the only supported QOP. -.It mech -The name of a GSS_API mechanism. -"kerberos_v5" is currently the only supported mechanism. -.It number_ret -Buffer in which to place the returned QOP number -.El -.Sh RETURN VALUES -If the QOP and mechanism names are recognized, -.Dv TRUE -is returned. -The corresponding QOP number is returned in -.Fa *num_ret . -Otherwise -.Dv FALSE -is returned and -.It number_ret -is left untouched. -.Sh AVAILABILITY -The -.Fn rpc_gss_qop_to_num -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_seccreate.3t b/libtirpc-1.3.1/man/rpc_gss_seccreate.3t deleted file mode 100644 index b52df19..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_seccreate.3t +++ /dev/null @@ -1,109 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SECCREATE 3 -.Os -.Sh NAME -.Nm rpc_gss_seccreate -.Nd "create a security context using the RPCSEC_GSS protocol" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft AUTH * -.Fo rpc_gss_seccreate -.Fa "CLIENT *clnt" -.Fa "const char *principal" -.Fa "const char *mechanism" -.Fa "rpc_gss_service_t service" -.Fa "const char *qop" -.Fa "rpc_gss_options_req_t *options_req" -.Fa "rpc_gss_options_ret_t *options_ret" -.Fc -.Sh DESCRIPTION -This function is used to establish a security context between an -application and a remote peer using the RPSEC_GSS protocol. -.Sh PARAMETERS -.Bl -tag -width "options_req" -.It clnt -An RPC handle which is connected to the remote peer -.It principal -The name of the service principal on the remote peer. -For instance, a principal such as -.Qq nfs@server.example.com -might be used by an application which needs to contact an NFS server -.It mechanism -The name of the GSS_API mechanism to use for the new security context. -"kerberos_v5" is currently the only supported mechanism. -.It service -Type of service requested. -.Bl -tag -width "rpc_gss_svc_integrity" -.It rpc_gss_svc_default -The default - typically the same as -.Dv rpc_gss_svc_none . -.It rpc_gss_svc_none -RPC headers only are integrity protected by a checksum. -.It rpc_gss_svc_integrity -RPC headers and data are integrity protected by a checksum. -.It rpc_gss_svc_privacy -RPC headers are integrity protected by a checksum and data is encrypted. -.El -.It qop -The name of the Quality of Protection to use for the new security context, -or NULL to use the default QOP. -"GSS_C_QOP_DEFAULT" is currently the only supported QOP. -.It options_req -Extra security context options to be passed to the underlying GSS-API -mechanism. -Pass -.Dv NULL -to supply default values. -.It options_ret -Various values returned by the underlying GSS-API mechanism. -Pass -.Dv NULL -if these values are not required. -.El -.Sh RETURN VALUES -If the security context was created successfully, a pointer to an -.Vt AUTH -structure that represents the context is returned. -To use this security context for subsequent RPC calls, set -.Va clnt->cl_auth -to this value. -.Sh AVAILABILITY -The -.Fn rpc_gss_seccreate -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr mech 5 , -.Xr qop 5 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_set_callback.3t b/libtirpc-1.3.1/man/rpc_gss_set_callback.3t deleted file mode 100644 index ee4ebdf..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_set_callback.3t +++ /dev/null @@ -1,112 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SET_CALLBACK 3 -.Os -.Sh NAME -.Nm rpc_gss_set_callback -.Nd "Register a security context creation callback" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fo (*callback) -.Fa "struct svc_req *req" -.Fa "gss_cred_id_t deleg" -.Fa "gss_ctx_id_t gss_context" -.Fa "rpc_gss_lock_t *lock" -.Fa "void **cookie" -.Fc -.Ft bool_t -.Fn rpc_gss_set_callback "rpc_gss_callback_t *cb" -.Sh DESCRIPTION -Register a function which will be called when new security contexts -are created on a server. -This function will be called on the first RPC request which uses that -context and has the opportunity of rejecting the request (for instance -after matching the request credentials to an access control list). -To accept the new security context, the callback should return -.Dv TRUE , -otherwise -.Dv FALSE . -If the callback accepts a context, it becomes responsible for the -lifetime of the delegated client credentials (if any). -.Pp -It is also possible to 'lock' the values of service and quality of -protection used by the context. -If a context is locked, any subsequent requests which use different -values for service and quality of protection will be rejected. -.Sh PARAMETERS -.Bl -tag -width ".It gss_context" -.It cb -A structure containing the RPC program and version for this callback -and a function which will be called when new contexts are created for -the given RPC program and version -.It req -The RPC request using the new context -.It deleg -GSS-API delegated credentials (if any) -.It gss_context -The GSS-API context -.It lock -A structure used to enforce a particular QOP and service. Set -.Fa lock->locked -to -.Dv TRUE -to lock the service and QOP values -.It cookie -The callback function may set -.Fa *cookie -to any pointer sized value. -This value can be accessed during the lifetime of the context via -.Fn rpc_gss_getcred . -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if the callback was registered successfully or -.Dv FALSE -otherwise -.Sh AVAILABILITY -The -.Fn rpc_gss_set_callback -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpc_gss_getcred 3 -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . -.Sh BUGS -There is no mechanism for informing a server when a security context -has been deleted. -This makes it difficult to allocate resources (e.g. to return via the -callback's -.Fa cookie -argument). diff --git a/libtirpc-1.3.1/man/rpc_gss_set_defaults.3t b/libtirpc-1.3.1/man/rpc_gss_set_defaults.3t deleted file mode 100644 index 471a829..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_set_defaults.3t +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SET_DEFAULTS 3 -.Os -.Sh NAME -.Nm rpc_gss_set_defaults -.Nd "set service and quality of protection" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fo rpc_gss_set_defaults -.Fa "AUTH *auth" -.Fa "rpc_gss_service_t service" -.Fa "const char *qop" -.Fc -.Sh DESCRIPTION -Set the service and quality of protection to be used for RPC requests. -The new values apply for the rest of the lifetime of the context -(unless changed again with this function). -.Sh PARAMETERS -.Bl -tag -width ".It service" -.It service -The service type to use for subsequent RPC requests -.It qop -The quality of protection to use or NULL for the default -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if the values were set -.Sh AVAILABILITY -The -.Fn rpc_gss_set_defaults -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_set_svc_name.3t b/libtirpc-1.3.1/man/rpc_gss_set_svc_name.3t deleted file mode 100644 index b895920..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_set_svc_name.3t +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SET_SVC_NAME 3 -.Os -.Sh NAME -.Nm rpc_gss_set_svc_name -.Nd "Associate a GSS-API service principal with an RPC service" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft bool_t -.Fo rpc_gss_set_svc_name -.Fa "const char *principal" -.Fa "const char *mechanism" -.Fa "u_int req_time" -.Fa "u_int program" -.Fa "u_int version" -.Fc -.Sh DESCRIPTION -This function registers a service principal which will be used to -authenticate RPCSEC_GSS security contexts for a given RPC program and -version. -.Sh PARAMETERS -.Bl -tag -width ".It mechanism" -.It principal -A string representing the service principal in the form -.Qq service@hostname -.It mechanism -The name of the security mechanism -.It req_time -The time in seconds that the service credentials should remain -valid. -See -.Xr gss_acquire_cred 3 -for more details. -principal. -.It program -RPC program number for this service -.It version -RPC program version for this service -.El -.Sh RETURN VALUES -Returns -.Dv TRUE -if the service principal was registered or -.Dv FALSE -otherwise. -.Sh AVAILABILITY -The -.Fn rpc_gss_set_svc_name -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr gss_acquire_cred 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_gss_svc_max_data_length.3t b/libtirpc-1.3.1/man/rpc_gss_svc_max_data_length.3t deleted file mode 100644 index 4b89716..0000000 --- a/libtirpc-1.3.1/man/rpc_gss_svc_max_data_length.3t +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SVC_MAX_DATA_LENGTH 3 -.Os -.Sh NAME -.Nm rpc_gss_svc_max_data_length -.Nd "calculate maximum data size" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Ft int -.Fn rpc_gss_svc_max_data_length "struct svc_req *req" "int max_tp_unit_len" -.Sh DESCRIPTION -Calculate the maximum message size that will fit into a packet of size -.Fa max_tp_unit_len , -given the current service and QoP setting. -.Sh PARAMETERS -.Bl -tag -width ".It max_tp_unit_len" -.It req -An RPC request -.It max_tp_unit_len -Maximum packet size of the underlying transport protocol -.El -.Sh RETURN VALUES -The maximum message size that can be encoded -.Sh AVAILABILITY -The -.Fn rpc_gss_svc_max_data_length -function is part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 , -.Xr rpcsec_gss 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rpc_secure.3t b/libtirpc-1.3.1/man/rpc_secure.3t deleted file mode 100644 index 404df0b..0000000 --- a/libtirpc-1.3.1/man/rpc_secure.3t +++ /dev/null @@ -1,295 +0,0 @@ -.\" @(#)rpc_secure.3n 2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI -.\" $FreeBSD: src/lib/libc/rpc/rpc_secure.3,v 1.14 2002/12/19 09:40:23 ru Exp $ -.\" -.Dd February 16, 1988 -.Dt RPC 3 -.Os -.Sh NAME -.Nm rpc_secure -.Nd library routines for secure remote procedure calls -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft AUTH * -.Fo authdes_create -.Fa "char *name" -.Fa "unsigned window" -.Fa "struct sockaddr *addr" -.Fa "des_block *ckey" -.Fc -.Ft AUTH * -.Fo authdes_pk_create -.Fa "char *name" -.Fa "netobj *publickey" -.Fa "unsigned window" -.Fa "struct sockaddr *addr" -.Fa "des_block *ckey" -.Fc -.Ft int -.Fn authdes_getucred "struct authdes_cred *adc" "uid_t *uid" "gid_t *gid" "int *grouplen" "gid_t *groups" -.Ft int -.Fn getnetname "char *name" -.Ft int -.Fn host2netname "char *name" "const char *host" "const char *domain" -.Ft int -.Fn key_decryptsession "const char *remotename" "des_block *deskey" -.Ft int -.Fn key_encryptsession "const char *remotename" "des_block *deskey" -.Ft int -.Fn key_gendes "des_block *deskey" -.Ft int -.Fn key_setsecret "const char *key" -.Ft int -.Fn netname2host "char *name" "char *host" "int hostlen" -.Ft int -.Fn netname2user "char *name" "uid_t *uidp" "gid_t *gidp" "int *gidlenp" "gid_t *gidlist" -.Ft int -.Fn user2netname "char *name" "const uid_t uid" "const char *domain" -.Sh DESCRIPTION -These routines are part of the -.Tn RPC -library. They implement -.Tn DES -Authentication. See -.Xr rpc 3 -for further details about -.Tn RPC . -.Pp -The -.Fn authdes_create -is the first of two routines which interface to the -.Tn RPC -secure authentication system, known as -.Tn DES -authentication. -The second is -.Fn authdes_getucred , -below. -.Pp -Note: the keyserver daemon -.Xr keyserv 8 -must be running for the -.Tn DES -authentication system to work. -.Pp -The -.Fn authdes_create -function, -used on the client side, returns an authentication handle that -will enable the use of the secure authentication system. -The first argument -.Fa name -is the network name, or -.Fa netname , -of the owner of the server process. -This field usually -represents a -.Fa hostname -derived from the utility routine -.Fn host2netname , -but could also represent a user name using -.Fn user2netname . -The second field is window on the validity of -the client credential, given in seconds. A small -window is more secure than a large one, but choosing -too small of a window will increase the frequency of -resynchronizations because of clock drift. -The third -argument -.Fa addr -is optional. If it is -.Dv NULL , -then the authentication system will assume -that the local clock is always in sync with the server's -clock, and will not attempt resynchronizations. -If an address -is supplied, however, then the system will use the address -for consulting the remote time service whenever -resynchronization -is required. -This argument is usually the -address of the -.Tn RPC -server itself. -The final argument -.Fa ckey -is also optional. If it is -.Dv NULL , -then the authentication system will -generate a random -.Tn DES -key to be used for the encryption of credentials. -If it is supplied, however, then it will be used instead. -.Pp -The -.Fn authdes_pk_create -function is identical to -.Fn authdes_create , -except that the public key needs to be provided at calling time and -will not looked up by this function itself. -.Pp -The -.Fn authdes_getucred -function, -the second of the two -.Tn DES -authentication routines, -is used on the server side for converting a -.Tn DES -credential, which is -operating system independent, into a -.Ux -credential. -This routine differs from utility routine -.Fn netname2user -in that -.Fn authdes_getucred -pulls its information from a cache, and does not have to do a -Yellow Pages lookup every time it is called to get its information. -.Pp -The -.Fn getnetname -function -installs the unique, operating-system independent netname of -the -caller in the fixed-length array -.Fa name . -Returns -.Dv TRUE -if it succeeds and -.Dv FALSE -if it fails. -.Pp -The -.Fn host2netname -function -converts from a domain-specific hostname to an -operating-system independent netname. -Returns -.Dv TRUE -if it succeeds and -.Dv FALSE -if it fails. -Inverse of -.Fn netname2host . -.Pp -The -.Fn key_decryptsession -function -is an interface to the keyserver daemon, which is associated -with -.Tn RPC Ns 's -secure authentication system -.Tn ( DES -authentication). -User programs rarely need to call it, or its associated routines -.Fn key_encryptsession , -.Fn key_gendes -and -.Fn key_setsecret . -System commands such as -.Xr login 1 -and the -.Tn RPC -library are the main clients of these four routines. -.Pp -The -.Fn key_decryptsession -function -takes a server netname and a -.Tn DES -key, and decrypts the key by -using the public key of the server and the secret key -associated with the effective uid of the calling process. It -is the inverse of -.Fn key_encryptsession . -.Pp -The -.Fn key_encryptsession -function -is a keyserver interface routine. -It -takes a server netname and a des key, and encrypts -it using the public key of the server and the secret key -associated with the effective uid of the calling process. It -is the inverse of -.Fn key_decryptsession . -.Pp -The -.Fn key_gendes -function -is a keyserver interface routine. -It -is used to ask the keyserver for a secure conversation key. -Choosing one -.Qq random -is usually not good enough, -because -the common ways of choosing random numbers, such as using the -current time, are very easy to guess. -.Pp -The -.Fn key_setsecret -function -is a keyserver interface routine. -It is used to set the key for -the effective -.Fa uid -of the calling process. -.Pp -The -.Fn netname2host -function -converts from an operating-system independent netname to a -domain-specific hostname. -Returns -.Dv TRUE -if it succeeds and -.Dv FALSE -if it fails. Inverse of -.Fn host2netname . -.Pp -The -.Fn netname2user -function -converts from an operating-system independent netname to a -domain-specific user ID. -Returns -.Dv TRUE -if it succeeds and -.Dv FALSE -if it fails. -Inverse of -.Fn user2netname . -.Pp -The -.Fn user2netname -function -converts from a domain-specific username to an operating-system -independent netname. -Returns -.Dv TRUE -if it succeeds and -.Dv FALSE -if it fails. -Inverse of -.Fn netname2user . -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr xdr 3 -.Pp -The following manuals: -.Rs -.%B Remote Procedure Calls: Protocol Specification -.Re -.Rs -.%B Remote Procedure Call Programming Guide -.Re -.Rs -.%B Rpcgen Programming Guide -.Re -.Rs -.%B RPC: Remote Procedure Call Protocol Specification -.%O RFC1050, Sun Microsystems Inc., USC-ISI -.Re diff --git a/libtirpc-1.3.1/man/rpc_soc.3t b/libtirpc-1.3.1/man/rpc_soc.3t deleted file mode 100644 index f26c0af..0000000 --- a/libtirpc-1.3.1/man/rpc_soc.3t +++ /dev/null @@ -1,1726 +0,0 @@ -.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI -.\" $NetBSD: rpc_soc.3,v 1.2 2000/06/07 13:39:43 simonb Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_soc.3,v 1.12 2003/02/06 11:04:47 charnier Exp $ -.\" -.Dd February 16, 1988 -.Dt RPC_SOC 3 -.Os -.Sh NAME -.Nm rpc_soc , -.Nm auth_destroy , -.Nm authnone_create , -.Nm authunix_create , -.Nm authunix_create_default , -.Nm callrpc , -.Nm clnt_broadcast , -.Nm clnt_call , -.Nm clnt_control , -.Nm clnt_create , -.Nm clnt_destroy , -.Nm clnt_freeres , -.Nm clnt_geterr , -.Nm clnt_pcreateerror , -.Nm clnt_perrno , -.Nm clnt_perror , -.Nm clnt_spcreateerror , -.Nm clnt_sperrno , -.Nm clnt_sperror , -.Nm clntraw_create , -.Nm clnttcp_create , -.Nm clntudp_bufcreate , -.Nm clntudp_create , -.Nm clntunix_create , -.Nm get_myaddress , -.Nm pmap_getmaps , -.Nm pmap_getport , -.Nm pmap_rmtcall , -.Nm pmap_set , -.Nm pmap_unset , -.Nm registerrpc , -.Nm rpc_createerr , -.Nm svc_destroy , -.Nm svc_fds , -.Nm svc_fdset , -.Nm svc_getargs , -.Nm svc_getcaller , -.Nm svc_getreq , -.Nm svc_getreqset , -.Nm svc_register , -.Nm svc_run , -.Nm svc_sendreply , -.Nm svc_unregister , -.Nm svcerr_auth , -.Nm svcerr_decode , -.Nm svcerr_noproc , -.Nm svcerr_noprog , -.Nm svcerr_progvers , -.Nm svcerr_systemerr , -.Nm svcerr_weakauth , -.Nm svcfd_create , -.Nm svcunixfd_create , -.Nm svcraw_create , -.Nm svcunix_create , -.Nm xdr_accepted_reply , -.Nm xdr_authunix_parms , -.Nm xdr_callhdr , -.Nm xdr_callmsg , -.Nm xdr_opaque_auth , -.Nm xdr_pmap , -.Nm xdr_pmaplist , -.Nm xdr_rejected_reply , -.Nm xdr_replymsg , -.Nm xprt_register , -.Nm xprt_unregister -.Nd "library routines for remote procedure calls" -.Sh SYNOPSIS -.In rpc/rpc.h -.Pp -See -.Sx DESCRIPTION -for function declarations. -.Sh DESCRIPTION -.Bf -symbolic -The -.Fn svc_* -and -.Fn clnt_* -functions described in this page are the old, TS-RPC -interface to the XDR and RPC library, and exist for backward compatibility. -The new interface is described in the pages -referenced from -.Xr rpc 3 . -.Ef -.Pp -These routines allow C programs to make procedure -calls on other machines across the network. -First, the client calls a procedure to send a -data packet to the server. -Upon receipt of the packet, the server calls a dispatch routine -to perform the requested service, and then sends back a -reply. -Finally, the procedure call returns to the client. -.Pp -Routines that are used for Secure -.Tn RPC ( DES -authentication) are described in -.Xr rpc_secure 3 . -Secure -.Tn RPC -can be used only if -.Tn DES -encryption is available. -.Bl -tag -width indent -compact -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn auth_destroy "AUTH *auth" -.Xc -.Pp -A macro that destroys the authentication information associated with -.Fa auth . -Destruction usually involves deallocation of private data -structures. -The use of -.Fa auth -is undefined after calling -.Fn auth_destroy . -.Pp -.It Xo -.Ft "AUTH *" -.Xc -.It Xo -.Fn authnone_create -.Xc -.Pp -Create and return an -.Tn RPC -authentication handle that passes nonusable authentication -information with each remote procedure call. -This is the -default authentication used by -.Tn RPC . -.Pp -.It Xo -.Ft "AUTH *" -.Xc -.It Xo -.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids" -.Xc -.Pp -Create and return an -.Tn RPC -authentication handle that contains -.Ux -authentication information. -The -.Fa host -argument -is the name of the machine on which the information was -created; -.Fa uid -is the user's user ID; -.Fa gid -is the user's current group ID; -.Fa len -and -.Fa aup_gids -refer to a counted array of groups to which the user belongs. -It is easy to impersonate a user. -.Pp -.It Xo -.Ft "AUTH *" -.Xc -.It Xo -.Fn authunix_create_default -.Xc -.Pp -Calls -.Fn authunix_create -with the appropriate arguments. -.Pp -.It Xo -.Ft int -.Fo callrpc -.Fa "char *host" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "u_long procnum" -.Fa "xdrproc_t inproc" -.Fa "void *in" -.Fa "xdrproc_t outproc" -.Fa "void *out" -.Fc -.Xc -.Pp -Call the remote procedure associated with -.Fa prognum , -.Fa versnum , -and -.Fa procnum -on the machine -.Fa host . -The -.Fa in -argument -is the address of the procedure's argument(s), and -.Fa out -is the address of where to place the result(s); -.Fa inproc -is used to encode the procedure's arguments, and -.Fa outproc -is used to decode the procedure's results. -This routine returns zero if it succeeds, or the value of -.Vt "enum clnt_stat" -cast to an integer if it fails. -The routine -.Fn clnt_perrno -is handy for translating failure statuses into messages. -.Pp -Warning: calling remote procedures with this routine -uses -.Tn UDP/IP -as a transport; see -.Fn clntudp_create -for restrictions. -You do not have control of timeouts or authentication using -this routine. -.Pp -.It Xo -.Ft "enum clnt_stat" -.Xc -.It Xo -.Fo clnt_broadcast -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "u_long procnum" -.Fa "xdrproc_t inproc" -.Fa "char *in" -.Fa "xdrproc_t outproc" -.Fa "char *out" -.Fa "bool_t (*eachresult)(caddr_t, struct sockaddr_in *)" -.Fc -.Xc -.Pp -Like -.Fn callrpc , -except the call message is broadcast to all locally -connected broadcast nets. -Each time it receives a -response, this routine calls -.Fn eachresult , -whose form is: -.Bd -ragged -offset indent -.Ft bool_t -.Fn eachresult "caddr_t out" "struct sockaddr_in *addr" -.Ed -.Pp -where -.Fa out -is the same as -.Fa out -passed to -.Fn clnt_broadcast , -except that the remote procedure's output is decoded there; -.Fa addr -points to the address of the machine that sent the results. -If -.Fn eachresult -returns zero, -.Fn clnt_broadcast -waits for more replies; otherwise it returns with appropriate -status. -.Pp -Warning: broadcast sockets are limited in size to the -maximum transfer unit of the data link. -For ethernet, -this value is 1500 bytes. -.Pp -.It Xo -.Ft "enum clnt_stat" -.Xc -.It Xo -.Fo clnt_call -.Fa "CLIENT *clnt" -.Fa "u_long procnum" -.Fa "xdrproc_t inproc" -.Fa "char *in" -.Fa "xdrproc_t outproc" -.Fa "char *out" -.Fa "struct timeval tout" -.Fc -.Xc -.Pp -A macro that calls the remote procedure -.Fa procnum -associated with the client handle, -.Fa clnt , -which is obtained with an -.Tn RPC -client creation routine such as -.Fn clnt_create . -The -.Fa in -argument -is the address of the procedure's argument(s), and -.Fa out -is the address of where to place the result(s); -.Fa inproc -is used to encode the procedure's arguments, and -.Fa outproc -is used to decode the procedure's results; -.Fa tout -is the time allowed for results to come back. -.Pp -.It Xo -.Ft void -.Fn clnt_destroy "CLIENT *clnt" -.Xc -.Pp -A macro that destroys the client's -.Tn RPC -handle. -Destruction usually involves deallocation -of private data structures, including -.Fa clnt -itself. -Use of -.Fa clnt -is undefined after calling -.Fn clnt_destroy . -If the -.Tn RPC -library opened the associated socket, it will close it also. -Otherwise, the socket remains open. -.Pp -.It Xo -.Ft CLIENT * -.Xc -.It Xo -.Fn clnt_create "char *host" "u_long prog" "u_long vers" "char *proto" -.Xc -.Pp -Generic client creation routine. -The -.Fa host -argument -identifies the name of the remote host where the server -is located. -The -.Fa proto -argument -indicates which kind of transport protocol to use. -The -currently supported values for this field are -.Qq Li udp -and -.Qq Li tcp . -Default timeouts are set, but can be modified using -.Fn clnt_control . -.Pp -Warning: Using -.Tn UDP -has its shortcomings. -Since -.Tn UDP Ns \-based -.Tn RPC -messages can only hold up to 8 Kbytes of encoded data, -this transport cannot be used for procedures that take -large arguments or return huge results. -.Pp -.It Xo -.Ft bool_t -.Xc -.It Xo -.Fn clnt_control "CLIENT *cl" "u_int req" "char *info" -.Xc -.Pp -A macro used to change or retrieve various information -about a client object. -The -.Fa req -argument -indicates the type of operation, and -.Fa info -is a pointer to the information. -For both -.Tn UDP -and -.Tn TCP , -the supported values of -.Fa req -and their argument types and what they do are: -.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" -.It Dv CLSET_TIMEOUT Ta Xo -.Vt "struct timeval" Ta "set total timeout" -.Xc -.It Dv CLGET_TIMEOUT Ta Xo -.Vt "struct timeval" Ta "get total timeout" -.Xc -.El -.Pp -Note: if you set the timeout using -.Fn clnt_control , -the timeout argument passed to -.Fn clnt_call -will be ignored in all future calls. -.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" -.It Dv CLGET_SERVER_ADDR Ta Xo -.Vt "struct sockaddr_in" Ta "get server's address" -.Xc -.El -.Pp -The following operations are valid for -.Tn UDP -only: -.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" -.It Dv CLSET_RETRY_TIMEOUT Ta Xo -.Vt "struct timeval" Ta "set the retry timeout" -.Xc -.It Dv CLGET_RETRY_TIMEOUT Ta Xo -.Vt "struct timeval" Ta "get the retry timeout" -.Xc -.El -.Pp -The retry timeout is the time that -.Tn "UDP RPC" -waits for the server to reply before -retransmitting the request. -.Pp -.It Xo -.Ft bool_t -.Fn clnt_freeres "CLIENT *clnt" "xdrproc_t outproc" "char *out" -.Xc -.Pp -A macro that frees any data allocated by the -.Tn RPC/XDR -system when it decoded the results of an -.Tn RPC -call. -The -.Fa out -argument -is the address of the results, and -.Fa outproc -is the -.Tn XDR -routine describing the results. -This routine returns one if the results were successfully -freed, -and zero otherwise. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn clnt_geterr "CLIENT *clnt" "struct rpc_err *errp" -.Xc -.Pp -A macro that copies the error structure out of the client -handle -to the structure at address -.Fa errp . -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn clnt_pcreateerror "char *s" -.Xc -.Pp -prints a message to standard error indicating -why a client -.Tn RPC -handle could not be created. -The message is prepended with string -.Fa s -and a colon. -A newline is appended at the end of the message. -Used when a -.Fn clnt_create , -.Fn clntraw_create , -.Fn clnttcp_create , -or -.Fn clntudp_create -call fails. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn clnt_perrno "enum clnt_stat stat" -.Xc -.Pp -Print a message to standard error corresponding -to the condition indicated by -.Fa stat . -A newline is appended at the end of the message. -Used after -.Fn callrpc . -.Pp -.It Xo -.Ft void -.Fn clnt_perror "CLIENT *clnt" "char *s" -.Xc -.Pp -Print a message to standard error indicating why an -.Tn RPC -call failed; -.Fa clnt -is the handle used to do the call. -The message is prepended with string -.Fa s -and a colon. -A newline is appended at the end of the message. -Used after -.Fn clnt_call . -.Pp -.It Xo -.Ft "char *" -.Xc -.It Xo -.Fn clnt_spcreateerror "char *s" -.Xc -.Pp -Like -.Fn clnt_pcreateerror , -except that it returns a string -instead of printing to the standard error. -.Pp -Bugs: returns pointer to static data that is overwritten -on each call. -.Pp -.It Xo -.Ft "char *" -.Xc -.It Xo -.Fn clnt_sperrno "enum clnt_stat stat" -.Xc -.Pp -Take the same arguments as -.Fn clnt_perrno , -but instead of sending a message to the standard error -indicating why an -.Tn RPC -call failed, return a pointer to a string which contains -the message. -.Pp -The -.Fn clnt_sperrno -function -is used instead of -.Fn clnt_perrno -if the program does not have a standard error (as a program -running as a server quite likely does not), or if the -programmer -does not want the message to be output with -.Fn printf , -or if a message format different from that supported by -.Fn clnt_perrno -is to be used. -.Pp -Note: unlike -.Fn clnt_sperror -and -.Fn clnt_spcreateerror , -.Fn clnt_sperrno -returns pointer to static data, but the -result will not get overwritten on each call. -.Pp -.It Xo -.Ft "char *" -.Xc -.It Xo -.Fn clnt_sperror "CLIENT *rpch" "char *s" -.Xc -.Pp -Like -.Fn clnt_perror , -except that (like -.Fn clnt_sperrno ) -it returns a string instead of printing to standard error. -.Pp -Bugs: returns pointer to static data that is overwritten -on each call. -.Pp -.It Xo -.Ft "CLIENT *" -.Xc -.It Xo -.Fn clntraw_create "u_long prognum" "u_long versnum" -.Xc -.Pp -This routine creates a toy -.Tn RPC -client for the remote program -.Fa prognum , -version -.Fa versnum . -The transport used to pass messages to the service is -actually a buffer within the process's address space, so the -corresponding -.Tn RPC -server should live in the same address space; see -.Fn svcraw_create . -This allows simulation of -.Tn RPC -and acquisition of -.Tn RPC -overheads, such as round trip times, without any -kernel interference. -This routine returns -.Dv NULL -if it fails. -.Pp -.It Xo -.Ft "CLIENT *" -.Xc -.It Xo -.Fo clnttcp_create -.Fa "struct sockaddr_in *addr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "int *sockp" -.Fa "u_int sendsz" -.Fa "u_int recvsz" -.Fc -.Xc -.Pp -This routine creates an -.Tn RPC -client for the remote program -.Fa prognum , -version -.Fa versnum ; -the client uses -.Tn TCP/IP -as a transport. -The remote program is located at Internet -address -.Fa addr . -If -.Fa addr\->sin_port -is zero, then it is set to the actual port that the remote -program is listening on (the remote -.Xr rpcbind 8 -service is consulted for this information). -The -.Fa sockp -argument -is a socket; if it is -.Dv RPC_ANYSOCK , -then this routine opens a new one and sets -.Fa sockp . -Since -.Tn TCP Ns \-based -.Tn RPC -uses buffered -.Tn I/O , -the user may specify the size of the send and receive buffers -with the -.Fa sendsz -and -.Fa recvsz -arguments; -values of zero choose suitable defaults. -This routine returns -.Dv NULL -if it fails. -.Pp -.It Xo -.Ft "CLIENT *" -.Xc -.It Xo -.Fo clntudp_create -.Fa "struct sockaddr_in *addr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "struct timeval wait" -.Fa "int *sockp" -.Fc -.Xc -.Pp -This routine creates an -.Tn RPC -client for the remote program -.Fa prognum , -version -.Fa versnum ; -the client uses -.Tn UDP/IP -as a transport. -The remote program is located at Internet -address -.Fa addr . -If -.Fa addr\->sin_port -is zero, then it is set to actual port that the remote -program is listening on (the remote -.Xr rpcbind 8 -service is consulted for this information). -The -.Fa sockp -argument -is a socket; if it is -.Dv RPC_ANYSOCK , -then this routine opens a new one and sets -.Fa sockp . -The -.Tn UDP -transport resends the call message in intervals of -.Fa wait -time until a response is received or until the call times -out. -The total time for the call to time out is specified by -.Fn clnt_call . -.Pp -Warning: since -.Tn UDP Ns \-based -.Tn RPC -messages can only hold up to 8 Kbytes -of encoded data, this transport cannot be used for procedures -that take large arguments or return huge results. -.Pp -.It Xo -.Ft "CLIENT *" -.Xc -.It Xo -.Fo clntudp_bufcreate -.Fa "struct sockaddr_in *addr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "struct timeval wait" -.Fa "int *sockp" -.Fa "unsigned int sendsize" -.Fa "unsigned int recosize" -.Fc -.Xc -.Pp -This routine creates an -.Tn RPC -client for the remote program -.Fa prognum , -on -.Fa versnum ; -the client uses -.Tn UDP/IP -as a transport. -The remote program is located at Internet -address -.Fa addr . -If -.Fa addr\->sin_port -is zero, then it is set to actual port that the remote -program is listening on (the remote -.Xr rpcbind 8 -service is consulted for this information). -The -.Fa sockp -argument -is a socket; if it is -.Dv RPC_ANYSOCK , -then this routine opens a new one and sets -.Fa sockp . -The -.Tn UDP -transport resends the call message in intervals of -.Fa wait -time until a response is received or until the call times -out. -The total time for the call to time out is specified by -.Fn clnt_call . -.Pp -This allows the user to specify the maximum packet size -for sending and receiving -.Tn UDP Ns \-based -.Tn RPC -messages. -.Pp -.It Xo -.Ft "CLIENT *" -.Xc -.It Xo -.Fo clntunix_create -.Fa "struct sockaddr_un *raddr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "int *sockp" -.Fa "u_int sendsz" -.Fa "u_int recvsz" -.Fc -.Xc -.Pp -This routine creates an -.Tn RPC -client for the local -program -.Fa prognum , -version -.Fa versnum ; -the client uses -.Ux Ns -domain -sockets as a transport. -The local program is located at the -.Fa *raddr . -The -.Fa sockp -argument -is a socket; if it is -.Dv RPC_ANYSOCK , -then this routine opens a new one and sets -.Fa sockp . -Since -.Ux Ns -based -.Tn RPC -uses buffered -.Tn I/O , -the user may specify the size of the send and receive buffers -with the -.Fa sendsz -and -.Fa recvsz -arguments; -values of zero choose suitable defaults. -This routine returns -.Dv NULL -if it fails. -.Pp -.It Xo -.Ft int -.Xc -.It Xo -.Fn get_myaddress "struct sockaddr_in *addr" -.Xc -.Pp -Stuff the machine's -.Tn IP -address into -.Fa addr , -without consulting the library routines that deal with -.Pa /etc/hosts . -The port number is always set to -.Fn htons PMAPPORT . -Returns zero on success, non-zero on failure. -.Pp -.It Xo -.Ft "struct pmaplist *" -.Xc -.It Xo -.Fn pmap_getmaps "struct sockaddr_in *addr" -.Xc -.Pp -A user interface to the -.Xr rpcbind 8 -service, which returns a list of the current -.Tn RPC -program\-to\-port mappings -on the host located at -.Tn IP -address -.Fa addr . -This routine can return -.Dv NULL . -The command -.Dq Nm rpcinfo Fl p -uses this routine. -.Pp -.It Xo -.Ft u_short -.Xc -.It Xo -.Fo pmap_getport -.Fa "struct sockaddr_in *addr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "u_long protocol" -.Fc -.Xc -.Pp -A user interface to the -.Xr rpcbind 8 -service, which returns the port number -on which waits a service that supports program number -.Fa prognum , -version -.Fa versnum , -and speaks the transport protocol associated with -.Fa protocol . -The value of -.Fa protocol -is most likely -.Dv IPPROTO_UDP -or -.Dv IPPROTO_TCP . -A return value of zero means that the mapping does not exist -or that -the -.Tn RPC -system failed to contact the remote -.Xr rpcbind 8 -service. -In the latter case, the global variable -.Va rpc_createerr -contains the -.Tn RPC -status. -.Pp -.It Xo -.Ft "enum clnt_stat" -.Xc -.It Xo -.Fo pmap_rmtcall -.Fa "struct sockaddr_in *addr" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "u_long procnum" -.Fa "xdrproc_t inproc" -.Fa "char *in" -.Fa "xdrproc_t outproc" -.Fa "char *out" -.Fa "struct timeval tout" -.Fa "u_long *portp" -.Fc -.Xc -.Pp -A user interface to the -.Xr rpcbind 8 -service, which instructs -.Xr rpcbind 8 -on the host at -.Tn IP -address -.Fa addr -to make an -.Tn RPC -call on your behalf to a procedure on that host. -The -.Fa portp -argument -will be modified to the program's port number if the -procedure -succeeds. -The definitions of other arguments are discussed -in -.Fn callrpc -and -.Fn clnt_call . -This procedure should be used for a -.Dq ping -and nothing -else. -See also -.Fn clnt_broadcast . -.Pp -.It Xo -.Ft bool_t -.Fn pmap_set "u_long prognum" "u_long versnum" "u_long protocol" "u_short port" -.Xc -.Pp -A user interface to the -.Xr rpcbind 8 -service, which establishes a mapping between the triple -.Pq Fa prognum , versnum , protocol -and -.Fa port -on the machine's -.Xr rpcbind 8 -service. -The value of -.Fa protocol -is most likely -.Dv IPPROTO_UDP -or -.Dv IPPROTO_TCP . -This routine returns one if it succeeds, zero otherwise. -Automatically done by -.Fn svc_register . -.Pp -.It Xo -.Ft bool_t -.Fn pmap_unset "u_long prognum" "u_long versnum" -.Xc -.Pp -A user interface to the -.Xr rpcbind 8 -service, which destroys all mapping between the triple -.Pq Fa prognum , versnum , * -and -.Fa ports -on the machine's -.Xr rpcbind 8 -service. -This routine returns one if it succeeds, zero -otherwise. -.Pp -.It Xo -.Ft bool_t -.Fo registerrpc -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "u_long procnum" -.Fa "char *(*procname)(void)" -.Fa "xdrproc_t inproc" -.Fa "xdrproc_t outproc" -.Fc -.Xc -.Pp -Register procedure -.Fa procname -with the -.Tn RPC -service package. -If a request arrives for program -.Fa prognum , -version -.Fa versnum , -and procedure -.Fa procnum , -.Fa procname -is called with a pointer to its argument(s); -.Fa progname -should return a pointer to its static result(s); -.Fa inproc -is used to decode the arguments while -.Fa outproc -is used to encode the results. -This routine returns zero if the registration succeeded, \-1 -otherwise. -.Pp -Warning: remote procedures registered in this form -are accessed using the -.Tn UDP/IP -transport; see -.Fn svcudp_create -for restrictions. -.Pp -.It Xo -.Vt "struct rpc_createerr" rpc_createerr ; -.Xc -.Pp -A global variable whose value is set by any -.Tn RPC -client creation routine -that does not succeed. -Use the routine -.Fn clnt_pcreateerror -to print the reason why. -.Pp -.It Xo -.Ft bool_t -.Fn svc_destroy "SVCXPRT * xprt" -.Xc -.Pp -A macro that destroys the -.Tn RPC -service transport handle, -.Fa xprt . -Destruction usually involves deallocation -of private data structures, including -.Fa xprt -itself. -Use of -.Fa xprt -is undefined after calling this routine. -.Pp -.It Xo -.Vt fd_set svc_fdset ; -.Xc -.Pp -A global variable reflecting the -.Tn RPC -service side's -read file descriptor bit mask; it is suitable as a template argument -to the -.Xr select 2 -system call. -This is only of interest -if a service implementor does not call -.Fn svc_run , -but rather does his own asynchronous event processing. -This variable is read\-only (do not pass its address to -.Xr select 2 ! ) , -yet it may change after calls to -.Fn svc_getreqset -or any creation routines. -As well, note that if the process has descriptor limits -which are extended beyond -.Dv FD_SETSIZE , -this variable will only be usable for the first -.Dv FD_SETSIZE -descriptors. -.Pp -.It Xo -.Vt int svc_fds ; -.Xc -.Pp -Similar to -.Va svc_fdset , -but limited to 32 descriptors. -This -interface is obsoleted by -.Va svc_fdset . -.Pp -.It Xo -.Ft bool_t -.Fn svc_freeargs "SVCXPRT *xprt" "xdrproc_t inproc" "char *in" -.Xc -.Pp -A macro that frees any data allocated by the -.Tn RPC/XDR -system when it decoded the arguments to a service procedure -using -.Fn svc_getargs . -This routine returns 1 if the results were successfully -freed, -and zero otherwise. -.Pp -.It Xo -.Ft bool_t -.Fn svc_getargs "SVCXPRT *xprt" "xdrproc_t inproc" "char *in" -.Xc -.Pp -A macro that decodes the arguments of an -.Tn RPC -request -associated with the -.Tn RPC -service transport handle, -.Fa xprt . -The -.Fa in -argument -is the address where the arguments will be placed; -.Fa inproc -is the -.Tn XDR -routine used to decode the arguments. -This routine returns one if decoding succeeds, and zero -otherwise. -.Pp -.It Xo -.Ft "struct sockaddr_in *" -.Xc -.It Xo -.Fn svc_getcaller "SVCXPRT *xprt" -.Xc -.Pp -The approved way of getting the network address of the caller -of a procedure associated with the -.Tn RPC -service transport handle, -.Fa xprt . -.Pp -.It Xo -.Ft void -.Fn svc_getreqset "fd_set *rdfds" -.Xc -.Pp -This routine is only of interest if a service implementor -does not call -.Fn svc_run , -but instead implements custom asynchronous event processing. -It is called when the -.Xr select 2 -system call has determined that an -.Tn RPC -request has arrived on some -.Tn RPC -socket(s); -.Fa rdfds -is the resultant read file descriptor bit mask. -The routine returns when all sockets associated with the -value of -.Fa rdfds -have been serviced. -.Pp -.It Xo -.Ft void -.Fn svc_getreq "int rdfds" -.Xc -.Pp -Similar to -.Fn svc_getreqset , -but limited to 32 descriptors. -This interface is obsoleted by -.Fn svc_getreqset . -.Pp -.It Xo -.Ft bool_t -.Fo svc_register -.Fa "SVCXPRT *xprt" -.Fa "u_long prognum" -.Fa "u_long versnum" -.Fa "void (*dispatch)(struct svc_req *, SVCXPRT *)" -.Fa "int protocol" -.Fc -.Xc -.Pp -Associates -.Fa prognum -and -.Fa versnum -with the service dispatch procedure, -.Fn dispatch . -If -.Fa protocol -is zero, the service is not registered with the -.Xr rpcbind 8 -service. -If -.Fa protocol -is non-zero, then a mapping of the triple -.Pq Fa prognum , versnum , protocol -to -.Fa xprt\->xp_port -is established with the local -.Xr rpcbind 8 -service (generally -.Fa protocol -is zero, -.Dv IPPROTO_UDP -or -.Dv IPPROTO_TCP ) . -The procedure -.Fn dispatch -has the following form: -.Bd -ragged -offset indent -.Ft bool_t -.Fn dispatch "struct svc_req *request" "SVCXPRT *xprt" -.Ed -.Pp -The -.Fn svc_register -routine returns one if it succeeds, and zero otherwise. -.Pp -.It Xo -.Fn svc_run -.Xc -.Pp -This routine never returns. -It waits for -.Tn RPC -requests to arrive, and calls the appropriate service -procedure using -.Fn svc_getreq -when one arrives. -This procedure is usually waiting for a -.Xr select 2 -system call to return. -.Pp -.It Xo -.Ft bool_t -.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "char *out" -.Xc -.Pp -Called by an -.Tn RPC -service's dispatch routine to send the results of a -remote procedure call. -The -.Fa xprt -argument -is the request's associated transport handle; -.Fa outproc -is the -.Tn XDR -routine which is used to encode the results; and -.Fa out -is the address of the results. -This routine returns one if it succeeds, zero otherwise. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svc_unregister "u_long prognum" "u_long versnum" -.Xc -.Pp -Remove all mapping of the double -.Pq Fa prognum , versnum -to dispatch routines, and of the triple -.Pq Fa prognum , versnum , * -to port number. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_auth "SVCXPRT *xprt" "enum auth_stat why" -.Xc -.Pp -Called by a service dispatch routine that refuses to perform -a remote procedure call due to an authentication error. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_decode "SVCXPRT *xprt" -.Xc -.Pp -Called by a service dispatch routine that cannot successfully -decode its arguments. -See also -.Fn svc_getargs . -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_noproc "SVCXPRT *xprt" -.Xc -.Pp -Called by a service dispatch routine that does not implement -the procedure number that the caller requests. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_noprog "SVCXPRT *xprt" -.Xc -.Pp -Called when the desired program is not registered with the -.Tn RPC -package. -Service implementors usually do not need this routine. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_progvers "SVCXPRT *xprt" "u_long low_vers" "u_long high_vers" -.Xc -.Pp -Called when the desired version of a program is not registered -with the -.Tn RPC -package. -Service implementors usually do not need this routine. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_systemerr "SVCXPRT *xprt" -.Xc -.Pp -Called by a service dispatch routine when it detects a system -error -not covered by any particular protocol. -For example, if a service can no longer allocate storage, -it may call this routine. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn svcerr_weakauth "SVCXPRT *xprt" -.Xc -.Pp -Called by a service dispatch routine that refuses to perform -a remote procedure call due to insufficient -authentication arguments. -The routine calls -.Fn svcerr_auth xprt AUTH_TOOWEAK . -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svcraw_create void -.Xc -.Pp -This routine creates a toy -.Tn RPC -service transport, to which it returns a pointer. -The transport -is really a buffer within the process's address space, -so the corresponding -.Tn RPC -client should live in the same -address space; -see -.Fn clntraw_create . -This routine allows simulation of -.Tn RPC -and acquisition of -.Tn RPC -overheads (such as round trip times), without any kernel -interference. -This routine returns -.Dv NULL -if it fails. -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svctcp_create "int sock" "u_int send_buf_size" "u_int recv_buf_size" -.Xc -.Pp -This routine creates a -.Tn TCP/IP Ns \-based -.Tn RPC -service transport, to which it returns a pointer. -The transport is associated with the socket -.Fa sock , -which may be -.Dv RPC_ANYSOCK , -in which case a new socket is created. -If the socket is not bound to a local -.Tn TCP -port, then this routine binds it to an arbitrary port. -Upon completion, -.Fa xprt\->xp_fd -is the transport's socket descriptor, and -.Fa xprt\->xp_port -is the transport's port number. -This routine returns -.Dv NULL -if it fails. -Since -.Tn TCP Ns \-based -.Tn RPC -uses buffered -.Tn I/O , -users may specify the size of buffers; values of zero -choose suitable defaults. -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svcunix_create "int sock" "u_int send_buf_size" "u_int recv_buf_size" "char *path" -.Xc -.Pp -This routine creates a -.Ux Ns -based -.Tn RPC -service transport, to which it returns a pointer. -The transport is associated with the socket -.Fa sock , -which may be -.Dv RPC_ANYSOCK , -in which case a new socket is created. -The -.Fa *path -argument -is a variable-length file system pathname of -at most 104 characters. -This file is -.Em not -removed when the socket is closed. -The -.Xr unlink 2 -system call must be used to remove the file. -Upon completion, -.Fa xprt\->xp_fd -is the transport's socket descriptor. -This routine returns -.Dv NULL -if it fails. -Since -.Ux Ns -based -.Tn RPC -uses buffered -.Tn I/O , -users may specify the size of buffers; values of zero -choose suitable defaults. -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svcunixfd_create "int fd" "u_int sendsize" "u_int recvsize" -.Xc -.Pp -Create a service on top of any open descriptor. -The -.Fa sendsize -and -.Fa recvsize -arguments -indicate sizes for the send and receive buffers. -If they are -zero, a reasonable default is chosen. -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svcfd_create "int fd" "u_int sendsize" "u_int recvsize" -.Xc -.Pp -Create a service on top of any open descriptor. -Typically, -this -descriptor is a connected socket for a stream protocol such -as -.Tn TCP . -The -.Fa sendsize -and -.Fa recvsize -arguments -indicate sizes for the send and receive buffers. -If they are -zero, a reasonable default is chosen. -.Pp -.It Xo -.Ft "SVCXPRT *" -.Xc -.It Xo -.Fn svcudp_bufcreate "int sock" "u_int sendsize" "u_int recvsize" -.Xc -.Pp -This routine creates a -.Tn UDP/IP Ns \-based -.Tn RPC -service transport, to which it returns a pointer. -The transport is associated with the socket -.Fa sock , -which may be -.Dv RPC_ANYSOCK , -in which case a new socket is created. -If the socket is not bound to a local -.Tn UDP -port, then this routine binds it to an arbitrary port. -Upon -completion, -.Fa xprt\->xp_fd -is the transport's socket descriptor, and -.Fa xprt\->xp_port -is the transport's port number. -This routine returns -.Dv NULL -if it fails. -.Pp -This allows the user to specify the maximum packet size for sending and -receiving -.Tn UDP Ns \-based -.Tn RPC -messages. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_accepted_reply "XDR *xdrs" "struct accepted_reply *ar" -.Xc -.Pp -Used for encoding -.Tn RPC -reply messages. -This routine is useful for users who -wish to generate -.Tn RPC Ns \-style -messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_authunix_parms "XDR *xdrs" "struct authunix_parms *aupp" -.Xc -.Pp -Used for describing -.Ux -credentials. -This routine is useful for users -who wish to generate these credentials without using the -.Tn RPC -authentication package. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Ft bool_t -.Fn xdr_callhdr "XDR *xdrs" "struct rpc_msg *chdr" -.Xc -.Pp -Used for describing -.Tn RPC -call header messages. -This routine is useful for users who wish to generate -.Tn RPC Ns \-style -messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_callmsg "XDR *xdrs" "struct rpc_msg *cmsg" -.Xc -.Pp -Used for describing -.Tn RPC -call messages. -This routine is useful for users who wish to generate -.Tn RPC Ns \-style -messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_opaque_auth "XDR *xdrs" "struct opaque_auth *ap" -.Xc -.Pp -Used for describing -.Tn RPC -authentication information messages. -This routine is useful for users who wish to generate -.Tn RPC Ns \-style -messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Vt struct pmap ; -.Xc -.It Xo -.Ft bool_t -.Fn xdr_pmap "XDR *xdrs" "struct pmap *regs" -.Xc -.Pp -Used for describing arguments to various -.Xr rpcbind 8 -procedures, externally. -This routine is useful for users who wish to generate -these arguments without using the -.Fn pmap_* -interface. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_pmaplist "XDR *xdrs" "struct pmaplist **rp" -.Xc -.Pp -Used for describing a list of port mappings, externally. -This routine is useful for users who wish to generate -these arguments without using the -.Fn pmap_* -interface. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_rejected_reply "XDR *xdrs" "struct rejected_reply *rr" -.Xc -.Pp -Used for describing -.Tn RPC -reply messages. -This routine is useful for users who wish to generate -.Tn RPC Ns \-style -messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Ft bool_t -.Fn xdr_replymsg "XDR *xdrs" "struct rpc_msg *rmsg" -.Xc -.Pp -Used for describing -.Tn RPC -reply messages. -This routine is useful for users who wish to generate -.Tn RPC -style messages without using the -.Tn RPC -package. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn xprt_register "SVCXPRT *xprt" -.Xc -.Pp -After -.Tn RPC -service transport handles are created, -they should register themselves with the -.Tn RPC -service package. -This routine modifies the global variable -.Va svc_fds . -Service implementors usually do not need this routine. -.Pp -.It Xo -.Ft void -.Xc -.It Xo -.Fn xprt_unregister "SVCXPRT *xprt" -.Xc -.Pp -Before an -.Tn RPC -service transport handle is destroyed, -it should unregister itself with the -.Tn RPC -service package. -This routine modifies the global variable -.Va svc_fds . -Service implementors usually do not need this routine. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc_secure 3 , -.Xr xdr 3 -.Rs -.%T "Remote Procedure Calls: Protocol Specification" -.Re -.Rs -.%T "Remote Procedure Call Programming Guide" -.Re -.Rs -.%T "rpcgen Programming Guide" -.Re -.Rs -.%T "RPC: Remote Procedure Call Protocol Specification" -.%O RFC1050 -.%Q "Sun Microsystems, Inc., USC-ISI" -.Re diff --git a/libtirpc-1.3.1/man/rpc_svc_calls.3t b/libtirpc-1.3.1/man/rpc_svc_calls.3t deleted file mode 100644 index 4b3c08b..0000000 --- a/libtirpc-1.3.1/man/rpc_svc_calls.3t +++ /dev/null @@ -1,267 +0,0 @@ -.\" @(#)rpc_svc_calls.3n 1.28 93/05/10 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_svc_calls 1.5 89/07/25 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_svc_calls.3,v 1.1 2000/06/02 23:11:13 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_calls.3,v 1.8 2003/09/08 19:57:15 ru Exp $ -.Dd May 3, 1993 -.Dt RPC_SVC_CALLS 3 -.Os -.Sh NAME -.Nm svc_dg_enablecache , -.Nm svc_exit , -.Nm svc_fdset , -.Nm svc_freeargs , -.Nm svc_getargs , -.Nm svc_getreq_common , -.Nm svc_getreq_poll , -.Nm svc_getreqset , -.Nm svc_getrpccaller , -.Nm svc_pollset , -.Nm svc_run , -.Nm svc_sendreply -.Nd library routines for RPC servers -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft int -.Fn svc_dg_enablecache "SVCXPRT *xprt" "const unsigned cache_size" -.Ft void -.Fn svc_exit "void" -.Ft bool_t -.Fn svc_freeargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in" -.Ft bool_t -.Fn svc_getargs "const SVCXPRT *xprt" "const xdrproc_t inproc" "caddr_t in" -.Ft void -.Fn svc_getreq_common "const int fd" -.Ft void -.Fn svc_getreq_poll "struct pollfd *pfdp" "const int pollretval" -.Ft void -.Fn svc_getreqset "fd_set * rdfds" -.Ft "struct netbuf *" -.Fn svc_getrpccaller "const SVCXPRT *xprt" -.Ft "struct cmsgcred *" -.Fn __svc_getcallercreds "const SVCXPRT *xprt" -.Vt struct pollfd svc_pollset[FD_SETSIZE]; -.Ft void -.Fn svc_run "void" -.Ft bool_t -.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "char *out" -.Sh DESCRIPTION -These routines are part of the -RPC -library which allows C language programs to make procedure -calls on other machines across the network. -.Pp -These routines are associated with the server side of the -RPC mechanism. -Some of them are called by the server side dispatch function, -while others -(such as -.Fn svc_run ) -are called when the server is initiated. -.\" .Pp -.\" In the current implementation, the service transport handle, -.\" .Dv SVCXPRT , -.\" contains a single data area for decoding arguments and encoding results. -.\" Therefore, this structure cannot be freely shared between threads that call -.\" functions that do this. -.\" Routines on this page that are affected by this -.\" restriction are marked as unsafe for MT applications. -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt SVCXPRT -data structure. -.Bl -tag -width __svc_getcallercreds() -.It Fn svc_dg_enablecache -This function allocates a duplicate request cache for the -service endpoint -.Fa xprt , -large enough to hold -.Fa cache_size -entries. -Once enabled, there is no way to disable caching. -This routine returns 0 if space necessary for a cache of the given size -was successfully allocated, and 1 otherwise. -.It Fn svc_exit -This function, when called by any of the RPC server procedure or -otherwise, causes -.Fn svc_run -to return. -.Pp -As currently implemented, -.Fn svc_exit -zeroes the -.Va svc_fdset -global variable. -If RPC server activity is to be resumed, -services must be reregistered with the RPC library -either through one of the -.Xr rpc_svc_create 3 -functions, or using -.Fn xprt_register . -The -.Fn svc_exit -function -has global scope and ends all RPC server activity. -.It Xo -.Vt fd_set Va svc_fdset -.Xc -A global variable reflecting the -RPC server's read file descriptor bit mask; it is suitable as an argument -to the -.Xr select 2 -system call. -This is only of interest -if service implementors do not call -.Fn svc_run , -but rather do their own asynchronous event processing. -This variable is read-only (do not pass its address to -.Xr select 2 ! ) , -yet it may change after calls to -.Fn svc_getreqset -or any creation routines. -.It Fn svc_freeargs -A function macro that frees any data allocated by the -RPC/XDR system when it decoded the arguments to a service procedure -using -.Fn svc_getargs . -This routine returns -.Dv TRUE -if the results were successfully -freed, and -.Dv FALSE -otherwise. -.It Fn svc_getargs -A function macro that decodes the arguments of an -RPC request associated with the RPC -service transport handle -.Fa xprt . -The -.Fa in -argument -is the address where the arguments will be placed; -.Fa inproc -is the XDR -routine used to decode the arguments. -This routine returns -.Dv TRUE -if decoding succeeds, and -.Dv FALSE -otherwise. -.It Fn svc_getreq_common -This routine is called to handle a request on the given -file descriptor. -.It Fn svc_getreq_poll -This routine is only of interest if a service implementor -does not call -.Fn svc_run , -but instead implements custom asynchronous event processing. -It is called when -.Xr poll 2 -has determined that an RPC request has arrived on some RPC -file descriptors; -.Fa pollretval -is the return value from -.Xr poll 2 -and -.Fa pfdp -is the array of -.Vt pollfd -structures on which the -.Xr poll 2 -was done. -It is assumed to be an array large enough to -contain the maximal number of descriptors allowed. -.It Fn svc_getreqset -This routine is only of interest if a service implementor -does not call -.Fn svc_run , -but instead implements custom asynchronous event processing. -It is called when -.Xr poll 2 -has determined that an RPC -request has arrived on some RPC file descriptors; -.Fa rdfds -is the resultant read file descriptor bit mask. -The routine returns when all file descriptors -associated with the value of -.Fa rdfds -have been serviced. -.It Fn svc_getrpccaller -The approved way of getting the network address of the caller -of a procedure associated with the -RPC service transport handle -.Fa xprt . -.It Fn __svc_getcallercreds -.Em Warning : -this macro is specific to -.Fx -and thus not portable. -This macro returns a pointer to a -.Vt cmsgcred -structure, defined in -.In sys/socket.h , -identifying the calling client. -This only works if the client is -calling the server over an -.Dv AF_LOCAL -socket. -.It Xo -.Vt struct pollfd Va svc_pollset[FD_SETSIZE] ; -.Xc -.Va svc_pollset -is an array of -.Vt pollfd -structures derived from -.Va svc_fdset[] . -It is suitable as an argument to the -.Xr poll 2 -system call. -The derivation of -.Va svc_pollset -from -.Va svc_fdset -is made in the current implementation in -.Fn svc_run . -Service implementors who do not call -.Fn svc_run -and who wish to use this array must perform this derivation themselves. -.It Fn svc_run -This routine never returns. -It waits for RPC -requests to arrive, and calls the appropriate service -procedure using -.Fn svc_getreq_poll -when one arrives. -This procedure is usually waiting for the -.Xr poll 2 -system call to return. -.It Fn svc_sendreply -Called by an RPC service's dispatch routine to send the results of a -remote procedure call. -The -.Fa xprt -argument -is the request's associated transport handle; -.Fa outproc -is the XDR -routine which is used to encode the results; and -.Fa out -is the address of the results. -This routine returns -.Dv TRUE -if it succeeds, -.Dv FALSE -otherwise. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr poll 2 , -.Xr select 2 , -.Xr rpc 3 , -.Xr rpc_svc_create 3 , -.Xr rpc_svc_err 3 , -.Xr rpc_svc_reg 3 diff --git a/libtirpc-1.3.1/man/rpc_svc_create.3t b/libtirpc-1.3.1/man/rpc_svc_create.3t deleted file mode 100644 index 6e28d2e..0000000 --- a/libtirpc-1.3.1/man/rpc_svc_create.3t +++ /dev/null @@ -1,337 +0,0 @@ -.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_svc_create 1.3 89/06/28 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_create.3,v 1.7 2003/09/08 19:57:15 ru Exp $ -.Dd May 3, 1993 -.Dt RPC_SVC_CREATE 3 -.Os -.Sh NAME -.Nm rpc_svc_create , -.Nm svc_control , -.Nm svc_create , -.Nm svc_destroy , -.Nm svc_dg_create , -.Nm svc_fd_create , -.Nm svc_raw_create , -.Nm svc_tli_create , -.Nm svc_tp_create , -.Nm svc_vc_create -.Nd library routines for the creation of server handles -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft bool_t -.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info" -.Ft int -.Fn svc_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" -.Ft SVCXPRT * -.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz" -.Ft void -.Fn svc_destroy "SVCXPRT *xprt" -.Ft "SVCXPRT *" -.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz" -.Ft "SVCXPRT *" -.Fn svc_raw_create "void" -.Ft "SVCXPRT *" -.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz" -.Ft "SVCXPRT *" -.Fn svc_tp_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" -.Ft "SVCXPRT *" -.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz" -.Sh DESCRIPTION -These routines are part of the RPC -library which allows C language programs to make procedure -calls on servers across the network. -These routines deal with the creation of service handles. -Once the handle is created, the server can be invoked by calling -.Fn svc_run . -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt SVCXPRT -data structure. -.Bl -tag -width XXXXX -.It Fn svc_control -A function to change or retrieve various information -about a service object. -The -.Fa req -argument -indicates the type of operation and -.Fa info -is a pointer to the information. -The supported values of -.Fa req , -their argument types, and what they do are: -.Bl -tag -width SVCGET_XID -.It Dv SVCGET_VERSQUIET -If a request is received for a program number -served by this server but the version number -is outside the range registered with the server, -an -.Dv RPC_PROGVERSMISMATCH -error will normally -be returned. -The -.Fa info -argument -should be a pointer to an -integer. -Upon successful completion of the -.Dv SVCGET_VERSQUIET -request, -.Fa *info -contains an -integer which describes the server's current -behavior: 0 indicates normal server behavior -(that is, an -.Dv RPC_PROGVERSMISMATCH -error -will be returned); 1 indicates that the out of -range request will be silently ignored. -.It Dv SVCSET_VERSQUIET -If a request is received for a program number -served by this server but the version number -is outside the range registered with the server, -an -.Dv RPC_PROGVERSMISMATCH -error will normally -be returned. -It is sometimes desirable to -change this behavior. -The -.Fa info -argument -should be a -pointer to an integer which is either 0 -(indicating normal server behavior - an -.Dv RPC_PROGVERSMISMATCH -error will be returned), -or 1 (indicating that the out of range request -should be silently ignored). -.El -.It Fn svc_create -The -.Fn svc_create -function -creates server handles for all the transports -belonging to the class -.Fa nettype . -The -.Fa nettype -argument -defines a class of transports which can be used -for a particular application. -The transports are tried in left to right order in -.Ev NETPATH -variable or in top to bottom order in the netconfig database. -If -.Fa nettype -is -.Dv NULL , -it defaults to -.Qq netpath . -.Pp -The -.Fn svc_create -function -registers itself with the rpcbind -service (see -.Xr rpcbind 8 ) . -The -.Fa dispatch -function -is called when there is a remote procedure call for the given -.Fa prognum -and -.Fa versnum ; -this requires calling -.Fn svc_run -(see -.Fn svc_run -in -.Xr rpc_svc_reg 3 ) . -If -.Fn svc_create -succeeds, it returns the number of server -handles it created, -otherwise it returns 0 and an error message is logged. -.It Fn svc_destroy -A function macro that destroys the RPC -service handle -.Fa xprt . -Destruction usually involves deallocation -of private data structures, -including -.Fa xprt -itself. -Use of -.Fa xprt -is undefined after calling this routine. -.It Fn svc_dg_create -This routine creates a connectionless RPC -service handle, and returns a pointer to it. -This routine returns -.Dv NULL -if it fails, and an error message is logged. -The -.Fa sendsz -and -.Fa recvsz -arguments -are arguments used to specify the size of the buffers. -If they are 0, suitable defaults are chosen. -The file descriptor -.Fa fildes -should be open and bound. -The server is not registered with -.Xr rpcbind 8 . -.Pp -Warning: -since connectionless-based RPC -messages can only hold limited amount of encoded data, -this transport cannot be used for procedures -that take large arguments or return huge results. -.It Fn svc_fd_create -This routine creates a service on top of an open and bound file descriptor, -and returns the handle to it. -Typically, this descriptor is a connected file descriptor for a -connection-oriented transport. -The -.Fa sendsz -and -.Fa recvsz -arguments -indicate sizes for the send and receive buffers. -If they are 0, reasonable defaults are chosen. -This routine returns -.Dv NULL -if it fails, and an error message is logged. -.It Fn svc_raw_create -This routine creates an RPC -service handle and returns a pointer to it. -The transport is really a buffer within the process's -address space, so the corresponding RPC -client should live in the same address space; -(see -.Fn clnt_raw_create -in -.Xr rpc_clnt_create 3 ) . -This routine allows simulation of RPC and acquisition of -RPC overheads (such as round trip times), -without any kernel and networking interference. -This routine returns -.Dv NULL -if it fails, and an error message is logged. -.Pp -Note: -.Fn svc_run -should not be called when the raw interface is being used. -.It Fn svc_tli_create -This routine creates an RPC -server handle, and returns a pointer to it. -The -.Fa fildes -argument -is the file descriptor on which the service is listening. -If -.Fa fildes -is -.Dv RPC_ANYFD , -it opens a file descriptor on the transport specified by -.Fa netconf . -If the file descriptor is unbound and -.Fa bindaddr -is not -.Dv NULL , -.Fa fildes -is bound to the address specified by -.Fa bindaddr , -otherwise -.Fa fildes -is bound to a default address chosen by the transport. -.Pp -Note: the -.Vt t_bind -structure comes from the TLI/XTI SysV interface, which -.Nx -does not use. -The structure is defined in -.In rpc/types.h -for compatibility as: -.Bd -literal -struct t_bind { - struct netbuf addr; /* network address, see rpc(3) */ - unsigned int qlen; /* queue length (for listen(2)) */ -}; -.Ed -.Pp -In the case where the default address is chosen, -the number of outstanding connect requests is set to 8 -for connection-oriented transports. -The user may specify the size of the send and receive buffers -with the arguments -.Fa sendsz -and -.Fa recvsz ; -values of 0 choose suitable defaults. -This routine returns -.Dv NULL -if it fails, -and an error message is logged. -The server is not registered with the -.Xr rpcbind 8 -service. -.It Fn svc_tp_create -The -.Fn svc_tp_create -function -creates a server handle for the network -specified by -.Fa netconf , -and registers itself with the rpcbind service. -The -.Fa dispatch -function -is called when there is a remote procedure call -for the given -.Fa prognum -and -.Fa versnum ; -this requires calling -.Fn svc_run . -The -.Fn svc_tp_create -function -returns the service handle if it succeeds, -otherwise a -.Dv NULL -is returned and an error message is logged. -.It Fn svc_vc_create -This routine creates a connection-oriented RPC -service and returns a pointer to it. -This routine returns -.Dv NULL -if it fails, and an error message is logged. -The users may specify the size of the send and receive buffers -with the arguments -.Fa sendsz -and -.Fa recvsz ; -values of 0 choose suitable defaults. -The file descriptor -.Fa fildes -should be open and bound. -The server is not registered with the -.Xr rpcbind 8 -service. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr rpc_svc_calls 3 , -.Xr rpc_svc_err 3 , -.Xr rpc_svc_reg 3 , -.Xr rpcbind 8 diff --git a/libtirpc-1.3.1/man/rpc_svc_err.3t b/libtirpc-1.3.1/man/rpc_svc_err.3t deleted file mode 100644 index ffc7f53..0000000 --- a/libtirpc-1.3.1/man/rpc_svc_err.3t +++ /dev/null @@ -1,97 +0,0 @@ -.\" @(#)rpc_svc_err.3n 1.23 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_svc_err 1.4 89/06/28 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_svc_err.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_err.3,v 1.4 2002/12/19 09:40:23 ru Exp $ -.Dd May 3, 1993 -.Dt RPC_SVC_ERR 3 -.Os -.Sh NAME -.Nm rpc_svc_err , -.Nm svcerr_auth , -.Nm svcerr_decode , -.Nm svcerr_noproc , -.Nm svcerr_noprog , -.Nm svcerr_progvers , -.Nm svcerr_systemerr , -.Nm svcerr_weakauth -.Nd library routines for server side remote procedure call errors -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft void -.Fn svcerr_auth "SVCXPRT *xprt" "enum auth_stat why" -.Ft void -.Fn svcerr_decode "SVCXPRT *xprt" -.Ft void -.Fn svcerr_noproc "SVCXPRT *xprt" -.Ft void -.Fn svcerr_noprog "SVCXPRT *xprt" -.Ft void -.Fn svcerr_progvers "SVCXPRT *xprt" "rpcvers_t low_vers" "rpcvers_t high_vers" -.Ft void -.Fn svcerr_systemerr "SVCXPRT *xprt" -.Ft void -.Fn svcerr_weakauth "SVCXPRT *xprt" -.Sh DESCRIPTION -These routines are part of the RPC -library which allows C language programs to make procedure -calls on other machines across the network. -.Pp -These routines can be called by the server side -dispatch function if there is any error in the -transaction with the client. -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt SVCXPRT -data structure. -.Bl -tag -width XXXXX -.It Fn svcerr_auth -Called by a service dispatch routine that refuses to perform -a remote procedure call due to an authentication error. -.It Fn svcerr_decode -Called by a service dispatch routine that cannot successfully -decode the remote arguments -(see -.Fn svc_getargs -in -.Xr rpc_svc_reg 3 ) . -.It Fn svcerr_noproc -Called by a service dispatch routine that does not implement -the procedure number that the caller requests. -.It Fn svcerr_noprog -Called when the desired program is not registered with the -RPC package. -Service implementors usually do not need this routine. -.It Fn svcerr_progvers -Called when the desired version of a program is not registered with the -RPC package. -The -.Fa low_vers -argument -is the lowest version number, -and -.Fa high_vers -is the highest version number. -Service implementors usually do not need this routine. -.It Fn svcerr_systemerr -Called by a service dispatch routine when it detects a system -error not covered by any particular protocol. -For example, if a service can no longer allocate storage, -it may call this routine. -.It Fn svcerr_weakauth -Called by a service dispatch routine that refuses to perform -a remote procedure call due to insufficient (but correct) -authentication arguments. -The routine calls -.Fn svcerr_auth "xprt" "AUTH_TOOWEAK" . -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr rpc_svc_calls 3 , -.Xr rpc_svc_create 3 , -.Xr rpc_svc_reg 3 diff --git a/libtirpc-1.3.1/man/rpc_svc_reg.3t b/libtirpc-1.3.1/man/rpc_svc_reg.3t deleted file mode 100644 index e74f7fc..0000000 --- a/libtirpc-1.3.1/man/rpc_svc_reg.3t +++ /dev/null @@ -1,183 +0,0 @@ -.\" @(#)rpc_svc_reg.3n 1.32 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_svc_call 1.6 89/07/20 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_svc_reg.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_reg.3,v 1.5 2002/12/19 09:40:23 ru Exp $ -.Dd May 3, 1993 -.Dt RPC_SVC_REG 3 -.Os -.Sh NAME -.Nm rpc_svc_reg , -.Nm rpc_reg , -.Nm svc_reg , -.Nm svc_unreg , -.Nm svc_auth_reg , -.Nm xprt_register , -.Nm xprt_unregister -.Nd library routines for registering servers -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft int -.Fn rpc_reg "rpcprog_t prognum" "rpcvers_t versnum" "rpcproc_t procnum" "char *(*procname)()" "xdrproc_t inproc" "xdrproc_t outproc" "char *nettype" -.Ft bool_t -.Fn svc_reg "SVCXPRT *xprt" "const rpcprog_t prognum" "const rpcvers_t versnum" "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const struct netconfig *netconf" -.Ft void -.Fn svc_unreg "const rpcprog_t prognum" "const rpcvers_t versnum" -.Ft int -.Fn svc_auth_reg "int cred_flavor" "enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *)" -.Ft void -.Fn xprt_register "SVCXPRT *xprt" -.Ft void -.Fn xprt_unregister "SVCXPRT *xprt" -.Sh DESCRIPTION -These routines are a part of the RPC -library which allows the RPC -servers to register themselves with rpcbind -(see -.Xr rpcbind 8 ) , -and associate the given program and version -number with the dispatch function. -When the RPC server receives a RPC request, the library invokes the -dispatch routine with the appropriate arguments. -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt SVCXPRT -data structure. -.Bl -tag -width XXXXX -.It Fn rpc_reg -Register program -.Fa prognum , -procedure -.Fa procname , -and version -.Fa versnum -with the RPC -service package. -If a request arrives for program -.Fa prognum , -version -.Fa versnum , -and procedure -.Fa procnum , -.Fa procname -is called with a pointer to its argument(s); -.Fa procname -should return a pointer to its static result(s); -.Fa inproc -is the XDR function used to decode the arguments while -.Fa outproc -is the XDR function used to encode the results. -Procedures are registered on all available transports of the class -.Fa nettype . -See -.Xr rpc 3 . -This routine returns 0 if the registration succeeded, -\-1 otherwise. -.It Fn svc_reg -Associates -.Fa prognum -and -.Fa versnum -with the service dispatch procedure, -.Fa dispatch . -If -.Fa netconf -is -.Dv NULL , -the service is not registered with the -.Xr rpcbind 8 -service. -If -.Fa netconf -is non-zero, -then a mapping of the triple -.Bq Fa prognum , versnum , netconf->nc_netid -to -.Fa xprt->xp_ltaddr -is established with the local rpcbind -service. -.Pp -The -.Fn svc_reg -routine returns 1 if it succeeds, -and 0 otherwise. -.It Fn svc_unreg -Remove from the rpcbind -service, all mappings of the triple -.Bq Fa prognum , versnum , No all-transports -to network address -and all mappings within the RPC service package -of the double -.Bq Fa prognum , versnum -to dispatch routines. -.It Fn svc_auth_reg -Registers the service authentication routine -.Fa handler -with the dispatch mechanism so that it can be -invoked to authenticate RPC requests received -with authentication type -.Fa cred_flavor . -This interface allows developers to add new authentication -types to their RPC applications without needing to modify -the libraries. -Service implementors usually do not need this routine. -.Pp -Typical service application would call -.Fn svc_auth_reg -after registering the service and prior to calling -.Fn svc_run . -When needed to process an RPC credential of type -.Fa cred_flavor , -the -.Fa handler -procedure will be called with two arguments, -.Fa "struct svc_req *rqst" -and -.Fa "struct rpc_msg *msg" , -and is expected to return a valid -.Vt "enum auth_stat" -value. -There is no provision to change or delete an authentication handler -once registered. -.Pp -The -.Fn svc_auth_reg -routine returns 0 if the registration is successful, -1 if -.Fa cred_flavor -already has an authentication handler registered for it, -and \-1 otherwise. -.It Fn xprt_register -After RPC service transport handle -.Fa xprt -is created, it is registered with the RPC -service package. -This routine modifies the global variable -.Va svc_fdset -(see -.Xr rpc_svc_calls 3 ) . -Service implementors usually do not need this routine. -.It Fn xprt_unregister -Before an RPC service transport handle -.Fa xprt -is destroyed, it unregisters itself with the -RPC service package. -This routine modifies the global variable -.Va svc_fdset -(see -.Xr rpc_svc_calls 3 ) . -Service implementors usually do not need this routine. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr select 2 , -.Xr rpc 3 , -.Xr rpcbind 3 , -.Xr rpc_svc_calls 3 , -.Xr rpc_svc_create 3 , -.Xr rpc_svc_err 3 , -.Xr rpcbind 8 diff --git a/libtirpc-1.3.1/man/rpc_xdr.3t b/libtirpc-1.3.1/man/rpc_xdr.3t deleted file mode 100644 index ae3d663..0000000 --- a/libtirpc-1.3.1/man/rpc_xdr.3t +++ /dev/null @@ -1,101 +0,0 @@ -.\" @(#)rpc_xdr.3n 1.24 93/08/31 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" @(#)rpc_xdr.new 1.1 89/04/06 SMI; -.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD: src/lib/libc/rpc/rpc_xdr.3,v 1.3 2001/10/03 16:47:56 bde Exp $ -.Dd May 3, 1993 -.Dt RPC_XDR 3 -.Os -.Sh NAME -.Nm xdr_accepted_reply , -.Nm xdr_authsys_parms , -.Nm xdr_callhdr , -.Nm xdr_callmsg , -.Nm xdr_opaque_auth , -.Nm xdr_rejected_reply , -.Nm xdr_replymsg -.Nd XDR library routines for remote procedure calls -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft bool_t -.Fn xdr_accepted_reply "XDR *xdrs" "struct accepted_reply *ar" -.Ft bool_t -.Fn xdr_authsys_parms "XDR *xdrs" "struct authsys_parms *aupp" -.Ft bool_t -.Fn xdr_callhdr "XDR *xdrs" "struct rpc_msg *chdr" -.Ft bool_t -.Fn xdr_callmsg "XDR *xdrs" "struct rpc_msg *cmsg" -.Ft bool_t -.Fn xdr_opaque_auth "XDR *xdrs" "struct opaque_auth *ap" -.Ft bool_t -.Fn xdr_rejected_reply "XDR *xdrs" "struct rejected_reply *rr" -.Ft bool_t -.Fn xdr_replymsg "XDR *xdrs" "struct rpc_msg *rmsg" -.Sh DESCRIPTION -These routines are used for describing the -RPC messages in XDR language. -They should normally be used by those who do not -want to use the RPC -package directly. -These routines return -.Dv TRUE -if they succeed, -.Dv FALSE -otherwise. -.Sh Routines -See -.Xr rpc 3 -for the definition of the -.Vt XDR -data structure. -.Bl -tag -width XXXXX -.It Fn xdr_accepted_reply -Used to translate between RPC -reply messages and their external representation. -It includes the status of the RPC -call in the XDR language format. -In the case of success, it also includes the call results. -.It Fn xdr_authsys_parms -Used for describing -.Ux -operating system credentials. -It includes machine-name, uid, gid list, etc. -.It Fn xdr_callhdr -Used for describing -RPC -call header messages. -It encodes the static part of the call message header in the -XDR language format. -It includes information such as transaction -ID, RPC version number, program and version number. -.It Fn xdr_callmsg -Used for describing -RPC call messages. -This includes all the RPC -call information such as transaction -ID, RPC version number, program number, version number, -authentication information, etc. -This is normally used by servers to determine information about the client -RPC call. -.It Fn xdr_opaque_auth -Used for describing RPC -opaque authentication information messages. -.It Fn xdr_rejected_reply -Used for describing RPC reply messages. -It encodes the rejected RPC message in the XDR language format. -The message could be rejected either because of version -number mis-match or because of authentication errors. -.It Fn xdr_replymsg -Used for describing RPC -reply messages. -It translates between the -RPC reply message and its external representation. -This reply could be either an acceptance, -rejection or -.Dv NULL . -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr xdr 3 diff --git a/libtirpc-1.3.1/man/rpcbind.3t b/libtirpc-1.3.1/man/rpcbind.3t deleted file mode 100644 index ec492cc..0000000 --- a/libtirpc-1.3.1/man/rpcbind.3t +++ /dev/null @@ -1,194 +0,0 @@ -.\" @(#)rpcbind.3n 1.25 93/05/07 SMI; from SVr4 -.\" Copyright 1989 AT&T -.\" Copyright (c) 1988 Sun Microsystem's, Inc. - All Right's Reserved. -.\" $NetBSD: rpcbind.3,v 1.2 2000/06/03 18:47:28 fvdl Exp $ -.\" $FreeBSD: src/lib/libc/rpc/rpcbind.3,v 1.5 2002/12/19 09:40:23 ru Exp $ -.Dd May 7, 1993 -.Dt RPCBIND 3 -.Os -.Sh NAME -.Nm rpcb_getmaps , -.Nm rpcb_getaddr , -.Nm rpcb_gettime , -.Nm rpcb_rmtcall , -.Nm rpcb_set , -.Nm rpcb_unset -.Nd library routines for RPC bind service -.Sh SYNOPSIS -.In rpc/rpc.h -.Ft "rpcblist *" -.Fn rpcb_getmaps "const struct netconfig *netconf" "const char *host" -.Ft bool_t -.Fn rpcb_getaddr "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "struct netbuf *svcaddr" "const char *host" -.Ft bool_t -.Fn rpcb_gettime "const char *host" "time_t * timep" -.Ft "enum clnt_stat" -.Fn rpcb_rmtcall "const struct netconfig *netconf" "const char *host" "const rpcprog_t prognum, const rpcvers_t versnum" "const rpcproc_t procnum, const xdrproc_t inproc" "const caddr_t in" "const xdrproc_t outproc" "const caddr_t out" "const struct timeval tout, const struct netbuf *svcaddr" -.Ft bool_t -.Fn rpcb_set "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "const struct netbuf *svcaddr" -.Ft bool_t -.Fn rpcb_unset "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" -.Sh DESCRIPTION -These routines allow client C programs to make procedure -calls to the RPC binder service. -(see -.Xr rpcbind 8 ) -maintains a list of mappings between programs -and their universal addresses. -.Sh Routines -.Bl -tag -width XXXXX -.It Fn rpcb_getmaps -An interface to the rpcbind service, -which returns a list of the current -RPC program-to-address mappings on -.Fa host . -It uses the transport specified through -.Fa netconf -to contact the remote rpcbind -service on -.Fa host . -This routine will return -.Dv NULL , -if the remote rpcbind could not be contacted. -.It Fn rpcb_getaddr -An interface to the rpcbind -service, which finds the address of the service on -.Fa host -that is registered with program number -.Fa prognum , -version -.Fa versnum , -and speaks the transport protocol associated with -.Fa netconf . -The address found is returned in -.Fa svcaddr . -The -.Fa svcaddr -argument -should be preallocated. -This routine returns -.Dv TRUE -if it succeeds. -A return value of -.Dv FALSE -means that the mapping does not exist -or that the RPC -system failed to contact the remote -rpcbind service. -In the latter case, the global variable -.Va rpc_createerr -(see -.Xr rpc_clnt_create 3 ) -contains the -RPC status. -.It Fn rpcb_gettime -This routine returns the time on -.Fa host -in -.Fa timep . -If -.Fa host -is -.Dv NULL , -.Fn rpcb_gettime -returns the time on its own machine. -This routine returns -.Dv TRUE -if it succeeds, -.Dv FALSE -if it fails. -The -.Fn rpcb_gettime -function -can be used to synchronize the time between the -client and the remote server. -.It Fn rpcb_rmtcall -An interface to the rpcbind service, which instructs -rpcbind on -.Fa host -to make an RPC -call on your behalf to a procedure on that host. -The -.Fn netconfig -structure should correspond to a connectionless transport. -The -.Fa svcaddr -argument -will be modified to the server's address if the procedure succeeds -(see -.Fn rpc_call -and -.Fn clnt_call -in -.Xr rpc_clnt_calls 3 -for the definitions of other arguments). -.Pp -This procedure should normally be used for a -.Dq ping -and nothing else. -This routine allows programs to do lookup and call, all in one step. -.Pp -Note: Even if the server is not running -.Fn rpcb_rmtcall -does not return any error messages to the caller. -In such a case, the caller times out. -.Pp -Note: -.Fn rpcb_rmtcall -is only available for connectionless transports. -.It Fn rpcb_set -An interface to the rpcbind -service, which establishes a mapping between the triple -.Bq Fa prognum , versnum , netconf->nc_netid -and -.Fa svcaddr -on the machine's rpcbind -service. -The value of -.Fa nc_netid -must correspond to a network identifier that is defined by the -netconfig database. -This routine returns -.Dv TRUE -if it succeeds, -.Dv FALSE -otherwise. -(See also -.Fn svc_reg -in -.Xr rpc_svc_calls 3 . ) -If there already exists such an entry with rpcbind, -.Fn rpcb_set -will fail. -.It Fn rpcb_unset -An interface to the rpcbind -service, which destroys the mapping between the triple -.Bq Fa prognum , versnum , netconf->nc_netid -and the address on the machine's rpcbind -service. -If -.Fa netconf -is -.Dv NULL , -.Fn rpcb_unset -destroys all mapping between the triple -.Bq Fa prognum , versnum , No all-transports -and the addresses on the machine's rpcbind service. -This routine returns -.Dv TRUE -if it succeeds, -.Dv FALSE -otherwise. -Only the owner of the service or the super-user can destroy the mapping. -(See also -.Fn svc_unreg -in -.Xr rpc_svc_calls 3 . ) -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc_clnt_calls 3 , -.Xr rpc_svc_calls 3 , -.Xr rpcbind 8 , -.Xr rpcinfo 8 diff --git a/libtirpc-1.3.1/man/rpcsec_gss.3t b/libtirpc-1.3.1/man/rpcsec_gss.3t deleted file mode 100644 index d5f72cc..0000000 --- a/libtirpc-1.3.1/man/rpcsec_gss.3t +++ /dev/null @@ -1,222 +0,0 @@ -.\" Copyright (c) 2008 Isilon Inc http://www.isilon.com/ -.\" Authors: Doug Rabson -.\" Developed with Red Inc: Alfred Perlstein -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 26, 2010 -.Dt RPC_GSS_SECCREATE 3 -.Os -.Sh NAME -.Nm RPCSEC_GSS -.Nd "GSS-API based authentication for RPC" -.Sh SYNOPSIS -.In rpc/rpcsec_gss.h -.Sh DESCRIPTION -.Nm -is a security mechanism for the RPC protocol. -It uses the Generic Security Service API (GSS-API) to establish a -security context between a client and a server and to ensure that all -subsequent communication between client and server are properly -authenticated. -Optionally, extra protection can be applied to the connection. -The integrity service uses checksums to ensure that all data sent by -a peer is received without modification. -The privacy service uses encryption to ensure that no third party can -access the data for a connection. -.Pp -To use this system, an application must first use -.Fn rpc_gss_seccreate -to establish a security context. -.Sh DATA STRUCTURES -Data structures used by -.Nm -appear below. -.Bl -tag -width "MMMM" -.It Vt rpc_gss_service_t -This type defines the types of security service required for -.Fn rpc_gss_seccreate . -.Bd -literal -typedef enum { - rpc_gss_svc_default = 0, - rpc_gss_svc_none = 1, - rpc_gss_svc_integrity = 2, - rpc_gss_svc_privacy = 3 -} rpc_gss_service_t; -.Ed -.It Vt rpc_gss_options_ret_t -This structure contains various optional values which are used while -creating a security context. -.Bd -literal -typedef struct { - int req_flags; /* GSS request bits */ - int time_req; /* requested lifetime */ - gss_cred_id_t my_cred; /* GSS credential */ - gss_channel_bindings_t input_channel_bindings; -} rpc_gss_options_req_t; -.Ed -.It Vt rpc_gss_options_ret_t -Various details of the created security context are returned using -this structure. -.Bd -literal -typedef struct { - int major_status; - int minor_status; - u_int rpcsec_version; - int ret_flags; - int time_req; - gss_ctx_id_t gss_context; - char actual_mechanism[MAX_GSS_MECH]; -} rpc_gss_options_ret_t; -.Ed -.It Vt rpc_gss_principal_t -This type is used to refer to an client principal which is represented -in GSS-API exported name form -(see -.Xr gss_export_name 3 -for more details). -Names in this format may be stored in access control lists or compared -with other names in exported name form. -This structure is returned by -.Fn rpc_gss_get_principal_name -and is also referenced by the -.Vt rpc_gss_rawcred_t -structure. -.Bd -literal -typedef struct { - int len; - char name[1]; -} *rpc_gss_principal_t; -.Ed -.It Vt rpc_gss_rawcred_t -This structure is used to access the raw credentials associated with a -security context. -.Bd -literal -typedef struct { - u_int version; /* RPC version number */ - const char *mechanism; /* security mechanism */ - const char *qop; /* quality of protection */ - rpc_gss_principal_t client_principal; /* client name */ - const char *svc_principal; /* server name */ - rpc_gss_service_t service; /* service type */ -} rpc_gss_rawcred_t; -.Ed -.It Vt rpc_gss_ucred_t -Unix credentials which are derived form the raw credentials, -accessed via -.Fn rpc_gss_getcred . -.Bd -literal -typedef struct { - uid_t uid; /* user ID */ - gid_t gid; /* group ID */ - short gidlen; - gid_t *gidlist; /* list of groups */ -} rpc_gss_ucred_t; -.Ed -.It Vt rpc_gss_lock_t -Structure used to enforce a particular QOP and service. -.Bd -literal -typedef struct { - bool_t locked; - rpc_gss_rawcred_t *raw_cred; -} rpc_gss_lock_t; -.Ed -.It Vt rpc_gss_callback_t -Callback structure used by -.Fn rpc_gss_set_callback . -.Bd -literal -typedef struct { - u_int program; /* RPC program number */ - u_int version; /* RPC version number */ - /* user defined callback */ - bool_t (*callback)(struct svc_req *req, - gss_cred_id_t deleg, - gss_ctx_id_t gss_context, - rpc_gss_lock_t *lock, - void **cookie); -} rpc_gss_callback_t; -.Ed -.It Vt rpc_gss_error_t -Structure used to return error information by -.Fn rpc_gss_get_error . -.Bd -literal -typedef struct { - int rpc_gss_error; - int system_error; /* same as errno */ -} rpc_gss_error_t; - -/* - * Values for rpc_gss_error - */ -#define RPC_GSS_ER_SUCCESS 0 /* no error */ -#define RPC_GSS_ER_SYSTEMERROR 1 /* system error */ -.Ed -.El -.Sh INDEX -.Bl -tag -width "MMMM" -.It Xr rpc_gss_seccreate 3 -Create a new security context -.It Xr rpc_gss_set_defaults 3 -Set service and quality of protection for a context -.It Xr rpc_gss_max_data_length 3 -Calculate maximum client message sizes. -.It Xr rpc_gss_get_error 3 -Get details of the last error -.It Xr rpc_gss_mech_to_oid 3 -Convert a mechanism name to the corresponding GSS-API oid. -.It Xr rpc_gss_oid_to_mech 3 -Convert a GSS-API oid to a mechanism name -.It Xr rpc_gss_qop_to_num 3 -Convert a quality of protection name to the corresponding number -.It Xr rpc_gss_get_mechanisms 3 -Get a list of security mechanisms. -.It Xr rpc_gss_get_mech_info 3 -Return extra information about a security mechanism -.It Xr rpc_gss_get_versions 3 -Return the maximum and minimum supported versions of the -.Nm -protocol -.It Xr rpc_gss_is_installed 3 -Query for the presence of a particular security mechanism -.It Xr rpc_gss_set_svc_name 3 -Set the name of a service principal which matches a given RPC program -plus version pair -.It Xr rpc_gss_getcred 3 -Get credential details for the security context of an RPC request -.It Xr rpc_gss_set_callback 3 -Install a callback routine which is called on the server when new -security contexts are created -.It Xr rpc_gss_get_principal_name 3 -Create a client principal name from various strings -.It Xr rpc_gss_svc_max_data_length 3 -Calculate maximum server message sizes. -.El -.Sh AVAILABILITY -These functions are part of libtirpc. -.Sh SEE ALSO -.Xr rpc 3 , -.Xr gssapi 3 -.Sh AUTHORS -This -manual page was written by -.An Doug Rabson Aq dfr@FreeBSD.org . diff --git a/libtirpc-1.3.1/man/rtime.3t b/libtirpc-1.3.1/man/rtime.3t deleted file mode 100644 index bc93af6..0000000 --- a/libtirpc-1.3.1/man/rtime.3t +++ /dev/null @@ -1,50 +0,0 @@ -.\" @(#)rtime.3n 2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI -.\" $FreeBSD: src/lib/libc/rpc/rtime.3,v 1.8 2002/12/19 09:40:23 ru Exp $ -.\" -.Dd November 22, 1987 -.Dt RTIME 3 -.Os -.Sh NAME -.Nm rtime -.Nd "get remote time" -.Sh SYNOPSIS -.In sys/types.h -.In sys/time.h -.In netinet/in.h -.Ft int -.Fo rtime -.Fa "struct sockaddr_in *addrp" -.Fa "struct timeval *timep" -.Fa "struct timeval *timeout" -.Fc -.Sh DESCRIPTION -The -.Fn rtime -function -consults the Internet Time Server at the address pointed to by -.Fa addrp -and returns the remote time in the -.Vt timeval -struct pointed to by -.Fa timep . -Normally, the -.Tn UDP -protocol is used when consulting the Time Server. -The -.Fa timeout -argument specifies how long the -routine should wait before giving -up when waiting for a reply. -If -.Fa timeout -is specified as -.Dv NULL , -however, the routine will instead use -.Tn TCP -and block until a reply is received from the time server. -.Sh RETURN VALUES -.Rv -std rtime -.Sh AVAILABILITY -The -.Fn rtime -function is part of libtirpc. diff --git a/libtirpc-1.3.1/src/Makefile.am b/libtirpc-1.3.1/src/Makefile.am deleted file mode 100644 index b2d5436..0000000 --- a/libtirpc-1.3.1/src/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -## Process this file with automake to create Makefile.in. - -## NOTE: this file doesn't really try to be complete. In particular -## `make dist' won't work at all. We're just aiming to get the -## program built. We also don't bother trying to assemble code, or -## anything like that. - -noinst_HEADERS = rpc_com.h debug.h - -AM_CPPFLAGS = -I$(top_srcdir)/tirpc -include config.h -DPORTMAP -DINET6 \ - -D_GNU_SOURCE -Wall -pipe - -lib_LTLIBRARIES = libtirpc.la - -libtirpc_la_LDFLAGS = @LDFLAG_NOUNDEFINED@ -no-undefined -lpthread -libtirpc_la_LDFLAGS += -version-info @LT_VERSION_INFO@ - -libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c \ - binddynport.c bindresvport.c \ - clnt_bcast.c clnt_dg.c clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c \ - clnt_vc.c rpc_dtablesize.c getnetconfig.c getnetpath.c getrpcent.c \ - getrpcport.c mt_misc.c pmap_clnt.c pmap_getmaps.c pmap_getport.c \ - pmap_prot.c pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c \ - rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \ - rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \ - svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \ - auth_time.c debug.c - -if AUTHDES -libtirpc_la_SOURCES += auth_des.c authdes_prot.c des_crypt.c des_impl.c des_soft.c svc_auth_des.c -endif - -## XDR -libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c xdr_sizeof.c - -if SYMVERS - libtirpc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtirpc.map -endif - -## Secure-RPC -if GSS - libtirpc_la_SOURCES += auth_gss.c authgss_prot.c svc_auth_gss.c \ - rpc_gss_utils.c - libtirpc_la_LIBADD = $(GSSAPI_LIBS) - libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS) -endif - -libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c -libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c - -CLEANFILES = cscope.* *~ -DISTCLEANFILES = Makefile.in diff --git a/libtirpc-1.3.1/src/auth_des.c b/libtirpc-1.3.1/src/auth_des.c deleted file mode 100644 index c9af2e9..0000000 --- a/libtirpc-1.3.1/src/auth_des.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* - * auth_des.c, client-side implementation of DES authentication - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nis.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#endif - -#include "debug.h" - -#define USEC_PER_SEC 1000000 -#define RTIME_TIMEOUT 5 /* seconds to wait for sync */ - -#define AUTH_PRIVATE(auth) (struct ad_private *) auth->ah_private -#define ALLOC(object_type) (object_type *) mem_alloc(sizeof(object_type)) -#define FREE(ptr, size) mem_free((char *)(ptr), (int) size) -#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) - -extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *); -extern bool_t xdr_authdes_verf( XDR *, struct authdes_verf *); -extern int key_encryptsession_pk( char *, netobj *, des_block *); - -extern bool_t __rpc_get_time_offset(struct timeval *, nis_server *, char *, - char **, char **); - -/* - * DES authenticator operations vector - */ -static void authdes_nextverf(AUTH *); -static bool_t authdes_marshal(AUTH *, XDR *); -static bool_t authdes_validate(AUTH *, struct opaque_auth *); -static bool_t authdes_refresh(AUTH *, void *); -static void authdes_destroy(AUTH *); - -static struct auth_ops *authdes_ops(void); - -/* - * This struct is pointed to by the ah_private field of an "AUTH *" - */ -struct ad_private { - char *ad_fullname; /* client's full name */ - u_int ad_fullnamelen; /* length of name, rounded up */ - char *ad_servername; /* server's full name */ - u_int ad_servernamelen; /* length of name, rounded up */ - u_int ad_window; /* client specified window */ - bool_t ad_dosync; /* synchronize? */ - struct netbuf ad_syncaddr; /* remote host to synch with */ - char *ad_timehost; /* remote host to synch with */ - struct timeval ad_timediff; /* server's time - client's time */ - u_int ad_nickname; /* server's nickname for client */ - struct authdes_cred ad_cred; /* storage for credential */ - struct authdes_verf ad_verf; /* storage for verifier */ - struct timeval ad_timestamp; /* timestamp sent */ - des_block ad_xkey; /* encrypted conversation key */ - u_char ad_pkey[1024]; /* Server's actual public key */ - char *ad_netid; /* Timehost netid */ - char *ad_uaddr; /* Timehost uaddr */ - nis_server *ad_nis_srvr; /* NIS+ server struct */ -}; - -AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *, - const des_block *, nis_server *); - -/* - * documented version of authdes_seccreate - */ -/* - servername: network name of server - win: time to live - timehost: optional hostname to sync with - ckey: optional conversation key to use -*/ - -AUTH * -authdes_seccreate(const char *servername, const u_int win, - const char *timehost, const des_block *ckey) -{ - u_char pkey_data[1024]; - netobj pkey; - AUTH *dummy; - - if (! getpublickey(servername, (char *) pkey_data)) { - syslog(LOG_ERR, - "authdes_seccreate: no public key found for %s", - servername); - return (NULL); - } - - pkey.n_bytes = (char *) pkey_data; - pkey.n_len = (u_int)strlen((char *)pkey_data) + 1; - dummy = authdes_pk_seccreate(servername, &pkey, win, timehost, - ckey, NULL); - return (dummy); -} - -/* - * Slightly modified version of authdessec_create which takes the public key - * of the server principal as an argument. This spares us a call to - * getpublickey() which in the nameserver context can cause a deadlock. - */ -AUTH * -authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window, - const char *timehost, const des_block *ckey, nis_server *srvr) -{ - AUTH *auth; - struct ad_private *ad; - char namebuf[MAXNETNAMELEN+1]; - - /* - * Allocate everything now - */ - auth = ALLOC(AUTH); - if (auth == NULL) { - syslog(LOG_ERR, "authdes_pk_seccreate: out of memory"); - return (NULL); - } - ad = ALLOC(struct ad_private); - if (ad == NULL) { - syslog(LOG_ERR, "authdes_pk_seccreate: out of memory"); - goto failed; - } - ad->ad_fullname = ad->ad_servername = NULL; /* Sanity reasons */ - ad->ad_timehost = NULL; - ad->ad_netid = NULL; - ad->ad_uaddr = NULL; - ad->ad_nis_srvr = NULL; - ad->ad_timediff.tv_sec = 0; - ad->ad_timediff.tv_usec = 0; - memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len); - if (!getnetname(namebuf)) - goto failed; - ad->ad_fullnamelen = RNDUP((u_int) strlen(namebuf)); - ad->ad_fullname = (char *)mem_alloc(ad->ad_fullnamelen + 1); - ad->ad_servernamelen = strlen(servername); - ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1); - - if (ad->ad_fullname == NULL || ad->ad_servername == NULL) { - syslog(LOG_ERR, "authdes_seccreate: out of memory"); - goto failed; - } - if (timehost != NULL) { - ad->ad_timehost = (char *)mem_alloc(strlen(timehost) + 1); - if (ad->ad_timehost == NULL) { - syslog(LOG_ERR, "authdes_seccreate: out of memory"); - goto failed; - } - memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1); - ad->ad_dosync = TRUE; - } else if (srvr != NULL) { - ad->ad_nis_srvr = srvr; /* transient */ - ad->ad_dosync = TRUE; - } else { - ad->ad_dosync = FALSE; - } - memcpy(ad->ad_fullname, namebuf, ad->ad_fullnamelen + 1); - memcpy(ad->ad_servername, servername, ad->ad_servernamelen + 1); - ad->ad_window = window; - if (ckey == NULL) { - if (key_gendes(&auth->ah_key) < 0) { - syslog(LOG_ERR, - "authdes_seccreate: keyserv(1m) is unable to generate session key"); - goto failed; - } - } else { - auth->ah_key = *ckey; - } - - /* - * Set up auth handle - */ - auth->ah_cred.oa_flavor = AUTH_DES; - auth->ah_verf.oa_flavor = AUTH_DES; - auth->ah_ops = authdes_ops(); - auth->ah_private = (caddr_t)ad; - - if (!authdes_refresh(auth, NULL)) { - goto failed; - } - ad->ad_nis_srvr = NULL; /* not needed any longer */ - return (auth); - -failed: - if (auth) - FREE(auth, sizeof (AUTH)); - if (ad) { - if (ad->ad_fullname) - FREE(ad->ad_fullname, ad->ad_fullnamelen + 1); - if (ad->ad_servername) - FREE(ad->ad_servername, ad->ad_servernamelen + 1); - if (ad->ad_timehost) - FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1); - if (ad->ad_netid) - FREE(ad->ad_netid, strlen(ad->ad_netid) + 1); - if (ad->ad_uaddr) - FREE(ad->ad_uaddr, strlen(ad->ad_uaddr) + 1); - FREE(ad, sizeof (struct ad_private)); - } - return (NULL); -} - -/* - * Implement the five authentication operations - */ - - -/* - * 1. Next Verifier - */ -/*ARGSUSED*/ -static void -authdes_nextverf(AUTH *auth) -{ - /* what the heck am I supposed to do??? */ -} - - -/* - * 2. Marshal - */ -static bool_t -authdes_marshal(AUTH *auth, XDR *xdrs) -{ -/* LINTED pointer alignment */ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_cred *cred = &ad->ad_cred; - struct authdes_verf *verf = &ad->ad_verf; - des_block cryptbuf[2]; - des_block ivec; - int status; - int len; - rpc_inline_t *ixdr; - - /* - * Figure out the "time", accounting for any time difference - * with the server if necessary. - */ - (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL); - ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; - ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; - while (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) { - ad->ad_timestamp.tv_usec -= USEC_PER_SEC; - ad->ad_timestamp.tv_sec++; - } - - /* - * XDR the timestamp and possibly some other things, then - * encrypt them. - */ - ixdr = (rpc_inline_t *)cryptbuf; - IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_sec); - IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_usec); - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - IXDR_PUT_U_INT32(ixdr, ad->ad_window); - IXDR_PUT_U_INT32(ixdr, ad->ad_window - 1); - ivec.key.high = ivec.key.low = 0; - status = cbc_crypt((char *)&auth->ah_key, (char *)cryptbuf, - (u_int) 2 * sizeof (des_block), - DES_ENCRYPT | DES_HW, (char *)&ivec); - } else { - status = ecb_crypt((char *)&auth->ah_key, (char *)cryptbuf, - (u_int) sizeof (des_block), - DES_ENCRYPT | DES_HW); - } - if (DES_FAILED(status)) { - syslog(LOG_ERR, "authdes_marshal: DES encryption failure"); - return (FALSE); - } - ad->ad_verf.adv_xtimestamp = cryptbuf[0]; - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high; - ad->ad_verf.adv_winverf = cryptbuf[1].key.low; - } else { - ad->ad_cred.adc_nickname = ad->ad_nickname; - ad->ad_verf.adv_winverf = 0; - } - - /* - * Serialize the credential and verifier into opaque - * authentication data. - */ - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - len = ((1 + 1 + 2 + 1)*BYTES_PER_XDR_UNIT + ad->ad_fullnamelen); - } else { - len = (1 + 1)*BYTES_PER_XDR_UNIT; - } - - if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) { - IXDR_PUT_INT32(ixdr, AUTH_DES); - IXDR_PUT_INT32(ixdr, len); - } else { - ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_cred.oa_flavor)); - ATTEMPT(xdr_putint32(xdrs, &len)); - } - ATTEMPT(xdr_authdes_cred(xdrs, cred)); - - len = (2 + 1)*BYTES_PER_XDR_UNIT; - if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) { - IXDR_PUT_INT32(ixdr, AUTH_DES); - IXDR_PUT_INT32(ixdr, len); - } else { - ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_verf.oa_flavor)); - ATTEMPT(xdr_putint32(xdrs, &len)); - } - ATTEMPT(xdr_authdes_verf(xdrs, verf)); - return (TRUE); -} - - -/* - * 3. Validate - */ -static bool_t -authdes_validate(AUTH *auth, struct opaque_auth *rverf) -{ -/* LINTED pointer alignment */ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_verf verf; - int status; - uint32_t *ixdr; - des_block buf; - - if (rverf->oa_length != (2 + 1) * BYTES_PER_XDR_UNIT) { - return (FALSE); - } -/* LINTED pointer alignment */ - ixdr = (uint32_t *)rverf->oa_base; - buf.key.high = (uint32_t)*ixdr++; - buf.key.low = (uint32_t)*ixdr++; - verf.adv_int_u = (uint32_t)*ixdr++; - - /* - * Decrypt the timestamp - */ - status = ecb_crypt((char *)&auth->ah_key, (char *)&buf, - (u_int)sizeof (des_block), DES_DECRYPT | DES_HW); - - if (DES_FAILED(status)) { - syslog(LOG_ERR, "authdes_validate: DES decryption failure"); - return (FALSE); - } - - /* - * xdr the decrypted timestamp - */ -/* LINTED pointer alignment */ - ixdr = (uint32_t *)buf.c; - verf.adv_timestamp.tv_sec = IXDR_GET_INT32(ixdr) + 1; - verf.adv_timestamp.tv_usec = IXDR_GET_INT32(ixdr); - - /* - * validate - */ - if (memcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp, - sizeof(struct timeval)) != 0) { - LIBTIRPC_DEBUG(1, ("authdes_validate: verifier mismatch")); - return (FALSE); - } - - /* - * We have a nickname now, let's use it - */ - ad->ad_nickname = verf.adv_nickname; - ad->ad_cred.adc_namekind = ADN_NICKNAME; - return (TRUE); -} - -/* - * 4. Refresh - */ -/*ARGSUSED*/ -static bool_t -authdes_refresh(AUTH *auth, void *dummy) -{ -/* LINTED pointer alignment */ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_cred *cred = &ad->ad_cred; - int ok; - netobj pkey; - - if (ad->ad_dosync) { - ok = __rpc_get_time_offset(&ad->ad_timediff, ad->ad_nis_srvr, - ad->ad_timehost, &(ad->ad_uaddr), - &(ad->ad_netid)); - if (! ok) { - /* - * Hope the clocks are synced! - */ - ad->ad_dosync = 0; - LIBTIRPC_DEBUG(1, ("authdes_refresh: unable to synchronize clock")); - } - } - ad->ad_xkey = auth->ah_key; - pkey.n_bytes = (char *)(ad->ad_pkey); - pkey.n_len = (u_int)strlen((char *)ad->ad_pkey) + 1; - if (key_encryptsession_pk(ad->ad_servername, &pkey, &ad->ad_xkey) < 0) { - LIBTIRPC_DEBUG(1, - ("authdes_refresh: keyserv(1m) is unable to encrypt session key")); - return (FALSE); - } - cred->adc_fullname.key = ad->ad_xkey; - cred->adc_namekind = ADN_FULLNAME; - cred->adc_fullname.name = ad->ad_fullname; - return (TRUE); -} - - -/* - * 5. Destroy - */ -static void -authdes_destroy(AUTH *auth) -{ -/* LINTED pointer alignment */ - struct ad_private *ad = AUTH_PRIVATE(auth); - - FREE(ad->ad_fullname, ad->ad_fullnamelen + 1); - FREE(ad->ad_servername, ad->ad_servernamelen + 1); - if (ad->ad_timehost) - FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1); - if (ad->ad_netid) - FREE(ad->ad_netid, strlen(ad->ad_netid) + 1); - if (ad->ad_uaddr) - FREE(ad->ad_uaddr, strlen(ad->ad_uaddr) + 1); - FREE(ad, sizeof (struct ad_private)); - FREE(auth, sizeof(AUTH)); -} - -static bool_t -authdes_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere) -{ - return ((*xfunc)(xdrs, xwhere)); -} - -static struct auth_ops * -authdes_ops(void) -{ - static struct auth_ops ops; - extern mutex_t authdes_ops_lock; - - /* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&authdes_ops_lock); - if (ops.ah_nextverf == NULL) { - ops.ah_nextverf = authdes_nextverf; - ops.ah_marshal = authdes_marshal; - ops.ah_validate = authdes_validate; - ops.ah_refresh = authdes_refresh; - ops.ah_destroy = authdes_destroy; - ops.ah_wrap = authdes_wrap; - ops.ah_unwrap = authdes_wrap; - } - mutex_unlock(&authdes_ops_lock); - return (&ops); -} diff --git a/libtirpc-1.3.1/src/auth_gss.c b/libtirpc-1.3.1/src/auth_gss.c deleted file mode 100644 index d871672..0000000 --- a/libtirpc-1.3.1/src/auth_gss.c +++ /dev/null @@ -1,984 +0,0 @@ -/* - auth_gss.c - - RPCSEC_GSS client routines. - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -static void authgss_nextverf(AUTH *); -static bool_t authgss_marshal(AUTH *, XDR *); -static bool_t authgss_refresh(AUTH *, void *); -static bool_t authgss_validate(AUTH *, struct opaque_auth *); -static void authgss_destroy(AUTH *); -static void authgss_destroy_context(AUTH *); -static bool_t authgss_wrap(AUTH *, XDR *, xdrproc_t, caddr_t); -static bool_t authgss_unwrap(AUTH *, XDR *, xdrproc_t, caddr_t); - -void rpc_gss_set_error(int); -void rpc_gss_clear_error(void); -bool_t rpc_gss_oid_to_mech(rpc_gss_OID, char **); - -/* - * from mit-krb5-1.2.1 mechglue/mglueP.h: - * Array of context IDs typed by mechanism OID - */ -typedef struct gss_union_ctx_id_t { - gss_OID mech_type; - gss_ctx_id_t internal_ctx_id; -} gss_union_ctx_id_desc, *gss_union_ctx_id_t; - -static struct auth_ops authgss_ops = { - authgss_nextverf, - authgss_marshal, - authgss_validate, - authgss_refresh, - authgss_destroy, - authgss_wrap, - authgss_unwrap -}; - - -/* useful as i add more mechanisms */ -void -print_rpc_gss_sec(struct rpc_gss_sec *ptr) -{ -int i; -char *p; - - if (libtirpc_debug_level < 4 || log_stderr == 0) - return; - - gss_log_debug("rpc_gss_sec:"); - if(ptr->mech == NULL) - gss_log_debug("NULL gss_OID mech"); - else { - fprintf(stderr, " mechanism_OID: {"); - p = (char *)ptr->mech->elements; - for (i=0; i < ptr->mech->length; i++) - /* First byte of OIDs encoded to save a byte */ - if (i == 0) { - int first, second; - if (*p < 40) { - first = 0; - second = *p; - } - else if (40 <= *p && *p < 80) { - first = 1; - second = *p - 40; - } - else if (80 <= *p && *p < 127) { - first = 2; - second = *p - 80; - } - else { - /* Invalid value! */ - first = -1; - second = -1; - } - fprintf(stderr, " %u %u", first, second); - p++; - } - else { - fprintf(stderr, " %u", (unsigned char)*p++); - } - fprintf(stderr, " }\n"); - } - fprintf(stderr, " qop: %d\n", ptr->qop); - fprintf(stderr, " service: %d\n", ptr->svc); - fprintf(stderr, " cred: %p\n", ptr->cred); -} - -extern pthread_mutex_t auth_ref_lock; - -struct rpc_gss_data { - bool_t established; /* context established */ - gss_buffer_desc gc_wire_verf; /* save GSS_S_COMPLETE NULL RPC verfier - * to process at end of context negotiation*/ - CLIENT *clnt; /* client handle */ - gss_name_t name; /* service name */ - struct rpc_gss_sec sec; /* security tuple */ - gss_ctx_id_t ctx; /* context id */ - struct rpc_gss_cred gc; /* client credentials */ - u_int win; /* sequence window */ - int time_req; /* init_sec_context time_req */ - gss_channel_bindings_t icb; /* input channel bindings */ - int refcnt; /* reference count gss AUTHs */ -}; - -#define AUTH_PRIVATE(auth) ((struct rpc_gss_data *)auth->ah_private) - -static struct timeval AUTH_TIMEOUT = { 25, 0 }; - -static void -authgss_auth_get(AUTH *auth) -{ - struct rpc_gss_data *gd = AUTH_PRIVATE(auth); - - mutex_lock(&auth_ref_lock); - ++gd->refcnt; - mutex_unlock(&auth_ref_lock); -} - -static int -authgss_auth_put(AUTH *auth) -{ - int refcnt; - struct rpc_gss_data *gd = AUTH_PRIVATE(auth); - - mutex_lock(&auth_ref_lock); - refcnt = --gd->refcnt; - mutex_unlock(&auth_ref_lock); - return refcnt; -} - -AUTH * -authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec) -{ - AUTH *auth, *save_auth; - struct rpc_gss_data *gd; - OM_uint32 min_stat = 0; - - gss_log_debug("in authgss_create()"); - - memset(&rpc_createerr, 0, sizeof(rpc_createerr)); - - if ((auth = calloc(sizeof(*auth), 1)) == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - return (NULL); - } - if ((gd = calloc(sizeof(*gd), 1)) == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - free(auth); - return (NULL); - } - LIBTIRPC_DEBUG(3, ("authgss_create: name is %p", name)); - if (name != GSS_C_NO_NAME) { - if (gss_duplicate_name(&min_stat, name, &gd->name) - != GSS_S_COMPLETE) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - free(auth); - free(gd); - return (NULL); - } - } - else - gd->name = name; - - LIBTIRPC_DEBUG(3, ("authgss_create: gd->name is %p", gd->name)); - gd->clnt = clnt; - gd->ctx = GSS_C_NO_CONTEXT; - gd->sec = *sec; - - gd->gc.gc_v = RPCSEC_GSS_VERSION; - gd->gc.gc_proc = RPCSEC_GSS_INIT; - gd->gc.gc_svc = gd->sec.svc; - - auth->ah_ops = &authgss_ops; - auth->ah_private = (caddr_t)gd; - - save_auth = clnt->cl_auth; - clnt->cl_auth = auth; - - if (!authgss_refresh(auth, NULL)) - auth = NULL; - else - authgss_auth_get(auth); /* Reference for caller */ - - clnt->cl_auth = save_auth; - - return (auth); -} - -AUTH * -authgss_create_default(CLIENT *clnt, char *service, struct rpc_gss_sec *sec) -{ - AUTH *auth; - OM_uint32 maj_stat = 0, min_stat = 0; - gss_buffer_desc sname; - gss_name_t name = GSS_C_NO_NAME; - - gss_log_debug("in authgss_create_default()"); - - - sname.value = service; - sname.length = strlen(service); - - maj_stat = gss_import_name(&min_stat, &sname, - (gss_OID)GSS_C_NT_HOSTBASED_SERVICE, - &name); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("authgss_create_default: gss_import_name", - maj_stat, min_stat); - rpc_createerr.cf_stat = RPC_AUTHERROR; - return (NULL); - } - - auth = authgss_create(clnt, name, sec); - - if (name != GSS_C_NO_NAME) { - LIBTIRPC_DEBUG(3, ("authgss_create_default: freeing name %p", name)); - gss_release_name(&min_stat, &name); - } - - return (auth); -} - -bool_t -authgss_get_private_data(AUTH *auth, struct authgss_private_data *pd) -{ - struct rpc_gss_data *gd; - - gss_log_debug("in authgss_get_private_data()"); - - if (!auth || !pd) - return (FALSE); - - gd = AUTH_PRIVATE(auth); - - if (!gd || !gd->established) - return (FALSE); - - pd->pd_ctx = gd->ctx; - pd->pd_ctx_hndl = gd->gc.gc_ctx; - pd->pd_seq_win = gd->win; - /* - * We've given this away -- don't try to use it ourself any more - * Caller should call authgss_free_private_data to free data. - * This also ensures that authgss_destroy_context() won't try to - * send an RPCSEC_GSS_DESTROY request which might inappropriately - * destroy the context. - */ - gd->ctx = GSS_C_NO_CONTEXT; - gd->gc.gc_ctx.length = 0; - gd->gc.gc_ctx.value = NULL; - - return (TRUE); -} - -bool_t -authgss_free_private_data(struct authgss_private_data *pd) -{ - OM_uint32 min_stat; - gss_log_debug("in authgss_free_private_data()"); - - if (!pd) - return (FALSE); - - if (pd->pd_ctx != GSS_C_NO_CONTEXT) - gss_delete_sec_context(&min_stat, &pd->pd_ctx, NULL); - gss_release_buffer(&min_stat, &pd->pd_ctx_hndl); - memset(&pd->pd_ctx_hndl, 0, sizeof(pd->pd_ctx_hndl)); - pd->pd_seq_win = 0; - - return (TRUE); -} - -static void -authgss_nextverf(AUTH *auth) -{ - gss_log_debug("in authgss_nextverf()"); - /* no action necessary */ -} - -static bool_t -authgss_marshal(AUTH *auth, XDR *xdrs) -{ - XDR tmpxdrs; - char tmp[MAX_AUTH_BYTES]; - struct rpc_gss_data *gd; - gss_buffer_desc rpcbuf, checksum; - OM_uint32 maj_stat, min_stat; - bool_t xdr_stat; - - gss_log_debug("in authgss_marshal()"); - - gd = AUTH_PRIVATE(auth); - - if (gd->established) - gd->gc.gc_seq++; - - xdrmem_create(&tmpxdrs, tmp, sizeof(tmp), XDR_ENCODE); - - if (!xdr_rpc_gss_cred(&tmpxdrs, &gd->gc)) { - XDR_DESTROY(&tmpxdrs); - return (FALSE); - } - auth->ah_cred.oa_flavor = RPCSEC_GSS; - auth->ah_cred.oa_base = tmp; - auth->ah_cred.oa_length = XDR_GETPOS(&tmpxdrs); - - XDR_DESTROY(&tmpxdrs); - - if (!xdr_opaque_auth(xdrs, &auth->ah_cred)) - return (FALSE); - - if (gd->gc.gc_proc == RPCSEC_GSS_INIT || - gd->gc.gc_proc == RPCSEC_GSS_CONTINUE_INIT) { - return (xdr_opaque_auth(xdrs, &_null_auth)); - } - /* Checksum serialized RPC header, up to and including credential. */ - rpcbuf.length = XDR_GETPOS(xdrs); - XDR_SETPOS(xdrs, 0); - rpcbuf.value = XDR_INLINE(xdrs, rpcbuf.length); - - maj_stat = gss_get_mic(&min_stat, gd->ctx, gd->sec.qop, - &rpcbuf, &checksum); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("authgss_marshal: gss_get_mic", - maj_stat, min_stat); - if (maj_stat == GSS_S_CONTEXT_EXPIRED) { - gd->established = FALSE; - authgss_destroy_context(auth); - } - return (FALSE); - } - auth->ah_verf.oa_flavor = RPCSEC_GSS; - auth->ah_verf.oa_base = checksum.value; - auth->ah_verf.oa_length = checksum.length; - - xdr_stat = xdr_opaque_auth(xdrs, &auth->ah_verf); - gss_release_buffer(&min_stat, &checksum); - - return (xdr_stat); -} - -static bool_t -authgss_validate(AUTH *auth, struct opaque_auth *verf) -{ - struct rpc_gss_data *gd; - u_int num, qop_state; - gss_buffer_desc signbuf, checksum; - OM_uint32 maj_stat, min_stat; - - gss_log_debug("in authgss_validate()"); - - gd = AUTH_PRIVATE(auth); - - if (gd->established == FALSE) { - /* would like to do this only on NULL rpc -- - * gc->established is good enough. - * save the on the wire verifier to validate last - * INIT phase packet after decode if the major - * status is GSS_S_COMPLETE - */ - if ((gd->gc_wire_verf.value = - mem_alloc(verf->oa_length)) == NULL) { - fprintf(stderr, "gss_validate: out of memory\n"); - return (FALSE); - } - memcpy(gd->gc_wire_verf.value, verf->oa_base, verf->oa_length); - gd->gc_wire_verf.length = verf->oa_length; - return (TRUE); - } - - if (gd->gc.gc_proc == RPCSEC_GSS_INIT || - gd->gc.gc_proc == RPCSEC_GSS_CONTINUE_INIT) { - num = htonl(gd->win); - } - else num = htonl(gd->gc.gc_seq); - - signbuf.value = # - signbuf.length = sizeof(num); - - checksum.value = verf->oa_base; - checksum.length = verf->oa_length; - - maj_stat = gss_verify_mic(&min_stat, gd->ctx, &signbuf, - &checksum, &qop_state); - - if (maj_stat != GSS_S_COMPLETE || qop_state != gd->sec.qop) { - gss_log_status("authgss_validate: gss_verify_mic", - maj_stat, min_stat); - if (maj_stat == GSS_S_CONTEXT_EXPIRED) { - gd->established = FALSE; - authgss_destroy_context(auth); - } - return (FALSE); - } - return (TRUE); -} - -static bool_t -_rpc_gss_refresh(AUTH *auth, rpc_gss_options_ret_t *options_ret) -{ - struct rpc_gss_data *gd; - struct rpc_gss_init_res gr; - gss_buffer_desc *recv_tokenp, send_token; - OM_uint32 maj_stat, min_stat, call_stat, ret_flags, - time_ret; - gss_OID actual_mech_type; - char *mechanism; - - gss_log_debug("in authgss_refresh()"); - - gd = AUTH_PRIVATE(auth); - - if (gd->established) - return (TRUE); - - /* GSS context establishment loop. */ - memset(&gr, 0, sizeof(gr)); - recv_tokenp = GSS_C_NO_BUFFER; - - print_rpc_gss_sec(&gd->sec); - - for (;;) { - /* print the token we just received */ - if (recv_tokenp != GSS_C_NO_BUFFER) { - gss_log_debug("The token we just received (length %lu):", - recv_tokenp->length); - gss_log_hexdump(recv_tokenp->value, recv_tokenp->length, 0); - } - maj_stat = gss_init_sec_context(&min_stat, - gd->sec.cred, - &gd->ctx, - gd->name, - gd->sec.mech, - gd->sec.req_flags, - gd->time_req, - gd->icb, - recv_tokenp, - &actual_mech_type, - &send_token, - &ret_flags, - &time_ret); - - if (recv_tokenp != GSS_C_NO_BUFFER) { - gss_release_buffer(&min_stat, &gr.gr_token); - recv_tokenp = GSS_C_NO_BUFFER; - } - if (maj_stat != GSS_S_COMPLETE && - maj_stat != GSS_S_CONTINUE_NEEDED) { - gss_log_status("gss_init_sec_context", maj_stat, min_stat); - options_ret->major_status = maj_stat; - options_ret->minor_status = min_stat; - break; - } - if (send_token.length != 0) { - memset(&gr, 0, sizeof(gr)); - - /* print the token we are about to send */ - gss_log_debug("The token being sent (length %lu):", - send_token.length); - gss_log_hexdump(send_token.value, send_token.length, 0); - - call_stat = clnt_call(gd->clnt, NULLPROC, - (xdrproc_t)xdr_rpc_gss_init_args, - &send_token, - (xdrproc_t)xdr_rpc_gss_init_res, - (caddr_t)&gr, AUTH_TIMEOUT); - - gss_release_buffer(&min_stat, &send_token); - - if (call_stat != RPC_SUCCESS || - (gr.gr_major != GSS_S_COMPLETE && - gr.gr_major != GSS_S_CONTINUE_NEEDED)) { - options_ret->major_status = gr.gr_major; - options_ret->minor_status = gr.gr_minor; - if (call_stat != RPC_SUCCESS) { - struct rpc_err err; - clnt_geterr(gd->clnt, &err); - LIBTIRPC_DEBUG(1, ("authgss_refresh: %s errno: %s", - clnt_sperrno(call_stat), strerror(err.re_errno))); - } else - gss_log_status("authgss_refresh:", - gr.gr_major, gr.gr_minor); - return FALSE; - } - - if (gr.gr_ctx.length != 0) { - if (gd->gc.gc_ctx.value) - gss_release_buffer(&min_stat, - &gd->gc.gc_ctx); - gd->gc.gc_ctx = gr.gr_ctx; - } - if (gr.gr_token.length != 0) { - if (maj_stat != GSS_S_CONTINUE_NEEDED) - break; - recv_tokenp = &gr.gr_token; - } - gd->gc.gc_proc = RPCSEC_GSS_CONTINUE_INIT; - } - - /* GSS_S_COMPLETE => check gss header verifier, - * usually checked in gss_validate - */ - if (maj_stat == GSS_S_COMPLETE) { - gss_buffer_desc bufin; - gss_buffer_desc bufout; - u_int seq, qop_state = 0; - - seq = htonl(gr.gr_win); - bufin.value = (unsigned char *)&seq; - bufin.length = sizeof(seq); - bufout.value = (unsigned char *)gd->gc_wire_verf.value; - bufout.length = gd->gc_wire_verf.length; - - maj_stat = gss_verify_mic(&min_stat, gd->ctx, - &bufin, &bufout, &qop_state); - - if (maj_stat != GSS_S_COMPLETE - || qop_state != gd->sec.qop) { - gss_log_status("authgss_refresh: gss_verify_mic", - maj_stat, min_stat); - if (maj_stat == GSS_S_CONTEXT_EXPIRED) { - gd->established = FALSE; - authgss_destroy_context(auth); - } - rpc_gss_set_error(EPERM); - options_ret->major_status = maj_stat; - options_ret->minor_status = min_stat; - return (FALSE); - } - - options_ret->major_status = GSS_S_COMPLETE; - options_ret->minor_status = 0; - options_ret->rpcsec_version = gd->gc.gc_v; - options_ret->ret_flags = ret_flags; - options_ret->time_ret = time_ret; - options_ret->gss_context = gd->ctx; - options_ret->actual_mechanism[0] = '\0'; - if (rpc_gss_oid_to_mech(actual_mech_type, &mechanism)) { - strncpy(options_ret->actual_mechanism, - mechanism, - (sizeof(options_ret->actual_mechanism)-1)); - } - - gd->established = TRUE; - gd->gc.gc_proc = RPCSEC_GSS_DATA; - gd->gc.gc_seq = 0; - gd->win = gr.gr_win; - break; - } - } - /* End context negotiation loop. */ - if (gd->gc.gc_proc != RPCSEC_GSS_DATA) { - if (gr.gr_token.length != 0) - gss_release_buffer(&min_stat, &gr.gr_token); - - authgss_destroy(auth); - auth = NULL; - rpc_createerr.cf_stat = RPC_AUTHERROR; - rpc_gss_set_error(EPERM); - - return (FALSE); - } - return (TRUE); -} - -static bool_t -authgss_refresh(AUTH *auth, void *dummy) -{ - rpc_gss_options_ret_t ret; - - memset(&ret, 0, sizeof(ret)); - return _rpc_gss_refresh(auth, &ret); -} - -bool_t -authgss_service(AUTH *auth, int svc) -{ - struct rpc_gss_data *gd; - - gss_log_debug("in authgss_service()"); - - if (!auth) - return(FALSE); - gd = AUTH_PRIVATE(auth); - if (!gd || !gd->established) - return (FALSE); - gd->sec.svc = svc; - gd->gc.gc_svc = svc; - return (TRUE); -} - -static void -authgss_destroy_context(AUTH *auth) -{ - struct rpc_gss_data *gd; - OM_uint32 min_stat; - - gss_log_debug("in authgss_destroy_context()"); - - gd = AUTH_PRIVATE(auth); - - if (gd->gc.gc_ctx.length != 0) { - if (gd->established) { - AUTH *save_auth = NULL; - - /* Make sure we use the right auth_ops */ - if (gd->clnt->cl_auth != auth) { - save_auth = gd->clnt->cl_auth; - gd->clnt->cl_auth = auth; - } - - gd->gc.gc_proc = RPCSEC_GSS_DESTROY; - clnt_call(gd->clnt, NULLPROC, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_void, NULL, AUTH_TIMEOUT); - - if (save_auth != NULL) - gd->clnt->cl_auth = save_auth; - } - gss_release_buffer(&min_stat, &gd->gc.gc_ctx); - /* XXX ANDROS check size of context - should be 8 */ - memset(&gd->gc.gc_ctx, 0, sizeof(gd->gc.gc_ctx)); - } - if (gd->ctx != GSS_C_NO_CONTEXT) { - gss_delete_sec_context(&min_stat, &gd->ctx, NULL); - gd->ctx = GSS_C_NO_CONTEXT; - } - - /* free saved wire verifier (if any) */ - mem_free(gd->gc_wire_verf.value, gd->gc_wire_verf.length); - gd->gc_wire_verf.value = NULL; - gd->gc_wire_verf.length = 0; - - gd->established = FALSE; -} - -static void -authgss_destroy(AUTH *auth) -{ - if(authgss_auth_put(auth) == 0) - { - struct rpc_gss_data *gd; - OM_uint32 min_stat; - - gss_log_debug("in authgss_destroy()"); - - gd = AUTH_PRIVATE(auth); - - authgss_destroy_context(auth); - - LIBTIRPC_DEBUG(3, ("authgss_destroy: freeing name %p", gd->name)); - if (gd->name != GSS_C_NO_NAME) - gss_release_name(&min_stat, &gd->name); - - free(gd); - free(auth); - } -} - -static bool_t -authgss_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr) -{ - struct rpc_gss_data *gd; - - gss_log_debug("in authgss_wrap()"); - - gd = AUTH_PRIVATE(auth); - - if (!gd->established || gd->sec.svc == RPCSEC_GSS_SVC_NONE) { - return ((*xdr_func)(xdrs, xdr_ptr)); - } - return (xdr_rpc_gss_data(xdrs, xdr_func, xdr_ptr, - gd->ctx, gd->sec.qop, - gd->sec.svc, gd->gc.gc_seq)); -} - -static bool_t -authgss_unwrap(AUTH *auth, XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr) -{ - struct rpc_gss_data *gd; - - gss_log_debug("in authgss_unwrap()"); - - gd = AUTH_PRIVATE(auth); - - if (!gd->established || gd->sec.svc == RPCSEC_GSS_SVC_NONE) { - return ((*xdr_func)(xdrs, xdr_ptr)); - } - return (xdr_rpc_gss_data(xdrs, xdr_func, xdr_ptr, - gd->ctx, gd->sec.qop, - gd->sec.svc, gd->gc.gc_seq)); -} - -static AUTH * -_rpc_gss_seccreate_error(int system_error) -{ - rpc_gss_set_error(system_error); - return NULL; -} - -/* - * External API: Create a GSS security context for this "clnt" - * - * clnt: a valid RPC CLIENT structure - * principal: NUL-terminated C string containing GSS principal - * mechanism: NUL-terminated C string containing GSS mechanism name - * service: GSS security value to use - * qop: NUL-terminated C string containing QOP name - * req: pointer to additional request parameters, or NULL - * ret: pointer to additional results, or NULL - * - * Returns pointer to a filled in RPC AUTH structure or NULL. - * Caller must free returned structure with AUTH_DESTROY. - */ -AUTH * -rpc_gss_seccreate(CLIENT *clnt, char *principal, char *mechanism, - rpc_gss_service_t service, char *qop, - rpc_gss_options_req_t *req, rpc_gss_options_ret_t *ret) -{ - rpc_gss_options_ret_t options_ret; - OM_uint32 maj_stat, min_stat; - struct rpc_gss_sec sec = { - .req_flags = GSS_C_MUTUAL_FLAG, - .cred = GSS_C_NO_CREDENTIAL, - }; - struct rpc_gss_data *gd; - AUTH *auth, *save_auth; - gss_buffer_desc sname; - - if (clnt == NULL || principal == NULL) - return _rpc_gss_seccreate_error(EINVAL); - - if (rpc_gss_mech_to_oid(mechanism, &sec.mech) == FALSE) - return NULL; - - sec.qop = GSS_C_QOP_DEFAULT; - if (qop != NULL) { - u_int qop_num; - if (rpc_gss_qop_to_num(qop, mechanism, &qop_num) == FALSE) - return NULL; - sec.qop = qop_num; - } - - switch (service) { - case rpcsec_gss_svc_none: - sec.svc = RPCSEC_GSS_SVC_NONE; - break; - case rpcsec_gss_svc_integrity: - sec.svc = RPCSEC_GSS_SVC_INTEGRITY; - break; - case rpcsec_gss_svc_privacy: - sec.svc = RPCSEC_GSS_SVC_PRIVACY; - break; - case rpcsec_gss_svc_default: - sec.svc = RPCSEC_GSS_SVC_INTEGRITY; - break; - default: - return _rpc_gss_seccreate_error(ENOENT); - } - - if (ret == NULL) - ret = &options_ret; - memset(ret, 0, sizeof(*ret)); - - auth = calloc(1, sizeof(*auth)); - gd = calloc(1, sizeof(*gd)); - if (auth == NULL || gd == NULL) { - free(gd); - free(auth); - return _rpc_gss_seccreate_error(ENOMEM); - } - - sname.value = principal; - sname.length = strlen(principal); - maj_stat = gss_import_name(&min_stat, &sname, - (gss_OID)GSS_C_NT_HOSTBASED_SERVICE, - &gd->name); - if (maj_stat != GSS_S_COMPLETE) { - ret->major_status = maj_stat; - ret->minor_status = min_stat; - free(gd); - free(auth); - return _rpc_gss_seccreate_error(ENOMEM); - } - - gd->clnt = clnt; - gd->ctx = GSS_C_NO_CONTEXT; - gd->sec = sec; - - if (req) { - sec.req_flags = req->req_flags; - gd->time_req = req->time_req; - sec.cred = req->my_cred; - gd->icb = req->input_channel_bindings; - } - - gd->gc.gc_v = RPCSEC_GSS_VERSION; - gd->gc.gc_proc = RPCSEC_GSS_INIT; - gd->gc.gc_svc = sec.svc; - - auth->ah_ops = &authgss_ops; - auth->ah_private = (caddr_t)gd; - - save_auth = clnt->cl_auth; - clnt->cl_auth = auth; - - if (_rpc_gss_refresh(auth, ret) == FALSE) { - auth = NULL; - } else { - rpc_gss_clear_error(); - authgss_auth_get(auth); - } - - clnt->cl_auth = save_auth; - - return auth; -} - -/* - * External API: Modify an AUTH's service and QOP settings - * - * auth: a valid RPC AUTH structure - * service: GSS security value to use - * qop: NUL-terminated C string containing QOP name - * - * Returns TRUE if successful, otherwise FALSE is returned. - */ -bool_t -rpc_gss_set_defaults(AUTH *auth, rpc_gss_service_t service, char *qop) -{ - struct rpc_gss_data *gd; - char *mechanism; - u_int qop_num; - - if (auth == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - gd = AUTH_PRIVATE(auth); - if (gd == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - if (rpc_gss_oid_to_mech(gd->sec.mech, &mechanism) == FALSE) - return FALSE; - - qop_num = GSS_C_QOP_DEFAULT; - if (qop != NULL) { - if (rpc_gss_qop_to_num(qop, mechanism, &qop_num) == FALSE) - return FALSE; - } - - switch (service) { - case rpcsec_gss_svc_none: - gd->gc.gc_svc = gd->sec.svc = RPCSEC_GSS_SVC_NONE; - break; - case rpcsec_gss_svc_integrity: - gd->gc.gc_svc = gd->sec.svc = RPCSEC_GSS_SVC_INTEGRITY; - break; - case rpcsec_gss_svc_privacy: - gd->gc.gc_svc = gd->sec.svc = RPCSEC_GSS_SVC_PRIVACY; - break; - case rpcsec_gss_svc_default: - gd->gc.gc_svc = gd->sec.svc = RPCSEC_GSS_SVC_INTEGRITY; - break; - default: - rpc_gss_set_error(ENOENT); - return FALSE; - } - - gd->sec.qop = (gss_qop_t)qop_num; - rpc_gss_clear_error(); - return TRUE; -} - -/* - * External API: Return maximum data size for a security mechanism and transport - * - * auth: a valid RPC AUTH structure - * maxlen: transport's maximum data size, in bytes - * - * Returns maximum data size given transformations done by current - * security setting of "auth", in bytes, or zero if that value - * cannot be determined. - */ -int -rpc_gss_max_data_length(AUTH *auth, int maxlen) -{ - OM_uint32 max_input_size, maj_stat, min_stat; - struct rpc_gss_data *gd; - int conf_req_flag; - int result; - - if (auth == NULL) { - rpc_gss_set_error(EINVAL); - return 0; - } - - gd = AUTH_PRIVATE(auth); - if (gd == NULL) { - rpc_gss_set_error(EINVAL); - return 0; - } - - switch (gd->sec.svc) { - case RPCSEC_GSS_SVC_NONE: - rpc_gss_clear_error(); - return maxlen; - case RPCSEC_GSS_SVC_INTEGRITY: - conf_req_flag = 0; - break; - case RPCSEC_GSS_SVC_PRIVACY: - conf_req_flag = 1; - break; - default: - rpc_gss_set_error(ENOENT); - return 0; - } - - result = 0; - maj_stat = gss_wrap_size_limit(&min_stat, gd->ctx, conf_req_flag, - gd->sec.qop, maxlen, &max_input_size); - if (maj_stat == GSS_S_COMPLETE) - if ((int)max_input_size > 0) - result = (int)max_input_size; - rpc_gss_clear_error(); - return result; -} diff --git a/libtirpc-1.3.1/src/auth_none.c b/libtirpc-1.3.1/src/auth_none.c deleted file mode 100644 index 0b0bbd1..0000000 --- a/libtirpc-1.3.1/src/auth_none.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -__FBSDID("$FreeBSD: src/lib/libc/rpc/auth_none.c,v 1.12 2002/03/22 23:18:35 obrien Exp $"); -*/ - - -/* - * auth_none.c - * Creates a client authentication handle for passing "null" - * credentials and verifiers to remote systems. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#include -#include -#include -#include -#include -#include -#include - -#define MAX_MARSHAL_SIZE 20 - -/* - * Authenticator operations routines - */ - -static bool_t authnone_marshal (AUTH *, XDR *); -static void authnone_verf (AUTH *); -static bool_t authnone_validate (AUTH *, struct opaque_auth *); -static bool_t authnone_refresh (AUTH *, void *); -static void authnone_destroy (AUTH *); - -extern bool_t xdr_opaque_auth(); - -static struct auth_ops *authnone_ops(); - -static struct authnone_private { - AUTH no_client; - char marshalled_client[MAX_MARSHAL_SIZE]; - u_int mcnt; -} *authnone_private; - -AUTH * -authnone_create() -{ - struct authnone_private *ap = authnone_private; - XDR xdr_stream; - XDR *xdrs; - extern mutex_t authnone_lock; - - mutex_lock(&authnone_lock); - if (ap == 0) { - ap = (struct authnone_private *)calloc(1, sizeof (*ap)); - if (ap == 0) { - mutex_unlock(&authnone_lock); - return (0); - } - authnone_private = ap; - } - if (!ap->mcnt) { - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = authnone_ops(); - xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, - (u_int)MAX_MARSHAL_SIZE, XDR_ENCODE); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); - ap->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - } - mutex_unlock(&authnone_lock); - return (&ap->no_client); -} - -/*ARGSUSED*/ -static bool_t -authnone_marshal(AUTH *client, XDR *xdrs) -{ - struct authnone_private *ap; - bool_t rv = FALSE; - extern mutex_t authnone_lock; - - assert(xdrs != NULL); - - mutex_lock(&authnone_lock); - ap = authnone_private; - if (ap) { - rv = (*xdrs->x_ops->x_putbytes)(xdrs, ap->marshalled_client, - ap->mcnt); - } - mutex_unlock(&authnone_lock); - return (rv); -} - -/* All these unused parameters are required to keep ANSI-C from grumbling */ -/*ARGSUSED*/ -static void -authnone_verf(AUTH *client) -{ -} - -/*ARGSUSED*/ -static bool_t -authnone_validate(AUTH *client, struct opaque_auth *opaque) -{ - - return (TRUE); -} - -/*ARGSUSED*/ -static bool_t -authnone_refresh(AUTH *client, void *dummy) -{ - - return (FALSE); -} - -/*ARGSUSED*/ -static void -authnone_destroy(AUTH *client) -{ -} - -static bool_t -authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere) -{ - return ((*xfunc)(xdrs, xwhere)); -} - -static struct auth_ops * -authnone_ops() -{ - static struct auth_ops ops; - extern mutex_t ops_lock; - -/* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&ops_lock); - if (ops.ah_nextverf == NULL) { - ops.ah_nextverf = authnone_verf; - ops.ah_marshal = authnone_marshal; - ops.ah_validate = authnone_validate; - ops.ah_refresh = authnone_refresh; - ops.ah_destroy = authnone_destroy; - ops.ah_wrap = authnone_wrap; - ops.ah_unwrap = authnone_wrap; - } - mutex_unlock(&ops_lock); - return (&ops); -} diff --git a/libtirpc-1.3.1/src/auth_time.c b/libtirpc-1.3.1/src/auth_time.c deleted file mode 100644 index 936dd76..0000000 --- a/libtirpc-1.3.1/src/auth_time.c +++ /dev/null @@ -1,495 +0,0 @@ -/* - * auth_time.c - * - * This module contains the private function __rpc_get_time_offset() - * which will return the difference in seconds between the local system's - * notion of time and a remote server's notion of time. This must be - * possible without calling any functions that may invoke the name - * service. (netdir_getbyxxx, getXbyY, etc). The function is used in the - * synchronize call of the authdes code to synchronize clocks between - * NIS+ clients and their servers. - * - * Note to minimize the amount of duplicate code, portions of the - * synchronize() function were folded into this code, and the synchronize - * call becomes simply a wrapper around this function. Further, if this - * function is called with a timehost it *DOES* recurse to the name - * server so don't use it in that mode if you are doing name service code. - * - * Copyright (c) 1992 Sun Microsystems Inc. - * All rights reserved. - * - * Side effects : - * When called a client handle to a RPCBIND process is created - * and destroyed. Two strings "netid" and "uaddr" are malloc'd - * and returned. The SIGALRM processing is modified only if - * needed to deal with TCP connections. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include - -#include "nis.h" - - -#ifdef TESTING -#define msg(x) printf("ERROR: %s\n", x) -/* #define msg(x) syslog(LOG_ERR, "%s", x) */ -#else -#define msg(x) -#endif - -static int saw_alarm = 0; - -static void -alarm_hndler(s) - int s; -{ - saw_alarm = 1; - return; -} - -/* - * The internet time server defines the epoch to be Jan 1, 1900 - * whereas UNIX defines it to be Jan 1, 1970. To adjust the result - * from internet time-service time, into UNIX time we subtract the - * following offset : - */ -#define NYEARS (1970 - 1900) -#define TOFFSET ((u_long)60*60*24*(365*NYEARS + (NYEARS/4))) - - -/* - * Stolen from rpc.nisd: - * Turn a 'universal address' into a struct sockaddr_in. - * Bletch. - */ -static int uaddr_to_sockaddr(uaddr, sin) -#ifdef foo - endpoint *endpt; -#endif - char *uaddr; - struct sockaddr_in *sin; -{ - unsigned char p_bytes[2]; - int i; - unsigned long a[6]; - - i = sscanf(uaddr, "%lu.%lu.%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2], - &a[3], &a[4], &a[5]); - - if (i < 6) - return(1); - - for (i = 0; i < 4; i++) - sin->sin_addr.s_addr |= (a[i] & 0x000000FF) << (8 * i); - - p_bytes[0] = (unsigned char)a[4] & 0x000000FF; - p_bytes[1] = (unsigned char)a[5] & 0x000000FF; - - sin->sin_family = AF_INET; /* always */ - memcpy((char *)&sin->sin_port, (char *)&p_bytes, 2); - - return (0); -} - -/* - * free_eps() - * - * Free the strings that were strduped into the eps structure. - */ -static void -free_eps(eps, num) - endpoint eps[]; - int num; -{ - int i; - - for (i = 0; i < num; i++) { - free(eps[i].uaddr); - free(eps[i].proto); - free(eps[i].family); - } - return; -} - -/* - * get_server() - * - * This function constructs a nis_server structure description for the - * indicated hostname. - * - * NOTE: There is a chance we may end up recursing here due to the - * fact that gethostbyname() could do an NIS search. Ideally, the - * NIS+ server will call __rpc_get_time_offset() with the nis_server - * structure already populated. - */ -static nis_server * -get_server(sin, host, srv, eps, maxep) - struct sockaddr_in *sin; - char *host; /* name of the time host */ - nis_server *srv; /* nis_server struct to use. */ - endpoint eps[]; /* array of endpoints */ - int maxep; /* max array size */ -{ - char hname[256]; - int num_ep = 0, i; - struct hostent *he; - struct hostent dummy; - char *ptr[2]; - - if (host == NULL && sin == NULL) - return (NULL); - - if (sin == NULL) { - he = gethostbyname(host); - if (he == NULL) - return(NULL); - } else { - he = &dummy; - ptr[0] = (char *)&sin->sin_addr.s_addr; - ptr[1] = NULL; - dummy.h_addr_list = ptr; - } - - /* - * This is lame. We go around once for TCP, then again - * for UDP. - */ - for (i = 0; (he->h_addr_list[i] != NULL) && (num_ep < maxep); - i++, num_ep++) { - struct in_addr *a; - - a = (struct in_addr *)he->h_addr_list[i]; - snprintf(hname, sizeof(hname), "%s.0.111", inet_ntoa(*a)); - eps[num_ep].uaddr = strdup(hname); - eps[num_ep].family = strdup("inet"); - eps[num_ep].proto = strdup("tcp"); - } - - for (i = 0; (he->h_addr_list[i] != NULL) && (num_ep < maxep); - i++, num_ep++) { - struct in_addr *a; - - a = (struct in_addr *)he->h_addr_list[i]; - snprintf(hname, sizeof(hname), "%s.0.111", inet_ntoa(*a)); - eps[num_ep].uaddr = strdup(hname); - eps[num_ep].family = strdup("inet"); - eps[num_ep].proto = strdup("udp"); - } - - srv->name = (nis_name) host; - srv->ep.ep_len = num_ep; - srv->ep.ep_val = eps; - srv->key_type = NIS_PK_NONE; - srv->pkey.n_bytes = NULL; - srv->pkey.n_len = 0; - return (srv); -} - -/* - * __rpc_get_time_offset() - * - * This function uses a nis_server structure to contact the a remote - * machine (as named in that structure) and returns the offset in time - * between that machine and this one. This offset is returned in seconds - * and may be positive or negative. - * - * The first time through, a lot of fiddling is done with the netconfig - * stuff to find a suitable transport. The function is very aggressive - * about choosing UDP or at worst TCP if it can. This is because - * those transports support both the RCPBIND call and the internet - * time service. - * - * Once through, *uaddr is set to the universal address of - * the machine and *netid is set to the local netid for the transport - * that uaddr goes with. On the second call, the netconfig stuff - * is skipped and the uaddr/netid pair are used to fetch the netconfig - * structure and to then contact the machine for the time. - * - * td = "server" - "client" - */ -int -__rpc_get_time_offset(td, srv, thost, uaddr, netid) - struct timeval *td; /* Time difference */ - nis_server *srv; /* NIS Server description */ - char *thost; /* if no server, this is the timehost */ - char **uaddr; /* known universal address */ - struct sockaddr_in *netid; /* known network identifier */ -{ - CLIENT *clnt; /* Client handle */ - endpoint *ep, /* useful endpoints */ - *useep = NULL; /* endpoint of xp */ - char *useua = NULL; /* uaddr of selected xp */ - int epl, i; /* counters */ - enum clnt_stat status; /* result of clnt_call */ - u_long thetime, delta; - int needfree = 0; - struct timeval tv; - int time_valid; - int udp_ep = -1, tcp_ep = -1; - int a1, a2, a3, a4; - char ut[64], ipuaddr[64]; - endpoint teps[32]; - nis_server tsrv; - void (*oldsig)() = NULL; /* old alarm handler */ - struct sockaddr_in sin; - int s = RPC_ANYSOCK; - socklen_t len; - int type = 0; - - td->tv_sec = 0; - td->tv_usec = 0; - - /* - * First check to see if we need to find and address for this - * server. - */ - if (*uaddr == NULL) { - if ((srv != NULL) && (thost != NULL)) { - msg("both timehost and srv pointer used!"); - return (0); - } - if (! srv) { - srv = get_server(netid, thost, &tsrv, teps, 32); - if (srv == NULL) { - msg("unable to contruct server data."); - return (0); - } - needfree = 1; /* need to free data in endpoints */ - } - - ep = srv->ep.ep_val; - epl = srv->ep.ep_len; - - /* Identify the TCP and UDP endpoints */ - for (i = 0; - (i < epl) && ((udp_ep == -1) || (tcp_ep == -1)); i++) { - if (strcasecmp(ep[i].proto, "udp") == 0) - udp_ep = i; - if (strcasecmp(ep[i].proto, "tcp") == 0) - tcp_ep = i; - } - - /* Check to see if it is UDP or TCP */ - if (tcp_ep > -1) { - useep = &ep[tcp_ep]; - useua = ep[tcp_ep].uaddr; - type = SOCK_STREAM; - } else if (udp_ep > -1) { - useep = &ep[udp_ep]; - useua = ep[udp_ep].uaddr; - type = SOCK_DGRAM; - } - - if (useep == NULL) { - msg("no acceptable transport endpoints."); - if (needfree) - free_eps(teps, tsrv.ep.ep_len); - return (0); - } - } - - /* - * Create a sockaddr from the uaddr. - */ - if (*uaddr != NULL) - useua = *uaddr; - - /* Fixup test for NIS+ */ - sscanf(useua, "%d.%d.%d.%d.", &a1, &a2, &a3, &a4); - sprintf(ipuaddr, "%d.%d.%d.%d.0.111", a1, a2, a3, a4); - useua = &ipuaddr[0]; - - memset(&sin, 0, sizeof(sin)); - if (uaddr_to_sockaddr(useua, &sin)) { - msg("unable to translate uaddr to sockaddr."); - if (needfree) - free_eps(teps, tsrv.ep.ep_len); - return (0); - } - - /* - * Create the client handle to rpcbind. Note we always try - * version 3 since that is the earliest version that supports - * the RPCB_GETTIME call. Also it is the version that comes - * standard with SVR4. Since most everyone supports TCP/IP - * we could consider trying the rtime call first. - */ - clnt = clnttcp_create(&sin, RPCBPROG, RPCBVERS, &s, 0, 0); - if (clnt == NULL) { - msg("unable to create client handle to rpcbind."); - if (needfree) - free_eps(teps, tsrv.ep.ep_len); - return (0); - } - - tv.tv_sec = 5; - tv.tv_usec = 0; - time_valid = 0; - status = clnt_call(clnt, RPCBPROC_GETTIME, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_u_long, &thetime, tv); - /* - * The only error we check for is anything but success. In - * fact we could have seen PROGMISMATCH if talking to a 4.1 - * machine (pmap v2) or TIMEDOUT if the net was busy. - */ - if (status == RPC_SUCCESS) - time_valid = 1; - else { - int save; - - /* Blow away possible stale CLNT handle. */ - if (clnt != NULL) { - clnt_destroy(clnt); - clnt = NULL; - } - - /* - * Convert PMAP address into timeservice address - * We take advantage of the fact that we "know" what - * the universal address looks like for inet transports. - * - * We also know that the internet timeservice is always - * listening on port 37. - */ - sscanf(useua, "%d.%d.%d.%d.", &a1, &a2, &a3, &a4); - sprintf(ut, "%d.%d.%d.%d.0.37", a1, a2, a3, a4); - - if (uaddr_to_sockaddr(ut, &sin)) { - msg("cannot convert timeservice uaddr to sockaddr."); - goto error; - } - - s = socket(AF_INET, type, 0); - if (s == -1) { - msg("unable to open fd to network."); - goto error; - } - - /* - * Now depending on whether or not we're talking to - * UDP we set a timeout or not. - */ - if (type == SOCK_DGRAM) { - struct timeval timeout = { 20, 0 }; - struct sockaddr_in from; - fd_set readfds; - int res; - - if (sendto(s, &thetime, sizeof(thetime), 0, - (struct sockaddr *)&sin, sizeof(sin)) == -1) { - msg("udp : sendto failed."); - goto error; - } - do { - FD_ZERO(&readfds); - FD_SET(s, &readfds); - res = select(_rpc_dtablesize(), &readfds, - (fd_set *)NULL, (fd_set *)NULL, &timeout); - } while (res < 0 && errno == EINTR); - if (res <= 0) - goto error; - len = sizeof(from); - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)&from, &len); - if (res == -1) { - msg("recvfrom failed on udp transport."); - goto error; - } - time_valid = 1; - } else { - int res; - - oldsig = (void (*)())signal(SIGALRM, alarm_hndler); - saw_alarm = 0; /* global tracking the alarm */ - alarm(20); /* only wait 20 seconds */ - res = connect(s, (struct sockaddr *)&sin, sizeof(sin)); - if (res == -1) { - msg("failed to connect to tcp endpoint."); - goto error; - } - if (saw_alarm) { - msg("alarm caught it, must be unreachable."); - goto error; - } - res = read(s, (char *)&thetime, sizeof(thetime)); - if (res != sizeof(thetime)) { - if (saw_alarm) - msg("timed out TCP call."); - else - msg("wrong size of results returned"); - - goto error; - } - time_valid = 1; - } - save = errno; - (void)close(s); - errno = save; - s = RPC_ANYSOCK; - - if (time_valid) { - thetime = ntohl(thetime); - thetime = thetime - TOFFSET; /* adjust to UNIX time */ - } else - thetime = 0; - } - - gettimeofday(&tv, 0); - -error: - /* - * clean up our allocated data structures. - */ - - if (s != RPC_ANYSOCK) - (void)close(s); - - if (clnt != NULL) - clnt_destroy(clnt); - - alarm(0); /* reset that alarm if its outstanding */ - if (oldsig) { - signal(SIGALRM, oldsig); - } - - /* - * note, don't free uaddr strings until after we've made a - * copy of them. - */ - if (time_valid) { - if (*uaddr == NULL) - *uaddr = strdup(useua); - - /* Round to the nearest second */ - tv.tv_sec += (tv.tv_sec > 500000) ? 1 : 0; - delta = (thetime > tv.tv_sec) ? thetime - tv.tv_sec : - tv.tv_sec - thetime; - td->tv_sec = (thetime < tv.tv_sec) ? - delta : delta; - td->tv_usec = 0; - } else { - msg("unable to get the server's time."); - } - - if (needfree) - free_eps(teps, tsrv.ep.ep_len); - - return (time_valid); -} diff --git a/libtirpc-1.3.1/src/auth_unix.c b/libtirpc-1.3.1/src/auth_unix.c deleted file mode 100644 index fc2be02..0000000 --- a/libtirpc-1.3.1/src/auth_unix.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * auth_unix.c, Implements UNIX style authentication parameters. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The system is very weak. The client uses no encryption for it's - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - * - */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/* auth_unix.c */ -static void authunix_nextverf (AUTH *); -static bool_t authunix_marshal (AUTH *, XDR *); -static bool_t authunix_validate (AUTH *, struct opaque_auth *); -static bool_t authunix_refresh (AUTH *, void *); -static void authunix_destroy (AUTH *); -static void marshal_new_auth (AUTH *); -static struct auth_ops *authunix_ops (void); - -/* - * This struct is pointed to by the ah_private field of an auth_handle. - */ -struct audata { - struct opaque_auth au_origcred; /* original credentials */ - struct opaque_auth au_shcred; /* short hand cred */ - u_long au_shfaults; /* short hand cache faults */ - char au_marshed[MAX_AUTH_BYTES]; - u_int au_mpos; /* xdr pos at end of marshed */ -}; -#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) - -/* - * Create a unix style authenticator. - * Returns an auth handle with the given stuff in it. - */ -AUTH * -authunix_create(machname, uid, gid, len, aup_gids) - char *machname; - uid_t uid; - gid_t gid; - int len; - gid_t *aup_gids; -{ - struct authunix_parms aup; - char mymem[MAX_AUTH_BYTES]; - struct timeval now; - XDR xdrs; - AUTH *auth; - struct audata *au; - - memset(&rpc_createerr, 0, sizeof(rpc_createerr)); - - /* - * Allocate and set up auth handle - */ - au = NULL; - auth = mem_alloc(sizeof(*auth)); -#ifndef _KERNEL - if (auth == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - goto cleanup_authunix_create; - } -#endif - au = mem_alloc(sizeof(*au)); -#ifndef _KERNEL - if (au == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - goto cleanup_authunix_create; - } -#endif - auth->ah_ops = authunix_ops(); - auth->ah_private = (caddr_t)au; - auth->ah_verf = au->au_shcred = _null_auth; - au->au_shfaults = 0; - au->au_origcred.oa_base = NULL; - - /* - * fill in param struct from the given params - */ - (void)gettimeofday(&now, NULL); - aup.aup_time = now.tv_sec; - aup.aup_machname = machname; - aup.aup_uid = uid; - aup.aup_gid = gid; - aup.aup_len = (u_int)len; - aup.aup_gids = aup_gids; - - /* - * Serialize the parameters into origcred - */ - xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); - if (!xdr_authunix_parms(&xdrs, &aup)) { - rpc_createerr.cf_stat = RPC_CANTENCODEARGS; - goto cleanup_authunix_create; - } - au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); - au->au_origcred.oa_flavor = AUTH_UNIX; -#ifdef _KERNEL - au->au_origcred.oa_base = mem_alloc((u_int) len); -#else - if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - goto cleanup_authunix_create; - } -#endif - memmove(au->au_origcred.oa_base, mymem, (size_t)len); - - /* - * set auth handle to reflect new cred. - */ - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); - return (auth); -#ifndef _KERNEL - cleanup_authunix_create: - if (auth) - mem_free(auth, sizeof(*auth)); - if (au) { - if (au->au_origcred.oa_base) - mem_free(au->au_origcred.oa_base, (u_int)len); - mem_free(au, sizeof(*au)); - } - return (NULL); -#endif -} - -/* - * Returns an auth handle with parameters determined by doing lots of - * syscalls. - */ -AUTH * -authunix_create_default() -{ - int len; - char machname[MAXHOSTNAMELEN + 1]; - uid_t uid; - gid_t gid, *gids; - AUTH *result; - - memset(&rpc_createerr, 0, sizeof(rpc_createerr)); - - if (gethostname(machname, sizeof machname) == -1) { - rpc_createerr.cf_error.re_errno = errno; - goto out_err; - } - machname[sizeof(machname) - 1] = 0; - uid = geteuid(); - gid = getegid(); - - /* According to glibc comments, an intervening setgroups(2) - * call can increase the number of supplemental groups between - * these two getgroups(2) calls. */ -retry: - len = getgroups(0, NULL); - if (len == -1) { - rpc_createerr.cf_error.re_errno = errno; - goto out_err; - } - - /* Bump allocation size. A zero allocation size may result in a - * NULL calloc(3) result, which is not reliably distinguishable - * from a memory allocation error. */ - gids = calloc(len + 1, sizeof(gid_t)); - if (gids == NULL) { - rpc_createerr.cf_error.re_errno = ENOMEM; - goto out_err; - } - - len = getgroups(len, gids); - if (len == -1) { - rpc_createerr.cf_error.re_errno = errno; - free(gids); - if (rpc_createerr.cf_error.re_errno == EINVAL) { - rpc_createerr.cf_error.re_errno = 0; - goto retry; - } - goto out_err; - } - - /* - * AUTH_UNIX sends on the wire only the first NGRPS groups in the - * supplemental groups list. - */ - if (len > NGRPS) - len = NGRPS; - - /* XXX: interface problem; those should all have been unsigned */ - result = authunix_create(machname, uid, gid, len, gids); - free(gids); - return result; - -out_err: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - return NULL; -} - -/* - * authunix operations - */ - -/* ARGSUSED */ -static void -authunix_nextverf(auth) - AUTH *auth; -{ - /* no action necessary */ -} - -static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; -{ - struct audata *au; - - assert(auth != NULL); - assert(xdrs != NULL); - - au = AUTH_PRIVATE(auth); - return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); -} - -static bool_t -authunix_validate(auth, verf) - AUTH *auth; - struct opaque_auth *verf; -{ - struct audata *au; - XDR xdrs; - - assert(auth != NULL); - assert(verf != NULL); - - if (verf->oa_flavor == AUTH_SHORT) { - au = AUTH_PRIVATE(auth); - xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, - XDR_DECODE); - - if (au->au_shcred.oa_base != NULL) { - mem_free(au->au_shcred.oa_base, - au->au_shcred.oa_length); - au->au_shcred.oa_base = NULL; - } - if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { - auth->ah_cred = au->au_shcred; - } else { - xdrs.x_op = XDR_FREE; - (void)xdr_opaque_auth(&xdrs, &au->au_shcred); - au->au_shcred.oa_base = NULL; - auth->ah_cred = au->au_origcred; - } - marshal_new_auth(auth); - } - return (TRUE); -} - -static bool_t -authunix_refresh(AUTH *auth, void *dummy) -{ - struct audata *au = AUTH_PRIVATE(auth); - struct authunix_parms aup; - struct timeval now; - XDR xdrs; - int stat; - - assert(auth != NULL); - - if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { - /* there is no hope. Punt */ - return (FALSE); - } - au->au_shfaults ++; - - /* first deserialize the creds back into a struct authunix_parms */ - aup.aup_machname = NULL; - aup.aup_gids = NULL; - xdrmem_create(&xdrs, au->au_origcred.oa_base, - au->au_origcred.oa_length, XDR_DECODE); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - - /* update the time and serialize in place */ - (void)gettimeofday(&now, NULL); - aup.aup_time = now.tv_sec; - xdrs.x_op = XDR_ENCODE; - XDR_SETPOS(&xdrs, 0); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); -done: - /* free the struct authunix_parms created by deserializing */ - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, &aup); - XDR_DESTROY(&xdrs); - return (stat); -} - -static void -authunix_destroy(auth) - AUTH *auth; -{ - struct audata *au; - - assert(auth != NULL); - - au = AUTH_PRIVATE(auth); - mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); - - if (au->au_shcred.oa_base != NULL) - mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); - - mem_free(auth->ah_private, sizeof(struct audata)); - - if (auth->ah_verf.oa_base != NULL) - mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); - - mem_free(auth, sizeof(*auth)); -} - -/* - * Marshals (pre-serializes) an auth struct. - * sets private data, au_marshed and au_mpos - */ -static void -marshal_new_auth(auth) - AUTH *auth; -{ - XDR xdr_stream; - XDR *xdrs = &xdr_stream; - struct audata *au; - - assert(auth != NULL); - - au = AUTH_PRIVATE(auth); - xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); - if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || - (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) - warnx("auth_none.c - Fatal marshalling problem"); - else - au->au_mpos = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); -} - -static bool_t -authunix_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere) -{ - return ((*xfunc)(xdrs, xwhere)); -} - -static struct auth_ops * -authunix_ops() -{ - static struct auth_ops ops; - extern mutex_t ops_lock; - - /* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&ops_lock); - if (ops.ah_nextverf == NULL) { - ops.ah_nextverf = authunix_nextverf; - ops.ah_marshal = authunix_marshal; - ops.ah_validate = authunix_validate; - ops.ah_refresh = authunix_refresh; - ops.ah_destroy = authunix_destroy; - ops.ah_wrap = authunix_wrap; - ops.ah_unwrap = authunix_wrap; - } - mutex_unlock(&ops_lock); - return (&ops); -} diff --git a/libtirpc-1.3.1/src/authdes_prot.c b/libtirpc-1.3.1/src/authdes_prot.c deleted file mode 100644 index 227d08a..0000000 --- a/libtirpc-1.3.1/src/authdes_prot.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * authdes_prot.c, XDR routines for DES authentication - */ - -#include - -#include -#include -#include - -#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) - -bool_t -xdr_authdes_cred(xdrs, cred) - XDR *xdrs; - struct authdes_cred *cred; -{ - /* - * Unrolled xdr - */ - ATTEMPT(xdr_enum(xdrs, (enum_t *)&cred->adc_namekind)); - switch (cred->adc_namekind) { - case ADN_FULLNAME: - ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name, - MAXNETNAMELEN)); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key, - sizeof(des_block))); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window, - sizeof(cred->adc_fullname.window))); - return (TRUE); - case ADN_NICKNAME: - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname, - sizeof(cred->adc_nickname))); - return (TRUE); - default: - return (FALSE); - } -} - - -bool_t -xdr_authdes_verf(xdrs, verf) - XDR *xdrs; - struct authdes_verf *verf; -{ - /* - * Unrolled xdr - */ - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp, - sizeof(des_block))); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u, - sizeof(verf->adv_int_u))); - return (TRUE); -} diff --git a/libtirpc-1.3.1/src/authgss_prot.c b/libtirpc-1.3.1/src/authgss_prot.c deleted file mode 100644 index c2b25db..0000000 --- a/libtirpc-1.3.1/src/authgss_prot.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - authgss_prot.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -/* additional space needed for encoding */ -#define RPC_SLACK_SPACE 1024 - -bool_t -xdr_rpc_gss_buf(XDR *xdrs, gss_buffer_t buf, u_int maxsize) -{ - bool_t xdr_stat; - u_int tmplen; - - if (xdrs->x_op != XDR_DECODE) { - if (buf->length > UINT_MAX) - return FALSE; - else - tmplen = buf->length; - } - xdr_stat = xdr_bytes(xdrs, (char **)&buf->value, &tmplen, maxsize); - - if (xdr_stat && xdrs->x_op == XDR_DECODE) - buf->length = tmplen; - - gss_log_debug("xdr_rpc_gss_buf: %s %s (%p:%lu)", - (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode", - (xdr_stat == TRUE) ? "success" : "failure", - buf->value, buf->length); - - return xdr_stat; -} - -bool_t -xdr_rpc_gss_cred(XDR *xdrs, struct rpc_gss_cred *p) -{ - bool_t xdr_stat; - - xdr_stat = (xdr_u_int(xdrs, &p->gc_v) && - xdr_enum(xdrs, (enum_t *)&p->gc_proc) && - xdr_u_int(xdrs, &p->gc_seq) && - xdr_enum(xdrs, (enum_t *)&p->gc_svc) && - xdr_rpc_gss_buf(xdrs, &p->gc_ctx, MAX_AUTH_BYTES)); - - gss_log_debug("xdr_rpc_gss_cred: %s %s " - "(v %d, proc %d, seq %d, svc %d, ctx %p:%lu)", - (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode", - (xdr_stat == TRUE) ? "success" : "failure", - p->gc_v, p->gc_proc, p->gc_seq, p->gc_svc, - p->gc_ctx.value, p->gc_ctx.length); - - return (xdr_stat); -} - -bool_t -xdr_rpc_gss_init_args(XDR *xdrs, gss_buffer_desc *p) -{ - bool_t xdr_stat; - u_int maxlen = (u_int)(p->length + RPC_SLACK_SPACE); - - xdr_stat = xdr_rpc_gss_buf(xdrs, p, maxlen); - - gss_log_debug("xdr_rpc_gss_init_args: %s %s (token %p:%lu)", - (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode", - (xdr_stat == TRUE) ? "success" : "failure", - p->value, p->length); - - return (xdr_stat); -} - -bool_t -xdr_rpc_gss_init_res(XDR *xdrs, struct rpc_gss_init_res *p) -{ - bool_t xdr_stat; - - u_int ctx_maxlen = (u_int)(p->gr_ctx.length + RPC_SLACK_SPACE); - u_int tok_maxlen = (u_int)(p->gr_token.length + RPC_SLACK_SPACE); - - xdr_stat = (xdr_rpc_gss_buf(xdrs, &p->gr_ctx, ctx_maxlen) && - xdr_u_int(xdrs, &p->gr_major) && - xdr_u_int(xdrs, &p->gr_minor) && - xdr_u_int(xdrs, &p->gr_win) && - xdr_rpc_gss_buf(xdrs, &p->gr_token, tok_maxlen)); - - gss_log_debug("xdr_rpc_gss_init_res %s %s " - "(ctx %p:%lu, maj %d, min %d, win %d, token %p:%lu)", - (xdrs->x_op == XDR_ENCODE) ? "encode" : "decode", - (xdr_stat == TRUE) ? "success" : "failure", - p->gr_ctx.value, p->gr_ctx.length, - p->gr_major, p->gr_minor, p->gr_win, - p->gr_token.value, p->gr_token.length); - - return (xdr_stat); -} - -bool_t -xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, - gss_ctx_id_t ctx, gss_qop_t qop, - rpc_gss_svc_t svc, u_int seq) -{ - gss_buffer_desc databuf, wrapbuf; - OM_uint32 maj_stat, min_stat; - int start, end, conf_state; - bool_t xdr_stat; - u_int databuflen, maxwrapsz; - - /* Skip databody length. */ - start = XDR_GETPOS(xdrs); - XDR_SETPOS(xdrs, start + 4); - - memset(&databuf, 0, sizeof(databuf)); - memset(&wrapbuf, 0, sizeof(wrapbuf)); - - /* Marshal rpc_gss_data_t (sequence number + arguments). */ - if (!xdr_u_int(xdrs, &seq) || !(*xdr_func)(xdrs, xdr_ptr)) - return (FALSE); - end = XDR_GETPOS(xdrs); - - /* Set databuf to marshalled rpc_gss_data_t. */ - databuflen = end - start - 4; - XDR_SETPOS(xdrs, start + 4); - databuf.value = XDR_INLINE(xdrs, databuflen); - databuf.length = databuflen; - - xdr_stat = FALSE; - - if (svc == RPCSEC_GSS_SVC_INTEGRITY) { - /* Marshal databody_integ length. */ - XDR_SETPOS(xdrs, start); - if (!xdr_u_int(xdrs, (u_int *)&databuflen)) - return (FALSE); - - /* Checksum rpc_gss_data_t. */ - maj_stat = gss_get_mic(&min_stat, ctx, qop, - &databuf, &wrapbuf); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("xdr_rpc_gss_wrap_data: gss_get_mic", - maj_stat, min_stat); - return (FALSE); - } - /* Marshal checksum. */ - XDR_SETPOS(xdrs, end); - maxwrapsz = (u_int)(wrapbuf.length + RPC_SLACK_SPACE); - xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, maxwrapsz); - gss_release_buffer(&min_stat, &wrapbuf); - } - else if (svc == RPCSEC_GSS_SVC_PRIVACY) { - /* Encrypt rpc_gss_data_t. */ - maj_stat = gss_wrap(&min_stat, ctx, TRUE, qop, &databuf, - &conf_state, &wrapbuf); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("xdr_rpc_gss_wrap_data: gss_wrap", - maj_stat, min_stat); - return (FALSE); - } - /* Marshal databody_priv. */ - XDR_SETPOS(xdrs, start); - maxwrapsz = (u_int)(wrapbuf.length + RPC_SLACK_SPACE); - xdr_stat = xdr_rpc_gss_buf(xdrs, &wrapbuf, maxwrapsz); - gss_release_buffer(&min_stat, &wrapbuf); - } - return (xdr_stat); -} - -bool_t -xdr_rpc_gss_unwrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, - gss_ctx_id_t ctx, gss_qop_t qop, - rpc_gss_svc_t svc, u_int seq) -{ - XDR tmpxdrs; - gss_buffer_desc databuf, wrapbuf; - OM_uint32 maj_stat, min_stat; - u_int seq_num, qop_state; - int conf_state; - bool_t xdr_stat; - - if (xdr_func == (xdrproc_t)xdr_void || xdr_ptr == NULL) - return (TRUE); - - memset(&databuf, 0, sizeof(databuf)); - memset(&wrapbuf, 0, sizeof(wrapbuf)); - - if (svc == RPCSEC_GSS_SVC_INTEGRITY) { - /* Decode databody_integ. */ - if (!xdr_rpc_gss_buf(xdrs, &databuf, (u_int)-1)) { - LIBTIRPC_DEBUG(1, ("xdr_rpc_gss_unwrap_data: decode databody_integ failed")); - return (FALSE); - } - /* Decode checksum. */ - if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (u_int)-1)) { - gss_release_buffer(&min_stat, &databuf); - LIBTIRPC_DEBUG(1, ("xdr_rpc_gss_unwrap_data: decode checksum failed")); - return (FALSE); - } - /* Verify checksum and QOP. */ - maj_stat = gss_verify_mic(&min_stat, ctx, &databuf, - &wrapbuf, &qop_state); - gss_release_buffer(&min_stat, &wrapbuf); - - if (maj_stat != GSS_S_COMPLETE || qop_state != qop) { - gss_release_buffer(&min_stat, &databuf); - gss_log_status("xdr_rpc_gss_unwrap_data: gss_verify_mic", - maj_stat, min_stat); - return (FALSE); - } - } - else if (svc == RPCSEC_GSS_SVC_PRIVACY) { - /* Decode databody_priv. */ - if (!xdr_rpc_gss_buf(xdrs, &wrapbuf, (u_int)-1)) { - LIBTIRPC_DEBUG(1, ("xdr_rpc_gss_unwrap_data: decode databody_priv failed")); - return (FALSE); - } - /* Decrypt databody. */ - maj_stat = gss_unwrap(&min_stat, ctx, &wrapbuf, &databuf, - &conf_state, &qop_state); - - gss_release_buffer(&min_stat, &wrapbuf); - - /* Verify encryption and QOP. */ - if (maj_stat != GSS_S_COMPLETE || qop_state != qop || - conf_state != TRUE) { - gss_release_buffer(&min_stat, &databuf); - gss_log_status("xdr_rpc_gss_unwrap_data: gss_unwrap", - maj_stat, min_stat); - return (FALSE); - } - } - /* Decode rpc_gss_data_t (sequence number + arguments). */ - xdrmem_create(&tmpxdrs, databuf.value, databuf.length, XDR_DECODE); - xdr_stat = (xdr_u_int(&tmpxdrs, &seq_num) && - (*xdr_func)(&tmpxdrs, xdr_ptr)); - XDR_DESTROY(&tmpxdrs); - gss_release_buffer(&min_stat, &databuf); - - /* Verify sequence number. */ - if (xdr_stat == TRUE && seq_num != seq) { - LIBTIRPC_DEBUG(1, - ("xdr_rpc_gss_unwrap_data: wrong sequence number in databody")); - return (FALSE); - } - return (xdr_stat); -} - -bool_t -xdr_rpc_gss_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, - gss_ctx_id_t ctx, gss_qop_t qop, - rpc_gss_svc_t svc, u_int seq) -{ - switch (xdrs->x_op) { - - case XDR_ENCODE: - return (xdr_rpc_gss_wrap_data(xdrs, xdr_func, xdr_ptr, - ctx, qop, svc, seq)); - case XDR_DECODE: - return (xdr_rpc_gss_unwrap_data(xdrs, xdr_func, xdr_ptr, - ctx, qop,svc, seq)); - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -void -gss_log_debug(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vlibtirpc_log_dbg(2, fmt, ap); - va_end(ap); -} - -void -gss_log_status(char *m, OM_uint32 maj_stat, OM_uint32 min_stat) -{ - OM_uint32 min, maj; - gss_buffer_desc maj_msg, min_msg; - u_int32_t msg_ctx = 0; - - gss_display_status(&maj, maj_stat, GSS_C_GSS_CODE, GSS_C_NULL_OID, - &msg_ctx, &maj_msg); - gss_display_status(&min, min_stat, GSS_C_MECH_CODE, GSS_C_NULL_OID, - &msg_ctx, &min_msg); - - LIBTIRPC_DEBUG(1, ("%s: %s - %s", m, (char *)maj_msg.value, (char *)min_msg.value)); - - gss_release_buffer(&maj, &maj_msg); - gss_release_buffer(&min, &min_msg); -} - -void -gss_log_hexdump(const u_char *buf, int len, int offset) -{ - u_int i, j, jm; - int c; - - if (libtirpc_debug_level < 4 || log_stderr == 0) - return; - - fprintf(stderr, "\n"); - for (i = 0; i < len; i += 0x10) { - fprintf(stderr, " %04x: ", (u_int)(i + offset)); - jm = len - i; - jm = jm > 16 ? 16 : jm; - - for (j = 0; j < jm; j++) { - if ((j % 2) == 1) - fprintf(stderr, "%02x ", (u_int) buf[i+j]); - else - fprintf(stderr, "%02x", (u_int) buf[i+j]); - } - for (; j < 16; j++) { - if ((j % 2) == 1) printf(" "); - else fprintf(stderr, " "); - } - fprintf(stderr, " "); - - for (j = 0; j < jm; j++) { - c = buf[i+j]; - c = isprint(c) ? c : '.'; - fprintf(stderr, "%c", c); - } - fprintf(stderr, "\n"); - } -} - diff --git a/libtirpc-1.3.1/src/authunix_prot.c b/libtirpc-1.3.1/src/authunix_prot.c deleted file mode 100644 index 0a04336..0000000 --- a/libtirpc-1.3.1/src/authunix_prot.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * authunix_prot.c - * XDR for UNIX style authentication parameters for RPC - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -#include -#include -#include -#include - -/* - * XDR for unix authentication parameters. - */ -bool_t -xdr_authunix_parms(xdrs, p) - XDR *xdrs; - struct authunix_parms *p; -{ - - assert(xdrs != NULL); - assert(p != NULL); - - if (xdr_u_long(xdrs, &(p->aup_time)) - && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_u_int(xdrs, &(p->aup_uid)) - && xdr_u_int(xdrs, &(p->aup_gid)) - && xdr_array(xdrs, (caddr_t *)&(p->aup_gids), - &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { - return (TRUE); - } - return (FALSE); -} diff --git a/libtirpc-1.3.1/src/binddynport.c b/libtirpc-1.3.1/src/binddynport.c deleted file mode 100644 index 062629a..0000000 --- a/libtirpc-1.3.1/src/binddynport.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2018, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "reentrant.h" -#include "rpc_com.h" - -extern pthread_mutex_t port_lock; - -/* - * Dynamic port range as defined in RFC 6335 Section 6. - * This range avoids all IANA-assigned service port - * numbers. - */ -enum { - LOWPORT = 49152, - ENDPORT = 65534, - NPORTS = ENDPORT - LOWPORT + 1, -}; - -/* - * Bind a socket to a dynamically-assigned IP port. - * - * @fd is an open but unbound socket. - * - * On each call, a port number is chosen at random from - * within the dynamic/private port range, even if the - * caller has CAP_NET_ADMIN_BIND. - * - * Returns 0 on success, -1 on failure. errno may be - * set to a non-determinant value. - * - * This function is re-entrant. - */ -int __binddynport(int fd) -{ - struct sockaddr_storage ss; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - struct sockaddr_in *sin; - static unsigned int seed; - in_port_t port, *portp; - struct sockaddr *sap; - socklen_t salen; - int i, res; - - if (__rpc_sockisbound(fd)) - return 0; - - res = -1; - sap = (struct sockaddr *)(void *)&ss; - salen = sizeof(ss); - memset(sap, 0, salen); - - mutex_lock(&port_lock); - - if (getsockname(fd, sap, &salen) == -1) - goto out; - - switch (ss.ss_family) { - case AF_INET: - sin = (struct sockaddr_in *)(void *)&ss; - portp = &sin->sin_port; - salen = sizeof(struct sockaddr_in); - break; -#ifdef INET6 - case AF_INET6: - sin6 = (struct sockaddr_in6 *)(void *)&ss; - portp = &sin6->sin6_port; - salen = sizeof(struct sockaddr_in6); - break; -#endif - default: - goto out; - } - - if (!seed) { - struct timeval tv; - - gettimeofday(&tv, NULL); - seed = tv.tv_usec * getpid(); - } - port = (rand_r(&seed) % NPORTS) + LOWPORT; - for (i = 0; i < NPORTS; ++i) { - *portp = htons(port++); - res = bind(fd, sap, salen); - if (res >= 0) { - res = 0; - break; - } - if (errno != EADDRINUSE) - break; - if (port > ENDPORT) - port = LOWPORT; - } - -out: - mutex_unlock(&port_lock); - return res; -} diff --git a/libtirpc-1.3.1/src/bindresvport.c b/libtirpc-1.3.1/src/bindresvport.c deleted file mode 100644 index ef9b345..0000000 --- a/libtirpc-1.3.1/src/bindresvport.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * Copyright (c) 1987 by Sun Microsystems, Inc. - * - * Portions Copyright(C) 1996, Jason Downs. All rights reserved. - */ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -extern pthread_mutex_t port_lock; - -/* - * Bind a socket to a privileged IP port - */ -int -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; -{ - return bindresvport_sa(sd, (struct sockaddr *)sin); -} - -#ifdef __linux__ - -#define STARTPORT 600 -#define LOWPORT 512 -#define ENDPORT (IPPORT_RESERVED - 1) -#define NPORTS (ENDPORT - STARTPORT + 1) - -/* - * Read the file /etc/bindresvport.blacklist, so that we don't bind - * to these ports. - */ - -static int blacklist_read; -static int *list; -static int list_size = 0; - -static void -load_blacklist (void) -{ - FILE *fp; - char *buf = NULL; - size_t buflen = 0; - int size = 0, ptr = 0; - - blacklist_read = 1; - - fp = fopen ("/etc/bindresvport.blacklist", "r"); - if (NULL == fp) - return; - - while (!feof (fp)) - { - unsigned long port; - char *tmp, *cp; - ssize_t n = getline (&buf, &buflen, fp); - if (n < 1) - break; - - cp = buf; - tmp = strchr (cp, '#'); /* remove comments */ - if (tmp) - *tmp = '\0'; - while (isspace ((int)*cp)) /* remove spaces and tabs */ - ++cp; - if (*cp == '\0') /* ignore empty lines */ - continue; - if (cp[strlen (cp) - 1] == '\n') - cp[strlen (cp) - 1] = '\0'; - - port = strtoul (cp, &tmp, 0); - while (isspace(*tmp)) - ++tmp; - if (*tmp != '\0' || (port == ULONG_MAX && errno == ERANGE)) - continue; - - /* Don't bother with out-of-range ports */ - if (port < LOWPORT || port > ENDPORT) - continue; - - if (ptr >= size) - { - size += 10; - list = realloc (list, size * sizeof (int)); - if (list == NULL) - { - free (buf); - return; - } - } - - list[ptr++] = port; - } - - fclose (fp); - - if (buf) - free (buf); - - list_size = ptr; -} - -int -bindresvport_sa(sd, sa) - int sd; - struct sockaddr *sa; -{ - int res, af; - struct sockaddr_storage myaddr; - struct sockaddr_in *sin; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - u_int16_t *portp; - static u_int16_t port; - static short startport = STARTPORT; - socklen_t salen; - int nports; - int endport = ENDPORT; - int i; - - if (!blacklist_read) - load_blacklist(); - - mutex_lock(&port_lock); - nports = ENDPORT - startport + 1; - - if (sa == NULL) { - salen = sizeof(myaddr); - sa = (struct sockaddr *)&myaddr; - - if (getsockname(sd, (struct sockaddr *)&myaddr, &salen) == -1) { - mutex_unlock(&port_lock); - return -1; /* errno is correctly set */ - } - - af = myaddr.ss_family; - } else - af = sa->sa_family; - - switch (af) { - case AF_INET: - sin = (struct sockaddr_in *)sa; - salen = sizeof(struct sockaddr_in); - port = ntohs(sin->sin_port); - portp = &sin->sin_port; - break; -#ifdef INET6 - case AF_INET6: - sin6 = (struct sockaddr_in6 *)sa; - salen = sizeof(struct sockaddr_in6); - port = ntohs(sin6->sin6_port); - portp = &sin6->sin6_port; - break; -#endif - default: - errno = EPFNOSUPPORT; - mutex_unlock(&port_lock); - return (-1); - } - sa->sa_family = af; - - if (port == 0) { - port = (getpid() % NPORTS) + STARTPORT; - } - res = -1; - errno = EADDRINUSE; - again: - for (i = 0; i < nports; ++i) { - int j; - - /* Check if this port is not blacklisted. */ - for (j = 0; j < list_size; j++) - if (port == list[j]) - goto try_next_port; - - *portp = htons(port); - res = bind(sd, sa, salen); - if (res >= 0 || errno != EADDRINUSE) - break; - -try_next_port: - if (++port > endport) - port = startport; - } - if (i == nports && startport != LOWPORT) { - startport = LOWPORT; - endport = STARTPORT - 1; - nports = STARTPORT - LOWPORT; - port = LOWPORT + port % (STARTPORT - LOWPORT); - goto again; - } - mutex_unlock(&port_lock); - - return (res); -} -#else - -#define IP_PORTRANGE 19 -#define IP_PORTRANGE_LOW 2 - -/* - * Bind a socket to a privileged IP port - */ -int -bindresvport_sa(sd, sa) - int sd; - struct sockaddr *sa; -{ - int old, error, af; - struct sockaddr_storage myaddr; - struct sockaddr_in *sin; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - int proto, portrange, portlow; - u_int16_t *portp; - socklen_t salen; - - if (sa == NULL) { - salen = sizeof(myaddr); - sa = (struct sockaddr *)&myaddr; - - if (getsockname(sd, sa, &salen) == -1) - return -1; /* errno is correctly set */ - - af = sa->sa_family; - memset(sa, 0, salen); - } else - af = sa->sa_family; - - switch (af) { - case AF_INET: - proto = IPPROTO_IP; - portrange = IP_PORTRANGE; - portlow = IP_PORTRANGE_LOW; - sin = (struct sockaddr_in *)sa; - salen = sizeof(struct sockaddr_in); - portp = &sin->sin_port; - break; -#ifdef INET6 - case AF_INET6: - proto = IPPROTO_IPV6; - portrange = IPV6_PORTRANGE; - portlow = IPV6_PORTRANGE_LOW; - sin6 = (struct sockaddr_in6 *)sa; - salen = sizeof(struct sockaddr_in6); - portp = &sin6->sin6_port; - break; -#endif - default: - errno = EPFNOSUPPORT; - return (-1); - } - sa->sa_family = af; - - if (*portp == 0) { - socklen_t oldlen = sizeof(old); - - error = getsockopt(sd, proto, portrange, &old, &oldlen); - if (error < 0) - return (error); - - error = setsockopt(sd, proto, portrange, &portlow, - sizeof(portlow)); - if (error < 0) - return (error); - } - - error = bind(sd, sa, salen); - - if (*portp == 0) { - int saved_errno = errno; - - if (error < 0) { - if (setsockopt(sd, proto, portrange, &old, - sizeof(old)) < 0) - errno = saved_errno; - return (error); - } - - if (sa != (struct sockaddr *)&myaddr) { - /* Hmm, what did the kernel assign? */ - if (getsockname(sd, sa, &salen) < 0) - errno = saved_errno; - return (error); - } - } - return (error); -} -#endif diff --git a/libtirpc-1.3.1/src/clnt_bcast.c b/libtirpc-1.3.1/src/clnt_bcast.c deleted file mode 100644 index 2ad6c89..0000000 --- a/libtirpc-1.3.1/src/clnt_bcast.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * clnt_bcast.c - * Client interface to broadcast service. - * - * Copyright (C) 1988, Sun Microsystems, Inc. - * - * The following is kludged-up support for simple rpc broadcasts. - * Someday a large, complicated system will replace these routines. - */ -#include -#include -#include - -#include -#include -#include -#include -#include -#ifdef PORTMAP -#include -#include -#include -#endif /* PORTMAP */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rpc_com.h" -#include "debug.h" - -#define MAXBCAST 20 /* Max no of broadcasting transports */ -#define INITTIME 4000 /* Time to wait initially */ -#define WAITTIME 8000 /* Maximum time to wait */ - -# define POLLRDNORM 0x040 /* Normal data may be read. */ -# define POLLRDBAND 0x080 /* Priority data may be read. */ - - - -/* - * If nettype is NULL, it broadcasts on all the available - * datagram_n transports. May potentially lead to broadacst storms - * and hence should be used with caution, care and courage. - * - * The current parameter xdr packet size is limited by the max tsdu - * size of the transport. If the max tsdu size of any transport is - * smaller than the parameter xdr packet, then broadcast is not - * sent on that transport. - * - * Also, the packet size should be less the packet size of - * the data link layer (for ethernet it is 1400 bytes). There is - * no easy way to find out the max size of the data link layer and - * we are assuming that the args would be smaller than that. - * - * The result size has to be smaller than the transport tsdu size. - * - * If PORTMAP has been defined, we send two packets for UDP, one for - * rpcbind and one for portmap. For those machines which support - * both rpcbind and portmap, it will cause them to reply twice, and - * also here it will get two responses ... inefficient and clumsy. - */ - -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_FIRST(head) ((head)->tqh_first) - - -struct broadif { - int index; - struct sockaddr_storage broadaddr; - TAILQ_ENTRY(broadif) link; -}; - -typedef TAILQ_HEAD(, broadif) broadlist_t; - -int __rpc_getbroadifs(int, int, int, broadlist_t *); -void __rpc_freebroadifs(broadlist_t *); -int __rpc_broadenable(int, int, struct broadif *); - -int __rpc_lowvers = 0; - -int -__rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list) -{ - int count = 0; - struct broadif *bip; - struct ifaddrs *ifap, *ifp; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - struct sockaddr_in *sin; - struct addrinfo hints, *res; - - if (getifaddrs(&ifp) < 0) - return 0; - - memset(&hints, 0, sizeof hints); - - hints.ai_family = af; - hints.ai_protocol = proto; - hints.ai_socktype = socktype; - - if (getaddrinfo(NULL, "sunrpc", &hints, &res) != 0) - return 0; - - for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { - if (ifap->ifa_addr == NULL || /* happens for eg tuntap devices */ - ifap->ifa_addr->sa_family != af || - !(ifap->ifa_flags & IFF_UP)) - continue; - bip = (struct broadif *)malloc(sizeof *bip); - if (bip == NULL) - break; - bip->index = if_nametoindex(ifap->ifa_name); - if ( -#ifdef INET6 - af != AF_INET6 && -#endif - (ifap->ifa_flags & IFF_BROADCAST) && - ifap->ifa_broadaddr) { - /* memcpy(&bip->broadaddr, ifap->ifa_broadaddr, - (size_t)ifap->ifa_broadaddr->sa_len);*/ - memcpy(&bip->broadaddr, ifap->ifa_broadaddr, - sizeof(bip->broadaddr)); - sin = (struct sockaddr_in *)(void *)&bip->broadaddr; - sin->sin_port = - ((struct sockaddr_in *) - (void *)res->ai_addr)->sin_port; - } else -#ifdef INET6 - if (af == AF_INET6 && (ifap->ifa_flags & IFF_MULTICAST)) { - sin6 = (struct sockaddr_in6 *)(void *)&bip->broadaddr; - inet_pton(af, RPCB_MULTICAST_ADDR, &sin6->sin6_addr); - sin6->sin6_family = af; - sin6->sin6_port = - ((struct sockaddr_in6 *) - (void *)res->ai_addr)->sin6_port; - sin6->sin6_scope_id = bip->index; - } else -#endif - { - free(bip); - continue; - } - TAILQ_INSERT_TAIL(list, bip, link); - count++; - } - freeifaddrs(ifp); - freeaddrinfo(res); - - return count; -} - -void -__rpc_freebroadifs(broadlist_t *list) -{ - struct broadif *bip, *next; - - bip = TAILQ_FIRST(list); - - while (bip != NULL) { - next = TAILQ_NEXT(bip, link); - free(bip); - bip = next; - } -} - -int -/*ARGSUSED*/ -__rpc_broadenable(int af, int s, struct broadif *bip) -{ - int o = 1; - -#if 0 - if (af == AF_INET6) { - fprintf(stderr, "set v6 multicast if to %d\n", bip->index); - if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index, - sizeof bip->index) < 0) - return -1; - } else -#endif - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o, sizeof o) < 0) - return -1; - - return 0; -} - -/* - * Some rpcbind implementations use an IPv6 socket to serve both - * IPv4 and IPv6 messages, but neglect to check for the caller's - * address family when sending broadcast replies. These rpcbind - * implementations return an IPv6 address in reply to an IPv4 - * broadcast. We can either ignore them, or try to patch them up. - */ -static struct netbuf * -__ipv6v4_fixup(struct sockaddr_storage *ss, const char *uaddr) -{ - struct sockaddr_in sin; - struct netbuf *np; - - /* ss is the remote rpcbind server's address */ - if (ss->ss_family != AF_INET) - return NULL; - memcpy(&sin, ss, sizeof(sin)); - - np = __rpc_uaddr2taddr_af(AF_INET6, uaddr); - if (np == NULL) - return NULL; - - /* Overwrite the port with that of the service we - * wanted to talk to. */ - sin.sin_port = ((struct sockaddr_in6 *) np)->sin6_port; - - /* We know netbuf holds a sockaddr_in6, so it can easily - * hold a sockaddr_in as well. */ - memcpy(np->buf, &sin, sizeof(sin)); - np->len = sizeof(sin); - - return np; -} - -enum clnt_stat -rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, - eachresult, inittime, waittime, nettype) - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ - int inittime; /* how long to wait initially */ - int waittime; /* maximum time to wait */ - const char *nettype; /* transport type */ -{ - enum clnt_stat stat = RPC_SUCCESS; /* Return status */ - XDR xdr_stream; /* XDR stream */ - XDR *xdrs = &xdr_stream; - struct rpc_msg msg; /* RPC message */ - struct timeval t; - char *outbuf = NULL; /* Broadcast msg buffer */ - char *inbuf = NULL; /* Reply buf */ - int inlen; - u_int maxbufsize = 0; - AUTH *sys_auth = authunix_create_default(); - int i; - void *handle; - char uaddress[1024]; /* A self imposed limit */ - char *uaddrp = uaddress; - int pmap_reply_flag; /* reply recvd from PORTMAP */ - /* An array of all the suitable broadcast transports */ - struct { - int fd; /* File descriptor */ - int af; - int proto; - struct netconfig *nconf; /* Netconfig structure */ - u_int asize; /* Size of the addr buf */ - u_int dsize; /* Size of the data buf */ - struct sockaddr_storage raddr; /* Remote address */ - broadlist_t nal; - } fdlist[MAXBCAST]; - struct pollfd pfd[MAXBCAST]; - size_t fdlistno = 0; - struct r_rpcb_rmtcallargs barg; /* Remote arguments */ - struct r_rpcb_rmtcallres bres; /* Remote results */ - size_t outlen; - struct netconfig *nconf; - int msec; - int pollretval; - int fds_found; - -#ifdef PORTMAP - size_t outlen_pmap = 0; - u_long port; /* Remote port number */ - int pmap_flag = 0; /* UDP exists ? */ - char *outbuf_pmap = NULL; - struct rmtcallargs barg_pmap; /* Remote arguments */ - struct rmtcallres bres_pmap; /* Remote results */ - u_int udpbufsz = 0; -#endif /* PORTMAP */ - - if (sys_auth == NULL) { - return (RPC_SYSTEMERROR); - } - /* - * initialization: create a fd, a broadcast address, and send the - * request on the broadcast transport. - * Listen on all of them and on replies, call the user supplied - * function. - */ - - if (nettype == NULL) - nettype = "datagram_n"; - if ((handle = __rpc_setconf(nettype)) == NULL) { - AUTH_DESTROY(sys_auth); - return (RPC_UNKNOWNPROTO); - } - while ((nconf = __rpc_getconf(handle)) != NULL) { - int fd; - struct __rpc_sockinfo si; - - if (nconf->nc_semantics != NC_TPI_CLTS) - continue; - if (fdlistno >= MAXBCAST) - break; /* No more slots available */ - if (!__rpc_nconf2sockinfo(nconf, &si)) - continue; - - TAILQ_INIT(&fdlist[fdlistno].nal); - if (__rpc_getbroadifs(si.si_af, si.si_proto, si.si_socktype, - &fdlist[fdlistno].nal) == 0) - continue; - - fd = socket(si.si_af, si.si_socktype, si.si_proto); - if (fd < 0) { - stat = RPC_CANTSEND; - continue; - } - fdlist[fdlistno].af = si.si_af; - fdlist[fdlistno].proto = si.si_proto; - fdlist[fdlistno].fd = fd; - fdlist[fdlistno].nconf = nconf; - fdlist[fdlistno].asize = __rpc_get_a_size(si.si_af); - pfd[fdlistno].events = POLLIN | POLLPRI | - POLLRDNORM | POLLRDBAND; - pfd[fdlistno].fd = fdlist[fdlistno].fd = fd; - fdlist[fdlistno].dsize = __rpc_get_t_size(si.si_af, si.si_proto, - 0); - - if (maxbufsize <= fdlist[fdlistno].dsize) - maxbufsize = fdlist[fdlistno].dsize; - -#ifdef PORTMAP - if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) { - udpbufsz = fdlist[fdlistno].dsize; - if ((outbuf_pmap = malloc(udpbufsz)) == NULL) { - close(fd); - stat = RPC_SYSTEMERROR; - goto done_broad; - } - pmap_flag = 1; - } -#endif /* PORTMAP */ - fdlistno++; - } - - if (fdlistno == 0) { - if (stat == RPC_SUCCESS) - stat = RPC_UNKNOWNPROTO; - goto done_broad; - } - if (maxbufsize == 0) { - if (stat == RPC_SUCCESS) - stat = RPC_CANTSEND; - goto done_broad; - } - inbuf = malloc(maxbufsize); - outbuf = malloc(maxbufsize); - if ((inbuf == NULL) || (outbuf == NULL)) { - stat = RPC_SYSTEMERROR; - goto done_broad; - } - - /* Serialize all the arguments which have to be sent */ - (void) gettimeofday(&t, NULL); - msg.rm_xid = __RPC_GETXID(&t); - msg.rm_direction = CALL; - msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - msg.rm_call.cb_prog = RPCBPROG; - msg.rm_call.cb_vers = RPCBVERS; - msg.rm_call.cb_proc = RPCBPROC_CALLIT; - barg.prog = prog; - barg.vers = vers; - barg.proc = proc; - barg.args.args_val = argsp; - barg.xdr_args = xargs; - bres.addr = uaddrp; - bres.results.results_val = resultsp; - bres.xdr_res = xresults; - msg.rm_call.cb_cred = sys_auth->ah_cred; - msg.rm_call.cb_verf = sys_auth->ah_verf; - xdrmem_create(xdrs, outbuf, maxbufsize, XDR_ENCODE); - if ((!xdr_callmsg(xdrs, &msg)) || - (!xdr_rpcb_rmtcallargs(xdrs, - (struct rpcb_rmtcallargs *)(void *)&barg))) { - stat = RPC_CANTENCODEARGS; - goto done_broad; - } - outlen = xdr_getpos(xdrs); - xdr_destroy(xdrs); - -#ifdef PORTMAP - /* Prepare the packet for version 2 PORTMAP */ - if (pmap_flag) { - msg.rm_xid++; /* One way to distinguish */ - msg.rm_call.cb_prog = PMAPPROG; - msg.rm_call.cb_vers = PMAPVERS; - msg.rm_call.cb_proc = PMAPPROC_CALLIT; - barg_pmap.prog = prog; - barg_pmap.vers = vers; - barg_pmap.proc = proc; - barg_pmap.args_ptr = argsp; - barg_pmap.xdr_args = xargs; - bres_pmap.port_ptr = &port; - bres_pmap.xdr_results = xresults; - bres_pmap.results_ptr = resultsp; - xdrmem_create(xdrs, outbuf_pmap, udpbufsz, XDR_ENCODE); - if ((! xdr_callmsg(xdrs, &msg)) || - (! xdr_rmtcall_args(xdrs, &barg_pmap))) { - stat = RPC_CANTENCODEARGS; - goto done_broad; - } - outlen_pmap = xdr_getpos(xdrs); - xdr_destroy(xdrs); - } -#endif /* PORTMAP */ - - /* - * Basic loop: broadcast the packets to transports which - * support data packets of size such that one can encode - * all the arguments. - * Wait a while for response(s). - * The response timeout grows larger per iteration. - */ - for (msec = inittime; msec <= waittime; msec += msec) { - struct broadif *bip; - - /* Broadcast all the packets now */ - for (i = 0; i < fdlistno; i++) { - if (fdlist[i].dsize < outlen) { - stat = RPC_CANTSEND; - continue; - } - for (bip = TAILQ_FIRST(&fdlist[i].nal); bip != NULL; - bip = TAILQ_NEXT(bip, link)) { - void *addr; - - addr = &bip->broadaddr; - - __rpc_broadenable(fdlist[i].af, fdlist[i].fd, - bip); - - /* - * Only use version 3 if lowvers is not set - */ - - if (!__rpc_lowvers) - if (sendto(fdlist[i].fd, outbuf, - outlen, 0, (struct sockaddr*)addr, - (size_t)fdlist[i].asize) != - outlen) { - LIBTIRPC_DEBUG(1, - ("rpc_broadcast_exp: sendto failed: errno %d", errno)); - warnx("rpc_broadcast_exp: cannot send broadcast packet"); - stat = RPC_CANTSEND; - continue; - }; - if (!__rpc_lowvers) - LIBTIRPC_DEBUG(3, ("rpc_broadcast_exp: Broadcast packet sent for %s\n", - fdlist[i].nconf->nc_netid)); -#ifdef PORTMAP - /* - * Send the version 2 packet also - * for UDP/IP - */ - if (pmap_flag && - fdlist[i].proto == IPPROTO_UDP) { - if (sendto(fdlist[i].fd, outbuf_pmap, - outlen_pmap, 0, addr, - (size_t)fdlist[i].asize) != - outlen_pmap) { - warnx("clnt_bcast: " - "Cannot send broadcast packet"); - stat = RPC_CANTSEND; - continue; - } - } - LIBTIRPC_DEBUG(3, ("rpc_broadcast_exp: PMAP Broadcast packet sent for %s\n", - fdlist[i].nconf->nc_netid)); -#endif /* PORTMAP */ - } - /* End for sending all packets on this transport */ - } /* End for sending on all transports */ - - if (eachresult == NULL) { - stat = RPC_SUCCESS; - goto done_broad; - } - - /* - * Get all the replies from these broadcast requests - */ - recv_again: - - switch (pollretval = poll(pfd, fdlistno, msec)) { - case 0: /* timed out */ - stat = RPC_TIMEDOUT; - continue; - case -1: /* some kind of error - we ignore it */ - goto recv_again; - } /* end of poll results switch */ - - for (i = fds_found = 0; - i < fdlistno && fds_found < pollretval; i++) { - bool_t done = FALSE; - - if (pfd[i].revents == 0) - continue; - else if (pfd[i].revents & POLLNVAL) { - /* - * Something bad has happened to this descri- - * ptor. We can cause _poll() to ignore - * it simply by using a negative fd. We do that - * rather than compacting the pfd[] and fdlist[] - * arrays. - */ - pfd[i].fd = -1; - fds_found++; - continue; - } else - fds_found++; - LIBTIRPC_DEBUG(3, ("rpc_broadcast_exp: response for %s\n", - fdlist[i].nconf->nc_netid)); - try_again: - inlen = recvfrom(fdlist[i].fd, inbuf, fdlist[i].dsize, - 0, (struct sockaddr *)(void *)&fdlist[i].raddr, - &fdlist[i].asize); - if (inlen < 0) { - if (errno == EINTR) - goto try_again; - warnx("clnt_bcast: Cannot receive reply to " - "broadcast"); - stat = RPC_CANTRECV; - continue; - } - if (inlen < sizeof (u_int32_t)) - continue; /* Drop that and go ahead */ - /* - * see if reply transaction id matches sent id. - * If so, decode the results. If return id is xid + 1 - * it was a PORTMAP reply - */ - if (*((u_int32_t *)(void *)(inbuf)) == - *((u_int32_t *)(void *)(outbuf))) { - pmap_reply_flag = 0; - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = - (caddr_t)(void *)&bres; - msg.acpted_rply.ar_results.proc = - (xdrproc_t)xdr_rpcb_rmtcallres; -#ifdef PORTMAP - } else if (pmap_flag && - *((u_int32_t *)(void *)(inbuf)) == - *((u_int32_t *)(void *)(outbuf_pmap))) { - pmap_reply_flag = 1; - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = - (caddr_t)(void *)&bres_pmap; - msg.acpted_rply.ar_results.proc = - (xdrproc_t)xdr_rmtcallres; -#endif /* PORTMAP */ - } else - continue; - xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); - if (xdr_replymsg(xdrs, &msg)) { - if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) && - (msg.acpted_rply.ar_stat == SUCCESS)) { - struct netbuf *np; -#ifdef PORTMAP - struct netbuf taddr; - struct sockaddr_in sin; - - if (pmap_flag && pmap_reply_flag) { - memcpy(&sin, &fdlist[i].raddr, sizeof(sin)); - sin.sin_port = htons((u_short)port); - memcpy(&fdlist[i].raddr, &sin, sizeof(sin)); - taddr.len = taddr.maxlen = - sizeof(fdlist[i].raddr); - taddr.buf = &fdlist[i].raddr; - done = (*eachresult)(resultsp, - &taddr, fdlist[i].nconf); - } else { -#endif /* PORTMAP */ - LIBTIRPC_DEBUG(3, ("rpc_broadcast_exp: uaddr %s\n", uaddrp)); - np = uaddr2taddr( - fdlist[i].nconf, uaddrp); - /* Some misguided rpcbind implemenations - * seem to return an IPv6 uaddr in IPv4 - * responses. */ - if (np == NULL) - np = __ipv6v4_fixup( - &fdlist[i].raddr, - uaddrp); - if (np != NULL) { - done = (*eachresult)(resultsp, - np, fdlist[i].nconf); - free(np); - } -#ifdef PORTMAP - } -#endif /* PORTMAP */ - } - /* otherwise, we just ignore the errors ... */ - } - /* else some kind of deserialization problem ... */ - - xdrs->x_op = XDR_FREE; - msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void; - (void) xdr_replymsg(xdrs, &msg); - (void) (*xresults)(xdrs, resultsp); - XDR_DESTROY(xdrs); - if (done) { - stat = RPC_SUCCESS; - goto done_broad; - } else { - goto recv_again; - } - } /* The recv for loop */ - } /* The giant for loop */ - -done_broad: - if (inbuf) - (void) free(inbuf); - if (outbuf) - (void) free(outbuf); -#ifdef PORTMAP - if (outbuf_pmap) - (void) free(outbuf_pmap); -#endif /* PORTMAP */ - for (i = 0; i < fdlistno; i++) { - (void)close(fdlist[i].fd); - __rpc_freebroadifs(&fdlist[i].nal); - } - AUTH_DESTROY(sys_auth); - (void) __rpc_endconf(handle); - - return (stat); -} - - -enum clnt_stat -rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, - eachresult, nettype) - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ - const char *nettype; /* transport type */ -{ - enum clnt_stat dummy; - - dummy = rpc_broadcast_exp(prog, vers, proc, xargs, argsp, - xresults, resultsp, eachresult, - INITTIME, WAITTIME, nettype); - return (dummy); -} diff --git a/libtirpc-1.3.1/src/clnt_dg.c b/libtirpc-1.3.1/src/clnt_dg.c deleted file mode 100644 index abc09f1..0000000 --- a/libtirpc-1.3.1/src/clnt_dg.c +++ /dev/null @@ -1,788 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * Implements a connectionless client side RPC. - */ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_com.h" -#include "clnt_fd_locks.h" - -#ifdef IP_RECVERR -#include -#include -#include -#endif - - -#define MAX_DEFAULT_FDS 20000 - -static struct clnt_ops *clnt_dg_ops(void); -static bool_t time_not_ok(struct timeval *); -static enum clnt_stat clnt_dg_call(CLIENT *, rpcproc_t, xdrproc_t, void *, - xdrproc_t, void *, struct timeval); -static void clnt_dg_geterr(CLIENT *, struct rpc_err *); -static bool_t clnt_dg_freeres(CLIENT *, xdrproc_t, void *); -static void clnt_dg_abort(CLIENT *); -static bool_t clnt_dg_control(CLIENT *, u_int, void *); -static void clnt_dg_destroy(CLIENT *); - - -/* - * This machinery implements per-fd locks for MT-safety. It is not - * sufficient to do per-CLIENT handle locks for MT-safety because a - * user may create more than one CLIENT handle with the same fd behind - * it. - * - * We keep track of a list of per-fd locks, protected by the clnt_fd_lock - * mutex. Each per-fd lock consists of a predicate indicating whether is - * active or not: fd_lock->active == TRUE => a call is active on some - * CLIENT handle created for that fd. Each fd predicate is guarded by a - * condition variable so that the global mutex can be unlocked while - * waiting for the predicate to change. - * - * The current implementation holds locks across the entire RPC and reply, - * including retransmissions. Yes, this is silly, and as soon as this - * code is proven to work, this should be the first thing fixed. One step - * at a time. - */ -static fd_locks_t *dg_fd_locks; -extern mutex_t clnt_fd_lock; -#define release_fd_lock(fd_lock, mask) { \ - mutex_lock(&clnt_fd_lock); \ - fd_lock->active = FALSE; \ - mutex_unlock(&clnt_fd_lock); \ - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); \ - cond_signal(&fd_lock->cv); \ -} - -static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory"; - -/* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd_locks, dg_cv */ - -/* - * Private data kept per client handle - */ -struct cu_data { - int cu_fd; /* connections fd */ - fd_lock_t *cu_fd_lock; - bool_t cu_closeit; /* opened by library */ - struct sockaddr_storage cu_raddr; /* remote address */ - int cu_rlen; - struct timeval cu_wait; /* retransmit interval */ - struct timeval cu_total; /* total time for the call */ - struct rpc_err cu_error; - XDR cu_outxdrs; - u_int cu_xdrpos; - u_int cu_sendsz; /* send size */ - char *cu_outbuf; - u_int cu_recvsz; /* recv size */ - int cu_async; - int cu_connect; /* Use connect(). */ - int cu_connected; /* Have done connect(). */ - char cu_inbuf[1]; -}; - -/* - * Connection less client creation returns with client handle parameters. - * Default options are set, which the user can change using clnt_control(). - * fd should be open and bound. - * NB: The rpch->cl_auth is initialized to null authentication. - * Caller may wish to set this something more useful. - * - * sendsz and recvsz are the maximum allowable packet sizes that can be - * sent and received. Normally they are the same, but they can be - * changed to improve the program efficiency and buffer allocation. - * If they are 0, use the transport default. - * - * If svcaddr is NULL, returns NULL. - */ -CLIENT * -clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz) - int fd; /* open file descriptor */ - const struct netbuf *svcaddr; /* servers address */ - rpcprog_t program; /* program number */ - rpcvers_t version; /* version number */ - u_int sendsz; /* buffer recv size */ - u_int recvsz; /* buffer send size */ -{ - CLIENT *cl = NULL; /* client handle */ - struct cu_data *cu = NULL; /* private data */ - struct timeval now; - struct rpc_msg call_msg; - sigset_t mask; - sigset_t newmask; - struct __rpc_sockinfo si; - int one = 1; - fd_lock_t *fd_lock; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (dg_fd_locks == (fd_locks_t *) NULL) { - dg_fd_locks = fd_locks_init(); - if (dg_fd_locks == (fd_locks_t *) NULL) { - goto err1; - } - } - fd_lock = fd_lock_create(fd, dg_fd_locks); - if (fd_lock == (fd_lock_t *) NULL) - goto err1; - - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - - if (svcaddr == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return (NULL); - } - - if (!__rpc_fd2sockinfo(fd, &si)) { - rpc_createerr.cf_stat = RPC_TLIERROR; - rpc_createerr.cf_error.re_errno = 0; - return (NULL); - } - /* - * Find the receive and the send size - */ - sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz); - recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); - if ((sendsz == 0) || (recvsz == 0)) { - rpc_createerr.cf_stat = RPC_TLIERROR; /* XXX */ - rpc_createerr.cf_error.re_errno = 0; - return (NULL); - } - - if ((cl = mem_alloc(sizeof (CLIENT))) == NULL) - goto err1; - /* - * Should be multiple of 4 for XDR. - */ - sendsz = ((sendsz + 3) / 4) * 4; - recvsz = ((recvsz + 3) / 4) * 4; - cu = mem_alloc(sizeof (*cu) + sendsz + recvsz); - if (cu == NULL) - goto err1; - (void) memcpy(&cu->cu_raddr, svcaddr->buf, (size_t)svcaddr->len); - cu->cu_rlen = svcaddr->len; - cu->cu_outbuf = &cu->cu_inbuf[recvsz]; - /* Other values can also be set through clnt_control() */ - cu->cu_wait.tv_sec = 15; /* heuristically chosen */ - cu->cu_wait.tv_usec = 0; - cu->cu_total.tv_sec = -1; - cu->cu_total.tv_usec = -1; - cu->cu_sendsz = sendsz; - cu->cu_recvsz = recvsz; - cu->cu_async = FALSE; - cu->cu_connect = FALSE; - cu->cu_connected = FALSE; - (void) gettimeofday(&now, NULL); - call_msg.rm_xid = __RPC_GETXID(&now); - call_msg.rm_call.cb_prog = program; - call_msg.rm_call.cb_vers = version; - xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); - if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { - rpc_createerr.cf_stat = RPC_CANTENCODEARGS; /* XXX */ - rpc_createerr.cf_error.re_errno = 0; - goto err2; - } - cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); - - /* XXX fvdl - do we still want this? */ -#if 0 - (void)bindresvport_sa(fd, (struct sockaddr *)svcaddr->buf); -#endif -#ifdef IP_RECVERR - { - int on = 1; - setsockopt(fd, SOL_IP, IP_RECVERR, &on, sizeof(on)); - } -#endif - ioctl(fd, FIONBIO, (char *)(void *)&one); - /* - * By default, closeit is always FALSE. It is users responsibility - * to do a close on it, else the user may use clnt_control - * to let clnt_destroy do it for him/her. - */ - cu->cu_closeit = FALSE; - cu->cu_fd = fd; - cu->cu_fd_lock = fd_lock; - cl->cl_ops = clnt_dg_ops(); - cl->cl_private = (caddr_t)(void *)cu; - cl->cl_auth = authnone_create(); - cl->cl_tp = NULL; - cl->cl_netid = NULL; - - return (cl); -err1: - warnx(mem_err_clnt_dg); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; -err2: - if (cl) { - mem_free(cl, sizeof (CLIENT)); - if (cu) - mem_free(cu, sizeof (*cu) + sendsz + recvsz); - } - return (NULL); -} - -static enum clnt_stat -clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) - CLIENT *cl; /* client handle */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - void *argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - void *resultsp; /* pointer to results */ - struct timeval utimeout; /* seconds to wait before giving up */ -{ - struct cu_data *cu = (struct cu_data *)cl->cl_private; - XDR *xdrs; - size_t outlen = 0; - struct rpc_msg reply_msg; - XDR reply_xdrs; - bool_t ok; - int nrefreshes = 2; /* number of times to refresh cred */ - struct timeval timeout; - struct pollfd fd; - int total_time, nextsend_time, tv=0; - struct sockaddr *sa; - sigset_t mask; - sigset_t newmask; - socklen_t salen; - ssize_t recvlen = 0; - u_int32_t xid, inval, outval; - - outlen = 0; - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (cu->cu_fd_lock->active) - cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); - cu->cu_fd_lock->active = TRUE; - mutex_unlock(&clnt_fd_lock); - if (cu->cu_total.tv_usec == -1) { - timeout = utimeout; /* use supplied timeout */ - } else { - timeout = cu->cu_total; /* use default timeout */ - } - total_time = timeout.tv_sec * 1000 + timeout.tv_usec / 1000; - nextsend_time = cu->cu_wait.tv_sec * 1000 + cu->cu_wait.tv_usec / 1000; - - if (cu->cu_connect && !cu->cu_connected) { - if (connect(cu->cu_fd, (struct sockaddr *)&cu->cu_raddr, - cu->cu_rlen) < 0) { - cu->cu_error.re_errno = errno; - cu->cu_error.re_status = RPC_CANTSEND; - goto out; - } - cu->cu_connected = 1; - } - if (cu->cu_connected) { - sa = NULL; - salen = 0; - } else { - sa = (struct sockaddr *)&cu->cu_raddr; - salen = cu->cu_rlen; - } - - /* Clean up in case the last call ended in a longjmp(3) call. */ -call_again: - xdrs = &(cu->cu_outxdrs); - if (cu->cu_async == TRUE && xargs == NULL) - goto get_reply; - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, cu->cu_xdrpos); - /* - * the transaction is the first thing in the out buffer - * XXX Yes, and it's in network byte order, so we should to - * be careful when we increment it, shouldn't we. - */ - xid = ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf)); - xid++; - *(u_int32_t *)(void *)(cu->cu_outbuf) = htonl(xid); - - if ((! XDR_PUTINT32(xdrs, (int32_t *)&proc)) || - (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || - (! AUTH_WRAP(cl->cl_auth, xdrs, xargs, argsp))) { - cu->cu_error.re_status = RPC_CANTENCODEARGS; - goto out; - } - outlen = (size_t)XDR_GETPOS(xdrs); - - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - cu->cu_error.re_status = RPC_TIMEDOUT; - goto out; - } - -send_again: - if (total_time <= 0) { - cu->cu_error.re_status = RPC_TIMEDOUT; - goto out; - } - nextsend_time = cu->cu_wait.tv_sec * 1000 + cu->cu_wait.tv_usec / 1000; - if (sendto(cu->cu_fd, cu->cu_outbuf, outlen, 0, sa, salen) != outlen) { - cu->cu_error.re_errno = errno; - cu->cu_error.re_status = RPC_CANTSEND; - goto out; - } - -get_reply: - - /* - * sub-optimal code appears here because we have - * some clock time to spare while the packets are in flight. - * (We assume that this is actually only executed once.) - */ - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - - fd.fd = cu->cu_fd; - fd.events = POLLIN; - fd.revents = 0; - while (total_time > 0) { - tv = total_time < nextsend_time ? total_time : nextsend_time; - switch (poll(&fd, 1, tv)) { - case 0: - total_time -= tv; - goto send_again; - case -1: - if (errno == EINTR) - continue; - cu->cu_error.re_status = RPC_CANTRECV; - cu->cu_error.re_errno = errno; - goto out; - } - break; - } -#ifdef IP_RECVERR - if (fd.revents & POLLERR) - { - struct msghdr msg; - struct cmsghdr *cmsg; - struct sock_extended_err *e; - struct sockaddr_in err_addr; - struct sockaddr_in *sin = (struct sockaddr_in *)&cu->cu_raddr; - struct iovec iov; - char *cbuf = (char *) mem_alloc((outlen + 256)); - int ret; - - if (cbuf == NULL) - { - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTRECV); - } - iov.iov_base = cbuf + 256; - iov.iov_len = outlen; - msg.msg_name = (void *) &err_addr; - msg.msg_namelen = sizeof (err_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_flags = 0; - msg.msg_control = cbuf; - msg.msg_controllen = 256; - ret = recvmsg (cu->cu_fd, &msg, MSG_ERRQUEUE); - if (ret >= 0 - && memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0 - && (msg.msg_flags & MSG_ERRQUEUE) - && ((msg.msg_namelen == 0 - && ret >= 12) - || (msg.msg_namelen == sizeof (err_addr) - && err_addr.sin_family == AF_INET - && memcmp (&err_addr.sin_addr, &sin->sin_addr, - sizeof (err_addr.sin_addr)) == 0 - && err_addr.sin_port == sin->sin_port))) - for (cmsg = CMSG_FIRSTHDR (&msg); cmsg; - cmsg = CMSG_NXTHDR (&msg, cmsg)) - if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR) - { - mem_free(cbuf, (outlen + 256)); - e = (struct sock_extended_err *) CMSG_DATA(cmsg); - cu->cu_error.re_errno = e->ee_errno; - release_fd_lock(cu->cu_fd_lock, mask); - return (cu->cu_error.re_status = RPC_CANTRECV); - } - mem_free(cbuf, (outlen + 256)); - } -#endif - - /* We have some data now */ - do { - recvlen = recvfrom(cu->cu_fd, cu->cu_inbuf, - cu->cu_recvsz, 0, NULL, NULL); - } while (recvlen < 0 && errno == EINTR); - if (recvlen < 0 && errno != EWOULDBLOCK) { - cu->cu_error.re_errno = errno; - cu->cu_error.re_status = RPC_CANTRECV; - goto out; - } - - if (recvlen < sizeof(u_int32_t)) { - total_time -= tv; - goto send_again; - } - - if (cu->cu_async == FALSE) { - memcpy(&inval, cu->cu_inbuf, sizeof(u_int32_t)); - memcpy(&outval, cu->cu_outbuf, sizeof(u_int32_t)); - if (inval != outval) { - total_time -= tv; - goto send_again; - } - } - - /* - * now decode and validate the response - */ - - xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)recvlen, XDR_DECODE); - ok = xdr_replymsg(&reply_xdrs, &reply_msg); - /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ - if (ok) { - if ((reply_msg.rm_reply.rp_stat == MSG_ACCEPTED) && - (reply_msg.acpted_rply.ar_stat == SUCCESS)) - cu->cu_error.re_status = RPC_SUCCESS; - else - _seterr_reply(&reply_msg, &(cu->cu_error)); - - if (cu->cu_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(cl->cl_auth, - &reply_msg.acpted_rply.ar_verf)) { - cu->cu_error.re_status = RPC_AUTHERROR; - cu->cu_error.re_why = AUTH_INVALIDRESP; - } else if (! AUTH_UNWRAP(cl->cl_auth, &reply_xdrs, - xresults, resultsp)) { - if (cu->cu_error.re_status == RPC_SUCCESS) - cu->cu_error.re_status = RPC_CANTDECODERES; - } - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void) xdr_opaque_auth(xdrs, - &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - /* - * If unsuccesful AND error is an authentication error - * then refresh credentials and try again, else break - */ - else if (cu->cu_error.re_status == RPC_AUTHERROR) - /* maybe our credentials need to be refreshed ... */ - if (nrefreshes > 0 && - AUTH_REFRESH(cl->cl_auth, &reply_msg)) { - nrefreshes--; - goto call_again; - } - /* end of unsuccessful completion */ - } /* end of valid reply message */ - else { - cu->cu_error.re_status = RPC_CANTDECODERES; - - } -out: - release_fd_lock(cu->cu_fd_lock, mask); - return (cu->cu_error.re_status); -} - -static void -clnt_dg_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; -{ - struct cu_data *cu = (struct cu_data *)cl->cl_private; - - *errp = cu->cu_error; -} - -static bool_t -clnt_dg_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; -{ - struct cu_data *cu = (struct cu_data *)cl->cl_private; - XDR *xdrs = &(cu->cu_outxdrs); - bool_t dummy; - sigset_t mask; - sigset_t newmask; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (cu->cu_fd_lock->active) - cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); - cu->cu_fd_lock->active = TRUE; - xdrs->x_op = XDR_FREE; - dummy = (*xdr_res)(xdrs, res_ptr); - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &mask, NULL); - cond_signal(&cu->cu_fd_lock->cv); - return (dummy); -} - -/*ARGSUSED*/ -static void -clnt_dg_abort(h) - CLIENT *h; -{ -} - -static bool_t -clnt_dg_control(cl, request, info) - CLIENT *cl; - u_int request; - void *info; -{ - struct cu_data *cu = (struct cu_data *)cl->cl_private; - struct netbuf *addr; - sigset_t mask; - sigset_t newmask; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (cu->cu_fd_lock->active) - cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); - cu->cu_fd_lock->active = TRUE; - mutex_unlock(&clnt_fd_lock); - switch (request) { - case CLSET_FD_CLOSE: - cu->cu_closeit = TRUE; - release_fd_lock(cu->cu_fd_lock, mask); - return (TRUE); - case CLSET_FD_NCLOSE: - cu->cu_closeit = FALSE; - release_fd_lock(cu->cu_fd_lock, mask); - return (TRUE); - } - - /* for other requests which use info */ - if (info == NULL) { - release_fd_lock(cu->cu_fd_lock, mask); - return (FALSE); - } - switch (request) { - case CLSET_TIMEOUT: - if (time_not_ok((struct timeval *)info)) { - release_fd_lock(cu->cu_fd_lock, mask); - return (FALSE); - } - cu->cu_total = *(struct timeval *)info; - break; - case CLGET_TIMEOUT: - *(struct timeval *)info = cu->cu_total; - break; - case CLGET_SERVER_ADDR: /* Give him the fd address */ - /* Now obsolete. Only for backward compatibility */ - (void) memcpy(info, &cu->cu_raddr, (size_t)cu->cu_rlen); - break; - case CLSET_RETRY_TIMEOUT: - if (time_not_ok((struct timeval *)info)) { - release_fd_lock(cu->cu_fd_lock, mask); - return (FALSE); - } - cu->cu_wait = *(struct timeval *)info; - break; - case CLGET_RETRY_TIMEOUT: - *(struct timeval *)info = cu->cu_wait; - break; - case CLGET_FD: - *(int *)info = cu->cu_fd; - break; - case CLGET_SVC_ADDR: - addr = (struct netbuf *)info; - addr->buf = &cu->cu_raddr; - addr->len = cu->cu_rlen; - addr->maxlen = sizeof cu->cu_raddr; - break; - case CLSET_SVC_ADDR: /* set to new address */ - addr = (struct netbuf *)info; - if (addr->len < sizeof cu->cu_raddr) { - release_fd_lock(cu->cu_fd_lock, mask); - return (FALSE); - } - (void) memcpy(&cu->cu_raddr, addr->buf, addr->len); - cu->cu_rlen = addr->len; - break; - case CLGET_XID: - /* - * use the knowledge that xid is the - * first element in the call structure *. - * This will get the xid of the PREVIOUS call - */ - *(u_int32_t *)info = - ntohl(*(u_int32_t *)(void *)cu->cu_outbuf); - break; - - case CLSET_XID: - /* This will set the xid of the NEXT call */ - *(u_int32_t *)(void *)cu->cu_outbuf = - htonl(*(u_int32_t *)info - 1); - /* decrement by 1 as clnt_dg_call() increments once */ - break; - - case CLGET_VERS: - /* - * This RELIES on the information that, in the call body, - * the version number field is the fifth field from the - * begining of the RPC header. MUST be changed if the - * call_struct is changed - */ - *(u_int32_t *)info = - ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf + - 4 * BYTES_PER_XDR_UNIT)); - break; - - case CLSET_VERS: - *(u_int32_t *)(void *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT) - = htonl(*(u_int32_t *)info); - break; - - case CLGET_PROG: - /* - * This RELIES on the information that, in the call body, - * the program number field is the fourth field from the - * begining of the RPC header. MUST be changed if the - * call_struct is changed - */ - *(u_int32_t *)info = - ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf + - 3 * BYTES_PER_XDR_UNIT)); - break; - - case CLSET_PROG: - *(u_int32_t *)(void *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT) - = htonl(*(u_int32_t *)info); - break; - case CLSET_ASYNC: - cu->cu_async = *(int *)info; - break; - case CLSET_CONNECT: - cu->cu_connect = *(int *)info; - break; - default: - release_fd_lock(cu->cu_fd_lock, mask); - return (FALSE); - } - release_fd_lock(cu->cu_fd_lock, mask); - return (TRUE); -} - -static void -clnt_dg_destroy(cl) - CLIENT *cl; -{ - struct cu_data *cu = (struct cu_data *)cl->cl_private; - int cu_fd = cu->cu_fd; - fd_lock_t *cu_fd_lock = cu->cu_fd_lock; - sigset_t mask; - sigset_t newmask; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (cu_fd_lock->active) - cond_wait(&cu_fd_lock->cv, &clnt_fd_lock); - if (cu->cu_closeit) - (void)close(cu_fd); - XDR_DESTROY(&(cu->cu_outxdrs)); - mem_free(cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz)); - if (cl->cl_netid && cl->cl_netid[0]) - mem_free(cl->cl_netid, strlen(cl->cl_netid) +1); - if (cl->cl_tp && cl->cl_tp[0]) - mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); - mem_free(cl, sizeof (CLIENT)); - cond_signal(&cu_fd_lock->cv); - fd_lock_destroy(cu_fd, cu_fd_lock, dg_fd_locks); - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &mask, NULL); -} - -static struct clnt_ops * -clnt_dg_ops() -{ - static struct clnt_ops ops; - extern mutex_t ops_lock; - sigset_t mask; - sigset_t newmask; - -/* VARIABLES PROTECTED BY ops_lock: ops */ - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&ops_lock); - if (ops.cl_call == NULL) { - ops.cl_call = clnt_dg_call; - ops.cl_abort = clnt_dg_abort; - ops.cl_geterr = clnt_dg_geterr; - ops.cl_freeres = clnt_dg_freeres; - ops.cl_destroy = clnt_dg_destroy; - ops.cl_control = clnt_dg_control; - } - mutex_unlock(&ops_lock); - thr_sigsetmask(SIG_SETMASK, &mask, NULL); - return (&ops); -} - -/* - * Make sure that the time is not garbage. -1 value is allowed. - */ -static bool_t -time_not_ok(t) - struct timeval *t; -{ - return (t->tv_sec < -1 || t->tv_sec > 100000000 || - t->tv_usec < -1 || t->tv_usec > 1000000); -} - diff --git a/libtirpc-1.3.1/src/clnt_fd_locks.h b/libtirpc-1.3.1/src/clnt_fd_locks.h deleted file mode 100644 index 359f995..0000000 --- a/libtirpc-1.3.1/src/clnt_fd_locks.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * debug.h -- debugging routines for libtirpc - * - * Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _CLNT_FD_LOCKS_H -#define _CLNT_FD_LOCKS_H - -#include -#include -#include -#include - - -/* - * This utility manages a list of per-fd locks for the clients. - * - * If MAX_FDLOCKS_PREALLOC is defined, a number of pre-fd locks will be - * pre-allocated. This number is the minimum of MAX_FDLOCKS_PREALLOC or - * the process soft limit of allowed fds. - */ -#ifdef MAX_FDLOCKS_PREALLOC -static unsigned int fd_locks_prealloc = 0; -#endif - -/* per-fd lock */ -struct fd_lock_t { - bool_t active; - cond_t cv; -}; -typedef struct fd_lock_t fd_lock_t; - - -/* internal type to store per-fd locks in a list */ -struct fd_lock_item_t { - /* fd_lock_t first so we can cast to fd_lock_item_t */ - fd_lock_t fd_lock; - int fd; - unsigned int refs; - TAILQ_ENTRY(fd_lock_item_t) link; -}; -typedef struct fd_lock_item_t fd_lock_item_t; -#define to_fd_lock_item(fdlock_t_ptr) ((fd_lock_item_t*) fdlock_t_ptr) - - -/* internal list of per-fd locks */ -typedef TAILQ_HEAD(,fd_lock_item_t) fd_lock_list_t; - - -#ifdef MAX_FDLOCKS_PREALLOC - -/* With pre-allocation, keep track of both an array and a list */ -struct fd_locks_t { - fd_lock_list_t fd_lock_list; - fd_lock_t *fd_lock_array; -}; -typedef struct fd_locks_t fd_locks_t; -#define to_fd_lock_list(fd_locks_t_ptr) (&fd_locks_t_ptr->fd_lock_list) - -#else - -/* With no pre-allocation, just keep track of a list */ -typedef fd_lock_list_t fd_locks_t; -#define to_fd_lock_list(fd_locks_t_ptr) ((fd_lock_list_t *) fd_locks_t_ptr) - -#endif - - -/* allocate fd locks */ -static inline -fd_locks_t* fd_locks_init() { - fd_locks_t *fd_locks; - - fd_locks = (fd_locks_t *) mem_alloc(sizeof(fd_locks_t)); - if (fd_locks == (fd_locks_t *) NULL) { - errno = ENOMEM; - return (NULL); - } - TAILQ_INIT(to_fd_lock_list(fd_locks)); - -#ifdef MAX_FDLOCKS_PREALLOC - size_t fd_lock_arraysz; - - if (fd_locks_prealloc == 0) { - unsigned int dtbsize = __rpc_dtbsize(); - if (0 < dtbsize && dtbsize < MAX_FDLOCKS_PREALLOC) - fd_locks_prealloc = dtbsize; - else - fd_locks_prealloc = MAX_FDLOCKS_PREALLOC; - } - - if ( (size_t) fd_locks_prealloc > SIZE_MAX/sizeof(fd_lock_t)) { - mem_free(fd_locks, sizeof (*fd_locks)); - errno = EOVERFLOW; - return (NULL); - } - - fd_lock_arraysz = fd_locks_prealloc * sizeof (fd_lock_t); - fd_locks->fd_lock_array = (fd_lock_t *) mem_alloc(fd_lock_arraysz); - if (fd_locks->fd_lock_array == (fd_lock_t *) NULL) { - mem_free(fd_locks, sizeof (*fd_locks)); - errno = ENOMEM; - return (NULL); - } - else { - int i; - - for (i = 0; i < fd_locks_prealloc; i++) { - fd_locks->fd_lock_array[i].active = FALSE; - cond_init(&fd_locks->fd_lock_array[i].cv, 0, (void *) 0); - } - } -#endif - - return fd_locks; -} - -/* de-allocate fd locks */ -static inline -void fd_locks_destroy(fd_locks_t *fd_locks) { -#ifdef MAX_FDLOCKS_PREALLOC - fd_lock_t *array = fd_locks->fd_lock_array; - mem_free(array, fd_locks_prealloc * sizeof (fd_lock_t)); -#endif - fd_lock_item_t *item; - fd_lock_list_t *list = to_fd_lock_list(fd_locks); - - TAILQ_FOREACH(item, list, link) { - cond_destroy(&item->fd_lock.cv); - mem_free(item, sizeof (*item)); - } - mem_free(fd_locks, sizeof (*fd_locks)); -} - -/* allocate per-fd lock */ -static inline -fd_lock_t* fd_lock_create(int fd, fd_locks_t *fd_locks) { -#ifdef MAX_FDLOCKS_PREALLOC - if (fd < fd_locks_prealloc) { - return &fd_locks->fd_lock_array[fd]; - } -#endif - fd_lock_item_t *item; - fd_lock_list_t *list = to_fd_lock_list(fd_locks); - - for (item = TAILQ_FIRST(list); - item != (fd_lock_item_t *) NULL && item->fd != fd; - item = TAILQ_NEXT(item, link)); - - if (item == (fd_lock_item_t *) NULL) { - item = (fd_lock_item_t *) mem_alloc(sizeof(fd_lock_item_t)); - if (item == (fd_lock_item_t *) NULL) { - errno = ENOMEM; - return (NULL); - } - item->fd = fd; - item->refs = 1; - item->fd_lock.active = FALSE; - cond_init(&item->fd_lock.cv, 0, (void *) 0); - TAILQ_INSERT_HEAD(list, item, link); - } else { - item->refs++; - } - return &item->fd_lock; -} - -/* de-allocate per-fd lock */ -static inline -void fd_lock_destroy(int fd, fd_lock_t *fd_lock, fd_locks_t *fd_locks) { -#ifdef MAX_FDLOCKS_PREALLOC - if (fd < fd_locks_prealloc) - return; -#endif - fd_lock_item_t* item = to_fd_lock_item(fd_lock); - item->refs--; - if (item->refs <= 0) { - TAILQ_REMOVE(to_fd_lock_list(fd_locks), item, link); - cond_destroy(&item->fd_lock.cv); - mem_free(item, sizeof (*item)); - } -} - -#endif /* _CLNT_FD_LOCKS_H */ diff --git a/libtirpc-1.3.1/src/clnt_generic.c b/libtirpc-1.3.1/src/clnt_generic.c deleted file mode 100644 index 3f3dabf..0000000 --- a/libtirpc-1.3.1/src/clnt_generic.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 2010, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_com.h" - -extern bool_t __rpc_is_local_host(const char *); -int __rpc_raise_fd(int); - -#ifndef NETIDLEN -#define NETIDLEN 32 -#endif - -/* - * Generic client creation with version checking the value of - * vers_out is set to the highest server supported value - * vers_low <= vers_out <= vers_high AND an error results - * if this can not be done. - * - * It calls clnt_create_vers_timed() with a NULL value for the timeout - * pointer, which indicates that the default timeout should be used. - */ -CLIENT * -clnt_create_vers(const char *hostname, rpcprog_t prog, rpcvers_t *vers_out, - rpcvers_t vers_low, rpcvers_t vers_high, const char *nettype) -{ - - return (clnt_create_vers_timed(hostname, prog, vers_out, vers_low, - vers_high, nettype, NULL)); -} - -/* - * This the routine has the same definition as clnt_create_vers(), - * except it takes an additional timeout parameter - a pointer to - * a timeval structure. A NULL value for the pointer indicates - * that the default timeout value should be used. - */ -CLIENT * -clnt_create_vers_timed(const char *hostname, rpcprog_t prog, - rpcvers_t *vers_out, rpcvers_t vers_low, rpcvers_t vers_high, - const char *nettype, const struct timeval *tp) -{ - CLIENT *clnt; - struct timeval to; - enum clnt_stat rpc_stat; - struct rpc_err rpcerr; - - clnt = clnt_create_timed(hostname, prog, vers_high, nettype, tp); - if (clnt == NULL) { - return (NULL); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(clnt, NULLPROC, (xdrproc_t)xdr_void, - (char *)NULL, (xdrproc_t)xdr_void, (char *)NULL, to); - if (rpc_stat == RPC_SUCCESS) { - *vers_out = vers_high; - return (clnt); - } - while (rpc_stat == RPC_PROGVERSMISMATCH && vers_high > vers_low) { - unsigned int minvers, maxvers; - - clnt_geterr(clnt, &rpcerr); - minvers = rpcerr.re_vers.low; - maxvers = rpcerr.re_vers.high; - if (maxvers < vers_high) - vers_high = maxvers; - else - vers_high--; - if (minvers > vers_low) - vers_low = minvers; - if (vers_low > vers_high) { - goto error; - } - CLNT_CONTROL(clnt, CLSET_VERS, (char *)&vers_high); - rpc_stat = clnt_call(clnt, NULLPROC, (xdrproc_t)xdr_void, - (char *)NULL, (xdrproc_t)xdr_void, - (char *)NULL, to); - if (rpc_stat == RPC_SUCCESS) { - *vers_out = vers_high; - return (clnt); - } - } - clnt_geterr(clnt, &rpcerr); - -error: - rpc_createerr.cf_stat = rpc_stat; - rpc_createerr.cf_error = rpcerr; - clnt_destroy(clnt); - return (NULL); -} - -/* - * Top level client creation routine. - * Generic client creation: takes (servers name, program-number, nettype) and - * returns client handle. Default options are set, which the user can - * change using the rpc equivalent of _ioctl()'s. - * - * It tries for all the netids in that particular class of netid until - * it succeeds. - * XXX The error message in the case of failure will be the one - * pertaining to the last create error. - * - * It calls clnt_create_timed() with the default timeout. - */ -CLIENT * -clnt_create(const char *hostname, rpcprog_t prog, rpcvers_t vers, - const char *nettype) -{ - - return (clnt_create_timed(hostname, prog, vers, nettype, NULL)); -} - -/* - * This the routine has the same definition as clnt_create(), - * except it takes an additional timeout parameter - a pointer to - * a timeval structure. A NULL value for the pointer indicates - * that the default timeout value should be used. - * - * This function calls clnt_tp_create_timed(). - */ -CLIENT * -clnt_create_timed(const char *hostname, rpcprog_t prog, rpcvers_t vers, - const char *netclass, const struct timeval *tp) -{ - struct netconfig *nconf; - CLIENT *clnt = NULL; - void *handle; - enum clnt_stat save_cf_stat = RPC_SUCCESS; - struct rpc_err save_cf_error; - char nettype_array[NETIDLEN]; - char *nettype = &nettype_array[0]; - - if (netclass == NULL) - nettype = NULL; - else { - size_t len = strlen(netclass); - if (len >= sizeof (nettype_array)) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - strcpy(nettype, netclass); - } - - if ((handle = __rpc_setconf((char *)nettype)) == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - rpc_createerr.cf_stat = RPC_SUCCESS; - while (clnt == NULL) { - if ((nconf = __rpc_getconf(handle)) == NULL) { - if (rpc_createerr.cf_stat == RPC_SUCCESS) - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - break; - } -#ifdef CLNT_DEBUG - printf("trying netid %s\n", nconf->nc_netid); -#endif - clnt = clnt_tp_create_timed(hostname, prog, vers, nconf, tp); - if (clnt) - break; - else { - /* - * Since we didn't get a name-to-address - * translation failure here, we remember - * this particular error. The object of - * this is to enable us to return to the - * caller a more-specific error than the - * unhelpful ``Name to address translation - * failed'' which might well occur if we - * merely returned the last error (because - * the local loopbacks are typically the - * last ones in /etc/netconfig and the most - * likely to be unable to translate a host - * name). We also check for a more - * meaningful error than ``unknown host - * name'' for the same reasons. - */ - if (rpc_createerr.cf_stat != RPC_N2AXLATEFAILURE && - rpc_createerr.cf_stat != RPC_UNKNOWNHOST) { - save_cf_stat = rpc_createerr.cf_stat; - save_cf_error = rpc_createerr.cf_error; - } - } - } - - /* - * Attempt to return an error more specific than ``Name to address - * translation failed'' or ``unknown host name'' - */ - if ((rpc_createerr.cf_stat == RPC_N2AXLATEFAILURE || - rpc_createerr.cf_stat == RPC_UNKNOWNHOST) && - (save_cf_stat != RPC_SUCCESS)) { - rpc_createerr.cf_stat = save_cf_stat; - rpc_createerr.cf_error = save_cf_error; - } - __rpc_endconf(handle); - return (clnt); -} - -/* - * Generic client creation: takes (servers name, program-number, netconf) and - * returns client handle. Default options are set, which the user can - * change using the rpc equivalent of _ioctl()'s : clnt_control() - * It finds out the server address from rpcbind and calls clnt_tli_create(). - * - * It calls clnt_tp_create_timed() with the default timeout. - */ -CLIENT * -clnt_tp_create(const char *hostname, rpcprog_t prog, rpcvers_t vers, - const struct netconfig *nconf) -{ - return (clnt_tp_create_timed(hostname, prog, vers, nconf, NULL)); -} - -/* - * This has the same definition as clnt_tp_create(), except it - * takes an additional parameter - a pointer to a timeval structure. - * A NULL value for the timeout pointer indicates that the default - * value for the timeout should be used. - */ -CLIENT * -clnt_tp_create_timed(const char *hostname, rpcprog_t prog, rpcvers_t vers, - const struct netconfig *nconf, const struct timeval *tp) -{ - struct netbuf *svcaddr; /* servers address */ - CLIENT *cl = NULL; /* client handle */ - - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - - /* - * Get the address of the server - */ - if ((svcaddr = __rpcb_findaddr_timed(prog, vers, - (struct netconfig *)nconf, (char *)hostname, - &cl, (struct timeval *)tp)) == NULL) { - /* appropriate error number is set by rpcbind libraries */ - return (NULL); - } - if (cl == NULL) { - cl = clnt_tli_create(RPC_ANYFD, nconf, svcaddr, - prog, vers, 0, 0); - } else { - /* Reuse the CLIENT handle and change the appropriate fields */ - if (CLNT_CONTROL(cl, CLSET_SVC_ADDR, (void *)svcaddr) == TRUE) { - if (cl->cl_netid == NULL) - cl->cl_netid = strdup(nconf->nc_netid); - if (cl->cl_tp == NULL) - cl->cl_tp = strdup(nconf->nc_device); - (void) CLNT_CONTROL(cl, CLSET_PROG, (void *)&prog); - (void) CLNT_CONTROL(cl, CLSET_VERS, (void *)&vers); - } else { - CLNT_DESTROY(cl); - cl = clnt_tli_create(RPC_ANYFD, nconf, svcaddr, - prog, vers, 0, 0); - } - } - free(svcaddr->buf); - free(svcaddr); - return (cl); -} - -/* - * Generic client creation: returns client handle. - * Default options are set, which the user can - * change using the rpc equivalent of _ioctl()'s : clnt_control(). - * If fd is RPC_ANYFD, it will be opened using nconf. - * It will be bound if not so. - * If sizes are 0; appropriate defaults will be chosen. - */ -CLIENT * -clnt_tli_create(int fd, const struct netconfig *nconf, - struct netbuf *svcaddr, rpcprog_t prog, rpcvers_t vers, - uint sendsz, uint recvsz) -{ - CLIENT *cl; /* client handle */ - bool_t madefd = FALSE; /* whether fd opened here */ - long servtype; - int one = 1; - struct __rpc_sockinfo si; - extern int __rpc_minfd; - - if (fd == RPC_ANYFD) { - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - - fd = __rpc_nconf2fd(nconf); - - if (fd == -1) - goto err; - if (fd < __rpc_minfd) - fd = __rpc_raise_fd(fd); - madefd = TRUE; - servtype = nconf->nc_semantics; - if (!__rpc_fd2sockinfo(fd, &si)) - goto err; - bindresvport(fd, NULL); - } else { - if (!__rpc_fd2sockinfo(fd, &si)) - goto err; - servtype = __rpc_socktype2seman(si.si_socktype); - if (servtype == -1) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - } - - if (si.si_af != ((struct sockaddr *)svcaddr->buf)->sa_family) { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; /* XXX */ - goto err1; - } - - switch (servtype) { - case NC_TPI_COTS: - cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz); - break; - case NC_TPI_COTS_ORD: - if (nconf && - ((strcmp(nconf->nc_protofmly, "inet") == 0) || - (strcmp(nconf->nc_protofmly, "inet6") == 0))) { - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, - sizeof (one)); - } - cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz); - break; - case NC_TPI_CLTS: - cl = clnt_dg_create(fd, svcaddr, prog, vers, sendsz, recvsz); - break; - default: - goto err; - } - - if (cl == NULL) - goto err1; /* borrow errors from clnt_dg/vc creates */ - if (nconf) { - cl->cl_netid = strdup(nconf->nc_netid); - cl->cl_tp = strdup(nconf->nc_device); - } else { - cl->cl_netid = ""; - cl->cl_tp = ""; - } - if (madefd) { - (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL); -/* (void) CLNT_CONTROL(cl, CLSET_POP_TIMOD, NULL); */ - }; - - return (cl); - -err: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; -err1: if (madefd) - (void)close(fd); - return (NULL); -} - -/* - * To avoid conflicts with the "magic" file descriptors (0, 1, and 2), - * we try to not use them. The __rpc_raise_fd() routine will dup - * a descriptor to a higher value. If we fail to do it, we continue - * to use the old one (and hope for the best). - */ -int __rpc_minfd = 3; - -int -__rpc_raise_fd(int fd) -{ - int nfd; - - if (fd >= __rpc_minfd) - return (fd); - - if ((nfd = fcntl(fd, F_DUPFD, __rpc_minfd)) == -1) - return (fd); - - if (fsync(nfd) == -1) { - close(nfd); - return (fd); - } - - if (close(fd) == -1) { - /* this is okay, we will syslog an error, then use the new fd */ - (void) syslog(LOG_ERR, - "could not close() fd %d; mem & fd leak", fd); - } - - return (nfd); -} diff --git a/libtirpc-1.3.1/src/clnt_perror.c b/libtirpc-1.3.1/src/clnt_perror.c deleted file mode 100644 index fb7fb80..0000000 --- a/libtirpc-1.3.1/src/clnt_perror.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * clnt_perror.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ -#include -#include -#include - -#include -#include -#include -#include - -static char *buf; - -static char *_buf(void); -static char *auth_errmsg(enum auth_stat); -#define CLNT_PERROR_BUFLEN 256 - -static char * -_buf() -{ - - if (buf == 0) - buf = (char *)malloc(CLNT_PERROR_BUFLEN); - return (buf); -} - -/* - * Print reply error info - */ -char * -clnt_sperror(rpch, s) - CLIENT *rpch; - const char *s; -{ - struct rpc_err e; - char *err; - char *str; - char *strstart; - size_t len, i; - - if (rpch == NULL || s == NULL) - return(0); - - str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */ - if (str == 0) - return (0); - len = CLNT_PERROR_BUFLEN; - strstart = str; - CLNT_GETERR(rpch, &e); - - if (snprintf(str, len, "%s: ", s) > 0) { - i = strlen(str); - str += i; - len -= i; - } - - (void)strncpy(str, clnt_sperrno(e.re_status), len - 1); - i = strlen(str); - str += i; - len -= i; - - switch (e.re_status) { - case RPC_SUCCESS: - case RPC_CANTENCODEARGS: - case RPC_CANTDECODERES: - case RPC_TIMEDOUT: - case RPC_PROGUNAVAIL: - case RPC_PROCUNAVAIL: - case RPC_CANTDECODEARGS: - case RPC_SYSTEMERROR: - case RPC_UNKNOWNHOST: - case RPC_UNKNOWNPROTO: - case RPC_PMAPFAILURE: - case RPC_PROGNOTREGISTERED: - case RPC_FAILED: - break; - - case RPC_CANTSEND: - case RPC_CANTRECV: - snprintf(str, len, "; errno = %s", strerror(e.re_errno)); - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - break; - - case RPC_VERSMISMATCH: - snprintf(str, len, "; low version = %u, high version = %u", - e.re_vers.low, e.re_vers.high); - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - break; - - case RPC_AUTHERROR: - err = auth_errmsg(e.re_why); - snprintf(str, len, "; why = "); - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - if (err != NULL) { - snprintf(str, len, "%s",err); - } else { - snprintf(str, len, - "(unknown authentication error - %d)", - (int) e.re_why); - } - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - break; - - case RPC_PROGVERSMISMATCH: - snprintf(str, len, "; low version = %u, high version = %u", - e.re_vers.low, e.re_vers.high); - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - break; - - default: /* unknown */ - snprintf(str, len, "; s1 = %u, s2 = %u", - e.re_lb.s1, e.re_lb.s2); - i = strlen(str); - if (i > 0) { - str += i; - len -= i; - } - break; - } - strstart[CLNT_PERROR_BUFLEN-1] = '\0'; - return(strstart) ; -} - -void -clnt_perror(rpch, s) - CLIENT *rpch; - const char *s; -{ - - if (rpch == NULL || s == NULL) - return; - - (void) fprintf(stderr, "%s\n", clnt_sperror(rpch,s)); -} - -static const char *const rpc_errlist[] = { - "RPC: Success", /* 0 - RPC_SUCCESS */ - "RPC: Can't encode arguments", /* 1 - RPC_CANTENCODEARGS */ - "RPC: Can't decode result", /* 2 - RPC_CANTDECODERES */ - "RPC: Unable to send", /* 3 - RPC_CANTSEND */ - "RPC: Unable to receive", /* 4 - RPC_CANTRECV */ - "RPC: Timed out", /* 5 - RPC_TIMEDOUT */ - "RPC: Incompatible versions of RPC", /* 6 - RPC_VERSMISMATCH */ - "RPC: Authentication error", /* 7 - RPC_AUTHERROR */ - "RPC: Program unavailable", /* 8 - RPC_PROGUNAVAIL */ - "RPC: Program/version mismatch", /* 9 - RPC_PROGVERSMISMATCH */ - "RPC: Procedure unavailable", /* 10 - RPC_PROCUNAVAIL */ - "RPC: Server can't decode arguments", /* 11 - RPC_CANTDECODEARGS */ - "RPC: Remote system error", /* 12 - RPC_SYSTEMERROR */ - "RPC: Unknown host", /* 13 - RPC_UNKNOWNHOST */ - "RPC: Port mapper failure", /* 14 - RPC_PMAPFAILURE */ - "RPC: Program not registered", /* 15 - RPC_PROGNOTREGISTERED */ - "RPC: Failed (unspecified error)", /* 16 - RPC_FAILED */ - "RPC: Unknown protocol" /* 17 - RPC_UNKNOWNPROTO */ -}; - - -/* - * This interface for use by clntrpc - */ -char * -clnt_sperrno(stat) - enum clnt_stat stat; -{ - unsigned int errnum = stat; - - if (errnum < (sizeof(rpc_errlist)/sizeof(rpc_errlist[0]))) - /* LINTED interface problem */ - return (char *)rpc_errlist[errnum]; - - return ("RPC: (unknown error code)"); -} - -void -clnt_perrno(num) - enum clnt_stat num; -{ - (void) fprintf(stderr, "%s\n", clnt_sperrno(num)); -} - - -char * -clnt_spcreateerror(s) - const char *s; -{ - char *str, *err; - size_t len, i; - - if (s == NULL) - return(0); - - str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */ - if (str == 0) - return(0); - len = CLNT_PERROR_BUFLEN; - snprintf(str, len, "%s: ", s); - i = strlen(str); - if (i > 0) - len -= i; - (void)strncat(str, clnt_sperrno(rpc_createerr.cf_stat), len - 1); - switch (rpc_createerr.cf_stat) { - case RPC_PMAPFAILURE: - (void) strncat(str, " - ", len - 1); - err = clnt_sperrno(rpc_createerr.cf_error.re_status); - if (err) - (void) strncat(str, err+5, len-5); - switch(rpc_createerr.cf_error.re_status) { - case RPC_CANTSEND: - case RPC_CANTRECV: - i = strlen(str); - len -= i; - snprintf(str+i, len, ": errno %d (%s)", - rpc_createerr.cf_error.re_errno, - strerror(rpc_createerr.cf_error.re_errno)); - break; - default: - break; - } - break; - - case RPC_SYSTEMERROR: - (void)strncat(str, " - ", len - 1); - (void)strncat(str, strerror(rpc_createerr.cf_error.re_errno), - len - 4); - break; - - case RPC_CANTSEND: - case RPC_CANTDECODERES: - case RPC_CANTENCODEARGS: - case RPC_SUCCESS: - case RPC_UNKNOWNPROTO: - case RPC_PROGNOTREGISTERED: - case RPC_FAILED: - case RPC_UNKNOWNHOST: - case RPC_CANTDECODEARGS: - case RPC_PROCUNAVAIL: - case RPC_PROGVERSMISMATCH: - case RPC_PROGUNAVAIL: - case RPC_AUTHERROR: - case RPC_VERSMISMATCH: - case RPC_TIMEDOUT: - case RPC_CANTRECV: - default: - break; - } - str[CLNT_PERROR_BUFLEN-1] = '\0'; - return (str); -} - -void -clnt_pcreateerror(s) - const char *s; -{ - - if (s == NULL) - return; - - (void) fprintf(stderr, "%s\n", clnt_spcreateerror(s)); -} - -static const char *const auth_errlist[] = { - "Authentication OK", /* 0 - AUTH_OK */ - "Invalid client credential", /* 1 - AUTH_BADCRED */ - "Server rejected credential", /* 2 - AUTH_REJECTEDCRED */ - "Invalid client verifier", /* 3 - AUTH_BADVERF */ - "Server rejected verifier", /* 4 - AUTH_REJECTEDVERF */ - "Client credential too weak", /* 5 - AUTH_TOOWEAK */ - "Invalid server verifier", /* 6 - AUTH_INVALIDRESP */ - "Failed (unspecified error)" /* 7 - AUTH_FAILED */ -}; - -static char * -auth_errmsg(stat) - enum auth_stat stat; -{ - unsigned int errnum = stat; - - if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0]))) - /* LINTED interface problem */ - return (char *)auth_errlist[errnum]; - - return(NULL); -} diff --git a/libtirpc-1.3.1/src/clnt_raw.c b/libtirpc-1.3.1/src/clnt_raw.c deleted file mode 100644 index 31f9d0c..0000000 --- a/libtirpc-1.3.1/src/clnt_raw.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * clnt_raw.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Memory based rpc for simple testing and timing. - * Interface to create an rpc client and server in the same process. - * This lets us similate rpc and get round trip overhead, without - * any interference from the kernel. - */ -#include -#include -#include -#include -#include -#include - -#include -#include - -extern mutex_t clntraw_lock; - -#define MCALL_MSG_SIZE 24 - -/* - * This is the "network" we will be moving stuff over. - */ -static struct clntraw_private { - CLIENT client_object; - XDR xdr_stream; - char *_raw_buf; - union { - struct rpc_msg mashl_rpcmsg; - char mashl_callmsg[MCALL_MSG_SIZE]; - } u; - u_int mcnt; -} *clntraw_private; - -static enum clnt_stat clnt_raw_call(CLIENT *, rpcproc_t, xdrproc_t, void *, - xdrproc_t, void *, struct timeval); -static void clnt_raw_geterr(CLIENT *, struct rpc_err *); -static bool_t clnt_raw_freeres(CLIENT *, xdrproc_t, void *); -static void clnt_raw_abort(CLIENT *); -static bool_t clnt_raw_control(CLIENT *, u_int, void *); -static void clnt_raw_destroy(CLIENT *); -static struct clnt_ops *clnt_raw_ops(void); - -/* - * Create a client handle for memory based rpc. - */ -CLIENT * -clnt_raw_create(prog, vers) - rpcprog_t prog; - rpcvers_t vers; -{ - struct clntraw_private *clp; - struct rpc_msg call_msg; - XDR *xdrs; - CLIENT *client; - - mutex_lock(&clntraw_lock); - clp = clntraw_private; - if (clp == NULL) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); - if (clp == NULL) { - mutex_unlock(&clntraw_lock); - return NULL; - } - if (__rpc_rawcombuf == NULL) - __rpc_rawcombuf = - (char *)calloc(UDPMSGSIZE, sizeof (char)); - clp->_raw_buf = __rpc_rawcombuf; - clntraw_private = clp; - } - xdrs = &clp->xdr_stream; - client = &clp->client_object; - /* - * pre-serialize the static part of the call msg and stash it away - */ - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - /* XXX: prog and vers have been long historically :-( */ - call_msg.rm_call.cb_prog = (u_int32_t)prog; - call_msg.rm_call.cb_vers = (u_int32_t)vers; - xdrmem_create(xdrs, clp->u.mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); - if (! xdr_callhdr(xdrs, &call_msg)) - warnx("clntraw_create - Fatal header serialization error."); - clp->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - - /* - * Set xdrmem for client/server shared buffer - */ - xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); - - /* - * create client handle - */ - client->cl_ops = clnt_raw_ops(); - client->cl_auth = authnone_create(); - mutex_unlock(&clntraw_lock); - return (client); -} - -/* ARGSUSED */ -static enum clnt_stat -clnt_raw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - rpcproc_t proc; - xdrproc_t xargs; - void *argsp; - xdrproc_t xresults; - void *resultsp; - struct timeval timeout; -{ - struct clntraw_private *clp = clntraw_private; - XDR *xdrs = &clp->xdr_stream; - struct rpc_msg msg; - enum clnt_stat status; - struct rpc_err error; - - assert(h != NULL); - - mutex_lock(&clntraw_lock); - if (clp == NULL) { - mutex_unlock(&clntraw_lock); - return (RPC_FAILED); - } - mutex_unlock(&clntraw_lock); - -call_again: - /* - * send request - */ - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - clp->u.mashl_rpcmsg.rm_xid ++ ; - if ((! XDR_PUTBYTES(xdrs, clp->u.mashl_callmsg, clp->mcnt)) || - (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) { - return (RPC_CANTENCODEARGS); - } - (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ - - /* - * We have to call server input routine here because this is - * all going on in one process. Yuk. - */ - svc_getreq_common(FD_SETSIZE); - - /* - * get results - */ - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = resultsp; - msg.acpted_rply.ar_results.proc = xresults; - if (! xdr_replymsg(xdrs, &msg)) { - /* - * It's possible for xdr_replymsg() to fail partway - * through its attempt to decode the result from the - * server. If this happens, it will leave the reply - * structure partially populated with dynamically - * allocated memory. (This can happen if someone uses - * clntudp_bufcreate() to create a CLIENT handle and - * specifies a receive buffer size that is too small.) - * This memory must be free()ed to avoid a leak. - */ - int op = xdrs->x_op; - xdrs->x_op = XDR_FREE; - xdr_replymsg(xdrs, &msg); - xdrs->x_op = op; - return (RPC_CANTDECODERES); - } - _seterr_reply(&msg, &error); - status = error.re_status; - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - } /* end successful completion */ - else { - if (AUTH_REFRESH(h->cl_auth, &msg)) - goto call_again; - } /* end of unsuccessful completion */ - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - if (msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); - } - } - - return (status); -} - -/*ARGSUSED*/ -static void -clnt_raw_geterr(cl, err) - CLIENT *cl; - struct rpc_err *err; -{ -} - - -/* ARGSUSED */ -static bool_t -clnt_raw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; -{ - struct clntraw_private *clp = clntraw_private; - XDR *xdrs = &clp->xdr_stream; - bool_t rval; - - mutex_lock(&clntraw_lock); - if (clp == NULL) { - rval = (bool_t) RPC_FAILED; - mutex_unlock(&clntraw_lock); - return (rval); - } - mutex_unlock(&clntraw_lock); - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -/*ARGSUSED*/ -static void -clnt_raw_abort(cl) - CLIENT *cl; -{ -} - -/*ARGSUSED*/ -static bool_t -clnt_raw_control(cl, ui, str) - CLIENT *cl; - u_int ui; - void *str; -{ - return (FALSE); -} - -/*ARGSUSED*/ -static void -clnt_raw_destroy(cl) - CLIENT *cl; -{ -} - -static struct clnt_ops * -clnt_raw_ops() -{ - static struct clnt_ops ops; - extern mutex_t ops_lock; - - /* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&ops_lock); - if (ops.cl_call == NULL) { - ops.cl_call = clnt_raw_call; - ops.cl_abort = clnt_raw_abort; - ops.cl_geterr = clnt_raw_geterr; - ops.cl_freeres = clnt_raw_freeres; - ops.cl_destroy = clnt_raw_destroy; - ops.cl_control = clnt_raw_control; - } - mutex_unlock(&ops_lock); - return (&ops); -} diff --git a/libtirpc-1.3.1/src/clnt_simple.c b/libtirpc-1.3.1/src/clnt_simple.c deleted file mode 100644 index 1700060..0000000 --- a/libtirpc-1.3.1/src/clnt_simple.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - -/* - * clnt_simple.c - * Simplified front end to client rpc. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#ifndef NETIDLEN -#define NETIDLEN 32 -#endif - -struct rpc_call_private { - int valid; /* Is this entry valid ? */ - CLIENT *client; /* Client handle */ - pid_t pid; /* process-id at moment of creation */ - rpcprog_t prognum; /* Program */ - rpcvers_t versnum; /* Version */ - char host[MAXHOSTNAMELEN]; /* Servers host */ - char nettype[NETIDLEN]; /* Network type */ -}; - -static void rpc_call_destroy(void *); - -static void -rpc_call_destroy(void *vp) -{ - struct rpc_call_private *rcp = (struct rpc_call_private *)vp; - - if (rcp) { - if (rcp->client) - CLNT_DESTROY(rcp->client); - free(rcp); - } -} - -/* - * This is the simplified interface to the client rpc layer. - * The client handle is not destroyed here and is reused for - * the future calls to same prog, vers, host and nettype combination. - * - * The total time available is 25 seconds. - */ -enum clnt_stat -rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) - const char *host; /* host name */ - rpcprog_t prognum; /* program number */ - rpcvers_t versnum; /* version number */ - rpcproc_t procnum; /* procedure number */ - xdrproc_t inproc, outproc; /* in/out XDR procedures */ - const char *in; - char *out; /* recv/send data */ - const char *nettype; /* nettype */ -{ - struct rpc_call_private *rcp = (struct rpc_call_private *) 0; - enum clnt_stat clnt_stat; - struct timeval timeout, tottimeout; - extern thread_key_t rpc_call_key; - extern mutex_t tsd_lock; - - if (rpc_call_key == KEY_INITIALIZER) { - mutex_lock(&tsd_lock); - if (rpc_call_key == KEY_INITIALIZER) - thr_keycreate(&rpc_call_key, rpc_call_destroy); - mutex_unlock(&tsd_lock); - } - rcp = (struct rpc_call_private *)thr_getspecific(rpc_call_key); - if (rcp == NULL) { - rcp = malloc(sizeof (*rcp)); - if (rcp == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - return (rpc_createerr.cf_stat); - } - thr_setspecific(rpc_call_key, (void *) rcp); - rcp->valid = 0; - rcp->client = NULL; - } - if ((nettype == NULL) || (nettype[0] == 0)) - nettype = "netpath"; - if (!(rcp->valid && rcp->pid == getpid() && - (rcp->prognum == prognum) && - (rcp->versnum == versnum) && - (!strcmp(rcp->host, host)) && - (!strcmp(rcp->nettype, nettype)))) { - int fd; - - rcp->valid = 0; - if (rcp->client) - CLNT_DESTROY(rcp->client); - /* - * Using the first successful transport for that type - */ - rcp->client = clnt_create(host, prognum, versnum, nettype); - rcp->pid = getpid(); - if (rcp->client == NULL) { - return (rpc_createerr.cf_stat); - } - /* - * Set time outs for connectionless case. Do it - * unconditionally. Faster than doing a t_getinfo() - * and then doing the right thing. - */ - timeout.tv_usec = 0; - timeout.tv_sec = 5; - (void) CLNT_CONTROL(rcp->client, - CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout); - if (CLNT_CONTROL(rcp->client, CLGET_FD, (char *)(void *)&fd)) - fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ - rcp->prognum = prognum; - rcp->versnum = versnum; - if ((strlen(host) < (size_t)MAXHOSTNAMELEN) && - (strlen(nettype) < (size_t)NETIDLEN)) { - (void) strcpy(rcp->host, host); - (void) strcpy(rcp->nettype, nettype); - rcp->valid = 1; - } else { - rcp->valid = 0; - } - } /* else reuse old client */ - tottimeout.tv_sec = 25; - tottimeout.tv_usec = 0; - - /* LINTED const castaway */ - clnt_stat = CLNT_CALL(rcp->client, procnum, inproc, (char *) in, - outproc, out, tottimeout); - /* - * if call failed, empty cache - */ - if (clnt_stat != RPC_SUCCESS) - rcp->valid = 0; - return (clnt_stat); -} diff --git a/libtirpc-1.3.1/src/clnt_vc.c b/libtirpc-1.3.1/src/clnt_vc.c deleted file mode 100644 index 6f7f7da..0000000 --- a/libtirpc-1.3.1/src/clnt_vc.c +++ /dev/null @@ -1,777 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * clnt_tcp.c, Implements a TCP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * TCP based RPC supports 'batched calls'. - * A sequence of calls may be batched-up in a send buffer. The rpc call - * return immediately to the client even though the call was not necessarily - * sent. The batching occurs if the results' xdr routine is NULL (0) AND - * the rpc timeout value is zero (see clnt.h, rpc). - * - * Clients should NOT casually batch calls that in fact return results; that is, - * the server side should be aware that a call is batched and not produce any - * return message. Batched calls that produce many result messages can - * deadlock (netlock) the client and the server.... - * - * Now go hang yourself. - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "rpc_com.h" -#include "clnt_fd_locks.h" - -#define MCALL_MSG_SIZE 24 - -#define CMGROUP_MAX 16 -#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ - -#undef rpc_createerr /* make it clear it is a thread safe variable */ - -/* - * Credentials structure, used to verify the identity of a peer - * process that has sent us a message. This is allocated by the - * peer process but filled in by the kernel. This prevents the - * peer from lying about its identity. (Note that cmcred_groups[0] - * is the effective GID.) - */ -struct cmsgcred { - pid_t cmcred_pid; /* PID of sending process */ - uid_t cmcred_uid; /* real UID of sending process */ - uid_t cmcred_euid; /* effective UID of sending process */ - gid_t cmcred_gid; /* real GID of sending process */ - short cmcred_ngroups; /* number or groups */ - gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ -}; - -struct cmessage { - struct cmsghdr cmsg; - struct cmsgcred cmcred; -}; - -static enum clnt_stat clnt_vc_call(CLIENT *, rpcproc_t, xdrproc_t, void *, - xdrproc_t, void *, struct timeval); -static void clnt_vc_geterr(CLIENT *, struct rpc_err *); -static bool_t clnt_vc_freeres(CLIENT *, xdrproc_t, void *); -static void clnt_vc_abort(CLIENT *); -static bool_t clnt_vc_control(CLIENT *, u_int, void *); -static void clnt_vc_destroy(CLIENT *); -static struct clnt_ops *clnt_vc_ops(void); -static bool_t time_not_ok(struct timeval *); -static int read_vc(void *, void *, int); -static int write_vc(void *, void *, int); - -struct ct_data { - int ct_fd; /* connection's fd */ - fd_lock_t *ct_fd_lock; - bool_t ct_closeit; /* close it on destroy */ - struct timeval ct_wait; /* wait interval in milliseconds */ - bool_t ct_waitset; /* wait set by clnt_control? */ - struct netbuf ct_addr; /* remote addr */ - struct rpc_err ct_error; - union { - char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */ - u_int32_t ct_mcalli; - } ct_u; - u_int ct_mpos; /* pos after marshal */ - XDR ct_xdrs; /* XDR stream */ -}; - -/* - * This machinery implements per-fd locks for MT-safety. It is not - * sufficient to do per-CLIENT handle locks for MT-safety because a - * user may create more than one CLIENT handle with the same fd behind - * it. - * - * We keep track of a list of per-fd locks, protected by the clnt_fd_lock - * mutex. Each per-fd lock consists of a predicate indicating whether is - * active or not: fd_lock->active == TRUE => a call is active on some - * CLIENT handle created for that fd. Each fd predicate is guarded by a - * condition variable so that the global mutex can be unlocked while - * waiting for the predicate to change. - * - * The current implementation holds locks across the entire RPC and reply, - * including retransmissions. Yes, this is silly, and as soon as this - * code is proven to work, this should be the first thing fixed. One step - * at a time. - */ -static fd_locks_t *vc_fd_locks; -extern pthread_mutex_t disrupt_lock; -extern mutex_t clnt_fd_lock; -#define release_fd_lock(fd_lock, mask) { \ - mutex_lock(&clnt_fd_lock); \ - fd_lock->active = FALSE; \ - mutex_unlock(&clnt_fd_lock); \ - thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \ - cond_signal(&fd_lock->cv); \ -} - -static const char clnt_vc_errstr[] = "%s : %s"; -static const char clnt_vc_str[] = "clnt_vc_create"; -static const char __no_mem_str[] = "out of memory"; - -/* - * Create a client handle for a connection. - * Default options are set, which the user can change using clnt_control()'s. - * The rpc/vc package does buffering similar to stdio, so the client - * must pick send and receive buffer sizes, 0 => use the default. - * NB: fd is copied into a private area. - * NB: The rpch->cl_auth is set null authentication. Caller may wish to - * set this something more useful. - * - * fd should be an open socket - */ -CLIENT * -clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) - int fd; /* open file descriptor */ - const struct netbuf *raddr; /* servers address */ - const rpcprog_t prog; /* program number */ - const rpcvers_t vers; /* version number */ - u_int sendsz; /* buffer recv size */ - u_int recvsz; /* buffer send size */ -{ - CLIENT *cl; /* client handle */ - struct ct_data *ct = NULL; /* client handle */ - struct timeval now; - struct rpc_msg call_msg; - static u_int32_t disrupt; - sigset_t mask; - sigset_t newmask; - struct sockaddr_storage ss; - socklen_t slen; - struct __rpc_sockinfo si; - fd_lock_t *fd_lock; - - mutex_lock(&disrupt_lock); - if (disrupt == 0) - disrupt = (u_int32_t)(long)raddr; - mutex_unlock(&disrupt_lock); - - cl = (CLIENT *)mem_alloc(sizeof (*cl)); - ct = (struct ct_data *)mem_alloc(sizeof (*ct)); - if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) { - struct rpc_createerr *ce = &get_rpc_createerr(); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - (void) syslog(LOG_ERR, clnt_vc_errstr, - clnt_vc_str, __no_mem_str); - goto err; - } - ct->ct_addr.buf = NULL; - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (vc_fd_locks == (fd_locks_t *) NULL) { - vc_fd_locks = fd_locks_init(); - if (vc_fd_locks == (fd_locks_t *) NULL) { - struct rpc_createerr *ce = &get_rpc_createerr(); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - goto err; - } - } - fd_lock = fd_lock_create(fd, vc_fd_locks); - if (fd_lock == (fd_lock_t *) NULL) { - struct rpc_createerr *ce = &get_rpc_createerr(); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - goto err; - } - - /* - * Do not hold mutex during connect - */ - mutex_unlock(&clnt_fd_lock); - - slen = sizeof ss; - if (getpeername(fd, (struct sockaddr *)&ss, &slen) < 0) { - if (errno != ENOTCONN) { - struct rpc_createerr *ce = &get_rpc_createerr(); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err; - } - if (connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){ - if (errno != EISCONN) { - struct rpc_createerr *ce = &get_rpc_createerr(); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err; - } - } - } - if (!__rpc_fd2sockinfo(fd, &si)) - goto err; - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - - ct->ct_closeit = FALSE; - - /* - * Set up private data struct - */ - ct->ct_fd = fd; - ct->ct_fd_lock = fd_lock; - ct->ct_wait.tv_usec = 0; - ct->ct_waitset = FALSE; - ct->ct_addr.buf = malloc(raddr->maxlen); - if (ct->ct_addr.buf == NULL) - goto err; - memcpy(ct->ct_addr.buf, raddr->buf, raddr->len); - ct->ct_addr.len = raddr->len; - ct->ct_addr.maxlen = raddr->maxlen; - - /* - * Initialize call message - */ - (void)gettimeofday(&now, NULL); - mutex_lock(&disrupt_lock); - call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now); - mutex_unlock(&disrupt_lock); - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = (u_int32_t)prog; - call_msg.rm_call.cb_vers = (u_int32_t)vers; - - /* - * pre-serialize the static part of the call msg and stash it away - */ - xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE, - XDR_ENCODE); - if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { - if (ct->ct_closeit) { - (void)close(fd); - } - goto err; - } - ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); - XDR_DESTROY(&(ct->ct_xdrs)); - - /* - * Create a client handle which uses xdrrec for serialization - * and authnone for authentication. - */ - cl->cl_ops = clnt_vc_ops(); - cl->cl_private = ct; - cl->cl_auth = authnone_create(); - sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz); - recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); - xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, - cl->cl_private, read_vc, write_vc); - return (cl); - -err: - if (cl) { - if (ct) { - if (ct->ct_addr.len) - mem_free(ct->ct_addr.buf, ct->ct_addr.len); - mem_free(ct, sizeof (struct ct_data)); - } - mem_free(cl, sizeof (CLIENT)); - } else if (ct) { - if (ct->ct_addr.len) - mem_free(ct->ct_addr.buf, ct->ct_addr.len); - mem_free(ct, sizeof (struct ct_data)); - } - return ((CLIENT *)NULL); -} - -static enum clnt_stat -clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) - CLIENT *cl; - rpcproc_t proc; - xdrproc_t xdr_args; - void *args_ptr; - xdrproc_t xdr_results; - void *results_ptr; - struct timeval timeout; -{ - struct ct_data *ct = (struct ct_data *) cl->cl_private; - XDR *xdrs = &(ct->ct_xdrs); - struct rpc_msg reply_msg; - u_int32_t x_id; - u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */ - bool_t shipnow; - int refreshes = 2; - sigset_t mask, newmask; - - assert(cl != NULL); - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (ct->ct_fd_lock->active) - cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); - ct->ct_fd_lock->active = TRUE; - mutex_unlock(&clnt_fd_lock); - if (!ct->ct_waitset) { - /* If time is not within limits, we ignore it. */ - if (time_not_ok(&timeout) == FALSE) - ct->ct_wait = timeout; - } - - shipnow = - (xdr_results == NULL && timeout.tv_sec == 0 - && timeout.tv_usec == 0) ? FALSE : TRUE; - -call_again: - xdrs->x_op = XDR_ENCODE; - ct->ct_error.re_status = RPC_SUCCESS; - x_id = ntohl(--(*msg_x_id)); - - if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) || - (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) || - (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || - (! AUTH_WRAP(cl->cl_auth, xdrs, xdr_args, args_ptr))) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTENCODEARGS; - (void)xdrrec_endofrecord(xdrs, TRUE); - release_fd_lock(ct->ct_fd_lock, mask); - return (ct->ct_error.re_status); - } - if (! xdrrec_endofrecord(xdrs, shipnow)) { - release_fd_lock(ct->ct_fd_lock, mask); - return (ct->ct_error.re_status = RPC_CANTSEND); - } - if (! shipnow) { - release_fd_lock(ct->ct_fd_lock, mask); - return (RPC_SUCCESS); - } - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - release_fd_lock(ct->ct_fd_lock, mask); - return(ct->ct_error.re_status = RPC_TIMEDOUT); - } - - - /* - * Keep receiving until we get a valid transaction id - */ - xdrs->x_op = XDR_DECODE; - while (TRUE) { - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - if (! xdrrec_skiprecord(xdrs)) { - release_fd_lock(ct->ct_fd_lock, mask); - return (ct->ct_error.re_status); - } - /* now decode and validate the response header */ - if (! xdr_replymsg(xdrs, &reply_msg)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - continue; - release_fd_lock(ct->ct_fd_lock, mask); - return (ct->ct_error.re_status); - } - if (reply_msg.rm_xid == x_id) - break; - } - - /* - * process header - */ - _seterr_reply(&reply_msg, &(ct->ct_error)); - if (ct->ct_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(cl->cl_auth, - &reply_msg.acpted_rply.ar_verf)) { - ct->ct_error.re_status = RPC_AUTHERROR; - ct->ct_error.re_why = AUTH_INVALIDRESP; - } else if (! AUTH_UNWRAP(cl->cl_auth, xdrs, - xdr_results, results_ptr)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTDECODERES; - } - /* free verifier ... */ - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, - &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else { - /* maybe our credentials need to be refreshed ... */ - if (refreshes-- && AUTH_REFRESH(cl->cl_auth, &reply_msg)) - goto call_again; - } /* end of unsuccessful completion */ - release_fd_lock(ct->ct_fd_lock, mask); - return (ct->ct_error.re_status); -} - -static void -clnt_vc_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; -{ - struct ct_data *ct; - - assert(cl != NULL); - assert(errp != NULL); - - ct = (struct ct_data *) cl->cl_private; - *errp = ct->ct_error; -} - -static bool_t -clnt_vc_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; -{ - struct ct_data *ct; - XDR *xdrs; - bool_t dummy; - sigset_t mask; - sigset_t newmask; - - assert(cl != NULL); - - ct = (struct ct_data *)cl->cl_private; - xdrs = &(ct->ct_xdrs); - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (ct->ct_fd_lock->active) - cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); - xdrs->x_op = XDR_FREE; - dummy = (*xdr_res)(xdrs, res_ptr); - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - cond_signal(&ct->ct_fd_lock->cv); - - return dummy; -} - -/*ARGSUSED*/ -static void -clnt_vc_abort(cl) - CLIENT *cl; -{ -} - -static bool_t -clnt_vc_control(cl, request, info) - CLIENT *cl; - u_int request; - void *info; -{ - struct ct_data *ct; - void *infop = info; - sigset_t mask; - sigset_t newmask; - u_int32_t tmp; - u_int32_t ltmp; - - assert(cl != NULL); - - ct = (struct ct_data *)cl->cl_private; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (ct->ct_fd_lock->active) - cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); - ct->ct_fd_lock->active = TRUE; - mutex_unlock(&clnt_fd_lock); - - switch (request) { - case CLSET_FD_CLOSE: - ct->ct_closeit = TRUE; - release_fd_lock(ct->ct_fd_lock, mask); - return (TRUE); - case CLSET_FD_NCLOSE: - ct->ct_closeit = FALSE; - release_fd_lock(ct->ct_fd_lock, mask); - return (TRUE); - default: - break; - } - - /* for other requests which use info */ - if (info == NULL) { - release_fd_lock(ct->ct_fd_lock, mask); - return (FALSE); - } - switch (request) { - case CLSET_TIMEOUT: - if (time_not_ok((struct timeval *)info)) { - release_fd_lock(ct->ct_fd_lock, mask); - return (FALSE); - } - ct->ct_wait = *(struct timeval *)infop; - ct->ct_waitset = TRUE; - break; - case CLGET_TIMEOUT: - *(struct timeval *)infop = ct->ct_wait; - break; - case CLGET_SERVER_ADDR: - (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len); - break; - case CLGET_FD: - *(int *)info = ct->ct_fd; - break; - case CLGET_SVC_ADDR: - /* The caller should not free this memory area */ - *(struct netbuf *)info = ct->ct_addr; - break; - case CLSET_SVC_ADDR: /* set to new address */ - release_fd_lock(ct->ct_fd_lock, mask); - return (FALSE); - case CLGET_XID: - /* - * use the knowledge that xid is the - * first element in the call structure - * This will get the xid of the PREVIOUS call - */ - *(u_int32_t *)info = - ntohl(*(u_int32_t *)(void *)&ct->ct_u.ct_mcalli); - break; - case CLSET_XID: - /* This will set the xid of the NEXT call */ - *(u_int32_t *)(void *)&ct->ct_u.ct_mcalli = - htonl(*((u_int32_t *)info) + 1); - /* increment by 1 as clnt_vc_call() decrements once */ - break; - case CLGET_VERS: - /* - * This RELIES on the information that, in the call body, - * the version number field is the fifth field from the - * begining of the RPC header. MUST be changed if the - * call_struct is changed - */ - memcpy(&tmp, ct->ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT, sizeof (tmp)); - ltmp = ntohl(tmp); - memcpy(info, <mp, sizeof (ltmp)); - break; - - case CLSET_VERS: - memcpy(<mp, info, sizeof (ltmp)); - tmp = htonl(ltmp); - memcpy(ct->ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT, &tmp, sizeof(tmp)); - break; - - case CLGET_PROG: - /* - * This RELIES on the information that, in the call body, - * the program number field is the fourth field from the - * begining of the RPC header. MUST be changed if the - * call_struct is changed - */ - memcpy(&tmp, ct->ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT, sizeof (tmp)); - ltmp = ntohl (tmp); - memcpy(info, <mp, sizeof (ltmp)); - break; - - case CLSET_PROG: - memcpy(<mp, info, sizeof (ltmp)); - tmp = htonl(ltmp); - memcpy(ct->ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT, &tmp, sizeof(tmp)); - break; - - default: - release_fd_lock(ct->ct_fd_lock, mask); - return (FALSE); - } - release_fd_lock(ct->ct_fd_lock, mask); - return (TRUE); -} - - -static void -clnt_vc_destroy(cl) - CLIENT *cl; -{ - assert(cl != NULL); - struct ct_data *ct = (struct ct_data *) cl->cl_private; - int ct_fd = ct->ct_fd; - fd_lock_t *ct_fd_lock = ct->ct_fd_lock; - sigset_t mask; - sigset_t newmask; - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - while (ct_fd_lock->active) - cond_wait(&ct_fd_lock->cv, &clnt_fd_lock); - if (ct->ct_closeit && ct->ct_fd != -1) { - (void)close(ct->ct_fd); - } - XDR_DESTROY(&(ct->ct_xdrs)); - if (ct->ct_addr.buf) - free(ct->ct_addr.buf); - mem_free(ct, sizeof(struct ct_data)); - if (cl->cl_netid && cl->cl_netid[0]) - mem_free(cl->cl_netid, strlen(cl->cl_netid) +1); - if (cl->cl_tp && cl->cl_tp[0]) - mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); - mem_free(cl, sizeof(CLIENT)); - cond_signal(&ct_fd_lock->cv); - fd_lock_destroy(ct_fd, ct_fd_lock, vc_fd_locks); - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -} - -/* - * Interface between xdr serializer and tcp connection. - * Behaves like the system calls, read & write, but keeps some error state - * around for the rpc level. - */ -static int -read_vc(ctp, buf, len) - void *ctp; - void *buf; - int len; -{ - /* - struct sockaddr sa; - socklen_t sal; - */ - struct ct_data *ct = (struct ct_data *)ctp; - struct pollfd fd; - int milliseconds = (int)((ct->ct_wait.tv_sec * 1000) + - (ct->ct_wait.tv_usec / 1000)); - - if (len == 0) - return (0); - fd.fd = ct->ct_fd; - fd.events = POLLIN; - for (;;) { - switch (poll(&fd, 1, milliseconds)) { - case 0: - ct->ct_error.re_status = RPC_TIMEDOUT; - return (-1); - - case -1: - if (errno == EINTR) - continue; - ct->ct_error.re_status = RPC_CANTRECV; - ct->ct_error.re_errno = errno; - return (-1); - } - break; - } - - len = read(ct->ct_fd, buf, (size_t)len); - - switch (len) { - case 0: - /* premature eof */ - ct->ct_error.re_errno = ECONNRESET; - ct->ct_error.re_status = RPC_CANTRECV; - len = -1; /* it's really an error */ - break; - - case -1: - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTRECV; - break; - } - return (len); -} - -static int -write_vc(ctp, buf, len) - void *ctp; - void *buf; - int len; -{ - struct ct_data *ct = (struct ct_data *)ctp; - int i = 0, cnt; - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(ct->ct_fd, buf, (size_t)cnt)) == -1) { - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTSEND; - return (-1); - } - } - return (len); -} - -static struct clnt_ops * -clnt_vc_ops() -{ - static struct clnt_ops ops; - extern mutex_t ops_lock; - sigset_t mask, newmask; - - /* VARIABLES PROTECTED BY ops_lock: ops */ - - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&ops_lock); - if (ops.cl_call == NULL) { - ops.cl_call = clnt_vc_call; - ops.cl_abort = clnt_vc_abort; - ops.cl_geterr = clnt_vc_geterr; - ops.cl_freeres = clnt_vc_freeres; - ops.cl_destroy = clnt_vc_destroy; - ops.cl_control = clnt_vc_control; - } - mutex_unlock(&ops_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - return (&ops); -} - -/* - * Make sure that the time is not garbage. -1 value is disallowed. - * Note this is different from time_not_ok in clnt_dg.c - */ -static bool_t -time_not_ok(t) - struct timeval *t; -{ - return (t->tv_sec <= -1 || t->tv_sec > 100000000 || - t->tv_usec <= -1 || t->tv_usec > 1000000); -} diff --git a/libtirpc-1.3.1/src/crypt_client.c b/libtirpc-1.3.1/src/crypt_client.c deleted file mode 100644 index cd6f7de..0000000 --- a/libtirpc-1.3.1/src/crypt_client.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 1996 - * Bill Paul . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -#include -#include -#include -#include -#include -#include - -#include - -int -_des_crypt_call(buf, len, dparms) - char *buf; - int len; - struct desparams *dparms; -{ - CLIENT *clnt; - desresp *result_1; - desargs des_crypt_1_arg; - struct netconfig *nconf; - void *localhandle; - int stat; - - nconf = NULL; - localhandle = setnetconfig(); - while ((nconf = getnetconfig(localhandle)) != NULL) { - if (nconf->nc_protofmly != NULL && - strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) - break; - } - if (nconf == NULL) { - warnx("getnetconfig: %s", nc_sperror()); - return(DESERR_HWERROR); - } - clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf); - if (clnt == (CLIENT *) NULL) { - endnetconfig(localhandle); - return(DESERR_HWERROR); - } - endnetconfig(localhandle); - - des_crypt_1_arg.desbuf.desbuf_len = len; - des_crypt_1_arg.desbuf.desbuf_val = buf; - des_crypt_1_arg.des_dir = dparms->des_dir; - des_crypt_1_arg.des_mode = dparms->des_mode; - memcpy(des_crypt_1_arg.des_ivec, dparms->des_ivec, 8); - memcpy(des_crypt_1_arg.des_key, dparms->des_key, 8); - - result_1 = des_crypt_1(&des_crypt_1_arg, clnt); - if (result_1 == (desresp *) NULL) { - clnt_destroy(clnt); - return(DESERR_HWERROR); - } - - stat = result_1->stat; - - if (result_1->stat == DESERR_NONE || - result_1->stat == DESERR_NOHWDEVICE) { - memcpy(buf, result_1->desbuf.desbuf_val, len); - memcpy(dparms->des_ivec, result_1->des_ivec, 8); - } - - clnt_freeres(clnt, (xdrproc_t)xdr_desresp, result_1); - clnt_destroy(clnt); - - return(stat); -} diff --git a/libtirpc-1.3.1/src/debug.c b/libtirpc-1.3.1/src/debug.c deleted file mode 100644 index 332831c..0000000 --- a/libtirpc-1.3.1/src/debug.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * debug.c -- debugging routines for libtirpc - * - * Copyright (C) 2014 Red Hat, Steve Dickson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -/* library global debug level */ -int libtirpc_debug_level = 0; -int log_stderr = 1; /* log to stderr instead of systlog */ - -/* - * Set the debug level for the entire library. - * Different area will used the value to determin - * the verbosity of the debugging output. - */ -void -libtirpc_set_debug(char *name, int level, int use_stderr) -{ - if (level < 0) - level = 0; - - log_stderr = use_stderr; - if (!use_stderr) - openlog(name, LOG_PID, LOG_DAEMON); - - libtirpc_debug_level = level; - LIBTIRPC_DEBUG(1, ("libtirpc: debug level %d", libtirpc_debug_level)); -} - -void -libtirpc_log_dbg(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - if (log_stderr) { - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); - } else - vsyslog(LOG_NOTICE, fmt, args); - va_end(args); -} diff --git a/libtirpc-1.3.1/src/debug.h b/libtirpc-1.3.1/src/debug.h deleted file mode 100644 index 0c98ba4..0000000 --- a/libtirpc-1.3.1/src/debug.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * debug.h -- debugging routines for libtirpc - * - * Copyright (C) 2014 Red Hat, Steve Dickson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEBUG_H -#define _DEBUG_H - -#include -#include - -extern int libtirpc_debug_level; -extern int log_stderr; - -void libtirpc_log_dbg(char *format, ...); -void libtirpc_set_debug(char *name, int level, int use_stderr); - -#define LIBTIRPC_DEBUG(level, msg) \ - do { \ - if (level <= libtirpc_debug_level) \ - libtirpc_log_dbg msg; \ - } while (0) - -static inline void -vlibtirpc_log_dbg(int level, const char *fmt, va_list args) -{ - if (level <= libtirpc_debug_level) { - if (log_stderr) { - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); - } else - vsyslog(LOG_NOTICE, fmt, args); - } -} -#endif /* _DEBUG_H */ diff --git a/libtirpc-1.3.1/src/des_crypt.c b/libtirpc-1.3.1/src/des_crypt.c deleted file mode 100644 index 1d1badd..0000000 --- a/libtirpc-1.3.1/src/des_crypt.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * des_crypt.c, DES encryption library routines - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#if 0 -#ifndef lint -static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; -#endif -#endif - -static int common_crypt( char *, char *, unsigned, unsigned, struct desparams * ); -/* - * Copy 8 bytes - */ -#define COPY8(src, dst) { \ - char *a = (char *) dst; \ - char *b = (char *) src; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ -} - -/* - * Copy multiple of 8 bytes - */ -#define DESCOPY(src, dst, len) { \ - char *a = (char *) dst; \ - char *b = (char *) src; \ - int i; \ - for (i = (int) len; i > 0; i -= 8) { \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - } \ -} - -/* - * CBC mode encryption - */ -int -cbc_crypt(key, buf, len, mode, ivec) - char *key; - char *buf; - unsigned len; - unsigned mode; - char *ivec; -{ - int err; - struct desparams dp; - -#ifdef BROKEN_DES - dp.UDES.UDES_buf = buf; - dp.des_mode = ECB; -#else - dp.des_mode = CBC; -#endif - COPY8(ivec, dp.des_ivec); - err = common_crypt(key, buf, len, mode, &dp); - COPY8(dp.des_ivec, ivec); - return(err); -} - - -/* - * ECB mode encryption - */ -int -ecb_crypt(key, buf, len, mode) - char *key; - char *buf; - unsigned len; - unsigned mode; -{ - struct desparams dp; - -#ifdef BROKEN_DES - dp.UDES.UDES_buf = buf; - dp.des_mode = CBC; -#else - dp.des_mode = ECB; -#endif - return(common_crypt(key, buf, len, mode, &dp)); -} - - - -/* - * Common code to cbc_crypt() & ecb_crypt() - */ -static int -common_crypt(key, buf, len, mode, desp) - char *key; - char *buf; - unsigned len; - unsigned mode; - struct desparams *desp; -{ - int desdev; - - if ((len % 8) != 0 || len > DES_MAXDATA) { - return(DESERR_BADPARAM); - } - desp->des_dir = - ((mode & DES_DIRMASK) == DES_ENCRYPT) ? ENCRYPT : DECRYPT; - - desdev = mode & DES_DEVMASK; - COPY8(key, desp->des_key); - /* - * software - */ - if (!_des_crypt(buf, len, desp)) { - return (DESERR_HWERROR); - } - - return(desdev == DES_SW ? DESERR_NONE : DESERR_NOHWDEVICE); -} diff --git a/libtirpc-1.3.1/src/des_impl.c b/libtirpc-1.3.1/src/des_impl.c deleted file mode 100644 index 15bec2a..0000000 --- a/libtirpc-1.3.1/src/des_impl.c +++ /dev/null @@ -1,594 +0,0 @@ -/* Copyright (C) 1992 Eric Young */ -/* Collected from libdes and modified for SECURE RPC by Martin Kuck 1994 */ -/* This file is distributed under the terms of the GNU Lesser General */ -/* Public License, version 2.1 or later - see the file COPYING.LIB for details.*/ -/* If you did not receive a copy of the license with this program, please*/ -/* see to obtain a copy. */ -#include -#include -#include -#include - - -static const uint32_t des_SPtrans[8][64] = -{ - { /* nibble 0 */ - 0x00820200, 0x00020000, 0x80800000, 0x80820200, - 0x00800000, 0x80020200, 0x80020000, 0x80800000, - 0x80020200, 0x00820200, 0x00820000, 0x80000200, - 0x80800200, 0x00800000, 0x00000000, 0x80020000, - 0x00020000, 0x80000000, 0x00800200, 0x00020200, - 0x80820200, 0x00820000, 0x80000200, 0x00800200, - 0x80000000, 0x00000200, 0x00020200, 0x80820000, - 0x00000200, 0x80800200, 0x80820000, 0x00000000, - 0x00000000, 0x80820200, 0x00800200, 0x80020000, - 0x00820200, 0x00020000, 0x80000200, 0x00800200, - 0x80820000, 0x00000200, 0x00020200, 0x80800000, - 0x80020200, 0x80000000, 0x80800000, 0x00820000, - 0x80820200, 0x00020200, 0x00820000, 0x80800200, - 0x00800000, 0x80000200, 0x80020000, 0x00000000, - 0x00020000, 0x00800000, 0x80800200, 0x00820200, - 0x80000000, 0x80820000, 0x00000200, 0x80020200}, - - { /* nibble 1 */ - 0x10042004, 0x00000000, 0x00042000, 0x10040000, - 0x10000004, 0x00002004, 0x10002000, 0x00042000, - 0x00002000, 0x10040004, 0x00000004, 0x10002000, - 0x00040004, 0x10042000, 0x10040000, 0x00000004, - 0x00040000, 0x10002004, 0x10040004, 0x00002000, - 0x00042004, 0x10000000, 0x00000000, 0x00040004, - 0x10002004, 0x00042004, 0x10042000, 0x10000004, - 0x10000000, 0x00040000, 0x00002004, 0x10042004, - 0x00040004, 0x10042000, 0x10002000, 0x00042004, - 0x10042004, 0x00040004, 0x10000004, 0x00000000, - 0x10000000, 0x00002004, 0x00040000, 0x10040004, - 0x00002000, 0x10000000, 0x00042004, 0x10002004, - 0x10042000, 0x00002000, 0x00000000, 0x10000004, - 0x00000004, 0x10042004, 0x00042000, 0x10040000, - 0x10040004, 0x00040000, 0x00002004, 0x10002000, - 0x10002004, 0x00000004, 0x10040000, 0x00042000}, - - { /* nibble 2 */ - 0x41000000, 0x01010040, 0x00000040, 0x41000040, - 0x40010000, 0x01000000, 0x41000040, 0x00010040, - 0x01000040, 0x00010000, 0x01010000, 0x40000000, - 0x41010040, 0x40000040, 0x40000000, 0x41010000, - 0x00000000, 0x40010000, 0x01010040, 0x00000040, - 0x40000040, 0x41010040, 0x00010000, 0x41000000, - 0x41010000, 0x01000040, 0x40010040, 0x01010000, - 0x00010040, 0x00000000, 0x01000000, 0x40010040, - 0x01010040, 0x00000040, 0x40000000, 0x00010000, - 0x40000040, 0x40010000, 0x01010000, 0x41000040, - 0x00000000, 0x01010040, 0x00010040, 0x41010000, - 0x40010000, 0x01000000, 0x41010040, 0x40000000, - 0x40010040, 0x41000000, 0x01000000, 0x41010040, - 0x00010000, 0x01000040, 0x41000040, 0x00010040, - 0x01000040, 0x00000000, 0x41010000, 0x40000040, - 0x41000000, 0x40010040, 0x00000040, 0x01010000}, - - { /* nibble 3 */ - 0x00100402, 0x04000400, 0x00000002, 0x04100402, - 0x00000000, 0x04100000, 0x04000402, 0x00100002, - 0x04100400, 0x04000002, 0x04000000, 0x00000402, - 0x04000002, 0x00100402, 0x00100000, 0x04000000, - 0x04100002, 0x00100400, 0x00000400, 0x00000002, - 0x00100400, 0x04000402, 0x04100000, 0x00000400, - 0x00000402, 0x00000000, 0x00100002, 0x04100400, - 0x04000400, 0x04100002, 0x04100402, 0x00100000, - 0x04100002, 0x00000402, 0x00100000, 0x04000002, - 0x00100400, 0x04000400, 0x00000002, 0x04100000, - 0x04000402, 0x00000000, 0x00000400, 0x00100002, - 0x00000000, 0x04100002, 0x04100400, 0x00000400, - 0x04000000, 0x04100402, 0x00100402, 0x00100000, - 0x04100402, 0x00000002, 0x04000400, 0x00100402, - 0x00100002, 0x00100400, 0x04100000, 0x04000402, - 0x00000402, 0x04000000, 0x04000002, 0x04100400}, - - { /* nibble 4 */ - 0x02000000, 0x00004000, 0x00000100, 0x02004108, - 0x02004008, 0x02000100, 0x00004108, 0x02004000, - 0x00004000, 0x00000008, 0x02000008, 0x00004100, - 0x02000108, 0x02004008, 0x02004100, 0x00000000, - 0x00004100, 0x02000000, 0x00004008, 0x00000108, - 0x02000100, 0x00004108, 0x00000000, 0x02000008, - 0x00000008, 0x02000108, 0x02004108, 0x00004008, - 0x02004000, 0x00000100, 0x00000108, 0x02004100, - 0x02004100, 0x02000108, 0x00004008, 0x02004000, - 0x00004000, 0x00000008, 0x02000008, 0x02000100, - 0x02000000, 0x00004100, 0x02004108, 0x00000000, - 0x00004108, 0x02000000, 0x00000100, 0x00004008, - 0x02000108, 0x00000100, 0x00000000, 0x02004108, - 0x02004008, 0x02004100, 0x00000108, 0x00004000, - 0x00004100, 0x02004008, 0x02000100, 0x00000108, - 0x00000008, 0x00004108, 0x02004000, 0x02000008}, - - { /* nibble 5 */ - 0x20000010, 0x00080010, 0x00000000, 0x20080800, - 0x00080010, 0x00000800, 0x20000810, 0x00080000, - 0x00000810, 0x20080810, 0x00080800, 0x20000000, - 0x20000800, 0x20000010, 0x20080000, 0x00080810, - 0x00080000, 0x20000810, 0x20080010, 0x00000000, - 0x00000800, 0x00000010, 0x20080800, 0x20080010, - 0x20080810, 0x20080000, 0x20000000, 0x00000810, - 0x00000010, 0x00080800, 0x00080810, 0x20000800, - 0x00000810, 0x20000000, 0x20000800, 0x00080810, - 0x20080800, 0x00080010, 0x00000000, 0x20000800, - 0x20000000, 0x00000800, 0x20080010, 0x00080000, - 0x00080010, 0x20080810, 0x00080800, 0x00000010, - 0x20080810, 0x00080800, 0x00080000, 0x20000810, - 0x20000010, 0x20080000, 0x00080810, 0x00000000, - 0x00000800, 0x20000010, 0x20000810, 0x20080800, - 0x20080000, 0x00000810, 0x00000010, 0x20080010}, - - { /* nibble 6 */ - 0x00001000, 0x00000080, 0x00400080, 0x00400001, - 0x00401081, 0x00001001, 0x00001080, 0x00000000, - 0x00400000, 0x00400081, 0x00000081, 0x00401000, - 0x00000001, 0x00401080, 0x00401000, 0x00000081, - 0x00400081, 0x00001000, 0x00001001, 0x00401081, - 0x00000000, 0x00400080, 0x00400001, 0x00001080, - 0x00401001, 0x00001081, 0x00401080, 0x00000001, - 0x00001081, 0x00401001, 0x00000080, 0x00400000, - 0x00001081, 0x00401000, 0x00401001, 0x00000081, - 0x00001000, 0x00000080, 0x00400000, 0x00401001, - 0x00400081, 0x00001081, 0x00001080, 0x00000000, - 0x00000080, 0x00400001, 0x00000001, 0x00400080, - 0x00000000, 0x00400081, 0x00400080, 0x00001080, - 0x00000081, 0x00001000, 0x00401081, 0x00400000, - 0x00401080, 0x00000001, 0x00001001, 0x00401081, - 0x00400001, 0x00401080, 0x00401000, 0x00001001}, - - { /* nibble 7 */ - 0x08200020, 0x08208000, 0x00008020, 0x00000000, - 0x08008000, 0x00200020, 0x08200000, 0x08208020, - 0x00000020, 0x08000000, 0x00208000, 0x00008020, - 0x00208020, 0x08008020, 0x08000020, 0x08200000, - 0x00008000, 0x00208020, 0x00200020, 0x08008000, - 0x08208020, 0x08000020, 0x00000000, 0x00208000, - 0x08000000, 0x00200000, 0x08008020, 0x08200020, - 0x00200000, 0x00008000, 0x08208000, 0x00000020, - 0x00200000, 0x00008000, 0x08000020, 0x08208020, - 0x00008020, 0x08000000, 0x00000000, 0x00208000, - 0x08200020, 0x08008020, 0x08008000, 0x00200020, - 0x08208000, 0x00000020, 0x00200020, 0x08008000, - 0x08208020, 0x00200000, 0x08200000, 0x08000020, - 0x00208000, 0x00008020, 0x08008020, 0x08200000, - 0x00000020, 0x08208000, 0x00208020, 0x00000000, - 0x08000000, 0x08200020, 0x00008000, 0x00208020}}; - -static const uint32_t des_skb[8][64] = -{ - { /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830}, - { /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404}, - { /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203}, - { /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108}, - { /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004}, - { /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409}, - { /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310}, - { /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822}, -}; - -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8, \ - l|=((unsigned long)(*((c)++)))<<16, \ - l|=((unsigned long)(*((c)++)))<<24) - -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff)) - -/* - * IP and FP - * The problem is more of a geometric problem that random bit fiddling. - * 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 - * 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 - * 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 - * 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 - * - * 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 - * 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 - * 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 - * 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 - * - * The output has been subject to swaps of the form - * 0 1 -> 3 1 but the odd and even bits have been put into - * 2 3 2 0 - * different words. The main trick is to remember that - * t=((l>>size)^r)&(mask); - * r^=t; - * l^=(t<>(n))^(b))&(m)),\ - (b)^=(t),\ - (a)^=((t)<<(n))) - -#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ - (a)=(a)^(t)^(t>>(16-(n)))) - - -#define D_ENCRYPT(L,R,S) \ - u=(R^s[S ]); \ - t=R^s[S+1]; \ - t=((t>>4)+(t<<28)); \ - L^= des_SPtrans[1][(t )&0x3f]| \ - des_SPtrans[3][(t>> 8)&0x3f]| \ - des_SPtrans[5][(t>>16)&0x3f]| \ - des_SPtrans[7][(t>>24)&0x3f]| \ - des_SPtrans[0][(u )&0x3f]| \ - des_SPtrans[2][(u>> 8)&0x3f]| \ - des_SPtrans[4][(u>>16)&0x3f]| \ - des_SPtrans[6][(u>>24)&0x3f]; - -#define ITERATIONS 16 - -static const char shifts2[16] = -{0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0}; - -static void des_set_key (unsigned char *, unsigned long *); -static void des_encrypt (unsigned long *, unsigned long *, int); -int _des_crypt (char *, unsigned, struct desparams *); - -static void -des_set_key (unsigned char *key, unsigned long *schedule) -{ - register unsigned long c, d, t, s; - register unsigned char *in; - register unsigned long *k; - register int i; - - k = (unsigned long *) schedule; - in = key; - - c2l (in, c); - c2l (in, d); - - /* I now do it in 47 simple operations - * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) - * for the inspiration. */ - PERM_OP (d, c, t, 4, 0x0f0f0f0f); - HPERM_OP (c, t, -2, 0xcccc0000); - HPERM_OP (d, t, -2, 0xcccc0000); - PERM_OP (d, c, t, 1, 0x55555555); - PERM_OP (c, d, t, 8, 0x00ff00ff); - PERM_OP (d, c, t, 1, 0x55555555); - d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | - ((d & 0x00ff0000) >> 16) | ((c & 0xf0000000) >> 4)); - c &= 0x0fffffff; - - for (i = 0; i < ITERATIONS; i++) - { - if (shifts2[i]) - { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } - else - { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } - c &= 0x0fffffff; - d &= 0x0fffffff; - /* could be a few less shifts but I am to lazy at this - * point in time to investigate */ - s = des_skb[0][(c) & 0x3f] | - des_skb[1][((c >> 6) & 0x03) | ((c >> 7) & 0x3c)] | - des_skb[2][((c >> 13) & 0x0f) | ((c >> 14) & 0x30)] | - des_skb[3][((c >> 20) & 0x01) | ((c >> 21) & 0x06) | ((c >> 22) & 0x38)]; - t = des_skb[4][(d) & 0x3f] | - des_skb[5][((d >> 7) & 0x03) | ((d >> 8) & 0x3c)] | - des_skb[6][(d >> 15) & 0x3f] | - des_skb[7][((d >> 21) & 0x0f) | ((d >> 22) & 0x30)]; - - /* table contained 0213 4657 */ - *(k++) = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; - s = ((s >> 16) | (t & 0xffff0000)); - - s = (s << 4) | (s >> 28); - *(k++) = s & 0xffffffff; - } -} - - -static void -des_encrypt (unsigned long *buf, unsigned long *schedule, int encrypt) -{ - register unsigned long l, r, t, u; - register int i; - register unsigned long *s; - - l = buf[0]; - r = buf[1]; - - /* do IP */ - PERM_OP (r, l, t, 4, 0x0f0f0f0f); - PERM_OP (l, r, t, 16, 0x0000ffff); - PERM_OP (r, l, t, 2, 0x33333333); - PERM_OP (l, r, t, 8, 0x00ff00ff); - PERM_OP (r, l, t, 1, 0x55555555); - /* r and l are reversed - remember that - fix - * it in the next step */ - - /* Things have been modified so that the initial rotate is - * done outside the loop. This required the - * des_SPtrans values in sp.h to be rotated 1 bit to the right. - * One perl script later and things have a 5% speed up on a sparc2. - * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> - * for pointing this out. */ - t = (r << 1) | (r >> 31); - r = (l << 1) | (l >> 31); - l = t; - - /* clear the top bits on machines with 8byte longs */ - l &= 0xffffffff; - r &= 0xffffffff; - - s = (unsigned long *) schedule; - /* I don't know if it is worth the effort of loop unrolling the - * inner loop */ - if (encrypt) - { - for (i = 0; i < 32; i += 4) - { - D_ENCRYPT (l, r, i + 0); /* 1 */ - D_ENCRYPT (r, l, i + 2); /* 2 */ - } - } - else - { - for (i = 30; i > 0; i -= 4) - { - D_ENCRYPT (l, r, i - 0); /* 16 */ - D_ENCRYPT (r, l, i - 2); /* 15 */ - } - } - l = (l >> 1) | (l << 31); - r = (r >> 1) | (r << 31); - /* clear the top bits on machines with 8byte longs */ - l &= 0xffffffff; - r &= 0xffffffff; - - /* swap l and r - * we will not do the swap so just remember they are - * reversed for the rest of the subroutine - * luckily FP fixes this problem */ - - PERM_OP (r, l, t, 1, 0x55555555); - PERM_OP (l, r, t, 8, 0x00ff00ff); - PERM_OP (r, l, t, 2, 0x33333333); - PERM_OP (l, r, t, 16, 0x0000ffff); - PERM_OP (r, l, t, 4, 0x0f0f0f0f); - - buf[0] = l; - buf[1] = r; - - l = r = t = u = 0; -} - - -int -_des_crypt (char *buf, unsigned len, struct desparams *desp) -{ - unsigned long schedule[32]; - register unsigned long tin0, tin1; - register unsigned long tout0, tout1, xor0, xor1; - register unsigned char *in, *out; - unsigned long tbuf[2]; - unsigned char *iv, *oiv; - int cbc_mode; - - cbc_mode = (desp->des_mode == CBC) ? 1 : 0; - - in = (unsigned char *) buf; - out = (unsigned char *) buf; - oiv = iv = (unsigned char *) desp->des_ivec; - - des_set_key (desp->des_key, schedule); - - tin0 = tin1 = 0; /* For GCC */ - if (desp->des_dir == ENCRYPT) - { - c2l (iv, tout0); - c2l (iv, tout1); - for (; len > 0; len -= 8) - { - c2l (in, tin0); - c2l (in, tin1); - if (cbc_mode) - { - tin0 ^= tout0; - tin1 ^= tout1; - } - tbuf[0] = tin0; - tbuf[1] = tin1; - des_encrypt (tbuf, schedule, 1); - tout0 = tbuf[0]; - tout1 = tbuf[1]; - l2c (tout0, out); - l2c (tout1, out); - } - l2c (tout0, oiv); - l2c (tout1, oiv); - } - else - { - c2l (iv, xor0); - c2l (iv, xor1); - for (; len > 0; len -= 8) - { - c2l (in, tin0); - c2l (in, tin1); - tbuf[0] = tin0; - tbuf[1] = tin1; - des_encrypt (tbuf, schedule, 0); - if (cbc_mode) - { - tout0 = tbuf[0] ^ xor0; - tout1 = tbuf[1] ^ xor1; - xor0 = tin0; - xor1 = tin1; - } - else - { - tout0 = tbuf[0]; - tout1 = tbuf[1]; - } - l2c (tout0, out); - l2c (tout1, out); - } - l2c (tin0, oiv); - l2c (tin1, oiv); - } - tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; - tbuf[0] = tbuf[1] = 0; - memset (schedule, 0, sizeof (schedule)); - - return (1); -} diff --git a/libtirpc-1.3.1/src/des_soft.c b/libtirpc-1.3.1/src/des_soft.c deleted file mode 100644 index e6fdf20..0000000 --- a/libtirpc-1.3.1/src/des_soft.c +++ /dev/null @@ -1,65 +0,0 @@ -//#include - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Table giving odd parity in the low bit for ASCII characters - */ -static char partab[128] = { - 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, - 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, - 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, - 0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f, - 0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26, - 0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f, - 0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37, - 0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e, - 0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46, - 0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f, - 0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57, - 0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e, - 0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67, - 0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e, - 0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76, - 0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f, -}; - -/* - * Add odd parity to low bit of 8 byte key - */ -void -des_setparity(p) - char *p; -{ - int i; - - for (i = 0; i < 8; i++) { - *p = partab[*p & 0x7f]; - p++; - } -} diff --git a/libtirpc-1.3.1/src/epoll_sub.c b/libtirpc-1.3.1/src/epoll_sub.c deleted file mode 100644 index 16583ba..0000000 --- a/libtirpc-1.3.1/src/epoll_sub.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2003 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include -#include -#include -#include -#include - - -/*Paramètres du syscall - Attention spécifique hardware */ -#define __NR_epoll_create 254 -#define __NR_epoll_ctl 255 -#define __NR_epoll_wait 256 - -int -epoll_create(int size) -{ - return (syscall(__NR_epoll_create, size)); -} - -int -epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) -{ - - return (syscall(__NR_epoll_ctl, epfd, op, fd, event)); -} - -int -epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) -{ - return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); -} diff --git a/libtirpc-1.3.1/src/getnetconfig.c b/libtirpc-1.3.1/src/getnetconfig.c deleted file mode 100644 index cfd33c2..0000000 --- a/libtirpc-1.3.1/src/getnetconfig.c +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1989 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_com.h" - -/* - * The five library routines in this file provide application access to the - * system network configuration database, /etc/netconfig. In addition to the - * netconfig database and the routines for accessing it, the environment - * variable NETPATH and its corresponding routines in getnetpath.c may also be - * used to specify the network transport to be used. - */ - -/* - * netconfig errors - */ - -#define NC_NONETCONFIG ENOENT -#define NC_NOMEM ENOMEM -#define NC_NOTINIT EINVAL /* setnetconfig was not called first */ -#define NC_BADFILE EBADF /* format for netconfig file is bad */ -#define NC_NOTFOUND ENOPROTOOPT /* specified netid was not found */ - -/* - * semantics as strings (should be in netconfig.h) - */ -#define NC_TPI_CLTS_S "tpi_clts" -#define NC_TPI_COTS_S "tpi_cots" -#define NC_TPI_COTS_ORD_S "tpi_cots_ord" -#define NC_TPI_RAW_S "tpi_raw" - -/* - * flags as characters (also should be in netconfig.h) - */ -#define NC_NOFLAG_C '-' -#define NC_VISIBLE_C 'v' -#define NC_BROADCAST_C 'b' - -/* - * Character used to indicate there is no name-to-address lookup library - */ -#define NC_NOLOOKUP "-" - -static const char * const _nc_errors[] = { - "Netconfig database not found", - "Not enough memory", - "Not initialized", - "Netconfig database has invalid format", - "Netid not found in netconfig database" -}; - -struct netconfig_info { - int eof; /* all entries has been read */ - int ref; /* # of times setnetconfig() has been called */ - struct netconfig_list *head; /* head of the list */ - struct netconfig_list *tail; /* last of the list */ -}; - -struct netconfig_list { - char *linep; /* hold line read from netconfig */ - struct netconfig *ncp; - struct netconfig_list *next; -}; - -struct netconfig_vars { - int valid; /* token that indicates a valid netconfig_vars */ - int flag; /* first time flag */ - struct netconfig_list *nc_configs; /* pointer to the current netconfig entry */ -}; - -#define NC_VALID 0xfeed -#define NC_STORAGE 0xf00d -#define NC_INVALID 0 - - -static int *__nc_error(void); -static int parse_ncp(char *, struct netconfig *); -static struct netconfig *dup_ncp(struct netconfig *); - - -static FILE *nc_file; /* for netconfig db */ -static struct netconfig_info ni = { 0, 0, NULL, NULL}; -extern pthread_mutex_t nc_db_lock; - -#define MAXNETCONFIGLINE 1000 - -static int * -__nc_error() -{ - static pthread_mutex_t nc_lock = PTHREAD_MUTEX_INITIALIZER; - extern thread_key_t nc_key; - static int nc_error = 0; - int error, *nc_addr; - - /* - * Use the static `nc_error' if we are the main thread - * (including non-threaded programs), or if an allocation - * fails. - */ - if (nc_key == KEY_INITIALIZER) { - error = 0; - mutex_lock(&nc_lock); - if (nc_key == KEY_INITIALIZER) - error = thr_keycreate(&nc_key, free); - mutex_unlock(&nc_lock); - if (error) - return (&nc_error); - } - if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) { - if((nc_addr = (int *)malloc(sizeof (int))) == NULL) - return (&nc_error); - if (thr_setspecific(nc_key, (void *) nc_addr) != 0) { - if (nc_addr) - free(nc_addr); - return (&nc_error); - } - *nc_addr = 0; - } - return (nc_addr); -} - -#define nc_error (*(__nc_error())) -/* - * A call to setnetconfig() establishes a /etc/netconfig "session". A session - * "handle" is returned on a successful call. At the start of a session (after - * a call to setnetconfig()) searches through the /etc/netconfig database will - * proceed from the start of the file. The session handle must be passed to - * getnetconfig() to parse the file. Each call to getnetconfig() using the - * current handle will process one subsequent entry in /etc/netconfig. - * setnetconfig() must be called before the first call to getnetconfig(). - * (Handles are used to allow for nested calls to setnetpath()). - * - * A new session is established with each call to setnetconfig(), with a new - * handle being returned on each call. Previously established sessions remain - * active until endnetconfig() is called with that session's handle as an - * argument. - * - * setnetconfig() need *not* be called before a call to getnetconfigent(). - * setnetconfig() returns a NULL pointer on failure (for example, if - * the netconfig database is not present). - */ -void * -setnetconfig() -{ - struct netconfig_vars *nc_vars; - - if ((nc_vars = (struct netconfig_vars *)malloc(sizeof - (struct netconfig_vars))) == NULL) { - return(NULL); - } - - /* - * For multiple calls, i.e. nc_file is not NULL, we just return the - * handle without reopening the netconfig db. - */ - mutex_lock(&nc_db_lock); - ni.ref++; - if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "r")) != NULL) { - nc_vars->valid = NC_VALID; - nc_vars->flag = 0; - nc_vars->nc_configs = ni.head; - mutex_unlock(&nc_db_lock); - return ((void *)nc_vars); - } - ni.ref--; - mutex_unlock(&nc_db_lock); - nc_error = NC_NONETCONFIG; - free(nc_vars); - return (NULL); -} - - -/* - * When first called, getnetconfig() returns a pointer to the first entry in - * the netconfig database, formatted as a struct netconfig. On each subsequent - * call, getnetconfig() returns a pointer to the next entry in the database. - * getnetconfig() can thus be used to search the entire netconfig file. - * getnetconfig() returns NULL at end of file. - */ - -struct netconfig * -getnetconfig(handlep) -void *handlep; -{ - struct netconfig_vars *ncp = (struct netconfig_vars *)handlep; - char *stringp; /* tmp string pointer */ - struct netconfig_list *list; - struct netconfig *np; - struct netconfig *result; - - /* - * Verify that handle is valid - */ - mutex_lock(&nc_db_lock); - if (ncp == NULL || nc_file == NULL) { - nc_error = NC_NOTINIT; - mutex_unlock(&nc_db_lock); - return (NULL); - } - - switch (ncp->valid) { - case NC_VALID: - /* - * If entry has already been read into the list, - * we return the entry in the linked list. - * If this is the first time call, check if there are any entries in - * linked list. If no entries, we need to read the netconfig db. - * If we have been here and the next entry is there, we just return - * it. - */ - if (ncp->flag == 0) { /* first time */ - ncp->flag = 1; - ncp->nc_configs = ni.head; - if (ncp->nc_configs != NULL) /* entry already exist */ { - mutex_unlock(&nc_db_lock); - return(ncp->nc_configs->ncp); - } - } - else if (ncp->nc_configs != NULL && ncp->nc_configs->next != NULL) { - ncp->nc_configs = ncp->nc_configs->next; - mutex_unlock(&nc_db_lock); - return(ncp->nc_configs->ncp); - } - - /* - * If we cannot find the entry in the list and is end of file, - * we give up. - */ - if (ni.eof == 1) { - mutex_unlock(&nc_db_lock); - return(NULL); - } - break; - default: - nc_error = NC_NOTINIT; - mutex_unlock(&nc_db_lock); - return (NULL); - } - - stringp = (char *) malloc(MAXNETCONFIGLINE); - if (stringp == NULL) { - mutex_unlock(&nc_db_lock); - return (NULL); - } - -#ifdef MEM_CHK - if (malloc_verify() == 0) { - fprintf(stderr, "memory heap corrupted in getnetconfig\n"); - exit(1); - } -#endif - - /* - * Read a line from netconfig file. - */ - do { - if (fgets(stringp, MAXNETCONFIGLINE, nc_file) == NULL) { - free(stringp); - ni.eof = 1; - mutex_unlock(&nc_db_lock); - return (NULL); - } - } while (*stringp == '#'); - - list = (struct netconfig_list *) malloc(sizeof (struct netconfig_list)); - if (list == NULL) { - free(stringp); - mutex_unlock(&nc_db_lock); - return(NULL); - } - np = (struct netconfig *) malloc(sizeof (struct netconfig)); - if (np == NULL) { - free(stringp); - free(list); - mutex_unlock(&nc_db_lock); - return(NULL); - } - list->ncp = np; - list->next = NULL; - list->ncp->nc_lookups = NULL; - list->linep = stringp; - if (parse_ncp(stringp, list->ncp) == -1) { - free(stringp); - free(np); - free(list); - mutex_unlock(&nc_db_lock); - return (NULL); - } - else { - /* - * If this is the first entry that's been read, it is the head of - * the list. If not, put the entry at the end of the list. - * Reposition the current pointer of the handle to the last entry - * in the list. - */ - if (ni.head == NULL) { /* first entry */ - ni.head = ni.tail = list; - } - else { - ni.tail->next = list; - ni.tail = ni.tail->next; - } - ncp->nc_configs = ni.tail; - result = ni.tail->ncp; - mutex_unlock(&nc_db_lock); - return result; - } -} - -/* - * endnetconfig() may be called to "unbind" or "close" the netconfig database - * when processing is complete, releasing resources for reuse. endnetconfig() - * may not be called before setnetconfig(). endnetconfig() returns 0 on - * success and -1 on failure (for example, if setnetconfig() was not called - * previously). - */ -int -endnetconfig(handlep) -void *handlep; -{ - struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep; - - struct netconfig_list *q, *p; - - /* - * Verify that handle is valid - */ - if (nc_handlep == NULL || (nc_handlep->valid != NC_VALID && - nc_handlep->valid != NC_STORAGE)) { - nc_error = NC_NOTINIT; - return (-1); - } - - /* - * Return 0 if anyone still needs it. - */ - nc_handlep->valid = NC_INVALID; - nc_handlep->flag = 0; - nc_handlep->nc_configs = NULL; - mutex_lock(&nc_db_lock); - if (--ni.ref > 0) { - mutex_unlock(&nc_db_lock); - free(nc_handlep); - return(0); - } - - /* - * Noone needs these entries anymore, then frees them. - * Make sure all info in netconfig_info structure has been reinitialized. - */ - q = p = ni.head; - ni.eof = ni.ref = 0; - ni.head = NULL; - ni.tail = NULL; - while (q) { - p = q->next; - if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups); - free(q->ncp); - free(q->linep); - free(q); - q = p; - } - free(nc_handlep); - if(nc_file != NULL) { - fclose(nc_file); - } - nc_file = NULL; - mutex_unlock(&nc_db_lock); - return (0); -} - -/* - * getnetconfigent(netid) returns a pointer to the struct netconfig structure - * corresponding to netid. It returns NULL if netid is invalid (that is, does - * not name an entry in the netconfig database). It returns NULL and sets - * errno in case of failure (for example, if the netconfig database cannot be - * opened). - */ - -struct netconfig * -getnetconfigent(netid) - const char *netid; -{ - FILE *file; /* NETCONFIG db's file pointer */ - char *linep; /* holds current netconfig line */ - char *stringp; /* temporary string pointer */ - struct netconfig *ncp = NULL; /* returned value */ - struct netconfig_list *list; /* pointer to cache list */ - - nc_error = NC_NOTFOUND; /* default error. */ - if (netid == NULL || strlen(netid) == 0) { - return (NULL); - } - - if (strcmp(netid, "unix") == 0) { - fprintf(stderr, "The local transport is called \"unix\" "); - fprintf(stderr, "in /etc/netconfig.\n"); - fprintf(stderr, "Please change this to \"local\" manually "); - fprintf(stderr, "or run mergemaster(8).\n"); - fprintf(stderr, "See UPDATING entry 20021216 for details.\n"); - fprintf(stderr, "Continuing in 10 seconds\n\n"); - fprintf(stderr, "This warning will be removed 20030301\n"); - sleep(10); - - } - - /* - * Look up table if the entries have already been read and parsed in - * getnetconfig(), then copy this entry into a buffer and return it. - * If we cannot find the entry in the current list and there are more - * entries in the netconfig db that has not been read, we then read the - * db and try find the match netid. - * If all the netconfig db has been read and placed into the list and - * there is no match for the netid, return NULL. - */ - mutex_lock(&nc_db_lock); - if (ni.head != NULL) { - for (list = ni.head; list; list = list->next) { - if (strcmp(list->ncp->nc_netid, netid) == 0) { - ncp = dup_ncp(list->ncp); - mutex_unlock(&nc_db_lock); - return ncp; - } - } - if (ni.eof == 1) { /* that's all the entries */ - mutex_unlock(&nc_db_lock); - return(NULL); - } - } - mutex_unlock(&nc_db_lock); - - if ((file = fopen(NETCONFIG, "r")) == NULL) { - nc_error = NC_NONETCONFIG; - return (NULL); - } - - if ((linep = malloc(MAXNETCONFIGLINE)) == NULL) { - fclose(file); - nc_error = NC_NOMEM; - return (NULL); - } - do { - ptrdiff_t len; - char *tmpp; /* tmp string pointer */ - - do { - if ((stringp = fgets(linep, MAXNETCONFIGLINE, file)) == NULL) { - break; - } - } while (*stringp == '#'); - if (stringp == NULL) { /* eof */ - break; - } - if ((tmpp = strpbrk(stringp, "\t ")) == NULL) { /* can't parse file */ - nc_error = NC_BADFILE; - break; - } - if (strlen(netid) == (size_t) (len = tmpp - stringp) && /* a match */ - strncmp(stringp, netid, (size_t)len) == 0) { - if ((ncp = (struct netconfig *) - malloc(sizeof (struct netconfig))) == NULL) { - break; - } - ncp->nc_lookups = NULL; - if (parse_ncp(linep, ncp) == -1) { - free(ncp); - ncp = NULL; - } - break; - } - } while (stringp != NULL); - if (ncp == NULL) { - free(linep); - } - fclose(file); - return(ncp); -} - -/* - * freenetconfigent(netconfigp) frees the netconfig structure pointed to by - * netconfigp (previously returned by getnetconfigent()). - */ - -void -freenetconfigent(netconfigp) - struct netconfig *netconfigp; -{ - if (netconfigp != NULL) { - free(netconfigp->nc_netid); /* holds all netconfigp's strings */ - if (netconfigp->nc_lookups != NULL) - free(netconfigp->nc_lookups); - free(netconfigp); - } - return; -} - -/* - * Parse line and stuff it in a struct netconfig - * Typical line might look like: - * udp tpi_cots vb inet udp /dev/udp /usr/lib/ip.so,/usr/local/ip.so - * - * We return -1 if any of the tokens don't parse, or malloc fails. - * - * Note that we modify stringp (putting NULLs after tokens) and - * we set the ncp's string field pointers to point to these tokens within - * stringp. - */ - -static int -parse_ncp(stringp, ncp) -char *stringp; /* string to parse */ -struct netconfig *ncp; /* where to put results */ -{ - char *tokenp; /* for processing tokens */ - char *lasts; - - nc_error = NC_BADFILE; /* nearly anything that breaks is for this reason */ - stringp[strlen(stringp)-1] = '\0'; /* get rid of newline */ - /* netid */ - if ((ncp->nc_netid = strtok_r(stringp, "\t ", &lasts)) == NULL) { - return (-1); - } - - /* semantics */ - if ((tokenp = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - if (strcmp(tokenp, NC_TPI_COTS_ORD_S) == 0) - ncp->nc_semantics = NC_TPI_COTS_ORD; - else if (strcmp(tokenp, NC_TPI_COTS_S) == 0) - ncp->nc_semantics = NC_TPI_COTS; - else if (strcmp(tokenp, NC_TPI_CLTS_S) == 0) - ncp->nc_semantics = NC_TPI_CLTS; - else if (strcmp(tokenp, NC_TPI_RAW_S) == 0) - ncp->nc_semantics = NC_TPI_RAW; - else - return (-1); - - /* flags */ - if ((tokenp = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - for (ncp->nc_flag = NC_NOFLAG; *tokenp != '\0'; - tokenp++) { - switch (*tokenp) { - case NC_NOFLAG_C: - break; - case NC_VISIBLE_C: - ncp->nc_flag |= NC_VISIBLE; - break; - case NC_BROADCAST_C: - ncp->nc_flag |= NC_BROADCAST; - break; - default: - return (-1); - } - } - /* protocol family */ - if ((ncp->nc_protofmly = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - /* protocol name */ - if ((ncp->nc_proto = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - /* network device */ - if ((ncp->nc_device = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - if ((tokenp = strtok_r(NULL, "\t ", &lasts)) == NULL) { - return (-1); - } - if (strcmp(tokenp, NC_NOLOOKUP) == 0) { - ncp->nc_nlookups = 0; - ncp->nc_lookups = NULL; - } else { - char *cp; /* tmp string */ - - if (ncp->nc_lookups != NULL) /* from last visit */ - free(ncp->nc_lookups); - /* preallocate one string pointer */ - ncp->nc_lookups = (char **)malloc(sizeof (char *)); - ncp->nc_nlookups = 0; - while ((cp = tokenp) != NULL) { - tokenp = _get_next_token(cp, ','); - ncp->nc_lookups[(size_t)ncp->nc_nlookups++] = cp; - ncp->nc_lookups = (char **)realloc(ncp->nc_lookups, - (size_t)(ncp->nc_nlookups+1) *sizeof(char *)); /* for next loop */ - } - } - return (0); -} - - -/* - * Returns a string describing the reason for failure. - */ -char * -nc_sperror() -{ - const char *message; - - switch(nc_error) { - case NC_NONETCONFIG: - message = _nc_errors[0]; - break; - case NC_NOMEM: - message = _nc_errors[1]; - break; - case NC_NOTINIT: - message = _nc_errors[2]; - break; - case NC_BADFILE: - message = _nc_errors[3]; - break; - case NC_NOTFOUND: - message = _nc_errors[4]; - break; - default: - message = "Unknown network selection error"; - } - /* LINTED const castaway */ - return ((char *)message); -} - -/* - * Prints a message onto standard error describing the reason for failure. - */ -void -nc_perror(s) - const char *s; -{ - fprintf(stderr, "%s: %s\n", s, nc_sperror()); -} - -/* - * Duplicates the matched netconfig buffer. - */ -static struct netconfig * -dup_ncp(ncp) -struct netconfig *ncp; -{ - struct netconfig *p; - char *tmp; - char *t; - u_int i; - - if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL) - return(NULL); - if ((p=(struct netconfig *)malloc(sizeof(struct netconfig))) == NULL) { - free(tmp); - return(NULL); - } - /* - * First we dup all the data from matched netconfig buffer. Then we - * adjust some of the member pointer to a pre-allocated buffer where - * contains part of the data. - * To follow the convention used in parse_ncp(), we store all the - * necessary information in the pre-allocated buffer and let each - * of the netconfig char pointer member point to the right address - * in the buffer. - */ - *p = *ncp; - p->nc_netid = (char *)strcpy(tmp,ncp->nc_netid); - t = strchr(tmp, 0) + 1; - p->nc_protofmly = (char *)strcpy(t,ncp->nc_protofmly); - t = strchr(t, 0) + 1; - p->nc_proto = (char *)strcpy(t,ncp->nc_proto); - t = strchr(t, 0) + 1; - p->nc_device = (char *)strcpy(t,ncp->nc_device); - p->nc_lookups = (char **)malloc((size_t)(p->nc_nlookups+1) * sizeof(char *)); - if (p->nc_lookups == NULL) { - free(p); - free(tmp); - return(NULL); - } - for (i=0; i < p->nc_nlookups; i++) { - t = strchr(t, 0) + 1; - p->nc_lookups[i] = (char *)strcpy(t,ncp->nc_lookups[i]); - } - return(p); -} diff --git a/libtirpc-1.3.1/src/getnetpath.c b/libtirpc-1.3.1/src/getnetpath.c deleted file mode 100644 index ea1a18c..0000000 --- a/libtirpc-1.3.1/src/getnetpath.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1989 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include - -/* - * internal structure to keep track of a netpath "session" - */ -struct netpath_chain { - struct netconfig *ncp; /* an nconf entry */ - struct netpath_chain *nchain_next; /* next nconf entry allocated */ -}; - - -struct netpath_vars { - int valid; /* token that indicates a valid netpath_vars */ - void *nc_handlep; /* handle for current netconfig "session" */ - char *netpath; /* pointer to current view-point in NETPATH */ - char *netpath_start; /* pointer to start of our copy of NETPATH */ - struct netpath_chain *ncp_list; /* list of nconfs allocated this session*/ -}; - -#define NP_VALID 0xf00d -#define NP_INVALID 0 - -char *_get_next_token(char *, int); - - -/* - * A call to setnetpath() establishes a NETPATH "session". setnetpath() - * must be called before the first call to getnetpath(). A "handle" is - * returned to distinguish the session; this handle should be passed - * subsequently to getnetpath(). (Handles are used to allow for nested calls - * to setnetpath()). - * If setnetpath() is unable to establish a session (due to lack of memory - * resources, or the absence of the /etc/netconfig file), a NULL pointer is - * returned. - */ - -void * -setnetpath() -{ - - struct netpath_vars *np_sessionp; /* this session's variables */ - char *npp; /* NETPATH env variable */ - -#ifdef MEM_CHK - malloc_debug(1); -#endif - - if ((np_sessionp = - (struct netpath_vars *)malloc(sizeof (struct netpath_vars))) == NULL) { - return (NULL); - } - if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) { - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - free(np_sessionp); - return (NULL); - } - np_sessionp->valid = NP_VALID; - np_sessionp->ncp_list = NULL; - if ((npp = getenv(NETPATH)) == NULL) { - np_sessionp->netpath = NULL; - } else { - (void) endnetconfig(np_sessionp->nc_handlep);/* won't need nc session*/ - np_sessionp->nc_handlep = NULL; - if ((np_sessionp->netpath = malloc(strlen(npp)+1)) == NULL) { - free(np_sessionp); - return (NULL); - } else { - (void) strcpy(np_sessionp->netpath, npp); - } - } - np_sessionp->netpath_start = np_sessionp->netpath; - return ((void *)np_sessionp); -} - -/* - * When first called, getnetpath() returns a pointer to the netconfig - * database entry corresponding to the first valid NETPATH component. The - * netconfig entry is formatted as a struct netconfig. - * On each subsequent call, getnetpath returns a pointer to the netconfig - * entry that corresponds to the next valid NETPATH component. getnetpath - * can thus be used to search the netconfig database for all networks - * included in the NETPATH variable. - * When NETPATH has been exhausted, getnetpath() returns NULL. It returns - * NULL and sets errno in case of an error (e.g., setnetpath was not called - * previously). - * getnetpath() silently ignores invalid NETPATH components. A NETPATH - * compnent is invalid if there is no corresponding entry in the netconfig - * database. - * If the NETPATH variable is unset, getnetpath() behaves as if NETPATH - * were set to the sequence of default or visible networks in the netconfig - * database, in the order in which they are listed. - */ - -struct netconfig * -getnetpath(handlep) - void *handlep; -{ - struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep; - struct netconfig *ncp = NULL; /* temp. holds a netconfig session */ - struct netpath_chain *chainp; /* holds chain of ncp's we alloc */ - char *npp; /* holds current NETPATH */ - - if (np_sessionp == NULL || np_sessionp->valid != NP_VALID) { - errno = EINVAL; - return (NULL); - } - if (np_sessionp->netpath_start == NULL) { /* NETPATH was not set */ - do { /* select next visible network */ - if (np_sessionp->nc_handlep == NULL) { - np_sessionp->nc_handlep = setnetconfig(); - if (np_sessionp->nc_handlep == NULL) - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - } - if ((ncp = getnetconfig(np_sessionp->nc_handlep)) == NULL) { - return(NULL); - } - } while ((ncp->nc_flag & NC_VISIBLE) == 0); - return (ncp); - } - /* - * Find first valid network ID in netpath. - */ - while ((npp = np_sessionp->netpath) != NULL && strlen(npp) != 0) { - np_sessionp->netpath = _get_next_token(npp, ':'); - /* - * npp is a network identifier. - */ - if ((ncp = getnetconfigent(npp)) != NULL) { - chainp = (struct netpath_chain *) /* cobble alloc chain entry */ - malloc(sizeof (struct netpath_chain)); - chainp->ncp = ncp; - chainp->nchain_next = NULL; - if (np_sessionp->ncp_list == NULL) { - np_sessionp->ncp_list = chainp; - } else { - np_sessionp->ncp_list->nchain_next = chainp; - } - return (ncp); - } - /* couldn't find this token in the database; go to next one. */ - } - return (NULL); -} - -/* - * endnetpath() may be called to unbind NETPATH when processing is complete, - * releasing resources for reuse. It returns 0 on success and -1 on failure - * (e.g. if setnetpath() was not called previously. - */ -int -endnetpath(handlep) - void *handlep; -{ - struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep; - struct netpath_chain *chainp, *lastp; - - if (np_sessionp == NULL || np_sessionp->valid != NP_VALID) { - errno = EINVAL; - return (-1); - } - if (np_sessionp->nc_handlep != NULL) - endnetconfig(np_sessionp->nc_handlep); - if (np_sessionp->netpath_start != NULL) - free(np_sessionp->netpath_start); - for (chainp = np_sessionp->ncp_list; chainp != NULL; - lastp=chainp, chainp=chainp->nchain_next, free(lastp)) { - freenetconfigent(chainp->ncp); - } - free(np_sessionp); -#ifdef MEM_CHK - if (malloc_verify() == 0) { - fprintf(stderr, "memory heap corrupted in endnetpath\n"); - exit(1); - } -#endif - return (0); -} - - - -/* - * Returns pointer to the rest-of-the-string after the current token. - * The token itself starts at arg, and we null terminate it. We return NULL - * if either the arg is empty, or if this is the last token. - */ - -char * -_get_next_token(npp, token) -char *npp; /* string */ -int token; /* char to parse string for */ -{ - char *cp; /* char pointer */ - char *np; /* netpath pointer */ - char *ep; /* escape pointer */ - - if ((cp = strchr(npp, token)) == NULL) { - return (NULL); - } - /* - * did find a token, but it might be escaped. - */ - if ((cp > npp) && (cp[-1] == '\\')) { - /* if slash was also escaped, carry on, otherwise find next token */ - if ((cp > npp + 1) && (cp[-2] != '\\')) { - /* shift r-o-s onto the escaped token */ - strcpy(&cp[-1], cp); /* XXX: overlapping string copy */ - /* - * Do a recursive call. - * We don't know how many escaped tokens there might be. - */ - return (_get_next_token(cp, token)); - } - } - - *cp++ = '\0'; /* null-terminate token */ - /* get rid of any backslash escapes */ - ep = npp; - while ((np = strchr(ep, '\\')) != 0) { - if (np[1] == '\\') - np++; - strcpy(np, (ep = &np[1])); /* XXX: overlapping string copy */ - } - return (cp); /* return ptr to r-o-s */ -} diff --git a/libtirpc-1.3.1/src/getpeereid.c b/libtirpc-1.3.1/src/getpeereid.c deleted file mode 100644 index dd85270..0000000 --- a/libtirpc-1.3.1/src/getpeereid.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001 Dima Dorfman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -#include -#include -#include - -#include -#include - -int -getpeereid(int s, uid_t *euid, gid_t *egid) -{ - struct ucred uc; - socklen_t uclen; - int error; - - uclen = sizeof(uc); - error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /* SCM_CREDENTIALS */ - if (error != 0) - return (error); - // if (uc.cr_version != XUCRED_VERSION) - // return (EINVAL); - *euid = uc.uid; - *egid = uc.gid; - return (0); - } diff --git a/libtirpc-1.3.1/src/getpublickey.c b/libtirpc-1.3.1/src/getpublickey.c deleted file mode 100644 index be37a24..0000000 --- a/libtirpc-1.3.1/src/getpublickey.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * publickey.c - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -/* - * Public key lookup routines - */ -#include -#include -#include -#include -#ifdef YP -#include -#include -#endif -#include -#include - -#include "debug.h" - -#define PKFILE "/etc/publickey" - -/* - * Hack to let ypserv/rpc.nisd use AUTH_DES. - */ -int (*__getpublickey_LOCAL)() = 0; - -/* - * Get somebody's public key - */ -int -__getpublickey_real(netname, publickey) - char *netname; - char *publickey; -{ - char lookup[3 * HEXKEYBYTES]; - char *p; - - if (publickey == NULL) - return (0); - if (!getpublicandprivatekey(netname, lookup)) - return (0); - p = strchr(lookup, ':'); - if (p == NULL) { - return (0); - } - *p = '\0'; - memcpy(publickey, lookup, HEXKEYBYTES); - publickey[HEXKEYBYTES] = '\0'; - return (1); -} - -/* - * reads the file /etc/publickey looking for a + to optionally go to the - * yellow pages - */ - -int -getpublicandprivatekey(key, ret) - char *key; - char *ret; -{ - char buf[1024]; /* big enough */ - char *res; - FILE *fd; - char *mkey; - char *mval; - - fd = fopen(PKFILE, "r"); - if (fd == NULL) - return (0); - for (;;) { - res = fgets(buf, sizeof(buf), fd); - if (res == NULL) { - fclose(fd); - return (0); - } - if (res[0] == '#') - continue; - else if (res[0] == '+') { -#ifdef YP - char *PKMAP = "publickey.byname"; - char *lookup; - char *domain; - int err; - int len; - - err = yp_get_default_domain(&domain); - if (err) { - continue; - } - lookup = NULL; - err = yp_match(domain, PKMAP, key, strlen(key), &lookup, &len); - if (err) { - LIBTIRPC_DEBUG(1, - ("getpublicandprivatekey: match failed error %d\n", err)); - continue; - } - lookup[len] = 0; - strcpy(ret, lookup); - fclose(fd); - free(lookup); - return (2); -#else /* YP */ - LIBTIRPC_DEBUG(1, -("Bad record in %s '+' -- NIS not supported in this library copy\n", PKFILE)); - continue; -#endif /* YP */ - } else { - mkey = strsep(&res, "\t "); - if (mkey == NULL) { - fprintf(stderr, - "Bad record in %s -- %s", PKFILE, buf); - continue; - } - do { - mval = strsep(&res, " \t#\n"); - } while (mval != NULL && !*mval); - if (mval == NULL) { - fprintf(stderr, - "Bad record in %s val problem - %s", PKFILE, buf); - continue; - } - if (strcmp(mkey, key) == 0) { - strcpy(ret, mval); - fclose(fd); - return (1); - } - } - } -} - -int getpublickey(netname, publickey) - const char *netname; - char *publickey; -{ - if (__getpublickey_LOCAL != NULL) - return(__getpublickey_LOCAL(netname, publickey)); - else - return(__getpublickey_real(netname, publickey)); -} diff --git a/libtirpc-1.3.1/src/getrpcent.c b/libtirpc-1.3.1/src/getrpcent.c deleted file mode 100644 index e49dc05..0000000 --- a/libtirpc-1.3.1/src/getrpcent.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1984 by Sun Microsystems, Inc. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#ifdef YP -#include -#include -#endif -#if defined(__FreeBSD__) || defined(__NetBSD__) -#include -#endif - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#if !HAVE_GETRPCBYNAME || !HAVE_GETRPCBYNUMBER || \ - !HAVE_SETRPCENT || !HAVE_ENDRPCENT || !HAVE_GETRPCENT - -/* - * Internet version. - */ -static struct rpcdata { - FILE *rpcf; - int stayopen; -#define MAXALIASES 35 - char *rpc_aliases[MAXALIASES]; - struct rpcent rpc; - char line[BUFSIZ+1]; -#ifdef YP - char *domain; - char *current; - int currentlen; -#endif -} *rpcdata; - -static struct rpcent *interpret(char *val, size_t len); - -#ifdef YP -static int __yp_nomap = 0; -#endif /* YP */ - -#define RPCDB "/etc/rpc" - -static struct rpcdata *_rpcdata(void); - -static struct rpcdata * -_rpcdata() -{ - struct rpcdata *d = rpcdata; - - if (d == 0) { - d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); - rpcdata = d; - } - return (d); -} - -#if !HAVE_GETRPCBYNUMBER -struct rpcent * -getrpcbynumber(number) - int number; -{ -#ifdef YP - int reason; - char adrstr[16]; -#endif - struct rpcent *p; - struct rpcdata *d = _rpcdata(); - - if (d == 0) - return (0); -#ifdef YP - if (!__yp_nomap && __yp_check(&d->domain)) { - sprintf(adrstr, "%d", number); - reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr), - &d->current, &d->currentlen); - switch(reason) { - case 0: - break; - case YPERR_MAP: - __yp_nomap = 1; - goto no_yp; - break; - default: - return(0); - break; - } - d->current[d->currentlen] = '\0'; - p = interpret(d->current, d->currentlen); - (void) free(d->current); - return p; - } -no_yp: -#endif /* YP */ - - setrpcent(0); - while ((p = getrpcent()) != NULL) { - if (p->r_number == number) - break; - } - endrpcent(); - return (p); -} -#endif /* !HAVE_GETRPCBYNUMBER */ - -#if !HAVE_GETRPCBYNAME -struct rpcent * -getrpcbyname(name) - const char *name; -{ - struct rpcent *rpc = NULL; - char **rp; - - assert(name != NULL); - - setrpcent(0); - while ((rpc = getrpcent()) != NULL) { - if (strcmp(rpc->r_name, name) == 0) - goto done; - for (rp = rpc->r_aliases; *rp != NULL; rp++) { - if (strcmp(*rp, name) == 0) - goto done; - } - } -done: - endrpcent(); - return (rpc); -} -#endif /* !HAVE_GETRPCBYNAME */ - -#if !HAVE_SETRPCENT -void -setrpcent(f) - int f; -{ - struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; -#ifdef YP - if (!__yp_nomap && __yp_check(NULL)) { - if (d->current) - free(d->current); - d->current = NULL; - d->currentlen = 0; - return; - } - __yp_nomap = 0; -#endif /* YP */ - if (d->rpcf == NULL) - d->rpcf = fopen(RPCDB, "r"); - else - rewind(d->rpcf); - d->stayopen |= f; -} -#endif - -#if !HAVE_ENDRPCENT -void -endrpcent() -{ - struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; -#ifdef YP - if (!__yp_nomap && __yp_check(NULL)) { - if (d->current && !d->stayopen) - free(d->current); - d->current = NULL; - d->currentlen = 0; - return; - } - __yp_nomap = 0; -#endif /* YP */ - if (d->rpcf && !d->stayopen) { - fclose(d->rpcf); - d->rpcf = NULL; - } -} -#endif - -#if !HAVE_GETRPCENT -struct rpcent * -getrpcent() -{ - struct rpcdata *d = _rpcdata(); -#ifdef YP - struct rpcent *hp; - int reason; - char *val = NULL; - int vallen; -#endif - - if (d == 0) - return(NULL); -#ifdef YP - if (!__yp_nomap && __yp_check(&d->domain)) { - if (d->current == NULL && d->currentlen == 0) { - reason = yp_first(d->domain, "rpc.bynumber", - &d->current, &d->currentlen, - &val, &vallen); - } else { - reason = yp_next(d->domain, "rpc.bynumber", - d->current, d->currentlen, - &d->current, &d->currentlen, - &val, &vallen); - } - switch(reason) { - case 0: - break; - case YPERR_MAP: - __yp_nomap = 1; - goto no_yp; - break; - default: - return(0); - break; - } - val[vallen] = '\0'; - hp = interpret(val, vallen); - (void) free(val); - return hp; - } -no_yp: -#endif /* YP */ - if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) - return (NULL); - /* -1 so there is room to append a \n below */ - if (fgets(d->line, BUFSIZ - 1, d->rpcf) == NULL) - return (NULL); - return (interpret(d->line, strlen(d->line))); -} -#endif - -static struct rpcent * -interpret(val, len) - char *val; - size_t len; -{ - struct rpcdata *d = _rpcdata(); - char *p; - char *cp, **q; - - assert(val != NULL); - - if (d == 0) - return (0); - (void) strncpy(d->line, val, BUFSIZ); - d->line[BUFSIZ] = '\0'; - p = d->line; - p[len] = '\n'; - if (*p == '#') - return (getrpcent()); - cp = strpbrk(p, "#\n"); - if (cp == NULL) - return (getrpcent()); - *cp = '\0'; - cp = strpbrk(p, " \t"); - if (cp == NULL) - return (getrpcent()); - *cp++ = '\0'; - /* THIS STUFF IS INTERNET SPECIFIC */ - d->rpc.r_name = d->line; - while (*cp == ' ' || *cp == '\t') - cp++; - d->rpc.r_number = atoi(cp); - q = d->rpc.r_aliases = d->rpc_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &(d->rpc_aliases[MAXALIASES - 1])) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&d->rpc); -} - -#endif diff --git a/libtirpc-1.3.1/src/getrpcport.c b/libtirpc-1.3.1/src/getrpcport.c deleted file mode 100644 index c28cd61..0000000 --- a/libtirpc-1.3.1/src/getrpcport.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include - -int -getrpcport(host, prognum, versnum, proto) - char *host; - int prognum, versnum, proto; -{ - struct sockaddr_in addr; - struct hostent *hp; - - assert(host != NULL); - - if ((hp = gethostbyname(host)) == NULL) - return (0); - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = 0; - if (hp->h_length > sizeof(addr.sin_addr.s_addr)) - hp->h_length = sizeof(addr.sin_addr.s_addr); - memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length); - /* Inconsistent interfaces need casts! :-( */ - return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum, - (u_int)proto)); -} diff --git a/libtirpc-1.3.1/src/key_call.c b/libtirpc-1.3.1/src/key_call.c deleted file mode 100644 index 9f4b1d2..0000000 --- a/libtirpc-1.3.1/src/key_call.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - - -/* - * key_call.c, Interface to keyserver - * - * setsecretkey(key) - set your secret key - * encryptsessionkey(agent, deskey) - encrypt a session key to talk to agent - * decryptsessionkey(agent, deskey) - decrypt ditto - * gendeskey(deskey) - generate a secure des key - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -#define KEY_TIMEOUT 5 /* per-try timeout in seconds */ -#define KEY_NRETRY 12 /* number of retries */ - -/* - * Hack to allow the keyserver to use AUTH_DES (for authenticated - * NIS+ calls, for example). The only functions that get called - * are key_encryptsession_pk, key_decryptsession_pk, and key_gendes. - * - * The approach is to have the keyserver fill in pointers to local - * implementations of these functions, and to call those in key_call(). - */ - -cryptkeyres *(*__key_encryptsession_pk_LOCAL)() = 0; -cryptkeyres *(*__key_decryptsession_pk_LOCAL)() = 0; -des_block *(*__key_gendes_LOCAL)() = 0; - -static int key_call( u_long, xdrproc_t, void *, xdrproc_t, void *); - -int -key_setsecret(secretkey) - const char *secretkey; -{ - keystatus status; - - if (!key_call((u_long) KEY_SET, (xdrproc_t)xdr_keybuf, - (void *)secretkey, - (xdrproc_t)xdr_keystatus, &status)) { - return (-1); - } - if (status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_setsecret: set status is nonzero")); - return (-1); - } - return (0); -} - - -/* key_secretkey_is_set() returns 1 if the keyserver has a secret key - * stored for the caller's effective uid; it returns 0 otherwise - * - * N.B.: The KEY_NET_GET key call is undocumented. Applications shouldn't - * be using it, because it allows them to get the user's secret key. - */ - -int -key_secretkey_is_set(void) -{ - struct key_netstres kres; - - memset((void*)&kres, 0, sizeof (kres)); - if (key_call((u_long) KEY_NET_GET, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_key_netstres, &kres) && - (kres.status == KEY_SUCCESS) && - (kres.key_netstres_u.knet.st_priv_key[0] != 0)) { - /* avoid leaving secret key in memory */ - memset(kres.key_netstres_u.knet.st_priv_key, 0, HEXKEYBYTES); - return (1); - } - return (0); -} - -int -key_encryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; -{ - cryptkeyarg2 arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.remotekey = *remotekey; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_ENCRYPT_PK, (xdrproc_t)xdr_cryptkeyarg2, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_encryptsession_pk: encrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_decryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; -{ - cryptkeyarg2 arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.remotekey = *remotekey; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_DECRYPT_PK, (xdrproc_t)xdr_cryptkeyarg2, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_decryptsession_pk: decrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_encryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = (char *) remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_ENCRYPT, (xdrproc_t)xdr_cryptkeyarg, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_encryptsession: encrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_decryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = (char *) remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_DECRYPT, (xdrproc_t)xdr_cryptkeyarg, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_decryptsession: decrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_gendes(key) - des_block *key; -{ - if (!key_call((u_long)KEY_GEN, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_des_block, key)) { - return (-1); - } - return (0); -} - -int -key_setnet(arg) -struct key_netstarg *arg; -{ - keystatus status; - - - if (!key_call((u_long) KEY_NET_PUT, (xdrproc_t)xdr_key_netstarg, arg, - (xdrproc_t)xdr_keystatus, &status)){ - return (-1); - } - - if (status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_setnet: key_setnet status is nonzero")); - return (-1); - } - return (1); -} - - -int -key_get_conv(pkey, deskey) - char *pkey; - des_block *deskey; -{ - cryptkeyres res; - - if (!key_call((u_long) KEY_GET_CONV, (xdrproc_t)xdr_keybuf, pkey, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_get_conv: get_conv status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -struct key_call_private { - CLIENT *client; /* Client handle */ - pid_t pid; /* process-id at moment of creation */ - uid_t uid; /* user-id at last authorization */ -}; -static struct key_call_private *key_call_private_main = NULL; - -static void -key_call_destroy(void *vp) -{ - struct key_call_private *kcp = (struct key_call_private *)vp; - - if (kcp) { - if (kcp->client) - clnt_destroy(kcp->client); - free(kcp); - } -} - -/* - * Keep the handle cached. This call may be made quite often. - */ -static CLIENT * -getkeyserv_handle(vers) -int vers; -{ - void *localhandle; - struct netconfig *nconf; - struct netconfig *tpconf; - struct key_call_private *kcp = key_call_private_main; - struct timeval wait_time; - struct utsname u; - int fd; - extern thread_key_t key_call_key; - extern mutex_t tsd_lock; - -#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */ -#define TOTAL_TRIES 5 /* Number of tries */ - - if (key_call_key == -1) { - mutex_lock(&tsd_lock); - if (key_call_key == -1) - thr_keycreate(&key_call_key, key_call_destroy); - mutex_unlock(&tsd_lock); - } - kcp = (struct key_call_private *)thr_getspecific(key_call_key); - if (kcp == (struct key_call_private *)NULL) { - kcp = (struct key_call_private *)malloc(sizeof (*kcp)); - if (kcp == (struct key_call_private *)NULL) { - return ((CLIENT *) NULL); - } - thr_setspecific(key_call_key, (void *) kcp); - kcp->client = NULL; - } - - /* if pid has changed, destroy client and rebuild */ - if (kcp->client != NULL && kcp->pid != getpid()) { - clnt_destroy(kcp->client); - kcp->client = NULL; - } - - if (kcp->client != NULL) { - /* if uid has changed, build client handle again */ - if (kcp->uid != geteuid()) { - kcp->uid = geteuid(); - auth_destroy(kcp->client->cl_auth); - kcp->client->cl_auth = - authsys_create("", kcp->uid, 0, 0, NULL); - if (kcp->client->cl_auth == NULL) { - clnt_destroy(kcp->client); - kcp->client = NULL; - return ((CLIENT *) NULL); - } - } - /* Change the version number to the new one */ - clnt_control(kcp->client, CLSET_VERS, (void *)&vers); - return (kcp->client); - } - if (!(localhandle = setnetconfig())) { - return ((CLIENT *) NULL); - } - tpconf = NULL; - if (uname(&u) == -1) { - endnetconfig(localhandle); - return ((CLIENT *) NULL); - } - while ((nconf = getnetconfig(localhandle)) != NULL) { - if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) { - /* - * We use COTS_ORD here so that the caller can - * find out immediately if the server is dead. - */ - if (nconf->nc_semantics == NC_TPI_COTS_ORD) { - kcp->client = clnt_tp_create(u.nodename, - KEY_PROG, vers, nconf); - if (kcp->client) - break; - } else { - tpconf = nconf; - } - } - } - if ((kcp->client == (CLIENT *) NULL) && (tpconf)) - /* Now, try the CLTS or COTS loopback transport */ - kcp->client = clnt_tp_create(u.nodename, - KEY_PROG, vers, tpconf); - endnetconfig(localhandle); - - if (kcp->client == (CLIENT *) NULL) { - return ((CLIENT *) NULL); - } - kcp->uid = geteuid(); - kcp->pid = getpid(); - kcp->client->cl_auth = authsys_create("", kcp->uid, 0, 0, NULL); - if (kcp->client->cl_auth == NULL) { - clnt_destroy(kcp->client); - kcp->client = NULL; - return ((CLIENT *) NULL); - } - - wait_time.tv_sec = TOTAL_TIMEOUT/TOTAL_TRIES; - wait_time.tv_usec = 0; - (void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT, - (char *)&wait_time); - if (clnt_control(kcp->client, CLGET_FD, (char *)&fd)) - fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ - - return (kcp->client); -} - -/* returns 0 on failure, 1 on success */ - -static int -key_call(proc, xdr_arg, arg, xdr_rslt, rslt) - u_long proc; - xdrproc_t xdr_arg; - void *arg; - xdrproc_t xdr_rslt; - void *rslt; -{ - CLIENT *clnt; - struct timeval wait_time; - - if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL) { - cryptkeyres *res; - res = (*__key_encryptsession_pk_LOCAL)(geteuid(), arg); - *(cryptkeyres*)rslt = *res; - return (1); - } else if (proc == KEY_DECRYPT_PK && __key_decryptsession_pk_LOCAL) { - cryptkeyres *res; - res = (*__key_decryptsession_pk_LOCAL)(geteuid(), arg); - *(cryptkeyres*)rslt = *res; - return (1); - } else if (proc == KEY_GEN && __key_gendes_LOCAL) { - des_block *res; - res = (*__key_gendes_LOCAL)(geteuid(), 0); - *(des_block*)rslt = *res; - return (1); - } - - if ((proc == KEY_ENCRYPT_PK) || (proc == KEY_DECRYPT_PK) || - (proc == KEY_NET_GET) || (proc == KEY_NET_PUT) || - (proc == KEY_GET_CONV)) - clnt = getkeyserv_handle(2); /* talk to version 2 */ - else - clnt = getkeyserv_handle(1); /* talk to version 1 */ - - if (clnt == NULL) { - return (0); - } - - wait_time.tv_sec = TOTAL_TIMEOUT; - wait_time.tv_usec = 0; - - if (clnt_call(clnt, proc, xdr_arg, arg, xdr_rslt, rslt, - wait_time) == RPC_SUCCESS) { - return (1); - } else { - return (0); - } -} diff --git a/libtirpc-1.3.1/src/key_prot_xdr.c b/libtirpc-1.3.1/src/key_prot_xdr.c deleted file mode 100644 index 772f582..0000000 --- a/libtirpc-1.3.1/src/key_prot_xdr.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#include -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ - - -/* - * Compiled from key_prot.x using rpcgen. - * DO NOT EDIT THIS FILE! - * This is NOT source code! - */ - -bool_t -xdr_keystatus(register XDR *xdrs, keystatus *objp) -{ - - if (!xdr_enum(xdrs, (enum_t *)objp)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_keybuf(register XDR *xdrs, keybuf objp) -{ - - if (!xdr_opaque(xdrs, objp, HEXKEYBYTES)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_netnamestr(register XDR *xdrs, netnamestr *objp) -{ - - if (!xdr_string(xdrs, objp, MAXNETNAMELEN)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyarg(register XDR *xdrs, cryptkeyarg *objp) -{ - - if (!xdr_netnamestr(xdrs, &objp->remotename)) - return (FALSE); - if (!xdr_des_block(xdrs, &objp->deskey)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyarg2(register XDR *xdrs, cryptkeyarg2 *objp) -{ - - if (!xdr_netnamestr(xdrs, &objp->remotename)) - return (FALSE); - if (!xdr_netobj(xdrs, &objp->remotekey)) - return (FALSE); - if (!xdr_des_block(xdrs, &objp->deskey)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyres(register XDR *xdrs, cryptkeyres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} - -bool_t -xdr_unixcred(register XDR *xdrs, unixcred *objp) -{ - - if (!xdr_u_int(xdrs, &objp->uid)) - return (FALSE); - if (!xdr_u_int(xdrs, &objp->gid)) - return (FALSE); - if (!xdr_array(xdrs, (char **)&objp->gids.gids_val, (u_int *) &objp->gids.gids_len, MAXGIDS, - sizeof (u_int), (xdrproc_t) xdr_u_int)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_getcredres(register XDR *xdrs, getcredres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_unixcred(xdrs, &objp->getcredres_u.cred)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} - -bool_t -xdr_key_netstarg(register XDR *xdrs, key_netstarg *objp) -{ - - if (!xdr_keybuf(xdrs, objp->st_priv_key)) - return (FALSE); - if (!xdr_keybuf(xdrs, objp->st_pub_key)) - return (FALSE); - if (!xdr_netnamestr(xdrs, &objp->st_netname)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_key_netstres(register XDR *xdrs, key_netstres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_key_netstarg(xdrs, &objp->key_netstres_u.knet)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} diff --git a/libtirpc-1.3.1/src/libtirpc.map b/libtirpc-1.3.1/src/libtirpc.map deleted file mode 100644 index 21d6065..0000000 --- a/libtirpc-1.3.1/src/libtirpc.map +++ /dev/null @@ -1,335 +0,0 @@ -TIRPC_0.3.0 { - global: - # __* - __rpc_createerr; - __rpc_dtbsize; - __rpc_endconf; - __rpc_fd2sockinfo; - __rpc_fixup_addr; - __rpc_get_a_size; - __rpc_get_local_uid; - __rpc_get_t_size; - __rpc_getconf; - __rpc_getconfip; - __rpc_nconf2fd; - __rpc_nconf2fd_flags; - __rpc_nconf2sockinfo; - __rpc_rawcombuf; - __rpc_seman2socktype; - __rpc_setconf; - __rpc_sockinfo2netid; - __rpc_sockisbound; - __rpc_socktype2seman; - __rpc_taddr2uaddr_af; - __rpc_uaddr2taddr_af; - __rpcgettp; - - # _* - _authenticate; - _get_next_token; - _gss_authenticate; - _null_auth; - _rpc_dtablesize; - _seterr_reply; - _svcauth_none; - _svcauth_short; - _svcauth_unix; - _svcauth_gss; - - # a* - authdes_create; - authdes_seccreate; - authgss_create; - authgss_create_default; - authgss_free_private_data; - authgss_get_private_data; - authgss_service; - authnone_create; - authunix_create; - authunix_create_default; - - # b* - bindresvport; - bindresvport_sa; - - # c* - callrpc; - cbc_crypt; - clnt_broadcast; - clnt_create; - clnt_create_timed; - clnt_create_vers; - clnt_create_vers_timed; - clnt_dg_create; - clnt_pcreateerror; - clnt_perrno; - clnt_perror; - clnt_raw_create; - clnt_spcreateerror; - clnt_sperrno; - clnt_sperror; - clnt_tli_create; - clnt_tp_create; - clnt_tp_create_timed; - clnt_vc_create; - clntraw_create; - clnttcp_create; - clntudp_bufcreate; - clntudp_create; - clntunix_create; - - # e* - ecb_crypt; - endnetconfig; - endnetpath; - endrpcent; - - # f* - freenetconfigent; - - # g* - get_myaddress; - getnetconfig; - getnetconfigent; - getnetpath; - getrpcent; - getrpcbynumber; - getrpcbyname; - getrpcport; - gss_log_debug; - gss_log_hexdump; - gss_log_status; - - # n* - nc_perror; - nc_sperror; - - # p* - pmap_getmaps; - pmap_getport; - pmap_rmtcall; - pmap_set; - pmap_unset; - - # r* - registerrpc; - rpc_broadcast; - rpc_broadcast_exp; - rpc_call; - rpc_control; - rpc_createerr; - rpc_gss_get_error; - rpc_gss_get_mech_info; - rpc_gss_get_mechanisms; - rpc_gss_get_principal_name; - rpc_gss_get_versions; - rpc_gss_getcred; - rpc_gss_is_installed; - rpc_gss_max_data_length; - rpc_gss_mech_to_oid; - rpc_gss_qop_to_num; - rpc_gss_seccreate; - rpc_gss_set_callback; - rpc_gss_set_defaults; - rpc_gss_set_svc_name; - rpc_gss_svc_max_data_length; - rpc_nullproc; - rpc_reg; - rpcb_getaddr; - rpcb_getmaps; - rpcb_gettime; - rpcb_rmtcall; - rpcb_set; - rpcb_taddr2uaddr; - rpcb_uaddr2taddr; - rpcb_unset; - - # s* - setnetconfig; - setnetpath; - setrpcent; - svc_auth_reg; - svc_create; - svc_dg_create; - svc_dg_enablecache; - svc_exit; - svc_fd_create; - svc_fdset; - svc_getreq; - svc_getreq_common; - svc_getreq_poll; - svc_getreqset; - svc_maxfd; - svc_raw_create; - svc_reg; - svc_register; - svc_run; - svc_sendreply; - svc_tli_create; - svc_tp_create; - svc_unreg; - svc_unregister; - svc_vc_create; - svcerr_auth; - svcerr_decode; - svcerr_noproc; - svcerr_noprog; - svcerr_progvers; - svcerr_systemerr; - svcerr_weakauth; - svcfd_create; - svcraw_create; - svctcp_create; - svcudp_bufcreate; - svcudp_create; - svcunix_create; - svcunixfd_create; - - # t* - taddr2uaddr; - - # u* - uaddr2taddr; - - # x* - xdr_accepted_reply; - xdr_array; - xdr_authdes_cred; - xdr_authdes_verf; - xdr_authunix_parms; - xdr_bool; - xdr_bytes; - xdr_callhdr; xdr_callmsg; - xdr_char; - xdr_des_block; - xdr_double; - xdr_enum; - xdr_float; - xdr_free; - xdr_hyper; - xdr_int16_t; - xdr_int32_t; - xdr_int64_t; - xdr_int8_t; - xdr_int; - xdr_long; - xdr_longlong_t; - xdr_netbuf; - xdr_netobj; - xdr_opaque; - xdr_opaque_auth; - xdr_pmap; - xdr_pmaplist; - xdr_pmaplist_ptr; - xdr_pointer; - xdr_quad_t; - xdr_reference; - xdr_rejected_reply; - xdr_replymsg; - xdr_rmtcall_args; - xdr_rmtcallres; - xdr_rpc_gss_cred; - xdr_rpc_gss_data; - xdr_rpc_gss_init_args; - xdr_rpc_gss_init_res; - xdr_rpcb; - xdr_rpcb_entry; - xdr_rpcb_entry_list_ptr; - xdr_rpcb_rmtcallargs; - xdr_rpcb_rmtcallres; - xdr_rpcb_stat; - xdr_rpcb_stat_byvers; - xdr_rpcblist; - xdr_rpcblist_ptr; - xdr_rpcbs_addrlist; - xdr_rpcbs_addrlist_ptr; - xdr_rpcbs_proc; - xdr_rpcbs_rmtcalllist; - xdr_rpcbs_rmtcalllist_ptr; - xdr_short; - xdr_string; - xdr_u_char; - xdr_u_hyper; - xdr_u_int16_t; - xdr_u_int32_t; - xdr_u_int64_t; - xdr_u_int8_t; - xdr_u_int; - xdr_u_long; - xdr_u_longlong_t; - xdr_u_quad_t; - xdr_u_short; - xdr_uint16_t; - xdr_uint32_t; - xdr_uint64_t; - xdr_uint8_t; - xdr_union; - xdr_vector; - xdr_void; - xdr_wrapstring; - xdrmem_create; - xdrrec_create; - xdrrec_endofrecord; - xdrrec_eof; - xdrrec_skiprecord; - xdrstdio_create; - xprt_register; - xprt_unregister; - - local: - *; -}; - -TIRPC_0.3.1 { - svcauth_gss_get_principal; - svcauth_gss_set_svc_name; -} TIRPC_0.3.0; - -TIRPC_0.3.2 { - getnetname; - getpublicandprivatekey; - getpublickey; - host2netname; - key_call_destroy; - key_decryptsession; - key_decryptsession_pk; - key_encryptsession; - key_encryptsession_pk; - key_gendes; - key_get_conv; - key_setsecret; - key_secretkey_is_set; - key_setnet; - netname2host; - netname2user; - rtime; - user2netname; - xdr_cryptkeyarg; - xdr_cryptkeyarg2; - xdr_cryptkeyres; - xdr_getcredres; - xdr_key_netstarg; - xdr_key_netstres; - xdr_keybuf; - xdr_keystatus; - xdr_netnamestr; - xdr_unixcred; -} TIRPC_0.3.1; - -TIRPC_0.3.3 { - __getpublickey_LOCAL; - __key_decryptsession_pk_LOCAL; - __key_encryptsession_pk_LOCAL; - __key_gendes_LOCAL; - xdr_sizeof; - authdes_pk_create; - svc_pollfd; - svc_max_pollfd; -} TIRPC_0.3.2; - -TIRPC_PRIVATE { - global: - __libc_clntudp_bufcreate; - # private, but used by rpcbind: - __svc_clean_idle; svc_auth_none; libtirpc_set_debug; -}; diff --git a/libtirpc-1.3.1/src/mt_misc.c b/libtirpc-1.3.1/src/mt_misc.c deleted file mode 100644 index 5a49b78..0000000 --- a/libtirpc-1.3.1/src/mt_misc.c +++ /dev/null @@ -1,153 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -/* protects the services list (svc.c) */ -pthread_rwlock_t svc_lock = PTHREAD_RWLOCK_INITIALIZER; - -/* protects svc_fdset and the xports[] array */ -pthread_rwlock_t svc_fd_lock = PTHREAD_RWLOCK_INITIALIZER; - -/* protects the RPCBIND address cache */ -pthread_rwlock_t rpcbaddr_cache_lock = PTHREAD_RWLOCK_INITIALIZER; - -/* protects authdes cache (svcauth_des.c) */ -pthread_mutex_t authdes_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serializes authdes ops initializations */ -pthread_mutex_t authdes_ops_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects des stats list */ -pthread_mutex_t svcauthdesstats_lock = PTHREAD_MUTEX_INITIALIZER; - -/* auth_none.c serialization */ -pthread_mutex_t authnone_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects the Auths list (svc_auth.c) */ -pthread_mutex_t authsvc_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects client-side fd lock array */ -pthread_mutex_t clnt_fd_lock = PTHREAD_MUTEX_INITIALIZER; - -/* clnt_raw.c serialization */ -pthread_mutex_t clntraw_lock = PTHREAD_MUTEX_INITIALIZER; - -/* domainname and domain_fd (getdname.c) and default_domain (rpcdname.c) */ -pthread_mutex_t dname_lock = PTHREAD_MUTEX_INITIALIZER; - -/* dupreq variables (svc_dg.c) */ -pthread_mutex_t dupreq_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects first_time and hostname (key_call.c) */ -pthread_mutex_t keyserv_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serializes rpc_trace() (rpc_trace.c) */ -pthread_mutex_t libnsl_trace_lock = PTHREAD_MUTEX_INITIALIZER; - -/* loopnconf (rpcb_clnt.c) */ -pthread_mutex_t loopnconf_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serializes ops initializations */ -pthread_mutex_t ops_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects ``port'' static in bindresvport() */ -pthread_mutex_t portnum_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects proglst list (svc_simple.c) */ -pthread_mutex_t proglst_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serializes clnt_com_create() (rpc_soc.c) */ -pthread_mutex_t rpcsoc_lock = PTHREAD_MUTEX_INITIALIZER; - -/* svc_raw.c serialization */ -pthread_mutex_t svcraw_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects TSD key creation */ -pthread_mutex_t tsd_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects RPCSEC GSS callback list */ -pthread_mutex_t svcauth_cb_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serialize updates to AUTH ref count */ -pthread_mutex_t auth_ref_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects RPCSEC GSS cache */ -pthread_mutex_t svcauth_gss_cache_lock = PTHREAD_MUTEX_INITIALIZER; - -/* Library global tsd keys */ -thread_key_t clnt_broadcast_key = KEY_INITIALIZER; -thread_key_t rpc_call_key = KEY_INITIALIZER; -thread_key_t tcp_key = KEY_INITIALIZER; -thread_key_t udp_key = KEY_INITIALIZER; -thread_key_t nc_key = KEY_INITIALIZER; -thread_key_t rce_key = KEY_INITIALIZER; -thread_key_t rg_key = KEY_INITIALIZER; -thread_key_t key_call_key = KEY_INITIALIZER; - -/* xprtlist (svc_generic.c) */ -pthread_mutex_t xprtlist_lock = PTHREAD_MUTEX_INITIALIZER; - -/* serializes calls to public key routines */ -pthread_mutex_t serialize_pkey = PTHREAD_MUTEX_INITIALIZER; - -/* protects global variables ni and nc_file (getnetconfig.c) */ -pthread_mutex_t nc_db_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects static port and startport (bindresvport.c) */ -pthread_mutex_t port_lock = PTHREAD_MUTEX_INITIALIZER; - -/* protects static disrupt (clnt_vc.c) */ -pthread_mutex_t disrupt_lock = PTHREAD_MUTEX_INITIALIZER; - -#undef rpc_createerr - -struct rpc_createerr rpc_createerr; - -struct rpc_createerr * -__rpc_createerr() -{ - struct rpc_createerr *rce_addr; - - mutex_lock(&tsd_lock); - if (rce_key == KEY_INITIALIZER) - thr_keycreate(&rce_key, free); - mutex_unlock(&tsd_lock); - - rce_addr = (struct rpc_createerr *)thr_getspecific(rce_key); - if (!rce_addr) { - rce_addr = (struct rpc_createerr *) - malloc(sizeof (struct rpc_createerr)); - if (!rce_addr || - thr_setspecific(rce_key, (void *) rce_addr) != 0) { - if (rce_addr) - free(rce_addr); - return (&rpc_createerr); - } - memset(rce_addr, 0, sizeof (struct rpc_createerr)); - } - return (rce_addr); -} - -void tsd_key_delete(void) -{ - if (clnt_broadcast_key != KEY_INITIALIZER) - pthread_key_delete(clnt_broadcast_key); - if (rpc_call_key != KEY_INITIALIZER) - pthread_key_delete(rpc_call_key); - if (tcp_key != KEY_INITIALIZER) - pthread_key_delete(tcp_key); - if (udp_key != KEY_INITIALIZER) - pthread_key_delete(udp_key); - if (nc_key != KEY_INITIALIZER) - pthread_key_delete(nc_key); - if (rce_key != KEY_INITIALIZER) - pthread_key_delete(rce_key); - if (rg_key != KEY_INITIALIZER) - pthread_key_delete(rce_key); - return; -} - diff --git a/libtirpc-1.3.1/src/netname.c b/libtirpc-1.3.1/src/netname.c deleted file mode 100644 index ea61b1a..0000000 --- a/libtirpc-1.3.1/src/netname.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * netname utility routines - * convert from unix names to network names and vice-versa - * This module is operating system dependent! - * What we define here will work with any unix system that has adopted - * the sun NIS domain architecture. - */ - -#include -#include -#include "rpc_com.h" -#ifdef YP -#include -#include -#endif -#include -#include -#include -#include -#include -#include - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 256 -#endif -#ifndef NGROUPS -#define NGROUPS 16 -#endif - -#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) - -#define TYPE_SIGNED(type) (((type) -1) < 0) - -/* -** 302 / 1000 is log10(2.0) rounded up. -** Subtract one for the sign bit if the type is signed; -** add one for integer division truncation; -** add one more for a minus sign if the type is signed. -*/ -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) - -static char *OPSYS = "unix"; - -/* - * Figure out my fully qualified network name - */ -int -getnetname(name) - char name[MAXNETNAMELEN+1]; -{ - uid_t uid; - - uid = geteuid(); - if (uid == 0) { - return (host2netname(name, (char *) NULL, (char *) NULL)); - } else { - return (user2netname(name, uid, (char *) NULL)); - } -} - - -/* - * Convert unix cred to network-name - */ -int -user2netname(netname, uid, domain) - char netname[MAXNETNAMELEN + 1]; - const uid_t uid; - const char *domain; -{ - char *dfltdom; - - if (domain == NULL) { - if (__rpc_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (strlen(domain) + 1 + INT_STRLEN_MAXIMUM(u_long) + 1 + strlen(OPSYS) > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain); - return (1); -} - - -/* - * Convert host to network-name - */ -int -host2netname(netname, host, domain) - char netname[MAXNETNAMELEN + 1]; - const char *host; - const char *domain; -{ - char *dfltdom; - char hostname[MAXHOSTNAMELEN+1]; - - if (domain == NULL) { - if (__rpc_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (host == NULL) { - (void) gethostname(hostname, sizeof(hostname)); - host = hostname; - } - if (strlen(domain) + 1 + strlen(host) + 1 + strlen(OPSYS) > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain); - return (1); -} diff --git a/libtirpc-1.3.1/src/netnamer.c b/libtirpc-1.3.1/src/netnamer.c deleted file mode 100644 index 6b6c8e0..0000000 --- a/libtirpc-1.3.1/src/netnamer.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * netname utility routines convert from unix names to network names and - * vice-versa This module is operating system dependent! What we define here - * will work with any unix system that has adopted the sun NIS domain - * architecture. - */ -#include -#include -#include "rpc_com.h" -#ifdef YP -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -static char *OPSYS = "unix"; -#ifdef YP -static char *NETID = "netid.byname"; -#endif -static char *NETIDFILE = "/etc/netid"; - -static int getnetid( char *, char * ); -static int _getgroups( char *, gid_t * ); - -#ifndef NGROUPS -#define NGROUPS 16 -#endif - -/* - * Convert network-name into unix credential - */ -int -netname2user(netname, uidp, gidp, gidlenp, gidlist) - char netname[MAXNETNAMELEN + 1]; - uid_t *uidp; - gid_t *gidp; - int *gidlenp; - gid_t *gidlist; -{ - char *p; - int gidlen; - uid_t uid; - long luid; - struct passwd *pwd; - char val[1024]; - char *val1, *val2; - char *domain; - int vallen; - int err; - - if (getnetid(netname, val)) { - char *res = val; - - p = strsep(&res, ":"); - if (p == NULL) - return (0); - *uidp = (uid_t) atol(p); - p = strsep(&res, "\n,"); - if (p == NULL) { - return (0); - } - *gidp = (gid_t) atol(p); - gidlen = 0; - for (gidlen = 0; gidlen < NGROUPS; gidlen++) { - p = strsep(&res, "\n,"); - if (p == NULL) - break; - gidlist[gidlen] = (gid_t) atol(p); - } - *gidlenp = gidlen; - - return (1); - } - val1 = strchr(netname, '.'); - if (val1 == NULL) - return (0); - if (strncmp(netname, OPSYS, (val1-netname))) - return (0); - val1++; - val2 = strchr(val1, '@'); - if (val2 == NULL) - return (0); - vallen = val2 - val1; - if (vallen > (1024 - 1)) - vallen = 1024 - 1; - (void) strncpy(val, val1, 1024); - val[vallen] = 0; - - err = __rpc_get_default_domain(&domain); /* change to rpc */ - if (err) - return (0); - - if (strcmp(val2 + 1, domain)) - return (0); /* wrong domain */ - - if (sscanf(val, "%ld", &luid) != 1) - return (0); - uid = luid; - - /* use initgroups method */ - pwd = getpwuid(uid); - if (pwd == NULL) - return (0); - *uidp = pwd->pw_uid; - *gidp = pwd->pw_gid; - *gidlenp = _getgroups(pwd->pw_name, gidlist); - return (1); -} - -/* - * initgroups - */ - -static int -_getgroups(uname, groups) - char *uname; - gid_t groups[NGROUPS]; -{ - gid_t ngroups = 0; - struct group *grp; - int i; - int j; - int filter; - - setgrent(); - while ((grp = getgrent())) { - for (i = 0; grp->gr_mem[i]; i++) - if (!strcmp(grp->gr_mem[i], uname)) { - if (ngroups == NGROUPS) { - LIBTIRPC_DEBUG(1, - ("_getgroups: %s is in too many groups\n", uname)); - goto toomany; - } - /* filter out duplicate group entries */ - filter = 0; - for (j = 0; j < ngroups; j++) - if (groups[j] == grp->gr_gid) { - filter++; - break; - } - if (!filter) - groups[ngroups++] = grp->gr_gid; - } - } -toomany: - endgrent(); - return (ngroups); -} - -/* - * Convert network-name to hostname - */ -int -netname2host(netname, hostname, hostlen) - char netname[MAXNETNAMELEN + 1]; - char *hostname; - int hostlen; -{ - int err; - char valbuf[1024]; - char *val; - char *val2; - int vallen; - char *domain; - - if (getnetid(netname, valbuf)) { - val = valbuf; - if ((*val == '0') && (val[1] == ':')) { - (void) strncpy(hostname, val + 2, hostlen); - return (1); - } - } - val = strchr(netname, '.'); - if (val == NULL) - return (0); - if (strncmp(netname, OPSYS, (val - netname))) - return (0); - val++; - val2 = strchr(val, '@'); - if (val2 == NULL) - return (0); - vallen = val2 - val; - if (vallen > (hostlen - 1)) - vallen = hostlen - 1; - (void) strncpy(hostname, val, vallen); - hostname[vallen] = 0; - - err = __rpc_get_default_domain(&domain); /* change to rpc */ - if (err) - return (0); - - if (strcmp(val2 + 1, domain)) - return (0); /* wrong domain */ - else - return (1); -} - -/* - * reads the file /etc/netid looking for a + to optionally go to the - * network information service. - */ -static int -getnetid(key, ret) - char *key, *ret; -{ - char buf[1024]; /* big enough */ - char *res; - char *mkey; - char *mval; - FILE *fd; -#ifdef YP - char *domain; - int err; - char *lookup; - int len; -#endif - - fd = fopen(NETIDFILE, "r"); - if (fd == NULL) { -#ifdef YP - res = "+"; - goto getnetidyp; -#else - return (0); -#endif - } - for (;;) { - if (fd == NULL) - return (0); /* getnetidyp brings us here */ - res = fgets(buf, sizeof(buf), fd); - if (res == NULL) { - fclose(fd); - return (0); - } - if (res[0] == '#') - continue; - else if (res[0] == '+') { -#ifdef YP - getnetidyp: - err = yp_get_default_domain(&domain); - if (err) { - continue; - } - lookup = NULL; - err = yp_match(domain, NETID, key, - strlen(key), &lookup, &len); - if (err) { - LIBTIRPC_DEBUG(1, ("getnetid: match failed error %d", err)); - continue; - } - lookup[len] = 0; - strcpy(ret, lookup); - free(lookup); - if (fd != NULL) - fclose(fd); - return (2); -#else /* YP */ - LIBTIRPC_DEBUG(1, -("Bad record in %s '+' -- NIS not supported in this library copy\n", - NETIDFILE)); - continue; -#endif /* YP */ - } else { - mkey = strsep(&res, "\t "); - if (mkey == NULL) { - fprintf(stderr, - "Bad record in %s -- %s", NETIDFILE, buf); - continue; - } - do { - mval = strsep(&res, " \t#\n"); - } while (mval != NULL && !*mval); - if (mval == NULL) { - fprintf(stderr, - "Bad record in %s val problem - %s", NETIDFILE, buf); - continue; - } - if (strcmp(mkey, key) == 0) { - strcpy(ret, mval); - fclose(fd); - return (1); - - } - } - } -} diff --git a/libtirpc-1.3.1/src/nis.h b/libtirpc-1.3.1/src/nis.h deleted file mode 100644 index 588c041..0000000 --- a/libtirpc-1.3.1/src/nis.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _INTERNAL_NIS_H -#define _INTERNAL_NIS_H 1 - -/* This file only contains the definition of nis_server, to be - able to compile libtirpc without the need to have a glibc - with sunrpc or a libnsl already installed. */ - -#define NIS_PK_NONE 0 - -struct nis_attr { - char *zattr_ndx; - struct { - u_int zattr_val_len; - char *zattr_val_val; - } zattr_val; -}; -typedef struct nis_attr nis_attr; - -typedef char *nis_name; - -struct endpoint { - char *uaddr; - char *family; - char *proto; -}; -typedef struct endpoint endpoint; - -struct nis_server { - nis_name name; - struct { - u_int ep_len; - endpoint *ep_val; - } ep; - uint32_t key_type; - netobj pkey; -}; -typedef struct nis_server nis_server; - -#endif /* ! _INTERNAL_NIS_H */ diff --git a/libtirpc-1.3.1/src/pmap_clnt.c b/libtirpc-1.3.1/src/pmap_clnt.c deleted file mode 100644 index 4b5fd85..0000000 --- a/libtirpc-1.3.1/src/pmap_clnt.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * pmap_clnt.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "rpc_com.h" - -bool_t -pmap_set(u_long program, u_long version, int protocol, int port) -{ - bool_t rslt; - struct netbuf *na; - struct netconfig *nconf; - char buf[32]; - - if ((protocol != IPPROTO_UDP) && (protocol != IPPROTO_TCP)) { - return (FALSE); - } - nconf = __rpc_getconfip(protocol == IPPROTO_UDP ? "udp" : "tcp"); - if (nconf == NULL) { - return (FALSE); - } - snprintf(buf, sizeof buf, "0.0.0.0.%d.%d", - (((u_int32_t)port) >> 8) & 0xff, port & 0xff); - na = uaddr2taddr(nconf, buf); - if (na == NULL) { - freenetconfigent(nconf); - return (FALSE); - } - rslt = rpcb_set((rpcprog_t)program, (rpcvers_t)version, nconf, na); - free(na); - freenetconfigent(nconf); - return (rslt); -} - -/* - * Remove the mapping between program, version and port. - * Calls the pmap service remotely to do the un-mapping. - */ -bool_t -pmap_unset(u_long program, u_long version) -{ - struct netconfig *nconf; - bool_t udp_rslt = FALSE; - bool_t tcp_rslt = FALSE; - - nconf = __rpc_getconfip("udp"); - if (nconf != NULL) { - udp_rslt = rpcb_unset((rpcprog_t)program, (rpcvers_t)version, - nconf); - freenetconfigent(nconf); - } - nconf = __rpc_getconfip("tcp"); - if (nconf != NULL) { - tcp_rslt = rpcb_unset((rpcprog_t)program, (rpcvers_t)version, - nconf); - freenetconfigent(nconf); - } - /* - * XXX: The call may still succeed even if only one of the - * calls succeeded. This was the best that could be - * done for backward compatibility. - */ - return (tcp_rslt || udp_rslt); -} diff --git a/libtirpc-1.3.1/src/pmap_getmaps.c b/libtirpc-1.3.1/src/pmap_getmaps.c deleted file mode 100644 index 853f724..0000000 --- a/libtirpc-1.3.1/src/pmap_getmaps.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * pmap_getmap.c - * Client interface to pmap rpc service. - * contains pmap_getmaps, which is only tcp service involved - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -//#include -#define NAMELEN 255 -#define MAX_BROADCAST_SIZE 1400 - -/* - * Get a copy of the current port maps. - * Calls the pmap service remotely to do get the maps. - */ -struct pmaplist * -pmap_getmaps(address) - struct sockaddr_in *address; -{ - struct pmaplist *head = NULL; - int sock = -1; - struct timeval minutetimeout; - CLIENT *client; - - assert(address != NULL); - - minutetimeout.tv_sec = 60; - minutetimeout.tv_usec = 0; - address->sin_port = htons(PMAPPORT); - client = clnttcp_create(address, PMAPPROG, - PMAPVERS, &sock, 50, 500); - if (client != NULL) { - if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP, - (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_pmaplist, &head, minutetimeout) != - RPC_SUCCESS) { - clnt_perror(client, "pmap_getmaps rpc problem"); - } - CLNT_DESTROY(client); - } - address->sin_port = 0; - return (head); -} diff --git a/libtirpc-1.3.1/src/pmap_getport.c b/libtirpc-1.3.1/src/pmap_getport.c deleted file mode 100644 index 72853a0..0000000 --- a/libtirpc-1.3.1/src/pmap_getport.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * pmap_getport.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -static const struct timeval timeout = { 5, 0 }; -static const struct timeval tottimeout = { 60, 0 }; - -/* - * Find the mapped port for program,version. - * Calls the pmap service remotely to do the lookup. - * Returns 0 if no map exists. - */ -u_short -pmap_getport(address, program, version, protocol) - struct sockaddr_in *address; - u_long program; - u_long version; - u_int protocol; -{ - u_short port = 0; - int sock = -1; - CLIENT *client; - struct pmap parms; - - assert(address != NULL); - - address->sin_port = htons(PMAPPORT); - client = clntudp_bufcreate(address, PMAPPROG, - PMAPVERS, timeout, &sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client != NULL) { - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = 0; /* not needed or used */ - if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT, - (xdrproc_t)xdr_pmap, - &parms, (xdrproc_t)xdr_u_short, &port, tottimeout) != - RPC_SUCCESS){ - rpc_createerr.cf_stat = RPC_PMAPFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - } else if (port == 0) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - } - CLNT_DESTROY(client); - } - address->sin_port = 0; - return (port); -} diff --git a/libtirpc-1.3.1/src/pmap_prot.c b/libtirpc-1.3.1/src/pmap_prot.c deleted file mode 100644 index c0a642b..0000000 --- a/libtirpc-1.3.1/src/pmap_prot.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * pmap_prot.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -#include -#include -#include - - -bool_t -xdr_pmap(xdrs, regs) - XDR *xdrs; - struct pmap *regs; -{ - - assert(xdrs != NULL); - assert(regs != NULL); - - if (xdr_u_long(xdrs, ®s->pm_prog) && - xdr_u_long(xdrs, ®s->pm_vers) && - xdr_u_long(xdrs, ®s->pm_prot)) - return (xdr_u_long(xdrs, ®s->pm_port)); - return (FALSE); -} diff --git a/libtirpc-1.3.1/src/pmap_prot2.c b/libtirpc-1.3.1/src/pmap_prot2.c deleted file mode 100644 index 5583ff0..0000000 --- a/libtirpc-1.3.1/src/pmap_prot2.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * pmap_prot2.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -#include -#include -#include - - -/* - * What is going on with linked lists? (!) - * First recall the link list declaration from pmap_prot.h: - * - * struct pmaplist { - * struct pmap pml_map; - * struct pmaplist *pml_map; - * }; - * - * Compare that declaration with a corresponding xdr declaration that - * is (a) pointer-less, and (b) recursive: - * - * typedef union switch (bool_t) { - * - * case TRUE: struct { - * struct pmap; - * pmaplist_t foo; - * }; - * - * case FALSE: struct {}; - * } pmaplist_t; - * - * Notice that the xdr declaration has no nxt pointer while - * the C declaration has no bool_t variable. The bool_t can be - * interpreted as ``more data follows me''; if FALSE then nothing - * follows this bool_t; if TRUE then the bool_t is followed by - * an actual struct pmap, and then (recursively) by the - * xdr union, pamplist_t. - * - * This could be implemented via the xdr_union primitive, though this - * would cause a one recursive call per element in the list. Rather than do - * that we can ``unwind'' the recursion - * into a while loop and do the union arms in-place. - * - * The head of the list is what the C programmer wishes to past around - * the net, yet is the data that the pointer points to which is interesting; - * this sounds like a job for xdr_reference! - */ -bool_t -xdr_pmaplist(xdrs, rp) - XDR *xdrs; - struct pmaplist **rp; -{ - /* - * more_elements is pre-computed in case the direction is - * XDR_ENCODE or XDR_FREE. more_elements is overwritten by - * xdr_bool when the direction is XDR_DECODE. - */ - bool_t more_elements; - int freeing; - struct pmaplist **next = NULL; /* pacify gcc */ - - assert(xdrs != NULL); - assert(rp != NULL); - - freeing = (xdrs->x_op == XDR_FREE); - - for (;;) { - more_elements = (bool_t)(*rp != NULL); - if (! xdr_bool(xdrs, &more_elements)) - return (FALSE); - if (! more_elements) - return (TRUE); /* we are done */ - /* - * the unfortunate side effect of non-recursion is that in - * the case of freeing we must remember the next object - * before we free the current object ... - */ - if (freeing) - next = &((*rp)->pml_next); - if (! xdr_reference(xdrs, (caddr_t *)rp, - (u_int)sizeof(struct pmaplist), (xdrproc_t)xdr_pmap)) - return (FALSE); - rp = (freeing) ? next : &((*rp)->pml_next); - } -} - - -/* - * xdr_pmaplist_ptr() is specified to take a PMAPLIST *, but is identical in - * functionality to xdr_pmaplist(). - */ -bool_t -xdr_pmaplist_ptr(xdrs, rp) - XDR *xdrs; - struct pmaplist *rp; -{ - return xdr_pmaplist(xdrs, (struct pmaplist **)(void *)rp); -} diff --git a/libtirpc-1.3.1/src/pmap_rmt.c b/libtirpc-1.3.1/src/pmap_rmt.c deleted file mode 100644 index 1c76114..0000000 --- a/libtirpc-1.3.1/src/pmap_rmt.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * pmap_rmt.c - * Client interface to pmap rpc service. - * remote call and broadcast service - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// For the clnttcp_create function -//#include - - -static const struct timeval timeout = { 3, 0 }; - -/* - * pmapper remote-call-service interface. - * This routine is used to call the pmapper remote call service - * which will look up a service program in the port maps, and then - * remotely call that routine with the given parameters. This allows - * programs to do a lookup and call in one step. -*/ -enum clnt_stat -pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, - port_ptr) - struct sockaddr_in *addr; - u_long prog, vers, proc; - xdrproc_t xdrargs, xdrres; - caddr_t argsp, resp; - struct timeval tout; - u_long *port_ptr; -{ - int sock = -1; - CLIENT *client; - struct rmtcallargs a; - struct rmtcallres r; - enum clnt_stat stat; - - assert(addr != NULL); - assert(port_ptr != NULL); - - addr->sin_port = htons(PMAPPORT); - client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &sock); - if (client != NULL) { - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.args_ptr = argsp; - a.xdr_args = xdrargs; - r.port_ptr = port_ptr; - r.results_ptr = resp; - r.xdr_results = xdrres; - stat = CLNT_CALL(client, (rpcproc_t)PMAPPROC_CALLIT, - (xdrproc_t)xdr_rmtcall_args, &a, (xdrproc_t)xdr_rmtcallres, - &r, tout); - CLNT_DESTROY(client); - } else { - stat = RPC_FAILED; - } - addr->sin_port = 0; - return (stat); -} - - -/* - * XDR remote call arguments - * written for XDR_ENCODE direction only - */ -bool_t -xdr_rmtcall_args(xdrs, cap) - XDR *xdrs; - struct rmtcallargs *cap; -{ - u_int lenposition, argposition, position; - - assert(xdrs != NULL); - assert(cap != NULL); - - if (xdr_u_long(xdrs, &(cap->prog)) && - xdr_u_long(xdrs, &(cap->vers)) && - xdr_u_long(xdrs, &(cap->proc))) { - lenposition = XDR_GETPOS(xdrs); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - argposition = XDR_GETPOS(xdrs); - if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) - return (FALSE); - position = XDR_GETPOS(xdrs); - cap->arglen = (u_long)position - (u_long)argposition; - XDR_SETPOS(xdrs, lenposition); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - XDR_SETPOS(xdrs, position); - return (TRUE); - } - return (FALSE); -} - -/* - * XDR remote call results - * written for XDR_DECODE direction only - */ -bool_t -xdr_rmtcallres(xdrs, crp) - XDR *xdrs; - struct rmtcallres *crp; -{ - caddr_t port_ptr; - - assert(xdrs != NULL); - assert(crp != NULL); - - port_ptr = (caddr_t)(void *)crp->port_ptr; - if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), - (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { - crp->port_ptr = (u_long *)(void *)port_ptr; - return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); - } - return (FALSE); -} diff --git a/libtirpc-1.3.1/src/rpc_callmsg.c b/libtirpc-1.3.1/src/rpc_callmsg.c deleted file mode 100644 index d5f7d0c..0000000 --- a/libtirpc-1.3.1/src/rpc_callmsg.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_callmsg.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ - -#include -#include -#include - -#include -#include - -#include - -/* - * XDR a call message - */ -bool_t -xdr_callmsg(xdrs, cmsg) - XDR *xdrs; - struct rpc_msg *cmsg; -{ - int32_t *buf; - struct opaque_auth *oa; - - assert(xdrs != NULL); - assert(cmsg != NULL); - - if (xdrs->x_op == XDR_ENCODE) { - if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_cred.oa_length) - + 2 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_verf.oa_length)); - if (buf != NULL) { - IXDR_PUT_INT32(buf, cmsg->rm_xid); - IXDR_PUT_ENUM(buf, cmsg->rm_direction); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - IXDR_PUT_INT32(buf, cmsg->rm_call.cb_rpcvers); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - IXDR_PUT_INT32(buf, cmsg->rm_call.cb_prog); - IXDR_PUT_INT32(buf, cmsg->rm_call.cb_vers); - IXDR_PUT_INT32(buf, cmsg->rm_call.cb_proc); - oa = &cmsg->rm_call.cb_cred; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_INT32(buf, oa->oa_length); - if (oa->oa_length) { - memmove(buf, oa->oa_base, oa->oa_length); - buf += RNDUP(oa->oa_length) / sizeof (int32_t); - } - oa = &cmsg->rm_call.cb_verf; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_INT32(buf, oa->oa_length); - if (oa->oa_length) { - memmove(buf, oa->oa_base, oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / sizeof (int32_t); - */ - } - return (TRUE); - } - } - if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); - if (buf != NULL) { - cmsg->rm_xid = IXDR_GET_U_INT32(buf); - cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - cmsg->rm_call.cb_rpcvers = IXDR_GET_U_INT32(buf); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - cmsg->rm_call.cb_prog = IXDR_GET_U_INT32(buf); - cmsg->rm_call.cb_vers = IXDR_GET_U_INT32(buf); - cmsg->rm_call.cb_proc = IXDR_GET_U_INT32(buf); - oa = &cmsg->rm_call.cb_cred; - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = (u_int)IXDR_GET_U_INT32(buf); - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - if (oa->oa_base == NULL) - return (FALSE); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - memmove(oa->oa_base, buf, - oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / - sizeof (int32_t); - */ - } - } - oa = &cmsg->rm_call.cb_verf; - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || - xdr_u_int(xdrs, &oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = (u_int)IXDR_GET_U_INT32(buf); - } - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - if (oa->oa_base == NULL) - return (FALSE); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - memmove(oa->oa_base, buf, - oa->oa_length); - /* no real need... - buf += RNDUP(oa->oa_length) / - sizeof (int32_t); - */ - } - } - return (TRUE); - } - } - if ( - xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - (cmsg->rm_direction == CALL) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_proc)) && - xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) ) - return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf))); - return (FALSE); -} diff --git a/libtirpc-1.3.1/src/rpc_com.h b/libtirpc-1.3.1/src/rpc_com.h deleted file mode 100644 index 76badef..0000000 --- a/libtirpc-1.3.1/src/rpc_com.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpc_com.h, Common definitions for both the server and client side. - * All for the topmost layer of rpc - * - * In Sun's tirpc distribution, this was installed as , - * but as it contains only non-exported interfaces, it was moved here. - */ - -#ifndef _TIRPC_RPCCOM_H -#define _TIRPC_RPCCOM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct netbuf *__rpc_set_netbuf(struct netbuf *, const void *, size_t); - -struct netbuf *__rpcb_findaddr_timed(rpcprog_t, rpcvers_t, - const struct netconfig *, const char *host, CLIENT **clpp, - struct timeval *tp); - -bool_t __rpc_control(int,void *); - -bool_t __svc_clean_idle(fd_set *, int, bool_t); -bool_t __xdrrec_setnonblock(XDR *, int); -bool_t __xdrrec_getrec(XDR *, enum xprt_stat *, bool_t); -void __xprt_unregister_unlocked(SVCXPRT *); -void __xprt_set_raddr(SVCXPRT *, const struct sockaddr_storage *); - - -extern int __svc_maxrec; - -#ifdef __cplusplus -} -#endif - -#endif /* _TIRPC_RPCCOM_H */ diff --git a/libtirpc-1.3.1/src/rpc_commondata.c b/libtirpc-1.3.1/src/rpc_commondata.c deleted file mode 100644 index 918c1aa..0000000 --- a/libtirpc-1.3.1/src/rpc_commondata.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - - -/* - * This file should only contain common data (global data) that is exported - * by public interfaces - */ -struct opaque_auth _null_auth; -fd_set svc_fdset; -int svc_maxfd = -1; -struct pollfd *svc_pollfd; -int svc_max_pollfd; - diff --git a/libtirpc-1.3.1/src/rpc_dtablesize.c b/libtirpc-1.3.1/src/rpc_dtablesize.c deleted file mode 100644 index 3fe503a..0000000 --- a/libtirpc-1.3.1/src/rpc_dtablesize.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -/* - * Cache the result of getdtablesize(), so we don't have to do an - * expensive system call every time. - */ -int -_rpc_dtablesize(void) -{ - static int size; - - if (size == 0) { - size = getdtablesize(); - } - return (size); -} diff --git a/libtirpc-1.3.1/src/rpc_generic.c b/libtirpc-1.3.1/src/rpc_generic.c deleted file mode 100644 index aabbe4b..0000000 --- a/libtirpc-1.3.1/src/rpc_generic.c +++ /dev/null @@ -1,879 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - -/* - * rpc_generic.c, Miscl routines for RPC. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_com.h" - -struct handle { - NCONF_HANDLE *nhandle; - int nflag; /* Whether NETPATH or NETCONFIG */ - int nettype; -}; - -static const struct _rpcnettype { - const char *name; - const int type; -} _rpctypelist[] = { - { "netpath", _RPC_NETPATH }, - { "visible", _RPC_VISIBLE }, - { "circuit_v", _RPC_CIRCUIT_V }, - { "datagram_v", _RPC_DATAGRAM_V }, - { "circuit_n", _RPC_CIRCUIT_N }, - { "datagram_n", _RPC_DATAGRAM_N }, - { "tcp", _RPC_TCP }, - { "udp", _RPC_UDP }, - { 0, _RPC_NONE } -}; - -struct netid_af { - const char *netid; - int af; - int protocol; -}; - -static const struct netid_af na_cvt[] = { - { "udp", AF_INET, IPPROTO_UDP }, - { "tcp", AF_INET, IPPROTO_TCP }, -#ifdef INET6 - { "udp6", AF_INET6, IPPROTO_UDP }, - { "tcp6", AF_INET6, IPPROTO_TCP }, -#endif - { "local", AF_LOCAL, 0 } -}; - -#if 0 -static char *strlocase(char *); -#endif -static int getnettype(const char *); - -/* - * Cache the result of getrlimit(), so we don't have to do an - * expensive call every time. - */ -int -__rpc_dtbsize() -{ - static int tbsize; - struct rlimit rl; - - if (tbsize) { - return (tbsize); - } - if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { - return (tbsize = (int)rl.rlim_cur); - } - /* - * Something wrong. I'll try to save face by returning a - * pessimistic number. - */ - return (32); -} - - -/* - * Find the appropriate buffer size - */ -u_int -/*ARGSUSED*/ -__rpc_get_t_size(af, proto, size) - int af, proto; - int size; /* Size requested */ -{ - int maxsize, defsize; - - maxsize = 256 * 1024; /* XXX */ - switch (proto) { - case IPPROTO_TCP: - defsize = 64 * 1024; /* XXX */ - break; - case IPPROTO_UDP: - defsize = UDPMSGSIZE; - break; - default: - defsize = RPC_MAXDATASIZE; - break; - } - if (size == 0) - return defsize; - - /* Check whether the value is within the upper max limit */ - return (size > maxsize ? (u_int)maxsize : (u_int)size); -} - -/* - * Find the appropriate address buffer size - */ -u_int -__rpc_get_a_size(af) - int af; -{ - switch (af) { - case AF_INET: - return sizeof (struct sockaddr_in); -#ifdef INET6 - case AF_INET6: - return sizeof (struct sockaddr_in6); -#endif - case AF_LOCAL: - return sizeof (struct sockaddr_un); - default: - break; - } - return ((u_int)RPC_MAXADDRSIZE); -} - -#if 0 -static char * -strlocase(p) - char *p; -{ - char *t = p; - - for (; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - return (t); -} -#endif - -/* - * Returns the type of the network as defined in - * If nettype is NULL, it defaults to NETPATH. - */ -static int -getnettype(nettype) - const char *nettype; -{ - int i; - - if ((nettype == NULL) || (nettype[0] == 0)) { - return (_RPC_NETPATH); /* Default */ - } - -#if 0 - nettype = strlocase(nettype); -#endif - for (i = 0; _rpctypelist[i].name; i++) - if (strcasecmp(nettype, _rpctypelist[i].name) == 0) { - return (_rpctypelist[i].type); - } - return (_rpctypelist[i].type); -} - -/* - * For the given nettype (tcp or udp only), return the first - * IPv4 structure found. - * This should be freed by calling freenetconfigent() - */ -struct netconfig * -__rpc_getconfip(nettype) - const char *nettype; -{ - char *netid; - char *netid_tcp = (char *) NULL; - char *netid_udp = (char *) NULL; - struct netconfig *dummy; - extern thread_key_t tcp_key, udp_key; - extern mutex_t tsd_lock; - - if (tcp_key == KEY_INITIALIZER) { - mutex_lock(&tsd_lock); - if (tcp_key == KEY_INITIALIZER) - thr_keycreate(&tcp_key, free); - mutex_unlock(&tsd_lock); - } - netid_tcp = (char *)thr_getspecific(tcp_key); - if (udp_key == KEY_INITIALIZER) { - mutex_lock(&tsd_lock); - if (udp_key == KEY_INITIALIZER) - thr_keycreate(&udp_key, free); - mutex_unlock(&tsd_lock); - } - netid_udp = (char *)thr_getspecific(udp_key); - if (!netid_udp && !netid_tcp) { - struct netconfig *nconf; - void *confighandle; - - if (!(confighandle = setnetconfig())) { - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - return (NULL); - } - while ((nconf = getnetconfig(confighandle)) != NULL) { - if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { - if (strcmp(nconf->nc_proto, NC_TCP) == 0 && - netid_tcp == NULL) { - netid_tcp = strdup(nconf->nc_netid); - thr_setspecific(tcp_key, - (void *) netid_tcp); - } else - if (strcmp(nconf->nc_proto, NC_UDP) == 0 && - netid_udp == NULL) { - netid_udp = strdup(nconf->nc_netid); - thr_setspecific(udp_key, - (void *) netid_udp); - } - } - } - endnetconfig(confighandle); - } - if (strcmp(nettype, "udp") == 0) - netid = netid_udp; - else if (strcmp(nettype, "tcp") == 0) - netid = netid_tcp; - else { - return (NULL); - } - if ((netid == NULL) || (netid[0] == 0)) { - return (NULL); - } - dummy = getnetconfigent(netid); - return (dummy); -} - -/* - * Returns the type of the nettype, which should then be used with - * __rpc_getconf(). - */ -void * -__rpc_setconf(nettype) - const char *nettype; -{ - struct handle *handle; - - handle = (struct handle *) malloc(sizeof (struct handle)); - if (handle == NULL) { - return (NULL); - } - switch (handle->nettype = getnettype(nettype)) { - case _RPC_NETPATH: - case _RPC_CIRCUIT_N: - case _RPC_DATAGRAM_N: - if (!(handle->nhandle = setnetpath())) { - free(handle); - return (NULL); - } - handle->nflag = TRUE; - break; - case _RPC_VISIBLE: - case _RPC_CIRCUIT_V: - case _RPC_DATAGRAM_V: - case _RPC_TCP: - case _RPC_UDP: - if (!(handle->nhandle = setnetconfig())) { - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - free(handle); - return (NULL); - } - handle->nflag = FALSE; - break; - default: - free(handle); - return (NULL); - } - - return (handle); -} - -/* - * Returns the next netconfig struct for the given "net" type. - * __rpc_setconf() should have been called previously. - */ -struct netconfig * -__rpc_getconf(vhandle) - void *vhandle; -{ - struct handle *handle; - struct netconfig *nconf; - - handle = (struct handle *)vhandle; - if (handle == NULL) { - return (NULL); - } - for (;;) { - if (handle->nflag) - nconf = getnetpath(handle->nhandle); - else - nconf = getnetconfig(handle->nhandle); - if (nconf == NULL) - break; - if ((nconf->nc_semantics != NC_TPI_CLTS) && - (nconf->nc_semantics != NC_TPI_COTS) && - (nconf->nc_semantics != NC_TPI_COTS_ORD)) - continue; - switch (handle->nettype) { - case _RPC_VISIBLE: - if (!(nconf->nc_flag & NC_VISIBLE)) - continue; - /* FALLTHROUGH */ - case _RPC_NETPATH: /* Be happy */ - break; - case _RPC_CIRCUIT_V: - if (!(nconf->nc_flag & NC_VISIBLE)) - continue; - /* FALLTHROUGH */ - case _RPC_CIRCUIT_N: - if ((nconf->nc_semantics != NC_TPI_COTS) && - (nconf->nc_semantics != NC_TPI_COTS_ORD)) - continue; - break; - case _RPC_DATAGRAM_V: - if (!(nconf->nc_flag & NC_VISIBLE)) - continue; - /* FALLTHROUGH */ - case _RPC_DATAGRAM_N: - if (nconf->nc_semantics != NC_TPI_CLTS) - continue; - break; - case _RPC_TCP: - if (((nconf->nc_semantics != NC_TPI_COTS) && - (nconf->nc_semantics != NC_TPI_COTS_ORD)) || - (strcmp(nconf->nc_protofmly, NC_INET) -#ifdef INET6 - && strcmp(nconf->nc_protofmly, NC_INET6)) -#else - ) -#endif - || - strcmp(nconf->nc_proto, NC_TCP)) - continue; - break; - case _RPC_UDP: - if ((nconf->nc_semantics != NC_TPI_CLTS) || - (strcmp(nconf->nc_protofmly, NC_INET) -#ifdef INET6 - && strcmp(nconf->nc_protofmly, NC_INET6)) -#else - ) -#endif - || - strcmp(nconf->nc_proto, NC_UDP)) - continue; - break; - } - break; - } - return (nconf); -} - -void -__rpc_endconf(vhandle) - void * vhandle; -{ - struct handle *handle; - - handle = (struct handle *) vhandle; - if (handle == NULL) { - return; - } - if (handle->nflag) { - endnetpath(handle->nhandle); - } else { - endnetconfig(handle->nhandle); - } - free(handle); -} - -/* - * Used to ping the NULL procedure for clnt handle. - * Returns NULL if fails, else a non-NULL pointer. - */ -void * -rpc_nullproc(clnt) - CLIENT *clnt; -{ - struct timeval TIMEOUT = {25, 0}; - - if (clnt_call(clnt, NULLPROC, (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_void, NULL, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *) clnt); -} - -/* - * Try all possible transports until - * one succeeds in finding the netconf for the given fd. - */ -struct netconfig * -__rpcgettp(fd) - int fd; -{ - const char *netid; - struct __rpc_sockinfo si; - - if (!__rpc_fd2sockinfo(fd, &si)) - return NULL; - - if (!__rpc_sockinfo2netid(&si, &netid)) - return NULL; - - /*LINTED const castaway*/ - return getnetconfigent((char *)netid); -} - -int -__rpc_fd2sockinfo(int fd, struct __rpc_sockinfo *sip) -{ - socklen_t len; - int type, proto; - struct sockaddr_storage ss; - - len = sizeof ss; - if (getsockname(fd, (struct sockaddr *)&ss, &len) < 0) - return 0; - sip->si_alen = len; - - len = sizeof type; - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &len) < 0) - return 0; - - /* XXX */ - if (ss.ss_family != AF_LOCAL) { - if (type == SOCK_STREAM) - proto = IPPROTO_TCP; - else if (type == SOCK_DGRAM) - proto = IPPROTO_UDP; - else - return 0; - } else - proto = 0; - - sip->si_af = ss.ss_family; - sip->si_proto = proto; - sip->si_socktype = type; - - return 1; -} - -/* - * Linear search, but the number of entries is small. - */ -int -__rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip) -{ - int i; - - for (i = 0; i < (sizeof na_cvt) / (sizeof (struct netid_af)); i++) - if (strcmp(na_cvt[i].netid, nconf->nc_netid) == 0 || ( - strcmp(nconf->nc_netid, "unix") == 0 && - strcmp(na_cvt[i].netid, "local") == 0)) { - sip->si_af = na_cvt[i].af; - sip->si_proto = na_cvt[i].protocol; - sip->si_socktype = - __rpc_seman2socktype((int)nconf->nc_semantics); - if (sip->si_socktype == -1) - return 0; - sip->si_alen = __rpc_get_a_size(sip->si_af); - return 1; - } - - return 0; -} - -int -__rpc_nconf2fd_flags(const struct netconfig *nconf, int flags) -{ - struct __rpc_sockinfo si; - int fd; - - if (!__rpc_nconf2sockinfo(nconf, &si)) - return 0; - - if ((fd = socket(si.si_af, si.si_socktype | flags, si.si_proto)) >= 0 && - si.si_af == AF_INET6) { - int val = 1; - -#ifdef INET6 - setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &val, sizeof(val)); -#endif - } - return fd; -} - -int -__rpc_nconf2fd(const struct netconfig *nconf) -{ - return __rpc_nconf2fd_flags(nconf, 0); -} - -int -__rpc_sockinfo2netid(struct __rpc_sockinfo *sip, const char **netid) -{ - int i; - struct netconfig *nconf; - - nconf = getnetconfigent("local"); - - for (i = 0; i < (sizeof na_cvt) / (sizeof (struct netid_af)); i++) { - if (na_cvt[i].af == sip->si_af && - na_cvt[i].protocol == sip->si_proto) { - if (strcmp(na_cvt[i].netid, "local") == 0 && nconf == NULL) { - if (netid) - *netid = "unix"; - } else { - if (netid) - *netid = na_cvt[i].netid; - } - if (nconf != NULL) - freenetconfigent(nconf); - return 1; - } - } - if (nconf != NULL) - freenetconfigent(nconf); - - return 0; -} - -char * -taddr2uaddr(const struct netconfig *nconf, const struct netbuf *nbuf) -{ - struct __rpc_sockinfo si; - - if (!__rpc_nconf2sockinfo(nconf, &si)) - return NULL; - return __rpc_taddr2uaddr_af(si.si_af, nbuf); -} - -struct netbuf * -uaddr2taddr(const struct netconfig *nconf, const char *uaddr) -{ - struct __rpc_sockinfo si; - - if (!__rpc_nconf2sockinfo(nconf, &si)) - return NULL; - return __rpc_uaddr2taddr_af(si.si_af, uaddr); -} - -char * -__rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) -{ - char *ret; - struct sockaddr_in *sin; - struct sockaddr_un *sun; - char namebuf[INET_ADDRSTRLEN]; -#ifdef INET6 - struct sockaddr_in6 *sin6; - char namebuf6[INET6_ADDRSTRLEN]; -#endif - int path_len; - u_int16_t port; - - if (nbuf->len <= 0) - return NULL; - - switch (af) { - case AF_INET: - if (nbuf->len < sizeof(*sin)) { - return NULL; - } - sin = nbuf->buf; - if (inet_ntop(af, &sin->sin_addr, namebuf, sizeof namebuf) - == NULL) - return NULL; - port = ntohs(sin->sin_port); - if (asprintf(&ret, "%s.%u.%u", namebuf, ((u_int32_t)port) >> 8, - port & 0xff) < 0) - return NULL; - break; -#ifdef INET6 - case AF_INET6: - if (nbuf->len < sizeof(*sin6)) { - return NULL; - } - sin6 = nbuf->buf; - if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6) - == NULL) - return NULL; - port = ntohs(sin6->sin6_port); - if (asprintf(&ret, "%s.%u.%u", namebuf6, ((u_int32_t)port) >> 8, - port & 0xff) < 0) - return NULL; - break; -#endif - case AF_LOCAL: - sun = nbuf->buf; - - path_len = nbuf->len - offsetof(struct sockaddr_un, sun_path); - if (path_len < 0) - return NULL; - - if (asprintf(&ret, "%.*s", path_len, sun->sun_path) < 0) - return (NULL); - break; - default: - return NULL; - } - - return ret; -} - -struct netbuf * -__rpc_uaddr2taddr_af(int af, const char *uaddr) -{ - struct netbuf *ret = NULL; - char *addrstr, *p; - unsigned port, portlo, porthi; - struct sockaddr_in *sin; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - struct sockaddr_un *sun; - - port = 0; - sin = NULL; - if (uaddr == NULL) - return NULL; - addrstr = strdup(uaddr); - if (addrstr == NULL) - return NULL; - - /* - * AF_LOCAL addresses are expected to be absolute - * pathnames, anything else will be AF_INET or AF_INET6. - */ - if (*addrstr != '/') { - p = strrchr(addrstr, '.'); - if (p == NULL) - goto out; - portlo = (unsigned)atoi(p + 1); - *p = '\0'; - - p = strrchr(addrstr, '.'); - if (p == NULL) - goto out; - porthi = (unsigned)atoi(p + 1); - *p = '\0'; - port = (porthi << 8) | portlo; - } - - ret = (struct netbuf *)malloc(sizeof *ret); - if (ret == NULL) - goto out; - - switch (af) { - case AF_INET: - sin = (struct sockaddr_in *)malloc(sizeof *sin); - if (sin == NULL) - goto out; - memset(sin, 0, sizeof *sin); - sin->sin_family = AF_INET; - sin->sin_port = htons(port); - if (inet_pton(AF_INET, addrstr, &sin->sin_addr) <= 0) { - free(sin); - free(ret); - ret = NULL; - goto out; - } - ret->maxlen = ret->len = sizeof *sin; - ret->buf = sin; - break; -#ifdef INET6 - case AF_INET6: - sin6 = (struct sockaddr_in6 *)malloc(sizeof *sin6); - if (sin6 == NULL) - goto out; - memset(sin6, 0, sizeof *sin6); - sin6->sin6_family = AF_INET6; - sin6->sin6_port = htons(port); - if (inet_pton(AF_INET6, addrstr, &sin6->sin6_addr) <= 0) { - free(sin6); - free(ret); - ret = NULL; - goto out; - } - ret->maxlen = ret->len = sizeof *sin6; - ret->buf = sin6; - break; -#endif - case AF_LOCAL: - sun = (struct sockaddr_un *)malloc(sizeof *sun); - if (sun == NULL) - goto out; - memset(sun, 0, sizeof *sun); - sun->sun_family = AF_LOCAL; - strncpy(sun->sun_path, addrstr, sizeof(sun->sun_path) - 1); - ret->len = SUN_LEN(sun); - ret->maxlen = sizeof(struct sockaddr_un); - ret->buf = sun; - break; - default: - break; - } -out: - free(addrstr); - return ret; -} - -int -__rpc_seman2socktype(int semantics) -{ - switch (semantics) { - case NC_TPI_CLTS: - return SOCK_DGRAM; - case NC_TPI_COTS_ORD: - return SOCK_STREAM; - case NC_TPI_RAW: - return SOCK_RAW; - default: - break; - } - - return -1; -} - -int -__rpc_socktype2seman(int socktype) -{ - switch (socktype) { - case SOCK_DGRAM: - return NC_TPI_CLTS; - case SOCK_STREAM: - return NC_TPI_COTS_ORD; - case SOCK_RAW: - return NC_TPI_RAW; - default: - break; - } - - return -1; -} - -/* - * XXXX - IPv6 scope IDs can't be handled in universal addresses. - * Here, we compare the original server address to that of the RPC - * service we just received back from a call to rpcbind on the remote - * machine. If they are both "link local" or "site local", copy - * the scope id of the server address over to the service address. - */ -int -__rpc_fixup_addr(struct netbuf *new, const struct netbuf *svc) -{ -#ifdef INET6 - struct sockaddr *sa_new, *sa_svc; - struct sockaddr_in6 *sin6_new, *sin6_svc; - - sa_svc = (struct sockaddr *)svc->buf; - sa_new = (struct sockaddr *)new->buf; - - if (sa_new->sa_family == sa_svc->sa_family && - sa_new->sa_family == AF_INET6) { - sin6_new = (struct sockaddr_in6 *)new->buf; - sin6_svc = (struct sockaddr_in6 *)svc->buf; - - if ((IN6_IS_ADDR_LINKLOCAL(&sin6_new->sin6_addr) && - IN6_IS_ADDR_LINKLOCAL(&sin6_svc->sin6_addr)) || - (IN6_IS_ADDR_SITELOCAL(&sin6_new->sin6_addr) && - IN6_IS_ADDR_SITELOCAL(&sin6_svc->sin6_addr))) { - sin6_new->sin6_scope_id = sin6_svc->sin6_scope_id; - } - } -#endif - return 1; -} - -int -__rpc_sockisbound(int fd) -{ - struct sockaddr_storage ss; - union { - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - struct sockaddr_un usin; - } u_addr; - socklen_t slen; - - slen = sizeof (struct sockaddr_storage); - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) - return 0; - - switch (ss.ss_family) { - case AF_INET: - memcpy(&u_addr.sin, &ss, sizeof(u_addr.sin)); - return (u_addr.sin.sin_port != 0); -#ifdef INET6 - case AF_INET6: - memcpy(&u_addr.sin6, &ss, sizeof(u_addr.sin6)); - return (u_addr.sin6.sin6_port != 0); -#endif - case AF_LOCAL: - /* XXX check this */ - memcpy(&u_addr.usin, &ss, sizeof(u_addr.usin)); - return (u_addr.usin.sun_path[0] != 0); - default: - break; - } - - return 0; -} - -/* - * Helper function to set up a netbuf - */ -struct netbuf * -__rpc_set_netbuf(struct netbuf *nb, const void *ptr, size_t len) -{ - if (nb->len != len) { - if (nb->len) - mem_free(nb->buf, nb->len); - nb->buf = mem_alloc(len); - if (nb->buf == NULL) - return NULL; - - nb->maxlen = nb->len = len; - } - memcpy(nb->buf, ptr, len); - return nb; -} diff --git a/libtirpc-1.3.1/src/rpc_gss_utils.c b/libtirpc-1.3.1/src/rpc_gss_utils.c deleted file mode 100644 index 80fc78a..0000000 --- a/libtirpc-1.3.1/src/rpc_gss_utils.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Copyright (c) 2013, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include -#include - -#include - -/* Internal only */ -void rpc_gss_set_error(int); -void rpc_gss_clear_error(void); -bool_t rpc_gss_oid_to_mech(rpc_gss_OID, char **); - -/* - * Return the static "_rpc_gss_error" if we are the main thread - * (including non-threaded programs), or if an allocation fails. - */ -static rpc_gss_error_t * -__rpc_gss_error(void) -{ - static rpc_gss_error_t _rpc_gss_error = { 0, 0 }; - extern thread_key_t rg_key; - rpc_gss_error_t *result; - - if (rg_key == KEY_INITIALIZER) { - static mutex_t _rpc_gss_error_lock = MUTEX_INITIALIZER; - int err = 0; - - mutex_lock(&_rpc_gss_error_lock); - if (rg_key == KEY_INITIALIZER) - err = thr_keycreate(&rg_key, free); - mutex_unlock(&_rpc_gss_error_lock); - - if (err != 0) - return &_rpc_gss_error; - } - - result = thr_getspecific(rg_key); - if (result == NULL) { - result = calloc(1, sizeof(*result)); - if (result == NULL) - return &_rpc_gss_error; - - if (thr_setspecific(rg_key, result) != 0) { - free(result); - return &_rpc_gss_error; - } - } - - return result; -} - -/* - * External API: Retrieve thread-specific error values - * - * error: address of rpc_gss_error_t structure to fill in - */ -void -rpc_gss_get_error(rpc_gss_error_t *result) -{ - rpc_gss_error_t *error = __rpc_gss_error(); - - result->rpc_gss_error = error->rpc_gss_error; - result->system_error = error->system_error; -} - -/* - * Internal only: Set thread-specific error value - * - * system_error: new value for thread's .system_error field. - * .rpc_gss_error is always set to RPC_GSS_ER_SYSTEMERROR. - */ -void -rpc_gss_set_error(int system_error) -{ - rpc_gss_error_t *error = __rpc_gss_error(); - - error->rpc_gss_error = RPC_GSS_ER_SYSTEMERROR; - error->system_error = system_error; -} - -/* - * Internal only: Clear thread-specific error values - */ -void -rpc_gss_clear_error(void) -{ - rpc_gss_error_t *error = __rpc_gss_error(); - - error->rpc_gss_error = RPC_GSS_ER_SUCCESS; - error->system_error = 0; -} - -/* - * On Solaris, the GSS-API implementation consults the files - * /etc/gss/mech and /etc/gss/qop for a mapping of mechanism - * names to OIDs, and QOP names to numbers. - * - * GNU's GSS-API has no such database. We emulate it here - * with a built-in table of supported mechanisms and qops, - * since the set of supported mechanisms is unlikely to - * change often. - */ - -struct _rpc_gss_qop { - char *qi_name; - unsigned int qi_num; -}; - -struct _rpc_gss_mechanism { - char *mi_name; - rpc_gss_OID_desc mi_oid; - char **mi_qop_names; - struct _rpc_gss_qop **mi_qops; -}; - - -static struct _rpc_gss_qop _rpc_gss_qop_default = { - .qi_name = "GSS_C_QOP_DEFAULT", - .qi_num = GSS_C_QOP_DEFAULT, -}; - -static struct _rpc_gss_qop *_rpc_gss_krb5_qops[] = { - &_rpc_gss_qop_default, - NULL, -}; - -static char *_rpc_gss_krb5_qop_names[] = { - "GSS_C_QOP_DEFAULT", - NULL, -}; - -/* GSS_MECH_KRB5_OID: Defined by RFC 1964 */ -static struct _rpc_gss_mechanism _rpc_gss_mech_kerberos_v5 = { - .mi_name = "kerberos_v5", - .mi_oid = { 9, "\052\206\110\206\367\022\001\002\002" }, - .mi_qop_names = _rpc_gss_krb5_qop_names, - .mi_qops = _rpc_gss_krb5_qops, -}; - -/* GSS_KRB5_NT_PRINCIPAL_NAME: Defined by RFC 1964 */ -static struct _rpc_gss_mechanism _rpc_gss_mech_kerberos_v5_princname = { - .mi_name = "kerberos_v5", - .mi_oid = { 10, "\052\206\110\206\367\022\001\002\002\001" }, - .mi_qop_names = _rpc_gss_krb5_qop_names, - .mi_qops = _rpc_gss_krb5_qops, -}; - -static struct _rpc_gss_mechanism *_rpc_gss_mechanisms[] = { - &_rpc_gss_mech_kerberos_v5, - &_rpc_gss_mech_kerberos_v5_princname, - NULL, -}; - -static char *_rpc_gss_mechanism_names[] = { - "kerberos_v5", - NULL, -}; - -static struct _rpc_gss_mechanism * -_rpc_gss_find_mechanism(char *mechanism) -{ - unsigned int i; - - for (i = 0; _rpc_gss_mechanisms[i] != NULL; i++) - if (strcmp(mechanism, _rpc_gss_mechanisms[i]->mi_name) == 0) - return _rpc_gss_mechanisms[i]; - return NULL; -} - -static bool_t -_rpc_gss_OID_equal(rpc_gss_OID o1, rpc_gss_OID o2) -{ - return (o1->length == o2->length) && - (memcmp(o1->elements, o2->elements, o1->length) == 0); -} - -static struct _rpc_gss_mechanism * -_rpc_gss_find_oid(rpc_gss_OID oid) -{ - unsigned int i; - - for (i = 0; _rpc_gss_mechanisms[i] != NULL; i++) - if (_rpc_gss_OID_equal(oid, &_rpc_gss_mechanisms[i]->mi_oid)) - return _rpc_gss_mechanisms[i]; - return NULL; -} - -static struct _rpc_gss_qop * -_rpc_gss_find_qop_by_name(struct _rpc_gss_mechanism *m, char *qop) -{ - unsigned int i; - - for (i = 0; m->mi_qops[i] != NULL; i++) - if (strcmp(qop, m->mi_qops[i]->qi_name) == 0) - return m->mi_qops[i]; - return NULL; -} - -static struct _rpc_gss_qop * -_rpc_gss_find_qop_by_num(struct _rpc_gss_mechanism *m, u_int num) -{ - unsigned int i; - - for (i = 0; m->mi_qops[i] != NULL; i++) - if (num == m->mi_qops[i]->qi_num) - return m->mi_qops[i]; - return NULL; -} - -/* - * External API: Return array of security mechanism names - * - * Returns NULL-terminated array of pointers to NUL-terminated C - * strings, each containing a mechanism name. This is statically - * allocated memory. Caller must not free this array. - */ -char ** -rpc_gss_get_mechanisms(void) -{ - rpc_gss_clear_error(); - return (char **)_rpc_gss_mechanism_names; -} - -/* - * External API: Return array of qop names for a security mechanism - * - * mechanism: NUL-terminated C string containing mechanism name - * dummy: address of a service enum - * - * Returns NULL-terminated array of pointers to NUL-terminated C - * strings, each containing a qop name. This is statically - * allocated memory. Caller must not free this array. - */ -char ** -rpc_gss_get_mech_info(char *mechanism, rpc_gss_service_t *dummy) -{ - struct _rpc_gss_mechanism *m; - - if (mechanism == NULL || dummy == NULL) { - rpc_gss_set_error(EINVAL); - return NULL; - } - - m = _rpc_gss_find_mechanism(mechanism); - if (m == NULL) { - rpc_gss_set_error(ENOENT); - return NULL; - } - - rpc_gss_clear_error(); - *dummy = rpcsec_gss_svc_privacy; - return (char **)m->mi_qop_names; -} - -/* - * External API: Return range of supported RPCSEC_GSS versions - * - * high: address of highest supported version to fill in - * low: address of lowest supported version to fill in - * - * Returns TRUE if successful, or FALSE if an error occurs. - */ -bool_t -rpc_gss_get_versions(u_int *high, u_int *low) -{ - if (high == NULL || low == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - rpc_gss_clear_error(); - *high = *low = RPCSEC_GSS_VERSION; - return TRUE; -} - -/* - * External API: Check if a security mechanism is supported - * - * mechanism: NUL-terminated C string containing mechanism name - * - * Returns TRUE if the mechanism name is recognized and supported, - * otherwise FALSE is returned. - */ -bool_t -rpc_gss_is_installed(char *mechanism) -{ - struct _rpc_gss_mechanism *m; - - if (mechanism == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - rpc_gss_clear_error(); - m = _rpc_gss_find_mechanism(mechanism); - if (m == NULL) - return FALSE; - return TRUE; -} - -/* - * External API: Return the OID for a given security mechanism - * - * mechanism: NUL-terminated C string containing mechanism name - * oid: address of OID buffer to fill in - * - * Returns TRUE if the mechanism name is recognized and supported, - * otherwise FALSE is returned. - */ -bool_t -rpc_gss_mech_to_oid(char *mechanism, rpc_gss_OID *result) -{ - struct _rpc_gss_mechanism *m; - - if (mechanism == NULL || result == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - m = _rpc_gss_find_mechanism(mechanism); - if (m == NULL) { - rpc_gss_set_error(ENOENT); - return FALSE; - } - - *result = &m->mi_oid; - rpc_gss_clear_error(); - return TRUE; -} - -/* - * Internal only: Return the mechanism name for a given OID - * - * oid: GSS mechanism OID - * mechanism: address of a char * to fill in. This is statically - * allocated memory. Caller must not free this memory. - * - * Returns TRUE if the OID is a recognized and supported mechanism, - * otherwise FALSE is returned. - */ -bool_t -rpc_gss_oid_to_mech(rpc_gss_OID oid, char **mechanism) -{ - struct _rpc_gss_mechanism *m; - - if (oid == NULL || mechanism == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - m = _rpc_gss_find_oid(oid); - if (m == NULL) { - rpc_gss_set_error(ENOENT); - return FALSE; - } - - *mechanism = m->mi_name; - rpc_gss_clear_error(); - return TRUE; -} - -/* - * External API: Return the QOP number for a given QOP and mechanism name - * - * qop: NUL-terminated C string containing qop name - * mechanism: NUL-terminated C string containing mechanism name - * num: address of QOP buffer to fill in - * - * Returns TRUE if the qop and mechanism name are recognized and - * supported, otherwise FALSE is returned. - */ -bool_t -rpc_gss_qop_to_num(char *qop, char *mechanism, u_int *num) -{ - struct _rpc_gss_mechanism *m; - struct _rpc_gss_qop *q; - - if (qop == NULL || mechanism == NULL || num == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - m = _rpc_gss_find_mechanism(mechanism); - if (m == NULL) - goto out_err; - - q = _rpc_gss_find_qop_by_name(m, qop); - if (q == NULL) - goto out_err; - - *num = q->qi_num; - rpc_gss_clear_error(); - return TRUE; - -out_err: - rpc_gss_set_error(ENOENT); - return FALSE; -} - -/* - * Internal only: Return the QOP name for a given mechanism and QOP number - * - * mechanism: NUL-terminated C string containing security mechanism name - * num: QOP number - * qop: address of a char * to fill in. This is statically - * allocated memory. Caller must not free this memory. - * - * Returns TRUE if the QOP and mechanism are recognized and supported, - * otherwise FALSE is returned. - */ -bool_t -rpc_gss_num_to_qop(char *mechanism, u_int num, char **qop) -{ - struct _rpc_gss_mechanism *m; - struct _rpc_gss_qop *q; - - if (mechanism == NULL || qop == NULL) { - rpc_gss_set_error(EINVAL); - return FALSE; - } - - m = _rpc_gss_find_mechanism(mechanism); - if (m == NULL) - goto out_err; - - q = _rpc_gss_find_qop_by_num(m, num); - if (q == NULL) - goto out_err; - - *qop = q->qi_name; - rpc_gss_clear_error(); - return TRUE; - -out_err: - rpc_gss_set_error(ENOENT); - return FALSE; -} diff --git a/libtirpc-1.3.1/src/rpc_prot.c b/libtirpc-1.3.1/src/rpc_prot.c deleted file mode 100644 index 5841e51..0000000 --- a/libtirpc-1.3.1/src/rpc_prot.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_prot.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements the rpc message definition, - * its serializer and some common rpc utility routines. - * The routines are meant for various implementations of rpc - - * they are NOT for the rpc client or rpc service implementations! - * Because authentication stuff is easy and is part of rpc, the opaque - * routines are also in this program. - */ - -#include - -#include - -#include - -static void accepted(enum accept_stat, struct rpc_err *); -static void rejected(enum reject_stat, struct rpc_err *); - -/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ - -extern struct opaque_auth _null_auth; - -/* - * XDR an opaque authentication struct - * (see auth.h) - */ -bool_t -xdr_opaque_auth(xdrs, ap) - XDR *xdrs; - struct opaque_auth *ap; -{ - - assert(xdrs != NULL); - assert(ap != NULL); - - if (xdr_enum(xdrs, &(ap->oa_flavor))) - return (xdr_bytes(xdrs, &ap->oa_base, - &ap->oa_length, MAX_AUTH_BYTES)); - return (FALSE); -} - -/* - * XDR a DES block - */ -bool_t -xdr_des_block(xdrs, blkp) - XDR *xdrs; - des_block *blkp; -{ - - assert(xdrs != NULL); - assert(blkp != NULL); - - return (xdr_opaque(xdrs, (caddr_t)(void *)blkp, sizeof(des_block))); -} - -/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ - -/* - * XDR the MSG_ACCEPTED part of a reply message union - */ -bool_t -xdr_accepted_reply(xdrs, ar) - XDR *xdrs; - struct accepted_reply *ar; -{ - - assert(xdrs != NULL); - assert(ar != NULL); - - /* personalized union, rather than calling xdr_union */ - if (! xdr_opaque_auth(xdrs, &(ar->ar_verf))) - return (FALSE); - if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat))) - return (FALSE); - switch (ar->ar_stat) { - - case SUCCESS: - return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where)); - - case PROG_MISMATCH: - if (! xdr_u_int32_t(xdrs, &(ar->ar_vers.low))) - return (FALSE); - return (xdr_u_int32_t(xdrs, &(ar->ar_vers.high))); - - case GARBAGE_ARGS: - case SYSTEM_ERR: - case PROC_UNAVAIL: - case PROG_UNAVAIL: - break; - } - return (TRUE); /* TRUE => open ended set of problems */ -} - -/* - * XDR the MSG_DENIED part of a reply message union - */ -bool_t -xdr_rejected_reply(xdrs, rr) - XDR *xdrs; - struct rejected_reply *rr; -{ - - assert(xdrs != NULL); - assert(rr != NULL); - - /* personalized union, rather than calling xdr_union */ - if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat))) - return (FALSE); - switch (rr->rj_stat) { - - case RPC_MISMATCH: - if (! xdr_u_int32_t(xdrs, &(rr->rj_vers.low))) - return (FALSE); - return (xdr_u_int32_t(xdrs, &(rr->rj_vers.high))); - - case AUTH_ERROR: - return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why))); - } - /* NOTREACHED */ - return (FALSE); -} - -static const struct xdr_discrim reply_dscrm[3] = { - { (int)MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply }, - { (int)MSG_DENIED, (xdrproc_t)xdr_rejected_reply }, - { __dontcare__, NULL_xdrproc_t } }; - -/* - * XDR a reply message - */ -bool_t -xdr_replymsg(xdrs, rmsg) - XDR *xdrs; - struct rpc_msg *rmsg; -{ - assert(xdrs != NULL); - assert(rmsg != NULL); - - if ( - xdr_u_int32_t(xdrs, &(rmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) && - (rmsg->rm_direction == REPLY) ) - return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat), - (caddr_t)(void *)&(rmsg->rm_reply.ru), reply_dscrm, - NULL_xdrproc_t)); - return (FALSE); -} - - -/* - * Serializes the "static part" of a call message header. - * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers. - * The rm_xid is not really static, but the user can easily munge on the fly. - */ -bool_t -xdr_callhdr(xdrs, cmsg) - XDR *xdrs; - struct rpc_msg *cmsg; -{ - - assert(xdrs != NULL); - assert(cmsg != NULL); - - cmsg->rm_direction = CALL; - cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; - if ( - (xdrs->x_op == XDR_ENCODE) && - xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) ) - return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers))); - return (FALSE); -} - -/* ************************** Client utility routine ************* */ - -static void -accepted(acpt_stat, error) - enum accept_stat acpt_stat; - struct rpc_err *error; -{ - - assert(error != NULL); - - switch (acpt_stat) { - - case PROG_UNAVAIL: - error->re_status = RPC_PROGUNAVAIL; - return; - - case PROG_MISMATCH: - error->re_status = RPC_PROGVERSMISMATCH; - return; - - case PROC_UNAVAIL: - error->re_status = RPC_PROCUNAVAIL; - return; - - case GARBAGE_ARGS: - error->re_status = RPC_CANTDECODEARGS; - return; - - case SYSTEM_ERR: - error->re_status = RPC_SYSTEMERROR; - return; - - case SUCCESS: - error->re_status = RPC_SUCCESS; - return; - } - /* NOTREACHED */ - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (int32_t)MSG_ACCEPTED; - error->re_lb.s2 = (int32_t)acpt_stat; -} - -static void -rejected(rjct_stat, error) - enum reject_stat rjct_stat; - struct rpc_err *error; -{ - - assert(error != NULL); - - switch (rjct_stat) { - case RPC_MISMATCH: - error->re_status = RPC_VERSMISMATCH; - return; - - case AUTH_ERROR: - error->re_status = RPC_AUTHERROR; - return; - } - /* something's wrong, but we don't know what ... */ - /* NOTREACHED */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (int32_t)MSG_DENIED; - error->re_lb.s2 = (int32_t)rjct_stat; -} - -/* - * given a reply message, fills in the error - */ -void -_seterr_reply(msg, error) - struct rpc_msg *msg; - struct rpc_err *error; -{ - - assert(msg != NULL); - assert(error != NULL); - - /* optimized for normal, SUCCESSful case */ - switch (msg->rm_reply.rp_stat) { - - case MSG_ACCEPTED: - if (msg->acpted_rply.ar_stat == SUCCESS) { - error->re_status = RPC_SUCCESS; - return; - } - accepted(msg->acpted_rply.ar_stat, error); - break; - - case MSG_DENIED: - rejected(msg->rjcted_rply.rj_stat, error); - break; - - default: - error->re_status = RPC_FAILED; - error->re_lb.s1 = (int32_t)(msg->rm_reply.rp_stat); - break; - } - switch (error->re_status) { - - case RPC_VERSMISMATCH: - error->re_vers.low = msg->rjcted_rply.rj_vers.low; - error->re_vers.high = msg->rjcted_rply.rj_vers.high; - break; - - case RPC_AUTHERROR: - error->re_why = msg->rjcted_rply.rj_why; - break; - - case RPC_PROGVERSMISMATCH: - error->re_vers.low = msg->acpted_rply.ar_vers.low; - error->re_vers.high = msg->acpted_rply.ar_vers.high; - break; - - case RPC_FAILED: - case RPC_SUCCESS: - case RPC_PROGNOTREGISTERED: - case RPC_PMAPFAILURE: - case RPC_UNKNOWNPROTO: - case RPC_UNKNOWNHOST: - case RPC_SYSTEMERROR: - case RPC_CANTDECODEARGS: - case RPC_PROCUNAVAIL: - case RPC_PROGUNAVAIL: - case RPC_TIMEDOUT: - case RPC_CANTRECV: - case RPC_CANTSEND: - case RPC_CANTDECODERES: - case RPC_CANTENCODEARGS: - default: - break; - } -} diff --git a/libtirpc-1.3.1/src/rpc_soc.c b/libtirpc-1.3.1/src/rpc_soc.c deleted file mode 100644 index fde121d..0000000 --- a/libtirpc-1.3.1/src/rpc_soc.c +++ /dev/null @@ -1,745 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - * In addition, portions of such source code were derived from Berkeley - * 4.3 BSD under license from the Regents of the University of - * California. - */ - -#ifdef PORTMAP -/* - * rpc_soc.c - * - * The backward compatibility routines for the earlier implementation - * of RPC, where the only transports supported were tcp/ip and udp/ip. - * Based on berkeley socket abstraction, now implemented on the top - * of TLI/Streams - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nis.h" -#include "rpc_com.h" - -extern mutex_t rpcsoc_lock; - -static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t, - int *, u_int, u_int, char *, int); -static SVCXPRT *svc_com_create(int, u_int, u_int, char *); -static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *); - -/* XXX */ -#define IN4_LOCALHOST_STRING "127.0.0.1" -#define IN6_LOCALHOST_STRING "::1" - -/* - * A common clnt create routine - */ -static CLIENT * -clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags) - struct sockaddr_in *raddr; - rpcprog_t prog; - rpcvers_t vers; - int *sockp; - u_int sendsz; - u_int recvsz; - char *tp; - int flags; -{ - CLIENT *cl; - int madefd = FALSE; - int fd = *sockp; - struct netconfig *nconf; - struct netbuf bindaddr; - - mutex_lock(&rpcsoc_lock); - if ((nconf = __rpc_getconfip(tp)) == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - mutex_unlock(&rpcsoc_lock); - return (NULL); - } - if (fd == RPC_ANYSOCK) { - static int have_cloexec; - fd = __rpc_nconf2fd_flags(nconf, flags); -#ifdef SOCK_CLOEXEC - if (fd == -1) { - if ((flags & SOCK_CLOEXEC) && have_cloexec <= 0) { - fd = __rpc_nconf2fd(nconf); - if (fd == -1) - goto syserror; - if (flags & SOCK_CLOEXEC) { - have_cloexec = -1; - fcntl(fd, F_SETFD, FD_CLOEXEC); - } - } else - goto syserror; - } else if (flags & SOCK_CLOEXEC) - have_cloexec = 1; -#else - if (fd == -1) - goto syserror; -#endif - madefd = TRUE; - } - - if (raddr->sin_port == 0) { - u_int proto; - u_short sport; - - mutex_unlock(&rpcsoc_lock); /* pmap_getport is recursive */ - proto = strcmp(tp, "udp") == 0 ? IPPROTO_UDP : IPPROTO_TCP; - sport = pmap_getport(raddr, (u_long)prog, (u_long)vers, - proto); - if (sport == 0) { - goto err; - } - raddr->sin_port = htons(sport); - mutex_lock(&rpcsoc_lock); /* pmap_getport is recursive */ - } - - /* Transform sockaddr_in to netbuf */ - bindaddr.maxlen = bindaddr.len = sizeof (struct sockaddr_in); - bindaddr.buf = raddr; - - bindresvport(fd, NULL); - cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers, - sendsz, recvsz); - if (cl) { - if (madefd == TRUE) { - /* - * The fd should be closed while destroying the handle. - */ - (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL); - *sockp = fd; - } - (void) freenetconfigent(nconf); - mutex_unlock(&rpcsoc_lock); - return (cl); - } - goto err; - -syserror: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - -err: if (madefd == TRUE) - (void)close(fd); - (void) freenetconfigent(nconf); - mutex_unlock(&rpcsoc_lock); - return (NULL); -} - -CLIENT * -__libc_clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz, flags) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - struct timeval wait; - int *sockp; - u_int sendsz; - u_int recvsz; - int flags; -{ - CLIENT *cl; - - cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, - sendsz, recvsz, "udp", flags); - if (cl == NULL) { - return (NULL); - } - (void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); - return (cl); -} - -CLIENT * -clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - struct timeval wait; - int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *cl; - - cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, - sendsz, recvsz, "udp", 0); - if (cl == NULL) { - return (NULL); - } - (void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); - return (cl); -} - -CLIENT * -clntudp_create(raddr, program, version, wait, sockp) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - int *sockp; -{ - return clntudp_bufcreate(raddr, program, version, wait, sockp, UDPMSGSIZE, UDPMSGSIZE); -} - -CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - int *sockp; - u_int sendsz; - u_int recvsz; -{ - return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, - sendsz, recvsz, "tcp", 0); -} - -/* IPv6 version of clnt*_*create */ - -#ifdef INET6_NOT_USED - -CLIENT * -clntudp6_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) - struct sockaddr_in6 *raddr; - u_long prog; - u_long vers; - struct timeval wait; - int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *cl; - - cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, - sendsz, recvsz, "udp6", 0); - if (cl == NULL) { - return (NULL); - } - (void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait); - return (cl); -} - -CLIENT * -clntudp6_create(raddr, program, version, wait, sockp) - struct sockaddr_in6 *raddr; - u_long program; - u_long version; - struct timeval wait; - int *sockp; -{ - return clntudp6_bufcreate(raddr, program, version, wait, sockp, UDPMSGSIZE, UDPMSGSIZE); -} - -CLIENT * -clnttcp6_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in6 *raddr; - u_long prog; - u_long vers; - int *sockp; - u_int sendsz; - u_int recvsz; -{ - return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, - sendsz, recvsz, "tcp6", 0); -} - -#endif - -CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; -{ - return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers); -} - -/* - * A common server create routine - */ -static SVCXPRT * -svc_com_create(fd, sendsize, recvsize, netid) - int fd; - u_int sendsize; - u_int recvsize; - char *netid; -{ - struct netconfig *nconf; - SVCXPRT *svc; - int madefd = FALSE; - int port; - - if ((nconf = __rpc_getconfip(netid)) == NULL) { - (void) syslog(LOG_ERR, "Could not get %s transport", netid); - return (NULL); - } - if (fd == RPC_ANYSOCK) { - fd = __rpc_nconf2fd(nconf); - if (fd == -1) { - (void) freenetconfigent(nconf); - (void) syslog(LOG_ERR, - "svc%s_create: could not open connection", netid); - return (NULL); - } - madefd = TRUE; - } - - svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize); - (void) freenetconfigent(nconf); - if (svc == NULL) { - if (madefd) - (void)close(fd); - return (NULL); - } - port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port); - svc->xp_port = ntohs(port); - return (svc); -} - -SVCXPRT * -svctcp_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - - return svc_com_create(fd, sendsize, recvsize, "tcp"); -} - - - -SVCXPRT * -svcudp_bufcreate(fd, sendsz, recvsz) - int fd; - u_int sendsz, recvsz; -{ - - return svc_com_create(fd, sendsz, recvsz, "udp"); -} - - - -SVCXPRT * -svcfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - - return svc_fd_create(fd, sendsize, recvsize); -} - - -SVCXPRT * -svcudp_create(fd) - int fd; -{ - - return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp"); -} - - -SVCXPRT * -svcraw_create() -{ - - return svc_raw_create(); -} - - -/* IPV6 version */ -#ifdef INET6_NOT_USED -SVCXPRT * -svcudp6_bufcreate(fd, sendsz, recvsz) - int fd; - u_int sendsz, recvsz; -{ - return svc_com_create(fd, sendsz, recvsz, "udp6"); -} - - -SVCXPRT * -svctcp6_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - return svc_com_create(fd, sendsize, recvsize, "tcp6"); -} - - -SVCXPRT * -svcudp6_create(fd) - int fd; -{ - return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp6"); -} -#endif - -int -get_myaddress(addr) - struct sockaddr_in *addr; -{ - - memset((void *) addr, 0, sizeof(*addr)); - addr->sin_family = AF_INET; - addr->sin_port = htons(PMAPPORT); - addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK); - return (0); -} - -/* - * For connectionless "udp" transport. Obsoleted by rpc_call(). - */ -int -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - const char *host; - int prognum, versnum, procnum; - xdrproc_t inproc, outproc; - void *in, *out; -{ - - return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum, - (rpcproc_t)procnum, inproc, in, outproc, out, "udp"); -} - -/* - * For connectionless kind of transport. Obsoleted by rpc_reg() - */ -int -registerrpc(prognum, versnum, procnum, progname, inproc, outproc) - int prognum, versnum, procnum; - char *(*progname)(char [UDPMSGSIZE]); - xdrproc_t inproc, outproc; -{ - - return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum, - (rpcproc_t)procnum, progname, inproc, outproc, "udp"); -} - -/* - * All the following clnt_broadcast stuff is convulated; it supports - * the earlier calling style of the callback function - */ -extern thread_key_t clnt_broadcast_key; - -/* - * Need to translate the netbuf address into sockaddr_in address. - * Dont care about netid here. - */ -/* ARGSUSED */ -static bool_t -rpc_wrap_bcast(resultp, addr, nconf) - char *resultp; /* results of the call */ - struct netbuf *addr; /* address of the guy who responded */ - struct netconfig *nconf; /* Netconf of the transport */ -{ - resultproc_t clnt_broadcast_result; - - if (strcmp(nconf->nc_netid, "udp")) - return (FALSE); - clnt_broadcast_result = (resultproc_t)thr_getspecific(clnt_broadcast_key); - return (*clnt_broadcast_result)(resultp, - (struct sockaddr_in *)addr->buf); -} - -/* - * Broadcasts on UDP transport. Obsoleted by rpc_broadcast(). - */ -enum clnt_stat -clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) - u_long prog; /* program number */ - u_long vers; /* version number */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - void *argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - void *resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ -{ - extern mutex_t tsd_lock; - - if (clnt_broadcast_key == KEY_INITIALIZER) { - mutex_lock(&tsd_lock); - if (clnt_broadcast_key == KEY_INITIALIZER) - thr_keycreate(&clnt_broadcast_key, free); - mutex_unlock(&tsd_lock); - } - thr_setspecific(clnt_broadcast_key, (void *) eachresult); - return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers, - (rpcproc_t)proc, xargs, argsp, xresults, resultsp, - (resultproc_t) rpc_wrap_bcast, "udp"); -} - -#ifdef AUTHDES_SUPPORT -/* - * Create the client des authentication object. Obsoleted by - * authdes_seccreate(). - */ -AUTH * -authdes_create(servername, window, syncaddr, ckey) - char *servername; /* network name of server */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional hostaddr to sync with */ - des_block *ckey; /* optional conversation key to use */ -{ - AUTH *nauth; - char hostname[NI_MAXHOST]; - - if (syncaddr) { - /* - * Change addr to hostname, because that is the way - * new interface takes it. - */ - switch (syncaddr->sa_family) { - case AF_INET: - if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, - sizeof hostname, NULL, 0, 0) != 0) - goto fallback; - break; - case AF_INET6: - if (getnameinfo(syncaddr, sizeof(struct sockaddr_in6), hostname, - sizeof hostname, NULL, 0, 0) != 0) - goto fallback; - break; - default: - goto fallback; - } - nauth = authdes_seccreate(servername, window, hostname, ckey); - return (nauth); - } -fallback: - return authdes_seccreate(servername, window, NULL, ckey); -} - -/* - * Create the client des authentication object. Obsoleted by - * authdes_pk_seccreate(). - */ -extern AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *, - const des_block *, nis_server *); - -AUTH * -authdes_pk_create(servername, pkey, window, syncaddr, ckey) - char *servername; /* network name of server */ - netobj *pkey; /* public key */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional hostaddr to sync with */ - des_block *ckey; /* optional conversation key to use */ -{ - AUTH *nauth; - char hostname[NI_MAXHOST]; - - if (syncaddr) { - /* - * Change addr to hostname, because that is the way - * new interface takes it. - */ - switch (syncaddr->sa_family) { - case AF_INET: - if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, - sizeof hostname, NULL, 0, 0) != 0) - goto fallback; - break; - default: - goto fallback; - } - nauth = authdes_pk_seccreate(servername, pkey, window, hostname, ckey, NULL); - return (nauth); - } -fallback: - return authdes_pk_seccreate(servername, pkey, window, NULL, ckey, NULL); -} -#else -AUTH * -authdes_create(servername, window, syncaddr, ckey) - char *servername; /* network name of server */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional hostaddr to sync with */ - des_block *ckey; /* optional conversation key to use */ -{ return (NULL); } - -AUTH * -authdes_pk_create(servername, pkey, window, syncaddr, ckey) - char *servername; /* network name of server */ - netobj *pkey; /* public key */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional hostaddr to sync with */ - des_block *ckey; /* optional conversation key to use */ -{ return (NULL); } - -AUTH * -authdes_seccreate(const char *servername, const u_int win, - const char *timehost, const des_block *ckey) -{ - return (NULL); -} - -#endif - - -/* - * Create a client handle for a unix connection. Obsoleted by clnt_vc_create() - */ -CLIENT * -clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_un *raddr; - u_long prog; - u_long vers; - int *sockp; - u_int sendsz; - u_int recvsz; -{ - struct netbuf svcaddr = {0, 0, NULL}; - CLIENT *cl = NULL; - int len; - - memset(&svcaddr, 0, sizeof(svcaddr)); - if (__rpc_set_netbuf(&svcaddr, raddr, sizeof(*raddr)) == NULL) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - return(cl); - } - if (*sockp < 0) { - *sockp = socket(AF_LOCAL, SOCK_STREAM, 0); - len = SUN_LEN(raddr); - if ((*sockp < 0) || (connect(*sockp, - (struct sockaddr *)raddr, len) < 0)) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - if (*sockp != -1) - (void)close(*sockp); - goto done; - } - } - cl = clnt_vc_create(*sockp, &svcaddr, prog, - vers, sendsz, recvsz); -done: - free(svcaddr.buf); - return(cl); -} - -/* - * Creates, registers, and returns a (rpc) unix based transporter. - * Obsoleted by svc_vc_create(). - */ -SVCXPRT * -svcunix_create(sock, sendsize, recvsize, path) - int sock; - u_int sendsize; - u_int recvsize; - char *path; -{ - struct netconfig *nconf; - void *localhandle; - struct sockaddr_un sun; - struct sockaddr *sa; - struct t_bind taddr; - SVCXPRT *xprt; - int addrlen; - - xprt = (SVCXPRT *)NULL; - localhandle = setnetconfig(); - while ((nconf = getnetconfig(localhandle)) != NULL) { - if (nconf->nc_protofmly != NULL && - strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) - break; - } - if (nconf == NULL) { - endnetconfig(localhandle); - return(xprt); - } - - if ((sock = __rpc_nconf2fd(nconf)) < 0) - goto done; - - memset(&sun, 0, sizeof sun); - sun.sun_family = AF_LOCAL; - strncpy(sun.sun_path, path, (sizeof(sun.sun_path)-1)); - addrlen = sizeof(struct sockaddr_un); - sa = (struct sockaddr *)&sun; - - if (bind(sock, sa, addrlen) < 0) - goto done; - - taddr.addr.len = taddr.addr.maxlen = addrlen; - taddr.addr.buf = malloc(addrlen); - if (taddr.addr.buf == NULL) - goto done; - memcpy(taddr.addr.buf, sa, addrlen); - - if (nconf->nc_semantics != NC_TPI_CLTS) { - if (listen(sock, SOMAXCONN) < 0) { - free(taddr.addr.buf); - goto done; - } - } - - xprt = (SVCXPRT *)svc_tli_create(sock, nconf, &taddr, sendsize, recvsize); - if (xprt == NULL) - close(sock); - -done: - endnetconfig(localhandle); - return(xprt); -} - -/* - * Like svunix_create(), except the routine takes any *open* UNIX file - * descriptor as its first input. Obsoleted by svc_fd_create(); - */ -SVCXPRT * -svcunixfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - return (svc_fd_create(fd, sendsize, recvsize)); -} - -#endif /* PORTMAP */ diff --git a/libtirpc-1.3.1/src/rpcb_clnt.c b/libtirpc-1.3.1/src/rpcb_clnt.c deleted file mode 100644 index 0c34cb7..0000000 --- a/libtirpc-1.3.1/src/rpcb_clnt.c +++ /dev/null @@ -1,1291 +0,0 @@ -/* - * Copyright (c) 2010, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpcb_clnt.c - * interface to rpcbind rpc service. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef PORTMAP -#include /* FOR IPPROTO_TCP/UDP definitions */ -#include -#endif /* PORTMAP */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rpc_com.h" -#include "debug.h" - -static struct timeval tottimeout = { 60, 0 }; -static const struct timeval rmttimeout = { 3, 0 }; -static struct timeval rpcbrmttime = { 15, 0 }; - -extern bool_t xdr_wrapstring(XDR *, char **); - -static const char nullstring[] = "\000"; - -#define RPCB_OWNER_STRING "libtirpc" - -#define CACHESIZE 6 - -struct address_cache { - char *ac_host; - char *ac_netid; - char *ac_uaddr; - struct netbuf *ac_taddr; - struct address_cache *ac_next; -}; - -static struct address_cache *front; -static int cachesize; - -#define CLCR_GET_RPCB_TIMEOUT 1 -#define CLCR_SET_RPCB_TIMEOUT 2 - - -extern int __rpc_lowvers; - -static struct address_cache *check_cache(const char *, const char *); -static void delete_cache(struct netbuf *); -static void add_cache(const char *, const char *, struct netbuf *, char *); -static CLIENT *getclnthandle(const char *, const struct netconfig *, char **); -static CLIENT *local_rpcb(void); -#ifdef NOTUSED -static struct netbuf *got_entry(rpcb_entry_list_ptr, const struct netconfig *); -#endif - -/* - * This routine adjusts the timeout used for calls to the remote rpcbind. - * Also, this routine can be used to set the use of portmapper version 2 - * only when doing rpc_broadcasts - * These are private routines that may not be provided in future releases. - */ -bool_t -__rpc_control(request, info) - int request; - void *info; -{ - switch (request) { - case CLCR_GET_RPCB_TIMEOUT: - *(struct timeval *)info = tottimeout; - break; - case CLCR_SET_RPCB_TIMEOUT: - tottimeout = *(struct timeval *)info; - break; - case CLCR_SET_LOWVERS: - __rpc_lowvers = *(int *)info; - break; - case CLCR_GET_LOWVERS: - *(int *)info = __rpc_lowvers; - break; - default: - return (FALSE); - } - return (TRUE); -} - -/* - * It might seem that a reader/writer lock would be more reasonable here. - * However because getclnthandle(), the only user of the cache functions, - * may do a delete_cache() operation if a check_cache() fails to return an - * address useful to clnt_tli_create(), we may as well use a mutex. - */ -/* - * As it turns out, if the cache lock is *not* a reader/writer lock, we will - * block all clnt_create's if we are trying to connect to a host that's down, - * since the lock will be held all during that time. - */ -extern rwlock_t rpcbaddr_cache_lock; - -/* - * The routines check_cache(), add_cache(), delete_cache() manage the - * cache of rpcbind addresses for (host, netid). - */ - -static struct address_cache * -check_cache(host, netid) - const char *host, *netid; -{ - struct address_cache *cptr; - - /* READ LOCK HELD ON ENTRY: rpcbaddr_cache_lock */ - - for (cptr = front; cptr != NULL; cptr = cptr->ac_next) { - if (!strcmp(cptr->ac_host, host) && - !strcmp(cptr->ac_netid, netid)) { - LIBTIRPC_DEBUG(3, ("check_cache: Found cache entry for %s: %s\n", - host, netid)); - return (cptr); - } - } - return ((struct address_cache *) NULL); -} - -static void -delete_cache(addr) - struct netbuf *addr; -{ - struct address_cache *cptr, *prevptr = NULL; - - /* WRITE LOCK HELD ON ENTRY: rpcbaddr_cache_lock */ - for (cptr = front; cptr != NULL; cptr = cptr->ac_next) { - if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) { - free(cptr->ac_host); - free(cptr->ac_netid); - free(cptr->ac_taddr->buf); - free(cptr->ac_taddr); - if (cptr->ac_uaddr) - free(cptr->ac_uaddr); - if (prevptr) - prevptr->ac_next = cptr->ac_next; - else - front = cptr->ac_next; - free(cptr); - cachesize--; - break; - } - prevptr = cptr; - } -} - -static void -add_cache(host, netid, taddr, uaddr) - const char *host, *netid; - char *uaddr; - struct netbuf *taddr; -{ - struct address_cache *ad_cache, *cptr, *prevptr; - - ad_cache = (struct address_cache *) - malloc(sizeof (struct address_cache)); - if (!ad_cache) { - return; - } - ad_cache->ac_host = strdup(host); - ad_cache->ac_netid = strdup(netid); - ad_cache->ac_uaddr = uaddr ? strdup(uaddr) : NULL; - ad_cache->ac_taddr = (struct netbuf *)malloc(sizeof (struct netbuf)); - if (!ad_cache->ac_host || !ad_cache->ac_netid || !ad_cache->ac_taddr || - (uaddr && !ad_cache->ac_uaddr)) - goto out_free; - ad_cache->ac_taddr->len = ad_cache->ac_taddr->maxlen = taddr->len; - ad_cache->ac_taddr->buf = (char *) malloc(taddr->len); - if (ad_cache->ac_taddr->buf == NULL) - goto out_free; - memcpy(ad_cache->ac_taddr->buf, taddr->buf, taddr->len); - LIBTIRPC_DEBUG(3, ("add_cache: Added to cache: %s : %s\n", host, netid)); - -/* VARIABLES PROTECTED BY rpcbaddr_cache_lock: cptr */ - - rwlock_wrlock(&rpcbaddr_cache_lock); - if (cachesize < CACHESIZE) { - ad_cache->ac_next = front; - front = ad_cache; - cachesize++; - } else { - /* Free the last entry */ - cptr = front; - prevptr = NULL; - while (cptr->ac_next) { - prevptr = cptr; - cptr = cptr->ac_next; - } - - LIBTIRPC_DEBUG(3, ("add_cache: Deleted from cache: %s : %s\n", - cptr->ac_host, cptr->ac_netid)); - free(cptr->ac_host); - free(cptr->ac_netid); - free(cptr->ac_taddr->buf); - free(cptr->ac_taddr); - if (cptr->ac_uaddr) - free(cptr->ac_uaddr); - - if (prevptr) { - prevptr->ac_next = NULL; - ad_cache->ac_next = front; - front = ad_cache; - } else { - front = ad_cache; - ad_cache->ac_next = NULL; - } - free(cptr); - } - rwlock_unlock(&rpcbaddr_cache_lock); - return; - -out_free: - free(ad_cache->ac_host); - free(ad_cache->ac_netid); - free(ad_cache->ac_uaddr); - free(ad_cache->ac_taddr); - free(ad_cache); -} - -/* - * This routine will return a client handle that is connected to the - * rpcbind. If targaddr is non-NULL, the "universal address" of the - * host will be stored in *targaddr; the caller is responsible for - * freeing this string. - * On error, returns NULL and free's everything. - */ -static CLIENT * -getclnthandle(host, nconf, targaddr) - const char *host; - const struct netconfig *nconf; - char **targaddr; -{ - CLIENT *client; - struct netbuf *addr, taddr; - struct netbuf addr_to_delete; - struct __rpc_sockinfo si; - struct addrinfo hints, *res, *tres; - struct address_cache *ad_cache; - char *tmpaddr; - - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; - } - - if (nconf->nc_protofmly != NULL && - strcmp(nconf->nc_protofmly, NC_LOOPBACK) != 0 && - host == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; - return NULL; - } - -/* VARIABLES PROTECTED BY rpcbaddr_cache_lock: ad_cache */ - - /* Get the address of the rpcbind. Check cache first */ - client = NULL; - if (targaddr) - *targaddr = NULL; - addr_to_delete.len = 0; - rwlock_rdlock(&rpcbaddr_cache_lock); - ad_cache = NULL; - - if (host != NULL) - ad_cache = check_cache(host, nconf->nc_netid); - if (ad_cache != NULL) { - addr = ad_cache->ac_taddr; - client = clnt_tli_create(RPC_ANYFD, nconf, addr, - (rpcprog_t)RPCBPROG, (rpcvers_t)RPCBVERS4, 0, 0); - if (client != NULL) { - if (targaddr && ad_cache->ac_uaddr) - *targaddr = strdup(ad_cache->ac_uaddr); - rwlock_unlock(&rpcbaddr_cache_lock); - return (client); - } - addr_to_delete.len = addr->len; - addr_to_delete.buf = (char *)malloc(addr->len); - if (addr_to_delete.buf == NULL) { - addr_to_delete.len = 0; - } else { - memcpy(addr_to_delete.buf, addr->buf, addr->len); - } - } - rwlock_unlock(&rpcbaddr_cache_lock); - if (addr_to_delete.len != 0) { - /* - * Assume this may be due to cache data being - * outdated - */ - rwlock_wrlock(&rpcbaddr_cache_lock); - delete_cache(&addr_to_delete); - rwlock_unlock(&rpcbaddr_cache_lock); - free(addr_to_delete.buf); - } - if (!__rpc_nconf2sockinfo(nconf, &si)) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - assert(client == NULL); - goto out_err; - } - - memset(&hints, 0, sizeof hints); - hints.ai_family = si.si_af; - hints.ai_socktype = si.si_socktype; - hints.ai_protocol = si.si_proto; - - LIBTIRPC_DEBUG(3, ("getclnthandle: trying netid %s family %d proto %d socktype %d\n", - nconf->nc_netid, si.si_af, si.si_proto, si.si_socktype)); - - if (nconf->nc_protofmly != NULL && strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) { - client = local_rpcb(); - if (! client) { - LIBTIRPC_DEBUG(1, ("getclnthandle: %s", - clnt_spcreateerror("local_rpcb failed"))); - goto out_err; - } else { - struct sockaddr_un sun; - - if (targaddr) { - *targaddr = malloc(sizeof(sun.sun_path)); - strncpy(*targaddr, _PATH_RPCBINDSOCK, - sizeof(sun.sun_path)); - } - return (client); - } - } else { - if (getaddrinfo(host, "sunrpc", &hints, &res) != 0) { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; - assert(client == NULL); - goto out_err; - } - } - - for (tres = res; tres != NULL; tres = tres->ai_next) { - taddr.buf = tres->ai_addr; - taddr.len = taddr.maxlen = tres->ai_addrlen; - - if (libtirpc_debug_level > 3 && log_stderr) { - char *ua; - int i; - - ua = taddr2uaddr(nconf, &taddr); - fprintf(stderr, "Got it [%s]\n", ua); - free(ua); - - fprintf(stderr, "\tnetbuf len = %d, maxlen = %d\n", - taddr.len, taddr.maxlen); - fprintf(stderr, "\tAddress is "); - for (i = 0; i < taddr.len; i++) - fprintf(stderr, "%u.", ((char *)(taddr.buf))[i]); - fprintf(stderr, "\n"); - } - - client = clnt_tli_create(RPC_ANYFD, nconf, &taddr, - (rpcprog_t)RPCBPROG, (rpcvers_t)RPCBVERS4, 0, 0); - if (! client) { - LIBTIRPC_DEBUG(1, ("getclnthandle: %s", - clnt_spcreateerror("clnt_tli_create failed"))); - } - - if (client) { - tmpaddr = targaddr ? taddr2uaddr(nconf, &taddr) : NULL; - if (host) - add_cache(host, nconf->nc_netid, &taddr, tmpaddr); - if (targaddr) - *targaddr = tmpaddr; - break; - } - } - if (res) - freeaddrinfo(res); -out_err: - if (!client && targaddr) - free(*targaddr); - return (client); -} - -/* - * Create a PMAP client handle. - */ -static CLIENT * -getpmaphandle(nconf, hostname, tgtaddr) - const struct netconfig *nconf; - const char *hostname; - char **tgtaddr; -{ - CLIENT *client = NULL; - rpcvers_t pmapvers = 2; - - /* - * Try UDP only - there are some portmappers out - * there that use UDP only. - */ - if (nconf == NULL || strcmp(nconf->nc_proto, NC_TCP) == 0) { - struct netconfig *newnconf; - - if ((newnconf = getnetconfigent("udp")) == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; - } - client = getclnthandle(hostname, newnconf, tgtaddr); - freenetconfigent(newnconf); - } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) { - if (strcmp(nconf->nc_protofmly, NC_INET) != 0) - return NULL; - client = getclnthandle(hostname, nconf, tgtaddr); - } - - /* Set version */ - if (client != NULL) - CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers); - - return client; -} - -/* XXX */ -#define IN4_LOCALHOST_STRING "127.0.0.1" -#define IN6_LOCALHOST_STRING "::1" - -/* - * This routine will return a client handle that is connected to the local - * rpcbind. Returns NULL on error and free's everything. - */ -static CLIENT * -local_rpcb() -{ - CLIENT *client; - static struct netconfig *loopnconf; - static char *hostname; - extern mutex_t loopnconf_lock; - int sock; - size_t tsize; - struct netbuf nbuf; - struct sockaddr_un sun; - - /* - * Try connecting to the local rpcbind through a local socket - * first. If this doesn't work, try all transports defined in - * the netconfig file. - */ - memset(&sun, 0, sizeof sun); - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sock < 0) - goto try_nconf; - sun.sun_family = AF_LOCAL; - strcpy(sun.sun_path, _PATH_RPCBINDSOCK); - nbuf.len = SUN_LEN(&sun); - nbuf.maxlen = sizeof (struct sockaddr_un); - nbuf.buf = &sun; - - tsize = __rpc_get_t_size(AF_LOCAL, 0, 0); - client = clnt_vc_create(sock, &nbuf, (rpcprog_t)RPCBPROG, - (rpcvers_t)RPCBVERS, tsize, tsize); - - if (client != NULL) { - /* Mark the socket to be closed in destructor */ - (void) CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL); - return client; - } - - /* Nobody needs this socket anymore; free the descriptor. */ - close(sock); - -try_nconf: - -/* VARIABLES PROTECTED BY loopnconf_lock: loopnconf */ - mutex_lock(&loopnconf_lock); - if (loopnconf == NULL) { - struct netconfig *nconf, *tmpnconf = NULL; - void *nc_handle; - int fd; - - nc_handle = setnetconfig(); - if (nc_handle == NULL) { - /* fails to open netconfig file */ - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - mutex_unlock(&loopnconf_lock); - return (NULL); - } - while ((nconf = getnetconfig(nc_handle)) != NULL) { -#ifdef INET6 - if ((strcmp(nconf->nc_protofmly, NC_INET6) == 0 || -#else - if (( -#endif - strcmp(nconf->nc_protofmly, NC_INET) == 0) && - (nconf->nc_semantics == NC_TPI_COTS || - nconf->nc_semantics == NC_TPI_COTS_ORD)) { - fd = __rpc_nconf2fd(nconf); - /* - * Can't create a socket, assume that - * this family isn't configured in the kernel. - */ - if (fd < 0) - continue; - close(fd); - tmpnconf = nconf; - if (!strcmp(nconf->nc_protofmly, NC_INET)) - hostname = IN4_LOCALHOST_STRING; - else - hostname = IN6_LOCALHOST_STRING; - } - } - if (tmpnconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - mutex_unlock(&loopnconf_lock); - endnetconfig(nc_handle); - return (NULL); - } - loopnconf = getnetconfigent(tmpnconf->nc_netid); - /* loopnconf is never freed */ - endnetconfig(nc_handle); - } - mutex_unlock(&loopnconf_lock); - client = getclnthandle(hostname, loopnconf, NULL); - return (client); -} - -/* - * Set a mapping between program, version and address. - * Calls the rpcbind service to do the mapping. - */ -bool_t -rpcb_set(program, version, nconf, address) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; /* Network structure of transport */ - const struct netbuf *address; /* Services netconfig address */ -{ - CLIENT *client; - bool_t rslt = FALSE; - RPCB parms; - char uidbuf[32]; - - /* parameter checking */ - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (FALSE); - } - if (address == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return (FALSE); - } - client = local_rpcb(); - if (! client) { - return (FALSE); - } - - /* convert to universal */ - /*LINTED const castaway*/ - parms.r_addr = taddr2uaddr((struct netconfig *) nconf, - (struct netbuf *)address); - if (!parms.r_addr) { - CLNT_DESTROY(client); - rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; - return (FALSE); /* no universal address */ - } - parms.r_prog = program; - parms.r_vers = version; - parms.r_netid = nconf->nc_netid; - /* - * Though uid is not being used directly, we still send it for - * completeness. For non-unix platforms, perhaps some other - * string or an empty string can be sent. - */ - (void) snprintf(uidbuf, sizeof uidbuf, "%d", geteuid()); - parms.r_owner = uidbuf; - - CLNT_CALL(client, (rpcproc_t)RPCBPROC_SET, (xdrproc_t) xdr_rpcb, - (char *)&parms, (xdrproc_t) xdr_bool, - (char *)&rslt, tottimeout); - - CLNT_DESTROY(client); - free(parms.r_addr); - return (rslt); -} - -/* - * Remove the mapping between program, version and netbuf address. - * Calls the rpcbind service to do the un-mapping. - * If netbuf is NULL, unset for all the transports, otherwise unset - * only for the given transport. - */ -bool_t -rpcb_unset(program, version, nconf) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; -{ - CLIENT *client; - bool_t rslt = FALSE; - RPCB parms; - char uidbuf[32]; - - client = local_rpcb(); - if (! client) { - return (FALSE); - } - - parms.r_prog = program; - parms.r_vers = version; - if (nconf) - parms.r_netid = nconf->nc_netid; - else { - /*LINTED const castaway*/ - parms.r_netid = (char *) &nullstring[0]; /* unsets all */ - } - /*LINTED const castaway*/ - parms.r_addr = (char *) &nullstring[0]; - (void) snprintf(uidbuf, sizeof uidbuf, "%d", geteuid()); - parms.r_owner = uidbuf; - - CLNT_CALL(client, (rpcproc_t)RPCBPROC_UNSET, (xdrproc_t) xdr_rpcb, - (char *)(void *)&parms, (xdrproc_t) xdr_bool, - (char *)(void *)&rslt, tottimeout); - - CLNT_DESTROY(client); - return (rslt); -} - -#ifdef NOTUSED -/* - * From the merged list, find the appropriate entry - */ -static struct netbuf * -got_entry(relp, nconf) - rpcb_entry_list_ptr relp; - const struct netconfig *nconf; -{ - struct netbuf *na = NULL; - rpcb_entry_list_ptr sp; - rpcb_entry *rmap; - - for (sp = relp; sp != NULL; sp = sp->rpcb_entry_next) { - rmap = &sp->rpcb_entry_map; - if ((strcmp(nconf->nc_proto, rmap->r_nc_proto) == 0) && - (strcmp(nconf->nc_protofmly, rmap->r_nc_protofmly) == 0) && - (nconf->nc_semantics == rmap->r_nc_semantics) && - (rmap->r_maddr != NULL) && (rmap->r_maddr[0] != 0)) { - na = uaddr2taddr(nconf, rmap->r_maddr); - LIBTIRPC_DEBUG(3, ("got_entry: Remote address is [%s] %s", - rmap->r_maddr, (na ? "Resolvable" : "Not Resolvable"))); - break; - } - } - return (na); -} - -/* - * Quick check to see if rpcbind is up. Tries to connect over - * local transport. - */ -bool_t -__rpcbind_is_up() -{ - struct netconfig *nconf; - struct sockaddr_un sun; - void *localhandle; - int sock; - - nconf = NULL; - localhandle = setnetconfig(); - while ((nconf = getnetconfig(localhandle)) != NULL) { - if (nconf->nc_protofmly != NULL && - strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) - break; - } - if (nconf == NULL) - return (FALSE); - - endnetconfig(localhandle); - - memset(&sun, 0, sizeof sun); - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sock < 0) - return (FALSE); - sun.sun_family = AF_LOCAL; - strncpy(sun.sun_path, _PATH_RPCBINDSOCK, sizeof(sun.sun_path)); - - if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) < 0) { - close(sock); - return (FALSE); - } - - close(sock); - return (TRUE); -} -#endif - -#ifdef PORTMAP -static struct netbuf * -__try_protocol_version_2(program, version, nconf, host, tp) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; - const char *host; - struct timeval *tp; -{ - u_short port = 0; - struct netbuf remote; - struct pmap pmapparms; - CLIENT *client = NULL; - enum clnt_stat clnt_st; - struct netbuf *pmapaddress; - RPCB parms; - - if (strcmp(nconf->nc_proto, NC_UDP) != 0 - && strcmp(nconf->nc_proto, NC_TCP) != 0) - return (NULL); - - client = getpmaphandle(nconf, host, &parms.r_addr); - if (client == NULL) - goto error; - - /* - * Set retry timeout. - */ - CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime); - - pmapparms.pm_prog = program; - pmapparms.pm_vers = version; - pmapparms.pm_prot = strcmp(nconf->nc_proto, NC_TCP) ? - IPPROTO_UDP : IPPROTO_TCP; - pmapparms.pm_port = 0; /* not needed */ - clnt_st = CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT, - (xdrproc_t) xdr_pmap, (caddr_t)(void *)&pmapparms, - (xdrproc_t) xdr_u_short, (caddr_t)(void *)&port, - *tp); - if (clnt_st != RPC_SUCCESS) { - rpc_createerr.cf_stat = RPC_PMAPFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - goto error; - } else if (port == 0) { - pmapaddress = NULL; - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - goto error; - } - port = htons(port); - CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote); - if (((pmapaddress = (struct netbuf *) - malloc(sizeof (struct netbuf))) == NULL) || - ((pmapaddress->buf = (char *) - malloc(remote.len)) == NULL)) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - clnt_geterr(client, &rpc_createerr.cf_error); - if (pmapaddress) { - free(pmapaddress); - pmapaddress = NULL; - } - goto error; - } - memcpy(pmapaddress->buf, remote.buf, remote.len); - memcpy(&((char *)pmapaddress->buf)[sizeof (short)], - (char *)(void *)&port, sizeof (short)); - pmapaddress->len = pmapaddress->maxlen = remote.len; - - CLNT_DESTROY(client); - return pmapaddress; - -error: - if (client) { - CLNT_DESTROY(client); - client = NULL; - - } - return (NULL); - -} -#endif - -/* - * An internal function which optimizes rpcb_getaddr function. It also - * returns the client handle that it uses to contact the remote rpcbind. - * - * The algorithm used: If the transports is TCP or UDP, it first tries - * version 4 (srv4), then 3 and then fall back to version 2 (portmap). - * With this algorithm, we get performance as well as a plan for - * obsoleting version 2. - * - * For all other transports, the algorithm remains as 4 and then 3. - * - * XXX: Due to some problems with t_connect(), we do not reuse the same client - * handle for COTS cases and hence in these cases we do not return the - * client handle. This code will change if t_connect() ever - * starts working properly. Also look under clnt_vc.c. - */ -struct netbuf * -__rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; - const char *host; - CLIENT **clpp; - struct timeval *tp; -{ -#ifdef NOTUSED - static bool_t check_rpcbind = TRUE; -#endif - CLIENT *client = NULL; - RPCB parms; - enum clnt_stat clnt_st; - char *ua = NULL; - rpcvers_t vers; - struct netbuf *address = NULL; - rpcvers_t start_vers = RPCBVERS4; - struct netbuf servaddr; - struct rpc_err rpcerr; - - /* parameter checking */ - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - - parms.r_addr = NULL; - - /* - * Use default total timeout if no timeout is specified. - */ - if (tp == NULL) - tp = &tottimeout; - - parms.r_prog = program; - parms.r_vers = version; - parms.r_netid = nconf->nc_netid; - - /* - * rpcbind ignores the r_owner field in GETADDR requests, but we - * need to give xdr_rpcb something to gnaw on. Might as well make - * it something human readable for when we see these in captures. - */ - parms.r_owner = RPCB_OWNER_STRING; - - /* Now the same transport is to be used to get the address */ - if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) || - (nconf->nc_semantics == NC_TPI_COTS))) { - /* A CLTS type of client - destroy it */ - CLNT_DESTROY(client); - client = NULL; - free(parms.r_addr); - parms.r_addr = NULL; - } - - if (client == NULL) { - client = getclnthandle(host, nconf, &parms.r_addr); - if (client == NULL) { - goto error; - } - } - if (parms.r_addr == NULL) { - /*LINTED const castaway*/ - parms.r_addr = (char *) &nullstring[0]; - } - - /* First try from start_vers(4) and then version 3 (RPCBVERS) */ - - CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *) &rpcbrmttime); - for (vers = start_vers; vers >= RPCBVERS; vers--) { - /* Set the version */ - CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers); - clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR, - (xdrproc_t) xdr_rpcb, (char *)(void *)&parms, - (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp); - switch (clnt_st) { - case RPC_SUCCESS: - if ((ua == NULL) || (ua[0] == 0)) { - /* address unknown */ - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - goto error; - } - address = uaddr2taddr(nconf, ua); - LIBTIRPC_DEBUG(3, ("__rpcb_findaddr_timed: Remote address is [%s] %s", - ua, (address ? "Resolvable" : "Not Resolvable"))); - - xdr_free((xdrproc_t)xdr_wrapstring, - (char *)(void *)&ua); - - if (! address) { - /* We don't know about your universal address */ - rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; - goto error; - } - CLNT_CONTROL(client, CLGET_SVC_ADDR, - (char *)(void *)&servaddr); - __rpc_fixup_addr(address, &servaddr); - goto done; - case RPC_PROGVERSMISMATCH: - clnt_geterr(client, &rpcerr); - if (rpcerr.re_vers.low > RPCBVERS4) - goto error; /* a new version, can't handle */ - /* Try the next lower version */ - case RPC_PROGUNAVAIL: - case RPC_CANTDECODEARGS: - break; - default: - /* Cant handle this error */ - rpc_createerr.cf_stat = clnt_st; - clnt_geterr(client, &rpc_createerr.cf_error); - goto error; - } - } - -#ifdef PORTMAP /* Try version 2 for TCP or UDP */ - if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { - address = __try_protocol_version_2(program, version, nconf, host, tp); - if (address == NULL) - goto error; - } -#endif /* PORTMAP */ - - if ((address == NULL) || (address->len == 0)) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - clnt_geterr(client, &rpc_createerr.cf_error); - } - -error: - if (client) { - CLNT_DESTROY(client); - client = NULL; - } -done: - if (nconf->nc_semantics != NC_TPI_CLTS) { - /* This client is the connectionless one */ - if (client) { - CLNT_DESTROY(client); - client = NULL; - } - } - if (clpp) { - *clpp = client; - } else if (client) { - CLNT_DESTROY(client); - } - if (parms.r_addr != NULL && parms.r_addr != nullstring) - free(parms.r_addr); - return (address); -} - - -/* - * Find the mapped address for program, version. - * Calls the rpcbind service remotely to do the lookup. - * Uses the transport specified in nconf. - * Returns FALSE (0) if no map exists, else returns 1. - * - * Assuming that the address is all properly allocated - */ -int -rpcb_getaddr(program, version, nconf, address, host) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; - struct netbuf *address; - const char *host; -{ - struct netbuf *na; - - if ((na = __rpcb_findaddr_timed(program, version, - (struct netconfig *) nconf, (char *) host, - (CLIENT **) NULL, (struct timeval *) NULL)) == NULL) - return (FALSE); - - if (na->len > address->maxlen) { - /* Too long address */ - free(na->buf); - free(na); - rpc_createerr.cf_stat = RPC_FAILED; - return (FALSE); - } - memcpy(address->buf, na->buf, (size_t)na->len); - address->len = na->len; - free(na->buf); - free(na); - return (TRUE); -} - -/* - * Get a copy of the current maps. - * Calls the rpcbind service remotely to get the maps. - * - * It returns only a list of the services - * It returns NULL on failure. - */ -rpcblist * -rpcb_getmaps(nconf, host) - const struct netconfig *nconf; - const char *host; -{ - rpcblist_ptr head = NULL; - CLIENT *client; - enum clnt_stat clnt_st; - rpcvers_t vers = 0; - - client = getclnthandle(host, nconf, NULL); - if (client == NULL) { - return (head); - } - clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_DUMP, - (xdrproc_t) xdr_void, NULL, (xdrproc_t) xdr_rpcblist_ptr, - (char *)(void *)&head, tottimeout); - if (clnt_st == RPC_SUCCESS) - goto done; - - if ((clnt_st != RPC_PROGVERSMISMATCH) && - (clnt_st != RPC_PROGUNAVAIL)) { - rpc_createerr.cf_stat = RPC_RPCBFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - goto done; - } - - /* fall back to earlier version */ - CLNT_CONTROL(client, CLGET_VERS, (char *)(void *)&vers); - if (vers == RPCBVERS4) { - vers = RPCBVERS; - CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers); - if (CLNT_CALL(client, (rpcproc_t)RPCBPROC_DUMP, - (xdrproc_t) xdr_void, NULL, (xdrproc_t) xdr_rpcblist_ptr, - (char *)(void *)&head, tottimeout) == RPC_SUCCESS) - goto done; - } - rpc_createerr.cf_stat = RPC_RPCBFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - -done: - CLNT_DESTROY(client); - return (head); -} - -/* - * rpcbinder remote-call-service interface. - * This routine is used to call the rpcbind remote call service - * which will look up a service program in the address maps, and then - * remotely call that routine with the given parameters. This allows - * programs to do a lookup and call in one step. -*/ -enum clnt_stat -rpcb_rmtcall(nconf, host, prog, vers, proc, xdrargs, argsp, - xdrres, resp, tout, addr_ptr) - const struct netconfig *nconf; /* Netconfig structure */ - const char *host; /* Remote host name */ - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; /* Remote proc identifiers */ - xdrproc_t xdrargs, xdrres; /* XDR routines */ - caddr_t argsp, resp; /* Argument and Result */ - struct timeval tout; /* Timeout value for this call */ - const struct netbuf *addr_ptr; /* Preallocated netbuf address */ -{ - CLIENT *client; - enum clnt_stat stat; - struct r_rpcb_rmtcallargs a; - struct r_rpcb_rmtcallres r; - rpcvers_t rpcb_vers; - - stat = 0; - client = getclnthandle(host, nconf, NULL); - if (client == NULL) { - return (RPC_FAILED); - } - /*LINTED const castaway*/ - CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)(void *)&rmttimeout); - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.args.args_val = argsp; - a.xdr_args = xdrargs; - r.addr = NULL; - r.results.results_val = resp; - r.xdr_res = xdrres; - - for (rpcb_vers = RPCBVERS4; rpcb_vers >= RPCBVERS; rpcb_vers--) { - CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&rpcb_vers); - stat = CLNT_CALL(client, (rpcproc_t)RPCBPROC_CALLIT, - (xdrproc_t) xdr_rpcb_rmtcallargs, (char *)(void *)&a, - (xdrproc_t) xdr_rpcb_rmtcallres, (char *)(void *)&r, tout); - if ((stat == RPC_SUCCESS) && (addr_ptr != NULL)) { - struct netbuf *na; - /*LINTED const castaway*/ - na = uaddr2taddr((struct netconfig *) nconf, r.addr); - if (!na) { - stat = RPC_N2AXLATEFAILURE; - /*LINTED const castaway*/ - ((struct netbuf *) addr_ptr)->len = 0; - goto error; - } - if (na->len > addr_ptr->maxlen) { - /* Too long address */ - stat = RPC_FAILED; /* XXX A better error no */ - free(na->buf); - free(na); - /*LINTED const castaway*/ - ((struct netbuf *) addr_ptr)->len = 0; - goto error; - } - memcpy(addr_ptr->buf, na->buf, (size_t)na->len); - /*LINTED const castaway*/ - ((struct netbuf *)addr_ptr)->len = na->len; - free(na->buf); - free(na); - break; - } else if ((stat != RPC_PROGVERSMISMATCH) && - (stat != RPC_PROGUNAVAIL)) { - goto error; - } - } -error: - CLNT_DESTROY(client); - if (r.addr) - xdr_free((xdrproc_t) xdr_wrapstring, (char *)(void *)&r.addr); - return (stat); -} - -/* - * Gets the time on the remote host. - * Returns 1 if succeeds else 0. - */ -bool_t -rpcb_gettime(host, timep) - const char *host; - time_t *timep; -{ - CLIENT *client = NULL; - void *handle; - struct netconfig *nconf; - rpcvers_t vers; - enum clnt_stat st; - - if ((host == NULL) || (host[0] == 0)) { - time(timep); - return (TRUE); - } - - if ((handle = __rpc_setconf("netpath")) == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (FALSE); - } - rpc_createerr.cf_stat = RPC_SUCCESS; - while (client == NULL) { - if ((nconf = __rpc_getconf(handle)) == NULL) { - if (rpc_createerr.cf_stat == RPC_SUCCESS) - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - break; - } - client = getclnthandle(host, nconf, NULL); - if (client) - break; - } - __rpc_endconf(handle); - if (client == (CLIENT *) NULL) { - return (FALSE); - } - - st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETTIME, - (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_int, (char *)(void *)timep, tottimeout); - - if ((st == RPC_PROGVERSMISMATCH) || (st == RPC_PROGUNAVAIL)) { - CLNT_CONTROL(client, CLGET_VERS, (char *)(void *)&vers); - if (vers == RPCBVERS4) { - /* fall back to earlier version */ - vers = RPCBVERS; - CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers); - st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETTIME, - (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_int, (char *)(void *)timep, - tottimeout); - } - } - CLNT_DESTROY(client); - return (st == RPC_SUCCESS? TRUE: FALSE); -} - -/* - * Converts taddr to universal address. This routine should never - * really be called because local n2a libraries are always provided. - */ -char * -rpcb_taddr2uaddr(nconf, taddr) - struct netconfig *nconf; - struct netbuf *taddr; -{ - CLIENT *client; - char *uaddr = NULL; - - - /* parameter checking */ - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - if (taddr == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return (NULL); - } - client = local_rpcb(); - if (! client) { - return (NULL); - } - - CLNT_CALL(client, (rpcproc_t)RPCBPROC_TADDR2UADDR, - (xdrproc_t) xdr_netbuf, (char *)(void *)taddr, - (xdrproc_t) xdr_wrapstring, (char *)(void *)&uaddr, tottimeout); - CLNT_DESTROY(client); - return (uaddr); -} - -/* - * Converts universal address to netbuf. This routine should never - * really be called because local n2a libraries are always provided. - */ -struct netbuf * -rpcb_uaddr2taddr(nconf, uaddr) - struct netconfig *nconf; - char *uaddr; -{ - CLIENT *client; - struct netbuf *taddr; - - - /* parameter checking */ - if (nconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return (NULL); - } - if (uaddr == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return (NULL); - } - client = local_rpcb(); - if (! client) { - return (NULL); - } - - taddr = (struct netbuf *)calloc(1, sizeof (struct netbuf)); - if (taddr == NULL) { - CLNT_DESTROY(client); - return (NULL); - } - if (CLNT_CALL(client, (rpcproc_t)RPCBPROC_UADDR2TADDR, - (xdrproc_t) xdr_wrapstring, (char *)(void *)&uaddr, - (xdrproc_t) xdr_netbuf, (char *)(void *)taddr, - tottimeout) != RPC_SUCCESS) { - free(taddr); - taddr = NULL; - } - CLNT_DESTROY(client); - return (taddr); -} diff --git a/libtirpc-1.3.1/src/rpcb_prot.c b/libtirpc-1.3.1/src/rpcb_prot.c deleted file mode 100644 index a923c8e..0000000 --- a/libtirpc-1.3.1/src/rpcb_prot.c +++ /dev/null @@ -1,324 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * rpcb_prot.c - * XDR routines for the rpcbinder version 3. - * - * Copyright (C) 1984, 1988, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include "rpc_com.h" - -bool_t -xdr_rpcb(xdrs, objp) - XDR *xdrs; - RPCB *objp; -{ - if (!xdr_u_int32_t(xdrs, &objp->r_prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->r_vers)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_addr, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_owner, RPC_MAXDATASIZE)) { - return (FALSE); - } - return (TRUE); -} - -/* - * rpcblist_ptr implements a linked list. The RPCL definition from - * rpcb_prot.x is: - * - * struct rpcblist { - * rpcb rpcb_map; - * struct rpcblist *rpcb_next; - * }; - * typedef rpcblist *rpcblist_ptr; - * - * Recall that "pointers" in XDR are encoded as a boolean, indicating whether - * there's any data behind the pointer, followed by the data (if any exists). - * The boolean can be interpreted as ``more data follows me''; if FALSE then - * nothing follows the boolean; if TRUE then the boolean is followed by an - * actual struct rpcb, and another rpcblist_ptr (declared in RPCL as "struct - * rpcblist *"). - * - * This could be implemented via the xdr_pointer type, though this would - * result in one recursive call per element in the list. Rather than do that - * we can ``unwind'' the recursion into a while loop and use xdr_reference to - * serialize the rpcb elements. - */ - -bool_t -xdr_rpcblist_ptr(xdrs, rp) - XDR *xdrs; - rpcblist_ptr *rp; -{ - /* - * more_elements is pre-computed in case the direction is - * XDR_ENCODE or XDR_FREE. more_elements is overwritten by - * xdr_bool when the direction is XDR_DECODE. - */ - bool_t more_elements; - int freeing = (xdrs->x_op == XDR_FREE); - rpcblist_ptr next; - rpcblist_ptr next_copy; - - next = NULL; - for (;;) { - more_elements = (bool_t)(*rp != NULL); - if (! xdr_bool(xdrs, &more_elements)) { - return (FALSE); - } - if (! more_elements) { - return (TRUE); /* we are done */ - } - /* - * the unfortunate side effect of non-recursion is that in - * the case of freeing we must remember the next object - * before we free the current object ... - */ - if (freeing) - next = (*rp)->rpcb_next; - if (! xdr_reference(xdrs, (caddr_t *)rp, - (u_int)sizeof (rpcblist), (xdrproc_t)xdr_rpcb)) { - return (FALSE); - } - if (freeing) { - next_copy = next; - rp = &next_copy; - /* - * Note that in the subsequent iteration, next_copy - * gets nulled out by the xdr_reference - * but next itself survives. - */ - } else { - rp = &((*rp)->rpcb_next); - } - } - /*NOTREACHED*/ -} - -/* - * xdr_rpcblist() is specified to take a RPCBLIST **, but is identical in - * functionality to xdr_rpcblist_ptr(). - */ -bool_t -xdr_rpcblist(xdrs, rp) - XDR *xdrs; - RPCBLIST **rp; -{ - bool_t dummy; - - dummy = xdr_rpcblist_ptr(xdrs, (rpcblist_ptr *)rp); - return (dummy); -} - - -bool_t -xdr_rpcb_entry(xdrs, objp) - XDR *xdrs; - rpcb_entry *objp; -{ - if (!xdr_string(xdrs, &objp->r_maddr, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_nc_netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->r_nc_semantics)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_nc_protofmly, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->r_nc_proto, RPC_MAXDATASIZE)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_rpcb_entry_list_ptr(xdrs, rp) - XDR *xdrs; - rpcb_entry_list_ptr *rp; -{ - /* - * more_elements is pre-computed in case the direction is - * XDR_ENCODE or XDR_FREE. more_elements is overwritten by - * xdr_bool when the direction is XDR_DECODE. - */ - bool_t more_elements; - int freeing = (xdrs->x_op == XDR_FREE); - rpcb_entry_list_ptr next; - rpcb_entry_list_ptr next_copy; - - next = NULL; - for (;;) { - more_elements = (bool_t)(*rp != NULL); - if (! xdr_bool(xdrs, &more_elements)) { - return (FALSE); - } - if (! more_elements) { - return (TRUE); /* we are done */ - } - /* - * the unfortunate side effect of non-recursion is that in - * the case of freeing we must remember the next object - * before we free the current object ... - */ - if (freeing) - next = (*rp)->rpcb_entry_next; - if (! xdr_reference(xdrs, (caddr_t *)rp, - (u_int)sizeof (rpcb_entry_list), - (xdrproc_t)xdr_rpcb_entry)) { - return (FALSE); - } - if (freeing) { - next_copy = next; - rp = &next_copy; - /* - * Note that in the subsequent iteration, next_copy - * gets nulled out by the xdr_reference - * but next itself survives. - */ - } else { - rp = &((*rp)->rpcb_entry_next); - } - } - /*NOTREACHED*/ -} - -/* - * XDR remote call arguments - * written for XDR_ENCODE direction only - */ -bool_t -xdr_rpcb_rmtcallargs(xdrs, p) - XDR *xdrs; - struct rpcb_rmtcallargs *p; -{ - struct r_rpcb_rmtcallargs *objp = - (struct r_rpcb_rmtcallargs *)(void *)p; - u_int lenposition, argposition, position; - int32_t *buf; - - buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int32_t(xdrs, &objp->prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->vers)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->proc)) { - return (FALSE); - } - } else { - IXDR_PUT_U_INT32(buf, objp->prog); - IXDR_PUT_U_INT32(buf, objp->vers); - IXDR_PUT_U_INT32(buf, objp->proc); - } - - /* - * All the jugglery for just getting the size of the arguments - */ - lenposition = XDR_GETPOS(xdrs); - if (! xdr_u_int(xdrs, &(objp->args.args_len))) { - return (FALSE); - } - argposition = XDR_GETPOS(xdrs); - if (! (*objp->xdr_args)(xdrs, objp->args.args_val)) { - return (FALSE); - } - position = XDR_GETPOS(xdrs); - objp->args.args_len = (u_int)((u_long)position - (u_long)argposition); - XDR_SETPOS(xdrs, lenposition); - if (! xdr_u_int(xdrs, &(objp->args.args_len))) { - return (FALSE); - } - XDR_SETPOS(xdrs, position); - return (TRUE); -} - -/* - * XDR remote call results - * written for XDR_DECODE direction only - */ -bool_t -xdr_rpcb_rmtcallres(xdrs, p) - XDR *xdrs; - struct rpcb_rmtcallres *p; -{ - bool_t dummy; - struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p; - - if (!xdr_string(xdrs, &objp->addr, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->results.results_len)) { - return (FALSE); - } - dummy = (*(objp->xdr_res))(xdrs, objp->results.results_val); - return (dummy); -} - -bool_t -xdr_netbuf(xdrs, objp) - XDR *xdrs; - struct netbuf *objp; -{ - bool_t dummy; - - if (!xdr_u_int32_t(xdrs, (u_int32_t *) &objp->maxlen)) { - return (FALSE); - } - - if (objp->maxlen > RPC_MAXDATASIZE) { - return (FALSE); - } - - dummy = xdr_bytes(xdrs, (char **)&(objp->buf), - (u_int *)&(objp->len), objp->maxlen); - return (dummy); -} diff --git a/libtirpc-1.3.1/src/rpcb_st_xdr.c b/libtirpc-1.3.1/src/rpcb_st_xdr.c deleted file mode 100644 index 28e6a48..0000000 --- a/libtirpc-1.3.1/src/rpcb_st_xdr.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright 1991 Sun Microsystems, Inc. - * rpcb_stat_xdr.c - */ - -/* - * This file was generated from rpcb_prot.x, but includes only those - * routines used with the rpcbind stats facility. - */ - - -#include -#include "rpc_com.h" - -/* Link list of all the stats about getport and getaddr */ - -bool_t -xdr_rpcbs_addrlist(xdrs, objp) - XDR *xdrs; - rpcbs_addrlist *objp; -{ - - if (!xdr_u_int32_t(xdrs, &objp->prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->vers)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - - if (!xdr_pointer(xdrs, (char **)&objp->next, - sizeof (rpcbs_addrlist), - (xdrproc_t)xdr_rpcbs_addrlist)) { - return (FALSE); - } - - return (TRUE); -} - -/* Link list of all the stats about rmtcall */ - -bool_t -xdr_rpcbs_rmtcalllist(xdrs, objp) - XDR *xdrs; - rpcbs_rmtcalllist *objp; -{ - int32_t *buf; - - if (xdrs->x_op == XDR_ENCODE) { - buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int32_t(xdrs, &objp->prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->vers)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->proc)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->indirect)) { - return (FALSE); - } - } else { - IXDR_PUT_U_INT32(buf, objp->prog); - IXDR_PUT_U_INT32(buf, objp->vers); - IXDR_PUT_U_INT32(buf, objp->proc); - IXDR_PUT_INT32(buf, objp->success); - IXDR_PUT_INT32(buf, objp->failure); - IXDR_PUT_INT32(buf, objp->indirect); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->next, - sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); - } else if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int32_t(xdrs, &objp->prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->vers)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->proc)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->indirect)) { - return (FALSE); - } - } else { - objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf); - objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf); - objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf); - objp->success = (int)IXDR_GET_INT32(buf); - objp->failure = (int)IXDR_GET_INT32(buf); - objp->indirect = (int)IXDR_GET_INT32(buf); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->next, - sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); - } - if (!xdr_u_int32_t(xdrs, &objp->prog)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->vers)) { - return (FALSE); - } - if (!xdr_u_int32_t(xdrs, &objp->proc)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->indirect)) { - return (FALSE); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->next, - sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_rpcbs_proc(xdrs, objp) - XDR *xdrs; - rpcbs_proc objp; -{ - if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC, - sizeof (int), (xdrproc_t)xdr_int)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_rpcbs_addrlist_ptr(xdrs, objp) - XDR *xdrs; - rpcbs_addrlist_ptr *objp; -{ - if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist), - (xdrproc_t)xdr_rpcbs_addrlist)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_rpcbs_rmtcalllist_ptr(xdrs, objp) - XDR *xdrs; - rpcbs_rmtcalllist_ptr *objp; -{ - if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_rpcb_stat(xdrs, objp) - XDR *xdrs; - rpcb_stat *objp; -{ - - if (!xdr_rpcbs_proc(xdrs, objp->info)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->setinfo)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->unsetinfo)) { - return (FALSE); - } - if (!xdr_rpcbs_addrlist_ptr(xdrs, &objp->addrinfo)) { - return (FALSE); - } - if (!xdr_rpcbs_rmtcalllist_ptr(xdrs, &objp->rmtinfo)) { - return (FALSE); - } - return (TRUE); -} - -/* - * One rpcb_stat structure is returned for each version of rpcbind - * being monitored. - */ -bool_t -xdr_rpcb_stat_byvers(xdrs, objp) - XDR *xdrs; - rpcb_stat_byvers objp; -{ - if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT, - sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) { - return (FALSE); - } - return (TRUE); -} diff --git a/libtirpc-1.3.1/src/rpcdname.c b/libtirpc-1.3.1/src/rpcdname.c deleted file mode 100644 index 3e6a988..0000000 --- a/libtirpc-1.3.1/src/rpcdname.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpcdname.c - * Gets the default domain name - */ - -#include -#include -#include - -static char *default_domain = 0; - -static char * -get_default_domain() -{ - char temp[256]; - - if (default_domain) - return (default_domain); - if (getdomainname(temp, sizeof(temp)) < 0) - return (0); - if ((int) strlen(temp) > 0) { - default_domain = (char *)malloc((strlen(temp)+(unsigned)1)); - if (default_domain == 0) - return (0); - (void) strcpy(default_domain, temp); - return (default_domain); - } - return (0); -} - -/* - * This is a wrapper for the system call getdomainname which returns a - * ypclnt.h error code in the failure case. It also checks to see that - * the domain name is non-null, knowing that the null string is going to - * get rejected elsewhere in the NIS client package. - */ -int -__rpc_get_default_domain(domain) - char **domain; -{ - if ((*domain = get_default_domain()) != 0) - return (0); - return (-1); -} diff --git a/libtirpc-1.3.1/src/rtime.c b/libtirpc-1.3.1/src/rtime.c deleted file mode 100644 index 29fbf0a..0000000 --- a/libtirpc-1.3.1/src/rtime.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - - */ - -/* - * rtime - get time from remote machine - * - * gets time, obtaining value from host - * on the udp/time socket. Since timeserver returns - * with time of day in seconds since Jan 1, 1900, must - * subtract seconds before Jan 1, 1970 to get - * what unix uses. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern int _rpc_dtablesize( void ); - -#define NYEARS (unsigned long)(1970 - 1900) -#define TOFFSET (unsigned long)(60*60*24*(365*NYEARS + (NYEARS/4))) - -static void do_close( int ); - -int -rtime(addrp, timep, timeout) - struct sockaddr_in *addrp; - struct timeval *timep; - struct timeval *timeout; -{ - int s; - struct pollfd fd; - int milliseconds; - int res; - unsigned long thetime; - struct sockaddr_in from; - socklen_t fromlen; - int type; - struct servent *serv; - - if (timeout == NULL) { - type = SOCK_STREAM; - } else { - type = SOCK_DGRAM; - } - s = socket(AF_INET, type, 0); - if (s < 0) { - return(-1); - } - addrp->sin_family = AF_INET; - - /* TCP and UDP port are the same in this case */ - if ((serv = getservbyname("time", "tcp")) == NULL) { - do_close(s); - return(-1); - } - - addrp->sin_port = serv->s_port; - - if (type == SOCK_DGRAM) { - res = sendto(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)addrp, sizeof(*addrp)); - if (res < 0) { - do_close(s); - return(-1); - } - - milliseconds = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); - fd.fd = s; - fd.events = POLLIN; - do - res = poll (&fd, 1, milliseconds); - while (res < 0 && errno == EINTR); - if (res <= 0) { - if (res == 0) { - errno = ETIMEDOUT; - } - do_close(s); - return(-1); - } - fromlen = sizeof(from); - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)&from, &fromlen); - do_close(s); - if (res < 0) { - return(-1); - } - } else { - if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) { - do_close(s); - return(-1); - } - res = read(s, (char *)&thetime, sizeof(thetime)); - do_close(s); - if (res < 0) { - return(-1); - } - } - if (res != sizeof(thetime)) { - errno = EIO; - return(-1); - } - thetime = ntohl(thetime); - timep->tv_sec = thetime - TOFFSET; - timep->tv_usec = 0; - return(0); -} - -static void -do_close(s) - int s; -{ - int save; - - save = errno; - (void)close(s); - errno = save; -} diff --git a/libtirpc-1.3.1/src/svc.c b/libtirpc-1.3.1/src/svc.c deleted file mode 100644 index 6db164b..0000000 --- a/libtirpc-1.3.1/src/svc.c +++ /dev/null @@ -1,806 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * svc.c, Server-side remote procedure call interface. - * - * There are two sets of procedures here. The xprt routines are - * for handling transport handles. The svc routines handle the - * list of service routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#ifdef PORTMAP -#include -#endif /* PORTMAP */ - -#include "rpc_com.h" - -#define RQCRED_SIZE 400 /* this size is excessive */ - -#define max(a, b) (a > b ? a : b) - -static SVCXPRT **__svc_xports; -int __svc_maxrec; - -/* - * The services list - * Each entry represents a set of procedures (an rpc program). - * The dispatch routine takes request structs and runs the - * apropriate procedure. - */ -static struct svc_callout -{ - struct svc_callout *sc_next; - rpcprog_t sc_prog; - rpcvers_t sc_vers; - char *sc_netid; - void (*sc_dispatch) (struct svc_req *, SVCXPRT *); -} *svc_head; - -extern rwlock_t svc_lock; -extern rwlock_t svc_fd_lock; - -static struct svc_callout *svc_find (rpcprog_t, rpcvers_t, - struct svc_callout **, char *); -static void __xprt_do_unregister (SVCXPRT * xprt, bool_t dolock); - -/* *************** SVCXPRT related stuff **************** */ - -/* - * Activate a transport handle. - */ -void -xprt_register (xprt) - SVCXPRT *xprt; -{ - int sock; - - assert (xprt != NULL); - - sock = xprt->xp_fd; - - rwlock_wrlock (&svc_fd_lock); - if (__svc_xports == NULL) - { - __svc_xports = (SVCXPRT **) calloc (_rpc_dtablesize(), sizeof (SVCXPRT *)); - if (__svc_xports == NULL) - goto unlock; - } - if (sock < _rpc_dtablesize()) - { - int i; - struct pollfd *new_svc_pollfd; - - __svc_xports[sock] = xprt; - if (sock < FD_SETSIZE) - { - FD_SET (sock, &svc_fdset); - svc_maxfd = max (svc_maxfd, sock); - } - - /* Check if we have an empty slot */ - for (i = 0; i < svc_max_pollfd; ++i) - if (svc_pollfd[i].fd == -1) - { - svc_pollfd[i].fd = sock; - svc_pollfd[i].events = (POLLIN | POLLPRI | - POLLRDNORM | POLLRDBAND); - goto unlock; - } - - new_svc_pollfd = (struct pollfd *) realloc (svc_pollfd, - sizeof (struct pollfd) - * (svc_max_pollfd + 1)); - if (new_svc_pollfd == NULL) /* Out of memory */ - goto unlock; - svc_pollfd = new_svc_pollfd; - ++svc_max_pollfd; - - svc_pollfd[svc_max_pollfd - 1].fd = sock; - svc_pollfd[svc_max_pollfd - 1].events = (POLLIN | POLLPRI | - POLLRDNORM | POLLRDBAND); - } -unlock: - rwlock_unlock (&svc_fd_lock); -} - -void -xprt_unregister (SVCXPRT * xprt) -{ - __xprt_do_unregister (xprt, TRUE); -} - -void -__xprt_unregister_unlocked (SVCXPRT * xprt) -{ - __xprt_do_unregister (xprt, FALSE); -} - -/* - * De-activate a transport handle. - */ -static void -__xprt_do_unregister (xprt, dolock) - SVCXPRT *xprt; - bool_t dolock; -{ - int sock; - - assert (xprt != NULL); - - sock = xprt->xp_fd; - - if (dolock) - rwlock_wrlock (&svc_fd_lock); - if ((sock < _rpc_dtablesize() ) && (__svc_xports[sock] == xprt)) - { - int i; - - __svc_xports[sock] = NULL; - if (sock < FD_SETSIZE) - { - FD_CLR (sock, &svc_fdset); - if (sock >= svc_maxfd) - { - for (svc_maxfd--; svc_maxfd >= 0; svc_maxfd--) - if (__svc_xports[svc_maxfd]) - break; - } - } - - for (i = 0; i < svc_max_pollfd; ++i) - if (svc_pollfd[i].fd == sock) - svc_pollfd[i].fd = -1; - } - if (dolock) - rwlock_unlock (&svc_fd_lock); -} - -/* - * Add a service program to the callout list. - * The dispatch routine will be called when a rpc request for this - * program number comes in. - */ -bool_t -svc_reg (xprt, prog, vers, dispatch, nconf) - SVCXPRT *xprt; - const rpcprog_t prog; - const rpcvers_t vers; - void (*dispatch) (struct svc_req *, SVCXPRT *); - const struct netconfig *nconf; -{ - bool_t dummy; - struct svc_callout *prev; - struct svc_callout *s; - struct netconfig *tnconf; - char *netid = NULL; - int flag = 0; - -/* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */ - if (xprt->xp_netid) - { - netid = strdup (xprt->xp_netid); - flag = 1; - } - else if (nconf && nconf->nc_netid) - { - netid = strdup (nconf->nc_netid); - flag = 1; - } - else if ((tnconf = __rpcgettp (xprt->xp_fd)) != NULL) - { - netid = strdup (tnconf->nc_netid); - flag = 1; - freenetconfigent (tnconf); - } /* must have been created with svc_raw_create */ - if ((netid == NULL) && (flag == 1)) - { - return (FALSE); - } - - rwlock_wrlock (&svc_lock); - if ((s = svc_find (prog, vers, &prev, netid)) != NULL) - { - if (netid) - free (netid); - if (s->sc_dispatch == dispatch) - goto rpcb_it; /* he is registering another xptr */ - rwlock_unlock (&svc_lock); - return (FALSE); - } - s = mem_alloc (sizeof (struct svc_callout)); - if (s == NULL) - { - if (netid) - free (netid); - rwlock_unlock (&svc_lock); - return (FALSE); - } - - s->sc_prog = prog; - s->sc_vers = vers; - s->sc_dispatch = dispatch; - s->sc_netid = netid; - s->sc_next = svc_head; - svc_head = s; - - if ((xprt->xp_netid == NULL) && (flag == 1) && netid) - ((SVCXPRT *) xprt)->xp_netid = strdup (netid); - -rpcb_it: - rwlock_unlock (&svc_lock); - /* now register the information with the local binder service */ - if (nconf) - { - /*LINTED const castaway */ - dummy = rpcb_set (prog, vers, (struct netconfig *) nconf, - &((SVCXPRT *) xprt)->xp_ltaddr); - return (dummy); - } - return (TRUE); -} - -/* - * Remove a service program from the callout list. - */ -void -svc_unreg (prog, vers) - const rpcprog_t prog; - const rpcvers_t vers; -{ - struct svc_callout *prev; - struct svc_callout *s; - - /* unregister the information anyway */ - (void) rpcb_unset (prog, vers, NULL); - rwlock_wrlock (&svc_lock); - while ((s = svc_find (prog, vers, &prev, NULL)) != NULL) - { - if (prev == NULL) - { - svc_head = s->sc_next; - } - else - { - prev->sc_next = s->sc_next; - } - s->sc_next = NULL; - if (s->sc_netid) - mem_free (s->sc_netid, sizeof (s->sc_netid) + 1); - mem_free (s, sizeof (struct svc_callout)); - } - rwlock_unlock (&svc_lock); -} - -/* ********************** CALLOUT list related stuff ************* */ - -#ifdef PORTMAP -/* - * Add a service program to the callout list. - * The dispatch routine will be called when a rpc request for this - * program number comes in. - */ -bool_t -svc_register (xprt, prog, vers, dispatch, protocol) - SVCXPRT *xprt; - u_long prog; - u_long vers; - void (*dispatch) (struct svc_req *, SVCXPRT *); - int protocol; -{ - struct svc_callout *prev; - struct svc_callout *s; - - assert (xprt != NULL); - assert (dispatch != NULL); - - if ((s = svc_find ((rpcprog_t) prog, (rpcvers_t) vers, &prev, NULL)) != - NULL) - { - if (s->sc_dispatch == dispatch) - goto pmap_it; /* he is registering another xptr */ - return (FALSE); - } - s = mem_alloc (sizeof (struct svc_callout)); - if (s == NULL) - { - return (FALSE); - } - s->sc_prog = (rpcprog_t) prog; - s->sc_vers = (rpcvers_t) vers; - s->sc_dispatch = dispatch; - s->sc_next = svc_head; - svc_head = s; -pmap_it: - /* now register the information with the local binder service */ - if (protocol) - { - return (pmap_set (prog, vers, protocol, xprt->xp_port)); - } - return (TRUE); -} - -/* - * Remove a service program from the callout list. - */ -void -svc_unregister (prog, vers) - u_long prog; - u_long vers; -{ - struct svc_callout *prev; - struct svc_callout *s; - - if ((s = svc_find ((rpcprog_t) prog, (rpcvers_t) vers, &prev, NULL)) == - NULL) - return; - if (prev == NULL) - { - svc_head = s->sc_next; - } - else - { - prev->sc_next = s->sc_next; - } - s->sc_next = NULL; - mem_free (s, sizeof (struct svc_callout)); - /* now unregister the information with the local binder service */ - (void) pmap_unset (prog, vers); -} -#endif /* PORTMAP */ - -/* - * Search the callout list for a program number, return the callout - * struct. - */ -static struct svc_callout * -svc_find (prog, vers, prev, netid) - rpcprog_t prog; - rpcvers_t vers; - struct svc_callout **prev; - char *netid; -{ - struct svc_callout *s, *p; - - assert (prev != NULL); - - p = NULL; - for (s = svc_head; s != NULL; s = s->sc_next) - { - if (((s->sc_prog == prog) && (s->sc_vers == vers)) && - ((netid == NULL) || (s->sc_netid == NULL) || - (strcmp (netid, s->sc_netid) == 0))) - break; - p = s; - } - *prev = p; - return (s); -} - -/* ******************* REPLY GENERATION ROUTINES ************ */ - -/* - * Send a reply to an rpc request - */ -bool_t -svc_sendreply (xprt, xdr_results, xdr_location) - SVCXPRT *xprt; - xdrproc_t xdr_results; - void *xdr_location; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SUCCESS; - rply.acpted_rply.ar_results.where = xdr_location; - rply.acpted_rply.ar_results.proc = xdr_results; - return (SVC_REPLY (xprt, &rply)); -} - -/* - * No procedure error reply - */ -void -svcerr_noproc (xprt) - SVCXPRT *xprt; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROC_UNAVAIL; - SVC_REPLY (xprt, &rply); -} - -/* - * Can't decode args error reply - */ -void -svcerr_decode (xprt) - SVCXPRT *xprt; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = GARBAGE_ARGS; - SVC_REPLY (xprt, &rply); -} - -/* - * Some system error - */ -void -svcerr_systemerr (xprt) - SVCXPRT *xprt; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SYSTEM_ERR; - SVC_REPLY (xprt, &rply); -} - -#if 0 -/* - * Tell RPC package to not complain about version errors to the client. This - * is useful when revving broadcast protocols that sit on a fixed address. - * There is really one (or should be only one) example of this kind of - * protocol: the portmapper (or rpc binder). - */ -void -__svc_versquiet_on (xprt) - SVCXPRT *xprt; -{ - svc_flags (xprt) |= SVC_VERSQUIET; -} - -void -__svc_versquiet_off (xprt) - SVCXPRT *xprt; -{ - svc_flags (xprt) &= ~SVC_VERSQUIET; -} - -void -svc_versquiet (xprt) - SVCXPRT *xprt; -{ - __svc_versquiet_on (xprt); -} - -int -__svc_versquiet_get (xprt) - SVCXPRT *xprt; -{ - return version_keepquiet (xprt); -} -#endif - -/* - * Authentication error reply - */ -void -svcerr_auth (xprt, why) - SVCXPRT *xprt; - enum auth_stat why; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_DENIED; - rply.rjcted_rply.rj_stat = AUTH_ERROR; - rply.rjcted_rply.rj_why = why; - SVC_REPLY (xprt, &rply); -} - -/* - * Auth too weak error reply - */ -void -svcerr_weakauth (xprt) - SVCXPRT *xprt; -{ - - assert (xprt != NULL); - - svcerr_auth (xprt, AUTH_TOOWEAK); -} - -/* - * Program unavailable error reply - */ -void -svcerr_noprog (xprt) - SVCXPRT *xprt; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_UNAVAIL; - SVC_REPLY (xprt, &rply); -} - -/* - * Program version mismatch error reply - */ -void -svcerr_progvers (xprt, low_vers, high_vers) - SVCXPRT *xprt; - rpcvers_t low_vers; - rpcvers_t high_vers; -{ - struct rpc_msg rply; - - assert (xprt != NULL); - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_MISMATCH; - rply.acpted_rply.ar_vers.low = (u_int32_t) low_vers; - rply.acpted_rply.ar_vers.high = (u_int32_t) high_vers; - SVC_REPLY (xprt, &rply); -} - -/* ******************* SERVER INPUT STUFF ******************* */ - -/* - * Get server side input from some transport. - * - * Statement of authentication parameters management: - * This function owns and manages all authentication parameters, specifically - * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and - * the "cooked" credentials (rqst->rq_clntcred). - * However, this function does not know the structure of the cooked - * credentials, so it make the following assumptions: - * a) the structure is contiguous (no pointers), and - * b) the cred structure size does not exceed RQCRED_SIZE bytes. - * In all events, all three parameters are freed upon exit from this routine. - * The storage is trivially management on the call stack in user land, but - * is mallocated in kernel land. - */ - -void -svc_getreq (rdfds) - int rdfds; -{ - fd_set readfds; - - FD_ZERO (&readfds); - readfds.fds_bits[0] = rdfds; - svc_getreqset (&readfds); -} - -void -svc_getreqset (readfds) - fd_set *readfds; -{ - int bit, fd; - fd_mask mask, *maskp; - int sock; - int setsize; - - assert (readfds != NULL); - - setsize = _rpc_dtablesize (); - if (setsize > FD_SETSIZE) - setsize = FD_SETSIZE; - maskp = readfds->fds_bits; - for (sock = 0; sock < setsize; sock += NFDBITS) - { - for (mask = *maskp++; (bit = ffsl(mask)) != 0; mask ^= (1L << (bit - 1))) - { - /* sock has input waiting */ - fd = sock + bit - 1; - svc_getreq_common (fd); - } - } -} - -void -svc_getreq_common (fd) - int fd; -{ - SVCXPRT *xprt; - struct svc_req r; - struct rpc_msg msg; - int prog_found; - rpcvers_t low_vers; - rpcvers_t high_vers; - enum xprt_stat stat; - char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE]; - - msg.rm_call.cb_cred.oa_base = cred_area; - msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); - r.rq_clntcred = &(cred_area[2 * MAX_AUTH_BYTES]); - - rwlock_rdlock (&svc_fd_lock); - xprt = __svc_xports[fd]; - rwlock_unlock (&svc_fd_lock); - if (xprt == NULL) - /* But do we control sock? */ - return; - /* now receive msgs from xprtprt (support batch calls) */ - do - { - if (SVC_RECV (xprt, &msg)) - { - bool_t no_dispatch; - - /* now find the exported program and call it */ - struct svc_callout *s; - enum auth_stat why; - - r.rq_xprt = xprt; - r.rq_prog = msg.rm_call.cb_prog; - r.rq_vers = msg.rm_call.cb_vers; - r.rq_proc = msg.rm_call.cb_proc; - r.rq_cred = msg.rm_call.cb_cred; - /* first authenticate the message */ - why = _gss_authenticate(&r, &msg, &no_dispatch); - if (why != AUTH_OK) - { - svcerr_auth (xprt, why); - goto call_done; - } - if (no_dispatch) - goto call_done; - /* now match message with a registered service */ - prog_found = FALSE; - low_vers = (rpcvers_t) - 1L; - high_vers = (rpcvers_t) 0L; - for (s = svc_head; s != NULL; s = s->sc_next) - { - if (s->sc_prog == r.rq_prog) - { - if (s->sc_vers == r.rq_vers) - { - (*s->sc_dispatch) (&r, xprt); - goto call_done; - } /* found correct version */ - prog_found = TRUE; - if (s->sc_vers < low_vers) - low_vers = s->sc_vers; - if (s->sc_vers > high_vers) - high_vers = s->sc_vers; - } /* found correct program */ - } - /* - * if we got here, the program or version - * is not served ... - */ - if (prog_found) - svcerr_progvers (xprt, low_vers, high_vers); - else - svcerr_noprog (xprt); - /* Fall through to ... */ - } - /* - * Check if the xprt has been disconnected in a - * recursive call in the service dispatch routine. - * If so, then break. - */ - rwlock_rdlock (&svc_fd_lock); - - if (xprt != __svc_xports[fd]) - { - rwlock_unlock (&svc_fd_lock); - break; - } - rwlock_unlock (&svc_fd_lock); - call_done: - if ((stat = SVC_STAT (xprt)) == XPRT_DIED) - { - SVC_DESTROY (xprt); - break; - } - } - while (stat == XPRT_MOREREQS); -} - - -void -svc_getreq_poll (pfdp, pollretval) - struct pollfd *pfdp; - int pollretval; -{ - int fds_found, i; - - for (i = fds_found = 0; i < svc_max_pollfd; ++i) - { - struct pollfd *p = &pfdp[i]; - - if (p->fd != -1 && p->revents) - { - /* fd has input waiting */ - if (p->revents & POLLNVAL) - xprt_unregister (__svc_xports[p->fd]); - else - svc_getreq_common (p->fd); - - if (++fds_found >= pollretval) - break; - } - } -} - -bool_t -rpc_control (int what, void *arg) -{ - int val; - - switch (what) - { - case RPC_SVC_CONNMAXREC_SET: - val = *(int *) arg; - if (val <= 0) - return FALSE; - __svc_maxrec = val; - return TRUE; - case RPC_SVC_CONNMAXREC_GET: - *(int *) arg = __svc_maxrec; - return TRUE; - default: - break; - } - return FALSE; -} diff --git a/libtirpc-1.3.1/src/svc_auth.c b/libtirpc-1.3.1/src/svc_auth.c deleted file mode 100644 index ce8bbd8..0000000 --- a/libtirpc-1.3.1/src/svc_auth.c +++ /dev/null @@ -1,216 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * svc_auth.c, Server-side rpc authenticator interface. - * - */ -#include -#include -#include -#include -#include -#include - -/* - * svcauthsw is the bdevsw of server side authentication. - * - * Server side authenticators are called from authenticate by - * using the client auth struct flavor field to index into svcauthsw. - * The server auth flavors must implement a routine that looks - * like: - * - * enum auth_stat - * flavorx_auth(rqst, msg) - * struct svc_req *rqst; - * struct rpc_msg *msg; - * - */ - -/* declarations to allow servers to specify new authentication flavors */ -struct authsvc { - int flavor; - enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *); - struct authsvc *next; -}; -static struct authsvc *Auths = NULL; - -extern SVCAUTH svc_auth_none; - -/* - * The call rpc message, msg has been obtained from the wire. The msg contains - * the raw form of credentials and verifiers. authenticate returns AUTH_OK - * if the msg is successfully authenticated. If AUTH_OK then the routine also - * does the following things: - * set rqst->rq_xprt->verf to the appropriate response verifier; - * sets rqst->rq_client_cred to the "cooked" form of the credentials. - * - * NB: rqst->rq_cxprt->verf must be pre-alloctaed; - * its length is set appropriately. - * - * The caller still owns and is responsible for msg->u.cmb.cred and - * msg->u.cmb.verf. The authentication system retains ownership of - * rqst->rq_client_cred, the cooked credentials. - * - * There is an assumption that any flavour less than AUTH_NULL is - * invalid. - */ -enum auth_stat -_gss_authenticate(rqst, msg, no_dispatch) - struct svc_req *rqst; - struct rpc_msg *msg; - bool_t *no_dispatch; -{ - int cred_flavor; - struct authsvc *asp; - enum auth_stat dummy; - extern mutex_t authsvc_lock; - -/* VARIABLES PROTECTED BY authsvc_lock: asp, Auths */ - - rqst->rq_cred = msg->rm_call.cb_cred; - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_ops = svc_auth_none.svc_ah_ops; - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_private = NULL; - rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; - rqst->rq_xprt->xp_verf.oa_length = 0; - cred_flavor = rqst->rq_cred.oa_flavor; - *no_dispatch = FALSE; - switch (cred_flavor) { - case AUTH_NONE: - dummy = _svcauth_none(rqst, msg); - return (dummy); - case AUTH_SYS: - dummy = _svcauth_unix(rqst, msg); - return (dummy); - case AUTH_SHORT: - dummy = _svcauth_short(rqst, msg); - return (dummy); - case AUTH_DES: -#ifdef AUTHDES_SUPPORT - dummy = _svcauth_des(rqst, msg); - return (dummy); -#else - return (AUTH_FAILED); -#endif -#ifdef HAVE_RPCSEC_GSS - case RPCSEC_GSS: - dummy = _svcauth_gss(rqst, msg, no_dispatch); - return (dummy); -#endif - default: - break; - } - - /* flavor doesn't match any of the builtin types, so try new ones */ - mutex_lock(&authsvc_lock); - for (asp = Auths; asp; asp = asp->next) { - if (asp->flavor == cred_flavor) { - enum auth_stat as; - - as = (*asp->handler)(rqst, msg); - mutex_unlock(&authsvc_lock); - return (as); - } - } - mutex_unlock(&authsvc_lock); - - return (AUTH_REJECTEDCRED); -} - -enum auth_stat -_authenticate(struct svc_req *rqst, struct rpc_msg *msg) -{ - bool_t no_dispatch; - return _gss_authenticate(rqst, msg, &no_dispatch); -} - -/* - * Allow the rpc service to register new authentication types that it is - * prepared to handle. When an authentication flavor is registered, - * the flavor is checked against already registered values. If not - * registered, then a new Auths entry is added on the list. - * - * There is no provision to delete a registration once registered. - * - * This routine returns: - * 0 if registration successful - * 1 if flavor already registered - * -1 if can't register (errno set) - */ - -int -svc_auth_reg(cred_flavor, handler) - int cred_flavor; - enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *); -{ - struct authsvc *asp; - extern mutex_t authsvc_lock; - - switch (cred_flavor) { - case AUTH_NULL: - case AUTH_SYS: - case AUTH_SHORT: - case AUTH_DES: -#ifndef AUTHDES_SUPPORT - return(-1); -#endif -#ifdef HAVE_RPCSEC_GSS - case RPCSEC_GSS: -#endif - /* already registered */ - return (1); - - default: - mutex_lock(&authsvc_lock); - for (asp = Auths; asp; asp = asp->next) { - if (asp->flavor == cred_flavor) { - /* already registered */ - mutex_unlock(&authsvc_lock); - return (1); - } - } - - /* this is a new one, so go ahead and register it */ - asp = mem_alloc(sizeof (*asp)); - if (asp == NULL) { - mutex_unlock(&authsvc_lock); - return (-1); - } - asp->flavor = cred_flavor; - asp->handler = handler; - asp->next = Auths; - Auths = asp; - mutex_unlock(&authsvc_lock); - break; - } - return (0); -} diff --git a/libtirpc-1.3.1/src/svc_auth_des.c b/libtirpc-1.3.1/src/svc_auth_des.c deleted file mode 100644 index b096e08..0000000 --- a/libtirpc-1.3.1/src/svc_auth_des.c +++ /dev/null @@ -1,529 +0,0 @@ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * svcauth_des.c, server-side des authentication - * - * We insure for the service the following: - * (1) The timestamp microseconds do not exceed 1 million. - * (2) The timestamp plus the window is less than the current time. - * (3) The timestamp is not less than the one previously - * seen in the current session. - * - * It is up to the server to determine if the window size is - * too small . - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__FreeBSD__) || defined(__NetBSD__) -#include -#endif - -#include "debug.h" - -extern int key_decryptsession_pk(const char *, netobj *, des_block *); - -#define USEC_PER_SEC ((u_long) 1000000L) -#define BEFORE(t1, t2) timercmp(t1, t2, <) - -/* - * LRU cache of conversation keys and some other useful items. - */ -#define AUTHDES_CACHESZ 64 -struct cache_entry { - des_block key; /* conversation key */ - char *rname; /* client's name */ - u_int window; /* credential lifetime window */ - struct timeval laststamp; /* detect replays of creds */ - char *localcred; /* generic local credential */ -}; -static struct cache_entry *authdes_cache/* [AUTHDES_CACHESZ] */; -static short *authdes_lru/* [AUTHDES_CACHESZ] */; - -static void cache_init(); /* initialize the cache */ -static short cache_spot(des_block *key, char *name, struct timeval *timestamp); /* find an entry in the cache */ -static void cache_ref(short sid); /* note that sid was ref'd */ - -static void invalidate(char *cred); /* invalidate entry in cache */ - -/* - * cache statistics - */ -static struct { - u_long ncachehits; /* times cache hit, and is not replay */ - u_long ncachereplays; /* times cache hit, and is replay */ - u_long ncachemisses; /* times cache missed */ -} svcauthdes_stats; - -/* - * Service side authenticator for AUTH_DES - */ -enum auth_stat -_svcauth_des(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; -{ - - long *ixdr; - des_block cryptbuf[2]; - struct authdes_cred *cred; - struct authdes_verf verf; - int status; - struct cache_entry *entry; - short sid = 0; - des_block *sessionkey; - des_block ivec; - u_int window; - struct timeval timestamp; - u_long namelen; - struct area { - struct authdes_cred area_cred; - char area_netname[MAXNETNAMELEN+1]; - } *area; - - if (authdes_cache == NULL) { - cache_init(); - } - - area = (struct area *)rqst->rq_clntcred; - cred = (struct authdes_cred *)&area->area_cred; - - /* - * Get the credential - */ - ixdr = (long *)msg->rm_call.cb_cred.oa_base; - cred->adc_namekind = IXDR_GET_ENUM(ixdr, enum authdes_namekind); - switch (cred->adc_namekind) { - case ADN_FULLNAME: - namelen = IXDR_GET_U_LONG(ixdr); - if (namelen > MAXNETNAMELEN) { - return (AUTH_BADCRED); - } - cred->adc_fullname.name = area->area_netname; - memcpy(cred->adc_fullname.name, (char *)ixdr, - (u_int)namelen); - cred->adc_fullname.name[namelen] = 0; - ixdr += (RNDUP(namelen) / BYTES_PER_XDR_UNIT); - cred->adc_fullname.key.key.high = (u_long)*ixdr++; - cred->adc_fullname.key.key.low = (u_long)*ixdr++; - cred->adc_fullname.window = (u_long)*ixdr++; - break; - case ADN_NICKNAME: - cred->adc_nickname = (u_long)*ixdr++; - break; - default: - return (AUTH_BADCRED); - } - - /* - * Get the verifier - */ - ixdr = (long *)msg->rm_call.cb_verf.oa_base; - verf.adv_xtimestamp.key.high = (u_long)*ixdr++; - verf.adv_xtimestamp.key.low = (u_long)*ixdr++; - verf.adv_int_u = (u_long)*ixdr++; - - - /* - * Get the conversation key - */ - if (cred->adc_namekind == ADN_FULLNAME) { - netobj pkey; - char pkey_data[1024]; - - sessionkey = &cred->adc_fullname.key; - if (! getpublickey(cred->adc_fullname.name, pkey_data)) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: getpublickey failed")); - return(AUTH_BADCRED); - } - pkey.n_bytes = pkey_data; - pkey.n_len = strlen(pkey_data) + 1; - if (key_decryptsession_pk(cred->adc_fullname.name, &pkey, - sessionkey) < 0) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: key_decryptsessionkey failed")); - return (AUTH_BADCRED); /* key not found */ - } - } else { /* ADN_NICKNAME */ - sid = (short)cred->adc_nickname; - if (sid < 0 || sid >= AUTHDES_CACHESZ) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: bad nickname")); - return (AUTH_BADCRED); /* garbled credential */ - } - sessionkey = &authdes_cache[sid].key; - } - - - /* - * Decrypt the timestamp - */ - cryptbuf[0] = verf.adv_xtimestamp; - if (cred->adc_namekind == ADN_FULLNAME) { - cryptbuf[1].key.high = cred->adc_fullname.window; - cryptbuf[1].key.low = verf.adv_winverf; - ivec.key.high = ivec.key.low = 0; - status = cbc_crypt((char *)sessionkey, (char *)cryptbuf, - 2*sizeof(des_block), DES_DECRYPT | DES_HW, - (char *)&ivec); - } else { - status = ecb_crypt((char *)sessionkey, (char *)cryptbuf, - sizeof(des_block), DES_DECRYPT | DES_HW); - } - if (DES_FAILED(status)) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: decryption failure")); - return (AUTH_FAILED); /* system error */ - } - - /* - * XDR the decrypted timestamp - */ - ixdr = (long *)cryptbuf; - timestamp.tv_sec = IXDR_GET_LONG(ixdr); - timestamp.tv_usec = IXDR_GET_LONG(ixdr); - - /* - * Check for valid credentials and verifiers. - * They could be invalid because the key was flushed - * out of the cache, and so a new session should begin. - * Be sure and send AUTH_REJECTED{CRED, VERF} if this is the case. - */ - { - struct timeval current; - int nick; - int winverf; - - if (cred->adc_namekind == ADN_FULLNAME) { - window = IXDR_GET_U_LONG(ixdr); - winverf = IXDR_GET_U_LONG(ixdr); - if (winverf != window - 1) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: window verifier mismatch")); - return (AUTH_BADCRED); /* garbled credential */ - } - sid = cache_spot(sessionkey, cred->adc_fullname.name, - ×tamp); - if (sid < 0) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: replayed credential")); - return (AUTH_REJECTEDCRED); /* replay */ - } - nick = 0; - } else { /* ADN_NICKNAME */ - window = authdes_cache[sid].window; - nick = 1; - } - - if ((u_long)timestamp.tv_usec >= USEC_PER_SEC) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: invalid usecs")); - /* cached out (bad key), or garbled verifier */ - return (nick ? AUTH_REJECTEDVERF : AUTH_BADVERF); - } - if (nick && BEFORE(×tamp, - &authdes_cache[sid].laststamp)) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: timestamp before last seen")); - return (AUTH_REJECTEDVERF); /* replay */ - } - (void) gettimeofday(¤t, (struct timezone *)NULL); - current.tv_sec -= window; /* allow for expiration */ - if (!BEFORE(¤t, ×tamp)) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: timestamp expired")); - /* replay, or garbled credential */ - return (nick ? AUTH_REJECTEDVERF : AUTH_BADCRED); - } - } - - /* - * Set up the reply verifier - */ - verf.adv_nickname = (u_long)sid; - - /* - * xdr the timestamp before encrypting - */ - ixdr = (long *)cryptbuf; - IXDR_PUT_LONG(ixdr, timestamp.tv_sec - 1); - IXDR_PUT_LONG(ixdr, timestamp.tv_usec); - - /* - * encrypt the timestamp - */ - status = ecb_crypt((char *)sessionkey, (char *)cryptbuf, - sizeof(des_block), DES_ENCRYPT | DES_HW); - if (DES_FAILED(status)) { - LIBTIRPC_DEBUG(1, ("_svcauth_des: encryption failure")); - return (AUTH_FAILED); /* system error */ - } - verf.adv_xtimestamp = cryptbuf[0]; - - /* - * Serialize the reply verifier, and update rqst - */ - ixdr = (long *)msg->rm_call.cb_verf.oa_base; - *ixdr++ = (long)verf.adv_xtimestamp.key.high; - *ixdr++ = (long)verf.adv_xtimestamp.key.low; - *ixdr++ = (long)verf.adv_int_u; - - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_DES; - rqst->rq_xprt->xp_verf.oa_base = msg->rm_call.cb_verf.oa_base; - rqst->rq_xprt->xp_verf.oa_length = - (char *)ixdr - msg->rm_call.cb_verf.oa_base; - - /* - * We succeeded, commit the data to the cache now and - * finish cooking the credential. - */ - entry = &authdes_cache[sid]; - entry->laststamp = timestamp; - cache_ref(sid); - if (cred->adc_namekind == ADN_FULLNAME) { - cred->adc_fullname.window = window; - cred->adc_nickname = (u_long)sid; /* save nickname */ - if (entry->rname != NULL) { - mem_free(entry->rname, strlen(entry->rname) + 1); - } - entry->rname = (char *)mem_alloc((u_int)strlen(cred->adc_fullname.name) - + 1); - if (entry->rname != NULL) { - (void) strcpy(entry->rname, cred->adc_fullname.name); - } else { - LIBTIRPC_DEBUG(1, ("_svcauth_des: out of memory")); - } - entry->key = *sessionkey; - entry->window = window; - invalidate(entry->localcred); /* mark any cached cred invalid */ - } else { /* ADN_NICKNAME */ - /* - * nicknames are cooked into fullnames - */ - cred->adc_namekind = ADN_FULLNAME; - cred->adc_fullname.name = entry->rname; - cred->adc_fullname.key = entry->key; - cred->adc_fullname.window = entry->window; - } - return (AUTH_OK); /* we made it!*/ -} - - -/* - * Initialize the cache - */ -static void -cache_init() -{ - int i; - - authdes_cache = (struct cache_entry *) - mem_alloc(sizeof(struct cache_entry) * AUTHDES_CACHESZ); - memset(authdes_cache, 0, - sizeof(struct cache_entry) * AUTHDES_CACHESZ); - - authdes_lru = (short *)mem_alloc(sizeof(short) * AUTHDES_CACHESZ); - /* - * Initialize the lru list - */ - for (i = 0; i < AUTHDES_CACHESZ; i++) { - authdes_lru[i] = i; - } -} - - -/* - * Find the lru victim - */ -static short -cache_victim() -{ - return (authdes_lru[AUTHDES_CACHESZ-1]); -} - -/* - * Note that sid was referenced - */ -static void -cache_ref(sid) - short sid; -{ - int i; - short curr; - short prev; - - prev = authdes_lru[0]; - authdes_lru[0] = sid; - for (i = 1; prev != sid; i++) { - curr = authdes_lru[i]; - authdes_lru[i] = prev; - prev = curr; - } -} - - -/* - * Find a spot in the cache for a credential containing - * the items given. Return -1 if a replay is detected, otherwise - * return the spot in the cache. - */ -static short -cache_spot(key, name, timestamp) - des_block *key; - char *name; - struct timeval *timestamp; -{ - struct cache_entry *cp; - int i; - u_long hi; - - hi = key->key.high; - for (cp = authdes_cache, i = 0; i < AUTHDES_CACHESZ; i++, cp++) { - if (cp->key.key.high == hi && - cp->key.key.low == key->key.low && - cp->rname != NULL && - memcmp(cp->rname, name, strlen(name) + 1) == 0) { - if (BEFORE(timestamp, &cp->laststamp)) { - svcauthdes_stats.ncachereplays++; - return (-1); /* replay */ - } - svcauthdes_stats.ncachehits++; - return (i); /* refresh */ - } - } - svcauthdes_stats.ncachemisses++; - return (cache_victim()); /* new credential */ -} - - -/* - * Local credential handling stuff. - * NOTE: bsd unix dependent. - * Other operating systems should put something else here. - */ -#define UNKNOWN -2 /* grouplen, if cached cred is unknown user */ -#define INVALID -1 /* grouplen, if cache entry is invalid */ - -struct bsdcred { - short uid; /* cached uid */ - short gid; /* cached gid */ - short grouplen; /* length of cached groups */ - short groups[NGROUPS]; /* cached groups */ -}; - -/* - * Map a des credential into a unix cred. - * We cache the credential here so the application does - * not have to make an rpc call every time to interpret - * the credential. - */ -int -authdes_getucred(adc, uid, gid, grouplen, groups) - struct authdes_cred *adc; - uid_t *uid; - gid_t *gid; - int *grouplen; - gid_t *groups; -{ - unsigned sid; - int i; - uid_t i_uid; - gid_t i_gid; - int i_grouplen; - struct bsdcred *cred; - - sid = adc->adc_nickname; - if (sid >= AUTHDES_CACHESZ) { - LIBTIRPC_DEBUG(1, ("authdes_getucred: invalid nickname")); - return (0); - } - cred = (struct bsdcred *)authdes_cache[sid].localcred; - if (cred == NULL) { - cred = (struct bsdcred *)mem_alloc(sizeof(struct bsdcred)); - authdes_cache[sid].localcred = (char *)cred; - cred->grouplen = INVALID; - } - if (cred->grouplen == INVALID) { - /* - * not in cache: lookup - */ - if (!netname2user(adc->adc_fullname.name, &i_uid, &i_gid, - &i_grouplen, groups)) - { - LIBTIRPC_DEBUG(1, ("authdes_getucred: unknown netname")); - cred->grouplen = UNKNOWN; /* mark as lookup up, but not found */ - return (0); - } - LIBTIRPC_DEBUG(1, ("authdes_getucred: missed ucred cache")); - *uid = cred->uid = i_uid; - *gid = cred->gid = i_gid; - *grouplen = cred->grouplen = i_grouplen; - for (i = i_grouplen - 1; i >= 0; i--) { - cred->groups[i] = groups[i]; /* int to short */ - } - return (1); - } else if (cred->grouplen == UNKNOWN) { - /* - * Already lookup up, but no match found - */ - return (0); - } - - /* - * cached credentials - */ - *uid = cred->uid; - *gid = cred->gid; - *grouplen = cred->grouplen; - for (i = cred->grouplen - 1; i >= 0; i--) { - groups[i] = cred->groups[i]; /* short to int */ - } - return (1); -} - -static void -invalidate(cred) - char *cred; -{ - if (cred == NULL) { - return; - } - ((struct bsdcred *)cred)->grouplen = INVALID; -} diff --git a/libtirpc-1.3.1/src/svc_auth_gss.c b/libtirpc-1.3.1/src/svc_auth_gss.c deleted file mode 100644 index bece46a..0000000 --- a/libtirpc-1.3.1/src/svc_auth_gss.c +++ /dev/null @@ -1,1180 +0,0 @@ -/* - svc_auth_gss.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_GSSAPI_GSSAPI_EXT_H -/* MIT Kerberos */ -#include -#else -/* Heimdal Kerberos */ -#include -#endif - -#include - -#define UNUSED(x) UNUSED_ ## x __attribute__((unused)) - -extern SVCAUTH svc_auth_none; - -/* Internal only */ -bool_t rpc_gss_oid_to_mech(rpc_gss_OID, char **); -bool_t rpc_gss_num_to_qop(char *, u_int, char **); - -/* - * from mit-krb5-1.2.1 mechglue/mglueP.h: - * Array of context IDs typed by mechanism OID - */ -typedef struct gss_union_ctx_id_t { - gss_OID mech_type; - gss_ctx_id_t internal_ctx_id; -} gss_union_ctx_id_desc, *gss_union_ctx_id_t; - - - -static bool_t svcauth_gss_wrap(SVCAUTH *, XDR *, xdrproc_t, caddr_t); -static bool_t svcauth_gss_unwrap(SVCAUTH *, XDR *, xdrproc_t, caddr_t); -static bool_t svcauth_gss_destroy(SVCAUTH *); - -static struct svc_auth_ops svc_auth_gss_ops = { - svcauth_gss_wrap, - svcauth_gss_unwrap, - svcauth_gss_destroy -}; - -struct svcauth_gss_cache_entry { - SVCXPRT *xprt; - struct svc_rpc_gss_data *gd; - time_t time_to_die; - struct svcauth_gss_cache_entry *next; -}; - -extern pthread_mutex_t svcauth_gss_cache_lock; -static struct svcauth_gss_cache_entry *svcauth_gss_cache = NULL; - -struct svc_rpc_gss_callback { - struct svc_rpc_gss_callback *cb_next; - rpc_gss_callback_t cb_args; -}; - -extern pthread_mutex_t svcauth_cb_lock; -static struct svc_rpc_gss_callback *_svcauth_callbacks = NULL; - -struct svc_rpc_gss_data { - bool_t established; /* context established */ - bool_t locked; /* service/qop unchanging */ - gss_ctx_id_t ctx; /* context id */ - gss_cred_id_t deleg; /* delegated creds */ - struct rpc_gss_sec sec; /* security triple */ - gss_buffer_desc cname; /* GSS client name */ - u_int seq; /* sequence number */ - u_int win; /* sequence window */ - u_int seqlast; /* last sequence number */ - u_int32_t seqmask; /* bitmask of seqnums */ - gss_name_t client_name; /* unparsed name string */ - rpc_gss_rawcred_t rcred; /* internal raw credential */ - rpc_gss_rawcred_t scratch; /* copy exposed to user */ - rpc_gss_ucred_t ucred; /* cooked credential */ - gid_t gids[NGRPS]; /* list of groups */ - bool_t callback_done; /* TRUE after callback */ - void * cookie; /* callback cookie */ -}; - -#define SVCAUTH_PRIVATE(auth) \ - ((struct svc_rpc_gss_data *)(auth)->svc_ah_private) - -/* Global server credentials. */ -static u_int _svcauth_req_time = 0; -static gss_OID_set_desc _svcauth_oid_set = {1, GSS_C_NULL_OID }; -static gss_cred_id_t _svcauth_gss_creds; -static gss_name_t _svcauth_gss_name = GSS_C_NO_NAME; -static char * _svcauth_svc_name = NULL; - -bool_t -svcauth_gss_set_svc_name(gss_name_t name) -{ - OM_uint32 maj_stat, min_stat; - - gss_log_debug("in svcauth_gss_set_svc_name()"); - - if (_svcauth_gss_name != GSS_C_NO_NAME) { - maj_stat = gss_release_name(&min_stat, &_svcauth_gss_name); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_set_svc_name: gss_release_name", - maj_stat, min_stat); - return (FALSE); - } - _svcauth_gss_name = GSS_C_NO_NAME; - } - maj_stat = gss_duplicate_name(&min_stat, name, &_svcauth_gss_name); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_set_svc_name: gss_duplicate_name", - maj_stat, min_stat); - return (FALSE); - } - - return (TRUE); -} - -static bool_t -svcauth_gss_import_name(char *service) -{ - gss_name_t name; - gss_buffer_desc namebuf; - OM_uint32 maj_stat, min_stat; - bool_t result; - - gss_log_debug("in svcauth_gss_import_name()"); - - namebuf.value = service; - namebuf.length = strlen(service); - - maj_stat = gss_import_name(&min_stat, &namebuf, - (gss_OID)GSS_C_NT_HOSTBASED_SERVICE, &name); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_import_name: gss_import_name", - maj_stat, min_stat); - return (FALSE); - } - result = svcauth_gss_set_svc_name(name); - gss_release_name(&min_stat, &name); - return result; -} - -static bool_t -svcauth_gss_acquire_cred(void) -{ - OM_uint32 maj_stat, min_stat; - - gss_log_debug("in svcauth_gss_acquire_cred()"); - - maj_stat = gss_acquire_cred(&min_stat, _svcauth_gss_name, - _svcauth_req_time, &_svcauth_oid_set, - GSS_C_ACCEPT, - &_svcauth_gss_creds, NULL, NULL); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_acquire_cred: gss_acquire_cred", - maj_stat, min_stat); - return (FALSE); - } - return (TRUE); -} - -static bool_t -svcauth_gss_release_cred(void) -{ - OM_uint32 maj_stat, min_stat; - - gss_log_debug("in svcauth_gss_release_cred()"); - - maj_stat = gss_release_cred(&min_stat, &_svcauth_gss_creds); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_release_cred: gss_release_cred", - maj_stat, min_stat); - return (FALSE); - } - - _svcauth_gss_creds = NULL; - - return (TRUE); -} - -static rpc_gss_service_t -_rpc_gss_svc_to_service(rpc_gss_svc_t svc) -{ - switch (svc) { - case RPCSEC_GSS_SVC_NONE: - return rpcsec_gss_svc_none; - case RPCSEC_GSS_SVC_INTEGRITY: - return rpcsec_gss_svc_integrity; - case RPCSEC_GSS_SVC_PRIVACY: - return rpcsec_gss_svc_privacy; - } - return rpcsec_gss_svc_default; -} - -static bool_t -_rpc_gss_fill_in_creds(struct svc_rpc_gss_data *gd, struct rpc_gss_cred *gc) -{ - rpc_gss_rawcred_t *rcred = &gd->rcred; - - rcred->version = gc->gc_v; - if (!rpc_gss_oid_to_mech(gd->sec.mech, &rcred->mechanism)) - return FALSE; - rcred->service = _rpc_gss_svc_to_service(gd->sec.svc); - - rcred->client_principal = calloc(1, sizeof(rpc_gss_principal_t) + - gd->cname.length); - if (rcred->client_principal == NULL) - return FALSE; - - rcred->client_principal->len = gd->cname.length; - (void)memcpy(rcred->client_principal->name, - gd->cname.value, gd->cname.length); - - rcred->svc_principal = _svcauth_svc_name; - - return TRUE; -} - -static bool_t -svcauth_gss_accept_sec_context(struct svc_req *rqst, - struct rpc_gss_init_res *gr) -{ - struct svc_rpc_gss_data *gd; - struct rpc_gss_cred *gc; - gss_buffer_desc recv_tok, seqbuf, checksum; - gss_OID mech; - OM_uint32 maj_stat = 0, min_stat = 0, ret_flags, seq; - - gss_log_debug("in svcauth_gss_accept_context()"); - - gd = SVCAUTH_PRIVATE(&SVC_XP_AUTH(rqst->rq_xprt)); - gc = (struct rpc_gss_cred *)rqst->rq_clntcred; - memset(gr, 0, sizeof(*gr)); - - /* Deserialize arguments. */ - memset(&recv_tok, 0, sizeof(recv_tok)); - - if (!svc_getargs(rqst->rq_xprt, (xdrproc_t)xdr_rpc_gss_init_args, - (caddr_t)&recv_tok)) - return (FALSE); - - gr->gr_major = gss_accept_sec_context(&gr->gr_minor, - &gd->ctx, - _svcauth_gss_creds, - &recv_tok, - GSS_C_NO_CHANNEL_BINDINGS, - &gd->client_name, - &mech, - &gr->gr_token, - &ret_flags, - NULL, - &gd->deleg); - - xdr_free((xdrproc_t)xdr_rpc_gss_init_args, (caddr_t)&recv_tok); - - if (gr->gr_major != GSS_S_COMPLETE && - gr->gr_major != GSS_S_CONTINUE_NEEDED) { - gss_log_status("svcauth_gss_accept_sec_context: accept_sec_context", - gr->gr_major, gr->gr_minor); - gd->ctx = GSS_C_NO_CONTEXT; - gss_release_buffer(&min_stat, &gr->gr_token); - return (FALSE); - } - /* ANDROS: krb5 mechglue returns ctx of size 8 - two pointers, - * one to the mechanism oid, one to the internal_ctx_id */ - if ((gr->gr_ctx.value = mem_alloc(sizeof(gss_union_ctx_id_desc))) == NULL) { - fprintf(stderr, "svcauth_gss_accept_context: out of memory\n"); - return (FALSE); - } - memcpy(gr->gr_ctx.value, gd->ctx, sizeof(gss_union_ctx_id_desc)); - gr->gr_ctx.length = sizeof(gss_union_ctx_id_desc); - - /* ANDROS: change for debugging linux kernel version... - gr->gr_win = sizeof(gd->seqmask) * 8; - */ - gr->gr_win = 0x00000005; - - /* Save client info. */ - gd->sec.mech = mech; - gd->sec.qop = GSS_C_QOP_DEFAULT; - gd->sec.svc = gc->gc_svc; - gd->seq = gc->gc_seq; - gd->win = gr->gr_win; - gd->callback_done = FALSE; - - if (gr->gr_major == GSS_S_COMPLETE) { - maj_stat = gss_display_name(&min_stat, gd->client_name, - &gd->cname, &gd->sec.mech); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_accept_sec_context: display_name", - maj_stat, min_stat); - return (FALSE); - } - if (!_rpc_gss_fill_in_creds(gd, gc)) - return (FALSE); - - seq = htonl(gr->gr_win); - seqbuf.value = &seq; - seqbuf.length = sizeof(seq); - - maj_stat = gss_sign(&min_stat, gd->ctx, GSS_C_QOP_DEFAULT, - &seqbuf, &checksum); - - if (maj_stat != GSS_S_COMPLETE) - return (FALSE); - - rqst->rq_xprt->xp_verf.oa_flavor = RPCSEC_GSS; - memcpy(rqst->rq_xprt->xp_verf.oa_base, checksum.value, - checksum.length); - rqst->rq_xprt->xp_verf.oa_length = checksum.length; - - gss_release_buffer(&min_stat, &checksum); - } - return (TRUE); -} - -static bool_t -svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg, - gss_qop_t *qop) -{ - struct opaque_auth *oa; - gss_buffer_desc rpcbuf, checksum; - OM_uint32 maj_stat, min_stat, qop_state; - u_char *rpchdr; - int32_t *buf; - - gss_log_debug("in svcauth_gss_validate()"); - - /* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */ - oa = &msg->rm_call.cb_cred; - if (oa->oa_length > MAX_AUTH_BYTES) - return (FALSE); - - rpchdr = (u_char *)calloc(((8 * BYTES_PER_XDR_UNIT) + - RNDUP(oa->oa_length)), 1); - if (rpchdr == NULL) - return (FALSE); - - buf = (int32_t *)rpchdr; - IXDR_PUT_LONG(buf, msg->rm_xid); - IXDR_PUT_ENUM(buf, msg->rm_direction); - IXDR_PUT_LONG(buf, msg->rm_call.cb_rpcvers); - IXDR_PUT_LONG(buf, msg->rm_call.cb_prog); - IXDR_PUT_LONG(buf, msg->rm_call.cb_vers); - IXDR_PUT_LONG(buf, msg->rm_call.cb_proc); - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_LONG(buf, oa->oa_length); - if (oa->oa_length) { - memcpy((caddr_t)buf, oa->oa_base, oa->oa_length); - buf += RNDUP(oa->oa_length) / sizeof(int32_t); - } - rpcbuf.value = rpchdr; - rpcbuf.length = (u_char *)buf - rpchdr; - - checksum.value = msg->rm_call.cb_verf.oa_base; - checksum.length = msg->rm_call.cb_verf.oa_length; - - maj_stat = gss_verify_mic(&min_stat, gd->ctx, &rpcbuf, &checksum, - &qop_state); - - free(rpchdr); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_validate: gss_verify_mic", - maj_stat, min_stat); - return (FALSE); - } - *qop = qop_state; - return (TRUE); -} - -static bool_t -svcauth_gss_nextverf(struct svc_req *rqst, u_int num) -{ - struct svc_rpc_gss_data *gd; - gss_buffer_desc signbuf, checksum; - OM_uint32 maj_stat, min_stat; - - gss_log_debug("in svcauth_gss_nextverf()"); - - gd = SVCAUTH_PRIVATE(&SVC_XP_AUTH(rqst->rq_xprt)); - - signbuf.value = # - signbuf.length = sizeof(num); - - maj_stat = gss_get_mic(&min_stat, gd->ctx, gd->sec.qop, - &signbuf, &checksum); - - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("svcauth_gss_nextverf: gss_get_mic", - maj_stat, min_stat); - return (FALSE); - } - - rqst->rq_xprt->xp_verf.oa_flavor = RPCSEC_GSS; - memcpy(rqst->rq_xprt->xp_verf.oa_base, checksum.value, checksum.length); - rqst->rq_xprt->xp_verf.oa_length = (u_int)checksum.length; - - gss_release_buffer(&min_stat, &checksum); - - return (TRUE); -} - -static bool_t -svcauth_gss_do_call(struct svc_req *rqst, struct svc_rpc_gss_data *gd, - struct svc_rpc_gss_callback *cb) -{ - rpc_gss_lock_t lock; - bool_t result; - - lock.locked = FALSE; - lock.raw_cred = &gd->rcred; - result = cb->cb_args.callback(rqst, gd->deleg, gd->ctx, - &lock, &gd->cookie); - if (result) { - gd->locked = lock.locked; - gd->deleg = GSS_C_NO_CREDENTIAL; - } - return result; -} - -static bool_t -svcauth_gss_callback(struct svc_req *rqst, struct svc_rpc_gss_data *gd) -{ - struct svc_rpc_gss_callback *cb; - bool_t result; - - result = TRUE; - mutex_lock(&svcauth_cb_lock); - - for (cb = _svcauth_callbacks; cb != NULL; cb = cb->cb_next) { - if (cb->cb_args.program == rqst->rq_prog && - cb->cb_args.version == rqst->rq_vers) { - result = svcauth_gss_do_call(rqst, gd, cb); - break; - } - } - - if (gd->deleg != GSS_C_NO_CREDENTIAL) { - OM_uint32 min_stat; - (void)gss_release_cred(&min_stat, &gd->deleg); - } - - mutex_unlock(&svcauth_cb_lock); - return result; -} - -static void -destroy_gd(struct svc_rpc_gss_data *gd) -{ - OM_uint32 min_stat; - - gss_delete_sec_context(&min_stat, &gd->ctx, GSS_C_NO_BUFFER); - gss_release_buffer(&min_stat, &gd->cname); - - if (gd->client_name) - gss_release_name(&min_stat, &gd->client_name); - if (gd->rcred.client_principal != NULL) - free(gd->rcred.client_principal); - - mem_free(gd, sizeof(*gd)); -} - -/* call with svcauth_gss_cache_lock */ -static struct svcauth_gss_cache_entry ** -lookup_cache_entry(struct svc_req *rqst) -{ - struct svcauth_gss_cache_entry **ce; - - /* - * for now, only one set of gss data per xprt, which is borked, - * but that gss data will at least survive if there are - * interleaved calls with another cred flavor on the same xprt - */ - for (ce = &svcauth_gss_cache; *ce; ce = &(*ce)->next) { - if ((*ce)->xprt == rqst->rq_xprt) - break; - } - - return (ce); -} - -/* call with svcauth_gss_cache_lock */ -static void -use_cache_entry(struct svcauth_gss_cache_entry **ce, time_t now) -{ - struct svcauth_gss_cache_entry *ce_new_head; - - (*ce)->time_to_die = now + 300; /* 5 minutes */ - - if (ce == &svcauth_gss_cache) - return; /* ce already at the head */ - - ce_new_head = *ce; - *ce = (*ce)->next; - ce_new_head->next = svcauth_gss_cache; - svcauth_gss_cache = ce_new_head; -} - -/* call with svcauth_gss_cache_lock */ -static void -destroy_cold_cache_entries(time_t now) -{ - struct svcauth_gss_cache_entry **ce; - - for (ce = &svcauth_gss_cache; *ce; ce = &(*ce)->next) { - if (now > (*ce)->time_to_die) - break; - } - - while (*ce) { - struct svcauth_gss_cache_entry *ce_next = (*ce)->next; - destroy_gd((*ce)->gd); - mem_free(*ce, sizeof(**ce)); - *ce = ce_next; - } -} - -enum auth_stat -_svcauth_gss(struct svc_req *rqst, struct rpc_msg *msg, bool_t *no_dispatch) -{ - XDR xdrs; - struct svc_rpc_gss_data *gd; - struct rpc_gss_cred *gc; - struct rpc_gss_init_res gr; - int call_stat, offset; - gss_qop_t qop; - struct svcauth_gss_cache_entry **ce; - time_t now; - enum auth_stat result = AUTH_OK; - OM_uint32 min_stat; - - gss_log_debug("in svcauth_gss()"); - - /* Initialize reply. */ - rqst->rq_xprt->xp_verf = _null_auth; - - now = time(NULL); - mutex_lock(&svcauth_gss_cache_lock); - ce = lookup_cache_entry(rqst); - if (!*ce) { - /* no cache entry for this xprt, allocate and set it up */ - if ((*ce = calloc(sizeof(**ce), 1)) == NULL) { - fprintf(stderr, "svcauth_gss: out_of_memory\n"); - mutex_unlock(&svcauth_gss_cache_lock); - return (AUTH_FAILED); - } - if ((gd = calloc(sizeof(*gd), 1)) == NULL) { - free(*ce); - fprintf(stderr, "svcauth_gss: out_of_memory\n"); - mutex_unlock(&svcauth_gss_cache_lock); - return (AUTH_FAILED); - } - gd->locked = FALSE; - (*ce)->xprt = rqst->rq_xprt; - (*ce)->gd = gd; - (*ce)->next = NULL; - } - else - gd = (*ce)->gd; - use_cache_entry(ce, now); - destroy_cold_cache_entries(now); - mutex_unlock(&svcauth_gss_cache_lock); - - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_ops = &svc_auth_gss_ops; - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_private = (caddr_t) gd; - - /* Deserialize client credentials. */ - if (rqst->rq_cred.oa_length <= 0) - return (AUTH_BADCRED); - - gc = (struct rpc_gss_cred *)rqst->rq_clntcred; - memset(gc, 0, sizeof(*gc)); - - xdrmem_create(&xdrs, rqst->rq_cred.oa_base, - rqst->rq_cred.oa_length, XDR_DECODE); - - if (!xdr_rpc_gss_cred(&xdrs, gc)) { - XDR_DESTROY(&xdrs); - return (AUTH_BADCRED); - } - XDR_DESTROY(&xdrs); - - /* Check version. */ - if (gc->gc_v != RPCSEC_GSS_VERSION) { - result = AUTH_BADCRED; - goto out; - } - - /* Check RPCSEC_GSS service. */ - if (gc->gc_svc != RPCSEC_GSS_SVC_NONE && - gc->gc_svc != RPCSEC_GSS_SVC_INTEGRITY && - gc->gc_svc != RPCSEC_GSS_SVC_PRIVACY) { - result = AUTH_BADCRED; - goto out; - } - - /* Check sequence number. */ - if (gd->established) { - if (gc->gc_seq > MAXSEQ) { - result = RPCSEC_GSS_CTXPROBLEM; - goto out; - } - - if ((offset = gd->seqlast - gc->gc_seq) < 0) { - gd->seqlast = gc->gc_seq; - offset = 0 - offset; - gd->seqmask <<= offset; - offset = 0; - } - else if (offset >= gd->win || (gd->seqmask & (1 << offset))) { - *no_dispatch = 1; - result = RPCSEC_GSS_CTXPROBLEM; - goto out; - } - gd->seq = gc->gc_seq; - gd->seqmask |= (1 << offset); - } - - if (gd->established) { - rqst->rq_clntname = (char *)gd->client_name; - rqst->rq_svcname = (char *)gd->ctx; - } - - rqst->rq_xprt->xp_verf.oa_base = msg->rm_call.cb_verf.oa_base; - - /* Handle RPCSEC_GSS control procedure. */ - switch (gc->gc_proc) { - - case RPCSEC_GSS_INIT: - case RPCSEC_GSS_CONTINUE_INIT: - if (rqst->rq_proc != NULLPROC) { - result = AUTH_FAILED; /* XXX ? */ - break; - } - - if (_svcauth_gss_name == GSS_C_NO_NAME) { - if (!svcauth_gss_import_name("nfs")) { - result = AUTH_FAILED; - break; - } - } - - if (!svcauth_gss_acquire_cred()) { - result = AUTH_FAILED; - break; - } - - if (!svcauth_gss_accept_sec_context(rqst, &gr)) { - result = AUTH_REJECTEDCRED; - break; - } - - if (!svcauth_gss_nextverf(rqst, htonl(gr.gr_win))) { - result = AUTH_FAILED; - break; - } - - *no_dispatch = TRUE; - - call_stat = svc_sendreply(rqst->rq_xprt, - (xdrproc_t)xdr_rpc_gss_init_res, (caddr_t)&gr); - - gss_release_buffer(&min_stat, &gr.gr_token); - free(gr.gr_ctx.value); - - if (!call_stat) { - result = AUTH_FAILED; - break; - } - - if (gr.gr_major == GSS_S_COMPLETE) - gd->established = TRUE; - - break; - - case RPCSEC_GSS_DATA: - if (!svcauth_gss_validate(gd, msg, &qop)) { - result = RPCSEC_GSS_CREDPROBLEM; - break; - } - - if (!svcauth_gss_nextverf(rqst, htonl(gc->gc_seq))) { - result = AUTH_FAILED; - break; - } - - if (!gd->callback_done) { - gd->callback_done = TRUE; - gd->sec.qop = qop; - (void)rpc_gss_num_to_qop(gd->rcred.mechanism, - gd->sec.qop, &gd->rcred.qop); - if (!svcauth_gss_callback(rqst, gd)) { - result = AUTH_REJECTEDCRED; - break; - } - } - - if (gd->locked) { - if (gd->rcred.service != - _rpc_gss_svc_to_service(gc->gc_svc)) { - result = AUTH_FAILED; - break; - } - if (gd->sec.qop != qop) { - result = AUTH_BADVERF; - break; - } - } - - if (gd->sec.qop != qop) { - gd->sec.qop = qop; - (void)rpc_gss_num_to_qop(gd->rcred.mechanism, - qop, &gd->rcred.qop); - } - - gd->rcred.service = _rpc_gss_svc_to_service(gc->gc_svc); - - break; - - case RPCSEC_GSS_DESTROY: - if (rqst->rq_proc != NULLPROC) { - result = AUTH_FAILED; /* XXX ? */ - break; - } - - if (!svcauth_gss_validate(gd, msg, &qop)) { - result = RPCSEC_GSS_CREDPROBLEM; - break; - } - - if (!svcauth_gss_nextverf(rqst, htonl(gc->gc_seq))) { - result = AUTH_FAILED; - break; - } - - if (!svcauth_gss_release_cred()) { - result = AUTH_FAILED; - break; - } - - SVCAUTH_DESTROY(&SVC_XP_AUTH(rqst->rq_xprt)); - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_ops = svc_auth_none.svc_ah_ops; - SVC_XP_AUTH(rqst->rq_xprt).svc_ah_private = NULL; - - break; - - default: - result = AUTH_REJECTEDCRED; - break; - } -out: - xdr_free((xdrproc_t)xdr_rpc_gss_cred, (caddr_t)gc); - return result; -} - -static bool_t -svcauth_gss_destroy(SVCAUTH *auth) -{ - struct svc_rpc_gss_data *gd; - struct svcauth_gss_cache_entry **ce; - - gss_log_debug("in svcauth_gss_destroy()"); - - gd = SVCAUTH_PRIVATE(auth); - - mutex_lock(&svcauth_gss_cache_lock); - for (ce = &svcauth_gss_cache; *ce; ce = &(*ce)->next) { - if ((*ce)->gd == gd) { - struct svcauth_gss_cache_entry *ce_destroy = *ce; - *ce = (*ce)->next; - mem_free(ce_destroy, sizeof(*ce_destroy)); - break; - } - } - mutex_unlock(&svcauth_gss_cache_lock); - - destroy_gd(gd); - - return (TRUE); -} - -static bool_t -svcauth_gss_wrap(SVCAUTH *auth, XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr) -{ - struct svc_rpc_gss_data *gd; - - gss_log_debug("in svcauth_gss_wrap()"); - - gd = SVCAUTH_PRIVATE(auth); - - if (!gd->established || gd->sec.svc == RPCSEC_GSS_SVC_NONE) { - return ((*xdr_func)(xdrs, xdr_ptr)); - } - return (xdr_rpc_gss_data(xdrs, xdr_func, xdr_ptr, - gd->ctx, gd->sec.qop, - gd->sec.svc, gd->seq)); -} - -static bool_t -svcauth_gss_unwrap(SVCAUTH *auth, XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr) -{ - struct svc_rpc_gss_data *gd; - - gss_log_debug("in svcauth_gss_unwrap()"); - - gd = SVCAUTH_PRIVATE(auth); - - if (!gd->established || gd->sec.svc == RPCSEC_GSS_SVC_NONE) { - return ((*xdr_func)(xdrs, xdr_ptr)); - } - return (xdr_rpc_gss_data(xdrs, xdr_func, xdr_ptr, - gd->ctx, gd->sec.qop, - gd->sec.svc, gd->seq)); -} - -char * -svcauth_gss_get_principal(SVCAUTH *auth) -{ - struct svc_rpc_gss_data *gd; - char *pname; - - gd = SVCAUTH_PRIVATE(auth); - - if (gd->cname.length == 0) - return (NULL); - - if ((pname = malloc(gd->cname.length + 1)) == NULL) - return (NULL); - - memcpy(pname, gd->cname.value, gd->cname.length); - pname[gd->cname.length] = '\0'; - - return (pname); -} - -/* - * External API: Return maximum data size for a security mechanism and transport - * - * rqst: an incoming RPC request - * maxlen: transport's maximum data size, in bytes - * - * Returns maximum data size given transformations done by current - * security setting of "auth", in bytes, or zero if that value - * cannot be determined. - */ -int -rpc_gss_svc_max_data_length(struct svc_req *rqst, int maxlen) -{ - OM_uint32 max_input_size, maj_stat, min_stat; - struct svc_rpc_gss_data *gd; - int conf_req_flag; - int result; - - if (!rqst) - return 0; - - gd = SVCAUTH_PRIVATE(&SVC_XP_AUTH(rqst->rq_xprt)); - - switch (gd->rcred.service) { - case rpcsec_gss_svc_none: - return maxlen; - case rpcsec_gss_svc_default: - case rpcsec_gss_svc_integrity: - conf_req_flag = 0; - break; - case rpcsec_gss_svc_privacy: - conf_req_flag = 1; - break; - default: - return 0; - } - - result = 0; - maj_stat = gss_wrap_size_limit(&min_stat, gd->ctx, conf_req_flag, - gd->sec.qop, maxlen, &max_input_size); - if (maj_stat == GSS_S_COMPLETE) - if ((int)max_input_size > 0) - result = (int)max_input_size; - return result; -} - -/* - * External API: Set server's GSS principal - * - * principal: NUL-terminated C string containing GSS principal - * mechanism: NUL-terminated C string containing GSS mechanism name - * req_time: time in seconds until credential expires - * program: program number of the RPC service - * version: version number of the RPC service - * - * Returns TRUE if successful, otherwise FALSE is returned. - */ -bool_t -rpc_gss_set_svc_name(char *principal, char *mechanism, u_int req_time, - u_int UNUSED(program), u_int UNUSED(version)) -{ - rpc_gss_OID oid; - char *save; - - if (principal == NULL) - return FALSE; - save = strdup(principal); - if (save == NULL) - return FALSE; - - if (!rpc_gss_mech_to_oid(mechanism, &oid)) - goto out_err; - - if (!svcauth_gss_import_name(principal)) - goto out_err; - - _svcauth_req_time = req_time; - _svcauth_oid_set.count = 1; - _svcauth_oid_set.elements = (gss_OID)oid; - free(_svcauth_svc_name); - _svcauth_svc_name = save; - return TRUE; - -out_err: - free(save); - return FALSE; -} - -static void -_rpc_gss_fill_in_ucreds(struct svc_rpc_gss_data *gd) -{ - rpc_gss_ucred_t *ucred = &gd->ucred; - OM_uint32 maj_stat, min_stat; - struct passwd pwd, *pw; - long buflen; - uid_t uid; - char *buf; - int len; - - /* default: "nfsnobody" */ - ucred->uid = 65534; - ucred->gid = 65534; - ucred->gidlen = 0; - ucred->gidlist = gd->gids; - - maj_stat = gss_pname_to_uid(&min_stat, gd->client_name, - gd->sec.mech, &uid); - if (maj_stat != GSS_S_COMPLETE) - return; - - buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - if (buflen == -1) - return; - buf = malloc((size_t)buflen); - if (buf == NULL) - return; - - (void)getpwuid_r(uid, &pwd, buf, buflen, &pw); - if (pw == NULL) { - free(buf); - return; - } - - ucred->uid = pw->pw_uid; - ucred->gid = pw->pw_gid; - len = NGRPS; - (void)getgrouplist(pw->pw_name, pw->pw_gid, ucred->gidlist, &len); - ucred->gidlen = len; - - free(buf); -} - -/* - * External API: Retrieve requesting client's GSS credential - * - * rqst: an incoming RPC request - * rcred: address of pointer to fill in, or NULL - * ucred: address of pointer to fill in, or NULL - * cookie: address of pointer to fill in, or NULL - * - * Returns TRUE if successful. "rcred," "ucred," and "cookie" - * are filled in with pointers to the relevant structures. - * Caller must not free the memory returned by this API. - */ -bool_t -rpc_gss_getcred(struct svc_req *rqst, rpc_gss_rawcred_t **rcred, - rpc_gss_ucred_t **ucred, void **cookie) -{ - struct svc_rpc_gss_data *gd; - - if (rqst == NULL) - return FALSE; - - if (rqst->rq_xprt->xp_verf.oa_flavor != RPCSEC_GSS) - return FALSE; - - gd = SVCAUTH_PRIVATE(&SVC_XP_AUTH(rqst->rq_xprt)); - - if (rcred != NULL) { - gd->scratch = gd->rcred; - gd->scratch.service = _rpc_gss_svc_to_service(gd->sec.svc); - (void)rpc_gss_num_to_qop(gd->scratch.mechanism, gd->sec.qop, - &gd->scratch.qop); - *rcred = &gd->scratch; - } - - if (ucred != NULL) { - _rpc_gss_fill_in_ucreds(gd); - *ucred = &gd->ucred; - } - - if (cookie != NULL) - *cookie = gd->cookie; - - return TRUE; -} - -/* - * External API: Register a callback function - * - * callback: callback structure containing function and parameters - * - * Returns TRUE if successful, otherwise FALSE. - * - * "callback" is copied by rpc_gss_set_callback(), and may be freed - * immediately after it returns. - */ -bool_t -rpc_gss_set_callback(rpc_gss_callback_t *callback) -{ - struct svc_rpc_gss_callback *new; - - if (callback == NULL) - return FALSE; - - /* XXX: This is never freed */ - new = malloc(sizeof(*new)); - if (new == NULL) - return FALSE; - - new->cb_args = *callback; - - mutex_lock(&svcauth_cb_lock); - new->cb_next = _svcauth_callbacks; - _svcauth_callbacks = new; - mutex_unlock(&svcauth_cb_lock); - - return TRUE; -} - -/* - * External API: Form a generic rpc_gss_principal - * - * principal: address of buffer to fill in - * mechanism: NUL-terminated C string containing GSS mechanism name - * user_name: NUL-terminated C string containing user or service principal - * node: NUL-terminated C string containing a hostname - * secdomain: NUL-terminated C string containing a security realm - * - * Returns TRUE if successful, otherwise FALSE. Caller must free - * returned "principal" with free(3). - */ -bool_t -rpc_gss_get_principal_name(rpc_gss_principal_t *principal, char *mechanism, - char *user_name, char *node, char *secdomain) -{ - OM_uint32 maj_stat, min_stat; - rpc_gss_principal_t result; - size_t nodelen, secdomlen; - gss_name_t name, mechname; - gss_buffer_desc namebuf; - rpc_gss_OID oid; - - - if (principal == NULL || user_name == NULL || strlen(user_name) == 0) - return FALSE; - if (!rpc_gss_mech_to_oid(mechanism, &oid)) - return FALSE; - - nodelen = 0; - if (node != NULL) - nodelen = strlen(node) + 1; - secdomlen = 0; - if (secdomain != NULL) - secdomlen = strlen(secdomain) + 1; - namebuf.length = strlen(user_name) + nodelen + secdomlen; - namebuf.value = calloc(1, namebuf.length); - if (namebuf.value == NULL) - return FALSE; - (void)strcpy(namebuf.value, user_name); - if (nodelen > 0) { - (void)strcat(namebuf.value, "/"); - (void)strcat(namebuf.value, node); - } - if (secdomlen > 0) { - (void)strcat(namebuf.value, "@"); - (void)strcat(namebuf.value, secdomain); - } - - maj_stat = gss_import_name(&min_stat, &namebuf, - GSS_C_NT_USER_NAME, &name); - free(namebuf.value); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("gss_import_name", maj_stat, min_stat); - return FALSE; - } - - maj_stat = gss_canonicalize_name(&min_stat, name, oid, &mechname); - (void)gss_release_name(&min_stat, &name); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("gss_canonicalize_name", maj_stat, min_stat); - return FALSE; - } - - maj_stat = gss_export_name(&min_stat, mechname, &namebuf); - (void)gss_release_name(&min_stat, &mechname); - if (maj_stat != GSS_S_COMPLETE) { - gss_log_status("gss_export_name", maj_stat, min_stat); - return FALSE; - } - - result = calloc(1, sizeof(*result) + namebuf.length); - if (result == NULL) { - (void)gss_release_buffer(&min_stat, &namebuf); - return FALSE; - } - result->len = namebuf.length; - (void)memcpy(result->name, namebuf.value, namebuf.length); - (void)gss_release_buffer(&min_stat, &namebuf); - - *principal = result; - return TRUE; -} diff --git a/libtirpc-1.3.1/src/svc_auth_none.c b/libtirpc-1.3.1/src/svc_auth_none.c deleted file mode 100644 index 887e809..0000000 --- a/libtirpc-1.3.1/src/svc_auth_none.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - svc_auth_none.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: svc_auth_none.c,v 1.1 2004/10/22 17:24:30 bfields Exp $ - */ - -#include - -static bool_t svcauth_none_destroy(); -static bool_t svcauth_none_wrap(); - -struct svc_auth_ops svc_auth_none_ops = { - svcauth_none_wrap, - svcauth_none_wrap, - svcauth_none_destroy -}; - -SVCAUTH svc_auth_none = { - &svc_auth_none_ops, - NULL, -}; - -static bool_t -svcauth_none_destroy(SVCAUTH *auth) -{ - return (TRUE); -} - -static bool_t -svcauth_none_wrap(SVCAUTH *auth, XDR *xdrs, xdrproc_t xdr_func, - caddr_t xdr_ptr) -{ - return ((*xdr_func)(xdrs, xdr_ptr)); -} - -enum auth_stat -_svcauth_none(struct svc_req *rqst, struct rpc_msg *msg) -{ - return (AUTH_OK); -} diff --git a/libtirpc-1.3.1/src/svc_auth_unix.c b/libtirpc-1.3.1/src/svc_auth_unix.c deleted file mode 100644 index 8f992a4..0000000 --- a/libtirpc-1.3.1/src/svc_auth_unix.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * svc_auth_unix.c - * Handles UNIX flavor authentication parameters on the service side of rpc. - * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. - * _svcauth_unix does full blown unix style uid,gid+gids auth, - * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. - * Note: the shorthand has been gutted for efficiency. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#include -#include -#include -#include - -#include - -extern SVCAUTH svc_auth_none; - -/* - * Unix longhand authenticator - */ -enum auth_stat -_svcauth_unix(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; -{ - enum auth_stat stat; - XDR xdrs; - struct authunix_parms *aup; - int32_t *buf; - struct area { - struct authunix_parms area_aup; - char area_machname[MAX_MACHINE_NAME+1]; - gid_t area_gids[NGRPS]; - } *area; - u_int auth_len; - size_t str_len, gid_len; - u_int i; - - assert(rqst != NULL); - assert(msg != NULL); - - area = (struct area *) rqst->rq_clntcred; - aup = &area->area_aup; - aup->aup_machname = area->area_machname; - aup->aup_gids = area->area_gids; - auth_len = (u_int)msg->rm_call.cb_cred.oa_length; - xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); - buf = XDR_INLINE(&xdrs, auth_len); - if (buf != NULL) { - aup->aup_time = IXDR_GET_INT32(buf); - str_len = (size_t)IXDR_GET_U_INT32(buf); - if (str_len > MAX_MACHINE_NAME) { - stat = AUTH_BADCRED; - goto done; - } - memmove(aup->aup_machname, buf, str_len); - aup->aup_machname[str_len] = 0; - str_len = RNDUP(str_len); - buf += str_len / sizeof (int32_t); - aup->aup_uid = (int)IXDR_GET_INT32(buf); - aup->aup_gid = (int)IXDR_GET_INT32(buf); - gid_len = (size_t)IXDR_GET_U_INT32(buf); - if (gid_len > NGRPS) { - stat = AUTH_BADCRED; - goto done; - } - aup->aup_len = gid_len; - for (i = 0; i < gid_len; i++) { - aup->aup_gids[i] = (int)IXDR_GET_INT32(buf); - } - /* - * five is the smallest unix credentials structure - - * timestamp, hostname len (0), uid, gid, and gids len (0). - */ - if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { - (void) printf("bad auth_len gid %ld str %ld auth %u\n", - (long)gid_len, (long)str_len, auth_len); - stat = AUTH_BADCRED; - goto done; - } - } else if (! xdr_authunix_parms(&xdrs, aup)) { - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, aup); - stat = AUTH_BADCRED; - goto done; - } - - /* get the verifier */ - if ((u_int)msg->rm_call.cb_verf.oa_length) { - rqst->rq_xprt->xp_verf.oa_flavor = - msg->rm_call.cb_verf.oa_flavor; - rqst->rq_xprt->xp_verf.oa_base = - msg->rm_call.cb_verf.oa_base; - rqst->rq_xprt->xp_verf.oa_length = - msg->rm_call.cb_verf.oa_length; - } else { - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; - rqst->rq_xprt->xp_verf.oa_length = 0; - } - stat = AUTH_OK; -done: - XDR_DESTROY(&xdrs); - return (stat); -} - - -/* - * Shorthand unix authenticator - * Looks up longhand in a cache. - */ -/*ARGSUSED*/ -enum auth_stat -_svcauth_short(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; -{ - return (AUTH_REJECTEDCRED); -} diff --git a/libtirpc-1.3.1/src/svc_dg.c b/libtirpc-1.3.1/src/svc_dg.c deleted file mode 100644 index a9f63ff..0000000 --- a/libtirpc-1.3.1/src/svc_dg.c +++ /dev/null @@ -1,721 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - -/* - * svc_dg.c, Server side for connectionless RPC. - * - * Does some caching in the hopes of achieving execute-at-most-once semantics. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rpc_com.h" -#include "debug.h" - -#define su_data(xprt) ((struct svc_dg_data *)((xprt)->xp_p2)) -#define rpc_buffer(xprt) ((xprt)->xp_p1) - -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -static void svc_dg_ops(SVCXPRT *); -static enum xprt_stat svc_dg_stat(SVCXPRT *); -static bool_t svc_dg_recv(SVCXPRT *, struct rpc_msg *); -static bool_t svc_dg_reply(SVCXPRT *, struct rpc_msg *); -static bool_t svc_dg_getargs(SVCXPRT *, xdrproc_t, void *); -static bool_t svc_dg_freeargs(SVCXPRT *, xdrproc_t, void *); -static void svc_dg_destroy(SVCXPRT *); -static bool_t svc_dg_control(SVCXPRT *, const u_int, void *); -static int cache_get(SVCXPRT *, struct rpc_msg *, char **, size_t *); -static void cache_set(SVCXPRT *, size_t); -int svc_dg_enablecache(SVCXPRT *, u_int); -static void svc_dg_enable_pktinfo(int, const struct __rpc_sockinfo *); -static int svc_dg_valid_pktinfo(struct msghdr *); - -/* - * Usage: - * xprt = svc_dg_create(sock, sendsize, recvsize); - * Does other connectionless specific initializations. - * Once *xprt is initialized, it is registered. - * see (svc.h, xprt_register). If recvsize or sendsize are 0 suitable - * system defaults are chosen. - * The routines returns NULL if a problem occurred. - */ -static const char svc_dg_str[] = "svc_dg_create: %s"; -static const char svc_dg_err1[] = "could not get transport information"; -static const char svc_dg_err2[] = " transport does not support data transfer"; -static const char __no_mem_str[] = "out of memory"; - -SVCXPRT * -svc_dg_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - SVCXPRT *xprt; - SVCXPRT_EXT *ext = NULL; - struct svc_dg_data *su = NULL; - struct __rpc_sockinfo si; - struct sockaddr_storage ss; - socklen_t slen; - - if (!__rpc_fd2sockinfo(fd, &si)) { - warnx(svc_dg_str, svc_dg_err1); - return (NULL); - } - /* - * Find the receive and the send size - */ - sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize); - recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize); - if ((sendsize == 0) || (recvsize == 0)) { - warnx(svc_dg_str, svc_dg_err2); - return (NULL); - } - - xprt = mem_alloc(sizeof (SVCXPRT)); - if (xprt == NULL) - goto freedata; - memset(xprt, 0, sizeof (SVCXPRT)); - - ext = mem_alloc(sizeof (*ext)); - if (ext == NULL) - goto freedata; - memset(ext, 0, sizeof (*ext)); - - su = mem_alloc(sizeof (*su)); - if (su == NULL) - goto freedata; - su->su_iosz = ((MAX(sendsize, recvsize) + 3) / 4) * 4; - if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) - goto freedata; - xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, - XDR_DECODE); - su->su_cache = NULL; - xprt->xp_fd = fd; - xprt->xp_p2 = su; - xprt->xp_p3 = ext; - xprt->xp_verf.oa_base = su->su_verfbody; - svc_dg_ops(xprt); - xprt->xp_rtaddr.maxlen = sizeof (struct sockaddr_storage); - - slen = sizeof ss; - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) - goto freedata; - __rpc_set_netbuf(&xprt->xp_ltaddr, &ss, slen); - - /* Enable reception of IP*_PKTINFO control msgs */ - svc_dg_enable_pktinfo(fd, &si); - - xprt_register(xprt); - return (xprt); -freedata: - (void) warnx(svc_dg_str, __no_mem_str); - if (xprt) { - if (su) - (void) mem_free(su, sizeof (*su)); - if (ext) - (void) mem_free(ext, sizeof (*ext)); - (void) mem_free(xprt, sizeof (SVCXPRT)); - } - return (NULL); -} - -/*ARGSUSED*/ -static enum xprt_stat -svc_dg_stat(xprt) - SVCXPRT *xprt; -{ - return (XPRT_IDLE); -} - -static bool_t -svc_dg_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct svc_dg_data *su = su_data(xprt); - XDR *xdrs = &(su->su_xdrs); - char *reply; - struct sockaddr_storage ss; - struct msghdr *mesgp; - struct iovec iov; - size_t replylen; - ssize_t rlen; - -again: - iov.iov_base = rpc_buffer(xprt); - iov.iov_len = su->su_iosz; - mesgp = &su->su_msghdr; - memset(mesgp, 0, sizeof(*mesgp)); - mesgp->msg_iov = &iov; - mesgp->msg_iovlen = 1; - mesgp->msg_name = (struct sockaddr *)(void *) &ss; - mesgp->msg_namelen = sizeof (struct sockaddr_storage); - mesgp->msg_control = su->su_cmsg; - mesgp->msg_controllen = sizeof(su->su_cmsg); - - rlen = recvmsg(xprt->xp_fd, mesgp, 0); - if (rlen == -1 && errno == EINTR) - goto again; - if (rlen == -1 || (rlen < (ssize_t)(4 * sizeof (u_int32_t)))) - return (FALSE); - __rpc_set_netbuf(&xprt->xp_rtaddr, &ss, mesgp->msg_namelen); - - /* Check whether there's an IP_PKTINFO or IP6_PKTINFO control message. - * If yes, preserve it for svc_dg_reply; otherwise just zap any cmsgs */ - if (!svc_dg_valid_pktinfo(mesgp)) { - mesgp->msg_control = NULL; - mesgp->msg_controllen = 0; - } - - __xprt_set_raddr(xprt, &ss); - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) { - return (FALSE); - } - su->su_xid = msg->rm_xid; - if (su->su_cache != NULL) { - if (cache_get(xprt, msg, &reply, &replylen)) { - iov.iov_base = reply; - iov.iov_len = replylen; - (void) sendmsg(xprt->xp_fd, mesgp, 0); - return (FALSE); - } - } - return (TRUE); -} - -static bool_t -svc_dg_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct svc_dg_data *su = su_data(xprt); - XDR *xdrs = &(su->su_xdrs); - bool_t stat = FALSE; - size_t slen; - - xdrproc_t xdr_results; - caddr_t xdr_location; - bool_t has_args; - - if (msg->rm_reply.rp_stat == MSG_ACCEPTED && - msg->rm_reply.rp_acpt.ar_stat == SUCCESS) { - has_args = TRUE; - xdr_results = msg->acpted_rply.ar_results.proc; - xdr_location = msg->acpted_rply.ar_results.where; - - msg->acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - msg->acpted_rply.ar_results.where = NULL; - } else - has_args = FALSE; - - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - msg->rm_xid = su->su_xid; - if (xdr_replymsg(xdrs, msg) && - (!has_args || - SVCAUTH_WRAP(&SVC_XP_AUTH(xprt), - xdrs, xdr_results, xdr_location))) { - struct msghdr *msg = &su->su_msghdr; - struct iovec iov; - - iov.iov_base = rpc_buffer(xprt); - iov.iov_len = slen = XDR_GETPOS(xdrs); - msg->msg_iov = &iov; - msg->msg_iovlen = 1; - msg->msg_name = (struct sockaddr *)(void *) xprt->xp_rtaddr.buf; - msg->msg_namelen = xprt->xp_rtaddr.len; - /* cmsg already set in svc_dg_recv */ - - if (sendmsg(xprt->xp_fd, msg, 0) == (ssize_t) slen) { - stat = TRUE; - if (su->su_cache) - cache_set(xprt, slen); - } - } - return (stat); -} - -static bool_t -svc_dg_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - if (!SVCAUTH_UNWRAP(&SVC_XP_AUTH(xprt), - &(su_data(xprt)->su_xdrs), - xdr_args, args_ptr)) { - return FALSE; - } - return TRUE; -} - -static bool_t -svc_dg_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - XDR *xdrs = &(su_data(xprt)->su_xdrs); - - xdrs->x_op = XDR_FREE; - return (*xdr_args)(xdrs, args_ptr); -} - -static void -svc_dg_destroy(xprt) - SVCXPRT *xprt; -{ - SVCXPRT_EXT *ext = SVCEXT(xprt); - struct svc_dg_data *su = su_data(xprt); - - xprt_unregister(xprt); - if (xprt->xp_fd != -1) - (void)close(xprt->xp_fd); - XDR_DESTROY(&(su->su_xdrs)); - (void) mem_free(rpc_buffer(xprt), su->su_iosz); - (void) mem_free(su, sizeof (*su)); - (void) mem_free(ext, sizeof (*ext)); - if (xprt->xp_rtaddr.buf) - (void) mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen); - if (xprt->xp_ltaddr.buf) - (void) mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen); - if (xprt->xp_tp) - (void) free(xprt->xp_tp); - if (xprt->xp_netid) - (void) free(xprt->xp_netid); - (void) mem_free(xprt, sizeof (SVCXPRT)); -} - -static bool_t -/*ARGSUSED*/ -svc_dg_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; -{ - return (FALSE); -} - -static void -svc_dg_ops(xprt) - SVCXPRT *xprt; -{ - static struct xp_ops ops; - static struct xp_ops2 ops2; - extern mutex_t ops_lock; - -/* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&ops_lock); - if (ops.xp_recv == NULL) { - ops.xp_recv = svc_dg_recv; - ops.xp_stat = svc_dg_stat; - ops.xp_getargs = svc_dg_getargs; - ops.xp_reply = svc_dg_reply; - ops.xp_freeargs = svc_dg_freeargs; - ops.xp_destroy = svc_dg_destroy; - ops2.xp_control = svc_dg_control; - } - xprt->xp_ops = &ops; - xprt->xp_ops2 = &ops2; - mutex_unlock(&ops_lock); -} - -/* The CACHING COMPONENT */ - -/* - * Could have been a separate file, but some part of it depends upon the - * private structure of the client handle. - * - * Fifo cache for cl server - * Copies pointers to reply buffers into fifo cache - * Buffers are sent again if retransmissions are detected. - */ - -#define SPARSENESS 4 /* 75% sparse */ - -#define ALLOC(type, size) \ - (type *) mem_alloc((sizeof (type) * (size))) - -#define MEMZERO(addr, type, size) \ - (void) memset((void *) (addr), 0, sizeof (type) * (int) (size)) - -#define FREE(addr, type, size) \ - mem_free((addr), (sizeof (type) * (size))) - -/* - * An entry in the cache - */ -typedef struct cache_node *cache_ptr; -struct cache_node { - /* - * Index into cache is xid, proc, vers, prog and address - */ - u_int32_t cache_xid; - rpcproc_t cache_proc; - rpcvers_t cache_vers; - rpcprog_t cache_prog; - struct netbuf cache_addr; - /* - * The cached reply and length - */ - char *cache_reply; - size_t cache_replylen; - /* - * Next node on the list, if there is a collision - */ - cache_ptr cache_next; -}; - -/* - * The entire cache - */ -struct cl_cache { - u_int uc_size; /* size of cache */ - cache_ptr *uc_entries; /* hash table of entries in cache */ - cache_ptr *uc_fifo; /* fifo list of entries in cache */ - u_int uc_nextvictim; /* points to next victim in fifo list */ - rpcprog_t uc_prog; /* saved program number */ - rpcvers_t uc_vers; /* saved version number */ - rpcproc_t uc_proc; /* saved procedure number */ -}; - - -/* - * the hashing function - */ -#define CACHE_LOC(transp, xid) \ - (xid % (SPARSENESS * ((struct cl_cache *) \ - su_data(transp)->su_cache)->uc_size)) - -extern mutex_t dupreq_lock; - -/* - * Enable use of the cache. Returns 1 on success, 0 on failure. - * Note: there is no disable. - */ -static const char cache_enable_str[] = "svc_enablecache: %s %s"; -static const char alloc_err[] = "could not allocate cache "; -static const char enable_err[] = "cache already enabled"; - -int -svc_dg_enablecache(transp, size) - SVCXPRT *transp; - u_int size; -{ - struct svc_dg_data *su = su_data(transp); - struct cl_cache *uc; - - mutex_lock(&dupreq_lock); - if (su->su_cache != NULL) { - (void) warnx(cache_enable_str, enable_err, " "); - mutex_unlock(&dupreq_lock); - return (0); - } - uc = ALLOC(struct cl_cache, 1); - if (uc == NULL) { - warnx(cache_enable_str, alloc_err, " "); - mutex_unlock(&dupreq_lock); - return (0); - } - uc->uc_size = size; - uc->uc_nextvictim = 0; - uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); - if (uc->uc_entries == NULL) { - warnx(cache_enable_str, alloc_err, "data"); - FREE(uc, struct cl_cache, 1); - mutex_unlock(&dupreq_lock); - return (0); - } - MEMZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); - uc->uc_fifo = ALLOC(cache_ptr, size); - if (uc->uc_fifo == NULL) { - warnx(cache_enable_str, alloc_err, "fifo"); - FREE(uc->uc_entries, cache_ptr, size * SPARSENESS); - FREE(uc, struct cl_cache, 1); - mutex_unlock(&dupreq_lock); - return (0); - } - MEMZERO(uc->uc_fifo, cache_ptr, size); - su->su_cache = (char *)(void *)uc; - mutex_unlock(&dupreq_lock); - return (1); -} - -/* - * Set an entry in the cache. It assumes that the uc entry is set from - * the earlier call to cache_get() for the same procedure. This will always - * happen because cache_get() is calle by svc_dg_recv and cache_set() is called - * by svc_dg_reply(). All this hoopla because the right RPC parameters are - * not available at svc_dg_reply time. - */ - -static const char cache_set_str[] = "cache_set: %s"; -static const char cache_set_err1[] = "victim not found"; -static const char cache_set_err2[] = "victim alloc failed"; -static const char cache_set_err3[] = "could not allocate new rpc buffer"; - -static void -cache_set(xprt, replylen) - SVCXPRT *xprt; - size_t replylen; -{ - cache_ptr victim; - cache_ptr *vicp; - struct svc_dg_data *su = su_data(xprt); - struct cl_cache *uc = (struct cl_cache *) su->su_cache; - u_int loc; - char *newbuf; - struct netconfig *nconf; - char *uaddr; - - mutex_lock(&dupreq_lock); - /* - * Find space for the new entry, either by - * reusing an old entry, or by mallocing a new one - */ - victim = uc->uc_fifo[uc->uc_nextvictim]; - if (victim != NULL) { - loc = CACHE_LOC(xprt, victim->cache_xid); - for (vicp = &uc->uc_entries[loc]; - *vicp != NULL && *vicp != victim; - vicp = &(*vicp)->cache_next) - ; - if (*vicp == NULL) { - warnx(cache_set_str, cache_set_err1); - mutex_unlock(&dupreq_lock); - return; - } - *vicp = victim->cache_next; /* remove from cache */ - newbuf = victim->cache_reply; - } else { - victim = ALLOC(struct cache_node, 1); - if (victim == NULL) { - warnx(cache_set_str, cache_set_err2); - mutex_unlock(&dupreq_lock); - return; - } - newbuf = mem_alloc(su->su_iosz); - if (newbuf == NULL) { - warnx(cache_set_str, cache_set_err3); - FREE(victim, struct cache_node, 1); - mutex_unlock(&dupreq_lock); - return; - } - } - - /* - * Store it away - */ - if (libtirpc_debug_level > 3) { - if ((nconf = getnetconfigent(xprt->xp_netid))) { - uaddr = taddr2uaddr(nconf, &xprt->xp_rtaddr); - freenetconfigent(nconf); - LIBTIRPC_DEBUG(4, - ("cache set for xid= %x prog=%d vers=%d proc=%d for rmtaddr=%s\n", - su->su_xid, uc->uc_prog, uc->uc_vers, - uc->uc_proc, uaddr)); - free(uaddr); - } - } - victim->cache_replylen = replylen; - victim->cache_reply = rpc_buffer(xprt); - rpc_buffer(xprt) = newbuf; - xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), - su->su_iosz, XDR_ENCODE); - victim->cache_xid = su->su_xid; - victim->cache_proc = uc->uc_proc; - victim->cache_vers = uc->uc_vers; - victim->cache_prog = uc->uc_prog; - victim->cache_addr = xprt->xp_rtaddr; - victim->cache_addr.buf = ALLOC(char, xprt->xp_rtaddr.len); - (void) memcpy(victim->cache_addr.buf, xprt->xp_rtaddr.buf, - (size_t)xprt->xp_rtaddr.len); - loc = CACHE_LOC(xprt, victim->cache_xid); - victim->cache_next = uc->uc_entries[loc]; - uc->uc_entries[loc] = victim; - uc->uc_fifo[uc->uc_nextvictim++] = victim; - uc->uc_nextvictim %= uc->uc_size; - mutex_unlock(&dupreq_lock); -} - -/* - * Try to get an entry from the cache - * return 1 if found, 0 if not found and set the stage for cache_set() - */ -static int -cache_get(xprt, msg, replyp, replylenp) - SVCXPRT *xprt; - struct rpc_msg *msg; - char **replyp; - size_t *replylenp; -{ - u_int loc; - cache_ptr ent; - struct svc_dg_data *su = su_data(xprt); - struct cl_cache *uc = (struct cl_cache *) su->su_cache; - struct netconfig *nconf; - char *uaddr; - - mutex_lock(&dupreq_lock); - loc = CACHE_LOC(xprt, su->su_xid); - for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { - if (ent->cache_xid == su->su_xid && - ent->cache_proc == msg->rm_call.cb_proc && - ent->cache_vers == msg->rm_call.cb_vers && - ent->cache_prog == msg->rm_call.cb_prog && - ent->cache_addr.len == xprt->xp_rtaddr.len && - (memcmp(ent->cache_addr.buf, xprt->xp_rtaddr.buf, - xprt->xp_rtaddr.len) == 0)) { - if (libtirpc_debug_level > 3) { - if ((nconf = getnetconfigent(xprt->xp_netid))) { - uaddr = taddr2uaddr(nconf, &xprt->xp_rtaddr); - freenetconfigent(nconf); - LIBTIRPC_DEBUG(4, - ("cache entry found for xid=%x prog=%d" - "vers=%d proc=%d for rmtaddr=%s\n", - su->su_xid, msg->rm_call.cb_prog, - msg->rm_call.cb_vers, - msg->rm_call.cb_proc, uaddr)); - free(uaddr); - } - } - *replyp = ent->cache_reply; - *replylenp = ent->cache_replylen; - mutex_unlock(&dupreq_lock); - return (1); - } - } - /* - * Failed to find entry - * Remember a few things so we can do a set later - */ - uc->uc_proc = msg->rm_call.cb_proc; - uc->uc_vers = msg->rm_call.cb_vers; - uc->uc_prog = msg->rm_call.cb_prog; - mutex_unlock(&dupreq_lock); - return (0); -} - -/* - * Enable reception of PKTINFO control messages - */ -void -svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si) -{ - int val = 1; - - switch (si->si_af) { - case AF_INET: - (void) setsockopt(fd, SOL_IP, IP_PKTINFO, &val, sizeof(val)); - break; -#ifdef INET6 - case AF_INET6: - (void) setsockopt(fd, SOL_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); - break; -#endif - } -} - -/* - * When given a control message received from the socket - * layer, check whether it contains valid PKTINFO data matching - * the address family of the peer address. - */ -int -svc_dg_valid_pktinfo(struct msghdr *msg) -{ - struct cmsghdr *cmsg; - - if (!msg->msg_name) - return 0; - - if (msg->msg_flags & MSG_CTRUNC) - return 0; - - cmsg = CMSG_FIRSTHDR(msg); - if (cmsg == NULL || CMSG_NXTHDR(msg, cmsg) != NULL) - return 0; - - switch (((struct sockaddr *) msg->msg_name)->sa_family) { - case AF_INET: - if (cmsg->cmsg_level != SOL_IP - || cmsg->cmsg_type != IP_PKTINFO - || cmsg->cmsg_len < CMSG_LEN(sizeof (struct in_pktinfo))) { - return 0; - } else { - struct in_pktinfo *pkti; - - pkti = (struct in_pktinfo *) CMSG_DATA (cmsg); - pkti->ipi_ifindex = 0; - } - break; - -#ifdef INET6 - case AF_INET6: - if (cmsg->cmsg_level != SOL_IPV6 - || cmsg->cmsg_type != IPV6_PKTINFO - || cmsg->cmsg_len < CMSG_LEN(sizeof (struct in6_pktinfo))) { - return 0; - } else { - struct in6_pktinfo *pkti; - - pkti = (struct in6_pktinfo *) CMSG_DATA (cmsg); - pkti->ipi6_ifindex = 0; - } - break; -#endif - - default: - return 0; - } - - return 1; -} diff --git a/libtirpc-1.3.1/src/svc_generic.c b/libtirpc-1.3.1/src/svc_generic.c deleted file mode 100644 index 20abaa2..0000000 --- a/libtirpc-1.3.1/src/svc_generic.c +++ /dev/null @@ -1,299 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * svc_generic.c, Server side for RPC. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rpc_com.h" -#include - -extern int __svc_vc_setflag(SVCXPRT *, int); -extern int __binddynport(int fd); - -/* - * The highest level interface for server creation. - * It tries for all the nettokens in that particular class of token - * and returns the number of handles it can create and/or find. - * - * It creates a link list of all the handles it could create. - * If svc_create() is called multiple times, it uses the handle - * created earlier instead of creating a new handle every time. - */ -int -svc_create(dispatch, prognum, versnum, nettype) - void (*dispatch)(struct svc_req *, SVCXPRT *); - rpcprog_t prognum; /* Program number */ - rpcvers_t versnum; /* Version number */ - const char *nettype; /* Networktype token */ -{ - struct xlist { - SVCXPRT *xprt; /* Server handle */ - struct xlist *next; /* Next item */ - } *l; - static struct xlist *xprtlist; /* A link list of all the handles */ - int num = 0; - SVCXPRT *xprt; - struct netconfig *nconf; - void *handle; - extern mutex_t xprtlist_lock; - -/* VARIABLES PROTECTED BY xprtlist_lock: xprtlist */ - - if ((handle = __rpc_setconf(nettype)) == NULL) { - warnx("svc_create: unknown protocol"); - return (0); - } - while ((nconf = __rpc_getconf(handle)) != NULL) { - mutex_lock(&xprtlist_lock); - for (l = xprtlist; l; l = l->next) { - if (strcmp(l->xprt->xp_netid, nconf->nc_netid) == 0) { - /* Found an old one, use it */ - (void) rpcb_unset(prognum, versnum, nconf); - if (svc_reg(l->xprt, prognum, versnum, - dispatch, nconf) == FALSE) - warnx( - "svc_create: could not register prog %u vers %u on %s", - (unsigned)prognum, (unsigned)versnum, - nconf->nc_netid); - else - num++; - break; - } - } - if (l == NULL) { - /* It was not found. Now create a new one */ - xprt = svc_tp_create(dispatch, prognum, versnum, nconf); - if (xprt) { - l = (struct xlist *)malloc(sizeof (*l)); - if (l == NULL) { - warnx("svc_create: no memory"); - mutex_unlock(&xprtlist_lock); - __rpc_endconf(handle); - return (0); - } - l->xprt = xprt; - l->next = xprtlist; - xprtlist = l; - num++; - } - } - mutex_unlock(&xprtlist_lock); - } - __rpc_endconf(handle); - /* - * In case of num == 0; the error messages are generated by the - * underlying layers; and hence not needed here. - */ - return (num); -} - -/* - * The high level interface to svc_tli_create(). - * It tries to create a server for "nconf" and registers the service - * with the rpcbind. It calls svc_tli_create(); - */ -SVCXPRT * -svc_tp_create(dispatch, prognum, versnum, nconf) - void (*dispatch)(struct svc_req *, SVCXPRT *); - rpcprog_t prognum; /* Program number */ - rpcvers_t versnum; /* Version number */ - const struct netconfig *nconf; /* Netconfig structure for the network */ -{ - SVCXPRT *xprt; - - if (nconf == NULL) { - warnx( - "svc_tp_create: invalid netconfig structure for prog %u vers %u", - (unsigned)prognum, (unsigned)versnum); - return (NULL); - } - xprt = svc_tli_create(RPC_ANYFD, nconf, NULL, 0, 0); - if (xprt == NULL) { - return (NULL); - } - /*LINTED const castaway*/ - (void) rpcb_unset(prognum, versnum, (struct netconfig *) nconf); - if (svc_reg(xprt, prognum, versnum, dispatch, nconf) == FALSE) { - warnx( - "svc_tp_create: Could not register prog %u vers %u on %s", - (unsigned)prognum, (unsigned)versnum, - nconf->nc_netid); - SVC_DESTROY(xprt); - return (NULL); - } - return (xprt); -} - - /* - * If fd is RPC_ANYFD, then it opens a fd for the given transport - * provider (nconf cannot be NULL then). If the t_state is T_UNBND and - * bindaddr is NON-NULL, it performs a t_bind using the bindaddr. For - * NULL bindadr and Connection oriented transports, the value of qlen - * is set to 8. - * - * If sendsz or recvsz are zero, their default values are chosen. - */ -SVCXPRT * -svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz) - int fd; /* Connection end point */ - const struct netconfig *nconf; /* Netconfig struct for nettoken */ - const struct t_bind *bindaddr; /* Local bind address */ - u_int sendsz; /* Max sendsize */ - u_int recvsz; /* Max recvsize */ -{ - SVCXPRT *xprt = NULL; /* service handle */ - bool_t madefd = FALSE; /* whether fd opened here */ - struct __rpc_sockinfo si; - struct sockaddr_storage ss; - socklen_t slen; - - if (fd == RPC_ANYFD) { - if (nconf == NULL) { - warnx("svc_tli_create: invalid netconfig"); - return (NULL); - } - fd = __rpc_nconf2fd(nconf); - if (fd == -1) { - warnx( - "svc_tli_create: could not open connection for %s", - nconf->nc_netid); - return (NULL); - } - __rpc_nconf2sockinfo(nconf, &si); - madefd = TRUE; - } else { - /* - * It is an open descriptor. Get the transport info. - */ - if (!__rpc_fd2sockinfo(fd, &si)) { - warnx( - "svc_tli_create: could not get transport information"); - return (NULL); - } - } - - /* - * If the fd is unbound, try to bind it. - */ - if (madefd || !__rpc_sockisbound(fd)) { - if (bindaddr == NULL) { - if (__binddynport(fd) == -1) { - warnx( - "svc_tli_create: could not bind to anonymous port"); - goto freedata; - } - listen(fd, SOMAXCONN); - } else { - if (bind(fd, - (struct sockaddr *)bindaddr->addr.buf, - (socklen_t)si.si_alen) < 0) { - warnx( - "svc_tli_create: could not bind to requested address"); - goto freedata; - } - listen(fd, (int)bindaddr->qlen); - } - - } - /* - * call transport specific function. - */ - switch (si.si_socktype) { - case SOCK_STREAM: - slen = sizeof ss; - if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) - == 0) { - /* accepted socket */ - xprt = svc_fd_create(fd, sendsz, recvsz); - } else - xprt = svc_vc_create(fd, sendsz, recvsz); - if (!nconf || !xprt) - break; -#if 0 - /* XXX fvdl */ - if (strcmp(nconf->nc_protofmly, "inet") == 0 || - strcmp(nconf->nc_protofmly, "inet6") == 0) - (void) __svc_vc_setflag(xprt, TRUE); -#endif - break; - case SOCK_DGRAM: - xprt = svc_dg_create(fd, sendsz, recvsz); - break; - default: - warnx("svc_tli_create: bad service type"); - goto freedata; - } - - if (xprt == NULL) - /* - * The error messages here are spitted out by the lower layers: - * svc_vc_create(), svc_fd_create() and svc_dg_create(). - */ - goto freedata; - - /* Fill in type of service */ - xprt->xp_type = __rpc_socktype2seman(si.si_socktype); - - if (nconf) { - if (xprt->xp_netid != NULL) - free(xprt->xp_netid); - xprt->xp_netid = strdup(nconf->nc_netid); - xprt->xp_tp = strdup(nconf->nc_device); - } - return (xprt); - -freedata: - if (madefd) - (void)close(fd); - if (xprt) { - if (!madefd) /* so that svc_destroy doesnt close fd */ - xprt->xp_fd = RPC_ANYFD; - SVC_DESTROY(xprt); - } - return (NULL); -} diff --git a/libtirpc-1.3.1/src/svc_raw.c b/libtirpc-1.3.1/src/svc_raw.c deleted file mode 100644 index a8a396f..0000000 --- a/libtirpc-1.3.1/src/svc_raw.c +++ /dev/null @@ -1,256 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - -/* - * svc_raw.c, This a toy for simple testing and timing. - * Interface to create an rpc client and server in the same UNIX process. - * This lets us similate rpc and get rpc (round trip) overhead, without - * any interference from the kernel. - * - */ -#include -#include -#include -#include -#include -#include - -#ifndef UDPMSGSIZE -#define UDPMSGSIZE 8800 -#endif - -/* - * This is the "network" that we will be moving data over - */ -static struct svc_raw_private { - char *raw_buf; /* should be shared with the cl handle */ - SVCXPRT server; - XDR xdr_stream; - char verf_body[MAX_AUTH_BYTES]; -} *svc_raw_private; - -extern mutex_t svcraw_lock; - -static enum xprt_stat svc_raw_stat(SVCXPRT *); -static bool_t svc_raw_recv(SVCXPRT *, struct rpc_msg *); -static bool_t svc_raw_reply(SVCXPRT *, struct rpc_msg *); -static bool_t svc_raw_getargs(SVCXPRT *, xdrproc_t, void *); -static bool_t svc_raw_freeargs(SVCXPRT *, xdrproc_t, void *); -static void svc_raw_destroy(SVCXPRT *); -static void svc_raw_ops(SVCXPRT *); -static bool_t svc_raw_control(SVCXPRT *, const u_int, void *); - -char *__rpc_rawcombuf = NULL; - -SVCXPRT * -svc_raw_create() -{ - struct svc_raw_private *srp; - SVCXPRT_EXT *ext = NULL; -/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */ - - mutex_lock(&svcraw_lock); - srp = svc_raw_private; - if (srp == NULL) { - srp = (struct svc_raw_private *)calloc(1, sizeof (*srp)); - if (srp == NULL) { - mutex_unlock(&svcraw_lock); - return (NULL); - } - ext = mem_alloc(sizeof (*ext)); - if (ext == NULL) { - free(srp); - mutex_unlock(&svcraw_lock); - return (NULL); - } - memset(ext, 0, sizeof (*ext)); - srp->server.xp_p3 = ext; - if (__rpc_rawcombuf == NULL) - __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char)); - srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */ - svc_raw_private = srp; - } - srp->server.xp_fd = FD_SETSIZE; - srp->server.xp_port = 0; - svc_flags(&srp->server) = 0; - svc_raw_ops(&srp->server); - srp->server.xp_verf.oa_base = srp->verf_body; - xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE); - xprt_register(&srp->server); - mutex_unlock(&svcraw_lock); - return (&srp->server); -} - -/*ARGSUSED*/ -static enum xprt_stat -svc_raw_stat(xprt) -SVCXPRT *xprt; /* args needed to satisfy ANSI-C typechecking */ -{ - return (XPRT_IDLE); -} - -/*ARGSUSED*/ -static bool_t -svc_raw_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct svc_raw_private *srp; - XDR *xdrs; - - mutex_lock(&svcraw_lock); - srp = svc_raw_private; - if (srp == NULL) { - mutex_unlock(&svcraw_lock); - return (FALSE); - } - mutex_unlock(&svcraw_lock); - - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_DECODE; - (void) XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) { - return (FALSE); - } - return (TRUE); -} - -/*ARGSUSED*/ -static bool_t -svc_raw_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct svc_raw_private *srp; - XDR *xdrs; - - mutex_lock(&svcraw_lock); - srp = svc_raw_private; - if (srp == NULL) { - mutex_unlock(&svcraw_lock); - return (FALSE); - } - mutex_unlock(&svcraw_lock); - - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_ENCODE; - (void) XDR_SETPOS(xdrs, 0); - if (! xdr_replymsg(xdrs, msg)) { - return (FALSE); - } - (void) XDR_GETPOS(xdrs); /* called just for overhead */ - return (TRUE); -} - -/*ARGSUSED*/ -static bool_t -svc_raw_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - struct svc_raw_private *srp; - - mutex_lock(&svcraw_lock); - srp = svc_raw_private; - if (srp == NULL) { - mutex_unlock(&svcraw_lock); - return (FALSE); - } - mutex_unlock(&svcraw_lock); - return (*xdr_args)(&srp->xdr_stream, args_ptr); -} - -/*ARGSUSED*/ -static bool_t -svc_raw_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - struct svc_raw_private *srp; - XDR *xdrs; - - mutex_lock(&svcraw_lock); - srp = svc_raw_private; - if (srp == NULL) { - mutex_unlock(&svcraw_lock); - return (FALSE); - } - mutex_unlock(&svcraw_lock); - - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_FREE; - return (*xdr_args)(xdrs, args_ptr); -} - -/*ARGSUSED*/ -static void -svc_raw_destroy(xprt) -SVCXPRT *xprt; -{ -} - -/*ARGSUSED*/ -static bool_t -svc_raw_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; -{ - return (FALSE); -} - -static void -svc_raw_ops(xprt) - SVCXPRT *xprt; -{ - static struct xp_ops ops; - static struct xp_ops2 ops2; - extern mutex_t ops_lock; - -/* VARIABLES PROTECTED BY ops_lock: ops */ - - mutex_lock(&ops_lock); - if (ops.xp_recv == NULL) { - ops.xp_recv = svc_raw_recv; - ops.xp_stat = svc_raw_stat; - ops.xp_getargs = svc_raw_getargs; - ops.xp_reply = svc_raw_reply; - ops.xp_freeargs = svc_raw_freeargs; - ops.xp_destroy = svc_raw_destroy; - ops2.xp_control = svc_raw_control; - } - xprt->xp_ops = &ops; - xprt->xp_ops2 = &ops2; - mutex_unlock(&ops_lock); -} diff --git a/libtirpc-1.3.1/src/svc_run.c b/libtirpc-1.3.1/src/svc_run.c deleted file mode 100644 index f40314b..0000000 --- a/libtirpc-1.3.1/src/svc_run.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This is the rpc server side idle loop - * Wait for input, call server program. - */ -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include "rpc_com.h" -#include - -void -svc_run() -{ - int i; - struct pollfd *my_pollfd = NULL; - int last_max_pollfd = 0; - - for (;;) { - int max_pollfd = svc_max_pollfd; - if (max_pollfd == 0 && svc_pollfd == NULL) - break; - - if (last_max_pollfd != max_pollfd) - { - struct pollfd *new_pollfd - = realloc (my_pollfd, sizeof (struct pollfd) * max_pollfd); - - if (new_pollfd == NULL) - { - warn ("svc_run: - out of memory"); - break; - } - - my_pollfd = new_pollfd; - last_max_pollfd = max_pollfd; - } - - for (i = 0; i < max_pollfd; ++i) - { - my_pollfd[i].fd = svc_pollfd[i].fd; - my_pollfd[i].events = svc_pollfd[i].events; - my_pollfd[i].revents = 0; - } - - switch (i = poll (my_pollfd, max_pollfd, -1)) - { - case -1: - if (errno == EINTR) - continue; - warn ("svc_run: - poll failed"); - break; - case 0: - continue; - default: - svc_getreq_poll (my_pollfd, i); - continue; - } - break; - } - - free (my_pollfd); -} - -/* - * This function causes svc_run() to exit by telling it that it has no - * more work to do. - */ -void -svc_exit() -{ - extern rwlock_t svc_fd_lock; - - rwlock_wrlock(&svc_fd_lock); - free (svc_pollfd); - svc_pollfd = NULL; - svc_max_pollfd = 0; - rwlock_unlock(&svc_fd_lock); -} diff --git a/libtirpc-1.3.1/src/svc_simple.c b/libtirpc-1.3.1/src/svc_simple.c deleted file mode 100644 index c32fe0a..0000000 --- a/libtirpc-1.3.1/src/svc_simple.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - -/* - * svc_simple.c - * Simplified front end to rpc. - */ - -/* - * This interface creates a virtual listener for all the services - * started thru rpc_reg(). It listens on the same endpoint for - * all the services and then executes the corresponding service - * for the given prognum and procnum. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rpc_com.h" - -static void universal(struct svc_req *, SVCXPRT *); - -static struct proglst { - char *(*p_progname)(char *); - rpcprog_t p_prognum; - rpcvers_t p_versnum; - rpcproc_t p_procnum; - SVCXPRT *p_transp; - char *p_netid; - char *p_xdrbuf; - int p_recvsz; - xdrproc_t p_inproc, p_outproc; - struct proglst *p_nxt; -} *proglst; - -static const char rpc_reg_err[] = "%s: %s"; -static const char rpc_reg_msg[] = "rpc_reg: "; -static const char __reg_err1[] = "can't find appropriate transport"; -static const char __reg_err2[] = "can't get protocol info"; -static const char __reg_err3[] = "unsupported transport size"; -static const char __no_mem_str[] = "out of memory"; - -/* - * For simplified, easy to use kind of rpc interfaces. - * nettype indicates the type of transport on which the service will be - * listening. Used for conservation of the system resource. Only one - * handle is created for all the services (actually one of each netid) - * and same xdrbuf is used for same netid. The size of the arguments - * is also limited by the recvsize for that transport, even if it is - * a COTS transport. This may be wrong, but for cases like these, they - * should not use the simplified interfaces like this. - */ - -int -rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype) - rpcprog_t prognum; /* program number */ - rpcvers_t versnum; /* version number */ - rpcproc_t procnum; /* procedure number */ - char *(*progname)(char *); /* Server routine */ - xdrproc_t inproc, outproc; /* in/out XDR procedures */ - char *nettype; /* nettype */ -{ - struct netconfig *nconf; - int done = FALSE; - void *handle; - extern mutex_t proglst_lock; - - if (procnum == NULLPROC) { - warnx("%s can't reassign procedure number %u", rpc_reg_msg, - NULLPROC); - return (-1); - } - - if (nettype == NULL) - nettype = "netpath"; /* The default behavior */ - if ((handle = __rpc_setconf(nettype)) == NULL) { - warnx(rpc_reg_err, rpc_reg_msg, __reg_err1); - return (-1); - } -/* VARIABLES PROTECTED BY proglst_lock: proglst */ - mutex_lock(&proglst_lock); - while ((nconf = __rpc_getconf(handle)) != NULL) { - struct proglst *pl; - SVCXPRT *svcxprt; - int madenow; - u_int recvsz; - char *xdrbuf; - char *netid; - - madenow = FALSE; - svcxprt = NULL; - recvsz = 0; - xdrbuf = netid = NULL; - for (pl = proglst; pl; pl = pl->p_nxt) { - if (strcmp(pl->p_netid, nconf->nc_netid) == 0) { - svcxprt = pl->p_transp; - xdrbuf = pl->p_xdrbuf; - recvsz = pl->p_recvsz; - netid = pl->p_netid; - break; - } - } - - if (svcxprt == NULL) { - struct __rpc_sockinfo si; - - svcxprt = svc_tli_create(RPC_ANYFD, nconf, NULL, 0, 0); - if (svcxprt == NULL) - continue; - if (!__rpc_fd2sockinfo(svcxprt->xp_fd, &si)) { - warnx(rpc_reg_err, rpc_reg_msg, __reg_err2); - SVC_DESTROY(svcxprt); - continue; - } - recvsz = __rpc_get_t_size(si.si_af, si.si_proto, 0); - if (recvsz == 0) { - warnx(rpc_reg_err, rpc_reg_msg, __reg_err3); - SVC_DESTROY(svcxprt); - continue; - } - if (((xdrbuf = malloc((unsigned)recvsz)) == NULL) || - ((netid = strdup(nconf->nc_netid)) == NULL)) { - warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str); - SVC_DESTROY(svcxprt); - free(xdrbuf); - break; - } - madenow = TRUE; - } - /* - * Check if this (program, version, netid) had already been - * registered. The check may save a few RPC calls to rpcbind - */ - for (pl = proglst; pl; pl = pl->p_nxt) - if ((pl->p_prognum == prognum) && - (pl->p_versnum == versnum) && - (strcmp(pl->p_netid, netid) == 0)) - break; - if (pl == NULL) { /* Not yet */ - (void) rpcb_unset(prognum, versnum, nconf); - } else { - /* so that svc_reg does not call rpcb_set() */ - nconf = NULL; - } - - if (!svc_reg(svcxprt, prognum, versnum, universal, nconf)) { - warnx("%s couldn't register prog %u vers %u for %s", - rpc_reg_msg, (unsigned)prognum, - (unsigned)versnum, netid); - if (madenow) { - SVC_DESTROY(svcxprt); - free(xdrbuf); - free(netid); - } - continue; - } - - pl = malloc(sizeof (struct proglst)); - if (pl == NULL) { - warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str); - if (madenow) { - SVC_DESTROY(svcxprt); - free(xdrbuf); - free(netid); - } - break; - } - pl->p_progname = progname; - pl->p_prognum = prognum; - pl->p_versnum = versnum; - pl->p_procnum = procnum; - pl->p_inproc = inproc; - pl->p_outproc = outproc; - pl->p_transp = svcxprt; - pl->p_xdrbuf = xdrbuf; - pl->p_recvsz = recvsz; - pl->p_netid = netid; - pl->p_nxt = proglst; - proglst = pl; - done = TRUE; - } - __rpc_endconf(handle); - mutex_unlock(&proglst_lock); - - if (done == FALSE) { - warnx("%s cant find suitable transport for %s", - rpc_reg_msg, nettype); - return (-1); - } - return (0); -} - -/* - * The universal handler for the services registered using registerrpc. - * It handles both the connectionless and the connection oriented cases. - */ - -static void -universal(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - char *outdata; - char *xdrbuf; - struct proglst *pl; - extern mutex_t proglst_lock; - - /* - * enforce "procnum 0 is echo" convention - */ - if (rqstp->rq_proc == NULLPROC) { - if (svc_sendreply(transp, (xdrproc_t) xdr_void, NULL) == - FALSE) { - warnx("svc_sendreply failed"); - } - return; - } - prog = rqstp->rq_prog; - vers = rqstp->rq_vers; - proc = rqstp->rq_proc; - mutex_lock(&proglst_lock); - for (pl = proglst; pl; pl = pl->p_nxt) - if (pl->p_prognum == prog && pl->p_procnum == proc && - pl->p_versnum == vers && - (strcmp(pl->p_netid, transp->xp_netid) == 0)) { - /* decode arguments into a CLEAN buffer */ - xdrbuf = pl->p_xdrbuf; - /* Zero the arguments: reqd ! */ - (void) memset(xdrbuf, 0, sizeof (pl->p_recvsz)); - /* - * Assuming that sizeof (xdrbuf) would be enough - * for the arguments; if not then the program - * may bomb. BEWARE! - */ - if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) { - svcerr_decode(transp); - mutex_unlock(&proglst_lock); - return; - } - outdata = (*(pl->p_progname))(xdrbuf); - if (outdata == NULL && - pl->p_outproc != (xdrproc_t) xdr_void){ - /* there was an error */ - mutex_unlock(&proglst_lock); - return; - } - if (!svc_sendreply(transp, pl->p_outproc, outdata)) { - warnx( - "rpc: rpc_reg trouble replying to prog %u vers %u", - (unsigned)prog, (unsigned)vers); - mutex_unlock(&proglst_lock); - return; - } - /* free the decoded arguments */ - (void)svc_freeargs(transp, pl->p_inproc, xdrbuf); - mutex_unlock(&proglst_lock); - return; - } - mutex_unlock(&proglst_lock); - /* This should never happen */ - warnx("rpc: rpc_reg: never registered prog %u vers %u", - (unsigned)prog, (unsigned)vers); - return; -} diff --git a/libtirpc-1.3.1/src/svc_vc.c b/libtirpc-1.3.1/src/svc_vc.c deleted file mode 100644 index f1d9f00..0000000 --- a/libtirpc-1.3.1/src/svc_vc.c +++ /dev/null @@ -1,822 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * svc_vc.c, Server side for Connection Oriented based RPC. - * - * Actually implements two flavors of transporter - - * a tcp rendezvouser (a listner and connection establisher) - * and a record/tcp stream. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "rpc_com.h" - -#include - - -extern rwlock_t svc_fd_lock; - -static SVCXPRT *makefd_xprt(int, u_int, u_int); -static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *); -static enum xprt_stat rendezvous_stat(SVCXPRT *); -static void svc_vc_destroy(SVCXPRT *); -static void __svc_vc_dodestroy (SVCXPRT *); -static int read_vc(void *, void *, int); -static int write_vc(void *, void *, int); -static enum xprt_stat svc_vc_stat(SVCXPRT *); -static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *); -static bool_t svc_vc_getargs(SVCXPRT *, xdrproc_t, void *); -static bool_t svc_vc_freeargs(SVCXPRT *, xdrproc_t, void *); -static bool_t svc_vc_reply(SVCXPRT *, struct rpc_msg *); -static void svc_vc_rendezvous_ops(SVCXPRT *); -static void svc_vc_ops(SVCXPRT *); -static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in); -static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq, - void *in); - -struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */ - u_int sendsize; - u_int recvsize; - int maxrec; -}; - -struct cf_conn { /* kept in xprt->xp_p1 for actual connection */ - enum xprt_stat strm_stat; - u_int32_t x_id; - XDR xdrs; - char verf_body[MAX_AUTH_BYTES]; - u_int sendsize; - u_int recvsize; - int maxrec; - bool_t nonblock; - struct timeval last_recv_time; -}; - -/* - * This is used to set xprt->xp_raddr in a way legacy - * apps can deal with - */ -void -__xprt_set_raddr(SVCXPRT *xprt, const struct sockaddr_storage *ss) -{ - switch (ss->ss_family) { - case AF_INET6: - memcpy(&xprt->xp_raddr, ss, sizeof(struct sockaddr_in6)); - xprt->xp_addrlen = sizeof (struct sockaddr_in6); - break; - case AF_INET: - memcpy(&xprt->xp_raddr, ss, sizeof(struct sockaddr_in)); - xprt->xp_addrlen = sizeof (struct sockaddr_in); - break; - default: - xprt->xp_raddr.sin6_family = AF_UNSPEC; - xprt->xp_addrlen = sizeof (struct sockaddr); - break; - } -} - -/* - * Usage: - * xprt = svc_vc_create(sock, send_buf_size, recv_buf_size); - * - * Creates, registers, and returns a (rpc) tcp based transporter. - * Once *xprt is initialized, it is registered as a transporter - * see (svc.h, xprt_register). This routine returns - * a NULL if a problem occurred. - * - * The filedescriptor passed in is expected to refer to a bound, but - * not yet connected socket. - * - * Since streams do buffered io similar to stdio, the caller can specify - * how big the send and receive buffers are via the second and third parms; - * 0 => use the system default. - */ -SVCXPRT * -svc_vc_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - SVCXPRT *xprt = NULL; - SVCXPRT_EXT *ext = NULL; - struct cf_rendezvous *r = NULL; - struct __rpc_sockinfo si; - struct sockaddr_storage sslocal; - socklen_t slen; - - r = mem_alloc(sizeof(*r)); - if (r == NULL) { - warnx("svc_vc_create: out of memory"); - goto cleanup_svc_vc_create; - } - if (!__rpc_fd2sockinfo(fd, &si)) { - warnx("svc_vc_create: __rpc_fd2sockinfo failed"); - goto cleanup_svc_vc_create; - } - r->sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize); - r->recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize); - r->maxrec = __svc_maxrec; - xprt = mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - warnx("svc_vc_create: out of memory"); - goto cleanup_svc_vc_create; - } - ext = mem_alloc(sizeof (*ext)); - if (ext == NULL) { - warnx("svc_vc_create: out of memory"); - goto cleanup_svc_vc_create; - } - memset(ext, 0, sizeof (*ext)); - xprt->xp_tp = NULL; - xprt->xp_p1 = r; - xprt->xp_p2 = NULL; - xprt->xp_p3 = ext; - xprt->xp_verf = _null_auth; - svc_vc_rendezvous_ops(xprt); - xprt->xp_port = (u_short)-1; /* It is the rendezvouser */ - xprt->xp_fd = fd; - - slen = sizeof (struct sockaddr_storage); - if (getsockname(fd, (struct sockaddr *)(void *)&sslocal, &slen) < 0) { - warnx("svc_vc_create: could not retrieve local addr"); - goto cleanup_svc_vc_create; - } - - if (!__rpc_set_netbuf(&xprt->xp_ltaddr, &sslocal, sizeof(sslocal))) { - warnx("svc_vc_create: no mem for local addr"); - goto cleanup_svc_vc_create; - } - xprt_register(xprt); - return (xprt); -cleanup_svc_vc_create: - if (r != NULL) - mem_free(r, sizeof(*r)); - if (xprt != NULL) - mem_free(xprt, sizeof(*xprt)); - if (ext != NULL) - mem_free(ext, sizeof(*ext)); - return (NULL); -} - -/* - * Like svtcp_create(), except the routine takes any *open* UNIX file - * descriptor as its first input. - */ -SVCXPRT * -svc_fd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - struct sockaddr_storage ss; - socklen_t slen; - SVCXPRT *ret; - - assert(fd != -1); - - ret = makefd_xprt(fd, sendsize, recvsize); - if (ret == NULL) - return NULL; - - slen = sizeof (struct sockaddr_storage); - if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) { - warnx("svc_fd_create: could not retrieve local addr"); - goto freedata; - } - if (!__rpc_set_netbuf(&ret->xp_ltaddr, &ss, sizeof(ss))) { - warnx("svc_fd_create: no mem for local addr"); - goto freedata; - } - - slen = sizeof (struct sockaddr_storage); - if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) { - warnx("svc_fd_create: could not retrieve remote addr"); - goto freedata; - } - if (!__rpc_set_netbuf(&ret->xp_rtaddr, &ss, sizeof(ss))) { - warnx("svc_fd_create: no mem for remote addr"); - goto freedata; - } - - /* Set xp_raddr for compatibility */ - __xprt_set_raddr(ret, &ss); - - return ret; - -freedata: - if (ret->xp_ltaddr.buf != NULL) { - mem_free(ret->xp_ltaddr.buf, rep->xp_ltaddr.maxlen); - ret->xp_ltaddr.buf = NULL; - } - return NULL; -} - -static SVCXPRT * -makefd_xprt(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - SVCXPRT *xprt; - SVCXPRT_EXT *ext; - struct cf_conn *cd; - const char *netid; - struct __rpc_sockinfo si; - - assert(fd != -1); - - xprt = mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - warnx("svc_vc: makefd_xprt: out of memory"); - goto done; - } - memset(xprt, 0, sizeof *xprt); - ext = mem_alloc(sizeof (*ext)); - if (ext == NULL) { - warnx("svc_vc: makefd_xprt: out of memory"); - mem_free(xprt, sizeof(SVCXPRT)); - xprt = NULL; - goto done; - } - memset(ext, 0, sizeof (*ext)); - cd = mem_alloc(sizeof(struct cf_conn)); - if (cd == NULL) { - warnx("svc_vc: makefd_xprt: out of memory"); - mem_free(ext, sizeof(*ext)); - mem_free(xprt, sizeof(SVCXPRT)); - xprt = NULL; - goto done; - } - cd->strm_stat = XPRT_IDLE; - xdrrec_create(&(cd->xdrs), sendsize, recvsize, - xprt, read_vc, write_vc); - xprt->xp_p1 = cd; - xprt->xp_p3 = ext; - xprt->xp_verf.oa_base = cd->verf_body; - svc_vc_ops(xprt); /* truely deals with calls */ - xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ - xprt->xp_fd = fd; - if (__rpc_fd2sockinfo(fd, &si) && __rpc_sockinfo2netid(&si, &netid)) - xprt->xp_netid = strdup(netid); - - xprt_register(xprt); -done: - return (xprt); -} - -/*ARGSUSED*/ -static bool_t -rendezvous_request(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - int sock, flags; - struct cf_rendezvous *r; - struct cf_conn *cd; - struct sockaddr_storage addr; - socklen_t len; - struct __rpc_sockinfo si; - SVCXPRT *newxprt; - - assert(xprt != NULL); - assert(msg != NULL); - - r = (struct cf_rendezvous *)xprt->xp_p1; -again: - len = sizeof addr; - sock = accept(xprt->xp_fd, (struct sockaddr *)(void *)&addr, &len); - if (sock < 0) { - if (errno == EINTR) - goto again; - return (FALSE); - } - /* - * make a new transporter (re-uses xprt) - */ - - newxprt = makefd_xprt(sock, r->sendsize, r->recvsize); - if (!newxprt) - return (FALSE); - - if (!__rpc_set_netbuf(&newxprt->xp_rtaddr, &addr, len)) - return (FALSE); - - __xprt_set_raddr(newxprt, &addr); - - if (__rpc_fd2sockinfo(sock, &si) && si.si_proto == IPPROTO_TCP) { - len = 1; - /* XXX fvdl - is this useful? */ - setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &len, sizeof (len)); - } - - cd = (struct cf_conn *)newxprt->xp_p1; - - cd->recvsize = r->recvsize; - cd->sendsize = r->sendsize; - cd->maxrec = r->maxrec; - - if (cd->maxrec != 0) { - flags = fcntl(sock, F_GETFL, 0); - if (flags == -1) - return (FALSE); - if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) - return (FALSE); - if (cd->recvsize > cd->maxrec) - cd->recvsize = cd->maxrec; - cd->nonblock = TRUE; - __xdrrec_setnonblock(&cd->xdrs, cd->maxrec); - } else - cd->nonblock = FALSE; - - gettimeofday(&cd->last_recv_time, NULL); - - return (FALSE); /* there is never an rpc msg to be processed */ -} - -/*ARGSUSED*/ -static enum xprt_stat -rendezvous_stat(xprt) - SVCXPRT *xprt; -{ - - return (XPRT_IDLE); -} - -static void -svc_vc_destroy(xprt) - SVCXPRT *xprt; -{ - assert(xprt != NULL); - - xprt_unregister(xprt); - __svc_vc_dodestroy(xprt); -} - -static bool_t -__svc_rendezvous_socket(xprt) - SVCXPRT *xprt; -{ - return (xprt->xp_ops->xp_recv == rendezvous_request); -} -static void -__svc_vc_dodestroy(xprt) - SVCXPRT *xprt; -{ - SVCXPRT_EXT *ext = SVCEXT(xprt); - struct cf_conn *cd; - struct cf_rendezvous *r; - - cd = (struct cf_conn *)xprt->xp_p1; - - if (xprt->xp_fd != RPC_ANYFD) - (void)close(xprt->xp_fd); - if (__svc_rendezvous_socket(xprt)) { - /* a rendezvouser socket */ - r = (struct cf_rendezvous *)xprt->xp_p1; - mem_free(r, sizeof (struct cf_rendezvous)); - xprt->xp_port = 0; - } else { - /* an actual connection socket */ - XDR_DESTROY(&(cd->xdrs)); - mem_free(cd, sizeof(struct cf_conn)); - } - if (ext) - mem_free(ext, sizeof (*ext)); - if (xprt->xp_rtaddr.buf) - mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen); - if (xprt->xp_ltaddr.buf) - mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen); - if (xprt->xp_tp) - free(xprt->xp_tp); - if (xprt->xp_netid) - free(xprt->xp_netid); - mem_free(xprt, sizeof(SVCXPRT)); -} - -/*ARGSUSED*/ -static bool_t -svc_vc_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; -{ - return (FALSE); -} - -static bool_t -svc_vc_rendezvous_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; -{ - struct cf_rendezvous *cfp; - - cfp = (struct cf_rendezvous *)xprt->xp_p1; - if (cfp == NULL) - return (FALSE); - switch (rq) { - case SVCGET_CONNMAXREC: - *(int *)in = cfp->maxrec; - break; - case SVCSET_CONNMAXREC: - cfp->maxrec = *(int *)in; - break; - default: - return (FALSE); - } - return (TRUE); -} - -/* - * reads data from the tcp or uip connection. - * any error is fatal and the connection is closed. - * (And a read of zero bytes is a half closed stream => error.) - * All read operations timeout after 35 seconds. A timeout is - * fatal for the connection. - */ -static int -read_vc(xprtp, buf, len) - void *xprtp; - void *buf; - int len; -{ - SVCXPRT *xprt; - int sock; - int milliseconds = 35 * 1000; - struct pollfd pollfd; - struct cf_conn *cfp; - - xprt = (SVCXPRT *)xprtp; - assert(xprt != NULL); - - sock = xprt->xp_fd; - - cfp = (struct cf_conn *)xprt->xp_p1; - - if (cfp->nonblock) { - /* Since len == 0 is returned on zero length - * read or EOF errno needs to be reset before - * the read - */ - errno = 0; - len = read(sock, buf, (size_t)len); - if (len < 0) { - if (errno == EAGAIN || errno == EWOULDBLOCK) - len = 0; - else - goto fatal_err; - } - if (len != 0) - gettimeofday(&cfp->last_recv_time, NULL); - return len; - } - - do { - pollfd.fd = sock; - pollfd.events = POLLIN; - pollfd.revents = 0; - switch (poll(&pollfd, 1, milliseconds)) { - case -1: - if (errno == EINTR) - continue; - /*FALLTHROUGH*/ - case 0: - goto fatal_err; - - default: - break; - } - } while ((pollfd.revents & POLLIN) == 0); - - if ((len = read(sock, buf, (size_t)len)) > 0) { - gettimeofday(&cfp->last_recv_time, NULL); - return (len); - } - -fatal_err: - ((struct cf_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; - return (-1); -} - -/* - * writes data to the tcp connection. - * Any error is fatal and the connection is closed. - */ -static int -write_vc(xprtp, buf, len) - void *xprtp; - void *buf; - int len; -{ - SVCXPRT *xprt; - int i, cnt; - struct cf_conn *cd; - struct timeval tv0, tv1; - - xprt = (SVCXPRT *)xprtp; - assert(xprt != NULL); - - cd = (struct cf_conn *)xprt->xp_p1; - - if (cd->nonblock) - gettimeofday(&tv0, NULL); - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - i = write(xprt->xp_fd, buf, (size_t)cnt); - if (i < 0) { - if (errno != EAGAIN || !cd->nonblock) { - cd->strm_stat = XPRT_DIED; - return (-1); - } - /* - * For non-blocking connections, do not - * take more than 2 seconds writing the - * data out. - * - * XXX 2 is an arbitrary amount. - */ - gettimeofday(&tv1, NULL); - if (tv1.tv_sec - tv0.tv_sec >= 2) { - cd->strm_stat = XPRT_DIED; - return (-1); - } - i = 0; /* Don't change buf and cnt */ - } - } - - return (len); -} - -static enum xprt_stat -svc_vc_stat(xprt) - SVCXPRT *xprt; -{ - struct cf_conn *cd; - - assert(xprt != NULL); - - cd = (struct cf_conn *)(xprt->xp_p1); - - if (cd->strm_stat == XPRT_DIED) - return (XPRT_DIED); - if (! xdrrec_eof(&(cd->xdrs))) - return (XPRT_MOREREQS); - return (XPRT_IDLE); -} - -static bool_t -svc_vc_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct cf_conn *cd; - XDR *xdrs; - - assert(xprt != NULL); - assert(msg != NULL); - - cd = (struct cf_conn *)(xprt->xp_p1); - xdrs = &(cd->xdrs); - - if (cd->nonblock) { - if (!__xdrrec_getrec(xdrs, &cd->strm_stat, TRUE)) - return FALSE; - } - - xdrs->x_op = XDR_DECODE; - /* - * No need skip records with nonblocking connections - */ - if (cd->nonblock == FALSE) - (void)xdrrec_skiprecord(xdrs); - if (xdr_callmsg(xdrs, msg)) { - cd->x_id = msg->rm_xid; - return (TRUE); - } - cd->strm_stat = XPRT_DIED; - return (FALSE); -} - -static bool_t -svc_vc_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - - assert(xprt != NULL); - /* args_ptr may be NULL */ - - if (!SVCAUTH_UNWRAP(&SVC_XP_AUTH(xprt), - &(((struct cf_conn *)(xprt->xp_p1))->xdrs), - xdr_args, args_ptr)) { - return FALSE; - } - return TRUE; -} - -static bool_t -svc_vc_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; -{ - XDR *xdrs; - - assert(xprt != NULL); - /* args_ptr may be NULL */ - - xdrs = &(((struct cf_conn *)(xprt->xp_p1))->xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static bool_t -svc_vc_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - struct cf_conn *cd; - XDR *xdrs; - bool_t rstat; - - xdrproc_t xdr_results; - caddr_t xdr_location; - bool_t has_args; - - assert(xprt != NULL); - assert(msg != NULL); - - cd = (struct cf_conn *)(xprt->xp_p1); - xdrs = &(cd->xdrs); - - if (msg->rm_reply.rp_stat == MSG_ACCEPTED && - msg->rm_reply.rp_acpt.ar_stat == SUCCESS) { - has_args = TRUE; - xdr_results = msg->acpted_rply.ar_results.proc; - xdr_location = msg->acpted_rply.ar_results.where; - - msg->acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - msg->acpted_rply.ar_results.where = NULL; - } else - has_args = FALSE; - - xdrs->x_op = XDR_ENCODE; - msg->rm_xid = cd->x_id; - rstat = FALSE; - if (xdr_replymsg(xdrs, msg) && - (!has_args || - SVCAUTH_WRAP(&SVC_XP_AUTH(xprt), - xdrs, xdr_results, xdr_location))) { - rstat = TRUE; - } - (void)xdrrec_endofrecord(xdrs, TRUE); - return (rstat); -} - -static void -svc_vc_ops(xprt) - SVCXPRT *xprt; -{ - static struct xp_ops ops; - static struct xp_ops2 ops2; - extern mutex_t ops_lock; - -/* VARIABLES PROTECTED BY ops_lock: ops, ops2 */ - - mutex_lock(&ops_lock); - if (ops.xp_recv == NULL) { - ops.xp_recv = svc_vc_recv; - ops.xp_stat = svc_vc_stat; - ops.xp_getargs = svc_vc_getargs; - ops.xp_reply = svc_vc_reply; - ops.xp_freeargs = svc_vc_freeargs; - ops.xp_destroy = svc_vc_destroy; - ops2.xp_control = svc_vc_control; - } - xprt->xp_ops = &ops; - xprt->xp_ops2 = &ops2; - mutex_unlock(&ops_lock); -} - -static void -svc_vc_rendezvous_ops(xprt) - SVCXPRT *xprt; -{ - static struct xp_ops ops; - static struct xp_ops2 ops2; - extern mutex_t ops_lock; - - mutex_lock(&ops_lock); - if (ops.xp_recv == NULL) { - ops.xp_recv = rendezvous_request; - ops.xp_stat = rendezvous_stat; - ops.xp_getargs = - (bool_t (*)(SVCXPRT *, xdrproc_t, void *))abort; - ops.xp_reply = - (bool_t (*)(SVCXPRT *, struct rpc_msg *))abort; - ops.xp_freeargs = - (bool_t (*)(SVCXPRT *, xdrproc_t, void *))abort, - ops.xp_destroy = svc_vc_destroy; - ops2.xp_control = svc_vc_rendezvous_control; - } - xprt->xp_ops = &ops; - xprt->xp_ops2 = &ops2; - mutex_unlock(&ops_lock); -} - -/* - * Get the effective UID of the sending process. Used by rpcbind, keyserv - * and rpc.yppasswdd on AF_LOCAL. - */ -int -__rpc_get_local_uid(SVCXPRT *transp, uid_t *uid) { - int sock, ret; - gid_t egid; - uid_t euid; - struct sockaddr *sa; - - sock = transp->xp_fd; - sa = (struct sockaddr *)transp->xp_rtaddr.buf; - if (sa->sa_family == AF_LOCAL) { - ret = getpeereid(sock, &euid, &egid); - if (ret == 0) - *uid = euid; - return (ret); - } else - return (-1); -} - -/* - * Destroy xprts that have not have had any activity in 'timeout' seconds. - * If 'cleanblock' is true, blocking connections (the default) are also - * cleaned. If timeout is 0, the least active connection is picked. - * - * Though this is not a publicly documented interface, some versions of - * rpcbind are known to call this function. Do not alter or remove this - * API without changing the library's sonum. - */ -/* Since this is an exported interface used by rpcbind, we cannot - remove it. But since poll() can handle much more and much higher - file descriptors, this code doesn't really work anymore, too. - So for now, keep it as dummy function and do nothing to not break - existing binaries. If we have ported rpcbind to the poll() interface - and find out, that we really need this cleanup stuff (but nobody - besides FreeBSD has this), we need to re-implement it using poll(). - But this means a new function name with different parameters. For - ABI/API compatibility, we cannot reuse this one. */ -bool_t -__svc_clean_idle(fd_set *fds, int timeout, bool_t cleanblock) -{ - return FALSE; -} diff --git a/libtirpc-1.3.1/src/xdr.c b/libtirpc-1.3.1/src/xdr.c deleted file mode 100644 index 28d1382..0000000 --- a/libtirpc-1.3.1/src/xdr.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -typedef quad_t longlong_t; /* ANSI long long type */ -typedef u_quad_t u_longlong_t; /* ANSI unsigned long long type */ - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) - -/* - * for unit alignment - */ -static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free(proc, objp) - xdrproc_t proc; - void *objp; -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc)(&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void(void) -{ - - return (TRUE); -} - - -/* - * XDR integers - */ -bool_t -xdr_int(xdrs, ip) - XDR *xdrs; - int *ip; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *ip; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *ip = (int) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int(xdrs, up) - XDR *xdrs; - u_int *up; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *up; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *up = (u_int) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR long integers - * same as xdr_u_long - open coded to save a proc call! - */ -bool_t -xdr_long(xdrs, lp) - XDR *xdrs; - long *lp; -{ - switch (xdrs->x_op) { - case XDR_ENCODE: - return (XDR_PUTLONG(xdrs, lp)); - case XDR_DECODE: - return (XDR_GETLONG(xdrs, lp)); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned long integers - * same as xdr_long - open coded to save a proc call! - */ -bool_t -xdr_u_long(xdrs, ulp) - XDR *xdrs; - u_long *ulp; -{ - switch (xdrs->x_op) { - case XDR_ENCODE: - return (XDR_PUTLONG(xdrs, (long *)ulp)); - case XDR_DECODE: - return (XDR_GETLONG(xdrs, (long *)ulp)); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR 32-bit integers - * same as xdr_u_int32_t - open coded to save a proc call! - */ -bool_t -xdr_int32_t(xdrs, int32_p) - XDR *xdrs; - int32_t *int32_p; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *int32_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int32_p = (int32_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 32-bit integers - * same as xdr_int32_t - open coded to save a proc call! - */ -bool_t -xdr_u_int32_t(xdrs, u_int32_p) - XDR *xdrs; - u_int32_t *u_int32_p; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *u_int32_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *u_int32_p = (u_int32_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 32-bit integers - */ -bool_t -xdr_uint32_t(xdrs, uint32_p) - XDR *xdrs; - uint32_t *uint32_p; -{ - return (xdr_u_int32_t(xdrs, (u_int32_t *)uint32_p)); -} - - -/* - * XDR short integers - */ -bool_t -xdr_short(xdrs, sp) - XDR *xdrs; - short *sp; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *sp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *sp = (short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short(xdrs, usp) - XDR *xdrs; - u_short *usp; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *usp; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *usp = (u_short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR 16-bit integers - */ -bool_t -xdr_int16_t(xdrs, int16_p) - XDR *xdrs; - int16_t *int16_p; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *int16_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int16_p = (int16_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 16-bit integers - */ -bool_t -xdr_u_int16_t(xdrs, u_int16_p) - XDR *xdrs; - u_int16_t *u_int16_p; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *u_int16_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *u_int16_p = (u_int16_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 16-bit integers - */ -bool_t -xdr_uint16_t(xdrs, uint16_p) - XDR *xdrs; - uint16_t *uint16_p; -{ - return (xdr_u_int16_t(xdrs, (u_int16_t *)uint16_p)); -} - - -/* - * XDR 8-bit integers - */ -bool_t -xdr_int8_t(xdrs, int8_p) - XDR *xdrs; - int8_t *int8_p; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *int8_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int8_p = (int8_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 8-bit integers - */ -bool_t -xdr_u_int8_t(xdrs, uint8_p) - XDR *xdrs; - uint8_t *uint8_p; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *uint8_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *uint8_p = (uint8_t) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 8-bit integers - */ -bool_t -xdr_uint8_t(xdrs, uint8_p) - XDR *xdrs; - uint8_t *uint8_p; -{ - return (xdr_u_int8_t(xdrs, (uint8_t *)uint8_p)); -} - - -/* - * XDR a char - */ -bool_t -xdr_char(xdrs, cp) - XDR *xdrs; - char *cp; -{ - int i; - - i = (*cp); - if (!xdr_int(xdrs, &i)) { - return (FALSE); - } - *cp = i; - return (TRUE); -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char(xdrs, cp) - XDR *xdrs; - u_char *cp; -{ - u_int u; - - u = (*cp); - if (!xdr_u_int(xdrs, &u)) { - return (FALSE); - } - *cp = u; - return (TRUE); -} - -/* - * XDR booleans - */ -bool_t -xdr_bool(xdrs, bp) - XDR *xdrs; - bool_t *bp; -{ - long lb; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return (XDR_PUTLONG(xdrs, &lb)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &lb)) { - return (FALSE); - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR enumerations - */ -bool_t -xdr_enum(xdrs, ep) - XDR *xdrs; - enum_t *ep; -{ - enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - /* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) { - return (xdr_long(xdrs, (long *)(void *)ep)); - } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) { - return (xdr_int(xdrs, (int *)(void *)ep)); - } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) { - return (xdr_short(xdrs, (short *)(void *)ep)); - } else { - return (FALSE); - } -} - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque(xdrs, cp, cnt) - XDR *xdrs; - caddr_t cp; - u_int cnt; -{ - u_int rndup; - static int crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return (TRUE); - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - if (xdrs->x_op == XDR_DECODE) { - if (!XDR_GETBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_GETBYTES(xdrs, (caddr_t)(void *)crud, rndup)); - } - - if (xdrs->x_op == XDR_ENCODE) { - if (!XDR_PUTBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); - } - - if (xdrs->x_op == XDR_FREE) { - return (TRUE); - } - - return (FALSE); -} - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes(xdrs, cpp, sizep, maxsize) - XDR *xdrs; - char **cpp; - u_int *sizep; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int nodesize; - bool_t ret, allocated = FALSE; - - /* - * first deal with the length since xdr bytes are counted - */ - if (! xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) { - *cpp = sp = mem_alloc(nodesize); - allocated = TRUE; - } - if (sp == NULL) { - warnx("xdr_bytes: out of memory"); - return (FALSE); - } - /* FALLTHROUGH */ - - case XDR_ENCODE: - ret = xdr_opaque(xdrs, sp, nodesize); - if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) { - if (allocated == TRUE) { - free(sp); - *cpp = NULL; - } - } - return (ret); - - case XDR_FREE: - if (sp != NULL) { - mem_free(sp, nodesize); - *cpp = NULL; - } - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj(xdrs, np) - XDR *xdrs; - struct netobj *np; -{ - - return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); -} - -/* - * XDR a descriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -bool_t -xdr_union(xdrs, dscmp, unp, choices, dfault) - XDR *xdrs; - enum_t *dscmp; /* enum to decide which arm to work on */ - char *unp; /* the union itself */ - const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ - xdrproc_t dfault; /* default xdr routine */ -{ - enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (! xdr_enum(xdrs, dscmp)) { - return (FALSE); - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) { - if (choices->value == dscm) - return ((*(choices->proc))(xdrs, unp)); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault)(xdrs, unp)); -} - - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string(xdrs, cpp, maxsize) - XDR *xdrs; - char **cpp; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - bool_t ret, allocated = FALSE; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) { - return(TRUE); /* already free */ - } - /* FALLTHROUGH */ - case XDR_ENCODE: - if (sp == NULL) - return FALSE; - size = strlen(sp); - break; - case XDR_DECODE: - break; - } - if (! xdr_u_int(xdrs, &size)) { - return (FALSE); - } - if (size > maxsize) { - return (FALSE); - } - nodesize = size + 1; - if (nodesize == 0) { - /* This means an overflow. It a bug in the caller which - * provided a too large maxsize but nevertheless catch it - * here. - */ - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (sp == NULL) { - *cpp = sp = mem_alloc(nodesize); - allocated = TRUE; - } - if (sp == NULL) { - warnx("xdr_string: out of memory"); - return (FALSE); - } - sp[size] = 0; - /* FALLTHROUGH */ - - case XDR_ENCODE: - ret = xdr_opaque(xdrs, sp, size); - if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) { - if (allocated == TRUE) { - free(sp); - *cpp = NULL; - } - } - return (ret); - - case XDR_FREE: - mem_free(sp, nodesize); - *cpp = NULL; - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring(xdrs, cpp) - XDR *xdrs; - char **cpp; -{ - return xdr_string(xdrs, cpp, RPC_MAXDATASIZE); -} - -/* - * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t() - * are in the "non-portable" section because they require that a `long long' - * be a 64-bit type. - * - * --thorpej@netbsd.org, November 30, 1999 - */ - -/* - * XDR 64-bit integers - */ -bool_t -xdr_int64_t(xdrs, llp) - XDR *xdrs; - int64_t *llp; -{ - u_long ul[2]; - - switch (xdrs->x_op) { - case XDR_ENCODE: - ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff; - ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *llp = (int64_t) - (((u_int64_t)ul[0] << 32) | - ((u_int64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 64-bit integers - */ -bool_t -xdr_u_int64_t(xdrs, ullp) - XDR *xdrs; - u_int64_t *ullp; -{ - u_long ul[2]; - - switch (xdrs->x_op) { - case XDR_ENCODE: - ul[0] = (u_long)(*ullp >> 32) & 0xffffffff; - ul[1] = (u_long)(*ullp) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *ullp = (u_int64_t) - (((u_int64_t)ul[0] << 32) | - ((u_int64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - - -/* - * XDR unsigned 64-bit integers - */ -bool_t -xdr_uint64_t(xdrs, ullp) - XDR *xdrs; - uint64_t *ullp; -{ - return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); -} - - -/* - * XDR hypers - */ -bool_t -xdr_hyper(xdrs, llp) - XDR *xdrs; - longlong_t *llp; -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_int64_t(). - */ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - - -/* - * XDR unsigned hypers - */ -bool_t -xdr_u_hyper(xdrs, ullp) - XDR *xdrs; - u_longlong_t *ullp; -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_u_int64_t(). - */ - return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); -} - - -/* - * XDR longlong_t's - */ -bool_t -xdr_longlong_t(xdrs, llp) - XDR *xdrs; - longlong_t *llp; -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_int64_t(). - */ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - - -/* - * XDR u_longlong_t's - */ -bool_t -xdr_u_longlong_t(xdrs, ullp) - XDR *xdrs; - u_longlong_t *ullp; -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_u_int64_t(). - */ - return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); -} - -/* - * XDR quad_t - */ -bool_t -xdr_quad_t(xdrs, llp) - XDR *xdrs; - int64_t *llp; -{ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - - -/* - * XDR u_quad_t - */ -bool_t -xdr_u_quad_t(xdrs, ullp) - XDR *xdrs; - u_int64_t *ullp; -{ - return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); -} diff --git a/libtirpc-1.3.1/src/xdr_array.c b/libtirpc-1.3.1/src/xdr_array.c deleted file mode 100644 index 7fc8fb8..0000000 --- a/libtirpc-1.3.1/src/xdr_array.c +++ /dev/null @@ -1,154 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_array.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include "un-namespace.h" - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -bool_t -xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) - XDR *xdrs; - caddr_t *addrp; /* array pointer */ - u_int *sizep; /* number of elements */ - u_int maxsize; /* max numberof elements */ - u_int elsize; /* size in bytes of each element */ - xdrproc_t elproc; /* xdr routine to handle each element */ -{ - u_int i; - caddr_t target = *addrp; - u_int c; /* the actual element count */ - bool_t stat = TRUE; - u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (!xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - c = *sizep; - if ((c > maxsize || UINT_MAX/elsize < c) && - (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) { - case XDR_DECODE: - if (c == 0) - return (TRUE); - *addrp = target = mem_alloc(nodesize); - if (target == NULL) { - warnx("xdr_array: out of memory"); - return (FALSE); - } - memset(target, 0, nodesize); - break; - - case XDR_FREE: - return (TRUE); - - case XDR_ENCODE: - break; - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) { - stat = (*elproc)(xdrs, target); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) { - mem_free(*addrp, nodesize); - *addrp = NULL; - } - return (stat); -} - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) - XDR *xdrs; - char *basep; - u_int nelem; - u_int elemsize; - xdrproc_t xdr_elem; -{ - u_int i; - char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) { - if (!(*xdr_elem)(xdrs, elptr)) { - return(FALSE); - } - elptr += elemsize; - } - return(TRUE); -} diff --git a/libtirpc-1.3.1/src/xdr_float.c b/libtirpc-1.3.1/src/xdr_float.c deleted file mode 100644 index 349d48f..0000000 --- a/libtirpc-1.3.1/src/xdr_float.c +++ /dev/null @@ -1,297 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_float.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include - -#include - -#include -#include -#include "un-namespace.h" - -/* - * NB: Not portable. - * This routine works on machines with IEEE754 FP and Vaxen. - */ - -#if defined(__vax__) - -/* What IEEE single precision floating point looks like on a Vax */ -struct ieee_single { - unsigned int mantissa: 23; - unsigned int exp : 8; - unsigned int sign : 1; -}; - -/* Vax single precision floating point */ -struct vax_single { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; -}; - -#define VAX_SNG_BIAS 0x81 -#define IEEE_SNG_BIAS 0x7f - -static struct sgl_limits { - struct vax_single s; - struct ieee_single ieee; -} sgl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ - { 0x0, 0xff, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ - { 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; -#else - -#include -#define IEEEFP - -#endif /* vax */ - -bool_t -xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; -{ -#ifndef IEEEFP - struct ieee_single is; - struct vax_single vs, *vsp; - struct sgl_limits *lim; - int i; -#endif - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef IEEEFP - return (XDR_PUTINT32(xdrs, (int32_t *)fp)); -#else - vs = *((struct vax_single *)fp); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((vs.mantissa2 == lim->s.mantissa2) && - (vs.exp == lim->s.exp) && - (vs.mantissa1 == lim->s.mantissa1)) { - is = lim->ieee; - goto shipit; - } - } - is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; - is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; - shipit: - is.sign = vs.sign; - return (XDR_PUTINT32(xdrs, (int32_t *)&is)); -#endif - - case XDR_DECODE: -#ifdef IEEEFP - return (XDR_GETINT32(xdrs, (int32_t *)fp)); -#else - vsp = (struct vax_single *)fp; - if (!XDR_GETINT32(xdrs, (int32_t *)&is)) - return (FALSE); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((is.exp == lim->ieee.exp) && - (is.mantissa == lim->ieee.mantissa)) { - *vsp = lim->s; - goto doneit; - } - } - vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; - vsp->mantissa2 = is.mantissa; - vsp->mantissa1 = (is.mantissa >> 16); - doneit: - vsp->sign = is.sign; - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -#if defined(__vax__) -/* What IEEE double precision floating point looks like on a Vax */ -struct ieee_double { - unsigned int mantissa1 : 20; - unsigned int exp : 11; - unsigned int sign : 1; - unsigned int mantissa2 : 32; -}; - -/* Vax double precision floating point */ -struct vax_double { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; - unsigned int mantissa3 : 16; - unsigned int mantissa4 : 16; -}; - -#define VAX_DBL_BIAS 0x81 -#define IEEE_DBL_BIAS 0x3ff -#define MASK(nbits) ((1 << nbits) - 1) - -static struct dbl_limits { - struct vax_double d; - struct ieee_double ieee; -} dbl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ - { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ - { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; - -#endif /* vax */ - - -bool_t -xdr_double(xdrs, dp) - XDR *xdrs; - double *dp; -{ -#ifdef IEEEFP - int32_t *i32p; - bool_t rv; -#else - int32_t *lp; - struct ieee_double id; - struct vax_double vd; - struct dbl_limits *lim; - int i; -#endif - - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef IEEEFP - i32p = (int32_t *)(void *)dp; -#if BYTE_ORDER == BIG_ENDIAN - rv = XDR_PUTINT32(xdrs, i32p); - if (!rv) - return (rv); - rv = XDR_PUTINT32(xdrs, i32p+1); -#else - rv = XDR_PUTINT32(xdrs, i32p+1); - if (!rv) - return (rv); - rv = XDR_PUTINT32(xdrs, i32p); -#endif - return (rv); -#else - vd = *((struct vax_double *)dp); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((vd.mantissa4 == lim->d.mantissa4) && - (vd.mantissa3 == lim->d.mantissa3) && - (vd.mantissa2 == lim->d.mantissa2) && - (vd.mantissa1 == lim->d.mantissa1) && - (vd.exp == lim->d.exp)) { - id = lim->ieee; - goto shipit; - } - } - id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; - id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); - id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | - (vd.mantissa3 << 13) | - ((vd.mantissa4 >> 3) & MASK(13)); - shipit: - id.sign = vd.sign; - lp = (int32_t *)&id; - return (XDR_PUTINT32(xdrs, lp++) && XDR_PUTINT32(xdrs, lp)); -#endif - - case XDR_DECODE: -#ifdef IEEEFP - i32p = (int32_t *)(void *)dp; -#if BYTE_ORDER == BIG_ENDIAN - rv = XDR_GETINT32(xdrs, i32p); - if (!rv) - return (rv); - rv = XDR_GETINT32(xdrs, i32p+1); -#else - rv = XDR_GETINT32(xdrs, i32p+1); - if (!rv) - return (rv); - rv = XDR_GETINT32(xdrs, i32p); -#endif - return (rv); -#else - lp = (int32_t *)&id; - if (!XDR_GETINT32(xdrs, lp++) || !XDR_GETINT32(xdrs, lp)) - return (FALSE); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((id.mantissa2 == lim->ieee.mantissa2) && - (id.mantissa1 == lim->ieee.mantissa1) && - (id.exp == lim->ieee.exp)) { - vd = lim->d; - goto doneit; - } - } - vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; - vd.mantissa1 = (id.mantissa1 >> 13); - vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | - (id.mantissa2 >> 29); - vd.mantissa3 = (id.mantissa2 >> 13); - vd.mantissa4 = (id.mantissa2 << 3); - doneit: - vd.sign = id.sign; - *dp = *((double *)&vd); - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} diff --git a/libtirpc-1.3.1/src/xdr_mem.c b/libtirpc-1.3.1/src/xdr_mem.c deleted file mode 100644 index ecdc932..0000000 --- a/libtirpc-1.3.1/src/xdr_mem.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_mem.h, XDR implementation using memory buffers. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * If you have some data to be interpreted as external data representation - * or to be converted to external data representation in a memory buffer, - * then this is the package for you. - * - */ - -#include - -#include - -#include - -#include -#include -#include "un-namespace.h" - -static void xdrmem_destroy(XDR *); -static bool_t xdrmem_getlong_aligned(XDR *, long *); -static bool_t xdrmem_putlong_aligned(XDR *, const long *); -static bool_t xdrmem_getlong_unaligned(XDR *, long *); -static bool_t xdrmem_putlong_unaligned(XDR *, const long *); -static bool_t xdrmem_getbytes(XDR *, char *, u_int); -static bool_t xdrmem_putbytes(XDR *, const char *, u_int); -/* XXX: w/64-bit pointers, u_int not enough! */ -static u_int xdrmem_getpos(XDR *); -static bool_t xdrmem_setpos(XDR *, u_int); -static int32_t *xdrmem_inline_aligned(XDR *, u_int); -static int32_t *xdrmem_inline_unaligned(XDR *, u_int); - -static const struct xdr_ops xdrmem_ops_aligned = { - xdrmem_getlong_aligned, - xdrmem_putlong_aligned, - xdrmem_getbytes, - xdrmem_putbytes, - xdrmem_getpos, - xdrmem_setpos, - xdrmem_inline_aligned, - xdrmem_destroy -}; - -static const struct xdr_ops xdrmem_ops_unaligned = { - xdrmem_getlong_unaligned, - xdrmem_putlong_unaligned, - xdrmem_getbytes, - xdrmem_putbytes, - xdrmem_getpos, - xdrmem_setpos, - xdrmem_inline_unaligned, - xdrmem_destroy -}; - -/* - * The procedure xdrmem_create initializes a stream descriptor for a - * memory buffer. - */ -void -xdrmem_create(xdrs, addr, size, op) - XDR *xdrs; - char *addr; - u_int size; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = ((unsigned long)addr & (sizeof(int32_t) - 1)) - ? &xdrmem_ops_unaligned : &xdrmem_ops_aligned; - xdrs->x_private = xdrs->x_base = addr; - xdrs->x_handy = size; -} - -/*ARGSUSED*/ -static void -xdrmem_destroy(xdrs) - XDR *xdrs; -{ - -} - -static bool_t -xdrmem_getlong_aligned(xdrs, lp) - XDR *xdrs; - long *lp; -{ - - if (xdrs->x_handy < sizeof(int32_t)) - return (FALSE); - xdrs->x_handy -= sizeof(int32_t); - *lp = ntohl(*(u_int32_t *)xdrs->x_private); - xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); - return (TRUE); -} - -static bool_t -xdrmem_putlong_aligned(xdrs, lp) - XDR *xdrs; - const long *lp; -{ - - if (xdrs->x_handy < sizeof(int32_t)) - return (FALSE); - xdrs->x_handy -= sizeof(int32_t); - *(u_int32_t *)xdrs->x_private = htonl((u_int32_t)*lp); - xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); - return (TRUE); -} - -static bool_t -xdrmem_getlong_unaligned(xdrs, lp) - XDR *xdrs; - long *lp; -{ - u_int32_t l; - - if (xdrs->x_handy < sizeof(int32_t)) - return (FALSE); - xdrs->x_handy -= sizeof(int32_t); - memmove(&l, xdrs->x_private, sizeof(int32_t)); - *lp = ntohl(l); - xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); - return (TRUE); -} - -static bool_t -xdrmem_putlong_unaligned(xdrs, lp) - XDR *xdrs; - const long *lp; -{ - u_int32_t l; - - if (xdrs->x_handy < sizeof(int32_t)) - return (FALSE); - xdrs->x_handy -= sizeof(int32_t); - l = htonl((u_int32_t)*lp); - memmove(xdrs->x_private, &l, sizeof(int32_t)); - xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); - return (TRUE); -} - -static bool_t -xdrmem_getbytes(xdrs, addr, len) - XDR *xdrs; - char *addr; - u_int len; -{ - - if (xdrs->x_handy < len) - return (FALSE); - xdrs->x_handy -= len; - memmove(addr, xdrs->x_private, len); - xdrs->x_private = (char *)xdrs->x_private + len; - return (TRUE); -} - -static bool_t -xdrmem_putbytes(xdrs, addr, len) - XDR *xdrs; - const char *addr; - u_int len; -{ - - if (xdrs->x_handy < len) - return (FALSE); - xdrs->x_handy -= len; - memmove(xdrs->x_private, addr, len); - xdrs->x_private = (char *)xdrs->x_private + len; - return (TRUE); -} - -static u_int -xdrmem_getpos(xdrs) - XDR *xdrs; -{ - - /* XXX w/64-bit pointers, u_int not enough! */ - return (u_int)((u_long)xdrs->x_private - (u_long)xdrs->x_base); -} - -static bool_t -xdrmem_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - char *newaddr = xdrs->x_base + pos; - char *lastaddr = (char *)xdrs->x_private + xdrs->x_handy; - - if (newaddr > lastaddr) - return (FALSE); - xdrs->x_private = newaddr; - xdrs->x_handy = (u_int)(lastaddr - newaddr); /* XXX sizeof(u_int) x_handy >= len) { - xdrs->x_handy -= len; - buf = (int32_t *)xdrs->x_private; - xdrs->x_private = (char *)xdrs->x_private + len; - } - return (buf); -} - -/* ARGSUSED */ -static int32_t * -xdrmem_inline_unaligned(xdrs, len) - XDR *xdrs; - u_int len; -{ - - return (0); -} diff --git a/libtirpc-1.3.1/src/xdr_rec.c b/libtirpc-1.3.1/src/xdr_rec.c deleted file mode 100644 index 676cc82..0000000 --- a/libtirpc-1.3.1/src/xdr_rec.c +++ /dev/null @@ -1,792 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" - * layer above tcp (for rpc's use). - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These routines interface XDRSTREAMS to a tcp/ip connection. - * There is a record marking layer between the xdr stream - * and the tcp transport level. A record is composed on one or more - * record fragments. A record fragment is a thirty-two bit header followed - * by n bytes of data, where n is contained in the header. The header - * is represented as a htonl(u_long). Thegh order bit encodes - * whether or not the fragment is the last fragment of the record - * (1 => fragment is last, 0 => more fragments to follow. - * The other 31 bits encode the byte length of the fragment. - */ - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_com.h" -static bool_t xdrrec_getlong(XDR *, long *); -static bool_t xdrrec_putlong(XDR *, const long *); -static bool_t xdrrec_getbytes(XDR *, char *, u_int); - -static bool_t xdrrec_putbytes(XDR *, const char *, u_int); -static u_int xdrrec_getpos(XDR *); -static bool_t xdrrec_setpos(XDR *, u_int); -static int32_t *xdrrec_inline(XDR *, u_int); -static void xdrrec_destroy(XDR *); - -static const struct xdr_ops xdrrec_ops = { - xdrrec_getlong, - xdrrec_putlong, - xdrrec_getbytes, - xdrrec_putbytes, - xdrrec_getpos, - xdrrec_setpos, - xdrrec_inline, - xdrrec_destroy -}; - -/* - * A record is composed of one or more record fragments. - * A record fragment is a four-byte header followed by zero to - * 2**32-1 bytes. The header is treated as a long unsigned and is - * encode/decoded to the network via htonl/ntohl. The low order 31 bits - * are a byte count of the fragment. The highest order bit is a boolean: - * 1 => this fragment is the last fragment of the record, - * 0 => this fragment is followed by more fragment(s). - * - * The fragment/record machinery is not general; it is constructed to - * meet the needs of xdr and rpc based on tcp. - */ - -#define LAST_FRAG ((u_int32_t)(1 << 31)) - -typedef struct rec_strm { - char *tcp_handle; - /* - * out-goung bits - */ - int (*writeit)(void *, void *, int); - char *out_base; /* output buffer (points to frag header) */ - char *out_finger; /* next output position */ - char *out_boundry; /* data cannot up to this address */ - u_int32_t *frag_header; /* beginning of curren fragment */ - bool_t frag_sent; /* true if buffer sent in middle of record */ - /* - * in-coming bits - */ - int (*readit)(void *, void *, int); - u_long in_size; /* fixed size of the input buffer */ - char *in_base; - char *in_finger; /* location of next byte to be had */ - char *in_boundry; /* can read up to this location */ - long fbtbc; /* fragment bytes to be consumed */ - bool_t last_frag; - u_int sendsize; - u_int recvsize; - - bool_t nonblock; - bool_t in_haveheader; - u_int32_t in_header; - char *in_hdrp; - int in_hdrlen; - int in_reclen; - int in_received; - int in_maxrec; -} RECSTREAM; - -static u_int fix_buf_size(u_int); -static bool_t flush_out(RECSTREAM *, bool_t); -static bool_t fill_input_buf(RECSTREAM *); -static bool_t get_input_bytes(RECSTREAM *, char *, int); -static bool_t set_input_fragment(RECSTREAM *); -static bool_t skip_input_bytes(RECSTREAM *, long); -static bool_t realloc_stream(RECSTREAM *, int); - - -/* - * Create an xdr handle for xdrrec - * xdrrec_create fills in xdrs. Sendsize and recvsize are - * send and recv buffer sizes (0 => use default). - * tcp_handle is an opaque handle that is passed as the first parameter to - * the procedures readit and writeit. Readit and writeit are read and - * write respectively. They are like the system - * calls expect that they take an opaque handle rather than an fd. - */ -void -xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) - XDR *xdrs; - u_int sendsize; - u_int recvsize; - void *tcp_handle; - /* like read, but pass it a tcp_handle, not sock */ - int (*readit)(void *, void *, int); - /* like write, but pass it a tcp_handle, not sock */ - int (*writeit)(void *, void *, int); -{ - RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM)); - - if (rstrm == NULL) { - warnx("xdrrec_create: out of memory"); - /* - * This is bad. Should rework xdrrec_create to - * return a handle, and in this case return NULL - */ - return; - } - rstrm->sendsize = sendsize = fix_buf_size(sendsize); - rstrm->out_base = mem_alloc(rstrm->sendsize); - if (rstrm->out_base == NULL) { - warnx("xdrrec_create: out of memory"); - mem_free(rstrm, sizeof(RECSTREAM)); - return; - } - rstrm->recvsize = recvsize = fix_buf_size(recvsize); - rstrm->in_base = mem_alloc(recvsize); - if (rstrm->in_base == NULL) { - warnx("xdrrec_create: out of memory"); - mem_free(rstrm->out_base, sendsize); - mem_free(rstrm, sizeof(RECSTREAM)); - return; - } - /* - * now the rest ... - */ - xdrs->x_ops = &xdrrec_ops; - xdrs->x_private = rstrm; - rstrm->tcp_handle = tcp_handle; - rstrm->readit = readit; - rstrm->writeit = writeit; - rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; - rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base; - rstrm->out_finger += sizeof(u_int32_t); - rstrm->out_boundry += sendsize; - rstrm->frag_sent = FALSE; - rstrm->in_size = recvsize; - rstrm->in_boundry = rstrm->in_base; - rstrm->in_finger = (rstrm->in_boundry += recvsize); - rstrm->fbtbc = 0; - rstrm->last_frag = TRUE; - rstrm->in_haveheader = FALSE; - rstrm->in_hdrlen = 0; - rstrm->in_hdrp = (char *)(void *)&rstrm->in_header; - rstrm->nonblock = FALSE; - rstrm->in_reclen = 0; - rstrm->in_received = 0; -} - - -/* - * The reoutines defined below are the xdr ops which will go into the - * xdr handle filled in by xdrrec_create. - */ - -static bool_t -xdrrec_getlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger); - int32_t mylong; - - /* first try the inline, fast case */ - if ((rstrm->fbtbc >= sizeof(int32_t)) && - (((long)rstrm->in_boundry - (long)buflp) >= sizeof(int32_t))) { - *lp = (long)ntohl((u_int32_t)(*buflp)); - rstrm->fbtbc -= sizeof(int32_t); - rstrm->in_finger += sizeof(int32_t); - } else { - if (! xdrrec_getbytes(xdrs, (char *)(void *)&mylong, - sizeof(int32_t))) - return (FALSE); - *lp = (long)ntohl((u_int32_t)mylong); - } - return (TRUE); -} - -static bool_t -xdrrec_putlong(xdrs, lp) - XDR *xdrs; - const long *lp; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); - - if ((rstrm->out_finger += sizeof(int32_t)) > rstrm->out_boundry) { - /* - * this case should almost never happen so the code is - * inefficient - */ - rstrm->out_finger -= sizeof(int32_t); - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); - rstrm->out_finger += sizeof(int32_t); - } - *dest_lp = (int32_t)htonl((u_int32_t)(*lp)); - return (TRUE); -} - -static bool_t /* must manage buffers, fragments, and records */ -xdrrec_getbytes(xdrs, addr, len) - XDR *xdrs; - char *addr; - u_int len; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - int current; - - while (len > 0) { - current = (int)rstrm->fbtbc; - if (current == 0) { - if (rstrm->last_frag) - return (FALSE); - if (! set_input_fragment(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - if (! get_input_bytes(rstrm, addr, current)) - return (FALSE); - addr += current; - rstrm->fbtbc -= current; - len -= current; - } - return (TRUE); -} - -static bool_t -xdrrec_putbytes(xdrs, addr, len) - XDR *xdrs; - const char *addr; - u_int len; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - size_t current; - - while (len > 0) { - current = (size_t)((u_long)rstrm->out_boundry - - (u_long)rstrm->out_finger); - current = (len < current) ? len : current; - memmove(rstrm->out_finger, addr, current); - rstrm->out_finger += current; - addr += current; - len -= current; - if (rstrm->out_finger == rstrm->out_boundry) { - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - } - } - return (TRUE); -} - -static u_int -xdrrec_getpos(xdrs) - XDR *xdrs; -{ - RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - off_t pos; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - pos = rstrm->out_finger - rstrm->out_base - - BYTES_PER_XDR_UNIT; - break; - - case XDR_DECODE: - pos = rstrm->in_boundry - rstrm->in_finger - - BYTES_PER_XDR_UNIT; - break; - - default: - pos = (off_t) -1; - break; - } - return ((u_int) pos); -} - -static bool_t -xdrrec_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - u_int currpos = xdrrec_getpos(xdrs); - int delta = currpos - pos; - char *newpos; - - if ((int)currpos != -1) - switch (xdrs->x_op) { - - case XDR_ENCODE: - newpos = rstrm->out_finger - delta; - if ((newpos > (char *)(void *)(rstrm->frag_header)) && - (newpos < rstrm->out_boundry)) { - rstrm->out_finger = newpos; - return (TRUE); - } - break; - - case XDR_DECODE: - newpos = rstrm->in_finger - delta; - if ((delta < (int)(rstrm->fbtbc)) && - (newpos <= rstrm->in_boundry) && - (newpos >= rstrm->in_base)) { - rstrm->in_finger = newpos; - rstrm->fbtbc -= delta; - return (TRUE); - } - break; - - case XDR_FREE: - break; - } - return (FALSE); -} - -static int32_t * -xdrrec_inline(xdrs, len) - XDR *xdrs; - u_int len; -{ - RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - int32_t *buf = NULL; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - if ((rstrm->out_finger + len) <= rstrm->out_boundry) { - buf = (int32_t *)(void *)rstrm->out_finger; - rstrm->out_finger += len; - } - break; - - case XDR_DECODE: - if ((len <= rstrm->fbtbc) && - ((rstrm->in_finger + len) <= rstrm->in_boundry)) { - buf = (int32_t *)(void *)rstrm->in_finger; - rstrm->fbtbc -= len; - rstrm->in_finger += len; - } - break; - - case XDR_FREE: - break; - } - return (buf); -} - -static void -xdrrec_destroy(xdrs) - XDR *xdrs; -{ - RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - - mem_free(rstrm->out_base, rstrm->sendsize); - mem_free(rstrm->in_base, rstrm->recvsize); - mem_free(rstrm, sizeof(RECSTREAM)); -} - - -/* - * Exported routines to manage xdr records - */ - -/* - * Before reading (deserializing from the stream, one should always call - * this procedure to guarantee proper record alignment. - */ -bool_t -xdrrec_skiprecord(xdrs) - XDR *xdrs; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - enum xprt_stat xstat; - - if (rstrm->nonblock) { - if (__xdrrec_getrec(xdrs, &xstat, FALSE)) { - rstrm->fbtbc = 0; - return TRUE; - } - if (rstrm->in_finger == rstrm->in_boundry && - xstat == XPRT_MOREREQS) { - rstrm->fbtbc = 0; - return TRUE; - } - return FALSE; - } - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (FALSE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (FALSE); - } - rstrm->last_frag = FALSE; - return (TRUE); -} - -/* - * Look ahead function. - * Returns TRUE iff there is no more input in the buffer - * after consuming the rest of the current record. - */ -bool_t -xdrrec_eof(xdrs) - XDR *xdrs; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (TRUE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (TRUE); - } - if (rstrm->in_finger == rstrm->in_boundry) - return (TRUE); - return (FALSE); -} - -/* - * The client must tell the package when an end-of-record has occurred. - * The second paraemters tells whether the record should be flushed to the - * (output) tcp stream. (This let's the package support batched or - * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. - */ -bool_t -xdrrec_endofrecord(xdrs, sendnow) - XDR *xdrs; - bool_t sendnow; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - u_long len; /* fragment length */ - - if (sendnow || rstrm->frag_sent || - ((u_long)rstrm->out_finger + sizeof(u_int32_t) >= - (u_long)rstrm->out_boundry)) { - rstrm->frag_sent = FALSE; - return (flush_out(rstrm, TRUE)); - } - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - - sizeof(u_int32_t); - *(rstrm->frag_header) = htonl((u_int32_t)len | LAST_FRAG); - rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_finger; - rstrm->out_finger += sizeof(u_int32_t); - return (TRUE); -} - -/* - * Fill the stream buffer with a record for a non-blocking connection. - * Return true if a record is available in the buffer, false if not. - */ -bool_t -__xdrrec_getrec(xdrs, statp, expectdata) - XDR *xdrs; - enum xprt_stat *statp; - bool_t expectdata; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - ssize_t n; - int fraglen; - - if (!rstrm->in_haveheader) { - n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp, - (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen); - if (n == 0) { - /* EAGAIN or EWOULDBLOCK means a zero length - * read not an EOF. - */ - if (errno == EAGAIN || errno == EWOULDBLOCK) - *statp = XPRT_IDLE; - else - *statp = expectdata ? XPRT_DIED : XPRT_IDLE; - return FALSE; - } - if (n < 0) { - *statp = XPRT_DIED; - return FALSE; - } - rstrm->in_hdrp += n; - rstrm->in_hdrlen += n; - if (rstrm->in_hdrlen < sizeof (rstrm->in_header)) { - *statp = XPRT_MOREREQS; - return FALSE; - } - rstrm->in_header = ntohl(rstrm->in_header); - fraglen = (int)(rstrm->in_header & ~LAST_FRAG); - if (fraglen == 0 || fraglen > rstrm->in_maxrec || - (rstrm->in_reclen + fraglen) > rstrm->in_maxrec) { - *statp = XPRT_DIED; - return FALSE; - } - rstrm->in_reclen += fraglen; - if (rstrm->in_reclen > rstrm->recvsize) - realloc_stream(rstrm, rstrm->in_reclen); - if (rstrm->in_header & LAST_FRAG) { - rstrm->in_header &= ~LAST_FRAG; - rstrm->last_frag = TRUE; - } - rstrm->in_haveheader = 1; - } - - n = rstrm->readit(rstrm->tcp_handle, - rstrm->in_base + rstrm->in_received, - (rstrm->in_reclen - rstrm->in_received)); - - if (n < 0) { - *statp = XPRT_DIED; - return FALSE; - } - - if (n == 0) { - /* EAGAIN or EWOULDBLOCK means a zero length - * read not an EOF. - */ - if (errno == EAGAIN || errno == EWOULDBLOCK) - *statp = XPRT_IDLE; - else - *statp = expectdata ? XPRT_DIED : XPRT_IDLE; - return FALSE; - } - - rstrm->in_received += n; - - if (rstrm->in_received == rstrm->in_reclen) { - rstrm->in_haveheader = FALSE; - rstrm->in_hdrp = (char *)(void *)&rstrm->in_header; - rstrm->in_hdrlen = 0; - if (rstrm->last_frag) { - rstrm->fbtbc = rstrm->in_reclen; - rstrm->in_boundry = rstrm->in_base + rstrm->in_reclen; - rstrm->in_finger = rstrm->in_base; - rstrm->in_reclen = rstrm->in_received = 0; - *statp = XPRT_MOREREQS; - return TRUE; - } - } - - *statp = XPRT_MOREREQS; - return FALSE; -} - -bool_t -__xdrrec_setnonblock(xdrs, maxrec) - XDR *xdrs; - int maxrec; -{ - RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - rstrm->nonblock = TRUE; - if (maxrec == 0) - maxrec = rstrm->recvsize; - rstrm->in_maxrec = maxrec; - return TRUE; -} - -/* - * Internal useful routines - */ -static bool_t -flush_out(rstrm, eor) - RECSTREAM *rstrm; - bool_t eor; -{ - u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0; - u_int32_t len = (u_int32_t)((u_long)(rstrm->out_finger) - - (u_long)(rstrm->frag_header) - sizeof(u_int32_t)); - - *(rstrm->frag_header) = htonl(len | eormask); - len = (u_int32_t)((u_long)(rstrm->out_finger) - - (u_long)(rstrm->out_base)); - if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) - != (int)len) - return (FALSE); - rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base; - rstrm->out_finger = (char *)rstrm->out_base + sizeof(u_int32_t); - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -fill_input_buf(rstrm) - RECSTREAM *rstrm; -{ - char *where; - u_int32_t i; - int len; - - if (rstrm->nonblock) - return FALSE; - - where = rstrm->in_base; - i = (u_int32_t)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT); - where += i; - len = (u_int32_t)(rstrm->in_size - i); - if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) - return (FALSE); - rstrm->in_finger = where; - where += len; - rstrm->in_boundry = where; - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -get_input_bytes(rstrm, addr, len) - RECSTREAM *rstrm; - char *addr; - int len; -{ - size_t current; - - if (rstrm->nonblock) { - if (len > (int)(rstrm->in_boundry - rstrm->in_finger)) - return FALSE; - memcpy(addr, rstrm->in_finger, (size_t)len); - rstrm->in_finger += len; - return TRUE; - } - - while (len > 0) { - current = (size_t)((long)rstrm->in_boundry - - (long)rstrm->in_finger); - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - memmove(addr, rstrm->in_finger, current); - rstrm->in_finger += current; - addr += current; - len -= current; - } - return (TRUE); -} - -static bool_t /* next two bytes of the input stream are treated as a header */ -set_input_fragment(rstrm) - RECSTREAM *rstrm; -{ - u_int32_t header; - - if (rstrm->nonblock) - return FALSE; - if (! get_input_bytes(rstrm, (char *)(void *)&header, sizeof(header))) - return (FALSE); - header = ntohl(header); - rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; - /* - * Sanity check. Try not to accept wildly incorrect - * record sizes. Unfortunately, the only record size - * we can positively identify as being 'wildly incorrect' - * is zero. Ridiculously large record sizes may look wrong, - * but we don't have any way to be certain that they aren't - * what the client actually intended to send us. - */ - if (header == 0) - return(FALSE); - rstrm->fbtbc = header & (~LAST_FRAG); - return (TRUE); -} - -static bool_t /* consumes input bytes; knows nothing about records! */ -skip_input_bytes(rstrm, cnt) - RECSTREAM *rstrm; - long cnt; -{ - u_int32_t current; - - while (cnt > 0) { - current = (size_t)((long)rstrm->in_boundry - - (long)rstrm->in_finger); - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (u_int32_t)((cnt < current) ? cnt : current); - rstrm->in_finger += current; - cnt -= current; - } - return (TRUE); -} - -static u_int -fix_buf_size(s) - u_int s; -{ - - if (s < 100) - s = 4000; - return (RNDUP(s)); -} - -/* - * Reallocate the input buffer for a non-block stream. - */ -static bool_t -realloc_stream(rstrm, size) - RECSTREAM *rstrm; - int size; -{ - ptrdiff_t diff; - char *buf; - - if (size > rstrm->recvsize) { - buf = realloc(rstrm->in_base, (size_t)size); - if (buf == NULL) - return FALSE; - diff = buf - rstrm->in_base; - rstrm->in_finger += diff; - rstrm->in_base = buf; - rstrm->in_boundry = buf + size; - rstrm->recvsize = size; - rstrm->in_size = size; - } - - return TRUE; -} diff --git a/libtirpc-1.3.1/src/xdr_reference.c b/libtirpc-1.3.1/src/xdr_reference.c deleted file mode 100644 index 13f6410..0000000 --- a/libtirpc-1.3.1/src/xdr_reference.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_reference.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1987, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * "pointers". See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include -#include - -#include -#include - -#if defined(__FreeBSD__) || defined(__NetBSD__) -#include -#endif - -/* - * XDR an indirect pointer - * xdr_reference is for recursively translating a structure that is - * referenced by a pointer inside the structure that is currently being - * translated. pp references a pointer to storage. If *pp is null - * the necessary storage is allocated. - * size is the sizeof the referneced structure. - * proc is the routine to handle the referenced structure. - */ -bool_t -xdr_reference(xdrs, pp, size, proc) - XDR *xdrs; - caddr_t *pp; /* the pointer to work on */ - u_int size; /* size of the object pointed to */ - xdrproc_t proc; /* xdr routine to handle the object */ -{ - caddr_t loc = *pp; - bool_t stat; - - if (loc == NULL) - switch (xdrs->x_op) { - case XDR_FREE: - return (TRUE); - - case XDR_DECODE: - *pp = loc = (caddr_t) mem_alloc(size); - if (loc == NULL) { - warnx("xdr_reference: out of memory"); - return (FALSE); - } - memset(loc, 0, size); - break; - - case XDR_ENCODE: - break; - } - - stat = (*proc)(xdrs, loc); - - if (xdrs->x_op == XDR_FREE) { - mem_free(loc, size); - *pp = NULL; - } - return (stat); -} - - -/* - * xdr_pointer(): - * - * XDR a pointer to a possibly recursive data structure. This - * differs with xdr_reference in that it can serialize/deserialiaze - * trees correctly. - * - * What's sent is actually a union: - * - * union object_pointer switch (boolean b) { - * case TRUE: object_data data; - * case FALSE: void nothing; - * } - * - * > objpp: Pointer to the pointer to the object. - * > obj_size: size of the object. - * > xdr_obj: routine to XDR an object. - * - */ -bool_t -xdr_pointer(xdrs,objpp,obj_size,xdr_obj) - XDR *xdrs; - char **objpp; - u_int obj_size; - xdrproc_t xdr_obj; -{ - - bool_t more_data; - - more_data = (*objpp != NULL); - if (! xdr_bool(xdrs,&more_data)) { - return (FALSE); - } - if (! more_data) { - *objpp = NULL; - return (TRUE); - } - return (xdr_reference(xdrs,objpp,obj_size,xdr_obj)); -} diff --git a/libtirpc-1.3.1/src/xdr_sizeof.c b/libtirpc-1.3.1/src/xdr_sizeof.c deleted file mode 100644 index 79d6707..0000000 --- a/libtirpc-1.3.1/src/xdr_sizeof.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * xdr_sizeof.c - * - * Copyright 1990 Sun Microsystems, Inc. - * - * General purpose routine to see how much space something will use - * when serialized using XDR. - */ - - -#include -#include -#include -#include -#include -#include "un-namespace.h" - -/* ARGSUSED */ -static bool_t -x_putlong(xdrs, longp) - XDR *xdrs; - long *longp; -{ - xdrs->x_handy += BYTES_PER_XDR_UNIT; - return (TRUE); -} - -/* ARGSUSED */ -static bool_t -x_putbytes(xdrs, bp, len) - XDR *xdrs; - char *bp; - u_int len; -{ - xdrs->x_handy += len; - return (TRUE); -} - -static u_int -x_getpostn(xdrs) - XDR *xdrs; -{ - return (xdrs->x_handy); -} - -/* ARGSUSED */ -static bool_t -x_setpostn(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - /* This is not allowed */ - return (FALSE); -} - -static int32_t * -x_inline(xdrs, len) - XDR *xdrs; - u_int len; -{ - if (len == 0) { - return (NULL); - } - if (xdrs->x_op != XDR_ENCODE) { - return (NULL); - } - if (len < (uintptr_t)xdrs->x_base) { - /* x_private was already allocated */ - xdrs->x_handy += len; - return ((int32_t *) xdrs->x_private); - } else { - /* Free the earlier space and allocate new area */ - if (xdrs->x_private) - free(xdrs->x_private); - if ((xdrs->x_private = (caddr_t) malloc(len)) == NULL) { - xdrs->x_base = 0; - return (NULL); - } - xdrs->x_base = (caddr_t)(uintptr_t)len; - xdrs->x_handy += len; - return ((int32_t *) xdrs->x_private); - } -} - -static int -harmless() -{ - /* Always return FALSE/NULL, as the case may be */ - return (0); -} - -static void -x_destroy(xdrs) - XDR *xdrs; -{ - xdrs->x_handy = 0; - xdrs->x_base = 0; - if (xdrs->x_private) { - free(xdrs->x_private); - xdrs->x_private = NULL; - } - return; -} - -unsigned long -xdr_sizeof(func, data) - xdrproc_t func; - void *data; -{ - XDR x; - struct xdr_ops ops; - bool_t stat; - /* to stop ANSI-C compiler from complaining */ - typedef bool_t (* dummyfunc1)(XDR *, long *); - typedef bool_t (* dummyfunc2)(XDR *, caddr_t, u_int); - - ops.x_putlong = x_putlong; - ops.x_putbytes = x_putbytes; - ops.x_inline = x_inline; - ops.x_getpostn = x_getpostn; - ops.x_setpostn = x_setpostn; - ops.x_destroy = x_destroy; - - /* the other harmless ones */ - ops.x_getlong = (dummyfunc1) harmless; - ops.x_getbytes = (dummyfunc2) harmless; - - x.x_op = XDR_ENCODE; - x.x_ops = &ops; - x.x_handy = 0; - x.x_private = (caddr_t) NULL; - x.x_base = (caddr_t) 0; - - stat = func(&x, data); - if (x.x_private) - free(x.x_private); - return (stat == TRUE ? (unsigned) x.x_handy: 0); -} diff --git a/libtirpc-1.3.1/src/xdr_stdio.c b/libtirpc-1.3.1/src/xdr_stdio.c deleted file mode 100644 index 846c7bf..0000000 --- a/libtirpc-1.3.1/src/xdr_stdio.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include -#include - -#include -#include -#include -#include "un-namespace.h" - -static void xdrstdio_destroy(XDR *); -static bool_t xdrstdio_getlong(XDR *, long *); -static bool_t xdrstdio_putlong(XDR *, const long *); -static bool_t xdrstdio_getbytes(XDR *, char *, u_int); -static bool_t xdrstdio_putbytes(XDR *, const char *, u_int); -static u_int xdrstdio_getpos(XDR *); -static bool_t xdrstdio_setpos(XDR *, u_int); -static int32_t *xdrstdio_inline(XDR *, u_int); - -/* - * Ops vector for stdio type XDR - */ -static const struct xdr_ops xdrstdio_ops = { - xdrstdio_getlong, /* deseraialize a long int */ - xdrstdio_putlong, /* seraialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy /* destroy stream */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create(xdrs, file, op) - XDR *xdrs; - FILE *file; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = &xdrstdio_ops; - xdrs->x_private = file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy(xdrs) - XDR *xdrs; -{ - (void)fflush((FILE *)xdrs->x_private); - /* XXX: should we close the file ?? */ -} - -static bool_t -xdrstdio_getlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - int32_t mycopy; - - if (fread(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - - *lp = (long)ntohl(mycopy); - return (TRUE); -} - -static bool_t -xdrstdio_putlong(xdrs, lp) - XDR *xdrs; - const long *lp; -{ - int32_t mycopy; - -#if defined(_LP64) - if ((*lp > UINT32_MAX) || (*lp < INT32_MIN)) - return (FALSE); -#endif - - mycopy = (int32_t)htonl((int32_t)*lp); - if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_getbytes(xdrs, addr, len) - XDR *xdrs; - char *addr; - u_int len; -{ - - if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_putbytes(xdrs, addr, len) - XDR *xdrs; - const char *addr; - u_int len; -{ - - if ((len != 0) && (fwrite(addr, (size_t)len, 1, - (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static u_int -xdrstdio_getpos(xdrs) - XDR *xdrs; -{ - - return ((u_int) ftell((FILE *)xdrs->x_private)); -} - -static bool_t -xdrstdio_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - - return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? - FALSE : TRUE); -} - -/* ARGSUSED */ -static int32_t * -xdrstdio_inline(xdrs, len) - XDR *xdrs; - u_int len; -{ - - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return (NULL); -} diff --git a/libtirpc-1.3.1/tirpc/getpeereid.h b/libtirpc-1.3.1/tirpc/getpeereid.h deleted file mode 100644 index 025143f..0000000 --- a/libtirpc-1.3.1/tirpc/getpeereid.h +++ /dev/null @@ -1,2 +0,0 @@ - -int getpeereid(int s, uid_t *euid, gid_t *egid); diff --git a/libtirpc-1.3.1/tirpc/libc_private.h b/libtirpc-1.3.1/tirpc/libc_private.h deleted file mode 100644 index e69de29..0000000 diff --git a/libtirpc-1.3.1/tirpc/netconfig.h b/libtirpc-1.3.1/tirpc/netconfig.h deleted file mode 100644 index 3f1a685..0000000 --- a/libtirpc-1.3.1/tirpc/netconfig.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _NETCONFIG_H_ -#define _NETCONFIG_H_ - -#ifdef HAVE_FEATURES_H -#include -#endif - -#define NETCONFIG "/etc/netconfig" -#define NETPATH "NETPATH" - -struct netconfig { - char *nc_netid; /* Network ID */ - unsigned long nc_semantics; /* Semantics (see below) */ - unsigned long nc_flag; /* Flags (see below) */ - char *nc_protofmly; /* Protocol family */ - char *nc_proto; /* Protocol name */ - char *nc_device; /* Network device pathname */ - unsigned long nc_nlookups; /* Number of directory lookup libs */ - char **nc_lookups; /* Names of the libraries */ - unsigned long nc_unused[9]; /* reserved */ -}; - -typedef struct { - struct netconfig **nc_head; - struct netconfig **nc_curr; -} NCONF_HANDLE; - -/* - * nc_semantics values - */ -#define NC_TPI_CLTS 1 -#define NC_TPI_COTS 2 -#define NC_TPI_COTS_ORD 3 -#define NC_TPI_RAW 4 - -/* - * nc_flag values - */ -#define NC_NOFLAG 0x00 -#define NC_VISIBLE 0x01 -#define NC_BROADCAST 0x02 - -/* - * nc_protofmly values - */ -#define NC_NOPROTOFMLY "-" -#define NC_LOOPBACK "loopback" -#define NC_INET "inet" -#define NC_INET6 "inet6" -#define NC_IMPLINK "implink" -#define NC_PUP "pup" -#define NC_CHAOS "chaos" -#define NC_NS "ns" -#define NC_NBS "nbs" -#define NC_ECMA "ecma" -#define NC_DATAKIT "datakit" -#define NC_CCITT "ccitt" -#define NC_SNA "sna" -#define NC_DECNET "decnet" -#define NC_DLI "dli" -#define NC_LAT "lat" -#define NC_HYLINK "hylink" -#define NC_APPLETALK "appletalk" -#define NC_NIT "nit" -#define NC_IEEE802 "ieee802" -#define NC_OSI "osi" -#define NC_X25 "x25" -#define NC_OSINET "osinet" -#define NC_GOSIP "gosip" - -/* - * nc_proto values - */ -#define NC_NOPROTO "-" -#define NC_TCP "tcp" -#define NC_UDP "udp" -#define NC_ICMP "icmp" - -#ifdef __cplusplus -extern "C" { -#endif - -extern void *setnetconfig (void); -extern struct netconfig *getnetconfig (void *); -extern struct netconfig *getnetconfigent (const char *); -extern void freenetconfigent (struct netconfig *); -extern int endnetconfig (void *); - -extern void *setnetpath (void); -extern struct netconfig *getnetpath (void *); -extern int endnetpath (void *); - -extern void nc_perror (const char *); -extern char *nc_sperror (void); - -#ifdef __cplusplus -} -#endif - -#endif /* _NETCONFIG_H_ */ diff --git a/libtirpc-1.3.1/tirpc/reentrant.h b/libtirpc-1.3.1/tirpc/reentrant.h deleted file mode 100644 index 5bb581a..0000000 --- a/libtirpc-1.3.1/tirpc/reentrant.h +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * Copyright (c) 1997,98 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * This file was derived from a copy in FreeBSD CVS on August 26, 2010. - * FreeBSD/NetBSD have slightly different definitions for some/most of - * these functions and types, so they should just use the ones found - * in their system copy of reentrant.h. - * These definitions are only guaranteed to be valid on Linux. - */ - -#if defined(__linux__) - -#include - -#define mutex_t pthread_mutex_t -#define cond_t pthread_cond_t -#define rwlock_t pthread_rwlock_t -#define once_t pthread_once_t - -#define thread_key_t pthread_key_t - -#define KEY_INITIALIZER ((thread_key_t)-1) -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER -#define ONCE_INITIALIZER PTHREAD_ONCE_INIT - -#define mutex_init(m, a) pthread_mutex_init(m, a) -#define mutex_lock(m) pthread_mutex_lock(m) -#define mutex_unlock(m) pthread_mutex_unlock(m) - -#define cond_init(c, a, p) pthread_cond_init(c, a) -#define cond_destroy(c) pthread_cond_destroy(c) -#define cond_signal(m) pthread_cond_signal(m) -#define cond_broadcast(m) pthread_cond_broadcast(m) -#define cond_wait(c, m) pthread_cond_wait(c, m) - -#define rwlock_init(l, a) pthread_rwlock_init(l, a) -#define rwlock_rdlock(l) pthread_rwlock_rdlock(l) -#define rwlock_wrlock(l) pthread_rwlock_wrlock(l) -#define rwlock_unlock(l) pthread_rwlock_unlock(l) - -#define thr_keycreate(k, d) pthread_key_create(k, d) -#define thr_setspecific(k, p) pthread_setspecific(k, p) -#define thr_getspecific(k) pthread_getspecific(k) -#define thr_sigsetmask(f, n, o) pthread_sigmask(f, n, o) - -#define thr_once(o, i) pthread_once(o, i) -#define thr_self() pthread_self() -#define thr_exit(x) pthread_exit(x) - -#endif diff --git a/libtirpc-1.3.1/tirpc/rpc/auth.h b/libtirpc-1.3.1/tirpc/rpc/auth.h deleted file mode 100644 index 5f8ea72..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/auth.h +++ /dev/null @@ -1,380 +0,0 @@ -/* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)auth.h 1.17 88/02/08 SMI - * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC - * from: @(#)auth.h 1.43 98/02/02 SMI - * $FreeBSD: src/include/rpc/auth.h,v 1.20 2003/01/01 18:48:42 schweikh Exp $ - */ - -/* - * auth.h, Authentication interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The data structures are completely opaque to the client. The client - * is required to pass an AUTH * to routines that create rpc - * "sessions". - */ - -#ifndef _TIRPC_AUTH_H -#define _TIRPC_AUTH_H - -#include -#include -#include -#include - - -#define MAX_AUTH_BYTES 400 -#define MAXNETNAMELEN 255 /* maximum length of network user's name */ - -/* - * Client side authentication/security data - */ - -typedef struct sec_data { - u_int secmod; /* security mode number e.g. in nfssec.conf */ - u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ - int flags; /* AUTH_F_xxx flags */ - caddr_t data; /* opaque data per flavor */ -} sec_data_t; - -#ifdef _SYSCALL32_IMPL -struct sec_data32 { - uint32_t secmod; /* security mode number e.g. in nfssec.conf */ - uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ - int32_t flags; /* AUTH_F_xxx flags */ - caddr32_t data; /* opaque data per flavor */ -}; -#endif /* _SYSCALL32_IMPL */ - -/* - * AUTH_DES flavor specific data from sec_data opaque data field. - * AUTH_KERB has the same structure. - */ -typedef struct des_clnt_data { - struct netbuf syncaddr; /* time sync addr */ - struct knetconfig *knconf; /* knetconfig info that associated */ - /* with the syncaddr. */ - char *netname; /* server's netname */ - int netnamelen; /* server's netname len */ -} dh_k4_clntdata_t; - -#ifdef _SYSCALL32_IMPL -struct des_clnt_data32 { - struct netbuf32 syncaddr; /* time sync addr */ - caddr32_t knconf; /* knetconfig info that associated */ - /* with the syncaddr. */ - caddr32_t netname; /* server's netname */ - int32_t netnamelen; /* server's netname len */ -}; -#endif /* _SYSCALL32_IMPL */ - -/* - * authentication/security specific flags - */ -#define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ -#define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ - - -/* - * Status returned from authentication check - */ -enum auth_stat { - AUTH_OK=0, - /* - * failed at remote end - */ - AUTH_BADCRED=1, /* bogus credentials (seal broken) */ - AUTH_REJECTEDCRED=2, /* client should begin new session */ - AUTH_BADVERF=3, /* bogus verifier (seal broken) */ - AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ - AUTH_TOOWEAK=5, /* rejected due to security reasons */ - /* - * failed locally - */ - AUTH_INVALIDRESP=6, /* bogus response verifier */ - AUTH_FAILED=7, /* some unknown reason */ - /* - * kerberos errors - */ - AUTH_KERB_GENERIC = 8, /* kerberos generic error */ - AUTH_TIMEEXPIRE = 9, /* time of credential expired */ - AUTH_TKT_FILE = 10, /* something wrong with ticket file */ - AUTH_DECODE = 11, /* can't decode authenticator */ - AUTH_NET_ADDR = 12, /* wrong net address in ticket */ - /* - * RPCSEC_GSS errors - */ - RPCSEC_GSS_CREDPROBLEM = 13, - RPCSEC_GSS_CTXPROBLEM = 14 - -}; - -typedef u_int32_t u_int32; /* 32-bit unsigned integers */ - -union des_block { - struct { - u_int32_t high; - u_int32_t low; - } key; - char c[8]; -}; -typedef union des_block des_block; -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_des_block(XDR *, des_block *); -#ifdef __cplusplus -} -#endif - -/* - * Authentication info. Opaque to client. - */ -struct opaque_auth { - enum_t oa_flavor; /* flavor of auth */ - caddr_t oa_base; /* address of more auth stuff */ - u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ -}; - - -/* - * Auth handle, interface to client side authenticators. - */ -typedef struct __auth { - struct opaque_auth ah_cred; - struct opaque_auth ah_verf; - union des_block ah_key; - struct auth_ops { - void (*ah_nextverf) (struct __auth *); - /* nextverf & serialize */ - int (*ah_marshal) (struct __auth *, XDR *); - /* validate verifier */ - int (*ah_validate) (struct __auth *, - struct opaque_auth *); - /* refresh credentials */ - int (*ah_refresh) (struct __auth *, void *); - /* destroy this structure */ - void (*ah_destroy) (struct __auth *); - /* encode data for wire */ - int (*ah_wrap) (struct __auth *, XDR *, xdrproc_t, caddr_t); - /* decode data for wire */ - int (*ah_unwrap) (struct __auth *, XDR *, xdrproc_t, caddr_t); - - } *ah_ops; - void *ah_private; -} AUTH; - -/* - * Authentication ops. - * The ops and the auth handle provide the interface to the authenticators. - * - * AUTH *auth; - * XDR *xdrs; - * struct opaque_auth verf; - */ -#define AUTH_NEXTVERF(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) -#define auth_nextverf(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) - -#define AUTH_MARSHALL(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) -#define auth_marshall(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) - -#define AUTH_VALIDATE(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define auth_validate(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) - -#define AUTH_REFRESH(auth, msg) \ - ((*((auth)->ah_ops->ah_refresh))(auth, msg)) -#define auth_refresh(auth, msg) \ - ((*((auth)->ah_ops->ah_refresh))(auth, msg)) - -#define AUTH_DESTROY(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)); -#define auth_destroy(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)); - -#define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ - xfunc, xwhere)) -#define auth_wrap(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ - xfunc, xwhere)) - -#define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ - xfunc, xwhere)) -#define auth_unwrap(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ - xfunc, xwhere)) - - -#ifdef __cplusplus -extern "C" { -#endif -extern struct opaque_auth _null_auth; -#ifdef __cplusplus -} -#endif - -/* - * Any style authentication. These routines can be used by any - * authentication style that does not use the wrap/unwrap functions. - */ -int authany_wrap(void), authany_unwrap(void); - -/* - * These are the various implementations of client side authenticators. - */ - -/* - * System style authentication - * AUTH *authunix_create(machname, uid, gid, len, aup_gids) - * char *machname; - * int uid; - * int gid; - * int len; - * int *aup_gids; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern AUTH *authunix_create(char *, uid_t, uid_t, int, uid_t *); -extern AUTH *authunix_create_default(void); /* takes no parameters */ -extern AUTH *authnone_create(void); /* takes no parameters */ -#ifdef __cplusplus -} -#endif -/* - * DES style authentication - * AUTH *authsecdes_create(servername, window, timehost, ckey) - * char *servername; - network name of server - * u_int window; - time to live - * const char *timehost; - optional hostname to sync with - * des_block *ckey; - optional conversation key to use - */ -#ifdef __cplusplus -extern "C" { -#endif -extern AUTH *authdes_create (char *, u_int, struct sockaddr *, des_block *); -extern AUTH *authdes_pk_create (char *, netobj *, u_int, - struct sockaddr *, des_block *); -extern AUTH *authdes_seccreate (const char *, const u_int, const char *, - const des_block *); -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); -#ifdef __cplusplus -} -#endif - -#define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) -#define authsys_create_default() authunix_create_default() - -/* - * Netname manipulation routines. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern int getnetname(char *); -extern int host2netname(char *, const char *, const char *); -extern int user2netname(char *, const uid_t, const char *); -extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); -extern int netname2host(char *, char *, const int); -extern void passwd2des ( char *, char * ); -#ifdef __cplusplus -} -#endif - -/* - * - * These routines interface to the keyserv daemon - * - */ -#ifdef __cplusplus -extern "C" { -#endif -extern int key_decryptsession(const char *, des_block *); -extern int key_encryptsession(const char *, des_block *); -extern int key_gendes(des_block *); -extern int key_setsecret(const char *); -extern int key_secretkey_is_set(void); -#ifdef __cplusplus -} -#endif - -/* - * Publickey routines. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern int getpublickey (const char *, char *); -extern int getpublicandprivatekey (char *, char *); -extern int getsecretkey (char *, char *, char *); -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif -struct svc_req; -struct rpc_msg; -enum auth_stat _svcauth_none (struct svc_req *, struct rpc_msg *); -enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *); -enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *); -enum auth_stat _svcauth_gss (struct svc_req *, struct rpc_msg *, bool_t *); -#ifdef __cplusplus -} -#endif - -#define AUTH_NONE 0 /* no authentication */ -#define AUTH_NULL 0 /* backward compatibility */ -#define AUTH_SYS 1 /* unix style (uid, gids) */ -#define AUTH_UNIX AUTH_SYS -#define AUTH_SHORT 2 /* short hand unix style */ -#define AUTH_DH 3 /* for Diffie-Hellman mechanism */ -#define AUTH_DES AUTH_DH /* for backward compatibility */ -#define AUTH_KERB 4 /* kerberos style */ -#define RPCSEC_GSS 6 /* RPCSEC_GSS */ - -#endif /* !_TIRPC_AUTH_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/auth_des.h b/libtirpc-1.3.1/tirpc/rpc/auth_des.h deleted file mode 100644 index 3b1cb47..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/auth_des.h +++ /dev/null @@ -1,123 +0,0 @@ -/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ -/* $FreeBSD: src/include/rpc/auth_des.h,v 1.3 2002/03/23 17:24:55 imp Exp $ */ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC - * from: @(#)auth_des.h 1.14 94/04/25 SMI - */ - -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * auth_des.h, Protocol for DES style authentication for RPC - */ - -#ifndef _TI_AUTH_DES_ -#define _TI_AUTH_DES_ - -#include - -/* - * There are two kinds of "names": fullnames and nicknames - */ -enum authdes_namekind { - ADN_FULLNAME, - ADN_NICKNAME -}; - -/* - * A fullname contains the network name of the client, - * a conversation key and the window - */ -struct authdes_fullname { - char *name; /* network name of client, up to MAXNETNAMELEN */ - union des_block key; /* conversation key */ - /* u_long window; */ - u_int32_t window; /* associated window */ -}; - - -/* - * A credential - */ -struct authdes_cred { - enum authdes_namekind adc_namekind; - struct authdes_fullname adc_fullname; - /*u_long adc_nickname;*/ - u_int32_t adc_nickname; -}; - - - -/* - * A des authentication verifier - */ -struct authdes_verf { - union { - struct timeval adv_ctime; /* clear time */ - des_block adv_xtime; /* crypt time */ - } adv_time_u; - /*u_long adv_int_u;*/ - u_int32_t adv_int_u; -}; - -/* - * des authentication verifier: client variety - * - * adv_timestamp is the current time. - * adv_winverf is the credential window + 1. - * Both are encrypted using the conversation key. - */ -#define adv_timestamp adv_time_u.adv_ctime -#define adv_xtimestamp adv_time_u.adv_xtime -#define adv_winverf adv_int_u - -/* - * des authentication verifier: server variety - * - * adv_timeverf is the client's timestamp + client's window - * adv_nickname is the server's nickname for the client. - * adv_timeverf is encrypted using the conversation key. - */ -#define adv_timeverf adv_time_u.adv_ctime -#define adv_xtimeverf adv_time_u.adv_xtime -#define adv_nickname adv_int_u - -#ifdef __cplusplus -extern "C" { -#endif -extern int rtime(struct sockaddr_in *, struct timeval *, - struct timeval *); -extern void kgetnetname(char *); -#ifdef __cplusplus -} -#endif - -#endif /* ndef _TI_AUTH_DES_ */ diff --git a/libtirpc-1.3.1/tirpc/rpc/auth_gss.h b/libtirpc-1.3.1/tirpc/rpc/auth_gss.h deleted file mode 100644 index 5316ed6..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/auth_gss.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - auth_gss.h - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef _TIRPC_AUTH_GSS_H -#define _TIRPC_AUTH_GSS_H - -#include -#include - -/* RPCSEC_GSS control procedures. */ -typedef enum { - RPCSEC_GSS_DATA = 0, - RPCSEC_GSS_INIT = 1, - RPCSEC_GSS_CONTINUE_INIT = 2, - RPCSEC_GSS_DESTROY = 3 -} rpc_gss_proc_t; - -/* RPCSEC_GSS services. */ -typedef enum { - RPCSEC_GSS_SVC_NONE = 1, - RPCSEC_GSS_SVC_INTEGRITY = 2, - RPCSEC_GSS_SVC_PRIVACY = 3 -} rpc_gss_svc_t; - -#define RPCSEC_GSS_VERSION 1 - -/* RPCSEC_GSS security triple. */ -struct rpc_gss_sec { - gss_OID mech; /* mechanism */ - gss_qop_t qop; /* quality of protection */ - rpc_gss_svc_t svc; /* service */ - gss_cred_id_t cred; /* cred handle */ - u_int req_flags; /* req flags for init_sec_context */ -}; - -/* Private data required for kernel implementation */ -struct authgss_private_data { - gss_ctx_id_t pd_ctx; /* Session context handle */ - gss_buffer_desc pd_ctx_hndl; /* Credentials context handle */ - u_int pd_seq_win; /* Sequence window */ -}; - -/* from kerberos source, gssapi_krb5.c */ -extern gss_OID_desc krb5oid; -extern gss_OID_desc spkm3oid; - -/* Credentials. */ -struct rpc_gss_cred { - u_int gc_v; /* version */ - rpc_gss_proc_t gc_proc; /* control procedure */ - u_int gc_seq; /* sequence number */ - rpc_gss_svc_t gc_svc; /* service */ - gss_buffer_desc gc_ctx; /* context handle */ -}; - -/* Context creation response. */ -struct rpc_gss_init_res { - gss_buffer_desc gr_ctx; /* context handle */ - u_int gr_major; /* major status */ - u_int gr_minor; /* minor status */ - u_int gr_win; /* sequence window */ - gss_buffer_desc gr_token; /* token */ -}; - -/* Maximum sequence number value. */ -#define MAXSEQ 0x80000000 - -/* Prototypes. */ -#ifdef __cplusplus -extern "C" { -#endif -bool_t xdr_rpc_gss_cred (XDR *xdrs, struct rpc_gss_cred *p); -bool_t xdr_rpc_gss_init_args (XDR *xdrs, gss_buffer_desc *p); -bool_t xdr_rpc_gss_init_res (XDR *xdrs, struct rpc_gss_init_res *p); -bool_t xdr_rpc_gss_data (XDR *xdrs, xdrproc_t xdr_func, - caddr_t xdr_ptr, gss_ctx_id_t ctx, - gss_qop_t qop, rpc_gss_svc_t svc, - u_int seq); - -AUTH *authgss_create (CLIENT *, gss_name_t, struct rpc_gss_sec *); -AUTH *authgss_create_default (CLIENT *, char *, struct rpc_gss_sec *); -bool_t authgss_service (AUTH *auth, int svc); -bool_t authgss_get_private_data (AUTH *auth, struct authgss_private_data *); -bool_t authgss_free_private_data (struct authgss_private_data *); - -void gss_log_debug (const char *fmt, ...); -void gss_log_status (char *m, OM_uint32 major, OM_uint32 minor); -void gss_log_hexdump (const u_char *buf, int len, int offset); - -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_AUTH_GSS_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/auth_unix.h b/libtirpc-1.3.1/tirpc/rpc/auth_unix.h deleted file mode 100644 index b10e71d..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/auth_unix.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)auth_unix.h 1.8 88/02/08 SMI - * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/auth_unix.h,v 1.11 2002/03/23 17:24:55 imp Exp $ - */ - -/* - * auth_unix.h, Protocol for UNIX style authentication parameters for RPC - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * The system is very weak. The client uses no encryption for it - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - */ - -#ifndef _TIRPC_AUTH_UNIX_H -#define _TIRPC_AUTH_UNIX_H - -/* The machine name is part of a credential; it may not exceed 255 bytes */ -#define MAX_MACHINE_NAME 255 - -/* gids compose part of a credential; there may not be more than 16 of them */ -#define NGRPS 16 - -/* - * Unix style credentials. - */ -struct authunix_parms { - u_long aup_time; - char *aup_machname; - uid_t aup_uid; - gid_t aup_gid; - u_int aup_len; - gid_t *aup_gids; -}; - -#define authsys_parms authunix_parms - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); -#ifdef __cplusplus -} -#endif - -/* - * If a response verifier has flavor AUTH_SHORT, - * then the body of the response verifier encapsulates the following structure; - * again it is serialized in the obvious fashion. - */ -struct short_hand_verf { - struct opaque_auth new_cred; -}; - -#endif /* !_TIRPC_AUTH_UNIX_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/clnt.h b/libtirpc-1.3.1/tirpc/rpc/clnt.h deleted file mode 100644 index 05f2215..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/clnt.h +++ /dev/null @@ -1,567 +0,0 @@ -/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)clnt.h 1.31 94/04/29 SMI - * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ - */ - -/* - * clnt.h - Client side remote procedure call interface. - */ - -#ifndef _TIRPC_CLNT_H_ -#define _TIRPC_CLNT_H_ - -#include -#include - -#include -#include - -/* - * Well-known IPV6 RPC broadcast address. - */ -#define RPCB_MULTICAST_ADDR "ff02::202" - -/* - * the following errors are in general unrecoverable. The caller - * should give up rather than retry. - */ -#define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ - ((s) == RPC_CANTENCODEARGS) || \ - ((s) == RPC_CANTDECODERES) || \ - ((s) == RPC_VERSMISMATCH) || \ - ((s) == RPC_PROCUNAVAIL) || \ - ((s) == RPC_PROGUNAVAIL) || \ - ((s) == RPC_PROGVERSMISMATCH) || \ - ((s) == RPC_CANTDECODEARGS)) - -/* - * Error info. - */ -struct rpc_err { - enum clnt_stat re_status; - union { - int RE_errno; /* related system error */ - enum auth_stat RE_why; /* why the auth error occurred */ - struct { - rpcvers_t low; /* lowest version supported */ - rpcvers_t high; /* highest version supported */ - } RE_vers; - struct { /* maybe meaningful if RPC_FAILED */ - int32_t s1; - int32_t s2; - } RE_lb; /* life boot & debugging only */ - } ru; -#define re_errno ru.RE_errno -#define re_why ru.RE_why -#define re_vers ru.RE_vers -#define re_lb ru.RE_lb -}; - - -/* - * Client rpc handle. - * Created by individual implementations - * Client is responsible for initializing auth, see e.g. auth_none.c. - */ -typedef struct __rpc_client { - AUTH *cl_auth; /* authenticator */ - struct clnt_ops { - /* call remote procedure */ - enum clnt_stat (*cl_call)(struct __rpc_client *, - rpcproc_t, xdrproc_t, void *, xdrproc_t, - void *, struct timeval); - /* abort a call */ - void (*cl_abort)(struct __rpc_client *); - /* get specific error code */ - void (*cl_geterr)(struct __rpc_client *, - struct rpc_err *); - /* frees results */ - bool_t (*cl_freeres)(struct __rpc_client *, - xdrproc_t, void *); - /* destroy this structure */ - void (*cl_destroy)(struct __rpc_client *); - /* the ioctl() of rpc */ - bool_t (*cl_control)(struct __rpc_client *, u_int, - void *); - } *cl_ops; - void *cl_private; /* private stuff */ - char *cl_netid; /* network token */ - char *cl_tp; /* device name */ -} CLIENT; - - -/* - * Timers used for the pseudo-transport protocol when using datagrams - */ -struct rpc_timers { - u_short rt_srtt; /* smoothed round-trip time */ - u_short rt_deviate; /* estimated deviation */ - u_long rt_rtxcur; /* current (backed-off) rto */ -}; - -/* - * Feedback values used for possible congestion and rate control - */ -#define FEEDBACK_REXMIT1 1 /* first retransmit */ -#define FEEDBACK_OK 2 /* no retransmits */ - -/* Used to set version of portmapper used in broadcast */ - -#define CLCR_SET_LOWVERS 3 -#define CLCR_GET_LOWVERS 4 - -#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ - -/* - * client side rpc interface ops - * - * Parameter types are: - * - */ - -/* - * enum clnt_stat - * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) - * CLIENT *rh; - * rpcproc_t proc; - * xdrproc_t xargs; - * void *argsp; - * xdrproc_t xres; - * void *resp; - * struct timeval timeout; - */ -#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ - argsp, xres, resp, secs)) -#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ - argsp, xres, resp, secs)) - -/* - * void - * CLNT_ABORT(rh); - * CLIENT *rh; - */ -#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) -#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) - -/* - * struct rpc_err - * CLNT_GETERR(rh); - * CLIENT *rh; - */ -#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) -#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) - - -/* - * bool_t - * CLNT_FREERES(rh, xres, resp); - * CLIENT *rh; - * xdrproc_t xres; - * void *resp; - */ -#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) -#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) - -/* - * bool_t - * CLNT_CONTROL(cl, request, info) - * CLIENT *cl; - * u_int request; - * char *info; - */ -#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) -#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) - -/* - * control operations that apply to both udp and tcp transports - */ -#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ -#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ -#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ -#define CLGET_FD 6 /* get connections file descriptor */ -#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ -#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ -#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ -#define CLGET_XID 10 /* Get xid */ -#define CLSET_XID 11 /* Set xid */ -#define CLGET_VERS 12 /* Get version number */ -#define CLSET_VERS 13 /* Set version number */ -#define CLGET_PROG 14 /* Get program number */ -#define CLSET_PROG 15 /* Set program number */ -#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ -#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ -#define CLSET_POP_TIMOD 18 /* pop timod */ -/* - * Connectionless only control operations - */ -#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ -#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ -#define CLSET_ASYNC 19 -#define CLSET_CONNECT 20 /* Use connect() for UDP. (int) */ - -/* - * void - * CLNT_DESTROY(rh); - * CLIENT *rh; - */ -#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) -#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) - - -/* - * RPCTEST is a test program which is accessible on every rpc - * transport/port. It is used for testing, performance evaluation, - * and network administration. - */ - -#define RPCTEST_PROGRAM ((rpcprog_t)1) -#define RPCTEST_VERSION ((rpcvers_t)1) -#define RPCTEST_NULL_PROC ((rpcproc_t)2) -#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) - -/* - * By convention, procedure 0 takes null arguments and returns them - */ - -#define NULLPROC ((rpcproc_t)0) - -/* - * Below are the client handle creation routines for the various - * implementations of client side rpc. They can return NULL if a - * creation failure occurs. - */ - -/* - * Generic client creation routine. Supported protocols are those that - * belong to the nettype namespace (/etc/netconfig). - */ -#ifdef __cplusplus -extern "C" { -#endif -extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, - const char *); -/* - * - * const char *hostname; -- hostname - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const char *nettype; -- network type - */ - - /* - * Generic client creation routine. Just like clnt_create(), except - * it takes an additional timeout parameter. - */ -extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, - const rpcvers_t, const char *, const struct timeval *); -/* - * - * const char *hostname; -- hostname - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const char *nettype; -- network type - * const struct timeval *tp; -- timeout - */ - -/* - * Generic client creation routine. Supported protocols are which belong - * to the nettype name space. - */ -extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, - const rpcvers_t, const rpcvers_t, - const char *); -/* - * const char *host; -- hostname - * const rpcprog_t prog; -- program number - * rpcvers_t *vers_out; -- servers highest available version - * const rpcvers_t vers_low; -- low version number - * const rpcvers_t vers_high; -- high version number - * const char *nettype; -- network type - */ - -/* - * Generic client creation routine. Supported protocols are which belong - * to the nettype name space. - */ -extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, - rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, - const struct timeval *); -/* - * const char *host; -- hostname - * const rpcprog_t prog; -- program number - * rpcvers_t *vers_out; -- servers highest available version - * const rpcvers_t vers_low; -- low version number - * const rpcvers_t vers_high; -- high version number - * const char *nettype; -- network type - * const struct timeval *tp -- timeout - */ - -/* - * Generic client creation routine. It takes a netconfig structure - * instead of nettype - */ -extern CLIENT *clnt_tp_create(const char *, const rpcprog_t, - const rpcvers_t, const struct netconfig *); -/* - * const char *hostname; -- hostname - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const struct netconfig *netconf; -- network config structure - */ - -/* - * Generic client creation routine. Just like clnt_tp_create(), except - * it takes an additional timeout parameter. - */ -extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, - const rpcvers_t, const struct netconfig *, const struct timeval *); -/* - * const char *hostname; -- hostname - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const struct netconfig *netconf; -- network config structure - * const struct timeval *tp -- timeout - */ - -/* - * Generic TLI create routine. Only provided for compatibility. - */ - -extern CLIENT *clnt_tli_create(const int, const struct netconfig *, - struct netbuf *, const rpcprog_t, - const rpcvers_t, const u_int, const u_int); -/* - * const register int fd; -- fd - * const struct netconfig *nconf; -- netconfig structure - * struct netbuf *svcaddr; -- servers address - * const u_long prog; -- program number - * const u_long vers; -- version number - * const u_int sendsz; -- send size - * const u_int recvsz; -- recv size - */ - -/* - * Low level clnt create routine for connectionful transports, e.g. tcp. - */ -extern CLIENT *clnt_vc_create(const int, const struct netbuf *, - const rpcprog_t, const rpcvers_t, - u_int, u_int); -/* - * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). - */ -extern CLIENT *clntunix_create(struct sockaddr_un *, - u_long, u_long, int *, u_int, u_int); -/* - * const int fd; -- open file descriptor - * const struct netbuf *svcaddr; -- servers address - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const u_int sendsz; -- buffer recv size - * const u_int recvsz; -- buffer send size - */ - -/* - * Low level clnt create routine for connectionless transports, e.g. udp. - */ -extern CLIENT *clnt_dg_create(const int, const struct netbuf *, - const rpcprog_t, const rpcvers_t, - const u_int, const u_int); -/* - * const int fd; -- open file descriptor - * const struct netbuf *svcaddr; -- servers address - * const rpcprog_t program; -- program number - * const rpcvers_t version; -- version number - * const u_int sendsz; -- buffer recv size - * const u_int recvsz; -- buffer send size - */ - -/* - * Memory based rpc (for speed check and testing) - * CLIENT * - * clnt_raw_create(prog, vers) - * u_long prog; - * u_long vers; - */ -extern CLIENT *clnt_raw_create(rpcprog_t, rpcvers_t); - -#ifdef __cplusplus -} -#endif - - -/* - * Print why creation failed - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void clnt_pcreateerror(const char *); /* stderr */ -extern char *clnt_spcreateerror(const char *); /* string */ -#ifdef __cplusplus -} -#endif - -/* - * Like clnt_perror(), but is more verbose in its output - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void clnt_perrno(enum clnt_stat); /* stderr */ -extern char *clnt_sperrno(enum clnt_stat); /* string */ -#ifdef __cplusplus -} -#endif - -/* - * Print an English error message, given the client error code - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void clnt_perror(CLIENT *, const char *); /* stderr */ -extern char *clnt_sperror(CLIENT *, const char *); /* string */ -#ifdef __cplusplus -} -#endif - - -/* - * If a creation fails, the following allows the user to figure out why. - */ -struct rpc_createerr { - enum clnt_stat cf_stat; - struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ -}; - -#ifdef __cplusplus -extern "C" { -#endif -extern struct rpc_createerr *__rpc_createerr(void); -#ifdef __cplusplus -} -#endif -#define get_rpc_createerr() (*(__rpc_createerr())) -#define rpc_createerr (*(__rpc_createerr())) - -/* - * The simplified interface: - * enum clnt_stat - * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) - * const char *host; - * const rpcprog_t prognum; - * const rpcvers_t versnum; - * const rpcproc_t procnum; - * const xdrproc_t inproc, outproc; - * const char *in; - * char *out; - * const char *nettype; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern enum clnt_stat rpc_call(const char *, const rpcprog_t, - const rpcvers_t, const rpcproc_t, - const xdrproc_t, const char *, - const xdrproc_t, char *, const char *); -#ifdef __cplusplus -} -#endif - -/* - * RPC broadcast interface - * The call is broadcasted to all locally connected nets. - * - * extern enum clnt_stat - * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, - * eachresult, nettype) - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const rpcproc_t proc; -- procedure number - * const xdrproc_t xargs; -- xdr routine for args - * caddr_t argsp; -- pointer to args - * const xdrproc_t xresults; -- xdr routine for results - * caddr_t resultsp; -- pointer to results - * const resultproc_t eachresult; -- call with each result - * const char *nettype; -- Transport type - * - * For each valid response received, the procedure eachresult is called. - * Its form is: - * done = eachresult(resp, raddr, nconf) - * bool_t done; - * caddr_t resp; - * struct netbuf *raddr; - * struct netconfig *nconf; - * where resp points to the results of the call and raddr is the - * address if the responder to the broadcast. nconf is the transport - * on which the response was received. - * - * extern enum clnt_stat - * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, - * eachresult, inittime, waittime, nettype) - * const rpcprog_t prog; -- program number - * const rpcvers_t vers; -- version number - * const rpcproc_t proc; -- procedure number - * const xdrproc_t xargs; -- xdr routine for args - * caddr_t argsp; -- pointer to args - * const xdrproc_t xresults; -- xdr routine for results - * caddr_t resultsp; -- pointer to results - * const resultproc_t eachresult; -- call with each result - * const int inittime; -- how long to wait initially - * const int waittime; -- maximum time to wait - * const char *nettype; -- Transport type - */ - -typedef bool_t (*resultproc_t)(caddr_t, ...); - -#ifdef __cplusplus -extern "C" { -#endif -extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, - const rpcproc_t, const xdrproc_t, - caddr_t, const xdrproc_t, caddr_t, - const resultproc_t, const char *); -extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, - const rpcproc_t, const xdrproc_t, - caddr_t, const xdrproc_t, caddr_t, - const resultproc_t, const int, - const int, const char *); -#ifdef __cplusplus -} -#endif - -/* For backward compatibility */ -#include - -#endif /* !_TIRPC_CLNT_H_ */ diff --git a/libtirpc-1.3.1/tirpc/rpc/clnt_soc.h b/libtirpc-1.3.1/tirpc/rpc/clnt_soc.h deleted file mode 100644 index 6ec545c..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/clnt_soc.h +++ /dev/null @@ -1,137 +0,0 @@ -/* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/clnt_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. - */ - -/* - * clnt.h - Client side remote procedure call interface. - */ - -#ifndef _RPC_CLNT_SOC_H -#define _RPC_CLNT_SOC_H - -/* derived from clnt_soc.h 1.3 88/12/17 SMI */ - -/* - * All the following declarations are only for backward compatibility - * with TS-RPC. - */ - - -#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ - -/* - * TCP based rpc - * CLIENT * - * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long prog; - * u_long version; - * register int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, int *, - u_int, u_int); -#ifdef __cplusplus -} -#endif - -/* - * Raw (memory) rpc. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern CLIENT *clntraw_create(u_long, u_long); -#ifdef __cplusplus -} -#endif - - -/* -IPv6 socket version -*/ -#ifdef INET6 -#ifdef __cplusplus -extern "C" { -#endif -extern CLIENT *clnttcp6_create(struct sockaddr_in6 *, u_long, u_long, int *, - u_int, u_int); -#ifdef __cplusplus -} -#endif -#endif - -/* - * UDP based rpc. - * CLIENT * - * clntudp_create(raddr, program, version, wait, sockp) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * - * Same as above, but you specify max packet sizes. - * CLIENT * - * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern CLIENT *clntudp_create(struct sockaddr_in *, u_long, u_long, - struct timeval, int *); -extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, u_long, u_long, - struct timeval, int *, u_int, u_int); -#ifdef INET6 -extern CLIENT *clntudp6_create(struct sockaddr_in6 *, u_long, u_long, - struct timeval, int *); -extern CLIENT *clntudp6_bufcreate(struct sockaddr_in6 *, u_long, u_long, - struct timeval, int *, u_int, u_int); -#endif -#ifdef __cplusplus -} -#endif - - -#endif /* _RPC_CLNT_SOC_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/clnt_stat.h b/libtirpc-1.3.1/tirpc/rpc/clnt_stat.h deleted file mode 100644 index 397bdbc..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/clnt_stat.h +++ /dev/null @@ -1,83 +0,0 @@ -/* $FreeBSD: src/include/rpc/clnt_stat.h,v 1.2 2001/03/20 08:20:50 alfred Exp $ */ -/* - * Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * clnt_stat.h - Client side remote procedure call enum - * - */ - -#ifndef _RPC_CLNT_STAT_H -#define _RPC_CLNT_STAT_H - -/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */ - -#ifdef __cplusplus -extern "C" { -#endif - -enum clnt_stat { - RPC_SUCCESS = 0, /* call succeeded */ - /* - * local errors - */ - RPC_CANTENCODEARGS = 1, /* can't encode arguments */ - RPC_CANTDECODERES = 2, /* can't decode results */ - RPC_CANTSEND = 3, /* failure in sending call */ - RPC_CANTRECV = 4, - /* failure in receiving result */ - RPC_TIMEDOUT = 5, /* call timed out */ - RPC_INTR = 18, /* call interrupted */ - RPC_UDERROR = 23, /* recv got uderr indication */ - /* - * remote errors - */ - RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ - RPC_AUTHERROR = 7, /* authentication error */ - RPC_PROGUNAVAIL = 8, /* program not available */ - RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ - RPC_PROCUNAVAIL = 10, /* procedure unavailable */ - RPC_CANTDECODEARGS = 11, /* decode arguments error */ - RPC_SYSTEMERROR = 12, /* generic "other problem" */ - - /* - * rpc_call & clnt_create errors - */ - RPC_UNKNOWNHOST = 13, /* unknown host name */ - RPC_UNKNOWNPROTO = 17, /* unknown protocol */ - RPC_UNKNOWNADDR = 19, /* Remote address unknown */ - RPC_NOBROADCAST = 21, /* Broadcasting not supported */ - - /* - * rpcbind errors - */ - RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ -#define RPC_PMAPFAILURE RPC_RPCBFAILURE - RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ - RPC_N2AXLATEFAILURE = 22, - /* Name to address translation failed */ - /* - * Misc error in the TLI library - */ - RPC_TLIERROR = 20, - /* - * unspecified error - */ - RPC_FAILED = 16, - /* - * asynchronous errors - */ - RPC_INPROGRESS = 24, - RPC_STALERACHANDLE = 25, - RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ - RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ - RPC_CANTCREATESTREAM = 28 /* can't push rpc module (cots) */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_CLNT_STAT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/des.h b/libtirpc-1.3.1/tirpc/rpc/des.h deleted file mode 100644 index 018aa48..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/des.h +++ /dev/null @@ -1,87 +0,0 @@ -/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ -/* $FreeBSD: src/include/rpc/des.h,v 1.4 2002/03/23 17:24:55 imp Exp $ */ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Generic DES driver interface - * Keep this file hardware independent! - * Copyright (c) 1986 by Sun Microsystems, Inc. - */ - -#ifndef _RPC_DES_H_ -#define _RPC_DES_H_ - -#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ -#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ - -enum desdir { ENCRYPT, DECRYPT }; -enum desmode { CBC, ECB }; - -/* - * parameters to ioctl call - */ -struct desparams { - u_char des_key[8]; /* key (with low bit parity) */ - enum desdir des_dir; /* direction */ - enum desmode des_mode; /* mode */ - u_char des_ivec[8]; /* input vector */ - unsigned des_len; /* number of bytes to crypt */ - union { - u_char UDES_data[DES_QUICKLEN]; - u_char *UDES_buf; - } UDES; -# define des_data UDES.UDES_data /* direct data here if quick */ -# define des_buf UDES.UDES_buf /* otherwise, pointer to data */ -}; - -#ifdef notdef - -/* - * These ioctls are only implemented in SunOS. Maybe someday - * if somebody writes a driver for DES hardware that works - * with FreeBSD, we can being that back. - */ - -/* - * Encrypt an arbitrary sized buffer - */ -#define DESIOCBLOCK _IOWR('d', 6, struct desparams) - -/* - * Encrypt of small amount of data, quickly - */ -#define DESIOCQUICK _IOWR('d', 7, struct desparams) - -#endif - -/* - * Software DES. - */ -extern int _des_crypt( char *, unsigned, struct desparams * ); - -#endif diff --git a/libtirpc-1.3.1/tirpc/rpc/des_crypt.h b/libtirpc-1.3.1/tirpc/rpc/des_crypt.h deleted file mode 100644 index 2358960..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/des_crypt.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI - * $FreeBSD: src/include/rpc/des_crypt.h,v 1.4 2002/03/23 17:24:55 imp Exp $ - * - * des_crypt.h, des library routine interface - * Copyright (C) 1986, Sun Microsystems, Inc. - */ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * des_crypt.h, des library routine interface - */ - -#ifndef _DES_DES_CRYPT_H -#define _DES_DES_CRYPT_H - -#include - -#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ -#define DES_DIRMASK (1 << 0) -#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ -#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ - - -#define DES_DEVMASK (1 << 1) -#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ -#define DES_SW (1*DES_DEVMASK) /* Use software device */ - - -#define DESERR_NONE 0 /* succeeded */ -#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ -#define DESERR_HWERROR 2 /* failed, hardware/driver error */ -#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ - -#define DES_FAILED(err) \ - ((err) > DESERR_NOHWDEVICE) - -/* - * cbc_crypt() - * ecb_crypt() - * - * Encrypt (or decrypt) len bytes of a buffer buf. - * The length must be a multiple of eight. - * The key should have odd parity in the low bit of each byte. - * ivec is the input vector, and is updated to the new one (cbc only). - * The mode is created by oring together the appropriate parameters. - * DESERR_NOHWDEVICE is returned if DES_HW was specified but - * there was no hardware to do it on (the data will still be - * encrypted though, in software). - */ - - -/* - * Cipher Block Chaining mode - */ -#ifdef __cplusplus -extern "C" { -#endif -int cbc_crypt( char *, char *, unsigned int, unsigned int, char *); -#ifdef __cplusplus -} -#endif - -/* - * Electronic Code Book mode - */ -#ifdef __cplusplus -extern "C" { -#endif -int ecb_crypt( char *, char *, unsigned int, unsigned int ); -#ifdef __cplusplus -} -#endif - -/* - * Set des parity for a key. - * DES parity is odd and in the low bit of each byte - */ -#ifdef __cplusplus -extern "C" { -#endif -void des_setparity( char *); -#ifdef __cplusplus -} -#endif - -#endif /* _DES_DES_CRYPT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/key_prot.h b/libtirpc-1.3.1/tirpc/rpc/key_prot.h deleted file mode 100644 index ff852dc..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/key_prot.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _KEY_PROT_H_RPCGEN -#define _KEY_PROT_H_RPCGEN - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if 0 -#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" -#endif - -/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ - -/* - * Compiled from key_prot.x using rpcgen. - * DO NOT EDIT THIS FILE! - * This is NOT source code! - */ -#define PROOT 3 -#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" -#define HEXKEYBYTES 48 -#define KEYSIZE 192 -#define KEYBYTES 24 -#define KEYCHECKSUMSIZE 16 - -enum keystatus { - KEY_SUCCESS = 0, - KEY_NOSECRET = 1, - KEY_UNKNOWN = 2, - KEY_SYSTEMERR = 3, -}; -typedef enum keystatus keystatus; - -typedef char keybuf[HEXKEYBYTES]; - -typedef char *netnamestr; - -struct cryptkeyarg { - netnamestr remotename; - des_block deskey; -}; -typedef struct cryptkeyarg cryptkeyarg; - -struct cryptkeyarg2 { - netnamestr remotename; - netobj remotekey; - des_block deskey; -}; -typedef struct cryptkeyarg2 cryptkeyarg2; - -struct cryptkeyres { - keystatus status; - union { - des_block deskey; - } cryptkeyres_u; -}; -typedef struct cryptkeyres cryptkeyres; -#define MAXGIDS 16 - -struct unixcred { - u_int uid; - u_int gid; - struct { - u_int gids_len; - u_int *gids_val; - } gids; -}; -typedef struct unixcred unixcred; - -struct getcredres { - keystatus status; - union { - unixcred cred; - } getcredres_u; -}; -typedef struct getcredres getcredres; - -struct key_netstarg { - keybuf st_priv_key; - keybuf st_pub_key; - netnamestr st_netname; -}; -typedef struct key_netstarg key_netstarg; - -struct key_netstres { - keystatus status; - union { - key_netstarg knet; - } key_netstres_u; -}; -typedef struct key_netstres key_netstres; - -#ifndef opaque -#define opaque char -#endif - - -#define KEY_PROG 100029 -#define KEY_VERS 1 - -#if defined(__STDC__) || defined(__cplusplus) -#define KEY_SET 1 -extern keystatus * key_set_1(char *, CLIENT *); -extern keystatus * key_set_1_svc(char *, struct svc_req *); -#define KEY_ENCRYPT 2 -extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); -extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); -#define KEY_DECRYPT 3 -extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); -extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); -#define KEY_GEN 4 -extern des_block * key_gen_1(void *, CLIENT *); -extern des_block * key_gen_1_svc(void *, struct svc_req *); -#define KEY_GETCRED 5 -extern getcredres * key_getcred_1(netnamestr *, CLIENT *); -extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); -extern int key_prog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - -#else /* K&R C */ -#define KEY_SET 1 -extern keystatus * key_set_1(); -extern keystatus * key_set_1_svc(); -#define KEY_ENCRYPT 2 -extern cryptkeyres * key_encrypt_1(); -extern cryptkeyres * key_encrypt_1_svc(); -#define KEY_DECRYPT 3 -extern cryptkeyres * key_decrypt_1(); -extern cryptkeyres * key_decrypt_1_svc(); -#define KEY_GEN 4 -extern des_block * key_gen_1(); -extern des_block * key_gen_1_svc(); -#define KEY_GETCRED 5 -extern getcredres * key_getcred_1(); -extern getcredres * key_getcred_1_svc(); -extern int key_prog_1_freeresult (); -#endif /* K&R C */ -#define KEY_VERS2 2 - -#if defined(__STDC__) || defined(__cplusplus) -extern keystatus * key_set_2(char *, CLIENT *); -extern keystatus * key_set_2_svc(char *, struct svc_req *); -extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); -extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); -extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); -extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); -extern des_block * key_gen_2(void *, CLIENT *); -extern des_block * key_gen_2_svc(void *, struct svc_req *); -extern getcredres * key_getcred_2(netnamestr *, CLIENT *); -extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); -#define KEY_ENCRYPT_PK 6 -extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); -extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); -#define KEY_DECRYPT_PK 7 -extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); -extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); -#define KEY_NET_PUT 8 -extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); -extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); -#define KEY_NET_GET 9 -extern key_netstres * key_net_get_2(void *, CLIENT *); -extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); -#define KEY_GET_CONV 10 -extern cryptkeyres * key_get_conv_2(char *, CLIENT *); -extern cryptkeyres * key_get_conv_2_svc(char *, struct svc_req *); -extern int key_prog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - -#else /* K&R C */ -extern keystatus * key_set_2(); -extern keystatus * key_set_2_svc(); -extern cryptkeyres * key_encrypt_2(); -extern cryptkeyres * key_encrypt_2_svc(); -extern cryptkeyres * key_decrypt_2(); -extern cryptkeyres * key_decrypt_2_svc(); -extern des_block * key_gen_2(); -extern des_block * key_gen_2_svc(); -extern getcredres * key_getcred_2(); -extern getcredres * key_getcred_2_svc(); -#define KEY_ENCRYPT_PK 6 -extern cryptkeyres * key_encrypt_pk_2(); -extern cryptkeyres * key_encrypt_pk_2_svc(); -#define KEY_DECRYPT_PK 7 -extern cryptkeyres * key_decrypt_pk_2(); -extern cryptkeyres * key_decrypt_pk_2_svc(); -#define KEY_NET_PUT 8 -extern keystatus * key_net_put_2(); -extern keystatus * key_net_put_2_svc(); -#define KEY_NET_GET 9 -extern key_netstres * key_net_get_2(); -extern key_netstres * key_net_get_2_svc(); -#define KEY_GET_CONV 10 -extern cryptkeyres * key_get_conv_2(); -extern cryptkeyres * key_get_conv_2_svc(); -extern int key_prog_2_freeresult (); -#endif /* K&R C */ - -/* the xdr functions */ - -#if defined(__STDC__) || defined(__cplusplus) -extern bool_t xdr_keystatus (XDR *, keystatus*); -extern bool_t xdr_keybuf (XDR *, keybuf); -extern bool_t xdr_netnamestr (XDR *, netnamestr*); -extern bool_t xdr_cryptkeyarg (XDR *, cryptkeyarg*); -extern bool_t xdr_cryptkeyarg2 (XDR *, cryptkeyarg2*); -extern bool_t xdr_cryptkeyres (XDR *, cryptkeyres*); -extern bool_t xdr_unixcred (XDR *, unixcred*); -extern bool_t xdr_getcredres (XDR *, getcredres*); -extern bool_t xdr_key_netstarg (XDR *, key_netstarg*); -extern bool_t xdr_key_netstres (XDR *, key_netstres*); - -#else /* K&R C */ -extern bool_t xdr_keystatus (); -extern bool_t xdr_keybuf (); -extern bool_t xdr_netnamestr (); -extern bool_t xdr_cryptkeyarg (); -extern bool_t xdr_cryptkeyarg2 (); -extern bool_t xdr_cryptkeyres (); -extern bool_t xdr_unixcred (); -extern bool_t xdr_getcredres (); -extern bool_t xdr_key_netstarg (); -extern bool_t xdr_key_netstres (); - -#endif /* K&R C */ - -#ifdef __cplusplus -} -#endif - -#endif /* !_KEY_PROT_H_RPCGEN */ diff --git a/libtirpc-1.3.1/tirpc/rpc/nettype.h b/libtirpc-1.3.1/tirpc/rpc/nettype.h deleted file mode 100644 index 926797a..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/nettype.h +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: nettype.h,v 1.2 2000/07/06 03:17:19 christos Exp $ */ -/* $FreeBSD: src/include/rpc/nettype.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * nettype.h, Nettype definitions. - * All for the topmost layer of rpc - * - */ - -#ifndef _TIRPC_NETTYPE_H -#define _TIRPC_NETTYPE_H - -#include - -#define _RPC_NONE 0 -#define _RPC_NETPATH 1 -#define _RPC_VISIBLE 2 -#define _RPC_CIRCUIT_V 3 -#define _RPC_DATAGRAM_V 4 -#define _RPC_CIRCUIT_N 5 -#define _RPC_DATAGRAM_N 6 -#define _RPC_TCP 7 -#define _RPC_UDP 8 - -#ifdef __cplusplus -extern "C" { -#endif -extern void *__rpc_setconf(const char *); -extern void __rpc_endconf(void *); -extern struct netconfig *__rpc_getconf(void *); -extern struct netconfig *__rpc_getconfip(const char *); -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_NETTYPE_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/pmap_clnt.h b/libtirpc-1.3.1/tirpc/rpc/pmap_clnt.h deleted file mode 100644 index cf1ab61..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/pmap_clnt.h +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: pmap_clnt.h,v 1.9 2000/06/02 22:57:55 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI - * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_clnt.h,v 1.14 2002/04/28 15:18:45 des Exp $ - */ - -/* - * pmap_clnt.h - * Supplies C routines to get to portmap services. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * Usage: - * success = pmap_set(program, version, protocol, port); - * success = pmap_unset(program, version); - * port = pmap_getport(address, program, version, protocol); - * head = pmap_getmaps(address); - * clnt_stat = pmap_rmtcall(address, program, version, procedure, - * xdrargs, argsp, xdrres, resp, tout, port_ptr) - * (works for udp only.) - * clnt_stat = clnt_broadcast(program, version, procedure, - * xdrargs, argsp, xdrres, resp, eachresult) - * (like pmap_rmtcall, except the call is broadcasted to all - * locally connected nets. For each valid response received, - * the procedure eachresult is called. Its form is: - * done = eachresult(resp, raddr) - * bool_t done; - * caddr_t resp; - * struct sockaddr_in raddr; - * where resp points to the results of the call and raddr is the - * address if the responder to the broadcast. - */ - -#ifndef _RPC_PMAP_CLNT_H_ -#define _RPC_PMAP_CLNT_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t pmap_set(u_long, u_long, int, int); -extern bool_t pmap_unset(u_long, u_long); -extern struct pmaplist *pmap_getmaps(struct sockaddr_in *); -extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, - u_long, u_long, u_long, - xdrproc_t, caddr_t, - xdrproc_t, caddr_t, - struct timeval, u_long *); -extern enum clnt_stat clnt_broadcast(u_long, u_long, u_long, - xdrproc_t, void *, - xdrproc_t, void *, - resultproc_t); -extern u_short pmap_getport(struct sockaddr_in *, - u_long, u_long, u_int); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_PMAP_CLNT_H_ */ diff --git a/libtirpc-1.3.1/tirpc/rpc/pmap_prot.h b/libtirpc-1.3.1/tirpc/rpc/pmap_prot.h deleted file mode 100644 index 75354ce..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/pmap_prot.h +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_prot.h 1.14 88/02/08 SMI - * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.12 2002/03/23 17:24:55 imp Exp $ - */ - -/* - * pmap_prot.h - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The following procedures are supported by the protocol: - * - * PMAPPROC_NULL() returns () - * takes nothing, returns nothing - * - * PMAPPROC_SET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Registers the tuple - * [prog, vers, prot, port]. - * - * PMAPPROC_UNSET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Un-registers pair - * [prog, vers]. prot and port are ignored. - * - * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). - * 0 is failure. Otherwise returns the port number where the pair - * [prog, vers] is registered. It may lie! - * - * PMAPPROC_DUMP() RETURNS (struct pmaplist *) - * - * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) - * RETURNS (port, string<>); - * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); - * Calls the procedure on the local machine. If it is not registered, - * this procedure is quite; ie it does not return error information!!! - * This procedure only is supported on rpc/udp and calls via - * rpc/udp. This routine only passes null authentication parameters. - * This file has no interface to xdr routines for PMAPPROC_CALLIT. - * - * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. - */ - -#ifndef _RPC_PMAP_PROT_H -#define _RPC_PMAP_PROT_H - -#define PMAPPORT ((u_short)111) -#define PMAPPROG ((u_long)100000) -#define PMAPVERS ((u_long)2) -#define PMAPVERS_PROTO ((u_long)2) -#define PMAPVERS_ORIG ((u_long)1) -#define PMAPPROC_NULL ((u_long)0) -#define PMAPPROC_SET ((u_long)1) -#define PMAPPROC_UNSET ((u_long)2) -#define PMAPPROC_GETPORT ((u_long)3) -#define PMAPPROC_DUMP ((u_long)4) -#define PMAPPROC_CALLIT ((u_long)5) - -struct pmap { - long unsigned pm_prog; - long unsigned pm_vers; - long unsigned pm_prot; - long unsigned pm_port; -}; - -struct pmaplist { - struct pmap pml_map; - struct pmaplist *pml_next; -}; - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_pmap(XDR *, struct pmap *); -extern bool_t xdr_pmaplist(XDR *, struct pmaplist **); -extern bool_t xdr_pmaplist_ptr(XDR *, struct pmaplist *); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_PMAP_PROT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/pmap_rmt.h b/libtirpc-1.3.1/tirpc/rpc/pmap_rmt.h deleted file mode 100644 index 2a385e7..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/pmap_rmt.h +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: pmap_rmt.h,v 1.7 1998/02/11 23:01:23 lukem Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI - * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.12 2002/03/23 17:24:55 imp Exp $ - */ - -/* - * Structures and XDR routines for parameters to and replies from - * the portmapper remote-call-service. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#ifndef _RPC_PMAP_RMT_H -#define _RPC_PMAP_RMT_H - -struct rmtcallargs { - u_long prog, vers, proc, arglen; - caddr_t args_ptr; - xdrproc_t xdr_args; -}; - -struct rmtcallres { - u_long *port_ptr; - u_long resultslen; - caddr_t results_ptr; - xdrproc_t xdr_results; -}; - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *); -extern bool_t xdr_rmtcallres(XDR *, struct rmtcallres *); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_PMAP_RMT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/raw.h b/libtirpc-1.3.1/tirpc/rpc/raw.h deleted file mode 100644 index 4edd738..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/raw.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: raw.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/raw.h,v 1.1 2001/03/19 12:49:47 alfred Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -#ifndef _RPC_RAW_H -#define _RPC_RAW_H - -/* from: @(#)raw.h 1.11 94/04/25 SMI */ -/* from: @(#)raw.h 1.2 88/10/25 SMI */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * raw.h - * - * Raw interface - * The common memory area over which they will communicate - */ -extern char *__rpc_rawcombuf; - -#ifdef __cplusplus -} -#endif - -#endif /* _RPC_RAW_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpc.h b/libtirpc-1.3.1/tirpc/rpc/rpc.h deleted file mode 100644 index c3055ba..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpc.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc.h, Just includes the billions of rpc header files necessary to - * do remote procedure calling. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#ifndef _TIRPC_RPC_H -#define _TIRPC_RPC_H - -#include /* some typedefs */ -#include -#include - -/* external data representation interfaces */ -#include /* generic (de)serializer */ - -/* Client side only authentication */ -#include /* generic authenticator (client side) */ - -/* Client side (mostly) remote procedure call */ -#include /* generic rpc stuff */ - -/* semi-private protocol headers */ -#include /* protocol for rpc messages */ -#include /* protocol for unix style cred */ - -/* - * Uncomment-out the next line if you are building the rpc library with - * DES Authentication (see the README file in the secure_rpc/ directory). - */ -#include /* protocol for des style cred */ - -/* Server side only remote procedure callee */ -#include /* service side authenticator */ -#include /* service manager and multiplexer */ - -/* Portmapper client, server, and protocol headers */ -#include -#include - -#ifndef _KERNEL -#include /* rpcbind interface functions */ -#include -#endif -#include - -#ifndef UDPMSGSIZE -#define UDPMSGSIZE 8800 -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern int get_myaddress(struct sockaddr_in *); -extern int bindresvport(int, struct sockaddr_in *); -extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]), - xdrproc_t, xdrproc_t); -extern int callrpc(const char *, int, int, int, xdrproc_t, void *, - xdrproc_t , void *); -extern int getrpcport(char *, int, int, int); - -char *taddr2uaddr(const struct netconfig *, const struct netbuf *); -struct netbuf *uaddr2taddr(const struct netconfig *, const char *); - -struct sockaddr; -extern int bindresvport_sa(int, struct sockaddr *); -#ifdef __cplusplus -} -#endif - -/* - * The following are not exported interfaces, they are for internal library - * and rpcbind use only. Do not use, they may change without notice. - */ -#ifdef __cplusplus -extern "C" { -#endif -int __rpc_nconf2fd(const struct netconfig *); -int __rpc_nconf2fd_flags(const struct netconfig *, int); -int __rpc_nconf2sockinfo(const struct netconfig *, struct __rpc_sockinfo *); -int __rpc_fd2sockinfo(int, struct __rpc_sockinfo *); -u_int __rpc_get_t_size(int, int, int); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_RPC_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpc_com.h b/libtirpc-1.3.1/tirpc/rpc/rpc_com.h deleted file mode 100644 index 236fcee..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpc_com.h +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ -/* $FreeBSD: src/include/rpc/rpc_com.h,v 1.6 2003/01/16 07:13:51 mbr Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpc_com.h, Common definitions for both the server and client side. - * All for the topmost layer of rpc - * - */ - -#ifndef _RPC_RPCCOM_H -#define _RPC_RPCCOM_H - - -/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ - -/* - * The max size of the transport, if the size cannot be determined - * by other means. - */ -#define RPC_MAXDATASIZE 9000 -#define RPC_MAXADDRSIZE 1024 - -#define __RPC_GETXID(now) ((u_int32_t)getpid() ^ (u_int32_t)(now)->tv_sec ^ \ - (u_int32_t)(now)->tv_usec) - -#ifdef __cplusplus -extern "C" { -#endif -extern u_int __rpc_get_a_size(int); -extern int __rpc_dtbsize(void); -extern int _rpc_dtablesize(void); -extern struct netconfig * __rpcgettp(int); -extern int __rpc_get_default_domain(char **); - -char *__rpc_taddr2uaddr_af(int, const struct netbuf *); -struct netbuf *__rpc_uaddr2taddr_af(int, const char *); -int __rpc_fixup_addr(struct netbuf *, const struct netbuf *); -int __rpc_sockinfo2netid(struct __rpc_sockinfo *, const char **); -int __rpc_seman2socktype(int); -int __rpc_socktype2seman(int); -void *rpc_nullproc(CLIENT *); -int __rpc_sockisbound(int); - -struct netbuf *__rpcb_findaddr(rpcprog_t, rpcvers_t, const struct netconfig *, - const char *, CLIENT **); -bool_t rpc_control(int,void *); - -char *_get_next_token(char *, int); - -#ifdef __cplusplus -} -#endif - -#endif /* _RPC_RPCCOM_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpc_msg.h b/libtirpc-1.3.1/tirpc/rpc/rpc_msg.h deleted file mode 100644 index f7aabd8..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpc_msg.h +++ /dev/null @@ -1,219 +0,0 @@ -/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)rpc_msg.h 1.7 86/07/16 SMI - * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $ - */ - -/* - * rpc_msg.h - * rpc message definition - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _TIRPC_RPC_MSG_H -#define _TIRPC_RPC_MSG_H - -#define RPC_MSG_VERSION ((u_int32_t) 2) -#define RPC_SERVICE_PORT ((u_short) 2048) - -#include - -/* - * Bottom up definition of an rpc message. - * NOTE: call and reply use the same overall stuct but - * different parts of unions within it. - */ - -enum msg_type { - CALL=0, - REPLY=1 -}; - -enum reply_stat { - MSG_ACCEPTED=0, - MSG_DENIED=1 -}; - -enum accept_stat { - SUCCESS=0, - PROG_UNAVAIL=1, - PROG_MISMATCH=2, - PROC_UNAVAIL=3, - GARBAGE_ARGS=4, - SYSTEM_ERR=5 -}; - -enum reject_stat { - RPC_MISMATCH=0, - AUTH_ERROR=1 -}; - -/* - * Reply part of an rpc exchange - */ - -/* - * Reply to an rpc request that was accepted by the server. - * Note: there could be an error even though the request was - * accepted. - */ -struct accepted_reply { - struct opaque_auth ar_verf; - enum accept_stat ar_stat; - union { - struct { - rpcvers_t low; - rpcvers_t high; - } AR_versions; - struct { - caddr_t where; - xdrproc_t proc; - } AR_results; - /* and many other null cases */ - } ru; -#define ar_results ru.AR_results -#define ar_vers ru.AR_versions -}; - -/* - * Reply to an rpc request that was rejected by the server. - */ -struct rejected_reply { - enum reject_stat rj_stat; - union { - struct { - rpcvers_t low; - rpcvers_t high; - } RJ_versions; - enum auth_stat RJ_why; /* why authentication did not work */ - } ru; -#define rj_vers ru.RJ_versions -#define rj_why ru.RJ_why -}; - -/* - * Body of a reply to an rpc request. - */ -struct reply_body { - enum reply_stat rp_stat; - union { - struct accepted_reply RP_ar; - struct rejected_reply RP_dr; - } ru; -#define rp_acpt ru.RP_ar -#define rp_rjct ru.RP_dr -}; - -/* - * Body of an rpc request call. - */ -struct call_body { - rpcvers_t cb_rpcvers; /* must be equal to two */ - rpcprog_t cb_prog; - rpcvers_t cb_vers; - rpcproc_t cb_proc; - struct opaque_auth cb_cred; - struct opaque_auth cb_verf; /* protocol specific - provided by client */ -}; - -/* - * The rpc message - */ -struct rpc_msg { - u_int32_t rm_xid; - enum msg_type rm_direction; - union { - struct call_body RM_cmb; - struct reply_body RM_rmb; - } ru; -#define rm_call ru.RM_cmb -#define rm_reply ru.RM_rmb -}; -#define acpted_rply ru.RM_rmb.ru.RP_ar -#define rjcted_rply ru.RM_rmb.ru.RP_dr - -#ifdef __cplusplus -extern "C" { -#endif -/* - * XDR routine to handle a rpc message. - * xdr_callmsg(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); - -/* - * XDR routine to pre-serialize the static part of a rpc message. - * xdr_callhdr(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); - -/* - * XDR routine to handle a rpc reply. - * xdr_replymsg(xdrs, rmsg) - * XDR *xdrs; - * struct rpc_msg *rmsg; - */ -extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); - - -/* - * XDR routine to handle an accepted rpc reply. - * xdr_accepted_reply(xdrs, rej) - * XDR *xdrs; - * struct accepted_reply *rej; - */ -extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); - -/* - * XDR routine to handle a rejected rpc reply. - * xdr_rejected_reply(xdrs, rej) - * XDR *xdrs; - * struct rejected_reply *rej; - */ -extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); - -/* - * Fills in the error part of a reply message. - * _seterr_reply(msg, error) - * struct rpc_msg *msg; - * struct rpc_err *error; - */ -extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_RPC_MSG_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpcb_clnt.h b/libtirpc-1.3.1/tirpc/rpc/rpcb_clnt.h deleted file mode 100644 index 86d81f6..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpcb_clnt.h +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: rpcb_clnt.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/rpcb_clnt.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpcb_clnt.h - * Supplies C routines to get to rpcbid services. - * - */ - -/* - * Usage: - * success = rpcb_set(program, version, nconf, address); - * success = rpcb_unset(program, version, nconf); - * success = rpcb_getaddr(program, version, nconf, host); - * head = rpcb_getmaps(nconf, host); - * clnt_stat = rpcb_rmtcall(nconf, host, program, version, procedure, - * xdrargs, argsp, xdrres, resp, tout, addr_ptr) - * success = rpcb_gettime(host, timep) - * uaddr = rpcb_taddr2uaddr(nconf, taddr); - * taddr = rpcb_uaddr2uaddr(nconf, uaddr); - */ - -#ifndef _RPC_RPCB_CLNT_H -#define _RPC_RPCB_CLNT_H - -/* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */ -/* rpcb_clnt.h 1.3 88/12/05 SMI */ - -#include -#include -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t rpcb_set(const rpcprog_t, const rpcvers_t, - const struct netconfig *, const struct netbuf *); -extern bool_t rpcb_unset(const rpcprog_t, const rpcvers_t, - const struct netconfig *); -extern rpcblist *rpcb_getmaps(const struct netconfig *, const char *); -extern enum clnt_stat rpcb_rmtcall(const struct netconfig *, - const char *, const rpcprog_t, - const rpcvers_t, const rpcproc_t, - const xdrproc_t, const caddr_t, - const xdrproc_t, const caddr_t, - const struct timeval, - const struct netbuf *); -extern bool_t rpcb_getaddr(const rpcprog_t, const rpcvers_t, - const struct netconfig *, struct netbuf *, - const char *); -extern bool_t rpcb_gettime(const char *, time_t *); -extern char *rpcb_taddr2uaddr(struct netconfig *, struct netbuf *); -extern struct netbuf *rpcb_uaddr2taddr(struct netconfig *, char *); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_RPCB_CLNT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.h b/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.h deleted file mode 100644 index 7ae48b8..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.h +++ /dev/null @@ -1,797 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _RPCB_PROT_H_RPCGEN -#define _RPCB_PROT_H_RPCGEN - -#include - -#ifndef IXDR_GET_INT32 -#define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf)) -#endif -#ifndef IXDR_PUT_INT32 -#define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v)) -#endif -#ifndef IXDR_GET_U_INT32 -#define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf)) -#endif -#ifndef IXDR_PUT_U_INT32 -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v)) -#endif -/* - * $FreeBSD: src/include/rpc/rpcb_prot.x,v 1.3 2002/03/13 10:29:06 obrien Exp $ - * - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* from rpcb_prot.x */ - -/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ - -#ifndef _KERNEL - - -/* - * The following procedures are supported by the protocol in version 3: - * - * RPCBPROC_NULL() returns () - * takes nothing, returns nothing - * - * RPCBPROC_SET(rpcb) returns (bool_t) - * TRUE is success, FALSE is failure. Registers the tuple - * [prog, vers, address, owner, netid]. - * Finds out owner and netid information on its own. - * - * RPCBPROC_UNSET(rpcb) returns (bool_t) - * TRUE is success, FALSE is failure. Un-registers tuple - * [prog, vers, netid]. addresses is ignored. - * If netid is NULL, unregister all. - * - * RPCBPROC_GETADDR(rpcb) returns (string). - * 0 is failure. Otherwise returns the universal address where the - * triple [prog, vers, netid] is registered. Ignore address and owner. - * - * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) - * used to dump the entire rpcbind maps - * - * RPCBPROC_CALLIT(rpcb_rmtcallargs) - * RETURNS (rpcb_rmtcallres); - * Calls the procedure on the remote machine. If it is not registered, - * this procedure is quiet; i.e. it does not return error information!!! - * This routine only passes null authentication parameters. - * It has no interface to xdr routines for RPCBPROC_CALLIT. - * - * RPCBPROC_GETTIME() returns (int). - * Gets the remote machines time - * - * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) - * Returns the netbuf address from universal address. - * - * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) - * Returns the universal address from netbuf address. - * - * END OF RPCBIND VERSION 3 PROCEDURES - */ -/* - * Except for RPCBPROC_CALLIT, the procedures above are carried over to - * rpcbind version 4. Those below are added or modified for version 4. - * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER - * AS RPCBPROC_CALLIT. - * - * RPCBPROC_BCAST(rpcb_rmtcallargs) - * RETURNS (rpcb_rmtcallres); - * Calls the procedure on the remote machine. If it is not registered, - * this procedure IS quiet; i.e. it DOES NOT return error information!!! - * This routine should be used for broadcasting and nothing else. - * - * RPCBPROC_GETVERSADDR(rpcb) returns (string). - * 0 is failure. Otherwise returns the universal address where the - * triple [prog, vers, netid] is registered. Ignore address and owner. - * Same as RPCBPROC_GETADDR except that if the given version number - * is not available, the address is not returned. - * - * RPCBPROC_INDIRECT(rpcb_rmtcallargs) - * RETURNS (rpcb_rmtcallres); - * Calls the procedure on the remote machine. If it is not registered, - * this procedure is NOT quiet; i.e. it DOES return error information!!! - * as any normal application would expect. - * - * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). - * Same as RPCBPROC_GETADDR except that it returns a list of all the - * addresses registered for the combination (prog, vers) (for all - * transports). - * - * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) - * Returns the statistics about the kind of requests received by rpcbind. - */ - -/* - * A mapping of (program, version, network ID) to address - */ - -struct rpcb { - rpcprog_t r_prog; - rpcvers_t r_vers; - char *r_netid; - char *r_addr; - char *r_owner; -}; -typedef struct rpcb rpcb; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb(XDR *, rpcb*); -#elif __STDC__ -extern bool_t xdr_rpcb(XDR *, rpcb*); -#else /* Old Style C */ -bool_t xdr_rpcb(); -#endif /* Old Style C */ - - -typedef rpcb RPCB; - - -/* - * A list of mappings - * - * Below are two definitions for the rpcblist structure. This is done because - * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a - * struct rpcblist * that rpcgen would produce. One version of the rpcblist - * structure (actually called rp__list) is used with rpcgen, and the other is - * defined only in the header file for compatibility with the specified - * interface. - */ - -struct rp__list { - rpcb rpcb_map; - struct rp__list *rpcb_next; -}; -typedef struct rp__list rp__list; -#ifdef __cplusplus -extern "C" bool_t xdr_rp__list(XDR *, rp__list*); -#elif __STDC__ -extern bool_t xdr_rp__list(XDR *, rp__list*); -#else /* Old Style C */ -bool_t xdr_rp__list(); -#endif /* Old Style C */ - - -typedef rp__list *rpcblist_ptr; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcblist_ptr(XDR *, rpcblist_ptr*); -#elif __STDC__ -extern bool_t xdr_rpcblist_ptr(XDR *, rpcblist_ptr*); -#else /* Old Style C */ -bool_t xdr_rpcblist_ptr(); -#endif /* Old Style C */ - - -typedef struct rp__list rpcblist; -typedef struct rp__list RPCBLIST; - -#ifndef __cplusplus -struct rpcblist { - RPCB rpcb_map; - struct rpcblist *rpcb_next; -}; -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_rpcblist(XDR *, rpcblist**); -#ifdef __cplusplus -} -#endif - - -/* - * Arguments of remote calls - */ - -struct rpcb_rmtcallargs { - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - struct { - u_int args_len; - char *args_val; - } args; -}; -typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_rmtcallargs(XDR *, rpcb_rmtcallargs*); -#elif __STDC__ -extern bool_t xdr_rpcb_rmtcallargs(XDR *, rpcb_rmtcallargs*); -#else /* Old Style C */ -bool_t xdr_rpcb_rmtcallargs(); -#endif /* Old Style C */ - - -/* - * Client-side only representation of rpcb_rmtcallargs structure. - * - * The routine that XDRs the rpcb_rmtcallargs structure must deal with the - * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to - * be passed the XDR routine that knows the args' structure. This routine - * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since - * the application being called already knows the args structure. So we use a - * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which - * includes the args' XDR routine. - */ -struct r_rpcb_rmtcallargs { - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - struct { - u_int args_len; - char *args_val; - } args; - xdrproc_t xdr_args; /* encodes args */ -}; - - -/* - * Results of the remote call - */ - -struct rpcb_rmtcallres { - char *addr; - struct { - u_int results_len; - char *results_val; - } results; -}; -typedef struct rpcb_rmtcallres rpcb_rmtcallres; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_rmtcallres(XDR *, rpcb_rmtcallres*); -#elif __STDC__ -extern bool_t xdr_rpcb_rmtcallres(XDR *, rpcb_rmtcallres*); -#else /* Old Style C */ -bool_t xdr_rpcb_rmtcallres(); -#endif /* Old Style C */ - - -/* - * Client-side only representation of rpcb_rmtcallres structure. - */ -struct r_rpcb_rmtcallres { - char *addr; - struct { - u_int32_t results_len; - char *results_val; - } results; - xdrproc_t xdr_res; /* decodes results */ -}; - -/* - * rpcb_entry contains a merged address of a service on a particular - * transport, plus associated netconfig information. A list of rpcb_entrys - * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used - * in r_nc_* fields. - */ - -struct rpcb_entry { - char *r_maddr; - char *r_nc_netid; - u_int r_nc_semantics; - char *r_nc_protofmly; - char *r_nc_proto; -}; -typedef struct rpcb_entry rpcb_entry; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_entry(XDR *, rpcb_entry*); -#elif __STDC__ -extern bool_t xdr_rpcb_entry(XDR *, rpcb_entry*); -#else /* Old Style C */ -bool_t xdr_rpcb_entry(); -#endif /* Old Style C */ - - -/* - * A list of addresses supported by a service. - */ - -struct rpcb_entry_list { - rpcb_entry rpcb_entry_map; - struct rpcb_entry_list *rpcb_entry_next; -}; -typedef struct rpcb_entry_list rpcb_entry_list; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_entry_list(XDR *, rpcb_entry_list*); -#elif __STDC__ -extern bool_t xdr_rpcb_entry_list(XDR *, rpcb_entry_list*); -#else /* Old Style C */ -bool_t xdr_rpcb_entry_list(); -#endif /* Old Style C */ - - -typedef rpcb_entry_list *rpcb_entry_list_ptr; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_entry_list_ptr(XDR *, rpcb_entry_list_ptr*); -#elif __STDC__ -extern bool_t xdr_rpcb_entry_list_ptr(XDR *, rpcb_entry_list_ptr*); -#else /* Old Style C */ -bool_t xdr_rpcb_entry_list_ptr(); -#endif /* Old Style C */ - - -/* - * rpcbind statistics - */ - -#define rpcb_highproc_2 RPCBPROC_CALLIT -#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR -#define rpcb_highproc_4 RPCBPROC_GETSTAT -#define RPCBSTAT_HIGHPROC 13 -#define RPCBVERS_STAT 3 -#define RPCBVERS_4_STAT 2 -#define RPCBVERS_3_STAT 1 -#define RPCBVERS_2_STAT 0 - -/* Link list of all the stats about getport and getaddr */ - -struct rpcbs_addrlist { - rpcprog_t prog; - rpcvers_t vers; - int success; - int failure; - char *netid; - struct rpcbs_addrlist *next; -}; -typedef struct rpcbs_addrlist rpcbs_addrlist; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcbs_addrlist(XDR *, rpcbs_addrlist*); -#elif __STDC__ -extern bool_t xdr_rpcbs_addrlist(XDR *, rpcbs_addrlist*); -#else /* Old Style C */ -bool_t xdr_rpcbs_addrlist(); -#endif /* Old Style C */ - - -/* Link list of all the stats about rmtcall */ - -struct rpcbs_rmtcalllist { - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - int success; - int failure; - int indirect; - char *netid; - struct rpcbs_rmtcalllist *next; -}; -typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcbs_rmtcalllist(XDR *, rpcbs_rmtcalllist*); -#elif __STDC__ -extern bool_t xdr_rpcbs_rmtcalllist(XDR *, rpcbs_rmtcalllist*); -#else /* Old Style C */ -bool_t xdr_rpcbs_rmtcalllist(); -#endif /* Old Style C */ - - -typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcbs_proc(XDR *, rpcbs_proc); -#elif __STDC__ -extern bool_t xdr_rpcbs_proc(XDR *, rpcbs_proc); -#else /* Old Style C */ -bool_t xdr_rpcbs_proc(); -#endif /* Old Style C */ - - -typedef rpcbs_addrlist *rpcbs_addrlist_ptr; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcbs_addrlist_ptr(XDR *, rpcbs_addrlist_ptr*); -#elif __STDC__ -extern bool_t xdr_rpcbs_addrlist_ptr(XDR *, rpcbs_addrlist_ptr*); -#else /* Old Style C */ -bool_t xdr_rpcbs_addrlist_ptr(); -#endif /* Old Style C */ - - -typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcbs_rmtcalllist_ptr(XDR *, rpcbs_rmtcalllist_ptr*); -#elif __STDC__ -extern bool_t xdr_rpcbs_rmtcalllist_ptr(XDR *, rpcbs_rmtcalllist_ptr*); -#else /* Old Style C */ -bool_t xdr_rpcbs_rmtcalllist_ptr(); -#endif /* Old Style C */ - - -struct rpcb_stat { - rpcbs_proc info; - int setinfo; - int unsetinfo; - rpcbs_addrlist_ptr addrinfo; - rpcbs_rmtcalllist_ptr rmtinfo; -}; -typedef struct rpcb_stat rpcb_stat; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_stat(XDR *, rpcb_stat*); -#elif __STDC__ -extern bool_t xdr_rpcb_stat(XDR *, rpcb_stat*); -#else /* Old Style C */ -bool_t xdr_rpcb_stat(); -#endif /* Old Style C */ - - -/* - * One rpcb_stat structure is returned for each version of rpcbind - * being monitored. - */ - -typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; -#ifdef __cplusplus -extern "C" bool_t xdr_rpcb_stat_byvers(XDR *, rpcb_stat_byvers); -#elif __STDC__ -extern bool_t xdr_rpcb_stat_byvers(XDR *, rpcb_stat_byvers); -#else /* Old Style C */ -bool_t xdr_rpcb_stat_byvers(); -#endif /* Old Style C */ - - -/* - * We don't define netbuf in RPCL, since it would contain structure member - * names that would conflict with the definition of struct netbuf in - * . Instead we merely declare the XDR routine xdr_netbuf() here, - * and implement it ourselves in rpc/rpcb_prot.c. - */ -#ifdef __cplusplus -extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); - -#else /* __STDC__ */ -extern bool_t xdr_netbuf(XDR *, struct netbuf *); - -#endif - -#define RPCBVERS_3 RPCBVERS -#define RPCBVERS_4 RPCBVERS4 - -#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" - -#else /* ndef _KERNEL */ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * A mapping of (program, version, network ID) to address - */ -struct rpcb { - rpcprog_t r_prog; /* program number */ - rpcvers_t r_vers; /* version number */ - char *r_netid; /* network id */ - char *r_addr; /* universal address */ - char *r_owner; /* owner of the mapping */ -}; -typedef struct rpcb RPCB; - -/* - * A list of mappings - */ -struct rpcblist { - RPCB rpcb_map; - struct rpcblist *rpcb_next; -}; -typedef struct rpcblist RPCBLIST; -typedef struct rpcblist *rpcblist_ptr; - -/* - * Remote calls arguments - */ -struct rpcb_rmtcallargs { - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - u_int32_t arglen; /* arg len */ - caddr_t args_ptr; /* argument */ - xdrproc_t xdr_args; /* XDR routine for argument */ -}; -typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; - -/* - * Remote calls results - */ -struct rpcb_rmtcallres { - char *addr_ptr; /* remote universal address */ - u_int32_t resultslen; /* results length */ - caddr_t results_ptr; /* results */ - xdrproc_t xdr_results; /* XDR routine for result */ -}; -typedef struct rpcb_rmtcallres rpcb_rmtcallres; - -struct rpcb_entry { - char *r_maddr; - char *r_nc_netid; - unsigned int r_nc_semantics; - char *r_nc_protofmly; - char *r_nc_proto; -}; -typedef struct rpcb_entry rpcb_entry; - -/* - * A list of addresses supported by a service. - */ - -struct rpcb_entry_list { - rpcb_entry rpcb_entry_map; - struct rpcb_entry_list *rpcb_entry_next; -}; -typedef struct rpcb_entry_list rpcb_entry_list; - -typedef rpcb_entry_list *rpcb_entry_list_ptr; - -/* - * rpcbind statistics - */ - -#define rpcb_highproc_2 RPCBPROC_CALLIT -#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR -#define rpcb_highproc_4 RPCBPROC_GETSTAT -#define RPCBSTAT_HIGHPROC 13 -#define RPCBVERS_STAT 3 -#define RPCBVERS_4_STAT 2 -#define RPCBVERS_3_STAT 1 -#define RPCBVERS_2_STAT 0 - -/* Link list of all the stats about getport and getaddr */ - -struct rpcbs_addrlist { - rpcprog_t prog; - rpcvers_t vers; - int success; - int failure; - char *netid; - struct rpcbs_addrlist *next; -}; -typedef struct rpcbs_addrlist rpcbs_addrlist; - -/* Link list of all the stats about rmtcall */ - -struct rpcbs_rmtcalllist { - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - int success; - int failure; - int indirect; - char *netid; - struct rpcbs_rmtcalllist *next; -}; -typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; - -typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; - -typedef rpcbs_addrlist *rpcbs_addrlist_ptr; - -typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; - -struct rpcb_stat { - rpcbs_proc info; - int setinfo; - int unsetinfo; - rpcbs_addrlist_ptr addrinfo; - rpcbs_rmtcalllist_ptr rmtinfo; -}; -typedef struct rpcb_stat rpcb_stat; - -/* - * One rpcb_stat structure is returned for each version of rpcbind - * being monitored. - */ - -typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; - -#ifdef __cplusplus -} -#endif - -#endif /* ndef _KERNEL */ - -#define RPCBPROG ((u_int32_t)100000) -#define RPCBVERS ((u_int32_t)3) - -#ifdef __cplusplus -#define RPCBPROC_SET ((u_int32_t)1) -extern "C" bool_t * rpcbproc_set_3(rpcb *, CLIENT *); -extern "C" bool_t * rpcbproc_set_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_UNSET ((u_int32_t)2) -extern "C" bool_t * rpcbproc_unset_3(rpcb *, CLIENT *); -extern "C" bool_t * rpcbproc_unset_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_GETADDR ((u_int32_t)3) -extern "C" char ** rpcbproc_getaddr_3(rpcb *, CLIENT *); -extern "C" char ** rpcbproc_getaddr_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_DUMP ((u_int32_t)4) -extern "C" rpcblist_ptr * rpcbproc_dump_3(void *, CLIENT *); -extern "C" rpcblist_ptr * rpcbproc_dump_3_svc(void *, struct svc_req *); -#define RPCBPROC_CALLIT ((u_int32_t)5) -extern "C" rpcb_rmtcallres * rpcbproc_callit_3(rpcb_rmtcallargs *, CLIENT *); -extern "C" rpcb_rmtcallres * rpcbproc_callit_3_svc(rpcb_rmtcallargs *, struct svc_req *); -#define RPCBPROC_GETTIME ((u_int32_t)6) -extern "C" u_int * rpcbproc_gettime_3(void *, CLIENT *); -extern "C" u_int * rpcbproc_gettime_3_svc(void *, struct svc_req *); -#define RPCBPROC_UADDR2TADDR ((u_int32_t)7) -extern "C" struct netbuf * rpcbproc_uaddr2taddr_3(char **, CLIENT *); -extern "C" struct netbuf * rpcbproc_uaddr2taddr_3_svc(char **, struct svc_req *); -#define RPCBPROC_TADDR2UADDR ((u_int32_t)8) -extern "C" char ** rpcbproc_taddr2uaddr_3(struct netbuf *, CLIENT *); -extern "C" char ** rpcbproc_taddr2uaddr_3_svc(struct netbuf *, struct svc_req *); - -#elif __STDC__ -#define RPCBPROC_SET ((u_int32_t)1) -extern bool_t * rpcbproc_set_3(rpcb *, CLIENT *); -extern bool_t * rpcbproc_set_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_UNSET ((u_int32_t)2) -extern bool_t * rpcbproc_unset_3(rpcb *, CLIENT *); -extern bool_t * rpcbproc_unset_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_GETADDR ((u_int32_t)3) -extern char ** rpcbproc_getaddr_3(rpcb *, CLIENT *); -extern char ** rpcbproc_getaddr_3_svc(rpcb *, struct svc_req *); -#define RPCBPROC_DUMP ((u_int32_t)4) -extern rpcblist_ptr * rpcbproc_dump_3(void *, CLIENT *); -extern rpcblist_ptr * rpcbproc_dump_3_svc(void *, struct svc_req *); -#define RPCBPROC_CALLIT ((u_int32_t)5) -extern rpcb_rmtcallres * rpcbproc_callit_3(rpcb_rmtcallargs *, CLIENT *); -extern rpcb_rmtcallres * rpcbproc_callit_3_svc(rpcb_rmtcallargs *, struct svc_req *); -#define RPCBPROC_GETTIME ((u_int32_t)6) -extern u_int * rpcbproc_gettime_3(void *, CLIENT *); -extern u_int * rpcbproc_gettime_3_svc(void *, struct svc_req *); -#define RPCBPROC_UADDR2TADDR ((u_int32_t)7) -extern struct netbuf * rpcbproc_uaddr2taddr_3(char **, CLIENT *); -extern struct netbuf * rpcbproc_uaddr2taddr_3_svc(char **, struct svc_req *); -#define RPCBPROC_TADDR2UADDR ((u_int32_t)8) -extern char ** rpcbproc_taddr2uaddr_3(struct netbuf *, CLIENT *); -extern char ** rpcbproc_taddr2uaddr_3_svc(struct netbuf *, struct svc_req *); - -#else /* Old Style C */ -#define RPCBPROC_SET ((u_int32_t)1) -extern bool_t * rpcbproc_set_3(); -extern bool_t * rpcbproc_set_3_svc(); -#define RPCBPROC_UNSET ((u_int32_t)2) -extern bool_t * rpcbproc_unset_3(); -extern bool_t * rpcbproc_unset_3_svc(); -#define RPCBPROC_GETADDR ((u_int32_t)3) -extern char ** rpcbproc_getaddr_3(); -extern char ** rpcbproc_getaddr_3_svc(); -#define RPCBPROC_DUMP ((u_int32_t)4) -extern rpcblist_ptr * rpcbproc_dump_3(); -extern rpcblist_ptr * rpcbproc_dump_3_svc(); -#define RPCBPROC_CALLIT ((u_int32_t)5) -extern rpcb_rmtcallres * rpcbproc_callit_3(); -extern rpcb_rmtcallres * rpcbproc_callit_3_svc(); -#define RPCBPROC_GETTIME ((u_int32_t)6) -extern u_int * rpcbproc_gettime_3(); -extern u_int * rpcbproc_gettime_3_svc(); -#define RPCBPROC_UADDR2TADDR ((u_int32_t)7) -extern struct netbuf * rpcbproc_uaddr2taddr_3(); -extern struct netbuf * rpcbproc_uaddr2taddr_3_svc(); -#define RPCBPROC_TADDR2UADDR ((u_int32_t)8) -extern char ** rpcbproc_taddr2uaddr_3(); -extern char ** rpcbproc_taddr2uaddr_3_svc(); -#endif /* Old Style C */ -#define RPCBVERS4 ((u_int32_t)4) - -#ifdef __cplusplus -extern "C" bool_t * rpcbproc_set_4(rpcb *, CLIENT *); -extern "C" bool_t * rpcbproc_set_4_svc(rpcb *, struct svc_req *); -extern "C" bool_t * rpcbproc_unset_4(rpcb *, CLIENT *); -extern "C" bool_t * rpcbproc_unset_4_svc(rpcb *, struct svc_req *); -extern "C" char ** rpcbproc_getaddr_4(rpcb *, CLIENT *); -extern "C" char ** rpcbproc_getaddr_4_svc(rpcb *, struct svc_req *); -extern "C" rpcblist_ptr * rpcbproc_dump_4(void *, CLIENT *); -extern "C" rpcblist_ptr * rpcbproc_dump_4_svc(void *, struct svc_req *); -#define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) -extern "C" rpcb_rmtcallres * rpcbproc_bcast_4(rpcb_rmtcallargs *, CLIENT *); -extern "C" rpcb_rmtcallres * rpcbproc_bcast_4_svc(rpcb_rmtcallargs *, struct svc_req *); -extern "C" u_int * rpcbproc_gettime_4(void *, CLIENT *); -extern "C" u_int * rpcbproc_gettime_4_svc(void *, struct svc_req *); -extern "C" struct netbuf * rpcbproc_uaddr2taddr_4(char **, CLIENT *); -extern "C" struct netbuf * rpcbproc_uaddr2taddr_4_svc(char **, struct svc_req *); -extern "C" char ** rpcbproc_taddr2uaddr_4(struct netbuf *, CLIENT *); -extern "C" char ** rpcbproc_taddr2uaddr_4_svc(struct netbuf *, struct svc_req *); -#define RPCBPROC_GETVERSADDR ((u_int32_t)9) -extern "C" char ** rpcbproc_getversaddr_4(rpcb *, CLIENT *); -extern "C" char ** rpcbproc_getversaddr_4_svc(rpcb *, struct svc_req *); -#define RPCBPROC_INDIRECT ((u_int32_t)10) -extern "C" rpcb_rmtcallres * rpcbproc_indirect_4(rpcb_rmtcallargs *, CLIENT *); -extern "C" rpcb_rmtcallres * rpcbproc_indirect_4_svc(rpcb_rmtcallargs *, struct svc_req *); -#define RPCBPROC_GETADDRLIST ((u_int32_t)11) -extern "C" rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(rpcb *, CLIENT *); -extern "C" rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(rpcb *, struct svc_req *); -#define RPCBPROC_GETSTAT ((u_int32_t)12) -extern "C" rpcb_stat * rpcbproc_getstat_4(void *, CLIENT *); -extern "C" rpcb_stat * rpcbproc_getstat_4_svc(void *, struct svc_req *); - -#elif __STDC__ -extern bool_t * rpcbproc_set_4(rpcb *, CLIENT *); -extern bool_t * rpcbproc_set_4_svc(rpcb *, struct svc_req *); -extern bool_t * rpcbproc_unset_4(rpcb *, CLIENT *); -extern bool_t * rpcbproc_unset_4_svc(rpcb *, struct svc_req *); -extern char ** rpcbproc_getaddr_4(rpcb *, CLIENT *); -extern char ** rpcbproc_getaddr_4_svc(rpcb *, struct svc_req *); -extern rpcblist_ptr * rpcbproc_dump_4(void *, CLIENT *); -extern rpcblist_ptr * rpcbproc_dump_4_svc(void *, struct svc_req *); -#define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) -extern rpcb_rmtcallres * rpcbproc_bcast_4(rpcb_rmtcallargs *, CLIENT *); -extern rpcb_rmtcallres * rpcbproc_bcast_4_svc(rpcb_rmtcallargs *, struct svc_req *); -extern u_int * rpcbproc_gettime_4(void *, CLIENT *); -extern u_int * rpcbproc_gettime_4_svc(void *, struct svc_req *); -extern struct netbuf * rpcbproc_uaddr2taddr_4(char **, CLIENT *); -extern struct netbuf * rpcbproc_uaddr2taddr_4_svc(char **, struct svc_req *); -extern char ** rpcbproc_taddr2uaddr_4(struct netbuf *, CLIENT *); -extern char ** rpcbproc_taddr2uaddr_4_svc(struct netbuf *, struct svc_req *); -#define RPCBPROC_GETVERSADDR ((u_int32_t)9) -extern char ** rpcbproc_getversaddr_4(rpcb *, CLIENT *); -extern char ** rpcbproc_getversaddr_4_svc(rpcb *, struct svc_req *); -#define RPCBPROC_INDIRECT ((u_int32_t)10) -extern rpcb_rmtcallres * rpcbproc_indirect_4(rpcb_rmtcallargs *, CLIENT *); -extern rpcb_rmtcallres * rpcbproc_indirect_4_svc(rpcb_rmtcallargs *, struct svc_req *); -#define RPCBPROC_GETADDRLIST ((u_int32_t)11) -extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(rpcb *, CLIENT *); -extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(rpcb *, struct svc_req *); -#define RPCBPROC_GETSTAT ((u_int32_t)12) -extern rpcb_stat * rpcbproc_getstat_4(void *, CLIENT *); -extern rpcb_stat * rpcbproc_getstat_4_svc(void *, struct svc_req *); - -#else /* Old Style C */ -extern bool_t * rpcbproc_set_4(); -extern bool_t * rpcbproc_set_4_svc(); -extern bool_t * rpcbproc_unset_4(); -extern bool_t * rpcbproc_unset_4_svc(); -extern char ** rpcbproc_getaddr_4(); -extern char ** rpcbproc_getaddr_4_svc(); -extern rpcblist_ptr * rpcbproc_dump_4(); -extern rpcblist_ptr * rpcbproc_dump_4_svc(); -#define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) -extern rpcb_rmtcallres * rpcbproc_bcast_4(); -extern rpcb_rmtcallres * rpcbproc_bcast_4_svc(); -extern u_int * rpcbproc_gettime_4(); -extern u_int * rpcbproc_gettime_4_svc(); -extern struct netbuf * rpcbproc_uaddr2taddr_4(); -extern struct netbuf * rpcbproc_uaddr2taddr_4_svc(); -extern char ** rpcbproc_taddr2uaddr_4(); -extern char ** rpcbproc_taddr2uaddr_4_svc(); -#define RPCBPROC_GETVERSADDR ((u_int32_t)9) -extern char ** rpcbproc_getversaddr_4(); -extern char ** rpcbproc_getversaddr_4_svc(); -#define RPCBPROC_INDIRECT ((u_int32_t)10) -extern rpcb_rmtcallres * rpcbproc_indirect_4(); -extern rpcb_rmtcallres * rpcbproc_indirect_4_svc(); -#define RPCBPROC_GETADDRLIST ((u_int32_t)11) -extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(); -extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(); -#define RPCBPROC_GETSTAT ((u_int32_t)12) -extern rpcb_stat * rpcbproc_getstat_4(); -extern rpcb_stat * rpcbproc_getstat_4_svc(); -#endif /* Old Style C */ - -#endif /* !_RPCB_PROT_H_RPCGEN */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.x b/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.x deleted file mode 100644 index b21ac3d..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpcb_prot.x +++ /dev/null @@ -1,553 +0,0 @@ -%/* -% * $FreeBSD: src/include/rpc/rpcb_prot.x,v 1.3 2002/03/13 10:29:06 obrien Exp $ -% * -% * Copyright (c) 2009, Sun Microsystems, Inc. -% * All rights reserved. -% * -% * Redistribution and use in source and binary forms, with or without -% * modification, are permitted provided that the following conditions are met: -% * - Redistributions of source code must retain the above copyright notice, -% * this list of conditions and the following disclaimer. -% * - Redistributions in binary form must reproduce the above copyright notice, -% * this list of conditions and the following disclaimer in the documentation -% * and/or other materials provided with the distribution. -% * - Neither the name of Sun Microsystems, Inc. nor the names of its -% * contributors may be used to endorse or promote products derived -% * from this software without specific prior written permission. -% * -% * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -% * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -% * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -% * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -% * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -% * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -% * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -% * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -% * POSSIBILITY OF SUCH DAMAGE. -% */ -%/* -% * Copyright (c) 1988 by Sun Microsystems, Inc. -% */ - -%/* from rpcb_prot.x */ - -#ifdef RPC_HDR -% -%/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ -% -%#ifndef _KERNEL -% -#endif - -/* - * rpcb_prot.x - * rpcbind protocol, versions 3 and 4, in RPC Language - */ -% -%/* -% * The following procedures are supported by the protocol in version 3: -% * -% * RPCBPROC_NULL() returns () -% * takes nothing, returns nothing -% * -% * RPCBPROC_SET(rpcb) returns (bool_t) -% * TRUE is success, FALSE is failure. Registers the tuple -% * [prog, vers, address, owner, netid]. -% * Finds out owner and netid information on its own. -% * -% * RPCBPROC_UNSET(rpcb) returns (bool_t) -% * TRUE is success, FALSE is failure. Un-registers tuple -% * [prog, vers, netid]. addresses is ignored. -% * If netid is NULL, unregister all. -% * -% * RPCBPROC_GETADDR(rpcb) returns (string). -% * 0 is failure. Otherwise returns the universal address where the -% * triple [prog, vers, netid] is registered. Ignore address and owner. -% * -% * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) -% * used to dump the entire rpcbind maps -% * -% * RPCBPROC_CALLIT(rpcb_rmtcallargs) -% * RETURNS (rpcb_rmtcallres); -% * Calls the procedure on the remote machine. If it is not registered, -% * this procedure is quiet; i.e. it does not return error information!!! -% * This routine only passes null authentication parameters. -% * It has no interface to xdr routines for RPCBPROC_CALLIT. -% * -% * RPCBPROC_GETTIME() returns (int). -% * Gets the remote machines time -% * -% * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) -% * Returns the netbuf address from universal address. -% * -% * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) -% * Returns the universal address from netbuf address. -% * -% * END OF RPCBIND VERSION 3 PROCEDURES -% */ -%/* -% * Except for RPCBPROC_CALLIT, the procedures above are carried over to -% * rpcbind version 4. Those below are added or modified for version 4. -% * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER -% * AS RPCBPROC_CALLIT. -% * -% * RPCBPROC_BCAST(rpcb_rmtcallargs) -% * RETURNS (rpcb_rmtcallres); -% * Calls the procedure on the remote machine. If it is not registered, -% * this procedure IS quiet; i.e. it DOES NOT return error information!!! -% * This routine should be used for broadcasting and nothing else. -% * -% * RPCBPROC_GETVERSADDR(rpcb) returns (string). -% * 0 is failure. Otherwise returns the universal address where the -% * triple [prog, vers, netid] is registered. Ignore address and owner. -% * Same as RPCBPROC_GETADDR except that if the given version number -% * is not available, the address is not returned. -% * -% * RPCBPROC_INDIRECT(rpcb_rmtcallargs) -% * RETURNS (rpcb_rmtcallres); -% * Calls the procedure on the remote machine. If it is not registered, -% * this procedure is NOT quiet; i.e. it DOES return error information!!! -% * as any normal application would expect. -% * -% * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). -% * Same as RPCBPROC_GETADDR except that it returns a list of all the -% * addresses registered for the combination (prog, vers) (for all -% * transports). -% * -% * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) -% * Returns the statistics about the kind of requests received by rpcbind. -% */ -% -%/* -% * A mapping of (program, version, network ID) to address -% */ -struct rpcb { - rpcprog_t r_prog; /* program number */ - rpcvers_t r_vers; /* version number */ - string r_netid<>; /* network id */ - string r_addr<>; /* universal address */ - string r_owner<>; /* owner of this service */ -}; -#ifdef RPC_HDR -% -%typedef rpcb RPCB; -% -#endif -% -%/* -% * A list of mappings -% * -% * Below are two definitions for the rpcblist structure. This is done because -% * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a -% * struct rpcblist * that rpcgen would produce. One version of the rpcblist -% * structure (actually called rp__list) is used with rpcgen, and the other is -% * defined only in the header file for compatibility with the specified -% * interface. -% */ - -struct rp__list { - rpcb rpcb_map; - struct rp__list *rpcb_next; -}; - -typedef rp__list *rpcblist_ptr; /* results of RPCBPROC_DUMP */ - -#ifdef RPC_HDR -% -%typedef struct rp__list rpcblist; -%typedef struct rp__list RPCBLIST; -% -%#ifndef __cplusplus -%struct rpcblist { -% RPCB rpcb_map; -% struct rpcblist *rpcb_next; -%}; -%#endif -% -%#ifdef __cplusplus -%extern "C" { -%#endif -%extern bool_t xdr_rpcblist(XDR *, rpcblist**); -%#ifdef __cplusplus -%} -%#endif -% -#endif - -% -%/* -% * Arguments of remote calls -% */ -struct rpcb_rmtcallargs { - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - opaque args<>; /* argument */ -}; -#ifdef RPC_HDR -% -%/* -% * Client-side only representation of rpcb_rmtcallargs structure. -% * -% * The routine that XDRs the rpcb_rmtcallargs structure must deal with the -% * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to -% * be passed the XDR routine that knows the args' structure. This routine -% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since -% * the application being called already knows the args structure. So we use a -% * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which -% * includes the args' XDR routine. -% */ -%struct r_rpcb_rmtcallargs { -% rpcprog_t prog; -% rpcvers_t vers; -% rpcproc_t proc; -% struct { -% u_int args_len; -% char *args_val; -% } args; -% xdrproc_t xdr_args; /* encodes args */ -%}; -% -#endif /* def RPC_HDR */ -% -%/* -% * Results of the remote call -% */ -struct rpcb_rmtcallres { - string addr<>; /* remote universal address */ - opaque results<>; /* result */ -}; -#ifdef RPC_HDR -% -%/* -% * Client-side only representation of rpcb_rmtcallres structure. -% */ -%struct r_rpcb_rmtcallres { -% char *addr; -% struct { -% u_int32_t results_len; -% char *results_val; -% } results; -% xdrproc_t xdr_res; /* decodes results */ -%}; -#endif /* RPC_HDR */ -% -%/* -% * rpcb_entry contains a merged address of a service on a particular -% * transport, plus associated netconfig information. A list of rpcb_entrys -% * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used -% * in r_nc_* fields. -% */ -struct rpcb_entry { - string r_maddr<>; /* merged address of service */ - string r_nc_netid<>; /* netid field */ - unsigned int r_nc_semantics; /* semantics of transport */ - string r_nc_protofmly<>; /* protocol family */ - string r_nc_proto<>; /* protocol name */ -}; -% -%/* -% * A list of addresses supported by a service. -% */ -struct rpcb_entry_list { - rpcb_entry rpcb_entry_map; - struct rpcb_entry_list *rpcb_entry_next; -}; - -typedef rpcb_entry_list *rpcb_entry_list_ptr; - -% -%/* -% * rpcbind statistics -% */ -% -const rpcb_highproc_2 = RPCBPROC_CALLIT; -const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR; -const rpcb_highproc_4 = RPCBPROC_GETSTAT; - -const RPCBSTAT_HIGHPROC = 13; /* # of procs in rpcbind V4 plus one */ -const RPCBVERS_STAT = 3; /* provide only for rpcbind V2, V3 and V4 */ -const RPCBVERS_4_STAT = 2; -const RPCBVERS_3_STAT = 1; -const RPCBVERS_2_STAT = 0; -% -%/* Link list of all the stats about getport and getaddr */ -struct rpcbs_addrlist { - rpcprog_t prog; - rpcvers_t vers; - int success; - int failure; - string netid<>; - struct rpcbs_addrlist *next; -}; -% -%/* Link list of all the stats about rmtcall */ -struct rpcbs_rmtcalllist { - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; - int success; - int failure; - int indirect; /* whether callit or indirect */ - string netid<>; - struct rpcbs_rmtcalllist *next; -}; - -typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; -typedef rpcbs_addrlist *rpcbs_addrlist_ptr; -typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; - -struct rpcb_stat { - rpcbs_proc info; - int setinfo; - int unsetinfo; - rpcbs_addrlist_ptr addrinfo; - rpcbs_rmtcalllist_ptr rmtinfo; -}; -% -%/* -% * One rpcb_stat structure is returned for each version of rpcbind -% * being monitored. -% */ - -typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; - -#ifdef RPC_HDR -% -%/* -% * We don't define netbuf in RPCL, since it would contain structure member -% * names that would conflict with the definition of struct netbuf in -% * . Instead we merely declare the XDR routine xdr_netbuf() here, -% * and implement it ourselves in rpc/rpcb_prot.c. -% */ -%#ifdef __cplusplus -%extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); -% -%#else /* __STDC__ */ -%extern bool_t xdr_netbuf(XDR *, struct netbuf *); -% -%#endif -#endif /* def RPC_HDR */ - -/* - * rpcbind procedures - */ -program RPCBPROG { - version RPCBVERS { - bool - RPCBPROC_SET(rpcb) = 1; - - bool - RPCBPROC_UNSET(rpcb) = 2; - - string - RPCBPROC_GETADDR(rpcb) = 3; - - rpcblist_ptr - RPCBPROC_DUMP(void) = 4; - - rpcb_rmtcallres - RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5; - - unsigned int - RPCBPROC_GETTIME(void) = 6; - - struct netbuf - RPCBPROC_UADDR2TADDR(string) = 7; - - string - RPCBPROC_TADDR2UADDR(struct netbuf) = 8; - } = 3; - - version RPCBVERS4 { - bool - RPCBPROC_SET(rpcb) = 1; - - bool - RPCBPROC_UNSET(rpcb) = 2; - - string - RPCBPROC_GETADDR(rpcb) = 3; - - rpcblist_ptr - RPCBPROC_DUMP(void) = 4; - - /* - * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT; - * the new name is intended to indicate that this - * procedure should be used for broadcast RPC, and - * RPCBPROC_INDIRECT should be used for indirect calls. - */ - rpcb_rmtcallres - RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT; - - unsigned int - RPCBPROC_GETTIME(void) = 6; - - struct netbuf - RPCBPROC_UADDR2TADDR(string) = 7; - - string - RPCBPROC_TADDR2UADDR(struct netbuf) = 8; - - string - RPCBPROC_GETVERSADDR(rpcb) = 9; - - rpcb_rmtcallres - RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10; - - rpcb_entry_list_ptr - RPCBPROC_GETADDRLIST(rpcb) = 11; - - rpcb_stat_byvers - RPCBPROC_GETSTAT(void) = 12; - } = 4; -} = 100000; -#ifdef RPC_HDR -% -%#define RPCBVERS_3 RPCBVERS -%#define RPCBVERS_4 RPCBVERS4 -% -%#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" -% -%#else /* ndef _KERNEL */ -%#ifdef __cplusplus -%extern "C" { -%#endif -% -%/* -% * A mapping of (program, version, network ID) to address -% */ -%struct rpcb { -% rpcprog_t r_prog; /* program number */ -% rpcvers_t r_vers; /* version number */ -% char *r_netid; /* network id */ -% char *r_addr; /* universal address */ -% char *r_owner; /* owner of the mapping */ -%}; -%typedef struct rpcb RPCB; -% -%/* -% * A list of mappings -% */ -%struct rpcblist { -% RPCB rpcb_map; -% struct rpcblist *rpcb_next; -%}; -%typedef struct rpcblist RPCBLIST; -%typedef struct rpcblist *rpcblist_ptr; -% -%/* -% * Remote calls arguments -% */ -%struct rpcb_rmtcallargs { -% rpcprog_t prog; /* program number */ -% rpcvers_t vers; /* version number */ -% rpcproc_t proc; /* procedure number */ -% u_int32_t arglen; /* arg len */ -% caddr_t args_ptr; /* argument */ -% xdrproc_t xdr_args; /* XDR routine for argument */ -%}; -%typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; -% -%/* -% * Remote calls results -% */ -%struct rpcb_rmtcallres { -% char *addr_ptr; /* remote universal address */ -% u_int32_t resultslen; /* results length */ -% caddr_t results_ptr; /* results */ -% xdrproc_t xdr_results; /* XDR routine for result */ -%}; -%typedef struct rpcb_rmtcallres rpcb_rmtcallres; -% -%struct rpcb_entry { -% char *r_maddr; -% char *r_nc_netid; -% unsigned int r_nc_semantics; -% char *r_nc_protofmly; -% char *r_nc_proto; -%}; -%typedef struct rpcb_entry rpcb_entry; -% -%/* -% * A list of addresses supported by a service. -% */ -% -%struct rpcb_entry_list { -% rpcb_entry rpcb_entry_map; -% struct rpcb_entry_list *rpcb_entry_next; -%}; -%typedef struct rpcb_entry_list rpcb_entry_list; -% -%typedef rpcb_entry_list *rpcb_entry_list_ptr; -% -%/* -% * rpcbind statistics -% */ -% -%#define rpcb_highproc_2 RPCBPROC_CALLIT -%#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR -%#define rpcb_highproc_4 RPCBPROC_GETSTAT -%#define RPCBSTAT_HIGHPROC 13 -%#define RPCBVERS_STAT 3 -%#define RPCBVERS_4_STAT 2 -%#define RPCBVERS_3_STAT 1 -%#define RPCBVERS_2_STAT 0 -% -%/* Link list of all the stats about getport and getaddr */ -% -%struct rpcbs_addrlist { -% rpcprog_t prog; -% rpcvers_t vers; -% int success; -% int failure; -% char *netid; -% struct rpcbs_addrlist *next; -%}; -%typedef struct rpcbs_addrlist rpcbs_addrlist; -% -%/* Link list of all the stats about rmtcall */ -% -%struct rpcbs_rmtcalllist { -% rpcprog_t prog; -% rpcvers_t vers; -% rpcproc_t proc; -% int success; -% int failure; -% int indirect; -% char *netid; -% struct rpcbs_rmtcalllist *next; -%}; -%typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; -% -%typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; -% -%typedef rpcbs_addrlist *rpcbs_addrlist_ptr; -% -%typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; -% -%struct rpcb_stat { -% rpcbs_proc info; -% int setinfo; -% int unsetinfo; -% rpcbs_addrlist_ptr addrinfo; -% rpcbs_rmtcalllist_ptr rmtinfo; -%}; -%typedef struct rpcb_stat rpcb_stat; -% -%/* -% * One rpcb_stat structure is returned for each version of rpcbind -% * being monitored. -% */ -% -%typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; -% -%#ifdef __cplusplus -%} -%#endif -% -%#endif /* ndef _KERNEL */ -#endif /* RPC_HDR */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpcent.h b/libtirpc-1.3.1/tirpc/rpc/rpcent.h deleted file mode 100644 index 5bff876..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpcent.h +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: rpcent.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/rpcent.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpcent.h, - * For converting rpc program numbers to names etc. - * - */ - -#ifndef _RPC_RPCENT_H -#define _RPC_RPCENT_H - -/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ -/* @(#)rpcent.h 1.1 88/12/06 SMI */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* These are defined in /usr/include/rpc/netdb.h, unless we are using - the C library without RPC support. */ -#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__) -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; - -/* Old interfaces that return a pointer to a static area; MT-unsafe */ -extern struct rpcent *getrpcbyname(const char *); -extern struct rpcent *getrpcbynumber(int); -extern struct rpcent *getrpcent(void); - -extern void setrpcent(int); -extern void endrpcent(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_CENT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/rpcsec_gss.h b/libtirpc-1.3.1/tirpc/rpc/rpcsec_gss.h deleted file mode 100644 index 4fcdc29..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/rpcsec_gss.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2013, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _TIRPC_RPCSEC_GSS_H -#define _TIRPC_RPCSEC_GSS_H - -#include - -#include -#include - -#include - -typedef enum { - rpcsec_gss_svc_default = 0, - rpcsec_gss_svc_none = 1, - rpcsec_gss_svc_integrity = 2, - rpcsec_gss_svc_privacy = 3 -} rpc_gss_service_t; - -typedef struct { - int len; - char name[1]; -} *rpc_gss_principal_t; - -typedef struct { - int req_flags; - int time_req; - gss_cred_id_t my_cred; - gss_channel_bindings_t input_channel_bindings; -} rpc_gss_options_req_t; - -#define MAX_GSS_MECH 128 -typedef struct { - int major_status; - int minor_status; - u_int rpcsec_version; - int ret_flags; - int time_ret; - gss_ctx_id_t gss_context; - char actual_mechanism[MAX_GSS_MECH]; -} rpc_gss_options_ret_t; - -typedef struct { - u_int version; - char *mechanism; - char *qop; - rpc_gss_principal_t client_principal; - char *svc_principal; - rpc_gss_service_t service; -} rpc_gss_rawcred_t; - -typedef struct { - uid_t uid; - gid_t gid; - short gidlen; - gid_t *gidlist; -} rpc_gss_ucred_t; - -typedef struct { - bool_t locked; - rpc_gss_rawcred_t *raw_cred; -} rpc_gss_lock_t; - -typedef struct { - u_int program; - u_int version; - bool_t (*callback)(struct svc_req *, - gss_cred_id_t, gss_ctx_id_t, - rpc_gss_lock_t *, void **); -} rpc_gss_callback_t; - -typedef struct { - int rpc_gss_error; - int system_error; -} rpc_gss_error_t; -#define RPC_GSS_ER_SUCCESS 0 -#define RPC_GSS_ER_SYSTEMERROR 1 - -typedef gss_OID_desc rpc_gss_OID_desc; -typedef rpc_gss_OID_desc *rpc_gss_OID; - - -#ifdef __cplusplus -extern "C" { -#endif - -AUTH *rpc_gss_seccreate(CLIENT *, char *, char *, rpc_gss_service_t, - char *, rpc_gss_options_req_t *, - rpc_gss_options_ret_t *); -bool_t rpc_gss_set_defaults(AUTH *, rpc_gss_service_t, char *); -int rpc_gss_max_data_length(AUTH *, int); -int rpc_gss_svc_max_data_length(struct svc_req *, int); -bool_t rpc_gss_set_svc_name(char *, char *, u_int, u_int, u_int); -bool_t rpc_gss_getcred(struct svc_req *, rpc_gss_rawcred_t **, - rpc_gss_ucred_t **, void **); -bool_t rpc_gss_set_callback(rpc_gss_callback_t *); -bool_t rpc_gss_get_principal_name(rpc_gss_principal_t *, char *, - char *, char *, char *); -void rpc_gss_get_error(rpc_gss_error_t *); -char **rpc_gss_get_mechanisms(void); -char **rpc_gss_get_mech_info(char *, rpc_gss_service_t *); -bool_t rpc_gss_get_versions(u_int *, u_int *); -bool_t rpc_gss_is_installed(char *); -bool_t rpc_gss_mech_to_oid(char *, rpc_gss_OID *); -bool_t rpc_gss_qop_to_num(char *, char *, u_int *); - -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_RPCSEC_GSS_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/svc.h b/libtirpc-1.3.1/tirpc/rpc/svc.h deleted file mode 100644 index 6d176f0..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc.h +++ /dev/null @@ -1,467 +0,0 @@ -/* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)svc.h 1.35 88/12/17 SMI - * from: @(#)svc.h 1.27 94/04/25 SMI - * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ - */ - -/* - * svc.h, Server-side remote procedure call interface. - * - * Copyright (C) 1986-1993 by Sun Microsystems, Inc. - */ - -#ifndef _TIRPC_SVC_H -#define _TIRPC_SVC_H - -/* - * This interface must manage two items concerning remote procedure calling: - * - * 1) An arbitrary number of transport connections upon which rpc requests - * are received. The two most notable transports are TCP and UDP; they are - * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; - * they in turn call xprt_register and xprt_unregister. - * - * 2) An arbitrary number of locally registered services. Services are - * described by the following four data: program number, version number, - * "service dispatch" function, a transport handle, and a boolean that - * indicates whether or not the exported program should be registered with a - * local binder service; if true the program's number and version and the - * port number from the transport handle are registered with the binder. - * These data are registered with the rpc svc system via svc_register. - * - * A service's dispatch function is called whenever an rpc request comes in - * on a transport. The request's program and version numbers must match - * those of the registered service. The dispatch function is passed two - * parameters, struct svc_req * and SVCXPRT *, defined below. - */ - -/* - * Service control requests - */ -#define SVCGET_VERSQUIET 1 -#define SVCSET_VERSQUIET 2 -#define SVCGET_CONNMAXREC 3 -#define SVCSET_CONNMAXREC 4 - -/* - * Operations for rpc_control(). - */ -#define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ -#define RPC_SVC_CONNMAXREC_GET 1 - -enum xprt_stat { - XPRT_DIED, - XPRT_MOREREQS, - XPRT_IDLE -}; - -/* - * Server side transport handle - */ -typedef struct __rpc_svcxprt { - int xp_fd; -#define xp_sock xp_fd - u_short xp_port; /* associated port number */ - const struct xp_ops { - /* receive incoming requests */ - bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); - /* get transport status */ - enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); - /* get arguments */ - bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, - void *); - /* send reply */ - bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); - /* free mem allocated for args */ - bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, - void *); - /* destroy this struct */ - void (*xp_destroy)(struct __rpc_svcxprt *); - } *xp_ops; - int xp_addrlen; /* length of remote address */ - struct sockaddr_in6 xp_raddr; /* remote addr. (backward ABI compat) */ - /* XXX - fvdl stick this here for ABI backward compat reasons */ - const struct xp_ops2 { - /* catch-all function */ - bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, - void *); - } *xp_ops2; - char *xp_tp; /* transport provider device name */ - char *xp_netid; /* network token */ - struct netbuf xp_ltaddr; /* local transport address */ - struct netbuf xp_rtaddr; /* remote transport address */ - struct opaque_auth xp_verf; /* raw response verifier */ - void *xp_p1; /* private: for use by svc ops */ - void *xp_p2; /* private: for use by svc ops */ - void *xp_p3; /* private: for use by svc lib */ - int xp_type; /* transport type */ -} SVCXPRT; - -/* - * Service request - */ -struct svc_req { - /* ORDER: compatibility with legacy RPC */ - u_int32_t rq_prog; /* service program number */ - u_int32_t rq_vers; /* service protocol version */ - u_int32_t rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - void *rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ - - /* New with TI-RPC */ - caddr_t rq_clntname; /* read only client name */ - caddr_t rq_svcname; /* read only cooked service cred */ -}; - -/* - * Approved way of getting address of caller - */ -#define svc_getrpccaller(x) (&(x)->xp_rtaddr) - -/* - * Operations defined on an SVCXPRT handle - * - * SVCXPRT *xprt; - * struct rpc_msg *msg; - * xdrproc_t xargs; - * void * argsp; - */ -#define SVC_RECV(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) -#define svc_recv(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) - -#define SVC_STAT(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) -#define svc_stat(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) - -#define SVC_GETARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) -#define svc_getargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) - -#define SVC_REPLY(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) -#define svc_reply(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) - -#define SVC_FREEARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) -#define svc_freeargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) - -#define SVC_DESTROY(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) -#define svc_destroy(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) - -#define SVC_CONTROL(xprt, rq, in) \ - (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) - -/* - * Service registration - * - * svc_reg(xprt, prog, vers, dispatch, nconf) - * const SVCXPRT *xprt; - * const rpcprog_t prog; - * const rpcvers_t vers; - * const void (*dispatch)(); - * const struct netconfig *nconf; - */ - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, - void (*)(struct svc_req *, SVCXPRT *), - const struct netconfig *); -#ifdef __cplusplus -} -#endif - -/* - * Service un-registration - * - * svc_unreg(prog, vers) - * const rpcprog_t prog; - * const rpcvers_t vers; - */ - -#ifdef __cplusplus -extern "C" { -#endif -extern void svc_unreg(const rpcprog_t, const rpcvers_t); -#ifdef __cplusplus -} -#endif - -/* - * Transport registration. - * - * xprt_register(xprt) - * SVCXPRT *xprt; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void xprt_register(SVCXPRT *); -#ifdef __cplusplus -} -#endif - -/* - * Transport un-register - * - * xprt_unregister(xprt) - * SVCXPRT *xprt; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void xprt_unregister(SVCXPRT *); -#ifdef __cplusplus -} -#endif - - -/* - * When the service routine is called, it must first check to see if it - * knows about the procedure; if not, it should call svcerr_noproc - * and return. If so, it should deserialize its arguments via - * SVC_GETARGS (defined above). If the deserialization does not work, - * svcerr_decode should be called followed by a return. Successful - * decoding of the arguments should be followed the execution of the - * procedure's code and a call to svc_sendreply. - * - * Also, if the service refuses to execute the procedure due to too- - * weak authentication parameters, svcerr_weakauth should be called. - * Note: do not confuse access-control failure with weak authentication! - * - * NB: In pure implementations of rpc, the caller always waits for a reply - * msg. This message is sent when svc_sendreply is called. - * Therefore pure service implementations should always call - * svc_sendreply even if the function logically returns void; use - * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows - * for the abuse of pure rpc via batched calling or pipelining. In the - * case of a batched call, svc_sendreply should NOT be called since - * this would send a return message, which is what batching tries to avoid. - * It is the service/protocol writer's responsibility to know which calls are - * batched and which are not. Warning: responding to batch calls may - * deadlock the caller and server processes! - */ - -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); -extern void svcerr_decode(SVCXPRT *); -extern void svcerr_weakauth(SVCXPRT *); -extern void svcerr_noproc(SVCXPRT *); -extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); -extern void svcerr_auth(SVCXPRT *, enum auth_stat); -extern void svcerr_noprog(SVCXPRT *); -extern void svcerr_systemerr(SVCXPRT *); -extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, - char *(*)(char *), xdrproc_t, xdrproc_t, - char *); -#ifdef __cplusplus -} -#endif - -/* - * Lowest level dispatching -OR- who owns this process anyway. - * Somebody has to wait for incoming requests and then call the correct - * service routine. The routine svc_run does infinite waiting; i.e., - * svc_run never returns. - * Since another (co-existant) package may wish to selectively wait for - * incoming calls or other events outside of the rpc architecture, the - * routine svc_getreq is provided. It must be passed readfds, the - * "in-place" results of a select system call (see select, section 2). - */ - -/* - * Global keeper of rpc service descriptors in use - * dynamic; must be inspected before each call to select - */ -extern int svc_maxfd; -extern fd_set svc_fdset; -#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ -extern struct pollfd *svc_pollfd; -extern int svc_max_pollfd; - -/* - * a small program implemented by the svc_rpc implementation itself; - * also see clnt.h for protocol numbers. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void rpctest_service(void); -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern void svc_getreq(int); -extern void svc_getreqset(fd_set *); -extern void svc_getreq_common(int); -struct pollfd; -extern void svc_getreq_poll(struct pollfd *, int); - -extern void svc_run(void); -extern void svc_exit(void); -#ifdef __cplusplus -} -#endif - -/* - * Socket to use on svcxxx_create call to get default socket - */ -#define RPC_ANYSOCK -1 -#define RPC_ANYFD RPC_ANYSOCK - -/* - * These are the existing service side transport implementations - */ - -#ifdef __cplusplus -extern "C" { -#endif -/* - * Transport independent svc_create routine. - */ -extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), - const rpcprog_t, const rpcvers_t, const char *); -/* - * void (*dispatch)(); -- dispatch routine - * const rpcprog_t prognum; -- program number - * const rpcvers_t versnum; -- version number - * const char *nettype; -- network type - */ - - -/* - * Generic server creation routine. It takes a netconfig structure - * instead of a nettype. - */ - -extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), - const rpcprog_t, const rpcvers_t, - const struct netconfig *); - /* - * void (*dispatch)(); -- dispatch routine - * const rpcprog_t prognum; -- program number - * const rpcvers_t versnum; -- version number - * const struct netconfig *nconf; -- netconfig structure - */ - - -/* - * Generic TLI create routine - */ -extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, - const struct t_bind *, const u_int, - const u_int); -/* - * const int fd; -- connection end point - * const struct netconfig *nconf; -- netconfig structure for network - * const struct t_bind *bindaddr; -- local bind address - * const u_int sendsz; -- max sendsize - * const u_int recvsz; -- max recvsize - */ - -/* - * Connectionless and connectionful create routines - */ - -extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); -/* - * const int fd; -- open connection end point - * const u_int sendsize; -- max send size - * const u_int recvsize; -- max recv size - */ - -/* - * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). - */ -extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); - -extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int); - /* - * const int fd; -- open connection - * const u_int sendsize; -- max send size - * const u_int recvsize; -- max recv size - */ - - -/* - * the routine takes any *open* connection - * descriptor as its first input and is used for open connections. - */ -extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); -/* - * const int fd; -- open connection end point - * const u_int sendsize; -- max send size - * const u_int recvsize; -- max recv size - */ - -/* - * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). - */ -extern SVCXPRT *svcunixfd_create(int, u_int, u_int); - -/* - * Memory based rpc (for speed check and testing) - */ -extern SVCXPRT *svc_raw_create(void); - -/* - * svc_dg_enable_cache() enables the cache on dg transports. - */ -int svc_dg_enablecache(SVCXPRT *, const u_int); - -int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid); - -#ifdef __cplusplus -} -#endif - - -/* for backward compatibility */ -#include - - - -#endif /* !_TIRPC_SVC_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/svc_auth.h b/libtirpc-1.3.1/tirpc/rpc/svc_auth.h deleted file mode 100644 index 67608d0..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc_auth.h +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: svc_auth.h,v 1.8 2000/06/02 22:57:57 fvdl Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)svc_auth.h 1.6 86/07/16 SMI - * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/svc_auth.h,v 1.14 2002/03/23 17:24:55 imp Exp $ - */ - -/* - * svc_auth.h, Service side of rpc authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_SVC_AUTH_H -#define _RPC_SVC_AUTH_H - -/* - * Interface to server-side authentication flavors. - */ -typedef struct SVCAUTH { - struct svc_auth_ops { - int (*svc_ah_wrap)(struct SVCAUTH *, XDR *, xdrproc_t, - caddr_t); - int (*svc_ah_unwrap)(struct SVCAUTH *, XDR *, xdrproc_t, - caddr_t); - int (*svc_ah_destroy)(struct SVCAUTH *); - } *svc_ah_ops; - caddr_t svc_ah_private; -} SVCAUTH; - -#define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->svc_ah_ops->svc_ah_wrap))(auth, xdrs, xfunc, xwhere)) -#define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ - ((*((auth)->svc_ah_ops->svc_ah_unwrap))(auth, xdrs, xfunc, xwhere)) -#define SVCAUTH_DESTROY(auth) \ - ((*((auth)->svc_ah_ops->svc_ah_destroy))(auth)) - -/* - * Server side authenticator - */ -#ifdef __cplusplus -extern "C" { -#endif -extern enum auth_stat _gss_authenticate(struct svc_req *, struct rpc_msg *, - bool_t *); -extern enum auth_stat _authenticate(struct svc_req *, struct rpc_msg *); -extern int svc_auth_reg(int, enum auth_stat (*)(struct svc_req *, - struct rpc_msg *)); - -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_SVC_AUTH_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/svc_auth_gss.h b/libtirpc-1.3.1/tirpc/rpc/svc_auth_gss.h deleted file mode 100644 index 09f755d..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc_auth_gss.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, Oracle America, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _TIRPC_SVC_AUTH_GSS_H -#define _TIRPC_SVC_AUTH_GSS_H - -#include -#include - -/* - * Legacy U-M server GSS APIs - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern bool_t svcauth_gss_set_svc_name(gss_name_t name); -extern char *svcauth_gss_get_principal(SVCAUTH *); - -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_SVC_AUTH_GSS_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/svc_dg.h b/libtirpc-1.3.1/tirpc/rpc/svc_dg.h deleted file mode 100644 index 332128d..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc_dg.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: svc_dg.h,v 1.1 2000/06/02 23:11:16 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/svc_dg.h,v 1.1 2001/03/19 12:49:47 alfred Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * XXX - this file exists only so that the rpcbind code can pull it in. - * This should go away. It should only be include by svc_dg.c and - * rpcb_svc_com.c in the rpcbind code. - */ - -/* - * kept in xprt->xp_p2 - */ -struct svc_dg_data { - /* XXX: optbuf should be the first field, used by ti_opts.c code */ - size_t su_iosz; /* size of send.recv buffer */ - u_int32_t su_xid; /* transaction id */ - XDR su_xdrs; /* XDR handle */ - char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ - void *su_cache; /* cached data, NULL if none */ - - struct msghdr su_msghdr; /* msghdr received from clnt */ - unsigned char su_cmsg[64]; /* cmsghdr received from clnt */ -}; - -#define __rpcb_get_dg_xidp(x) (&((struct svc_dg_data *)(x)->xp_p2)->su_xid) diff --git a/libtirpc-1.3.1/tirpc/rpc/svc_mt.h b/libtirpc-1.3.1/tirpc/rpc/svc_mt.h deleted file mode 100644 index 84a9f44..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc_mt.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, Axentia Technologies AB. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * svc_mt.h, Server-side transport extensions - */ - -#ifndef _TIRPC_SVC_MT_H -#define _TIRPC_SVC_MT_H - -typedef struct __rpc_svcxprt_ext { - int flags; - SVCAUTH xp_auth; -} SVCXPRT_EXT; - - -#define SVCEXT(xprt) \ - ((SVCXPRT_EXT *)(xprt)->xp_p3) - -#define SVC_XP_AUTH(xprt) \ - (SVCEXT(xprt)->xp_auth) - -#define SVC_VERSQUIET 0x0001 /* keep quiet about version mismatch */ - -#define svc_flags(xprt) \ - (SVCEXT(xprt)->flags) - -#define version_keepquiet(xprt) \ - (svc_flags(xprt) & SVC_VERSQUIET) - -#endif /* !_TIRPC_SVC_MT_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/svc_soc.h b/libtirpc-1.3.1/tirpc/rpc/svc_soc.h deleted file mode 100644 index 9b7befa..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/svc_soc.h +++ /dev/null @@ -1,142 +0,0 @@ -/* $NetBSD: svc_soc.h,v 1.1 2000/06/02 22:57:57 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/svc_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * svc.h, Server-side remote procedure call interface. - */ - -#ifndef _RPC_SVC_SOC_H -#define _RPC_SVC_SOC_H - -/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ -/* svc_soc.h 1.8 89/05/01 SMI */ - -/* - * All the following declarations are only for backward compatibility - * with TS-RPC - */ - -/* - * Approved way of getting address of caller - */ -#define svc_getcaller(x) (&(x)->xp_raddr) -/* Getting address of a caller using netbuf xp_rtaddr */ -#define svc_getcaller_netbuf(x) (&(x)->xp_rtaddr) -/* - * Service registration - * - * svc_register(xprt, prog, vers, dispatch, protocol) - * SVCXPRT *xprt; - * u_long prog; - * u_long vers; - * void (*dispatch)(); - * int protocol; like TCP or UDP, zero means do not register - */ -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t svc_register(SVCXPRT *, u_long, u_long, - void (*)(struct svc_req *, SVCXPRT *), int); -#ifdef __cplusplus -} -#endif - -/* - * Service un-registration - * - * svc_unregister(prog, vers) - * u_long prog; - * u_long vers; - */ -#ifdef __cplusplus -extern "C" { -#endif -extern void svc_unregister(u_long, u_long); -#ifdef __cplusplus -} -#endif - - -/* - * Memory based rpc for testing and timing. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern SVCXPRT *svcraw_create(void); -#ifdef __cplusplus -} -#endif - - -/* - * Udp based rpc. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern SVCXPRT *svcudp_create(int); -extern SVCXPRT *svcudp_bufcreate(int, u_int, u_int); -extern int svcudp_enablecache(SVCXPRT *, u_long); -extern SVCXPRT *svcudp6_create(int); -extern SVCXPRT *svcudp6_bufcreate(int, u_int, u_int); -#ifdef __cplusplus -} -#endif - - -/* - * Tcp based rpc. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern SVCXPRT *svctcp_create(int, u_int, u_int); -extern SVCXPRT *svctcp6_create(int, u_int, u_int); -#ifdef __cplusplus -} -#endif - -/* - * Fd based rpc. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern SVCXPRT *svcfd_create(int, u_int, u_int); -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_SVC_SOC_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/types.h b/libtirpc-1.3.1/tirpc/rpc/types.h deleted file mode 100644 index 0153a5c..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/types.h +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)types.h 1.18 87/07/24 SMI - * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC - * $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $ - */ - -/* - * Rpc additions to - */ -#ifndef _TIRPC_TYPES_H -#define _TIRPC_TYPES_H - -#include - -typedef int32_t bool_t; -typedef int32_t enum_t; - -typedef u_int32_t rpcprog_t; -typedef u_int32_t rpcvers_t; -typedef u_int32_t rpcproc_t; -typedef u_int32_t rpcprot_t; -typedef u_int32_t rpcport_t; -typedef int32_t rpc_inline_t; - -#ifndef NULL -# define NULL 0 -#endif -#define __dontcare__ -1 - -#ifndef FALSE -# define FALSE (0) -#endif -#ifndef TRUE -# define TRUE (1) -#endif - -#define mem_alloc(bsize) calloc(1, bsize) -#define mem_free(ptr, bsize) free(ptr) - - -#if defined __APPLE_CC__ || defined __FreeBSD__ || !defined (__GLIBC__) -# define __u_char_defined -# define __daddr_t_defined -#endif - -#ifndef __u_char_defined -typedef __u_char u_char; -typedef __u_short u_short; -typedef __u_int u_int; -typedef __u_long u_long; -typedef __quad_t quad_t; -typedef __u_quad_t u_quad_t; -typedef __fsid_t fsid_t; -# define __u_char_defined -#endif -#ifndef __daddr_t_defined -typedef __daddr_t daddr_t; -typedef __caddr_t caddr_t; -# define __daddr_t_defined -#endif - -#include -#include -#include -#include - -/* - * The netbuf structure is defined here, because FreeBSD / NetBSD only use - * it inside the RPC code. It's in on SVR4, but it would be confusing - * to have an xti.h, since FreeBSD / NetBSD does not support XTI/TLI. - */ - -/* - * The netbuf structure is used for transport-independent address storage. - */ -struct netbuf { - unsigned int maxlen; - unsigned int len; - void *buf; -}; - -/* - * The format of the addres and options arguments of the XTI t_bind call. - * Only provided for compatibility, it should not be used. - */ - -struct t_bind { - struct netbuf addr; - unsigned int qlen; -}; - -/* - * Internal library and rpcbind use. This is not an exported interface, do - * not use. - */ -struct __rpc_sockinfo { - int si_af; - int si_proto; - int si_socktype; - int si_alen; -}; - -#endif /* _TIRPC_TYPES_H */ diff --git a/libtirpc-1.3.1/tirpc/rpc/xdr.h b/libtirpc-1.3.1/tirpc/rpc/xdr.h deleted file mode 100644 index 80b35ce..0000000 --- a/libtirpc-1.3.1/tirpc/rpc/xdr.h +++ /dev/null @@ -1,378 +0,0 @@ -/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)xdr.h 1.19 87/04/22 SMI - * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ - */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _TIRPC_XDR_H -#define _TIRPC_XDR_H -#include -#include - -#include - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE=0, - XDR_DECODE=1, - XDR_FREE=2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular implementation. - */ -typedef struct __rpc_xdr { - enum xdr_op x_op; /* operation; fast additional param */ - const struct xdr_ops { - /* get a long from underlying stream */ - bool_t (*x_getlong)(struct __rpc_xdr *, long *); - /* put a long to " */ - bool_t (*x_putlong)(struct __rpc_xdr *, const long *); - /* get some bytes from " */ - bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int); - /* put some bytes to " */ - bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int); - /* returns bytes off from beginning */ - u_int (*x_getpostn)(struct __rpc_xdr *); - /* lets you reposition the stream */ - bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); - /* buf quick ptr to buffered data */ - int32_t *(*x_inline)(struct __rpc_xdr *, u_int); - /* free privates of this xdr_stream */ - void (*x_destroy)(struct __rpc_xdr *); - bool_t (*x_control)(struct __rpc_xdr *, int, void *); - } *x_ops; - char * x_public; /* users' data */ - void * x_private; /* pointer to private data */ - char * x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ -} XDR; - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - */ -#ifdef _KERNEL -typedef bool_t (*xdrproc_t)(XDR *, void *, u_int); -#else -/* - * XXX can't actually prototype it, because some take three args!!! - */ -typedef bool_t (*xdrproc_t)(XDR *, ...); -#endif - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * long *longp; - * char * addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -static __inline int -xdr_getint32(XDR *xdrs, int32_t *ip) -{ - long l; - - if (!xdr_getlong(xdrs, &l)) - return (FALSE); - *ip = (int32_t)l; - return (TRUE); -} - -static __inline int -xdr_putint32(XDR *xdrs, int32_t *ip) -{ - long l; - - l = (long)*ip; - return xdr_putlong(xdrs, &l); -} - -#define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) -#define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) -#define xdr_destroy(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) - -#define XDR_CONTROL(xdrs, req, op) \ - if ((xdrs)->x_ops->x_control) \ - (*(xdrs)->x_ops->x_control)(xdrs, req, op) -#define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) - -#define xdr_rpcvers(xdrs, versp) xdr_u_int32_t(xdrs, versp) -#define xdr_rpcprog(xdrs, progp) xdr_u_int32_t(xdrs, progp) -#define xdr_rpcproc(xdrs, procp) xdr_u_int32_t(xdrs, procp) -#define xdr_rpcprot(xdrs, protp) xdr_u_int32_t(xdrs, protp) -#define xdr_rpcport(xdrs, portp) xdr_u_int32_t(xdrs, portp) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim { - int value; - xdrproc_t proc; -}; - -/* - * In-line routines for fast encode/decode of primitive data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ -#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) -#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) -#define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf)) -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) - -#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) - -/* - * These are the "generic" xdr routines. - */ -#ifdef __cplusplus -extern "C" { -#endif -extern bool_t xdr_void(void); -extern bool_t xdr_int(XDR *, int *); -extern bool_t xdr_u_int(XDR *, u_int *); -extern bool_t xdr_long(XDR *, long *); -extern bool_t xdr_u_long(XDR *, u_long *); -extern bool_t xdr_short(XDR *, short *); -extern bool_t xdr_u_short(XDR *, u_short *); -extern bool_t xdr_int8_t(XDR *, int8_t *); -extern bool_t xdr_u_int8_t(XDR *, uint8_t *); -extern bool_t xdr_uint8_t(XDR *, uint8_t *); -extern bool_t xdr_int16_t(XDR *, int16_t *); -extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); -extern bool_t xdr_uint16_t(XDR *, uint16_t *); -extern bool_t xdr_int32_t(XDR *, int32_t *); -extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); -extern bool_t xdr_uint32_t(XDR *, uint32_t *); -extern bool_t xdr_int64_t(XDR *, int64_t *); -extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); -extern bool_t xdr_uint64_t(XDR *, uint64_t *); -extern bool_t xdr_quad_t(XDR *, int64_t *); -extern bool_t xdr_u_quad_t(XDR *, u_int64_t *); -extern bool_t xdr_bool(XDR *, bool_t *); -extern bool_t xdr_enum(XDR *, enum_t *); -extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); -extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); -extern bool_t xdr_opaque(XDR *, char *, u_int); -extern bool_t xdr_string(XDR *, char **, u_int); -extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); -extern bool_t xdr_char(XDR *, char *); -extern bool_t xdr_u_char(XDR *, u_char *); -extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); -extern bool_t xdr_float(XDR *, float *); -extern bool_t xdr_double(XDR *, double *); -extern bool_t xdr_quadruple(XDR *, long double *); -extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); -extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); -extern bool_t xdr_wrapstring(XDR *, char **); -extern void xdr_free(xdrproc_t, void *); -extern bool_t xdr_hyper(XDR *, quad_t *); -extern bool_t xdr_u_hyper(XDR *, u_quad_t *); -extern bool_t xdr_longlong_t(XDR *, quad_t *); -extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); -extern u_long xdr_sizeof(xdrproc_t, void *); -#ifdef __cplusplus -} -#endif - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj { - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj(XDR *, struct netobj *); - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ -#ifdef __cplusplus -extern "C" { -#endif -/* XDR using memory buffers */ -extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op); - -/* XDR using stdio library */ -extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); - -/* XDR pseudo records for tcp */ -extern void xdrrec_create(XDR *, u_int, u_int, void *, - int (*)(void *, void *, int), - int (*)(void *, void *, int)); - -/* make end of xdr record */ -extern bool_t xdrrec_endofrecord(XDR *, int); - -/* move to beginning of next record */ -extern bool_t xdrrec_skiprecord(XDR *); - -/* true if no more input */ -extern bool_t xdrrec_eof(XDR *); -extern u_int xdrrec_readbytes(XDR *, caddr_t, u_int); -#ifdef __cplusplus -} -#endif - -#endif /* !_TIRPC_XDR_H */ diff --git a/libtirpc-1.3.1/tirpc/rpcsvc/crypt.h b/libtirpc-1.3.1/tirpc/rpcsvc/crypt.h deleted file mode 100644 index da1f9cc..0000000 --- a/libtirpc-1.3.1/tirpc/rpcsvc/crypt.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _CRYPT_H_RPCGEN -#define _CRYPT_H_RPCGEN - -#include - -#ifndef IXDR_GET_INT32 -#define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf)) -#endif -#ifndef IXDR_PUT_INT32 -#define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v)) -#endif -#ifndef IXDR_GET_U_INT32 -#define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf)) -#endif -#ifndef IXDR_PUT_U_INT32 -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v)) -#endif - -enum des_dir { - ENCRYPT_DES = 0, - DECRYPT_DES = 1, -}; -typedef enum des_dir des_dir; -#ifdef __cplusplus -extern "C" bool_t xdr_des_dir(XDR *, des_dir*); -#elif __STDC__ -extern bool_t xdr_des_dir(XDR *, des_dir*); -#else /* Old Style C */ -bool_t xdr_des_dir(); -#endif /* Old Style C */ - - -enum des_mode { - CBC_DES = 0, - ECB_DES = 1, -}; -typedef enum des_mode des_mode; -#ifdef __cplusplus -extern "C" bool_t xdr_des_mode(XDR *, des_mode*); -#elif __STDC__ -extern bool_t xdr_des_mode(XDR *, des_mode*); -#else /* Old Style C */ -bool_t xdr_des_mode(); -#endif /* Old Style C */ - - -struct desargs { - u_char des_key[8]; - des_dir des_dir; - des_mode des_mode; - u_char des_ivec[8]; - struct { - u_int desbuf_len; - char *desbuf_val; - } desbuf; -}; -typedef struct desargs desargs; -#ifdef __cplusplus -extern "C" bool_t xdr_desargs(XDR *, desargs*); -#elif __STDC__ -extern bool_t xdr_desargs(XDR *, desargs*); -#else /* Old Style C */ -bool_t xdr_desargs(); -#endif /* Old Style C */ - - -struct desresp { - struct { - u_int desbuf_len; - char *desbuf_val; - } desbuf; - u_char des_ivec[8]; - int stat; -}; -typedef struct desresp desresp; -#ifdef __cplusplus -extern "C" bool_t xdr_desresp(XDR *, desresp*); -#elif __STDC__ -extern bool_t xdr_desresp(XDR *, desresp*); -#else /* Old Style C */ -bool_t xdr_desresp(); -#endif /* Old Style C */ - - -#define CRYPT_PROG ((u_int32_t)600100029) -#define CRYPT_VERS ((u_int32_t)1) - -#ifdef __cplusplus -#define DES_CRYPT ((u_int32_t)1) -extern "C" desresp * des_crypt_1(desargs *, CLIENT *); -extern "C" desresp * des_crypt_1_svc(desargs *, struct svc_req *); - -#elif __STDC__ -#define DES_CRYPT ((u_int32_t)1) -extern desresp * des_crypt_1(desargs *, CLIENT *); -extern desresp * des_crypt_1_svc(desargs *, struct svc_req *); - -#else /* Old Style C */ -#define DES_CRYPT ((u_int32_t)1) -extern desresp * des_crypt_1(); -extern desresp * des_crypt_1_svc(); -#endif /* Old Style C */ - -#endif /* !_CRYPT_H_RPCGEN */ diff --git a/libtirpc-1.3.1/tirpc/rpcsvc/crypt.x b/libtirpc-1.3.1/tirpc/rpcsvc/crypt.x deleted file mode 100644 index b50cf8d..0000000 --- a/libtirpc-1.3.1/tirpc/rpcsvc/crypt.x +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1996 - * Bill Paul . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef RPC_HDR -%#include -%__FBSDID("$FreeBSD: src/include/rpcsvc/crypt.x,v 1.5 2003/05/04 02:51:42 obrien Exp $"); -#endif - -/* - * This protocol definition exists because of the U.S. government and - * its stupid export laws. We can't export DES code from the United - * States to other countries (even though the code already exists - * outside the U.S. -- go figure that one out) but we need to make - * Secure RPC work. The normal way around this is to break the DES - * code out into a shared library; we can then provide a dummy lib - * in the base OS and provide the real lib in the secure dist, which - * the user can install later. But we need Secure RPC for NIS+, and - * there are several system programs that use NIS+ which are statically - * linked. We would have to provide replacements for these programs - * in the secure dist, but there are a lot, and this is a pain. The - * shared lib trick won't work for these programs, and we can't change - * them once they're compiled. - * - * One solution for this problem is to do the DES encryption as a system - * call; no programs need to be changed and we can even supply the DES - * support as an LKM. But this bloats the kernel. Maybe if we have - * Secure NFS one day this will be worth it, but for now we should keep - * this mess in user space. - * - * So we have this second solution: we provide a server that does the - * DES encryption for us. In this case, the server is keyserv (we need - * it to make Secure RPC work anyway) and we use this protocol to ship - * the data back and forth between keyserv and the application. - */ - -enum des_dir { ENCRYPT_DES, DECRYPT_DES }; -enum des_mode { CBC_DES, ECB_DES }; - -struct desargs { - u_char des_key[8]; /* key (with low bit parity) */ - des_dir des_dir; /* direction */ - des_mode des_mode; /* mode */ - u_char des_ivec[8]; /* input vector */ - opaque desbuf<>; -}; - -struct desresp { - opaque desbuf<>; - u_char des_ivec[8]; - int stat; -}; - -program CRYPT_PROG { - version CRYPT_VERS { - desresp - DES_CRYPT(desargs) = 1; - } = 1; -} = 600100029; diff --git a/libtirpc-1.3.1/tirpc/rpcsvc/key_prot.x b/libtirpc-1.3.1/tirpc/rpcsvc/key_prot.x deleted file mode 100644 index 63c1bbc..0000000 --- a/libtirpc-1.3.1/tirpc/rpcsvc/key_prot.x +++ /dev/null @@ -1,284 +0,0 @@ -%/* -% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for -% * unrestricted use provided that this legend is included on all tape -% * media and as a part of the software program in whole or part. Users -% * may copy or modify Sun RPC without charge, but are not authorized -% * to license or distribute it to anyone else except as part of a product or -% * program developed by the user. -% * -% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE -% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR -% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. -% * -% * Sun RPC is provided with no support and without any obligation on the -% * part of Sun Microsystems, Inc. to assist in its use, correction, -% * modification or enhancement. -% * -% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE -% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC -% * OR ANY PART THEREOF. -% * -% * In no event will Sun Microsystems, Inc. be liable for any lost revenue -% * or profits or other special, indirect and consequential damages, even if -% * Sun has been advised of the possibility of such damages. -% * -% * Sun Microsystems, Inc. -% * 2550 Garcia Avenue -% * Mountain View, California 94043 -% */ -/* - * Key server protocol definition - * Copyright (C) 1990, 1991 Sun Microsystems, Inc. - * - * The keyserver is a public key storage/encryption/decryption service - * The encryption method used is based on the Diffie-Hellman exponential - * key exchange technology. - * - * The key server is local to each machine, akin to the portmapper. - * Under TI-RPC, communication with the keyserver is through the - * loopback transport. - * - * NOTE: This .x file generates the USER level headers for the keyserver. - * the KERNEL level headers are created by hand as they kernel has special - * requirements. - */ - -%#if 0 -%#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" -%#endif -% -%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -% -%/* -% * Compiled from key_prot.x using rpcgen. -% * DO NOT EDIT THIS FILE! -% * This is NOT source code! -% */ - -/* - * PROOT and MODULUS define the way the Diffie-Hellman key is generated. - * - * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1, - * where p is also prime. - * - * PROOT satisfies the following two conditions: - * (1) (PROOT ** 2) % MODULUS != 1 - * (2) (PROOT ** p) % MODULUS != 1 - * - */ - -const PROOT = 3; -const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; - -const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */ -const KEYSIZE = 192; /* KEYSIZE == bit length of key */ -const KEYBYTES = 24; /* byte length of key */ - -/* - * The first 16 hex digits of the encrypted secret key are used as - * a checksum in the database. - */ -const KEYCHECKSUMSIZE = 16; - -/* - * status of operation - */ -enum keystatus { - KEY_SUCCESS, /* no problems */ - KEY_NOSECRET, /* no secret key stored */ - KEY_UNKNOWN, /* unknown netname */ - KEY_SYSTEMERR /* system error (out of memory, encryption failure) */ -}; - -typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */ - -typedef string netnamestr; - -/* - * Argument to ENCRYPT or DECRYPT - */ -struct cryptkeyarg { - netnamestr remotename; - des_block deskey; -}; - -/* - * Argument to ENCRYPT_PK or DECRYPT_PK - */ -struct cryptkeyarg2 { - netnamestr remotename; - netobj remotekey; /* Contains a length up to 1024 bytes */ - des_block deskey; -}; - - -/* - * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK - */ -union cryptkeyres switch (keystatus status) { -case KEY_SUCCESS: - des_block deskey; -default: - void; -}; - -const MAXGIDS = 16; /* max number of gids in gid list */ - -/* - * Unix credential - */ -struct unixcred { - u_int uid; - u_int gid; - u_int gids; -}; - -/* - * Result returned from GETCRED - */ -union getcredres switch (keystatus status) { -case KEY_SUCCESS: - unixcred cred; -default: - void; -}; -/* - * key_netstarg; - */ - -struct key_netstarg { - keybuf st_priv_key; - keybuf st_pub_key; - netnamestr st_netname; -}; - -union key_netstres switch (keystatus status){ -case KEY_SUCCESS: - key_netstarg knet; -default: - void; -}; - -#ifdef RPC_HDR -% -%#ifndef opaque -%#define opaque char -%#endif -% -#endif -program KEY_PROG { - version KEY_VERS { - - /* - * This is my secret key. - * Store it for me. - */ - keystatus - KEY_SET(keybuf) = 1; - - /* - * I want to talk to X. - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT(cryptkeyarg) = 2; - - /* - * X just sent me a message. - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT(cryptkeyarg) = 3; - - /* - * Generate a secure conversation key for me - */ - des_block - KEY_GEN(void) = 4; - - /* - * Get me the uid, gid and group-access-list associated - * with this netname (for kernel which cannot use NIS) - */ - getcredres - KEY_GETCRED(netnamestr) = 5; - } = 1; - version KEY_VERS2 { - - /* - * ####### - * Procedures 1-5 are identical to version 1 - * ####### - */ - - /* - * This is my secret key. - * Store it for me. - */ - keystatus - KEY_SET(keybuf) = 1; - - /* - * I want to talk to X. - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT(cryptkeyarg) = 2; - - /* - * X just sent me a message. - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT(cryptkeyarg) = 3; - - /* - * Generate a secure conversation key for me - */ - des_block - KEY_GEN(void) = 4; - - /* - * Get me the uid, gid and group-access-list associated - * with this netname (for kernel which cannot use NIS) - */ - getcredres - KEY_GETCRED(netnamestr) = 5; - - /* - * I want to talk to X. and I know X's public key - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT_PK(cryptkeyarg2) = 6; - - /* - * X just sent me a message. and I know X's public key - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT_PK(cryptkeyarg2) = 7; - - /* - * Store my public key, netname and private key. - */ - keystatus - KEY_NET_PUT(key_netstarg) = 8; - - /* - * Retrieve my public key, netname and private key. - */ - key_netstres - KEY_NET_GET(void) = 9; - - /* - * Return me the conversation key that is constructed - * from my secret key and this publickey. - */ - - cryptkeyres - KEY_GET_CONV(keybuf) = 10; - - - } = 2; -} = 100029; diff --git a/libtirpc-1.3.1/tirpc/un-namespace.h b/libtirpc-1.3.1/tirpc/un-namespace.h deleted file mode 100644 index 067e22d..0000000 --- a/libtirpc-1.3.1/tirpc/un-namespace.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2001 Daniel Eischen . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/include/un-namespace.h,v 1.13 2003/05/01 19:03:13 nectar Exp $ - */ - -#ifndef _UN_NAMESPACE_H_ -#define _UN_NAMESPACE_H_ - -#undef accept -#undef __acl_aclcheck_fd -#undef __acl_delete_fd -#undef __acl_get_fd -#undef __acl_set_fd -#undef bind -#undef __cap_get_fd -#undef __cap_set_fd -#undef close -#undef connect -#undef dup -#undef dup2 -#undef execve -#undef fcntl -#undef flock -#undef flockfile -#undef fpathconf -#undef fstat -#undef fstatfs -#undef fsync -#undef funlockfile -#undef getdirentries -#undef getlogin -#undef getpeername -#undef getprogname -#undef getsockname -#undef getsockopt -#undef ioctl -#undef kevent -#undef listen -#undef nanosleep -#undef open -#undef poll -#undef pthread_cond_broadcast -#undef pthread_cond_destroy -#undef pthread_cond_init -#undef pthread_cond_signal -#undef pthread_cond_timedwait -#undef pthread_cond_wait -#undef pthread_exit -#undef pthread_getspecific -#undef pthread_key_create -#undef pthread_key_delete -#undef pthread_main_np -#undef pthread_mutex_destroy -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_trylock -#undef pthread_mutex_unlock -#undef pthread_mutexattr_init -#undef pthread_mutexattr_destroy -#undef pthread_mutexattr_settype -#undef pthread_once -#undef pthread_rwlock_destroy -#undef pthread_rwlock_init -#undef pthread_rwlock_rdlock -#undef pthread_rwlock_wrlock -#undef pthread_rwlock_tryrdlock -#undef pthread_rwlock_trywrlock -#undef pthread_rwlock_unlock -#undef pthread_self -#undef pthread_setspecific -#undef pthread_sigmask -#undef read -#undef readv -#undef recvfrom -#undef recvmsg -#undef select -#undef sendmsg -#undef sendto -#undef setsockopt -#undef sigaction -#undef sigprocmask -#undef sigsuspend -#undef socket -#undef socketpair -#undef wait4 -#undef waitpid -#undef write -#undef writev - -#if 0 -#undef creat -#undef fchflags -#undef fchmod -#undef ftrylockfile -#undef msync -#undef nfssvc -#undef pause -#undef pthread_rwlockattr_init -#undef pthread_rwlockattr_destroy -#undef sched_yield -#undef sendfile -#undef shutdown -#undef sigaltstack -#undef sigpending -#undef sigreturn -#undef sigsetmask -#undef sleep -#undef system -#undef tcdrain -#undef wait -#endif /* 0 */ - -#ifdef _SIGNAL_H_ -int _sigaction(int, const struct sigaction *, struct sigaction *); -#endif - -#ifdef _SYS_EVENT_H_ -int _kevent(int, const struct kevent *, int, struct kevent *, - int, const struct timespec *); -#endif - -#ifdef _SYS_FCNTL_H_ -int _flock(int, int); -#endif - -#undef err -#undef warn -#undef nsdispatch - -#endif /* _UN_NAMESPACE_H_ */ diff --git a/nfs-utils-2.5.2/.gitignore b/nfs-utils-2.5.2/.gitignore deleted file mode 100644 index e97b31f..0000000 --- a/nfs-utils-2.5.2/.gitignore +++ /dev/null @@ -1,85 +0,0 @@ -# files generated by autoconf, automake, autoheader and libtoolize -aclocal.m4 -autom4te.cache -compile -config.guess -config.sub -configure -depcomp -install-sh -libtool -ltmain.sh -Makefile.in -missing -support/include/config.h.in -aclocal/libtool.m4 -aclocal/ltoptions.m4 -aclocal/ltsugar.m4 -aclocal/ltversion.m4 -aclocal/lt~obsolete.m4 -# files generated by configure -confdefs.h -config.cache -config.log -config.status -conftest -conftest.c -conftest.cpp -conftest.er1 -conftest.err -.deps -Makefile -support/include/config.h -support/include/stamp-h1 -# file generated during compilation -*.o -*.lo -*.la -*.pc -.libs -lib*.a -test-driver -tools/rpcgen/rpcgen -tools/rpcdebug/rpcdebug -utils/blkmapd/blkmapd -utils/exportfs/exportfs -utils/idmapd/idmapd -utils/lockd/lockd -utils/mount/mount.nfs -utils/mountd/mountd -utils/nfsd/nfsd -utils/nfsstat/nfsstat -utils/nhfsstone/nhfsstone -utils/rquotad/rquotad -utils/rquotad/rquota.h -utils/rquotad/rquota_xdr.c -utils/showmount/showmount -utils/nfsdcld/nfsdcld -utils/nfsdcltrack/nfsdcltrack -utils/statd/statd -tools/locktest/testlk -tools/getiversion/getiversion -tools/nfsconf/nfsconf -support/export/mount.h -support/export/mount_clnt.c -support/export/mount_xdr.c -support/include/mount.h -support/nsm/sm_inter.h -support/nsm/sm_inter_clnt.c -support/nsm/sm_inter_svc.c -support/nsm/sm_inter_xdr.c -support/include/sm_inter.h -tests/nsm_client/nlm_sm_inter.h -tests/nsm_client/nlm_sm_inter_clnt.c -tests/nsm_client/nlm_sm_inter_svc.c -tests/nsm_client/nlm_sm_inter_xdr.c -utils/nfsidmap/nfsidmap -utils/nfsref/nfsref -systemd/nfs-server-generator -systemd/rpc-pipefs-generator -systemd/nfs-config.service -systemd/rpc-gssd.service -# cscope database files -cscope.* -# generic editor backup et al -*~ diff --git a/nfs-utils-2.5.2/COPYING b/nfs-utils-2.5.2/COPYING deleted file mode 100644 index 941c87d..0000000 --- a/nfs-utils-2.5.2/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/nfs-utils-2.5.2/INSTALL b/nfs-utils-2.5.2/INSTALL deleted file mode 100644 index b42a17a..0000000 --- a/nfs-utils-2.5.2/INSTALL +++ /dev/null @@ -1,182 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/nfs-utils-2.5.2/Makefile.am b/nfs-utils-2.5.2/Makefile.am deleted file mode 100644 index 0022084..0000000 --- a/nfs-utils-2.5.2/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = foreign - -SUBDIRS = support tools utils linux-nfs tests systemd - -MAINTAINERCLEANFILES = Makefile.in - -EXTRA_DIST = \ - autogen.sh \ - \ - aclocal/bsdsignals.m4 \ - aclocal/nfs-utils.m4 \ - aclocal/kerberos5.m4 \ - aclocal/tcp-wrappers.m4 \ - aclocal/libtirpc.m4 \ - aclocal/libevent.m4 \ - aclocal/libnfsidmap.m4 \ - aclocal/rpcsec_vers.m4 \ - aclocal/ipv6.m4 - -ACLOCAL_AMFLAGS = -I aclocal - -install-data-hook: - if [ ! -d $(DESTDIR)$(statedir) ]; then mkdir -p $(DESTDIR)$(statedir); fi - touch $(DESTDIR)$(statedir)/etab; chmod 644 $(DESTDIR)$(statedir)/etab - touch $(DESTDIR)$(statedir)/rmtab; chmod 644 $(DESTDIR)$(statedir)/rmtab - mkdir -p $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak - touch $(DESTDIR)$(statdpath)/state - chmod go-rwx $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state - -chown $(statduser) $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state - -uninstall-hook: - rm -f $(DESTDIR)$(statedir)/xtab - rm $(DESTDIR)$(statedir)/etab - rm $(DESTDIR)$(statedir)/rmtab - rm $(DESTDIR)$(statdpath)/state diff --git a/nfs-utils-2.5.2/NEWS b/nfs-utils-2.5.2/NEWS deleted file mode 100644 index e70ae8a..0000000 --- a/nfs-utils-2.5.2/NEWS +++ /dev/null @@ -1,63 +0,0 @@ -Significant changes for nfs-utils 1.1.0 - March/April 2007 - - - rpc.lockd is gone. One 3 old kernel releases need it. - - rpc.rquotad is gone. Use the one from the 'quota' package. - Everone else does. - - /sbin/{u,}mount.nfs{,4} are now installed so 'mount' will - use these to mount nfs filesystems instead of internal code. - + mount.nfs will check for 'statd' to be running when mounting - a filesystem which requires it. If it is not running it will - run "/usr/sbin/start-statd" to try to start it. - If statd is not running and cannot be started, mount.nfs will - refuse to mount the filesystem and will suggest the 'nolock' - option. - - Substantial changes to statd - + The 'notify' process that must happen at boot has been split - into a separate program "sm-notify". It ensures that it - only runs once even if you restart statd. This is correct - behaviour. - + statd stores state in the files in /var/lib/nfs/sm/ so that - if you kill and restart it, it will restore that state and - continue working correctly. - + statd makes more use of DNS lookup and should handle - multi-homed peers better. In particular, files in - /var/lib/nfs/sm/ are named with the Full Qualified Domain Name - if available. - - If you export a directory as 'crossmnt', all filesystems - mounted beneath are automatically exported with the same - options (unless explicitly exported with different options). - - subtree_check is no-longer the default. The default is now - no_subtree_check. - - By default the system 'rpcgen' is used while building - nfs-utils rather than the internal one. - - Exportfs will warn if you try to export a filesystem that does - not support NFS export. - - Comprehensive notes on startup dependencies have been added - to the README file. - - Mount and statd now listen on a non-privileged port by default. - For maximum safety an upgrade to portmap-6.0 is recommended. - http://neil.brown.name/portmap/ - git://neil.brown.name/portmap - - - This release should work with MIT Kerberos and Heimdal 0.8.1 and later. - - - A new option, -n, was added to rpc.gssd which specifies that - accesses by root should not use 'machine credentials' when - accessing NFS file systems mounted with Kerberos. Using this - option allows the root user to access the NFS space using any - Kerberos principal, rather than always using the machine - credentials. However, its use also requires that root manually - authenticate before attempting a mount with Kerberos. - - When rpc.gssd uses machine credentials, the selection algorithm has - been changed. Instead of simply using the first "nfs/*" key in the - keytab, the keytab is now searched for keys in the following - defined order: - - root/@REALM - nfs/@REALM - host/@REALM - root/@REALM - nfs/@REALM - host/@REALM - diff --git a/nfs-utils-2.5.2/README b/nfs-utils-2.5.2/README deleted file mode 100644 index 7034c00..0000000 --- a/nfs-utils-2.5.2/README +++ /dev/null @@ -1,167 +0,0 @@ -This is nfs-utils, the Linux NFS userland utility package. - - -0. PROJECT RESOURCES - -Home page: http://sourceforge.net/projects/nfs/ - -To use the 'gss' support you must have kerberos-5 development -libraries installed. -Otherwise use "--disable-gss" - -To use nfsv4 support you need libevent and libnfsidmap development -libraries. They are available from - http://www.monkey.org/~provos/libevent/ - http://www.citi.umich.edu/projects/nfsv4/linux/libnfsidmap/ -Otherwise use --disable-nfsv4 - -To use the nfsdcld tracking daemon, nfsv4 support must be enabled, -and the libsqlite3 development libraries must be installed. - -1. COMPILING - -Unpack the sources and run these commands: - - # ./configure - # make - -To install binaries and documenation, run this command: - - # make install - - -2. COMPILING FROM GIT - -Getting nfs-utils for the first time: - - git clone git://linux-nfs.org/nfs-utils - -Updating to the latest head after you've already got it. - - git pull - -Building requires that autotools be installed. To invoke them -simply - - sh autogen.sh - -Finally, build as usual as above. - -3. DAEMON STARTUP ORDER - -This nfs-utils packages does not provide any scripts for starting -various daemons as most distributions replace them with their own, so -any scripts we package would not get much testing. -Instead, we explain the dependencies involved in startup so that -scripts can be written to work correctly. - -3.0 PREREQUISITES - - Name service (host name lookup) should be working before any - NFS services are started. - - "portmap" must be running before any NFS services (server or - client) are started. - - Normally network interfaces should be configured first as well, - though this isn't critical for the NFS server (providing name - service is handled locally). - -3.1. SERVER STARTUP - - - A/ mount -t nfsd /proc/fs/nfsd - This filesystem needs to be mount before most daemons, - particularly exportfs, mountd, svcgssd, idmapd. - It could be mounted once, or the script that starts each daemon - could test if it is mounted and mount it if not. - - B/ svcgssd ; idmapd - These supply services to nfsd and so should be started before - rpc.nfsd. Where they come between mounting the nfsd filesystem - and starting the nfsd server is not important. - idmapd is only needed for NFSv4 support. - svcgssd is only needed if exportfs NFS filesystem with crypto- - security (Kerberos). - - C/ exportfs -av ; rpc.mountd - It is important that exportfs be run before mountd so that - mountd is working from current information (in - /var/lib/nfs/etab). - It is also important that both of these are run before - rpc.nfsd. - If not, any NFS requests that arrive before mountd is started - will get replied to with a 'Stale NFS File handle' error. - - D/ rpc.statd --no-notify - It is best if statd is started before nfsd though this isn't - critical. Certainly it should be at most a few seconds after - nfsd. - When nfsd starts it will start lockd. If lockd then receives a - lock request it will communicate with statd. If statd is not - running lockd will retry, but it won't wait forever for a - reply. - Note that if statd is started before nfsd, the --no-notify - option must be used. If notify requests are sent out before - nfsd start, clients may try to reclaim locks and, on finding - that lockd isn't running, they will give up and never reclaim - the lock. - rpc.statd is only needed for NFSv2 and NFSv3 support. - - E/ rpc.nfsd - Starting nfsd will automatically start lockd. The nfs server - will now be fully active and respond to any requests from - clients. - - F/ sm-notify - This will notify any client which might have locks from before - a reboot to try to reclaim their locks. This should start - immediately after rpc.nfsd is started so that clients have a - chance to reclaim locks within the 90 second grace period. - sm-notify is only needed for NFSv2 and NFSv3 support. - - -3.2. CLIENT STARTUP - - A/ sm-notify - This should be run shortly after boot and before any NFS - filesystems are mounted with remote-locking support - - filesystems can be mounted with "-o nolock" before sm-notify. - This is appropriate for '/', '/usr', and '/var'. - - B/ gssd ; idmapd - idmapd should be started before mounting any NFSv4 filesystems. - gssd should be started before mounting any NFS filesystems - securely (with Kerberos). - - C/ statd should be run before any NFSv2 or NFSv3 filesystem is - mounted with remote locking (i.e. without -o nolock). - 'mount' will try to use "/usr/sbin/start-statd" to start statd - if it is not already running, so there is no need to explicitly - start statd in boot-time scripts. - -3.3. SERVER/CLIENT INTERACTIONS - - A/ sm-notify - Both the server and the client need sm-notify to be run. - It should be run after the NFS server is started, but before - and NFS filesystems are mounted with remote locking. - - B/ rpc.statd - Both the server and the client need rpc.statd to be running. - Each should try to start when they need it. - - C/ idmapd - - Both the server and client need idmapd to be running. If idmapd - is started (for the client) before starting nfsd the 'nfsd' - filesystem is mounted, then idmapd should be sent a HUP signal - afterwards to signal that the server channels should be opened. - - - - -Share And Enjoy! - - -- the nfs-utils developers - diff --git a/nfs-utils-2.5.2/aclocal/ax_gcc_func_attribute.m4 b/nfs-utils-2.5.2/aclocal/ax_gcc_func_attribute.m4 deleted file mode 100644 index 098c9aa..0000000 --- a/nfs-utils-2.5.2/aclocal/ax_gcc_func_attribute.m4 +++ /dev/null @@ -1,238 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) -# -# DESCRIPTION -# -# This macro checks if the compiler supports one of GCC's function -# attributes; many other compilers also provide function attributes with -# the same syntax. Compiler warnings are used to detect supported -# attributes as unsupported ones are ignored by default so quieting -# warnings when using this macro will yield false positives. -# -# The ATTRIBUTE parameter holds the name of the attribute to be checked. -# -# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_. -# -# The macro caches its result in the ax_cv_have_func_attribute_ -# variable. -# -# The macro currently supports the following function attributes: -# -# alias -# aligned -# alloc_size -# always_inline -# artificial -# cold -# const -# constructor -# constructor_priority for constructor attribute with priority -# deprecated -# destructor -# dllexport -# dllimport -# error -# externally_visible -# fallthrough -# flatten -# format -# format_arg -# gnu_inline -# hot -# ifunc -# leaf -# malloc -# noclone -# noinline -# nonnull -# noreturn -# nothrow -# optimize -# pure -# sentinel -# sentinel_position -# unused -# used -# visibility -# warning -# warn_unused_result -# weak -# weakref -# -# Unsupported function attributes will be tested with a prototype -# returning an int and not accepting any arguments and the result of the -# check might be wrong or meaningless so use with care. -# -# LICENSE -# -# Copyright (c) 2013 Gabriele Svelto -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 9 - -AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ - AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) - - AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([ - m4_case([$1], - [alias], [ - int foo( void ) { return 0; } - int bar( void ) __attribute__(($1("foo"))); - ], - [aligned], [ - int foo( void ) __attribute__(($1(32))); - ], - [alloc_size], [ - void *foo(int a) __attribute__(($1(1))); - ], - [always_inline], [ - inline __attribute__(($1)) int foo( void ) { return 0; } - ], - [artificial], [ - inline __attribute__(($1)) int foo( void ) { return 0; } - ], - [cold], [ - int foo( void ) __attribute__(($1)); - ], - [const], [ - int foo( void ) __attribute__(($1)); - ], - [constructor_priority], [ - int foo( void ) __attribute__((__constructor__(65535/2))); - ], - [constructor], [ - int foo( void ) __attribute__(($1)); - ], - [deprecated], [ - int foo( void ) __attribute__(($1(""))); - ], - [destructor], [ - int foo( void ) __attribute__(($1)); - ], - [dllexport], [ - __attribute__(($1)) int foo( void ) { return 0; } - ], - [dllimport], [ - int foo( void ) __attribute__(($1)); - ], - [error], [ - int foo( void ) __attribute__(($1(""))); - ], - [externally_visible], [ - int foo( void ) __attribute__(($1)); - ], - [fallthrough], [ - int foo( void ) {switch (0) { case 1: __attribute__(($1)); case 2: break ; }}; - ], - [flatten], [ - int foo( void ) __attribute__(($1)); - ], - [format], [ - int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); - ], - [format_arg], [ - char *foo(const char *p) __attribute__(($1(1))); - ], - [gnu_inline], [ - inline __attribute__(($1)) int foo( void ) { return 0; } - ], - [hot], [ - int foo( void ) __attribute__(($1)); - ], - [ifunc], [ - int my_foo( void ) { return 0; } - static int (*resolve_foo(void))(void) { return my_foo; } - int foo( void ) __attribute__(($1("resolve_foo"))); - ], - [leaf], [ - __attribute__(($1)) int foo( void ) { return 0; } - ], - [malloc], [ - void *foo( void ) __attribute__(($1)); - ], - [noclone], [ - int foo( void ) __attribute__(($1)); - ], - [noinline], [ - __attribute__(($1)) int foo( void ) { return 0; } - ], - [nonnull], [ - int foo(char *p) __attribute__(($1(1))); - ], - [noreturn], [ - void foo( void ) __attribute__(($1)); - ], - [nothrow], [ - int foo( void ) __attribute__(($1)); - ], - [optimize], [ - __attribute__(($1(3))) int foo( void ) { return 0; } - ], - [pure], [ - int foo( void ) __attribute__(($1)); - ], - [sentinel], [ - int foo(void *p, ...) __attribute__(($1)); - ], - [sentinel_position], [ - int foo(void *p, ...) __attribute__(($1(1))); - ], - [returns_nonnull], [ - void *foo( void ) __attribute__(($1)); - ], - [unused], [ - int foo( void ) __attribute__(($1)); - ], - [used], [ - int foo( void ) __attribute__(($1)); - ], - [visibility], [ - int foo_def( void ) __attribute__(($1("default"))); - int foo_hid( void ) __attribute__(($1("hidden"))); - int foo_int( void ) __attribute__(($1("internal"))); - int foo_pro( void ) __attribute__(($1("protected"))); - ], - [warning], [ - int foo( void ) __attribute__(($1(""))); - ], - [warn_unused_result], [ - int foo( void ) __attribute__(($1)); - ], - [weak], [ - int foo( void ) __attribute__(($1)); - ], - [weakref], [ - static int foo( void ) { return 0; } - static int bar( void ) __attribute__(($1("foo"))); - ], - [ - m4_warn([syntax], [Unsupported attribute $1, the test may fail]) - int foo( void ) __attribute__(($1)); - ] - )], []) - ], - dnl GCC doesn't exit with an error if an unknown attribute is - dnl provided but only outputs a warning, so accept the attribute - dnl only if no warning were issued. - [AS_IF([test -s conftest.err], - [AS_VAR_SET([ac_var], [no])], - [AS_VAR_SET([ac_var], [yes])])], - [AS_VAR_SET([ac_var], [no])]) - ]) - - AS_IF([test yes = AS_VAR_GET([ac_var])], - [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, - [Define to 1 if the system has the `$1' function attribute])], []) - - AS_VAR_POPDEF([ac_var]) -]) diff --git a/nfs-utils-2.5.2/aclocal/bsdsignals.m4 b/nfs-utils-2.5.2/aclocal/bsdsignals.m4 deleted file mode 100644 index 24572aa..0000000 --- a/nfs-utils-2.5.2/aclocal/bsdsignals.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl *********** BSD vs. POSIX signal handling ************** -AC_DEFUN([AC_BSD_SIGNALS], [ - AC_MSG_CHECKING(for BSD signal semantics) - AC_CACHE_VAL(knfsd_cv_bsd_signals, - [AC_TRY_RUN([ - #include - #include - #include - - static int counter = 0; - static RETSIGTYPE handler(int num) { counter++; } - - int main() - { - int s; - if ((s = fork()) < 0) return 1; - if (s != 0) { - if (wait(&s) < 0) return 1; - return WIFSIGNALED(s)? 1 : 0; - } - - signal(SIGHUP, handler); - kill(getpid(), SIGHUP); kill(getpid(), SIGHUP); - return (counter == 2)? 0 : 1; - } - ], knfsd_cv_bsd_signals=yes, knfsd_cv_bsd_signals=no, - [ - case "$host_os" in - *linux*) knfsd_cv_bsd_signals=no;; - *bsd*) knfsd_cv_bsd_signals=yes;; - *) AC_MSG_ERROR([unable to guess signal semantics for $host_os; please set knfsd_cv_bsd_signals]);; - esac - ])]) dnl - AC_MSG_RESULT($knfsd_cv_bsd_signals) - test $knfsd_cv_bsd_signals = yes && AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define this if you want to use BSD signal semantics]) -])dnl diff --git a/nfs-utils-2.5.2/aclocal/ipv6.m4 b/nfs-utils-2.5.2/aclocal/ipv6.m4 deleted file mode 100644 index 75a8582..0000000 --- a/nfs-utils-2.5.2/aclocal/ipv6.m4 +++ /dev/null @@ -1,20 +0,0 @@ -dnl Checks for IPv6 support -dnl -AC_DEFUN([AC_IPV6], [ - - if test "$enable_ipv6" = yes; then - - dnl TI-RPC required for IPv6 - if test "$enable_tirpc" = no; then - AC_MSG_ERROR(['--enable-ipv6' requires TIRPC support.]) - fi - - dnl IPv6-enabled networking functions required for IPv6 - AC_CHECK_FUNCS([getifaddrs getnameinfo], , - [AC_MSG_ERROR([Missing library functions needed for IPv6.])]) - - AC_CHECK_LIB([tirpc], [bindresvport_sa], [:], - [AC_MSG_ERROR([Missing library functions needed for IPv6.])]) - fi - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/kerberos5.m4 b/nfs-utils-2.5.2/aclocal/kerberos5.m4 deleted file mode 100644 index bf0e88b..0000000 --- a/nfs-utils-2.5.2/aclocal/kerberos5.m4 +++ /dev/null @@ -1,114 +0,0 @@ -dnl Checks for Kerberos -dnl NOTE: while we intend to do generic gss-api, currently we -dnl have a requirement to get an initial Kerberos machine -dnl credential. Thus, the requirement for Kerberos. -dnl The Kerberos gssapi library will be dynamically loaded? -AC_DEFUN([AC_KERBEROS_V5],[ - AC_MSG_CHECKING(for Kerberos v5) - AC_ARG_WITH(krb5, - [AC_HELP_STRING([--with-krb5=DIR], [use Kerberos v5 installation in DIR])], - [ case "$withval" in - yes|no) - krb5_with="" - ;; - *) - krb5_with="$withval" - ;; - esac ] - ) - - for dir in $krb5_with /usr /usr/kerberos /usr/local /usr/local/krb5 \ - /usr/krb5 /usr/heimdal /usr/local/heimdal /usr/athena ; do - dnl This ugly hack brought on by the split installation of - dnl MIT Kerberos on Fedora Core 1 - K5CONFIG="" - if test -f $dir/bin/krb5-config; then - K5CONFIG=$dir/bin/krb5-config - elif test -f "/usr/kerberos/bin/krb5-config"; then - K5CONFIG="/usr/kerberos/bin/krb5-config" - elif test -f "/usr/lib/mit/bin/krb5-config"; then - K5CONFIG="/usr/lib/mit/bin/krb5-config" - fi - if test "$K5CONFIG" != ""; then - KRBCFLAGS=`$K5CONFIG --cflags` - KRBLIBS=`$K5CONFIG --libs` - GSSKRB_CFLAGS=`$K5CONFIG --cflags gssapi` - GSSKRB_LIBS=`$K5CONFIG --libs gssapi` - K5VERS=`$K5CONFIG --version | head -n 1 | awk '{split($(4),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }'` - AC_DEFINE_UNQUOTED(KRB5_VERSION, $K5VERS, [Define this as the Kerberos version number]) - if test -f $dir/include/gssapi/gssapi_krb5.h -a \ - \( -f $dir/lib/libgssapi_krb5.a -o \ - -f $dir/lib/libgssapi_krb5.so -o \ - -f $dir/lib32/libgssapi_krb5.a -o \ - -f $dir/lib32/libgssapi_krb5.so -o \ - -f $dir/lib64/libgssapi_krb5.a -o \ - -f $dir/lib64/libgssapi_krb5.so -o \ - -f $dir/lib/$(uname -m)-linux-gnu/libgssapi_krb5.a -o \ - -f $dir/lib/$(uname -m)-linux-gnu/libgssapi_krb5.so \) ; then - AC_DEFINE(HAVE_KRB5, 1, [Define this if you have MIT Kerberos libraries]) - KRBDIR="$dir" - gssapi_lib=gssapi_krb5 - break - dnl The following ugly hack brought on by the split installation - dnl of Heimdal Kerberos on SuSe - elif test \( -f $dir/include/heim_err.h -o\ - -f $dir/include/heimdal/heim_err.h \) -a \ - -f $dir/lib/libroken.a; then - AC_DEFINE(HAVE_HEIMDAL, 1, [Define this if you have Heimdal Kerberos libraries]) - KRBDIR="$dir" - gssapi_lib=gssapi - break - fi - fi - done - dnl We didn't find a usable Kerberos environment - if test "x$KRBDIR" = "x"; then - if test "x$krb5_with" = "x"; then - AC_MSG_ERROR(Kerberos v5 with GSS support not found: consider --disable-gss or --with-krb5=) - else - AC_MSG_ERROR(Kerberos v5 with GSS support not found at $krb5_with) - fi - fi - AC_MSG_RESULT($KRBDIR) - - dnl Check if -rpath=$(KRBDIR)/lib is needed - echo "The current KRBDIR is $KRBDIR" - if test "$KRBDIR/lib" = "/lib" -o "$KRBDIR/lib" = "/usr/lib" \ - -o "$KRBDIR/lib" = "//lib" -o "$KRBDIR/lib" = "/usr//lib" ; then - KRBLDFLAGS=""; - elif /sbin/ldconfig -p | grep > /dev/null "=> $KRBDIR/lib/"; then - KRBLDFLAGS=""; - else - KRBLDFLAGS="-Wl,-rpath=$KRBDIR/lib" - fi - - dnl Now check for functions within gssapi library - AC_CHECK_LIB($gssapi_lib, gss_krb5_export_lucid_sec_context, - AC_DEFINE(HAVE_LUCID_CONTEXT_SUPPORT, 1, [Define this if the Kerberos GSS library supports gss_krb5_export_lucid_sec_context]), ,$KRBLIBS) - AC_CHECK_LIB($gssapi_lib, gss_krb5_set_allowable_enctypes, - AC_DEFINE(HAVE_SET_ALLOWABLE_ENCTYPES, 1, [Define this if the Kerberos GSS library supports gss_krb5_set_allowable_enctypes]), ,$KRBLIBS) - AC_CHECK_LIB($gssapi_lib, gss_krb5_free_lucid_sec_context, - AC_DEFINE(HAVE_GSS_KRB5_FREE_LUCID_SEC_CONTEXT, 1, [Define this if the Kerberos GSS library supports gss_krb5_free_lucid_sec_context]), ,$KRBLIBS) - - dnl Check for newer error message facility - AC_CHECK_LIB($gssapi_lib, krb5_get_error_message, - AC_DEFINE(HAVE_KRB5_GET_ERROR_MESSAGE, 1, [Define this if the function krb5_get_error_message is available]), ,$KRBLIBS) - - dnl Check for function to specify addressless tickets - AC_CHECK_LIB($gssapi_lib, krb5_get_init_creds_opt_set_addressless, - AC_DEFINE(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS, 1, [Define this if the function krb5_get_init_creds_opt_set_addressless is available]), ,$KRBLIBS) - - dnl If they specified a directory and it didn't work, give them a warning - if test "x$krb5_with" != "x" -a "$krb5_with" != "$KRBDIR"; then - AC_MSG_WARN(Using $KRBDIR instead of requested value of $krb5_with for Kerberos!) - fi - - AC_SUBST([KRBDIR]) - AC_SUBST([KRBLIBS]) - AC_SUBST([KRBCFLAGS]) - AC_SUBST([KRBLDFLAGS]) - AC_SUBST([K5VERS]) - AC_SUBST([GSSKRB_CFLAGS]) - AC_SUBST([GSSKRB_LIBS]) - -]) diff --git a/nfs-utils-2.5.2/aclocal/keyutils.m4 b/nfs-utils-2.5.2/aclocal/keyutils.m4 deleted file mode 100644 index 16b225d..0000000 --- a/nfs-utils-2.5.2/aclocal/keyutils.m4 +++ /dev/null @@ -1,15 +0,0 @@ -dnl Checks for keyutils library and headers -dnl -AC_DEFUN([AC_KEYUTILS], [ - - dnl Check for libkeyutils; do not add to LIBS if found - AC_CHECK_LIB([keyutils], [keyctl_instantiate], [LIBKEYUTILS=-lkeyutils], ,) - AC_SUBST(LIBKEYUTILS) - - AC_CHECK_HEADERS([keyutils.h]) - - AC_CHECK_LIB([keyutils], [find_key_by_type_and_desc], - [AC_DEFINE([HAVE_FIND_KEY_BY_TYPE_AND_DESC], [1], - [Define to 1 if you have the `find_key_by_type_and_desc' function.])],) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libblkid.m4 b/nfs-utils-2.5.2/aclocal/libblkid.m4 deleted file mode 100644 index 10824e9..0000000 --- a/nfs-utils-2.5.2/aclocal/libblkid.m4 +++ /dev/null @@ -1,19 +0,0 @@ -dnl *************************** libblkid needs version 1.40 or later *********************** -AC_DEFUN([AC_BLKID_VERS], [ - AC_MSG_CHECKING(for suitable libblkid version) - AC_CACHE_VAL([libblkid_cv_is_recent], - [ - saved_LIBS="$LIBS" - LIBS=-lblkid - AC_TRY_RUN([ - #include - int main() - { - int vers = blkid_get_library_version(0, 0); - return vers >= 140 ? 0 : 1; - } - ], [libblkid_cv_is_recent=yes], [libblkid_cv_is_recent=no], - [libblkid_cv_is_recent=unknown]) - LIBS="$saved_LIBS"]) - AC_MSG_RESULT($libblkid_cv_is_recent) -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libcap.m4 b/nfs-utils-2.5.2/aclocal/libcap.m4 deleted file mode 100644 index f8a0ed1..0000000 --- a/nfs-utils-2.5.2/aclocal/libcap.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl Checks for libcap.so -dnl -AC_DEFUN([AC_LIBCAP], [ - - dnl look for prctl - AC_CHECK_FUNC([prctl], , AC_MSG_ERROR([prctl syscall is not available])) - - AC_ARG_ENABLE([caps], - [AS_HELP_STRING([--disable-caps], [Disable capabilities support])]) - - LIBCAP= - - if test "x$enable_caps" != "xno" ; then - dnl look for the library; do not add to LIBS if found - AC_CHECK_LIB([cap], [cap_get_proc], [LIBCAP=-lcap], ,) - - AC_CHECK_HEADERS([sys/capability.h], , - [test "x$enable_caps" = "xyes" && AC_MSG_ERROR([libcap headers not found.])]) - fi - - AC_SUBST(LIBCAP) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libevent.m4 b/nfs-utils-2.5.2/aclocal/libevent.m4 deleted file mode 100644 index e0b820b..0000000 --- a/nfs-utils-2.5.2/aclocal/libevent.m4 +++ /dev/null @@ -1,12 +0,0 @@ -dnl Checks for libevent -AC_DEFUN([AC_LIBEVENT], [ - - dnl Check for libevent, but do not add -levent_core to LIBS - AC_CHECK_LIB([event_core], [event_base_dispatch], [LIBEVENT=-levent_core], - [AC_MSG_ERROR([libevent not found.])]) - AC_SUBST(LIBEVENT) - - AC_CHECK_HEADERS([event2/event.h], , - [AC_MSG_ERROR([libevent headers not found.])]) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libnfsidmap.m4 b/nfs-utils-2.5.2/aclocal/libnfsidmap.m4 deleted file mode 100644 index ae697e8..0000000 --- a/nfs-utils-2.5.2/aclocal/libnfsidmap.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl Checks for libnfsidmap -dnl -AC_DEFUN([AC_LIBNFSIDMAP], [ - - dnl Check for libnfsidmap, but do not add -lnfsidmap to LIBS - AC_CHECK_LIB([nfsidmap], [nfs4_init_name_mapping], [LIBNFSIDMAP=-lnfsidmap], - [AC_MSG_ERROR([libnfsidmap not found.])]) - - AC_CHECK_HEADERS([nfsidmap.h], , - [AC_MSG_ERROR([libnfsidmap headers not found.])]) - - dnl nfs4_set_debug() doesn't appear in all versions of libnfsidmap - AC_CHECK_LIB([nfsidmap], [nfs4_set_debug], - [AC_DEFINE([HAVE_NFS4_SET_DEBUG], 1, - [Define to 1 if you have the `nfs4_set_debug' function.])]) - - dnl nfs4_owner_to_uid() doesn't appear in all versions of libnfsidmap - dnl We just need this test to set $ac_cv_lib_nfsidmap_nfs4_owner_to_uid - AC_CHECK_LIB([nfsidmap], [nfs4_owner_to_uid], [:]) - - AC_SUBST(LIBNFSIDMAP) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libpthread.m4 b/nfs-utils-2.5.2/aclocal/libpthread.m4 deleted file mode 100644 index 55e046e..0000000 --- a/nfs-utils-2.5.2/aclocal/libpthread.m4 +++ /dev/null @@ -1,14 +0,0 @@ -dnl Checks for pthreads library and headers -dnl -AC_DEFUN([AC_LIBPTHREAD], [ - - dnl Check for library, but do not add -lpthreads to LIBS - AC_CHECK_LIB([pthread], [pthread_create], - [AC_DEFINE([HAVE_LIBPTHREAD], [1], - [Define to 1 if you have libpthread.]) - AC_CHECK_HEADERS([pthread.h], [], - [AC_MSG_ERROR([libpthread headers not found.])]) - AC_SUBST([LIBPTHREAD],[-lpthread])], - [$1]) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libsqlite3.m4 b/nfs-utils-2.5.2/aclocal/libsqlite3.m4 deleted file mode 100644 index 8c38993..0000000 --- a/nfs-utils-2.5.2/aclocal/libsqlite3.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl Checks for matching sqlite3 header and library, and -dnl sufficient sqlite3 version. -dnl -AC_DEFUN([AC_SQLITE3_VERS], [ - AC_CHECK_HEADERS([sqlite3.h], ,) - - dnl look for the library; do not add to LIBS if found - AC_CHECK_LIB([sqlite3], [sqlite3_libversion_number], [LIBSQLITE=-lsqlite3], ,) - AC_SUBST(LIBSQLITE) - - AC_MSG_CHECKING(for suitable sqlite3 version) - - AC_CACHE_VAL([libsqlite3_cv_is_recent], - [ - saved_LIBS="$LIBS" - LIBS=-lsqlite3 - AC_TRY_RUN([ - #include - #include - int main() - { - int vers = sqlite3_libversion_number(); - - return vers != SQLITE_VERSION_NUMBER || - vers < 3003000; - } - ], [libsqlite3_cv_is_recent=yes], [libsqlite3_cv_is_recent=no], - [libsqlite3_cv_is_recent=unknown]) - LIBS="$saved_LIBS"]) - - AC_MSG_RESULT($libsqlite3_cv_is_recent) -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libtirpc.m4 b/nfs-utils-2.5.2/aclocal/libtirpc.m4 deleted file mode 100644 index 27368ff..0000000 --- a/nfs-utils-2.5.2/aclocal/libtirpc.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl Checks for TI-RPC library and headers -dnl -AC_DEFUN([AC_LIBTIRPC], [ - - PKG_PROG_PKG_CONFIG([0.9.0]) - AS_IF( - [test "$enable_tirpc" != "no"], - [PKG_CHECK_MODULES([TIRPC], [libtirpc], - [LIBTIRPC="${TIRPC_LIBS}" - AM_CPPFLAGS="${AM_CPPFLAGS} ${TIRPC_CFLAGS}" - AC_DEFINE([HAVE_LIBTIRPC], [1], - [Define to 1 if you have and wish to use libtirpc.])], - [AC_LIBTIRPC_OLD - AS_IF([test "$enable_tirpc" = "yes" -a -z "${LIBTIRPC}"], - [AC_MSG_ERROR([libtirpc not found.])])])]) - - AS_IF([test -n "${LIBTIRPC}"], - [AC_CHECK_LIB([tirpc], [authgss_free_private_data], - [AC_DEFINE([HAVE_AUTHGSS_FREE_PRIVATE_DATA], [1], - [Define to 1 if your rpcsec library provides authgss_free_private_data])],, - [${LIBS}])]) - - AS_IF([test -n "${LIBTIRPC}"], - [AC_CHECK_LIB([tirpc], [libtirpc_set_debug], - [AC_DEFINE([HAVE_LIBTIRPC_SET_DEBUG], [1], - [Define to 1 if your tirpc library provides libtirpc_set_debug])],, - [${LIBS}])]) - - AC_SUBST([AM_CPPFLAGS]) - AC_SUBST(LIBTIRPC) - -])dnl - -dnl Old way of checking libtirpc without pkg-config -dnl This can go away when virtually all libtirpc provide a .pc file -dnl -AC_DEFUN([AC_LIBTIRPC_OLD], [ - - AC_ARG_WITH([tirpcinclude], - [AC_HELP_STRING([--with-tirpcinclude=DIR], - [use TI-RPC headers in DIR])], - [tirpc_header_dir=$withval], - [tirpc_header_dir=/usr/include/tirpc]) - - dnl Look for the library - AC_CHECK_LIB([tirpc], [clnt_tli_create], - [has_libtirpc="yes"], - [has_libtirpc="no"]) - - dnl Also must have the headers installed where we expect - dnl to look for headers; add -I compiler option if found - AS_IF([test "$has_libtirpc" = "yes"], - [AC_CHECK_HEADERS([${tirpc_header_dir}/netconfig.h], - [AC_SUBST([AM_CPPFLAGS], ["-I${tirpc_header_dir}"])], - [has_libtirpc="no"])]) - - dnl Now set $LIBTIRPC accordingly - AS_IF([test "$has_libtirpc" = "yes"], - [AC_DEFINE([HAVE_LIBTIRPC], [1], - [Define to 1 if you have and wish to use libtirpc.]) - LIBTIRPC="-ltirpc"]) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/libxml2.m4 b/nfs-utils-2.5.2/aclocal/libxml2.m4 deleted file mode 100644 index 8231553..0000000 --- a/nfs-utils-2.5.2/aclocal/libxml2.m4 +++ /dev/null @@ -1,17 +0,0 @@ -dnl Checks for libxml2.so -AC_DEFUN([AC_LIBXML2], [ - - PKG_PROG_PKG_CONFIG([0.9.0]) - AS_IF( - [test "$enable_junction" = "yes"], - [PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.4], - [LIBXML2="${XML2_LIBS}" - AM_CPPFLAGS="${AM_CPPFLAGS} ${XML2_CFLAGS}" - AC_DEFINE([HAVE_LIBXML2], [1], - [Define to 1 if you have and wish to use libxml2.])], - [AC_MSG_ERROR([libxml2 not found.])])]) - - AC_SUBST([AM_CPPFLAGS]) - AC_SUBST(LIBXML2) - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/nfs-utils.m4 b/nfs-utils-2.5.2/aclocal/nfs-utils.m4 deleted file mode 100644 index fae8b95..0000000 --- a/nfs-utils-2.5.2/aclocal/nfs-utils.m4 +++ /dev/null @@ -1,17 +0,0 @@ -dnl *********** GNU libc 2 *************** -AC_DEFUN([AC_GNULIBC],[ - AC_MSG_CHECKING(for GNU libc2) - AC_CACHE_VAL(knfsd_cv_glibc2, - [AC_TRY_CPP([ - #include - #if !defined(__GLIBC__) - # error Nope - #endif - ], - knfsd_cv_glibc2=yes, knfsd_cv_glibc2=no)]) - AC_MSG_RESULT($knfsd_cv_glibc2) - if test $knfsd_cv_glibc2 = yes; then - CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" - CPPFLAGS_FOR_BUILD="$CPPFLAGS_FOR_BUILD -D_GNU_SOURCE" - fi -]) diff --git a/nfs-utils-2.5.2/aclocal/rpcsec_vers.m4 b/nfs-utils-2.5.2/aclocal/rpcsec_vers.m4 deleted file mode 100644 index 11d2f18..0000000 --- a/nfs-utils-2.5.2/aclocal/rpcsec_vers.m4 +++ /dev/null @@ -1,16 +0,0 @@ -dnl Checks librpcsec version -AC_DEFUN([AC_RPCSEC_VERSION], [ - - AC_ARG_WITH([gssglue], - [AC_HELP_STRING([--with-gssglue], [Use libgssglue for GSS support])]) - if test x"$with_gssglue" = x"yes"; then - PKG_CHECK_MODULES([GSSGLUE], [libgssglue >= 0.3]) - AC_CHECK_LIB([gssglue], [gss_set_allowable_enctypes]) - fi - - dnl TI-RPC replaces librpcsecgss - if test "$enable_tirpc" = no; then - PKG_CHECK_MODULES([RPCSECGSS], [librpcsecgss >= 0.16]) - fi - -])dnl diff --git a/nfs-utils-2.5.2/aclocal/tcp-wrappers.m4 b/nfs-utils-2.5.2/aclocal/tcp-wrappers.m4 deleted file mode 100644 index f5de8bc..0000000 --- a/nfs-utils-2.5.2/aclocal/tcp-wrappers.m4 +++ /dev/null @@ -1,54 +0,0 @@ -# Check whether user wants TCP wrappers support -AC_DEFUN([AC_TCP_WRAPPERS],[ - TCPW_MSG="no" - AC_ARG_WITH(tcp-wrappers, - [ --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support - (optionally in PATH)], - with_tcpw=$withval, with_tcpw=no) - if test "x$with_tcpw" != "xno" ; then - saved_LIBS="$LIBS" - saved_LDFLAGS="$LDFLAGS" - saved_CPPFLAGS="$CPPFLAGS" - if test -n "${with_tcpw}" -a "${with_tcpw}" != "yes"; then - if test -d "${with_tcpw}/lib"; then - if test -n "${need_dash_r}"; then - LDFLAGS="-L${with_tcpw}/lib -R${with_tcpw}/lib ${LDFLAGS}" - else - LDFLAGS="-L${with_tcpw}/lib ${LDFLAGS}" - fi - else - if test -n "${need_dash_r}"; then - LDFLAGS="-L${with_tcpw} -R${with_tcpw} ${LDFLAGS}" - else - LDFLAGS="-L${with_tcpw} ${LDFLAGS}" - fi - fi - if test -d "${with_tcpw}/include"; then - CPPFLAGS="-I${with_tcpw}/include ${CPPFLAGS}" - else - CPPFLAGS="-I${with_tcpw} ${CPPFLAGS}" - fi - fi - LIBWRAP="-lwrap" - LIBS="$LIBWRAP $LIBS" - AC_MSG_CHECKING(for libwrap) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - int deny_severity = 0, allow_severity = 0; - ]], [[hosts_access(0);]])],[ - AC_MSG_RESULT(yes) - AC_SUBST(LIBWRAP) - AC_DEFINE([LIBWRAP], [1], [tcp-wrapper]) - AC_DEFINE([HAVE_LIBWRAP], [1], [tcp-wrapper]) - AC_DEFINE([HAVE_TCP_WRAPPER], [1], [tcp-wrapper]) - TCPW_MSG="yes" - ],[ - AC_MSG_ERROR([*** libwrap missing]) - - ]) - LIBS="$saved_LIBS" - fi - AC_SUBST(LIBWRAP) - AC_SUBST(HAVE_LIBWRAP) - AC_SUBST(HAVE_TCP_WRAPPER) -]) diff --git a/nfs-utils-2.5.2/autogen.sh b/nfs-utils-2.5.2/autogen.sh deleted file mode 100755 index 9e8b89b..0000000 --- a/nfs-utils-2.5.2/autogen.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -e - -echo -n cleaning up . - -# Clean up the generated crud -( - for FILE in compile config.guess config.sub depcomp install-sh ltmain.sh missing mkinstalldirs; do - if test -f $FILE; then - rm -f $FILE - fi - echo -n . - done -) - -for FILE in aclocal.m4 configure config.h.in; do - if test -f $FILE; then - rm -f $FILE - fi - echo -n . -done - -for DIR in autom4te.cache; do - if test -d $DIR; then - rm -rf $DIR - fi - echo -n . -done - -find . -type f -name 'Makefile.in' -print0 | xargs -r0 rm -f -- -find . -type f -name 'Makefile' -print0 | xargs -r0 rm -f -- - -echo ' done' - -if test x"${1}" = x"clean"; then - exit -fi - -aclocal -I aclocal -libtoolize --force --copy -autoheader -automake --add-missing --copy --gnu # -Wall -autoconf # -Wall diff --git a/nfs-utils-2.5.2/configure.ac b/nfs-utils-2.5.2/configure.ac deleted file mode 100644 index 50847d8..0000000 --- a/nfs-utils-2.5.2/configure.ac +++ /dev/null @@ -1,719 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -dnl -AC_INIT([linux nfs-utils],[2.5.2],[linux-nfs@vger.kernel.org],[nfs-utils]) -AC_CANONICAL_BUILD([]) -AC_CANONICAL_HOST([]) -AC_CONFIG_MACRO_DIR(aclocal) -AM_INIT_AUTOMAKE -AC_PREREQ(2.59) -AC_PREFIX_DEFAULT(/usr) -AM_MAINTAINER_MODE -AC_USE_SYSTEM_EXTENSIONS - -dnl ************************************************************* -dnl * Define the set of applicable options -dnl ************************************************************* -AC_ARG_WITH(release, - [AC_HELP_STRING([--with-release=XXX], [set release to XXX [1]])], - RELEASE=$withval, - RELEASE=1) - AC_SUBST(RELEASE) -AC_ARG_WITH(statedir, - [AC_HELP_STRING([--with-statedir=/foo], - [use state dir /foo @<:@default=/var/lib/nfs@:>@])], - statedir=$withval, - statedir=/var/lib/nfs) - AC_SUBST(statedir) -AC_ARG_WITH(nfsconfig, - [AC_HELP_STRING([--with-nfsconfig=/config/file], - [use general config file /config/file @<:@default=/etc/nfs.conf@:>@])], - nfsconfig=$withval, - nfsconfig=/etc/nfs.conf) - AC_SUBST(nfsconfig) -AC_ARG_WITH(statdpath, - [AC_HELP_STRING([--with-statdpath=/foo], - [define the statd state dir as /foo instead of the NFS statedir @<:@default=/var/lib/nfs@:>@])], - statdpath=$withval, - statdpath=$statedir - ) - AC_SUBST(statdpath) -AC_ARG_WITH(statduser, - [AC_HELP_STRING([--with-statduser=rpcuser], - [statd to run under @<:@rpcuser or nobody@:>@] - )], - statduser=$withval, - if test "x$cross_compiling" = "xno"; then - if grep -s '^rpcuser:' /etc/passwd > /dev/null; then - statduser=rpcuser - else - statduser=nobody - fi - else - statduser=nobody - fi) - AC_SUBST(statduser) -AC_ARG_WITH(start-statd, - [AC_HELP_STRING([--with-start-statd=scriptname], - [When an nfs filesystems is mounted with locking, run this script] - )], - startstatd=$withval, - startstatd=/usr/sbin/start-statd - ) - AC_SUBST(startstatd) - AC_DEFINE_UNQUOTED(START_STATD, "$startstatd", [Define this to a script which can start statd on mount]) -unitdir=/usr/lib/systemd/system -AC_ARG_WITH(systemd, - [AC_HELP_STRING([--with-systemd@<:@=unit-dir-path@:>@], - [install systemd unit files @<:@Default: no, and path defaults to /usr/lib/systemd/system if not given@:>@])], - if test "$withval" != "no" ; then - use_systemd=1 - if test "$withval" != "yes" ; then - unitdir=$withval - fi - else - use_systemd=0 - fi - ) - AM_CONDITIONAL(INSTALL_SYSTEMD, [test "$use_systemd" = 1]) - AC_SUBST(unitdir) - -AC_ARG_ENABLE(nfsv4, - [AC_HELP_STRING([--disable-nfsv4], - [disable support for NFSv4 @<:@default=no@:>@])], - enable_nfsv4=$enableval, - enable_nfsv4=yes) - if test "$enable_nfsv4" = yes; then - IDMAPD=idmapd - else - enable_nfsv4= - IDMAPD= - fi - AC_SUBST(IDMAPD) - AC_SUBST(enable_nfsv4) - AM_CONDITIONAL(CONFIG_NFSV4, [test "$enable_nfsv4" = "yes"]) - -AC_ARG_ENABLE(nfsv41, - [AC_HELP_STRING([--disable-nfsv41], - [disable support for NFSv41 @<:@default=no@:>@])], - enable_nfsv41=$enableval, - enable_nfsv41=yes) - if test "$enable_nfsv41" = yes; then - if test "$enable_nfsv4" != yes; then - AC_MSG_WARN([NFS v4 is not enabled. Disabling NFS v4.1]) - enable_nfsv41=no - fi - BLKMAPD=blkmapd - else - enable_nfsv41= - BLKMAPD= - fi - AC_SUBST(enable_nfsv41) - AM_CONDITIONAL(CONFIG_NFSV41, [test "$enable_nfsv41" = "yes"]) - -AC_ARG_ENABLE(gss, - [AC_HELP_STRING([--disable-gss], - [disable client support for rpcsec_gss @<:@default=no@:>@])], - enable_gss=$enableval, - enable_gss=yes) - if test "$enable_gss" = yes; then - GSSD=gssd - else - enable_gss= - GSSD= - fi - AC_SUBST(GSSD) - AC_SUBST(enable_gss) - AM_CONDITIONAL(CONFIG_GSS, [test "$enable_gss" = "yes"]) - -AC_ARG_ENABLE(svcgss, - [AC_HELP_STRING([--enable-svcgss], - [enable building svcgssd for rpcsec_gss server support @<:@default=no@:>@])], - enable_svcgss=$enableval, - enable_svcgss=no) - if test "$enable_gss" = yes -a "$enable_svcgss" = yes; then - SVCGSSD=svcgssd - else - enable_svcgss= - SVCGSSD= - fi - AC_SUBST(SVCGSSD) - AC_SUBST(enable_svcgss) - AM_CONDITIONAL(CONFIG_SVCGSS, [test "$enable_svcgss" = "yes"]) - -AC_ARG_ENABLE(kprefix, - [AC_HELP_STRING([--enable-kprefix], [install progs as rpc.knfsd etc])], - test "$enableval" = "yes" && kprefix=k, - kprefix=) - AC_SUBST(kprefix) -AC_ARG_WITH(rpcgen, - [AC_HELP_STRING([--with-rpcgen=internal], [use internal rpcgen instead of system one])], - rpcgen_path=$withval, - rpcgen_path=yes ) - rpcgen_cflags=-Werror=strict-prototypes - RPCGEN_PATH= - if test "$rpcgen_path" = "yes"; then - for p in /usr/local/bin/rpcgen /usr/bin/rpcgen /bin/rpcgen - do if test -f $p ; then RPCGEN_PATH=$p ; break; fi ; done - if test -z "$RPCGEN_PATH"; then - AC_MSG_ERROR([Please install rpcgen or use --with-rpcgen]) - fi - elif test "$rpcgen_path" != "internal"; then - RPCGEN_PATH=$rpcgen_path - else - RPCGEN_PATH=internal - rpcgen_cflags=-Wstrict-prototypes - fi - AC_SUBST(RPCGEN_PATH) - AM_CONDITIONAL(CONFIG_RPCGEN, [test "$RPCGEN_PATH" = "internal"]) -AC_ARG_ENABLE(uuid, - [AC_HELP_STRING([--disable-uuid], - [Exclude uuid support to avoid buggy libblkid. @<:@default=no@:>@])], - if test "$enableval" = "yes" ; then choose_blkid=yes; else choose_blkid=no; fi, - choose_blkid=default) -AC_ARG_ENABLE(mount, - [AC_HELP_STRING([--disable-mount], - [Do not build mount.nfs and do use the util-linux mount(8) functionality. @<:@default=no@:>@])], - enable_mount=$enableval, - enable_mount=yes) - AM_CONDITIONAL(CONFIG_MOUNT, [test "$enable_mount" = "yes"]) - -if test "$enable_mount" = yes; then - AC_ARG_ENABLE(libmount-mount, - [AC_HELP_STRING([--enable-libmount-mount], - [Link mount.nfs with libmount @<:@default=no@:>@])], - enable_libmount=$enableval, - enable_libmount=no) -else - enable_libmount=no -fi - -AC_ARG_ENABLE(junction, - [AC_HELP_STRING([--enable-junction], - [enable support for NFS junctions @<:@default=no@:>@])], - enable_junction=$enableval, - enable_junction=no) - if test "$enable_junction" = yes; then - AC_DEFINE(HAVE_JUNCTION_SUPPORT, 1, - [Define this if you want junction support compiled in]) - else - enable_junction= - fi - AM_CONDITIONAL(CONFIG_JUNCTION, [test "$enable_junction" = "yes" ]) - -AC_ARG_ENABLE(tirpc, - [AC_HELP_STRING([--disable-tirpc], - [disable use of TI-RPC library @<:@default=no@:>@])], - enable_tirpc=$enableval, - enable_tirpc=yes) -AC_ARG_ENABLE(ipv6, - [AC_HELP_STRING([--disable-ipv6], - [disable support for IPv6 @<:@default=no@:>@])], - enable_ipv6=$enableval, - enable_ipv6=yes) - if test "$enable_ipv6" = yes; then - AC_DEFINE(IPV6_SUPPORTED, 1, [Define this if you want IPv6 support compiled in]) - else - enable_ipv6= - fi - AC_SUBST(enable_ipv6) - AM_CONDITIONAL(CONFIG_IPV6, [test "$enable_ipv6" = "yes"]) - -if test "$enable_mount" = yes; then - AC_ARG_ENABLE(mountconfig, - [AC_HELP_STRING([--disable-mountconfig], - [disable mount to use a configuration file @<:@default=no@:>@])], - enable_mountconfig=$enableval, - enable_mountconfig=yes) - if test "$enable_mountconfig" = no; then - enable_mountconfig= - else - AC_DEFINE(MOUNT_CONFIG, 1, - [Define this if you want mount to read a configuration file]) - AC_ARG_WITH(mountfile, - [AC_HELP_STRING([--with-mountfile=filename], - [Using filename as the NFS mount options file [/etc/nfsmounts.conf]] - )], - mountfile=$withval, - mountfile=/etc/nfsmount.conf) - AC_SUBST(mountfile) - AC_DEFINE_UNQUOTED(MOUNTOPTS_CONFFILE, "$mountfile", - [This defines the location of the NFS mount configuration file]) - fi - AC_SUBST(enable_mountconfig) - AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mountconfig" = "yes"]) -else - AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mount" = "yes"]) -fi - -AC_ARG_ENABLE(nfsdcld, - [AC_HELP_STRING([--disable-nfsdcld], - [disable NFSv4 clientid tracking daemon @<:@default=no@:>@])], - enable_nfsdcld=$enableval, - enable_nfsdcld="yes") - -AC_ARG_ENABLE(nfsdcltrack, - [AC_HELP_STRING([--disable-nfsdcltrack], - [disable NFSv4 clientid tracking programs @<:@default=no@:>@])], - enable_nfsdcltrack=$enableval, - enable_nfsdcltrack="yes") - -dnl Check for TI-RPC library and headers -AC_LIBTIRPC - -dnl Check for -lcap -AC_LIBCAP - -dnl Check for -lxml2 -AC_LIBXML2 - -# Check whether user wants TCP wrappers support -AC_TCP_WRAPPERS - -# Arrange for large-file support -AC_SYS_LARGEFILE - -AC_CONFIG_SRCDIR([support/include/config.h.in]) -AC_CONFIG_HEADERS([support/include/config.h]) - -# Checks for programs. -AC_PROG_CXX -AC_PROG_CC -AC_PROG_CPP -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -AC_PROG_LIBTOOL -AM_PROG_CC_C_O - -if test "x$cross_compiling" = "xno"; then - CC_FOR_BUILD=${CC_FOR_BUILD-${CC-gcc}} -else - CC_FOR_BUILD=${CC_FOR_BUILD-gcc} -fi - -AC_SUBST(CC_FOR_BUILD) - -AC_CHECK_TOOL(AR, ar) -AC_CHECK_TOOL(LD, ld) - -AC_HEADER_STDC([]) -AC_GNULIBC -AC_BSD_SIGNALS - -dnl ************************************************************* -dnl * Check for required libraries -dnl ************************************************************* - -AC_CHECK_FUNC([gethostbyname], , - [AC_CHECK_LIB([nsl], [gethostbyname], [LIBNSL="-lnsl"])]) -AC_SUBST(LIBNSL) - -AC_CHECK_FUNC([connect], , - [AC_CHECK_LIB([socket], [connect], [LIBSOCKET="-lsocket"], - [AC_MSG_ERROR([Function 'socket' not found.])], [$LIBNSL])]) - -AC_CHECK_FUNC([getaddrinfo], , - [AC_MSG_ERROR([Function 'getaddrinfo' not found.])]) - -AC_CHECK_FUNC([getservbyname], , - [AC_MSG_ERROR([Function 'getservbyname' not found.])]) - -AC_CHECK_LIB([crypt], [crypt], [LIBCRYPT="-lcrypt"]) - -AC_CHECK_HEADERS([sched.h], [], []) -AC_CHECK_FUNCS([unshare fstatat statx], [] , []) -AC_LIBPTHREAD([]) - -if test "$enable_nfsv4" = yes; then - dnl check for libevent libraries and headers - AC_LIBEVENT - - dnl check for the keyutils libraries and headers - AC_KEYUTILS - - dnl Check for sqlite3 - AC_SQLITE3_VERS - - if test "$enable_nfsdcld" = "yes"; then - AC_CHECK_HEADERS([libgen.h sys/inotify.h], , - AC_MSG_ERROR([Cannot find header needed for nfsdcld])) - - case $libsqlite3_cv_is_recent in - yes) ;; - unknown) - dnl do not fail when cross-compiling - AC_MSG_WARN([assuming sqlite is at least v3.3]) ;; - *) - AC_MSG_ERROR([nfsdcld requires sqlite-devel]) ;; - esac - fi - - if test "$enable_nfsdcltrack" = "yes"; then - AC_CHECK_HEADERS([libgen.h sys/inotify.h], , - AC_MSG_ERROR([Cannot find header needed for nfsdcltrack])) - - case $libsqlite3_cv_is_recent in - yes) ;; - unknown) - dnl do not fail when cross-compiling - AC_MSG_WARN([assuming sqlite is at least v3.3]) ;; - *) - AC_MSG_ERROR([nfsdcltrack requires sqlite-devel]) ;; - esac - fi - -else - enable_nfsdcld="no" - enable_nfsdcltrack="no" -fi - -if test "$enable_nfsv41" = yes; then - AC_CHECK_LIB([devmapper], [dm_task_create], [LIBDEVMAPPER="-ldevmapper"], AC_MSG_ERROR([libdevmapper needed])) - AC_CHECK_HEADER(libdevmapper.h, , AC_MSG_ERROR([Cannot find devmapper header file libdevmapper.h])) - AC_CHECK_HEADER(sys/inotify.h, , AC_MSG_ERROR([Cannot find header file sys/inotify.h])) -fi - -dnl enable nfsidmap when its support by libnfsidmap -AM_CONDITIONAL(CONFIG_NFSDCLD, [test "$enable_nfsdcld" = "yes" ]) -AM_CONDITIONAL(CONFIG_NFSDCLTRACK, [test "$enable_nfsdcltrack" = "yes" ]) - - -if test "$knfsd_cv_glibc2" = no; then - AC_CHECK_LIB(bsd, daemon, [LIBBSD="-lbsd"]) -fi - -if test "$choose_blkid" != no; then - AC_CHECK_LIB(blkid, blkid_get_library_version, [LIBBLKID="-lblkid"], AC_MSG_ERROR([libblkid needed])) - AC_CHECK_HEADER(blkid/blkid.h, , AC_MSG_ERROR([Cannot find libblkid header file blkid/blkid.h])) - AC_BLKID_VERS - if test $choose_blkid = yes; then - use_blkid=1 - test $libblkid_cv_is_recent = no && AC_MSG_WARN([libblkid is old and may cause mountd to leak memory]) - else - if test $libblkid_cv_is_recent = yes - then use_blkid=1 - else use_blkid=0 - AC_MSG_WARN([uuid support disabled as libblkid is too old]) - fi - fi - AC_DEFINE_UNQUOTED(USE_BLKID, $use_blkid, [Define if you want to use blkid to find uuid of filesystems]) -fi -AC_SUBST(LIBSOCKET) -AC_SUBST(LIBCRYPT) -AC_SUBST(LIBBSD) -AC_SUBST(LIBBLKID) - -if test "$enable_libmount" = yes; then - AC_CHECK_LIB(mount, mnt_context_do_mount, [LIBMOUNT="-lmount"], AC_MSG_ERROR([libmount needed])) - AC_CHECK_HEADER(libmount/libmount.h, , AC_MSG_ERROR([Cannot find libmount header file libmount/libmount.h])) -fi -AM_CONDITIONAL(CONFIG_LIBMOUNT, [test "$enable_libmount" = "yes"]) -AC_SUBST(LIBMOUNT) - -if test "$enable_gss" = yes; then - dnl 'gss' requires getnameinfo - at least for gssd_proc.c - AC_CHECK_FUNC([getnameinfo], , [AC_MSG_ERROR([GSSAPI support requires 'getnameinfo' function])]) - - dnl check for libevent libraries and headers - AC_LIBEVENT - - dnl Check for Kerberos V5 - AC_KERBEROS_V5 - - dnl Check for pthreads - AC_LIBPTHREAD([AC_MSG_ERROR([libpthread not found.])]) - - dnl librpcsecgss already has a dependency on libgssapi, - dnl but we need to make sure we get the right version - if test "$enable_gss" = yes; then - AC_RPCSEC_VERSION - if test x"$GSSGLUE_LIBS" != x""; then - GSSAPI_CFLAGS=$GSSGLUE_CFLAGS - GSSAPI_LIBS=$GSSGLUE_LIBS - else - GSSAPI_CFLAGS=$GSSKRB_CFLAGS - GSSAPI_LIBS=$GSSKRB_LIBS - fi - AC_SUBST([GSSAPI_CFLAGS]) - AC_SUBST([GSSAPI_LIBS]) - fi -fi - -dnl libdnsidmap specific checks -AC_CHECK_LIB([resolv], [__res_querydomain], , - AC_CHECK_LIB([resolv], [res_querydomain], , AC_MSG_ERROR(res_querydomain needed))) - -AC_ARG_ENABLE([ldap], - [AS_HELP_STRING([--disable-ldap],[Disable support for LDAP @<:default=detect@:>@])]) - -dnl will libdnsidmap support LDAP ? -if test "x$enable_ldap" != "xno" ; then - AC_CHECK_HEADER([ldap.h], - [AC_CHECK_LIB([ldap], [ldap_initialize], - [have_ldap="yes"],[have_ldap="no"])], - [have_ldap="no"]) - if test "x$have_ldap" = "xyes" ; then - dnl check for sasl funcs - AC_CHECK_HEADERS(sasl.h sasl/sasl.h) - AC_CHECK_HEADERS(gsssasl.h) - AC_CHECK_TYPE(sasl_interact_t,[have_sasl_interact_t="yes"],,[ - #ifdef HAVE_SASL_SASL_H - #include - #elif defined(HAVE_SASL_H) - #include - #endif]) - AC_CHECK_LIB([ldap],[ldap_sasl_interactive_bind_s],[have_ldap_sasl_interactive_bind_s="yes"]) - AC_CHECK_LIB([gssapi_krb5],[gss_krb5_ccache_name],[have_gss_krb5_ccache_name="yes"]) - if test "x$have_sasl_interact_t" = "xyes" -a \ - "x$have_ldap_sasl_interactive_bind_s" = "xyes" -a \ - "x$have_gss_krb5_ccache_name" = "xyes"; then - AC_DEFINE([HAVE_LDAP_SASL_INTERACTIVE_BIND_S],[1],[Has ldap_sasl_interactive_bind_s function]) - AC_DEFINE([HAVE_GSS_KRB5_CCACHE_NAME],[1],[Has gss_krb5_ccache_name function]) - AC_CHECK_HEADERS(gssapi/gssapi.h gssapi/gssapi_generic.h gssapi/gssapi_krb5.h gssapi.h krb5.h) - AC_DEFINE([ENABLE_LDAP_SASL],1,[Enable LDAP SASL support]) - have_ldap_sasl="yes" - fi - AC_DEFINE([ENABLE_LDAP], 1, [Enable LDAP Support]) - elif test "x$enable_ldap$have_ldap" = "xyesno" ; then - AC_MSG_ERROR(LDAP support not found!) - fi -fi -AM_CONDITIONAL(ENABLE_LDAP, test "x$have_ldap" = "xyes") -AM_CONDITIONAL(ENABLE_LDAP_SASL, test "x$have_ldap_sasl" = "xyes") - -dnl Should we build gums mapping library? -AC_ARG_ENABLE([gums], - [AS_HELP_STRING([--enable-gums],[Enable support for the GUMS mapping library @<:@default=false@:>@])]) -if test "x$enable_gums" = "xyes" ; then - AC_DEFINE([ENABLE_GUMS], 1, [Enable GUMS mapping library support]) -fi -AM_CONDITIONAL(ENABLE_GUMS, test "x$enable_gums" = "xyes") - -dnl Where do the Plugins live -AC_ARG_WITH(pluginpath, - [AS_HELP_STRING([--with-pluginpath=/foo],[Causes the library to look in /foo instead of /usr/lib/libnfsidmap for plugins - ])], - path_plugins=$withval, - path_plugins="" - ) -if test -n "$path_plugins" ; then - AC_DEFINE_UNQUOTED(PATH_PLUGINS, "$path_plugins", - [Define this to change the plugins path]) -fi -AM_CONDITIONAL(PATH_PLUGINS, test -n "$path_plugins") -AC_SUBST(PATH_PLUGINS, "$path_plugins") - -AC_SUBST(AM_CPPFLAGS, "$AM_CPPFLAGS") -AC_DEFINE([HAVE_NFS4_SET_DEBUG], 1, - [Bundled lib always has the `nfs4_set_debug' function.]) - -dnl Check for IPv6 support -AC_IPV6 - -dnl ************************************************************* -dnl Check for headers -dnl ************************************************************* -AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h \ - malloc.h memory.h netdb.h netinet/in.h paths.h \ - stdlib.h string.h sys/file.h sys/ioctl.h sys/mount.h \ - sys/param.h sys/socket.h sys/time.h sys/vfs.h \ - syslog.h unistd.h com_err.h et/com_err.h \ - ifaddrs.h]) - -dnl ************************************************************* -dnl Checks for typedefs, structures, and compiler characteristics -dnl ************************************************************* -AC_C_CONST -AC_TYPE_UID_T -AC_C_INLINE -AC_TYPE_OFF_T -AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_HEADER_TIME -AC_STRUCT_TM -AC_CHECK_TYPES([struct file_handle], [], [], [[ - #define _GNU_SOURCE - #include - #include - #include - ]]) - -dnl ************************************************************* -dnl Check for functions -dnl ************************************************************* -AC_FUNC_ALLOCA -AC_FUNC_CLOSEDIR_VOID -AC_FUNC_ERROR_AT_LINE -AC_FUNC_FORK -AC_FUNC_GETGROUPS -AC_FUNC_GETMNTENT -AC_PROG_GCC_TRADITIONAL -AC_FUNC_LSTAT -AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_HEADER_MAJOR -#AC_FUNC_MALLOC -AC_FUNC_MEMCMP -#AC_FUNC_REALLOC -AC_FUNC_SELECT_ARGTYPES -AC_TYPE_SIGNAL -AC_FUNC_STAT -AC_FUNC_VPRINTF -AC_CHECK_FUNCS([alarm atexit dup2 fdatasync ftruncate getcwd \ - gethostbyaddr gethostbyname gethostname getmntent \ - getnameinfo getrpcbyname getifaddrs \ - gettimeofday hasmntopt inet_ntoa innetgr memset mkdir pathconf \ - ppoll realpath rmdir select socket strcasecmp strchr strdup \ - strerror strrchr strtol strtoul sigprocmask name_to_handle_at]) - -save_CFLAGS=$CFLAGS -save_LIBS=$LIBS -CFLAGS="$CFLAGS $AM_CPPFLAGS" -LIBS="$LIBS $LIBTIRPC" -AC_CHECK_FUNCS([getrpcbynumber getrpcbynumber_r]) -CFLAGS=$save_CFLAGS -LIBS=$save_LIBS - -if test "$ac_cv_func_getrpcbynumber_r" != "yes" -a "$ac_cv_func_getrpcbynumber" != "yes"; then - AC_MSG_ERROR([Neither getrpcbynumber_r nor getrpcbynumber are available]) -fi - -dnl ************************************************************* -dnl Check for data sizes -dnl ************************************************************* -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(size_t) -AC_CHECK_SIZEOF(socklen_t,, [AC_INCLUDES_DEFAULT - #ifdef HAVE_SYS_SOCKET_H - # include - #endif]) - - -dnl ************************************************************* -dnl Export some path names to config.h -dnl ************************************************************* -AC_DEFINE_UNQUOTED(NFS_STATEDIR, "$statedir", [This defines the location of the NFS state files. Warning: this must match definitions in config.mk!]) -AC_DEFINE_UNQUOTED(NSM_DEFAULT_STATEDIR, "$statdpath", [Define this to the pathname where statd keeps its state file]) -AC_DEFINE_UNQUOTED(NFS_CONFFILE, "$nfsconfig", [This defines the location of NFS daemon config file]) - -if test "x$cross_compiling" = "xno"; then - CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-"$CFLAGS"} - CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-"$CXXFLAGS"} - CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"} - LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-"$LDFLAGS"} -else - CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-""} - CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-""} - CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""} - LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} -fi - -AC_SUBST(CFLAGS) -AC_SUBST(CXXFLAGS) -AC_SUBST(CPPFLAGS) -AC_SUBST(LDFLAGS) - -AC_SUBST(CFLAGS_FOR_BUILD) -AC_SUBST(CXXFLAGS_FOR_BUILD) -AC_SUBST(CPPFLAGS_FOR_BUILD) -AC_SUBST(LDFLAGS_FOR_BUILD) - -my_am_cflags="\ - -pipe \ - -Wall \ - -Wextra \ - $rpcgen_cflags \ - -Werror=missing-prototypes \ - -Werror=missing-declarations \ - -Werror=format=2 \ - -Werror=undef \ - -Werror=missing-include-dirs \ - -Werror=strict-aliasing=2 \ - -Werror=init-self \ - -Werror=implicit-function-declaration \ - -Werror=return-type \ - -Werror=switch \ - -Werror=overflow \ - -Werror=parentheses \ - -Werror=aggregate-return \ - -Werror=unused-result \ - -fno-strict-aliasing \ -" - -AC_DEFUN([CHECK_CCSUPPORT], [ - my_save_cflags="$CFLAGS" - CFLAGS="-Werror $1" - AC_MSG_CHECKING([whether CC supports $1]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [$2+=$1], - [AC_MSG_RESULT([no])] - ) - CFLAGS="$my_save_cflags" -]) - -CHECK_CCSUPPORT([-Werror=format-overflow=2], [flg1]) -CHECK_CCSUPPORT([-Werror=int-conversion], [flg2]) -CHECK_CCSUPPORT([-Werror=incompatible-pointer-types], [flg3]) -CHECK_CCSUPPORT([-Werror=misleading-indentation], [flg4]) -CHECK_CCSUPPORT([-Wno-cast-function-type], [flg5]) -AX_GCC_FUNC_ATTRIBUTE([format]) - -AC_SUBST([AM_CFLAGS], ["$my_am_cflags $flg1 $flg2 $flg3 $flg4 $flg5"]) - -# Make sure that $ACLOCAL_FLAGS are used during a rebuild -AC_SUBST([ACLOCAL_AMFLAGS], ["-I $ac_macro_dir \$(ACLOCAL_FLAGS)"]) - -# make _sysconfdir available for substituion in config files -# 2 "evals" needed late to expand variable names. -AC_SUBST([_sysconfdir]) -AC_CONFIG_COMMANDS_PRE([eval eval _sysconfdir=$sysconfdir]) - -AC_CONFIG_FILES([ - Makefile - systemd/rpc-gssd.service - linux-nfs/Makefile - support/Makefile - support/export/Makefile - support/include/nfs/Makefile - support/include/rpcsvc/Makefile - support/include/sys/fs/Makefile - support/include/sys/Makefile - support/include/Makefile - support/junction/Makefile - support/misc/Makefile - support/nfs/Makefile - support/nsm/Makefile - support/nfsidmap/Makefile - support/nfsidmap/libnfsidmap.pc - tools/Makefile - tools/locktest/Makefile - tools/nlmtest/Makefile - tools/rpcdebug/Makefile - tools/rpcgen/Makefile - tools/mountstats/Makefile - tools/nfs-iostat/Makefile - tools/nfsdclnts/Makefile - tools/nfsconf/Makefile - tools/nfsdclddb/Makefile - utils/Makefile - utils/blkmapd/Makefile - utils/nfsdcld/Makefile - utils/nfsdcltrack/Makefile - utils/exportfs/Makefile - utils/gssd/Makefile - utils/idmapd/Makefile - utils/mount/Makefile - utils/mountd/Makefile - utils/nfsd/Makefile - utils/nfsref/Makefile - utils/nfsstat/Makefile - utils/nfsidmap/Makefile - utils/showmount/Makefile - utils/statd/Makefile - systemd/Makefile - tests/Makefile - tests/nsm_client/Makefile]) -AC_OUTPUT - diff --git a/nfs-utils-2.5.2/linux-nfs/ChangeLog b/nfs-utils-2.5.2/linux-nfs/ChangeLog deleted file mode 100644 index 11ffe15..0000000 --- a/nfs-utils-2.5.2/linux-nfs/ChangeLog +++ /dev/null @@ -1,78 +0,0 @@ - -Release 0.4.11 - - * Added async writes. - * Fixed bug where two rpciod's would be started when insmod'ing - both nfs.o and nfsd.o. - -Release 0.4.12 - - * Fixed compile problem after renaming some debug macros. - * Improved readdir cache, which can now hold up to 16 (configurable) - readdir replies. - * Fixed async write bug(s) - * client file locking now does at least lock/unlock without - crashing the machine - * Started to work on NFS swapping - * nfs_get_super no longer requires the file handle passed by - mount but does a straight xprt_create_proto(). - * TCP reconnect should work now (not yet tested for long disconnect - periods, but it does work if you kill and restart nfsd). - -Release 0.4.13 - - * More writeback bugs removed. - * Added a modified (and ansified) tirpc rpcgen to get rid of all - the warnings in files generated from *.x descriptions. That old Sun - code is a real mess. - * Cleaned up nfsd export handling a bit. All syscalls now - take dev/ino rather than the pathname. - * Added sysctl interface to set/get debug flags (see tools/rpcdebug). - * Cleaned up Makefiles. - * (experimental) Gathered writes for nfsd (use the wdelay option in - /etc/exports). - * Fixed silly bug in nfs_readdir (the in-place decoding of readdir - replies requires a temporary buffer). - * Fixed readdir bug in nfsd (long directories were truncated). - -Release 0.4.14 - - * Upgraded to kernel 2.0.23 - * Fixed bug in rpcdebug - * readdir still didn't work right in nfsd. Argh! - * nfsd would refuse to create symlinks with slashes in them:-) - * nfsd's RPC reply cache should now work again. - * Heavily modified rpc.statd for more robust callback/notify handling - -Release 0.4.17 - - * Upgraded to kernel 2.1.14 - * Got lockd working with HPUX in most areas. - -Release 0.4.19 - - * RPC server UDP sockets now receive the sk_buff directly rather - than going through sock->ops->recvmsg. - Also got rid of all those cli/sti's and replaced them with - disable_bh/enable_bh calls. - * Fixed a bug in nfsd's handling of rename and friends. - -Release 0.4.20 - - * Some bugfixes, esp in the writeback code - * Avoid some unnecessary cli/sti pairs - * Added nhfsstone - -Release 0.4.21 - - * Minor bugfixes - * Moved to post-2.1.16 module handling code - -Release 0.4.22 - - * Fixed a bug that made rpcinfo -u host nlockmgr provoke a kernel - oops. - * Upgraded to mount-2.6b - * Added NFSv3 support to mountd and nfsd - * Made sure it compiles with glibc2. - diff --git a/nfs-utils-2.5.2/linux-nfs/INSTALL b/nfs-utils-2.5.2/linux-nfs/INSTALL deleted file mode 100644 index 351f733..0000000 --- a/nfs-utils-2.5.2/linux-nfs/INSTALL +++ /dev/null @@ -1,11 +0,0 @@ - -Even though the Makefiles offer a `make install' instruction, -I would suggest against using it yet. I have run nfsd and the nfs -client without kernel oopses for a while, but the picture may change -if you start playing with lockd. Automatic installation may not even -work for the kernel makefiles yet. - -I'd therefore advise that you use a separate Linux box for testing -if you have one. Use the etc/copy script to copy all modules and -support programs, and run the ins script to start the show. rmm -will clean up afterwards (provided you didn't trigger an oops). diff --git a/nfs-utils-2.5.2/linux-nfs/KNOWNBUGS b/nfs-utils-2.5.2/linux-nfs/KNOWNBUGS deleted file mode 100644 index b0ecd5c..0000000 --- a/nfs-utils-2.5.2/linux-nfs/KNOWNBUGS +++ /dev/null @@ -1,37 +0,0 @@ - -nfsd: - - * We currently keep the inode in the exports struct. This is - a bad idea with directories that are intended to be used as - a mount point. Must store the file name instead and do a - lookup when getfh is called. Yuck! - - Even yuckier: what do we do about exports matching when we - can't keep the inode number? - - * stating a file on remote cdrom returns st_blocks == 0 for some - apps. - - * Should allow multiple exports per dev if one of the directories - isn't a subdir of the other. - -nfsclnt: - - * On some occasions, an EAGAIN reported by the transport layer - will be propagated to the VFS. - * Some operations do not seem to release the inode properly, so - unmounting the device fails. - -lockd: - - * Handle portmap registration in a separate thread. portmap may - not be running when we try to mount the first NFS volume (esp. - when mounting /usr). - - * Does not inform rpc.statd when hosts no longer require - monitoring; hosts are incorrectly monitored until next system - reboot. - -exportfs/mountd: - - * Export handling is reported to do odd things at times. diff --git a/nfs-utils-2.5.2/linux-nfs/Makefile.am b/nfs-utils-2.5.2/linux-nfs/Makefile.am deleted file mode 100644 index 9c2065b..0000000 --- a/nfs-utils-2.5.2/linux-nfs/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = ChangeLog INSTALL KNOWNBUGS NEW README THANKS TODO - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/linux-nfs/NEW b/nfs-utils-2.5.2/linux-nfs/NEW deleted file mode 100644 index 43f5c69..0000000 --- a/nfs-utils-2.5.2/linux-nfs/NEW +++ /dev/null @@ -1,319 +0,0 @@ -This is the Linux kernel NFS daemon 1.4.7. It is based on linux-nfs -0.4.22. It is tested on Linux/alpha and Linux/x86 running glibc 2.1.1. - -WARNING: The NFS servers in Linux 2.2 to 2.2.11 are not compatible with -other NFS client implemenations. If you plan to use Linux 2.2.x as an -NFS server for non-Linux NFS clients, you should apply the patches -enlosed here. - -linux-2.2.7-sunrpc.patch, nfsd-2.2.7-2.lockd.patch, nfsd-2.2.7-3.patch -and nfsd-2.2.7-nfsfh.patch are required for Linux 2.2.7 to 2.2.11. -For other kernel versions, they have to be applied by hand if they are -still needed. - -For Linux 2.2.7 to 2.2.10, nfsd-2.2.7-1.lock.patch is also required. - -I made my knfsd package available only because I use it and noone else -seems to maintain it. But I don't have much time to really work on it. -I will only fix bugs in the NFS utilities and serious kernel NFS bugs -which I can duplcate easily. If you have any kernel NFS server problem, -please report it to the Linux kernel mailing list. If it can be -reproduced with Linux NFS server and client in less than 5 minutes, you -can also send me a copy in addition to sending it to the Linux kernel -mailing list. I may take a look when I have time. However I will collect -kernel NFS related patches. Contributions are more than welcome. - -The NFS lock only works with lockd. Please make sure the portmapper, -portmap, is started before mounting NFS. - -Changes from knfsd 1.4.6: - -1. Fix a typo in knfslock.init. -2. A new kernel patch, nfsd-2.2.7-1.lock.patch, to fix some NFS lock - bugs. - -Changes from knfsd 1.4.5: - -1. Rename /var/lib/nfs/xtab.export to /var/lib/nfs/etab. - -Changes from knfsd 1.4.4: - -1. Try to fix mountd performance problem by introducing - /var/lib/nfs/xtab.export. That is - - a. "exportfs" reads from /var/lib/nfs/xtab and writes to - /var/lib/nfs/xtab.export. - b. "mountd" reads from /var/lib/nfs/xtab.export and writes to - /var/lib/nfs/xtab. - - The idea is "mountd" doesn't have to read /var/lib/nfs/xtab, which - is very expensive. - -Changes from knfsd 1.4.3: - -1. nfsd-2.2.7-nfsfh.patch, a new kernel patch for filehandle. -2. nfsd-2.2.7-2.lockd.patch, a new patch for lockd. -3. Misc bug fixes. - -Changes from knfsd 1.4.2: - -1. A mountd patch so that the syslog reports unknown requests, and also - reports *what* is being (un)mounted, from Piete Brooks - . -2. Fix knfsd.init for restart. -3. Add knfslock.init. -4. knfsd-compat.spec is removed. -5. nfsd-2.2.7-lockd.patch, a patch to start lockd independent of - nfs and nfsd. - -Changes from knfsd 1.4.1: - -1. Resolve symlink for umount from Piete.Brooks@cl.cam.ac.uk (Piete - Brooks) -2. Fix knfsd.init for statd. - -Changes from knfsd 1.4: - -1. nfsd-2.2.7-3.patch. This is the only patch you need for Linux 2.2.7 - to 2.2.10. -2. Remove - nfsd-2.2.5-1.patch - nfsd-2.2.5-3.patch - nfsd-2.2.8-1.patch - nfsd-2.2.7-iget.diff - nfsd-2.2.5-nfsfh.diff - nfsd-2.2.5-file.patch - nfsd-2.2.7-quota.patch - nfsd-2.2.7-mknod.patch -3. Statd update by Jeff Uphoff . -4. netgroups patch from Peter Breitenlohner . -5. Add option checking to exportfs. - -Changes from knfsd 1.3.3b: - -1. Add linux-2.2.7-sunrpc.patch for a SMP bug in sunrpc. -2. Add --port/-P to nfsd/mountd, by Jeff Johnson . -3. Add nfsd.8, mountd.8 and statd.man, by Olaf Kirch - . -4. Update nfsstat.man by Olaf Kirch . -5. Statd fix by Jeff Uphoff . -6. Remove knfsd-nok.patch. - -Changes from knfsd 1.3.3a: - -1. Fix stdin/stdout/stdout handling in mountd. -2. nfsd-2.2.7-mknod.patch. A patch for mknod. -3. nfsd-2.2.7-quota.patch. A patch for quota. - -Changes from knfsd 1.3.3: - -1. Fix hostname matching for wildcard, subnet and netgroup. - -Changes from knfsd 1.3.2: - -1. Modified mountd to allow clients without IP address to hostname map. - -Changes from knfsd 1.3.1a: - -1. nfsd-2.2.5-3.patch. This is the only patch you need for Linux 2.2.5. - -Changes from knfsd 1.3.1: - -1. A patch for knfsd.spec from Markus Linnala . - -Changes from knfsd 1.3a: - -1. nfsd-2.2.8-1.patch. This is the only patch you need for Linux 2.2.8. -2. nfsd-2.2.7-2.patch. This is the only patch you need for Linux 2.2.7. - -Changes from knfsd 1.3: - -1. Adding "--no-nfs-version 3" to mountd in knfsd.init from RedHat 6.0. - -Changes from knfsd 1.2.2a: - -1. Updated knfsd.init from RedHat 6.0. -2. nfsd-2.2.7-1.patch. This is the only patch you need for Linux 2.2.7. -3. Misc updates from RedHat 6.0. - -Changes from knfsd 1.2.2: - -1. Make the default NFS server kernel thread to 8 in the rc script. - -Changes from knfsd 1.2: - -1. Moved knfsd.spec to knfsd-compat.spec. -2. Update knfsd.spec from knfsd-981204-3.src.rpm. -3. Fix the squash_[ug]id parsing in /etc/exports from Anders - Hammarquist . -4. nfsd-2.2.5-file.patch to clear the bogus bit for MKDIR and SYMLINK. -5. nfsd-2.2.5-1.patch. A NFS patch based on nfsd-2.2.3-1.patch for - Linux 2.2.5. - -Changes from knfsd 1.1: - -1. Remove - cache-2.1.131-1.patch - linux-2.1.1xx.diff - lock-2.1.131.diff - lock-2.1.1xx.diff - nfsd-2.1.127-5.patch - nullproc-2.1.1xx.diff - procfs-2.1.127.patch - quota-2.1.1xx.diff - root-2.1.1xx.diff - socket-2.1.1xx.diff - sunrpc-2.1.123-1.patch -2. locks-2.2.3.diff. A patch for file lock. -3. nfsd-2.2.3-1.patch. A NFS patch by "G. Allen Morris III" -(gam3@acm.org). - -Changes from knfsd 1.0: - -1. Handle broken /var/lib/nfs/rmtab. -2. Handle lower/upper cases in wildcard hostnames in /etc/exports. - -Changes from knfsd-981204: - -1. Modify etc/rc.nfsd to check /var/lib/nfs/rmtab during startup. -2. Add knfsd.spec for RedHat 5. Need nfs-server-2.2beta37-1.1.src.rpm - and initscripts-3.78.1-2.src.rpm. -3. Add support for "make install prefix=...". - -Changes from knfsd-981122: - -1. Modify etc/rc.nfsd and etc/rc.nfsfs to handle statd during shutdown. -2. Remove maximum knfsd count checking. -3. Clean up mountd. -4. cache-2.1.131-1.patch from G. Allen Morris III (gam3@acm.org). -5. lock-2.1.131.diff. A nfsd lock patch for Linux 2.1.131. - -Changes from knfsd-981113: - -1. procfs-2.1.127.patch from G. Allen Morris III (gam3@acm.org). -2. Modify etc/rc.nfsd and etc/rc.nfsfs to better handle statd. -3. Fix the sub-mounted directories. - -Changes from knfsd-981022: - -1. Fix buffer overruns from Peter Benie . -2. Fix hostname matching. -3. Correctly handle dupilcations in /etc/exports. -4. Add -F flag to statd. -5. nfsd-2.1.127-5.patch from G. Allen Morris III (gam3@acm.org). - -Changes from knfsd-981014: - -1. lock-2.1.1xx.diff. A nfsd lock patch. -2. nullproc-2.1.1xx.diff. Allow any clients to call the nfsd NULL proc. -3. Add etc/rc.nfsfs to handle statd. -3. Update etc/rc.nfsd to handle statd. -4. nfsd-2.1.125-2.patch from G. Allen Morris III (gam3@acm.org). -5. Fix inet_ntoa usage in statd. - -Changes from knfsd-981010: - -1. Check client aliases when matching for wildcard client hostnames. -2. Fix memory leak in mountd. -3. Fix filename in nfsd-2.1.125-1.patch. - -Changes from knfsd-980930: - -1. nfsd-2.1.125-1.patch from G. Allen Morris III (gam3@acm.org) and me. -2. Fix the hostent bugs in mountd and statd. -3. Remove "kexportfs -au" for "rc.nfsd stop". - -Changes from knfsd-980925: - -1. socket-2.1.1xx.diff for creating socket on NFS client. -2. There is a knsfd root_squash patch for Linux 2.1.1xx, - root-2.1.1xx.diff. It is only tested on linux 2.1.123. - It also fixes the server side 0711 mode bug. -3. sunrpc-2.1.123-1.patch from Bill Hawes . -4. nfsd-2.1.122-3.patch from G. Allen Morris III (gam3@acm.org). -5. Various buffer overrun changes. -6. Fix mountd to check the duplicated entry in rmtab. -7. Change exportfs to ignore warnings for "-r". -8. Fix showmount -e. - -Changes from knfsd-980922: - -1. nfsd-2.1.121-4.patch from G. Allen Morris III (gam3@acm.org). -2. Make async as default for export. It matches the user space NFS - server. - -Changes from knfsd-980920: - -1. Add NFS mount version flags to mountd. Change rc.nfsd to disable - NFS V3 for mountd. -2. Fix client hostname. -3. rc.nfsd runs kexportfs with -r instead of -a for restart and reload. - -Changes from knfsd-980915: - -1. There is a knsfd quota patch for Linux 2.1.1xx, quota-2.1.1xx.diff. - It is only tested on linux 2.1.122. -2. The submount pathname is removed from the xtab file. -3. rc.nfsd runs kexportfs with -r instead of -a for start. -4. Fix kshowmount -e. -5. Fix hostname matching. -6. Fix compiling on libc 5. - -Changes from knfsd-980910: - -1. nfsd-2.1.121-3.patch from G. Allen Morris III (gam3@acm.org). -2. A new flag, -r, for exportfs. -3. Don't put an entry in xtab if kernel rejects it. -4. Use the official hostname when checking if 2 hostnames are the same. -5. Allow submounts. - -It is available at - -ftp://ftp.varesearch.com/pub/support/hjl/knfsd/knfsd-1.4.7.tar.gz -ftp://ftp.varesearch.com/pub/support/hjl/knfsd/knfsd-1.4.6-1.4.7.diff.gz -ftp://ftp.kernel.org/pub/linux/devel/gcc/knfsd-1.4.7.tar.gz -ftp://ftp.kernel.org/pub/linux/devel/gcc/knfsd-1.4.6-1.4.7.diff.gz - -You have to apply the patch, locks-2.2.3.diff, to the Linux kernel -first. It fixes quite some file lock bugs. That patch is against Linux -2.2.3. If your kernel is different, you have to apply it by hand. - -nfsd-2.2.3-1.patch is a new knfsd patch against linux 2.2.3 from -"G. Allen Morris III" (gam3@acm.org). It works for me on x86 and alpha. -It is needed for the none-Linux NFS clients. You can get Allen's -current patch from - -http://www.CSUA.Berkeley.EDU/~gam3/knfsd/ - -nfsd-2.2.7-3.patch is based on nfsd-2.2.3-1.patch for Linux 2.2.7. If -you use Linux 2.2.7, you should apply nfsd-2.2.7-3.patch instead of -nfsd-2.2.3-1.patch. Please don't use any other patches included here -for Linux 2.2.7. For other kernel versions, you may have to apply it -by hand. - -nfsd-2.2.7-2.lockd.patch is also necessary to start lockd independent -of nfs and nfsd. - -To compile, just do - -# ./configure -# make - -Makefile will try to determine which C library you are using and compile -this package accordingly. - -# make install - -will install the knfsd binaries. You have to install a knfs start up -script by hand. There is a new rc.nfsd in etc. I use it for both the -user-space nfsd and the kernel nfsd. - -There is one RPM spec file, knfs.spec, which is for a Linux system -based on Linux 2.2 without support for Linux 2.0. You also need -knfsd-1.4.6.tar.gz to create the knfsd RPMs. - -Thanks. - -H.J. -hjl@lucon.org -08/14/99 diff --git a/nfs-utils-2.5.2/linux-nfs/README b/nfs-utils-2.5.2/linux-nfs/README deleted file mode 100644 index b210c61..0000000 --- a/nfs-utils-2.5.2/linux-nfs/README +++ /dev/null @@ -1,56 +0,0 @@ - -This package contains a greatly revised NFS implementation for Linux -along with the necessary daemons and utilities. There are still several -features missing that I'd want to include, and there are some recent -improvements to the Linux NFS kernel client not reflected here (notably -the attrtimeo fix). - -This thing has become much too large for me to handle all alone anymore. -Originally, I had planned to have most of the NFS implementation running -stably by August, so I could start to concentrate more on other jobs that -are currently in the queue (like updating the NAG). As it turned out, it -was much more work than I anticipated, and I fell short of my time goal. -I'm therefore looking for volunteers who would like to work with me on -finishing this package. Otherwise, this project could end up rusting in -the corner of some FTP site... - -Ideally, I would want to hand over parts of the source tree to other -hackers to maintain/enhance/etc. But that's not a requirement; if you -feel you don't have that much time, you can also contribute by picking -up one of the loose ends and finish what needs to be done (take a look -at the TODO file...) And then, you can also be plainly a tester. - -There's currently a mailing list for lockd development at NRAO -(lockd-statd@linux.nrao.edu --- mail majordomo@linux.nrao.edu to -subscribe). If Jeff agress, we could turn this into a general linux-nfs -mailing list. - - -Hope this covers about what I wanted to say, -Olaf - ------------------------------------------------------------------- - - - SOURCE TREE OVERVIEW - - - -support/ Support libraries for user-space programs - -support/nfs Generic library for nfsd utilities -support/export Manipulation of /etc/exports and /var/lib/nfs/{xtab,rmtab} - -utils/ Code for various user-space programs. -utils/exportfs Management of nfsd export table. -utils/mount Modified mount command to support NFS over TCP. -utils/mountd New rpc.mountd for kernel nfsd. -utils/nfsd New nfsd (just starts kernel nfsd). -utils/nfsstat Pretty-print NFS stats from /proc/net/rpc/nfs* -utils/rquotad Marco van Wieringen's rquotad -utils/showmount Rick Sladkey's showmount client -utils/statd Jeff Uphoff's rpc.statd. - -tools/ Support tools for developers/debuggers/testers -tools/rpcdebug This one sets/gets the debug flags for each of the kernel - modules. diff --git a/nfs-utils-2.5.2/linux-nfs/THANKS b/nfs-utils-2.5.2/linux-nfs/THANKS deleted file mode 100644 index 22a80dc..0000000 --- a/nfs-utils-2.5.2/linux-nfs/THANKS +++ /dev/null @@ -1,10 +0,0 @@ - - This piece of software owes a lot to all the people who - hacked on Linux NFS before me, most notably Rick Sladkey - and Donald Becker. - - I also wish to thank Holger Grothe for loaning me a hard - disk and a monitor to get my old 486 flying again so I have - a decentish test platform. - - Olaf diff --git a/nfs-utils-2.5.2/linux-nfs/TODO b/nfs-utils-2.5.2/linux-nfs/TODO deleted file mode 100644 index 3a439d4..0000000 --- a/nfs-utils-2.5.2/linux-nfs/TODO +++ /dev/null @@ -1,121 +0,0 @@ - -Todo/Status List for Linux-NFS - - * denotes to be done; - o denotes draft implementation, possibly commented out - - denotes done, - + denotes done and tested ------------------------------------------------------------------- - -RPC: - - * Server-side AUTH_DES authentication - -NFS: - - * stat() calls don't check whether the cached attrs are stil valid - (this is a problem in the VFS). - - NFS_ROOT stuff needs fixing. - o Swapping over NFS. - - Issues of swapout: - * Avoid recursion in low memory situations where - kmalloc may call try_to_swap_out etc ad inf. - * Don't do async I/O on swap files. - - For special-casing related to NFS swap I/O, flag swap file - semantics in inode->i_flags. In swapfile.c, change functions - to call readpage/writepage if available, otherwise proceed - as usual. - - - Write-back support. - * Disable page cache invalidation/flushing for locked file - regions. - - Directory caching (we now have page-sized dircache entries - which could easily be organized into a linked list). These - dircache pages come along as a linked list that can be copied - almost 1-to-1 into a dirent struct. If this is put into the - VFS, other remote fs's will also benefit. - - [Note: I just increased the readdir cache to hold more than - one directory. With this, the exclusive lock on readdir goes - away, too. With a larger cache, it may also be worth to think - about directory readahead...] - * Better lookup caching? - * When a read lock is present, don't time out attr cache or - page cache for that region. Likewise, if a write lock is present, - be lazy on write-back. - * Implement CTO. - - BUG: Invalidate readdir cache after remove/rename/unlink - * Automatic `mounting' when the server crosses mount points - transparently (some IRIX machines seem to do this when - using -nohide). - * NFSv3 support. This requires careful design to maximize - code sharing between NFSv2 and NFSv3. - * More robust rename handling (see comment before nfs_rename). - * Add Miquel's O_EXCL hack for file creation. - * Performance improvement: When a complete reply is received, and - the (async) task is woken up, don't put it on rpciod's scheduling - queue, but add it to a `fast scheduler queue.' The fast scheduler - could be a special handler that's registered on the tq_scheduler task - queue. This queue is fired by the kernel scheduler as soon as - the other bottom halves have been run. - - Note that implementing this for sync tasks is even trickier than - for async tasks, because you have to make sure you do the right - thing in rpc_sleep_on(). - * writeback of writable mmaps. Dirty pages are not subject to - writeback scheduling. Also, msync should make sure pages are - written with O_SYNC on. - - -nfsd: - - * uid/gid mapping, and rpc.ugidd support - - Don't read/write a file that might have mandatory locks. - * Implement secure/kerberos export options (take care of lockd - fopen() calls--most clients seem to use NULL creds for lockd). - - there's a bug in readdir wrt large directories. Try mounting - the linux source tree and do an ls on include/linux... - * Support for UNIX socket creation. - * Someone should look over the error return codes. I tend to - mix up EPERM and EACCES. - * NFSv3 support. - - Refuse to look up inodes in procfs (security issues). - o Delayed writes (delay syncing of file data when nfsd handles - several write requests for the same file concurrently). - (Draft - see nfsd_write in fs/nfsd/write.c. Needs benchmarking). - * Faster read operations (single copy): mmap the file region - to be read into VM, and pass the VMA to the xdr routines - which pass the region's VM address into sock->ops->writemsg. - This copies the file data directly from the page cache into - the network buffer. - Release the vma region after encoding. - * Faster write operations (single copy, with IPv6 net layout): - Get the unfragmented UDP datagram, pull the header and - do normal processing. Then mmap the file, copy the write data, - and release VMA. - - Clear setuid/setgid bit after write(). - * Quota support. - -lockd: - - * Server should run on privileged port. - * Testing reclaim support. - * HP lockd accepts our GRANT_MSG callback and passes on the grant - to the blocking process, but doesn't reply with a GRANT_RES. - It's not clear to me why it would do this. - * Unregister hosts (SM_UNMON) with rpc.statd when appropriate. - -mountd - - * Unregister service from portmapper upon exit/SIGTERM - -mount - - * If available, use version 3 of the mount protocol and - obtain pathconf data (fill in data->bsize). - -documentation: - - - Manpages need to be written diff --git a/nfs-utils-2.5.2/nfs.conf b/nfs-utils-2.5.2/nfs.conf deleted file mode 100644 index 186a5b1..0000000 --- a/nfs-utils-2.5.2/nfs.conf +++ /dev/null @@ -1,86 +0,0 @@ -# -# This is a general configuration for the -# NFS daemons and tools -# -[general] -# pipefs-directory=/var/lib/nfs/rpc_pipefs -# -[exports] -# rootdir=/export -# -[exportfs] -# debug=0 -# -[gssd] -# verbosity=0 -# rpc-verbosity=0 -# use-memcache=0 -# use-machine-creds=1 -# use-gss-proxy=0 -# avoid-dns=1 -# limit-to-legacy-enctypes=0 -# context-timeout=0 -# rpc-timeout=5 -# keytab-file=/etc/krb5.keytab -# cred-cache-directory= -# preferred-realm= -# -[lockd] -# port=0 -# udp-port=0 -# -[mountd] -# debug=0 -# manage-gids=n -# descriptors=0 -# port=0 -# threads=1 -# reverse-lookup=n -# state-directory-path=/var/lib/nfs -# ha-callout= -# -[nfsdcld] -# debug=0 -# storagedir=/var/lib/nfs/nfsdcld -# -[nfsdcltrack] -# debug=0 -# storagedir=/var/lib/nfs/nfsdcltrack -# -[nfsd] -# debug=0 -# threads=8 -# host= -# port=0 -# grace-time=90 -# lease-time=90 -# udp=n -# tcp=y -# vers2=n -# vers3=y -# vers4=y -# vers4.0=y -# vers4.1=y -# vers4.2=y -# rdma=n -# rdma-port=20049 -# -[statd] -# debug=0 -# port=0 -# outgoing-port=0 -# name= -# state-directory-path=/var/lib/nfs/statd -# ha-callout= -# no-notify=0 -# -[sm-notify] -# debug=0 -# force=0 -# retry-time=900 -# outgoing-port= -# outgoing-addr= -# lift-grace=y -# -[svcgssd] -# principal= diff --git a/nfs-utils-2.5.2/support/Makefile.am b/nfs-utils-2.5.2/support/Makefile.am deleted file mode 100644 index c962d4d..0000000 --- a/nfs-utils-2.5.2/support/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -## Process this file with automake to produce Makefile.in - -OPTDIRS = - -if CONFIG_NFSV4 -OPTDIRS += nfsidmap -endif - -if CONFIG_JUNCTION -OPTDIRS += junction -endif - -SUBDIRS = export include misc nfs nsm $(OPTDIRS) - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/support/export/Makefile.am b/nfs-utils-2.5.2/support/export/Makefile.am deleted file mode 100644 index 13f7a49..0000000 --- a/nfs-utils-2.5.2/support/export/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -## Process this file with automake to produce Makefile.in - - -GENFILES_CLNT = mount_clnt.c -GENFILES_XDR = mount_xdr.c -GENFILES_H = mount.h - -GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) - -EXTRA_DIST = mount.x - -noinst_LIBRARIES = libexport.a -libexport_a_SOURCES = client.c export.c hostname.c \ - xtab.c mount_clnt.c mount_xdr.c -BUILT_SOURCES = $(GENFILES) - -noinst_HEADERS = mount.h - -dist-hook: - for f in $(GENFILES); do \ - rm ${distdir}/$$f; \ - done - -if CONFIG_RPCGEN -RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen -$(RPCGEN): - make -C $(top_srcdir)/tools/rpcgen all -else -RPCGEN = @RPCGEN_PATH@ -endif - -$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -l -o $@ $< - -$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -c -i 0 -o $@ $< - -$(GENFILES_H): %.h: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -h -o $@ $< - rm -f $(top_builddir)/support/include/mount.h - $(LN_S) ../export/mount.h $(top_builddir)/support/include/mount.h - -MAINTAINERCLEANFILES = Makefile.in - -CLEANFILES = $(GENFILES) $(top_builddir)/support/include/mount.h diff --git a/nfs-utils-2.5.2/support/export/client.c b/nfs-utils-2.5.2/support/export/client.c deleted file mode 100644 index ea4f89d..0000000 --- a/nfs-utils-2.5.2/support/export/client.c +++ /dev/null @@ -1,797 +0,0 @@ -/* - * support/export/client.c - * - * Maintain list of nfsd clients. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "misc.h" -#include "nfslib.h" -#include "exportfs.h" - -/* netgroup stuff never seems to be defined in any header file. Linux is - * not alone in this. - */ -#if !defined(__GLIBC__) || __GLIBC__ < 2 -extern int innetgr(char *netgr, char *host, char *, char *); -#endif - -static char *add_name(char *old, const char *add); - -nfs_client *clientlist[MCL_MAXTYPES] = { NULL, }; - - -static void -init_addrlist(nfs_client *clp, const struct addrinfo *ai) -{ - int i; - - if (ai == NULL) - return; - - for (i = 0; (ai != NULL) && (i < NFSCLNT_ADDRMAX); i++) { - set_addrlist(clp, i, ai->ai_addr); - ai = ai->ai_next; - } - - clp->m_naddr = i; -} - -static void -client_free(nfs_client *clp) -{ - free(clp->m_hostname); - free(clp); -} - -static int -init_netmask4(nfs_client *clp, const char *slash) -{ - struct sockaddr_in sin = { - .sin_family = AF_INET, - }; - uint32_t shift; - - /* - * Decide what kind of netmask was specified. If there's - * no '/' present, assume the netmask is all ones. If - * there is a '/' and at least one '.', look for a spelled- - * out netmask. Otherwise, assume it was a prefixlen. - */ - if (slash == NULL) - shift = 0; - else { - unsigned long prefixlen; - - if (strchr(slash + 1, '.') != NULL) { - if (inet_pton(AF_INET, slash + 1, - &sin.sin_addr.s_addr) == 0) - goto out_badmask; - set_addrlist_in(clp, 1, &sin); - return 1; - } else { - char *endptr; - - prefixlen = strtoul(slash + 1, &endptr, 10); - if (*endptr != '\0' && prefixlen != ULONG_MAX && - errno != ERANGE) - goto out_badprefix; - } - if (prefixlen > 32) - goto out_badprefix; - shift = 32 - (uint32_t)prefixlen; - } - - /* - * Now construct the full netmask bitmask in a sockaddr_in, - * and plant it in the nfs_client record. - */ - sin.sin_addr.s_addr = htonl((uint32_t)~0 << shift); - set_addrlist_in(clp, 1, &sin); - - return 1; - -out_badmask: - xlog(L_ERROR, "Invalid netmask `%s' for %s", slash + 1, clp->m_hostname); - return 0; - -out_badprefix: - xlog(L_ERROR, "Invalid prefix `%s' for %s", slash + 1, clp->m_hostname); - return 0; -} - -#ifdef IPV6_SUPPORTED -static int -init_netmask6(nfs_client *clp, const char *slash) -{ - struct sockaddr_in6 sin6 = { - .sin6_family = AF_INET6, - }; - unsigned long prefixlen; - uint32_t shift; - int i; - - /* - * Decide what kind of netmask was specified. If there's - * no '/' present, assume the netmask is all ones. If - * there is a '/' and at least one ':', look for a spelled- - * out netmask. Otherwise, assume it was a prefixlen. - */ - if (slash == NULL) - prefixlen = 128; - else { - if (strchr(slash + 1, ':') != NULL) { - if (!inet_pton(AF_INET6, slash + 1, &sin6.sin6_addr)) - goto out_badmask; - set_addrlist_in6(clp, 1, &sin6); - return 1; - } else { - char *endptr; - - prefixlen = strtoul(slash + 1, &endptr, 10); - if (*endptr != '\0' && prefixlen != ULONG_MAX && - errno != ERANGE) - goto out_badprefix; - } - if (prefixlen > 128) - goto out_badprefix; - } - - /* - * Now construct the full netmask bitmask in a sockaddr_in6, - * and plant it in the nfs_client record. - */ - for (i = 0; prefixlen > 32; i++) { - sin6.sin6_addr.s6_addr32[i] = 0xffffffff; - prefixlen -= 32; - } - shift = 32 - (uint32_t)prefixlen; - sin6.sin6_addr.s6_addr32[i] = htonl((uint32_t)~0 << shift); - set_addrlist_in6(clp, 1, &sin6); - - return 1; - -out_badmask: - xlog(L_ERROR, "Invalid netmask `%s' for %s", slash + 1, clp->m_hostname); - return 0; - -out_badprefix: - xlog(L_ERROR, "Invalid prefix `%s' for %s", slash + 1, clp->m_hostname); - return 0; -} -#else /* IPV6_SUPPORTED */ -static int -init_netmask6(nfs_client *UNUSED(clp), const char *UNUSED(slash)) -{ - return 0; -} -#endif /* IPV6_SUPPORTED */ - -/* - * Parse the network mask for M_SUBNETWORK type clients. - * - * Return TRUE if successful, or FALSE if some error occurred. - */ -static int -init_subnetwork(nfs_client *clp) -{ - struct addrinfo *ai; - sa_family_t family; - int result = 0; - char *slash; - - slash = strchr(clp->m_hostname, '/'); - if (slash != NULL) { - *slash = '\0'; - ai = host_pton(clp->m_hostname); - *slash = '/'; - } else - ai = host_pton(clp->m_hostname); - if (ai == NULL) { - xlog(L_ERROR, "Invalid IP address %s", clp->m_hostname); - return result; - } - - set_addrlist(clp, 0, ai->ai_addr); - family = ai->ai_addr->sa_family; - - nfs_freeaddrinfo(ai); - - switch (family) { - case AF_INET: - result = init_netmask4(clp, slash); - break; - case AF_INET6: - result = init_netmask6(clp, slash); - break; - default: - xlog(L_ERROR, "Unsupported address family for %s", - clp->m_hostname); - } - - return result; -} - -static int -client_init(nfs_client *clp, const char *hname, const struct addrinfo *ai) -{ - clp->m_hostname = strdup(hname); - if (clp->m_hostname == NULL) - return 0; - - clp->m_exported = 0; - clp->m_count = 0; - clp->m_naddr = 0; - - if (clp->m_type == MCL_SUBNETWORK) - return init_subnetwork(clp); - - init_addrlist(clp, ai); - return 1; -} - -static void -client_add(nfs_client *clp) -{ - nfs_client **cpp; - - cpp = &clientlist[clp->m_type]; - while (*cpp != NULL) - cpp = &((*cpp)->m_next); - clp->m_next = NULL; - *cpp = clp; -} - -/** - * client_lookup - look for @hname in our list of cached nfs_clients - * @hname: '\0'-terminated ASCII string containing hostname to look for - * @canonical: if set, @hname is known to be canonical DNS name - * - * Returns pointer to a matching or freshly created nfs_client. NULL - * is returned if some problem occurs. - */ -nfs_client * -client_lookup(char *hname, int canonical) -{ - nfs_client *clp = NULL; - int htype; - struct addrinfo *ai = NULL; - - htype = client_gettype(hname); - - if (htype == MCL_FQDN && !canonical) { - ai = host_addrinfo(hname); - if (!ai) { - xlog(L_WARNING, "Failed to resolve %s", hname); - goto out; - } - hname = ai->ai_canonname; - - for (clp = clientlist[htype]; clp; clp = clp->m_next) - if (client_check(clp, ai)) - break; - } else { - for (clp = clientlist[htype]; clp; clp = clp->m_next) { - if (strcasecmp(hname, clp->m_hostname)==0) - break; - } - } - - if (clp == NULL) { - clp = calloc(1, sizeof(*clp)); - if (clp == NULL) - goto out; - clp->m_type = htype; - if (!client_init(clp, hname, NULL)) { - client_free(clp); - clp = NULL; - goto out; - } - client_add(clp); - } - - if (htype == MCL_FQDN && clp->m_naddr == 0) - init_addrlist(clp, ai); - -out: - nfs_freeaddrinfo(ai); - return clp; -} - -/** - * client_dup - create a copy of an nfs_client - * @clp: pointer to nfs_client to copy - * @ai: pointer to addrinfo used to initialize the new client's addrlist - * - * Returns a dynamically allocated nfs_client if successful, or - * NULL if some problem occurs. Caller must free the returned - * nfs_client with free(3). - */ -nfs_client * -client_dup(const nfs_client *clp, const struct addrinfo *ai) -{ - nfs_client *new; - - new = (nfs_client *)malloc(sizeof(*new)); - if (new == NULL) - return NULL; - memcpy(new, clp, sizeof(*new)); - new->m_type = MCL_FQDN; - new->m_hostname = NULL; - - if (!client_init(new, ai->ai_canonname, ai)) { - client_free(new); - return NULL; - } - client_add(new); - return new; -} - -/** - * client_release - drop a reference to an nfs_client record - * - */ -void -client_release(nfs_client *clp) -{ - if (clp->m_count <= 0) - xlog(L_FATAL, "client_free: m_count <= 0!"); - clp->m_count--; -} - -/** - * client_freeall - deallocate all nfs_client records - * - */ -void -client_freeall(void) -{ - nfs_client *clp, **head; - int i; - - for (i = 0; i < MCL_MAXTYPES; i++) { - head = clientlist + i; - while (*head) { - *head = (clp = *head)->m_next; - client_free(clp); - } - } -} - -/** - * client_resolve - look up an IP address - * @sap: pointer to socket address to resolve - * - * Returns an addrinfo structure, or NULL if some problem occurred. - * Caller must free the result with freeaddrinfo(3). - */ -struct addrinfo * -client_resolve(const struct sockaddr *sap) -{ - struct addrinfo *ai = NULL; - - if (clientlist[MCL_WILDCARD] || clientlist[MCL_NETGROUP]) - ai = host_reliable_addrinfo(sap); - if (ai == NULL) - ai = host_numeric_addrinfo(sap); - - return ai; -} - -/** - * client_compose - Make a list of cached hostnames that match an IP address - * @ai: pointer to addrinfo containing IP address information to match - * - * Gather all known client hostnames that match the IP address, and sort - * the result into a comma-separated list. - * - * Returns a '\0'-terminated ASCII string containing a comma-separated - * sorted list of client hostnames, or NULL if no client records matched - * the IP address or memory could not be allocated. Caller must free the - * returned string with free(3). - */ -char * -client_compose(const struct addrinfo *ai) -{ - char *name = NULL; - int i; - - for (i = 0 ; i < MCL_MAXTYPES; i++) { - nfs_client *clp; - for (clp = clientlist[i]; clp ; clp = clp->m_next) { - if (!client_check(clp, ai)) - continue; - name = add_name(name, clp->m_hostname); - } - } - return name; -} - -/** - * client_member - check if @name is contained in the list @client - * @client: '\0'-terminated ASCII string containing - * comma-separated list of hostnames - * @name: '\0'-terminated ASCII string containing hostname to look for - * - * Returns 1 if @name was found in @client, otherwise zero is returned. - */ -int -client_member(const char *client, const char *name) -{ - size_t l = strlen(name); - - while (*client) { - if (strncmp(client, name, l) == 0 && - (client[l] == ',' || client[l] == '\0')) - return 1; - client = strchr(client, ','); - if (client == NULL) - return 0; - client++; - } - return 0; -} - -static int -name_cmp(const char *a, const char *b) -{ - /* compare strings a and b, but only upto ',' in a */ - while (*a && *b && *a != ',' && *a == *b) - a++, b++; - if (!*b && (!*a || *a == ',')) - return 0; - if (!*b) return 1; - if (!*a || *a == ',') return -1; - return *a - *b; -} - -static char * -add_name(char *old, const char *add) -{ - size_t len = strlen(add) + 2; - char *new; - char *cp; - if (old) len += strlen(old); - - new = malloc(len); - if (!new) { - free(old); - return NULL; - } - cp = old; - while (cp && *cp && name_cmp(cp, add) < 0) { - /* step cp forward over a name */ - char *e = strchr(cp, ','); - if (e) - cp = e+1; - else - cp = cp + strlen(cp); - } - len = cp-old; - if (old && len > 0) { - strncpy(new, old, len); - new[cp-old] = 0; - } else { - new[0] = 0; - } - if (cp != old && !*cp) - strcat(new, ","); - strcat(new, add); - if (cp && *cp) { - strcat(new, ","); - strcat(new, cp); - } - free(old); - return new; -} - -/* - * Check each address listed in @ai against each address - * stored in @clp. Return 1 if a match is found, otherwise - * zero. - */ -static int -check_fqdn(const nfs_client *clp, const struct addrinfo *ai) -{ - int i; - - for (; ai; ai = ai->ai_next) - for (i = 0; i < clp->m_naddr; i++) - if (nfs_compare_sockaddr(ai->ai_addr, - get_addrlist(clp, i))) - return 1; - - return 0; -} - -static _Bool -mask_match(const uint32_t a, const uint32_t b, const uint32_t m) -{ - return ((a ^ b) & m) == 0; -} - -static int -check_subnet_v4(const struct sockaddr_in *address, - const struct sockaddr_in *mask, const struct addrinfo *ai) -{ - for (; ai; ai = ai->ai_next) { - struct sockaddr_in *sin = (struct sockaddr_in *)ai->ai_addr; - - if (sin->sin_family != AF_INET) - continue; - - if (mask_match(address->sin_addr.s_addr, - sin->sin_addr.s_addr, - mask->sin_addr.s_addr)) - return 1; - } - return 0; -} - -#ifdef IPV6_SUPPORTED -static int -check_subnet_v6(const struct sockaddr_in6 *address, - const struct sockaddr_in6 *mask, const struct addrinfo *ai) -{ - for (; ai; ai = ai->ai_next) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai->ai_addr; - - if (sin6->sin6_family != AF_INET6) - continue; - - if (mask_match(address->sin6_addr.s6_addr32[0], - sin6->sin6_addr.s6_addr32[0], - mask->sin6_addr.s6_addr32[0]) && - mask_match(address->sin6_addr.s6_addr32[1], - sin6->sin6_addr.s6_addr32[1], - mask->sin6_addr.s6_addr32[1]) && - mask_match(address->sin6_addr.s6_addr32[2], - sin6->sin6_addr.s6_addr32[2], - mask->sin6_addr.s6_addr32[2]) && - mask_match(address->sin6_addr.s6_addr32[3], - sin6->sin6_addr.s6_addr32[3], - mask->sin6_addr.s6_addr32[3])) - return 1; - } - return 0; -} -#else /* !IPV6_SUPPORTED */ -static int -check_subnet_v6(const struct sockaddr_in6 *UNUSED(address), - const struct sockaddr_in6 *UNUSED(mask), - const struct addrinfo *UNUSED(ai)) -{ - return 0; -} -#endif /* !IPV6_SUPPORTED */ - -/* - * Check each address listed in @ai against the subnetwork or - * host address stored in @clp. Return 1 if an address in @hp - * matches the host address stored in @clp, otherwise zero. - */ -static int -check_subnetwork(const nfs_client *clp, const struct addrinfo *ai) -{ - switch (get_addrlist(clp, 0)->sa_family) { - case AF_INET: - return check_subnet_v4(get_addrlist_in(clp, 0), - get_addrlist_in(clp, 1), ai); - case AF_INET6: - return check_subnet_v6(get_addrlist_in6(clp, 0), - get_addrlist_in6(clp, 1), ai); - } - - return 0; -} - -/* - * Check if a wildcard nfs_client record matches the canonical name - * or the aliases of a host. Return 1 if a match is found, otherwise - * zero. - */ -static int -check_wildcard(const nfs_client *clp, const struct addrinfo *ai) -{ - char *hname, *cname = clp->m_hostname; - struct hostent *hp; - char **ap; - int match; - - match = 0; - - hname = host_canonname(ai->ai_addr); - if (hname == NULL) - goto out; - - if (wildmat(hname, cname)) { - match = 1; - goto out; - } - - /* See if hname aliases listed in /etc/hosts or nis[+] - * match the requested wildcard */ - hp = gethostbyname(hname); - if (hp != NULL) { - for (ap = hp->h_aliases; *ap; ap++) - if (wildmat(*ap, cname)) { - match = 1; - goto out; - } - } - -out: - free(hname); - return match; -} - -/* - * Check if @ai's hostname or aliases fall in a given netgroup. - * Return 1 if @ai represents a host in the netgroup, otherwise - * zero. - */ -#ifdef HAVE_INNETGR -static int -check_netgroup(const nfs_client *clp, const struct addrinfo *ai) -{ - const char *netgroup = clp->m_hostname + 1; - struct addrinfo *tmp = NULL; - struct hostent *hp; - char *dot, *hname, *ip; - int i, match; - - match = 0; - - hname = host_canonname(ai->ai_addr); - if (hname == NULL) - goto out; - - /* First, try to match the hostname without - * splitting off the domain */ - if (innetgr(netgroup, hname, NULL, NULL)) { - match = 1; - goto out; - } - - /* See if hname aliases listed in /etc/hosts or nis[+] - * match the requested netgroup */ - hp = gethostbyname(hname); - if (hp != NULL) { - for (i = 0; hp->h_aliases[i]; i++) - if (innetgr(netgroup, hp->h_aliases[i], NULL, NULL)) { - match = 1; - goto out; - } - } - - /* If hname happens to be an IP address, convert it - * to a the canonical DNS name bound to this address. */ - tmp = host_pton(hname); - if (tmp != NULL) { - char *cname = host_canonname(tmp->ai_addr); - nfs_freeaddrinfo(tmp); - - /* The resulting FQDN may be in our netgroup. */ - if (cname != NULL) { - free(hname); - hname = cname; - if (innetgr(netgroup, hname, NULL, NULL)) { - match = 1; - goto out; - } - } - } - - /* check whether the IP itself is in the netgroup */ - ip = calloc(INET6_ADDRSTRLEN, 1); - if (inet_ntop(ai->ai_family, &(((struct sockaddr_in *)ai->ai_addr)->sin_addr), ip, INET6_ADDRSTRLEN) == ip) { - if (innetgr(netgroup, ip, NULL, NULL)) { - free(hname); - hname = ip; - match = 1; - goto out; - } - } - free(ip); - - /* Okay, strip off the domain (if we have one) */ - dot = strchr(hname, '.'); - if (dot == NULL) - goto out; - - *dot = '\0'; - match = innetgr(netgroup, hname, NULL, NULL); - -out: - free(hname); - return match; -} -#else /* !HAVE_INNETGR */ -static int -check_netgroup(__attribute__((unused)) const nfs_client *clp, - __attribute__((unused)) const struct addrinfo *ai) -{ - return 0; -} -#endif /* !HAVE_INNETGR */ - -/** - * client_check - check if IP address information matches a cached nfs_client - * @clp: pointer to a cached nfs_client record - * @ai: pointer to addrinfo to compare it with - * - * Returns 1 if the address information matches the cached nfs_client, - * otherwise zero. - */ -int -client_check(const nfs_client *clp, const struct addrinfo *ai) -{ - switch (clp->m_type) { - case MCL_FQDN: - return check_fqdn(clp, ai); - case MCL_SUBNETWORK: - return check_subnetwork(clp, ai); - case MCL_WILDCARD: - return check_wildcard(clp, ai); - case MCL_NETGROUP: - return check_netgroup(clp, ai); - case MCL_ANONYMOUS: - return 1; - case MCL_GSS: - return 0; - default: - xlog(D_GENERAL, "%s: unrecognized client type: %d", - __func__, clp->m_type); - } - - return 0; -} - -/** - * client_gettype - determine type of nfs_client given an identifier - * @ident: '\0'-terminated ASCII string containing a client identifier - * - * Returns the type of nfs_client record that would be used for - * this client. - */ -int -client_gettype(char *ident) -{ - char *sp; - - if (ident[0] == '\0' || strcmp(ident, "*")==0) - return MCL_ANONYMOUS; - if (strncmp(ident, "gss/", 4) == 0) - return MCL_GSS; - if (ident[0] == '@') { -#ifndef HAVE_INNETGR - xlog(L_WARNING, "netgroup support not compiled in"); -#endif - return MCL_NETGROUP; - } - for (sp = ident; *sp; sp++) { - if (*sp == '*' || *sp == '?' || *sp == '[') - return MCL_WILDCARD; - if (*sp == '/') - return MCL_SUBNETWORK; - if (*sp == '\\' && sp[1]) - sp++; - } - - return MCL_FQDN; -} diff --git a/nfs-utils-2.5.2/support/export/export.c b/nfs-utils-2.5.2/support/export/export.c deleted file mode 100644 index c753f68..0000000 --- a/nfs-utils-2.5.2/support/export/export.c +++ /dev/null @@ -1,422 +0,0 @@ -/* - * support/export/export.c - * - * Maintain list of exported file systems. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include "xmalloc.h" -#include "nfslib.h" -#include "exportfs.h" -#include "nfsd_path.h" -#include "xlog.h" - -exp_hash_table exportlist[MCL_MAXTYPES] = {{NULL, {{NULL,NULL}, }}, }; -static int export_hash(char *); - -static void export_init(nfs_export *exp, nfs_client *clp, - struct exportent *nep); -static void export_add(nfs_export *exp); -static int export_check(const nfs_export *exp, const struct addrinfo *ai, - const char *path); - -/* Return a real path for the export. */ -static void -exportent_mkrealpath(struct exportent *eep) -{ - const char *chroot = nfsd_path_nfsd_rootdir(); - char *ret = NULL; - - if (chroot) { - char buffer[PATH_MAX]; - if (realpath(chroot, buffer)) - ret = nfsd_path_prepend_dir(buffer, eep->e_path); - else - xlog(D_GENERAL, "%s: failed to resolve path %s: %m", - __func__, chroot); - } - if (!ret) - ret = xstrdup(eep->e_path); - eep->e_realpath = ret; -} - -char * -exportent_realpath(struct exportent *eep) -{ - if (!eep->e_realpath) - exportent_mkrealpath(eep); - return eep->e_realpath; -} - -void -exportent_release(struct exportent *eep) -{ - xfree(eep->e_squids); - xfree(eep->e_sqgids); - free(eep->e_mountpoint); - free(eep->e_fslocdata); - free(eep->e_uuid); - xfree(eep->e_hostname); - xfree(eep->e_realpath); -} - -static void -export_free(nfs_export *exp) -{ - exportent_release(&exp->m_export); - xfree(exp); -} - -static void warn_duplicated_exports(nfs_export *exp, struct exportent *eep) -{ - if (exp->m_export.e_flags != eep->e_flags) { - xlog(L_ERROR, "incompatible duplicated export entries:"); - xlog(L_ERROR, "\t%s:%s (0x%x) [IGNORED]", eep->e_hostname, - eep->e_path, eep->e_flags); - xlog(L_ERROR, "\t%s:%s (0x%x)", exp->m_export.e_hostname, - exp->m_export.e_path, exp->m_export.e_flags); - } else { - xlog(L_ERROR, "duplicated export entries:"); - xlog(L_ERROR, "\t%s:%s", eep->e_hostname, eep->e_path); - xlog(L_ERROR, "\t%s:%s", exp->m_export.e_hostname, - exp->m_export.e_path); - } -} - -/** - * export_read - read entries from /etc/exports - * @fname: name of file to read from - * @ignore_hosts: don't check validity of host names - * - * Returns number of read entries. - * @ignore_hosts can be set when the host names won't be used - * and when getting delays or errors due to problems with - * hostname looking is not acceptable. - */ -int -export_read(char *fname, int ignore_hosts) -{ - struct exportent *eep; - nfs_export *exp; - - int volumes = 0; - - setexportent(fname, "r"); - while ((eep = getexportent(0,1)) != NULL) { - exp = export_lookup(eep->e_hostname, eep->e_path, ignore_hosts); - if (!exp) { - if (export_create(eep, 0)) - /* possible complaints already logged */ - volumes++; - } - else - warn_duplicated_exports(exp, eep); - } - endexportent(); - - return volumes; -} - -/** - * export_d_read - read entries from /etc/exports. - * @fname: name of directory to read from - * @ignore_hosts: don't check validity of host names - * - * Returns number of read entries. - * Based on mnt_table_parse_dir() in - * util-linux-ng/shlibs/mount/src/tab_parse.c - */ -int -export_d_read(const char *dname, int ignore_hosts) -{ - int n = 0, i; - struct dirent **namelist = NULL; - int volumes = 0; - - - n = scandir(dname, &namelist, NULL, versionsort); - if (n < 0) { - if (errno == ENOENT) - /* Silently return */ - return volumes; - xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno)); - } else if (n == 0) - return volumes; - - for (i = 0; i < n; i++) { - struct dirent *d = namelist[i]; - size_t namesz; - char fname[PATH_MAX + 1]; - int fname_len; - - - if (d->d_type != DT_UNKNOWN - && d->d_type != DT_REG - && d->d_type != DT_LNK) - continue; - if (*d->d_name == '.') - continue; - -#define _EXT_EXPORT_SIZ (sizeof(_EXT_EXPORT) - 1) - namesz = strlen(d->d_name); - if (!namesz - || namesz < _EXT_EXPORT_SIZ + 1 - || strcmp(d->d_name + (namesz - _EXT_EXPORT_SIZ), - _EXT_EXPORT)) - continue; - - fname_len = snprintf(fname, PATH_MAX +1, "%s/%s", dname, d->d_name); - if (fname_len > PATH_MAX) { - xlog(L_WARNING, "Too long file name: %s in %s", d->d_name, dname); - continue; - } - - volumes += export_read(fname, ignore_hosts); - } - - for (i = 0; i < n; i++) - free(namelist[i]); - free(namelist); - - return volumes; -} - -/** - * export_create - create an in-core nfs_export record from an export entry - * @xep: export entry to lookup - * @canonical: if set, e_hostname is known to be canonical DNS name - * - * Returns a freshly instantiated export record, or NULL if - * a problem occurred. - */ -nfs_export * -export_create(struct exportent *xep, int canonical) -{ - nfs_client *clp; - nfs_export *exp; - - if (!(clp = client_lookup(xep->e_hostname, canonical))) { - /* bad export entry; complaint already logged */ - return NULL; - } - exp = (nfs_export *) xmalloc(sizeof(*exp)); - export_init(exp, clp, xep); - export_add(exp); - - return exp; -} - -static void -export_init(nfs_export *exp, nfs_client *clp, struct exportent *nep) -{ - struct exportent *e = &exp->m_export; - - dupexportent(e, nep); - if (nep->e_hostname) - e->e_hostname = xstrdup(nep->e_hostname); - - exp->m_exported = 0; - exp->m_xtabent = 0; - exp->m_mayexport = 0; - exp->m_changed = 0; - exp->m_warned = 0; - exp->m_client = clp; - clp->m_count++; -} - -/* - * Duplicate exports data. The in-core export struct retains the - * original hostname from /etc/exports, while the in-core client struct - * gets the newly found FQDN. - */ -static nfs_export * -export_dup(nfs_export *exp, const struct addrinfo *ai) -{ - nfs_export *new; - nfs_client *clp; - - new = (nfs_export *) xmalloc(sizeof(*new)); - memcpy(new, exp, sizeof(*new)); - dupexportent(&new->m_export, &exp->m_export); - if (exp->m_export.e_hostname) - new->m_export.e_hostname = xstrdup(exp->m_export.e_hostname); - clp = client_dup(exp->m_client, ai); - if (clp == NULL) { - export_free(new); - return NULL; - } - clp->m_count++; - new->m_client = clp; - new->m_mayexport = exp->m_mayexport; - new->m_exported = 0; - new->m_xtabent = 0; - new->m_changed = 0; - new->m_warned = 0; - export_add(new); - - return new; -} - -static void -export_add(nfs_export *exp) -{ - exp_hash_table *p_tbl; - exp_hash_entry *p_hen; - nfs_export *p_next; - - int type = exp->m_client->m_type; - int pos; - - pos = export_hash(exp->m_export.e_path); - p_tbl = &(exportlist[type]); /* pointer to hash table */ - p_hen = &(p_tbl->entries[pos]); /* pointer to hash table entry */ - - if (!(p_hen->p_first)) { /* hash table entry is empty */ - p_hen->p_first = exp; - p_hen->p_last = exp; - - exp->m_next = p_tbl->p_head; - p_tbl->p_head = exp; - } else { /* hash table entry is NOT empty */ - p_next = p_hen->p_last->m_next; - p_hen->p_last->m_next = exp; - exp->m_next = p_next; - p_hen->p_last = exp; - } -} - -/** - * export_find - find or create a suitable nfs_export for @ai and @path - * @ai: pointer to addrinfo for client - * @path: '\0'-terminated ASCII string containing export path - * - * Returns a pointer to nfs_export data matching @ai and @path, - * or NULL if an error occurs. - */ -nfs_export * -export_find(const struct addrinfo *ai, const char *path) -{ - nfs_export *exp; - int i; - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (!export_check(exp, ai, path)) - continue; - if (exp->m_client->m_type == MCL_FQDN) - return exp; - return export_dup(exp, ai); - } - } - - return NULL; -} - -/** - * export_lookup - search hash table for export entry - * @hname: '\0'-terminated ASCII string containing client hostname to look for - * @path: '\0'-terminated ASCII string containing export path to look for - * @canonical: if set, @hname is known to be canonical DNS name - * - * Returns a pointer to nfs_export record matching @hname and @path, - * or NULL if the export was not found. - */ -nfs_export * -export_lookup(char *hname, char *path, int canonical) -{ - nfs_client *clp; - nfs_export *exp; - exp_hash_entry *p_hen; - - int pos; - - clp = client_lookup(hname, canonical); - if(clp == NULL) - return NULL; - - pos = export_hash(path); - p_hen = &(exportlist[clp->m_type].entries[pos]); - for(exp = p_hen->p_first; exp && (exp != p_hen->p_last->m_next); - exp = exp->m_next) { - if (exp->m_client == clp && !strcmp(exp->m_export.e_path, path)) { - return exp; - } - } - return NULL; -} - -static int -export_check(const nfs_export *exp, const struct addrinfo *ai, const char *path) -{ - if (strcmp(path, exp->m_export.e_path)) - return 0; - - return client_check(exp->m_client, ai); -} - -/** - * export_freeall - deallocate all nfs_export records - * - */ -void -export_freeall(void) -{ - nfs_export *exp, *nxt; - int i, j; - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = nxt) { - nxt = exp->m_next; - client_release(exp->m_client); - export_free(exp); - } - for (j = 0; j < HASH_TABLE_SIZE; j++) { - exportlist[i].entries[j].p_first = NULL; - exportlist[i].entries[j].p_last = NULL; - } - exportlist[i].p_head = NULL; - } - client_freeall(); -} - -/* - * Compute and returns integer from string. - * Note: Its understood the smae integers can be same for - * different strings, but it should not matter. - */ -static unsigned int -strtoint(char *str) -{ - int i = 0; - unsigned int n = 0; - - while ( str[i] != '\0') { - n+=((int)str[i])*i; - i++; - } - return n; -} - -/* - * Hash function - */ -static int -export_hash(char *str) -{ - unsigned int num = strtoint(str); - - return num % HASH_TABLE_SIZE; -} diff --git a/nfs-utils-2.5.2/support/export/hostname.c b/nfs-utils-2.5.2/support/export/hostname.c deleted file mode 100644 index be4d7f6..0000000 --- a/nfs-utils-2.5.2/support/export/hostname.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright 2010 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "exportfs.h" - -/** - * host_ntop - generate presentation address given a sockaddr - * @sap: pointer to socket address - * @buf: working storage - * @buflen: size of @buf in bytes - * - * Returns a pointer to a @buf. - */ -#ifdef HAVE_GETNAMEINFO -char * -host_ntop(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - socklen_t salen = nfs_sockaddr_length(sap); - int error; - - memset(buf, 0, buflen); - - if (salen == 0) { - (void)strncpy(buf, "bad family", buflen - 1); - return buf; - } - - error = getnameinfo(sap, salen, buf, (socklen_t)buflen, - NULL, 0, NI_NUMERICHOST); - if (error != 0) { - buf[0] = '\0'; - (void)strncpy(buf, "bad address", buflen - 1); - } - - return buf; -} -#else /* !HAVE_GETNAMEINFO */ -char * -host_ntop(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)(char *)sap; - - memset(buf, 0, buflen); - - if (sin->sin_family != AF_INET) { - (void)strncpy(buf, "bad family", buflen - 1); - return buf; - } - - if (inet_ntop(AF_INET, &sin->sin_addr.s_addr, buf, buflen) != NULL) - return buf; - - buf[0] = '\0'; - (void)strncpy(buf, "bad address", buflen - 1); - return buf; -} -#endif /* !HAVE_GETNAMEINFO */ - -/** - * host_pton - return addrinfo for a given presentation address - * @paddr: pointer to a '\0'-terminated ASCII string containing an - * IP presentation address - * - * Returns address info structure, or NULL if an error occurs. Caller - * must free the returned structure with freeaddrinfo(3). - */ -__attribute__((__malloc__)) -struct addrinfo * -host_pton(const char *paddr) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { - /* don't return duplicates */ - .ai_protocol = (int)IPPROTO_UDP, - .ai_flags = AI_NUMERICHOST, - .ai_family = AF_UNSPEC, - }; - struct sockaddr_in sin; - int error, inet4; - - /* - * Although getaddrinfo(3) is easier to use and supports - * IPv6, it recognizes incomplete addresses like "10.4" - * as valid AF_INET addresses. It also accepts presentation - * addresses that end with a blank. - * - * inet_pton(3) is much stricter. Use it to be certain we - * have a real AF_INET presentation address, before invoking - * getaddrinfo(3) to generate the full addrinfo list. - */ - if (paddr == NULL) { - xlog(D_GENERAL, "%s: passed a NULL presentation address", - __func__); - return NULL; - } - inet4 = 1; - if (inet_pton(AF_INET, paddr, &sin.sin_addr) == 0) - inet4 = 0; - - error = getaddrinfo(paddr, NULL, &hint, &ai); - switch (error) { - case 0: - if (!inet4 && ai->ai_addr->sa_family == AF_INET) { - xlog(D_GENERAL, "%s: failed to convert %s", - __func__, paddr); - nfs_freeaddrinfo(ai); - break; - } - return ai; - case EAI_NONAME: - break; - case EAI_SYSTEM: - xlog(L_WARNING, "%s: failed to convert %s: (%d) %m", - __func__, paddr, errno); - break; - default: - xlog(L_WARNING, "%s: failed to convert %s: %s", - __func__, paddr, gai_strerror(error)); - break; - } - - return NULL; -} - -/** - * host_addrinfo - return addrinfo for a given hostname - * @hostname: pointer to a '\0'-terminated ASCII string containing a hostname - * - * Returns address info structure with ai_canonname filled in, or NULL - * if no information is available for @hostname. Caller must free the - * returned structure with freeaddrinfo(3). - */ -__attribute__((__malloc__)) -struct addrinfo * -host_addrinfo(const char *hostname) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { -#ifdef IPV6_SUPPORTED - .ai_family = AF_UNSPEC, -#else - .ai_family = AF_INET, -#endif - /* don't return duplicates */ - .ai_protocol = (int)IPPROTO_UDP, - .ai_flags = AI_CANONNAME, - }; - int error; - - error = getaddrinfo(hostname, NULL, &hint, &ai); - switch (error) { - case 0: - return ai; - case EAI_SYSTEM: - xlog(D_PARSE, "%s: failed to resolve %s: (%d) %m", - __func__, hostname, errno); - break; - default: - xlog(D_PARSE, "%s: failed to resolve %s: %s", - __func__, hostname, gai_strerror(error)); - break; - } - - return NULL; -} - -/** - * host_canonname - return canonical hostname bound to an address - * @sap: pointer to socket address to look up - * - * Discover the canonical hostname associated with the given socket - * address. The host's reverse mapping is verified in the process. - * - * Returns a '\0'-terminated ASCII string containing a hostname, or - * NULL if no hostname can be found for @sap. Caller must free - * the string. - */ -#ifdef HAVE_GETNAMEINFO -__attribute__((__malloc__)) -char * -host_canonname(const struct sockaddr *sap) -{ - socklen_t salen = nfs_sockaddr_length(sap); - char buf[NI_MAXHOST]; - int error; - - if (salen == 0) { - xlog(D_GENERAL, "%s: unsupported address family %d", - __func__, sap->sa_family); - return NULL; - } - - memset(buf, 0, sizeof(buf)); - error = getnameinfo(sap, salen, buf, (socklen_t)sizeof(buf), - NULL, 0, NI_NAMEREQD); - switch (error) { - case 0: - break; - case EAI_SYSTEM: - xlog(D_GENERAL, "%s: getnameinfo(3) failed: (%d) %m", - __func__, errno); - return NULL; - default: - (void)getnameinfo(sap, salen, buf, (socklen_t)sizeof(buf), - NULL, 0, NI_NUMERICHOST); - xlog(D_PARSE, "%s: failed to resolve %s: %s", - __func__, buf, gai_strerror(error)); - return NULL; - } - - return strdup(buf); -} -#else /* !HAVE_GETNAMEINFO */ -__attribute__((__malloc__)) -char * -host_canonname(const struct sockaddr *sap) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)(char *)sap; - const struct in_addr *addr = &sin->sin_addr; - struct hostent *hp; - - if (sap->sa_family != AF_INET) - return NULL; - - hp = gethostbyaddr(addr, (socklen_t)sizeof(addr), AF_INET); - if (hp == NULL) - return NULL; - - return strdup(hp->h_name); -} -#endif /* !HAVE_GETNAMEINFO */ - -/** - * host_reliable_addrinfo - return addrinfo for a given address - * @sap: pointer to socket address to look up - * - * Reverse and forward lookups are performed to ensure the address has - * matching forward and reverse mappings. - * - * Returns addrinfo structure with just the provided address. If there - * is a problem with resolution or the resolved records don't match up - * properly then returns NULL. - * - * Caller must free the returned structure with freeaddrinfo(3). - */ -__attribute__((__malloc__)) -struct addrinfo * -host_reliable_addrinfo(const struct sockaddr *sap) -{ - struct addrinfo *ai, *a; - char *hostname; - - ai = NULL; - hostname = host_canonname(sap); - if (hostname == NULL) - goto out; - - ai = host_addrinfo(hostname); - free(hostname); - if (!ai) - goto out; - - /* make sure there's a matching address in the list */ - for (a = ai; a; a = a->ai_next) - if (nfs_compare_sockaddr(a->ai_addr, sap)) - break; - - nfs_freeaddrinfo(ai); - ai = NULL; - if (!a) - goto out; - - /* get addrinfo with just the original address */ - ai = host_numeric_addrinfo(sap); - -out: - return ai; -} - -/** - * host_numeric_addrinfo - return addrinfo without doing DNS queries - * @sap: pointer to socket address - * - * Returns address info structure, or NULL if an error occurred. - * Caller must free the returned structure with freeaddrinfo(3). - */ -#ifdef HAVE_GETNAMEINFO -__attribute__((__malloc__)) -struct addrinfo * -host_numeric_addrinfo(const struct sockaddr *sap) -{ - socklen_t salen = nfs_sockaddr_length(sap); - char buf[INET6_ADDRSTRLEN]; - int error; - - if (salen == 0) { - xlog(D_GENERAL, "%s: unsupported address family %d", - __func__, sap->sa_family); - return NULL; - } - - memset(buf, 0, sizeof(buf)); - error = getnameinfo(sap, salen, buf, (socklen_t)sizeof(buf), - NULL, 0, NI_NUMERICHOST); - switch (error) { - case 0: - break; - case EAI_SYSTEM: - xlog(D_GENERAL, "%s: getnameinfo(3) failed: (%d) %m", - __func__, errno); - return NULL; - default: - xlog(D_GENERAL, "%s: getnameinfo(3) failed: %s", - __func__, gai_strerror(error)); - return NULL; - } - - return host_pton(buf); -} -#else /* !HAVE_GETNAMEINFO */ -__attribute__((__malloc__)) -struct addrinfo * -host_numeric_addrinfo(const struct sockaddr *sap) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - const struct in_addr *addr = &sin->sin_addr; - char buf[INET_ADDRSTRLEN]; - - if (sap->sa_family != AF_INET) - return NULL; - - memset(buf, 0, sizeof(buf)); - if (inet_ntop(AF_INET, (char *)addr, buf, - (socklen_t)sizeof(buf)) == NULL) - return NULL; - - return host_pton(buf); -} -#endif /* !HAVE_GETNAMEINFO */ diff --git a/nfs-utils-2.5.2/support/export/mount.x b/nfs-utils-2.5.2/support/export/mount.x deleted file mode 100644 index 12fd841..0000000 --- a/nfs-utils-2.5.2/support/export/mount.x +++ /dev/null @@ -1,343 +0,0 @@ -%/* -% * Copyright (c) 2009, Sun Microsystems, Inc. -% * All rights reserved. -% * -% * Redistribution and use in source and binary forms, with or without -% * modification, are permitted provided that the following conditions are met: -% * - Redistributions of source code must retain the above copyright notice, -% * this list of conditions and the following disclaimer. -% * - Redistributions in binary form must reproduce the above copyright notice, -% * this list of conditions and the following disclaimer in the documentation -% * and/or other materials provided with the distribution. -% * - Neither the name of Sun Microsystems, Inc. nor the names of its -% * contributors may be used to endorse or promote products derived -% * from this software without specific prior written permission. -% * -% * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -% * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -% * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -% * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -% * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -% * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -% * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -% * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -% * POSSIBILITY OF SUCH DAMAGE. -% */ - -%/* -% * Copyright (c) 1985, 1990 by Sun Microsystems, Inc. -% */ -% -%/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ - -/* - * Protocol description for the mount program - */ - -#ifdef RPC_HDR -%#ifndef _rpcsvc_mount_h -%#define _rpcsvc_mount_h -%#include -#endif - -const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ -const MNTNAMLEN = 255; /* maximum bytes in a name argument */ -const FHSIZE = 32; /* size in bytes of a file handle */ - -/* - * The fhandle is the file handle that the server passes to the client. - * All file operations are done using the file handles to refer to a file - * or a directory. The file handle can contain whatever information the - * server needs to distinguish an individual file. - */ -typedef opaque fhandle[FHSIZE]; - -/* - * If a status of zero is returned, the call completed successfully, and - * a file handle for the directory follows. A non-zero status indicates - * some sort of error. The status corresponds with UNIX error numbers. - */ -union fhstatus switch (unsigned fhs_status) { -case 0: - fhandle fhs_fhandle; -default: - void; -}; - -/* - * The type dirpath is the pathname of a directory - */ -typedef string dirpath; - -/* - * The type name is used for arbitrary names (hostnames, groupnames) - */ -typedef string name; - -/* - * A list of who has what mounted - */ -typedef struct mountbody *mountlist; -struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; -}; - -/* - * A list of netgroups - */ -typedef struct groupnode *groups; -struct groupnode { - name gr_name; - groups gr_next; -}; - -/* - * A list of what is exported and to whom - */ -typedef struct exportnode *exports; -struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; -}; - -/* - * POSIX pathconf information - */ -struct ppathcnf { - int pc_link_max; /* max links allowed */ - short pc_max_canon; /* max line len for a tty */ - short pc_max_input; /* input a tty can eat all at once */ - short pc_name_max; /* max file name length (dir entry) */ - short pc_path_max; /* max path name length (/x/y/x/.. ) */ - short pc_pipe_buf; /* size of a pipe (bytes) */ - u_char pc_vdisable; /* safe char to turn off c_cc[i] */ - char pc_xxx; /* alignment padding; cc_t == char */ - short pc_mask[2]; /* validity and boolean bits */ -}; - -/* - * NFSv3 file handle - */ -const FHSIZE3 = 64; /* max size of NFSv3 file handle in bytes */ -typedef opaque fhandle3; - -/* - * NFSv3 mount status - */ -enum mountstat3 { - MNT_OK = 0, /* no error */ - MNT3ERR_PERM = 1, /* not owner */ - MNT3ERR_NOENT = 2, /* no such file or directory */ - MNT3ERR_IO = 5, /* I/O error */ - MNT3ERR_ACCES = 13, /* Permission denied */ - MNT3ERR_NOTDIR = 20, /* Not a directory */ - MNT3ERR_INVAL = 22, /* Invalid argument */ - MNT3ERR_NAMETOOLONG = 63, /* File name too long */ - MNT3ERR_NOTSUPP = 10004,/* Operation not supported */ - MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ -}; - -/* - * NFSv3 mount result - */ -struct mountres3_ok { - fhandle3 fhandle; - int auth_flavors<>; -}; - -union mountres3 switch (mountstat3 fhs_status) { -case MNT_OK: - mountres3_ok mountinfo; /* File handle and supported flavors */ -default: - void; -}; - -program MOUNTPROG { - /* - * Version one of the mount protocol communicates with version two - * of the NFS protocol. The only connecting point is the fhandle - * structure, which is the same for both protocols. - */ - version MOUNTVERS { - /* - * Does no work. It is made available in all RPC services - * to allow server reponse testing and timing - */ - void - MOUNTPROC_NULL(void) = 0; - - /* - * If fhs_status is 0, then fhs_fhandle contains the - * file handle for the directory. This file handle may - * be used in the NFS protocol. This procedure also adds - * a new entry to the mount list for this client mounting - * the directory. - * Unix authentication required. - */ - fhstatus - MOUNTPROC_MNT(dirpath) = 1; - - /* - * Returns the list of remotely mounted filesystems. The - * mountlist contains one entry for each hostname and - * directory pair. - */ - mountlist - MOUNTPROC_DUMP(void) = 2; - - /* - * Removes the mount list entry for the directory - * Unix authentication required. - */ - void - MOUNTPROC_UMNT(dirpath) = 3; - - /* - * Removes all of the mount list entries for this client - * Unix authentication required. - */ - void - MOUNTPROC_UMNTALL(void) = 4; - - /* - * Returns a list of all the exported filesystems, and which - * machines are allowed to import it. - */ - exports - MOUNTPROC_EXPORT(void) = 5; - - /* - * Identical to MOUNTPROC_EXPORT above - */ - exports - MOUNTPROC_EXPORTALL(void) = 6; - } = 1; - - /* - * Version two of the mount protocol communicates with version two - * of the NFS protocol. - * The only difference from version one is the addition of a POSIX - * pathconf call. - */ - version MOUNTVERS_POSIX { - /* - * Does no work. It is made available in all RPC services - * to allow server reponse testing and timing - */ - void - MOUNTPROC_NULL(void) = 0; - - /* - * If fhs_status is 0, then fhs_fhandle contains the - * file handle for the directory. This file handle may - * be used in the NFS protocol. This procedure also adds - * a new entry to the mount list for this client mounting - * the directory. - * Unix authentication required. - */ - fhstatus - MOUNTPROC_MNT(dirpath) = 1; - - /* - * Returns the list of remotely mounted filesystems. The - * mountlist contains one entry for each hostname and - * directory pair. - */ - mountlist - MOUNTPROC_DUMP(void) = 2; - - /* - * Removes the mount list entry for the directory - * Unix authentication required. - */ - void - MOUNTPROC_UMNT(dirpath) = 3; - - /* - * Removes all of the mount list entries for this client - * Unix authentication required. - */ - void - MOUNTPROC_UMNTALL(void) = 4; - - /* - * Returns a list of all the exported filesystems, and which - * machines are allowed to import it. - */ - exports - MOUNTPROC_EXPORT(void) = 5; - - /* - * Identical to MOUNTPROC_EXPORT above - */ - exports - MOUNTPROC_EXPORTALL(void) = 6; - - /* - * POSIX pathconf info (Sun hack) - */ - ppathcnf - MOUNTPROC_PATHCONF(dirpath) = 7; - } = 2; - - /* - * Version 3 of the protocol is for NFSv3 - */ - version MOUNTVERS_NFSV3 { - /* - * Does no work. It is made available in all RPC services - * to allow server reponse testing and timing - */ - void - MOUNTPROC3_NULL(void) = 0; - - /* - * If fhs_status is 0, then fhs_fhandle contains the - * file handle for the directory. This file handle may - * be used in the NFS protocol. This procedure also adds - * a new entry to the mount list for this client mounting - * the directory. - * Unix authentication required. - */ - mountres3 - MOUNTPROC3_MNT(dirpath) = 1; - - /* - * Returns the list of remotely mounted filesystems. The - * mountlist contains one entry for each hostname and - * directory pair. - */ - mountlist - MOUNTPROC3_DUMP(void) = 2; - - /* - * Removes the mount list entry for the directory - * Unix authentication required. - */ - void - MOUNTPROC3_UMNT(dirpath) = 3; - - /* - * Removes all of the mount list entries for this client - * Unix authentication required. - */ - void - MOUNTPROC3_UMNTALL(void) = 4; - - /* - * Returns a list of all the exported filesystems, and which - * machines are allowed to import it. - */ - exports - MOUNTPROC3_EXPORT(void) = 5; - } = 3; -} = 100005; - -#ifdef RPC_HDR -%#endif /*!_rpcsvc_mount_h*/ -#endif diff --git a/nfs-utils-2.5.2/support/export/xtab.c b/nfs-utils-2.5.2/support/export/xtab.c deleted file mode 100644 index 00b25ea..0000000 --- a/nfs-utils-2.5.2/support/export/xtab.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * support/export/xtab.c - * - * Interface to the etab/exports file. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "exportfs.h" -#include "xio.h" -#include "xlog.h" -#include "v4root.h" -#include "misc.h" - -static char state_base_dirname[PATH_MAX] = NFS_STATEDIR; -extern struct state_paths etab; - -int v4root_needed; -static void cond_rename(char *newfile, char *oldfile); - -static int -xtab_read(char *xtab, char *lockfn, int is_export) -{ - /* is_export == 0 => reading /proc/fs/nfs/exports - we know these things are exported to kernel - * is_export == 1 => reading /var/lib/nfs/etab - these things are allowed to be exported - */ - struct exportent *xp; - nfs_export *exp; - int lockid; - - if ((lockid = xflock(lockfn, "r")) < 0) - return 0; - setexportent(xtab, "r"); - if (is_export == 1) - v4root_needed = 1; - while ((xp = getexportent(is_export==0, 0)) != NULL) { - if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) && - !(exp = export_create(xp, is_export!=1))) { - if(xp->e_hostname) { - free(xp->e_hostname); - xp->e_hostname=NULL; - } - if(xp->e_uuid) { - free(xp->e_uuid); - xp->e_uuid=NULL; - } - continue; - } - switch (is_export) { - case 0: - exp->m_exported = 1; - break; - case 1: - exp->m_xtabent = 1; - exp->m_mayexport = 1; - if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0) - v4root_needed = 0; - break; - } - if(xp->e_hostname) { - free(xp->e_hostname); - xp->e_hostname=NULL; - } - if(xp->e_uuid) { - free(xp->e_uuid); - xp->e_uuid=NULL; - } - - } - endexportent(); - xfunlock(lockid); - - return 0; -} - -int -xtab_export_read(void) -{ - return xtab_read(etab.statefn, etab.lockfn, 1); -} - -/* - * mountd now keeps an open fd for the etab at all times to make sure that the - * inode number changes when the xtab_export_write is done. If you change the - * routine below such that the files are edited in place, then you'll need to - * fix the auth_reload logic as well... - */ -static int -xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export) -{ - struct exportent xe; - nfs_export *exp; - int lockid, i; - - if ((lockid = xflock(lockfn, "w")) < 0) { - xlog(L_ERROR, "can't lock %s for writing", xtab); - return 0; - } - setexportent(xtabtmp, "w"); - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (is_export && !exp->m_xtabent) - continue; - if (!is_export && ! exp->m_exported) - continue; - - /* write out the export entry using the FQDN */ - xe = exp->m_export; - xe.e_hostname = exp->m_client->m_hostname; - putexportent(&xe); - } - } - endexportent(); - - cond_rename(xtabtmp, xtab); - - xfunlock(lockid); - - return 1; -} - -int -xtab_export_write() -{ - return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn, 1); -} - -/* - * rename newfile onto oldfile unless - * they are identical - */ -static void cond_rename(char *newfile, char *oldfile) -{ - int nfd, ofd; - char nbuf[4096], obuf[4096]; - int ncnt, ocnt; - - nfd = open(newfile, 0); - if (nfd < 0) - return; - ofd = open(oldfile, 0); - if (ofd < 0) { - close(nfd); - rename(newfile, oldfile); - return; - } - - do { - ncnt = read(nfd, nbuf, sizeof(nbuf)); - if (ncnt < 0) - break; - ocnt = read(ofd, obuf, sizeof(obuf)); - if (ocnt < 0) - break; - if (ncnt != ocnt) - break; - if (ncnt == 0) { - close(nfd); - close(ofd); - unlink(newfile); - return; - } - } while (memcmp(obuf, nbuf, ncnt) == 0); - - /* some mis-match */ - close(nfd); - close(ofd); - rename(newfile, oldfile); - return; -} - -/* - * Returns a dynamically allocated, '\0'-terminated buffer - * containing an appropriate pathname, or NULL if an error - * occurs. Caller must free the returned result with free(3). - */ -static char * -state_make_pathname(const char *tabname) -{ - return generic_make_pathname(state_base_dirname, tabname); -} - -/** - * state_setup_basedir - set up basedir - * @progname: C string containing name of program, for error messages - * @parentdir: C string containing pathname to on-disk state, or NULL - * - * This runs before logging is set up, so error messages are directed - * to stderr. - * - * Returns true and sets up our basedir, if @parentdir was valid - * and usable; otherwise false is returned. - */ -_Bool -state_setup_basedir(const char *progname, const char *parentdir) -{ - return generic_setup_basedir(progname, parentdir, state_base_dirname, - PATH_MAX); -} - -int -setup_state_path_names(const char *progname, const char *statefn, - const char *tmpfn, const char *lockfn, - struct state_paths *paths) -{ - paths->statefn = state_make_pathname(statefn); - if (!paths->statefn) { - fprintf(stderr, "%s: state_make_pathname(%s) failed\n", - progname, statefn); - goto out_err; - } - paths->tmpfn = state_make_pathname(tmpfn); - if (!paths->tmpfn) { - fprintf(stderr, "%s: state_make_pathname(%s) failed\n", - progname, tmpfn); - goto out_free_statefn; - } - paths->lockfn = state_make_pathname(lockfn); - if (!paths->lockfn) { - fprintf(stderr, "%s: state_make_pathname(%s) failed\n", - progname, lockfn); - goto out_free_tmpfn; - } - return 1; - -out_free_tmpfn: - free(paths->tmpfn); -out_free_statefn: - free(paths->statefn); -out_err: - return 0; - -} - -void -free_state_path_names(struct state_paths *paths) -{ - free(paths->statefn); - free(paths->tmpfn); - free(paths->lockfn); -} diff --git a/nfs-utils-2.5.2/support/include/Makefile.am b/nfs-utils-2.5.2/support/include/Makefile.am deleted file mode 100644 index 1373891..0000000 --- a/nfs-utils-2.5.2/support/include/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = nfs rpcsvc sys - -noinst_HEADERS = \ - cld.h \ - exportfs.h \ - ha-callout.h \ - junction.h \ - misc.h \ - nfs_mntent.h \ - nfs_paths.h \ - nfsd_path.h \ - nfslib.h \ - nfsrpc.h \ - nls.h \ - nsm.h \ - pseudoflavors.h \ - rpcmisc.h \ - sockaddr.h \ - tcpwrapper.h \ - v4root.h \ - workqueue.h \ - xio.h \ - xlog.h \ - xmalloc.h \ - xcommon.h \ - xstat.h \ - conffile.h - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/include/cld.h b/nfs-utils-2.5.2/support/include/cld.h deleted file mode 100644 index 88d3b63..0000000 --- a/nfs-utils-2.5.2/support/include/cld.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Upcall description for nfsdcld communication - * - * Copyright (c) 2012 Red Hat, Inc. - * Author(s): Jeff Layton - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _NFSD_CLD_H -#define _NFSD_CLD_H - -/* latest upcall version available */ -#define CLD_UPCALL_VERSION 2 - -/* defined by RFC3530 */ -#define NFS4_OPAQUE_LIMIT 1024 - -#ifndef SHA256_DIGEST_SIZE -#define SHA256_DIGEST_SIZE 32 -#endif - -enum cld_command { - Cld_Create, /* create a record for this cm_id */ - Cld_Remove, /* remove record of this cm_id */ - Cld_Check, /* is this cm_id allowed? */ - Cld_GraceDone, /* grace period is complete */ - Cld_GraceStart, /* grace start (upload client records) */ - Cld_GetVersion, /* query max supported upcall version */ -}; - -/* representation of long-form NFSv4 client ID */ -struct cld_name { - uint16_t cn_len; /* length of cm_id */ - unsigned char cn_id[NFS4_OPAQUE_LIMIT]; /* client-provided */ -} __attribute__((packed)); - -/* sha256 hash of the kerberos principal */ -struct cld_princhash { - uint8_t cp_len; /* length of cp_data */ - unsigned char cp_data[SHA256_DIGEST_SIZE]; /* hash of principal */ -} __attribute__((packed)); - -struct cld_clntinfo { - struct cld_name cc_name; - struct cld_princhash cc_princhash; -} __attribute__((packed)); - -/* message struct for communication with userspace */ -struct cld_msg { - uint8_t cm_vers; /* upcall version */ - uint8_t cm_cmd; /* upcall command */ - int16_t cm_status; /* return code */ - uint32_t cm_xid; /* transaction id */ - union { - int64_t cm_gracetime; /* grace period start time */ - struct cld_name cm_name; - uint8_t cm_version; /* for getting max version */ - } __attribute__((packed)) cm_u; -} __attribute__((packed)); - -/* version 2 message can include hash of kerberos principal */ -struct cld_msg_v2 { - uint8_t cm_vers; /* upcall version */ - uint8_t cm_cmd; /* upcall command */ - int16_t cm_status; /* return code */ - uint32_t cm_xid; /* transaction id */ - union { - struct cld_name cm_name; - uint8_t cm_version; /* for getting max version */ - struct cld_clntinfo cm_clntinfo; /* name & princ hash */ - } __attribute__((packed)) cm_u; -} __attribute__((packed)); - -struct cld_msg_hdr { - uint8_t cm_vers; /* upcall version */ - uint8_t cm_cmd; /* upcall command */ - int16_t cm_status; /* return code */ - uint32_t cm_xid; /* transaction id */ -} __attribute__((packed)); - -#endif /* !_NFSD_CLD_H */ diff --git a/nfs-utils-2.5.2/support/include/conffile.h b/nfs-utils-2.5.2/support/include/conffile.h deleted file mode 100644 index 7d974fe..0000000 --- a/nfs-utils-2.5.2/support/include/conffile.h +++ /dev/null @@ -1,86 +0,0 @@ -/* $OpenBSD: conf.h,v 1.30 2004/06/25 20:25:34 hshoexer Exp $ */ -/* $EOM: conf.h,v 1.13 2000/09/18 00:01:47 ho Exp $ */ - -/* - * Copyright (c) 1998, 1999, 2001 Niklas Hallqvist. All rights reserved. - * Copyright (c) 2000, 2003 Håkan Olsson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#ifndef _CONFFILE_H_ -#define _CONFFILE_H_ - -#include -#include -#include -#include -#include - -struct conf_list_node { - TAILQ_ENTRY(conf_list_node) link; - char *field; -}; - -struct conf_list { - size_t cnt; - TAILQ_HEAD(conf_list_fields_head, conf_list_node) fields; -}; - -extern int conf_begin(void); -extern int conf_decode_base64(uint8_t *, uint32_t *, const unsigned char *); -extern int conf_end(int, int); -extern void conf_free_list(struct conf_list *); -extern struct sockaddr *conf_get_address(const char *, const char *); -extern struct conf_list *conf_get_list(const char *, const char *); -extern struct conf_list *conf_get_tag_list(const char *, const char *); -extern int conf_get_num(const char *, const char *, int); -extern _Bool conf_get_bool(const char *, const char *, _Bool); -extern char *conf_get_str(const char *, const char *); -extern char *conf_get_str_with_def(const char *, const char *, char *); -extern char *conf_get_section(const char *, const char *, const char *); -extern int conf_init_file(const char *); -extern void conf_cleanup(void); -extern int conf_match_num(const char *, const char *, int); -extern int conf_remove(int, const char *, const char *); -extern int conf_remove_section(int, const char *); -extern void conf_report(FILE *); -extern int conf_write(const char *, const char *, const char *, const char *, const char *); - -extern const char *modified_by; - -/* - * Convert letter from upper case to lower case - */ -static inline void upper2lower(char *str) -{ - char c; - - while ((c = tolower(*str))) - *str++ = c; -} - - -#endif /* _CONFFILE_H_ */ diff --git a/nfs-utils-2.5.2/support/include/exportfs.h b/nfs-utils-2.5.2/support/include/exportfs.h deleted file mode 100644 index daa7e2a..0000000 --- a/nfs-utils-2.5.2/support/include/exportfs.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * support/include/exportfs.h - * - * Declarations for exportfs and mountd - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifndef EXPORTFS_H -#define EXPORTFS_H - -#include -#include - -#include "sockaddr.h" -#include "nfslib.h" - -enum { - MCL_FQDN = 0, - MCL_SUBNETWORK, - MCL_IPADDR = MCL_SUBNETWORK, - MCL_WILDCARD, - MCL_NETGROUP, - MCL_ANONYMOUS, - MCL_GSS, - MCL_MAXTYPES -}; - -enum { - FSLOC_NONE = 0, - FSLOC_REFER, - FSLOC_REPLICA, - FSLOC_STUB -}; - -#ifndef EXP_LOCKFILE -#define EXP_LOCKFILE "/var/lib/nfs/export-lock" -#endif - -typedef struct mclient { - struct mclient * m_next; - char * m_hostname; - int m_type; - int m_naddr; - union nfs_sockaddr m_addrlist[NFSCLNT_ADDRMAX]; - int m_exported; /* exported to nfsd */ - int m_count; -} nfs_client; - -static inline const struct sockaddr * -get_addrlist(const nfs_client *clp, const int i) -{ - return &clp->m_addrlist[i].sa; -} - -static inline const struct sockaddr_in * -get_addrlist_in(const nfs_client *clp, const int i) -{ - return &clp->m_addrlist[i].s4; -} - -static inline const struct sockaddr_in6 * -get_addrlist_in6(const nfs_client *clp, const int i) -{ - return &clp->m_addrlist[i].s6; -} - -static inline void -set_addrlist_in(nfs_client *clp, const int i, const struct sockaddr_in *sin) -{ - memcpy(&clp->m_addrlist[i].s4, sin, sizeof(*sin)); -} - -static inline void -set_addrlist_in6(nfs_client *clp, const int i, const struct sockaddr_in6 *sin6) -{ - memcpy(&clp->m_addrlist[i].s6, sin6, sizeof(*sin6)); -} - -static inline void -set_addrlist(nfs_client *clp, const int i, const struct sockaddr *sap) -{ - switch (sap->sa_family) { - case AF_INET: - memcpy(&clp->m_addrlist[i].s4, sap, sizeof(struct sockaddr_in)); - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - memcpy(&clp->m_addrlist[i].s6, sap, sizeof(struct sockaddr_in6)); - break; -#endif - } -} - -typedef struct mexport { - struct mexport * m_next; - struct mclient * m_client; - struct exportent m_export; - int m_exported; /* known to knfsd. */ - unsigned int m_xtabent : 1, /* xtab entry exists */ - m_mayexport: 1, /* derived from xtabbed */ - m_changed : 1, /* options (may) have changed */ - m_warned : 1; /* warned about multiple exports - * matching one client */ -} nfs_export; - -#define HASH_TABLE_SIZE 1021 -#define DEFAULT_TTL (30 * 60) - -typedef struct _exp_hash_entry { - nfs_export * p_first; - nfs_export * p_last; -} exp_hash_entry; - -typedef struct _exp_hash_table { - nfs_export * p_head; - exp_hash_entry entries[HASH_TABLE_SIZE]; -} exp_hash_table; - -extern exp_hash_table exportlist[MCL_MAXTYPES]; - -extern nfs_client * clientlist[MCL_MAXTYPES]; - -nfs_client * client_lookup(char *hname, int canonical); -nfs_client * client_dup(const nfs_client *clp, - const struct addrinfo *ai); -int client_gettype(char *hname); -int client_check(const nfs_client *clp, - const struct addrinfo *ai); -void client_release(nfs_client *); -void client_freeall(void); -char * client_compose(const struct addrinfo *ai); -struct addrinfo * client_resolve(const struct sockaddr *sap); -int client_member(const char *client, - const char *name); - -int export_read(char *fname, int ignore_hosts); -int export_d_read(const char *dname, int ignore_hosts); -void export_reset(nfs_export *); -nfs_export * export_lookup(char *hname, char *path, int caconical); -nfs_export * export_find(const struct addrinfo *ai, - const char *path); -nfs_export * export_create(struct exportent *, int canonical); -void exportent_release(struct exportent *); -void export_freeall(void); - -int xtab_export_read(void); -int xtab_export_write(void); - -int secinfo_addflavor(struct flav_info *, struct exportent *); - -char * host_ntop(const struct sockaddr *sap, - char *buf, const size_t buflen); -__attribute__((__malloc__)) -struct addrinfo * host_pton(const char *paddr); -__attribute__((__malloc__)) -struct addrinfo * host_addrinfo(const char *hostname); -__attribute__((__malloc__)) -char * host_canonname(const struct sockaddr *sap); -__attribute__((__malloc__)) -struct addrinfo * host_reliable_addrinfo(const struct sockaddr *sap); -__attribute__((__malloc__)) -struct addrinfo * host_numeric_addrinfo(const struct sockaddr *sap); - -struct nfskey * key_lookup(char *hname); - -struct export_features { - unsigned int flags; - unsigned int secinfo_flags; -}; - -struct export_features *get_export_features(void); -void fix_pseudoflavor_flags(struct exportent *ep); -char *exportent_realpath(struct exportent *eep); - -#endif /* EXPORTFS_H */ diff --git a/nfs-utils-2.5.2/support/include/ha-callout.h b/nfs-utils-2.5.2/support/include/ha-callout.h deleted file mode 100644 index a454bdb..0000000 --- a/nfs-utils-2.5.2/support/include/ha-callout.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * support/include/ha-callout.h - * - * High Availability NFS Callout support routines - * - * Copyright (c) 2004, Paul Clements, SteelEye Technology - * - * In order to implement HA NFS, we need several callouts at key - * points in statd and mountd. These callouts all come to ha_callout(), - * which, in turn, calls out to an ha-callout script (not part of nfs-utils; - * defined by -H argument to rpc.statd and rpc.mountd). - */ -#ifndef HA_CALLOUT_H -#define HA_CALLOUT_H - -#include -#include - -extern char *ha_callout_prog; - -static inline void -ha_callout(char *event, char *arg1, char *arg2, int arg3) -{ - char buf[16]; /* should be plenty */ - pid_t pid; - int ret = -1; - struct sigaction oldact, newact; - - if (!ha_callout_prog) /* HA callout is not enabled */ - return; - - sprintf(buf, "%d", arg3); - - /* many daemons ignore SIGCHLD as tcpwrappers will - * fork a child to do logging. We need to wait - * for a child here, so we need to un-ignore - * SIGCHLD temporarily - */ - newact.sa_handler = SIG_DFL; - newact.sa_flags = 0; - sigemptyset(&newact.sa_mask); - sigaction(SIGCHLD, &newact, &oldact); - pid = fork(); - switch (pid) { - case 0: execl(ha_callout_prog, ha_callout_prog, - event, arg1, arg2, - arg3 < 0 ? NULL : buf, - NULL); - perror("execl"); - _exit(2); - case -1: perror("fork"); - break; - default: pid = waitpid(pid, &ret, 0); - } - sigaction(SIGCHLD, &oldact, &newact); - xlog(D_GENERAL, "ha callout returned %d\n", WEXITSTATUS(ret)); -} - -#endif diff --git a/nfs-utils-2.5.2/support/include/junction.h b/nfs-utils-2.5.2/support/include/junction.h deleted file mode 100644 index 7257d80..0000000 --- a/nfs-utils-2.5.2/support/include/junction.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * @file support/include/junction.h - * @brief Declarations for libjunction.a - */ - -/* - * Copyright 2010, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef _NFS_JUNCTION_H_ -#define _NFS_JUNCTION_H_ - -#include - -/* - * The libjunction APIs use the status codes from the FedFS ADMIN - * protocol, which includes non-errno codes like FEDFS_ERR_NOTJUNCT. - */ -enum FedFsStatus { - FEDFS_OK = 0, - FEDFS_ERR_ACCESS = 1, - FEDFS_ERR_BADCHAR = 2, - FEDFS_ERR_BADNAME = 3, - FEDFS_ERR_NAMETOOLONG = 4, - FEDFS_ERR_LOOP = 5, - FEDFS_ERR_BADXDR = 6, - FEDFS_ERR_EXIST = 7, - FEDFS_ERR_INVAL = 8, - FEDFS_ERR_IO = 9, - FEDFS_ERR_NOSPC = 10, - FEDFS_ERR_NOTJUNCT = 11, - FEDFS_ERR_NOTLOCAL = 12, - FEDFS_ERR_PERM = 13, - FEDFS_ERR_ROFS = 14, - FEDFS_ERR_SVRFAULT = 15, - FEDFS_ERR_NOTSUPP = 16, - FEDFS_ERR_NSDB_ROUTE = 17, - FEDFS_ERR_NSDB_DOWN = 18, - FEDFS_ERR_NSDB_CONN = 19, - FEDFS_ERR_NSDB_AUTH = 20, - FEDFS_ERR_NSDB_LDAP = 21, - FEDFS_ERR_NSDB_LDAP_VAL = 22, - FEDFS_ERR_NSDB_NONCE = 23, - FEDFS_ERR_NSDB_NOFSN = 24, - FEDFS_ERR_NSDB_NOFSL = 25, - FEDFS_ERR_NSDB_RESPONSE = 26, - FEDFS_ERR_NSDB_FAULT = 27, - FEDFS_ERR_NSDB_PARAMS = 28, - FEDFS_ERR_NSDB_LDAP_REFERRAL = 29, - FEDFS_ERR_NSDB_LDAP_REFERRAL_VAL = 30, - FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED = 31, - FEDFS_ERR_NSDB_PARAMS_LDAP_REFERRAL = 32, - FEDFS_ERR_PATH_TYPE_UNSUPP = 33, - FEDFS_ERR_DELAY = 34, - FEDFS_ERR_NO_CACHE = 35, - FEDFS_ERR_UNKNOWN_CACHE = 36, - FEDFS_ERR_NO_CACHE_UPDATE = 37, -}; -typedef enum FedFsStatus FedFsStatus; - -/** - * Contains NFS fileset location information - * - * Each of these represents one server:/rootpath pair. The NFS - * implementation can coalesce multiple pairs into a single - * fs_location4 result if jfl_rootpath is the same across - * multiple servers. - * - * The nfl_server field can contain either one presentation format - * IP address or one DNS hostname. - * - * See Section 11.9 and 11.10 of RFC 5661 or section 4.2.2.3 and - * 4.2.2.4 of the NSDB protocol draft for details. - */ - -struct nfs_fsloc { - struct nfs_fsloc *nfl_next; - - char *nfl_hostname; - uint16_t nfl_hostport; - char **nfl_rootpath; - - struct { - _Bool nfl_varsub; - } nfl_flags; - int32_t nfl_currency; - int32_t nfl_validfor; - - struct { - _Bool nfl_writable, nfl_going, nfl_split; - } nfl_genflags; - struct { - _Bool nfl_rdma; - } nfl_transflags; - struct { - uint8_t nfl_simul, nfl_handle, nfl_fileid; - uint8_t nfl_writever, nfl_change, nfl_readdir; - uint8_t nfl_readrank, nfl_writerank; - uint8_t nfl_readorder, nfl_writeorder; - } nfl_info; -}; - - -/** - ** NFS location data management functions - **/ - -void nfs_free_location(struct nfs_fsloc *location); -void nfs_free_locations(struct nfs_fsloc *locations); -struct nfs_fsloc *nfs_new_location(void); - -__attribute_malloc__ -char **nfs_dup_string_array(char **array); -void nfs_free_string_array(char **array); - - -/** - ** NFS junction management functions - **/ - -FedFsStatus nfs_delete_junction(const char *pathname); -FedFsStatus nfs_add_junction(const char *pathname, - struct nfs_fsloc *locations); -FedFsStatus nfs_get_locations(const char *pathname, - struct nfs_fsloc **locations); -FedFsStatus nfs_is_prejunction(const char *pathname); -FedFsStatus nfs_is_junction(const char *pathname); - - -/** - ** Flush kernel NFS server's export cache - **/ -FedFsStatus junction_flush_exports_cache(void); - -/** - ** Pathname conversion helpers - **/ -void nsdb_free_string_array(char **strings); -FedFsStatus nsdb_path_array_to_posix(char * const *path_array, - char **pathname); -FedFsStatus nsdb_posix_to_path_array(const char *pathname, - char ***path_array); - -/** - ** Readability helpers - **/ - -const char *nsdb_display_fedfsstatus(const FedFsStatus status); -void nsdb_print_fedfsstatus(const FedFsStatus status); - -#endif /* !_NFS_JUNCTION_H_ */ diff --git a/nfs-utils-2.5.2/support/include/misc.h b/nfs-utils-2.5.2/support/include/misc.h deleted file mode 100644 index 2b0fef2..0000000 --- a/nfs-utils-2.5.2/support/include/misc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * misc.h All that didn't fit elsewhere. - * - * Copyright (C) 1995 Olaf Kirch - */ - -#ifndef MISC_H -#define MISC_H - -/* - * Generate random key, returning the length of the result. Currently, - * weakrandomkey generates a maximum of 20 bytes are generated, but this - * may change with future implementations. - */ -int randomkey(unsigned char *keyout, int len); -int weakrandomkey(unsigned char *keyout, int len); - -char *generic_make_pathname(const char *, const char *); -_Bool generic_setup_basedir(const char *, const char *, char *, const size_t); - -struct stat; - -extern int check_is_mountpoint(const char *path, - int (mystat)(const char *, struct stat *)); -#define is_mountpoint(path) \ - check_is_mountpoint(path, NULL) - -/* size of the file pointer buffers for rpc procfs files */ -#define RPC_CHAN_BUF_SIZE 32768 - -#endif /* MISC_H */ diff --git a/nfs-utils-2.5.2/support/include/nfs/Makefile.am b/nfs-utils-2.5.2/support/include/nfs/Makefile.am deleted file mode 100644 index 9903ba1..0000000 --- a/nfs-utils-2.5.2/support/include/nfs/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_HEADERS = debug.h export.h nfs.h - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/include/nfs/debug.h b/nfs-utils-2.5.2/support/include/nfs/debug.h deleted file mode 100644 index 80a1b1d..0000000 --- a/nfs-utils-2.5.2/support/include/nfs/debug.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _NFS_DEBUG_H -#define _NFS_DEBUG_H - -/* - * RPC debug facilities - */ -#define RPCDBG_XPRT 0x0001 -#define RPCDBG_CALL 0x0002 -#define RPCDBG_DEBUG 0x0004 -#define RPCDBG_NFS 0x0008 -#define RPCDBG_AUTH 0x0010 -#define RPCDBG_BIND 0x0020 -#define RPCDBG_SCHED 0x0040 -#define RPCDBG_TRANS 0x0080 -#define RPCDBG_SVCSOCK 0x0100 -#define RPCDBG_SVCDSP 0x0200 -#define RPCDBG_MISC 0x0400 -#define RPCDBG_CACHE 0x0800 -#define RPCDBG_ALL 0x7fff - -/* - * Declarations for the sysctl debug interface, which allows to read or - * change the debug flags for rpc, nfs, nfsd, and lockd. Since the sunrpc - * module currently registers its sysctl table dynamically, the sysctl path - * for module FOO is . - */ -#define CTL_SUNRPC 7249 /* arbitrary and hopefully unused */ - -enum { - CTL_RPCDEBUG = 1, - CTL_NFSDEBUG, - CTL_NFSDDEBUG, - CTL_NLMDEBUG, -}; - - -/* - * knfsd debug flags - */ -#define NFSDDBG_SOCK 0x0001 -#define NFSDDBG_FH 0x0002 -#define NFSDDBG_EXPORT 0x0004 -#define NFSDDBG_SVC 0x0008 -#define NFSDDBG_PROC 0x0010 -#define NFSDDBG_FILEOP 0x0020 -#define NFSDDBG_AUTH 0x0040 -#define NFSDDBG_REPCACHE 0x0080 -#define NFSDDBG_XDR 0x0100 -#define NFSDDBG_LOCKD 0x0200 -#define NFSDDBG_ALL 0x7FFF -#define NFSDDBG_NOCHANGE 0xFFFF - -/* - * Debug flags - */ -#define NLMDBG_SVC 0x0001 -#define NLMDBG_CLIENT 0x0002 -#define NLMDBG_CLNTLOCK 0x0004 -#define NLMDBG_SVCLOCK 0x0008 -#define NLMDBG_MONITOR 0x0010 -#define NLMDBG_CLNTSUBS 0x0020 -#define NLMDBG_SVCSUBS 0x0040 -#define NLMDBG_HOSTCACHE 0x0080 -#define NLMDBG_XDR 0x0100 -#define NLMDBG_ALL 0x7fff - - -#define NFSDBG_VFS 0x0001 -#define NFSDBG_DIRCACHE 0x0002 -#define NFSDBG_LOOKUPCACHE 0x0004 -#define NFSDBG_PAGECACHE 0x0008 -#define NFSDBG_PROC 0x0010 -#define NFSDBG_XDR 0x0020 -#define NFSDBG_FILE 0x0040 -#define NFSDBG_ROOT 0x0080 -#define NFSDBG_CALLBACK 0x0100 -#define NFSDBG_CLIENT 0x0200 -#define NFSDBG_MOUNT 0x0400 -#define NFSDBG_FSCACHE 0x0800 -#define NFSDBG_PNFS 0x1000 -#define NFSDBG_PNFS_LD 0x2000 -#define NFSDBG_STATE 0x4000 -#define NFSDBG_ALL 0xFFFF - -#endif /* _NFS_DEBUG_H */ diff --git a/nfs-utils-2.5.2/support/include/nfs/export.h b/nfs-utils-2.5.2/support/include/nfs/export.h deleted file mode 100644 index 0eca828..0000000 --- a/nfs-utils-2.5.2/support/include/nfs/export.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _NSF_EXPORT_H -#define _NSF_EXPORT_H - -/* - * Important limits for the exports stuff. - */ -#define NFSCLNT_IDMAX 1024 -#define NFSCLNT_ADDRMAX 16 -#define NFSCLNT_KEYMAX 32 - -/* - * Export flags. - */ -#define NFSEXP_READONLY 0x0001 -#define NFSEXP_INSECURE_PORT 0x0002 -#define NFSEXP_ROOTSQUASH 0x0004 -#define NFSEXP_ALLSQUASH 0x0008 -#define NFSEXP_ASYNC 0x0010 -#define NFSEXP_GATHERED_WRITES 0x0020 -#define NFSEXP_NOREADDIRPLUS 0x0040 -#define NFSEXP_SECURITY_LABEL 0x0080 -/* 0x100 unused */ -#define NFSEXP_NOHIDE 0x0200 -#define NFSEXP_NOSUBTREECHECK 0x0400 -#define NFSEXP_NOAUTHNLM 0x0800 -#define NFSEXP_FSID 0x2000 -#define NFSEXP_CROSSMOUNT 0x4000 -#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */ -#define NFSEXP_V4ROOT 0x10000 -#define NFSEXP_PNFS 0x20000 -/* - * All flags supported by the kernel before addition of the - * export_features interface: - */ -#define NFSEXP_OLDFLAGS 0x7E3F -/* - * Flags that can vary per flavor, for kernels before addition of the - * export_features interface: - */ -#define NFSEXP_OLD_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \ - | NFSEXP_ALLSQUASH) - -#endif /* _NSF_EXPORT_H */ diff --git a/nfs-utils-2.5.2/support/include/nfs/nfs.h b/nfs-utils-2.5.2/support/include/nfs/nfs.h deleted file mode 100644 index b7d9e06..0000000 --- a/nfs-utils-2.5.2/support/include/nfs/nfs.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _NFS_NFS_H -#define _NFS_NFS_H - -#include - -#include -#include -#include -#include -#include -#include - -#define NFS3_FHSIZE 64 -#define NFS_FHSIZE 32 - -#define NFSD_MINVERS 2 -#define NFSD_MAXVERS 4 - -#define NFS4_MINMINOR 0 -#define NFS4_MAXMINOR (WORD_BIT-1) - -struct nfs_fh_len { - int fh_size; - u_int8_t fh_handle[NFS3_FHSIZE]; -}; - - -#define NFSCTL_UDPBIT (1 << (17 - 1)) -#define NFSCTL_TCPBIT (1 << (18 - 1)) -#define NFSCTL_PROTODEFAULT (NFSCTL_TCPBIT) - -#define NFSCTL_VERUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1))) -#define NFSCTL_MINORUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << (_v))) -#define NFSCTL_UDPUNSET(_cltbits) ((_cltbits) &= ~NFSCTL_UDPBIT) -#define NFSCTL_TCPUNSET(_cltbits) ((_cltbits) &= ~NFSCTL_TCPBIT) - -#define NFSCTL_VERISSET(_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1))) -#define NFSCTL_MINORISSET(_cltbits, _v) ((_cltbits) & (1 << (_v))) -#define NFSCTL_UDPISSET(_cltbits) ((_cltbits) & NFSCTL_UDPBIT) -#define NFSCTL_TCPISSET(_cltbits) ((_cltbits) & NFSCTL_TCPBIT) - -#define NFSCTL_VERDEFAULT (0xc) /* versions 3 and 4 */ -#define NFSCTL_MINDEFAULT (0x7) /* minor versions 4.1 and 4.2 */ -#define NFSCTL_VERSET(_cltbits, _v) ((_cltbits) |= (1 << ((_v) - 1))) -#define NFSCTL_MINORSET(_cltbits, _v) ((_cltbits) |= (1 << (_v))) -#define NFSCTL_UDPSET(_cltbits) ((_cltbits) |= NFSCTL_UDPBIT) -#define NFSCTL_TCPSET(_cltbits) ((_cltbits) |= NFSCTL_TCPBIT) - -#define NFSCTL_ANYPROTO(_cltbits) ((_cltbits) & (NFSCTL_UDPBIT | NFSCTL_TCPBIT)) - -#endif /* _NFS_NFS_H */ diff --git a/nfs-utils-2.5.2/support/include/nfs_mntent.h b/nfs-utils-2.5.2/support/include/nfs_mntent.h deleted file mode 100644 index 010df24..0000000 --- a/nfs-utils-2.5.2/support/include/nfs_mntent.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 2006-06-08 Amit Gud - * - Moved code snippets here from util-linux/mount/my_mntent.h - */ - -#ifndef _NFS_MNTENT_H -#define _NFS_MNTENT_H -#include - -#define ERR_MAX 5 - -typedef struct mntFILEstruct { - FILE *mntent_fp; - char *mntent_file; - int mntent_lineno; - int mntent_errs; - int mntent_softerrs; -} mntFILE; - -mntFILE *nfs_setmntent (const char *file, char *mode); -void nfs_endmntent (mntFILE *mfp); -int nfs_addmntent (mntFILE *mfp, struct mntent *mnt); -struct nfs_mntent *my_getmntent (mntFILE *mfp); -struct mntent *nfs_getmntent (mntFILE *mfp); - -#endif /* _NFS_MNTENT_H */ diff --git a/nfs-utils-2.5.2/support/include/nfs_paths.h b/nfs-utils-2.5.2/support/include/nfs_paths.h deleted file mode 100644 index de4ac19..0000000 --- a/nfs-utils-2.5.2/support/include/nfs_paths.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _NFS_PATHS_H -#define _NFS_PATHS_H - -#ifndef _PATH_MOUNTED -#define _PATH_MOUNTED "/etc/fstab" -#endif -#define MOUNTED_LOCK _PATH_MOUNTED "~" -#define MOUNTED_TEMP _PATH_MOUNTED ".tmp" - -#endif /* _NFS_PATHS_H */ - diff --git a/nfs-utils-2.5.2/support/include/nfsd_path.h b/nfs-utils-2.5.2/support/include/nfsd_path.h deleted file mode 100644 index 3b73aad..0000000 --- a/nfs-utils-2.5.2/support/include/nfsd_path.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 Trond Myklebust - */ -#ifndef NFSD_PATH_H -#define NFSD_PATH_H - -#include - -struct file_handle; -struct statfs64; - -void nfsd_path_init(void); - -const char * nfsd_path_nfsd_rootdir(void); -char * nfsd_path_strip_root(char *pathname); -char * nfsd_path_prepend_dir(const char *dir, const char *pathname); - -int nfsd_path_stat(const char *pathname, struct stat *statbuf); -int nfsd_path_lstat(const char *pathname, struct stat *statbuf); - -int nfsd_path_statfs64(const char *pathname, - struct statfs64 *statbuf); - -char * nfsd_realpath(const char *path, char *resolved_path); - -ssize_t nfsd_path_read(int fd, char *buf, size_t len); -ssize_t nfsd_path_write(int fd, const char *buf, size_t len); - -int nfsd_name_to_handle_at(int fd, const char *path, - struct file_handle *fh, - int *mount_id, int flags); -#endif diff --git a/nfs-utils-2.5.2/support/include/nfslib.h b/nfs-utils-2.5.2/support/include/nfslib.h deleted file mode 100644 index 84d8270..0000000 --- a/nfs-utils-2.5.2/support/include/nfslib.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * support/include/nfslib.h - * - * General support functions for NFS user-space programs. - * - * Copyright (C) 1995 Olaf Kirch - */ - -#ifndef NFSLIB_H -#define NFSLIB_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "xlog.h" - -#ifndef _PATH_EXPORTS -#define _PATH_EXPORTS "/etc/exports" -#endif -#ifndef _PATH_EXPORTS_D -#define _PATH_EXPORTS_D "/etc/exports.d" -#endif -#ifndef _EXT_EXPORT -#define _EXT_EXPORT ".exports" -#endif -#ifndef _PATH_IDMAPDCONF -#define _PATH_IDMAPDCONF "/etc/idmapd.conf" -#endif -#ifndef _PATH_PROC_EXPORTS -#define _PATH_PROC_EXPORTS "/proc/fs/nfs/exports" -#define _PATH_PROC_EXPORTS_ALT "/proc/fs/nfsd/exports" -#endif - -#define ETAB "etab" -#define ETABTMP "etab.tmp" -#define ETABLCK ".etab.lock" -#define RMTAB "rmtab" -#define RMTABTMP "rmtab.tmp" -#define RMTABLCK ".rmtab.lock" - -struct state_paths { - char *statefn; - char *tmpfn; - char *lockfn; -}; - -/* Maximum number of security flavors on an export: */ -#define SECFLAVOR_COUNT 8 - -struct sec_entry { - struct flav_info *flav; - int flags; -}; - -/* - * Data related to a single exports entry as returned by getexportent. - * FIXME: export options should probably be parsed at a later time to - * allow overrides when using exportfs. - */ -struct exportent { - char * e_hostname; - char e_path[NFS_MAXPATHLEN+1]; - int e_flags; - int e_anonuid; - int e_anongid; - int * e_squids; - int e_nsquids; - int * e_sqgids; - int e_nsqgids; - unsigned int e_fsid; - char * e_mountpoint; - int e_fslocmethod; - char * e_fslocdata; - char * e_uuid; - struct sec_entry e_secinfo[SECFLAVOR_COUNT+1]; - unsigned int e_ttl; - char * e_realpath; -}; - -struct rmtabent { - char r_client[NFSCLNT_IDMAX+1]; - char r_path[NFS_MAXPATHLEN+1]; - int r_count; -}; - -/* - * configuration file parsing - */ -void setexportent(char *fname, char *type); -struct exportent * getexportent(int,int); -void secinfo_show(FILE *fp, struct exportent *ep); -void putexportent(struct exportent *xep); -void endexportent(void); -struct exportent * mkexportent(char *hname, char *path, char *opts); -void dupexportent(struct exportent *dst, - struct exportent *src); -int updateexportent(struct exportent *eep, char *options); - -int setrmtabent(char *type); -struct rmtabent * getrmtabent(int log, long *pos); -void putrmtabent(struct rmtabent *xep, long *pos); -void endrmtabent(void); -void rewindrmtabent(void); -FILE * fsetrmtabent(char *fname, char *type); -struct rmtabent * fgetrmtabent(FILE *fp, int log, long *pos); -void fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos); -void fendrmtabent(FILE *fp); -void frewindrmtabent(FILE *fp); - -_Bool state_setup_basedir(const char *, const char *); -int setup_state_path_names(const char *, const char *, const char *, const char *, struct state_paths *); -void free_state_path_names(struct state_paths *); - -/* mydaemon */ -void daemon_init(bool fg); -void daemon_ready(void); - -/* - * wildmat borrowed from INN - */ -int wildmat(char *text, char *pattern); - -int qword_get(char **bpp, char *dest, int bufsize); -int qword_get_int(char **bpp, int *anint); -void cache_flush(int force); -void qword_add(char **bpp, int *lp, char *str); -void qword_addhex(char **bpp, int *lp, char *buf, int blen); -void qword_addint(char **bpp, int *lp, int n); -void qword_adduint(char **bpp, int *lp, unsigned int n); -void qword_addeol(char **bpp, int *lp); -int qword_get_uint(char **bpp, unsigned int *anint); - -void closeall(int min); - -int svctcp_socket (u_long __number, int __reuse); -int svcudp_socket (u_long __number); -int svcsock_nonblock (int __sock); - -/* Misc shared code prototypes */ -size_t strlcat(char *, const char *, size_t); -size_t strlcpy(char *, const char *, size_t); -ssize_t atomicio(ssize_t (*f) (int, void*, size_t), - int, void *, size_t); - -#ifdef HAVE_LIBTIRPC_SET_DEBUG -void libtirpc_set_debug(char *name, int level, int use_stderr); -#endif - -#define UNUSED(x) UNUSED_ ## x __attribute__((unused)) - -/* - * Some versions of freeaddrinfo(3) do not tolerate being - * passed a NULL pointer. - */ -static inline void nfs_freeaddrinfo(struct addrinfo *ai) -{ - if (ai) { - freeaddrinfo(ai); - } -} -#endif /* NFSLIB_H */ diff --git a/nfs-utils-2.5.2/support/include/nfsrpc.h b/nfs-utils-2.5.2/support/include/nfsrpc.h deleted file mode 100644 index fbbdb6a..0000000 --- a/nfs-utils-2.5.2/support/include/nfsrpc.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * nfsrpc.h -- RPC client APIs provided by support/nfs - * - * Copyright (C) 2008 Oracle Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef __NFS_UTILS_NFSRPC_H -#define __NFS_UTILS_NFSRPC_H - -#include -#include -#include - -/* - * IANA does not define an IP protocol number for RDMA transports. - * Choose an arbitrary value we can use locally. - */ -#define NFSPROTO_RDMA (3939) - -/* - * Conventional RPC program numbers - */ -#ifndef RPCBPROG -#define RPCBPROG ((rpcprog_t)100000) -#endif -#ifndef PMAPPROG -#define PMAPPROG ((rpcprog_t)100000) -#endif - -#ifndef NFSPROG -#define NFSPROG ((rpcprog_t)100003) -#endif -#ifndef MOUNTPROG -#define MOUNTPROG ((rpcprog_t)100005) -#endif -#ifndef NLMPROG -#define NLMPROG ((rpcprog_t)100021) -#endif -#ifndef NSMPROG -#define NSMPROG ((rpcprog_t)100024) -#endif - -/** - * nfs_clear_rpc_createerr - zap all error reporting fields - * - */ -static inline void nfs_clear_rpc_createerr(void) -{ - memset(&rpc_createerr, 0, sizeof(rpc_createerr)); -} - -/* - * Look up an RPC program name in /etc/rpc - */ -extern rpcprog_t nfs_getrpcbyname(const rpcprog_t, const char *table[]); - -/* - * Acquire an RPC CLIENT * with an ephemeral source port - */ -extern CLIENT *nfs_get_rpcclient(const struct sockaddr *, - const socklen_t, const unsigned short, - const rpcprog_t, const rpcvers_t, - struct timeval *); - -/* - * Acquire an RPC CLIENT * with a privileged source port - */ -extern CLIENT *nfs_get_priv_rpcclient( const struct sockaddr *, - const socklen_t, const unsigned short, - const rpcprog_t, const rpcvers_t, - struct timeval *); - -/* - * Convert a netid to a protocol number and protocol family - */ -extern int nfs_get_proto(const char *netid, sa_family_t *family, - unsigned long *protocol); - -/* - * Convert a protocol family and protocol name to a netid - */ -extern char *nfs_get_netid(const sa_family_t family, - const unsigned long protocol); - -/* - * Convert a socket address to a universal address - */ -extern char *nfs_sockaddr2universal(const struct sockaddr *); - -/* - * Extract port number from a universal address - */ -extern int nfs_universal2port(const char *); - -/* - * Generic function that maps an RPC service tuple to an IP port - * number of the service on a remote post, and sends a NULL - * request to determine if the service is responding to requests - */ -extern int nfs_getport_ping(struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol); - -/* - * Generic function that maps an RPC service tuple to an IP port - * number of the service on a remote host - */ -extern unsigned short nfs_getport(const struct sockaddr *, - const socklen_t, const rpcprog_t, - const rpcvers_t, const unsigned short); - -/* - * Generic function that maps an RPC service tuple to an IP port - * number of the service on the local host - */ -extern unsigned short nfs_getlocalport(const rpcprot_t, - const rpcvers_t, const unsigned short); - -/* - * Function to invoke an rpcbind v3/v4 GETADDR request - */ -extern unsigned short nfs_rpcb_getaddr(const struct sockaddr *, - const socklen_t, - const unsigned short, - const struct sockaddr *, - const rpcprog_t, - const rpcvers_t, - const unsigned short, - const struct timeval *); - -/* - * Function to invoke a portmap GETPORT request - */ -extern unsigned long nfs_pmap_getport(const struct sockaddr_in *, - const unsigned short, - const unsigned long, - const unsigned long, - const unsigned long, - const struct timeval *); - -/* - * Use nfs_pmap_getport to see if statd is running locally - */ -extern int nfs_probe_statd(void); - -/* - * Contact a remote RPC service to discover whether it is responding - * to requests. - */ -extern int nfs_rpc_ping(const struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - const struct timeval *timeout); - -/* create AUTH_SYS handle with no supplemental groups */ -extern AUTH * nfs_authsys_create(void); - -#endif /* !__NFS_UTILS_NFSRPC_H */ diff --git a/nfs-utils-2.5.2/support/include/nls.h b/nfs-utils-2.5.2/support/include/nls.h deleted file mode 100644 index 899e8d7..0000000 --- a/nfs-utils-2.5.2/support/include/nls.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 2006-06-08 Amit Gud - * - Copied to nfs-utils/support/include from util-linux/mount - */ - -#ifndef LOCALEDIR -#define LOCALEDIR "/usr/share/locale" -#endif - -#ifdef ENABLE_NLS -# include -# define _(Text) gettext (Text) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# undef bindtextdomain -# define bindtextdomain(Domain, Directory) /* empty */ -# undef textdomain -# define textdomain(Domain) /* empty */ -# define _(Text) (Text) -# define N_(Text) (Text) -#endif - - diff --git a/nfs-utils-2.5.2/support/include/nsm.h b/nfs-utils-2.5.2/support/include/nsm.h deleted file mode 100644 index 080d176..0000000 --- a/nfs-utils-2.5.2/support/include/nsm.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -/* - * NSM for Linux. - */ - -#ifndef NFS_UTILS_SUPPORT_NSM_H -#define NFS_UTILS_SUPPORT_NSM_H - -#include -#include -#include - -#include -#include - -#include "sm_inter.h" - -typedef unsigned int - (*nsm_populate_t)(const char *hostname, - const struct sockaddr *sap, - const struct mon *mon, - const time_t timestamp); - -/* file.c */ - -extern _Bool nsm_setup_pathnames(const char *progname, - const char *parentdir); -extern _Bool nsm_is_default_parentdir(void); -extern _Bool nsm_drop_privileges(const int pidfd); - -extern int nsm_get_state(_Bool update); -extern void nsm_update_kernel_state(const int state); - -extern unsigned int - nsm_retire_monitored_hosts(void); -extern unsigned int - nsm_load_monitor_list(nsm_populate_t func); -extern unsigned int - nsm_load_notify_list(nsm_populate_t func); - -extern _Bool nsm_insert_monitored_host(const char *hostname, - const struct sockaddr *sap, const struct mon *m); -extern void nsm_delete_monitored_host(const char *hostname, - const char *mon_name, const char *my_name, - const int chatty); -extern void nsm_delete_notified_host(const char *hostname, - const char *mon_name, const char *my_name); -extern size_t nsm_priv_to_hex(const char *priv, char *buf, - const size_t buflen); - -/* rpc.c */ - -#define NSM_MAXMSGSIZE (2048u) - -extern uint32_t nsm_xmit_getport(const int sock, - const struct sockaddr_in *sin, - const unsigned long program, - const unsigned long version); -extern uint32_t nsm_xmit_getaddr(const int sock, - const struct sockaddr_in6 *sin6, - const rpcprog_t program, const rpcvers_t version); -extern uint32_t nsm_xmit_rpcbind(const int sock, const struct sockaddr *sap, - const rpcprog_t program, const rpcvers_t version); -extern uint32_t nsm_xmit_notify(const int sock, const struct sockaddr *sap, - const socklen_t salen, const rpcprog_t program, - const char *mon_name, const int state); -extern uint32_t nsm_xmit_nlmcall(const int sock, const struct sockaddr *sap, - const socklen_t salen, const struct mon *m, - const int state); -extern uint32_t nsm_parse_reply(XDR *xdrs); -extern unsigned long - nsm_recv_getport(XDR *xdrs); -extern uint16_t nsm_recv_getaddr(XDR *xdrs); -extern uint16_t nsm_recv_rpcbind(const sa_family_t family, XDR *xdrs); - -#endif /* !NFS_UTILS_SUPPORT_NSM_H */ diff --git a/nfs-utils-2.5.2/support/include/pseudoflavors.h b/nfs-utils-2.5.2/support/include/pseudoflavors.h deleted file mode 100644 index deb052b..0000000 --- a/nfs-utils-2.5.2/support/include/pseudoflavors.h +++ /dev/null @@ -1,14 +0,0 @@ -#define RPC_AUTH_GSS_KRB5 390003 -#define RPC_AUTH_GSS_KRB5I 390004 -#define RPC_AUTH_GSS_KRB5P 390005 -#define RPC_AUTH_GSS_LKEY 390006 -#define RPC_AUTH_GSS_LKEYI 390007 -#define RPC_AUTH_GSS_LKEYP 390008 - -struct flav_info { - char *flavour; - int fnum; -}; - -extern struct flav_info flav_map[]; -extern const int flav_map_size; diff --git a/nfs-utils-2.5.2/support/include/rpcmisc.h b/nfs-utils-2.5.2/support/include/rpcmisc.h deleted file mode 100644 index 31c8e5d..0000000 --- a/nfs-utils-2.5.2/support/include/rpcmisc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * rpcmisc Support for RPC startup, dispatching and logging. - * - * Copyright (C) 1995 Olaf Kirch - */ - -#ifndef RPCMISC_H -#define RPCMISC_H - -#include -#include - -#ifdef __STDC__ -# define CONCAT(a,b) a##b -# define STRING(a) #a -#else -# define CONCAT(a,b) a/**/b -# define STRING(a) "a" -#endif - -typedef bool_t (*rpcsvc_fn_t)(struct svc_req *, void *argp, void *resp); - -struct rpc_dentry { - const char *name; - rpcsvc_fn_t func; - xdrproc_t xdr_arg_fn; /* argument XDR */ - size_t xdr_arg_size; - xdrproc_t xdr_res_fn; /* result XDR */ - size_t xdr_res_size; -}; - -struct rpc_dtable { - struct rpc_dentry *entries; - rpcproc_t nproc; -}; - -#define dtable_ent(func, vers, arg_type, res_type) \ - { STRING(func), \ - (rpcsvc_fn_t)func##_##vers##_svc, \ - (xdrproc_t)xdr_##arg_type, sizeof(arg_type), \ - (xdrproc_t)xdr_##res_type, sizeof(res_type), \ - } - -void nfs_svc_unregister(const rpcprog_t program, - const rpcvers_t version); -unsigned int nfs_svc_create(char *name, const rpcprog_t program, - const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - const uint16_t port); -void rpc_init(char *name, int prog, int vers, - void (*dispatch)(struct svc_req *, SVCXPRT *), - int defport); -void rpc_dispatch(struct svc_req *rq, SVCXPRT *xprt, - struct rpc_dtable *dtable, int nvers, - void *argp, void *resp); -int getservport(u_long number, const char *proto); - -extern int _rpcpmstart; -extern unsigned int _rpcprotobits; -extern int _rpcsvcdirty; - -static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt) -{ - return (struct sockaddr_in *)(char *)svc_getcaller(xprt); -} - -static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt) -{ - return (struct sockaddr *)(char *)svc_getcaller(xprt); -} - -#endif /* RPCMISC_H */ diff --git a/nfs-utils-2.5.2/support/include/rpcsvc/Makefile.am b/nfs-utils-2.5.2/support/include/rpcsvc/Makefile.am deleted file mode 100644 index 252bf8f..0000000 --- a/nfs-utils-2.5.2/support/include/rpcsvc/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_HEADERS = nfs_prot.h - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/include/rpcsvc/nfs_prot.h b/nfs-utils-2.5.2/support/include/rpcsvc/nfs_prot.h deleted file mode 100644 index 9311341..0000000 --- a/nfs-utils-2.5.2/support/include/rpcsvc/nfs_prot.h +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _NFS_PROT_H_RPCGEN -#define _NFS_PROT_H_RPCGEN - -#include - -#define NFS_PORT 2049 -#define NFS_MAXDATA 8192 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_FHSIZE 32 -#define NFS_COOKIESIZE 4 -#define NFS_FIFO_DEV -1 -#define NFSMODE_FMT 0170000 -#define NFSMODE_DIR 0040000 -#define NFSMODE_CHR 0020000 -#define NFSMODE_BLK 0060000 -#define NFSMODE_REG 0100000 -#define NFSMODE_LNK 0120000 -#define NFSMODE_SOCK 0140000 -#define NFSMODE_FIFO 0010000 - -enum nfsstat { - NFS_OK = 0, - NFSERR_PERM = 1, - NFSERR_NOENT = 2, - NFSERR_IO = 5, - NFSERR_NXIO = 6, - NFSERR_ACCES = 13, - NFSERR_EXIST = 17, - NFSERR_NODEV = 19, - NFSERR_NOTDIR = 20, - NFSERR_ISDIR = 21, - NFSERR_FBIG = 27, - NFSERR_NOSPC = 28, - NFSERR_ROFS = 30, - NFSERR_NAMETOOLONG = 63, - NFSERR_NOTEMPTY = 66, - NFSERR_DQUOT = 69, - NFSERR_STALE = 70, - NFSERR_WFLUSH = 99, -}; -typedef enum nfsstat nfsstat; -#ifdef __cplusplus -extern "C" bool_t xdr_nfsstat(XDR *, nfsstat*); -#elif __STDC__ -extern bool_t xdr_nfsstat(XDR *, nfsstat*); -#else /* Old Style C */ -bool_t xdr_nfsstat(); -#endif /* Old Style C */ - - -enum ftype { - NFNON = 0, - NFREG = 1, - NFDIR = 2, - NFBLK = 3, - NFCHR = 4, - NFLNK = 5, - NFSOCK = 6, - NFBAD = 7, - NFFIFO = 8, -}; -typedef enum ftype ftype; -#ifdef __cplusplus -extern "C" bool_t xdr_ftype(XDR *, ftype*); -#elif __STDC__ -extern bool_t xdr_ftype(XDR *, ftype*); -#else /* Old Style C */ -bool_t xdr_ftype(); -#endif /* Old Style C */ - - -struct nfs_fh { - char data[NFS_FHSIZE]; -}; -typedef struct nfs_fh nfs_fh; -#ifdef __cplusplus -extern "C" bool_t xdr_nfs_fh(XDR *, nfs_fh*); -#elif __STDC__ -extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); -#else /* Old Style C */ -bool_t xdr_nfs_fh(); -#endif /* Old Style C */ - - -struct nfstime { - u_int seconds; - u_int useconds; -}; -typedef struct nfstime nfstime; -#ifdef __cplusplus -extern "C" bool_t xdr_nfstime(XDR *, nfstime*); -#elif __STDC__ -extern bool_t xdr_nfstime(XDR *, nfstime*); -#else /* Old Style C */ -bool_t xdr_nfstime(); -#endif /* Old Style C */ - - -struct fattr { - ftype type; - u_int mode; - u_int nlink; - u_int uid; - u_int gid; - u_int size; - u_int blocksize; - u_int rdev; - u_int blocks; - u_int fsid; - u_int fileid; - nfstime atime; - nfstime mtime; - nfstime ctime; -}; -typedef struct fattr fattr; -#ifdef __cplusplus -extern "C" bool_t xdr_fattr(XDR *, fattr*); -#elif __STDC__ -extern bool_t xdr_fattr(XDR *, fattr*); -#else /* Old Style C */ -bool_t xdr_fattr(); -#endif /* Old Style C */ - - -struct sattr { - u_int mode; - u_int uid; - u_int gid; - u_int size; - nfstime atime; - nfstime mtime; -}; -typedef struct sattr sattr; -#ifdef __cplusplus -extern "C" bool_t xdr_sattr(XDR *, sattr*); -#elif __STDC__ -extern bool_t xdr_sattr(XDR *, sattr*); -#else /* Old Style C */ -bool_t xdr_sattr(); -#endif /* Old Style C */ - - -typedef char *filename; -#ifdef __cplusplus -extern "C" bool_t xdr_filename(XDR *, filename*); -#elif __STDC__ -extern bool_t xdr_filename(XDR *, filename*); -#else /* Old Style C */ -bool_t xdr_filename(); -#endif /* Old Style C */ - - -typedef char *nfspath; -#ifdef __cplusplus -extern "C" bool_t xdr_nfspath(XDR *, nfspath*); -#elif __STDC__ -extern bool_t xdr_nfspath(XDR *, nfspath*); -#else /* Old Style C */ -bool_t xdr_nfspath(); -#endif /* Old Style C */ - - -struct attrstat { - nfsstat status; - union { - fattr attributes; - } attrstat_u; -}; -typedef struct attrstat attrstat; -#ifdef __cplusplus -extern "C" bool_t xdr_attrstat(XDR *, attrstat*); -#elif __STDC__ -extern bool_t xdr_attrstat(XDR *, attrstat*); -#else /* Old Style C */ -bool_t xdr_attrstat(); -#endif /* Old Style C */ - - -struct sattrargs { - nfs_fh file; - sattr attributes; -}; -typedef struct sattrargs sattrargs; -#ifdef __cplusplus -extern "C" bool_t xdr_sattrargs(XDR *, sattrargs*); -#elif __STDC__ -extern bool_t xdr_sattrargs(XDR *, sattrargs*); -#else /* Old Style C */ -bool_t xdr_sattrargs(); -#endif /* Old Style C */ - - -struct diropargs { - nfs_fh dir; - filename name; -}; -typedef struct diropargs diropargs; -#ifdef __cplusplus -extern "C" bool_t xdr_diropargs(XDR *, diropargs*); -#elif __STDC__ -extern bool_t xdr_diropargs(XDR *, diropargs*); -#else /* Old Style C */ -bool_t xdr_diropargs(); -#endif /* Old Style C */ - - -struct diropokres { - nfs_fh file; - fattr attributes; -}; -typedef struct diropokres diropokres; -#ifdef __cplusplus -extern "C" bool_t xdr_diropokres(XDR *, diropokres*); -#elif __STDC__ -extern bool_t xdr_diropokres(XDR *, diropokres*); -#else /* Old Style C */ -bool_t xdr_diropokres(); -#endif /* Old Style C */ - - -struct diropres { - nfsstat status; - union { - diropokres diropres; - } diropres_u; -}; -typedef struct diropres diropres; -#ifdef __cplusplus -extern "C" bool_t xdr_diropres(XDR *, diropres*); -#elif __STDC__ -extern bool_t xdr_diropres(XDR *, diropres*); -#else /* Old Style C */ -bool_t xdr_diropres(); -#endif /* Old Style C */ - - -struct readlinkres { - nfsstat status; - union { - nfspath data; - } readlinkres_u; -}; -typedef struct readlinkres readlinkres; -#ifdef __cplusplus -extern "C" bool_t xdr_readlinkres(XDR *, readlinkres*); -#elif __STDC__ -extern bool_t xdr_readlinkres(XDR *, readlinkres*); -#else /* Old Style C */ -bool_t xdr_readlinkres(); -#endif /* Old Style C */ - - -struct readargs { - nfs_fh file; - u_int offset; - u_int count; - u_int totalcount; -}; -typedef struct readargs readargs; -#ifdef __cplusplus -extern "C" bool_t xdr_readargs(XDR *, readargs*); -#elif __STDC__ -extern bool_t xdr_readargs(XDR *, readargs*); -#else /* Old Style C */ -bool_t xdr_readargs(); -#endif /* Old Style C */ - - -struct readokres { - fattr attributes; - struct { - u_int data_len; - char *data_val; - } data; -}; -typedef struct readokres readokres; -#ifdef __cplusplus -extern "C" bool_t xdr_readokres(XDR *, readokres*); -#elif __STDC__ -extern bool_t xdr_readokres(XDR *, readokres*); -#else /* Old Style C */ -bool_t xdr_readokres(); -#endif /* Old Style C */ - - -struct readres { - nfsstat status; - union { - readokres reply; - } readres_u; -}; -typedef struct readres readres; -#ifdef __cplusplus -extern "C" bool_t xdr_readres(XDR *, readres*); -#elif __STDC__ -extern bool_t xdr_readres(XDR *, readres*); -#else /* Old Style C */ -bool_t xdr_readres(); -#endif /* Old Style C */ - - -struct writeargs { - nfs_fh file; - u_int beginoffset; - u_int offset; - u_int totalcount; - struct { - u_int data_len; - char *data_val; - } data; -}; -typedef struct writeargs writeargs; -#ifdef __cplusplus -extern "C" bool_t xdr_writeargs(XDR *, writeargs*); -#elif __STDC__ -extern bool_t xdr_writeargs(XDR *, writeargs*); -#else /* Old Style C */ -bool_t xdr_writeargs(); -#endif /* Old Style C */ - - -struct createargs { - diropargs where; - sattr attributes; -}; -typedef struct createargs createargs; -#ifdef __cplusplus -extern "C" bool_t xdr_createargs(XDR *, createargs*); -#elif __STDC__ -extern bool_t xdr_createargs(XDR *, createargs*); -#else /* Old Style C */ -bool_t xdr_createargs(); -#endif /* Old Style C */ - - -struct renameargs { - diropargs from; - diropargs to; -}; -typedef struct renameargs renameargs; -#ifdef __cplusplus -extern "C" bool_t xdr_renameargs(XDR *, renameargs*); -#elif __STDC__ -extern bool_t xdr_renameargs(XDR *, renameargs*); -#else /* Old Style C */ -bool_t xdr_renameargs(); -#endif /* Old Style C */ - - -struct linkargs { - nfs_fh from; - diropargs to; -}; -typedef struct linkargs linkargs; -#ifdef __cplusplus -extern "C" bool_t xdr_linkargs(XDR *, linkargs*); -#elif __STDC__ -extern bool_t xdr_linkargs(XDR *, linkargs*); -#else /* Old Style C */ -bool_t xdr_linkargs(); -#endif /* Old Style C */ - - -struct symlinkargs { - diropargs from; - nfspath to; - sattr attributes; -}; -typedef struct symlinkargs symlinkargs; -#ifdef __cplusplus -extern "C" bool_t xdr_symlinkargs(XDR *, symlinkargs*); -#elif __STDC__ -extern bool_t xdr_symlinkargs(XDR *, symlinkargs*); -#else /* Old Style C */ -bool_t xdr_symlinkargs(); -#endif /* Old Style C */ - - -typedef char nfscookie[NFS_COOKIESIZE]; -#ifdef __cplusplus -extern "C" bool_t xdr_nfscookie(XDR *, nfscookie); -#elif __STDC__ -extern bool_t xdr_nfscookie(XDR *, nfscookie); -#else /* Old Style C */ -bool_t xdr_nfscookie(); -#endif /* Old Style C */ - - -struct readdirargs { - nfs_fh dir; - nfscookie cookie; - u_int count; -}; -typedef struct readdirargs readdirargs; -#ifdef __cplusplus -extern "C" bool_t xdr_readdirargs(XDR *, readdirargs*); -#elif __STDC__ -extern bool_t xdr_readdirargs(XDR *, readdirargs*); -#else /* Old Style C */ -bool_t xdr_readdirargs(); -#endif /* Old Style C */ - - -struct entry { - u_int fileid; - filename name; - nfscookie cookie; - struct entry *nextentry; -}; -typedef struct entry entry; -#ifdef __cplusplus -extern "C" bool_t xdr_entry(XDR *, entry*); -#elif __STDC__ -extern bool_t xdr_entry(XDR *, entry*); -#else /* Old Style C */ -bool_t xdr_entry(); -#endif /* Old Style C */ - - -struct dirlist { - entry *entries; - bool_t eof; -}; -typedef struct dirlist dirlist; -#ifdef __cplusplus -extern "C" bool_t xdr_dirlist(XDR *, dirlist*); -#elif __STDC__ -extern bool_t xdr_dirlist(XDR *, dirlist*); -#else /* Old Style C */ -bool_t xdr_dirlist(); -#endif /* Old Style C */ - - -struct readdirres { - nfsstat status; - union { - dirlist reply; - } readdirres_u; -}; -typedef struct readdirres readdirres; -#ifdef __cplusplus -extern "C" bool_t xdr_readdirres(XDR *, readdirres*); -#elif __STDC__ -extern bool_t xdr_readdirres(XDR *, readdirres*); -#else /* Old Style C */ -bool_t xdr_readdirres(); -#endif /* Old Style C */ - - -struct statfsokres { - u_int tsize; - u_int bsize; - u_int blocks; - u_int bfree; - u_int bavail; -}; -typedef struct statfsokres statfsokres; -#ifdef __cplusplus -extern "C" bool_t xdr_statfsokres(XDR *, statfsokres*); -#elif __STDC__ -extern bool_t xdr_statfsokres(XDR *, statfsokres*); -#else /* Old Style C */ -bool_t xdr_statfsokres(); -#endif /* Old Style C */ - - -struct statfsres { - nfsstat status; - union { - statfsokres reply; - } statfsres_u; -}; -typedef struct statfsres statfsres; -#ifdef __cplusplus -extern "C" bool_t xdr_statfsres(XDR *, statfsres*); -#elif __STDC__ -extern bool_t xdr_statfsres(XDR *, statfsres*); -#else /* Old Style C */ -bool_t xdr_statfsres(); -#endif /* Old Style C */ - - -#define NFS_PROGRAM ((u_long)100003) -#define NFS_VERSION ((u_long)2) - -#ifdef __cplusplus -#define NFSPROC_NULL ((u_long)0) -extern "C" void * nfsproc_null_2(void *, CLIENT *); -extern "C" void * nfsproc_null_2_svc(void *, struct svc_req *); -#define NFSPROC_GETATTR ((u_long)1) -extern "C" attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *); -extern "C" attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_SETATTR ((u_long)2) -extern "C" attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *); -extern "C" attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *); -#define NFSPROC_ROOT ((u_long)3) -extern "C" void * nfsproc_root_2(void *, CLIENT *); -extern "C" void * nfsproc_root_2_svc(void *, struct svc_req *); -#define NFSPROC_LOOKUP ((u_long)4) -extern "C" diropres * nfsproc_lookup_2(diropargs *, CLIENT *); -extern "C" diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READLINK ((u_long)5) -extern "C" readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *); -extern "C" readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_READ ((u_long)6) -extern "C" readres * nfsproc_read_2(readargs *, CLIENT *); -extern "C" readres * nfsproc_read_2_svc(readargs *, struct svc_req *); -#define NFSPROC_WRITECACHE ((u_long)7) -extern "C" void * nfsproc_writecache_2(void *, CLIENT *); -extern "C" void * nfsproc_writecache_2_svc(void *, struct svc_req *); -#define NFSPROC_WRITE ((u_long)8) -extern "C" attrstat * nfsproc_write_2(writeargs *, CLIENT *); -extern "C" attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *); -#define NFSPROC_CREATE ((u_long)9) -extern "C" diropres * nfsproc_create_2(createargs *, CLIENT *); -extern "C" diropres * nfsproc_create_2_svc(createargs *, struct svc_req *); -#define NFSPROC_REMOVE ((u_long)10) -extern "C" nfsstat * nfsproc_remove_2(diropargs *, CLIENT *); -extern "C" nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_RENAME ((u_long)11) -extern "C" nfsstat * nfsproc_rename_2(renameargs *, CLIENT *); -extern "C" nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *); -#define NFSPROC_LINK ((u_long)12) -extern "C" nfsstat * nfsproc_link_2(linkargs *, CLIENT *); -extern "C" nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *); -#define NFSPROC_SYMLINK ((u_long)13) -extern "C" nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *); -extern "C" nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *); -#define NFSPROC_MKDIR ((u_long)14) -extern "C" diropres * nfsproc_mkdir_2(createargs *, CLIENT *); -extern "C" diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *); -#define NFSPROC_RMDIR ((u_long)15) -extern "C" nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *); -extern "C" nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READDIR ((u_long)16) -extern "C" readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *); -extern "C" readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *); -#define NFSPROC_STATFS ((u_long)17) -extern "C" statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *); -extern "C" statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); - -#elif __STDC__ -#define NFSPROC_NULL ((u_long)0) -extern void * nfsproc_null_2(void *, CLIENT *); -extern void * nfsproc_null_2_svc(void *, struct svc_req *); -#define NFSPROC_GETATTR ((u_long)1) -extern attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *); -extern attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_SETATTR ((u_long)2) -extern attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *); -extern attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *); -#define NFSPROC_ROOT ((u_long)3) -extern void * nfsproc_root_2(void *, CLIENT *); -extern void * nfsproc_root_2_svc(void *, struct svc_req *); -#define NFSPROC_LOOKUP ((u_long)4) -extern diropres * nfsproc_lookup_2(diropargs *, CLIENT *); -extern diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READLINK ((u_long)5) -extern readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *); -extern readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_READ ((u_long)6) -extern readres * nfsproc_read_2(readargs *, CLIENT *); -extern readres * nfsproc_read_2_svc(readargs *, struct svc_req *); -#define NFSPROC_WRITECACHE ((u_long)7) -extern void * nfsproc_writecache_2(void *, CLIENT *); -extern void * nfsproc_writecache_2_svc(void *, struct svc_req *); -#define NFSPROC_WRITE ((u_long)8) -extern attrstat * nfsproc_write_2(writeargs *, CLIENT *); -extern attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *); -#define NFSPROC_CREATE ((u_long)9) -extern diropres * nfsproc_create_2(createargs *, CLIENT *); -extern diropres * nfsproc_create_2_svc(createargs *, struct svc_req *); -#define NFSPROC_REMOVE ((u_long)10) -extern nfsstat * nfsproc_remove_2(diropargs *, CLIENT *); -extern nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_RENAME ((u_long)11) -extern nfsstat * nfsproc_rename_2(renameargs *, CLIENT *); -extern nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *); -#define NFSPROC_LINK ((u_long)12) -extern nfsstat * nfsproc_link_2(linkargs *, CLIENT *); -extern nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *); -#define NFSPROC_SYMLINK ((u_long)13) -extern nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *); -extern nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *); -#define NFSPROC_MKDIR ((u_long)14) -extern diropres * nfsproc_mkdir_2(createargs *, CLIENT *); -extern diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *); -#define NFSPROC_RMDIR ((u_long)15) -extern nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *); -extern nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READDIR ((u_long)16) -extern readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *); -extern readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *); -#define NFSPROC_STATFS ((u_long)17) -extern statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *); -extern statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); - -#else /* Old Style C */ -#define NFSPROC_NULL ((u_long)0) -extern void * nfsproc_null_2(); -extern void * nfsproc_null_2_svc(); -#define NFSPROC_GETATTR ((u_long)1) -extern attrstat * nfsproc_getattr_2(); -extern attrstat * nfsproc_getattr_2_svc(); -#define NFSPROC_SETATTR ((u_long)2) -extern attrstat * nfsproc_setattr_2(); -extern attrstat * nfsproc_setattr_2_svc(); -#define NFSPROC_ROOT ((u_long)3) -extern void * nfsproc_root_2(); -extern void * nfsproc_root_2_svc(); -#define NFSPROC_LOOKUP ((u_long)4) -extern diropres * nfsproc_lookup_2(); -extern diropres * nfsproc_lookup_2_svc(); -#define NFSPROC_READLINK ((u_long)5) -extern readlinkres * nfsproc_readlink_2(); -extern readlinkres * nfsproc_readlink_2_svc(); -#define NFSPROC_READ ((u_long)6) -extern readres * nfsproc_read_2(); -extern readres * nfsproc_read_2_svc(); -#define NFSPROC_WRITECACHE ((u_long)7) -extern void * nfsproc_writecache_2(); -extern void * nfsproc_writecache_2_svc(); -#define NFSPROC_WRITE ((u_long)8) -extern attrstat * nfsproc_write_2(); -extern attrstat * nfsproc_write_2_svc(); -#define NFSPROC_CREATE ((u_long)9) -extern diropres * nfsproc_create_2(); -extern diropres * nfsproc_create_2_svc(); -#define NFSPROC_REMOVE ((u_long)10) -extern nfsstat * nfsproc_remove_2(); -extern nfsstat * nfsproc_remove_2_svc(); -#define NFSPROC_RENAME ((u_long)11) -extern nfsstat * nfsproc_rename_2(); -extern nfsstat * nfsproc_rename_2_svc(); -#define NFSPROC_LINK ((u_long)12) -extern nfsstat * nfsproc_link_2(); -extern nfsstat * nfsproc_link_2_svc(); -#define NFSPROC_SYMLINK ((u_long)13) -extern nfsstat * nfsproc_symlink_2(); -extern nfsstat * nfsproc_symlink_2_svc(); -#define NFSPROC_MKDIR ((u_long)14) -extern diropres * nfsproc_mkdir_2(); -extern diropres * nfsproc_mkdir_2_svc(); -#define NFSPROC_RMDIR ((u_long)15) -extern nfsstat * nfsproc_rmdir_2(); -extern nfsstat * nfsproc_rmdir_2_svc(); -#define NFSPROC_READDIR ((u_long)16) -extern readdirres * nfsproc_readdir_2(); -extern readdirres * nfsproc_readdir_2_svc(); -#define NFSPROC_STATFS ((u_long)17) -extern statfsres * nfsproc_statfs_2(); -extern statfsres * nfsproc_statfs_2_svc(); -#endif /* Old Style C */ - -#endif /* !_NFS_PROT_H_RPCGEN */ diff --git a/nfs-utils-2.5.2/support/include/sockaddr.h b/nfs-utils-2.5.2/support/include/sockaddr.h deleted file mode 100644 index eeebcdf..0000000 --- a/nfs-utils-2.5.2/support/include/sockaddr.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -#ifndef NFS_UTILS_SOCKADDR_H -#define NFS_UTILS_SOCKADDR_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -/* - * This type is for defining buffers that contain network socket - * addresses. - * - * Casting a "struct sockaddr *" to the address of a "struct - * sockaddr_storage" breaks C aliasing rules. The "union - * nfs_sockaddr" type follows C aliasing rules yet specifically - * allows converting pointers to it between "struct sockaddr *" - * and a few other network sockaddr-related pointer types. - * - * Note that this union is much smaller than a sockaddr_storage. - * It should be used only for AF_INET or AF_INET6 socket addresses. - * An AF_LOCAL sockaddr_un, for example, will clearly not fit into - * a buffer of this type. - */ -union nfs_sockaddr { - struct sockaddr sa; - struct sockaddr_in s4; - struct sockaddr_in6 s6; -}; - -#if SIZEOF_SOCKLEN_T - 0 == 0 -#define socklen_t unsigned int -#endif - -#define SIZEOF_SOCKADDR_UNKNOWN (socklen_t)0 -#define SIZEOF_SOCKADDR_IN (socklen_t)sizeof(struct sockaddr_in) - -#ifdef IPV6_SUPPORTED -#define SIZEOF_SOCKADDR_IN6 (socklen_t)sizeof(struct sockaddr_in6) -#else /* !IPV6_SUPPORTED */ -#define SIZEOF_SOCKADDR_IN6 SIZEOF_SOCKADDR_UNKNOWN -#endif /* !IPV6_SUPPORTED */ - -/** - * nfs_sockaddr_length - return the size in bytes of a socket address - * @sap: pointer to socket address - * - * Returns the size in bytes of @sap, or zero if the family is - * not recognized. - */ -static inline socklen_t -nfs_sockaddr_length(const struct sockaddr *sap) -{ - switch (sap->sa_family) { - case AF_INET: - return SIZEOF_SOCKADDR_IN; - case AF_INET6: - return SIZEOF_SOCKADDR_IN6; - } - return SIZEOF_SOCKADDR_UNKNOWN; -} - -static inline uint16_t -get_port4(const struct sockaddr *sap) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - return ntohs(sin->sin_port); -} - -#ifdef IPV6_SUPPORTED -static inline uint16_t -get_port6(const struct sockaddr *sap) -{ - const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; - return ntohs(sin6->sin6_port); -} -#else /* !IPV6_SUPPORTED */ -static inline uint16_t -get_port6(__attribute__ ((unused)) const struct sockaddr *sap) -{ - return 0; -} -#endif /* !IPV6_SUPPORTED */ - -/** - * nfs_get_port - extract port value from a socket address - * @sap: pointer to socket address - * - * Returns port value in host byte order, or zero if the - * socket address contains an unrecognized family. - */ -static inline uint16_t -nfs_get_port(const struct sockaddr *sap) -{ - switch (sap->sa_family) { - case AF_INET: - return get_port4(sap); - case AF_INET6: - return get_port6(sap); - } - return 0; -} - -static inline void -set_port4(struct sockaddr *sap, const uint16_t port) -{ - struct sockaddr_in *sin = (struct sockaddr_in *)sap; - sin->sin_port = htons(port); -} - -#ifdef IPV6_SUPPORTED -static inline void -set_port6(struct sockaddr *sap, const uint16_t port) -{ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; - sin6->sin6_port = htons(port); -} -#else /* !IPV6_SUPPORTED */ -static inline void -set_port6(__attribute__ ((unused)) struct sockaddr *sap, - __attribute__ ((unused)) const uint16_t port) -{ -} -#endif /* !IPV6_SUPPORTED */ - -/** - * nfs_set_port - set port value in a socket address - * @sap: pointer to socket address - * @port: port value to set - * - */ -static inline void -nfs_set_port(struct sockaddr *sap, const uint16_t port) -{ - switch (sap->sa_family) { - case AF_INET: - set_port4(sap, port); - break; - case AF_INET6: - set_port6(sap, port); - break; - } -} - -/** - * nfs_is_v4_loopback - test to see if socket address is AF_INET loopback - * @sap: pointer to socket address - * - * Returns true if the socket address is the standard IPv4 loopback - * address; otherwise false is returned. - */ -static inline _Bool -nfs_is_v4_loopback(const struct sockaddr *sap) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - - if (sin->sin_family != AF_INET) - return false; - if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) - return false; - return true; -} - -static inline _Bool -compare_sockaddr4(const struct sockaddr *sa1, const struct sockaddr *sa2) -{ - const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1; - const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2; - return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; -} - -#ifdef IPV6_SUPPORTED -static inline _Bool -compare_sockaddr6(const struct sockaddr *sa1, const struct sockaddr *sa2) -{ - const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1; - const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2; - const struct in6_addr *saddr1 = &sin1->sin6_addr; - const struct in6_addr *saddr2 = &sin2->sin6_addr; - - if (IN6_IS_ADDR_LINKLOCAL(saddr1) && IN6_IS_ADDR_LINKLOCAL(saddr2)) - if (sin1->sin6_scope_id != sin2->sin6_scope_id) - return false; - - return IN6_ARE_ADDR_EQUAL(saddr1, saddr2); -} -#else /* !IPV6_SUPPORTED */ -static inline _Bool -compare_sockaddr6(__attribute__ ((unused)) const struct sockaddr *sa1, - __attribute__ ((unused)) const struct sockaddr *sa2) -{ - return false; -} -#endif /* !IPV6_SUPPORTED */ - -/** - * nfs_compare_sockaddr - compare two socket addresses for equality - * @sa1: pointer to a socket address - * @sa2: pointer to a socket address - * - * Returns true if the two socket addresses contain equivalent - * network addresses; otherwise false is returned. - */ -static inline _Bool -nfs_compare_sockaddr(const struct sockaddr *sa1, const struct sockaddr *sa2) -{ - if (sa1 == NULL || sa2 == NULL) - return false; - - if (sa1->sa_family == sa2->sa_family) - switch (sa1->sa_family) { - case AF_INET: - return compare_sockaddr4(sa1, sa2); - case AF_INET6: - return compare_sockaddr6(sa1, sa2); - } - - return false; -} - -#endif /* !NFS_UTILS_SOCKADDR_H */ diff --git a/nfs-utils-2.5.2/support/include/sys/Makefile.am b/nfs-utils-2.5.2/support/include/sys/Makefile.am deleted file mode 100644 index aead11d..0000000 --- a/nfs-utils-2.5.2/support/include/sys/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = fs - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/include/sys/fs/Makefile.am b/nfs-utils-2.5.2/support/include/sys/fs/Makefile.am deleted file mode 100644 index 9d5fa43..0000000 --- a/nfs-utils-2.5.2/support/include/sys/fs/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_HEADERS = ext2fs.h - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/include/sys/fs/ext2fs.h b/nfs-utils-2.5.2/support/include/sys/fs/ext2fs.h deleted file mode 100644 index 93b3e2b..0000000 --- a/nfs-utils-2.5.2/support/include/sys/fs/ext2fs.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _SYS_FS_EXT2FS_H -#define _SYS_FS_EXT2FS_H - -/* - * ioctl commands - */ -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) -#define EXT2_IOC_GETVERSION _IOR('v', 1, long) -#define EXT2_IOC_SETVERSION _IOW('v', 2, long) - -/* - * File system states - */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ - -/* - * Mount flags - */ -#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */ -#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */ -#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \ - EXT2_MOUNT_CHECK_STRICT) -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ -#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ - -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ - EXT2_MOUNT_##opt) -/* - * Maximal mount counts between two filesystem checks - */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ - -#endif /* _SYS_FS_EXT2FS_H */ diff --git a/nfs-utils-2.5.2/support/include/tcpwrapper.h b/nfs-utils-2.5.2/support/include/tcpwrapper.h deleted file mode 100644 index f735106..0000000 --- a/nfs-utils-2.5.2/support/include/tcpwrapper.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef TCP_WRAPPER_H -#define TCP_WRAPPER_H - -#include -#include -#include - -extern int from_local(const struct sockaddr *sap); -extern int check_default(char *name, struct sockaddr *sap, - const unsigned long program); - -#endif /* TCP_WRAPPER_H */ diff --git a/nfs-utils-2.5.2/support/include/v4root.h b/nfs-utils-2.5.2/support/include/v4root.h deleted file mode 100644 index 706c15c..0000000 --- a/nfs-utils-2.5.2/support/include/v4root.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat - * support/include/v4root.h - * - * Support routines for dynamic pseudo roots. - * - */ - -#ifndef V4ROOT_H -#define V4ROOT_H - -extern int v4root_needed; -extern void v4root_set(void); - -#endif /* V4ROOT_H */ diff --git a/nfs-utils-2.5.2/support/include/workqueue.h b/nfs-utils-2.5.2/support/include/workqueue.h deleted file mode 100644 index 518be82..0000000 --- a/nfs-utils-2.5.2/support/include/workqueue.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2019 Trond Myklebust - */ -#ifndef WORKQUEUE_H -#define WORKQUEUE_H - -struct xthread_workqueue; - -struct xthread_workqueue *xthread_workqueue_alloc(void); -void xthread_workqueue_shutdown(struct xthread_workqueue *wq); - -void xthread_work_run_sync(struct xthread_workqueue *wq, - void (*fn)(void *), void *data); - -void xthread_workqueue_chroot(struct xthread_workqueue *wq, - const char *path); - -#endif diff --git a/nfs-utils-2.5.2/support/include/xcommon.h b/nfs-utils-2.5.2/support/include/xcommon.h deleted file mode 100644 index efde83c..0000000 --- a/nfs-utils-2.5.2/support/include/xcommon.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * xcommon.h -- Support function prototypes. Functions are in xcommon.c. - * - * 2006-06-06 Amit Gud - * - Moved code snippets from mount/sundries.h of util-linux - * and merged code from support/nfs/xmalloc.c by Olaf Kirch here. - */ - -#ifndef _XMALLOC_H -#define _XMALLOC_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MAJOR_IN_MKDEV -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif - -#define streq(s, t) (strcmp ((s), (t)) == 0) - -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define X_FORMAT(_x) __attribute__((__format__ _x)) -#else -#define X_FORMAT(_x) -#endif - -/* Functions in sundries.c that are used in mount.c and umount.c */ -char *canonicalize (const char *path); -void nfs_error (const char *fmt, ...) X_FORMAT((printf, 1, 2)); -void *xmalloc (size_t size); -void *xrealloc(void *p, size_t size); -void xfree(void *); -char *xstrdup (const char *s); -char *xstrndup (const char *s, int n); -char *xstrconcat2 (const char *, const char *); -char *xstrconcat3 (const char *, const char *, const char *); -char *xstrconcat4 (const char *, const char *, const char *, const char *); -void die (int errcode, const char *fmt, ...) X_FORMAT((printf, 2, 3)); - -extern void die(int err, const char *fmt, ...) X_FORMAT((printf, 2, 3)); -extern void (*at_die)(void); - -/* exit status - bits below are ORed */ -#define EX_SUCCESS 0 /* no failure occurred */ -#define EX_USAGE 1 /* incorrect invocation or permission */ -#define EX_SYSERR 2 /* out of memory, cannot fork, ... */ -#define EX_SOFTWARE 4 /* internal mount bug or wrong version */ -#define EX_USER 8 /* user interrupt */ -#define EX_FILEIO 16 /* problems writing, locking, ... mtab/fstab */ -#define EX_FAIL 32 /* mount failure */ -#define EX_SOMEOK 64 /* some mount succeeded */ -#define EX_BG 256 /* retry in background (internal only) */ - -#endif /* XMALLOC_H */ diff --git a/nfs-utils-2.5.2/support/include/xio.h b/nfs-utils-2.5.2/support/include/xio.h deleted file mode 100644 index a8e288e..0000000 --- a/nfs-utils-2.5.2/support/include/xio.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * xio.h Declarations for simple parsing functions. - * - */ - -#ifndef XIO_H -#define XIO_H - -#include - -typedef struct XFILE { - FILE *x_fp; - int x_line; -} XFILE; - -XFILE *xfopen(char *fname, char *type); -int xflock(char *fname, char *type); -void xfunlock(int lockid); -void xfclose(XFILE *xfp); -int xgettok(XFILE *xfp, char sepa, char *tok, int len); -int xgetc(XFILE *xfp); -void xungetc(int c, XFILE *xfp); -void xskip(XFILE *xfp, char *str); -char xskipcomment(XFILE *xfp); - -#endif /* XIO_H */ diff --git a/nfs-utils-2.5.2/support/include/xlog.h b/nfs-utils-2.5.2/support/include/xlog.h deleted file mode 100644 index 32ff5a1..0000000 --- a/nfs-utils-2.5.2/support/include/xlog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * xlog Logging functionality - * - * Copyright (C) 1995 Olaf Kirch - */ - -#ifndef XLOG_H -#define XLOG_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -/* These are logged always. L_FATAL also does exit(1) */ -#define L_FATAL 0x0100 -#define L_ERROR 0x0200 -#define L_WARNING 0x0400 -#define L_NOTICE 0x0800 -#define L_ALL 0xFF00 - -/* These are logged if enabled with xlog_[s]config */ -/* NB: code does not expect ORing together D_ and L_ */ -#define D_GENERAL 0x0001 /* general debug info */ -#define D_CALL 0x0002 -#define D_AUTH 0x0004 -#define D_FAC3 0x0008 -#define D_FAC4 0x0010 -#define D_FAC5 0x0020 -#define D_PARSE 0x0040 -#define D_FAC7 0x0080 -#define D_ALL 0x00FF - -/* This can be used to define symbolic log names that can be passed to - * xlog_config. */ -struct xlog_debugfac { - char *df_name; - int df_fac; -}; - -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define XLOG_FORMAT(_x) __attribute__((__format__ _x)) -#else -#define XLOG_FORMAT(_x) -#endif - -extern int export_errno; -void xlog_open(char *progname); -void xlog_stderr(int on); -void xlog_syslog(int on); -void xlog_config(int fac, int on); -void xlog_sconfig(char *, int on); -void xlog_from_conffile(char *); -int xlog_enabled(int fac); -void xlog(int fac, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_warn(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_err(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_errno(int err, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_backend(int fac, const char *fmt, va_list args) XLOG_FORMAT((printf, 2, 0)); - -#endif /* XLOG_H */ diff --git a/nfs-utils-2.5.2/support/include/xmalloc.h b/nfs-utils-2.5.2/support/include/xmalloc.h deleted file mode 100644 index 8b82800..0000000 --- a/nfs-utils-2.5.2/support/include/xmalloc.h +++ /dev/null @@ -1 +0,0 @@ -#include "xcommon.h" diff --git a/nfs-utils-2.5.2/support/include/xstat.h b/nfs-utils-2.5.2/support/include/xstat.h deleted file mode 100644 index f1241bb..0000000 --- a/nfs-utils-2.5.2/support/include/xstat.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (C) 2019 Trond Myklebust - */ -#ifndef XSTAT_H -#define XSTAT_H - -struct stat; - -int xlstat(const char *pathname, struct stat *statbuf); -int xstat(const char *pathname, struct stat *statbuf); -#endif diff --git a/nfs-utils-2.5.2/support/junction/Makefile.am b/nfs-utils-2.5.2/support/junction/Makefile.am deleted file mode 100644 index be6958b..0000000 --- a/nfs-utils-2.5.2/support/junction/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -## -## @file support/junction/Makefile.am -## @brief Process this file with automake to produce src/libjunction/Makefile.in -## - -## -## Copyright 2010, 2018 Oracle. All rights reserved. -## -## This file is part of nfs-utils. -## -## nfs-utils is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License version 2.0 as -## published by the Free Software Foundation. -## -## nfs-utils is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License version 2.0 for more details. -## -## You should have received a copy of the GNU General Public License -## version 2.0 along with nfs-utils. If not, see: -## -## http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt -## - -noinst_HEADERS = junction-internal.h - -noinst_LTLIBRARIES = libjunction.la -libjunction_la_SOURCES = display.c export-cache.c junction.c \ - locations.c nfs.c path.c xml.c - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/junction/display.c b/nfs-utils-2.5.2/support/junction/display.c deleted file mode 100644 index e1e1af1..0000000 --- a/nfs-utils-2.5.2/support/junction/display.c +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @file support/junction/display.c - * @brief Shared display helper functions - */ - -/* - * Copyright 2010, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include -#include -#include -#include - -#include "junction.h" - -/** - * Return human-readable equivalent of a FedFsStatus value - * - * @param status FedFsStatus code - * @return a static NUL-terminated C string - */ -const char * -nsdb_display_fedfsstatus(const FedFsStatus status) -{ - switch (status) { - case FEDFS_OK: - return "FEDFS_OK"; - case FEDFS_ERR_ACCESS: - return "FEDFS_ERR_ACCESS"; - case FEDFS_ERR_BADCHAR: - return "FEDFS_ERR_BADCHAR"; - case FEDFS_ERR_BADNAME: - return "FEDFS_ERR_BADNAME"; - case FEDFS_ERR_NAMETOOLONG: - return "FEDFS_ERR_NAMETOOLONG"; - case FEDFS_ERR_LOOP: - return "FEDFS_ERR_LOOP"; - case FEDFS_ERR_BADXDR: - return "FEDFS_ERR_BADXDR"; - case FEDFS_ERR_EXIST: - return "FEDFS_ERR_EXIST"; - case FEDFS_ERR_INVAL: - return "FEDFS_ERR_INVAL"; - case FEDFS_ERR_IO: - return "FEDFS_ERR_IO"; - case FEDFS_ERR_NOSPC: - return "FEDFS_ERR_NOSPC"; - case FEDFS_ERR_NOTJUNCT: - return "FEDFS_ERR_NOTJUNCT"; - case FEDFS_ERR_NOTLOCAL: - return "FEDFS_ERR_NOTLOCAL"; - case FEDFS_ERR_PERM: - return "FEDFS_ERR_PERM"; - case FEDFS_ERR_ROFS: - return "FEDFS_ERR_ROFS"; - case FEDFS_ERR_SVRFAULT: - return "FEDFS_ERR_SVRFAULT"; - case FEDFS_ERR_NOTSUPP: - return "FEDFS_ERR_NOTSUPP"; - case FEDFS_ERR_NSDB_ROUTE: - return "FEDFS_ERR_NSDB_ROUTE"; - case FEDFS_ERR_NSDB_DOWN: - return "FEDFS_ERR_NSDB_DOWN"; - case FEDFS_ERR_NSDB_CONN: - return "FEDFS_ERR_NSDB_CONN"; - case FEDFS_ERR_NSDB_AUTH: - return "FEDFS_ERR_NSDB_AUTH"; - case FEDFS_ERR_NSDB_LDAP: - return "FEDFS_ERR_NSDB_LDAP"; - case FEDFS_ERR_NSDB_LDAP_VAL: - return "FEDFS_ERR_NSDB_LDAP_VAL"; - case FEDFS_ERR_NSDB_NONCE: - return "FEDFS_ERR_NSDB_NONCE"; - case FEDFS_ERR_NSDB_NOFSN: - return "FEDFS_ERR_NSDB_NOFSN"; - case FEDFS_ERR_NSDB_NOFSL: - return "FEDFS_ERR_NSDB_NOFSL"; - case FEDFS_ERR_NSDB_RESPONSE: - return "FEDFS_ERR_NSDB_RESPONSE"; - case FEDFS_ERR_NSDB_FAULT: - return "FEDFS_ERR_NSDB_FAULT"; - case FEDFS_ERR_NSDB_PARAMS: - return "FEDFS_ERR_NSDB_PARAMS"; - case FEDFS_ERR_NSDB_LDAP_REFERRAL: - return "FEDFS_ERR_NSDB_LDAP_REFERRAL"; - case FEDFS_ERR_NSDB_LDAP_REFERRAL_VAL: - return "FEDFS_ERR_NSDB_LDAP_REFERRAL_VAL"; - case FEDFS_ERR_NSDB_PARAMS_LDAP_REFERRAL: - return "FEDFS_ERR_NSDB_PARAMS_LDAP_REFERRAL"; - case FEDFS_ERR_PATH_TYPE_UNSUPP: - return "FEDFS_ERR_PATH_TYPE_UNSUPP"; - case FEDFS_ERR_DELAY: - return "FEDFS_ERR_DELAY"; - case FEDFS_ERR_NO_CACHE: - return "FEDFS_ERR_NO_CACHE"; - case FEDFS_ERR_UNKNOWN_CACHE: - return "FEDFS_ERR_UNKNOWN_CACHE"; - case FEDFS_ERR_NO_CACHE_UPDATE: - return "FEDFS_ERR_NO_CACHE_UPDATE"; - default: - break; - } - return "an unrecognized error code"; -} - -/** - * Display human-readable FedFsStatus on stderr - * - * @param status FedFsStatus value to display - */ -void -nsdb_print_fedfsstatus(const FedFsStatus status) -{ - if (status == FEDFS_OK) { - printf("Call completed successfully\n"); - return; - } - - fprintf(stderr, "Server returned %s\n", - nsdb_display_fedfsstatus(status)); -} diff --git a/nfs-utils-2.5.2/support/junction/export-cache.c b/nfs-utils-2.5.2/support/junction/export-cache.c deleted file mode 100644 index 4e578c9..0000000 --- a/nfs-utils-2.5.2/support/junction/export-cache.c +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file support/junction/export-cache.c - * @brief Try to flush NFSD's exports cache - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -#include "junction.h" -#include "xlog.h" - -/** - * Ordered list of proc files to poke when requesting an NFSD cache flush - */ -static const char *junction_proc_files[] = { - "/proc/net/rpc/auth.unix.ip/flush", - "/proc/net/rpc/auth.unix.gid/flush", - "/proc/net/rpc/nfsd.fh/flush", - "/proc/net/rpc/nfsd.export/flush", - NULL, -}; - -/** - * Write time into one file - * - * @param pathname NUL-terminated C string containing POSIX pathname of file to write - * @param flushtime NUL-terminated C string containing current time in seconds since the Epoch - * @return a FedFsStatus code - */ -static FedFsStatus -junction_write_time(const char *pathname, const char *flushtime) -{ - FedFsStatus retval; - ssize_t len; - int fd; - - fd = open(pathname, O_RDWR); - if (fd == -1) { - xlog(D_GENERAL, "%s: Failed to open %s: %m", - __func__, pathname); - /* If the proc files don't exist, no server - * is running on this system */ - return FEDFS_ERR_NO_CACHE_UPDATE; - } - - len = write(fd, flushtime, strlen(flushtime)); - if (len != (ssize_t)strlen(flushtime)) { - xlog(D_GENERAL, "%s: Failed to write %s: %m", - __func__, pathname); - /* If the proc files exist but the update failed, - * we don't know the state of the cache */ - retval = FEDFS_ERR_UNKNOWN_CACHE; - } else - /* Cache flush succeeded */ - retval = FEDFS_OK; - - (void)close(fd); - return retval; -} - -/** - * Flush the kernel NFSD's exports cache - * - * @return a FedFsStatus code - */ -FedFsStatus -junction_flush_exports_cache(void) -{ - FedFsStatus retval; - char flushtime[20]; - unsigned int i; - time_t now; - - xlog(D_CALL, "%s: Flushing NFSD caches...", __func__); - - now = time(NULL); - if (now == -1) { - xlog(D_GENERAL, "%s: time(3) failed", __func__); - return FEDFS_ERR_SVRFAULT; - } - snprintf(flushtime, sizeof(flushtime), "%ld\n", now); - - for (i = 0; junction_proc_files[i] != NULL; i++) { - retval = junction_write_time(junction_proc_files[i], flushtime); - if (retval != FEDFS_OK) - return retval; - } - return FEDFS_OK; -} diff --git a/nfs-utils-2.5.2/support/junction/junction-internal.h b/nfs-utils-2.5.2/support/junction/junction-internal.h deleted file mode 100644 index 3dff4cc..0000000 --- a/nfs-utils-2.5.2/support/junction/junction-internal.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * @file support/junction/junction-internal.h - * @brief Internal declarations for libjunction.a - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef _FEDFS_JUNCTION_INTERNAL_H_ -#define _FEDFS_JUNCTION_INTERNAL_H_ - -#include -#include - -/** - ** Names of extended attributes that store junction data - **/ - -/** - * Name of extended attribute containing saved mode bits - */ -#define JUNCTION_XATTR_NAME_MODE "trusted.junction.mode" - -/** - * Name of extended attribute containing NFS-related junction data - */ -#define JUNCTION_XATTR_NAME_NFS "trusted.junction.nfs" - - -/** - ** Names of XML elements and attributes that represent junction data - **/ - -/** - * Tag name of root element of a junction XML document - */ -#define JUNCTION_XML_ROOT_TAG (const xmlChar *)"junction" - -/** - * Tag name of fileset element of a junction XML document - */ -#define JUNCTION_XML_FILESET_TAG (const xmlChar *)"fileset" - -/** - * Tag name of savedmode element of a junction XML document - */ -#define JUNCTION_XML_SAVEDMODE_TAG (const xmlChar *)"savedmode" - -/** - * Name of mode bits attribute on a savedmode element - */ -#define JUNCTION_XML_MODEBITS_ATTR (const xmlChar *)"bits" - -/** - ** Junction helper functions - **/ - -FedFsStatus junction_open_path(const char *pathname, int *fd); -FedFsStatus junction_is_directory(int fd, const char *path); -FedFsStatus junction_is_sticky_bit_set(int fd, const char *path); -FedFsStatus junction_set_sticky_bit(int fd, const char *path); -FedFsStatus junction_is_xattr_present(int fd, const char *path, - const char *name); -FedFsStatus junction_read_xattr(int fd, const char *path, const char *name, - char **contents); -FedFsStatus junction_get_xattr(int fd, const char *path, const char *name, - void **contents, size_t *contentlen); -FedFsStatus junction_set_xattr(int fd, const char *path, const char *name, - const void *contents, const size_t contentlen); -FedFsStatus junction_remove_xattr(int fd, const char *pathname, - const char *name); -FedFsStatus junction_get_mode(const char *pathname, mode_t *mode); -FedFsStatus junction_save_mode(const char *pathname); -FedFsStatus junction_restore_mode(const char *pathname); - - -/** - ** XML helper functions - **/ - -_Bool junction_xml_is_empty(const xmlChar *content); -_Bool junction_xml_match_node_name(xmlNodePtr node, - const xmlChar *name); -xmlNodePtr junction_xml_find_child_by_name(xmlNodePtr parent, - const xmlChar *name); -_Bool junction_xml_get_bool_attribute(xmlNodePtr node, - const xmlChar *attrname, _Bool *value); -void junction_xml_set_bool_attribute(xmlNodePtr node, - const xmlChar *attrname, _Bool value); -_Bool junction_xml_get_u8_attribute(xmlNodePtr node, - const xmlChar *attrname, uint8_t *value); -_Bool junction_xml_get_int_attribute(xmlNodePtr node, - const xmlChar *attrname, int *value); -void junction_xml_set_int_attribute(xmlNodePtr node, - const xmlChar *attrname, int value); -_Bool junction_xml_get_int_content(xmlNodePtr node, int *value); -xmlNodePtr junction_xml_set_int_content(xmlNodePtr parent, - const xmlChar *name, int value); -FedFsStatus junction_xml_parse(const char *pathname, const char *name, - xmlDocPtr *doc); -FedFsStatus junction_xml_write(const char *pathname, const char *name, - xmlDocPtr doc); - -#endif /* !_FEDFS_JUNCTION_INTERNAL_H_ */ diff --git a/nfs-utils-2.5.2/support/junction/junction.c b/nfs-utils-2.5.2/support/junction/junction.c deleted file mode 100644 index 41cce26..0000000 --- a/nfs-utils-2.5.2/support/junction/junction.c +++ /dev/null @@ -1,498 +0,0 @@ -/** - * @file support/junction/junction.c - * @brief Common utilities for managing junctions on the local file system - */ - -/* - * Copyright 2010, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "junction.h" -#include "junction-internal.h" -#include "xlog.h" - -/** - * Open a file system object - * - * @param pathname NUL-terminated C string containing pathname of an object - * @param fd OUT: a file descriptor number is filled in - * @return a FedFsStatus code - */ -FedFsStatus -junction_open_path(const char *pathname, int *fd) -{ - int tmp; - - if (pathname == NULL || fd == NULL) - return FEDFS_ERR_INVAL; - - tmp = open(pathname, O_DIRECTORY); - if (tmp == -1) { - switch (errno) { - case EPERM: - return FEDFS_ERR_ACCESS; - case EACCES: - return FEDFS_ERR_PERM; - default: - xlog(D_GENERAL, "%s: Failed to open path %s: %m", - __func__, pathname); - return FEDFS_ERR_INVAL; - } - } - - *fd = tmp; - return FEDFS_OK; -} - -/** - * Predicate: is object a directory? - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - */ -FedFsStatus -junction_is_directory(int fd, const char *path) -{ - struct stat stb; - - if (fstat(fd, &stb) == -1) { - xlog(D_GENERAL, "%s: failed to stat %s: %m", - __func__, path); - return FEDFS_ERR_ACCESS; - } - - if (!S_ISDIR(stb.st_mode)) { - xlog(D_CALL, "%s: %s is not a directory", - __func__, path); - return FEDFS_ERR_INVAL; - } - - xlog(D_CALL, "%s: %s is a directory", __func__, path); - return FEDFS_OK; -} - -/** - * Predicate: is a directory's sticky bit set? - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - */ -FedFsStatus -junction_is_sticky_bit_set(int fd, const char *path) -{ - struct stat stb; - - if (fstat(fd, &stb) == -1) { - xlog(D_GENERAL, "%s: failed to stat %s: %m", - __func__, path); - return FEDFS_ERR_ACCESS; - } - - if (stb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) { - xlog(D_CALL, "%s: execute bit set on %s", - __func__, path); - return FEDFS_ERR_NOTJUNCT; - } - - if (!(stb.st_mode & S_ISVTX)) { - xlog(D_CALL, "%s: sticky bit not set on %s", - __func__, path); - return FEDFS_ERR_NOTJUNCT; - } - - xlog(D_CALL, "%s: sticky bit is set on %s", __func__, path); - return FEDFS_OK; -} - -/** - * Set just a directory's sticky bit - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - */ -FedFsStatus -junction_set_sticky_bit(int fd, const char *path) -{ - struct stat stb; - - if (fstat(fd, &stb) == -1) { - xlog(D_GENERAL, "%s: failed to stat %s: %m", - __func__, path); - return FEDFS_ERR_ACCESS; - } - - stb.st_mode &= (unsigned int)~ALLPERMS; - stb.st_mode |= S_ISVTX; - - if (fchmod(fd, stb.st_mode) == -1) { - xlog(D_GENERAL, "%s: failed to set sticky bit on %s: %m", - __func__, path); - return FEDFS_ERR_ROFS; - } - - xlog(D_CALL, "%s: set sticky bit on %s", __func__, path); - return FEDFS_OK; -} - -/** - * Predicate: does a directory have an xattr named "name"? - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to check - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_is_xattr_present(int fd, const char *path, const char *name) -{ - ssize_t rc; - - /* - * Do not assume the total number of extended attributes - * this object may have. - */ - rc = fgetxattr(fd, name, NULL, 0); - if (rc == -1) { - switch (errno) { - case EPERM: - xlog(D_CALL, "%s: no access to xattr %s on %s", - __func__, name, path); - return FEDFS_ERR_PERM; - case ENODATA: - xlog(D_CALL, "%s: no xattr %s present on %s", - __func__, name, path); - return FEDFS_ERR_NOTJUNCT; - default: - xlog(D_CALL, "%s: xattr %s not found on %s: %m", - __func__, name, path); - return FEDFS_ERR_IO; - } - } - - xlog(D_CALL, "%s: xattr %s found on %s", - __func__, name, path); - return FEDFS_OK; -} - -/** - * Read the contents of xattr "name" - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to retrieve - * @param contents OUT: NUL-terminated C string containing contents of xattr - * @return a FedFsStatus code - * - * If junction_read_xattr() returns FEDFS_OK, the caller must free "*contents" - * with free(3). - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_read_xattr(int fd, const char *path, const char *name, char **contents) -{ - char *xattrbuf = NULL; - ssize_t len; - - len = fgetxattr(fd, name, xattrbuf, 0); - if (len < 0) { - xlog(D_GENERAL, "%s: failed to get size of xattr %s on %s: %m", - __func__, name, path); - return FEDFS_ERR_ACCESS; - } - - xattrbuf = malloc((size_t)len + 1); - if (xattrbuf == NULL) { - xlog(D_GENERAL, "%s: failed to get buffer for xattr %s on %s", - __func__, name, path); - return FEDFS_ERR_SVRFAULT; - } - - if (fgetxattr(fd, name, xattrbuf, (size_t)len) == -1) { - xlog(D_GENERAL, "%s: failed to get xattr %s on %s: %m", - __func__, name, path); - free(xattrbuf); - return FEDFS_ERR_ACCESS; - } - xattrbuf[len] = '\0'; - - xlog(D_CALL, "%s: read xattr %s from path %s", - __func__, name, path); - *contents = xattrbuf; - return FEDFS_OK; -} - -/** - * Retrieve the contents of xattr "name" - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to retrieve - * @param contents OUT: opaque byte array containing contents of xattr - * @param contentlen OUT: size of "contents" - * @return a FedFsStatus code - * - * If junction_get_xattr() returns FEDFS_OK, the caller must free "*contents" - * with free(3). - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_get_xattr(int fd, const char *path, const char *name, void **contents, - size_t *contentlen) -{ - void *xattrbuf = NULL; - ssize_t len; - - len = fgetxattr(fd, name, xattrbuf, 0); - if (len < 0) { - xlog(D_GENERAL, "%s: failed to get size of xattr %s on %s: %m", - __func__, name, path); - return FEDFS_ERR_ACCESS; - } - - xattrbuf = malloc((size_t)len); - if (xattrbuf == NULL) { - xlog(D_GENERAL, "%s: failed to get buffer for xattr %s on %s", - __func__, name, path); - return FEDFS_ERR_SVRFAULT; - } - - if (fgetxattr(fd, name, xattrbuf, (size_t)len) == -1) { - xlog(D_GENERAL, "%s: failed to get xattr %s on %s: %m", - __func__, name, path); - free(xattrbuf); - return FEDFS_ERR_ACCESS; - } - - xlog(D_CALL, "%s: read xattr %s from path %s", - __func__, name, path); - *contents = xattrbuf; - *contentlen = (size_t)len; - return FEDFS_OK; -} - -/** - * Update the contents of an xattr - * - * @param fd an open file descriptor - * @param path NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to set - * @param contents opaque byte array containing contents of xattr - * @param contentlen size of "contents" - * @return a FedFsStatus code - * - * The extended attribute is created if it does not exist. - * Its contents are replaced if it does. - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_set_xattr(int fd, const char *path, const char *name, - const void *contents, const size_t contentlen) -{ - /* - * XXX: Eventually should distinguish among several errors: - * object isn't there, no root access, some other issue - */ - if (fsetxattr(fd, name, contents, contentlen, 0) == -1) { - xlog(D_GENERAL, "%s: Failed to set xattr %s on %s: %m", - __func__, name, path); - return FEDFS_ERR_IO; - } - - xlog(D_CALL, "%s: Wrote xattr %s from path %s", - __func__, name, path); - return FEDFS_OK; -} - -/** - * Remove one xattr - * - * @param fd an open file descriptor - * @param pathname NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to set - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_remove_xattr(int fd, const char *pathname, const char *name) -{ - /* - * XXX: Eventually should distinguish among several errors: - * object isn't there, no root access, some other issue - */ - if (fremovexattr(fd, name) == -1) { - xlog(D_GENERAL, "%s: failed to remove xattr %s from %s: %m", - __func__, name, pathname); - return FEDFS_ERR_ACCESS; - } - xlog(D_CALL, "%s: removed xattr %s from path %s", - __func__, name, pathname); - return FEDFS_OK; -} - -/** - * Retrieve object's mode bits. - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @param mode OUT: mode bits - * @return a FedFsStatus code - */ -FedFsStatus -junction_get_mode(const char *pathname, mode_t *mode) -{ - FedFsStatus retval; - struct stat stb; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - if (fstat(fd, &stb) == -1) { - xlog(D_GENERAL, "%s: failed to stat %s: %m", - __func__, pathname); - (void)close(fd); - return FEDFS_ERR_ACCESS; - } - (void)close(fd); - - xlog(D_CALL, "%s: pathname %s has mode %o", - __func__, pathname, stb.st_mode); - *mode = stb.st_mode; - return FEDFS_OK; - -} - -/** - * Save the object's mode in an xattr. Saved mode is human-readable. - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - */ -FedFsStatus -junction_save_mode(const char *pathname) -{ - FedFsStatus retval; - mode_t mode; - char buf[8]; - int fd; - - retval = junction_get_mode(pathname, &mode); - if (retval != FEDFS_OK) - return retval; - (void)snprintf(buf, sizeof(buf), "%o", ALLPERMS & mode); - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_set_xattr(fd, pathname, JUNCTION_XATTR_NAME_MODE, - buf, strlen(buf)); - if (retval != FEDFS_OK) - goto out; - - retval = junction_set_sticky_bit(fd, pathname); - if (retval != FEDFS_OK) { - (void)junction_remove_xattr(fd, pathname, - JUNCTION_XATTR_NAME_MODE); - goto out; - } - - xlog(D_CALL, "%s: saved mode %o to %s", __func__, mode, pathname); - retval = FEDFS_OK; - -out: - (void)close(fd); - return retval; - -} - -/** - * Restore an object's mode bits - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - */ -FedFsStatus -junction_restore_mode(const char *pathname) -{ - FedFsStatus retval; - char *buf = NULL; - mode_t mode; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_read_xattr(fd, pathname, JUNCTION_XATTR_NAME_MODE, &buf); - if (retval != FEDFS_OK) - goto out; - - retval = FEDFS_ERR_SVRFAULT; - if (sscanf((char *)buf, "%o", &mode) != 1) { - xlog(D_GENERAL, "%s: failed to parse saved mode on %s", - __func__, pathname); - goto out; - } - - retval = FEDFS_ERR_ROFS; - if (fchmod(fd, mode) == -1) { - xlog(D_GENERAL, "%s: failed to set mode of %s to %o: %m", - __func__, pathname, mode); - goto out; - } - - xlog(D_CALL, "%s: restored mode %o to %s", __func__, mode, pathname); - retval = FEDFS_OK; - -out: - free(buf); - (void)close(fd); - return retval; -} diff --git a/nfs-utils-2.5.2/support/junction/locations.c b/nfs-utils-2.5.2/support/junction/locations.c deleted file mode 100644 index c577981..0000000 --- a/nfs-utils-2.5.2/support/junction/locations.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file support/junction/locations.c - * @brief Utility functions to manage NFS locations data - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "junction.h" - -/** - * Free an array of NUL-terminated C strings - * - * @param array array of pointers to C strings - */ -void -nfs_free_string_array(char **array) -{ - unsigned int i; - - if (array == NULL) - return; - for (i = 0; array[i] != NULL; i++) - free(array[i]); - free(array); -} - -/** - * Duplicate an array of NUL-terminated C strings - * - * @param array array of pointers to C strings - * @return freshly allocated array of points to C strings, or NULL - * - * Caller must free the returned array with nfs_free_string_array() - */ -__attribute_malloc__ char ** -nfs_dup_string_array(char **array) -{ - unsigned int size, i; - char **result; - - if (array == NULL) - return NULL; - - for (size = 0; array[size] != NULL; size++); - - result = calloc(size + 1, sizeof(char *)); - if (result == NULL) - return NULL; - for (i = 0; i < size; i++) { - result[i] = strdup(array[i]); - if (result[i] == NULL) { - nfs_free_string_array(result); - return NULL; - } - } - return result; -} - -/** - * Free a single NFS location - * - * @param location pointer to nfs_fsloc data - */ -void -nfs_free_location(struct nfs_fsloc *location) -{ - nfs_free_string_array(location->nfl_rootpath); - free(location->nfl_hostname); - free(location); -} - -/** - * Free a list of NFS locations - * - * @param locations pointer to list of one or more locations - */ -void -nfs_free_locations(struct nfs_fsloc *locations) -{ - struct nfs_fsloc *fsloc; - - while (locations != NULL) { - fsloc = locations; - locations = fsloc->nfl_next; - nfs_free_location(fsloc); - } -} - -/** - * Allocate a fresh nfs_fsloc structure - * - * @return pointer to new empty nfs_fsloc data structure - * - * Caller must free returned locations with nfs_free_location(). - */ -struct nfs_fsloc * -nfs_new_location(void) -{ - return calloc(1, sizeof(struct nfs_fsloc)); -} diff --git a/nfs-utils-2.5.2/support/junction/nfs.c b/nfs-utils-2.5.2/support/junction/nfs.c deleted file mode 100644 index 73e3533..0000000 --- a/nfs-utils-2.5.2/support/junction/nfs.c +++ /dev/null @@ -1,1564 +0,0 @@ -/** - * @file support/junction/nfs.c - * @brief Create, delete, and read NFS junctions on the local file system - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -/* - * An NFS junction is a list of NFS FSLs, represented in a well-formed XML - * document: - * - * - * - * - * - * - * - * - * foo - * bar - * baz - * - * -1 - * - * - * - * - * - * - * 0 - * - * - * .... - * - * - * - * - * NFS junction XML is stored in an extended attribute called - * "trusted.junction.nfs". The parent object is a directory. - * - * To help file servers discover junctions efficiently, the directory - * has no execute bits, and the sticky bit is set. In addition, an - * extended attribute called "trusted.junction.type" is added. The - * contents are ignored in user space. - * - * Finally, for pre-existing directories that are converted to - * junctions, their mode bits are saved in an extended attribute called - * "trusted.junction.mode". When the junction data is removed, the - * directory's mode bits are restored from this information. - */ - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "junction.h" -#include "junction-internal.h" -#include "xlog.h" - -/** - * Tag name of NFS location element of a junction XML document - */ -#define NFS_XML_LOCATION_TAG (const xmlChar *)"location" - -/** - * Tag name of host child element of an NFS location element - */ -#define NFS_XML_HOST_TAG (const xmlChar *)"host" - -/** - * Name of hostname attribute of a host element - */ -#define NFS_XML_HOST_NAME_ATTR (const xmlChar *)"name" - -/** - * Name of IP port attribute of a host element - */ -#define NFS_XML_HOST_PORT_ATTR (const xmlChar *)"port" - -/** - * Tag name of path child element of an NFS location element - */ -#define NFS_XML_PATH_TAG (const xmlChar *)"path" - -/** - * Tag name of component child element of a path element - */ -#define NFS_XML_COMPONENT_TAG (const xmlChar *)"component" - -/** - * Tag name of currency child element of an NFS location element - */ -#define NFS_XML_CURRENCY_TAG (const xmlChar *)"currency" - -/** - * Tag name of genflags child element of an NFS location element - */ -#define NFS_XML_GENFLAGS_TAG (const xmlChar *)"genflags" - -/** - * Name of writable attribute of a genflags element - */ -#define NFS_XML_GENFLAGS_WRITABLE_ATTR (const xmlChar *)"writable" - -/** - * Name of going attribute of a genflags element - */ -#define NFS_XML_GENFLAGS_GOING_ATTR (const xmlChar *)"going" - -/** - * Name of split attribute of a genflags element - */ -#define NFS_XML_GENFLAGS_SPLIT_ATTR (const xmlChar *)"split" - -/** - * Tag name of transflags child element of an NFS location element - */ -#define NFS_XML_TRANSFLAGS_TAG (const xmlChar *)"transflags" - -/** - * Name of rdma attribute of a transflags element - */ -#define NFS_XML_TRANSFLAGS_RDMA_ATTR (const xmlChar *)"rdma" - -/** - * Tag name of class child element of an NFS location element - */ -#define NFS_XML_CLASS_TAG (const xmlChar *)"class" - -/** - * Name of simul attribute of a class element - */ -#define NFS_XML_CLASS_SIMUL_ATTR (const xmlChar *)"simul" - -/** - * Name of handle attribute of a class element - */ -#define NFS_XML_CLASS_HANDLE_ATTR (const xmlChar *)"handle" - -/** - * Name of fileid attribute of a class element - */ -#define NFS_XML_CLASS_FILEID_ATTR (const xmlChar *)"fileid" - -/** - * Name of writever attribute of a class element - */ -#define NFS_XML_CLASS_WRITEVER_ATTR (const xmlChar *)"writever" - -/** - * Name of change attribute of a class element - */ -#define NFS_XML_CLASS_CHANGE_ATTR (const xmlChar *)"change" - -/** - * Name of readdir attribute of a class element - */ -#define NFS_XML_CLASS_READDIR_ATTR (const xmlChar *)"readdir" - -/** - * Tag name of read child element of an NFS location element - */ -#define NFS_XML_READ_TAG (const xmlChar *)"read" - -/** - * Name of rank attribute of a read element - */ -#define NFS_XML_READ_RANK_ATTR (const xmlChar *)"rank" - -/** - * Name of order attribute of a read element - */ -#define NFS_XML_READ_ORDER_ATTR (const xmlChar *)"order" - -/** - * Tag name of write attribute of an NFS location element - */ -#define NFS_XML_WRITE_TAG (const xmlChar *)"write" - -/** - * Name of rank attribute of a write element - */ -#define NFS_XML_WRITE_RANK_ATTR (const xmlChar *)"rank" - -/** - * Name of order attribute of a write element - */ -#define NFS_XML_WRITE_ORDER_ATTR (const xmlChar *)"order" - -/** - * Tag name of flags child element of an NFS location element - */ -#define NFS_XML_FLAGS_TAG (const xmlChar *)"flags" - -/** - * Name of varsub attribute of a flags element - */ -#define NFS_XML_FLAGS_VARSUB_ATTR (const xmlChar *)"varsub" - -/** - * Tag name of a validfor child element of an NFS location element - */ -#define NFS_XML_VALIDFOR_TAG (const xmlChar *)"validfor" - -/** - * XPath path to NFS location elements in a junction document - */ -#define NFS_XML_LOCATION_XPATH (const xmlChar *) \ - "/junction/fileset/location" - - -/** - * Remove all NFS-related xattrs from a directory - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -static FedFsStatus -nfs_remove_locations(const char *pathname) -{ - FedFsStatus retval; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_remove_xattr(fd, pathname, JUNCTION_XATTR_NAME_NFS); - - (void)close(fd); - return retval; -} - -/** - * Add a "host" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_host_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - uint16_t port = fsloc->nfl_hostport; - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_HOST_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add host element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - xmlSetProp(new, NFS_XML_HOST_NAME_ATTR, - (const xmlChar *)fsloc->nfl_hostname); - if (port != NFS_PORT && port != 0) - junction_xml_set_int_attribute(new, NFS_XML_HOST_PORT_ATTR, - port); - - return FEDFS_OK; -} - -/** - * Add a "path" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_path_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - int i; - - new = xmlNewTextChild(parent, NULL, NFS_XML_PATH_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add path element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - for (i = 0; fsloc->nfl_rootpath[i] != NULL; i++) { - xmlNodePtr component; - - component = xmlNewTextChild(new , NULL, - NFS_XML_COMPONENT_TAG, - (const xmlChar *) - fsloc->nfl_rootpath[i]); - if (component == NULL) { - xlog(D_GENERAL, "%s: Failed to add component " - "element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - } - - return FEDFS_OK; -} - -/** - * Add a "currency" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_currency_xml(__attribute__((unused)) const char *pathname, - xmlNodePtr parent, struct nfs_fsloc *fsloc) -{ - if (junction_xml_set_int_content(parent, NFS_XML_CURRENCY_TAG, - fsloc->nfl_currency) == NULL) - return FEDFS_ERR_SVRFAULT; - return FEDFS_OK; -} - -/** - * Add a "genflags" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_genflags_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_GENFLAGS_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add genflags element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_bool_attribute(new, NFS_XML_GENFLAGS_WRITABLE_ATTR, - fsloc->nfl_genflags.nfl_writable); - junction_xml_set_bool_attribute(new, NFS_XML_GENFLAGS_GOING_ATTR, - fsloc->nfl_genflags.nfl_going); - junction_xml_set_bool_attribute(new, NFS_XML_GENFLAGS_SPLIT_ATTR, - fsloc->nfl_genflags.nfl_split); - - return FEDFS_OK; -} - -/** - * Add a "transflags" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_transflags_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_TRANSFLAGS_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add transflags element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_bool_attribute(new, NFS_XML_TRANSFLAGS_RDMA_ATTR, - fsloc->nfl_transflags.nfl_rdma); - - return FEDFS_OK; -} - -/** - * Add a "class" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_class_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_CLASS_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add class element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_int_attribute(new, NFS_XML_CLASS_SIMUL_ATTR, - fsloc->nfl_info.nfl_simul); - junction_xml_set_int_attribute(new, NFS_XML_CLASS_HANDLE_ATTR, - fsloc->nfl_info.nfl_handle); - junction_xml_set_int_attribute(new, NFS_XML_CLASS_FILEID_ATTR, - fsloc->nfl_info.nfl_fileid); - junction_xml_set_int_attribute(new, NFS_XML_CLASS_WRITEVER_ATTR, - fsloc->nfl_info.nfl_writever); - junction_xml_set_int_attribute(new, NFS_XML_CLASS_CHANGE_ATTR, - fsloc->nfl_info.nfl_change); - junction_xml_set_int_attribute(new, NFS_XML_CLASS_READDIR_ATTR, - fsloc->nfl_info.nfl_readdir); - - return FEDFS_OK; -} - -/** - * Add a "read" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_read_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_READ_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add read element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_int_attribute(new, NFS_XML_READ_RANK_ATTR, - fsloc->nfl_info.nfl_readrank); - junction_xml_set_int_attribute(new, NFS_XML_READ_ORDER_ATTR, - fsloc->nfl_info.nfl_readorder); - - return FEDFS_OK; -} - -/** - * Add a "write" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_write_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_WRITE_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add write element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_int_attribute(new, NFS_XML_WRITE_RANK_ATTR, - fsloc->nfl_info.nfl_writerank); - junction_xml_set_int_attribute(new, NFS_XML_WRITE_ORDER_ATTR, - fsloc->nfl_info.nfl_writeorder); - - return FEDFS_OK; -} - -/** - * Add a "flags" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_flags_xml(const char *pathname, xmlNodePtr parent, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr new; - - new = xmlNewTextChild(parent, NULL, NFS_XML_FLAGS_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add flags element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - junction_xml_set_bool_attribute(new, NFS_XML_FLAGS_VARSUB_ATTR, - fsloc->nfl_flags.nfl_varsub); - - return FEDFS_OK; -} - -/** - * Add a "validfor" child to a "location" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param parent parent element to which to add "host" child - * @param fsloc NFS location containing host information to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_validfor_xml(__attribute__((unused)) const char *pathname, - xmlNodePtr parent, struct nfs_fsloc *fsloc) -{ - if (junction_xml_set_int_content(parent, NFS_XML_VALIDFOR_TAG, - fsloc->nfl_validfor) == NULL) - return FEDFS_ERR_SVRFAULT; - return FEDFS_OK; -} - -/** - * Construct and add one "location" element to a "fileset" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param fileset fileset element of junction XML parse tree - * @param fsloc one NFS location to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_location_xml(const char *pathname, xmlNodePtr fileset, - struct nfs_fsloc *fsloc) -{ - FedFsStatus retval; - xmlNodePtr new; - - new = xmlNewTextChild(fileset, NULL, NFS_XML_LOCATION_TAG, NULL); - if (new == NULL) { - xlog(D_GENERAL, "%s: Failed to add location element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - retval = nfs_location_host_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_path_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_currency_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_genflags_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_transflags_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_class_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_read_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_write_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_location_flags_xml(pathname, new, fsloc); - if (retval != FEDFS_OK) - return retval; - return nfs_location_validfor_xml(pathname, new, fsloc); -} - -/** - * Construct and add a "fileset" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param root root element of junction XML parse tree - * @param fslocs list of NFS locations to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_fileset_xml(const char *pathname, xmlNodePtr root, - struct nfs_fsloc *fslocs) -{ - struct nfs_fsloc *next; - xmlNodePtr fileset; - FedFsStatus retval; - - fileset = xmlNewTextChild(root, NULL, JUNCTION_XML_FILESET_TAG, NULL); - if (fileset == NULL) { - xlog(D_GENERAL, "%s: Failed to add fileset element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - for (next = fslocs; next != NULL; next = next->nfl_next) { - retval = nfs_location_xml(pathname, fileset, next); - if (retval != FEDFS_OK) - return retval; - } - - return FEDFS_OK; -} - -/** - * Construct a "savedmode" element - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param root root element of XML document tree - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_savedmode_xml(const char *pathname, xmlNodePtr root) -{ - xmlNodePtr savedmode; - FedFsStatus retval; - mode_t mode; - char buf[8]; - - retval = junction_get_mode(pathname, &mode); - if (retval != FEDFS_OK) - return retval; - - savedmode = xmlNewTextChild(root, NULL, JUNCTION_XML_SAVEDMODE_TAG, NULL); - if (savedmode == NULL) { - xlog(D_GENERAL, "%s: Failed to add savedmode element for %s\n", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - (void)snprintf(buf, sizeof(buf), "%o", ALLPERMS & mode); - xmlSetProp(savedmode, JUNCTION_XML_MODEBITS_ATTR, (const xmlChar *)buf); - - return FEDFS_OK; -} - -/** - * Construct NFS junction XML document from list of NFS locations - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param doc an XML parse tree in which to construct the junction XML document - * @param fslocs list of NFS locations to add - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_junction_xml(const char *pathname, xmlDocPtr doc, - struct nfs_fsloc *fslocs) -{ - FedFsStatus retval; - xmlNodePtr root; - - root = xmlNewNode(NULL, JUNCTION_XML_ROOT_TAG); - if (root == NULL) { - xlog(D_GENERAL, "%s: Failed to create root element for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - (void)xmlDocSetRootElement(doc, root); - - retval = nfs_savedmode_xml(pathname, root); - if (retval != FEDFS_OK) - return retval; - - return nfs_fileset_xml(pathname, root, fslocs); -} - -/** - * Write NFS locations information into an NFS junction extended attribute - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param doc an empty XML parse tree in which to construct the junction XML document - * @param fslocs list of NFS locations to add - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -static FedFsStatus -nfs_write_junction(const char *pathname, xmlDocPtr doc, - struct nfs_fsloc *fslocs) -{ - FedFsStatus retval; - - retval = nfs_junction_xml(pathname, doc, fslocs); - if (retval != FEDFS_OK) - return retval; - - return junction_xml_write(pathname, JUNCTION_XATTR_NAME_NFS, doc); -} - -/** - * Store NFS locations information into a junction object - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param fslocs list of NFS locations to add - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -static FedFsStatus -nfs_store_locations(const char *pathname, struct nfs_fsloc *fslocs) -{ - FedFsStatus retval; - xmlDocPtr doc; - - doc = xmlNewDoc((xmlChar *)"1.0"); - if (doc == NULL) { - xlog(D_GENERAL, "%s: Failed to create XML doc for %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - retval = nfs_write_junction(pathname, doc, fslocs); - - xmlFreeDoc(doc); - return retval; -} - -/** - * Add NFS junction information to a pre-existing object - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param fslocs list of NFS locations to add - * @return a FedFsStatus code - * - * An error occurs if the object referred to by "pathname" does not - * exist or contains existing junction data. - */ -FedFsStatus -nfs_add_junction(const char *pathname, struct nfs_fsloc *fslocs) -{ - FedFsStatus retval; - - if (fslocs == NULL) - return FEDFS_ERR_INVAL; - - retval = nfs_is_prejunction(pathname); - if (retval != FEDFS_ERR_NOTJUNCT) - return retval; - - retval = nfs_store_locations(pathname, fslocs); - if (retval != FEDFS_OK) - goto out_err; - - retval = junction_save_mode(pathname); - if (retval != FEDFS_OK) - goto out_err; - - return retval; - -out_err: - (void)nfs_remove_locations(pathname); - return retval; -} - -/** - * Remove NFS junction information from an object - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - * - * An error occurs if the object referred to by "pathname" does not - * exist or does not contain NFS junction data. - */ -FedFsStatus -nfs_delete_junction(const char *pathname) -{ - FedFsStatus retval; - - retval = nfs_is_junction(pathname); - if (retval != FEDFS_OK) - return retval; - - retval = junction_restore_mode(pathname); - if (retval != FEDFS_OK) - return retval; - - return nfs_remove_locations(pathname); -} - -/** - * Parse the first "host" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_host(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - FedFsStatus retval; - xmlChar *hostname; - xmlNodePtr node; - int hostport; - - retval = FEDFS_ERR_NOTJUNCT; - node = junction_xml_find_child_by_name(location, NFS_XML_HOST_TAG); - if (node == NULL) - return retval; - - hostname = xmlGetProp(node, NFS_XML_HOST_NAME_ATTR); - if (!junction_xml_get_int_attribute(node, NFS_XML_HOST_PORT_ATTR, - &hostport)) - fsloc->nfl_hostport = NFS_PORT; - else { - if (hostport < 1 || hostport > UINT16_MAX) { - xlog(D_GENERAL, "%s: Bad port attribute on %s", - __func__, pathname); - goto out; - } - fsloc->nfl_hostport = (uint16_t)hostport; - } - if (hostname == NULL) { - xlog(D_GENERAL, "%s: No hostname attribute on %s", - __func__, pathname); - goto out; - } - fsloc->nfl_hostname = strdup((const char *)hostname); - if (fsloc->nfl_hostname == NULL) { - retval = FEDFS_ERR_SVRFAULT; - goto out; - } - - retval = FEDFS_OK; - -out: - xmlFree(hostname); - return retval; -} - -/** - * Parse the first "path" child of "location" into a path array - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_path(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node, component; - unsigned int count; - xmlChar *value; - char **result; - - node = junction_xml_find_child_by_name(location, NFS_XML_PATH_TAG); - if (node == NULL) - return FEDFS_ERR_NOTJUNCT; - - count = 0; - for (component = node->children; - component != NULL; - component = component->next) { - if (!junction_xml_match_node_name(component, - NFS_XML_COMPONENT_TAG)) - continue; - value = xmlNodeGetContent(component); - if (junction_xml_is_empty(value)) { - xlog(D_GENERAL, "%s: Bad pathname component in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; - } - xmlFree(value); - count++; - } - xlog(D_GENERAL, "%s: Found %u component(s)", __func__, count); - - if (count == 0) { - xlog(D_GENERAL, "%s: Zero-component pathname", __func__); - fsloc->nfl_rootpath = (char **)calloc(1, sizeof(char *)); - if (fsloc->nfl_rootpath == NULL) - return FEDFS_ERR_SVRFAULT; - fsloc->nfl_rootpath[0] = NULL; - return FEDFS_OK; - } - - result = calloc(count + 1, sizeof(char *)); - if (result == NULL) - return FEDFS_ERR_SVRFAULT; - - count = 0; - for (component = node->children; - component != NULL; - component = component->next) { - if (!junction_xml_match_node_name(component, - NFS_XML_COMPONENT_TAG)) - continue; - value = xmlNodeGetContent(component); - result[count] = strdup((const char *)value); - xmlFree(value); - if (result[count] == NULL) { - nfs_free_string_array(result); - return FEDFS_ERR_SVRFAULT; - } - count++; - } - - fsloc->nfl_rootpath = result; - return FEDFS_OK; -} - -/** - * Parse the first "currency" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_currency(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_CURRENCY_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_int_content(node, &fsloc->nfl_currency)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid currency element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "genflags" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_genflags(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_GENFLAGS_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_bool_attribute(node, - NFS_XML_GENFLAGS_WRITABLE_ATTR, - &fsloc->nfl_genflags.nfl_writable)) - goto out_err; - if (!junction_xml_get_bool_attribute(node, - NFS_XML_GENFLAGS_GOING_ATTR, - &fsloc->nfl_genflags.nfl_going)) - goto out_err; - if (!junction_xml_get_bool_attribute(node, - NFS_XML_GENFLAGS_SPLIT_ATTR, - &fsloc->nfl_genflags.nfl_split)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid genflags element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "transflags" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_transflags(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_TRANSFLAGS_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_bool_attribute(node, - NFS_XML_TRANSFLAGS_RDMA_ATTR, - &fsloc->nfl_transflags.nfl_rdma)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid transflags element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "class" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_class(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_CLASS_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_SIMUL_ATTR, - &fsloc->nfl_info.nfl_simul)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_HANDLE_ATTR, - &fsloc->nfl_info.nfl_handle)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_FILEID_ATTR, - &fsloc->nfl_info.nfl_fileid)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_WRITEVER_ATTR, - &fsloc->nfl_info.nfl_writever)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_WRITEVER_ATTR, - &fsloc->nfl_info.nfl_writever)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_CHANGE_ATTR, - &fsloc->nfl_info.nfl_change)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_CLASS_READDIR_ATTR, - &fsloc->nfl_info.nfl_readdir)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid class element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "read" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_read(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_READ_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_u8_attribute(node, - NFS_XML_READ_RANK_ATTR, - &fsloc->nfl_info.nfl_readrank)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_READ_ORDER_ATTR, - &fsloc->nfl_info.nfl_readorder)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid read element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "write" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_write(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_WRITE_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_u8_attribute(node, - NFS_XML_WRITE_RANK_ATTR, - &fsloc->nfl_info.nfl_writerank)) - goto out_err; - if (!junction_xml_get_u8_attribute(node, - NFS_XML_WRITE_ORDER_ATTR, - &fsloc->nfl_info.nfl_writeorder)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid write element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "flags" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_flags(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_FLAGS_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_bool_attribute(node, - NFS_XML_FLAGS_VARSUB_ATTR, - &fsloc->nfl_flags.nfl_varsub)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid flags element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse the first "validfor" child of "location" - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - */ -static FedFsStatus -nfs_parse_location_validfor(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - xmlNodePtr node; - - node = junction_xml_find_child_by_name(location, NFS_XML_VALIDFOR_TAG); - if (node == NULL) - goto out_err; - - if (!junction_xml_get_int_content(node, &fsloc->nfl_validfor)) - goto out_err; - - return FEDFS_OK; - -out_err: - xlog(D_GENERAL, "%s: Missing or invalid validfor element in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; -} - -/** - * Parse children of NFS location element in an NFS junction - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc a blank nfs_fsloc to fill in - * @return a FedFsStatus code - * - * All children are required only-once elements, and may appear in any order. - * Extraneous or repeated elements are ignored for now. - */ -static FedFsStatus -nfs_parse_location_children(const char *pathname, xmlNodePtr location, - struct nfs_fsloc *fsloc) -{ - FedFsStatus retval; - - retval = nfs_parse_location_host(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_path(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_currency(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_genflags(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_transflags(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_class(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_read(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_write(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - retval = nfs_parse_location_flags(pathname, location, fsloc); - if (retval != FEDFS_OK) - return retval; - return nfs_parse_location_validfor(pathname, location, fsloc); -} - -/** - * Parse NFS location element in an NFS junction - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param location XML parse tree containing fileset location element - * @param fsloc OUT: a single NFS location item - * @return a FedFsStatus code - * - * If nfs_parse_location() returns FEDFS_OK, caller must free the returned - * location with nfs_free_location(). - */ -static FedFsStatus -nfs_parse_node(const char *pathname, xmlNodePtr location, - struct nfs_fsloc **fsloc) -{ - struct nfs_fsloc *tmp; - FedFsStatus retval; - - tmp = nfs_new_location(); - if (tmp == NULL) - return FEDFS_ERR_SVRFAULT; - - retval = nfs_parse_location_children(pathname, location, tmp); - if (retval != FEDFS_OK) - nfs_free_location(tmp); - else - *fsloc = tmp; - return retval; -} - -/** - * Build list of NFS locations from a nodeset - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param nodeset XML nodeset containing "location" elements - * @param fslocs OUT: pointer to a list of NFS locations - * @return a FedFsStatus code - * - * If nfs_parse_nodeset() returns FEDFS_OK, caller must free the returned - * list of locations with nfs_free_locations(). - */ -static FedFsStatus -nfs_parse_nodeset(const char *pathname, xmlNodeSetPtr nodeset, - struct nfs_fsloc **fslocs) -{ - struct nfs_fsloc *location, *result = NULL; - FedFsStatus retval; - int i; - - if (xmlXPathNodeSetIsEmpty(nodeset)) { - xlog(D_GENERAL, "%s: No fileset locations found in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; - } - - for (i = 0; i < nodeset->nodeNr; i++) { - xmlNodePtr node = nodeset->nodeTab[i]; - - retval = nfs_parse_node(pathname, node, &location); - if (retval != FEDFS_OK) { - nfs_free_locations(result); - return retval; - } - - if (result == NULL) - result = location; - else - result->nfl_next = location; - } - - *fslocs = result; - return FEDFS_OK; -} - -/** - * Parse fileset location information from junction XML - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param context XML path context containing junction XML - * @param fslocs OUT: pointer to a list of NFS locations - * @return a FedFsStatus code - * - * If nfs_parse_context() returns FEDFS_OK, caller must free the returned - * list of locations with nfs_free_locations(). - */ -static FedFsStatus -nfs_parse_context(const char *pathname, xmlXPathContextPtr context, - struct nfs_fsloc **fslocs) -{ - xmlXPathObjectPtr object; - FedFsStatus retval; - - object = xmlXPathEvalExpression(NFS_XML_LOCATION_XPATH, context); - if (object == NULL) { - xlog(D_GENERAL, "%s: Failed to evaluate XML in %s", - __func__, pathname); - return FEDFS_ERR_NOTJUNCT; - } - - retval = nfs_parse_nodeset(pathname, object->nodesetval, fslocs); - - xmlXPathFreeObject(object); - return retval; -} - -/** - * Parse NFS locations information from junction XML - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param doc XML parse tree containing junction XML document - * @param fslocs OUT: pointer to a list of NFS locations - * @return a FedFsStatus code - * - * If nfs_parse_xml() returns FEDFS_OK, caller must free the returned - * list of locations with nfs_free_locations(). - */ -static FedFsStatus -nfs_parse_xml(const char *pathname, xmlDocPtr doc, struct nfs_fsloc **fslocs) -{ - xmlXPathContextPtr context; - FedFsStatus retval; - - context = xmlXPathNewContext(doc); - if (context == NULL) { - xlog(D_GENERAL, "%s: Failed to create XPath context from %s", - __func__, pathname); - return FEDFS_ERR_SVRFAULT; - } - - retval = nfs_parse_context(pathname, context, fslocs); - - xmlXPathFreeContext(context); - return retval; -} - -/** - * Retrieve list of NFS locations from an NFS junction - * - * @param pathname NUL-terminated C string containing pathname of a junction - * @param fslocs OUT: pointer to a list of NFS locations - * @return a FedFsStatus code - * - * If nfs_get_locations() returns FEDFS_OK, caller must free the returned - * list of locations with nfs_free_locations(). - */ -FedFsStatus -nfs_get_locations(const char *pathname, struct nfs_fsloc **fslocs) -{ - FedFsStatus retval; - xmlDocPtr doc; - - if (fslocs == NULL) - return FEDFS_ERR_INVAL; - - retval = junction_xml_parse(pathname, JUNCTION_XATTR_NAME_NFS, &doc); - if (retval != FEDFS_OK) - return retval; - - retval = nfs_parse_xml(pathname, doc, fslocs); - - xmlFreeDoc(doc); - return retval; -} - -/** - * Predicate: does "pathname" refer to an object that can become an NFS junction? - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - * - * Return values: - * FEDFS_ERR_NOTJUNCT: "pathname" refers to an object that can be - * made into a NFS junction - * FEDFS_ERR_EXIST: "pathname" refers to something that is - * already a junction - * FEDFS_ERR_INVAL: "pathname" does not exist - * Other: Some error occurred, "pathname" not - * investigated - */ -FedFsStatus -nfs_is_prejunction(const char *pathname) -{ - FedFsStatus retval; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_is_directory(fd, pathname); - if (retval != FEDFS_OK) - goto out_close; - - retval = junction_is_sticky_bit_set(fd, pathname); - switch (retval) { - case FEDFS_ERR_NOTJUNCT: - break; - case FEDFS_OK: - goto out_exist; - default: - goto out_close; - } - - retval = junction_is_xattr_present(fd, pathname, JUNCTION_XATTR_NAME_NFS); - switch (retval) { - case FEDFS_ERR_NOTJUNCT: - break; - case FEDFS_OK: - goto out_exist; - default: - goto out_close; - } - -out_close: - (void)close(fd); - return retval; -out_exist: - retval = FEDFS_ERR_EXIST; - goto out_close; -} - -/** - * Verify that junction contains NFS junction XML - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - * - * Return values: - * FEDFS_OK: "pathname" refers to an NFS junction - * FEDFS_ERR_NOTJUNCT: "pathname" refers to something that is - * not an NFS junction - * FEDFS_ERR_INVAL: "pathname" does not exist - * Other: Some error occurred, "pathname" not - * investigated - * - * NB: This is an expensive test. However, it is only done if the object - * actually has a junction extended attribute, meaning it should be done - * rarely. If this is really a problem, we can make the XML test cheaper. - */ -static FedFsStatus -nfs_is_junction_xml(const char *pathname) -{ - struct nfs_fsloc *fslocs = NULL; - FedFsStatus retval; - xmlDocPtr doc; - - retval = junction_xml_parse(pathname, JUNCTION_XATTR_NAME_NFS, &doc); - if (retval != FEDFS_OK) - return retval; - - retval = nfs_parse_xml(pathname, doc, &fslocs); - nfs_free_locations(fslocs); - - xmlFreeDoc(doc); - return retval; -} - -/** - * Predicate: does "pathname" refer to an NFS junction? - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @return a FedFsStatus code - * - * Return values: - * FEDFS_OK: "pathname" refers to an NFS junction - * FEDFS_ERR_NOTJUNCT: "pathname" refers to an object that is - * not a junction - * FEDFS_ERR_INVAL: "pathname" does not exist - * Other: Some error occurred, "pathname" not - * investigated - */ -FedFsStatus -nfs_is_junction(const char *pathname) -{ - FedFsStatus retval; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_is_directory(fd, pathname); - if (retval != FEDFS_OK) - goto out_close; - - retval = junction_is_sticky_bit_set(fd, pathname); - if (retval != FEDFS_OK) - goto out_close; - - retval = junction_is_xattr_present(fd, pathname, JUNCTION_XATTR_NAME_NFS); - if (retval != FEDFS_OK) - goto out_close; - - (void)close(fd); - - return nfs_is_junction_xml(pathname); - -out_close: - (void)close(fd); - return retval; -} diff --git a/nfs-utils-2.5.2/support/junction/path.c b/nfs-utils-2.5.2/support/junction/path.c deleted file mode 100644 index 13a1438..0000000 --- a/nfs-utils-2.5.2/support/junction/path.c +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @file support/junction/path.c - * @brief Encode and decode FedFS pathnames - */ - -/* - * Copyright 2010, 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "junction.h" -#include "xlog.h" - -#define STRLEN_SLASH ((size_t)1) /* strlen("/") */ - -#define XDR_UINT_BYTES (sizeof(uint32_t)) - -/** - * Compute count of XDR 4-octet units from byte count - * - * @param bytes number of bytes to convert - * @return equivalent number of XDR 4-octet units - */ -static inline size_t -nsdb_quadlen(size_t bytes) -{ - return (bytes + 3) >> 2; -} - -/** - * Free array of NUL-terminated C strings - * - * @param strings array of char * to be released - */ -void -nsdb_free_string_array(char **strings) -{ - int i; - - if (strings == NULL) - return; - for (i = 0; strings[i] != NULL; i++) - free(strings[i]); - free(strings); -} - -static FedFsStatus -nsdb_alloc_zero_component_pathname(char ***path_array) -{ - char **result; - - xlog(D_GENERAL, "%s: Zero-component pathname", __func__); - - result = (char **)calloc(1, sizeof(char *)); - if (result == NULL) - return FEDFS_ERR_SVRFAULT; - result[0] = NULL; - *path_array = result; - return FEDFS_OK; -} - -/** - * Sanitize an incoming POSIX path - * - * @param pathname NUL-terminated C string containing a POSIX pathname - * @return NUL-terminated C string containing sanitized path - * - * Caller must free the returned pathname with free(3). - * - * Remove multiple sequential slashes and any trailing slashes, - * but leave "/" by itself alone. - */ -static __attribute_malloc__ char * -nsdb_normalize_path(const char *pathname) -{ - size_t i, j, len; - char *result; - - len = strlen(pathname); - if (len == 0) { - xlog(D_CALL, "%s: NULL pathname", __func__); - return NULL; - } - - result = malloc(len + 1); - if (result == NULL) - return NULL; - - for (i = 0, j = 0; i < len; i++) { - if (pathname[i] == '/' && pathname[i + 1] == '/') - continue; - result[j++] = pathname[i]; - } - result[j] = '\0'; - - if (j > 1 && result[j - 1] == '/') - result[j - 1] = '\0'; - - xlog(D_CALL, "%s: result = '%s'", __func__, result); - return result; -} - -/** - * Count the number of components in a POSIX pathname - * - * @param pathname NUL-terminated C string containing a POSIX pathname - * @param len OUT: number of bytes the encoded XDR stream will consume - * @param cnt OUT: component count - * @return true when successful - */ -static _Bool -nsdb_count_components(const char *pathname, size_t *len, - unsigned int *cnt) -{ - char *start, *component; - unsigned int count; - size_t length; - - /* strtok(3) will tromp on the string */ - start = strdup(pathname); - if (start == NULL) - return false; - - length = XDR_UINT_BYTES; - count = 0; - component = start; - for ( ;; ) { - char *next; - size_t tmp; - - if (*component == '/') - component++; - if (*component == '\0') - break; - next = strchrnul(component, '/'); - tmp = (size_t)(next - component); - if (tmp > 255) { - free(start); - return false; - } - length += XDR_UINT_BYTES + (nsdb_quadlen(tmp) << 2); - count++; - - if (*next == '\0') - break; - component = next; - } - - free(start); - - xlog(D_CALL, "%s: length = %zu, count = %u, path = '%s'", - __func__, length, count, pathname); - *len = length; - *cnt = count; - return true; -} - -/** - * Predicate: is input character set for a POSIX pathname valid UTF-8? - * - * @param pathname NUL-terminated C string containing a POSIX path - * @return true if the string is valid UTF-8 - * - * XXX: implement this - */ -static _Bool -nsdb_pathname_is_utf8(__attribute__((unused)) const char *pathname) -{ - return true; -} - -/** - * Construct a local POSIX-style pathname from an array of component strings - * - * @param path_array array of pointers to NUL-terminated C strings - * @param pathname OUT: pointer to NUL-terminated UTF-8 C string containing a POSIX-style path - * @return a FedFsStatus code - * - * Caller must free the returned pathname with free(3). - */ -FedFsStatus -nsdb_path_array_to_posix(char * const *path_array, char **pathname) -{ - char *component, *result; - unsigned int i, count; - size_t length, len; - - if (path_array == NULL || pathname == NULL) - return FEDFS_ERR_INVAL; - - if (path_array[0] == NULL) { - xlog(D_GENERAL, "%s: Zero-component pathname", __func__); - result = strdup("/"); - if (result == NULL) - return FEDFS_ERR_SVRFAULT; - *pathname = result; - return FEDFS_OK; - } - - for (length = 0, count = 0; - path_array[count] != NULL; - count++) { - component = path_array[count]; - len = strlen(component); - - if (len == 0) { - xlog(D_GENERAL, "%s: Zero-length component", __func__); - return FEDFS_ERR_BADNAME; - } - if (len > NAME_MAX) { - xlog(D_GENERAL, "%s: Component length too long", __func__); - return FEDFS_ERR_NAMETOOLONG; - } - if (strchr(component, '/') != NULL) { - xlog(D_GENERAL, "%s: Local separator character " - "found in component", __func__); - return FEDFS_ERR_BADNAME; - } - if (!nsdb_pathname_is_utf8(component)) { - xlog(D_GENERAL, "%s: Bad character in component", - __func__); - return FEDFS_ERR_BADCHAR; - } - - length += STRLEN_SLASH + len; - - if (length > PATH_MAX) { - xlog(D_GENERAL, "%s: Pathname too long", __func__); - return FEDFS_ERR_NAMETOOLONG; - } - } - - result = calloc(1, length + 1); - if (result == NULL) - return FEDFS_ERR_SVRFAULT; - - for (i = 0; i < count; i++) { - strcat(result, "/"); - strcat(result, path_array[i]); - } - *pathname = nsdb_normalize_path(result); - free(result); - if (*pathname == NULL) - return FEDFS_ERR_SVRFAULT; - return FEDFS_OK; -} - -/** - * Construct an array of component strings from a local POSIX-style pathname - * - * @param pathname NUL-terminated C string containing a POSIX-style pathname - * @param path_array OUT: pointer to array of pointers to NUL-terminated C strings - * @return a FedFsStatus code - * - * Caller must free "path_array" with nsdb_free_string_array(). - */ -FedFsStatus -nsdb_posix_to_path_array(const char *pathname, char ***path_array) -{ - char *normalized, *component, **result; - unsigned int i, count; - size_t length; - - if (pathname == NULL || path_array == NULL) - return FEDFS_ERR_INVAL; - - if (!nsdb_pathname_is_utf8(pathname)) { - xlog(D_GENERAL, "%s: Bad character in pathname", __func__); - return FEDFS_ERR_BADCHAR; - } - - normalized = nsdb_normalize_path(pathname); - if (normalized == NULL) - return FEDFS_ERR_SVRFAULT; - - if (!nsdb_count_components(normalized, &length, &count)) { - free(normalized); - return FEDFS_ERR_BADNAME; - } - - if (count == 0) { - free(normalized); - return nsdb_alloc_zero_component_pathname(path_array); - } - - result = (char **)calloc(count + 1, sizeof(char *)); - if (result == NULL) { - free(normalized); - return FEDFS_ERR_SVRFAULT; - } - - component = normalized; - for (i = 0; ; i++) { - char *next; - - if (*component == '/') - component++; - if (*component == '\0') - break; - next = strchrnul(component, '/'); - length = (size_t)(next - component); - if (length > 255) { - nsdb_free_string_array(result); - free(normalized); - return FEDFS_ERR_SVRFAULT; - } - - result[i] = strndup(component, length); - if (result[i] == NULL) { - free(normalized); - nsdb_free_string_array(result); - return FEDFS_ERR_SVRFAULT; - } - - if (*next == '\0') - break; - component = next; - } - - *path_array = result; - free(normalized); - return FEDFS_OK; -} diff --git a/nfs-utils-2.5.2/support/junction/xml.c b/nfs-utils-2.5.2/support/junction/xml.c deleted file mode 100644 index 813110b..0000000 --- a/nfs-utils-2.5.2/support/junction/xml.c +++ /dev/null @@ -1,401 +0,0 @@ -/** - * @file support/junction/xml.c - * @brief Common utilities for managing junction XML - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "junction.h" -#include "junction-internal.h" -#include "xlog.h" - -/** - * Predicate: is element content empty? - * - * @param content element content to test - * @return true if content is empty - */ -_Bool -junction_xml_is_empty(const xmlChar *content) -{ - return content == NULL || *content == '\0'; -} - -/** - * Match an XML parse tree node by its name - * - * @param node pointer to a node in an XML parse tree - * @param name NUL-terminated C string containing name to match - * @return true if "node" is named "name" - */ -_Bool -junction_xml_match_node_name(xmlNodePtr node, const xmlChar *name) -{ - return (node->type == XML_ELEMENT_NODE) && - (xmlStrcmp(node->name, name) == 0); -} - -/** - * Find a first-level child of "parent" named "name" - * - * @param parent pointer to node whose children are to be searched - * @param name NUL-terminated C string containing name to match - * @return pointer to child of "parent" whose name is "name" - */ -xmlNodePtr -junction_xml_find_child_by_name(xmlNodePtr parent, const xmlChar *name) -{ - xmlNodePtr node; - - for (node = parent->children; node != NULL; node = node->next) - if (junction_xml_match_node_name(node, name)) - return node; - return NULL; -} - -/** - * Read attribute into a boolean - * - * @param node pointer to a node in an XML parse tree - * @param attrname NUL-terminated C string containing attribute name - * @param value OUT: attribute's value converted to an integer - * @return true if attribute "attrname" has a valid boolean value - */ -_Bool -junction_xml_get_bool_attribute(xmlNodePtr node, const xmlChar *attrname, - _Bool *value) -{ - xmlChar *prop; - _Bool retval; - - retval = false; - prop = xmlGetProp(node, attrname); - if (prop == NULL) - goto out; - - if (xmlStrcmp(prop, (const xmlChar *)"true") == 0) { - *value = true; - retval = true; - goto out; - } - - if (xmlStrcmp(prop, (const xmlChar *)"false") == 0) { - *value = false; - retval = true; - goto out; - } - -out: - xmlFree(prop); - return retval; -} - -/** - * Set attribute to a boolean - * - * @param node pointer to a node in an XML parse tree - * @param attrname NUL-terminated C string containing attribute name - * @param value boolean value to set - */ -void -junction_xml_set_bool_attribute(xmlNodePtr node, const xmlChar *attrname, - _Bool value) -{ - xmlSetProp(node, attrname, (const xmlChar *)(value ? "true" : "false")); -} - -/** - * Read attribute into an uint8_t - * - * @param node pointer to a node in an XML parse tree - * @param attrname NUL-terminated C string containing attribute name - * @param value OUT: attribute's value converted to an uint8_t - * @return true if attribute "attrname" has a valid uint8_t value - */ -_Bool -junction_xml_get_u8_attribute(xmlNodePtr node, const xmlChar *attrname, - uint8_t *value) -{ - char *endptr; - _Bool retval; - char *prop; - long tmp; - - retval = false; - prop = (char *)xmlGetProp(node, attrname); - if (prop == NULL) - goto out; - - errno = 0; - tmp = strtol(prop, &endptr, 10); - if (errno != 0 || *endptr != '\0' || tmp > 255 || tmp < 0) - goto out; - - *value = (uint8_t)tmp; - retval = true; - -out: - xmlFree(prop); - return retval; -} - -/** - * Read attribute into an integer - * - * @param node pointer to a node in an XML parse tree - * @param attrname NUL-terminated C string containing attribute name - * @param value OUT: attribute's value converted to an integer - * @return true if attribute "attrname" has a valid integer value - */ -_Bool -junction_xml_get_int_attribute(xmlNodePtr node, const xmlChar *attrname, - int *value) -{ - char *endptr; - _Bool retval; - char *prop; - long tmp; - - retval = false; - prop = (char *)xmlGetProp(node, attrname); - if (prop == NULL) - goto out; - - errno = 0; - tmp = strtol(prop, &endptr, 10); - if (errno != 0 || *endptr != '\0' || tmp > INT32_MAX || tmp < INT32_MIN) - goto out; - - *value = (int)tmp; - retval = true; - -out: - xmlFree(prop); - return retval; -} - -/** - * Set attribute to an integer - * - * @param node pointer to a node in an XML parse tree - * @param attrname NUL-terminated C string containing attribute name - * @param value integer value to set - */ -void -junction_xml_set_int_attribute(xmlNodePtr node, const xmlChar *attrname, - int value) -{ - char buf[16]; - - snprintf(buf, sizeof(buf), "%d", value); - xmlSetProp(node, attrname, (const xmlChar *)buf); -} - -/** - * Read node content into an integer - * - * @param node pointer to a node in an XML parse tree - * @param value OUT: node's content converted to an integer - * @return true if "node" has valid integer content - */ -_Bool -junction_xml_get_int_content(xmlNodePtr node, int *value) -{ - xmlChar *content; - char *endptr; - _Bool retval; - long tmp; - - retval = false; - content = xmlNodeGetContent(node); - if (content == NULL) - goto out; - - errno = 0; - tmp = strtol((const char *)content, &endptr, 10); - if (errno != 0 || *endptr != '\0' || tmp > INT32_MAX || tmp < INT32_MIN) - goto out; - - *value = (int)tmp; - retval = true; - -out: - xmlFree(content); - return retval; -} - -/** - * Add a child node with integer content - * - * @param parent pointer to a node in an XML parse tree - * @param name NUL-terminated C string containing name of child to add - * @param value set node content to this value - * @return pointer to new child node - */ -xmlNodePtr -junction_xml_set_int_content(xmlNodePtr parent, const xmlChar *name, int value) -{ - char buf[16]; - - snprintf(buf, sizeof(buf), "%d", value); - return xmlNewTextChild(parent, NULL, name, (const xmlChar *)buf); -} - -/** - * Parse XML document in a buffer into an XML document tree - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to replace - * @param buf opaque byte array containing XML to parse - * @param len size of "buf" in bytes - * @param doc OUT: an XML parse tree containing junction XML - * @return a FedFsStatus code - * - * If junction_parse_xml_buf() returns success, caller must free "*doc" - * using xmlFreeDoc(3). - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -static FedFsStatus -junction_parse_xml_buf(const char *pathname, const char *name, - void *buf, size_t len, xmlDocPtr *doc) -{ - xmlDocPtr tmp; - - tmp = xmlParseMemory(buf, (int)len); - if (tmp == NULL) { - xlog(D_GENERAL, "Failed to parse XML in %s(%s)\n", - pathname, name); - return FEDFS_ERR_SVRFAULT; - } - - *doc = tmp; - return FEDFS_OK; -} - -/** - * Read an XML document from an extended attribute into an XML document tree - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @param fd an open file descriptor - * @param name NUL-terminated C string containing name of xattr to replace - * @param doc OUT: an XML parse tree containing junction XML - * @return a FedFsStatus code - * - * If junction_parse_xml_read() returns success, caller must free "*doc" - * using xmlFreeDoc(3). - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -static FedFsStatus -junction_parse_xml_read(const char *pathname, int fd, const char *name, - xmlDocPtr *doc) -{ - FedFsStatus retval; - void *buf = NULL; - size_t len; - - retval = junction_get_xattr(fd, pathname, name, &buf, &len); - if (retval != FEDFS_OK) - return retval; - - xlog(D_CALL, "%s: XML document contained in junction:\n%zu.%s", - __func__, len, (char *)buf); - - retval = junction_parse_xml_buf(pathname, name, buf, len, doc); - - free(buf); - return retval; -} - -/** - * Read an XML document from an extended attribute into an XML document tree - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to replace - * @param doc OUT: an XML parse tree containing junction XML - * @return a FedFsStatus code - * - * If junction_parse_xml() returns success, caller must free "*doc" - * using xmlFreeDoc(3). - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_xml_parse(const char *pathname, const char *name, xmlDocPtr *doc) -{ - FedFsStatus retval; - int fd; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = junction_parse_xml_read(pathname, fd, name, doc); - - (void)close(fd); - return retval; -} - -/** - * Write an XML document into an extended attribute - * - * @param pathname NUL-terminated C string containing pathname of a directory - * @param name NUL-terminated C string containing name of xattr to replace - * @param doc an XML parse tree containing junction XML - * @return a FedFsStatus code - * - * @note Access to trusted attributes requires CAP_SYS_ADMIN. - */ -FedFsStatus -junction_xml_write(const char *pathname, const char *name, xmlDocPtr doc) -{ - xmlChar *buf = NULL; - FedFsStatus retval; - int fd, len; - - retval = junction_open_path(pathname, &fd); - if (retval != FEDFS_OK) - return retval; - - retval = FEDFS_ERR_SVRFAULT; - xmlIndentTreeOutput = 1; - xmlDocDumpFormatMemoryEnc(doc, &buf, &len, "UTF-8", 1); - if (len < 0) - goto out; - - retval = junction_set_xattr(fd, pathname, name, buf, (size_t)len); - -out: - xmlFree(buf); - (void)close(fd); - return retval; -} diff --git a/nfs-utils-2.5.2/support/misc/Makefile.am b/nfs-utils-2.5.2/support/misc/Makefile.am deleted file mode 100644 index f9993e3..0000000 --- a/nfs-utils-2.5.2/support/misc/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = libmisc.a -libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c \ - nfsd_path.c workqueue.c xstat.c - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/support/misc/file.c b/nfs-utils-2.5.2/support/misc/file.c deleted file mode 100644 index 06f6bb2..0000000 --- a/nfs-utils-2.5.2/support/misc/file.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * Copyright 2017 Red Hat, Inc. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "misc.h" - -/* - * Returns a dynamically allocated, '\0'-terminated buffer - * containing an appropriate pathname, or NULL if an error - * occurs. Caller must free the returned result with free(3). - */ -__attribute__((__malloc__)) -char * -generic_make_pathname(const char *base, const char *leaf) -{ - size_t size; - char *path; - int len; - - size = strlen(base) + strlen(leaf) + 2; - if (size > PATH_MAX) - return NULL; - - path = malloc(size); - if (path == NULL) - return NULL; - - len = snprintf(path, size, "%s/%s", base, leaf); - if ((len < 0) || ((size_t)len >= size)) { - free(path); - return NULL; - } - - return path; -} - - -/** - * generic_setup_basedir - set up basedir - * @progname: C string containing name of program, for error messages - * @parentdir: C string containing pathname to on-disk state, or NULL - * @base: character buffer to contain the basedir that is set up - * @baselen: size of @base in bytes - * - * This runs before logging is set up, so error messages are directed - * to stderr. - * - * Returns true and sets up our basedir, if @parentdir was valid - * and usable; otherwise false is returned. - */ -_Bool -generic_setup_basedir(const char *progname, const char *parentdir, char *base, - const size_t baselen) -{ - static char buf[PATH_MAX]; - struct stat st; - char *path; - - /* First: test length of name and whether it exists */ - if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) { - (void)fprintf(stderr, "%s: Directory name too long: %s", - progname, parentdir); - return false; - } - if (lstat(parentdir, &st) == -1) { - (void)fprintf(stderr, "%s: Failed to stat %s: %s", - progname, parentdir, strerror(errno)); - return false; - } - - /* Ensure we have a clean directory pathname */ - strncpy(buf, parentdir, sizeof(buf)-1); - path = dirname(buf); - if (*path == '.') { - (void)fprintf(stderr, "%s: Unusable directory %s", - progname, parentdir); - return false; - } - - xlog(D_CALL, "Using %s as the state directory", parentdir); - strcpy(base, parentdir); - return true; -} diff --git a/nfs-utils-2.5.2/support/misc/from_local.c b/nfs-utils-2.5.2/support/misc/from_local.c deleted file mode 100644 index e2de969..0000000 --- a/nfs-utils-2.5.2/support/misc/from_local.c +++ /dev/null @@ -1,268 +0,0 @@ - /* - * Check if an address belongs to the local system. Adapted from: - * - * @(#)pmap_svc.c 1.32 91/03/11 Copyright 1984,1990 Sun Microsystems, Inc. - * @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC. - */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#if 0 -static char sccsid[] = "@(#) from_local.c 1.3 96/05/31 15:52:57"; -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "tcpwrapper.h" -#include "xlog.h" - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#ifdef HAVE_GETIFADDRS - -#include -#include - -/** - * from_local - determine whether request comes from the local system - * @sap: pointer to socket address to check - * - * With virtual hosting, each hardware network interface can have - * multiple network addresses. On such machines the number of machine - * addresses can be surprisingly large. - * - * We also expect the local network configuration to change over time, - * so call getifaddrs(3) more than once, but not too often. - * - * Returns TRUE if the sockaddr contains an address of one of the local - * network interfaces. Otherwise FALSE is returned. - */ -int -from_local(const struct sockaddr *sap) -{ - static struct ifaddrs *ifaddr = NULL; - static time_t last_update = 0; - struct ifaddrs *ifa; - unsigned int count; - time_t now; - - if (time(&now) == ((time_t)-1)) { - xlog(L_ERROR, "%s: time(2): %m", __func__); - - /* If we don't know what time it is, use the - * existing ifaddr list, if one exists */ - now = last_update; - if (ifaddr == NULL) - now++; - } - if (now != last_update) { - xlog(D_GENERAL, "%s: updating local if addr list", __func__); - - if (ifaddr) - freeifaddrs(ifaddr); - - if (getifaddrs(&ifaddr) == -1) { - xlog(L_ERROR, "%s: getifaddrs(3): %m", __func__); - return FALSE; - } - - last_update = now; - } - - count = 0; - for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) { - if ((ifa->ifa_flags & IFF_UP) && - nfs_compare_sockaddr(sap, ifa->ifa_addr)) { - xlog(D_GENERAL, "%s: incoming address matches " - "local interface address", __func__); - return TRUE; - } else - count++; - } - - xlog(D_GENERAL, "%s: checked %u local if addrs; " - "incoming address not found", __func__, count); - return FALSE; -} - -#else /* !HAVE_GETIFADDRS */ - -static int num_local; -static int num_addrs; -static struct in_addr *addrs; - -/* grow_addrs - extend list of local interface addresses */ - -static int grow_addrs(void) -{ - struct in_addr *new_addrs; - int new_num; - - /* - * Keep the previous result if we run out of memory. The system would - * really get hosed if we simply give up. - */ - new_num = (addrs == 0) ? 1 : num_addrs + num_addrs; - new_addrs = (struct in_addr *) malloc(sizeof(*addrs) * new_num); - if (new_addrs == 0) { - xlog_warn("%s: out of memory", __func__); - return (0); - } else { - if (addrs != 0) { - memcpy((char *) new_addrs, (char *) addrs, - sizeof(*addrs) * num_addrs); - free((char *) addrs); - } - num_addrs = new_num; - addrs = new_addrs; - return (1); - } -} - -/* find_local - find all IP addresses for this host */ -static int -find_local(void) -{ - struct ifconf ifc; - struct ifreq ifreq; - struct ifreq *ifr; - struct ifreq *the_end; - int sock; - char buf[BUFSIZ]; - - /* - * Get list of network interfaces. We use a huge buffer to allow for the - * presence of non-IP interfaces. - */ - - if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - xlog_warn("%s: socket(2): %m", __func__); - return (0); - } - ifc.ifc_len = sizeof(buf); - ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *) &ifc) < 0) { - xlog_warn("%s: ioctl(SIOCGIFCONF): %m", __func__); - (void) close(sock); - return (0); - } - /* Get IP address of each active IP network interface. */ - - the_end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len); - num_local = 0; - for (ifr = ifc.ifc_req; ifr < the_end; ifr++) { - if (ifr->ifr_addr.sa_family == AF_INET) { /* IP net interface */ - ifreq = *ifr; - if (ioctl(sock, SIOCGIFFLAGS, (char *) &ifreq) < 0) { - xlog_warn("%s: ioctl(SIOCGIFFLAGS): %m", __func__); - } else if (ifreq.ifr_flags & IFF_UP) { /* active interface */ - if (ioctl(sock, SIOCGIFADDR, (char *) &ifreq) < 0) { - xlog_warn("%s: ioctl(SIOCGIFADDR): %m", __func__); - } else { - if (num_local >= num_addrs) - if (grow_addrs() == 0) - break; - addrs[num_local++] = ((struct sockaddr_in *) - & ifreq.ifr_addr)->sin_addr; - } - } - } - /* Support for variable-length addresses. */ -#ifdef HAS_SA_LEN - ifr = (struct ifreq *) ((caddr_t) ifr - + ifr->ifr_addr.sa_len - sizeof(struct sockaddr)); -#endif - } - (void) close(sock); - return (num_local); -} - -/** - * from_local - determine whether request comes from the local system - * @sap: pointer to socket address to check - * - * With virtual hosting, each hardware network interface can have - * multiple network addresses. On such machines the number of machine - * addresses can be surprisingly large. - * - * Returns TRUE if the sockaddr contains an address of one of the local - * network interfaces. Otherwise FALSE is returned. - */ -int -from_local(const struct sockaddr *sap) -{ - const struct sockaddr_in *addr = (const struct sockaddr_in *)sap; - int i; - - if (sap->sa_family != AF_INET) - return (FALSE); - - if (addrs == 0 && find_local() == 0) - xlog(L_ERROR, "Cannot find any active local network interfaces"); - - for (i = 0; i < num_local; i++) { - if (memcmp((char *) &(addr->sin_addr), (char *) &(addrs[i]), - sizeof(struct in_addr)) == 0) - return (TRUE); - } - return (FALSE); -} - -#ifdef TEST - -int main(void) -{ - int i; - - find_local(); - for (i = 0; i < num_local; i++) - printf("%s\n", inet_ntoa(addrs[i])); -} - -#endif /* TEST */ - -#endif /* !HAVE_GETIFADDRS */ diff --git a/nfs-utils-2.5.2/support/misc/mountpoint.c b/nfs-utils-2.5.2/support/misc/mountpoint.c deleted file mode 100644 index 14d6731..0000000 --- a/nfs-utils-2.5.2/support/misc/mountpoint.c +++ /dev/null @@ -1,46 +0,0 @@ - -/* - * check if a given path is a mountpoint - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "xcommon.h" -#include -#include "misc.h" - -int -check_is_mountpoint(const char *path, int (mystat)(const char *, struct stat *)) -{ - if (!mystat) - mystat = lstat; - /* Check if 'path' is a current mountpoint. - * Possibly we should also check it is the mountpoint of the - * filesystem holding the target directory, but there doesn't - * seem a lot of point. - * - * We deem it to be a mountpoint if appending a ".." gives a different - * device or the same inode number. - */ - char *dotdot; - struct stat stb, pstb; - int rv; - - dotdot = xmalloc(strlen(path)+4); - - strcat(strcpy(dotdot, path), "/.."); - if (mystat(path, &stb) != 0 || - mystat(dotdot, &pstb) != 0) - rv = 0; - else - if (stb.st_dev != pstb.st_dev || - stb.st_ino == pstb.st_ino) - rv = 1; - else - rv = 0; - free(dotdot); - return rv; -} diff --git a/nfs-utils-2.5.2/support/misc/nfsd_path.c b/nfs-utils-2.5.2/support/misc/nfsd_path.c deleted file mode 100644 index 8efbfcd..0000000 --- a/nfs-utils-2.5.2/support/misc/nfsd_path.c +++ /dev/null @@ -1,409 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "xmalloc.h" -#include "xlog.h" -#include "xstat.h" -#include "nfslib.h" -#include "nfsd_path.h" -#include "workqueue.h" - -static struct xthread_workqueue *nfsd_wq; - -static int -nfsd_path_isslash(const char *path) -{ - return path[0] == '/' && path[1] == '/'; -} - -static int -nfsd_path_isdot(const char *path) -{ - return path[0] == '.' && path[1] == '/'; -} - -static const char * -nfsd_path_strip(const char *path) -{ - if (!path || *path == '\0') - goto out; - for (;;) { - if (nfsd_path_isslash(path)) { - path++; - continue; - } - if (nfsd_path_isdot(path)) { - path += 2; - continue; - } - break; - } -out: - return path; -} - -const char * -nfsd_path_nfsd_rootdir(void) -{ - const char *rootdir; - - rootdir = nfsd_path_strip(conf_get_str("exports", "rootdir")); - if (!rootdir || rootdir[0] == '\0') - return NULL; - if (rootdir[0] == '/' && rootdir[1] == '\0') - return NULL; - return rootdir; -} - -char * -nfsd_path_strip_root(char *pathname) -{ - char buffer[PATH_MAX]; - const char *dir = nfsd_path_nfsd_rootdir(); - - if (!dir) - goto out; - - if (realpath(dir, buffer)) - return strstr(pathname, buffer) == pathname ? - pathname + strlen(buffer) : NULL; - - xlog(D_GENERAL, "%s: failed to resolve path %s: %m", __func__, dir); -out: - return pathname; -} - -char * -nfsd_path_prepend_dir(const char *dir, const char *pathname) -{ - size_t len, dirlen; - char *ret; - - dirlen = strlen(dir); - while (dirlen > 0 && dir[dirlen - 1] == '/') - dirlen--; - if (!dirlen) - return NULL; - while (pathname[0] == '/') - pathname++; - len = dirlen + strlen(pathname) + 1; - ret = xmalloc(len + 1); - snprintf(ret, len+1, "%.*s/%s", (int)dirlen, dir, pathname); - return ret; -} - -static void -nfsd_setup_workqueue(void) -{ - const char *rootdir = nfsd_path_nfsd_rootdir(); - - if (!rootdir) - return; -printf("rootdir %s\n", rootdir); - nfsd_wq = xthread_workqueue_alloc(); - if (!nfsd_wq) - return; - xthread_workqueue_chroot(nfsd_wq, rootdir); -} - -void -nfsd_path_init(void) -{ - nfsd_setup_workqueue(); -} - -struct nfsd_stat_data { - const char *pathname; - struct stat *statbuf; - int ret; - int err; -}; - -static void -nfsd_statfunc(void *data) -{ - struct nfsd_stat_data *d = data; - - d->ret = xstat(d->pathname, d->statbuf); - if (d->ret < 0) - d->err = errno; -} - -static void -nfsd_lstatfunc(void *data) -{ - struct nfsd_stat_data *d = data; - - d->ret = xlstat(d->pathname, d->statbuf); - if (d->ret < 0) - d->err = errno; -} - -static int -nfsd_run_stat(struct xthread_workqueue *wq, - void (*func)(void *), - const char *pathname, - struct stat *statbuf) -{ - struct nfsd_stat_data data = { - pathname, - statbuf, - 0, - 0 - }; - xthread_work_run_sync(wq, func, &data); - if (data.ret < 0) - errno = data.err; - return data.ret; -} - -int -nfsd_path_stat(const char *pathname, struct stat *statbuf) -{ - if (!nfsd_wq) - return xstat(pathname, statbuf); - return nfsd_run_stat(nfsd_wq, nfsd_statfunc, pathname, statbuf); -} - -int -nfsd_path_lstat(const char *pathname, struct stat *statbuf) -{ - if (!nfsd_wq) - return xlstat(pathname, statbuf); - return nfsd_run_stat(nfsd_wq, nfsd_lstatfunc, pathname, statbuf); -} - -struct nfsd_statfs64_data { - const char *pathname; - struct statfs64 *statbuf; - int ret; - int err; -}; - -static void -nfsd_statfs64func(void *data) -{ - struct nfsd_statfs64_data *d = data; - - d->ret = statfs64(d->pathname, d->statbuf); - if (d->ret < 0) - d->err = errno; -} - -static int -nfsd_run_statfs64(struct xthread_workqueue *wq, - const char *pathname, - struct statfs64 *statbuf) -{ - struct nfsd_statfs64_data data = { - pathname, - statbuf, - 0, - 0 - }; - xthread_work_run_sync(wq, nfsd_statfs64func, &data); - if (data.ret < 0) - errno = data.err; - return data.ret; -} - -int -nfsd_path_statfs64(const char *pathname, struct statfs64 *statbuf) -{ - if (!nfsd_wq) - return statfs64(pathname, statbuf); - return nfsd_run_statfs64(nfsd_wq, pathname, statbuf); -} - -struct nfsd_realpath_data { - const char *pathname; - char *resolved; - int err; -}; - -static void -nfsd_realpathfunc(void *data) -{ - struct nfsd_realpath_data *d = data; - - d->resolved = realpath(d->pathname, d->resolved); - if (!d->resolved) - d->err = errno; -} - -char * -nfsd_realpath(const char *path, char *resolved_path) -{ - struct nfsd_realpath_data data = { - path, - resolved_path, - 0 - }; - - if (!nfsd_wq) - return realpath(path, resolved_path); - - xthread_work_run_sync(nfsd_wq, nfsd_realpathfunc, &data); - if (!data.resolved) - errno = data.err; - return data.resolved; -} - -struct nfsd_read_data { - int fd; - char *buf; - size_t len; - ssize_t ret; - int err; -}; - -static void -nfsd_readfunc(void *data) -{ - struct nfsd_read_data *d = data; - - d->ret = read(d->fd, d->buf, d->len); - if (d->ret < 0) - d->err = errno; -} - -static ssize_t -nfsd_run_read(struct xthread_workqueue *wq, int fd, char *buf, size_t len) -{ - struct nfsd_read_data data = { - fd, - buf, - len, - 0, - 0 - }; - xthread_work_run_sync(wq, nfsd_readfunc, &data); - if (data.ret < 0) - errno = data.err; - return data.ret; -} - -ssize_t -nfsd_path_read(int fd, char *buf, size_t len) -{ - if (!nfsd_wq) - return read(fd, buf, len); - return nfsd_run_read(nfsd_wq, fd, buf, len); -} - -struct nfsd_write_data { - int fd; - const char *buf; - size_t len; - ssize_t ret; - int err; -}; - -static void -nfsd_writefunc(void *data) -{ - struct nfsd_write_data *d = data; - - d->ret = write(d->fd, d->buf, d->len); - if (d->ret < 0) - d->err = errno; -} - -static ssize_t -nfsd_run_write(struct xthread_workqueue *wq, int fd, const char *buf, size_t len) -{ - struct nfsd_write_data data = { - fd, - buf, - len, - 0, - 0 - }; - xthread_work_run_sync(wq, nfsd_writefunc, &data); - if (data.ret < 0) - errno = data.err; - return data.ret; -} - -ssize_t -nfsd_path_write(int fd, const char *buf, size_t len) -{ - if (!nfsd_wq) - return write(fd, buf, len); - return nfsd_run_write(nfsd_wq, fd, buf, len); -} - -#if defined(HAVE_NAME_TO_HANDLE_AT) -struct nfsd_handle_data { - int fd; - const char *path; - struct file_handle *fh; - int *mount_id; - int flags; - int ret; - int err; -}; - -static void -nfsd_name_to_handle_func(void *data) -{ - struct nfsd_handle_data *d = data; - - d->ret = name_to_handle_at(d->fd, d->path, - d->fh, d->mount_id, d->flags); - if (d->ret < 0) - d->err = errno; -} - -static int -nfsd_run_name_to_handle_at(struct xthread_workqueue *wq, - int fd, const char *path, struct file_handle *fh, - int *mount_id, int flags) -{ - struct nfsd_handle_data data = { - fd, - path, - fh, - mount_id, - flags, - 0, - 0 - }; - - xthread_work_run_sync(wq, nfsd_name_to_handle_func, &data); - if (data.ret < 0) - errno = data.err; - return data.ret; -} - -int -nfsd_name_to_handle_at(int fd, const char *path, struct file_handle *fh, - int *mount_id, int flags) -{ - if (!nfsd_wq) - return name_to_handle_at(fd, path, fh, mount_id, flags); - - return nfsd_run_name_to_handle_at(nfsd_wq, fd, path, fh, - mount_id, flags); -} -#else -int -nfsd_name_to_handle_at(int UNUSED(fd), const char *UNUSED(path), - struct file_handle *UNUSED(fh), - int *UNUSED(mount_id), int UNUSED(flags)) -{ - errno = ENOSYS; - return -1; -} -#endif diff --git a/nfs-utils-2.5.2/support/misc/tcpwrapper.c b/nfs-utils-2.5.2/support/misc/tcpwrapper.c deleted file mode 100644 index 3128053..0000000 --- a/nfs-utils-2.5.2/support/misc/tcpwrapper.c +++ /dev/null @@ -1,270 +0,0 @@ -/* This is copied from portmap 4.0-29 in RedHat. */ - - /* - * pmap_check - additional portmap security. - * - * Always reject non-local requests to update the portmapper tables. - * - * Refuse to forward mount requests to the nfs mount daemon. Otherwise, the - * requests would appear to come from the local system, and nfs export - * restrictions could be bypassed. - * - * Refuse to forward requests to the nfsd process. - * - * Refuse to forward requests to NIS (YP) daemons; The only exception is the - * YPPROC_DOMAIN_NONACK broadcast rpc call that is used to establish initial - * contact with the NIS server. - * - * Always allocate an unprivileged port when forwarding a request. - * - * If compiled with -DCHECK_PORT, require that requests to register or - * unregister a privileged port come from a privileged port. This makes it - * more difficult to replace a critical service by a trojan. - * - * If compiled with -DHOSTS_ACCESS, reject requests from hosts that are not - * authorized by the /etc/hosts.{allow,deny} files. The local system is - * always treated as an authorized host. The access control tables are never - * consulted for requests from the local system, and are always consulted - * for requests from other hosts. - * - * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and - * Computing Science, Eindhoven University of Technology, The Netherlands. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_LIBWRAP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "tcpwrapper.h" -#include "xlog.h" - -#ifdef SYSV40 -#include -#include -#endif /* SYSV40 */ - -#define ALLOW 1 -#define DENY 0 - -#ifdef IPV6_SUPPORTED -static void -present_address(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; - socklen_t len = (socklen_t)buflen; - - switch (sap->sa_family) { - case AF_INET: - if (inet_ntop(AF_INET, &sin->sin_addr, buf, len) != 0) - return; - break; - case AF_INET6: - if (inet_ntop(AF_INET6, &sin6->sin6_addr, buf, len) != 0) - return; - } - - memset(buf, 0, buflen); - strncpy(buf, "unrecognized caller", buflen); -} -#else /* !IPV6_SUPPORTED */ -static void -present_address(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - socklen_t len = (socklen_t)buflen; - - if (sap->sa_family == AF_INET) - if (inet_ntop(AF_INET, &sin->sin_addr, buf, len) != 0) - return; - - memset(buf, 0, buflen); - strncpy(buf, "unrecognized caller", (size_t)buflen); -} -#endif /* !IPV6_SUPPORTED */ - -typedef struct _haccess_t { - TAILQ_ENTRY(_haccess_t) list; - int allowed; - union nfs_sockaddr address; -} haccess_t; - -#define HASH_TABLE_SIZE 1021 -typedef struct _hash_head { - TAILQ_HEAD(host_list, _haccess_t) h_head; -} hash_head; - -static hash_head haccess_tbl[HASH_TABLE_SIZE]; - -static unsigned long -strtoint(const char *str) -{ - unsigned long i, n = 0; - size_t len = strlen(str); - - for (i = 0; i < len; i++) - n += (unsigned char)str[i] * i; - - return n; -} - -static unsigned int -hashint(const unsigned long num) -{ - return (unsigned int)(num % HASH_TABLE_SIZE); -} - -static unsigned int -HASH(const char *addr, const unsigned long program) -{ - return hashint(strtoint(addr) + program); -} - -static void -haccess_add(const struct sockaddr *sap, const char *address, - const unsigned long program, const int allowed) -{ - hash_head *head; - haccess_t *hptr; - unsigned int hash; - - hptr = (haccess_t *)malloc(sizeof(haccess_t)); - if (hptr == NULL) - return; - - hash = HASH(address, program); - head = &(haccess_tbl[hash]); - - hptr->allowed = allowed; - memcpy(&hptr->address, sap, (size_t)nfs_sockaddr_length(sap)); - - if (TAILQ_EMPTY(&head->h_head)) - TAILQ_INSERT_HEAD(&head->h_head, hptr, list); - else - TAILQ_INSERT_TAIL(&head->h_head, hptr, list); -} - -static haccess_t * -haccess_lookup(const struct sockaddr *sap, const char *address, - const unsigned long program) -{ - hash_head *head; - haccess_t *hptr; - unsigned int hash; - - hash = HASH(address, program); - head = &(haccess_tbl[hash]); - - TAILQ_FOREACH(hptr, &head->h_head, list) { - if (nfs_compare_sockaddr(&hptr->address.sa, sap)) - return hptr; - } - return NULL; -} - -static void -logit(const char *address) -{ - xlog_warn("connect from %s denied: request from unauthorized host", - address); -} - -static int -good_client(char *name, struct sockaddr *sap) -{ - struct request_info req; - - request_init(&req, RQ_DAEMON, name, RQ_CLIENT_SIN, sap, 0); - sock_methods(&req); - - if (hosts_access(&req)) - return ALLOW; - - return DENY; -} - -static int -check_files(void) -{ - static time_t allow_mtime, deny_mtime; - struct stat astat, dstat; - int changed = 0; - - if (stat("/etc/hosts.allow", &astat) < 0) - astat.st_mtime = 0; - if (stat("/etc/hosts.deny", &dstat) < 0) - dstat.st_mtime = 0; - - if(!astat.st_mtime || !dstat.st_mtime) - return changed; - - if (astat.st_mtime != allow_mtime) - changed = 1; - else if (dstat.st_mtime != deny_mtime) - changed = 1; - - allow_mtime = astat.st_mtime; - deny_mtime = dstat.st_mtime; - - return changed; -} - -/** - * check_default - additional checks for NULL, DUMP, GETPORT and unknown - * @name: pointer to '\0'-terminated ASCII string containing name of the - * daemon requesting the access check - * @sap: pointer to sockaddr containing network address of caller - * @program: RPC program number caller is attempting to access - * - * Returns TRUE if the caller is allowed access; otherwise FALSE is returned. - */ -int -check_default(char *name, struct sockaddr *sap, const unsigned long program) -{ - haccess_t *acc = NULL; - int changed = check_files(); - char buf[INET6_ADDRSTRLEN]; - - present_address(sap, buf, sizeof(buf)); - - acc = haccess_lookup(sap, buf, program); - if (acc != NULL && changed == 0) { - xlog(D_GENERAL, "%s: access by %s %s (cached)", __func__, - buf, acc->allowed ? "ALLOWED" : "DENIED"); - return acc->allowed; - } - - if (!(from_local(sap) || good_client(name, sap))) { - logit(buf); - if (acc != NULL) - acc->allowed = FALSE; - else - haccess_add(sap, buf, program, FALSE); - xlog(D_GENERAL, "%s: access by %s DENIED", __func__, buf); - return (FALSE); - } - - if (acc != NULL) - acc->allowed = TRUE; - else - haccess_add(sap, buf, program, TRUE); - xlog(D_GENERAL, "%s: access by %s ALLOWED", __func__, buf); - - return (TRUE); -} - -#endif /* HAVE_LIBWRAP */ diff --git a/nfs-utils-2.5.2/support/misc/workqueue.c b/nfs-utils-2.5.2/support/misc/workqueue.c deleted file mode 100644 index 8043268..0000000 --- a/nfs-utils-2.5.2/support/misc/workqueue.c +++ /dev/null @@ -1,228 +0,0 @@ -#include -#include - -#include "config.h" -#include "workqueue.h" -#include "xlog.h" - -#if defined(HAVE_SCHED_H) && defined(HAVE_LIBPTHREAD) && defined(HAVE_UNSHARE) -#include -#include - -struct xwork_struct { - struct xwork_struct *next; - void (*fn)(void *); - void *data; -}; - -struct xwork_queue { - struct xwork_struct *head; - struct xwork_struct **tail; - - unsigned char shutdown : 1; -}; - -static void xwork_queue_init(struct xwork_queue *queue) -{ - queue->head = NULL; - queue->tail = &queue->head; - queue->shutdown = 0; -} - -static void xwork_enqueue(struct xwork_queue *queue, - struct xwork_struct *entry) -{ - entry->next = NULL; - *queue->tail = entry; - queue->tail = &entry->next; -} - -static struct xwork_struct *xwork_dequeue(struct xwork_queue *queue) -{ - struct xwork_struct *entry = NULL; - if (queue->head) { - entry = queue->head; - queue->head = entry->next; - if (!queue->head) - queue->tail = &queue->head; - } - return entry; -} - -struct xthread_work { - struct xwork_struct work; - - pthread_cond_t cond; -}; - -struct xthread_workqueue { - struct xwork_queue queue; - - pthread_mutex_t mutex; - pthread_cond_t cond; -}; - -static void xthread_workqueue_init(struct xthread_workqueue *wq) -{ - xwork_queue_init(&wq->queue); - pthread_mutex_init(&wq->mutex, NULL); - pthread_cond_init(&wq->cond, NULL); -} - -static void xthread_workqueue_fini(struct xthread_workqueue *wq) -{ - pthread_cond_destroy(&wq->cond); - pthread_mutex_destroy(&wq->mutex); -} - -static int xthread_work_enqueue(struct xthread_workqueue *wq, - struct xthread_work *work) -{ - xwork_enqueue(&wq->queue, &work->work); - pthread_cond_signal(&wq->cond); - return 0; -} - -static struct xthread_work *xthread_work_dequeue(struct xthread_workqueue *wq) -{ - return (struct xthread_work *)xwork_dequeue(&wq->queue); -} - -static void xthread_workqueue_do_work(struct xthread_workqueue *wq) -{ - struct xthread_work *work; - - pthread_mutex_lock(&wq->mutex); - /* Signal the caller that we're up and running */ - pthread_cond_signal(&wq->cond); - for (;;) { - work = xthread_work_dequeue(wq); - if (work) { - work->work.fn(work->work.data); - pthread_cond_signal(&work->cond); - continue; - } - if (wq->queue.shutdown) - break; - pthread_cond_wait(&wq->cond, &wq->mutex); - } - pthread_mutex_unlock(&wq->mutex); -} - -void xthread_workqueue_shutdown(struct xthread_workqueue *wq) -{ - pthread_mutex_lock(&wq->mutex); - wq->queue.shutdown = 1; - pthread_cond_signal(&wq->cond); - pthread_mutex_unlock(&wq->mutex); -} - -static void xthread_workqueue_free(struct xthread_workqueue *wq) -{ - xthread_workqueue_fini(wq); - free(wq); -} - -static void xthread_workqueue_cleanup(void *data) -{ - xthread_workqueue_free(data); -} - -static void *xthread_workqueue_worker(void *data) -{ - pthread_cleanup_push(xthread_workqueue_cleanup, data); - xthread_workqueue_do_work(data); - pthread_cleanup_pop(1); - return NULL; -} - -struct xthread_workqueue *xthread_workqueue_alloc(void) -{ - struct xthread_workqueue *ret; - pthread_t thread; - - ret = malloc(sizeof(*ret)); - if (ret) { - xthread_workqueue_init(ret); - - pthread_mutex_lock(&ret->mutex); - if (pthread_create(&thread, NULL, - xthread_workqueue_worker, - ret) == 0) { - /* Wait for thread to start */ - pthread_cond_wait(&ret->cond, &ret->mutex); - pthread_mutex_unlock(&ret->mutex); - return ret; - } - pthread_mutex_unlock(&ret->mutex); - xthread_workqueue_free(ret); - ret = NULL; - } - return NULL; -} - -void xthread_work_run_sync(struct xthread_workqueue *wq, - void (*fn)(void *), void *data) -{ - struct xthread_work work = { - { - NULL, - fn, - data - }, - PTHREAD_COND_INITIALIZER, - }; - pthread_mutex_lock(&wq->mutex); - xthread_work_enqueue(wq, &work); - pthread_cond_wait(&work.cond, &wq->mutex); - pthread_mutex_unlock(&wq->mutex); - pthread_cond_destroy(&work.cond); -} - -static void xthread_workqueue_do_chroot(void *data) -{ - const char *path = data; - - if (unshare(CLONE_FS) != 0) { - xlog_err("unshare() failed: %m"); - return; - } - if (chroot(path) != 0) - xlog_err("chroot(%s) failed: %m", path); -} - -void xthread_workqueue_chroot(struct xthread_workqueue *wq, - const char *path) -{ - xthread_work_run_sync(wq, xthread_workqueue_do_chroot, (void *)path); -} - -#else - -struct xthread_workqueue { -}; - -static struct xthread_workqueue ret; - -struct xthread_workqueue *xthread_workqueue_alloc(void) -{ - return &ret; -} - -void xthread_workqueue_shutdown(struct xthread_workqueue *wq) -{ -} - -void xthread_work_run_sync(struct xthread_workqueue *wq, - void (*fn)(void *), void *data) -{ - fn(data); -} - -void xthread_workqueue_chroot(struct xthread_workqueue *wq, - const char *path) -{ - xlog_err("Unable to run as chroot"); -} - -#endif /* defined(HAVE_SCHED_H) && defined(HAVE_LIBPTHREAD) && defined(HAVE_UNSHARE) */ diff --git a/nfs-utils-2.5.2/support/misc/xstat.c b/nfs-utils-2.5.2/support/misc/xstat.c deleted file mode 100644 index a438fbc..0000000 --- a/nfs-utils-2.5.2/support/misc/xstat.c +++ /dev/null @@ -1,112 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "xstat.h" - -#ifdef HAVE_FSTATAT -#ifdef HAVE_STATX - -static void -statx_copy(struct stat *stbuf, const struct statx *stxbuf) -{ - stbuf->st_dev = makedev(stxbuf->stx_dev_major, stxbuf->stx_dev_minor); - stbuf->st_ino = stxbuf->stx_ino; - stbuf->st_mode = stxbuf->stx_mode; - stbuf->st_nlink = stxbuf->stx_nlink; - stbuf->st_uid = stxbuf->stx_uid; - stbuf->st_gid = stxbuf->stx_gid; - stbuf->st_rdev = makedev(stxbuf->stx_rdev_major, stxbuf->stx_rdev_minor); - stbuf->st_size = stxbuf->stx_size; - stbuf->st_blksize = stxbuf->stx_blksize; - stbuf->st_blocks = stxbuf->stx_blocks; - stbuf->st_atim.tv_sec = stxbuf->stx_atime.tv_sec; - stbuf->st_atim.tv_nsec = stxbuf->stx_atime.tv_nsec; - stbuf->st_mtim.tv_sec = stxbuf->stx_mtime.tv_sec; - stbuf->st_mtim.tv_nsec = stxbuf->stx_mtime.tv_nsec; - stbuf->st_ctim.tv_sec = stxbuf->stx_ctime.tv_sec; - stbuf->st_ctim.tv_nsec = stxbuf->stx_ctime.tv_nsec; -} - -static int -statx_do_stat(int fd, const char *pathname, struct stat *statbuf, int flags) -{ - static int statx_supported = 1; - struct statx stxbuf; - int ret; - - if (statx_supported) { - ret = statx(fd, pathname, flags, - STATX_BASIC_STATS, - &stxbuf); - if (ret == 0) { - statx_copy(statbuf, &stxbuf); - return 0; - } - /* glibc emulation doesn't support AT_STATX_DONT_SYNC */ - if (errno == EINVAL) - errno = ENOSYS; - if (errno == ENOSYS) - statx_supported = 0; - } else - errno = ENOSYS; - return -1; -} - -static int -statx_stat_nosync(int fd, const char *pathname, struct stat *statbuf, int flags) -{ - return statx_do_stat(fd, pathname, statbuf, flags | AT_STATX_DONT_SYNC); -} - -#else - -static int -statx_stat_nosync(int UNUSED(fd), const char *UNUSED(pathname), struct stat *UNUSED(statbuf), int UNUSED(flags)) -{ - errno = ENOSYS; - return -1; -} - -#endif /* HAVE_STATX */ - -int xlstat(const char *pathname, struct stat *statbuf) -{ - if (statx_stat_nosync(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT| - AT_SYMLINK_NOFOLLOW) == 0) - return 0; - else if (errno != ENOSYS) - return -1; - return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT | - AT_SYMLINK_NOFOLLOW); -} - -int xstat(const char *pathname, struct stat *statbuf) -{ - if (statx_stat_nosync(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT) == 0) - return 0; - else if (errno != ENOSYS) - return -1; - return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT); -} - -#else - -int xlstat(const char *pathname, struct stat *statbuf) -{ - return lstat(pathname, statbuf); -} - -int xstat(const char *pathname, struct stat *statbuf) -{ - return stat(pathname, statbuf); -} -#endif diff --git a/nfs-utils-2.5.2/support/nfs/Makefile.am b/nfs-utils-2.5.2/support/nfs/Makefile.am deleted file mode 100644 index 67e3a8e..0000000 --- a/nfs-utils-2.5.2/support/nfs/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = -noinst_LTLIBRARIES = libnfs.la libnfsconf.la - -libnfs_la_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ - xcommon.c wildmat.c mydaemon.c \ - rpc_socket.c getport.c \ - svc_socket.c cacheio.c closeall.c nfs_mntent.c \ - svc_create.c atomicio.c strlcat.c strlcpy.c -libnfs_la_LIBADD = libnfsconf.la - -libnfsconf_la_SOURCES = conffile.c xlog.c - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/support/nfs/atomicio.c b/nfs-utils-2.5.2/support/nfs/atomicio.c deleted file mode 100644 index 0e81838..0000000 --- a/nfs-utils-2.5.2/support/nfs/atomicio.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002 Marius Aamodt Eriksen - * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include "nfslib.h" - -/* - * ensure all of data on socket comes through. f==read || f==write - */ -ssize_t atomicio(ssize_t(*f) (int, void *, size_t), int fd, void *_s, size_t n) -{ - char *s = _s; - ssize_t res, pos = 0; - - while ((ssize_t)n > pos) { - res = (f) (fd, s + pos, n - pos); - switch (res) { - case -1: - if (errno == EINTR || errno == EAGAIN) - continue; - /* FALLTHRU */ - case 0: - if (pos != 0) - return pos; - return res; - default: - pos += res; - } - } - return pos; -} diff --git a/nfs-utils-2.5.2/support/nfs/cacheio.c b/nfs-utils-2.5.2/support/nfs/cacheio.c deleted file mode 100644 index 70ead94..0000000 --- a/nfs-utils-2.5.2/support/nfs/cacheio.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * support/nfs/cacheio.c - * support IO on the cache channel files in 2.5 and beyond. - * These use 'qwords' which are like words, but with a little quoting. - * - */ - - -/* - * Support routines for text-based upcalls. - * Fields are separated by spaces. - * Fields are either mangled to quote space tab newline slosh with slosh - * or a hexified with a leading \x - * Record is terminated with newline. - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern struct state_paths etab; - -void qword_add(char **bpp, int *lp, char *str) -{ - char *bp = *bpp; - int len = *lp; - char c; - - if (len < 0) return; - - while ((c=*str++) && len > 0) - switch(c) { - case ' ': - case '\t': - case '\n': - case '\\': - if (len >= 4) { - *bp++ = '\\'; - *bp++ = '0' + ((c & 0300)>>6); - *bp++ = '0' + ((c & 0070)>>3); - *bp++ = '0' + ((c & 0007)>>0); - } - len -= 4; - break; - default: - *bp++ = c; - len--; - } - if (c || len <1) len = -1; - else { - *bp++ = ' '; - len--; - } - *bpp = bp; - *lp = len; -} - -void qword_addhex(char **bpp, int *lp, char *buf, int blen) -{ - char *bp = *bpp; - int len = *lp; - - if (len < 0) return; - - if (len > 2) { - *bp++ = '\\'; - *bp++ = 'x'; - len -= 2; - while (blen && len >= 2) { - unsigned char c = *buf++; - *bp++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1); - *bp++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1); - len -= 2; - blen--; - } - } - if (blen || len<1) len = -1; - else { - *bp++ = ' '; - len--; - } - *bpp = bp; - *lp = len; -} - -void qword_addint(char **bpp, int *lp, int n) -{ - int len; - - len = snprintf(*bpp, *lp, "%d ", n); - if (len > *lp) - len = *lp; - *bpp += len; - *lp -= len; -} - -void qword_adduint(char **bpp, int *lp, unsigned int n) -{ - int len; - - len = snprintf(*bpp, *lp, "%u ", n); - if (len > *lp) - len = *lp; - *bpp += len; - *lp -= len; -} - -void qword_addeol(char **bpp, int *lp) -{ - if (*lp <= 0) - return; - **bpp = '\n'; - (*bpp)++; - (*lp)--; -} - -#define isodigit(c) (isdigit(c) && c <= '7') -int qword_get(char **bpp, char *dest, int bufsize) -{ - /* return bytes copied, or -1 on error */ - char *bp = *bpp; - int len = 0; - - while (*bp == ' ') bp++; - - if (bp[0] == '\\' && bp[1] == 'x') { - /* HEX STRING */ - bp += 2; - while (isxdigit(bp[0]) && isxdigit(bp[1]) && len < bufsize) { - int byte = isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10; - bp++; - byte <<= 4; - byte |= isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10; - *dest++ = byte; - bp++; - len++; - } - } else { - /* text with \nnn octal quoting */ - while (*bp != ' ' && *bp != '\n' && *bp && len < bufsize-1) { - if (*bp == '\\' && - isodigit(bp[1]) && (bp[1] <= '3') && - isodigit(bp[2]) && - isodigit(bp[3])) { - int byte = (*++bp -'0'); - bp++; - byte = (byte << 3) | (*bp++ - '0'); - byte = (byte << 3) | (*bp++ - '0'); - *dest++ = byte; - len++; - } else { - *dest++ = *bp++; - len++; - } - } - } - - if (*bp != ' ' && *bp != '\n' && *bp != '\0') - return -1; - while (*bp == ' ') bp++; - *bpp = bp; - *dest = '\0'; - return len; -} - -int qword_get_int(char **bpp, int *anint) -{ - char buf[50]; - char *ep; - int rv; - int len = qword_get(bpp, buf, 50); - if (len < 0) return -1; - if (len ==0) return -1; - rv = strtol(buf, &ep, 0); - if (*ep) return -1; - *anint = rv; - return 0; -} - -int qword_get_uint(char **bpp, unsigned int *anint) -{ - char buf[50]; - char *ep; - unsigned int rv; - int len = qword_get(bpp, buf, 50); - if (len < 0) return -1; - if (len ==0) return -1; - rv = strtoul(buf, &ep, 0); - if (*ep) return -1; - *anint = rv; - return 0; -} - -/* flush the kNFSd caches. - * Set the flush time to the mtime of the etab state file or - * if force, to now. - * the caches to flush are: - * auth.unix.ip nfsd.export nfsd.fh - */ - -void -cache_flush(int force) -{ - struct stat stb; - int c; - char stime[32]; - char path[200]; - time_t now; - /* Note: the order of these caches is important. - * They need to be flushed in dependancy order. So - * a cache that references items in another cache, - * as nfsd.fh entries reference items in nfsd.export, - * must be flushed before the cache that it references. - */ - static char *cachelist[] = { - "auth.unix.ip", - "auth.unix.gid", - "nfsd.fh", - "nfsd.export", - NULL - }; - now = time(0); - if (force || - stat(etab.statefn, &stb) != 0 || - stb.st_mtime > now) - stb.st_mtime = time(0); - - sprintf(stime, "%" PRId64 "\n", (int64_t)stb.st_mtime); - for (c=0; cachelist[c]; c++) { - int fd; - sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]); - fd = open(path, O_RDWR); - if (fd >= 0) { - if (write(fd, stime, strlen(stime)) != (ssize_t)strlen(stime)) { - xlog_warn("Writing to '%s' failed: errno %d (%s)", - path, errno, strerror(errno)); - } - close(fd); - } - } -} diff --git a/nfs-utils-2.5.2/support/nfs/closeall.c b/nfs-utils-2.5.2/support/nfs/closeall.c deleted file mode 100644 index e07253e..0000000 --- a/nfs-utils-2.5.2/support/nfs/closeall.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * support/nfs/closeall.c - * Close all file descriptors greater than some limit, - * Use readdir "/proc/self/fd" to avoid excess close(2) calls. - */ - -#include -#include -#include -#include - -#include "nfslib.h" - -void -closeall(int min) -{ - char *endp; - long n; - DIR *dir = opendir("/proc/self/fd"); - - if (dir != NULL) { - int dfd = dirfd(dir); - struct dirent *d; - - while ((d = readdir(dir)) != NULL) { - errno = 0; - n = strtol(d->d_name, &endp, 10); - if (!errno && *endp == '\0' && endp != d->d_name && - n >= min && n != dfd) - (void) close(n); - } - closedir(dir); - } else { - int fd = sysconf(_SC_OPEN_MAX); - while (--fd >= min) - if(fd >= 0) - (void) close(fd); - } -} diff --git a/nfs-utils-2.5.2/support/nfs/conffile.c b/nfs-utils-2.5.2/support/nfs/conffile.c deleted file mode 100644 index 3d13610..0000000 --- a/nfs-utils-2.5.2/support/nfs/conffile.c +++ /dev/null @@ -1,2185 +0,0 @@ -/* $OpenBSD: conf.c,v 1.55 2003/06/03 14:28:16 ho Exp $ */ -/* $EOM: conf.c,v 1.48 2000/12/04 02:04:29 angelos Exp $ */ - -/* - * Copyright (c) 1998, 1999, 2000, 2001 Niklas Hallqvist. All rights reserved. - * Copyright (c) 2000, 2001, 2002 Håkan Olsson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This code was written under funding by Ericsson Radio Systems. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "xlog.h" - -#pragma GCC visibility push(hidden) - -static void conf_load_defaults(void); -static char * conf_readfile(const char *path); -static int conf_set(int , const char *, const char *, const char *, - const char *, int , int ); -static void conf_parse(int trans, char *buf, - char **section, char **subsection, const char *filename); - -struct conf_trans { - TAILQ_ENTRY (conf_trans) link; - int trans; - enum conf_op { CONF_SET, CONF_REMOVE, CONF_REMOVE_SECTION } op; - char *section; - char *arg; - char *tag; - char *value; - int override; - int is_default; -}; - -TAILQ_HEAD (conf_trans_head, conf_trans) conf_trans_queue; - -/* - * Radix-64 Encoding. - */ - -static const uint8_t asc2bin[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 62, 255, 255, 255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 255, 255, 255, 255, 255, 255, - 255, 0, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 255, 255, 255, 255, 255, - 255, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 255, 255, 255, 255, 255 -}; - -struct conf_binding { - LIST_ENTRY (conf_binding) link; - char *section; - char *arg; - char *tag; - char *value; - int is_default; -}; - -LIST_HEAD (conf_bindings, conf_binding) conf_bindings[256]; - -const char *modified_by = NULL; - -static __inline__ uint8_t -conf_hash(const char *s) -{ - uint8_t hash = 0; - - while (*s) { - hash = ((hash << 1) | (hash >> 7)) ^ tolower (*s); - s++; - } - return hash; -} - -/* - * Insert a tag-value combination from LINE (the equal sign is at POS) - */ -static int -conf_remove_now(const char *section, const char *tag) -{ - struct conf_binding *cb, *next; - - cb = LIST_FIRST(&conf_bindings[conf_hash (section)]); - for (; cb; cb = next) { - next = LIST_NEXT(cb, link); - if (strcasecmp(cb->section, section) == 0 - && strcasecmp(cb->tag, tag) == 0) { - LIST_REMOVE(cb, link); - xlog(LOG_INFO,"[%s]:%s->%s removed", section, tag, cb->value); - free(cb->section); - free(cb->arg); - free(cb->tag); - free(cb->value); - free(cb); - return 0; - } - } - return 1; -} - -static int -conf_remove_section_now(const char *section) -{ - struct conf_binding *cb, *next; - int unseen = 1; - - cb = LIST_FIRST(&conf_bindings[conf_hash (section)]); - for (; cb; cb = next) { - next = LIST_NEXT(cb, link); - if (strcasecmp(cb->section, section) == 0) { - unseen = 0; - LIST_REMOVE(cb, link); - xlog(LOG_INFO, "[%s]:%s->%s removed", section, cb->tag, cb->value); - free(cb->section); - free(cb->arg); - free(cb->tag); - free(cb->value); - free(cb); - } - } - return unseen; -} - -/* - * Insert a tag-value combination from LINE (the equal sign is at POS) - * into SECTION of our configuration database. - */ -static int -conf_set_now(const char *section, const char *arg, const char *tag, - const char *value, int override, int is_default) -{ - struct conf_binding *node = 0; - - if (override) - conf_remove_now(section, tag); - else if (conf_get_section(section, arg, tag)) { - if (!is_default) { - xlog(LOG_INFO, "conf_set: duplicate tag [%s]:%s, ignoring...", - section, tag); - } - return 1; - } - node = calloc(1, sizeof *node); - if (!node) { - xlog_warn("conf_set: calloc (1, %lu) failed", (unsigned long)sizeof *node); - return 1; - } - node->section = strdup(section); - if (arg) - node->arg = strdup(arg); - node->tag = strdup(tag); - node->value = strdup(value); - node->is_default = is_default; - LIST_INSERT_HEAD(&conf_bindings[conf_hash (section)], node, link); - return 0; -} - -/* Attempt to construct a relative path to the new file */ -static char * -relative_path(const char *oldfile, const char *newfile) -{ - char *tmpcopy = NULL; - char *dir = NULL; - char *relpath = NULL; - size_t pathlen; - - if (!newfile) - return strdup(oldfile); - - if (newfile[0] == '/') - return strdup(newfile); - - tmpcopy = strdup(oldfile); - if (!tmpcopy) - goto mem_err; - - dir = dirname(tmpcopy); - - pathlen = strlen(dir) + strlen(newfile) + 2; - relpath = calloc(1, pathlen); - if (!relpath) - goto mem_err; - - snprintf(relpath, pathlen, "%s/%s", dir, newfile); - - free(tmpcopy); - return relpath; -mem_err: - if (tmpcopy) - free(tmpcopy); - return NULL; -} - - -/* - * Parse the line LINE of SZ bytes. Skip Comments, recognize section - * headers and feed tag-value pairs into our configuration database. - */ -static void -conf_parse_line(int trans, char *line, const char *filename, int lineno, char **section, char **subsection) -{ - char *val, *ptr; - char *inc_section = NULL, *inc_subsection = NULL; - char *relpath, *subconf; - - /* Strip off any leading blanks */ - while (isspace(*line)) - line++; - - /* Ignore blank lines */ - if (*line == '\0') - return; - - /* Lines starting with '#' or ';' are comments. */ - if (*line == '#' || *line == ';') - return; - - /* '[section]' parsing... */ - if (*line == '[') { - line++; - - if (*section) { - free(*section); - *section = NULL; - } - if (*subsection) { - free(*subsection); - *subsection = NULL; - } - - /* Strip off any blanks after '[' */ - while (isblank(*line)) - line++; - - /* find the closing ] */ - ptr = strchr(line, ']'); - if (ptr == NULL) { - xlog_warn("config error at %s:%d: " - "non-matched ']', ignoring until next section", - filename, lineno); - return; - } - - /* just ignore everything after the closing ] */ - *(ptr--) = '\0'; - - /* Strip off any blanks before ']' */ - while (ptr >= line && isblank(*ptr)) - *(ptr--)='\0'; - - /* look for an arg to split from the section name */ - val = strchr(line, '"'); - if (val != NULL) { - ptr = val - 1; - *(val++) = '\0'; - - /* trim away any whitespace before the " */ - while (ptr > line && isblank(*ptr)) - *(ptr--)='\0'; - } - - /* copy the section name */ - *section = strdup(line); - if (!*section) { - xlog_warn("config error at %s:%d:" - "malloc failed", filename, lineno); - return; - } - - /* there is no arg, we are done */ - if (val == NULL) - return; - - /* check for the closing " */ - ptr = strchr(val, '"'); - if (ptr == NULL) { - xlog_warn("config error at %s:%d: " - "non-matched '\"', ignoring until next section", - filename, lineno); - return; - } - *ptr = '\0'; - *subsection = strdup(val); - if (!*subsection) - xlog_warn("config error at %s:%d: " - "malloc failed", filename, lineno); - return; - } - - /* Deal with assignments. */ - ptr = strchr(line, '='); - - /* not an assignment line */ - if (ptr == NULL) { - /* Other non-empty lines are weird. */ - if (line[strspn(line, " \t")]) - xlog_warn("config error at %s:%d: " - "line not empty and not an assignment", - filename, lineno); - return; - } - - /* If no section, we are ignoring the line. */ - if (!*section) { - xlog_warn("config error at %s:%d: " - "ignoring line not in a section", - filename, lineno); - return; - } - - val = ptr + 1; - *(ptr--) = '\0'; - - /* strip spaces before and after the = */ - while (ptr >= line && isblank(*ptr)) - *(ptr--)='\0'; - while (*val != '\0' && isblank(*val)) - val++; - - if (*val == '"') { - val++; - ptr = strchr(val, '"'); - if (ptr == NULL) { - xlog_warn("config error at %s:%d: " - "unmatched quotes",filename, lineno); - return; - } - *ptr = '\0'; - } else - if (*val == '\'') { - val++; - ptr = strchr(val, '\''); - if (ptr == NULL) { - xlog_warn("config error at %s:%d: " - "unmatched quotes", filename, lineno); - return; - } - *ptr = '\0'; - } else { - /* Trim any trailing spaces and comments */ - if ((ptr=strchr(val, '#'))!=NULL) - *ptr = '\0'; - if ((ptr=strchr(val, ';'))!=NULL) - *ptr = '\0'; - - ptr = val + strlen(val) - 1; - while (ptr > val && isspace(*ptr)) - *(ptr--) = '\0'; - } - - if (*line == '\0') { - xlog_warn("config error at %s:%d: " - "missing tag in assignment", filename, lineno); - return; - } - - if (strcasecmp(line, "include")==0) { - /* load and parse subordinate config files */ - _Bool optional = false; - - if (val && *val == '-') { - optional = true; - val++; - } - - relpath = relative_path(filename, val); - if (relpath == NULL) { - if (!optional) - xlog_warn("config error at %s:%d: error loading included config", - filename, lineno); - return; - } - - subconf = conf_readfile(relpath); - if (subconf == NULL) { - if (!optional) - xlog_warn("config error at %s:%d: error loading included config", - filename, lineno); - if (relpath) - free(relpath); - return; - } - - /* copy the section data so the included file can inherit it - * without accidentally changing it for us */ - if (*section != NULL) { - inc_section = strdup(*section); - if (*subsection != NULL) - inc_subsection = strdup(*subsection); - } - - conf_parse(trans, subconf, &inc_section, &inc_subsection, relpath); - - if (inc_section) - free(inc_section); - if (inc_subsection) - free(inc_subsection); - if (relpath) - free(relpath); - free(subconf); - } else { - /* XXX Perhaps should we not ignore errors? */ - conf_set(trans, *section, *subsection, line, val, 0, 0); - } -} - -/* Parse the mapped configuration file. */ -static void -conf_parse(int trans, char *buf, char **section, char **subsection, const char *filename) -{ - char *cp = buf; - char *bufend = NULL; - char *line; - int lineno = 0; - - line = cp; - bufend = buf + strlen(buf); - while (cp < bufend) { - if (*cp == '\n') { - /* Check for escaped newlines. */ - if (cp > buf && *(cp - 1) == '\\') - *(cp - 1) = *cp = ' '; - else { - *cp = '\0'; - lineno++; - conf_parse_line(trans, line, filename, lineno, section, subsection); - line = cp + 1; - } - } - cp++; - } - if (cp != line) - xlog_warn("conf_parse: last line non-terminated, ignored."); -} - -static void -conf_load_defaults(void) -{ - /* No defaults */ - return; -} - -static char * -conf_readfile(const char *path) -{ - struct stat sb; - if (!path) { - xlog(L_ERROR, "conf_readfile: no path given"); - return NULL; - } - - if ((stat (path, &sb) == 0) || (errno != ENOENT)) { - char *new_conf_addr = NULL; - off_t sz; - int fd = open (path, O_RDONLY, 0); - - if (fd == -1) { - xlog_warn("conf_readfile: open (\"%s\", O_RDONLY) failed", path); - return NULL; - } - - /* Grab a shared lock to ensure its not mid-rewrite */ - if (flock(fd, LOCK_SH)) { - xlog_warn("conf_readfile: attempt to grab read lock failed: %s", - strerror(errno)); - goto fail; - } - - /* only after we have the lock, check the file size ready to read it */ - sz = lseek(fd, 0, SEEK_END); - if (sz < 0) { - xlog_warn("conf_readfile: unable to determine file size: %s", - strerror(errno)); - goto fail; - } - lseek(fd, 0, SEEK_SET); - - new_conf_addr = malloc(sz+1); - if (!new_conf_addr) { - xlog_warn("conf_readfile: malloc (%lu) failed", (unsigned long)sz); - goto fail; - } - - /* XXX I assume short reads won't happen here. */ - if (read (fd, new_conf_addr, sz) != (int)sz) { - xlog_warn("conf_readfile: read (%d, %p, %lu) failed", - fd, new_conf_addr, (unsigned long)sz); - goto fail; - } - close(fd); - - /* XXX Should we not care about errors and rollback? */ - new_conf_addr[sz] = '\0'; - return new_conf_addr; - fail: - close(fd); - if (new_conf_addr) - free(new_conf_addr); - } - return NULL; -} - -/* remove and free up any existing config state */ -static void conf_free_bindings(void) -{ - unsigned int i; - for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++) { - struct conf_binding *cb, *next; - - cb = LIST_FIRST(&conf_bindings[i]); - for (; cb; cb = next) { - next = LIST_NEXT(cb, link); - LIST_REMOVE(cb, link); - free(cb->section); - free(cb->arg); - free(cb->tag); - free(cb->value); - free(cb); - } - LIST_INIT(&conf_bindings[i]); - } -} - -/* Open the config file and map it into our address space, then parse it. */ -static int -conf_load_file(const char *conf_file) -{ - int trans; - char * conf_data; - - trans = conf_begin(); - conf_data = conf_readfile(conf_file); - - if (conf_data == NULL) - return 1; - - /* Load default configuration values. */ - conf_load_defaults(); - - /* Parse config contents into the transaction queue */ - char *section = NULL; - char *subsection = NULL; - conf_parse(trans, conf_data, §ion, &subsection, conf_file); - if (section) free(section); - if (subsection) free(subsection); - free(conf_data); - - /* Free potential existing configuration. */ - conf_free_bindings(); - - /* Apply the new configuration values */ - conf_end(trans, 1); - return 0; -} - -int -conf_init_file(const char *conf_file) -{ - unsigned int i; - - for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++) - LIST_INIT (&conf_bindings[i]); - - TAILQ_INIT (&conf_trans_queue); - - if (conf_file == NULL) conf_file=NFS_CONFFILE; - return conf_load_file(conf_file); -} - -/* - * Empty the config and free up any used memory - */ -void -conf_cleanup(void) -{ - conf_free_bindings(); - - struct conf_trans *node, *next; - for (node = TAILQ_FIRST(&conf_trans_queue); node; node = next) { - next = TAILQ_NEXT(node, link); - TAILQ_REMOVE (&conf_trans_queue, node, link); - if (node->section) free(node->section); - if (node->arg) free(node->arg); - if (node->tag) free(node->tag); - if (node->value) free(node->value); - free (node); - } - TAILQ_INIT(&conf_trans_queue); -} - -/* - * Return the numeric value denoted by TAG in section SECTION or DEF - * if that tag does not exist. - */ -int -conf_get_num(const char *section, const char *tag, int def) -{ - char *value = conf_get_str(section, tag); - - if (value) - return atoi(value); - - return def; -} - -/* - * Return the Boolean value denoted by TAG in section SECTION, or DEF - * if that tags does not exist. - * FALSE is returned for case-insensitive comparisons with 0, f, false, n, no, off - * TRUE is returned for 1, t, true, y, yes, on - * A failure to match one of these results in DEF - */ -_Bool -conf_get_bool(const char *section, const char *tag, _Bool def) -{ - char *value = conf_get_str(section, tag); - - if (!value) - return def; - if (strcasecmp(value, "1") == 0 || - strcasecmp(value, "t") == 0 || - strcasecmp(value, "true") == 0 || - strcasecmp(value, "y") == 0 || - strcasecmp(value, "yes") == 0 || - strcasecmp(value, "on") == 0) - return true; - - if (strcasecmp(value, "0") == 0 || - strcasecmp(value, "f") == 0 || - strcasecmp(value, "false") == 0 || - strcasecmp(value, "n") == 0 || - strcasecmp(value, "no") == 0 || - strcasecmp(value, "off") == 0) - return false; - return def; -} - -/* Validate X according to the range denoted by TAG in section SECTION. */ -int -conf_match_num(const char *section, const char *tag, int x) -{ - char *value = conf_get_str (section, tag); - int val, min, max, n; - - if (!value) - return 0; - n = sscanf (value, "%d,%d:%d", &val, &min, &max); - switch (n) { - case 1: - xlog(LOG_INFO, "conf_match_num: %s:%s %d==%d?", section, tag, val, x); - return x == val; - case 3: - xlog(LOG_INFO, "conf_match_num: %s:%s %d<=%d<=%d?", section, - tag, min, x, max); - return min <= x && max >= x; - default: - xlog(LOG_INFO, "conf_match_num: section %s tag %s: invalid number spec %s", - section, tag, value); - } - return 0; -} - -/* Return the string value denoted by TAG in section SECTION. */ -char * -conf_get_str(const char *section, const char *tag) -{ - return conf_get_section(section, NULL, tag); -} - -/* Return the string value denoted by TAG in section SECTION, - * unless it is not set, in which case return def - */ -char * -conf_get_str_with_def(const char *section, const char *tag, char *def) -{ - char * result = conf_get_section(section, NULL, tag); - if (!result) - return def; - return result; -} - -/* - * Find a section that may or may not have an argument - */ -char * -conf_get_section(const char *section, const char *arg, const char *tag) -{ - struct conf_binding *cb; -retry: - cb = LIST_FIRST (&conf_bindings[conf_hash (section)]); - for (; cb; cb = LIST_NEXT (cb, link)) { - if (strcasecmp(section, cb->section) != 0) - continue; - if (arg && (cb->arg == NULL || strcasecmp(arg, cb->arg) != 0)) - continue; - if (!arg && cb->arg) - continue; - if (strcasecmp(tag, cb->tag) != 0) - continue; - if (cb->value[0] == '$') { - /* expand $name from [environment] section, - * or from environment - */ - char *env = getenv(cb->value+1); - if (env && *env) - return env; - section = "environment"; - tag = cb->value + 1; - goto retry; - } - return cb->value; - } - return 0; -} - -/* - * Build a list of string values out of the comma separated value denoted by - * TAG in SECTION. - */ -struct conf_list * -conf_get_list(const char *section, const char *tag) -{ - char *liststr = 0, *p, *field, *t; - struct conf_list *list = 0; - struct conf_list_node *node; - - list = malloc (sizeof *list); - if (!list) - goto cleanup; - TAILQ_INIT (&list->fields); - list->cnt = 0; - liststr = conf_get_str(section, tag); - if (!liststr) - goto cleanup; - liststr = strdup (liststr); - if (!liststr) - goto cleanup; - p = liststr; - while ((field = strsep (&p, ",")) != NULL) { - /* Skip leading whitespace */ - while (isspace (*field)) - field++; - /* Skip trailing whitespace */ - if (p) { - for (t = p - 1; t > field && isspace (*t); t--) - *t = '\0'; - } - if (*field == '\0') { - xlog(LOG_INFO, "conf_get_list: empty field, ignoring..."); - continue; - } - list->cnt++; - node = calloc (1, sizeof *node); - if (!node) - goto cleanup; - node->field = strdup (field); - if (!node->field) { - free(node); - goto cleanup; - } - TAILQ_INSERT_TAIL (&list->fields, node, link); - } - free (liststr); - return list; - -cleanup: - if (list) - conf_free_list(list); - if (liststr) - free(liststr); - return 0; -} - -struct conf_list * -conf_get_tag_list(const char *section, const char *arg) -{ - struct conf_list *list = 0; - struct conf_list_node *node; - struct conf_binding *cb; - - list = malloc(sizeof *list); - if (!list) - goto cleanup; - TAILQ_INIT(&list->fields); - list->cnt = 0; - cb = LIST_FIRST(&conf_bindings[conf_hash (section)]); - for (; cb; cb = LIST_NEXT(cb, link)) { - if (strcasecmp (section, cb->section) == 0) { - if (arg != NULL && strcasecmp(arg, cb->arg) != 0) - continue; - list->cnt++; - node = calloc(1, sizeof *node); - if (!node) - goto cleanup; - node->field = strdup(cb->tag); - if (!node->field) { - free(node); - goto cleanup; - } - TAILQ_INSERT_TAIL(&list->fields, node, link); - } - } - return list; - -cleanup: - if (list) - conf_free_list(list); - return 0; -} - -/* Decode a PEM encoded buffer. */ -int -conf_decode_base64 (uint8_t *out, uint32_t *len, const unsigned char *buf) -{ - uint32_t c = 0; - uint8_t c1, c2, c3, c4; - - while (*buf) { - if (*buf > 127 || (c1 = asc2bin[*buf]) == 255) - return 0; - - buf++; - if (*buf > 127 || (c2 = asc2bin[*buf]) == 255) - return 0; - - buf++; - if (*buf == '=') { - c3 = c4 = 0; - c++; - - /* Check last four bit */ - if (c2 & 0xF) - return 0; - - if (strcmp((char *)buf, "==") == 0) - buf++; - else - return 0; - } else if (*buf > 127 || (c3 = asc2bin[*buf]) == 255) - return 0; - else { - if (*++buf == '=') { - c4 = 0; - c += 2; - - /* Check last two bit */ - if (c3 & 3) - return 0; - - if (strcmp((char *)buf, "=")) - return 0; - } else if (*buf > 127 || (c4 = asc2bin[*buf]) == 255) - return 0; - else - c += 3; - } - - buf++; - *out++ = (c1 << 2) | (c2 >> 4); - *out++ = (c2 << 4) | (c3 >> 2); - *out++ = (c3 << 6) | c4; - } - - *len = c; - return 1; -} - -void -conf_free_list(struct conf_list *list) -{ - struct conf_list_node *node = TAILQ_FIRST(&list->fields); - - while (node) { - TAILQ_REMOVE(&list->fields, node, link); - if (node->field) - free(node->field); - free (node); - node = TAILQ_FIRST(&list->fields); - } - free (list); -} - -int -conf_begin(void) -{ - static int seq = 0; - - return ++seq; -} - -static struct conf_trans * -conf_trans_node(int transaction, enum conf_op op) -{ - struct conf_trans *node; - - node = calloc (1, sizeof *node); - if (!node) { - xlog_warn("conf_trans_node: calloc (1, %lu) failed", - (unsigned long)sizeof *node); - return 0; - } - node->trans = transaction; - node->op = op; - TAILQ_INSERT_TAIL (&conf_trans_queue, node, link); - return node; -} - -/* Queue a set operation. */ -static int -conf_set(int transaction, const char *section, const char *arg, - const char *tag, const char *value, int override, int is_default) -{ - struct conf_trans *node; - - if (!value || !*value) - return 0; - node = conf_trans_node(transaction, CONF_SET); - if (!node) - return 1; - node->section = strdup(section); - if (!node->section) { - xlog_warn("conf_set: strdup(\"%s\") failed", section); - goto fail; - } - /* Make Section names case-insensitive */ - upper2lower(node->section); - - if (arg) { - node->arg = strdup(arg); - if (!node->arg) { - xlog_warn("conf_set: strdup(\"%s\") failed", arg); - goto fail; - } - } else - node->arg = NULL; - - node->tag = strdup(tag); - if (!node->tag) { - xlog_warn("conf_set: strdup(\"%s\") failed", tag); - goto fail; - } - node->value = strdup(value); - if (!node->value) { - xlog_warn("conf_set: strdup(\"%s\") failed", value); - goto fail; - } - node->override = override; - node->is_default = is_default; - return 0; - -fail: - if (node->tag) - free(node->tag); - if (node->arg) - free(node->arg); - if (node->section) - free(node->section); - if (node) - free(node); - return 1; -} - -/* Queue a remove operation. */ -int -conf_remove(int transaction, const char *section, const char *tag) -{ - struct conf_trans *node; - - node = conf_trans_node(transaction, CONF_REMOVE); - if (!node) - goto fail; - node->section = strdup(section); - if (!node->section) { - xlog_warn("conf_remove: strdup(\"%s\") failed", section); - goto fail; - } - node->tag = strdup(tag); - if (!node->tag) { - xlog_warn("conf_remove: strdup(\"%s\") failed", tag); - goto fail; - } - return 0; - -fail: - if (node && node->section) - free (node->section); - if (node) - free (node); - return 1; -} - -/* Queue a remove section operation. */ -int -conf_remove_section(int transaction, const char *section) -{ - struct conf_trans *node; - - node = conf_trans_node(transaction, CONF_REMOVE_SECTION); - if (!node) - goto fail; - node->section = strdup(section); - if (!node->section) { - xlog_warn("conf_remove_section: strdup(\"%s\") failed", section); - goto fail; - } - return 0; - -fail: - if (node) - free(node); - return 1; -} - -/* Execute all queued operations for this transaction. Cleanup. */ -int -conf_end(int transaction, int commit) -{ - struct conf_trans *node, *next; - - for (node = TAILQ_FIRST(&conf_trans_queue); node; node = next) { - next = TAILQ_NEXT(node, link); - if (node->trans == transaction) { - if (commit) { - switch (node->op) { - case CONF_SET: - conf_set_now(node->section, node->arg, - node->tag, node->value, node->override, - node->is_default); - break; - case CONF_REMOVE: - conf_remove_now(node->section, node->tag); - break; - case CONF_REMOVE_SECTION: - conf_remove_section_now(node->section); - break; - default: - xlog(LOG_INFO, "conf_end: unknown operation: %d", node->op); - } - } - TAILQ_REMOVE (&conf_trans_queue, node, link); - if (node->section) - free(node->section); - if (node->arg) - free(node->arg); - if (node->tag) - free(node->tag); - if (node->value) - free(node->value); - free (node); - } - } - return 0; -} - -/* - * Dump running configuration upon SIGUSR1. - * Configuration is "stored in reverse order", so reverse it again. - */ -struct dumper { - char *section; - char *arg; - char *tag; - char *value; - struct dumper *next; -}; - -/* - * Test if two nodes belong to the same (sub)sections - */ -static int -dumper_section_compare(const struct dumper *nodea, const struct dumper *nodeb) -{ - int ret; - - /* missing node, shouldnt happen */ - if (!nodea || !nodeb) - return -1; - - /* no section names at all, they are equal */ - if (!nodea->section && !nodeb->section) - return 0; - - /* if only one has a section name, the blank one goes first */ - if (!nodea->section && nodeb->section) - return -1; - - if (nodea->section && !nodeb->section) - return 1; - - /* both have section names, but do they match */ - ret = strcmp(nodea->section, nodeb->section); - - /* section names differ, that was easy */ - if (ret != 0) - return ret; - - /* sections matched, but how about sub-sections, - * again, if only one has a value the blank goes first - */ - if (!nodea->arg && nodeb->arg) - return -1; - - if (nodea->arg && !nodeb->arg) - return 1; - - /* both have sub-section args and they differ */ - if (nodea->arg && nodeb->arg - && (ret=strcmp(nodea->arg, nodeb->arg))!=0) - return ret; - - return 0; -} - -/* If a string starts or ends with a space it should be quoted */ -static bool -should_escape(const char *text) -{ - int len; - - /* no string, no escaping needed */ - if (!text) - return false; - - /* first character is a space */ - if (isspace(text[0])) - return true; - - /* last character is a space */ - len = strlen(text); - if (isspace(text[len-1])) - return true; - - return false; -} - -static void -conf_report_dump_text(struct dumper *head, FILE *ff) -{ - const struct dumper *node = head; - const struct dumper *last = NULL; - - for (node=head; node!=NULL; node=node->next) { - /* starting a new section, print the section header */ - if (dumper_section_compare(last, node)!=0) { - if (node != head) - fprintf(ff, "\n"); - if (node->arg) - fprintf(ff, "[%s \"%s\"]\n", node->section, node->arg); - else - fprintf(ff, "[%s]\n", node->section); - } - - /* now print the tag and its value */ - fprintf(ff, " %s", node->tag); - if (node->value) { - if (should_escape(node->value)) - fprintf(ff, " = \"%s\"", node->value); - else - fprintf(ff, " = %s", node->value); - } - fprintf(ff, "\n"); - - last = node; - } -} - -/* sort by tag compare function */ -static int -dumper_compare(const void *a, const void *b) -{ - const struct dumper *nodea = *(struct dumper **)a; - const struct dumper *nodeb = *(struct dumper **)b; - int ret; - - /* missing node, shouldnt happen */ - if (!nodea || !nodeb) - return -1; - - /* are the two nodes in different (sub)sections */ - ret = dumper_section_compare(nodea, nodeb); - if (ret != 0) - return ret; - - /* sub-sections match (both blank, or both same) - * so we compare the tag names - */ - - /* blank tags shouldnt happen, but paranoia */ - if (!nodea->tag && !nodeb->tag) - return 0; - - /* still shouldnt happen, but use the blank-goes-first logic */ - if (!nodea->tag && nodeb->tag) - return -1; - if ( nodea->tag && !nodeb->tag) - return 1; - - /* last test, compare the tags directly */ - ret = strcmp(nodea->tag, nodeb->tag); - return ret; -} - -/* sort all of the report nodes */ -static struct dumper * -conf_report_sort(struct dumper *start) -{ - struct dumper **list; - struct dumper *node; - unsigned int count = 0; - unsigned int i=0; - - /* how long is this list */ - for (node=start; node!=NULL; node=node->next) - count++; - - /* no need to sort a list with less than 2 items */ - if (count < 2) - return start; - - /* build an array of all the nodes */ - list = calloc(count, sizeof(struct dumper *)); - if (!list) - goto mem_err; - - for (node=start,i=0; node!=NULL; node=node->next) { - list[i++] = node; - } - - /* sort the array alphabetically by section and tag */ - qsort(list, count, sizeof(struct dumper *), dumper_compare); - - /* rebuild the linked list in sorted order */ - for (i=0; inext = list[i+1]; - } - list[count-1]->next = NULL; - - /* remember the new head of list and discard the sorting array */ - node = list[0]; - free(list); - - /* return the new head of list */ - return node; - -mem_err: - free(list); - return NULL; -} - -/* Output a copy of the current configuration to file */ -void -conf_report(FILE *outfile) -{ - struct conf_binding *cb = NULL; - unsigned int i; - struct dumper *dumper = NULL, *dnode = NULL; - - xlog(LOG_INFO, "conf_report: dumping running configuration"); - - /* build a linked list of all the config nodes */ - for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++) { - for (cb = LIST_FIRST(&conf_bindings[i]); cb; cb = LIST_NEXT(cb, link)) { - struct dumper *newnode = calloc(1, sizeof (struct dumper)); - if (!newnode) - goto mem_fail; - - newnode->next = dumper; - dumper = newnode; - - newnode->section = cb->section; - newnode->arg = cb->arg; - newnode->tag = cb->tag; - newnode->value = cb->value; - } - } - - /* sort the list then print it */ - dumper = conf_report_sort(dumper); - conf_report_dump_text(dumper, outfile); - goto cleanup; - -mem_fail: - xlog_warn("conf_report: malloc/calloc failed"); -cleanup: - /* traverse the linked list freeing all the nodes */ - while ((dnode = dumper) != 0) { - dumper = dumper->next; - free(dnode); - } - return; -} - -/* struct and queue for buffing output lines */ -TAILQ_HEAD(tailhead, outbuffer); - -struct outbuffer { - TAILQ_ENTRY(outbuffer) link; - char *text; -}; - -static struct outbuffer * -make_outbuffer(char *line) -{ - struct outbuffer *new; - - if (line == NULL) - return NULL; - - new = calloc(1, sizeof(struct outbuffer)); - if (new == NULL) { - xlog(L_ERROR, "malloc error creating outbuffer"); - return NULL; - } - new->text = line; - return new; -} - -/* compose a properly escaped tag=value line */ -static char * -make_tagline(const char *tag, const char *value) -{ - char *line; - int ret; - - if (!value) - return NULL; - - if (should_escape(value)) - ret = asprintf(&line, "%s = \"%s\"\n", tag, value); - else - ret = asprintf(&line, "%s = %s\n", tag, value); - - if (ret == -1) { - xlog(L_ERROR, "malloc error composing a tag line"); - return NULL; - } - return line; -} - -/* compose a section header line */ -static char * -make_section(const char *section, const char *arg) -{ - char *line; - int ret; - - if (arg) - ret = asprintf(&line, "[%s \"%s\"]\n", section, arg); - else - ret = asprintf(&line, "[%s]\n", section); - - if (ret == -1) { - xlog(L_ERROR, "malloc error composing section header"); - return NULL; - } - return line; -} - -/* compose a comment line (with or without tag) */ -static char * -make_comment(const char *tag, const char *comment) -{ - char *line; - int ret; - - if (tag == NULL || *tag == '\0') { - ret = asprintf(&line, "# %s\n", comment); - } else { - ret = asprintf(&line, "# %s: %s\n", tag, comment); - } - - if (ret == -1) { - xlog(L_ERROR, "malloc error composing header"); - return NULL; - } - - return line; -} - -/* compose a 'file modified' comment */ -static char * -make_timestamp(const char *tag, time_t when) -{ - struct tm *tstamp; - char datestr[80]; - char *result = NULL, *tmpstr = NULL; - int ret; - - tstamp = localtime(&when); - if (strftime(datestr, sizeof(datestr), "%b %d %Y %H:%M:%S", tstamp) == 0) { - xlog(L_ERROR, "error composing date"); - datestr[0] = '\0'; - } - - if (modified_by) { - ret = asprintf(&tmpstr, "%s on %s", modified_by, datestr); - if (ret == -1) { - xlog(L_ERROR, "malloc error composing a time stamp"); - return NULL; - } - result = make_comment(tag, tmpstr); - free(tmpstr); - } else { - result = make_comment(tag, datestr); - } - return result; -} - -/* does the supplied line contain the named section header */ -static bool -is_section(const char *line, const char *section, const char *arg) -{ - char *end; - char *name; - char *sub; - bool found = false; - - /* Not a valid section name */ - if (strcmp(section, "#") == 0) - return false; - - /* skip leading white space */ - while (*line == '[' || isspace(*line)) - line++; - - name = strdup(line); - if (name == NULL) { - xlog_warn("conf_write: malloc failed "); - return false; - } - - /* find the end */ - end = strchr(name, ']'); - - /* malformed line */ - if (end == NULL) { - xlog_warn("conf_write: warning: malformed section name"); - goto cleanup; - } - - while (*end && ( *end == ']' || isblank(*end))) - *(end--) = '\0'; - - /* is there a subsection name (aka arg) */ - sub = strchr(name, '"'); - if (sub) { - end = sub - 1; - *(sub++) = '\0'; - - /* trim whitespace between section name and arg */ - while (end > name && isblank(*end)) - *(end--) = '\0'; - - /* trim off closing quote */ - end = strchr(sub, '"'); - if (end == NULL) { - xlog_warn("conf_write: warning: malformed sub-section name"); - goto cleanup; - } - *end = '\0'; - } - - /* ready to compare */ - if (strcasecmp(section, name)!=0) - goto cleanup; - - if (arg != NULL) { - if (sub == NULL || strcasecmp(arg, sub)!=0) - goto cleanup; - } else { - if (sub != NULL) - goto cleanup; - } - - found = true; - -cleanup: - free(name); - return found; -} - -/* check that line contains the specified tag assignment */ -static bool -is_tag(const char *line, const char *tagname) -{ - char *end; - char *name; - bool found = false; - - /* quick check, is this even an assignment line */ - end = strchr(line, '='); - if (end == NULL) - return false; - - /* skip leading white space before tag name */ - while (isblank(*line)) - line++; - - name = strdup(line); - if (name == NULL) { - xlog_warn("conf_write: malloc failed"); - return false; - } - - /* trim any newline characters */ - end = strchr(name, '\n'); - if (end) - *end = '\0'; - end = strchr(name, '\r'); - if (end) - *end = '\0'; - - /* find the assignment equals sign */ - end = strchr(name, '='); - - /* malformed line, i swear the equals was there earlier */ - if (end == NULL) { - xlog_warn("conf_write: warning: malformed tag name"); - goto cleanup; - } - - /* trim trailing whitespace after tag name */ - do { - *(end--) = '\0'; - }while (end > name && *end && isblank(*end)); - - /* quoted string, take contents of quotes only */ - if (*name == '"') { - char * new = strdup(name+1); - end = strchr(new, '"'); - if (end != NULL) { - *end = 0; - free(name); - name = new; - } else { - free(new); - } - } - - /* now compare */ - if (strcasecmp(tagname, name) == 0) - found = true; - -cleanup: - free(name); - return found; -} - -/* is this an empty line ? */ -static bool -is_empty(const char *line) -{ - const char *p = line; - - if (line == NULL) - return true; - if (*line == '\0') - return true; - - while (*p != '\0' && isspace(*p)) - p++; - - if (*p == '\0') - return true; - - return false; -} - -/* is this line just a comment ? */ -static bool -is_comment(const char *line) -{ - if (line == NULL) - return false; - - while (isblank(*line)) - line++; - - if (*line == '#') - return true; - - return false; -} - -/* check that line contains the specified comment header */ -static bool -is_taggedcomment(const char *line, const char *field) -{ - char *end; - char *name; - bool found = false; - - if (line == NULL) - return false; - - while (isblank(*line)) - line++; - - if (*line != '#') - return false; - - line++; - - /* quick check, is this even a likely formatted line */ - end = strchr(line, ':'); - if (end == NULL) - return false; - - /* skip leading white space before field name */ - while (isblank(*line)) - line++; - - name = strdup(line); - if (name == NULL) { - xlog_warn("conf_write: malloc failed"); - return false; - } - - /* strip trailing spaces from the name */ - end = strchr(name, ':'); - if (end) *(end--) = 0; - while (end && end > name && isblank(*end)) - *(end--)=0; - - if (strcasecmp(name, field)==0) - found = true; - - free(name); - return found; -} - - -/* delete a buffer queue whilst optionally outputting to file */ -static int -flush_outqueue(struct tailhead *queue, FILE *fout) -{ - int ret = 0; - while (queue->tqh_first != NULL) { - struct outbuffer *ob = queue->tqh_first; - TAILQ_REMOVE(queue, ob, link); - if (ob->text) { - if (fout) { - ret = fprintf(fout, "%s", ob->text); - if (ret == -1) { - xlog(L_ERROR, "Error writing to config file: %s", - strerror(errno)); - fout = NULL; - } - } - free(ob->text); - } - free(ob); - } - if (ret == -1) - return 1; - return 0; -} - -/* append one queue to another */ -static void -append_queue(struct tailhead *inq, struct tailhead *outq) -{ - while (inq->tqh_first != NULL) { - struct outbuffer *ob = inq->tqh_first; - TAILQ_REMOVE(inq, ob, link); - TAILQ_INSERT_TAIL(outq, ob, link); - } -} - -/* read one line of text from a file, growing the buffer as necessary */ -static int -read_line(char **buff, int *buffsize, FILE *in) -{ - char *readp; - int used = 0; - bool again = false; - - /* make sure we have a buffer to read into */ - if (*buff == NULL) { - *buffsize = 4096; - *buff = calloc(1, *buffsize); - if (*buff == NULL) { - xlog(L_ERROR, "malloc error for read buffer"); - return -1; - } - } - - readp = *buff; - - do { - int len; - - /* read in a chunk */ - if (fgets(readp, *buffsize-used, in)==NULL) - return -1; - - len = strlen(*buff); - if (len == 0) - return -1; - - /* was this the end of a line, or partial read */ - readp = *buff + len - 1; - - if (*readp != '\n' && *readp !='\r') { - /* no nl/cr must be partial read, go again */ - readp++; - again = true; - } else { - /* that was a normal end of line */ - again = false; - } - - /* do we need more space */ - if (again && *buffsize - len < 1024) { - int offset = readp - *buff; - char *newbuff; - *buffsize += 4096; - newbuff = realloc(*buff, *buffsize); - if (newbuff == NULL) { - xlog(L_ERROR, "malloc error reading line"); - return -1; - } - *buff = newbuff; - readp = newbuff + offset; - } - } while(again); - return 0; -} - -/* append a line to the given location in the queue */ -static int -append_line(struct tailhead *queue, struct outbuffer *entry, char *line) -{ - int ret = 0; - char *end; - bool splitmode = false; - char *start = line; - - if (line == NULL) - return -1; - - /* if there are \n's in the middle of the string - * then we need to split it into folded lines */ - do { - char *thisline; - struct outbuffer *qbuff; - - end = strchr(start, '\n'); - if (end && *(end+1) != '\0') { - *end = '\0'; - - ret = asprintf(&thisline, "%s\\\n", start); - if (ret == -1) { - xlog(L_ERROR, "malloc error composing output"); - return -1; - } - splitmode = true; - start = end+1; - } else { - end = NULL; - if (splitmode) { - thisline = strdup(start); - if (thisline == NULL) - return -1; - } else { - thisline = start; - } - } - - qbuff = make_outbuffer(thisline); - if (qbuff == NULL) - return -1; - - if (entry) { - TAILQ_INSERT_AFTER(queue, entry, qbuff, link); - entry = TAILQ_NEXT(entry, link); - } else { - TAILQ_INSERT_TAIL(queue, qbuff, link); - } - }while (end != NULL); - - /* we malloced copies of this, so free the original */ - if (splitmode) - free(line); - - return 0; -} - -/* is this a "folded" line, i.e. ends in backslash */ -static bool -is_folded(const char *line) -{ - const char *end; - if (line == NULL) - return false; - - end = line + strlen(line); - while (end > line) { - end--; - if (*end != '\n' && *end != '\r') - break; - } - - if (*end == '\\') - return true; - - return false; -} - -static int -lock_file(FILE *f) -{ - int ret; - ret = flock(fileno(f), LOCK_EX); - if (ret) - xlog(L_ERROR, "Error could not lock the file"); - return ret; -} - -/*** - * Write a value to an nfs.conf style filename - * - * create the file if it doesnt already exist - * if value==NULL removes the setting (if present) - */ -int -conf_write(const char *filename, const char *section, const char *arg, - const char *tag, const char *value) -{ - FILE *infile = NULL; - int ret = 1; - struct tailhead outqueue; - struct tailhead inqueue; - char * buff = NULL; - int buffsize = 0; - time_t now = time(NULL); - - TAILQ_INIT(&inqueue); - TAILQ_INIT(&outqueue); - - if (!filename) { - xlog_warn("conf_write: no filename supplied"); - return ret; - } - - if (!section || !tag) { - xlog_warn("conf_write: section or tag name missing"); - return ret; - } - - infile = fopen(filename, "r+"); - if (!infile) { - if (!value) { - xlog_warn("conf_write: config file \"%s\" not found, nothing to do", filename); - ret = 0; - goto cleanup; - } - - xlog_warn("conf_write: config file \"%s\" not found, creating.", filename); - infile = fopen(filename, "wx"); - if (!infile) { - xlog(L_ERROR, "conf_write: Error creating config file \"%s\".", filename); - goto cleanup; - } - - if (lock_file(infile)) - goto cleanup; - - if (strcmp(section, "#") == 0) { - if (append_line(&inqueue, NULL, make_comment(tag, value))) - goto cleanup; - } else { - if (append_line(&inqueue, NULL, make_section(section, arg))) - goto cleanup; - - if (append_line(&inqueue, NULL, make_tagline(tag, value))) - goto cleanup; - } - - append_queue(&inqueue, &outqueue); - } else - if (strcmp(section, "#") == 0) { - /* Adding a comment line */ - struct outbuffer *where = NULL; - struct outbuffer *next = NULL; - bool found = false; - int err = 0; - - if (lock_file(infile)) - goto cleanup; - - buffsize = 4096; - buff = calloc(1, buffsize); - if (buff == NULL) { - xlog(L_ERROR, "malloc error for read buffer"); - goto cleanup; - } - buff[0] = '\0'; - - /* read in the file */ - do { - if (*buff != '\0' - && !is_taggedcomment(buff, "Modified")) { - if (append_line(&inqueue, NULL, strdup(buff))) - goto cleanup; - } - - err = read_line(&buff, &buffsize, infile); - } while (err == 0); - - /* if a tagged comment, look for an existing instance */ - if (tag && *tag != '\0') { - where = TAILQ_FIRST(&inqueue); - while (where != NULL) { - next = TAILQ_NEXT(where, link); - struct outbuffer *prev = TAILQ_PREV(where, tailhead, link); - if (is_taggedcomment(where->text, tag)) { - TAILQ_REMOVE(&inqueue, where, link); - free(where->text); - free(where); - found = true; - if (append_line(&inqueue, prev, make_comment(tag, value))) - goto cleanup; - } - where = next; - } - } - /* it wasn't tagged or we didn't find it */ - if (!found) { - /* does the file end in a blank line or a comment */ - if (!TAILQ_EMPTY(&inqueue)) { - struct outbuffer *tail = TAILQ_LAST(&inqueue, tailhead); - if (tail && !is_empty(tail->text) && !is_comment(tail->text)) { - /* no, so add one for clarity */ - if (append_line(&inqueue, NULL, strdup("\n"))) - goto cleanup; - } - } - /* add the new comment line */ - if (append_line(&inqueue, NULL, make_comment(tag, value))) - goto cleanup; - } - /* move everything over to the outqueue for writing */ - append_queue(&inqueue, &outqueue); - } else { - bool found = false; - int err = 0; - - if (lock_file(infile)) - goto cleanup; - - buffsize = 4096; - buff = calloc(1, buffsize); - if (buff == NULL) { - xlog(L_ERROR, "malloc error for read buffer"); - goto cleanup; - } - - buff[0] = '\0'; - do { - struct outbuffer *where = NULL; - - /* read in one section worth of lines */ - do { - if (*buff != '\0' - && !is_taggedcomment(buff, "Modified")) { - if (append_line(&inqueue, NULL, strdup(buff))) - goto cleanup; - } - - err = read_line(&buff, &buffsize, infile); - } while (err == 0 && buff[0] != '['); - - /* find the section header */ - where = TAILQ_FIRST(&inqueue); - while (where != NULL) { - if (where->text != NULL && where->text[0] == '[') - break; - where = TAILQ_NEXT(where, link); - } - - /* this is the section we care about */ - if (where != NULL && is_section(where->text, section, arg)) { - struct outbuffer *section_start = where; - - /* is there an existing assignment */ - while ((where = TAILQ_NEXT(where, link)) != NULL) { - if (is_tag(where->text, tag)) { - found = true; - break; - } - } - - /* no active assignment, but is there a commented one */ - if (!found) { - where = section_start; - while ((where = TAILQ_NEXT(where, link)) != NULL) { - if (is_comment(where->text)) { - char *cline = where->text; - while (isspace(*cline)) - cline++; - - if (*cline != '#') - continue; - cline++; - - if (is_tag(cline, tag)) { - found = true; - break; - } - } - } - } - - /* replace the located tag with an updated one */ - if (found) { - struct outbuffer *prev = TAILQ_PREV(where, tailhead, link); - bool again = false; - - /* remove current tag */ - do { - struct outbuffer *next = TAILQ_NEXT(where, link); - TAILQ_REMOVE(&inqueue, where, link); - if (is_folded(where->text)) - again = true; - else - again = false; - free(where->text); - free(where); - where = next; - } while(again && where != NULL); - - /* insert new tag */ - if (value) { - if (append_line(&inqueue, prev, make_tagline(tag, value))) - goto cleanup; - } - } else - /* no existing assignment found and we need to add one */ - if (value) { - /* rewind past blank lines and comments */ - struct outbuffer *tail = TAILQ_LAST(&inqueue, tailhead); - - /* comments immediately before a section usually relate - * to the section below them */ - while (tail != NULL && is_comment(tail->text)) - tail = TAILQ_PREV(tail, tailhead, link); - - /* there is usually blank line(s) between sections */ - while (tail != NULL && is_empty(tail->text)) - tail = TAILQ_PREV(tail, tailhead, link); - - /* now add the tag here */ - if (append_line(&inqueue, tail, make_tagline(tag, value))) - goto cleanup; - - found = true; - } - } - - /* EOF and correct section not found, so add one */ - if (err && !found && value) { - /* did the last section end in a blank line */ - struct outbuffer *tail = TAILQ_LAST(&inqueue, tailhead); - if (tail && !is_empty(tail->text)) { - /* no, so add one for clarity */ - if (append_line(&inqueue, NULL, strdup("\n"))) - goto cleanup; - } - - /* add the new section header */ - if (append_line(&inqueue, NULL, make_section(section, arg))) - goto cleanup; - - /* now add the tag */ - if (append_line(&inqueue, NULL, make_tagline(tag, value))) - goto cleanup; - } - - /* we are done with this section, move it to the out queue */ - append_queue(&inqueue, &outqueue); - } while(err == 0); - } - - if (modified_by) { - /* check for and update the Modified header */ - /* does the file end in a blank line or a comment */ - if (!TAILQ_EMPTY(&outqueue)) { - struct outbuffer *tail = TAILQ_LAST(&outqueue, tailhead); - if (tail && !is_empty(tail->text) && !is_comment(tail->text)) { - /* no, so add one for clarity */ - if (append_line(&outqueue, NULL, strdup("\n"))) - goto cleanup; - } - } - - /* now append the modified date comment */ - if (append_line(&outqueue, NULL, make_timestamp("Modified", now))) - goto cleanup; - } - - /* now rewind and overwrite the file with the updated data */ - rewind(infile); - - if (ftruncate(fileno(infile), 0)) { - xlog(L_ERROR, "Error truncating config file"); - goto cleanup; - } - - if (flush_outqueue(&outqueue, infile)) - goto cleanup; - - if (infile) { - fclose(infile); - infile = NULL; - } - - ret = 0; - -cleanup: - flush_outqueue(&inqueue, NULL); - flush_outqueue(&outqueue, NULL); - - if (buff) - free(buff); - if (infile) - fclose(infile); - return ret; -} diff --git a/nfs-utils-2.5.2/support/nfs/exports.c b/nfs-utils-2.5.2/support/nfs/exports.c deleted file mode 100644 index 037febd..0000000 --- a/nfs-utils-2.5.2/support/nfs/exports.c +++ /dev/null @@ -1,851 +0,0 @@ -/* - * support/nfs/export.c - * - * Parse the exports file. Derived from the unfsd implementation. - * - * Authors: Donald J. Becker, - * Rick Sladkey, - * Fred N. van Kempen, - * Olaf Kirch, - * Alexander O. Yuriev, - * - * This software maybe be used for any purpose provided - * the above copyright notice is retained. It is supplied - * as is, with no warranty expressed or implied. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "nfslib.h" -#include "exportfs.h" -#include "xmalloc.h" -#include "xlog.h" -#include "xio.h" -#include "pseudoflavors.h" - -#define EXPORT_DEFAULT_FLAGS \ - (NFSEXP_READONLY|NFSEXP_ROOTSQUASH|NFSEXP_GATHERED_WRITES|NFSEXP_NOSUBTREECHECK) - -struct flav_info flav_map[] = { - { "krb5", RPC_AUTH_GSS_KRB5 }, - { "krb5i", RPC_AUTH_GSS_KRB5I }, - { "krb5p", RPC_AUTH_GSS_KRB5P }, - { "unix", AUTH_UNIX }, - { "sys", AUTH_SYS }, - { "null", AUTH_NULL }, - { "none", AUTH_NONE }, -}; - -const int flav_map_size = sizeof(flav_map)/sizeof(flav_map[0]); - -static char *efname = NULL; -static XFILE *efp = NULL; -static int first; -static int has_default_opts, has_default_subtree_opts; -static int *squids = NULL, nsquids = 0, - *sqgids = NULL, nsqgids = 0; - -static int getexport(char *exp, int len); -static int getpath(char *path, int len); -static int parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr); -static int parsesquash(char *list, int **idp, int *lenp, char **ep); -static int parsenum(char **cpp); -static void freesquash(void); -static void syntaxerr(char *msg); -static struct flav_info *find_flavor(char *name); - -void -setexportent(char *fname, char *type) -{ - if (efp) - endexportent(); - if (!fname) - fname = _PATH_EXPORTS; - if (!(efp = xfopen(fname, type))) - xlog(L_ERROR, "can't open %s for %sing", - fname, strcmp(type, "r")? "writ" : "read"); - efname = strdup(fname); - first = 1; -} - -static void init_exportent (struct exportent *ee, int fromkernel) -{ - ee->e_flags = EXPORT_DEFAULT_FLAGS; - /* some kernels assume the default is sync rather than - * async. More recent kernels always report one or other, - * but this test makes sure we assume same as kernel - * Ditto for wgather - */ - if (fromkernel) { - ee->e_flags &= ~NFSEXP_ASYNC; - ee->e_flags &= ~NFSEXP_GATHERED_WRITES; - } - ee->e_anonuid = 65534; - ee->e_anongid = 65534; - ee->e_squids = NULL; - ee->e_sqgids = NULL; - ee->e_mountpoint = NULL; - ee->e_fslocmethod = FSLOC_NONE; - ee->e_fslocdata = NULL; - ee->e_secinfo[0].flav = NULL; - ee->e_nsquids = 0; - ee->e_nsqgids = 0; - ee->e_uuid = NULL; - ee->e_ttl = DEFAULT_TTL; -} - -struct exportent * -getexportent(int fromkernel, int fromexports) -{ - static struct exportent ee, def_ee; - char exp[512], *hostname; - char rpath[MAXPATHLEN+1]; - char *opt, *sp; - int ok; - - if (!efp) - return NULL; - - freesquash(); - - if (first || (ok = getexport(exp, sizeof(exp))) == 0) { - has_default_opts = 0; - has_default_subtree_opts = 0; - - init_exportent(&def_ee, fromkernel); - - ok = getpath(def_ee.e_path, sizeof(def_ee.e_path)); - if (ok <= 0) - return NULL; - - ok = getexport(exp, sizeof(exp)); - } - if (ok < 0) { - xlog(L_ERROR, "expected client(options...)"); - return NULL; - } - first = 0; - - /* - * Check for default options. The kernel will never have default - * options in /proc/fs/nfs/exports, however due to the initial '-' in - * the -test-client- string from the test export we have to check that - * we're not reading from the kernel. - */ - if (exp[0] == '-' && !fromkernel) { - if (parseopts(exp + 1, &def_ee, 0, &has_default_subtree_opts) < 0) - return NULL; - - has_default_opts = 1; - - ok = getexport(exp, sizeof(exp)); - if (ok < 0) { - xlog(L_ERROR, "expected client(options...)"); - return NULL; - } - } - - xfree(ee.e_hostname); - xfree(ee.e_realpath); - ee = def_ee; - - /* Check for default client */ - if (ok == 0) - exp[0] = '\0'; - - hostname = exp; - if ((opt = strchr(exp, '(')) != NULL) { - if (opt == exp) { - xlog(L_WARNING, "No host name given with %s %s, suggest *%s to avoid warning", ee.e_path, exp, exp); - hostname = "*"; - } - *opt++ = '\0'; - if (!(sp = strchr(opt, ')')) || sp[1] != '\0') { - syntaxerr("bad option list"); - return NULL; - } - *sp = '\0'; - } else { - if (!has_default_opts) - xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp); - } - ee.e_hostname = xstrdup(hostname); - - if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) { - if(ee.e_hostname) - { - xfree(ee.e_hostname); - ee.e_hostname=NULL; - } - if(ee.e_uuid) - { - xfree(ee.e_uuid); - ee.e_uuid=NULL; - } - - return NULL; - } - /* resolve symlinks */ - if (realpath(ee.e_path, rpath) != NULL) { - rpath[sizeof (rpath) - 1] = '\0'; - strncpy(ee.e_path, rpath, sizeof (ee.e_path) - 1); - ee.e_path[sizeof (ee.e_path) - 1] = '\0'; - } - - return ⅇ -} - -static const struct secinfo_flag_displaymap { - unsigned int flag; - const char *set; - const char *unset; -} secinfo_flag_displaymap[] = { - { NFSEXP_READONLY, "ro", "rw" }, - { NFSEXP_INSECURE_PORT, "insecure", "secure" }, - { NFSEXP_ROOTSQUASH, "root_squash", "no_root_squash" }, - { NFSEXP_ALLSQUASH, "all_squash", "no_all_squash" }, - { 0, NULL, NULL } -}; - -static void secinfo_flags_show(FILE *fp, unsigned int flags, unsigned int mask) -{ - const struct secinfo_flag_displaymap *p; - - for (p = &secinfo_flag_displaymap[0]; p->flag != 0; p++) { - if (!(mask & p->flag)) - continue; - fprintf(fp, ",%s", (flags & p->flag) ? p->set : p->unset); - } -} - -void secinfo_show(FILE *fp, struct exportent *ep) -{ - const struct export_features *ef; - struct sec_entry *p1, *p2; - - ef = get_export_features(); - - if (ep->e_secinfo[0].flav == NULL) - secinfo_addflavor(find_flavor("sys"), ep); - for (p1=ep->e_secinfo; p1->flav; p1=p2) { - - fprintf(fp, ",sec=%s", p1->flav->flavour); - for (p2=p1+1; (p2->flav != NULL) && (p1->flags == p2->flags); - p2++) { - fprintf(fp, ":%s", p2->flav->flavour); - } - secinfo_flags_show(fp, p1->flags, ef->secinfo_flags); - } -} - -static void -fprintpath(FILE *fp, const char *path) -{ - int i; - for (i=0; path[i]; i++) - if (iscntrl(path[i]) || path[i] == '"' || path[i] == '\\' || path[i] == '#' || isspace(path[i])) - fprintf(fp, "\\%03o", path[i]); - else - fprintf(fp, "%c", path[i]); -} - -void -putexportent(struct exportent *ep) -{ - FILE *fp; - int *id, i; - - if (!efp) - return; - - fp = efp->x_fp; - fprintpath(fp, ep->e_path); - fprintf(fp, "\t%s(", ep->e_hostname); - fprintf(fp, "%s,", (ep->e_flags & NFSEXP_READONLY)? "ro" : "rw"); - fprintf(fp, "%ssync,", (ep->e_flags & NFSEXP_ASYNC)? "a" : ""); - fprintf(fp, "%swdelay,", (ep->e_flags & NFSEXP_GATHERED_WRITES)? - "" : "no_"); - fprintf(fp, "%shide,", (ep->e_flags & NFSEXP_NOHIDE)? - "no" : ""); - fprintf(fp, "%scrossmnt,", (ep->e_flags & NFSEXP_CROSSMOUNT)? - "" : "no"); - fprintf(fp, "%ssecure,", (ep->e_flags & NFSEXP_INSECURE_PORT)? - "in" : ""); - fprintf(fp, "%sroot_squash,", (ep->e_flags & NFSEXP_ROOTSQUASH)? - "" : "no_"); - fprintf(fp, "%sall_squash,", (ep->e_flags & NFSEXP_ALLSQUASH)? - "" : "no_"); - fprintf(fp, "%ssubtree_check,", (ep->e_flags & NFSEXP_NOSUBTREECHECK)? - "no_" : ""); - fprintf(fp, "%ssecure_locks,", (ep->e_flags & NFSEXP_NOAUTHNLM)? - "in" : ""); - fprintf(fp, "%sacl,", (ep->e_flags & NFSEXP_NOACL)? - "no_" : ""); - if (ep->e_flags & NFSEXP_NOREADDIRPLUS) - fprintf(fp, "nordirplus,"); - if (ep->e_flags & NFSEXP_SECURITY_LABEL) - fprintf(fp, "security_label,"); - fprintf(fp, "%spnfs,", (ep->e_flags & NFSEXP_PNFS)? "" : "no_"); - if (ep->e_flags & NFSEXP_FSID) { - fprintf(fp, "fsid=%d,", ep->e_fsid); - } - if (ep->e_uuid) - fprintf(fp, "fsid=%s,", ep->e_uuid); - if (ep->e_mountpoint) - fprintf(fp, "mountpoint%s%s,", - ep->e_mountpoint[0]?"=":"", ep->e_mountpoint); - switch (ep->e_fslocmethod) { - case FSLOC_NONE: - break; - case FSLOC_REFER: - fprintf(fp, "refer="); - fprintpath(fp, ep->e_fslocdata); - fprintf(fp, ","); - break; - case FSLOC_REPLICA: - fprintf(fp, "replicas="); - fprintpath(fp, ep->e_fslocdata); - fprintf(fp, ","); - break; -#ifdef DEBUG - case FSLOC_STUB: - fprintf(fp, "fsloc=stub,"); - break; -#endif - default: - xlog(L_ERROR, "unknown fsloc method for %s:%s", - ep->e_hostname, ep->e_path); - } - if ((id = ep->e_squids) != NULL) { - fprintf(fp, "squash_uids="); - for (i = 0; i < ep->e_nsquids; i += 2) - if (id[i] != id[i+1]) - fprintf(fp, "%d-%d,", id[i], id[i+1]); - else - fprintf(fp, "%d,", id[i]); - } - if ((id = ep->e_sqgids) != NULL) { - fprintf(fp, "squash_gids="); - for (i = 0; i < ep->e_nsquids; i += 2) - if (id[i] != id[i+1]) - fprintf(fp, "%d-%d,", id[i], id[i+1]); - else - fprintf(fp, "%d,", id[i]); - } - fprintf(fp, "anonuid=%d,anongid=%d", ep->e_anonuid, ep->e_anongid); - secinfo_show(fp, ep); - fprintf(fp, ")\n"); -} - -void -endexportent(void) -{ - if (efp) - xfclose(efp); - efp = NULL; - if (efname) - free(efname); - efname = NULL; - freesquash(); -} - -void -dupexportent(struct exportent *dst, struct exportent *src) -{ - int n; - - *dst = *src; - if ((n = src->e_nsquids) != 0) { - dst->e_squids = (int *) xmalloc(n * sizeof(int)); - memcpy(dst->e_squids, src->e_squids, n * sizeof(int)); - } - if ((n = src->e_nsqgids) != 0) { - dst->e_sqgids = (int *) xmalloc(n * sizeof(int)); - memcpy(dst->e_sqgids, src->e_sqgids, n * sizeof(int)); - } - if (src->e_mountpoint) - dst->e_mountpoint = strdup(src->e_mountpoint); - if (src->e_fslocdata) - dst->e_fslocdata = strdup(src->e_fslocdata); - if (src->e_uuid) - dst->e_uuid = strdup(src->e_uuid); - dst->e_hostname = NULL; - dst->e_realpath = NULL; -} - -struct exportent * -mkexportent(char *hname, char *path, char *options) -{ - static struct exportent ee; - - init_exportent(&ee, 0); - - xfree(ee.e_hostname); - ee.e_hostname = xstrdup(hname); - xfree(ee.e_realpath); - ee.e_realpath = NULL; - - if (strlen(path) >= sizeof(ee.e_path)) { - xlog(L_ERROR, "path name %s too long", path); - return NULL; - } - strncpy(ee.e_path, path, sizeof (ee.e_path)); - ee.e_path[sizeof (ee.e_path) - 1] = '\0'; - if (parseopts(options, &ee, 0, NULL) < 0) - return NULL; - return ⅇ -} - -int -updateexportent(struct exportent *eep, char *options) -{ - if (parseopts(options, eep, 0, NULL) < 0) - return 0; - return 1; -} - - -static int valid_uuid(char *uuid) -{ - /* must have 32 hex digits */ - int cnt; - for (cnt = 0 ; *uuid; uuid++) - if (isxdigit(*uuid)) - cnt++; - return cnt == 32; -} - -/* - * Append the given flavor to the exportent's e_secinfo array, or - * do nothing if it's already there. Returns the index of flavor - * in the resulting array in any case. - */ -int secinfo_addflavor(struct flav_info *flav, struct exportent *ep) -{ - struct sec_entry *p; - - for (p=ep->e_secinfo; p->flav; p++) { - if (p->flav == flav || p->flav->fnum == flav->fnum) - return p - ep->e_secinfo; - } - if (p - ep->e_secinfo >= SECFLAVOR_COUNT) { - xlog(L_ERROR, "more than %d security flavors on an export\n", - SECFLAVOR_COUNT); - return -1; - } - p->flav = flav; - p->flags = ep->e_flags; - (p+1)->flav = NULL; - return p - ep->e_secinfo; -} - -static struct flav_info *find_flavor(char *name) -{ - struct flav_info *flav; - for (flav = flav_map; flav < flav_map + flav_map_size; flav++) - if (strcmp(flav->flavour, name) == 0) - return flav; - return NULL; -} - -/* @str is a colon seperated list of security flavors. Their order - * is recorded in @ep, and a bitmap corresponding to the list is returned. - * A zero return indicates an error. - */ -static unsigned int parse_flavors(char *str, struct exportent *ep) -{ - unsigned int out=0; - char *flavor; - int bit; - - while ( (flavor=strsep(&str, ":")) ) { - struct flav_info *flav = find_flavor(flavor); - if (flav == NULL) { - xlog(L_ERROR, "unknown flavor %s\n", flavor); - return 0; - } - bit = secinfo_addflavor(flav, ep); - if (bit < 0) - return 0; - out |= 1<e_flags |= mask; - - while (active) { - if (active & 1) - ep->e_secinfo[bit].flags |= mask; - bit++; - active >>= 1; - } -} - -/* Clears the bits in @mask for the appropriate security flavor flags. */ -static void clearflags(int mask, unsigned int active, struct exportent *ep) -{ - int bit=0; - - ep->e_flags &= ~mask; - - while (active) { - if (active & 1) - ep->e_secinfo[bit].flags &= ~mask; - bit++; - active >>= 1; - } -} - -/* - * For those flags which are not allowed to vary by pseudoflavor, - * ensure that the export flags agree with the flags on each - * pseudoflavor: - */ -void fix_pseudoflavor_flags(struct exportent *ep) -{ - struct export_features *ef; - struct sec_entry *p; - - ef = get_export_features(); - for (p = ep->e_secinfo; p->flav; p++) - p->flags |= ep->e_flags & ~ef->secinfo_flags; -} - -/* - * Parse option string pointed to by cp and set mount options accordingly. - */ -static int -parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr) -{ - int had_subtree_opt = 0; - char *flname = efname?efname:"command line"; - int flline = efp?efp->x_line:0; - unsigned int active = 0; - - squids = ep->e_squids; nsquids = ep->e_nsquids; - sqgids = ep->e_sqgids; nsqgids = ep->e_nsqgids; - if (!cp) - goto out; - - while (isblank(*cp)) - cp++; - - while (*cp) { - char *opt = strdup(cp); - char *optstart = cp; - while (*cp && *cp != ',') - cp++; - if (*cp) { - opt[cp-optstart] = '\0'; - cp++; - } - - /* process keyword */ - if (strcmp(opt, "ro") == 0) - setflags(NFSEXP_READONLY, active, ep); - else if (strcmp(opt, "rw") == 0) - clearflags(NFSEXP_READONLY, active, ep); - else if (!strcmp(opt, "secure")) - clearflags(NFSEXP_INSECURE_PORT, active, ep); - else if (!strcmp(opt, "insecure")) - setflags(NFSEXP_INSECURE_PORT, active, ep); - else if (!strcmp(opt, "sync")) - clearflags(NFSEXP_ASYNC, active, ep); - else if (!strcmp(opt, "async")) - setflags(NFSEXP_ASYNC, active, ep); - else if (!strcmp(opt, "nordirplus")) - setflags(NFSEXP_NOREADDIRPLUS, active, ep); - else if (!strcmp(opt, "security_label")) - setflags(NFSEXP_SECURITY_LABEL, active, ep); - else if (!strcmp(opt, "nohide")) - setflags(NFSEXP_NOHIDE, active, ep); - else if (!strcmp(opt, "hide")) - clearflags(NFSEXP_NOHIDE, active, ep); - else if (!strcmp(opt, "crossmnt")) - setflags(NFSEXP_CROSSMOUNT, active, ep); - else if (!strcmp(opt, "nocrossmnt")) - clearflags(NFSEXP_CROSSMOUNT, active, ep); - else if (!strcmp(opt, "wdelay")) - setflags(NFSEXP_GATHERED_WRITES, active, ep); - else if (!strcmp(opt, "no_wdelay")) - clearflags(NFSEXP_GATHERED_WRITES, active, ep); - else if (strcmp(opt, "root_squash") == 0) - setflags(NFSEXP_ROOTSQUASH, active, ep); - else if (!strcmp(opt, "no_root_squash")) - clearflags(NFSEXP_ROOTSQUASH, active, ep); - else if (strcmp(opt, "all_squash") == 0) - setflags(NFSEXP_ALLSQUASH, active, ep); - else if (strcmp(opt, "no_all_squash") == 0) - clearflags(NFSEXP_ALLSQUASH, active, ep); - else if (strcmp(opt, "subtree_check") == 0) { - had_subtree_opt = 1; - clearflags(NFSEXP_NOSUBTREECHECK, active, ep); - } else if (strcmp(opt, "no_subtree_check") == 0) { - had_subtree_opt = 1; - setflags(NFSEXP_NOSUBTREECHECK, active, ep); - } else if (strcmp(opt, "auth_nlm") == 0) - clearflags(NFSEXP_NOAUTHNLM, active, ep); - else if (strcmp(opt, "no_auth_nlm") == 0) - setflags(NFSEXP_NOAUTHNLM, active, ep); - else if (strcmp(opt, "secure_locks") == 0) - clearflags(NFSEXP_NOAUTHNLM, active, ep); - else if (strcmp(opt, "insecure_locks") == 0) - setflags(NFSEXP_NOAUTHNLM, active, ep); - else if (strcmp(opt, "acl") == 0) - clearflags(NFSEXP_NOACL, active, ep); - else if (strcmp(opt, "no_acl") == 0) - setflags(NFSEXP_NOACL, active, ep); - else if (!strcmp(opt, "pnfs")) - setflags(NFSEXP_PNFS, active, ep); - else if (!strcmp(opt, "no_pnfs")) - clearflags(NFSEXP_PNFS, active, ep); - else if (strncmp(opt, "anonuid=", 8) == 0) { - char *oe; - ep->e_anonuid = strtol(opt+8, &oe, 10); - if (opt[8]=='\0' || *oe != '\0') { - xlog(L_ERROR, "%s: %d: bad anonuid \"%s\"\n", - flname, flline, opt); -bad_option: - free(opt); - return -1; - } - } else if (strncmp(opt, "anongid=", 8) == 0) { - char *oe; - ep->e_anongid = strtol(opt+8, &oe, 10); - if (opt[8]=='\0' || *oe != '\0') { - xlog(L_ERROR, "%s: %d: bad anongid \"%s\"\n", - flname, flline, opt); - goto bad_option; - } - } else if (strncmp(opt, "squash_uids=", 12) == 0) { - if (parsesquash(opt+12, &squids, &nsquids, &cp) < 0) { - goto bad_option; - } - } else if (strncmp(opt, "squash_gids=", 12) == 0) { - if (parsesquash(opt+12, &sqgids, &nsqgids, &cp) < 0) { - goto bad_option; - } - } else if (strncmp(opt, "fsid=", 5) == 0) { - char *oe; - if (strcmp(opt+5, "root") == 0) { - ep->e_fsid = 0; - setflags(NFSEXP_FSID, active, ep); - } else { - ep->e_fsid = strtoul(opt+5, &oe, 0); - if (opt[5]!='\0' && *oe == '\0') - setflags(NFSEXP_FSID, active, ep); - else if (valid_uuid(opt+5)) - ep->e_uuid = strdup(opt+5); - else { - xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n", - flname, flline, opt); - goto bad_option; - } - } - } else if (strcmp(opt, "mountpoint")==0 || - strcmp(opt, "mp") == 0 || - strncmp(opt, "mountpoint=", 11)==0 || - strncmp(opt, "mp=", 3) == 0) { - char * mp = strchr(opt, '='); - if (mp) - ep->e_mountpoint = strdup(mp+1); - else - ep->e_mountpoint = strdup(""); -#ifdef DEBUG - } else if (strncmp(opt, "fsloc=", 6) == 0) { - if (strcmp(opt+6, "stub") == 0) - ep->e_fslocmethod = FSLOC_STUB; - else { - xlog(L_ERROR, "%s:%d: bad option %s\n", - flname, flline, opt); - goto bad_option; - } -#endif - } else if (strncmp(opt, "refer=", 6) == 0) { - ep->e_fslocmethod = FSLOC_REFER; - ep->e_fslocdata = strdup(opt+6); - } else if (strncmp(opt, "replicas=", 9) == 0) { - ep->e_fslocmethod = FSLOC_REPLICA; - ep->e_fslocdata = strdup(opt+9); - } else if (strncmp(opt, "sec=", 4) == 0) { - active = parse_flavors(opt+4, ep); - if (!active) - goto bad_option; - } else { - xlog(L_ERROR, "%s:%d: unknown keyword \"%s\"\n", - flname, flline, opt); - setflags(NFSEXP_ALLSQUASH | NFSEXP_READONLY, active, ep); - goto bad_option; - } - free(opt); - while (isblank(*cp)) - cp++; - } - - fix_pseudoflavor_flags(ep); - ep->e_squids = squids; - ep->e_sqgids = sqgids; - ep->e_nsquids = nsquids; - ep->e_nsqgids = nsqgids; - -out: - if (warn && !had_subtree_opt) - xlog(L_WARNING, "%s [%d]: Neither 'subtree_check' or 'no_subtree_check' specified for export \"%s:%s\".\n" - " Assuming default behaviour ('no_subtree_check').\n" - " NOTE: this default has changed since nfs-utils version 1.0.x\n", - - flname, flline, - ep->e_hostname, ep->e_path); - if (had_subtree_opt_ptr) - *had_subtree_opt_ptr = had_subtree_opt; - - return 1; -} - -static int -parsesquash(char *list, int **idp, int *lenp, char **ep) -{ - char *cp = list; - int id0, id1; - int len = *lenp; - int *id = *idp; - - if (**ep) - *--(*ep) = ','; - - do { - id0 = parsenum(&cp); - if (*cp == '-') { - cp++; - id1 = parsenum(&cp); - } else { - id1 = id0; - } - if (id0 == -1 || id1 == -1) { - syntaxerr("uid/gid -1 not permitted"); - xfree(id); - return -1; - } - if ((len % 8) == 0) - id = (int *) xrealloc(id, (len + 8) * sizeof(*id)); - id[len++] = id0; - id[len++] = id1; - if (!*cp || *cp == ')' || (*cp == ',' && !isdigit(cp[1]))) - break; - if (*cp != ',') { - syntaxerr("bad uid/gid list"); - xfree(id); - return -1; - } - cp++; - } while(1); - - if (**ep == ',') (*ep)++; - - *lenp = len; - *idp = id; - return 1; -} - -static void -freesquash(void) -{ - if (squids) { - xfree (squids); - squids = NULL; - nsquids = 0; - } - if (sqgids) { - xfree (sqgids); - sqgids = NULL; - nsqgids = 0; - } -} - -static int -parsenum(char **cpp) -{ - char *cp = *cpp, c; - int num = 0; - - if (**cpp == '-') - (*cpp)++; - while (isdigit(**cpp)) - (*cpp)++; - c = **cpp; **cpp = '\0'; num = atoi(cp); **cpp = c; - return num; -} - -static int -getpath(char *path, int len) -{ - xskip(efp, " \t\n"); - return xgettok(efp, 0, path, len); -} - -static int -getexport(char *exp, int len) -{ - int ok; - - xskip(efp, " \t"); - if ((ok = xgettok(efp, 0, exp, len)) < 0) - xlog(L_ERROR, "%s:%d: syntax error", - efname?"command line":efname, efp->x_line); - return ok; -} - -static void -syntaxerr(char *msg) -{ - xlog(L_ERROR, "%s:%d: syntax error: %s", - efname, efp?efp->x_line:0, msg); -} -struct export_features *get_export_features(void) -{ - static char *path = "/proc/fs/nfsd/export_features"; - static struct export_features ef; - static int cached = 0; - char buf[50]; - int c; - int fd; - - if (cached) - return &ef; - - ef.flags = NFSEXP_OLDFLAGS; - ef.secinfo_flags = NFSEXP_OLD_SECINFO_FLAGS; - - fd = open(path, O_RDONLY); - if (fd == -1) - goto good; - c = read(fd, buf, 50); - close(fd); - if (c == -1) - goto err; - buf[c] = 0; - c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags); - if (c != 2) - goto err; -good: - cached = 1; - return &ef; -err: - xlog(L_WARNING, "unexpected error reading %s", path); - return &ef; -} diff --git a/nfs-utils-2.5.2/support/nfs/getport.c b/nfs-utils-2.5.2/support/nfs/getport.c deleted file mode 100644 index e458d8f..0000000 --- a/nfs-utils-2.5.2/support/nfs/getport.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* - * Provide a variety of APIs that query an rpcbind daemon to - * discover RPC service ports and allowed protocol version - * numbers. - * - * Copyright (C) 2008 Oracle Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#ifdef HAVE_LIBTIRPC -#include -#include -#endif - -#include "sockaddr.h" -#include "nfsrpc.h" -#include "nfslib.h" - -/* - * Try a local socket first to access the local rpcbind daemon - * - * Rpcbind's local socket service does not seem to be working. - * Disable this logic for now. - */ -#ifdef HAVE_LIBTIRPC -#undef NFS_GP_LOCAL -#else /* !HAVE_LIBTIRPC */ -#undef NFS_GP_LOCAL -#endif /* !HAVE_LIBTIRPC */ - -#ifdef HAVE_LIBTIRPC -static const rpcvers_t default_rpcb_version = RPCBVERS_4; -#else /* !HAVE_LIBTIRPC */ -static const rpcvers_t default_rpcb_version = PMAPVERS; -#endif /* !HAVE_LIBTIRPC */ - -/* - * Historical: Map TCP connect timeouts to timeout - * error code used by UDP. - */ -static void -nfs_gp_map_tcp_errorcodes(const unsigned short protocol) -{ - if (protocol != IPPROTO_TCP) - return; - - switch (rpc_createerr.cf_error.re_errno) { - case ETIMEDOUT: - rpc_createerr.cf_stat = RPC_TIMEDOUT; - break; - case ECONNREFUSED: - rpc_createerr.cf_stat = RPC_CANTRECV; - break; - } -} - -/* - * There's no easy way to tell how the local system's networking - * and rpcbind is configured (ie. whether we want to use IPv6 or - * IPv4 loopback to contact RPC services on the local host). We - * punt and simply try to look up "localhost". - * - * Returns TRUE on success. - */ -static int nfs_gp_loopback_address(struct sockaddr *sap, socklen_t *salen) -{ - struct addrinfo *gai_results; - int ret = 0; - - if (getaddrinfo("localhost", NULL, NULL, &gai_results)) - return 0; - - if (*salen >= gai_results->ai_addrlen) { - memcpy(sap, gai_results->ai_addr, - gai_results->ai_addrlen); - *salen = gai_results->ai_addrlen; - ret = 1; - } - - nfs_freeaddrinfo(gai_results); - return ret; -} - -/* - * Look up a network service in /etc/services and return the - * network-order port number of that service. - */ -static in_port_t nfs_gp_getservbyname(const char *service, - const unsigned short protocol) -{ - const struct addrinfo gai_hint = { - .ai_family = AF_INET, - .ai_protocol = protocol, - .ai_flags = AI_PASSIVE, - }; - struct addrinfo *gai_results; - const struct sockaddr_in *sin; - in_port_t port; - - if (getaddrinfo(NULL, service, &gai_hint, &gai_results) != 0) - return 0; - - sin = (const struct sockaddr_in *)gai_results->ai_addr; - port = sin->sin_port; - - nfs_freeaddrinfo(gai_results); - return port; -} - -/* - * Discover the port number that should be used to contact an - * rpcbind service. This will detect if the port has a local - * value that may have been set in /etc/services. - * - * Returns network byte-order port number of rpcbind service - * on this system. - */ -static in_port_t nfs_gp_get_rpcb_port(const unsigned short protocol) -{ - static const char *rpcb_netnametbl[] = { - "rpcbind", - "portmapper", - "sunrpc", - NULL, - }; - unsigned int i; - - for (i = 0; rpcb_netnametbl[i] != NULL; i++) { - in_port_t port; - - port = nfs_gp_getservbyname(rpcb_netnametbl[i], protocol); - if (port != 0) - return port; - } - - return (in_port_t)htons((uint16_t)PMAPPORT); -} - -/* - * Set up an RPC client for communicating with an rpcbind daemon at - * @sap over @transport with protocol version @version. - * - * Returns a pointer to a prepared RPC client if successful, and - * @timeout is initialized; caller must destroy a non-NULL returned RPC - * client. Otherwise returns NULL, and rpc_createerr.cf_stat is set to - * reflect the error. - */ -static CLIENT *nfs_gp_get_rpcbclient(struct sockaddr *sap, - const socklen_t salen, - const unsigned short transport, - const rpcvers_t version, - struct timeval *timeout) -{ - static const char *rpcb_pgmtbl[] = { - "rpcbind", - "portmap", - "portmapper", - "sunrpc", - NULL, - }; - rpcprog_t rpcb_prog = nfs_getrpcbyname(RPCBPROG, rpcb_pgmtbl); - CLIENT *clnt; - - nfs_set_port(sap, ntohs(nfs_gp_get_rpcb_port(transport))); - clnt = nfs_get_rpcclient(sap, salen, transport, rpcb_prog, - version, timeout); - nfs_gp_map_tcp_errorcodes(transport); - return clnt; -} - -/** - * nfs_get_proto - Convert a netid to an address family and protocol number - * @netid: C string containing a netid - * @family: OUT: address family - * @protocol: OUT: protocol number - * - * Returns 1 and fills in @protocol if the netid was recognized; - * otherwise zero is returned. - */ -#ifdef HAVE_LIBTIRPC -int -nfs_get_proto(const char *netid, sa_family_t *family, unsigned long *protocol) -{ - struct netconfig *nconf; - struct protoent *proto; - - /* - * IANA does not define a protocol number for rdma netids, - * since "rdma" is not an IP protocol. - */ - if (strcmp(netid, "rdma") == 0) { - *family = AF_INET; - *protocol = NFSPROTO_RDMA; - return 1; - } - if (strcmp(netid, "rdma6") == 0) { - *family = AF_INET6; - *protocol = NFSPROTO_RDMA; - return 1; - } - - nconf = getnetconfigent(netid); - if (nconf == NULL) - return 0; - - proto = getprotobyname(nconf->nc_proto); - if (proto == NULL) { - freenetconfigent(nconf); - return 0; - } - - *family = AF_UNSPEC; - if (strcmp(nconf->nc_protofmly, NC_INET) == 0) - *family = AF_INET; - if (strcmp(nconf->nc_protofmly, NC_INET6) == 0) - *family = AF_INET6; - freenetconfigent(nconf); - - *protocol = (unsigned long)proto->p_proto; - return 1; -} -#else /* !HAVE_LIBTIRPC */ -int -nfs_get_proto(const char *netid, sa_family_t *family, unsigned long *protocol) -{ - struct protoent *proto; - - /* - * IANA does not define a protocol number for rdma netids, - * since "rdma" is not an IP protocol. - */ - if (strcmp(netid, "rdma") == 0) { - *family = AF_INET; - *protocol = NFSPROTO_RDMA; - return 1; - } - - proto = getprotobyname(netid); - if (proto == NULL) - return 0; - - *family = AF_INET; - *protocol = (unsigned long)proto->p_proto; - return 1; -} -#endif /* !HAVE_LIBTIRPC */ - -/** - * nfs_get_netid - Convert a protocol family and protocol name to a netid - * @family: protocol family - * @protocol: protocol number - * - * One of the arguments passed when querying remote rpcbind services - * via rpcbind v3 or v4 is a netid string. This replaces the pm_prot - * field used in legacy PMAP_GETPORT calls. - * - * RFC 1833 says netids are not standard but rather defined on the local - * host. There are, however, standard definitions for nc_protofmly and - * nc_proto that can be used to derive a netid string on the local host, - * based on the contents of /etc/netconfig. - * - * Walk through the local netconfig database and grab the netid of the - * first entry that matches @family and @protocol and whose netid string - * fits in the provided buffer. - * - * Returns a '\0'-terminated string if successful. Caller must - * free the returned string. Otherwise NULL is returned, and - * rpc_createerr.cf_stat is set to reflect the error. - */ -#ifdef HAVE_LIBTIRPC -char *nfs_get_netid(const sa_family_t family, const unsigned long protocol) -{ - char *nc_protofmly, *nc_proto, *nc_netid; - struct netconfig *nconf; - struct protoent *proto; - void *handle; - - switch (family) { - case AF_LOCAL: - case AF_INET: - nc_protofmly = NC_INET; - break; - case AF_INET6: - nc_protofmly = NC_INET6; - break; - default: - goto out; - } - - proto = getprotobynumber(protocol); - if (proto == NULL) - goto out; - nc_proto = proto->p_name; - - handle = setnetconfig(); - while ((nconf = getnetconfig(handle)) != NULL) { - - if (nconf->nc_protofmly != NULL && - strcmp(nconf->nc_protofmly, nc_protofmly) != 0) - continue; - if (nconf->nc_proto != NULL && - strcmp(nconf->nc_proto, nc_proto) != 0) - continue; - - nc_netid = strdup(nconf->nc_netid); - endnetconfig(handle); - - if (nc_netid == NULL) - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - return nc_netid; - } - endnetconfig(handle); - -out: - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; -} -#else /* !HAVE_LIBTIRPC */ -char *nfs_get_netid(const sa_family_t family, const unsigned long protocol) -{ - struct protoent *proto; - char *netid; - - if (family != AF_INET) - goto out; - proto = getprotobynumber((int)protocol); - if (proto == NULL) - goto out; - - netid = strdup(proto->p_name); - if (netid == NULL) - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - return netid; - -out: - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; -} -#endif /* !HAVE_LIBTIRPC */ - -/* - * Extract a port number from a universal address, and terminate the - * string in @addrstr just after the address part. - * - * Returns -1 if unsuccesful; otherwise a decoded port number (possibly 0) - * is returned. - */ -static int nfs_gp_universal_porthelper(char *addrstr) -{ - char *p, *endptr; - unsigned long portlo, porthi; - int port = -1; - - p = strrchr(addrstr, '.'); - if (p == NULL) - goto out; - portlo = strtoul(p + 1, &endptr, 10); - if (*endptr != '\0' || portlo > 255) - goto out; - *p = '\0'; - - p = strrchr(addrstr, '.'); - if (p == NULL) - goto out; - porthi = strtoul(p + 1, &endptr, 10); - if (*endptr != '\0' || porthi > 255) - goto out; - *p = '\0'; - port = (porthi << 8) | portlo; - -out: - return port; -} - -/** - * nfs_universal2port - extract port number from a "universal address" - * @uaddr: '\0'-terminated C string containing a universal address - * - * Universal addresses (defined in RFC 1833) are used when calling an - * rpcbind daemon via protocol versions 3 or 4.. - * - * Returns -1 if unsuccesful; otherwise a decoded port number (possibly 0) - * is returned. - */ -int nfs_universal2port(const char *uaddr) -{ - char *addrstr; - int port = -1; - - addrstr = strdup(uaddr); - if (addrstr != NULL) { - port = nfs_gp_universal_porthelper(addrstr); - free(addrstr); - } - return port; -} - -/** - * nfs_sockaddr2universal - convert a sockaddr to a "universal address" - * @sap: pointer to a socket address - * - * Universal addresses (defined in RFC 1833) are used when calling an - * rpcbind daemon via protocol versions 3 or 4.. - * - * Returns a '\0'-terminated string if successful; caller must free - * the returned string. Otherwise NULL is returned and - * rpc_createerr.cf_stat is set to reflect the error. - * - * inet_ntop(3) is used here, since getnameinfo(3) is not available - * in some earlier glibc releases, and we don't require support for - * scope IDs for universal addresses. - */ -char *nfs_sockaddr2universal(const struct sockaddr *sap) -{ - const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; - const struct sockaddr_un *sun = (const struct sockaddr_un *)sap; - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - char buf[INET6_ADDRSTRLEN + 8 /* for port information */]; - uint16_t port; - size_t count; - char *result; - int len; - - switch (sap->sa_family) { - case AF_LOCAL: - return strndup(sun->sun_path, sizeof(sun->sun_path)); - case AF_INET: - if (inet_ntop(AF_INET, (const void *)&sin->sin_addr.s_addr, - buf, (socklen_t)sizeof(buf)) == NULL) - goto out_err; - port = ntohs(sin->sin_port); - break; - case AF_INET6: - if (inet_ntop(AF_INET6, (const void *)&sin6->sin6_addr, - buf, (socklen_t)sizeof(buf)) == NULL) - goto out_err; - port = ntohs(sin6->sin6_port); - break; - default: - goto out_err; - } - - count = sizeof(buf) - strlen(buf); - len = snprintf(buf + strlen(buf), count, ".%u.%u", - (unsigned)(port >> 8), (unsigned)(port & 0xff)); - /* before glibc 2.0.6, snprintf(3) could return -1 */ - if (len < 0 || (size_t)len > count) - goto out_err; - - result = strdup(buf); - if (result != NULL) - return result; - -out_err: - rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; - return NULL; -} - -/* - * Send a NULL request to the indicated RPC service. - * - * Returns 1 if the service responded; otherwise 0; - */ -static int nfs_gp_ping(CLIENT *client, struct timeval timeout) -{ - enum clnt_stat status; - - status = CLNT_CALL(client, NULLPROC, - (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_void, NULL, - timeout); - - if (status != RPC_SUCCESS) { - rpc_createerr.cf_stat = status; - CLNT_GETERR(client, &rpc_createerr.cf_error); - } - return (int)(status == RPC_SUCCESS); -} - -#ifdef HAVE_LIBTIRPC - -/* - * Initialize the rpcb argument for a GETADDR request. - * - * Returns 1 if successful, and caller must free strings pointed - * to by r_netid and r_addr; otherwise 0. - */ -static int nfs_gp_init_rpcb_parms(const struct sockaddr *sap, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - struct rpcb *parms) -{ - char *netid, *addr; - - netid = nfs_get_netid(sap->sa_family, protocol); - if (netid == NULL) - return 0; - - addr = nfs_sockaddr2universal(sap); - if (addr == NULL) { - free(netid); - return 0; - } - - memset(parms, 0, sizeof(*parms)); - parms->r_prog = program; - parms->r_vers = version; - parms->r_netid = netid; - parms->r_addr = addr; - parms->r_owner = ""; - - return 1; -} - -static void nfs_gp_free_rpcb_parms(struct rpcb *parms) -{ - free(parms->r_netid); - free(parms->r_addr); -} - -/* - * Try rpcbind GETADDR via version 4. If that fails, try same - * request via version 3. - * - * Returns non-zero port number on success; otherwise returns - * zero. rpccreateerr is set to reflect the nature of the error. - */ -static unsigned short nfs_gp_rpcb_getaddr(CLIENT *client, - struct rpcb *parms, - struct timeval timeout) -{ - rpcvers_t rpcb_version; - struct rpc_err rpcerr; - int port = 0; - - for (rpcb_version = RPCBVERS_4; - rpcb_version >= RPCBVERS_3; - rpcb_version--) { - enum clnt_stat status; - char *uaddr = NULL; - - CLNT_CONTROL(client, CLSET_VERS, (void *)&rpcb_version); - status = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR, - (xdrproc_t)xdr_rpcb, (void *)parms, - (xdrproc_t)xdr_wrapstring, (void *)&uaddr, - timeout); - - switch (status) { - case RPC_SUCCESS: - if ((uaddr == NULL) || (uaddr[0] == '\0')) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - return 0; - } - - port = nfs_universal2port(uaddr); - xdr_free((xdrproc_t)xdr_wrapstring, (char *)&uaddr); - if (port == -1) { - rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; - return 0; - } - return (unsigned short)port; - case RPC_PROGVERSMISMATCH: - clnt_geterr(client, &rpcerr); - if (rpcerr.re_vers.low > RPCBVERS4) - return 0; - continue; - case RPC_PROCUNAVAIL: - case RPC_PROGUNAVAIL: - continue; - default: - /* Most likely RPC_TIMEDOUT or RPC_CANTRECV */ - rpc_createerr.cf_stat = status; - clnt_geterr(client, &rpc_createerr.cf_error); - return 0; - } - - } - - if (port == 0) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - clnt_geterr(client, &rpc_createerr.cf_error); - } - return port; -} - -#endif /* HAVE_LIBTIRPC */ - -/* - * Try GETPORT request via rpcbind version 2. - * - * Returns non-zero port number on success; otherwise returns - * zero. rpccreateerr is set to reflect the nature of the error. - */ -static unsigned long nfs_gp_pmap_getport(CLIENT *client, - struct pmap *parms, - struct timeval timeout) -{ - enum clnt_stat status; - unsigned long port; - - status = CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT, - (xdrproc_t)xdr_pmap, (void *)parms, - (xdrproc_t)xdr_u_long, (void *)&port, - timeout); - - if (status != RPC_SUCCESS) { - rpc_createerr.cf_stat = status; - CLNT_GETERR(client, &rpc_createerr.cf_error); - port = 0; - } else if (port == 0) - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - - return port; -} - -#ifdef HAVE_LIBTIRPC - -static unsigned short nfs_gp_getport_rpcb(CLIENT *client, - const struct sockaddr *sap, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - struct timeval timeout) -{ - unsigned short port = 0; - struct rpcb parms; - - if (nfs_gp_init_rpcb_parms(sap, program, version, - protocol, &parms) != 0) { - port = nfs_gp_rpcb_getaddr(client, &parms, timeout); - nfs_gp_free_rpcb_parms(&parms); - } - - return port; -} - -#endif /* HAVE_LIBTIRPC */ - -static unsigned long nfs_gp_getport_pmap(CLIENT *client, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - struct timeval timeout) -{ - struct pmap parms = { - .pm_prog = program, - .pm_vers = version, - .pm_prot = protocol, - }; - rpcvers_t pmap_version = PMAPVERS; - - CLNT_CONTROL(client, CLSET_VERS, (void *)&pmap_version); - return nfs_gp_pmap_getport(client, &parms, timeout); -} - -/* - * Try an AF_INET6 request via rpcbind v4/v3; try an AF_INET - * request via rpcbind v2. - * - * Returns non-zero port number on success; otherwise returns - * zero. rpccreateerr is set to reflect the nature of the error. - */ -static unsigned short nfs_gp_getport(CLIENT *client, - const struct sockaddr *sap, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - struct timeval timeout) -{ - switch (sap->sa_family) { -#ifdef HAVE_LIBTIRPC - case AF_INET6: - return nfs_gp_getport_rpcb(client, sap, program, - version, protocol, timeout); -#endif /* HAVE_LIBTIRPC */ - case AF_INET: - return nfs_gp_getport_pmap(client, program, version, - protocol, timeout); - } - - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return 0; -} - -/** - * nfs_rpc_ping - Determine if RPC service is responding to requests - * @sap: pointer to address of server to query (port is already filled in) - * @salen: length of server address - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: requested IPPROTO_ value of transport protocol - * @timeout: pointer to request timeout (NULL means use default timeout) - * - * Returns 1 if the remote service responded without an error; otherwise - * zero. - */ -int nfs_rpc_ping(const struct sockaddr *sap, const socklen_t salen, - const rpcprog_t program, const rpcvers_t version, - const unsigned short protocol, const struct timeval *timeout) -{ - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - CLIENT *client; - struct timeval tout = { -1, 0 }; - int result = 0; - - if (timeout != NULL) - tout = *timeout; - - nfs_clear_rpc_createerr(); - - memcpy(saddr, sap, (size_t)salen); - client = nfs_get_rpcclient(saddr, salen, protocol, - program, version, &tout); - if (client != NULL) { - result = nfs_gp_ping(client, tout); - nfs_gp_map_tcp_errorcodes(protocol); - CLNT_DESTROY(client); - } - - return result; -} - -/** - * nfs_getport - query server's rpcbind to get port number for an RPC service - * @sap: pointer to address of server to query - * @salen: length of server's address - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: IPPROTO_ value of requested transport protocol - * - * Uses any acceptable rpcbind version to discover the port number for the - * RPC service described by the given [program, version, transport] tuple. - * Uses a quick timeout and an ephemeral source port. Supports AF_INET and - * AF_INET6 server addresses. - * - * Returns a positive integer representing the port number of the RPC - * service advertised by the server (in host byte order), or zero if the - * service is not advertised or there was some problem querying the server's - * rpcbind daemon. rpccreateerr is set to reflect the underlying cause of - * the error. - * - * There are a variety of ways to choose which transport and rpcbind versions - * to use. We chose to conserve local resources and try to avoid incurring - * timeouts. - * - * Transport - * To provide rudimentary support for traversing firewalls, query the remote - * using the same transport as the requested service. This provides some - * guarantee that the requested transport is available between this client - * and the server, and if the caller specifically requests TCP, for example, - * this may be becuase a firewall is in place that blocks UDP traffic. We - * could try both, but that could involve a lengthy timeout in several cases, - * and would often consume an extra ephemeral port. - * - * Rpcbind version - * To avoid using up too many ephemeral ports, AF_INET queries use tried-and- - * true rpcbindv2, and don't try the newer versions; and AF_INET6 queries use - * rpcbindv4, then rpcbindv3 on the same socket. The newer rpcbind protocol - * versions can adequately detect if a remote RPC service does not support - * AF_INET6 at all. The rpcbind socket is re-used in an attempt to keep the - * overall number of consumed ephemeral ports low. - */ -unsigned short nfs_getport(const struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol) -{ - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - struct timeval timeout = { -1, 0 }; - unsigned short port = 0; - CLIENT *client; - - nfs_clear_rpc_createerr(); - - memcpy(saddr, sap, (size_t)salen); - client = nfs_gp_get_rpcbclient(saddr, salen, protocol, - default_rpcb_version, &timeout); - if (client != NULL) { - port = nfs_gp_getport(client, saddr, program, - version, protocol, timeout); - CLNT_DESTROY(client); - } - - return port; -} - -/** - * nfs_getport_ping - query server's rpcbind and do RPC ping to verify result - * @sap: IN: pointer to address of server to query; - * OUT: pointer to updated address - * @salen: length of server's address - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: IPPROTO_ value of requested transport protocol - * - * Uses any acceptable rpcbind version to discover the port number for the - * RPC service described by the given [program, version, transport] tuple. - * Uses a quick timeout and an ephemeral source port. Supports AF_INET and - * AF_INET6 server addresses. - * - * Returns a 1 and sets the port number in the passed-in server address - * if both the query and the ping were successful; otherwise zero. - * rpccreateerr is set to reflect the underlying cause of the error. - */ -int nfs_getport_ping(struct sockaddr *sap, const socklen_t salen, - const rpcprog_t program, const rpcvers_t version, - const unsigned short protocol) -{ - struct timeval timeout = { -1, 0 }; - unsigned short port = 0; - CLIENT *client; - int result = 0; - - nfs_clear_rpc_createerr(); - - client = nfs_gp_get_rpcbclient(sap, salen, protocol, - default_rpcb_version, &timeout); - if (client != NULL) { - port = nfs_gp_getport(client, sap, program, - version, protocol, timeout); - CLNT_DESTROY(client); - client = NULL; - } - - if (port != 0) { - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - - memcpy(saddr, sap, (size_t)salen); - nfs_set_port(saddr, port); - - nfs_clear_rpc_createerr(); - - client = nfs_get_rpcclient(saddr, salen, protocol, - program, version, &timeout); - if (client != NULL) { - result = nfs_gp_ping(client, timeout); - nfs_gp_map_tcp_errorcodes(protocol); - CLNT_DESTROY(client); - } - } - - if (result) - nfs_set_port(sap, port); - - return result; -} - -/** - * nfs_getlocalport - query local rpcbind to get port number for an RPC service - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: IPPROTO_ value of requested transport protocol - * - * Uses any acceptable rpcbind version to discover the port number for the - * RPC service described by the given [program, version, transport] tuple. - * Uses a quick timeout and an ephemeral source port. Supports AF_INET and - * AF_INET6 local addresses. - * - * Returns a positive integer representing the port number of the RPC - * service advertised by the server (in host byte order), or zero if the - * service is not advertised or there was some problem querying the server's - * rpcbind daemon. rpccreateerr is set to reflect the underlying cause of - * the error. - * - * Try an AF_LOCAL connection first. The rpcbind daemon implementation should - * listen on AF_LOCAL. - * - * If that doesn't work (for example, if portmapper is running, or rpcbind - * isn't listening on /var/run/rpcbind.sock), send a query via UDP to localhost - * (UDP doesn't leave a socket in TIME_WAIT, and the timeout is a relatively - * short 3 seconds). - */ -unsigned short nfs_getlocalport(const rpcprot_t program, - const rpcvers_t version, - const unsigned short protocol) -{ - union nfs_sockaddr address; - struct sockaddr *lb_addr = &address.sa; - socklen_t lb_len = sizeof(*lb_addr); - unsigned short port = 0; - -#ifdef NFS_GP_LOCAL - const struct sockaddr_un sun = { - .sun_family = AF_LOCAL, - .sun_path = _PATH_RPCBINDSOCK, - }; - const struct sockaddr *sap = (struct sockaddr *)&sun; - const socklen_t salen = SUN_LEN(&sun); - CLIENT *client; - struct timeval timeout = { -1, 0 }; - - nfs_clear_rpc_createerr(); - - client = nfs_gp_get_rpcbclient(sap, salen, 0, RPCBVERS_4, &timeout); - if (client != NULL) { - struct rpcb parms; - - if (nfs_gp_init_rpcb_parms(sap, program, version, - protocol, &parms) != 0) { - port = nfs_gp_rpcb_getaddr(client, &parms, timeout); - nfs_gp_free_rpcb_parms(&parms); - } - CLNT_DESTROY(client); - } -#endif /* NFS_GP_LOCAL */ - - if (port == 0) { - nfs_clear_rpc_createerr(); - - if (nfs_gp_loopback_address(lb_addr, &lb_len)) { - port = nfs_getport(lb_addr, lb_len, - program, version, protocol); - } else - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - } - - return port; -} - -/** - * nfs_rpcb_getaddr - query rpcbind via rpcbind versions 4 and 3 - * @sap: pointer to address of server to query - * @salen: length of server address - * @transport: transport protocol to use for the query - * @addr: pointer to r_addr address - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: requested IPPROTO_ value of transport protocol - * @timeout: pointer to request timeout (NULL means use default timeout) - * - * Returns a positive integer representing the port number of the RPC - * service advertised by the server (in host byte order), or zero if the - * service is not advertised or there was some problem querying the - * server's rpcbind daemon. rpccreateerr is set to reflect the - * underlying cause of the error. - * - * This function provides similar functionality to nfs_pmap_getport(), - * but performs the rpcbind lookup via rpcbind version 4. If the server - * doesn't support rpcbind version 4, it will retry with version 3. - * The GETADDR procedure is exactly the same in these two versions of - * the rpcbind protocol, so the socket, RPC client, and arguments are - * re-used when retrying, saving ephemeral port space. - * - * These RPC procedures take a universal address as an argument, so the - * query will fail if the remote rpcbind daemon doesn't find an entry - * with a matching address. A matching address includes an ANYADDR - * address of the same address family. In this way an RPC server can - * advertise via rpcbind that it does not support AF_INET6. - */ -#ifdef HAVE_LIBTIRPC - -unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap, - const socklen_t salen, - const unsigned short transport, - const struct sockaddr *addr, - const rpcprog_t program, - const rpcvers_t version, - const unsigned short protocol, - const struct timeval *timeout) -{ - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - CLIENT *client; - struct rpcb parms; - struct timeval tout = { -1, 0 }; - unsigned short port = 0; - - if (timeout != NULL) - tout = *timeout; - - nfs_clear_rpc_createerr(); - - memcpy(saddr, sap, (size_t)salen); - client = nfs_gp_get_rpcbclient(saddr, salen, transport, - RPCBVERS_4, &tout); - if (client != NULL) { - if (nfs_gp_init_rpcb_parms(addr, program, version, - protocol, &parms) != 0) { - port = nfs_gp_rpcb_getaddr(client, &parms, tout); - nfs_gp_free_rpcb_parms(&parms); - } - CLNT_DESTROY(client); - } - - return port; -} - -#else /* !HAVE_LIBTIRPC */ - -unsigned short nfs_rpcb_getaddr(__attribute__((unused)) const struct sockaddr *sap, - __attribute__((unused)) const socklen_t salen, - __attribute__((unused)) const unsigned short transport, - __attribute__((unused)) const struct sockaddr *addr, - __attribute__((unused)) const rpcprog_t program, - __attribute__((unused)) const rpcvers_t version, - __attribute__((unused)) const unsigned short protocol, - __attribute__((unused)) const struct timeval *timeout) -{ - nfs_clear_rpc_createerr(); - - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return 0; -} - -#endif /* !HAVE_LIBTIRPC */ - -/** - * nfs_pmap_getport - query rpcbind via the portmap protocol (rpcbindv2) - * @sin: pointer to AF_INET address of server to query - * @transport: transport protocol to use for the query - * @program: requested RPC program number - * @version: requested RPC version number - * @protocol: requested IPPROTO_ value of transport protocol - * @timeout: pointer to request timeout (NULL means use default timeout) - * - * Returns a positive integer representing the port number of the RPC service - * advertised by the server (in host byte order), or zero if the service is - * not advertised or there was some problem querying the server's rpcbind - * daemon. rpccreateerr is set to reflect the underlying cause of the error. - * - * nfs_pmap_getport() is very similar to pmap_getport(), except that: - * - * 1. This version always tries to use an ephemeral port, since reserved - * ports are not needed for GETPORT queries. This conserves the very - * limited reserved port space, helping reduce failed socket binds - * during mount storms. - * - * 2. This version times out quickly by default. It time-limits the - * connect process as well as the actual RPC call, and even allows the - * caller to specify the timeout. - * - * 3. This version shares code with the rpcbindv3 and rpcbindv4 query - * functions. It can use a TI-RPC generated CLIENT. - */ -unsigned long nfs_pmap_getport(const struct sockaddr_in *sin, - const unsigned short transport, - const unsigned long program, - const unsigned long version, - const unsigned long protocol, - const struct timeval *timeout) -{ - struct sockaddr_in address; - struct sockaddr *saddr = (struct sockaddr *)&address; - CLIENT *client; - struct pmap parms = { - .pm_prog = program, - .pm_vers = version, - .pm_prot = protocol, - }; - struct timeval tout = { -1, 0 }; - unsigned long port = 0; - - if (timeout != NULL) - tout = *timeout; - - nfs_clear_rpc_createerr(); - - memcpy(saddr, sin, sizeof(address)); - client = nfs_gp_get_rpcbclient(saddr, (socklen_t)sizeof(*sin), - transport, PMAPVERS, &tout); - if (client != NULL) { - port = nfs_gp_pmap_getport(client, &parms, tout); - CLNT_DESTROY(client); - } - - return port; -} - -static const char *nfs_ns_pgmtbl[] = { - "status", - NULL, -}; - -/* - * nfs_probe_statd - use nfs_pmap_getport to see if statd is running locally - * - * Returns non-zero if statd is running locally. - */ -int nfs_probe_statd(void) -{ - struct sockaddr_in addr = { - .sin_family = AF_INET, - .sin_addr.s_addr = htonl(INADDR_LOOPBACK), - }; - rpcprog_t program = nfs_getrpcbyname(NSMPROG, nfs_ns_pgmtbl); - - return nfs_getport_ping((struct sockaddr *)(char *)&addr, sizeof(addr), - program, (rpcvers_t)1, IPPROTO_UDP); -} diff --git a/nfs-utils-2.5.2/support/nfs/mydaemon.c b/nfs-utils-2.5.2/support/nfs/mydaemon.c deleted file mode 100644 index d1cf08d..0000000 --- a/nfs-utils-2.5.2/support/nfs/mydaemon.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - mydaemon.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - Copyright (c) 2002 Andy Adamson . - Copyright (c) 2002 Marius Aamodt Eriksen . - Copyright (c) 2002 J. Bruce Fields . - Copyright (c) 2013 Jeff Layton - - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" - -static int pipefds[2] = { -1, -1}; - -/** - * daemon_init - initial daemon setup - * @fg: whether to run in the foreground - * - * This function is like daemon(), but with our own special sauce to delay - * the exit of the parent until the child is set up properly. A pipe is created - * between parent and child. The parent process will wait to exit until the - * child dies or writes an int on the pipe signaling its status. - */ -void -daemon_init(bool fg) -{ - int pid, status, tempfd; - - if (fg) - return; - - if (pipe(pipefds) < 0) { - xlog_err("mydaemon: pipe() failed: errno %d (%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - pid = fork(); - if (pid < 0) { - xlog_err("mydaemon: fork() failed: errno %d (%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - if (pid > 0) { - /* Parent */ - close(pipefds[1]); - if (read(pipefds[0], &status, sizeof(status)) != sizeof(status)) - exit(EXIT_FAILURE); - exit(status); - } - - /* Child */ - close(pipefds[0]); - setsid (); - - if (chdir ("/")) { - xlog_err("mydaemon: chdir() failed: errno %d (%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - while (pipefds[1] <= 2) { - pipefds[1] = dup(pipefds[1]); - if (pipefds[1] < 0) { - xlog_err("mydaemon: dup() failed: errno %d (%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - } - - tempfd = open("/dev/null", O_RDWR); - if (tempfd < 0) { - xlog_err("mydaemon: can't open /dev/null: errno %d " - "(%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - dup2(tempfd, 0); - dup2(tempfd, 1); - dup2(tempfd, 2); - close(tempfd); - closelog(); - dup2(pipefds[1], 3); - pipefds[1] = 3; - closeall(4); -} - -/** - * daemon_ready - tell interested parties that the daemon is ready - * - * This function tells e.g. the parent process that the daemon is up - * and running. - */ -void -daemon_ready(void) -{ - int status = 0; - - if (pipefds[1] > 0) { - if (write(pipefds[1], &status, sizeof(status)) != sizeof(status)) { - xlog_err("WARN: writing to parent pipe failed: errno " - "%d (%s)\n", errno, strerror(errno)); - } - close(pipefds[1]); - pipefds[1] = -1; - } -} - diff --git a/nfs-utils-2.5.2/support/nfs/nfs_mntent.c b/nfs-utils-2.5.2/support/nfs/nfs_mntent.c deleted file mode 100644 index 25e5944..0000000 --- a/nfs-utils-2.5.2/support/nfs/nfs_mntent.c +++ /dev/null @@ -1,240 +0,0 @@ -/* Private version of the libc *mntent() routines. */ -/* Note slightly different prototypes. */ - -/* 1999-02-22 Arkadiusz Miskiewicz - * - added Native Language Support - * - * 2006-06-08 Amit Gud - * - Moved to nfs-utils/support/nfs from util-linux/mount - */ - -#include -#include /* for strchr */ -#include /* for isdigit */ -#include /* for umask */ -#include /* for ftruncate */ -#include /* for errno */ - -#include "nfs_mntent.h" -#include "nls.h" -#include "xcommon.h" - -/* Unfortunately the classical Unix /etc/mtab and /etc/fstab - do not handle directory names containing spaces. - Here we mangle them, replacing a space by \040. - What do other Unices do? */ - -static unsigned char need_escaping[] = { ' ', '\t', '\n', '\\' }; - -static char * -mangle(const char *arg) { - const unsigned char *s = (const unsigned char *)arg; - char *ss, *sp; - unsigned int n; - - n = strlen(arg); - ss = sp = xmalloc(4*n+1); - while(1) { - for (n = 0; n < sizeof(need_escaping); n++) { - if (*s == need_escaping[n]) { - *sp++ = '\\'; - *sp++ = '0' + ((*s & 0300) >> 6); - *sp++ = '0' + ((*s & 070) >> 3); - *sp++ = '0' + (*s & 07); - goto next; - } - } - *sp++ = *s; - if (*s == 0) - break; - next: - s++; - } - return ss; -} - -static int -is_space_or_tab (char c) { - return (c == ' ' || c == '\t'); -} - -static char * -skip_spaces(char *s) { - while (is_space_or_tab(*s)) - s++; - return s; -} - -static char * -skip_nonspaces(char *s) { - while (*s && !is_space_or_tab(*s)) - s++; - return s; -} - -#define isoctal(a) (((a) & ~7) == '0') - -/* returns malloced pointer - no more strdup required */ -static char * -unmangle(char *s) { - char *ret, *ss, *sp; - - ss = skip_nonspaces(s); - ret = sp = xmalloc(ss-s+1); - while(s != ss) { - if (*s == '\\' && isoctal(s[1]) && isoctal(s[2]) && isoctal(s[3])) { - *sp++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7); - s += 4; - } else - *sp++ = *s++; - } - *sp = 0; - return ret; -} - -/* - * fstat'ing the file and allocating a buffer holding all of it - * may be a bad idea: if the file is /proc/mounts, the stat - * returns 0. - * (On the other hand, mangling and unmangling is meaningless - * for /proc/mounts.) - */ - -mntFILE * -nfs_setmntent (const char *file, char *mode) { - mntFILE *mfp = xmalloc(sizeof(*mfp)); - mode_t old_umask = umask(077); - - mfp->mntent_fp = fopen(file, mode); - umask(old_umask); - mfp->mntent_file = xstrdup(file); - mfp->mntent_errs = (mfp->mntent_fp == NULL); - mfp->mntent_softerrs = 0; - mfp->mntent_lineno = 0; - return mfp; -} - -void -nfs_endmntent (mntFILE *mfp) { - if (mfp) { - if (mfp->mntent_fp) - fclose(mfp->mntent_fp); - if (mfp->mntent_file) - free(mfp->mntent_file); - free(mfp); - } -} - -int -nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { - char *m1, *m2, *m3, *m4; - int res; - off_t length; - - if (fseek (mfp->mntent_fp, 0, SEEK_END)) - return 1; /* failure */ - length = ftell(mfp->mntent_fp); - - m1 = mangle(mnt->mnt_fsname); - m2 = mangle(mnt->mnt_dir); - m3 = mangle(mnt->mnt_type); - m4 = mangle(mnt->mnt_opts); - - res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n", - m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno); - - free(m1); - free(m2); - free(m3); - free(m4); - if (res >= 0) { - res = fflush(mfp->mntent_fp); - if (res < 0) { - nfs_error("Cant't flush out mtab: %s", strerror(errno)); - /* Avoid leaving a corrupt mtab file */ - if (ftruncate(fileno(mfp->mntent_fp), length)) - {/* Ignore this failure; Why confuse things */} - } - } - return (res < 0) ? 1 : 0; -} - -/* Read the next entry from the file fp. Stop reading at an incorrect entry. */ -struct mntent * -nfs_getmntent (mntFILE *mfp) { - static char buf[4096]; - static struct mntent me; - char *s; - - again: - if (mfp->mntent_errs || mfp->mntent_softerrs >= ERR_MAX) - return NULL; - - /* read the next non-blank non-comment line */ - do { - if (fgets (buf, sizeof(buf), mfp->mntent_fp) == NULL) - return NULL; - - mfp->mntent_lineno++; - s = strchr (buf, '\n'); - if (s == NULL) { - /* Missing final newline? Otherwise extremely */ - /* long line - assume file was corrupted */ - if (feof(mfp->mntent_fp)) { - fprintf(stderr, _("[mntent]: warning: no final " - "newline at the end of %s\n"), - mfp->mntent_file); - s = strchr (buf, 0); - } else { - mfp->mntent_errs = 1; - goto err; - } - } - *s = 0; - if (--s >= buf && *s == '\r') - *s = 0; - s = skip_spaces(buf); - } while (*s == '\0' || *s == '#'); - - me.mnt_fsname = unmangle(s); - s = skip_nonspaces(s); - s = skip_spaces(s); - me.mnt_dir = unmangle(s); - s = skip_nonspaces(s); - s = skip_spaces(s); - me.mnt_type = unmangle(s); - s = skip_nonspaces(s); - s = skip_spaces(s); - me.mnt_opts = unmangle(s); - s = skip_nonspaces(s); - s = skip_spaces(s); - - if (isdigit(*s)) { - me.mnt_freq = atoi(s); - while(isdigit(*s)) s++; - } else - me.mnt_freq = 0; - if(*s && !is_space_or_tab(*s)) - goto err; - - s = skip_spaces(s); - if(isdigit(*s)) { - me.mnt_passno = atoi(s); - while(isdigit(*s)) s++; - } else - me.mnt_passno = 0; - if(*s && !is_space_or_tab(*s)) - goto err; - - /* allow more stuff, e.g. comments, on this line */ - - return &me; - - err: - mfp->mntent_softerrs++; - fprintf(stderr, _("[mntent]: line %d in %s is bad%s\n"), - mfp->mntent_lineno, mfp->mntent_file, - (mfp->mntent_errs || mfp->mntent_softerrs >= ERR_MAX) ? - _("; rest of file ignored") : ""); - goto again; -} diff --git a/nfs-utils-2.5.2/support/nfs/rmtab.c b/nfs-utils-2.5.2/support/nfs/rmtab.c deleted file mode 100644 index 9f03167..0000000 --- a/nfs-utils-2.5.2/support/nfs/rmtab.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * support/nfs/rmtab.c - * - * Handling for rmtab. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "nfslib.h" - -/* - * Colons in incoming IPv6 presentation addresses have to - * replaced with another character, since rmtab already - * uses colons to delineate fields. - * - * Use a printable character, but one that would never be - * found in a presentation address or domain name - */ -#define IPV6_COLON ';' - -#define LINELEN (2048) - -static FILE *rmfp = NULL; - -extern struct state_paths rmtab; - -int -setrmtabent(char *type) -{ - if (rmfp) - fclose(rmfp); - rmfp = fsetrmtabent(rmtab.statefn, type); - return (rmfp != NULL); -} - -FILE * -fsetrmtabent(char *fname, char *type) -{ - int readonly = !strcmp(type, "r"); - FILE *fp; - - if (!fname) - return NULL; - if ((fp = fopen(fname, type)) == NULL) { - xlog(L_ERROR, "can't open %s for %sing", fname, - readonly ? "read" : "writ"); - return NULL; - } - return fp; -} - -struct rmtabent * -getrmtabent(int log, long *pos) -{ - return fgetrmtabent(rmfp, log, pos); -} - -struct rmtabent * -fgetrmtabent(FILE *fp, int log, long *pos) -{ - static struct rmtabent re; - char *count, *host, *path, *c; - static char buf[LINELEN]; - - errno = 0; - if (!fp) - return NULL; - do { - if (pos) - *pos = ftell (fp); - if (fgets(buf, sizeof(buf)-1, fp) == NULL) - return NULL; - host = buf; - if ((path = strchr(host, '\n')) != NULL) - *path = '\0'; - if (!(path = strchr(host, ':'))) { - if (log) - xlog(L_ERROR, "malformed entry in rmtab file"); - errno = EINVAL; - return NULL; - } - *path++ = '\0'; - count = strchr(path, ':'); - if (count) { - *count++ = '\0'; - re.r_count = strtol (count, NULL, 0); - } - else - re.r_count = 1; - } while (0); - - strncpy(re.r_client, host, sizeof (re.r_client) - 1); - re.r_client[sizeof (re.r_client) - 1] = '\0'; - for (c = re.r_client; *c != '\0'; c++) - if (*c == IPV6_COLON) - *c = ':'; - - strncpy(re.r_path, path, sizeof (re.r_path) - 1); - re.r_path[sizeof (re.r_path) - 1] = '\0'; - - return &re; -} - -void -putrmtabent(struct rmtabent *rep, long *pos) -{ - fputrmtabent(rmfp, rep, pos); -} - -void -fputrmtabent(FILE *fp, struct rmtabent *rep, long *pos) -{ - static char buf[LINELEN]; - char *c; - - if (!fp || (pos && fseek (fp, *pos, SEEK_SET) != 0)) - return; - - /* - * To avoid confusing the token parser in fgetrmtabent(), - * convert colons in incoming IPv6 presentation addresses - * to semicolons. - */ - if (strlen(rep->r_client) > sizeof(buf)) { - xlog(L_ERROR, "client name too large"); - return; - } - strncpy(buf, rep->r_client, sizeof(buf)); - for (c = buf; *c != '\0'; c++) - if (*c == ':') - *c = IPV6_COLON; - - (void)fprintf(fp, "%s:%s:0x%.8x\n", buf, rep->r_path, rep->r_count); -} - -void -endrmtabent(void) -{ - fendrmtabent(rmfp); - rmfp = NULL; -} - -void -fendrmtabent(FILE *fp) -{ - if (fp) - fclose(fp); -} - -void -rewindrmtabent(void) -{ - if (rmfp) - rewind(rmfp); -} - -void -frewindrmtabent(FILE *fp) -{ - if (fp) - rewind (fp); -} diff --git a/nfs-utils-2.5.2/support/nfs/rpc_socket.c b/nfs-utils-2.5.2/support/nfs/rpc_socket.c deleted file mode 100644 index 5fabf5a..0000000 --- a/nfs-utils-2.5.2/support/nfs/rpc_socket.c +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Generic RPC client socket-level APIs for nfs-utils - * - * Copyright (C) 2008 Oracle Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include "sockaddr.h" -#include "nfsrpc.h" - -#ifdef HAVE_LIBTIRPC -#include -#include -#endif /* HAVE_LIBTIRPC */ - -/* - * If "-1" is specified in the tv_sec field, use these defaults instead. - */ -#define NFSRPC_TIMEOUT_UDP (3) -#define NFSRPC_TIMEOUT_TCP (10) - - -/* - * Set up an RPC client for communicating via a AF_LOCAL socket. - * - * @timeout is initialized upon return - * - * Returns a pointer to a prepared RPC client if successful; caller - * must destroy a non-NULL returned RPC client. Otherwise NULL, and - * rpc_createerr.cf_stat is set to reflect the error. - */ -static CLIENT *nfs_get_localclient(const struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - struct timeval *timeout) -{ -#ifdef HAVE_LIBTIRPC - struct sockaddr_storage address; - const struct netbuf nbuf = { - .maxlen = sizeof(struct sockaddr_un), - .len = (size_t)salen, - .buf = &address, - }; -#else - (void) salen; -#endif /* HAVE_LIBTIRPC */ - CLIENT *client; - int sock; - - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sock == -1) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - return NULL; - } - - if (timeout->tv_sec == -1) - timeout->tv_sec = NFSRPC_TIMEOUT_TCP; - -#ifdef HAVE_LIBTIRPC - memcpy(nbuf.buf, sap, (size_t)salen); - client = clnt_vc_create(sock, &nbuf, program, version, 0, 0); -#else /* !HAVE_LIBTIRPC */ - client = clntunix_create((struct sockaddr_un *)sap, - program, version, &sock, 0, 0); -#endif /* !HAVE_LIBTIRPC */ - if (client != NULL) - CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL); - else - (void)close(sock); - - return client; -} - -#ifdef HAVE_LIBTIRPC - -/* - * Bind a socket using an unused privileged source port. - * - * Returns zero on success, or returns -1 on error. errno is - * set to reflect the nature of the error. - */ -static int nfs_bindresvport(const int sock, const sa_family_t family) -{ - struct sockaddr_in sin = { - .sin_family = AF_INET, - .sin_addr.s_addr = htonl(INADDR_ANY), - }; - struct sockaddr_in6 sin6 = { - .sin6_family = AF_INET6, - .sin6_addr = IN6ADDR_ANY_INIT, - }; - - switch (family) { - case AF_INET: - return bindresvport_sa(sock, (struct sockaddr *)(char *)&sin); - case AF_INET6: - return bindresvport_sa(sock, (struct sockaddr *)(char *)&sin6); - } - - errno = EAFNOSUPPORT; - return -1; -} - -#else /* !HAVE_LIBTIRPC */ - -/* - * Bind a socket using an unused privileged source port. - * - * Returns zero on success, or returns -1 on error. errno is - * set to reflect the nature of the error. - */ -static int nfs_bindresvport(const int sock, const sa_family_t family) -{ - if (family != AF_INET) { - errno = EAFNOSUPPORT; - return -1; - } - - return bindresvport(sock, NULL); -} - -#endif /* !HAVE_LIBTIRPC */ - -/* - * Perform a non-blocking connect on the socket fd. - * - * @timeout is modified to contain the time remaining (i.e. time provided - * minus time elasped). - * - * Returns zero on success, or returns -1 on error. errno is - * set to reflect the nature of the error. - */ -static int nfs_connect_nb(const int fd, const struct sockaddr *sap, - const socklen_t salen, struct timeval *timeout) -{ - int flags, ret; - fd_set rset; - - flags = fcntl(fd, F_GETFL, 0); - if (flags < 0) - return -1; - - ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK); - if (ret < 0) - return -1; - - /* - * From here on subsequent sys calls could change errno so - * we set ret = -errno to capture it in case we decide to - * use it later. - */ - ret = connect(fd, sap, salen); - if (ret < 0 && errno != EINPROGRESS && errno != EINTR) { - ret = -1; - goto done; - } - - if (ret == 0) - goto done; - - /* now wait */ - FD_ZERO(&rset); - FD_SET(fd, &rset); - - while ((ret = select(fd + 1, NULL, &rset, NULL, timeout)) < 0) { - if (errno != EINTR) { - ret = -1; - goto done; - } else { - continue; - } - } - if (ret == 0) { - errno = ETIMEDOUT; - ret = -1; - goto done; - } - - if (FD_ISSET(fd, &rset)) { - int status; - socklen_t len = (socklen_t)sizeof(ret); - - status = getsockopt(fd, SOL_SOCKET, SO_ERROR, &ret, &len); - if (status < 0) { - ret = -1; - goto done; - } - - /* Oops - something wrong with connect */ - if (ret != 0) { - errno = ret; - ret = -1; - } - } - -done: - (void)fcntl(fd, F_SETFL, flags); - return ret; -} - -/* - * Set up an RPC client for communicating via a datagram socket. - * A connected UDP socket is used to detect a missing remote - * listener as quickly as possible. - * - * @timeout is initialized upon return - * - * Returns a pointer to a prepared RPC client if successful; caller - * must destroy a non-NULL returned RPC client. Otherwise NULL, and - * rpc_createerr.cf_stat is set to reflect the error. - */ -static CLIENT *nfs_get_udpclient(const struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - struct timeval *timeout, - const int resvport) -{ - CLIENT *client; - int ret = 0; - int sock = 0; -#ifdef HAVE_LIBTIRPC - struct sockaddr_storage address; - const struct netbuf nbuf = { - .maxlen = salen, - .len = salen, - .buf = &address, - }; - -#else /* !HAVE_LIBTIRPC */ - - if (sap->sa_family != AF_INET) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; - } -#endif /* !HAVE_LIBTIRPC */ - - sock = socket((int)sap->sa_family, SOCK_DGRAM, IPPROTO_UDP); - if (sock == -1) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - return NULL; - } - - if (resvport) { - ret = nfs_bindresvport(sock, sap->sa_family); - - if (ret < 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(sock); - return NULL; - } - } - - if (timeout->tv_sec == -1) - timeout->tv_sec = NFSRPC_TIMEOUT_UDP; - - ret = nfs_connect_nb(sock, sap, salen, timeout); - if (ret != 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(sock); - return NULL; - } - -#ifdef HAVE_LIBTIRPC - memcpy(nbuf.buf, sap, (size_t)salen); - client = clnt_dg_create(sock, &nbuf, program, version, 0, 0); -#else /* !HAVE_LIBTIRPC */ - client = clntudp_create((struct sockaddr_in *)sap, program, - version, *timeout, &sock); -#endif /* !HAVE_LIBTIRPC */ - if (client != NULL) { - struct timeval retry_timeout = { 1, 0 }; - CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, - (char *)&retry_timeout); - CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL); - } else - (void)close(sock); - - return client; -} - -/* - * Set up and connect an RPC client for communicating via a stream socket. - * - * @timeout is initialized upon return - * - * Returns a pointer to a prepared and connected RPC client if - * successful; caller must destroy a non-NULL returned RPC client. - * Otherwise NULL, and rpc_createerr.cf_stat is set to reflect the - * error. - */ -static CLIENT *nfs_get_tcpclient(const struct sockaddr *sap, - const socklen_t salen, - const rpcprog_t program, - const rpcvers_t version, - struct timeval *timeout, - const int resvport) -{ - CLIENT *client; - int ret = 0; - int sock = 0; -#ifdef HAVE_LIBTIRPC - struct sockaddr_storage address; - const struct netbuf nbuf = { - .maxlen = salen, - .len = salen, - .buf = &address, - }; - -#else /* !HAVE_LIBTIRPC */ - - if (sap->sa_family != AF_INET) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; - } -#endif /* !HAVE_LIBTIRPC */ - - sock = socket((int)sap->sa_family, SOCK_STREAM, IPPROTO_TCP); - if (sock == -1) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - return NULL; - } - - if (resvport) { - ret = nfs_bindresvport(sock, sap->sa_family); - - if (ret < 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(sock); - return NULL; - } - } - - if (timeout->tv_sec == -1) - timeout->tv_sec = NFSRPC_TIMEOUT_TCP; - - ret = nfs_connect_nb(sock, sap, salen, timeout); - if (ret != 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(sock); - return NULL; - } - -#ifdef HAVE_LIBTIRPC - memcpy(nbuf.buf, sap, (size_t)salen); - client = clnt_vc_create(sock, &nbuf, program, version, 0, 0); -#else /* !HAVE_LIBTIRPC */ - client = clnttcp_create((struct sockaddr_in *)sap, - program, version, &sock, 0, 0); -#endif /* !HAVE_LIBTIRPC */ - if (client != NULL) - CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL); - else - (void)close(sock); - - return client; -} - -/** - * nfs_get_rpcclient - acquire an RPC client - * @sap: pointer to socket address of RPC server - * @salen: length of socket address - * @transport: IPPROTO_ value of transport protocol to use - * @program: RPC program number - * @version: RPC version number - * @timeout: pointer to request timeout (must not be NULL) - * - * Set up an RPC client for communicating with an RPC program @program - * and @version on the server @sap over @transport. An unprivileged - * source port is used. - * - * Returns a pointer to a prepared RPC client if successful, and - * @timeout is initialized; caller must destroy a non-NULL returned RPC - * client. Otherwise returns NULL, and rpc_createerr.cf_stat is set to - * reflect the error. - */ -CLIENT *nfs_get_rpcclient(const struct sockaddr *sap, - const socklen_t salen, - const unsigned short transport, - const rpcprog_t program, - const rpcvers_t version, - struct timeval *timeout) -{ - nfs_clear_rpc_createerr(); - - switch (sap->sa_family) { - case AF_LOCAL: - return nfs_get_localclient(sap, salen, program, - version, timeout); - case AF_INET: - case AF_INET6: - if (nfs_get_port(sap) == 0) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return NULL; - } - break; - default: - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return NULL; - } - - switch (transport) { - case IPPROTO_TCP: - return nfs_get_tcpclient(sap, salen, program, version, - timeout, 0); - case 0: - case IPPROTO_UDP: - return nfs_get_udpclient(sap, salen, program, version, - timeout, 0); - } - - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; -} - -/** - * nfs_get_priv_rpcclient - acquire an RPC client - * @sap: pointer to socket address of RPC server - * @salen: length of socket address - * @transport: IPPROTO_ value of transport protocol to use - * @program: RPC program number - * @version: RPC version number - * @timeout: pointer to request timeout (must not be NULL) - * - * Set up an RPC client for communicating with an RPC program @program - * and @version on the server @sap over @transport. A privileged - * source port is used. - * - * Returns a pointer to a prepared RPC client if successful, and - * @timeout is initialized; caller must destroy a non-NULL returned RPC - * client. Otherwise returns NULL, and rpc_createerr.cf_stat is set to - * reflect the error. - */ -CLIENT *nfs_get_priv_rpcclient(const struct sockaddr *sap, - const socklen_t salen, - const unsigned short transport, - const rpcprog_t program, - const rpcvers_t version, - struct timeval *timeout) -{ - nfs_clear_rpc_createerr(); - - switch (sap->sa_family) { - case AF_LOCAL: - return nfs_get_localclient(sap, salen, program, - version, timeout); - case AF_INET: - case AF_INET6: - if (nfs_get_port(sap) == 0) { - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return NULL; - } - break; - default: - rpc_createerr.cf_stat = RPC_UNKNOWNADDR; - return NULL; - } - - switch (transport) { - case IPPROTO_TCP: - return nfs_get_tcpclient(sap, salen, program, version, - timeout, 1); - case 0: - case IPPROTO_UDP: - return nfs_get_udpclient(sap, salen, program, version, - timeout, 1); - } - - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - return NULL; -} - -/** - * nfs_getrpcbyname - convert an RPC program name to a rpcprog_t - * @program: default program number to use if names not found in db - * @table: pointer to table of 'char *' names to try to find - * - * Returns program number of first name to be successfully looked - * up, or the default program number if all lookups fail. - */ -rpcprog_t nfs_getrpcbyname(const rpcprog_t program, const char *table[]) -{ -#ifdef HAVE_GETRPCBYNAME - struct rpcent *entry; - unsigned int i; - - if (table != NULL) - for (i = 0; table[i] != NULL; i++) { - entry = getrpcbyname(table[i]); - if (entry) - return (rpcprog_t)entry->r_number; - } -#endif /* HAVE_GETRPCBYNAME */ - - return program; -} - -/* - * AUTH_SYS doesn't allow more than 16 gids in the supplemental group list. - * If there are more than that, trying to determine which ones to include - * in the list is problematic. This function creates an auth handle that - * only has the primary gid in the supplemental gids list. It's intended to - * be used for protocols where credentials really don't matter much (the MNT - * protocol, for instance). - */ -AUTH * -nfs_authsys_create(void) -{ - char machname[MAXHOSTNAMELEN + 1]; - uid_t uid = geteuid(); - gid_t gid = getegid(); - - if (gethostname(machname, sizeof(machname)) == -1) - return NULL; - - return authunix_create(machname, uid, gid, 1, &gid); -} diff --git a/nfs-utils-2.5.2/support/nfs/rpcdispatch.c b/nfs-utils-2.5.2/support/nfs/rpcdispatch.c deleted file mode 100644 index f7c27c9..0000000 --- a/nfs-utils-2.5.2/support/nfs/rpcdispatch.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * support/nfs/rcpdispatch.c - * - * Generic RPC dispatcher. - * - * Copyright (C) 1995, 1996, Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "rpcmisc.h" -#include "xlog.h" - -void -rpc_dispatch(struct svc_req *rqstp, SVCXPRT *transp, - struct rpc_dtable *dtable, int nvers, - void *argp, void *resp) -{ - struct rpc_dentry *dent; - - if (((int)rqstp->rq_vers) > nvers) { - svcerr_progvers(transp, 1, nvers); - return; - } - dtable += (rqstp->rq_vers - 1); - if (rqstp->rq_proc > dtable->nproc) { - svcerr_noproc(transp); - return; - } - - if (dtable->nproc <= rqstp->rq_proc) { - svcerr_noproc(transp); - return; - } - - dent = dtable->entries + rqstp->rq_proc; - - if (dent->func == NULL) { - svcerr_noproc(transp); - return; - } - - memset(argp, 0, dent->xdr_arg_size); - memset(resp, 0, dent->xdr_res_size); - - if (!svc_getargs(transp, dent->xdr_arg_fn, argp)) { - svcerr_decode(transp); - return; - } - - if ((dent->func)(rqstp, argp, resp) && resp != 0) { - if (!svc_sendreply(transp, dent->xdr_res_fn, (caddr_t)resp)) - svcerr_systemerr(transp); - } - if (!svc_freeargs(transp, dent->xdr_arg_fn, argp)) { - xlog(L_ERROR, "failed to free RPC arguments"); - exit (2); - } -} diff --git a/nfs-utils-2.5.2/support/nfs/rpcmisc.c b/nfs-utils-2.5.2/support/nfs/rpcmisc.c deleted file mode 100644 index d84c04f..0000000 --- a/nfs-utils-2.5.2/support/nfs/rpcmisc.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Miscellaneous functions for RPC service startup and shutdown. - * - * This code is partially snarfed from rpcgen -s tcp -s udp, - * partly written by Mark Shand, Donald Becker, and Rick - * Sladkey. It was tweaked slightly by Olaf Kirch to be - * usable by both unfsd and mountd. - * - * This software may be used for any purpose provided - * the above copyright notice is retained. It is supplied - * as is, with no warranty expressed or implied. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nfslib.h" -#include "rpcmisc.h" - -#if SIZEOF_SOCKLEN_T - 0 == 0 -#define socklen_t int -#endif - -#define _RPCSVC_CLOSEDOWN 120 -int _rpcpmstart = 0; -unsigned int _rpcprotobits = (NFSCTL_UDPBIT|NFSCTL_TCPBIT); -int _rpcsvcdirty = 0; - -static void -closedown(int sig) -{ - (void) signal(sig, closedown); - - if (_rpcsvcdirty == 0) { - static int size; - int i, openfd; - - if (NFSCTL_TCPISSET(_rpcprotobits) == 0) - exit(0); - - if (size == 0) - size = getdtablesize(); - - for (i = 0, openfd = 0; i < size && openfd < 2; i++) - if (FD_ISSET(i, &svc_fdset)) - openfd++; - if (openfd <= 1) - exit(0); - } - - (void) alarm(_RPCSVC_CLOSEDOWN); -} - -/* - * Create listener socket for a given port - * - * Return an open network socket on success; otherwise return -1 - * if some error occurs. - */ -static int -makesock(int port, int proto) -{ - struct sockaddr_in sin; - int sock, sock_type, val; - - sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; - sock = socket(AF_INET, sock_type, proto); - if (sock < 0) { - xlog(L_FATAL, "Could not make a socket: %s", - strerror(errno)); - return -1; - } - memset((char *) &sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(INADDR_ANY); - sin.sin_port = htons(port); - - val = 1; - if (proto == IPPROTO_TCP) - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - &val, sizeof(val)) < 0) - xlog(L_ERROR, "setsockopt failed: %s", - strerror(errno)); - - if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) { - xlog(L_FATAL, "Could not bind name to socket: %s", - strerror(errno)); - close(sock); - return -1; - } - - return svcsock_nonblock(sock); -} - -void -rpc_init(char *name, int prog, int vers, - void (*dispatch)(struct svc_req *, register SVCXPRT *), - int defport) -{ - struct sockaddr_in saddr; - SVCXPRT *transp; - int sock; - socklen_t asize; - - asize = sizeof(saddr); - sock = 0; - if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0 - && saddr.sin_family == AF_INET) { - socklen_t ssize = sizeof(int); - int fdtype = 0; - if (getsockopt(0, SOL_SOCKET, SO_TYPE, - (char *)&fdtype, &ssize) == -1) - xlog(L_FATAL, "getsockopt failed: %s", strerror(errno)); - /* inetd passes a UDP socket or a listening TCP socket. - * listen will fail on a connected TCP socket(passed by rsh). - */ - if (!(fdtype == SOCK_STREAM && listen(0,5) == -1)) { - switch(fdtype) { - case SOCK_DGRAM: - NFSCTL_UDPSET(_rpcprotobits); - break; - case SOCK_STREAM: - NFSCTL_TCPSET(_rpcprotobits); - break; - default: - xlog(L_FATAL, "getsockopt returns bad socket type: %d", fdtype); - } - _rpcpmstart = 1; - } - } - if (!_rpcpmstart) { - pmap_unset(prog, vers); - sock = RPC_ANYSOCK; - } - - if (NFSCTL_UDPISSET(_rpcprotobits)) { - static SVCXPRT *last_transp = NULL; - - if (_rpcpmstart == 0) { - if (last_transp - && (!defport || defport == last_transp->xp_port)) { - transp = last_transp; - goto udp_transport; - } - if (defport == 0) - sock = RPC_ANYSOCK; - else - sock = makesock(defport, IPPROTO_UDP); - } - if (sock == RPC_ANYSOCK) - sock = svcudp_socket (prog); - transp = svcudp_create(sock); - if (transp == NULL) { - xlog(L_FATAL, "cannot create udp service."); - } - udp_transport: - if (!svc_register(transp, prog, vers, dispatch, IPPROTO_UDP)) { - xlog(L_FATAL, "unable to register (%s, %d, udp).", - name, vers); - } - last_transp = transp; - } - - if (NFSCTL_TCPISSET(_rpcprotobits)) { - static SVCXPRT *last_transp = NULL; - - if (_rpcpmstart == 0) { - if (last_transp - && (!defport || defport == last_transp->xp_port)) { - transp = last_transp; - goto tcp_transport; - } - if (defport == 0) - sock = RPC_ANYSOCK; - else - sock = makesock(defport, IPPROTO_TCP); - } - if (sock == RPC_ANYSOCK) - sock = svctcp_socket (prog, 1); - transp = svctcp_create(sock, 0, 0); - if (transp == NULL) { - xlog(L_FATAL, "cannot create tcp service."); - } - tcp_transport: - if (!svc_register(transp, prog, vers, dispatch, IPPROTO_TCP)) { - xlog(L_FATAL, "unable to register (%s, %d, tcp).", - name, vers); - } - last_transp = transp; - } - - if (_rpcpmstart) { - signal(SIGALRM, closedown); - alarm(_RPCSVC_CLOSEDOWN); - } -} diff --git a/nfs-utils-2.5.2/support/nfs/strlcat.c b/nfs-utils-2.5.2/support/nfs/strlcat.c deleted file mode 100644 index 0edee14..0000000 --- a/nfs-utils-2.5.2/support/nfs/strlcat.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include "nfslib.h" - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -strlcat(char *dst, - const char *src, - size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} diff --git a/nfs-utils-2.5.2/support/nfs/strlcpy.c b/nfs-utils-2.5.2/support/nfs/strlcpy.c deleted file mode 100644 index 23e3ae9..0000000 --- a/nfs-utils-2.5.2/support/nfs/strlcpy.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include "nfslib.h" - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -strlcpy(char *dst, - const char *src, - size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} diff --git a/nfs-utils-2.5.2/support/nfs/svc_create.c b/nfs-utils-2.5.2/support/nfs/svc_create.c deleted file mode 100644 index 976c2d2..0000000 --- a/nfs-utils-2.5.2/support/nfs/svc_create.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include "nfslib.h" - -#include - -#include -#include - -#include -#include - -#ifdef HAVE_TCP_WRAPPER -#include "tcpwrapper.h" -#endif - -#include "sockaddr.h" -#include "rpcmisc.h" -#include "xlog.h" - -#ifdef HAVE_LIBTIRPC - -#include - -#define SVC_CREATE_XPRT_CACHE_SIZE (8) -static SVCXPRT *svc_create_xprt_cache[SVC_CREATE_XPRT_CACHE_SIZE] = { NULL, }; - -/* - * Cache an SVC xprt, in case there are more programs or versions to - * register against it. - */ -static void -svc_create_cache_xprt(SVCXPRT *xprt) -{ - unsigned int i; - - /* Check if we've already got this one... */ - for (i = 0; i < SVC_CREATE_XPRT_CACHE_SIZE; i++) - if (svc_create_xprt_cache[i] == xprt) - return; - - /* No, we don't. Cache it. */ - for (i = 0; i < SVC_CREATE_XPRT_CACHE_SIZE; i++) - if (svc_create_xprt_cache[i] == NULL) { - svc_create_xprt_cache[i] = xprt; - return; - } - - xlog(L_ERROR, "%s: Failed to cache an xprt", __func__); -} - -/* - * Find a previously cached SVC xprt structure with the given bind address - * and transport semantics. - * - * Returns pointer to a cached SVC xprt. - * - * If no matching SVC XPRT can be found, NULL is returned. - */ -static SVCXPRT * -svc_create_find_xprt(const struct sockaddr *bindaddr, const struct netconfig *nconf) -{ - unsigned int i; - - for (i = 0; i < SVC_CREATE_XPRT_CACHE_SIZE; i++) { - SVCXPRT *xprt = svc_create_xprt_cache[i]; - struct sockaddr *sap; - - if (xprt == NULL) - continue; - if (strcmp(nconf->nc_netid, xprt->xp_netid) != 0) - continue; - sap = (struct sockaddr *)xprt->xp_ltaddr.buf; - if (!nfs_compare_sockaddr(bindaddr, sap)) - continue; - return xprt; - } - return NULL; -} - -/* - * Set up an appropriate bind address, given @port and @nconf. - * - * Returns getaddrinfo(3) results if successful. Caller must - * invoke freeaddrinfo(3) on these results. - * - * Otherwise NULL is returned if an error occurs. - */ -__attribute__((__malloc__)) -static struct addrinfo * -svc_create_bindaddr(struct netconfig *nconf, const uint16_t port) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { - .ai_flags = AI_PASSIVE | AI_NUMERICSERV, - }; - char buf[8]; - int error; - - if (strcmp(nconf->nc_protofmly, NC_INET) == 0) - hint.ai_family = AF_INET; -#ifdef IPV6_SUPPORTED - else if (strcmp(nconf->nc_protofmly, NC_INET6) == 0) - hint.ai_family = AF_INET6; -#endif /* IPV6_SUPPORTED */ - else { - xlog(L_ERROR, "Unrecognized bind address family: %s", - nconf->nc_protofmly); - return NULL; - } - - if (strcmp(nconf->nc_proto, NC_UDP) == 0) - hint.ai_protocol = (int)IPPROTO_UDP; - else if (strcmp(nconf->nc_proto, NC_TCP) == 0) - hint.ai_protocol = (int)IPPROTO_TCP; - else { - xlog(L_ERROR, "Unrecognized bind address protocol: %s", - nconf->nc_proto); - return NULL; - } - - (void)snprintf(buf, sizeof(buf), "%u", port); - error = getaddrinfo(NULL, buf, &hint, &ai); - if (error != 0) { - xlog(L_ERROR, "Failed to construct bind address: %s", - gai_strerror(error)); - return NULL; - } - - return ai; -} - -/* - * Create a listener socket on a specific bindaddr, and set - * special socket options to allow it to share the same port - * as other listeners. - * - * Returns an open, bound, and possibly listening network - * socket on success. - * - * Otherwise returns -1 if some error occurs. - */ -static int -svc_create_sock(const struct sockaddr *sap, socklen_t salen, - struct netconfig *nconf) -{ - int fd, type, protocol; - int one = 1; - - switch(nconf->nc_semantics) { - case NC_TPI_CLTS: - type = SOCK_DGRAM; - break; - case NC_TPI_COTS_ORD: - type = SOCK_STREAM; - break; - default: - xlog(D_GENERAL, "%s: Unrecognized bind address semantics: %lu", - __func__, nconf->nc_semantics); - return -1; - } - - if (strcmp(nconf->nc_proto, NC_UDP) == 0) - protocol = (int)IPPROTO_UDP; - else if (strcmp(nconf->nc_proto, NC_TCP) == 0) - protocol = (int)IPPROTO_TCP; - else { - xlog(D_GENERAL, "%s: Unrecognized bind address protocol: %s", - __func__, nconf->nc_proto); - return -1; - } - - fd = socket((int)sap->sa_family, type, protocol); - if (fd == -1) { - xlog(L_ERROR, "Could not make a socket: (%d) %m", - errno); - return -1; - } - -#ifdef IPV6_SUPPORTED - if (sap->sa_family == AF_INET6) { - if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, - &one, sizeof(one)) == -1) { - xlog(L_ERROR, "Failed to set IPV6_V6ONLY: (%d) %m", - errno); - (void)close(fd); - return -1; - } - } -#endif /* IPV6_SUPPORTED */ - - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - &one, sizeof(one)) == -1) { - xlog(L_ERROR, "Failed to set SO_REUSEADDR: (%d) %m", - errno); - (void)close(fd); - return -1; - } - - if (bind(fd, sap, salen) == -1) { - xlog(L_ERROR, "Could not bind socket: (%d) %m", - errno); - (void)close(fd); - return -1; - } - - if (nconf->nc_semantics == NC_TPI_COTS_ORD) - if (listen(fd, SOMAXCONN) == -1) { - xlog(L_ERROR, "Could not listen on socket: (%d) %m", - errno); - (void)close(fd); - return -1; - } - - return fd; -} - -/* - * The simple case is allowing the TI-RPC library to create a - * transport itself, given just the bind address and transport - * semantics. - * - * Our local xprt cache is ignored in this path, since the - * caller is not interested in sharing listeners or ports, and - * the library automatically avoids ports already in use. - * - * Returns the count of started listeners (one or zero). - */ -static unsigned int -svc_create_nconf_rand_port(const char *name, const rpcprog_t program, - const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - struct netconfig *nconf) -{ - struct t_bind bindaddr; - struct addrinfo *ai; - SVCXPRT *xprt; - - ai = svc_create_bindaddr(nconf, 0); - if (ai == NULL) - return 0; - - bindaddr.addr.buf = ai->ai_addr; - bindaddr.qlen = SOMAXCONN; - - xprt = svc_tli_create(RPC_ANYFD, nconf, &bindaddr, 0, 0); - nfs_freeaddrinfo(ai); - if (xprt == NULL) { - xlog(L_ERROR, "Failed to create listener xprt " - "(%s, %u, %s)", name, version, nconf->nc_netid); - return 0; - } - if (svcsock_nonblock(xprt->xp_fd) < 0) { - /* close() already done by svcsock_nonblock() */ - xprt->xp_fd = RPC_ANYFD; - SVC_DESTROY(xprt); - return 0; - } - - rpc_createerr.cf_stat = rpc_createerr.cf_error.re_errno = 0; - if (!svc_reg(xprt, program, version, dispatch, nconf)) { - /* svc_reg(3) destroys @xprt in this case */ - xlog(L_ERROR, "Failed to register (%s, %u, %s): %s", - name, version, nconf->nc_netid, - clnt_spcreateerror("svc_reg() err")); - return 0; - } - - return 1; -} - -/* - * If a port is specified on the command line, that port value will be - * the same for all listeners created here. Create each listener - * socket in advance and set SO_REUSEADDR, rather than allowing the - * RPC library to create the listeners for us on a randomly chosen - * port via svc_tli_create(RPC_ANYFD). - * - * Some callers want to listen for more than one RPC version using the - * same port number. For example, mountd could want to listen for MNT - * version 1, 2, and 3 requests. This means mountd must use the same - * set of listener sockets for multiple RPC versions, since, on one - * system, you can't have two listener sockets with the exact same - * bind address (and port) and transport protocol. - * - * To accomplish this, this function caches xprts as they are created. - * This cache is checked to see if a previously created xprt can be - * used, before creating a new xprt for this [program, version]. If - * there is a cached xprt with the same bindaddr and transport - * semantics, we simply register the new version with that xprt, - * rather than creating a fresh xprt for it. - * - * The xprt cache implemented here is local to a process. Two - * separate RPC daemons can not share a set of listeners. - * - * Returns the count of started listeners (one or zero). - */ -static unsigned int -svc_create_nconf_fixed_port(const char *name, const rpcprog_t program, - const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - const uint16_t port, struct netconfig *nconf) -{ - struct addrinfo *ai; - SVCXPRT *xprt; - - ai = svc_create_bindaddr(nconf, port); - if (ai == NULL) - return 0; - - xprt = svc_create_find_xprt(ai->ai_addr, nconf); - if (xprt == NULL) { - int fd; - - fd = svc_create_sock(ai->ai_addr, ai->ai_addrlen, nconf); - fd = svcsock_nonblock(fd); - if (fd == -1) - goto out_free; - - xprt = svc_tli_create(fd, nconf, NULL, 0, 0); - if (xprt == NULL) { - xlog(D_GENERAL, "Failed to create listener xprt " - "(%s, %u, %s)", name, version, nconf->nc_netid); - (void)close(fd); - goto out_free; - } - } - - if (!svc_reg(xprt, program, version, dispatch, nconf)) { - /* svc_reg(3) destroys @xprt in this case */ - xlog(D_GENERAL, "Failed to register (%s, %u, %s)", - name, version, nconf->nc_netid); - goto out_free; - } - - svc_create_cache_xprt(xprt); - - nfs_freeaddrinfo(ai); - return 1; - -out_free: - nfs_freeaddrinfo(ai); - return 0; -} - -static unsigned int -svc_create_nconf(const char *name, const rpcprog_t program, - const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - const uint16_t port, struct netconfig *nconf) -{ - if (port != 0) - return svc_create_nconf_fixed_port(name, program, - version, dispatch, port, nconf); - - return svc_create_nconf_rand_port(name, program, - version, dispatch, nconf); -} - -/** - * nfs_svc_create - start up RPC svc listeners - * @name: C string containing name of new service - * @program: RPC program number to register - * @version: RPC version number to register - * @dispatch: address of function that handles incoming RPC requests - * @port: if not zero, transport listens on this port - * - * Sets up network transports for receiving RPC requests, and starts - * the RPC dispatcher. Returns the number of started network transports. - */ -unsigned int -nfs_svc_create(char *name, const rpcprog_t program, const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - const uint16_t port) -{ - const struct sigaction create_sigaction = { - .sa_handler = SIG_IGN, - }; - int maxrec = RPC_MAXDATASIZE; - unsigned int visible, up, servport; - struct netconfig *nconf; - void *handlep; - - /* - * Ignore SIGPIPE to avoid exiting sideways when peers - * close their TCP connection while we're trying to reply - * to them. - */ - (void)sigaction(SIGPIPE, &create_sigaction, NULL); - - /* - * Setting MAXREC also enables non-blocking mode for tcp connections. - * This avoids DOS attacks by a client sending many requests but never - * reading the reply: - * - if a second request already is present for reading in the socket, - * after the first request just was read, libtirpc will break the - * connection. Thus an attacker can't simply send requests as fast as - * he can without waiting for the response. - * - if the write buffer of the socket is full, the next write() will - * fail with EAGAIN. libtirpc will retry the write in a loop for max. - * 2 seconds. If write still fails, the connection will be closed. - */ - rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec); - - handlep = setnetconfig(); - if (handlep == NULL) { - xlog(L_ERROR, "Failed to access local netconfig database: %s", - nc_sperror()); - return 0; - } - - visible = 0; - up = 0; - while ((nconf = getnetconfig(handlep)) != NULL) { - if (!(nconf->nc_flag & NC_VISIBLE)) - continue; - visible++; - - if (!strcmp(nconf->nc_proto, NC_UDP) && !NFSCTL_UDPISSET(_rpcprotobits)) - continue; - - if (!strcmp(nconf->nc_proto, NC_TCP) && !NFSCTL_TCPISSET(_rpcprotobits)) - continue; - - if (port == 0) - servport = getservport(program, nconf->nc_proto); - else - servport = port; - - up += svc_create_nconf(name, program, version, dispatch, - servport, nconf); - } - - if (visible == 0) - xlog(L_ERROR, "Failed to find any visible netconfig entries"); - - if (endnetconfig(handlep) == -1) - xlog(L_ERROR, "Failed to close local netconfig database: %s", - nc_sperror()); - - return up; -} - -/** - * nfs_svc_unregister - remove service registrations from local rpcbind database - * @program: RPC program number to unregister - * @version: RPC version number to unregister - * - * Removes all registrations for [ @program, @version ] . - */ -void -nfs_svc_unregister(const rpcprog_t program, const rpcvers_t version) -{ - if (rpcb_unset(program, version, NULL) == FALSE) - xlog(D_GENERAL, "Failed to unregister program %lu, version %lu", - (unsigned long)program, (unsigned long)version); -} - -#else /* !HAVE_LIBTIRPC */ - -/** - * nfs_svc_create - start up RPC svc listeners - * @name: C string containing name of new service - * @program: RPC program number to register - * @version: RPC version number to register - * @dispatch: address of function that handles incoming RPC requests - * @port: if not zero, transport listens on this port - * - * Sets up network transports for receiving RPC requests, and starts - * the RPC dispatcher. Returns the number of started network transports. - */ -unsigned int -nfs_svc_create(char *name, const rpcprog_t program, const rpcvers_t version, - void (*dispatch)(struct svc_req *, SVCXPRT *), - const uint16_t port) -{ - rpc_init(name, (int)program, (int)version, dispatch, (int)port); - return 1; -} - -/** - * nfs_svc_unregister - remove service registrations from local rpcbind database - * @program: RPC program number to unregister - * @version: RPC version number to unregister - * - * Removes all registrations for [ @program, @version ] . - */ -void -nfs_svc_unregister(const rpcprog_t program, const rpcvers_t version) -{ - if (pmap_unset((unsigned long)program, (unsigned long)version) == FALSE) - xlog(D_GENERAL, "Failed to unregister program %lu, version %lu", - (unsigned long)program, (unsigned long)version); -} - -#endif /* !HAVE_LIBTIRPC */ diff --git a/nfs-utils-2.5.2/support/nfs/svc_socket.c b/nfs-utils-2.5.2/support/nfs/svc_socket.c deleted file mode 100644 index 2e8fe1a..0000000 --- a/nfs-utils-2.5.2/support/nfs/svc_socket.c +++ /dev/null @@ -1,218 +0,0 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 0211-1301 USA */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "xlog.h" -#include "rpcmisc.h" -#include "nfslib.h" - -#include "config.h" - -#ifdef _LIBC -# include -#else -# ifndef _ -# define _(s) (s) -# endif -# define __socket(d, t, p) socket ((d), (t), (p)) -# define __close(f) close ((f)) -#endif - -int getservport(u_long number, const char *proto) -{ - char servdata[1024]; - struct rpcent *rpcp; - struct servent servbuf, *servp = NULL; - int ret = 0; -#ifdef HAVE_GETRPCBYNUMBER_R - char rpcdata[1024]; - struct rpcent rpcbuf; - - ret = getrpcbynumber_r(number, &rpcbuf, rpcdata, sizeof rpcdata, - &rpcp); -#else - rpcp = getrpcbynumber(number); -#endif - - if (ret == 0 && rpcp != NULL) { - /* First try name. */ - ret = getservbyname_r(rpcp->r_name, proto, &servbuf, servdata, - sizeof servdata, &servp); - if ((ret != 0 || servp == NULL) && rpcp->r_aliases) { - const char **a; - - /* Then we try aliases. */ - for (a = (const char **) rpcp->r_aliases; *a != NULL; a++) { - ret = getservbyname_r(*a, proto, &servbuf, servdata, - sizeof servdata, &servp); - if (ret == 0 && servp != NULL) - break; - } - } - } - - if (ret == 0 && servp != NULL) - return ntohs(servp->s_port); - - return 0; -} - -int -svcsock_nonblock(int sock) -{ - int flags; - - if (sock < 0) - return sock; - - /* This socket might be shared among multiple processes - * if mountd is run multi-threaded. So it is safest to - * make it non-blocking, else all threads might wake - * one will get the data, and the others will block - * indefinitely. - * In all cases, transaction on this socket are atomic - * (accept for TCP, packet-read and packet-write for UDP) - * so O_NONBLOCK will not confuse unprepared code causing - * it to corrupt messages. - * It generally safest to have O_NONBLOCK when doing an accept - * as if we get a RST after the SYN and before accept runs, - * we can block despite being told there was an acceptable - * connection. - */ - if ((flags = fcntl(sock, F_GETFL)) < 0) - xlog(L_ERROR, "svc_socket: can't get socket flags: %m"); - else if (fcntl(sock, F_SETFL, flags|O_NONBLOCK) < 0) - xlog(L_ERROR, "svc_socket: can't set socket flags: %m"); - else - return sock; - - (void) __close(sock); - return -1; -} - -static int -svc_socket (u_long number, int type, int protocol, int reuse) -{ - struct sockaddr_in addr; - socklen_t len = sizeof (struct sockaddr_in); - int sock, ret; - const char *proto = protocol == IPPROTO_TCP ? "tcp" : "udp"; - - if ((sock = __socket (AF_INET, type, protocol)) < 0) - { - xlog(L_ERROR, "svc_socket: socket creation problem: %m"); - return sock; - } - - if (reuse) - { - ret = 1; - ret = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &ret, - sizeof (ret)); - if (ret < 0) - { - xlog(L_ERROR, "svc_socket: socket reuse problem: %m"); - (void) __close(sock); - return ret; - } - } - - memset (&addr, 0, sizeof (addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons(getservport(number, proto)); - - if (bind(sock, (struct sockaddr *) &addr, len) < 0) - { - xlog(L_ERROR, "svc_socket: bind problem: %m"); - (void) __close(sock); - sock = -1; - } - - return svcsock_nonblock(sock); -} - -/* - * Create and bind a TCP socket based on program number - */ -int -svctcp_socket (u_long number, int reuse) -{ - return svc_socket (number, SOCK_STREAM, IPPROTO_TCP, reuse); -} - -/* - * Create and bind a UDP socket based on program number - */ -int -svcudp_socket (u_long number) -{ - return svc_socket (number, SOCK_DGRAM, IPPROTO_UDP, FALSE); -} - -#ifdef TEST -static int -check (u_long number, u_short port, int protocol, int reuse) -{ - int socket; - int result; - struct sockaddr_in addr; - socklen_t len = sizeof (struct sockaddr_in); - - if (protocol == IPPROTO_TCP) - socket = svctcp_socket (number, reuse); - else - socket = svcudp_socket (number); - - if (socket < 0) - return 1; - - result = getsockname (socket, (struct sockaddr *) &addr, &len); - if (result == 0) - { - if (port != 0 && ntohs (addr.sin_port) != port) - printf ("Program: %ld, expect port: %d, got: %d\n", - number, port, ntohs (addr.sin_port)); - else - printf ("Program: %ld, port: %d\n", - number, ntohs (addr.sin_port)); - } - - close (socket); - return result; -} - -int -main (void) -{ - int result = 0; - - result += check (100001, 0, IPPROTO_TCP, 0); - result += check (100001, 0, IPPROTO_UDP, 0); - result += check (100003, 2049, IPPROTO_TCP, 1); - result += check (100003, 2049, IPPROTO_UDP, 1); - - return result; -} -#endif diff --git a/nfs-utils-2.5.2/support/nfs/wildmat.c b/nfs-utils-2.5.2/support/nfs/wildmat.c deleted file mode 100644 index 437b2d1..0000000 --- a/nfs-utils-2.5.2/support/nfs/wildmat.c +++ /dev/null @@ -1,182 +0,0 @@ -/* $Revision: 0.2.18.1 $ -** -** Do shell-style pattern matching for ?, \, [], and * characters. -** Might not be robust in face of malformed patterns; e.g., "foo[a-" -** could cause a segmentation violation. It is 8bit clean. -** -** Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. -** Rich $alz is now . -** April, 1991: Replaced mutually-recursive calls with in-line code -** for the star character. -** -** Special thanks to Lars Mathiesen for the ABORT code. -** This can greatly speed up failing wildcard patterns. For example: -** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-* -** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 -** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1 -** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without -** the ABORT code, it takes 22310 calls to fail. Ugh. The following -** explanation is from Lars: -** The precondition that must be fulfilled is that DoMatch will consume -** at least one character in text. This is true if *p is neither '*' nor -** '\0'.) The last return has ABORT instead of FALSE to avoid quadratic -** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With -** FALSE, each star-loop has to run to the end of the text; with ABORT -** only the last one does. -** -** Once the control of one instance of DoMatch enters the star-loop, that -** instance will return either TRUE or ABORT, and any calling instance -** will therefore return immediately after (without calling recursively -** again). In effect, only one star-loop is ever active. It would be -** possible to modify the code to maintain this context explicitly, -** eliminating all recursive calls at the cost of some complication and -** loss of clarity (and the ABORT stuff seems to be unclear enough by -** itself). I think it would be unwise to try to get this into a -** released version unless you have a good test data base to try it out -** on. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "nfslib.h" - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#define ABORT -1 - - - /* What character marks an inverted character class? */ -#define NEGATE_CLASS '^' - /* Is "*" a common pattern? */ -#define OPTIMIZE_JUST_STAR - /* Do tar(1) matching rules, which ignore a trailing slash? */ -#undef MATCH_TAR_PATTERN - - -/* -** Match text and p, return TRUE, FALSE, or ABORT. -*/ -static int -DoMatch(char *text, char *p) -{ - register int last; - register int matched; - register int reverse; - - for ( ; *p; text++, p++) { - if (*text == '\0' && *p != '*') - return ABORT; - switch (*p) { - case '\\': - /* Literal match with following character. */ - p++; - /* FALLTHROUGH */ - default: - if (toupper (*text) != toupper (*p)) - return FALSE; - continue; - case '?': - /* Match anything. */ - continue; - case '*': - while (*++p == '*') - /* Consecutive stars act just like one. */ - continue; - if (*p == '\0') - /* Trailing star matches everything. */ - return TRUE; - while (*text) - if ((matched = DoMatch(text++, p)) != FALSE) - return matched; - return ABORT; - case '[': - reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE; - if (reverse) - /* Inverted character class. */ - p++; - matched = FALSE; - if (p[1] == ']' || p[1] == '-') - if (toupper (*++p) == toupper(*text)) - matched = TRUE; - for (last = *p; *++p && *p != ']'; last = *p) - /* This next line requires a good C compiler. */ - if (*p == '-' && p[1] != ']' - ? *text <= *++p && *text >= last - : toupper (*text) == toupper (*p)) - matched = TRUE; - if (matched == reverse) - return FALSE; - continue; - } - } - -#ifdef MATCH_TAR_PATTERN - if (*text == '/') - return TRUE; -#endif /* MATCH_TAR_ATTERN */ - return *text == '\0'; -} - - -/* -** User-level routine. Returns TRUE or FALSE. -*/ -int -wildmat(char *text, char *p) -{ -#ifdef OPTIMIZE_JUST_STAR - if (p[0] == '*' && p[1] == '\0') - return TRUE; -#endif /* OPTIMIZE_JUST_STAR */ - return DoMatch(text, p) == TRUE; -} - - - -#if defined(TEST) -#include - -/* Yes, we use gets not fgets. Sue me. */ -extern char *gets(); - - -int -main() -{ - char p[80]; - char text[80]; - - printf("Wildmat tester. Enter pattern, then strings to test.\n"); - printf("A blank line gets prompts for a new pattern; a blank pattern\n"); - printf("exits the program.\n"); - - for ( ; ; ) { - printf("\nEnter pattern: "); - (void)fflush(stdout); - if (gets(p) == NULL || p[0] == '\0') - break; - for ( ; ; ) { - printf("Enter text: "); - (void)fflush(stdout); - if (gets(text) == NULL) - exit(0); - if (text[0] == '\0') - /* Blank line; go back and get a new pattern. */ - break; - printf(" %s\n", wildmat(text, p) ? "YES" : "NO"); - } - } - - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/nfs-utils-2.5.2/support/nfs/xcommon.c b/nfs-utils-2.5.2/support/nfs/xcommon.c deleted file mode 100644 index 3989f0b..0000000 --- a/nfs-utils-2.5.2/support/nfs/xcommon.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * xcommon.c - various functions put together to avoid basic error checking. - * - * added fcntl locking by Kjetil T. (kjetilho@math.uio.no) - aeb, 950927 - * - * 1999-02-22 Arkadiusz Miskiewicz - * - added Native Language Support - * - * 2006-06-06 Amit Gud - * - Moved code snippets here from mount/sundries.c of util-linux - * and merged code from support/nfs/xmalloc.c by Olaf Kirch here. - */ - -#include -#include -#include -#include -#include - -#include "xcommon.h" -#include "nls.h" /* _() */ - -void (*at_die)(void ) = NULL; - -char * -xstrndup (const char *s, int n) { - char *t; - - if (s == NULL) - die (EX_SOFTWARE, _("bug in xstrndup call")); - - t = xmalloc(n+1); - strncpy(t,s,n); - t[n] = 0; - - return t; -} - -char * -xstrconcat2 (const char *s, const char *t) { - char *res; - - if (!s) s = ""; - if (!t) t = ""; - res = xmalloc(strlen(s) + strlen(t) + 1); - strcpy(res, s); - strcat(res, t); - return res; -} - -/* frees its first arg - typical use: s = xstrconcat3(s,t,u); */ -char * -xstrconcat3 (const char *s, const char *t, const char *u) { - char *res; - - int dofree = 1; - - if (!s) s = "", dofree=0; - if (!t) t = ""; - if (!u) u = ""; - res = xmalloc(strlen(s) + strlen(t) + strlen(u) + 1); - strcpy(res, s); - strcat(res, t); - strcat(res, u); - if (dofree) - free((void *) s); - return res; -} - -/* frees its first arg - typical use: s = xstrconcat4(s,t,u,v); */ -char * -xstrconcat4 (const char *s, const char *t, const char *u, const char *v) { - char *res; - - int dofree = 1; - - if (!s) s = "", dofree=0; - if (!t) t = ""; - if (!u) u = ""; - if (!v) v = ""; - res = xmalloc(strlen(s) + strlen(t) + strlen(u) + strlen(v) + 1); - strcpy(res, s); - strcat(res, t); - strcat(res, u); - strcat(res, v); - if (dofree) - free((void *) s); - return res; -} - -/* Non-fatal error. Print message and return. */ -/* (print the message in a single printf, in an attempt - to avoid mixing output of several threads) */ -void -nfs_error (const char *fmt, ...) { - va_list args; - char *fmt2; - - fmt2 = xstrconcat2 (fmt, "\n"); - va_start (args, fmt); - vfprintf (stderr, fmt2, args); - va_end (args); - free (fmt2); -} - -/* Make a canonical pathname from PATH. Returns a freshly malloced string. - It is up the *caller* to ensure that the PATH is sensible. i.e. - canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.'' - is not a legal pathname for ``/dev/fd0''. Anything we cannot parse - we return unmodified. */ -char *canonicalize (const char *path) { - char canonical[PATH_MAX+2]; - - if (path == NULL) - return NULL; - -#if 1 - if (streq(path, "none") || - streq(path, "proc") || - streq(path, "devpts")) - return xstrdup(path); -#endif - if (realpath (path, canonical)) - return xstrdup(canonical); - - return xstrdup(path); -} - -/* Fatal error. Print message and exit. */ -void -die(int err, const char *fmt, ...) { - va_list args; - - va_start(args, fmt); - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); - va_end(args); - - if (at_die) - (*at_die)(); - - exit(err); -} - -static void -die_if_null(void *t) { - if (t == NULL) - die(EX_SYSERR, _("not enough memory")); -} - -void * -xmalloc (size_t size) { - void *t; - - if (size == 0) - return NULL; - - t = malloc(size); - die_if_null(t); - - return t; -} - -void * -xrealloc (void *p, size_t size) { - void *t; - - t = realloc(p, size); - die_if_null(t); - - return t; -} - -void -xfree(void *ptr) -{ - free(ptr); -} - -char * -xstrdup (const char *s) { - char *t; - - if (s == NULL) - return NULL; - - t = strdup(s); - die_if_null(t); - - return t; -} diff --git a/nfs-utils-2.5.2/support/nfs/xio.c b/nfs-utils-2.5.2/support/nfs/xio.c deleted file mode 100644 index 6962751..0000000 --- a/nfs-utils-2.5.2/support/nfs/xio.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * support/nfs/xio.c - * - * Simple I/O functions for the parsing of /etc/exports and /etc/nfsclients. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include "xmalloc.h" -#include "xlog.h" -#include "xio.h" - -XFILE * -xfopen(char *fname, char *type) -{ - XFILE *xfp; - FILE *fp; - - if (!(fp = fopen(fname, type))) - return NULL; - xfp = (XFILE *) xmalloc(sizeof(*xfp)); - xfp->x_fp = fp; - xfp->x_line = 1; - - return xfp; -} - -void -xfclose(XFILE *xfp) -{ - fclose(xfp->x_fp); - xfree(xfp); -} - -int -xflock(char *fname, char *type) -{ - int readonly = !strcmp(type, "r"); - struct flock fl = { readonly? F_RDLCK : F_WRLCK, SEEK_SET, 0, 0, 0 }; - int fd; - - if (readonly) - fd = open(fname, (O_RDONLY|O_CREAT), 0600); - else - fd = open(fname, (O_RDWR|O_CREAT), 0600); - if (fd < 0) { - xlog(L_WARNING, "could not open %s for locking: errno %d (%s)", - fname, errno, strerror(errno)); - return -1; - } - - if (fcntl(fd, F_SETLKW, &fl) < 0) { - xlog(L_WARNING, "failed to lock %s: errno %d (%s)", - fname, errno, strerror(errno)); - close(fd); - fd = -1; - } - - return fd; -} - -void -xfunlock(int fd) -{ - close(fd); -} - -#define isoctal(x) (isdigit(x) && ((x)<'8')) -int -xgettok(XFILE *xfp, char sepa, char *tok, int len) -{ - int i = 0; - int c = 0; - int quoted=0; - - while (i < len && (c = xgetc(xfp)) != EOF && - (quoted || (c != sepa && !isspace(c)))) { - if (c == '"') { - quoted = !quoted; - continue; - } - tok[i++] = c; - if (i >= 4 && - tok[i-4] == '\\' && - isoctal(tok[i-3]) && - isoctal(tok[i-2]) && - isoctal(tok[i-1]) && - ((tok[i]=0), - (c = strtol(tok+i-3,NULL, 8)) < 256)) { - i -= 4; - tok[i++] = c; - } - } - if (c == '\n') - xungetc(c, xfp); - if (!i) - return 0; - if (i >= len || (sepa && c != sepa)) - return -1; - tok[i] = '\0'; - return 1; -} - -int -xgetc(XFILE *xfp) -{ - int c = getc(xfp->x_fp); - - if (c == EOF) - return c; - if (c == '\\') { - if ((c = getc(xfp->x_fp)) != '\n') { - ungetc(c, xfp->x_fp); - return '\\'; - } - xfp->x_line++; - while ((c = getc(xfp->x_fp)) == ' ' || c == '\t'); - ungetc(c, xfp->x_fp); - return ' '; - } - if (c == '\n') - xfp->x_line++; - return c; -} - -void -xungetc(int c, XFILE *xfp) -{ - if (c == EOF) - return; - - ungetc(c, xfp->x_fp); - if (c == '\n') - xfp->x_line--; -} - -void -xskip(XFILE *xfp, char *str) -{ - int c; - - while ((c = xgetc(xfp)) != EOF) { - if (c == '#') - c = xskipcomment(xfp); - if (strchr(str, c) == NULL) - break; - } - xungetc(c, xfp); -} - -char -xskipcomment(XFILE *xfp) -{ - int c; - - while ((c = getc(xfp->x_fp)) != EOF && c != '\n'); - return c; -} diff --git a/nfs-utils-2.5.2/support/nfs/xlog.c b/nfs-utils-2.5.2/support/nfs/xlog.c deleted file mode 100644 index 86acd6a..0000000 --- a/nfs-utils-2.5.2/support/nfs/xlog.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * support/nfs/xlog.c - * - * This module handles the logging of requests. - * - * TODO: Merge the two "XXX_log() calls. - * - * Authors: Donald J. Becker, - * Rick Sladkey, - * Fred N. van Kempen, - * Olaf Kirch, - * - * This software maybe be used for any purpose provided - * the above copyright notice is retained. It is supplied - * as is, with no warranty expressed or implied. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nfslib.h" -#include "conffile.h" - -#undef VERBOSE_PRINTF - -#pragma GCC visibility push(hidden) - -static int log_stderr = 1; -static int log_syslog = 1; -static int logging = 0; /* enable/disable DEBUG logs */ -static int logmask = 0; /* What will be logged */ -static char log_name[256]; /* name of this program */ -static int log_pid = -1; /* PID of this program */ - -int export_errno = 0; - -static void xlog_toggle(int sig); -static struct xlog_debugfac debugnames[] = { - { "general", D_GENERAL, }, - { "call", D_CALL, }, - { "auth", D_AUTH, }, - { "parse", D_PARSE, }, - { "all", D_ALL, }, - { NULL, 0, }, -}; - -void -xlog_open(char *progname) -{ - openlog(progname, LOG_PID, LOG_DAEMON); - - strncpy(log_name, progname, sizeof (log_name) - 1); - log_name [sizeof (log_name) - 1] = '\0'; - log_pid = getpid(); - - signal(SIGUSR1, xlog_toggle); - signal(SIGUSR2, xlog_toggle); -} - -void -xlog_stderr(int on) -{ - log_stderr = on; -} - -void -xlog_syslog(int on) -{ - log_syslog = on; -} - -static void -xlog_toggle(int sig) -{ - unsigned int tmp, i; - - if (sig == SIGUSR1) { - if ((logmask & D_ALL) && !logging) { - xlog(D_GENERAL, "turned on logging"); - logging = 1; - return; - } - tmp = ~logmask; - logmask |= ((logmask & D_ALL) << 1) | D_GENERAL; - for (i = -1, tmp &= logmask; tmp; tmp >>= 1, i++) - if (tmp & 1) - xlog(D_GENERAL, - "turned on logging level %d", i); - } else { - xlog(D_GENERAL, "turned off logging"); - logging = 0; - } - signal(sig, xlog_toggle); -} - -void -xlog_config(int fac, int on) -{ - if (on) - logmask |= fac; - else - logmask &= ~fac; - if (on) - logging = 1; -} - -void -xlog_sconfig(char *kind, int on) -{ - struct xlog_debugfac *tbl = debugnames; - - while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind)) - tbl++; - if (!tbl->df_name) { - xlog (L_WARNING, "Invalid debug facility: %s\n", kind); - return; - } - xlog_config(tbl->df_fac, on); -} - -void -xlog_from_conffile(char *service) -{ - struct conf_list *kinds; - struct conf_list_node *n; - - kinds = conf_get_list(service, "debug"); - if (!kinds || !kinds->cnt) { - free(kinds); - return; - } - TAILQ_FOREACH(n, &(kinds->fields), link) - xlog_sconfig(n->field, 1); - - conf_free_list(kinds); -} - -int -xlog_enabled(int fac) -{ - return (logging && (fac & logmask)); -} - - -/* Write something to the system logfile and/or stderr */ -void -xlog_backend(int kind, const char *fmt, va_list args) -{ - if (!(kind & (L_ALL)) && !(logging && (kind & logmask))) - return; - - if (log_stderr) { - va_list args2; -#ifdef VERBOSE_PRINTF - time_t now; - struct tm *tm; - - time(&now); - tm = localtime(&now); - fprintf(stderr, "%s[%d] %04d-%02d-%02d %02d:%02d:%02d ", - log_name, log_pid, - tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); -#else - fprintf(stderr, "%s: ", log_name); -#endif - va_copy(args2, args); - vfprintf(stderr, fmt, args2); - fprintf(stderr, "\n"); - va_end(args2); - } - - if (log_syslog) { - switch (kind) { - case L_FATAL: - vsyslog(LOG_ERR, fmt, args); - break; - case L_ERROR: - vsyslog(LOG_ERR, fmt, args); - break; - case L_WARNING: - vsyslog(LOG_WARNING, fmt, args); - break; - case L_NOTICE: - vsyslog(LOG_NOTICE, fmt, args); - break; - default: - if (!log_stderr) - vsyslog(LOG_INFO, fmt, args); - break; - } - } - - if (kind == L_FATAL) - exit(1); -} - -void -xlog(int kind, const char* fmt, ...) -{ - va_list args; - - if (kind & (L_ERROR|D_GENERAL)) - export_errno = 1; - - va_start(args, fmt); - xlog_backend(kind, fmt, args); - va_end(args); -} - -void -xlog_warn(const char* fmt, ...) -{ - va_list args; - - va_start(args, fmt); - xlog_backend(L_WARNING, fmt, args); - va_end(args); -} - - -void -xlog_err(const char* fmt, ...) -{ - va_list args; - - va_start(args, fmt); - xlog_backend(L_FATAL, fmt, args); - va_end(args); -} - -void -xlog_errno(int err, const char *fmt, ...) -{ - va_list args; - - errno = err; - va_start(args, fmt); - xlog_backend(L_FATAL, fmt, args); - va_end(args); -} diff --git a/nfs-utils-2.5.2/support/nfsidmap/AUTHORS b/nfs-utils-2.5.2/support/nfsidmap/AUTHORS deleted file mode 100644 index 1101630..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -J. Bruce Fields diff --git a/nfs-utils-2.5.2/support/nfsidmap/COPYING b/nfs-utils-2.5.2/support/nfsidmap/COPYING deleted file mode 100644 index 7571bb7..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/COPYING +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2004 The Regents of the University of Michigan. -All rights reserved. - -Marius Aamodt Eriksen -J. Bruce Fields - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/nfs-utils-2.5.2/support/nfsidmap/Makefile.am b/nfs-utils-2.5.2/support/nfsidmap/Makefile.am deleted file mode 100644 index f5b9de0..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/Makefile.am +++ /dev/null @@ -1,75 +0,0 @@ -if PATH_PLUGINS -pkgplugindir=$(PATH_PLUGINS) -else -pkgplugindir=$(libdir)/libnfsidmap -endif - -if ENABLE_LDAP -UMICH_LDAP_LIB = umich_ldap.la -else -UMICH_LDAP_LIB = -endif -if ENABLE_GUMS -GUMS_MAPPING_LIB = gums.la -else -GUMS_MAPPING_LIB = -endif -if ENABLE_LDAP_SASL -KRB5_GSS_LIB=-lgssapi_krb5 -endif -lib_LTLIBRARIES = libnfsidmap.la -pkgplugin_LTLIBRARIES = nsswitch.la static.la regex.la $(UMICH_LDAP_LIB) $(GUMS_MAPPING_LIB) - -# Library versioning notes from: -# http://sources.redhat.com/autobook/autobook/autobook_91.html -# -# -version-info :: -# The number of the current interface exported by library. -# The implementation number of the most recent interface -# exported by the library. (i.e. revision should be updated -# with each new release of the library, and reset to zero -# when is updated.) -# The number of previous additional interfaces supported -# by this library. - -libnfsidmap_la_SOURCES = libnfsidmap.c nfsidmap_common.c -libnfsidmap_la_LDFLAGS = -version-info 1:0:0 -libnfsidmap_la_LIBADD = -ldl ../../support/nfs/libnfsconf.la - -nsswitch_la_SOURCES = nss.c nfsidmap_common.c -nsswitch_la_LDFLAGS = -module -avoid-version -nsswitch_la_LIBADD = ../../support/nfs/libnfsconf.la - -static_la_SOURCES = static.c -static_la_LDFLAGS = -module -avoid-version -static_la_LIBADD = ../../support/nfs/libnfsconf.la - -regex_la_SOURCES = regex.c -regex_la_LDFLAGS = -module -avoid-version -regex_la_LIBADD = ../../support/nfs/libnfsconf.la - -umich_ldap_la_SOURCES = umich_ldap.c -umich_ldap_la_LDFLAGS = -module -avoid-version -umich_ldap_la_LIBADD = -lldap $(KRB5_GSS_LIB) ../../support/nfs/libnfsconf.la - -gums_la_SOURCES = gums.c -gums_la_LDFLAGS = -module -avoid-version - -man3_MANS = nfs4_uid_to_name.3 -man5_MANS = idmapd.conf.5 -include_HEADERS = nfsidmap.h nfsidmap_plugin.h - -EXTRA_DIST = $(man3_MANS) \ - $(man5_MANS) \ - libtest.c \ - idmapd.conf - -# XXX: also exclude debian/files and debian/files.new ? do a clean?? -dist-hook: - mkdir $(distdir)/debian/ - find $(srcdir)/debian -maxdepth 1 -not -type d |xargs -i cp {} $(distdir)/debian/ - -pkgconfigdir=$(libdir)/pkgconfig -pkgconfig_DATA = libnfsidmap.pc - -$(pkgconfig_DATA): $(top_builddir)/config.status diff --git a/nfs-utils-2.5.2/support/nfsidmap/README b/nfs-utils-2.5.2/support/nfsidmap/README deleted file mode 100644 index 5a448ef..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/README +++ /dev/null @@ -1,126 +0,0 @@ -Library to help mapping id's, mainly for NFSv4. - -When NFSv4 is using AUTH_GSS (which currently only supports Kerberos v5), the -NFSv4 server mapping functions MUST use secure communications. - -We provide several mapping functions, configured using /etc/idmapd.conf - -As of the 0.21 version of this library, mapping methods are separate -dynamically-loaded libaries. This allows the separation of any -LDAP requirements from the main libnfsidmap library. The main library -now basically loads and calls the functions in the method-specific -libaries. The method libraries are expected to be named -"libnfsidmap_.so", for example, "libnfsidmap_nsswitch.so". - -Several methods may be specified in the /etc/idmapd.conf configuration -file. Each method is called until a mapping is found. - -The following translation methods are delivered in the default distribution: - -nsswitch --------- - -The default method is called nsswitch. This method uses the get password -file entry functions getpwname(), getpwid(), and the get group file entry -functions getgrnam(), getgrgid(). The nsswitch method can therefore be -configured by the /etc/nss_switch.conf passwd data base stanza. If secure -communications are required (AUTH_GSS), the passwd data base stanza can contain -the 'file' entry because the rpc.idmapd and rpc.svcgssd run as root, and/or the -'ldap' entry if the ldap service is configured to use SASL in /etc/ldap.conf. -The 'nis' entry is NOT recommended, it does not have a secure communications -mode. - - -static ------- - -This method works only for translating GSS authenticated names to local -names. It uses a static mapping setup defined in the [Static] section -of the idmapd.conf file. The form of the entries are: - = - -For example: - nfs/host.domain.org@DOMAIN.ORG = root - -It is recommended that this module be used in combination with another -module (e.g. the nsswitch module). - -umich_ldap ----------- -An experimental method, umich_ldap uses an LDAP schema and ldap functions -to perform translations. This method is designed to service remote users, -allowing remote users to set and get ACLs as well as map GSS principals -to id's. The functions are LDAP based, and the ldap search filters look -for attribute names set by idmapd.conf [UMICH_SCHEMA] -NFSv4_name_attr, NFSv4_group_attr, and GSS_principal_attr. - -It is assumed that the LDAP server will index these attributes, and that these -attributes will be associated with the nss.schema posixAccount uidNumber and -gidNumber. We expect that the uidNumber and gidNumber attribute will be -configurable via the idmapd.conf file soon. - -NFSv4_name_attr holds an NFSv4 name of the form user@domain, where the domain -portion of the name is a valid NFSv4 domain name. There is a one-to-one -mapping between the NFSv4_name_attr name and a UID. - -NFSv4_group_attr holds an NFSv4 name of the form group@domain, where the domain -portion of the name is a valid NFSv4 domain name. There is a one-to-one -mapping between the NFSv4_group_attr name and a GID. - -GSS_principal_attr holds a GSS security mechanism specific context principal -name. For Kerberos v5, it is a Kerberos principal principal@REALM. -For SPKM3, it is a PKI DN such as (line is split):` -"/C=US/ST=Michigan/O=University of Michigan/OU=UMICH Kerberos - Certification Authority/CN=andros/USERID=andros/Email=andros@UMICH.EDU". -There is a many-to-one relationship between the GSS_principal_attr -name and a UID plus GID. - -We have defined LDAP object classes for our experimental NFSv4 id mapping. -We made the attribute names configurable so that other sites could still use -the TR_UMICH_LDAP translation functions with different LDAP attribute names. - -We use the same attribute name, NFSv4Name for the NFSv4_name_attr and the -NFSv4_group_attr. For local users and remote users that we wish to give -a local machine account, we add the NFSv4Name attribute and the GSSAuthName -attribute to the existing inetorgPerson and posixAccount schema. -For remote users that we do not wish to give a local machine account, -we use the NFSv4RemotePerson object to contain the NFSv4Name, uidNumber, -gidNumber, and GSSAuthName. - -nfsv4.schema ------------- -attributetype ( 1.3.6.1.4.1.250.1.61 - NAME ( 'NFSv4Name') - DESC 'NFS version 4 Name' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE) - -attributetype ( 1.3.6.1.4.1.250.1.62 - NAME ( 'GSSAuthName') - DESC 'RPCSEC GSS authenticated user name' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26) - -# -# minimal information for NFSv4 access. used when local filesystem -# access is not permitted (nsswitch ldap calls fail), or when -# inetorgPerson is too much info. -# -objectclass ( 1.3.6.1.4.1.250.1.60 NAME 'NFSv4RemotePerson' - DESC 'NFS version4 person from remote NFSv4 Domain' - SUP top STRUCTURAL - MUST ( uidNumber $ gidNumber $ NFSv4Name ) - MAY ( cn $ GSSAuthName $ description) ) - -# -# minimal information for NFSv4 access. used when local filesystem -# access is not permitted (nsswitch ldap calls fail), or when -# inetorgPerson is too much info. -# -objectclass ( 1.3.6.1.4.1.250.1.63 NAME 'NFSv4RemoteGroup' - DESC 'NFS version4 group from remote NFSv4 Domain' - SUP top STRUCTURAL - MUST ( gidNumber $ NFSv4Name ) - MAY ( cn $ memberUid $ description) ) - diff --git a/nfs-utils-2.5.2/support/nfsidmap/gums.c b/nfs-utils-2.5.2/support/nfsidmap/gums.c deleted file mode 100644 index 1d6eb31..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/gums.c +++ /dev/null @@ -1,787 +0,0 @@ -/* - * gums.c - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Olga Kornievskaia - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nfsidmap.h" -#include "nfsidmap_plugin.h" - -#include - -#include -#include -#include - -#define DEFAULT_PRIMA_CONF_LOCATION "/etc/grid-security/prima-authz.conf" -#define DEFAULT_VOMSDIR "/etc/grid-security/vomsdir" -#define DEFAULT_CADIR "/etc/grid-security/certificates" -#define X509_DN_SIZE 1024 - -//#define DEBUG_PRINT_VOMS - -#define USING_TEST_PROGRAM -#ifdef USING_TEST_PROGRAM -nfs4_idmap_log_function_t idmap_log_func = printf; -int idmap_verbosity = 10; -#endif - -/* - * GUMS Translation Methods - * - */ - -/* global variables. voms/gums configuration attributes*/ -static char prima_conf[] = DEFAULT_PRIMA_CONF_LOCATION; -typedef struct _plugin_config_params { - char *saml_schema_dir; - int saml_log_level; - char *server_cert; - char *server_key; - char *ca_dir; - char *gums_server_location; - char *voms_dir; -} plugin_config_params; -plugin_config_params conf; - -#ifdef VOMS_BUG -static void my_VOMS_Delete(struct voms *v) -{ - int i; - - if (!v) return; - if (v->user) - free(v->user); - if (v->server) - free(v->server); - if (v->fqan) { - for (i = 0; v->fqan[i] != NULL; i++) - free(v->fqan[i]); - free(v->fqan); - } - free(v); -} - -static struct voms *my_VOMS_Copy(struct voms *v, int *err) -{ - struct voms *cv; - int i; - - cv = calloc(1, sizeof(struct voms)); - if (cv == NULL) - goto out; - cv->user = strdup(v->user); - if (cv->user == NULL) - goto out; - cv->server = strdup(v->server); - if (cv->server == NULL) - goto out; - for (i = 0; v->fqan[i] != NULL; i++) { - if (v->fqan[i] == NULL) - break; - } - cv->fqan = calloc(i+1, sizeof(char *)); - if (cv->fqan == NULL) - goto out; - cv->fqan[i] = NULL; - for (i = 0; v->fqan[i] != NULL; i++) { - cv->fqan[i] = strdup(v->fqan[i]); - if (cv->fqan[i] == NULL) - goto out; - } - return cv; -out: - if (cv) - my_VOMS_Delete(cv); - - return NULL; -} -#endif - - -#ifdef DEBUG_PRINT_VOMS -void printvoms(struct voms *v) -{ - int j; - - printf("SIGLEN: %d\nUSER: %s\n", v->siglen, v->user); - printf("UCA: %s\nSERVER: %s\n", v->userca, v->server); - printf("SCA: %s\nVO: %s\n", v->serverca, v->voname); - printf("URI: %s\nDATE1: %s\n", v->uri, v->date1); - printf("DATE2: %s\n", v->date2); - - switch (v->type) { - case TYPE_NODATA: - printf("NO DATA\n"); - break; - case TYPE_CUSTOM: - printf("%*s\n", v->datalen - 10, v->custom); - break; - case TYPE_STD: - j = 0; - while (v->std[j]) { - printf("GROUP: %s\nROLE: %s\nCAP: %s\n",v->std[j]->group, - v->std[j]->role,v->std[j]->cap); - j++; - } - } -} - -void print(struct vomsdata *d) -{ - struct voms **vo = d->data; - struct voms *v; - int k = 0; - - while(vo[k]) { - v = vo[k++]; - printf("%d *******************************************\n",k); - printvoms(v); - } - - if (d->workvo) - printf("WORKVO: %s\n", d->workvo); - - if (d->extra_data) - printf("EXTRA: %s\n", d->extra_data); -} -#endif - -static void free_plugin_config_params() -{ - if (conf.saml_schema_dir) - free(conf.saml_schema_dir); - conf.saml_schema_dir = NULL; - if (conf.server_cert) - free(conf.server_cert); - conf.server_cert = NULL; - if (conf.server_key) - free(conf.server_key); - conf.server_key = NULL; - if (conf.ca_dir) - free(conf.ca_dir); - conf.ca_dir = NULL; - if (conf.voms_dir) - free(conf.voms_dir); - conf.voms_dir = NULL; -} - -static int validate_plugin_config_params() -{ - if (conf.saml_schema_dir == NULL || - conf.server_cert == NULL || - conf.server_key == NULL || - conf.gums_server_location == NULL) - return -1; - - if (conf.ca_dir == NULL) { - conf.ca_dir = strdup(DEFAULT_CADIR); - if (conf.ca_dir == NULL) - return -1; - } - if (conf.voms_dir == NULL) { - conf.voms_dir = strdup(DEFAULT_VOMSDIR); - if (conf.voms_dir == NULL) - return -1; - } - return 0; -} - -static int gums_init(void) -{ - FILE *f = NULL; - int ret = -1, i = 0; - char buf[512], type[128], value[256]; - char *alt_conf = NULL; - - alt_conf = nfsidmap_config_get("GUMS", "Conf_File"); - if (alt_conf == NULL) - f = fopen(prima_conf, "r"); - else - f = fopen(alt_conf, "r"); - if (f == NULL) - goto out; - - while (fgets(buf, 512, f)) { - i = 0; - while(buf[i] == ' ' || buf[i] == '\t') - i++; - if (buf[i] == '#' || buf[i] == '\0' || buf[i] == '\n') - continue; - if (sscanf(&buf[i], "%127s%255s",type,value) < 2) { - IDMAP_LOG(0, ("ERROR: malformed line: %s\n", &buf[i])); - goto out; - } - IDMAP_LOG(1, ("PRIMA conf: type=%s value=%s\n", type, value)); - if (strncmp(type, "imsContact", 10) == 0) { - conf.gums_server_location = strdup(value); - } else if (strncmp(type, "serviceCert", 11) == 0) { - conf.server_cert = strdup(value); - } else if (strncmp(type, "serviceKey", 10) == 0) { - conf.server_key = strdup(value); - } else if (strncmp(type, "caCertDir", 9) == 0) { - conf.ca_dir = strdup(value); - } else if (strncmp(type, "samlSchemaDir", 13) == 0) { - conf.saml_schema_dir = strdup(value); - } else if (strncmp(type, "logLevel", 8) == 0) { - if (strncmp(value, "debug", 5) == 0) - conf.saml_log_level = PRIMA_LOG_DEBUG; - else if (strncmp(value, "error", 5) == 0) - conf.saml_log_level = PRIMA_LOG_ERROR; - else if (strncmp(value, "none", 4) == 0) - conf.saml_log_level = PRIMA_LOG_NONE; - else - conf.saml_log_level = PRIMA_LOG_INFO; - } - } - - if (validate_plugin_config_params() != 0) - goto out; - - ret = 0; -out: - if (f) - fclose(f); - if (ret) - free_plugin_config_params(); - - return ret; -} - -static int retrieve_attributes(X509 *cert, STACK_OF(X509) *cas, - struct voms **attrs) -{ - int ret = -1, err = 0; - struct vomsdata *vd = NULL; - - vd = VOMS_Init(conf.voms_dir, conf.ca_dir); - if (vd == NULL) { - IDMAP_LOG(0, ("VOMS_Init failed\n")); - return -1; - } - ret = VOMS_Retrieve(cert, cas, RECURSE_CHAIN, vd, &err); - if (err) { - char *err_msg; - err_msg = VOMS_ErrorMessage(vd, err, NULL, 0); - if (err == VERR_NOEXT) - ret = 0; - else - IDMAP_LOG(0, ("VOMS error %s\n", err_msg)); - goto out; - } else if (ret) { - struct voms *v, *v2; -#ifdef DEBUG_PRINT_VOMS - print(vd); -#endif - v = VOMS_DefaultData(vd, &err); - if (err == VERR_NONE) { -#ifdef DEBUG_PRINT_VOMS - printvoms(v); - while (v->fqan[i] != NULL) - IDMAP_LOG(1, ("user's fqan: %s\n", v->fqan[i++])); -#endif -#ifdef VOMS_BUG - v2 = my_VOMS_Copy(v, &err); -#else - v2 = VOMS_Copy(v, &err); -#endif - if (v2 == NULL) { - IDMAP_LOG(0, ("VOMS_Copy failed err=%d\n", err)); - goto out; - } - *attrs = v2; - } - } - ret = 0; -out: - if (vd) - VOMS_Destroy(vd); - return ret; -} - -static int get_server_dn(unsigned char **server_dn) -{ - BIO *tmp = NULL; - X509 *cert = NULL; - int ret = -1; - char dn[X509_DN_SIZE]; - - tmp = BIO_new(BIO_s_file()); - if (tmp == NULL) - goto out; - - ret = BIO_read_filename(tmp, conf.server_cert); - if (ret == 0) { - ret = errno; - goto out; - } - - cert = (X509 *) PEM_read_bio_X509(tmp, NULL, NULL, NULL); - if (cert == NULL) - goto out; - - X509_NAME_oneline(X509_get_subject_name(cert), dn, sizeof(dn)); - - *server_dn = strdup(dn); - if (*server_dn == NULL) - goto out; - - ret = 0; -out: - if (tmp) - BIO_free(tmp); - if (cert) - X509_free(cert); - - return ret; -} - -static int create_saml_request(char *dn, struct voms *attrs, char **saml_req) -{ - int ret = -1, i; - char *req = NULL; - unsigned char *server_dn = NULL; - prima_saml_fqans fqans; - - IDMAP_LOG(2, ("create_saml_request start\n")); - ret = initPrimaSAMLFQANs(&fqans); - if (ret) { - IDMAP_LOG(0, ("initPrimaSAMLFQANs failed with %d\n", ret)); - goto out; - } - - if (attrs) { - for (i = 0; attrs->fqan[i] != NULL; i++) { - ret = addPrimaSAMLFQAN(&fqans, attrs->server, attrs->fqan[i]); - IDMAP_LOG(1, ("addPrimaSAMLFQAN returned %d\n", ret)); - } - dn = attrs->user; - } else - IDMAP_LOG(1, ("No VOMS attributes present in the cert\n")); - - if (get_server_dn(&server_dn) != 0) - goto out; - req = createSAMLQueryAndRequest(server_dn, dn, &fqans); - if (req == NULL) { - IDMAP_LOG(0, ("createSAMLQueryAndRequest failed to create " - "SAML request\n")); - goto out; - } - IDMAP_LOG(1, ("SAML Request %s\n", req)); - - ret = 0; - *saml_req = req; -out: - cleanupPrimaSAMLFQANs(&fqans); - - if (server_dn) - free(server_dn); - - IDMAP_LOG(2, ("create_saml_request returning %d\n", ret)); - return ret; -} - -static int process_parameters(extra_mapping_params **ex, X509 **user_cert, - STACK_OF(X509) **user_chain) -{ - - int ret = -1, i; - X509 *cert = NULL, *x; - STACK_OF(X509) *chain = NULL; - unsigned char *p; - - if (ex[0]->content_type != X509_CERT) - return -1; - - /* get user's x509 certificate */ - p = ex[0]->content; - cert = d2i_X509(NULL, &p, ex[0]->content_len); - if (cert == NULL) - goto out; - - /* get user's other certificates */ - chain = sk_X509_new_null(); - if (chain == NULL) - goto out; - for (i = 1; ex[i] != NULL; i++) { - if (ex[i]->content_type != X509_CERT) - continue; - p = ex[i]->content; - x = d2i_X509(NULL, &p, ex[i]->content_len); - if (x == NULL) - goto out; - sk_X509_push(chain, x); - } - ret = 0; - - *user_cert = cert; - *user_chain = chain; -out: - if (ret) { - int num; - if (cert) - X509_free(cert); - if (chain) - sk_X509_pop_free(chain, X509_free); - } - - return ret; -} - -struct pwbuf { - struct passwd pwbuf; - char buf[1]; -}; - -static int translate_to_uid(char *local_uid, uid_t *uid, uid_t *gid) -{ - int ret = -1; - struct passwd *pw = NULL; - struct pwbuf *buf = NULL; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - - buf = malloc(sizeof(*buf) + buflen); - if (buf == NULL) - goto out; - - ret = getpwnam_r(local_uid, &buf->pwbuf, buf->buf, buflen, &pw); - if (pw == NULL) { - IDMAP_LOG(0, ("getpwnam: name %s not found\n", local_uid)); - goto out; - } - *uid = pw->pw_uid; - *gid = pw->pw_gid; - - ret = 0; -out: - if (buf) - free(buf); - return ret; -} - -static int translate_to_gid(char *local_gid, uid_t *gid) -{ - struct group *gr = NULL; - struct group grbuf; - char *buf = NULL; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - int ret = -1; - - do { - buf = malloc(buflen); - if (buf == NULL) - goto out; - - ret = -getgrnam_r(local_gid, &grbuf, buf, buflen, &gr); - if (gr == NULL && !ret) - ret = -ENOENT; - if (ret == -ERANGE) { - buflen *= 2; - free(buf); - } - } while (ret == -ERANGE); - - if (ret) - goto out; - - *gid = gr->gr_gid; - - ret = 0; -out: - if (buf) - free(buf); - return ret; -} - -static int gums_gss_princ_to_ids(char *secname, char *princ, - uid_t *uid, uid_t *gid, - extra_mapping_params **ex) -{ - int ret = -1, size, i; - X509 *cert = NULL; - STACK_OF(X509) *cas = NULL; - char dn[X509_DN_SIZE]; - struct voms *attrs = NULL; - char *saml_req = NULL, *saml_resp = NULL; - int saml_result; - char *local_uid = NULL, *local_gid = NULL, *p; - - /* accept only spkm3 translations */ - if (strcmp(secname, "spkm3")) - return -EINVAL; - - /* must supply either a DN and/or at least 1 binary blob */ - if (princ == NULL && (ex == NULL || (ex && ex[0] == NULL))) - return -EINVAL; - - /* process extra parameters */ - if (process_parameters(ex, &cert, &cas) != 0) - goto out; - - IDMAP_LOG(1, ("Processing name translation of client\n")); - X509_NAME_oneline(X509_get_subject_name(cert), dn, sizeof(dn)); - IDMAP_LOG(1, ("DN=%s\n", dn)); - size = sk_X509_num(cas); - IDMAP_LOG(1, ("Including following CAs (%d)\n", size)); - for (i=0; i < size; i++) { - X509_NAME_oneline(X509_get_subject_name(sk_X509_value(cas, i)), - dn, sizeof(dn)); - IDMAP_LOG(1, ("DN=%s\n", dn)); - } - - /* retrieve VOMS attributes */ - if (retrieve_attributes(cert, cas, &attrs) != 0) - goto out; - if (attrs == NULL) - X509_NAME_oneline(X509_get_subject_name(cert), dn, sizeof(dn)); - - /* initialize SAML library */ - if (initPrimaSAMLSupport(conf.saml_schema_dir, - conf.saml_log_level) != 0) { - IDMAP_LOG(0, ("initPrimaSAMLSupport failed\n")); - goto out; - } - - /* create SAML request */ - if (create_saml_request(dn, attrs, &saml_req) != 0) - goto out; - - /* contact GUMS server */ - saml_resp = queryIdentityMappingService(conf.gums_server_location, - saml_req, conf.server_cert, conf.server_key, - conf.ca_dir); - if (saml_resp != NULL) { - saml_result = processResponse(saml_resp, saml_req, &local_uid, - &local_gid); - IDMAP_LOG(1, ("processResponse returned %d\n", saml_result)); - if (saml_result || local_uid == NULL) { - IDMAP_LOG(0, ("processResponse failed to return " - "local id\n")); - ret = -ENOENT; - goto out; - } - IDMAP_LOG(1, ("GUMS returned uid=%s gid=%s\n", local_uid, - local_gid)); - } - - /* translate account name to uid */ - if (translate_to_uid(local_uid, uid, gid)) - goto out; - if (local_gid) - if (translate_to_gid(local_gid, gid)) - goto out; - - ret = 0; -out: - if (cert) - X509_free(cert); - - if (cas) - sk_X509_pop_free(cas, X509_free); - - if (attrs) -#ifdef VOMS_BUG - my_VOMS_Delete(attrs); -#else - VOMS_Delete(attrs); -#endif - - if (saml_req) - free(saml_req); - - if (saml_resp) - free(saml_resp); - - cleanupPrimaSAMLSupport(); - - return ret; -} - -struct trans_func gums_trans = { - .name = "gums", - .init = gums_init, - .princ_to_ids = gums_gss_princ_to_ids, - .name_to_uid = NULL, - .name_to_gid = NULL, - .uid_to_name = NULL, - .gid_to_name = NULL, - .gss_princ_to_grouplist = NULL, -}; - -struct trans_func *libnfsidmap_plugin_init() -{ - return (&gums_trans); -} - -#ifdef USING_TEST_PROGRAM -static STACK_OF(X509) *load_chain(char *certfile) -{ - STACK_OF(X509_INFO) *sk=NULL; - STACK_OF(X509) *stack=NULL, *ret=NULL; - BIO *in=NULL; - X509_INFO *xi; - int first = 1; - - if (!(stack = sk_X509_new_null())) { - printf("memory allocation failure\n"); - goto end; - } - - if (!(in=BIO_new_file(certfile, "r"))) { - printf("error opening the file, %s\n",certfile); - goto end; - } - - /* This loads from a file, a stack of x509/crl/pkey sets */ - if (!(sk=(STACK_OF(X509_INFO) *)PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) { - /* if (!(sk=PEM_X509_read_bio(in,NULL,NULL,NULL))) { */ - printf("error reading the file, %s\n",certfile); - goto end; - } - - /* scan over it and pull out the certs */ - while (sk_X509_INFO_num(sk)) { - /* skip first cert */ - if (first) { - xi=sk_X509_INFO_shift(sk); - X509_INFO_free(xi); - first = 0; - continue; - } - xi=sk_X509_INFO_shift(sk); - if (xi->x509 != NULL) { - sk_X509_push(stack,xi->x509); - xi->x509=NULL; - } - X509_INFO_free(xi); - } - if (!sk_X509_num(stack)) { - printf("no certificates in file, %s\n",certfile); - sk_X509_free(stack); - goto end; - } - ret=stack; -end: - BIO_free(in); - sk_X509_INFO_free(sk); - return(ret); -} - -void create_params(X509 *cert, STACK_OF(X509) *cas, - extra_mapping_params ***ret_params) -{ - int len = 0, i, size = 0; - unsigned char *p, *buf = NULL; - extra_mapping_params **params = NULL; - X509 *x; - - if (cas) - size = sk_X509_num(cas); - params = malloc((size+2)*sizeof(extra_mapping_params *)); - params[size+1] = NULL; - - /* 1st element is user's certificate */ - len = i2d_X509(cert, NULL); - p = buf = malloc(len); - i2d_X509(cert, &p); - params[0] = malloc(sizeof(extra_mapping_params)); - params[0]->content_type = X509_CERT; - params[0]->content = buf; - params[0]->content_len = len; - - /* add other certificates to the array */ - for (i = 0; i < size; i++) { - x = sk_X509_value(cas, i); - params[i+1] = malloc(sizeof(extra_mapping_params)); - len = i2d_X509(x, NULL); - p = buf = malloc(len); - i2d_X509(x, &p); - params[i+1]->content_type = X509_CERT; - params[i+1]->content = buf; - params[i+1]->content_len = len; - } - *ret_params = params; -} - -int main(void) -{ - int uid, gid, ret, i; - extra_mapping_params **params = NULL; - BIO *tmp = NULL; - X509 *cert = NULL, *x; - STACK_OF(X509) *cas = NULL; - unsigned char *proxy_file; - - if (gums_init()) - return -1; - proxy_file = getenv("X509_USER_PROXY"); - if (proxy_file == NULL) { - fprintf(stderr, "X509_USER_PROXY is not set\n"); - return -1; - } - tmp = BIO_new(BIO_s_file()); - BIO_read_filename(tmp, proxy_file); - cert = (X509 *) PEM_read_bio_X509(tmp, NULL, NULL, NULL); - cas = load_chain(proxy_file); - create_params(cert, cas, ¶ms); - ret = gums_gss_princ_to_ids("spkm3", NULL, &uid, &gid, params); - fprintf(stderr, "gums_gss_princ_to_ids returns %d uid=%d gid=%d\n", - ret, uid, gid); - - if (tmp) - BIO_free(tmp); - if (cert) - X509_free(cert); - if (cas) - sk_X509_pop_free(cas, X509_free); - - free_plugin_config_params(); - - if (params) { - for (i=0; params[i] != NULL; i++) { - free(params[i]->content); - free(params[i]); - } - free(params); - } - - return 0; -} -#endif diff --git a/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf b/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf deleted file mode 100644 index 2a2f79a..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf +++ /dev/null @@ -1,169 +0,0 @@ -[General] -#Verbosity = 0 -# The following should be set to the local NFSv4 domain name -# The default is the host's DNS domain name. -#Domain = local.domain.edu - -# In multi-domain environments, some NFS servers will append the identity -# management domain to the owner and owner_group in lieu of a true NFSv4 -# domain. This option can facilitate lookups in such environments. If -# set to a value other than "none", the nsswitch plugin will first pass -# the name to the password/group lookup function without stripping the -# domain off. If that mapping fails then the plugin will try again using -# the old method (comparing the domain in the string to the Domain value, -# stripping it if it matches, and passing the resulting short name to the -# lookup function). Valid values are "user", "group", "both", and -# "none". The default is "none". -#No-Strip = none - -# Winbind has a quirk whereby doing a group lookup in UPN format -# (e.g. staff@americas.example.com) will cause the group to be -# displayed prefixed with the full domain in uppercase -# (e.g. AMERICAS.EXAMPLE.COM\staff) instead of in the familiar netbios -# name format (e.g. AMERICAS\staff). Setting this option to true -# causes the name to be reformatted before passing it to the group -# lookup function in order to work around this. This setting is -# ignored unless No-Strip is set to either "both" or "group". -# The default is "false". -#Reformat-Group = false - -# The following is a comma-separated list of Kerberos realm -# names that should be considered to be equivalent to the -# local realm, such that @REALM.A can be assumed to -# be the same user as @REALM.B -# If not specified, the default local realm is the domain name, -# which defaults to the host's DNS domain name, -# translated to upper-case. -# Note that if this value is specified, the local realm name -# must be included in the list! -#Local-Realms = - -[Mapping] - -#Nobody-User = nobody -#Nobody-Group = nobody - -[Translation] - -# Translation Method is an comma-separated, ordered list of -# translation methods that can be used. Distributed methods -# include "nsswitch", "umich_ldap", and "static". Each method -# is a dynamically loadable plugin library. -# New methods may be defined and inserted in the list. -# The default is "nsswitch". -#Method = nsswitch - -# Optional. This is a comma-separated, ordered list of -# translation methods to be used for translating GSS -# authenticated names to ids. -# If this option is omitted, the same methods as those -# specified in "Method" are used. -#GSS-Methods = - -#-------------------------------------------------------------------# -# The following are used only for the "static" Translation Method. -#-------------------------------------------------------------------# -[Static] - -# A "static" list of GSS-Authenticated names to -# local user name mappings - -#someuser@REALM = localuser - - -#-------------------------------------------------------------------# -# The following are used only for the "umich_ldap" Translation Method. -#-------------------------------------------------------------------# - -[UMICH_SCHEMA] - -# server information (REQUIRED) -LDAP_server = ldap-server.local.domain.edu - -# the default search base (REQUIRED) -LDAP_base = dc=local,dc=domain,dc=edu - -#-----------------------------------------------------------# -# The remaining options have defaults (as shown) -# and are therefore not required. -#-----------------------------------------------------------# - -# whether or not to perform canonicalization on the -# name given as LDAP_server -#LDAP_canonicalize_name = true - -# absolute search base for (people) accounts -#LDAP_people_base = - -# absolute search base for groups -#LDAP_group_base = - -# Whether to follow ldap referrals -#LDAP_follow_referrals = true - -# Set to true to enable SSL - anything else is not enabled -#LDAP_use_ssl = false - -# Controls the LDAP server certificate validation behavior -# It can take the same values as ldap.conf(5)'s TLS_REQCERT -# tunable -#LDAP_tls_reqcert = "hard" - -# Location of CA certificate, mandatory if LDAP_tls_reqcert -# is not set to "never" -#LDAP_ca_cert = /etc/ldapca.cert - -# SASL mechanism to use while binding to LDAP -#LDAP_sasl_mech = - -# SASL realm to be used for SASL auth -#LDAP_sasl_realm = - -# Authentication identity to be used for SASL auth -#LDAP_sasl_authcid = - -# Authorization identity for SASL auth -#LDAP_sasl_authzid = - -# Cyrus SASL security properties -#LDAP_sasl_secprops = - -# Specifies whether the LDAP server hostname should be canonicalised. -# If set to yes LDAP lib with do a reverse hostname lookup. -# If this is not set the LDAP library's default will be used. -#LDAP_sasl_canonicalize - -# Specifies the kerberos ticket cache to be used -#LDAP_sasl_krb5_ccname = - -# Objectclass mapping information - -# Mapping for the person (account) object class -#NFSv4_person_objectclass = NFSv4RemotePerson - -# Mapping for the nfsv4name attribute the person object -#NFSv4_name_attr = NFSv4Name - -# Mapping for the UID number -#NFSv4_uid_attr = UIDNumber - -# Mapping for the GSSAPI Principal name -#GSS_principal_attr = GSSAuthName - -# Mapping for the account name attribute (usually uid) -# The value for this attribute must match the value of -# the group member attribute - NFSv4_member_attr -#NFSv4_acctname_attr = uid - -# Mapping for the group object class -#NFSv4_group_objectclass = NFSv4RemoteGroup - -# Mapping for the GID attribute -#NFSv4_gid_attr = GIDNumber - -# Mapping for the Group NFSv4 name -#NFSv4_group_attr = NFSv4Name - -# Mapping for the Group member attribute (usually memberUID) -# The value of this attribute must match the value of NFSv4_acctname_attr -#NFSv4_member_attr = memberUID diff --git a/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf.5 b/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf.5 deleted file mode 100644 index f5b1816..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/idmapd.conf.5 +++ /dev/null @@ -1,411 +0,0 @@ -.\" -.\" idmapd.conf(5) -.\" -.\" COPYRIGHT (c) 2008 -.\" The Regents of the University of Michigan -.\" ALL RIGHTS RESERVED -.\" -.\" Permission is granted to use, copy, create derivative works -.\" and redistribute this software and such derivative works -.\" for any purpose, so long as the name of The University of -.\" Michigan is not used in any advertising or publicity -.\" pertaining to the use of distribution of this software -.\" without specific, written prior authorization. If the -.\" above copyright notice or any other identification of the -.\" University of Michigan is included in any copy of any -.\" portion of this software, then the disclaimer below must -.\" also be included. -.\" -.\" THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION -.\" FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY -.\" PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF -.\" MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -.\" WITHOUT LIMITATION THE IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE -.\" REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE -.\" FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR -.\" CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING -.\" OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN -.\" IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGES. -.\" -.TH idmapd.conf 5 "19 Nov 2008" -.SH NAME -idmapd.conf \- configuration file for libnfsidmap -.SH SYNOPSIS -Configuration file for libnfsidmap. Used by idmapd and svcgssd to map NFSv4 name to and from ids. -.SH DESCRIPTION -The -.B idmapd.conf -configuration file consists of several sections, initiated by strings of the -form [General] and [Mapping]. Each section may contain lines of the form -.nf - variable = value -.fi -The recognized sections and their recognized variables are as follows: -.\" -.\" ------------------------------------------------------------------- -.\" The [General] section -.\" ------------------------------------------------------------------- -.\" -.SS "[General] section variables" -.nf - - -.fi -.TP -.B Verbosity -Verbosity level of debugging -(Default: 0) -.TP -.B Domain -The local NFSv4 domain name. An NFSv4 domain is a namespace with -a unique username<->UID and groupname<->GID mapping. -(Default: Host's fully-qualified DNS domain name) -.TP -.B No-Strip -In multi-domain environments, some NFS servers will append the identity -management domain to the owner and owner_group in lieu of a true NFSv4 -domain. This option can facilitate lookups in such environments. If -set to a value other than "none", the nsswitch plugin will first pass -the name to the password/group lookup function without stripping the -domain off. If that mapping fails then the plugin will try again using -the old method (comparing the domain in the string to the Domain value, -stripping it if it matches, and passing the resulting short name to the -lookup function). Valid values are "user", "group", "both", and -"none". -(Default: "none") -.TP -.B Reformat-Group -Winbind has a quirk whereby doing a group lookup in UPN format -(e.g. staff@americas.example.com) will cause the group to be -displayed prefixed with the full domain in uppercase -(e.g. AMERICAS.EXAMPLE.COM\\staff) instead of in the familiar netbios -name format (e.g. AMERICAS\\staff). Setting this option to true -causes the name to be reformatted before passing it to the group -lookup function in order to work around this. This setting is -ignored unless No-Strip is set to either "both" or "group". -(Default: "false") -.TP -.B Local-Realms -A comma-separated list of Kerberos realm names that may be considered equivalent to the -local realm name. For example, users juser@ORDER.EDU and juser@MAIL.ORDER.EDU -may be considered to be the same user in the specified -.B Domain. -(Default: the host's default realm name) -.br -.B Note: -If a value is specified here, the default local realm must be included as well. -.\" -.\" ------------------------------------------------------------------- -.\" The [Mapping] section -.\" ------------------------------------------------------------------- -.\" -.SS "[Mapping] section variables" -.nf - -.fi -.TP -.B Nobody-User -Local user name to be used when a mapping cannot be completed. -.TP -.B Nobody-Group -Local group name to be used when a mapping cannot be completed. -.\" -.\" ------------------------------------------------------------------- -.\" The [Translation] section -.\" ------------------------------------------------------------------- -.\" -.SS "[Translation] section variables" -.nf - -.fi -.TP -.B Method -A comma-separated, ordered list of mapping methods (plug-ins) -to use when mapping between NFSv4 names and local IDs. Each -specified method is tried in order until a mapping is found, -or there are no more methods to try. The methods included in -the default distribution include "nsswitch", "umich_ldap", and -"static". -(Default: nsswitch) -.TP -.B GSS-Methods -An optional comma-separated, ordered list of mapping methods (plug-ins) -to use when mapping between GSS Authenticated names and local IDs. -(Default: the same list as specified for -.B Method) -.\" -.\" ------------------------------------------------------------------- -.\" The [Static] section -.\" ------------------------------------------------------------------- -.\" -.SS "[Static] section variables" -.nf - -.fi -The "static" translation method uses a static list of GSS-Authenticated -names to local user names. Entries in the list are of the form: -.nf - principal@REALM = localusername -.fi -.\" -.\" ------------------------------------------------------------------- -.\" The [REGEX] section -.\" ------------------------------------------------------------------- -.\" -.SS "[REGEX] section variables" -.nf - -.fi -If the "regex" translation method is specified, the following -variables within the [REGEX] section are used to map between NFS4 names and local IDs. -.TP -.B User-Regex -Case-insensitive regular expression that extracts the local user name from an NFSv4 name. Multiple expressions may be concatenated with '|'. The first match will be used. -There is no default. A basic regular expression for domain DOMAIN.ORG and realm MY.DOMAIN.ORG would be: -.nf -^DOMAIN\\([^@]+)@MY.DOMAIN.ORG$ -.fi -.TP -.B Group-Regex -Case-insensitive regular expression that extracts the local group name from an NFSv4 name. Multiple expressions may be concatenated with '|'. The first match will be used. -There is no default. A basic regular expression for domain DOMAIN.ORG and realm MY.DOMAIN.ORG would be: -.nf -^([^@]+)@DOMAIN.ORG@MY.DOMAIN.ORG$|^DOMAIN\\([^@]+)@MY.DOMAIN.ORG$ -.fi -.TP -.B Prepend-Before-User -Constant string to put before a local user name when building an NFSv4 name. Usually this is the short domain name followed by '\'. -(Default: none) -.TP -.B Append-After-User -Constant string to put after a local user name when building an NFSv4 name. Usually this is '@' followed by the default realm. -(Default: none) -.TP -.B Prepend-Before-Group -Constant string to put before a local group name when building an NFSv4 name. Usually not used. -(Default: none) -.TP -.B Append-After-Group -Constant string to put before a local group name when building an NFSv4 name. Usually this is '@' followed by the domain name followed by another '@' and the default realm. -(Default: none) -.TP -.B Group-Name-Prefix -Constant string that is prepended to a local group name when converting it to an NFSv4 name. If an NFSv4 group name has this prefix it is removed when converting it to a local group name. -With this group names of a central directory can be shortened for an isolated organizational unit if all groups have a common prefix. -(Default: none) -.TP -.B Group-Name-No-Prefix-Regex -Case-insensitive regular expression to exclude groups from adding and removing the prefix set by -.B Group-Name-Prefix -. The regular expression must match both the remote and local group names. Multiple expressions may be concatenated with '|'. -(Default: none) -.\" -.\" ------------------------------------------------------------------- -.\" The [UMICH_SCHEMA] section -.\" ------------------------------------------------------------------- -.\" -.SS "[UMICH_SCHEMA] section variables" -.nf - -.fi -If the "umich_ldap" translation method is specified, the following -variables within the [UMICH_SCHEMA] section are used. -.TP -.B LDAP_server -LDAP server name or address -(Required if using UMICH_LDAP) -.TP -.B LDAP_base -Absolute LDAP search base. -(Required if using UMICH_LDAP) -.TP -.B LDAP_people_base -Absolute LDAP search base for people accounts. -(Default: The -.B LDAP_base -value) -.TP -.B LDAP_group_base -Absolute LDAP search base for group accounts. -(Default: The -.B LDAP_base -value) -.TP -.B LDAP_canonicalize_name -Whether or not to perform name canonicalization on the -name given as -.B LDAP_server -(Default: "true") -.TP -.B LDAP_follow_referrals -Whether or not to follow ldap referrals. (Default: "true") -.TP -.B LDAP_use_ssl -Set to "true" to enable SSL communication with the LDAP server. -(Default: "false") -.TP -.B LDAP_ca_cert -Location of a trusted CA certificate used when SSL is enabled -(Required if -.B LDAP_use_ssl -is true and -.B LDAP_tls_reqcert -is not set to never) -.TP -.B LDAP_tls_reqcert -Controls the LDAP server certificate validation behavior. -It can take the same values as ldap.conf(5)'s -.B TLS_REQCERT -tunable. -(Default: "hard") -.TP -.B LDAP_timeout_seconds -Number of seconds before timing out an LDAP request -(Default: 4) -.TP -.B LDAP_sasl_mech -SASL mechanism to be used for sasl authentication. Required -if SASL auth is to be used (Default: None) -.TP -.B LDAP_realm -SASL realm to be used for sasl authentication. (Default: None) -.TP -.B LDAP_sasl_authcid -Authentication identity to be used for sasl authentication. (Default: None) -.TP -.B LDAP_sasl_authzid -Authorization identity to be used for sasl authentication. (Default: None) -.TP -.B LDAP_sasl_secprops -Cyrus SASL security properties. It can the same values as ldap.conf(5)'s -sasl_secprops. -.TP -.B LDAP_sasl_canonicalize -Specifies whether the LDAP server hostname should be canonicalised. -If set to yes LDAP lib with do a reverse hostname lookup. -If this is not set the LDAP library's default will be used. (Default: -None) -.TP -.B LDAP_sasl_krb5_ccname -Path to kerberos credential cache. If it is not set then the value -of environment variable KRB5CCNAME will be used. If the environment -variable is not set then the default mechanism of kerberos library -will be used. -.TP -.B NFSv4_person_objectclass -The object class name for people accounts in your local LDAP schema -(Default: NFSv4RemotePerson) -.TP -.B NFSv4_name_attr -Your local schema's attribute name to be used for NFSv4 user names -(Default: NFSv4Name) -.TP -.B NFSv4_uid_attr -Your local schema's attribute name to be used for uidNumber -(Default: uidNumber) -.TP -.B GSS_principal_attr -Your local schema's attribute name for GSSAPI Principal names -(Default: GSSAuthName) -.TP -.B NFSv4_acctname_attr -Your local schema's attribute name to be used for account names -(Default: uid) -.TP -.B NFSv4_group_objectclass -The object class name for group accounts in your local LDAP schema -(Default: NFSv4RemoteGroup) -.TP -.B NFSv4_gid_attr -Your local schema's attribute name to be used for gidNumber -(Default: gidNumber) -.TP -.B NFSv4_group_attr -Your local schema's attribute name to be used for NFSv4 group names -(Default: NFSv4Name) -.TP -.B LDAP_use_memberof_for_groups -Some LDAP servers do a better job with indexing where searching -through all the groups searching for the user in the memberuid -list. Others like SunOne directory that search can takes minutes -if there are thousands of groups. So setting -.B LDAP_use_memberof_for_groups -to true in the configuration file will use the memberof lists of -the account and search through only those groups to obtain gids. -(Default: false) -.TP -.B NFSv4_member_attr -If -.B LDAP_use_memberof_for_groups -is true, this is the attribute to be searched for. -(Default: memberUid) -.TP -.B NFSv4_grouplist_filter -An optional search filter for determining group membership. -(No Default) -.\" -.\" ------------------------------------------------------------------- -.\" An Example -.\" ------------------------------------------------------------------- -.\" -.SH EXAMPLES -An example -.I /etc/idmapd.conf -file: -.nf - - -[General] - -Verbosity = 0 -Domain = domain.org -Local-Realms = DOMAIN.ORG,MY.DOMAIN.ORG,YOUR.DOMAIN.ORG - -[Mapping] - -Nobody-User = nfsnobody -Nobody-Group = nfsnobody - -[Translation] - -Method = umich_ldap,regex,nsswitch -GSS-Methods = umich_ldap,regex,static - -[Static] - -johndoe@OTHER.DOMAIN.ORG = johnny - -[Regex] - -User-Regex = ^DOMAIN\\([^@]+)@DOMAIN.ORG$ -Group-Regex = ^([^@]+)@DOMAIN.ORG@DOMAIN.ORG$|^DOMAIN\\([^@]+)@DOMAIN.ORG$ -Prepend-Before-User = DOMAIN\ -Append-After-User = @DOMAIN.ORG -Append-After-Group = @domain.org@domain.org -Group-Name-Prefix = sales- -Group-Name-No-Prefix-Regex = -personal-group$ - -[UMICH_SCHEMA] - -LDAP_server = ldap.domain.org -LDAP_base = dc=org,dc=domain - -.fi -.\" -.\" ------------------------------------------------------------------- -.\" Additional sections -.\" ------------------------------------------------------------------- -.\" -.SH SEE ALSO -.BR idmapd (8) -.BR svcgssd (8) -.\".SH COMPATIBILITY -.\".SH STANDARDS -.\".SH ACKNOWLEDGEMENTS -.\".SH AUTHORS -.\".SH HISTORY -.SH BUGS -Report bugs to -.\".SH CAVEATS diff --git a/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.c b/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.c deleted file mode 100644 index 0a912e5..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.c +++ /dev/null @@ -1,707 +0,0 @@ -/* - * libnfsidmap.c - * - * nfs idmapping library, primarily for nfs4 client/server kernel idmapping - * and for userland nfs4 idmapping by acl libraries. - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Marius Aamodt Eriksen - * J. Bruce Fields - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfsidmap.h" -#include "nfsidmap_private.h" -#include "nfsidmap_plugin.h" -#include "conffile.h" - -#pragma GCC visibility push(hidden) - -void nfs4_cleanup_name_mapping(void); -static char *default_domain; -static struct mapping_plugin **nfs4_plugins = NULL; -static struct mapping_plugin **gss_plugins = NULL; -uid_t nobody_uid = (uid_t)-1; -gid_t nobody_gid = (gid_t)-1; - -#ifndef PATH_PLUGINS -#define PATH_PLUGINS "/usr/lib/libnfsidmap" -#endif -#define PLUGIN_INIT_FUNC "libnfsidmap_plugin_init" - - -#ifndef PATH_IDMAPDCONF -#define PATH_IDMAPDCONF "/etc/idmapd.conf" -#endif - -#ifndef IDMAPD_DEFAULT_DOMAIN -#define IDMAPD_DEFAULT_DOMAIN "localdomain" -#endif - -#ifndef NFS4DNSTXTREC -#define NFS4DNSTXTREC "_nfsv4idmapdomain" -#endif - -#ifndef NS_MAXMSG -#define NS_MAXMSG 65535 -#endif - -/* Default logging fuction */ -static void default_logger(const char *fmt, ...) -{ - va_list vp; - - va_start(vp, fmt); - vsyslog(LOG_WARNING, fmt, vp); - va_end(vp); -} - -#pragma GCC visibility pop -nfs4_idmap_log_function_t idmap_log_func = default_logger; -int idmap_verbosity = 0; -#pragma GCC visibility push(hidden) - -static int id_as_chars(char *name, uid_t *id) -{ - long int value; - - if (name == NULL) - return 0; - value = strtol(name, NULL, 10); - if (value == 0) { - /* zero value ids are valid */ - if (strcmp(name, "0") != 0) - return 0; - } - *id = (int)value; - return 1; -} - -static int dns_txt_query(char *domain, char **nfs4domain) -{ - char *txtname = NFS4DNSTXTREC; - unsigned char *msg, *eom, *mptr; - char *answ; - int len, status = -1; - HEADER *hdr; - - msg = calloc(1, NS_MAXMSG); - if (msg == NULL) - return -1; - - answ = calloc(1, NS_MAXMSG); - if (answ == NULL) { - free(msg); - return -1; - } - - if (res_init() < 0) { - IDMAP_LOG(2, ("libnfsidmap: res_init() failed for %s.%s: %s\n", - txtname, domain, hstrerror(h_errno))); - goto freemem; - } - len = res_querydomain(txtname, domain, C_IN, T_TXT, msg, NS_MAXMSG); - if (len < 0) { - IDMAP_LOG(2, ("libnfsidmap: res_querydomain() failed for %s.%s: %s\n", - txtname, domain, hstrerror(h_errno))); - goto freemem; - } - hdr = (HEADER *)msg; - - /* See if there is an answer */ - if (ntohs(hdr->ancount) < 1) { - IDMAP_LOG(2, ("libnfsidmap: No TXT record for %s.%s\n", - txtname, domain)); - goto freemem; - } - /* find the EndOfMessage */ - eom = msg + len; - - /* skip header */ - mptr = &msg[HFIXEDSZ]; - - /* skip name field in question section */ - mptr += dn_skipname(mptr, eom) + QFIXEDSZ; - - /* read in the question */ - len = dn_expand(msg, eom, mptr, answ, NS_MAXDNAME); - if (len < 0) { /* does this really matter?? */ - IDMAP_LOG(2, ("libnfsidmap: No question section for %s.%s: %s\n", - txtname, domain, hstrerror(h_errno))); - goto freemem; - } - - /* - * Now, dissect the answer section, Note: if there - * are more than one answer only the first - * one will be used. - */ - - /* skip passed the name field */ - mptr += dn_skipname(mptr, eom); - /* skip pass the type class and ttl fields */ - mptr += 2 + 2 + 4; - - /* make sure there is some data */ - GETSHORT(len, mptr); - if (len < 0) { - IDMAP_LOG(2, ("libnfsidmap: No data in answer for %s.%s\n", - txtname, domain)); - goto freemem; - } - /* get the lenght field */ - len = (int)*mptr++; - /* copy the data */ - memcpy(answ, mptr, len); - answ[len] = '\0'; - - *nfs4domain = strdup(answ); - status = 0; - -freemem: - free(msg); - free(answ); - - return (status); -} - -static int domain_from_dns(char **domain) -{ - struct hostent *he; - char hname[64], *c; - - if (gethostname(hname, sizeof(hname)) == -1) - return -1; - if ((he = gethostbyname(hname)) == NULL) - return -1; - if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0') - return -1; - /* - * Query DNS to see if the _nfsv4idmapdomain TXT record exists - * If so use it... - */ - if (dns_txt_query(c, domain) < 0) - *domain = strdup(c); - - return 0; -} - -static int load_translation_plugin(char *method, struct mapping_plugin *plgn) -{ - void *dl = NULL; - struct trans_func *trans = NULL; - libnfsidmap_plugin_init_t init_func = NULL; - char plgname[128]; - int ret = 0; - - /* Look for library using search path first to allow overriding */ - snprintf(plgname, sizeof(plgname), "%s.so", method); - - dl = dlopen(plgname, RTLD_NOW | RTLD_LOCAL); - if (dl != NULL) { - /* Is it really one of our libraries */ - init_func = (libnfsidmap_plugin_init_t) dlsym(dl, PLUGIN_INIT_FUNC); - if (init_func == NULL) { - dlclose(dl); - dl = NULL; - } - } - - if (dl == NULL) { - /* Fallback to hard-coded path */ - snprintf(plgname, sizeof(plgname), "%s/%s.so", PATH_PLUGINS, method); - - dl = dlopen(plgname, RTLD_NOW | RTLD_LOCAL); - if (dl == NULL) { - IDMAP_LOG(1, ("libnfsidmap: Unable to load plugin: %s: %s", - plgname, dlerror())); - return -1; - } - init_func = (libnfsidmap_plugin_init_t) dlsym(dl, PLUGIN_INIT_FUNC); - if (init_func == NULL) { - IDMAP_LOG(1, ("libnfsidmap: Unable to get init function: %s: %s", - plgname, dlerror())); - dlclose(dl); - return -1; - } - } - trans = init_func(); - if (trans == NULL) { - IDMAP_LOG(1, ("libnfsidmap: Failed to initialize plugin %s", - PLUGIN_INIT_FUNC, plgname)); - dlclose(dl); - return -1; - } - if (trans->init) { - ret = trans->init(); - if (ret) { - IDMAP_LOG(1, ("libnfsidmap: Failed in %s's init(), " - "returned %d", plgname, ret)); - dlclose(dl); - return -1; - } - } - plgn->dl_handle = dl; - plgn->trans = trans; - IDMAP_LOG(1, ("libnfsidmap: loaded plugin %s for method %s", - plgname, method)); - - return 0; -} - -static void unload_plugins(struct mapping_plugin **plgns) -{ - int i; - for (i = 0; plgns[i] != NULL; i++) { - if (plgns[i]->dl_handle && dlclose(plgns[i]->dl_handle)) - IDMAP_LOG(1, ("libnfsidmap: failed to " - "unload plugin for method = %s", - plgns[i]->trans->name)); - free(plgns[i]); - } - free(plgns); -} - -static int load_plugins(struct conf_list *methods, - struct mapping_plugin ***plugins) -{ - int ret = -1, i = 0; - struct mapping_plugin **plgns; - struct conf_list_node *m; - - plgns = calloc(methods->cnt + 1, sizeof(struct mapping_plugin *)); - if (plgns == NULL) - return -1; - plgns[methods->cnt] = NULL; - for (m = TAILQ_FIRST(&methods->fields), i = 0; m; - m = TAILQ_NEXT(m, link), i++) { - plgns[i] = calloc(1, sizeof(struct mapping_plugin)); - if (plgns[i] == NULL) - goto out; - if (load_translation_plugin(m->field, plgns[i]) == -1) { - IDMAP_LOG(0, ("libnfsidmap: requested translation " - "method, '%s', is not available", - m->field)); - goto out; - } - } - ret = 0; - *plugins = plgns; -out: - if (ret) - unload_plugins(plgns); - return ret; -} - -static char *get_default_domain(void) -{ - int ret; - - if (default_domain) - return default_domain; - ret = domain_from_dns(&default_domain); - if (ret) { - IDMAP_LOG(0, ("Unable to determine a default nfsv4 domain; " - " consider specifying one in idmapd.conf")); - default_domain = ""; - } - return default_domain; -} - -void nfs4_cleanup_name_mapping(void) -{ - if (nfs4_plugins) - unload_plugins(nfs4_plugins); - if (gss_plugins) - unload_plugins(gss_plugins); - nfs4_plugins = gss_plugins = NULL; -} - -#pragma GCC visibility pop - -const char * nfsidmap_conf_path = PATH_IDMAPDCONF; - -int nfs4_init_name_mapping(char *conffile) -{ - int ret = -ENOENT; - int dflt = 0; - struct conf_list *nfs4_methods, *gss_methods; - char *nobody_user, *nobody_group; - - /* XXX: need to be able to reload configurations... */ - if (nfs4_plugins) /* already succesfully initialized */ - return 0; - if (conffile) - nfsidmap_conf_path = conffile; - conf_init_file(nfsidmap_conf_path); - - default_domain = conf_get_str("General", "Domain"); - if (default_domain == NULL) { - dflt = 1; - ret = domain_from_dns(&default_domain); - if (ret) { - IDMAP_LOG(1, ("libnfsidmap: Unable to determine " - "the NFSv4 domain; Using '%s' as the NFSv4 domain " - "which means UIDs will be mapped to the 'Nobody-User' " - "user defined in %s", - IDMAPD_DEFAULT_DOMAIN, PATH_IDMAPDCONF)); - default_domain = IDMAPD_DEFAULT_DOMAIN; - } - } - IDMAP_LOG(1, ("libnfsidmap: using%s domain: %s", - (dflt ? " (default)" : ""), default_domain)); - - struct conf_list *local_realms = get_local_realms(); - if (local_realms == NULL) return -ENOMEM; - - if (idmap_verbosity >= 1) { - struct conf_list_node *r; - char *buf = NULL; - int siz=0; - - if (local_realms) { - TAILQ_FOREACH(r, &local_realms->fields, link) { - siz += (strlen(r->field)+4); - } - buf = malloc(siz); - if (buf) { - *buf = 0; - TAILQ_FOREACH(r, &local_realms->fields, link) { - sprintf(buf+strlen(buf), "'%s' ", r->field); - } - IDMAP_LOG(1, ("libnfsidmap: Realms list: %s", buf)); - free(buf); - } - } else - IDMAP_LOG(1, ("libnfsidmap: Realms list: ")); - } - - nfs4_methods = conf_get_list("Translation", "Method"); - if (nfs4_methods) { - IDMAP_LOG(1, ("libnfsidmap: processing 'Method' list")); - if (load_plugins(nfs4_methods, &nfs4_plugins) == -1) { - conf_free_list(nfs4_methods); - return -ENOENT; - } - } else { - struct conf_list list; - struct conf_list_node node; - - TAILQ_INIT(&list.fields); - list.cnt = 1; - node.field = "nsswitch"; - TAILQ_INSERT_TAIL (&list.fields, &node, link); - - if (load_plugins(&list, &nfs4_plugins) == -1) - return -ENOENT; - } - - gss_methods = conf_get_list("Translation", "GSS-Methods"); - if (gss_methods) { - IDMAP_LOG(1, ("libnfsidmap: processing 'GSS-Methods' list")); - if (load_plugins(gss_methods, &gss_plugins) == -1) - goto out; - } - - nobody_user = conf_get_str("Mapping", "Nobody-User"); - if (nobody_user) { - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - struct passwd *buf; - struct passwd *pw = NULL; - int err; - - buf = malloc(sizeof(*buf) + buflen); - if (buf) { - err = getpwnam_r(nobody_user, buf, ((char *)buf) + sizeof(*buf), buflen, &pw); - if (err == 0 && pw != NULL) - nobody_uid = pw->pw_uid; - else - IDMAP_LOG(1, ("libnfsidmap: Nobody-User (%s) not found: %s", - nobody_user, strerror(errno))); - free(buf); - } else - IDMAP_LOG(0,("libnfsidmap: Nobody-User: no memory : %s", - nobody_user, strerror(errno))); - } - - nobody_group = conf_get_str("Mapping", "Nobody-Group"); - if (nobody_group) { - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - struct group *buf; - struct group *gr = NULL; - int err; - - buf = malloc(sizeof(*buf) + buflen); - if (buf) { - err = getgrnam_r(nobody_group, buf, ((char *)buf) + sizeof(*buf), buflen, &gr); - if (err == 0 && gr != NULL) - nobody_gid = gr->gr_gid; - else - IDMAP_LOG(1, ("libnfsidmap: Nobody-Group (%s) not found: %s", - nobody_group, strerror(errno))); - free(buf); - } else - IDMAP_LOG(0,("libnfsidmap: Nobody-Group: no memory : %s", - nobody_group, strerror(errno))); - } - - ret = 0; -out: - if (ret) { - if (nfs4_plugins) - unload_plugins(nfs4_plugins); - if (gss_plugins) { - unload_plugins(gss_plugins); - } - nfs4_plugins = gss_plugins = NULL; - } - - if (gss_methods) - conf_free_list(gss_methods); - - if (nfs4_methods) - conf_free_list(nfs4_methods); - - return ret ? -ENOENT: 0; -} - -void nfs4_term_name_mapping(void) -{ - if (nfs4_plugins) - unload_plugins(nfs4_plugins); - if (gss_plugins) - unload_plugins(gss_plugins); - - nfs4_plugins = gss_plugins = NULL; - - free_local_realms(); - conf_cleanup(); -} - -int -nfs4_get_default_domain(char *UNUSED(server), char *domain, size_t len) -{ - char *d = get_default_domain(); - - if (strlen(d) + 1 > len) - return -ERANGE; - strcpy(domain, d); - return 0; -} - -/* - * Run through each configured translation method for - * function "funcname". - * If "prefer_gss" is true, then use the gss_plugins list, - * if present. Otherwise, use the default nfs4_plugins list. - * - * If the plugin function returns -ENOENT, then continue - * to the next plugin. - */ -#define RUN_TRANSLATIONS(funcname, prefer_gss, args...) \ - do { \ - int ret, i; \ - struct mapping_plugin **plgns; \ - \ - ret = nfs4_init_name_mapping(NULL); \ - if (ret) \ - return ret; \ - \ - if ((prefer_gss) && gss_plugins) \ - plgns = gss_plugins; \ - else \ - plgns = nfs4_plugins; \ - \ - for (i = 0; plgns[i] != NULL; i++) { \ - if (plgns[i]->trans->funcname == NULL) \ - continue; \ - \ - IDMAP_LOG(4, ("%s: calling %s->%s", __func__, \ - plgns[i]->trans->name, #funcname)); \ - \ - ret = plgns[i]->trans->funcname(args); \ - \ - IDMAP_LOG(4, ("%s: %s->%s returned %d", \ - __func__, plgns[i]->trans->name, \ - #funcname, ret)); \ - \ - if (ret == -ENOENT) \ - continue; \ - \ - break; \ - } \ - IDMAP_LOG(4, ("%s: final return value is %d", \ - __func__, ret)); \ - return ret; \ - } while (0) - -int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len) -{ - RUN_TRANSLATIONS(uid_to_name, 0, uid, domain, name, len); -} - -int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len) -{ - RUN_TRANSLATIONS(gid_to_name, 0, gid, domain, name, len); -} - -int nfs4_uid_to_owner(uid_t uid, char *domain, char *name, size_t len) -{ - if (nfs4_uid_to_name(uid, domain, name, len)) - sprintf(name, "%u", uid); - return 0; -} - -int nfs4_gid_to_group_owner(gid_t gid, char *domain, char *name, size_t len) -{ - if (nfs4_gid_to_name(gid, domain, name, len)) - sprintf(name, "%u", gid); - return 0; -} - -int nfs4_name_to_uid(char *name, uid_t *uid) -{ - RUN_TRANSLATIONS(name_to_uid, 0, name, uid); -} - -int nfs4_name_to_gid(char *name, gid_t *gid) -{ - RUN_TRANSLATIONS(name_to_gid, 0, name, gid); -} - -static int set_id_to_nobody(uid_t *id, uid_t is_uid) -{ - int rc = 0; - const char name[] = "nobody@"; - char nobody[strlen(name) + strlen(get_default_domain()) + 1]; - - /* First try to see whether a Nobody-User/Nobody-Group was - * configured, before we try to do a full lookup for the - * NFS nobody user. */ - if (is_uid && nobody_uid != (uid_t)-1) { - *id = (uid_t)nobody_uid; - return 0; - } else if (!is_uid && nobody_gid != (gid_t)-1) { - *id = (uid_t)nobody_gid; - return 0; - } - - strcpy(nobody, name); - strcat(nobody, get_default_domain()); - - if (is_uid) - rc = nfs4_name_to_uid(nobody, id); - else - rc = nfs4_name_to_gid(nobody, id); - - if (rc) { - *id = -2; - rc = 0; - } - return rc; -} - -int nfs4_owner_to_uid(char *name, uid_t *uid) -{ - int rc = nfs4_name_to_uid(name, uid); - if (rc && id_as_chars(name, uid)) - rc = 0; - else if (rc) - rc = set_id_to_nobody(uid, 1); - return rc; -} - -int nfs4_group_owner_to_gid(char *name, gid_t *gid) -{ - int rc = nfs4_name_to_gid(name, gid); - if (rc && id_as_chars(name, gid)) - rc = 0; - else if (rc) - rc = set_id_to_nobody((uid_t *)gid, 0); - return rc; -} - -int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid) -{ - RUN_TRANSLATIONS(princ_to_ids, 1, secname, princ, uid, gid, NULL); -} - -int nfs4_gss_princ_to_grouplist(char *secname, char *princ, - gid_t *groups, int *ngroups) -{ - RUN_TRANSLATIONS(gss_princ_to_grouplist, 1, secname, princ, - groups, ngroups, NULL); -} - -int nfs4_gss_princ_to_ids_ex(char *secname, char *princ, uid_t *uid, - gid_t *gid, extra_mapping_params **ex) -{ - RUN_TRANSLATIONS(princ_to_ids, 1, secname, princ, uid, gid, ex); -} - -int nfs4_gss_princ_to_grouplist_ex(char *secname, char *princ, gid_t *groups, - int *ngroups, extra_mapping_params **ex) -{ - RUN_TRANSLATIONS(gss_princ_to_grouplist, 1, secname, princ, - groups, ngroups, ex); -} - -void nfs4_set_debug(int dbg_level, void (*logger)(const char *, ...)) -{ - if (logger) - idmap_log_func = logger; - idmap_verbosity = dbg_level; - IDMAP_LOG(0, ("Setting log level to %d\n", idmap_verbosity)); -} - -const char *nfsidmap_config_get(const char *section, const char *tag) -{ - return conf_get_section(section, NULL, tag); -} diff --git a/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.pc.in b/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.pc.in deleted file mode 100644 index a11dbec..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/libnfsidmap.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libnfsidmap -Description: Library that handles mapping between names and ids for NFSv4. -Requires: -Version: @PACKAGE_VERSION@ -Libs: -L@libdir@ -lnfsidmap -Cflags: -I@includedir@ diff --git a/nfs-utils-2.5.2/support/nfsidmap/libtest.c b/nfs-utils-2.5.2/support/nfsidmap/libtest.c deleted file mode 100644 index 1c717b8..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/libtest.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * libtest.c - * - * nfs idmapping library, primarily for nfs4 client/server kernel idmapping - * and for userland nfs4 idmapping by acl libraries. - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * - * libtest: Test the translation table functions - * Reads /etc/idmapd.conf - * - * To compile: - * gcc -g libtest.c -lnfsidmap -o libtest - * - */ - -#include -#include -#include -#include - -#define QUIT_ON_ERROR 1 -#define PATH_IDMAPDCONF "/etc/idmapd.conf" -char *conf_path = PATH_IDMAPDCONF; - -main(int ac, char **av) -{ - char *name, *princ; - int err, uid = 0, gid = 0; - char name_buf[32]; - int gids[1000]; - int i, ngids; - - if (ac != 3) { - printf("Usage: %s \n",av[0]); - return 1; - } - - nfs4_set_debug(3, NULL); - - name = av[1]; - princ = av[2]; - err = nfs4_init_name_mapping(NULL); - if (err) { - printf("nfs4_init_name_mapping: error %d\n", err); - return 1; - } - - err = nfs4_gss_princ_to_ids("krb5", princ, &uid, &gid); - if (err) - printf("nfs4_gss_princ_to_ids: error %d\n", err); - else - printf("nfs4_gss_princ_to_ids: princ %s has uid %d gid %d\n", - princ, uid, gid); -#if QUIT_ON_ERROR - if (err) { - printf("calling it quits!\n"); - return err; - } -#endif - - err = nfs4_name_to_uid(name, &uid); - if (err) - printf("nfs4_name_to_uid: error %d\n", err); - else - printf("nfs4_name_to_uid: name %s has uid %d\n", - name, uid); - -#if QUIT_ON_ERROR - if (err) { - printf("calling it quits!\n"); - return err; - } -#endif - err = nfs4_name_to_gid(name, &gid); - if (err) - printf("nfs4_name_to_gid: error %d\n", err); - else - printf("nfs4_name_to_gid: name %s has gid %d\n", - name, gid); - - ngids = 1000; - err = nfs4_gss_princ_to_grouplist("krb5", princ, gids, &ngids); - if (err){ - printf(" nfs4_gss_princ_to_grouplist: error %d\n", err); - } else { - printf(" nfs4_gss_princ_to_grouplist: princ %s has gids ", - princ); - for (i = 0; i < ngids; i++) printf("%d ", gids[i]); - printf("\n"); - } - -#if QUIT_ON_ERROR - if (err) { - printf("calling it quits!\n"); - return err; - } -#endif - /* uid is set by nfs4_name_to_uid() */ - memset(name_buf, 0, 32); - err = nfs4_uid_to_name(uid, NULL, name_buf, 32); - if (err) - printf("nfs4_uid_to_name: error %d\n", err); - else - printf("nfs4_uid_to_name: uid %d has name %s\n", - uid, name_buf); - -#if QUIT_ON_ERROR - if (err) { - printf("calling it quits!\n"); - return err; - } -#endif - /* gid is set by nfs4_name_to_gid() */ - memset(name_buf, 0, 32); - err = nfs4_gid_to_name(gid, NULL, name_buf, 32); - if (err) - printf("nfs4_gid_to_name: error %d\n", err); - else - printf("nfs4_gid_to_name: gid %d has name %s\n", - gid, name_buf); - -#if QUIT_ON_ERROR - if (err) { - printf("calling it quits!\n"); - return err; - } -#endif - return 0; -} diff --git a/nfs-utils-2.5.2/support/nfsidmap/nfs4_uid_to_name.3 b/nfs-utils-2.5.2/support/nfsidmap/nfs4_uid_to_name.3 deleted file mode 100644 index 8a62d8a..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nfs4_uid_to_name.3 +++ /dev/null @@ -1,174 +0,0 @@ -.TH nfs4_uid_to_name 3 2004-08-05 -.SH NAME -nfs4_uid_to_name, nfs4_gid_to_name, nfs4_name_to_uid, nfs4_name_to_gid, -nfs4_init_name_mapping, nfs4_get_default_domain, -nfs4_gss_princ_to_ids, nfs4_gss_princ_to_grouplist, -nfs4_gss_princ_to_ids_ex, -nfs4_gss_princ_to_grouplist_ex, -nfs4_set_debug \- ID mapping routines used for NFSv4 -.SH SYNOPSIS -.B #include -.sp -.BI "int nfs4_init_name_mapping(char *conffile);" -.sp -.BI "int nfs4_get_default_domain(char *server, char *domain, size_t len);" -.sp -.BI "int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len);" -.sp -.BI "int nfs4_uid_to_owner(uid_t uid, char *domain, char *name, size_t len);" -.sp -.BI "int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len);" -.sp -.BI "int nfs4_gid_to_owner(gid_t gid, char *domain, char *name, size_t len);" -.sp -.BI "int nfs4_name_to_uid(char *name, uid_t *uid);" -.sp -.BI "int nfs4_name_to_gid(char *name, gid_t *gid);" -.sp -.BI "int nfs4_owner_to_uid(char *name, uid_t *uid);" -.sp -.BI "int nfs4_owner_to_gid(char *name, gid_t *gid);" -.sp -.BI "int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid);" -.sp -.BI "int nfs4_gss_princ_to_grouplist(char *secname, char *princ, gid_t *groups, int *ngroups);" -.sp -.BI "int nfs4_gss_princ_to_ids_ex(char *secname, char *princ, uid_t *uid, gid_t *gid, extra_mapping_params **ex);" -.sp -.BI "int nfs4_gss_princ_to_grouplist_ex(char *secname, char *princ, gid_t *groups, int *ngroups, extra_mapping_params **ex);" -.sp -.BI "void nfs4_set_debug(int dbg_level, void (*logger)(const char *, ...));" -.sp -.fi -.SH DESCRIPTION -NFSv4 uses names of the form -.IR user@domain . -To write code that helps the kernel map uid's (as -rpc.idmapd -does) or that processes NFSv4 ACLs, you need to be able to convert between -NFSv4 names and local uids and gids. -.PP -The -.B nfs4_uid_to_name() -and -.B nfs4_gid_to_name() -functions, given -.I uid -or -.I gid -and -.I domain -(as a null-terminated string), -write the corresponding nfsv4 name into the buffer provided in -.IR name , -which must be of length at least -.IR len . -.PP -The -.B nfs4_uid_to_owner() -and -.B nfs4_gid_to_group_owner() -functions, given -.I uid -or -.I gid -and -.I domain -(as a null-terminated string), -write the corresponding nfsv4 name into the buffer provided in -.IR name , -which must be of length at least -.IR len . -If there is no valid mapping from -.I uid -or -.I gid -to -.IR name , -then the numerical string representing uid or gid is returned instead. -.PP -The -.B nfs4_name_to_uid() -and -.B nfs4_name_to_gid() -functions, given -.I name -(as a null-terminated string), return the corresponding uid or gid in -the second parameter. -.PP -The -.B nfs4_owner_to_uid() -and -.B nfs4_group_owner_to_gid() -functions, given -.I name -(as a null-terminated string), return the corresponding uid or gid in -the second parameter. -If there is no valid mapping from -.I name -to -.I uid -or -.I gid -the value for the user or group "nobody" will be returned instead. -. PP -The -.B nfs4_init_name_mapping() -function must be called before using any of these functions. It reads -defaults from the configuration file at the provided path, usually -"etc/idmapd.conf". -.PP -The -.I domain -argument to the id-to-name functions is there to provide a hint to the name -mapper in the case where an id might be mapped to names in multiple domains. -In most cases, this argument should just be the name returned in the -.I domain -argument to -.B nfs4_get_default_domain() -which should be called with -.I server -set to NULL. The -.I domain -should be a buffer of length -.IR len . -The constant NFS4_MAX_DOMAIN_LEN may be used to determine a reasonable -value for that length. -.PP -The function -.BR nfs4_get_grouplist() , -given a -.IR name , -fills the provided array -.I groups -with up to -.I *ngroups -group IDs corresponding to which the user -.I name -belongs to, setting -.I *ngroups -to the actual number of such groups. If the user belongs to more than -.I *ngroups -groups, then an error is returned and the actual number of groups is stored in -*ngroups. -.PP -Functions -.BR nfs4_gss_princ_to_ids() , -.BR nfs4_gss_princ_to_grouplist() , -.BR nfs4_gss_princ_to_ids_ex() , -and -.B nfs4_gss_princ_to_grouplist_ex() -are used to convert from a gss principal name (as returned by -.BR gss_display_name() ) -to a uid and gid, or list of gids. -.PP -Finally, -.B nfs4_set_debug() -allows the application to set a debugging level to produce extra -debugging information from within the library. The optional -.I logger -function specifies an alternative logging function to call for -the debug messages rather than the default internal function -within the library. -.SH RETURN VALUE -All functions return 0 or, in the case of error, -ERRNO. diff --git a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap.h b/nfs-utils-2.5.2/support/nfsidmap/nfsidmap.h deleted file mode 100644 index 5a79568..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * nfsidmap.h - * - * nfs idmapping library, primarily for nfs4 client/server kernel idmapping - * and for userland nfs4 idmapping by acl libraries. - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * J. Bruce Fields - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* XXX arbitrary */ -#define NFS4_MAX_DOMAIN_LEN 512 -typedef enum { - X509_CERT = 1 -} extra_mapping_types; - -typedef struct _extra_mapping_params { - void *content; - int content_type; - int content_len; -} extra_mapping_params; - -typedef void (*nfs4_idmap_log_function_t)(const char *, ...); - -int nfs4_init_name_mapping(char *conffile); -void nfs4_term_name_mapping(void); -int nfs4_get_default_domain(char *server, char *domain, size_t len); -int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len); -int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len); -int nfs4_uid_to_owner(uid_t uid, char *domain, char *name, size_t len); -int nfs4_gid_to_group_owner(gid_t gid, char *domain, char *name, size_t len); -int nfs4_name_to_uid(char *name, uid_t *uid); -int nfs4_name_to_gid(char *name, gid_t *gid); -int nfs4_owner_to_uid(char *name, uid_t *uid); -int nfs4_owner_to_gid(char *name, gid_t *gid); -int nfs4_group_owner_to_gid(char *name, gid_t *gid); -int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid); -int nfs4_gss_princ_to_grouplist(char *secname, char *princ, gid_t *groups, int *ngroups); -int nfs4_gss_princ_to_ids_ex(char *secname, char *princ, uid_t *uid, gid_t *gid, extra_mapping_params **ex); -int nfs4_gss_princ_to_grouplist_ex(char *secname, char *princ, gid_t *groups, int *ngroups, extra_mapping_params **ex); -void nfs4_set_debug(int dbg_level, nfs4_idmap_log_function_t dbg_logfunc); diff --git a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_common.c b/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_common.c deleted file mode 100644 index 4d2cb14..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_common.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * nfsidmap_common.c - * - * nfs idmapping library, primarily for nfs4 client/server kernel idmapping - * and for userland nfs4 idmapping by acl libraries. - * - * Code common to libnfsidmap and some of its bundled plugins - * - * If you make use of these functions you must initialise your own - * copy of the config file data using: conf_init_file(nfsidmap_conf_path) - * failure to do so will appear as if the config was empty - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "nfsidmap.h" -#include "nfsidmap_private.h" -#include "nfsidmap_plugin.h" -#include "conffile.h" - -#pragma GCC visibility push(hidden) - -static char * toupper_str(char *s) -{ - size_t i; - for (i=0; i < strlen(s); i++) - s[i] = toupper(s[i]); - return s; -} - -static struct conf_list *local_realms = NULL; - -void free_local_realms(void) -{ - if (local_realms) { - conf_free_list(local_realms); - local_realms = NULL; - } -} - -/* Get list of "local equivalent" realms. Meaning the list of realms - * where john@REALM.A is considered the same user as john@REALM.B - * If not specified, default to upper-case of local domain name */ -struct conf_list *get_local_realms(void) -{ - if (local_realms) return local_realms; - - local_realms = conf_get_list("General", "Local-Realms"); - if (local_realms == NULL) { - struct conf_list_node *node; - - local_realms = malloc(sizeof *local_realms); - if (local_realms == NULL) - return NULL; - local_realms->cnt = 0; - TAILQ_INIT(&local_realms->fields); - - node = calloc(1, sizeof *node); - if (node == NULL) - return NULL; - - node->field = calloc(1, NFS4_MAX_DOMAIN_LEN); - if (node->field == NULL) { - free(node); - return NULL; - } - - nfs4_get_default_domain(NULL, node->field, NFS4_MAX_DOMAIN_LEN); - toupper_str(node->field); - - TAILQ_INSERT_TAIL(&local_realms->fields, node, link); - local_realms->cnt++; - } - return local_realms; -} - -static int no_strip = -1; -static int reformat_group = 0; - -int get_nostrip(void) -{ - if (no_strip != -1) return no_strip; - - char * nostrip = conf_get_str_with_def("General", "No-Strip", "none"); - if (strcasecmp(nostrip, "both") == 0) - no_strip = IDTYPE_USER|IDTYPE_GROUP; - else if (strcasecmp(nostrip, "group") == 0) - no_strip = IDTYPE_GROUP; - else if (strcasecmp(nostrip, "user") == 0) - no_strip = IDTYPE_USER; - else - no_strip = 0; - - if (no_strip & IDTYPE_GROUP) { - char * reformatgroup = conf_get_str_with_def("General", "Reformat-Group", "false"); - if ((strcasecmp(reformatgroup, "true") == 0) || - (strcasecmp(reformatgroup, "on") == 0) || - (strcasecmp(reformatgroup, "yes") == 0)) - reformat_group = 1; - else - reformat_group = 0; - } - - return no_strip; -} - -int get_reformat_group(void) -{ - if (no_strip != -1) return reformat_group; - - return reformat_group; -} diff --git a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_plugin.h b/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_plugin.h deleted file mode 100644 index 66fcdaa..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_plugin.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * nfsidmap_plugin.h - * - * Essentials functions and structs required when building - * plugins for libnfsidmap that are otherwise not exposed - * in the public API - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -struct trans_func { - char *name; - int (*init)(void); - int (*princ_to_ids)(char *secname, char *princ, uid_t *uid, gid_t *gid, - extra_mapping_params **ex); - int (*name_to_uid)(char *name, uid_t *uid); - int (*name_to_gid)(char *name, gid_t *gid); - int (*uid_to_name)(uid_t uid, char *domain, char *name, size_t len); - int (*gid_to_name)(gid_t gid, char *domain, char *name, size_t len); - int (*gss_princ_to_grouplist)(char *secname, char *princ, gid_t *groups, - int *ngroups, extra_mapping_params **ex); -}; - -extern int idmap_verbosity; -extern nfs4_idmap_log_function_t idmap_log_func; -struct trans_func *libnfsidmap_plugin_init(void); - -/* Level zero always prints, others print depending on verbosity level */ -#define IDMAP_LOG(LVL, MSG) \ - do { if (LVL <= idmap_verbosity) (*idmap_log_func)MSG; } while (0) - -#ifndef UNUSED -#ifdef __GNUC__ -#define UNUSED(foo) UNUSED_ ## foo __attribute__((__unused__)) -#else -#define UNUSED(foo) UNUSED_ ## foo -#endif -#endif - -extern const char *nfsidmap_conf_path; -extern const char *nfsidmap_config_get(const char *section, const char *tag); - diff --git a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_private.h b/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_private.h deleted file mode 100644 index a5cb6dd..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nfsidmap_private.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * nfsidmap_private.h - * - * For use only by bundled plugins, not for external use - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "conffile.h" - -struct conf_list *get_local_realms(void); -void free_local_realms(void); -int get_nostrip(void); -int get_reformat_group(void); - -typedef enum { - IDTYPE_USER = 1, - IDTYPE_GROUP = 2 -} idtypes; - -typedef struct trans_func * (*libnfsidmap_plugin_init_t)(void); - -struct mapping_plugin { - void *dl_handle; - struct trans_func *trans; -}; diff --git a/nfs-utils-2.5.2/support/nfsidmap/nss.c b/nfs-utils-2.5.2/support/nfsidmap/nss.c deleted file mode 100644 index 669760b..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/nss.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * nss.c - * - * nsswitch idmapping functions. - * - * Copyright (c) 2004 The Regents of the University of Michigan. - * All rights reserved. - * - * J. Bruce Fields - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nfsidmap.h" -#include "nfsidmap_plugin.h" -#include "nfsidmap_private.h" -#include - -static char *get_default_domain(void) -{ - static char default_domain[NFS4_MAX_DOMAIN_LEN] = ""; - if (default_domain[0] == 0) { - nfs4_get_default_domain(NULL, default_domain, NFS4_MAX_DOMAIN_LEN); - } - return default_domain; -} - -/* - * NSS Translation Methods - * - * These are all just wrappers around getpwnam and friends; - * we tack on the given domain to the results of getpwnam when looking up a uid, - * and ignore the domain entirely when looking up a name. - */ - -static int write_name(char *dest, char *localname, char *domain, size_t len, - int doappend) -{ - if (doappend || !strchr(localname,'@')) { - if (strlen(localname) + 1 + strlen(domain) + 1 > len) - return -ENOMEM; /* XXX: Is there an -ETOOLONG? */ - strcpy(dest, localname); - strcat(dest, "@"); - strcat(dest, domain); - } else { - if (strlen(localname) + 1 > len) - return -ENOMEM; - strcpy(dest, localname); - } - return 0; -} - -static int nss_uid_to_name(uid_t uid, char *domain, char *name, size_t len) -{ - struct passwd *pw = NULL; - struct passwd pwbuf; - char *buf; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - int err = -ENOMEM; - - buf = malloc(buflen); - if (!buf) - goto out; - if (domain == NULL) - domain = get_default_domain(); - err = -getpwuid_r(uid, &pwbuf, buf, buflen, &pw); - if (pw == NULL) - err = -ENOENT; - if (err) - goto out_buf; - if (get_nostrip() & IDTYPE_USER) - err = write_name(name, pw->pw_name, domain, len, 0); - else - err = write_name(name, pw->pw_name, domain, len, 1); -out_buf: - free(buf); -out: - return err; -} - -static int nss_gid_to_name(gid_t gid, char *domain, char *name, size_t len) -{ - struct group *gr = NULL; - struct group grbuf; - char *buf; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - int err; - - if (domain == NULL) - domain = get_default_domain(); - - do { - err = -ENOMEM; - buf = malloc(buflen); - if (!buf) - goto out; - err = -getgrgid_r(gid, &grbuf, buf, buflen, &gr); - if (gr == NULL && !err) - err = -ENOENT; - if (err == -ERANGE) { - buflen *= 2; - free(buf); - } - } while (err == -ERANGE); - - if (err) - goto out_buf; - if (get_nostrip() & IDTYPE_GROUP) - err = write_name(name, gr->gr_name, domain, len, 0); - else - err = write_name(name, gr->gr_name, domain, len, 1); -out_buf: - free(buf); -out: - return err; -} - -/* XXX: actually should return error, so can distinguish between - * memory allocation failure and failure to match domain */ -static char *strip_domain(const char *name, const char *domain) -{ - const char *c; - char *l = NULL; - int len; - - if (name == NULL) - goto out; - - c = strrchr(name, '@'); - if (c == NULL && domain != NULL) - goto out; - if (c == NULL && domain == NULL) { - len = strlen(name) + 1; - } else { - if (domain && strcasecmp(c + 1, domain) != 0) - goto out; - len = c - name; - } - - l = malloc(len + 1); - if (l == NULL) - goto out; - memcpy(l, name, len); - l[len] = '\0'; -out: - return l; -} - -struct pwbuf { - struct passwd pwbuf; - char buf[1]; -}; - -static struct passwd *nss_getpwnam(const char *name, const char *domain, - int *err_p, int dostrip) -{ - struct passwd *pw; - struct pwbuf *buf; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - char *localname; - int err = ENOMEM; - - if (buflen > UINT_MAX) - goto err; - - buf = malloc(sizeof(*buf) + buflen); - if (buf == NULL) - goto err; - - err = EINVAL; - if (dostrip) { - localname = strip_domain(name, domain); - IDMAP_LOG(4, ("nss_getpwnam: name '%s' domain '%s': " - "resulting localname '%s'", name, domain, localname)); - if (localname == NULL) { - IDMAP_LOG(0, ("nss_getpwnam: name '%s' does not map " - "into domain '%s'", name, - domain ? domain : "")); - goto err_free_buf; - } - - err = getpwnam_r(localname, &buf->pwbuf, buf->buf, buflen, &pw); - if (pw == NULL && domain != NULL) - IDMAP_LOG(1, - ("nss_getpwnam: name '%s' not found in domain '%s'", - localname, domain)); - free(localname); - } else { - err = getpwnam_r(name, &buf->pwbuf, buf->buf, buflen, &pw); - if (pw == NULL) - IDMAP_LOG(1, - ("nss_getpwnam: name '%s' not found (domain not stripped)", name)); - } - if (err == 0 && pw != NULL) { - *err_p = 0; - return pw; - } else if (err == 0 && pw == NULL) { - err = ENOENT; - } - -err_free_buf: - free(buf); -err: - *err_p = -err; - return NULL; -} - -static int nss_name_to_uid(char *name, uid_t *uid) -{ - struct passwd *pw = NULL; - char *domain; - int err = -ENOENT; - - domain = get_default_domain(); - if (get_nostrip() & IDTYPE_USER) { - pw = nss_getpwnam(name, domain, &err, 0); - if (pw != NULL) - goto out_uid; - } - pw = nss_getpwnam(name, domain, &err, 1); - if (pw == NULL) - goto out; -out_uid: - *uid = pw->pw_uid; - IDMAP_LOG(4, ("nss_name_to_uid: name '%s' uid %u", name, *uid)); - free(pw); - err = 0; -out: - return err; -} - -static char *reformat_name(const char *name) -{ - const char *domain; - const char *c; - const char *d; - char *l = NULL; - int len; - int dlen = 0; - int i; - - c = strchr(name, '@'); - if (c == NULL) - goto out; - len = c - name; - domain = ++c; - d = strchr(domain, '.'); - if (d == NULL) - goto out; - dlen = d - domain; - l = malloc(dlen + 1 + len + 1); - if (l == NULL) - goto out; - for (i = 0; i < dlen; i++) - l[i] = toupper(domain[i]); - l[dlen] = '\\'; - memcpy(l + dlen + 1, name, len); - l[dlen + 1 + len] = '\0'; -out: - return l; -} - -static int _nss_name_to_gid(char *name, gid_t *gid, int dostrip) -{ - struct group *gr = NULL; - struct group grbuf; - char *buf, *domain; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - int err = -EINVAL; - char *localname = NULL; - char *ref_name = NULL; - - domain = get_default_domain(); - if (dostrip) { - localname = strip_domain(name, domain); - IDMAP_LOG(4, ("nss_name_to_gid: name '%s' domain '%s': " - "resulting localname '%s'", name, domain, localname)); - if (!localname) { - IDMAP_LOG(0, ("nss_name_to_gid: name '%s' does not map " - "into domain '%s'", name, domain)); - goto out; - } - } else if (get_reformat_group()) { - ref_name = reformat_name(name); - if (ref_name == NULL) { - IDMAP_LOG(1, ("nss_name_to_gid: failed to reformat name '%s'", - name)); - err = -ENOENT; - goto out; - } - } - - err = -ENOMEM; - if (buflen > UINT_MAX) - goto out_name; - - do { - buf = malloc(buflen); - if (!buf) - goto out_name; - if (dostrip) - err = -getgrnam_r(localname, &grbuf, buf, buflen, &gr); - else if (get_reformat_group()) - err = -getgrnam_r(ref_name, &grbuf, buf, buflen, &gr); - else - err = -getgrnam_r(name, &grbuf, buf, buflen, &gr); - if (gr == NULL && !err) { - if (dostrip) - IDMAP_LOG(1, ("nss_name_to_gid: name '%s' not found " - "in domain '%s'", localname, domain)); - else if (get_reformat_group()) - IDMAP_LOG(1, ("nss_name_to_gid: name '%s' not found " - "(reformatted)", ref_name)); - else - IDMAP_LOG(1, ("nss_name_to_gid: name '%s' not found " - "(domain not stripped)", name)); - err = -ENOENT; - } - if (err == -ERANGE) { - buflen *= 2; - free(buf); - } - } while (err == -ERANGE); - - if (err) - goto out_buf; - *gid = gr->gr_gid; - IDMAP_LOG(4, ("nss_name_to_gid: name '%s' gid %u", name, *gid)); -out_buf: - free(buf); -out_name: - if (dostrip) - free(localname); - if (get_reformat_group()) - free(ref_name); -out: - return err; -} - -static int nss_name_to_gid(char *name, gid_t *gid) -{ - int err = 0; - - if (get_nostrip() & IDTYPE_GROUP) { - err = _nss_name_to_gid(name, gid, 0); - if (!err) - goto out; - } - err = _nss_name_to_gid(name, gid, 1); -out: - return err; -} - -static int nss_gss_princ_to_ids(char *secname, char *princ, - uid_t *uid, uid_t *gid, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int err = 0; - char *princ_realm; - struct conf_list *realms; - struct conf_list_node *r; - int found = 0; - - if (strcmp(secname, "spkm3") == 0) - return -ENOENT; - - if (strcmp(secname, "krb5") != 0) - return -EINVAL; - - /* get princ's realm */ - princ_realm = strstr(princ, "@"); - if (princ_realm == NULL) - return -EINVAL; - princ_realm++; - - /* get list of "local-equivalent" realms and - * check against the principal's realm */ - realms = get_local_realms(); - TAILQ_FOREACH(r, &realms->fields, link) { - if (strcmp(r->field, princ_realm) == 0) { - found = 1; - break; - } - } - if (!found) { - IDMAP_LOG(1, ("nss_gss_princ_to_ids: Local-Realm '%s': NOT FOUND", - princ_realm)); - return -ENOENT; - } - /* XXX: this should call something like getgssauthnam instead? */ - pw = nss_getpwnam(princ, NULL, &err, 1); - if (pw == NULL) { - err = -ENOENT; - goto out; - } - *uid = pw->pw_uid; - *gid = pw->pw_gid; - free(pw); -out: - return err; -} - -static int nss_gss_princ_to_grouplist(char *secname, char *princ, - gid_t *groups, int *ngroups, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int ret = -EINVAL; - - if (strcmp(secname, "krb5") != 0) - goto out; - /* XXX: not quite right? Need to know default realm? */ - /* XXX: this should call something like getgssauthnam instead? */ - pw = nss_getpwnam(princ, NULL, &ret, 1); - if (pw == NULL) { - ret = -ENOENT; - goto out; - } - if (getgrouplist(pw->pw_name, pw->pw_gid, groups, ngroups) < 0) - ret = -ERANGE; - free(pw); -out: - return ret; -} - -static int nss_plugin_init(void) -{ - if (nfsidmap_conf_path) - conf_init_file(nfsidmap_conf_path); - return 0; -} - -/* - * Called by dlclose(). See dlopen(3) man page - */ -__attribute__((destructor)) -static int nss_plugin_term(void) -{ - free_local_realms(); - conf_cleanup(); - return 0; -} - - -struct trans_func nss_trans = { - .name = "nsswitch", - .init = nss_plugin_init, - .princ_to_ids = nss_gss_princ_to_ids, - .name_to_uid = nss_name_to_uid, - .name_to_gid = nss_name_to_gid, - .uid_to_name = nss_uid_to_name, - .gid_to_name = nss_gid_to_name, - .gss_princ_to_grouplist = nss_gss_princ_to_grouplist, -}; - -struct trans_func *libnfsidmap_plugin_init(void) -{ - return (&nss_trans); -} diff --git a/nfs-utils-2.5.2/support/nfsidmap/regex.c b/nfs-utils-2.5.2/support/nfsidmap/regex.c deleted file mode 100644 index fdbb2e2..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/regex.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * regex.c - * - * regex idmapping functions. - * - * Copyright (c) 2017-2020 Stefan Walter . - * Copyright (c) 2008 David H?rdeman . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfsidmap.h" -#include "nfsidmap_plugin.h" - -#define CONFIG_GET_STRING nfsidmap_config_get -extern const char *nfsidmap_config_get(const char *, const char *); - -#define MAX_MATCHES 100 - -regex_t group_re; -regex_t user_re; -regex_t gpx_re; -int use_gpx; -const char * group_prefix; -const char * group_name_prefix; -const char * group_suffix; -const char * user_prefix; -const char * user_suffix; -const char * group_map_file; -const char * group_map_section; -char empty = '\0'; -size_t group_name_prefix_length; - -struct pwbuf { - struct passwd pwbuf; - char buf[1]; -}; - -struct grbuf { - struct group grbuf; - char buf[1]; -}; - -static char *get_default_domain(void) -{ - static char default_domain[NFS4_MAX_DOMAIN_LEN] = ""; - if (default_domain[0] == 0) { - nfs4_get_default_domain(NULL, default_domain, NFS4_MAX_DOMAIN_LEN); - } - return default_domain; -} - -/* - * Regexp Translation Methods - * - */ - -static struct passwd *regex_getpwnam(const char *name, const char *UNUSED(domain), - int *err_p) -{ - struct passwd *pw; - struct pwbuf *buf; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - char *localname; - size_t namelen; - int err; - int status; - int index; - regmatch_t matches[MAX_MATCHES]; - - buf = malloc(sizeof(*buf) + buflen); - if (!buf) { - err = ENOMEM; - goto err; - } - - status = regexec(&user_re, name, MAX_MATCHES, matches, 0); - if (status) { - IDMAP_LOG(4, ("regexp_getpwnam: user '%s' did not match regex", name)); - err = ENOENT; - goto err_free_buf; - } - - for (index = 1; index < MAX_MATCHES ; index++) - { - if (matches[index].rm_so >= 0) - break; - } - - if (index == MAX_MATCHES) { - IDMAP_LOG(4, ("regexp_getpwnam: user '%s' did not match regex", name)); - err = ENOENT; - goto err_free_buf; - } - - namelen = matches[index].rm_eo - matches[index].rm_so; - localname= malloc(namelen + 1); - if (!localname) - { - err = ENOMEM; - goto err_free_buf; - } - strncpy(localname, name+matches[index].rm_so, namelen); - localname[namelen] = '\0'; - -again: - err = getpwnam_r(localname, &buf->pwbuf, buf->buf, buflen, &pw); - - if (err == EINTR) - goto again; - - if (!pw) { - if (err == 0) - err = ENOENT; - - IDMAP_LOG(4, ("regex_getpwnam: local user '%s' for '%s' not found", - localname, name)); - - goto err_free_name; - } - - IDMAP_LOG(4, ("regexp_getpwnam: name '%s' mapped to '%s'", - name, localname)); - - *err_p = 0; - return pw; - -err_free_name: - free(localname); -err_free_buf: - free(buf); -err: - *err_p = err; - return NULL; -} - -static struct group *regex_getgrnam(const char *name, const char *UNUSED(domain), - int *err_p) -{ - struct group *gr; - struct grbuf *buf; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - char *localgroup; - char *groupname; - size_t namelen; - int err = 0; - int index; - int status; - regmatch_t matches[MAX_MATCHES]; - - buf = malloc(sizeof(*buf) + buflen); - if (!buf) { - err = ENOMEM; - goto err; - } - - status = regexec(&group_re, name, MAX_MATCHES, matches, 0); - if (status) { - IDMAP_LOG(4, ("regexp_getgrnam: group '%s' did not match regex", name)); - err = ENOENT; - goto err_free_buf; - } - - for (index = 1; index < MAX_MATCHES ; index++) - { - if (matches[index].rm_so >= 0) - break; - } - - if (index == MAX_MATCHES) { - IDMAP_LOG(4, ("regexp_getgrnam: group '%s' did not match regex", name)); - err = ENOENT; - goto err_free_buf; - } - - namelen = matches[index].rm_eo - matches[index].rm_so; - localgroup = malloc(namelen + 1); - if (!localgroup) - { - err = ENOMEM; - goto err_free_buf; - } - strncpy(localgroup, name+matches[index].rm_so, namelen); - localgroup[namelen] = '\0'; - - IDMAP_LOG(4, ("regexp_getgrnam: group '%s' after match of regex", localgroup)); - - groupname = localgroup; - if (group_name_prefix_length && ! strncmp(group_name_prefix, localgroup, group_name_prefix_length)) - { - err = 1; - if (use_gpx) - err = regexec(&gpx_re, localgroup, 0, NULL, 0); - - if (err) - { - IDMAP_LOG(4, ("regexp_getgrnam: removing prefix '%s' (%d long) from group '%s'", group_name_prefix, group_name_prefix_length, localgroup)); - groupname += group_name_prefix_length; - } - else - { - IDMAP_LOG(4, ("regexp_getgrnam: not removing prefix from group '%s'", localgroup)); - } - } - - IDMAP_LOG(4, ("regexp_getgrnam: will use '%s'", groupname)); - -again: - err = getgrnam_r(groupname, &buf->grbuf, buf->buf, buflen, &gr); - - if (err == EINTR) - goto again; - - if (!gr) { - if (err == 0) - err = ENOENT; - - IDMAP_LOG(4, ("regex_getgrnam: local group '%s' for '%s' not found", groupname, name)); - - goto err_free_name; - } - - IDMAP_LOG(4, ("regex_getgrnam: group '%s' mapped to '%s'", name, groupname)); - - free(localgroup); - - *err_p = 0; - return gr; - -err_free_name: - free(localgroup); -err_free_buf: - free(buf); -err: - *err_p = err; - return NULL; -} - -static int regex_gss_princ_to_ids(char *secname, char *princ, - uid_t *uid, uid_t *gid, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int err; - - /* XXX: Is this necessary? */ - if (strcmp(secname, "krb5") != 0 && strcmp(secname, "spkm3") != 0) - return -EINVAL; - - pw = regex_getpwnam(princ, NULL, &err); - - if (pw) { - *uid = pw->pw_uid; - *gid = pw->pw_gid; - free(pw); - } - - return -err; -} - -static int regex_gss_princ_to_grouplist(char *secname, char *princ, - gid_t *groups, int *ngroups, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int err; - - /* XXX: Is this necessary? */ - if (strcmp(secname, "krb5") != 0 && strcmp(secname, "spkm3") != 0) - return -EINVAL; - - pw = regex_getpwnam(princ, NULL, &err); - - if (pw) { - if (getgrouplist(pw->pw_name, pw->pw_gid, groups, ngroups) < 0) - err = -ERANGE; - free(pw); - } - - return -err; -} - -static int regex_name_to_uid(char *name, uid_t *uid) -{ - struct passwd *pw; - int err; - - pw = regex_getpwnam(name, NULL, &err); - - if (pw) { - *uid = pw->pw_uid; - free(pw); - } - - return -err; -} - -static int regex_name_to_gid(char *name, gid_t *gid) -{ - struct group *gr; - int err; - - gr = regex_getgrnam(name, NULL, &err); - - if (gr) { - *gid = gr->gr_gid; - free(gr); - } - - return -err; -} - -static int write_name(char *dest, char *localname, const char* name_prefix, const char *prefix, const char *suffix, size_t len) -{ - if (strlen(localname) + strlen(name_prefix) + strlen(prefix) + strlen(suffix) + 1 > len) { - return -ENOMEM; /* XXX: Is there an -ETOOLONG? */ - } - strcpy(dest, prefix); - strcat(dest, name_prefix); - strcat(dest, localname); - strcat(dest, suffix); - - IDMAP_LOG(4, ("write_name: will use '%s'", dest)); - - return 0; -} - -static int regex_uid_to_name(uid_t uid, char *domain, char *name, size_t len) -{ - struct passwd *pw = NULL; - struct passwd pwbuf; - char *buf; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - int err = -ENOMEM; - - buf = malloc(buflen); - if (!buf) - goto out; - if (domain == NULL) - domain = get_default_domain(); - err = -getpwuid_r(uid, &pwbuf, buf, buflen, &pw); - if (pw == NULL) - err = -ENOENT; - if (err) - goto out_buf; - err = write_name(name, pw->pw_name, &empty, user_prefix, user_suffix, len); -out_buf: - free(buf); -out: - return err; -} - -static int regex_gid_to_name(gid_t gid, char *UNUSED(domain), char *name, size_t len) -{ - struct group *gr = NULL; - struct group grbuf; - char *buf; - const char *name_prefix; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - int err; - char * groupname = NULL; - - do { - err = -ENOMEM; - buf = malloc(buflen); - if (!buf) - goto out; - err = -getgrgid_r(gid, &grbuf, buf, buflen, &gr); - if (gr == NULL && !err) - err = -ENOENT; - if (err == -ERANGE) { - buflen *= 2; - free(buf); - } - } while (err == -ERANGE); - - if (err) - goto out_buf; - - groupname = gr->gr_name; - name_prefix = group_name_prefix; - if (group_name_prefix_length) - { - if(! strncmp(group_name_prefix, groupname, group_name_prefix_length)) - { - name_prefix = ∅ - } - else if (use_gpx) - { - err = regexec(&gpx_re, groupname, 0, NULL, 0); - if (!err) - { - IDMAP_LOG(4, ("regex_gid_to_name: not adding prefix to group '%s'", groupname)); - name_prefix = ∅ - } - } - } - - err = write_name(name, groupname, name_prefix, group_prefix, group_suffix, len); - -out_buf: - free(buf); -out: - return err; -} - -static int regex_init(void) { - const char *string; - int status; - - - string = CONFIG_GET_STRING("Regex", "User-Regex"); - if (!string) - { - warnx("regex_init: regex for user mapping missing"); - goto error1; - } - - status = regcomp(&user_re, string, REG_EXTENDED|REG_ICASE); - if (status) - { - warnx("regex_init: compiling regex for user mapping failed with status %u", status); - goto error1; - } - - string = CONFIG_GET_STRING("Regex", "Group-Regex"); - if (!string) - { - warnx("regex_init: regex for group mapping missing"); - goto error2; - } - - status = regcomp(&group_re, string, REG_EXTENDED|REG_ICASE); - if (status) - { - warnx("regex_init: compiling regex for group mapping failed with status %u", status); - goto error2; - } - - group_name_prefix = CONFIG_GET_STRING("Regex", "Group-Name-Prefix"); - if (!group_name_prefix) - { - group_name_prefix = ∅ - } - group_name_prefix_length = strlen(group_name_prefix); - - user_prefix = CONFIG_GET_STRING("Regex", "Prepend-Before-User"); - if (!user_prefix) - { - user_prefix = ∅ - } - - user_suffix = CONFIG_GET_STRING("Regex", "Append-After-User"); - if (!user_suffix) - { - user_suffix = ∅ - } - - group_prefix = CONFIG_GET_STRING("Regex", "Prepend-Before-Group"); - if (!group_prefix) - { - group_prefix = ∅ - } - - group_suffix = CONFIG_GET_STRING("Regex", "Append-After-Group"); - if (!group_suffix) - { - group_suffix = ∅ - } - - string = CONFIG_GET_STRING("Regex", "Group-Name-No-Prefix-Regex"); - use_gpx = 0; - if (string) - { - status = regcomp(&gpx_re, string, REG_EXTENDED|REG_ICASE); - - if (status) - { - warnx("regex_init: compiling regex for group prefix exclusion failed with status %u", status); - goto error3; - } - - use_gpx = 1; - } - - return 0; - -error3: - regfree(&group_re); -error2: - regfree(&user_re); -error1: - return 0; - /* return -EINVAL; */ -} - - -struct trans_func regex_trans = { - .name = "regex", - .init = regex_init, - .name_to_uid = regex_name_to_uid, - .name_to_gid = regex_name_to_gid, - .uid_to_name = regex_uid_to_name, - .gid_to_name = regex_gid_to_name, - .princ_to_ids = regex_gss_princ_to_ids, - .gss_princ_to_grouplist = regex_gss_princ_to_grouplist, -}; - -struct trans_func *libnfsidmap_plugin_init() -{ - return (®ex_trans); -} - diff --git a/nfs-utils-2.5.2/support/nfsidmap/static.c b/nfs-utils-2.5.2/support/nfsidmap/static.c deleted file mode 100644 index 8ac4a39..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/static.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * static.c - * - * static idmapping functions for gss principals. - * - * Copyright (c) 2008 David Härdeman . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "nfsidmap.h" -#include "nfsidmap_plugin.h" - -/* - * Static Translation Methods - * - * These functions use getpwnam to find uid/gid(s) for gss principals - * which are first mapped to local user names using static mappings - * in idmapd.conf. - */ - -struct pwbuf { - struct passwd pwbuf; - char buf[1]; -}; - -struct grbuf { - struct group grbuf; - char buf[1]; -}; - -struct uid_mapping { - LIST_ENTRY (uid_mapping) link; - uid_t uid; - char * principal; - char * localname; -}; - -struct gid_mapping { - LIST_ENTRY (gid_mapping) link; - gid_t gid; - char * principal; - char * localgroup; -}; - -static __inline__ u_int8_t uid_hash (uid_t uid) -{ - return uid % 256; -} - -static __inline__ u_int8_t gid_hash (gid_t gid) -{ - return gid % 256; -} - -//Hash tables of uid and guids to principals mappings. -//We reuse some queue/hash functions from cfg.c. -LIST_HEAD (uid_mappings, uid_mapping) uid_mappings[256]; -LIST_HEAD (gid_mappings, gid_mapping) gid_mappings[256]; - -static struct passwd *static_getpwnam(const char *name, - const char *UNUSED(domain), - int *err_p) -{ - struct passwd *pw; - struct pwbuf *buf; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - char *localname; - int err; - - buf = malloc(sizeof(*buf) + buflen); - if (!buf) { - err = ENOMEM; - goto err; - } - - localname = conf_get_str("Static", (char *)name); - if (!localname) { - err = ENOENT; - goto err_free_buf; - } - -again: - err = getpwnam_r(localname, &buf->pwbuf, buf->buf, buflen, &pw); - - if (err == EINTR) - goto again; - - if (!pw) { - if (err == 0) - err = ENOENT; - - IDMAP_LOG(0, ("static_getpwnam: localname '%s' for '%s' not found", - localname, name)); - - goto err_free_buf; - } - - IDMAP_LOG(4, ("static_getpwnam: name '%s' mapped to '%s'", - name, localname)); - - *err_p = 0; - return pw; - -err_free_buf: - free(buf); -err: - *err_p = err; - return NULL; -} - -static struct group *static_getgrnam(const char *name, - const char *UNUSED(domain), - int *err_p) -{ - struct group *gr; - struct grbuf *buf; - size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); - char *localgroup; - int err; - - buf = malloc(sizeof(*buf) + buflen); - if (!buf) { - err = ENOMEM; - goto err; - } - - localgroup = conf_get_str("Static", (char *)name); - if (!localgroup) { - err = ENOENT; - goto err_free_buf; - } - -again: - err = getgrnam_r(localgroup, &buf->grbuf, buf->buf, buflen, &gr); - - if (err == EINTR) - goto again; - - if (!gr) { - if (err == 0) - err = ENOENT; - - IDMAP_LOG(0, ("static_getgrnam: local group '%s' for '%s' not found", - localgroup, name)); - - goto err_free_buf; - } - - IDMAP_LOG(4, ("static_getgrnam: group '%s' mapped to '%s'", - name, localgroup)); - - *err_p = 0; - return gr; - -err_free_buf: - free(buf); -err: - *err_p = err; - return NULL; -} - -static int static_gss_princ_to_ids(char *secname, char *princ, - uid_t *uid, uid_t *gid, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int err; - - /* XXX: Is this necessary? */ - if (strcmp(secname, "krb5") != 0 && strcmp(secname, "spkm3") != 0) - return -EINVAL; - - pw = static_getpwnam(princ, NULL, &err); - - if (pw) { - *uid = pw->pw_uid; - *gid = pw->pw_gid; - free(pw); - } - - return -err; -} - -static int static_gss_princ_to_grouplist(char *secname, char *princ, - gid_t *groups, int *ngroups, - extra_mapping_params **UNUSED(ex)) -{ - struct passwd *pw; - int err; - - /* XXX: Is this necessary? */ - if (strcmp(secname, "krb5") != 0 && strcmp(secname, "spkm3") != 0) - return -EINVAL; - - pw = static_getpwnam(princ, NULL, &err); - - if (pw) { - if (getgrouplist(pw->pw_name, pw->pw_gid, groups, ngroups) < 0) - err = -ERANGE; - free(pw); - } - - return -err; -} - -static int static_name_to_uid(char *name, uid_t *uid) -{ - struct passwd *pw; - int err; - - pw = static_getpwnam(name, NULL, &err); - - if (pw) { - *uid = pw->pw_uid; - free(pw); - } - - return -err; -} - -static int static_name_to_gid(char *name, gid_t *gid) -{ - struct group *gr; - int err; - - gr = static_getgrnam(name, NULL, &err); - - if (gr) { - *gid = gr->gr_gid; - free(gr); - } - - return -err; -} - -static int static_uid_to_name(uid_t uid, char *UNUSED(domain), char *name, size_t UNUSED(len)) -{ - struct uid_mapping * um; - - for (um = LIST_FIRST (&uid_mappings[uid_hash (uid)]); um; - um = LIST_NEXT (um, link)) { - if (um->uid == uid) { - strcpy(name, um->principal); - return 0; - } - } - - return -ENOENT; -} - -static int static_gid_to_name(gid_t gid, char *UNUSED(domain), char *name, size_t UNUSED(len)) -{ - struct gid_mapping * gm; - - for (gm = LIST_FIRST (&gid_mappings[gid_hash (gid)]); gm; - gm = LIST_NEXT (gm, link)) { - if (gm->gid == gid) { - strcpy(name, gm->principal); - return 0; - } - } - - return -ENOENT; -} - -/* - * We buffer all UID's for which static mappings is defined in advance, so the - * uid_to_name functions will be fast enough. - */ - -static int static_init(void) { - int err; - struct conf_list * princ_list = NULL; - struct conf_list_node * cln, *next; - struct uid_mapping * unode; - struct gid_mapping * gnode; - struct passwd * pw = NULL; - struct group * gr = NULL; - unsigned int i; - - //init hash_table first - for (i = 0; i < sizeof uid_mappings / sizeof uid_mappings[0]; i++) - LIST_INIT (&uid_mappings[i]); - - if (nfsidmap_conf_path) - conf_init_file(nfsidmap_conf_path); - - //get all principals for which we have mappings - princ_list = conf_get_tag_list("Static", NULL); - - if (!princ_list) { - return -ENOENT; - } - - /* As we can not distinguish between mappings for users and groups, we try to - * resolve all mappings for both cases. - */ - - //resolve uid of localname account for all such principals and cache it - for (cln = TAILQ_FIRST (&princ_list->fields); cln; cln = next) - { - next = TAILQ_NEXT (cln, link); - - pw = static_getpwnam(cln->field, NULL, &err); - if (!pw) { - continue; - } - - unode = calloc (1, sizeof *unode); - if (!unode) - { - warnx("static_init: calloc (1, %lu) failed", - (unsigned long)sizeof *unode); - free(pw); - conf_free_list(princ_list); - return -ENOMEM; - } - unode->uid = pw->pw_uid; - unode->principal = strdup(cln->field); - - unode->localname = conf_get_str("Static", cln->field); - if (!unode->localname) { - free(pw); - free(unode->principal); - free(unode); - conf_free_list(princ_list); - return -ENOENT; - } - - free(pw); - - LIST_INSERT_HEAD (&uid_mappings[uid_hash(unode->uid)], unode, link); - } - - //resolve gid of localgroup accounts and cache it - for (cln = TAILQ_FIRST (&princ_list->fields); cln; cln = next) - { - next = TAILQ_NEXT (cln, link); - - gr = static_getgrnam(cln->field, NULL, &err); - if (!gr) { - continue; - } - - gnode = calloc (1, sizeof *gnode); - if (!gnode) - { - warnx("static_init: calloc (1, %lu) failed", - (unsigned long)sizeof *gnode); - free(gr); - conf_free_list(princ_list); - return -ENOMEM; - } - gnode->gid = gr->gr_gid; - gnode->principal = strdup(cln->field); - - gnode->localgroup = conf_get_str("Static", cln->field); - if (!gnode->localgroup) { - free(gr); - free(gnode->principal); - free(gnode); - conf_free_list(princ_list); - return -ENOENT; - } - - free(gr); - - LIST_INSERT_HEAD (&gid_mappings[gid_hash(gnode->gid)], gnode, link); - } - - conf_free_list(princ_list); - return 0; -} - - -struct trans_func static_trans = { - .name = "static", - .init = static_init, - .name_to_uid = static_name_to_uid, - .name_to_gid = static_name_to_gid, - .uid_to_name = static_uid_to_name, - .gid_to_name = static_gid_to_name, - .princ_to_ids = static_gss_princ_to_ids, - .gss_princ_to_grouplist = static_gss_princ_to_grouplist, -}; - -struct trans_func *libnfsidmap_plugin_init(void) -{ - return (&static_trans); -} - diff --git a/nfs-utils-2.5.2/support/nfsidmap/umich_ldap.c b/nfs-utils-2.5.2/support/nfsidmap/umich_ldap.c deleted file mode 100644 index 1aa2af4..0000000 --- a/nfs-utils-2.5.2/support/nfsidmap/umich_ldap.c +++ /dev/null @@ -1,1615 +0,0 @@ -/* - * umich_ldap.c - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Copyright (c) 2004 Andy Adamson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_GSSAPI_GSSAPI_KRB5_H -#include -#endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */ -#ifdef HAVE_SASL_H -#include -#endif /* HAVE_SASL_H */ -#ifdef HAVE_SASL_SASL_H -#include -#endif /* HAVE_SASL_SASL_H */ -/* We are using deprecated functions, get the prototypes... */ -#define LDAP_DEPRECATED 1 -#include -#include "nfslib.h" -#include "nfsidmap.h" -#include "nfsidmap_plugin.h" -#include "nfsidmap_private.h" -#include "conffile.h" - -/* attribute/objectclass default mappings */ -#define DEFAULT_UMICH_OBJCLASS_REMOTE_PERSON "NFSv4RemotePerson" -#define DEFAULT_UMICH_OBJCLASS_REMOTE_GROUP "NFSv4RemoteGroup" -#define DEFAULT_UMICH_ATTR_NFSNAME "NFSv4Name" -#define DEFAULT_UMICH_ATTR_ACCTNAME "uid" -#define DEFAULT_UMICH_ATTR_UIDNUMBER "uidNumber" -#define DEFAULT_UMICH_ATTR_GROUP_NFSNAME "NFSv4Name" -#define DEFAULT_UMICH_ATTR_GIDNUMBER "gidNumber" -#define DEFAULT_UMICH_ATTR_MEMBERUID "memberUid" -#define DEFAULT_UMICH_ATTR_GSSAUTHNAME "GSSAuthName" -#define DEFAULT_UMICH_ATTR_MEMBEROF "memberof" - -#define DEFAULT_UMICH_SEARCH_TIMEOUT 4 - -/* config section */ -#define LDAP_SECTION "UMICH_SCHEMA" - -#ifndef LDAP_FILT_MAXSIZ -#define LDAP_FILT_MAXSIZ 1024 -#endif - - -/* Local structure definitions */ - -struct ldap_map_names{ - char *NFSv4_person_objcls; - char *NFSv4_nfsname_attr; - char *NFSv4_acctname_attr; - char *NFSv4_uid_attr; - char *NFSv4_group_objcls; - char *NFSv4_group_nfsname_attr; - char *NFSv4_gid_attr; - char *NFSv4_member_attr; - char *NFSv4_member_of_attr; - char *GSS_principal_attr; - char *NFSv4_grouplist_filter; /* Filter for grouplist lookups */ -}; - -struct umich_ldap_info { - char *server; /* server name/address */ - int port; /* server port */ - char *base; /* base DN */ - char *people_tree; /* base DN to start searches for people */ - char *group_tree; /* base DN to start searches for groups */ - char *user_dn; /* optional DN for user account when binding */ - char *passwd; /* Password to use when binding to directory */ - int use_ssl; /* SSL flag */ - char *ca_cert; /* File location of the ca_cert */ - int tls_reqcert; /* req and validate server cert */ - int memberof_for_groups;/* Use 'memberof' attribute when - looking up user groups */ - int ldap_timeout; /* Timeout in seconds for searches - by ldap_search_st */ - int follow_referrals; /* whether to follow ldap referrals */ - char *sasl_mech; /* sasl mech to be used */ - char *sasl_realm; /* SASL realm for SASL authentication */ - char *sasl_authcid; /* authentication identity to be used */ - char *sasl_authzid; /* authorization identity to be used */ - char *sasl_secprops; /* Cyrus SASL security properties. */ - int sasl_canonicalize; /* canonicalize LDAP server host name */ - char *sasl_krb5_ccname; /* krb5 ticket cache */ -}; - -/* GLOBAL data */ - -static struct umich_ldap_info ldap_info = { - .server = NULL, - .port = 0, - .base = NULL, - .people_tree = NULL, - .group_tree = NULL, - .user_dn = NULL, - .passwd = NULL, - .use_ssl = 0, - .ca_cert = NULL, - .tls_reqcert = LDAP_OPT_X_TLS_HARD, - .memberof_for_groups = 0, - .ldap_timeout = DEFAULT_UMICH_SEARCH_TIMEOUT, - .follow_referrals = 1, - .sasl_mech = NULL, - .sasl_realm = NULL, - .sasl_authcid = NULL, - .sasl_authzid = NULL, - .sasl_secprops = NULL, - .sasl_canonicalize = -1, /* leave to the LDAP lib */ - .sasl_krb5_ccname = NULL, -}; - -static struct ldap_map_names ldap_map = { - .NFSv4_person_objcls = NULL, - .NFSv4_nfsname_attr = NULL, - .NFSv4_uid_attr = NULL, - .NFSv4_acctname_attr = NULL, - .NFSv4_group_objcls = NULL, - .NFSv4_group_nfsname_attr = NULL, - .NFSv4_gid_attr = NULL, - .NFSv4_member_attr = NULL, - .NFSv4_member_of_attr = NULL, - .GSS_principal_attr = NULL, - .NFSv4_grouplist_filter = NULL, -}; - -#ifdef ENABLE_LDAP_SASL - -/** - * Set the path of the krb5 ticket cache - * use gss_krb5_ccache_name if available else set the env var - */ -static int set_krb5_ccname(const char *krb5_ccache_name) -{ - int retval = 0; -#ifdef HAVE_GSS_KRB5_CCACHE_NAME - OM_uint32 status; - - if (gss_krb5_ccache_name(&status, krb5_ccache_name, NULL) != - GSS_S_COMPLETE) { - IDMAP_LOG(5, - ("Failed to set creds cache for kerberos, minor_status(%d)", - status)); - retval = status; - goto out; - } -#else /* HAVE_GSS_KRB5_CCACHE_NAME */ - char *env; - int buflen = 0; - - buflen = strlen("KRB5CCNAME=") + strlen(krb5_ccache_name) + 1; - env = malloc(buflen); - if (env == NULL) { - retval = ENOMEM; - goto out; - } - snprintf(env, buflen, "KRB5CCNAME=%s", krb5_ccache_name); - if (putenv(env) != 0) { - retval = errno; - IDMAP_LOG(5, ("Failed to set creds cache for kerberos, err(%d)", - retval)); - } -#endif /* else HAVE_GSS_KRB5_CCACHE_NAME */ -out: - return retval; -} - -/** - * SASL interact callback - */ -static int sasl_interact_cb(__attribute__((unused)) LDAP * ld, - __attribute__((unused)) unsigned int flags, void *defaults, - void *ctx) -{ - struct umich_ldap_info *linfo = defaults; - sasl_interact_t *interact = ctx; - - while (interact->id != SASL_CB_LIST_END) { - switch (interact->id) { - case SASL_CB_AUTHNAME: - if (linfo->sasl_authcid == NULL || - linfo->sasl_authcid[0] == '\0') { - IDMAP_LOG(2, ("SASL_CB_AUTHNAME asked in " - "callback but not found in conf")); - } else { - IDMAP_LOG(5, - ("Setting SASL_CB_AUTHNAME to %s", - linfo->sasl_authcid)); - interact->result = linfo->sasl_authcid; - interact->len = strlen(linfo->sasl_authcid); - } - break; - case SASL_CB_PASS: - if (linfo->passwd == NULL || linfo->passwd[0] == '\0') { - IDMAP_LOG(2, ("SASL_CB_PASS asked in callback " - "but not found in conf")); - } else { - IDMAP_LOG(5, - ("Setting SASL_CB_PASS to ***")); - interact->result = linfo->passwd; - interact->len = strlen(linfo->passwd); - } - break; - case SASL_CB_GETREALM: - if (linfo->sasl_realm == NULL || - linfo->sasl_realm[0] == '\0') { - IDMAP_LOG(2, ("SASL_CB_GETREALM asked in " - "callback but not found in conf")); - } else { - IDMAP_LOG(5, - ("Setting SASL_CB_GETREALM to %s", - linfo->sasl_realm)); - interact->result = linfo->sasl_realm; - interact->len = strlen(linfo->sasl_realm); - } - break; - case SASL_CB_USER: - if (linfo->sasl_authzid == NULL || - linfo->sasl_authzid[0] == '\0') { - IDMAP_LOG(2, ("SASL_CB_USER asked in callback " - "but not found in conf")); - } else { - IDMAP_LOG(5, ("Setting SASL_CB_USER to %s", - linfo->sasl_authzid)); - interact->result = linfo->sasl_authzid; - interact->len = strlen(linfo->sasl_authzid); - } - break; - default: - IDMAP_LOG(2, ("Undefined value requested %d", - interact->id)); - break; - } - interact++; - } - return LDAP_SUCCESS; -} -#endif /* ENABLE_LDAP_SASL */ - -/* Local routines */ - -static int -ldap_init_and_bind(LDAP **pld, - int *sizelimit, - struct umich_ldap_info *linfo) -{ - LDAP *ld; - int lerr; - int err = -1; - int current_version, new_version; - char server_url[1024]; - int debug_level = 65535; - int i; - LDAPAPIInfo apiinfo = {.ldapai_info_version = LDAP_API_INFO_VERSION}; - - snprintf(server_url, sizeof(server_url), "%s://%s:%d", - (linfo->use_ssl) ? "ldaps" : "ldap", - linfo->server, linfo->port); - - /* - * XXX We really, REALLY only want to initialize once, not for - * each request. Figure out how to do that! - */ - if ((lerr = ldap_initialize(&ld, server_url)) != LDAP_SUCCESS) { - IDMAP_LOG(0, ("ldap_init_and_bind: ldap_initialize() failed " - "to [%s]: %s (%d)", server_url, - ldap_err2string(lerr), lerr)); - goto out; - } - - if ((ldap_set_option(ld, LDAP_OPT_DEBUG_LEVEL, &debug_level) - != LDAP_SUCCESS)) { - IDMAP_LOG(0, ("ldap_init_and_bind: error setting ldap " - "library debugging level")); - goto out; - } - - /* - * Get LDAP API information and compare the protocol version there - * to the protocol version returned directly from get_option. - */ - ldap_get_option(ld, LDAP_OPT_API_INFO, &apiinfo); - if (apiinfo.ldapai_info_version != LDAP_API_INFO_VERSION) { - IDMAP_LOG(0, ("ldap_init_and_bind: APIInfo version mismatch: " - "library %d, header %d", - apiinfo.ldapai_info_version, LDAP_API_INFO_VERSION)); - goto out; - } - ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, ¤t_version); - if (apiinfo.ldapai_protocol_version == LDAP_VERSION3 && - current_version != LDAP_VERSION3) { - new_version = LDAP_VERSION3; - IDMAP_LOG(4, ("ldap_init_and_bind: version mismatch between " - "API information and protocol version. Setting " - "protocol version to %d", new_version)); - ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &new_version); - } - - for (i = 0; apiinfo.ldapai_extensions[i]; i++) { - char *extension = apiinfo.ldapai_extensions[i]; - ldap_memfree (extension); - } - ldap_memfree (apiinfo.ldapai_extensions); - ldap_memfree(apiinfo.ldapai_vendor_name); - - /* Set sizelimit option if requested */ - if (sizelimit) { - ldap_set_option(ld, LDAP_OPT_SIZELIMIT, (void *)sizelimit); - } - - lerr = ldap_set_option(ld, LDAP_OPT_REFERRALS, - linfo->follow_referrals ? (void *)LDAP_OPT_ON : - (void *)LDAP_OPT_OFF); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: setting LDAP_OPT_REFERRALS " - "failed: %s (%d)", ldap_err2string(lerr), lerr)); - goto out; - } - - /* Set option to to use SSL/TLS if requested */ - if (linfo->use_ssl) { - int tls_type = LDAP_OPT_X_TLS_HARD; - lerr = ldap_set_option(ld, LDAP_OPT_X_TLS, &tls_type); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: setting SSL " - "failed : %s (%d)", - ldap_err2string(lerr), lerr)); - goto out; - } - - if (linfo->ca_cert != NULL) { - lerr = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, - linfo->ca_cert); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: setting CA " - "certificate file failed : %s (%d)", - ldap_err2string(lerr), lerr)); - goto out; - } - } - - lerr = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, - &linfo->tls_reqcert); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: setting " - "req CA cert failed : %s(%d)", - ldap_err2string(lerr), lerr)); - goto out; - } - } - - /* If we have a DN (and password) attempt an authenticated bind */ - if (linfo->user_dn) { -retry_bind: -#ifdef ENABLE_LDAP_SASL - if (linfo->sasl_mech != NULL && linfo->sasl_mech[0] != '\0') { - /* use sasl bind */ - if (linfo->sasl_canonicalize != -1) { - lerr = ldap_set_option(ld, - LDAP_OPT_X_SASL_NOCANON, - linfo->sasl_canonicalize ? - LDAP_OPT_OFF : LDAP_OPT_ON); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: " - "setting sasl_canonicalize" - " failed: %s (%d)", - ldap_err2string(lerr), - lerr)); - goto out; - } - } - if (linfo->sasl_secprops != NULL && - linfo->sasl_secprops[0] != '\0') { - lerr = ldap_set_option(ld, - LDAP_OPT_X_SASL_SECPROPS, - (void *) linfo->sasl_secprops); - if (lerr != LDAP_SUCCESS) { - IDMAP_LOG(2, ("ldap_init_and_bind: " - "setting sasl_secprops" - " failed: %s (%d)", - ldap_err2string(lerr), - lerr)); - goto out; - } - } - if (linfo->sasl_krb5_ccname != NULL && - linfo->sasl_krb5_ccname[0] != '\0') { - lerr = set_krb5_ccname(linfo->sasl_krb5_ccname); - if (lerr != 0) { - IDMAP_LOG(2, - ("ldap_init_and_bind: Failed " - "to set krb5 ticket cache, " - "err=%d", lerr)); - } - } - lerr = ldap_sasl_interactive_bind_s(ld, linfo->user_dn, - linfo->sasl_mech, NULL, NULL, LDAP_SASL_QUIET, - sasl_interact_cb, linfo); - } else { - lerr = ldap_simple_bind_s(ld, linfo->user_dn, - linfo->passwd); - } -#else /* ENABLE_LDAP_SASL */ - lerr = ldap_simple_bind_s(ld, linfo->user_dn, linfo->passwd); -#endif /* else ENABLE_LDAP_SASL */ - if (lerr) { - char *errmsg; - if (lerr == LDAP_PROTOCOL_ERROR) { - ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, - ¤t_version); - new_version = current_version == LDAP_VERSION2 ? - LDAP_VERSION3 : LDAP_VERSION2; - ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, - &new_version); - IDMAP_LOG(2, ("ldap_init_and_bind: " - "got protocol error while attempting " - "bind with protocol version %d, " - "trying protocol version %d", - current_version, new_version)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("ldap_init_and_bind: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - goto retry_bind; - } -#ifdef ENABLE_LDAP_SASL - IDMAP_LOG(2, ("ldap_init_and_bind: %s " - "to [%s] as user '%s': %s (%d)", - (linfo->sasl_mech != NULL && - linfo->sasl_mech[0] != '\0') ? - "ldap_sasl_interactive_bind_s" : - "ldap_simple_bind_s", - server_url, linfo->user_dn, - ldap_err2string(lerr), lerr)); -#else /* ENABLE_LDAP_SASL */ - IDMAP_LOG(2, ("ldap_init_and_bind: ldap_simple_bind_s" - "to [%s] as user '%s': %s (%d)", - server_url, linfo->user_dn, - ldap_err2string(lerr), lerr)); - -#endif /* else ENABLE_LDAP_SASL */ - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL)&& (*errmsg != '\0')) { - IDMAP_LOG(2, ("ldap_init_and_bind: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - goto out; - } - } -#ifdef LDAP_ANONYMOUS_BIND_REQUIRED - else { - lerr = ldap_simple_bind_s(ld, NULL, NULL); - if (lerr) { - char *errmsg; - - IDMAP_LOG(2, ("ldap_init_and_bind: ldap_simple_bind_s " - "to [%s] as anonymous: %s (%d)", server_url, - ldap_err2string(lerr), lerr)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("ldap_init_and_bind: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - goto out; - } - } -#endif - - *pld = ld; - err = 0; -out: - return err; -} - -static int -umich_name_to_ids(char *name, int idtype, uid_t *uid, gid_t *gid, - char *attrtype, struct umich_ldap_info *linfo) -{ - LDAP *ld = NULL; - struct timeval timeout = { - .tv_sec = linfo->ldap_timeout, - }; - LDAPMessage *result = NULL, *entry; - BerElement *ber = NULL; - char **idstr, filter[LDAP_FILT_MAXSIZ], *base; - char *attrs[3]; - char *attr_res; - int count = 0, err, lerr, f_len; - int sizelimit = 1; - - err = -EINVAL; - if (uid == NULL || gid == NULL || name == NULL || - attrtype == NULL || linfo == NULL || linfo->server == NULL || - linfo->people_tree == NULL || linfo->group_tree == NULL) - goto out; - - *uid = -1; - *gid = -1; - - if (idtype == IDTYPE_USER) { - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_person_objcls, - attrtype, name)) - == LDAP_FILT_MAXSIZ) { - IDMAP_LOG(0, ("ERROR: umich_name_to_ids: filter " - "too long!")); - goto out; - } - base = linfo->people_tree; - } - else if (idtype == IDTYPE_GROUP) { - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_group_objcls, - attrtype, name)) - == LDAP_FILT_MAXSIZ) { - IDMAP_LOG(0, ("ERROR: umich_name_to_ids: filter " - "too long!")); - goto out; - } - base = linfo->group_tree; - } - else { - IDMAP_LOG(0, ("ERROR: umich_name_to_ids: invalid idtype (%d)", - idtype)); - goto out; - } - - if (ldap_init_and_bind(&ld, &sizelimit, linfo)) - goto out; - - attrs[0] = ldap_map.NFSv4_uid_attr; - attrs[1] = ldap_map.NFSv4_gid_attr; - attrs[2] = NULL; - - err = ldap_search_st(ld, base, LDAP_SCOPE_SUBTREE, - filter, (char **)attrs, - 0, &timeout, &result); - if (err) { - char *errmsg; - - IDMAP_LOG(2, ("umich_name_to_ids: ldap_search_st for " - "base '%s', filter '%s': %s (%d)", - base, filter, ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_name_to_ids: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - err = -ENOENT; - goto out_unbind; - } - - err = -ENOENT; - count = ldap_count_entries(ld, result); - if (count != 1) { - goto out_unbind; - } - - if (!(entry = ldap_first_entry(ld, result))) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_name_to_ids: ldap_first_entry: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - /* - * Attributes come back in no particular order, so we need - * to check each one to see what it is before assigning values. - * XXX There must be a better way than comparing the - * name of each attribute? - */ - for (attr_res = ldap_first_attribute(ld, result, &ber); - attr_res != NULL; - attr_res = ldap_next_attribute(ld, result, ber)) { - - unsigned long tmp_u, tmp_g; - uid_t tmp_uid; - gid_t tmp_gid; - - if ((idstr = ldap_get_values(ld, result, attr_res)) == NULL) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_name_to_ids: ldap_get_values: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_memfree; - } - if (strcasecmp(attr_res, ldap_map.NFSv4_uid_attr) == 0) { - tmp_u = strtoul(*idstr, (char **)NULL, 10); - tmp_uid = tmp_u; - if (tmp_uid != tmp_u || - (errno == ERANGE && tmp_u == ULONG_MAX)) { - IDMAP_LOG(0, ("ERROR: umich_name_to_ids: " - "uidNumber too long converting '%s'", - *idstr)); - ldap_memfree(attr_res); - ldap_value_free(idstr); - goto out_memfree; - } - *uid = tmp_uid; - err = 0; - } else if (strcasecmp(attr_res, ldap_map.NFSv4_gid_attr) == 0) { - tmp_g = strtoul(*idstr, (char **)NULL, 10); - tmp_gid = tmp_g; - if (tmp_gid != tmp_g || - (errno == ERANGE && tmp_g == ULONG_MAX)) { - IDMAP_LOG(0, ("ERROR: umich_name_to_ids: " - "gidNumber too long converting '%s'", - *idstr)); - ldap_memfree(attr_res); - ldap_value_free(idstr); - goto out_memfree; - } - *gid = tmp_gid; - err = 0; - } else { - IDMAP_LOG(0, ("umich_name_to_ids: received attr " - "'%s' ???", attr_res)); - ldap_memfree(attr_res); - ldap_value_free(idstr); - goto out_memfree; - } - ldap_memfree(attr_res); - ldap_value_free(idstr); - } - -out_memfree: - ber_free(ber, 0); -out_unbind: - if (result) - ldap_msgfree(result); - ldap_unbind(ld); -out: - return err; -} - -static int -umich_id_to_name(uid_t id, int idtype, char **name, size_t len, - struct umich_ldap_info *linfo) -{ - LDAP *ld = NULL; - struct timeval timeout = { - .tv_sec = linfo->ldap_timeout, - }; - LDAPMessage *result = NULL, *entry; - BerElement *ber; - char **names = NULL, filter[LDAP_FILT_MAXSIZ], *base; - char idstr[16]; - char *attrs[2]; - char *attr_res; - int count = 0, err, lerr, f_len; - int sizelimit = 1; - - err = -EINVAL; - if (name == NULL || linfo == NULL || linfo->server == NULL || - linfo->people_tree == NULL || linfo->group_tree == NULL) - goto out; - - snprintf(idstr, sizeof(idstr), "%d", id); - - - if (idtype == IDTYPE_USER) { - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_person_objcls, - ldap_map.NFSv4_uid_attr, idstr)) - == LDAP_FILT_MAXSIZ) { - IDMAP_LOG(0, ("ERROR: umich_id_to_name: " - "uid filter too long!")); - goto out; - } - base = linfo->people_tree; - } else if (idtype == IDTYPE_GROUP) { - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_group_objcls, - ldap_map.NFSv4_gid_attr,idstr)) - == LDAP_FILT_MAXSIZ) { - IDMAP_LOG(0, ("ERROR: umich_id_to_name: " - "gid filter too long!")); - goto out; - } - base = linfo->group_tree; - } else { - IDMAP_LOG(0, ("ERROR: umich_id_to_name: invalid idtype (%d)", - idtype)); - err = -EINVAL; - goto out; - } - - if (ldap_init_and_bind(&ld, &sizelimit, linfo)) - goto out; - - if (idtype == IDTYPE_USER) - attrs[0] = ldap_map.NFSv4_nfsname_attr; - else - attrs[0] = ldap_map.NFSv4_group_nfsname_attr; - attrs[1] = NULL; - - err = ldap_search_st(ld, base, LDAP_SCOPE_SUBTREE, - filter, (char **)attrs, - 0, &timeout, &result); - if (err) { - char * errmsg; - - IDMAP_LOG(2, ("umich_id_to_name: ldap_search_st for " - "base '%s, filter '%s': %s (%d)", base, filter, - ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_id_to_name: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - - err = -ENOENT; - goto out_unbind; - } - - err = -ENOENT; - count = ldap_count_entries(ld, result); - if (count != 1) - goto out_unbind; - - if (!(entry = ldap_first_entry(ld, result))) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_id_to_name: ldap_first_entry: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - if (!(attr_res = ldap_first_attribute(ld, result, &ber))) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_id_to_name: ldap_first_attribute: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - if ((names = ldap_get_values(ld, result, attr_res)) == NULL) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_id_to_name: ldap_get_values: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_memfree; - } - - /* - * Verify there is enough room in the output buffer before - * copying returned string. (strlen doesn't count the null, - * we make sure there is room for the null also, therefore - * we use ">=" not just ">") - */ - if (strlen(names[0]) >= len) { - /* not enough space to return the name */ - IDMAP_LOG(1, ("umich_id_to_name: output buffer size (%d) " - "too small to return string, '%s', of length %d", - len, names[0], strlen(names[0]))); - goto out_memfree; - } - strcpy(*name, names[0]); - - err = 0; -out_memfree: - if (names) - ldap_value_free(names); - ldap_memfree(attr_res); - ber_free(ber, 0); -out_unbind: - if (result) - ldap_msgfree(result); - ldap_unbind(ld); -out: - return err; -} - -static int -umich_gss_princ_to_grouplist(char *principal, gid_t *groups, int *ngroups, - struct umich_ldap_info *linfo) -{ - LDAP *ld = NULL; - struct timeval timeout = { - .tv_sec = linfo->ldap_timeout, - }; - LDAPMessage *result, *entry; - char **names, filter[LDAP_FILT_MAXSIZ]; - char *attrs[2]; - int count = 0, err = -ENOMEM, lerr, f_len; - int i, num_gids; - gid_t *curr_group = groups; - - err = -EINVAL; - if (linfo == NULL || linfo->server == NULL || - linfo->people_tree == NULL || linfo->group_tree == NULL) - goto out; - - - if (ldap_init_and_bind(&ld, NULL, linfo)) - goto out; - - /* - * First we need to map the gss principal name to a uid (name) string - */ - err = -EINVAL; - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_person_objcls, - ldap_map.GSS_principal_attr, principal)) - == LDAP_FILT_MAXSIZ) { - IDMAP_LOG(0, ("ERROR: umich_gss_princ_to_grouplist: " - "filter too long!")); - goto out; - } - - attrs[0] = ldap_map.NFSv4_acctname_attr; - attrs[1] = NULL; - - err = ldap_search_st(ld, linfo->people_tree, LDAP_SCOPE_SUBTREE, - filter, attrs, 0, &timeout, &result); - if (err) { - char *errmsg; - - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_search_st " - "for tree '%s, filter '%s': %s (%d)", - linfo->people_tree, filter, - ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - err = -ENOENT; - goto out_unbind; - } - - err = -ENOENT; - count = ldap_count_entries(ld, result); - if (count != 1) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "ldap account lookup of gssauthname %s returned %d accounts", - principal,count)); - goto out_unbind; - } - - if (!(entry = ldap_first_entry(ld, result))) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_first_entry: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - if ((names = ldap_get_values(ld, result, attrs[0])) == NULL) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_get_values: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - if (ldap_info.memberof_for_groups) { - - /* - * Collect the groups the user belongs to - */ - if ((f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_person_objcls, - ldap_map.NFSv4_acctname_attr, - names[0])) == LDAP_FILT_MAXSIZ ) { - IDMAP_LOG(2, ("ERROR: umich_gss_princ_to_grouplist: " - "filter too long!")); - ldap_value_free(names); - goto out_unbind; - } - - ldap_value_free(names); - - attrs[0] = ldap_map.NFSv4_member_of_attr; - attrs[1] = NULL; - - err = ldap_search_st(ld, linfo->people_tree, LDAP_SCOPE_SUBTREE, - filter, attrs, 0, &timeout, &result); - - if (err) { - char *errmsg; - - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_search_st " - "for tree '%s, filter '%s': %s (%d)", - linfo->people_tree, filter, - ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) - && (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - err = -ENOENT; - goto out_unbind; - } - err = -ENOENT; - - /* pull the list of groups and place into names */ - count = ldap_count_entries(ld, result); - if (count != 1) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "ldap group member lookup of gssauthname %s returned %d multiple entries", - principal,count)); - goto out_unbind; - } - - if (!(entry = ldap_first_entry(ld, result))) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_first_entry: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - if ((names = ldap_get_values(ld, result, attrs[0])) == NULL) { - lerr = ldap_result2error(ld, result, 0); - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_get_values: " - "%s (%d)", ldap_err2string(lerr), lerr)); - goto out_unbind; - } - - /* Count the groups first before doing a lookup of the group. - If it exceeds the desired number of groups set the needed value - and abort. */ - for (i = 0; names[i] != NULL; i++); - if ( i > *ngroups ) { - ldap_value_free(names); - err = -EINVAL; - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: User %s, " - "number of groups %d, exceeds requested number %d", - principal, i, *ngroups)); - *ngroups = i; - goto out_unbind; - } - - /* Loop through the groupnames (names) and get the group gid */ - num_gids = 0; - for (i = 0; names[i] != NULL; i++){ - char **vals; - int valcount; - unsigned long tmp_g; - gid_t tmp_gid; - char *cnptr = NULL; - - cnptr = strchr(names[i],','); - if (cnptr) *cnptr = '\0'; - - err = -ENOENT; - if (ldap_map.NFSv4_grouplist_filter) - f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s)%s)", - ldap_map.NFSv4_group_objcls, - names[i], - ldap_map.NFSv4_grouplist_filter); - else - f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s))", - ldap_map.NFSv4_group_objcls, - names[i]); - - if ( f_len == LDAP_FILT_MAXSIZ ) { - IDMAP_LOG(2, ("ERROR: umich_gss_princ_to_grouplist: " - "filter too long!")); - ldap_value_free(names); - goto out_unbind; - } - attrs[0] = ldap_map.NFSv4_gid_attr; - attrs[1] = NULL; - - err = ldap_search_st(ld, linfo->group_tree, LDAP_SCOPE_SUBTREE, - filter, attrs, 0, &timeout, &result); - if (err) { - char *errmsg; - - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_search_st " - "for tree '%s, filter '%s': %s (%d)", - linfo->group_tree, filter, - ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg)==LDAP_SUCCESS) - && - (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - continue; - } - - count = ldap_count_entries(ld, result); - if (count == 0) - continue; - if (count != 1 ){ - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist:" - "Group %s has %d gids defined - aborting", names[i], count)); - ldap_value_free(names); - err = -ENOENT; - goto out_unbind; - } - - vals = ldap_get_values(ld, result, ldap_map.NFSv4_gid_attr); - - /* There should be only one gidNumber attribute per group */ - if ((valcount = ldap_count_values(vals)) != 1) { - IDMAP_LOG(2, ("DB problem getting gidNumber of " - "posixGroup! (count was %d)", valcount)); - ldap_value_free(vals); - continue; - } - - tmp_g = strtoul(vals[0], (char **)NULL, 10); - tmp_gid = tmp_g; - if (tmp_gid != tmp_g || - (errno == ERANGE && tmp_g == ULONG_MAX)) { - IDMAP_LOG(2, ("ERROR: umich_gss_princ_to_grouplist: " - "gidNumber too long converting '%s'", - vals[0])); - ldap_value_free(vals); - continue; - } - *curr_group++ = tmp_gid; - num_gids++; - ldap_value_free(vals); - } - ldap_value_free(names); - *ngroups = num_gids; - err = 0; - } else { - - /* - * Then determine the groups that uid (name) string is a member of - */ - err = -EINVAL; - if (ldap_map.NFSv4_grouplist_filter) - f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s)%s)", - ldap_map.NFSv4_group_objcls, - ldap_map.NFSv4_member_attr, - names[0], - ldap_map.NFSv4_grouplist_filter); - - else - f_len = snprintf(filter, LDAP_FILT_MAXSIZ, - "(&(objectClass=%s)(%s=%s))", - ldap_map.NFSv4_group_objcls, - ldap_map.NFSv4_member_attr, - names[0]); - - if ( f_len == LDAP_FILT_MAXSIZ ) { - IDMAP_LOG(0, ("ERROR: umich_gss_princ_to_grouplist: " - "filter too long!")); - ldap_value_free(names); - goto out_unbind; - } - - ldap_value_free(names); - - attrs[0] = ldap_map.NFSv4_gid_attr; - attrs[1] = NULL; - - err = ldap_search_st(ld, linfo->group_tree, LDAP_SCOPE_SUBTREE, - filter, attrs, 0, &timeout, &result); - - if (err) { - char *errmsg; - - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: ldap_search_st " - "for tree '%s, filter '%s': %s (%d)", - linfo->group_tree, filter, - ldap_err2string(err), err)); - if ((ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &errmsg) == LDAP_SUCCESS) && - (errmsg != NULL) && (*errmsg != '\0')) { - IDMAP_LOG(2, ("umich_gss_princ_to_grouplist: " - "Additional info: %s", errmsg)); - ldap_memfree(errmsg); - } - err = -ENOENT; - goto out_unbind; - } - - /* - * If we can't determine count, return that error - * If we have nothing to return, return success - * If we have more than they asked for, tell them the - * number required and return an error - */ - count = ldap_count_entries(ld, result); - - if (count < 0) { - err = count; - goto out_unbind; - } - if (count == 0) { - *ngroups = 0; - err = 0; - goto out_unbind; - } - if (count > *ngroups) { - *ngroups = count; - err = -EINVAL; - goto out_unbind; - } - *ngroups = count; - - curr_group = groups; - - err = -ENOENT; - for (entry = ldap_first_entry(ld, result); - entry != NULL; - entry = ldap_next_entry(ld, entry)) { - - char **vals; - int valcount; - unsigned long tmp_g; - gid_t tmp_gid; - - vals = ldap_get_values(ld, entry, ldap_map.NFSv4_gid_attr); - - /* There should be only one gidNumber attribute per group */ - if ((valcount = ldap_count_values(vals)) != 1) { - IDMAP_LOG(0, ("DB problem getting gidNumber of " - "posixGroup! (count was %d)", valcount)); - goto out_unbind; - } - tmp_g = strtoul(vals[0], (char **)NULL, 10); - tmp_gid = tmp_g; - if (tmp_gid != tmp_g || - (errno == ERANGE && tmp_g == ULONG_MAX)) { - IDMAP_LOG(0, ("ERROR: umich_gss_princ_to_grouplist: " - "gidNumber too long converting '%s'", - vals[0])); - ldap_value_free(vals); - goto out_unbind; - } - *curr_group++ = tmp_gid; - ldap_value_free(vals); - } - err = 0; - } - -out_unbind: - ldap_unbind(ld); -out: - return err; -} - - -/* - * principal: krb5 - princ@realm, use KrbName ldap attribute - * spkm3 - X.509 dn, use X509Name ldap attribute - */ -static int -umichldap_gss_princ_to_ids(char *secname, char *principal, - uid_t *uid, gid_t *gid, - extra_mapping_params **UNUSED(ex)) -{ - uid_t rtnd_uid = -1; - gid_t rtnd_gid = -1; - int err = -EINVAL; - - if ((strcmp(secname, "krb5") != 0) && (strcmp(secname, "spkm3") != 0)) { - IDMAP_LOG(0, ("ERROR: umichldap_gss_princ_to_ids: " - "invalid secname '%s'", secname)); - return err; - } - - err = umich_name_to_ids(principal, IDTYPE_USER, &rtnd_uid, &rtnd_gid, - ldap_map.GSS_principal_attr, &ldap_info); - if (err < 0) - goto out; - - *uid = rtnd_uid; - *gid = rtnd_gid; -out: - return err; -} - -static int -umichldap_name_to_uid(char *name, uid_t *uid) -{ - gid_t gid; - - return umich_name_to_ids(name, IDTYPE_USER, uid, - &gid, ldap_map.NFSv4_nfsname_attr, &ldap_info); -} - -static int -umichldap_name_to_gid(char *name, gid_t *gid) -{ - uid_t uid; - - return umich_name_to_ids(name, IDTYPE_GROUP, &uid, gid, - ldap_map.NFSv4_group_nfsname_attr, &ldap_info); -} - -static int -umichldap_uid_to_name(uid_t uid, char *UNUSED(domain), char *name, size_t len) -{ - return umich_id_to_name(uid, IDTYPE_USER, &name, len, &ldap_info); -} - -static int -umichldap_gid_to_name(gid_t gid, char *UNUSED(domain), char *name, size_t len) -{ - return umich_id_to_name(gid, IDTYPE_GROUP, &name, len, &ldap_info); -} - -static int -umichldap_gss_princ_to_grouplist(char *secname, char *principal, - gid_t *groups, int *ngroups, extra_mapping_params **UNUSED(ex)) -{ - int err = -EINVAL; - - if ((strcmp(secname, "krb5") != 0) && (strcmp(secname, "spkm3") != 0)) { - IDMAP_LOG(0, ("ERROR: umichldap_gss_princ_to_grouplist: " - "invalid secname '%s'", secname)); - return err; - } - - return umich_gss_princ_to_grouplist(principal, groups, ngroups, - &ldap_info); -} - -/* - * TLS connections require that the hostname we specify matches - * the hostname in the certificate that the server uses. - * Get a canonical name for the host specified in the config file. - */ -static char * -get_canonical_hostname(const char *inname) -{ - int aierr, error; - struct addrinfo *ap, aihints; - char *return_name = NULL; - char tmphost[NI_MAXHOST]; - - memset(&aihints, 0, sizeof(aihints)); - aihints.ai_socktype = SOCK_STREAM; - aihints.ai_flags = AI_CANONNAME; - aihints.ai_family = PF_INET; - aierr = getaddrinfo(inname, NULL, &aihints, &ap); - if (aierr) { - const char *msg; - /* We want to customize some messages. */ - switch (aierr) { - case EAI_NONAME: - msg = "host unknown"; - break; - default: - msg = gai_strerror(aierr); - break; - } - IDMAP_LOG(1, ("%s: '%s': %s", __FUNCTION__, inname, msg)); - goto out_err; - } - if (ap == 0) { - IDMAP_LOG(1, ("%s: no addresses for host '%s'?", - __FUNCTION__, inname)); - goto out_err; - } - - error = getnameinfo (ap->ai_addr, ap->ai_addrlen, tmphost, - sizeof(tmphost), NULL, 0, 0); - if (error) { - IDMAP_LOG(1, ("%s: getnameinfo for host '%s' failed (%d)", - __FUNCTION__, inname)); - goto out_free; - } - return_name = strdup (tmphost); - -out_free: - nfs_freeaddrinfo(ap); -out_err: - return return_name; -} - -static int -umichldap_init(void) -{ - char *tssl, *canonicalize, *memberof, *cert_req, *follow_referrals; - char missing_msg[128] = ""; - char *server_in, *canon_name; - - if (nfsidmap_conf_path) - conf_init_file(nfsidmap_conf_path); - - server_in = conf_get_str(LDAP_SECTION, "LDAP_server"); - ldap_info.base = conf_get_str(LDAP_SECTION, "LDAP_base"); - ldap_info.people_tree = conf_get_str(LDAP_SECTION, "LDAP_people_base"); - ldap_info.group_tree = conf_get_str(LDAP_SECTION, "LDAP_group_base"); - ldap_info.user_dn = conf_get_str(LDAP_SECTION, "LDAP_user_dn"); - ldap_info.passwd = conf_get_str(LDAP_SECTION, "LDAP_passwd"); - tssl = conf_get_str_with_def(LDAP_SECTION, "LDAP_use_ssl", "false"); - if ((strcasecmp(tssl, "true") == 0) || - (strcasecmp(tssl, "on") == 0) || - (strcasecmp(tssl, "yes") == 0)) - ldap_info.use_ssl = 1; - else - ldap_info.use_ssl = 0; - ldap_info.ca_cert = conf_get_str(LDAP_SECTION, "LDAP_CA_CERT"); - cert_req = conf_get_str(LDAP_SECTION, "LDAP_tls_reqcert"); - if (cert_req != NULL) { - if (strcasecmp(cert_req, "hard") == 0) - ldap_info.tls_reqcert = LDAP_OPT_X_TLS_HARD; - else if (strcasecmp(cert_req, "demand") == 0) - ldap_info.tls_reqcert = LDAP_OPT_X_TLS_DEMAND; - else if (strcasecmp(cert_req, "try") == 0) - ldap_info.tls_reqcert = LDAP_OPT_X_TLS_TRY; - else if (strcasecmp(cert_req, "allow") == 0) - ldap_info.tls_reqcert = LDAP_OPT_X_TLS_ALLOW; - else if (strcasecmp(cert_req, "never") == 0) - ldap_info.tls_reqcert = LDAP_OPT_X_TLS_NEVER; - else { - IDMAP_LOG(0, ("umichldap_init: Invalid value(%s) for " - "LDAP_tls_reqcert.")); - goto fail; - } - } - /* vary the default port depending on whether they use SSL or not */ - ldap_info.port = conf_get_num(LDAP_SECTION, "LDAP_port", - (ldap_info.use_ssl) ? - LDAPS_PORT : LDAP_PORT); - - ldap_info.sasl_mech = conf_get_str(LDAP_SECTION, "LDAP_sasl_mech"); - ldap_info.sasl_realm = conf_get_str(LDAP_SECTION, "LDAP_sasl_realm"); - ldap_info.sasl_authcid = conf_get_str(LDAP_SECTION, - "LDAP_sasl_authcid"); - ldap_info.sasl_authzid = conf_get_str(LDAP_SECTION, - "LDAP_sasl_authzid"); - ldap_info.sasl_secprops = conf_get_str(LDAP_SECTION, - "LDAP_sasl_secprops"); - - /* If it is not set let the ldap lib work with the lib default */ - canonicalize = conf_get_str_with_def(LDAP_SECTION, - "LDAP_sasl_canonicalize", "undef"); - if ((strcasecmp(canonicalize, "true") == 0) || - (strcasecmp(canonicalize, "on") == 0) || - (strcasecmp(canonicalize, "yes") == 0)) { - ldap_info.sasl_canonicalize = 1; - } else if ((strcasecmp(canonicalize, "false") == 0) || - (strcasecmp(canonicalize, "off") == 0) || - (strcasecmp(canonicalize, "no") == 0)) { - ldap_info.sasl_canonicalize = 0; - } - ldap_info.sasl_krb5_ccname = conf_get_str(LDAP_SECTION, - "LDAP_sasl_krb5_ccname"); - - follow_referrals = conf_get_str_with_def(LDAP_SECTION, - "LDAP_follow_referrals", - "true"); - if ((strcasecmp(follow_referrals, "true") == 0) || - (strcasecmp(follow_referrals, "on") == 0) || - (strcasecmp(follow_referrals, "yes") == 0)) - ldap_info.follow_referrals = 1; - else - ldap_info.follow_referrals = 0; - - /* Verify required information is supplied */ - if (server_in == NULL || strlen(server_in) == 0) - strncat(missing_msg, "LDAP_server ", sizeof(missing_msg)-1); - if (ldap_info.base == NULL || strlen(ldap_info.base) == 0) - strncat(missing_msg, "LDAP_base ", sizeof(missing_msg)-1); - if (strlen(missing_msg) != 0) { - IDMAP_LOG(0, ("umichldap_init: Missing required information: " - "%s", missing_msg)); - goto fail; - } - - ldap_info.server = server_in; - canonicalize = conf_get_str_with_def(LDAP_SECTION, - "LDAP_canonicalize_name", "yes"); - if ((strcasecmp(canonicalize, "true") == 0) || - (strcasecmp(canonicalize, "on") == 0) || - (strcasecmp(canonicalize, "yes") == 0)) { - canon_name = get_canonical_hostname(server_in); - if (canon_name == NULL) - IDMAP_LOG(0, ("umichldap_init: Warning! Unable to " - "canonicalize server name '%s' as requested.", - server_in)); - else - ldap_info.server = canon_name; - } - - /* get the ldap mapping attributes/objectclasses (all have defaults) */ - ldap_map.NFSv4_person_objcls = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_person_objectclass", - DEFAULT_UMICH_OBJCLASS_REMOTE_PERSON); - - ldap_map.NFSv4_group_objcls = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_group_objectclass", - DEFAULT_UMICH_OBJCLASS_REMOTE_GROUP); - - ldap_map.NFSv4_nfsname_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_name_attr", - DEFAULT_UMICH_ATTR_NFSNAME); - - ldap_map.NFSv4_uid_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_uid_attr", - DEFAULT_UMICH_ATTR_UIDNUMBER); - - ldap_map.NFSv4_acctname_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_acctname_attr", - DEFAULT_UMICH_ATTR_ACCTNAME); - - ldap_map.NFSv4_group_nfsname_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_group_attr", - DEFAULT_UMICH_ATTR_GROUP_NFSNAME); - - ldap_map.NFSv4_gid_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_gid_attr", - DEFAULT_UMICH_ATTR_GIDNUMBER); - - ldap_map.NFSv4_member_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_member_attr", - DEFAULT_UMICH_ATTR_MEMBERUID); - - ldap_map.GSS_principal_attr = - conf_get_str_with_def(LDAP_SECTION, "GSS_principal_attr", - DEFAULT_UMICH_ATTR_GSSAUTHNAME); - - ldap_map.NFSv4_grouplist_filter = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_grouplist_filter", - NULL); - - ldap_map.NFSv4_member_of_attr = - conf_get_str_with_def(LDAP_SECTION, "NFSv4_member_of_attr", - DEFAULT_UMICH_ATTR_MEMBEROF); - - ldap_info.ldap_timeout = - conf_get_num(LDAP_SECTION, "LDAP_timeout_seconds", - DEFAULT_UMICH_SEARCH_TIMEOUT); - - - /* - * Some LDAP servers do a better job with indexing where searching - * through all the groups searching for the user in the memberuid - * list. Others like SunOne directory that search can takes minutes - * if there are thousands of groups. So setting - * LDAP_use_memberof_for_groups to true in the configuration file - * will use the memberof lists of the account and search through - * only those groups to obtain gids. - */ - memberof = conf_get_str_with_def(LDAP_SECTION, - "LDAP_use_memberof_for_groups", "false"); - if ((strcasecmp(memberof, "true") == 0) || - (strcasecmp(memberof, "on") == 0) || - (strcasecmp(memberof, "yes") == 0)) - ldap_info.memberof_for_groups = 1; - else - ldap_info.memberof_for_groups = 0; - - /* - * If they specified a search base for the - * people tree or group tree we use that. - * Otherwise we use the default search base. - * Note: We no longer append the default base to the tree -- - * that should already be specified. - * this functions much like the NSS_LDAP modules - */ - if (ldap_info.people_tree == NULL || strlen(ldap_info.people_tree) == 0) - ldap_info.people_tree = ldap_info.base; - if (ldap_info.group_tree == NULL || strlen(ldap_info.group_tree) == 0) - ldap_info.group_tree = ldap_info.base; - - if (ldap_info.use_ssl && - ldap_info.tls_reqcert != LDAP_OPT_X_TLS_NEVER && - ldap_info.ca_cert == NULL) { - IDMAP_LOG(0, ("umichldap_init: You must specify LDAP_ca_cert " - "with LDAP_use_ssl=yes and " - "LDAP_tls_reqcert not set to \"never\"")); - goto fail; - } - - - /* print out some good debugging info */ - IDMAP_LOG(1, ("umichldap_init: canonicalize_name: %s", - canonicalize)); - IDMAP_LOG(1, ("umichldap_init: server : %s (from config value '%s')", - ldap_info.server, server_in)); - IDMAP_LOG(1, ("umichldap_init: port : %d", ldap_info.port)); - IDMAP_LOG(1, ("umichldap_init: people : %s", ldap_info.people_tree)); - IDMAP_LOG(1, ("umichldap_init: groups : %s", ldap_info.group_tree)); - - IDMAP_LOG(1, ("umichldap_init: user_dn : %s", - (ldap_info.user_dn && strlen(ldap_info.user_dn) != 0) - ? ldap_info.user_dn : "")); - /* Don't print actual password into the log. */ - IDMAP_LOG(1, ("umichldap_init: passwd : %s", - (ldap_info.passwd && strlen(ldap_info.passwd) != 0) ? - "" : "")); - IDMAP_LOG(1, ("umichldap_init: use_ssl : %s", - ldap_info.use_ssl ? "yes" : "no")); - IDMAP_LOG(1, ("umichldap_init: ca_cert : %s", - ldap_info.ca_cert ? ldap_info.ca_cert : "")); - IDMAP_LOG(1, ("umichldap_init: tls_reqcert : %s(%d)", - cert_req ? cert_req : "", - ldap_info.tls_reqcert)); - IDMAP_LOG(1, ("umichldap_init: use_memberof_for_groups : %s", - ldap_info.memberof_for_groups ? "yes" : "no")); - IDMAP_LOG(1, ("umichldap_init: sasl_mech: %s", - (ldap_info.sasl_mech && strlen(ldap_info.sasl_mech) != 0) ? - ldap_info.sasl_mech : "")); - IDMAP_LOG(1, ("umichldap_init: sasl_realm: %s", - (ldap_info.sasl_realm && strlen(ldap_info.sasl_realm) != 0) ? - ldap_info.sasl_realm : "")); - IDMAP_LOG(1, ("umichldap_init: sasl_authcid: %s", - (ldap_info.sasl_authcid && - strlen(ldap_info.sasl_authcid) != 0) ? - ldap_info.sasl_authcid : "")); - IDMAP_LOG(1, ("umichldap_init: sasl_authzid: %s", - (ldap_info.sasl_authzid && - strlen(ldap_info.sasl_authzid) != 0) ? - ldap_info.sasl_authzid : "")); - IDMAP_LOG(1, ("umichldap_init: sasl_secprops: %s", - (ldap_info.sasl_secprops && - strlen(ldap_info.sasl_secprops) != 0) ? - ldap_info.sasl_secprops : "")); - IDMAP_LOG(1, ("umichldap_init: sasl_canonicalize: %d", - ldap_info.sasl_canonicalize)); - IDMAP_LOG(1, ("umichldap_init: sasl_krb5_ccname: %s", - ldap_info.sasl_krb5_ccname)); - IDMAP_LOG(1, ("umichldap_init: follow_referrals: %s", - ldap_info.follow_referrals ? "yes" : "no")); - - IDMAP_LOG(1, ("umichldap_init: NFSv4_person_objectclass : %s", - ldap_map.NFSv4_person_objcls)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_nfsname_attr : %s", - ldap_map.NFSv4_nfsname_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_acctname_attr : %s", - ldap_map.NFSv4_acctname_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_uid_attr : %s", - ldap_map.NFSv4_uid_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_group_objectclass : %s", - ldap_map.NFSv4_group_objcls)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_gid_attr : %s", - ldap_map.NFSv4_gid_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_group_nfsname_attr : %s", - ldap_map.NFSv4_group_nfsname_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_member_attr : %s", - ldap_map.NFSv4_member_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_member_of_attr : %s", - ldap_map.NFSv4_member_of_attr)); - IDMAP_LOG(1, ("umichldap_init: NFSv4_grouplist_filter : %s", - ldap_map.NFSv4_grouplist_filter ? - ldap_map.NFSv4_grouplist_filter : "")); - IDMAP_LOG(1, ("umichldap_init: GSS_principal_attr : %s", - ldap_map.GSS_principal_attr)); - return 0; -fail: - return -1; -} - - -/* The external interface */ - -struct trans_func umichldap_trans = { - .name = "umich_ldap", - .init = umichldap_init, - .princ_to_ids = umichldap_gss_princ_to_ids, - .name_to_uid = umichldap_name_to_uid, - .name_to_gid = umichldap_name_to_gid, - .uid_to_name = umichldap_uid_to_name, - .gid_to_name = umichldap_gid_to_name, - .gss_princ_to_grouplist = umichldap_gss_princ_to_grouplist, -}; - -struct trans_func *libnfsidmap_plugin_init(void) -{ - return (&umichldap_trans); -} diff --git a/nfs-utils-2.5.2/support/nsm/Makefile.am b/nfs-utils-2.5.2/support/nsm/Makefile.am deleted file mode 100644 index 8f5874e..0000000 --- a/nfs-utils-2.5.2/support/nsm/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -## Process this file with automake to produce Makefile.in - -GENFILES_CLNT = sm_inter_clnt.c -GENFILES_SVC = sm_inter_svc.c -GENFILES_XDR = sm_inter_xdr.c -GENFILES_H = sm_inter.h - -GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) - -EXTRA_DIST = sm_inter.x - -noinst_LIBRARIES = libnsm.a -libnsm_a_SOURCES = $(GENFILES) file.c rpc.c - -BUILT_SOURCES = $(GENFILES) - -if CONFIG_RPCGEN -RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen -$(RPCGEN): - make -C ../../tools/rpcgen all -else -RPCGEN = @RPCGEN_PATH@ -endif - -$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -l -o $@ $< - -$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -m -o $@ $< - -$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -c -i 0 -o $@ $< - -$(GENFILES_H): %.h: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -h -o $@ $< - echo "void sm_prog_1(struct svc_req *, SVCXPRT *);" >> $@ - rm -f $(top_builddir)/support/include/sm_inter.h - $(LN_S) ../nsm/sm_inter.h $(top_builddir)/support/include/sm_inter.h - -MAINTAINERCLEANFILES = Makefile.in - -CLEANFILES = $(GENFILES) $(top_builddir)/support/include/sm_inter.h diff --git a/nfs-utils-2.5.2/support/nsm/file.c b/nfs-utils-2.5.2/support/nsm/file.c deleted file mode 100644 index f5b4480..0000000 --- a/nfs-utils-2.5.2/support/nsm/file.c +++ /dev/null @@ -1,1092 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -/* - * NSM for Linux. - * - * Callback information and NSM state is stored in files, usually - * under /var/lib/nfs. A database of information contained in local - * files stores NLM callback data and what remote peers to notify of - * reboots. - * - * For each monitored remote peer, a text file is created under the - * directory specified by NSM_MONITOR_DIR. The name of the file - * is a valid DNS hostname. The hostname string must be a valid - * ASCII DNS name, and must not contain slash characters, white space, - * or '\0' (ie. anything that might have some special meaning in a - * path name). - * - * The contents of each file include seven blank-separated fields of - * text, finished with '\n'. The first field contains the network - * address of the NLM service to call back. The current implementation - * supports using only IPv4 addresses, so the only contents of this - * field are a network order IPv4 address expressed in 8 hexadecimal - * characters. - * - * The next four fields are text strings of hexadecimal characters, - * representing: - * - * 2. A 4 byte RPC program number of the NLM service to call back - * 3. A 4 byte RPC version number of the NLM service to call back - * 4. A 4 byte RPC procedure number of the NLM service to call back - * 5. A 16 byte opaque cookie that the NLM service uses to identify - * the monitored host - * - * The sixth field is the monitored host's mon_name, passed to statd - * via an SM_MON request. - * - * The seventh field is the my_name for this peer, which is the - * hostname of the local NLM (currently on Linux, the result of - * `uname -n`). This can be used as the source address/hostname - * when sending SM_NOTIFY requests. - * - * The NSM protocol does not limit the contents of these strings - * in any way except that they must fit into 1024 bytes. Our - * implementation requires that these strings not contain - * white space or '\0'. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#ifdef HAVE_SYS_CAPABILITY_H -#include -#endif -#include -#include - -#include -#include -#include -#ifndef S_SPLINT_S -#include -#endif -#include -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "nsm.h" -#include "misc.h" - -#define RPCARGSLEN (4 * (8 + 1)) -#define LINELEN (RPCARGSLEN + SM_PRIV_SIZE * 2 + 1) - -#define NSM_KERNEL_STATE_FILE "/proc/sys/fs/nfs/nsm_local_state" - -static char nsm_base_dirname[PATH_MAX] = NSM_DEFAULT_STATEDIR; - -#define NSM_MONITOR_DIR "sm" -#define NSM_NOTIFY_DIR "sm.bak" -#define NSM_STATE_FILE "state" - - -static _Bool -error_check(const int len, const size_t buflen) -{ - return (len < 0) || ((size_t)len >= buflen); -} - -static _Bool -exact_error_check(const ssize_t len, const size_t buflen) -{ - return (len < 0) || ((size_t)len != buflen); -} - -/* - * Returns a dynamically allocated, '\0'-terminated buffer - * containing an appropriate pathname, or NULL if an error - * occurs. Caller must free the returned result with free(3). - */ -__attribute__((__malloc__)) -static char * -nsm_make_record_pathname(const char *directory, const char *hostname) -{ - const char *c; - size_t size; - char *path; - int len; - - /* - * Block hostnames that contain characters that have - * meaning to the file system (like '/'), or that can - * be confusing on visual inspection (like ' '). - */ - for (c = hostname; *c != '\0'; c++) - if (*c == '/' || isspace((int)*c) != 0) { - xlog(D_GENERAL, "Hostname contains invalid characters"); - return NULL; - } - - size = strlen(nsm_base_dirname) + strlen(directory) + strlen(hostname) + 3; - if (size > PATH_MAX) { - xlog(D_GENERAL, "Hostname results in pathname that is too long"); - return NULL; - } - - path = malloc(size); - if (path == NULL) { - xlog(D_GENERAL, "Failed to allocate memory for pathname"); - return NULL; - } - - len = snprintf(path, size, "%s/%s/%s", - nsm_base_dirname, directory, hostname); - if (error_check(len, size)) { - xlog(D_GENERAL, "Pathname did not fit in specified buffer"); - free(path); - return NULL; - } - - return path; -} - -/* - * Returns a dynamically allocated, '\0'-terminated buffer - * containing an appropriate pathname, or NULL if an error - * occurs. Caller must free the returned result with free(3). - */ -__attribute__((__malloc__)) -static char * -nsm_make_pathname(const char *directory) -{ - return generic_make_pathname(nsm_base_dirname, directory); -} - -/* - * Returns a dynamically allocated, '\0'-terminated buffer - * containing an appropriate pathname, or NULL if an error - * occurs. Caller must free the returned result with free(3). - */ -__attribute__((__malloc__)) -static char * -nsm_make_temp_pathname(const char *pathname) -{ - size_t size; - char *path; - int len; - - size = strlen(pathname) + sizeof(".new") + 2; - if (size > PATH_MAX) - return NULL; - - path = malloc(size); - if (path == NULL) - return NULL; - - len = snprintf(path, size, "%s.new", pathname); - if (error_check(len, size)) { - free(path); - return NULL; - } - - return path; -} - -/* - * Use "mktemp, write, rename" to update the contents of a file atomically. - * - * Returns true if completely successful, or false if some error occurred. - */ -static _Bool -nsm_atomic_write(const char *path, const void *buf, const size_t buflen) -{ - _Bool result = false; - ssize_t len; - char *temp; - int fd; - - temp = nsm_make_temp_pathname(path); - if (temp == NULL) { - xlog(L_ERROR, "Failed to create new path for %s", path); - goto out; - } - - fd = open(temp, O_CREAT | O_TRUNC | O_SYNC | O_WRONLY, 0644); - if (fd == -1) { - xlog(L_ERROR, "Failed to create %s: %m", temp); - goto out; - } - - len = write(fd, buf, buflen); - if (exact_error_check(len, buflen)) { - xlog(L_ERROR, "Failed to write %s: %m", temp); - (void)close(fd); - (void)unlink(temp); - goto out; - } - - if (close(fd) == -1) { - xlog(L_ERROR, "Failed to close %s: %m", temp); - (void)unlink(temp); - goto out; - } - - if (rename(temp, path) == -1) { - xlog(L_ERROR, "Failed to rename %s -> %s: %m", - temp, path); - (void)unlink(temp); - goto out; - } - - /* Ostensibly, a sync(2) is not needed here because - * open(O_CREAT), write(O_SYNC), and rename(2) are - * already synchronous with persistent storage, for - * any file system we care about. */ - - result = true; - -out: - free(temp); - return result; -} - -/** - * nsm_setup_pathnames - set up pathname - * @progname: C string containing name of program, for error messages - * @parentdir: C string containing pathname to on-disk state, or NULL - * - * This runs before logging is set up, so error messages are directed - * to stderr. - * - * Returns true and sets up our pathnames, if @parentdir was valid - * and usable; otherwise false is returned. - */ -_Bool -nsm_setup_pathnames(const char *progname, const char *parentdir) -{ - return generic_setup_basedir(progname, parentdir, nsm_base_dirname, - PATH_MAX); -} - -/** - * nsm_is_default_parentdir - check if parent directory is default - * - * Returns true if the active statd parent directory, set by - * nsm_change_pathname(), is the same as the built-in default - * parent directory; otherwise false is returned. - */ -_Bool -nsm_is_default_parentdir(void) -{ - return strcmp(nsm_base_dirname, NSM_DEFAULT_STATEDIR) == 0; -} - -/* - * Clear all capabilities but CAP_NET_BIND_SERVICE. This permits - * callers to acquire privileged source ports, but all other root - * capabilities are disallowed. - * - * Returns true if successful, or false if some error occurred. - */ -#ifdef HAVE_SYS_CAPABILITY_H -static _Bool -nsm_clear_capabilities(void) -{ - cap_t caps; - - caps = cap_from_text("cap_net_bind_service=ep"); - if (caps == NULL) { - xlog(L_ERROR, "Failed to allocate capability: %m"); - return false; - } - - if (cap_set_proc(caps) == -1) { - xlog(L_ERROR, "Failed to set capability flags: %m"); - (void)cap_free(caps); - return false; - } - - (void)cap_free(caps); - return true; -} - -#define CAP_BOUND_PROCFILE "/proc/sys/kernel/cap-bound" -static _Bool -prune_bounding_set(void) -{ -#ifdef PR_CAPBSET_DROP - int ret; - unsigned long i; - struct stat st; - - /* - * Prior to kernel 2.6.25, the capabilities bounding set was a global - * value. Check to see if /proc/sys/kernel/cap-bound exists and don't - * bother to clear the bounding set if it does. - */ - ret = stat(CAP_BOUND_PROCFILE, &st); - if (!ret) { - xlog(L_WARNING, "%s exists. Not attempting to clear " - "capabilities bounding set.", - CAP_BOUND_PROCFILE); - return true; - } else if (errno != ENOENT) { - /* Warn, but attempt to clear the bounding set anyway. */ - xlog(L_WARNING, "Unable to stat %s: %m", CAP_BOUND_PROCFILE); - } - - /* prune the bounding set to nothing */ - for (i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >=0 ; ++i) { - ret = prctl(PR_CAPBSET_DROP, i, 0, 0, 0); - if (ret) { - xlog(L_ERROR, "Unable to prune capability %lu from " - "bounding set: %m", i); - return false; - } - } -#endif /* PR_CAPBSET_DROP */ - return true; -} -#else /* !HAVE_SYS_CAPABILITY_H */ -static _Bool -nsm_clear_capabilities(void) -{ - return true; -} - -static _Bool -prune_bounding_set(void) -{ - return true; -} -#endif /* HAVE_SYS_CAPABILITY_H */ - -/** - * nsm_drop_privileges - drop root privileges - * @pidfd: file descriptor of a pid file - * - * Returns true if successful, or false if some error occurred. - * - * Set our effective UID and GID to that of our on-disk database. - */ -_Bool -nsm_drop_privileges(const int pidfd) -{ - struct stat st; - - (void)umask(S_IRWXO); - - if (chdir(nsm_base_dirname) == -1) { - xlog(L_ERROR, "Failed to change working directory to %s: %m", - nsm_base_dirname); - return false; - } - - if (lstat(NSM_MONITOR_DIR, &st) == -1) { - xlog(L_ERROR, "Failed to stat %s/%s: %m", nsm_base_dirname, NSM_MONITOR_DIR); - return false; - } - - if (!prune_bounding_set()) - return false; - - if (st.st_uid == 0) { - xlog_warn("Running as root. " - "chown %s to choose different user", nsm_base_dirname); - return true; - } - - /* - * If the pidfile happens to reside on NFS, dropping privileges - * will probably cause us to lose access, even though we are - * holding it open. Chown it to prevent this. - */ - if (pidfd >= 0) - if (fchown(pidfd, st.st_uid, st.st_gid) == -1) - xlog_warn("Failed to change owner of pidfile: %m"); - - /* - * Don't clear capabilities when dropping root. - */ - if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) { - xlog(L_ERROR, "prctl(PR_SET_KEEPCAPS) failed: %m"); - return false; - } - - if (setgroups(0, NULL) == -1) { - xlog(L_ERROR, "Failed to drop supplementary groups: %m"); - return false; - } - - /* - * ORDER - * - * setgid(2) first, as setuid(2) may remove privileges needed - * to set the group id. - */ - if (setgid(st.st_gid) == -1 || setuid(st.st_uid) == -1) { - xlog(L_ERROR, "Failed to drop privileges: %m"); - return false; - } - - xlog(D_CALL, "Effective UID, GID: %u, %u", st.st_uid, st.st_gid); - - return nsm_clear_capabilities(); -} - -/** - * nsm_get_state - retrieve on-disk NSM state number - * - * Returns an odd NSM state number read from disk, or an initial - * state number. Zero is returned if some error occurs. - */ -int -nsm_get_state(_Bool update) -{ - int fd, state = 0; - ssize_t result; - char *path = NULL; - - path = nsm_make_pathname(NSM_STATE_FILE); - if (path == NULL) { - xlog(L_ERROR, "Failed to allocate path for " NSM_STATE_FILE); - goto out; - } - - fd = open(path, O_RDONLY); - if (fd == -1) { - if (errno != ENOENT) { - xlog(L_ERROR, "Failed to open %s: %m", path); - goto out; - } - - xlog(L_NOTICE, "Initializing NSM state"); - state = 1; - update = true; - goto update; - } - - result = read(fd, &state, sizeof(state)); - if (exact_error_check(result, sizeof(state))) { - xlog_warn("Failed to read %s: %m", path); - - xlog(L_NOTICE, "Initializing NSM state"); - state = 1; - update = true; - goto update; - } - - if ((state & 1) == 0) - state++; - -update: - if(fd >= 0) - (void)close(fd); - - if (update) { - state += 2; - if (!nsm_atomic_write(path, &state, sizeof(state))) - state = 0; - } - -out: - free(path); - return state; -} - -/** - * nsm_update_kernel_state - attempt to post new NSM state to kernel - * @state: NSM state number - * - */ -void -nsm_update_kernel_state(const int state) -{ - ssize_t result; - char buf[20]; - int fd, len; - - fd = open(NSM_KERNEL_STATE_FILE, O_WRONLY); - if (fd == -1) { - xlog(D_GENERAL, "Failed to open " NSM_KERNEL_STATE_FILE ": %m"); - return; - } - - len = snprintf(buf, sizeof(buf), "%d", state); - if (error_check(len, sizeof(buf))) { - xlog_warn("Failed to form NSM state number string"); - close(fd); - return; - } - - result = write(fd, buf, strlen(buf)); - if (exact_error_check(result, strlen(buf))) - xlog_warn("Failed to write NSM state number: %m"); - - if (close(fd) == -1) - xlog(L_ERROR, "Failed to close NSM state file " - NSM_KERNEL_STATE_FILE ": %m"); -} - -/** - * nsm_retire_monitored_hosts - back up all hosts from "sm/" to "sm.bak/" - * - * Returns the count of host records that were moved. - * - * Note that if any error occurs during this process, some monitor - * records may be left in the "sm" directory. - */ -unsigned int -nsm_retire_monitored_hosts(void) -{ - unsigned int count = 0; - struct dirent *de; - char *path; - DIR *dir; - - path = nsm_make_pathname(NSM_MONITOR_DIR); - if (path == NULL) { - xlog(L_ERROR, "Failed to allocate path for " NSM_MONITOR_DIR); - return count; - } - - dir = opendir(path); - free(path); - if (dir == NULL) { - xlog_warn("Failed to open " NSM_MONITOR_DIR ": %m"); - return count; - } - - while ((de = readdir(dir)) != NULL) { - char *src, *dst; - struct stat stb; - - if (de->d_name[0] == '.') - continue; - - src = nsm_make_record_pathname(NSM_MONITOR_DIR, de->d_name); - if (src == NULL) { - xlog_warn("Bad monitor file name, skipping"); - continue; - } - - /* NB: not all file systems fill in d_type correctly */ - if (lstat(src, &stb) == -1) { - xlog_warn("Bad monitor file %s, skipping: %m", - de->d_name); - free(src); - continue; - } - if (!S_ISREG(stb.st_mode)) { - xlog(D_GENERAL, "Skipping non-regular file %s", - de->d_name); - free(src); - continue; - } - - dst = nsm_make_record_pathname(NSM_NOTIFY_DIR, de->d_name); - if (dst == NULL) { - free(src); - xlog_warn("Bad notify file name, skipping"); - continue; - } - - if (rename(src, dst) == -1) - xlog_warn("Failed to rename %s -> %s: %m", - src, dst); - else { - xlog(D_GENERAL, "Retired record for mon_name %s", - de->d_name); - count++; - } - - free(dst); - free(src); - } - - (void)closedir(dir); - return count; -} - -/* - * nsm_priv_to_hex - convert a NSM private cookie to a hex string. - * - * @priv: buffer holding the binary NSM private cookie - * @buf: output buffer for NULL terminated hex string - * @buflen: size of output buffer - * - * Returns the length of the resulting string or 0 on error - */ -size_t -nsm_priv_to_hex(const char *priv, char *buf, const size_t buflen) -{ - int i, len; - size_t remaining = buflen; - - for (i = 0; i < SM_PRIV_SIZE; i++) { - len = snprintf(buf, remaining, "%02x", - (unsigned int)(0xff & priv[i])); - if (error_check(len, remaining)) - return 0; - buf += len; - remaining -= (size_t)len; - } - - return buflen - remaining; -} - -/* - * Returns the length in bytes of the created record. - */ -__attribute__((__noinline__)) -static size_t -nsm_create_monitor_record(char *buf, const size_t buflen, - const struct sockaddr *sap, const struct mon *m) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - size_t hexlen, remaining = buflen; - int len; - - len = snprintf(buf, remaining, "%08x %08x %08x %08x ", - (unsigned int)sin->sin_addr.s_addr, - (unsigned int)m->mon_id.my_id.my_prog, - (unsigned int)m->mon_id.my_id.my_vers, - (unsigned int)m->mon_id.my_id.my_proc); - if (error_check(len, remaining)) - return 0; - buf += len; - remaining -= (size_t)len; - - hexlen = nsm_priv_to_hex(m->priv, buf, remaining); - if (hexlen == 0) - return 0; - buf += hexlen; - remaining -= hexlen; - - len = snprintf(buf, remaining, " %s %s\n", - m->mon_id.mon_name, m->mon_id.my_id.my_name); - if (error_check(len, remaining)) - return 0; - remaining -= (size_t)len; - - return buflen - remaining; -} - -static _Bool -nsm_append_monitored_host(const char *path, const char *line) -{ - _Bool result = false; - char *buf = NULL; - struct stat stb; - size_t buflen; - ssize_t len; - int fd; - - if (stat(path, &stb) == -1) { - xlog(L_ERROR, "Failed to insert: " - "could not stat original file %s: %m", path); - goto out; - } - buflen = (size_t)stb.st_size + strlen(line); - - buf = malloc(buflen + 1); - if (buf == NULL) { - xlog(L_ERROR, "Failed to insert: no memory"); - goto out; - } - memset(buf, 0, buflen + 1); - - fd = open(path, O_RDONLY); - if (fd == -1) { - xlog(L_ERROR, "Failed to insert: " - "could not open original file %s: %m", path); - goto out; - } - - len = read(fd, buf, (size_t)stb.st_size); - if (exact_error_check(len, (size_t)stb.st_size)) { - xlog(L_ERROR, "Failed to insert: " - "could not read original file %s: %m", path); - (void)close(fd); - goto out; - } - (void)close(fd); - - strcat(buf, line); - - if (nsm_atomic_write(path, buf, buflen)) - result = true; - -out: - free(buf); - return result; -} - -/** - * nsm_insert_monitored_host - write callback data for one host to disk - * @hostname: C string containing a hostname - * @sap: sockaddr containing NLM callback address - * @mon: SM_MON arguments to save - * - * Returns true if successful, otherwise false if some error occurs. - */ -_Bool -nsm_insert_monitored_host(const char *hostname, const struct sockaddr *sap, - const struct mon *m) -{ - static char buf[LINELEN + 1 + SM_MAXSTRLEN + 2]; - char *path; - _Bool result = false; - ssize_t len; - size_t size; - int fd; - - path = nsm_make_record_pathname(NSM_MONITOR_DIR, hostname); - if (path == NULL) { - xlog(L_ERROR, "Failed to insert: bad monitor hostname '%s'", - hostname); - return false; - } - - size = nsm_create_monitor_record(buf, sizeof(buf), sap, m); - if (size == 0) { - xlog(L_ERROR, "Failed to insert: record too long"); - goto out; - } - - /* - * If exclusive create fails, we're adding a new line to an - * existing file. - */ - fd = open(path, O_WRONLY | O_CREAT | O_EXCL | O_SYNC, S_IRUSR | S_IWUSR); - if (fd == -1) { - if (errno != EEXIST) { - xlog(L_ERROR, "Failed to insert: creating %s: %m", path); - goto out; - } - - result = nsm_append_monitored_host(path, buf); - goto out; - } - result = true; - - len = write(fd, buf, size); - if (exact_error_check(len, size)) { - xlog_warn("Failed to insert: writing %s: %m", path); - (void)unlink(path); - result = false; - } - - if (close(fd) == -1) { - xlog(L_ERROR, "Failed to insert: closing %s: %m", path); - (void)unlink(path); - result = false; - } - -out: - free(path); - return result; -} - -__attribute__((__noinline__)) -static _Bool -nsm_parse_line(char *line, struct sockaddr_in *sin, struct mon *m) -{ - unsigned int i, tmp; - int count; - char *c; - - c = strchr(line, '\n'); - if (c != NULL) - *c = '\0'; - - count = sscanf(line, "%8x %8x %8x %8x ", - (unsigned int *)&sin->sin_addr.s_addr, - (unsigned int *)&m->mon_id.my_id.my_prog, - (unsigned int *)&m->mon_id.my_id.my_vers, - (unsigned int *)&m->mon_id.my_id.my_proc); - if (count != 4) - return false; - - c = line + RPCARGSLEN; - for (i = 0; i < SM_PRIV_SIZE; i++) { - if (sscanf(c, "%2x", &tmp) != 1) - return false; - m->priv[i] = (char)tmp; - c += 2; - } - - c++; - m->mon_id.mon_name = c; - while (*c != '\0' && *c != ' ') - c++; - if (*c != '\0') - *c++ = '\0'; - while (*c == ' ') - c++; - m->mon_id.my_id.my_name = c; - - return true; -} - -/* - * Stuff a 'struct mon' with callback data, and call @func. - * - * Returns the count of in-core records created. - */ -static unsigned int -nsm_read_line(const char *hostname, const time_t timestamp, char *line, - nsm_populate_t func) -{ - struct sockaddr_in sin = { - .sin_family = AF_INET, - }; - struct mon m; - - if (!nsm_parse_line(line, &sin, &m)) - return 0; - - return func(hostname, (struct sockaddr *)(char *)&sin, &m, timestamp); -} - -/* - * Given a filename, reads data from a file under "directory" - * and invokes @func so caller can populate their in-core - * database with this data. - */ -static unsigned int -nsm_load_host(const char *directory, const char *filename, nsm_populate_t func) -{ - char buf[LINELEN + 1 + SM_MAXSTRLEN + 2]; - unsigned int result = 0; - struct stat stb; - char *path; - FILE *f; - - path = nsm_make_record_pathname(directory, filename); - if (path == NULL) - goto out_err; - - if (lstat(path, &stb) == -1) { - xlog(L_ERROR, "Failed to stat %s: %m", path); - goto out_freepath; - } - if (!S_ISREG(stb.st_mode)) { - xlog(D_GENERAL, "Skipping non-regular file %s", - path); - goto out_freepath; - } - - f = fopen(path, "r"); - if (f == NULL) { - xlog(L_ERROR, "Failed to open %s: %m", path); - goto out_freepath; - } - - while (fgets(buf, (int)sizeof(buf), f) != NULL) { - buf[sizeof(buf) - 1] = '\0'; - result += nsm_read_line(filename, stb.st_mtime, buf, func); - } - if (result == 0) - xlog(L_ERROR, "Failed to read monitor data from %s", path); - - (void)fclose(f); - -out_freepath: - free(path); -out_err: - return result; -} - -static unsigned int -nsm_load_dir(const char *directory, nsm_populate_t func) -{ - unsigned int count = 0; - struct dirent *de; - char *path; - DIR *dir; - - path = nsm_make_pathname(directory); - if (path == NULL) { - xlog(L_ERROR, "Failed to allocate path for directory %s", - directory); - return 0; - } - - dir = opendir(path); - free(path); - if (dir == NULL) { - xlog(L_ERROR, "Failed to open directory %s: %m", - directory); - return 0; - } - - while ((de = readdir(dir)) != NULL) { - if (de->d_name[0] == '.') - continue; - - count += nsm_load_host(directory, de->d_name, func); - } - - (void)closedir(dir); - return count; -} - -/** - * nsm_load_monitor_list - load list of hosts to monitor - * @func: callback function to create entry for one host - * - * Returns the count of hosts that were found in the directory. - */ -unsigned int -nsm_load_monitor_list(nsm_populate_t func) -{ - return nsm_load_dir(NSM_MONITOR_DIR, func); -} - -/** - * nsm_load_notify_list - load list of hosts to notify - * @func: callback function to create entry for one host - * - * Returns the count of hosts that were found in the directory. - */ -unsigned int -nsm_load_notify_list(nsm_populate_t func) -{ - return nsm_load_dir(NSM_NOTIFY_DIR, func); -} - -static void -nsm_delete_host(const char *directory, const char *hostname, - const char *mon_name, const char *my_name, const int chatty) -{ - char line[LINELEN + 1 + SM_MAXSTRLEN + 2]; - char *outbuf = NULL; - struct stat stb; - char *path, *next; - size_t remaining; - FILE *f; - - path = nsm_make_record_pathname(directory, hostname); - if (path == NULL) { - xlog(L_ERROR, "Bad filename, not deleting"); - return; - } - - if (stat(path, &stb) == -1) { - if (chatty) - xlog(L_ERROR, "Failed to delete: " - "could not stat original file %s: %m", path); - goto out; - } - remaining = (size_t)stb.st_size + 1; - - outbuf = malloc(remaining); - if (outbuf == NULL) { - xlog(L_ERROR, "Failed to delete: no memory"); - goto out; - } - - f = fopen(path, "r"); - if (f == NULL) { - xlog(L_ERROR, "Failed to delete: " - "could not open original file %s: %m", path); - goto out; - } - - /* - * Walk the records in the file, and copy the non-matching - * ones to our output buffer. - */ - next = outbuf; - while (fgets(line, (int)sizeof(line), f) != NULL) { - struct sockaddr_in sin; - struct mon m; - size_t len; - - if (!nsm_parse_line(line, &sin, &m)) { - xlog(L_ERROR, "Failed to delete: " - "could not parse original file %s", path); - (void)fclose(f); - goto out; - } - - if (strcmp(mon_name, m.mon_id.mon_name) == 0 && - strcmp(my_name, m.mon_id.my_id.my_name) == 0) - continue; - - /* nsm_parse_line destroys the contents of line[], so - * reconstruct the copy in our output buffer. */ - len = nsm_create_monitor_record(next, remaining, - (struct sockaddr *)(char *)&sin, &m); - if (len == 0) { - xlog(L_ERROR, "Failed to delete: " - "could not construct output record"); - (void)fclose(f); - goto out; - } - next += len; - remaining -= len; - } - - (void)fclose(f); - - /* - * If nothing was copied when we're done, then unlink the file. - * Otherwise, atomically update the contents of the file. - */ - if (next != outbuf) { - if (!nsm_atomic_write(path, outbuf, strlen(outbuf))) - xlog(L_ERROR, "Failed to delete: " - "could not write new file %s: %m", path); - } else { - if (unlink(path) == -1) - xlog(L_ERROR, "Failed to delete: " - "could not unlink file %s: %m", path); - } - -out: - free(outbuf); - free(path); -} - -/** - * nsm_delete_monitored_host - delete on-disk record for monitored host - * @hostname: '\0'-terminated C string containing hostname of record to delete - * @mon_name: '\0'-terminated C string containing monname of record to delete - * @my_name: '\0'-terminated C string containing myname of record to delete - * @chatty: should an error be logged if the monitor file doesn't exist? - * - */ -void -nsm_delete_monitored_host(const char *hostname, const char *mon_name, - const char *my_name, const int chatty) -{ - nsm_delete_host(NSM_MONITOR_DIR, hostname, mon_name, my_name, chatty); -} - -/** - * nsm_delete_notified_host - delete on-disk host record after notification - * @hostname: '\0'-terminated C string containing hostname of record to delete - * @mon_name: '\0'-terminated C string containing monname of record to delete - * @my_name: '\0'-terminated C string containing myname of record to delete - * - */ -void -nsm_delete_notified_host(const char *hostname, const char *mon_name, - const char *my_name) -{ - nsm_delete_host(NSM_NOTIFY_DIR, hostname, mon_name, my_name, 1); -} diff --git a/nfs-utils-2.5.2/support/nsm/rpc.c b/nfs-utils-2.5.2/support/nsm/rpc.c deleted file mode 100644 index 08b4746..0000000 --- a/nfs-utils-2.5.2/support/nsm/rpc.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -/* - * NSM for Linux. - * - * Instead of using ONC or TI RPC library calls, statd constructs - * RPC calls directly in socket buffers. This allows a single - * socket to be concurrently shared among several different RPC - * programs and versions using a simple RPC request dispatcher. - * - * This file contains the details of RPC header and call - * construction and reply parsing, and a method for creating a - * socket for use with these functions. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef HAVE_LIBTIRPC -#include -#include -#endif /* HAVE_LIBTIRPC */ - -#include "xlog.h" -#include "nfsrpc.h" -#include "nsm.h" -#include "sm_inter.h" - -/* - * Returns a fresh XID appropriate for RPC over UDP -- never zero. - */ -static uint32_t -nsm_next_xid(void) -{ - static uint32_t nsm_xid = 0; - struct timeval now; - - if (nsm_xid == 0) { - (void)gettimeofday(&now, NULL); - nsm_xid = (uint32_t)getpid() ^ - (uint32_t)now.tv_sec ^ (uint32_t)now.tv_usec; - } - - return nsm_xid++; -} - -/* - * Select a fresh XID and construct an RPC header in @mesg. - * Always use AUTH_NULL credentials and verifiers. - * - * Returns the new XID. - */ -static uint32_t -nsm_init_rpc_header(const rpcprog_t program, const rpcvers_t version, - const rpcproc_t procedure, struct rpc_msg *mesg) -{ - struct call_body *cb = &mesg->rm_call; - uint32_t xid = nsm_next_xid(); - - memset(mesg, 0, sizeof(*mesg)); - - mesg->rm_xid = (unsigned long)xid; - mesg->rm_direction = CALL; - - cb->cb_rpcvers = RPC_MSG_VERSION; - cb->cb_prog = program; - cb->cb_vers = version; - cb->cb_proc = procedure; - - cb->cb_cred.oa_flavor = AUTH_NULL; - cb->cb_cred.oa_base = (caddr_t) NULL; - cb->cb_cred.oa_length = 0; - cb->cb_verf.oa_flavor = AUTH_NULL; - cb->cb_verf.oa_base = (caddr_t) NULL; - cb->cb_verf.oa_length = 0; - - return xid; -} - -/* - * Initialize the network send buffer and XDR memory for encoding. - */ -static void -nsm_init_xdrmem(char *msgbuf, const unsigned int msgbuflen, - XDR *xdrp) -{ - memset(msgbuf, 0, (size_t)msgbuflen); - memset(xdrp, 0, sizeof(*xdrp)); - xdrmem_create(xdrp, msgbuf, msgbuflen, XDR_ENCODE); -} - -/* - * Send a completed RPC call on a socket. - * - * Returns true if all the bytes were sent successfully; otherwise - * false if any error occurred. - */ -static _Bool -nsm_rpc_sendto(const int sock, const struct sockaddr *sap, - const socklen_t salen, XDR *xdrs, void *buf) -{ - const size_t buflen = (size_t)xdr_getpos(xdrs); - ssize_t err; - - err = sendto(sock, buf, buflen, 0, sap, salen); - if ((err < 0) || ((size_t)err != buflen)) { - xlog(L_ERROR, "%s: sendto failed: %m", __func__); - return false; - } - return true; -} - -/** - * nsm_xmit_getport - post a PMAP_GETPORT call on a socket descriptor - * @sock: datagram socket descriptor - * @sin: pointer to AF_INET socket address of server - * @program: RPC program number to query - * @version: RPC version number to query - * - * Send a PMAP_GETPORT call to the portmap daemon at @sin using - * socket descriptor @sock. This request queries the RPC program - * [program, version, IPPROTO_UDP]. - * - * NB: PMAP_GETPORT works only for IPv4 hosts. This implementation - * works only over UDP, and queries only UDP registrations. - * - * Returns the XID of the call, or zero if an error occurred. - */ -uint32_t -nsm_xmit_getport(const int sock, const struct sockaddr_in *sin, - const unsigned long program, - const unsigned long version) -{ - char msgbuf[NSM_MAXMSGSIZE]; - struct sockaddr_in addr; - struct rpc_msg mesg; - _Bool sent = false; - struct pmap parms = { - .pm_prog = program, - .pm_vers = version, - .pm_prot = (unsigned long)IPPROTO_UDP, - }; - uint32_t xid; - XDR xdr; - - xlog(D_CALL, "Sending PMAP_GETPORT for %lu, %lu, udp", program, version); - - nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr); - xid = nsm_init_rpc_header(PMAPPROG, PMAPVERS, - (rpcproc_t)PMAPPROC_GETPORT, &mesg); - - addr = *sin; - addr.sin_port = htons(PMAPPORT); - - if (xdr_callmsg(&xdr, &mesg) == TRUE && - xdr_pmap(&xdr, &parms) == TRUE) - sent = nsm_rpc_sendto(sock, (struct sockaddr *)(char *)&addr, - (socklen_t)sizeof(addr), &xdr, msgbuf); - else - xlog(L_ERROR, "%s: can't encode PMAP_GETPORT call", __func__); - - xdr_destroy(&xdr); - - if (sent == false) - return 0; - return xid; -} - -/** - * nsm_xmit_getaddr - post an RPCB_GETADDR call on a socket descriptor - * @sock: datagram socket descriptor - * @sin: pointer to AF_INET6 socket address of server - * @program: RPC program number to query - * @version: RPC version number to query - * - * Send an RPCB_GETADDR call to the rpcbind daemon at @sap using - * socket descriptor @sock. This request queries the RPC program - * [program, version, "udp6"]. - * - * NB: RPCB_GETADDR works for both IPv4 and IPv6 hosts. This - * implementation works only over UDP and AF_INET6, and queries - * only "udp6" registrations. - * - * Returns the XID of the call, or zero if an error occurred. - */ -#ifdef HAVE_LIBTIRPC -uint32_t -nsm_xmit_getaddr(const int sock, const struct sockaddr_in6 *sin6, - const rpcprog_t program, const rpcvers_t version) -{ - char msgbuf[NSM_MAXMSGSIZE]; - struct sockaddr_in6 addr; - struct rpc_msg mesg; - _Bool sent = false; - struct rpcb parms = { - .r_prog = program, - .r_vers = version, - .r_netid = "udp6", - .r_owner = "", - }; - uint32_t xid; - XDR xdr; - - xlog(D_CALL, "Sending RPCB_GETADDR for %u, %u, udp6", program, version); - - nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr); - xid = nsm_init_rpc_header(RPCBPROG, RPCBVERS, - (rpcproc_t)RPCBPROC_GETADDR, &mesg); - - addr = *sin6; - addr.sin6_port = htons(PMAPPORT); - parms.r_addr = nfs_sockaddr2universal((struct sockaddr *)(char *)&addr); - if (parms.r_addr == NULL) { - xlog(L_ERROR, "%s: can't encode socket address", __func__); - return 0; - } - - if (xdr_callmsg(&xdr, &mesg) == TRUE && - xdr_rpcb(&xdr, &parms) == TRUE) - sent = nsm_rpc_sendto(sock, (struct sockaddr *)(char *)&addr, - (socklen_t)sizeof(addr), &xdr, msgbuf); - else - xlog(L_ERROR, "%s: can't encode RPCB_GETADDR call", __func__); - - xdr_destroy(&xdr); - free(parms.r_addr); - - if (sent == false) - return 0; - return xid; -} -#else /* !HAVE_LIBTIRPC */ -uint32_t -nsm_xmit_getaddr(const int sock __attribute__((unused)), - const struct sockaddr_in6 *sin6 __attribute__((unused)), - const rpcprog_t program __attribute__((unused)), - const rpcvers_t version __attribute__((unused))) -{ - return 0; -} -#endif /* !HAVE_LIBTIRPC */ - -/** - * nsm_xmit_rpcbind - post an rpcbind request - * @sock: datagram socket descriptor - * @sap: pointer to socket address of server - * @program: RPC program number to query - * @version: RPC version number to query - * - * Send an rpcbind query to the rpcbind daemon at @sap using - * socket descriptor @sock. - * - * NB: This implementation works only over UDP, but can query IPv4 or IPv6 - * hosts. It queries only UDP registrations. - * - * Returns the XID of the call, or zero if an error occurred. - */ -uint32_t -nsm_xmit_rpcbind(const int sock, const struct sockaddr *sap, - const rpcprog_t program, const rpcvers_t version) -{ - switch (sap->sa_family) { - case AF_INET: - return nsm_xmit_getport(sock, (const struct sockaddr_in *)sap, - program, version); - case AF_INET6: - return nsm_xmit_getaddr(sock, (const struct sockaddr_in6 *)sap, - program, version); - } - return 0; -} - -/** - * nsm_xmit_notify - post an NSMPROC_NOTIFY call on a socket descriptor - * @sock: datagram socket descriptor - * @sap: pointer to socket address of peer to notify (port already filled in) - * @salen: length of socket address - * @program: RPC program number to use - * @mon_name: mon_name of local peer (ie the rebooting system) - * @state: state of local peer - * - * Send an NSMPROC_NOTIFY call to the peer at @sap using socket descriptor @sock. - * This request notifies the peer that we have rebooted. - * - * NB: This implementation works only over UDP, but supports both AF_INET - * and AF_INET6. - * - * Returns the XID of the call, or zero if an error occurred. - */ -uint32_t -nsm_xmit_notify(const int sock, const struct sockaddr *sap, - const socklen_t salen, const rpcprog_t program, - const char *mon_name, const int state) -{ - char msgbuf[NSM_MAXMSGSIZE]; - struct stat_chge state_change; - struct rpc_msg mesg; - _Bool sent = false; - uint32_t xid; - XDR xdr; - - state_change.mon_name = strdup(mon_name); - if (state_change.mon_name == NULL) { - xlog(L_ERROR, "%s: no memory", __func__); - return 0; - } - state_change.state = state; - - xlog(D_CALL, "Sending SM_NOTIFY for %s", mon_name); - - nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr); - xid = nsm_init_rpc_header(program, SM_VERS, SM_NOTIFY, &mesg); - - if (xdr_callmsg(&xdr, &mesg) == TRUE && - xdr_stat_chge(&xdr, &state_change) == TRUE) - sent = nsm_rpc_sendto(sock, sap, salen, &xdr, msgbuf); - else - xlog(L_ERROR, "%s: can't encode NSMPROC_NOTIFY call", - __func__); - - xdr_destroy(&xdr); - free(state_change.mon_name); - - if (sent == false) - return 0; - return xid; -} - -/** - * nsm_xmit_nlmcall - post an unnamed call to local NLM on a socket descriptor - * @sock: datagram socket descriptor - * @sap: address/port of NLM service to contact - * @salen: size of @sap - * @m: callback data defining RPC call to make - * @state: state of rebooting host - * - * Send an unnamed call (previously requested via NSMPROC_MON) to the - * specified local UDP-based RPC service using socket descriptor @sock. - * - * NB: This implementation works only over UDP, but supports both AF_INET - * and AF_INET6. - * - * Returns the XID of the call, or zero if an error occurred. - */ -uint32_t -nsm_xmit_nlmcall(const int sock, const struct sockaddr *sap, - const socklen_t salen, const struct mon *m, - const int state) -{ - const struct my_id *id = &m->mon_id.my_id; - char msgbuf[NSM_MAXMSGSIZE]; - struct status new_status; - struct rpc_msg mesg; - _Bool sent = false; - uint32_t xid; - XDR xdr; - - xlog(D_CALL, "Sending NLM downcall for %s", m->mon_id.mon_name); - - nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr); - xid = nsm_init_rpc_header((rpcprog_t)id->my_prog, - (rpcvers_t)id->my_vers, - (rpcproc_t)id->my_proc, &mesg); - - new_status.mon_name = m->mon_id.mon_name; - new_status.state = state; - memcpy(&new_status.priv, &m->priv, sizeof(new_status.priv)); - - if (xdr_callmsg(&xdr, &mesg) == TRUE && - xdr_status(&xdr, &new_status) == TRUE) - sent = nsm_rpc_sendto(sock, sap, salen, &xdr, msgbuf); - else - xlog(L_ERROR, "%s: can't encode NLM downcall", __func__); - - xdr_destroy(&xdr); - - if (sent == false) - return 0; - return xid; -} - -/** - * nsm_parse_reply - parse and validate the header in an RPC reply - * @xdrs: pointer to XDR - * - * Returns the XID of the reply, or zero if an error occurred. - */ -uint32_t -nsm_parse_reply(XDR *xdrs) -{ - struct rpc_msg mesg = { - .rm_reply.rp_acpt.ar_results.proc = (xdrproc_t)xdr_void, - }; - uint32_t xid; - - if (xdr_replymsg(xdrs, &mesg) == FALSE) { - xlog(L_ERROR, "%s: can't decode RPC reply", __func__); - return 0; - } - xid = (uint32_t)mesg.rm_xid; - - if (mesg.rm_reply.rp_stat != MSG_ACCEPTED) { - xlog(L_ERROR, "%s: [0x%x] RPC status %d", - __func__, xid, mesg.rm_reply.rp_stat); - return 0; - } - - if (mesg.rm_reply.rp_acpt.ar_stat != SUCCESS) { - xlog(L_ERROR, "%s: [0x%x] RPC accept status %d", - __func__, xid, mesg.rm_reply.rp_acpt.ar_stat); - return 0; - } - - return xid; -} - -/** - * nsm_recv_getport - parse PMAP_GETPORT reply - * @xdrs: pointer to XDR - * - * Returns the port number from the RPC reply, or zero - * if an error occurred. - */ -unsigned long -nsm_recv_getport(XDR *xdrs) -{ - unsigned long port = 0; - - if (xdr_u_long(xdrs, &port) == FALSE) - xlog(L_ERROR, "%s: can't decode pmap reply", - __func__); - if (port > UINT16_MAX) { - xlog(L_ERROR, "%s: bad port number", - __func__); - port = 0; - } - - xlog(D_CALL, "Received PMAP_GETPORT result: %lu", port); - return port; -} - -/** - * nsm_recv_getaddr - parse RPCB_GETADDR reply - * @xdrs: pointer to XDR - * - * Returns the port number from the RPC reply, or zero - * if an error occurred. - */ -uint16_t -nsm_recv_getaddr(XDR *xdrs) -{ - char *uaddr = NULL; - int port; - - if (xdr_wrapstring(xdrs, &uaddr) == FALSE) - xlog(L_ERROR, "%s: can't decode rpcb reply", - __func__); - - if ((uaddr == NULL) || (uaddr[0] == '\0')) { - xlog(D_CALL, "Received RPCB_GETADDR result: " - "program not registered"); - return 0; - } - - port = nfs_universal2port(uaddr); - - xdr_free((xdrproc_t)xdr_wrapstring, (char *)&uaddr); - - if (port < 0 || port > UINT16_MAX) { - xlog(L_ERROR, "%s: bad port number", - __func__); - return 0; - } - - xlog(D_CALL, "Received RPCB_GETADDR result: %d", port); - return (uint16_t)port; -} - -/** - * nsm_recv_rpcbind - parse rpcbind reply - * @af: address family of reply - * @xdrs: pointer to XDR - * - * Returns the port number from the RPC reply, or zero - * if an error occurred. - */ -uint16_t -nsm_recv_rpcbind(const sa_family_t family, XDR *xdrs) -{ - switch (family) { - case AF_INET: - return (uint16_t)nsm_recv_getport(xdrs); - case AF_INET6: - return nsm_recv_getaddr(xdrs); - } - return 0; -} diff --git a/nfs-utils-2.5.2/support/nsm/sm_inter.x b/nfs-utils-2.5.2/support/nsm/sm_inter.x deleted file mode 100644 index d8e0ad7..0000000 --- a/nfs-utils-2.5.2/support/nsm/sm_inter.x +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 1986 Sun Microsystems, Inc. - * Modified by Jeffrey A. Uphoff, 1995, 1997-1999. - * Modified by Olaf Kirch, 1996. - * Modified by H.J. Lu, 1998. - * - * NSM for Linux. - */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Status monitor protocol specification - */ - -#ifdef RPC_CLNT -%#include -#endif - -program SM_PROG { - version SM_VERS { - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* if res_stat == stat_succ, state = state number of site sm_name */ - struct sm_stat_res SM_STAT(struct sm_name) = 1; - - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* stat consists of state number of local site */ - struct sm_stat_res SM_MON(struct mon) = 2; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON(struct mon_id) = 3; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON_ALL(struct my_id) = 4; - - void SM_SIMU_CRASH(void) = 5; - - void SM_NOTIFY(struct stat_chge) = 6; - - } = 1; -} = 100024; - -const SM_MAXSTRLEN = 1024; -const SM_PRIV_SIZE = 16; - -struct sm_name { - string mon_name; -}; - -struct my_id { - string my_name; /* name of the site iniates the monitoring request*/ - int my_prog; /* rpc program # of the requesting process */ - int my_vers; /* rpc version # of the requesting process */ - int my_proc; /* rpc procedure # of the requesting process */ -}; - -struct mon_id { - string mon_name; /* name of the site to be monitored */ - struct my_id my_id; -}; - - -struct mon { - struct mon_id mon_id; - opaque priv[SM_PRIV_SIZE]; /* private information to store at monitor for requesting process */ -}; - -struct stat_chge { - string mon_name; /* name of the site that had the state change */ - int state; -}; - -/* - * state # of status monitor monitonically increases each time - * status of the site changes: - * an even number (>= 0) indicates the site is down and - * an odd number (> 0) indicates the site is up; - */ -struct sm_stat { - int state; /* state # of status monitor */ -}; - -enum res { - stat_succ = 0, /* status monitor agrees to monitor */ - stat_fail = 1 /* status monitor cannot monitor */ -}; - -struct sm_stat_res { - res res_stat; - int state; -}; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct status { - string mon_name; - int state; - opaque priv[SM_PRIV_SIZE]; /* stored private information */ -}; - -%#define SM_INTER_X diff --git a/nfs-utils-2.5.2/systemd/Makefile.am b/nfs-utils-2.5.2/systemd/Makefile.am deleted file mode 100644 index 75cdd9f..0000000 --- a/nfs-utils-2.5.2/systemd/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -## Process this file with automake to produce Makefile.in - -MAINTAINERCLEANFILES = Makefile.in - -unit_files = \ - nfs-client.target \ - rpc_pipefs.target \ - \ - nfs-mountd.service \ - nfs-server.service \ - nfs-utils.service \ - rpc-statd-notify.service \ - rpc-statd.service \ - \ - proc-fs-nfsd.mount \ - var-lib-nfs-rpc_pipefs.mount - -if CONFIG_NFSV4 -unit_files += \ - nfs-idmapd.service -endif - -if CONFIG_NFSV41 -unit_files += \ - nfs-blkmap.service -endif - -if CONFIG_GSS -unit_files += \ - auth-rpcgss-module.service \ - rpc-gssd.service - -if CONFIG_SVCGSS -unit_files += \ - rpc-svcgssd.service -endif -endif - -if CONFIG_NFSDCLD -unit_files += \ - nfsdcld.service -endif - -man5_MANS = nfs.conf.man -man7_MANS = nfs.systemd.man -EXTRA_DIST = $(unit_files) $(man5_MANS) $(man7_MANS) - -unit_dir = /usr/lib/systemd/system -generator_dir = /usr/lib/systemd/system-generators - -EXTRA_PROGRAMS = nfs-server-generator rpc-pipefs-generator -genexecdir = $(generator_dir) - -COMMON_SRCS = systemd.c systemd.h - -nfs_server_generator_SOURCES = $(COMMON_SRCS) nfs-server-generator.c - -rpc_pipefs_generator_SOURCES = $(COMMON_SRCS) rpc-pipefs-generator.c - -nfs_server_generator_LDADD = ../support/export/libexport.a \ - ../support/nfs/libnfs.la \ - ../support/misc/libmisc.a \ - $(LIBPTHREAD) - -rpc_pipefs_generator_LDADD = ../support/nfs/libnfs.la - -if INSTALL_SYSTEMD -genexec_PROGRAMS = nfs-server-generator rpc-pipefs-generator -install-data-hook: $(unit_files) - mkdir -p $(DESTDIR)/$(unitdir) - cp $(unit_files) $(DESTDIR)/$(unitdir) -endif diff --git a/nfs-utils-2.5.2/systemd/README b/nfs-utils-2.5.2/systemd/README deleted file mode 100644 index da23d6f..0000000 --- a/nfs-utils-2.5.2/systemd/README +++ /dev/null @@ -1,79 +0,0 @@ - -Notes about systemd unit files for nfs-utils. - -The unit files provided here should be sufficient for systemd -to manage all daemons and related services provides by nfs-utils. - -They do *not* include any unit files for separate services such as -rpc.rquotad (in the 'quota' package) or rpcbind. - -There are 4 units that can be 'enabled' or 'disabled' by systemctl, or -by a suitable 'preset' setting: - - nfs-server.service - If enabled, nfs service is started together with dependencies - such as mountd, statd, rpc.idmapd - This is a "service" file rather than a "target" (which is the - normal grouping construct) so that - systemctl start nfs-server - can work (if no type is given, ".service" is assumed). - - nfs-client.target - If enabled, daemons needed for an nfs client are enabled. - This does *not* include rpc.statd. The rpc-statd.service unit - is started by /usr/sbin/start-statd which mount.nfs will run - if statd is needed. - - nfs-blkmap.service - If enabled, then blkmapd will be run when nfs-client.target is - started. - -Another special unit is "nfs-utils.service". This doesn't really do -anything, but exists so that other units may declare themselves as -"PartOf" nfs-utils.service. -The effect of this is that - systemctl restart nfs-utils -will restart all nfs-utils daemons as maybe be required during -software update. It isn't possible to make - systemctl try-restart nfs-server nfs-client.target -do this as some daemon are included in both, and rpc.statd would -not be restarted if nfs-server were not active (as nfs-client doesn't -Want it - it is started by mount.nfs running start-statd). - -It is possible that we should have an nfs-statd.target which can -selectively enable statd being stared by -server and sm-notify -being started by -server or -client. That way it could be disabled -completely on V4-only configurations. Currently statd is always -started on the server and sm-notify is always run if server or -client is enabled. - -Stopping nfs-server will also stop rpc.mountd, and rpc.svcgssd. -It cannot stop rpc.statd or rpc.gssd as they may be in use by the -client and systemd cannot specify is two-pronged reverse dependency. -(i.e. stop this unit if none of these units are running) - -Distro specific configuration can be included in /etc/nfs.conf, or -by providing drop-in files which replace the ExecStart line for a given -service, and possibly add an EnvironmentFile line. - -For example, if systemd/system/nfs-mountd.service.d/local.conf -contained - [Service] - EnvironmentFile=/etc/sysconfig/nfs - ExecStart= - ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDOPTS - -then the setting of RPCMOUNTDOPTS in /etc/sysconfig/nfs would be -passed to rpc.mountd. - -rpc.gssd and rpc.svcgssd are assumed to be needed if /etc/krb5.keytab -is present. -If a site needs this file present but does not want the gss daemons -running, it should create - /etc/systemd/system/rpc-gssd.service.d/01-disable.conf -and - /etc/systemd/system/rpc-svcgssd.service.d/01-disable.conf - -containing - [Unit] - ConditionNull=false diff --git a/nfs-utils-2.5.2/systemd/auth-rpcgss-module.service b/nfs-utils-2.5.2/systemd/auth-rpcgss-module.service deleted file mode 100644 index 4548283..0000000 --- a/nfs-utils-2.5.2/systemd/auth-rpcgss-module.service +++ /dev/null @@ -1,17 +0,0 @@ -# We want to start gss-proxy on kernels that support it and rpc.svcgssd -# on those that don't. Those services check for support by checking -# for existence of the path /proc/net/rpc/use-gss-proxy. Before they -# can perform that check, they need this module loaded. (Unless -# rpcsec_gss support is built directly into the kernel, in which case this -# unit will fail. But that's OK.) -[Unit] -Description=Kernel Module supporting RPCSEC_GSS -DefaultDependencies=no -Before=gssproxy.service rpc-svcgssd.service rpc-gssd.service -Wants=gssproxy.service rpc-svcgssd.service rpc-gssd.service -ConditionPathExists=/etc/krb5.keytab - -[Service] -Type=oneshot -ExecStart=/sbin/modprobe -q auth_rpcgss -RemainAfterExit=yes diff --git a/nfs-utils-2.5.2/systemd/nfs-blkmap.service b/nfs-utils-2.5.2/systemd/nfs-blkmap.service deleted file mode 100644 index 6aa45ba..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-blkmap.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=pNFS block layout mapping daemon -DefaultDependencies=no -Conflicts=umount.target -After=rpc_pipefs.target -Requires=rpc_pipefs.target - -PartOf=nfs-utils.service - -[Service] -Type=forking -PIDFile=/run/blkmapd.pid -ExecStart=/usr/sbin/blkmapd - -[Install] -WantedBy=nfs-client.target diff --git a/nfs-utils-2.5.2/systemd/nfs-client.target b/nfs-utils-2.5.2/systemd/nfs-client.target deleted file mode 100644 index 8a8300a..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-client.target +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=NFS client services -Before=remote-fs-pre.target -Wants=remote-fs-pre.target - -# Note: we don't "Wants=rpc-statd.service" as "mount.nfs" will arrange to -# start that on demand if needed. -Wants=rpc-statd-notify.service - -# GSS services dependencies and ordering -Wants=auth-rpcgss-module.service -After=rpc-gssd.service rpc-svcgssd.service gssproxy.service - -[Install] -WantedBy=multi-user.target -WantedBy=remote-fs.target diff --git a/nfs-utils-2.5.2/systemd/nfs-idmapd.service b/nfs-utils-2.5.2/systemd/nfs-idmapd.service deleted file mode 100644 index f38fe52..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-idmapd.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=NFSv4 ID-name mapping service -DefaultDependencies=no -Requires=rpc_pipefs.target -After=rpc_pipefs.target local-fs.target - -BindsTo=nfs-server.service - -[Service] -Type=forking -ExecStart=/usr/sbin/rpc.idmapd diff --git a/nfs-utils-2.5.2/systemd/nfs-mountd.service b/nfs-utils-2.5.2/systemd/nfs-mountd.service deleted file mode 100644 index e8ece53..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-mountd.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=NFS Mount Daemon -DefaultDependencies=no -Requires=proc-fs-nfsd.mount -Wants=network-online.target -After=proc-fs-nfsd.mount -After=network-online.target local-fs.target -After=rpcbind.socket -BindsTo=nfs-server.service - -[Service] -Type=forking -ExecStart=/usr/sbin/rpc.mountd diff --git a/nfs-utils-2.5.2/systemd/nfs-server-generator.c b/nfs-utils-2.5.2/systemd/nfs-server-generator.c deleted file mode 100644 index eec98fd..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-server-generator.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * nfs-server-generator: - * systemd generator to create ordering dependencies between - * nfs-server and various filesystem mounts - * - * 1/ nfs-server should start Before any 'nfs' mountpoints are - * mounted, in case they are loop-back mounts. This ordering is particularly - * important for the shutdown side, so the nfs-server is stopped - * after the filesystems are unmounted. - * 2/ nfs-server should start After all exported filesystems are mounted - * so there is no risk of exporting the underlying directory. - * This is particularly important for _net mounts which - * are not caught by "local-fs.target". - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "misc.h" -#include "nfslib.h" -#include "exportfs.h" -#include "systemd.h" - -/* A simple "set of strings" to remove duplicates - * found in /etc/exports - */ -struct list { - struct list *next; - char *name; -}; -static int is_unique(struct list **lp, char *path) -{ - struct list *l = *lp; - - while (l) { - if (strcmp(l->name, path) == 0) - return 0; - l = l->next; - } - l = malloc(sizeof(*l)); - if (l == NULL) - return 0; - l->name = path; - l->next = *lp; - *lp = l; - return 1; -} - -static int has_noauto_flag(char *path) -{ - FILE *fstab; - struct mntent *mnt; - - fstab = setmntent("/etc/fstab", "r"); - if (!fstab) - return 0; - - while ((mnt = getmntent(fstab)) != NULL) { - int l = strlen(mnt->mnt_dir); - if (strncmp(mnt->mnt_dir, path, l) != 0) - continue; - if (path[l] && path[l] != '/') - continue; - if (hasmntopt(mnt, "noauto")) - break; - } - fclose(fstab); - return mnt != NULL; -} - -int main(int argc, char *argv[]) -{ - char *path, *spath; - char dirbase[] = "/nfs-server.service.d"; - char filebase[] = "/order-with-mounts.conf"; - nfs_export *exp; - int i; - struct list *list = NULL; - FILE *f, *fstab; - struct mntent *mnt; - - /* Avoid using any external services */ - xlog_syslog(0); - - if (argc != 4 || argv[1][0] != '/') { - fprintf(stderr, "nfs-server-generator: create systemd dependencies for nfs-server\n"); - fprintf(stderr, "Usage: normal-dir early-dir late-dir\n"); - exit(1); - } - - path = alloca(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase)); - if (!path) - exit(2); - if (export_read(_PATH_EXPORTS, 1) + - export_d_read(_PATH_EXPORTS_D, 1) == 0) - /* Nothing is exported, so nothing to do */ - exit(0); - - strcat(strcpy(path, argv[1]), dirbase); - mkdir(path, 0755); - strcat(path, filebase); - f = fopen(path, "w"); - if (!f) - exit(1); - fprintf(f, "# Automatically generated by nfs-server-generator\n\n[Unit]\n"); - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (!is_unique(&list, exp->m_export.e_path)) - continue; - if (exp->m_export.e_mountpoint) - continue; - if (has_noauto_flag(exp->m_export.e_path)) - continue; - if (strchr(exp->m_export.e_path, ' ')) - fprintf(f, "RequiresMountsFor=\"%s\"\n", - exp->m_export.e_path); - else - fprintf(f, "RequiresMountsFor=%s\n", - exp->m_export.e_path); - } - } - - fstab = setmntent("/etc/fstab", "r"); - if (!fstab) - exit(1); - - while ((mnt = getmntent(fstab)) != NULL) { - if (strcmp(mnt->mnt_type, "nfs") != 0 && - strcmp(mnt->mnt_type, "nfs4") != 0) - continue; - - spath = systemd_escape(mnt->mnt_dir, ".mount"); - if (!spath) { - fprintf(stderr, - "nfs-server-generator: convert path failed: %s\n", - mnt->mnt_dir); - continue; - } - fprintf(f, "Before=%s\n", spath); - } - - fclose(fstab); - fclose(f); - - exit(0); -} diff --git a/nfs-utils-2.5.2/systemd/nfs-server.service b/nfs-utils-2.5.2/systemd/nfs-server.service deleted file mode 100644 index 06c1adb..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-server.service +++ /dev/null @@ -1,33 +0,0 @@ -[Unit] -Description=NFS server and services -DefaultDependencies=no -Requires=network.target proc-fs-nfsd.mount -Requires=nfs-mountd.service -Wants=rpcbind.socket network-online.target -Wants=rpc-statd.service nfs-idmapd.service -Wants=rpc-statd-notify.service -Wants=nfsdcld.service - -After=network-online.target local-fs.target -After=proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service -After=nfs-idmapd.service rpc-statd.service -After=nfsdcld.service -Before=rpc-statd-notify.service - -# GSS services dependencies and ordering -Wants=auth-rpcgss-module.service -After=rpc-gssd.service gssproxy.service rpc-svcgssd.service - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStartPre=/usr/sbin/exportfs -r -ExecStart=/usr/sbin/rpc.nfsd -ExecStop=/usr/sbin/rpc.nfsd 0 -ExecStopPost=/usr/sbin/exportfs -au -ExecStopPost=/usr/sbin/exportfs -f - -ExecReload=/usr/sbin/exportfs -r - -[Install] -WantedBy=multi-user.target diff --git a/nfs-utils-2.5.2/systemd/nfs-utils.service b/nfs-utils-2.5.2/systemd/nfs-utils.service deleted file mode 100644 index 54b6314..0000000 --- a/nfs-utils-2.5.2/systemd/nfs-utils.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=NFS server and client services -# This service should never be stopped, only restarted. -# When it is re-started, all other services which declare -# themselves to be "PartOf" this service will also be -# restarted. Thus -# systemctl restart nfs-utils -# will restart all daemons which are part of nfs-utils -# and which are running. This is useful after a software -# update. - -# This is a "service" rather than "target" so that we -# don't need to say "systemctl restart nfs-utils.target". -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/true diff --git a/nfs-utils-2.5.2/systemd/nfs.conf.man b/nfs-utils-2.5.2/systemd/nfs.conf.man deleted file mode 100644 index 3f1c726..0000000 --- a/nfs-utils-2.5.2/systemd/nfs.conf.man +++ /dev/null @@ -1,273 +0,0 @@ -.TH NFS.CONF 5 -.SH NAME -nfs.conf \- general configuration for NFS daemons and tools -.SH SYNOPSIS -.I /etc/nfs.conf -.SH DESCRIPTION -.PP -This file contains site-specific configuration for various NFS daemons -and other processes. Most configuration can also be passed to -processes via command line arguments, but it can be more convenient to -have a central file. In particular, this encourages consistent -configuration across different processes. -.PP -When command line options are provided, they override values set in -this file. When this file does not specify a particular parameter, -and no command line option is provided, each tool provides its own -default values. -.PP -The file format supports multiple sections, each of which can contain -multiple value assignments. A section is introduced by a line -containing the section name enclosed in square brackets, so -.RS -.B [global] -.RE -would introduce a section called -.BR global . -A value assignment is a single line that has the name of the value, an -equals sign, and a setting for the value, so -.RS -.B threads = 4 -.RE -would set the value named -.B threads -in the current section to -.BR 4 . -Leading and trailing spaces and tab -are ignored, as are spaces and tabs surrounding the equals sign. -Single and double quotes surrounding the assigned value are also -removed. If the resulting string is empty, the whole assignment -is ignored. -.PP -Any line starting with -.RB \*(lq # \*(rq -or -.RB \*(lq ; \*(rq -is ignored, as is any blank line. -.PP -If the assigned value started with a -.RB \*(lq $ \*(rq -then the remainder is treated as a name and looked for in the section -.B [environment] -or in the processes environment (see -.BR environ (7)). -The value found is used for this value. -.PP -The value name -.B include -is special. If a section contains -.RS -.B include = /some/file/name -.RE -then the named file will be read, and any value assignments found -there-in will be added to the current section. If the file contains -section headers, then new sections will be created just as if the -included file appeared in place of the -.B include -line. -If the file name starts with a hyphen then that is stripped off -before the file is opened, and if file doesn't exist no warning is -given. Normally a non-existent include file generates a warning. -.PP -Lookup of section and value names is case-insensitive. - -Where a Boolean value is expected, any of -.BR true , -.BR t , -.BR yes , -.BR y , -.BR on ", or" -.B 1 -can be used for "true", while -.BR false , -.BR f , -.BR no , -.BR n , -.BR off ", or" -.B 0 -can be used for "false". Comparisons are case-insensitive. - -.SH SECTIONS -The following sections are known to various programs, and can contain -the given named values. Most sections can also contain a -.B debug -value, which can be one or more from the list -.BR general , -.BR call , -.BR auth , -.BR parse , -.BR all . -When a list is given, the members should be comma-separated. -.TP -.B general -Recognized values: -.BR pipefs-directory . - -See -.BR blkmapd (8), -.BR rpc.idmapd (8), -and -.BR rpc.gssd (8) -for details. - -.TP -.B exports -Recognized values: -.BR rootdir . - -Setting -.B rootdir -to a valid path causes the nfs server to act as if the -supplied path is being prefixed to all the exported entries. For -instance, if -.BR rootdir=/my/root , -and there is an entry in /etc/exports for -.BR /filesystem , -then the client will be able to mount the path as -.BR /filesystem , -but on the server, this will resolve to the path -.BR /my/root/filesystem . - -.TP -.B nfsdcltrack -Recognized values: -.BR storagedir . - -The -.B nfsdcltrack -program is run directly by the Linux kernel and there is no -opportunity to provide command line arguments, so the configuration -file is the only way to configure this program. See -.BR nfsdcltrack (8) -for details. - -.TP -.B nfsd -Recognized values: -.BR threads , -.BR host , -.BR port , -.BR grace-time , -.BR lease-time , -.BR udp , -.BR tcp , -.BR vers2 , -.BR vers3 , -.BR vers4 , -.BR vers4.0 , -.BR vers4.1 , -.BR vers4.2 , -.BR rdma , - -Version and protocol values are Boolean values as described above, -and are also used by -.BR rpc.mountd . -Threads and the two times are integers. -.B port -and -.B rdma -are service names or numbers. See -.BR rpc.nfsd (8) -for details. - -.TP -.B mountd -Recognized values: -.BR manage-gids , -.BR descriptors , -.BR port , -.BR threads , -.BR reverse-lookup , -.BR state-directory-path , -.BR ha-callout . - -These, together with the protocol and version values in the -.B [nfsd] -section, are used to configure mountd. See -.BR rpc.mountd (8) -for details. - -The -.B state-directory-path -value in the -.B [mountd] -section is also used by -.BR exportfs (8). - -.TP -.B statd -Recognized values: -.BR port , -.BR outgoing-port , -.BR name , -.BR state-directory-path , -.BR ha-callout . - -See -.BR rpc.statd (8) -for details. - -.TP -.B lockd -Recognized values: -.B port -and -.BR udp-port . - -See -.BR rpc.statd (8) -for details. - -.TP -.B sm-notify -Recognized values: -.BR retry-time , -.BR outgoing-port ", and" -.BR outgoing-addr . - -See -.BR sm-notify (8) -for details. - -.TP -.B gssd -Recognized values: -.BR verbosity , -.BR rpc-verbosity , -.BR use-memcache , -.BR use-machine-creds , -.BR use-gss-proxy , -.BR avoid-dns , -.BR limit-to-legacy-enctypes , -.BR context-timeout , -.BR rpc-timeout , -.BR keytab-file , -.BR cred-cache-directory , -.BR preferred-realm . - -See -.BR rpc.gssd (8) -for details. - -.TP -.B svcgssd -Recognized values: -.BR principal . - -See -.BR rpc.svcgssd (8) -for details. - -.TP -.B exportfs -Only -.B debug= -is recognized. - -.SH FILES -.I /etc/nfs.conf -.SH SEE ALSO -.BR nfsdcltrack (8), -.BR rpc.nfsd (8), -.BR rpc.mountd (8), -.BR nfsmount.conf (5). diff --git a/nfs-utils-2.5.2/systemd/nfs.systemd.man b/nfs-utils-2.5.2/systemd/nfs.systemd.man deleted file mode 100644 index 46b476a..0000000 --- a/nfs-utils-2.5.2/systemd/nfs.systemd.man +++ /dev/null @@ -1,177 +0,0 @@ -.TH NFS.SYSTEMD 7 -.SH NAME -nfs.systemd \- managing NFS services through systemd. -.SH SYNOPSIS -nfs-utils.service -.br -nfs-server.service -.br -nfs-client.target -.br -.I etc -.SH DESCRIPTION -The -.I nfs-utils -package provides a suite of -.I systemd -unit files which allow the various services to be started and -managed. These unit files ensure that the services are started in the -correct order, and the prerequisites are active before dependant -services start. As there are quite few unit files, it is not -immediately obvious how best to achieve certain results. The -following subsections attempt to cover the issues that are most likely -to come up. -.SS Configuration -The standard systemd unit files do not provide any easy way to pass -any command line arguments to daemons so as to configure their -behavior. In many case such configuration can be performed by making -changes to -.I /etc/nfs.conf -or other configuration files. When that is not convenient, a -distribution might provide systemd "drop-in" files which replace the -.B ExecStart= -setting to start the program with different arguments. For example a -drop-in file -.B systemd/system/nfs-mountd.service.d/local.conf -containing -.RS -.nf -[Service] -EnvironmentFile=/etc/sysconfig/nfs -ExecStart= -ExecStart= /usr/sbin/rpc.mountd $RPCMOUNTDOPTS -.fi -.RE -would cause the -.B nfs-mountd.service -unit to run the -.I rpc.mountd -program using, for arguments, the value given for -.B RPCMOUNTDOPTS -in -.IR /etc/sysconfig/nfs . -This allows for seamless integration with existing configuration -tools. -.SS Enabling unit files -There are three unit files which are designed to be manually enabled. -All others are automatically run as required. The three are: -.TP -.B nfs-client.target -This should be enabled on any host which ever serves as an NFS client. -There is little cost in transparently enabling it whenever NFS client -software is installed. -.TP -.B nfs-server.service -This must be enabled to provide NFS service to clients. It starts and -configures the required daemons in the required order. -.TP -.B nfs-blkmap.service -The -.B blkmapd -daemon is only required on NFS clients which are using pNFS (parallel -NFS), and particularly using the -.B blocklayout -layout protocol. If you might use this particular extension to NFS, -the -.B nfs-blkmap.service -unit should be enabled. -.PP -Several other units which might be considered to be optional, such as -.I rpc-gssd.service -are careful to only start if the required configuration file exists. -.I rpc-gssd.service -will not start if the -.I krb5.keytab -file does not exist (typically in -.IR /etc ). -.SS Restarting NFS services -Most NFS daemons can be restarted at any time. They will reload any -state that they need, and continue servicing requests. This is rarely -necessary though. -.PP -When configuration changesare make, it can be hard to know exactly -which services need to be restarted to ensure that the configuration -takes effect. The simplest approach, which is often the best, is to -restart everything. To help with this, the -.B nfs-utils.service -unit is provided. It declares appropriate dependencies with other -unit files so that -.RS -.B systemctl restart nfs-utils -.RE -will restart all NFS daemons that are running. This will cause all -configuration changes to take effect -.I except -for changes to mount options lists in -.I /etc/fstab -or -.IR /etc/nfsmount.conf . -Mount options can only be changed by unmounting and remounting -filesystem. This can be a disruptive operation so it should only be -done when the value justifies the cost. The command -.RS -.B umount -a -t nfs; mount -a -t nfs -.RE -should unmount and remount all NFS filesystems. -.SS Masking unwanted services -Rarely there may be a desire to prohibit some services from running -even though there are normally part of a working NFS system. This may -be needed to reduce system load to an absolute minimum, or to reduce -attack surface by not running daemons that are not absolutely -required. -.PP -Three particular services which this can apply to are -.IR rpcbind , -.IR idmapd , -and -.IR rpc-gssd . -.I rpcbind -is not part of the -.I nfs-utils -package, but it used by several NFS services. However it is -.B not -needed when only NFSv4 is in use. If a site will never use NFSv3 (or -NFSv2) and does not want -.I rpcbind -to be running, the correct approach is to run -.RS -.B systemctl mask rpcbind -.RE -This will disable -.IR rpcbind , -and the various NFS services which depend on it (and are only needed -for NFSv3) will refuse to start, without interfering with the -operation of NFSv4 services. In particular, -.I rpc.statd -will not run when -.I rpcbind -is masked. -.PP -.I idmapd -is only needed for NFSv4, and even then is not needed when the client -and server agree to use user-ids rather than user-names to identify the -owners of files. If -.I idmapd -is not needed and not wanted, it can be masked with -.RS -.B systemctl mask idmapd -.RE -.I rpc-gssd -is assumed to be needed if the -.I krb5.keytab -file is present. If a site needs this file present but does not want -.I rpc-gssd -running, it can be masked with -.RS -.B systemctl mask rpc-gssd -.RE -.SH FILES -/etc/nfs.conf -.br -/etc/nfsmount.conf -.br -/etc/idmapd.conf -.SH SEE ALSO -.BR systemd.unit (5), -.BR nfs.conf (5), -.BR nfsmount.conf (5). diff --git a/nfs-utils-2.5.2/systemd/nfsdcld.service b/nfs-utils-2.5.2/systemd/nfsdcld.service deleted file mode 100644 index a32d243..0000000 --- a/nfs-utils-2.5.2/systemd/nfsdcld.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=NFSv4 Client Tracking Daemon -DefaultDependencies=no -Conflicts=umount.target -Requires=rpc_pipefs.target proc-fs-nfsd.mount -After=rpc_pipefs.target proc-fs-nfsd.mount - -[Service] -Type=forking -ExecStart=/usr/sbin/nfsdcld diff --git a/nfs-utils-2.5.2/systemd/proc-fs-nfsd.mount b/nfs-utils-2.5.2/systemd/proc-fs-nfsd.mount deleted file mode 100644 index 931a5ce..0000000 --- a/nfs-utils-2.5.2/systemd/proc-fs-nfsd.mount +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=NFSD configuration filesystem - -[Mount] -What=nfsd -Where=/proc/fs/nfsd -Type=nfsd diff --git a/nfs-utils-2.5.2/systemd/rpc-gssd.service.in b/nfs-utils-2.5.2/systemd/rpc-gssd.service.in deleted file mode 100644 index 6807db3..0000000 --- a/nfs-utils-2.5.2/systemd/rpc-gssd.service.in +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=RPC security service for NFS client and server -DefaultDependencies=no -Conflicts=umount.target -Requires=rpc_pipefs.target -After=rpc_pipefs.target - -ConditionPathExists=@_sysconfdir@/krb5.keytab - -PartOf=nfs-utils.service - -[Service] -Type=forking -ExecStart=/usr/sbin/rpc.gssd diff --git a/nfs-utils-2.5.2/systemd/rpc-pipefs-generator.c b/nfs-utils-2.5.2/systemd/rpc-pipefs-generator.c deleted file mode 100644 index 8e218aa..0000000 --- a/nfs-utils-2.5.2/systemd/rpc-pipefs-generator.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * rpc-pipefs-generator: - * systemd generator to create ordering dependencies between - * nfs services and the rpc_pipefs mountpoint - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "conffile.h" -#include "systemd.h" - -#define RPC_PIPEFS_DEFAULT "/var/lib/nfs/rpc_pipefs" - -static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit, - const char *dirname) -{ - char *path; - FILE *f; - - path = malloc(strlen(dirname) + 1 + strlen(pipefs_unit)); - if (!path) - return 1; - sprintf(path, "%s/%s", dirname, pipefs_unit); - f = fopen(path, "w"); - if (!f) - { - free(path); - return 1; - } - - fprintf(f, "# Automatically generated by rpc-pipefs-generator\n\n[Unit]\n"); - fprintf(f, "Description=RPC Pipe File System\n"); - fprintf(f, "DefaultDependencies=no\n"); - fprintf(f, "After=systemd-tmpfiles-setup.service\n"); - fprintf(f, "Conflicts=umount.target\n"); - fprintf(f, "\n[Mount]\n"); - fprintf(f, "What=sunrpc\n"); - fprintf(f, "Where=%s\n", pipefs_path); - fprintf(f, "Type=rpc_pipefs\n"); - - fclose(f); - free(path); - return 0; -} - -static -int generate_target(char *pipefs_path, const char *dirname) -{ - char *path; - char filebase[] = "/rpc_pipefs.target"; - char *pipefs_unit; - FILE *f; - int ret = 0; - - pipefs_unit = systemd_escape(pipefs_path, ".mount"); - if (!pipefs_unit) - return 1; - - ret = generate_mount_unit(pipefs_path, pipefs_unit, dirname); - if (ret) { - free(pipefs_unit); - return ret; - } - - path = malloc(strlen(dirname) + 1 + sizeof(filebase)); - if (!path) { - free(pipefs_unit); - return 2; - } - sprintf(path, "%s", dirname); - mkdir(path, 0755); - strcat(path, filebase); - f = fopen(path, "w"); - if (!f) - { - free(path); - free(pipefs_unit); - return 1; - } - - fprintf(f, "# Automatically generated by rpc-pipefs-generator\n\n[Unit]\n"); - fprintf(f, "Requires=%s\n", pipefs_unit); - fprintf(f, "After=%s\n", pipefs_unit); - fclose(f); - free(path); - free(pipefs_unit); - - return 0; -} - -static int is_non_pipefs_mountpoint(char *path) -{ - FILE *mtab; - struct mntent *mnt; - - mtab = setmntent("/etc/mtab", "r"); - if (!mtab) - return 0; - - while ((mnt = getmntent(mtab)) != NULL) { - if (strlen(mnt->mnt_dir) != strlen(path)) - continue; - if (strncmp(mnt->mnt_dir, path, strlen(mnt->mnt_dir))) - continue; - if (strncmp(mnt->mnt_type, "rpc_pipefs", strlen(mnt->mnt_type))) - break; - } - fclose(mtab); - return mnt != NULL; -} - -int main(int argc, char *argv[]) -{ - int ret; - char *s; - - /* Avoid using any external services */ - xlog_syslog(0); - - if (argc != 4 || argv[1][0] != '/') { - fprintf(stderr, "rpc-pipefs-generator: create systemd dependencies for nfs services\n"); - fprintf(stderr, "Usage: normal-dir early-dir late-dir\n"); - exit(1); - } - - conf_init_file(NFS_CONFFILE); - s = conf_get_str("general", "pipefs-directory"); - if (!s) - exit(0); - if (strlen(s) == strlen(RPC_PIPEFS_DEFAULT) && - strcmp(s, RPC_PIPEFS_DEFAULT) == 0) - exit(0); - - if (is_non_pipefs_mountpoint(s)) - exit(1); - - ret = generate_target(s, argv[1]); - exit(ret); -} diff --git a/nfs-utils-2.5.2/systemd/rpc-statd-notify.service b/nfs-utils-2.5.2/systemd/rpc-statd-notify.service deleted file mode 100644 index aad4c0d..0000000 --- a/nfs-utils-2.5.2/systemd/rpc-statd-notify.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Notify NFS peers of a restart -DefaultDependencies=no -Wants=network-online.target -After=local-fs.target network-online.target nss-lookup.target - -# if we run an nfs server, it needs to be running before we -# tell clients that it has restarted. -After=nfs-server.service - -PartOf=nfs-utils.service - -[Service] -Type=forking -ExecStart=-/usr/sbin/sm-notify -RemainAfterExit=yes diff --git a/nfs-utils-2.5.2/systemd/rpc-statd.service b/nfs-utils-2.5.2/systemd/rpc-statd.service deleted file mode 100644 index 095629f..0000000 --- a/nfs-utils-2.5.2/systemd/rpc-statd.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=NFS status monitor for NFSv2/3 locking. -DefaultDependencies=no -Conflicts=umount.target -Requires=nss-lookup.target rpcbind.socket -Wants=network-online.target -Wants=rpc-statd-notify.service -After=network-online.target nss-lookup.target rpcbind.socket - -PartOf=nfs-utils.service -IgnoreOnIsolate=yes - -[Service] -Environment=RPC_STATD_NO_NOTIFY=1 -Type=forking -PIDFile=/run/rpc.statd.pid -ExecStart=/usr/sbin/rpc.statd diff --git a/nfs-utils-2.5.2/systemd/rpc-svcgssd.service b/nfs-utils-2.5.2/systemd/rpc-svcgssd.service deleted file mode 100644 index cb2bcd4..0000000 --- a/nfs-utils-2.5.2/systemd/rpc-svcgssd.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=RPC security service for NFS server -DefaultDependencies=no -After=local-fs.target -PartOf=nfs-server.service -PartOf=nfs-utils.service - -After=gssproxy.service -ConditionPathExists=|!/run/gssproxy.pid -ConditionPathExists=|!/proc/net/rpc/use-gss-proxy -ConditionPathExists=/etc/krb5.keytab - -[Service] -Type=forking -ExecStart=/usr/sbin/rpc.svcgssd diff --git a/nfs-utils-2.5.2/systemd/rpc_pipefs.target b/nfs-utils-2.5.2/systemd/rpc_pipefs.target deleted file mode 100644 index 01d4d27..0000000 --- a/nfs-utils-2.5.2/systemd/rpc_pipefs.target +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -Requires=var-lib-nfs-rpc_pipefs.mount -After=var-lib-nfs-rpc_pipefs.mount diff --git a/nfs-utils-2.5.2/systemd/systemd.c b/nfs-utils-2.5.2/systemd/systemd.c deleted file mode 100644 index c7bdb4d..0000000 --- a/nfs-utils-2.5.2/systemd/systemd.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Helper functions for systemd generators in nfs-utils. - * - * Currently just systemd_escape(). - */ - -#include -#include -#include -#include -#include "systemd.h" - -static const char hex[16] = -{ - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', -}; - -/* - * determine length of the string that systemd_escape() needs to allocate - */ -static int systemd_len(char *path) -{ - char *p; - int len = 0; - - p = path; - while (*p == '/') - /* multiple leading "/" are ignored */ - p++; - - if (!*p) - /* root directory "/" becomes is encoded as a single "-" */ - return 1; - - if (*p == '.') - /* - * replace "." with "\x2d" escape sequence if - * it's the first character in escaped path - * */ - len += 4; - - while (*p) { - unsigned char c = *p++; - - if (c == '/') { - /* multiple non-trailing slashes become '-' */ - while (*p == '/') - p++; - if (*p) - len++; - } else if (isalnum(c) || c == ':' || c == '.' || c == '_') - /* these characters are not replaced */ - len++; - else - /* replace with "\x2d" escape sequence */ - len += 4; - } - - return len; -} - -/* - * convert c to "\x2d" escape sequence and append to string - * at position p, advancing p - */ -static char *hexify(unsigned char c, char *p) -{ - *p++ = '\\'; - *p++ = 'x'; - *p++ = hex[c >> 4]; - *p++ = hex[c & 0xf]; - return p; -} - -/* - * convert a path to a unit name according to the logic in systemd.unit(5): - * - * Basically, given a path, "/" is replaced by "-", and all other - * characters which are not ASCII alphanumerics are replaced by C-style - * "\x2d" escapes (except that "_" is never replaced and "." is only - * replaced when it would be the first character in the escaped path). - * The root directory "/" is encoded as single dash, while otherwise the - * initial and ending "/" are removed from all paths during - * transformation. - * - * NB: Although the systemd.unit(5) doesn't mention it, the ':' character - * is not escaped. - */ -char *systemd_escape(char *path, char *suffix) -{ - char *result; - char *p; - int len; - - len = systemd_len(path); - result = malloc(len + strlen(suffix) + 1); - p = result; - while (*path == '/') - /* multiple leading "/" are ignored */ - path++; - if (!*path) { - /* root directory "/" becomes is encoded as a single "-" */ - *p++ = '-'; - goto out; - } - if (*path == '.') - /* - * replace "." with "\x2d" escape sequence if - * it's the first character in escaped path - * */ - p = hexify(*path++, p); - - while (*path) { - unsigned char c = *path++; - - if (c == '/') { - /* multiple non-trailing slashes become '-' */ - while (*path == '/') - path++; - if (*path) - *p++ = '-'; - } else if (isalnum(c) || c == ':' || c == '.' || c == '_') - /* these characters are not replaced */ - *p++ = c; - else - /* replace with "\x2d" escape sequence */ - p = hexify(c, p); - } - -out: - sprintf(p, "%s", suffix); - return result; -} diff --git a/nfs-utils-2.5.2/systemd/systemd.h b/nfs-utils-2.5.2/systemd/systemd.h deleted file mode 100644 index 25235ec..0000000 --- a/nfs-utils-2.5.2/systemd/systemd.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SYSTEMD_H -#define SYSTEMD_H - -char *systemd_escape(char *path, char *suffix); - -#endif /* SYSTEMD_H */ diff --git a/nfs-utils-2.5.2/systemd/var-lib-nfs-rpc_pipefs.mount b/nfs-utils-2.5.2/systemd/var-lib-nfs-rpc_pipefs.mount deleted file mode 100644 index 26d1c76..0000000 --- a/nfs-utils-2.5.2/systemd/var-lib-nfs-rpc_pipefs.mount +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=RPC Pipe File System -DefaultDependencies=no -After=systemd-tmpfiles-setup.service -Conflicts=umount.target - -[Mount] -What=sunrpc -Where=/var/lib/nfs/rpc_pipefs -Type=rpc_pipefs diff --git a/nfs-utils-2.5.2/tests/Makefile.am b/nfs-utils-2.5.2/tests/Makefile.am deleted file mode 100644 index a199ce0..0000000 --- a/nfs-utils-2.5.2/tests/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## Process this file with automake to produce Makefile.in - -check_PROGRAMS = statdb_dump -statdb_dump_SOURCES = statdb_dump.c - -statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \ - ../support/nsm/libnsm.a \ - ../support/misc/libmisc.a $(LIBCAP) - -SUBDIRS = nsm_client - -MAINTAINERCLEANFILES = Makefile.in - -TESTS = t0001-statd-basic-mon-unmon.sh -EXTRA_DIST = test-lib.sh $(TESTS) diff --git a/nfs-utils-2.5.2/tests/nfsconf/01-errors.conf b/nfs-utils-2.5.2/tests/nfsconf/01-errors.conf deleted file mode 100644 index ca64d2c..0000000 --- a/nfs-utils-2.5.2/tests/nfsconf/01-errors.conf +++ /dev/null @@ -1,20 +0,0 @@ -# file of deliberate errors -[default] - - -[ one - -[ two " foo ] -aa = foo - -[ three -val = none - -[four] -one - = two -three = -four = foo = bar -five = " nothing -six = normal - diff --git a/nfs-utils-2.5.2/tests/nfsconf/01-errors.exp b/nfs-utils-2.5.2/tests/nfsconf/01-errors.exp deleted file mode 100644 index 0b985b4..0000000 --- a/nfs-utils-2.5.2/tests/nfsconf/01-errors.exp +++ /dev/null @@ -1,13 +0,0 @@ -nfsconf: config error at 01-errors.conf:5: non-matched ']', ignoring until next section -nfsconf: config error at 01-errors.conf:7: non-matched '"', ignoring until next section -nfsconf: config error at 01-errors.conf:10: non-matched ']', ignoring until next section -nfsconf: config error at 01-errors.conf:11: ignoring line not in a section -nfsconf: config error at 01-errors.conf:14: line not empty and not an assignment -nfsconf: config error at 01-errors.conf:15: missing tag in assignment -nfsconf: config error at 01-errors.conf:18: unmatched quotes -[four] - four = foo = bar - six = normal - -[two] - aa = foo diff --git a/nfs-utils-2.5.2/tests/nfsconf/02-valid.conf b/nfs-utils-2.5.2/tests/nfsconf/02-valid.conf deleted file mode 100644 index ca8ccab..0000000 --- a/nfs-utils-2.5.2/tests/nfsconf/02-valid.conf +++ /dev/null @@ -1,25 +0,0 @@ -[environment] -one = 1 -two = 2 -three = 3 - -[section_one] -one = 11 -two = 22 -three = $three - four = "six " - five six = seven eight - -[section_two "two"] -one = Un -two = Dau -include = "02-valid.sub" - -[section_two "one"] -one = Un -two = Deux - -[section_two "two"] -four = Pedwar - five = " Pump " - diff --git a/nfs-utils-2.5.2/tests/nfsconf/02-valid.exp b/nfs-utils-2.5.2/tests/nfsconf/02-valid.exp deleted file mode 100644 index 379d7a4..0000000 --- a/nfs-utils-2.5.2/tests/nfsconf/02-valid.exp +++ /dev/null @@ -1,26 +0,0 @@ -[environment] - one = 1 - three = 3 - two = 2 - -[extra_section] - bar = baz - foo = bar - -[section_one] - five six = seven eight - four = "six " - one = 11 - three = $three - two = 22 - -[section_two "one"] - one = Un - two = Deux - -[section_two "two"] - five = " Pump " - four = Pedwar - one = Un - three = Tri - two = Dau diff --git a/nfs-utils-2.5.2/tests/nfsconf/02-valid.sub b/nfs-utils-2.5.2/tests/nfsconf/02-valid.sub deleted file mode 100644 index ab7beda..0000000 --- a/nfs-utils-2.5.2/tests/nfsconf/02-valid.sub +++ /dev/null @@ -1,7 +0,0 @@ -# Included configs don't need a section, it is inherited -three=Tri - -# But if they do, that works also -[extra_section] -foo = bar -bar = baz diff --git a/nfs-utils-2.5.2/tests/nsm_client/Makefile.am b/nfs-utils-2.5.2/tests/nsm_client/Makefile.am deleted file mode 100644 index 47fd728..0000000 --- a/nfs-utils-2.5.2/tests/nsm_client/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -## Process this file with automake to produce Makefile.in - -GENFILES_CLNT = nlm_sm_inter_clnt.c -GENFILES_SVC = nlm_sm_inter_svc.c -GENFILES_XDR = nlm_sm_inter_xdr.c -GENFILES_H = nlm_sm_inter.h - -GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) - -AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations - -EXTRA_DIST = nlm_sm_inter.x - -check_PROGRAMS = nsm_client -nsm_client_SOURCES = $(GENFILES) nsm_client.c - -BUILT_SOURCES = $(GENFILES) -nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \ - ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC) - -if CONFIG_RPCGEN -RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen -$(RPCGEN): - make -C ../../tools/rpcgen all -else -RPCGEN = @RPCGEN_PATH@ -endif - -$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -l -o $@ $< - -$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -m -o $@ $< - -$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -c -o $@ $< - -$(GENFILES_H): %.h: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -h -o $@ $< - -MAINTAINERCLEANFILES = Makefile.in - -CLEANFILES = $(GENFILES) - diff --git a/nfs-utils-2.5.2/tests/nsm_client/README b/nfs-utils-2.5.2/tests/nsm_client/README deleted file mode 100644 index 85379dd..0000000 --- a/nfs-utils-2.5.2/tests/nsm_client/README +++ /dev/null @@ -1,12 +0,0 @@ -The nsm_client program is intended for testing statd. It has the ability -to act as a synthetic NSM client for sending artificial NSM calls to any -host you choose. - -It also has an NLM simulator that implements the call that statd uses to -communicate with lockd. The daemon simulator will start itself up, -register as an NLM service and listen for "downcalls" from statd. When -it gets one, it will log a message. - -Note that lockd will need to be down when using the daemon simulator. It -also does not implement the entire NLM protocol and is only really -useful for testing statd's downcall. diff --git a/nfs-utils-2.5.2/tests/nsm_client/nlm_sm_inter.x b/nfs-utils-2.5.2/tests/nsm_client/nlm_sm_inter.x deleted file mode 100644 index 95fa326..0000000 --- a/nfs-utils-2.5.2/tests/nsm_client/nlm_sm_inter.x +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, 1996. - * Modified by H.J. Lu, 1998. - * Modified by Jeff Layton, 2010. - * - * NLM similator for Linux - */ - -#ifdef RPC_CLNT -%#include -#endif - -/* - * statd rejects monitor registrations for any non-lockd services, so pretend - * to be lockd when testing. Furthermore, the only call we care about from - * statd is #16, which is the downcall to notify the kernel of a host's status - * change. - */ -program NLM_SM_PROG { - /* version 3 of the NLM protocol */ - version NLM_SM_VERS3 { - void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16; - } = 3; - - /* version 2 of NLM protocol */ - version NLM_SM_VERS4 { - void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16; - } = 4; -} = 100021; - -const SM_MAXSTRLEN = 1024; -const SM_PRIV_SIZE = 16; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct nlm_sm_notify { - string mon_name; - int state; - opaque priv[SM_PRIV_SIZE]; /* stored private information */ -}; diff --git a/nfs-utils-2.5.2/tests/nsm_client/nsm_client.c b/nfs-utils-2.5.2/tests/nsm_client/nsm_client.c deleted file mode 100644 index 8dc0591..0000000 --- a/nfs-utils-2.5.2/tests/nsm_client/nsm_client.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - * nsm_client.c -- synthetic client and lockd simulator for testing statd - * - * Copyright (C) 2010 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Very loosely based on "simulator.c" in the statd directory. Original - * copyright for that program follows: - * - * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "nfsrpc.h" -#include "nsm.h" -#include "sm_inter.h" -#include "nlm_sm_inter.h" -#include "sockaddr.h" -#include "xcommon.h" - -static void daemon_simulator(void); -static void sim_killer(int sig); -static int nsm_client_crash(char *); -static int nsm_client_mon(char *, char *, char *, char *, int, int); -static int nsm_client_stat(char *, char *); -static int nsm_client_notify(char *, char *, char *); -static int nsm_client_unmon(char *, char *, char *, int, int); -static int nsm_client_unmon_all(char *, char *, int, int); - -extern void nlm_sm_prog_4(struct svc_req *rqstp, register SVCXPRT *transp); -extern void svc_exit(void); - -/* - * default to 15 retransmit interval, which seems to be the default for - * UDP clients w/ legacy glibc RPC - */ -static struct timeval retrans_interval = -{ - .tv_sec = 15, -}; - -static struct option longopts[] = -{ - { "help", 0, 0, 'h' }, - { "host", 0, 0, 'H' }, - { "name", 1, 0, 'n' }, - { "program", 1, 0, 'P' }, - { "version", 1, 0, 'v' }, - { NULL, 0, 0, 0 }, -}; - -static int -usage(char *program) -{ - printf("Usage:\n"); - printf("%s [options] [arg]...\n", program); - printf("where command is one of these with the specified args:\n"); - printf("crash\t\t\t\ttell host to simulate crash\n"); - printf("daemon\t\t\t\t\tstart up lockd daemon simulator\n"); - printf("notify \tsend a reboot notification to host\n"); - printf("stat \t\t\tget status of on host\n"); - printf("unmon_all\t\t\ttell host to unmon everything\n"); - printf("unmon \t\t\ttell host to unmon \n"); - printf("mon \t\ttell host to monitor with private \n"); - return 1; -} - -static int -hex2bin(char *dst, size_t dstlen, char *src) -{ - int i; - unsigned int tmp; - - for (i = 0; *src && i < dstlen; i++) { - if (sscanf(src, "%2x", &tmp) != 1) - return 0; - dst[i] = tmp; - src++; - if (!*src) - break; - src++; - } - - return 1; -} - -static void -bin2hex(char *dst, char *src, size_t srclen) -{ - int i; - - for (i = 0; i < srclen; i++) - dst += sprintf(dst, "%02x", 0xff & src[i]); -} - -int -main(int argc, char **argv) -{ - int arg, err = 0; - int remaining_args; - char my_name[NI_MAXHOST], host[NI_MAXHOST]; - char cookie[SM_PRIV_SIZE]; - int my_prog = NLM_SM_PROG; - int my_vers = NLM_SM_VERS4; - - my_name[0] = '\0'; - host[0] = '\0'; - - while ((arg = getopt_long(argc, argv, "hHn:P:v:", longopts, - NULL)) != EOF) { - switch (arg) { - case 'H': - strncpy(host, optarg, sizeof(host)); - case 'n': - strncpy(my_name, optarg, sizeof(my_name)); - case 'P': - my_prog = atoi(optarg); - case 'v': - my_vers = atoi(optarg); - } - } - - remaining_args = argc - optind; - if (remaining_args <= 0) - usage(argv[0]); - - if (!my_name[0]) - gethostname(my_name, sizeof(my_name)); - if (!host[0]) - strncpy(host, "127.0.0.1", sizeof(host)); - - if (!strcasecmp(argv[optind], "daemon")) { - daemon_simulator(); - } else if (!strcasecmp(argv[optind], "crash")) { - err = nsm_client_crash(host); - } else if (!strcasecmp(argv[optind], "stat")) { - if (remaining_args < 2) - usage(argv[0]); - err = nsm_client_stat(host, argv[optind + 2]); - } else if (!strcasecmp(argv[optind], "unmon_all")) { - err = nsm_client_unmon_all(host, my_name, my_prog, my_vers); - } else if (!strcasecmp(argv[optind], "unmon")) { - if (remaining_args < 2) - usage(argv[0]); - err = nsm_client_unmon(host, argv[optind + 1], my_name, my_prog, - my_vers); - } else if (!strcasecmp(argv[optind], "notify")) { - if (remaining_args < 2) - usage(argv[0]); - err = nsm_client_notify(host, argv[optind + 1], - argv[optind + 2]); - } else if (!strcasecmp(argv[optind], "mon")) { - if (remaining_args < 2) - usage(argv[0]); - - memset(cookie, '\0', SM_PRIV_SIZE); - if (!hex2bin(cookie, sizeof(cookie), argv[optind + 2])) { - fprintf(stderr, "SYS:%d\n", EINVAL); - printf("Unable to convert hex cookie %s to binary.\n", - argv[optind + 2]); - return 1; - } - - err = nsm_client_mon(host, argv[optind + 1], cookie, my_name, - my_prog, my_vers); - } else { - err = usage(argv[0]); - } - - return err; -} - -static CLIENT * -nsm_client_get_rpcclient(const char *node) -{ - unsigned short port; - struct addrinfo *ai; - struct addrinfo hints = { }; - int err; - CLIENT *client = NULL; - -#ifndef IPV6_ENABLED - hints.ai_family = AF_INET; -#endif /* IPV6_ENABLED */ - - /* FIXME: allow support for providing port? */ - err = getaddrinfo(node, NULL, &hints, &ai); - if (err) { - fprintf(stderr, "EAI:%d\n", err); - if (err == EAI_SYSTEM) - fprintf(stderr, "SYS:%d\n", errno); - printf("Unable to translate host to address: %s\n", - err == EAI_SYSTEM ? strerror(errno) : - gai_strerror(err)); - return client; - } - - /* FIXME: allow for TCP too? */ - port = nfs_getport(ai->ai_addr, ai->ai_addrlen, SM_PROG, - SM_VERS, IPPROTO_UDP); - if (!port) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("Unable to determine port for service\n"); - goto out; - } - - nfs_set_port(ai->ai_addr, port); - - client = nfs_get_rpcclient(ai->ai_addr, ai->ai_addrlen, IPPROTO_UDP, - SM_PROG, SM_VERS, &retrans_interval); - if (!client) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("RPC client creation failed\n"); - } -out: - nfs_freeaddrinfo(ai); - return client; -} - -static int -nsm_client_mon(char *calling, char *monitoring, char *cookie, char *my_name, - int my_prog, int my_vers) -{ - CLIENT *client; - sm_stat_res *result; - mon mon; - int err = 0; - - printf("Calling %s (as %s) to monitor %s\n", calling, my_name, - monitoring); - - if ((client = nsm_client_get_rpcclient(calling)) == NULL) - return 1; - - memcpy(mon.priv, cookie, SM_PRIV_SIZE); - mon.mon_id.my_id.my_name = my_name; - mon.mon_id.my_id.my_prog = my_prog; - mon.mon_id.my_id.my_vers = my_vers; - mon.mon_id.my_id.my_proc = NLM_SM_NOTIFY; - mon.mon_id.mon_name = monitoring; - - if (!(result = sm_mon_1(&mon, client))) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_mon_1")); - err = 1; - goto mon_out; - } - - printf("SM_MON request %s, state: %d\n", - result->res_stat == stat_succ ? "successful" : "failed", - result->state); - - if (result->res_stat != stat_succ) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - err = 1; - } - -mon_out: - clnt_destroy(client); - return err; -} - -static int -nsm_client_unmon(char *calling, char *unmonitoring, char *my_name, int my_prog, - int my_vers) -{ - CLIENT *client; - sm_stat *result; - mon_id mon_id; - int err = 0; - - printf("Calling %s (as %s) to unmonitor %s\n", calling, my_name, - unmonitoring); - - if ((client = nsm_client_get_rpcclient(calling)) == NULL) - return 1; - - mon_id.my_id.my_name = my_name; - mon_id.my_id.my_prog = my_prog; - mon_id.my_id.my_vers = my_vers; - mon_id.my_id.my_proc = NLM_SM_NOTIFY; - mon_id.mon_name = unmonitoring; - - if (!(result = sm_unmon_1(&mon_id, client))) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_unmon_1")); - err = 1; - goto unmon_out; - } - - printf("SM_UNMON state: %d\n", result->state); - -unmon_out: - clnt_destroy(client); - return err; -} - -static int -nsm_client_unmon_all(char *calling, char *my_name, int my_prog, int my_vers) -{ - CLIENT *client; - sm_stat *result; - my_id my_id; - int err = 0; - - printf("Calling %s (as %s) to unmonitor all hosts\n", calling, my_name); - - if ((client = nsm_client_get_rpcclient(calling)) == NULL) { - printf("RPC client creation failed\n"); - return 1; - } - - my_id.my_name = my_name; - my_id.my_prog = my_prog; - my_id.my_vers = my_vers; - my_id.my_proc = NLM_SM_NOTIFY; - - if (!(result = sm_unmon_all_1(&my_id, client))) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_unmon_all_1")); - err = 1; - goto unmon_all_out; - } - - printf("SM_UNMON_ALL state: %d\n", result->state); - -unmon_all_out: - return err; -} - -static int -nsm_client_crash(char *host) -{ - CLIENT *client; - - if ((client = nsm_client_get_rpcclient(host)) == NULL) - return 1; - - if (!sm_simu_crash_1(NULL, client)) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_simu_crash_1")); - return 1; - } - - return 0; -} - -static int -nsm_client_stat(char *calling, char *monitoring) -{ - CLIENT *client; - sm_name checking; - sm_stat_res *result; - - if ((client = nsm_client_get_rpcclient(calling)) == NULL) - return 1; - - checking.mon_name = monitoring; - - if (!(result = sm_stat_1(&checking, client))) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_stat_1")); - return 1; - } - - if (result->res_stat != stat_succ) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("stat_fail from %s for %s, state: %d\n", calling, - monitoring, result->state); - return 1; - } - - printf("stat_succ from %s for %s, state: %d\n", calling, - monitoring, result->state); - - return 0; -} - -static int -nsm_client_notify(char *calling, char *mon_name, char *statestr) -{ - CLIENT *client; - - stat_chge stat_chge = { .mon_name = mon_name }; - - stat_chge.state = atoi(statestr); - - if ((client = nsm_client_get_rpcclient(calling)) == NULL) - return 1; - - if (!sm_notify_1(&stat_chge, client)) { - fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat); - printf("%s\n", clnt_sperror(client, "sm_notify_1")); - return 1; - } - - return 0; -} - -static void sim_killer(int sig) -{ -#ifdef HAVE_LIBTIRPC - (void) rpcb_unset(NLM_SM_PROG, NLM_SM_VERS4, NULL); -#else - (void) pmap_unset(NLM_SM_PROG, NLM_SM_VERS4); -#endif - exit(0); -} - -static void daemon_simulator(void) -{ - signal(SIGHUP, sim_killer); - signal(SIGINT, sim_killer); - signal(SIGTERM, sim_killer); - /* FIXME: allow for different versions? */ - nfs_svc_create("nlmsim", NLM_SM_PROG, NLM_SM_VERS4, nlm_sm_prog_4, 0); - svc_run(); -} - -void *nlm_sm_notify_4_svc(struct nlm_sm_notify *argp, struct svc_req *rqstp) -{ - static char *result; - char priv[SM_PRIV_SIZE * 2 + 1]; - - bin2hex(priv, argp->priv, SM_PRIV_SIZE); - - printf("state=%d:mon_name=%s:private=%s\n", argp->state, - argp->mon_name, priv); - return (void *) &result; -} - -void *nlm_sm_notify_3_svc(struct nlm_sm_notify *argp, struct svc_req *rqstp) -{ - return nlm_sm_notify_4_svc(argp, rqstp); -} diff --git a/nfs-utils-2.5.2/tests/statdb_dump.c b/nfs-utils-2.5.2/tests/statdb_dump.c deleted file mode 100644 index 3ac12bf..0000000 --- a/nfs-utils-2.5.2/tests/statdb_dump.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * statdb_dump.c -- dump contents of statd's monitor DB - * - * Copyright (C) 2010 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -#include "nsm.h" -#include "xlog.h" - -static char cookiebuf[(SM_PRIV_SIZE * 2) + 1]; -static char addrbuf[INET6_ADDRSTRLEN + 1]; - -static unsigned int -dump_host(const char *hostname, const struct sockaddr *sa, const struct mon *m, - const time_t timestamp) -{ - int ret; - const char *addr; - const struct sockaddr_in *sin; - const struct sockaddr_in6 *sin6; - - ret = nsm_priv_to_hex(m->priv, cookiebuf, sizeof(cookiebuf)); - if (!ret) { - xlog(L_ERROR, "Unable to convert cookie to hex string.\n"); - return ret; - } - - switch (sa->sa_family) { - case AF_INET: - sin = (struct sockaddr_in *)(char *)sa; - addr = inet_ntop(sa->sa_family, &sin->sin_addr.s_addr, addrbuf, - (socklen_t)sizeof(addrbuf)); - break; - case AF_INET6: - sin6 = (struct sockaddr_in6 *)(char *)sa; - addr = inet_ntop(sa->sa_family, &sin6->sin6_addr, addrbuf, - (socklen_t)sizeof(addrbuf)); - break; - default: - xlog(L_ERROR, "Unrecognized address family: %hu\n", - sa->sa_family); - return 0; - } - - if (addr == NULL) { - xlog(L_ERROR, "Unable to convert sockaddr to string: %s\n", - strerror(errno)); - return 0; - } - - /* - * Callers of this program should assume that in the future, extra - * fields may be added to the output. Anyone adding extra fields to - * the output should add them to the end of the line. - */ - printf("%s %s %s %s %s %d %d %d\n", - hostname, addr, cookiebuf, - m->mon_id.mon_name, - m->mon_id.my_id.my_name, - m->mon_id.my_id.my_prog, - m->mon_id.my_id.my_vers, - m->mon_id.my_id.my_proc); - - return 1; -} - -int -main(int argc, char **argv) -{ - xlog_syslog(0); - xlog_stderr(1); - xlog_open(argv[0]); - - nsm_load_monitor_list(dump_host); - return 0; -} diff --git a/nfs-utils-2.5.2/tests/t0001-statd-basic-mon-unmon.sh b/nfs-utils-2.5.2/tests/t0001-statd-basic-mon-unmon.sh deleted file mode 100755 index 92517a1..0000000 --- a/nfs-utils-2.5.2/tests/t0001-statd-basic-mon-unmon.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd -# -# Copyright (C) 2010 Red Hat, Jeff Layton -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA -# - -. ./test-lib.sh - -# This test needs root privileges -check_root - -start_statd -if [ $? -ne 0 ]; then - echo "FAIL: problem starting statd" - exit 1 -fi - -COOKIE=`echo $$ | md5sum | cut -d' ' -f1` -MON_NAME=`hostname` - -nsm_client mon $MON_NAME $COOKIE -if [ $? -ne 0 ]; then - echo "FAIL: mon failed" - kill_statd - exit 1 -fi - -statdb_dump | grep $MON_NAME | grep -q $COOKIE -if [ $? -ne 0 ]; then - echo "FAIL: monitor DB doesn't seem to contain entry" - kill_statd - exit 1 -fi - -nsm_client unmon $MON_NAME -if [ $? -ne 0 ]; then - echo "FAIL: unmon failed" - kill_statd - exit 1 -fi - -kill_statd - diff --git a/nfs-utils-2.5.2/tests/t0002-nfsconf.sh b/nfs-utils-2.5.2/tests/t0002-nfsconf.sh deleted file mode 100755 index 511d248..0000000 --- a/nfs-utils-2.5.2/tests/t0002-nfsconf.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -TESTFILES=nfsconf -DUMPER=`realpath ../tools/nfsconf/nfsconftool` - -BASEDIR=`dirname "$0"` -pushd $BASEDIR/$TESTFILES - -rm -f *.out - -TCOUNT=0 -TPASS=0 - -for i in *.conf -do -TNAME=`basename "$i" .conf` - -echo "Running test $TNAME" -TCOUNT=$((TCOUNT + 1)) - -if ! $DUMPER --file "$i" --dump - > "$TNAME.out" 2>&1 -then -echo "Error running test $TNAME" -elif ! diff -u "$TNAME.exp" "$TNAME.out" -then -echo "FAIL differences detected in test $TNAME" -else -echo "PASS $TNAME" -TPASS=$((TPASS + 1)) -fi - -done - -echo "nfsconf tests complete. $TPASS of $TCOUNT tests passed" - -if [ $TPASS -lt $TCOUNT ]; then -exit 1 -fi diff --git a/nfs-utils-2.5.2/tests/test-lib.sh b/nfs-utils-2.5.2/tests/test-lib.sh deleted file mode 100644 index 57af37b..0000000 --- a/nfs-utils-2.5.2/tests/test-lib.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# test-lib.sh -- library of functions for nfs-utils tests -# -# Copyright (C) 2010 Red Hat, Jeff Layton -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA -# - -# make sure $srcdir is set and sanity check it -srcdir=${srcdir-.} -if [ ! -d ${srcdir} ]; then - echo "***ERROR***: bad installation -- \$srcdir=${srcdir}" - exit 1 -fi - -export PATH=$PATH:${srcdir}:${srcdir}/nsm_client - -# Some tests require root privileges. Check for them and skip the test (exit 77) -# if the caller doesn't have them. -check_root() { - if [ $EUID -ne 0 ]; then - echo "*** Skipping this test as it requires root privs ***" - exit 77 - fi -} - -# is lockd registered as a service? -lockd_registered() { - rpcinfo -p | grep -q nlockmgr - return $? -} - -# start up statd -start_statd() { - rpcinfo -u 127.0.0.1 status 1 &> /dev/null - if [ $? -eq 0 ]; then - echo "***ERROR***: statd is already running and should " - echo " be down when starting this test" - return 1 - fi - $srcdir/../utils/statd/statd --no-notify -} - -# shut down statd -kill_statd() { - kill `cat /var/run/rpc.statd.pid` -} diff --git a/nfs-utils-2.5.2/tools/Makefile.am b/nfs-utils-2.5.2/tools/Makefile.am deleted file mode 100644 index 9b4b080..0000000 --- a/nfs-utils-2.5.2/tools/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -## Process this file with automake to produce Makefile.in - -OPTDIRS = - -if CONFIG_RPCGEN -OPTDIRS += rpcgen -endif - -OPTDIRS += nfsconf - -if CONFIG_NFSDCLD -OPTDIRS += nfsdclddb -endif - -SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat nfsdclnts $(OPTDIRS) - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/tools/locktest/Makefile.am b/nfs-utils-2.5.2/tools/locktest/Makefile.am deleted file mode 100644 index e891465..0000000 --- a/nfs-utils-2.5.2/tools/locktest/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_PROGRAMS = testlk -testlk_SOURCES = testlk.c -testlk_CFLAGS=$(CFLAGS_FOR_BUILD) -testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD) -testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD) - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/tools/locktest/testlk.c b/nfs-utils-2.5.2/tools/locktest/testlk.c deleted file mode 100644 index ea51f78..0000000 --- a/nfs-utils-2.5.2/tools/locktest/testlk.c +++ /dev/null @@ -1,107 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#ifdef linux -#include -#endif -#include - -static void usage(int exval); -static void fatal(char *); - -int -main(int argc, char **argv) -{ - unsigned long start = 0, len = 0; - struct flock fl; - int c, fd, cmd, typ; - char *fname; - - typ = F_RDLCK; - cmd = F_SETLK; - - while ((c = getopt(argc, argv, "bhrtw")) != EOF) { - switch (c) { - case 'h': - usage(0); - case 'r': - cmd = F_SETLK; - typ = F_RDLCK; - break; - case 'w': - cmd = F_SETLK; - typ = F_WRLCK; - break; - case 'b': - cmd = F_SETLKW; - typ = F_WRLCK; - break; - case 't': - cmd = F_GETLK; - break; - case '?': - usage(1); - } - } - - argc -= optind; - argv += optind; - - if (argc <= 0 || argc > 3) - usage(1); - - fname = argv[0]; - /* printf("TP\n"); */ - if (argc > 1) - start = atoi(argv[1]); - /* printf("TP\n"); */ - if (argc > 2) - len = atoi(argv[2]); - /* printf("TP\n"); */ - - if ((fd = open(fname, O_RDWR, 0644)) < 0) - fatal(fname); - - /* printf("TP1\n"); */ - fl.l_type = typ; - fl.l_whence = 0; - fl.l_start = start; - fl.l_len = len; - - if (fcntl(fd, cmd, &fl) < 0) - fatal("fcntl"); - printf("fcntl: ok\n"); - - /* printf("TP2\n"); */ - if (cmd == F_GETLK) { - if (fl.l_type == F_UNLCK) { - printf("%s: no conflicting lock\n", fname); - } else { - printf("%s: conflicting lock by %d on (%zd;%zd)\n", - fname, fl.l_pid, fl.l_start, fl.l_len); - } - return 0; - } - - /* printf("TP3\n"); */ - pause(); - return 0; -} - -static void -usage(int exval) -{ - fprintf(stderr, "usage: testlk filename [start [len]]\n"); - exit(exval); -} - -static void -fatal(char *msg) -{ - perror(msg); - exit(2); -} diff --git a/nfs-utils-2.5.2/tools/mountstats/Makefile.am b/nfs-utils-2.5.2/tools/mountstats/Makefile.am deleted file mode 100644 index c2e9f99..0000000 --- a/nfs-utils-2.5.2/tools/mountstats/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -## Process this file with automake to produce Makefile.in -PYTHON_FILES = mountstats.py - -man8_MANS = mountstats.man - -EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) - -all-local: $(PYTHON_FILES) - -install-data-hook: - $(INSTALL) -m 755 mountstats.py $(DESTDIR)$(sbindir)/mountstats - -MAINTAINERCLEANFILES=Makefile.in diff --git a/nfs-utils-2.5.2/tools/mountstats/mountstats.man b/nfs-utils-2.5.2/tools/mountstats/mountstats.man deleted file mode 100644 index d5595fc..0000000 --- a/nfs-utils-2.5.2/tools/mountstats/mountstats.man +++ /dev/null @@ -1,151 +0,0 @@ -.\" -.\" mountstats(8) -.\" -.TH mountstats 8 "12 Dec 2014" -.SH NAME -mountstats \- Displays various NFS client per-mount statistics -.SH SYNOPSIS -.B mountstats -.RB [ \-h | \-\-help ] -.RB [ \-v | \-\-version ] -.RB [ \-f | \-\-file -.IR infile ] -.RB [ \-S | \-\-since -.IR sincefile ] -.\" .RB [ \-n | \-\-nfs | \-r | \-\-rpc | \-R | \-\-raw ] -[ -.RB [ \-n | \-\-nfs ] -| -.RB [ \-r | \-\-rpc ] -| -.RB [ \-R | \-\-raw ] -| -.RB [ \-x | \-\-xprt ] -] -.RI [ mountpoint ] ... -.P -.B mountstats iostat -.RB [ \-h | \-\-help ] -.RB [ \-v | \-\-version ] -.RB [ \-f | \-\-file -.IR infile ] -.RB [ \-S | \-\-since -.IR sincefile ] -.RI [ interval ] -.RI [ count ] -.RI [ mountpoint ] ... -.P -.B mountstats nfsstat -.RB [ \-h | \-\-help ] -.RB [ \-v | \-\-version ] -.RB [ \-f | \-\-file -.IR infile ] -.RB [ \-S | \-\-since -.IR sincefile ] -.RB [ \-3 ] -.RB [ \-4 ] -.RI [ mountpoint ] ... -.P -.SH DESCRIPTION -.RB "The " mountstats " command displays various NFS client statisitics for each given" -.IR mountpoint . -.P -.RI "If no " mountpoint " is given, statistics will be displayed for all NFS mountpoints on the client." -.SS Sub-commands -Valid -.BR mountstats (8) -subcommands are: -.IP "\fBmountstats\fP" -Display a combination of per-op RPC statistics, NFS event counts, and NFS byte counts. This is the default sub-command that will be executed if no sub-command is given. -.IP "\fBiostat\fP" -Display iostat-like statistics. -.IP "\fBnfsstat\fP" -Display nfsstat-like statistics. -.SH OPTIONS -.SS Options valid for all sub-commands -.TP -.B \-h, \-\-help -show the help message and exit -.TP -.B \-v, \-\-version -show program's version number and exit -.TP -\fB\-f \fIinfile\fR, \fB\-\-file \fIinfile -Read stats from -.I infile -instead of -.IR /proc/self/mountstats ". " infile -must be in the same format as -.IR /proc/self/mountstats . -This may be used with the -.BR \-S | \-\-since -options to display the delta between two different points in time. -This may not be used with the -.IR interval " or " count -options of the -.B iostat -sub-command. -.TP -\fB\-S \fIsincefile\fR, \fB\-\-since \fIsincefile -Show difference between current stats and those in -.IR sincefile ". " sincefile -must be in the same format as -.IR /proc/self/mountstats . -This may be used with the -.BR \-f | \-\-file -options to display the delta between two different points in time. -This may not be used with the -.IR interval " or " count -options of the -.B iostat -sub-command. -.SS Options specific to the mountstats sub-command -.B \-n, \-\-nfs -Display only the NFS statistics -.TP -.B \-r, \-\-rpc -Display only the RPC statistics -.TP -.B \-R, \-\-raw -Display only the raw statistics. This is intended for use with the -.BR \-f | \-\-file -and -.BR \-S | \-\-since -options. -.TP -.B \-x, \-\-xprt -Display only the transport statistics -.SS Options specific to the iostat sub-command -.IP "\fIinterval\fP" -Specifies the amount of time in seconds between each report. The first report contains statistics for the time since each file system was mounted. Each subsequent report contains statistics collected during the interval since the previous report. This may not be used with the -.BR \-f | \-\-file -or -.BR \-S | \-\-since -options. -.P -.IP "\fIcount\fP" -Determines the number of reports generated at -.I interval -seconds apart. If the -.I interval -parameter is specified without the -.I count -parameter, the command generates reports continuously. This may not be used with the -.BR \-f | \-\-file -or -.BR \-S | \-\-since -options. -.SS Options specific to the nfsstat sub-command -.IP "\fB\-3\fP" -Show only NFS version 3 statistics. The default is to show both version 3 and version 4 statistics. -.IP "\fB\-4\fP" -Show only NFS version 4 statistics. The default is to show both version 3 and version 4 statistics. -.SH FILES -.TP -.B /proc/self/mountstats -.SH SEE ALSO -.BR iostat (8), -.BR nfsiostat (8), -.BR nfsstat (8) -.SH AUTHOR -Chuck Lever diff --git a/nfs-utils-2.5.2/tools/mountstats/mountstats.py b/nfs-utils-2.5.2/tools/mountstats/mountstats.py deleted file mode 100755 index 25e92a1..0000000 --- a/nfs-utils-2.5.2/tools/mountstats/mountstats.py +++ /dev/null @@ -1,1139 +0,0 @@ -#!/usr/bin/python3 -# -*- python-mode -*- -"""Parse /proc/self/mountstats and display it in human readable form -""" - -from __future__ import print_function -import datetime as datetime - -__copyright__ = """ -Copyright (C) 2005, Chuck Lever - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301 USA -""" - -import sys, os, time -from operator import itemgetter, add -try: - import argparse -except ImportError: - print('%s: Failed to import argparse - make sure argparse is installed!' - % sys.argv[0]) - sys.exit(1) - -Mountstats_version = '0.3' - -def difference(x, y): - """Used for a map() function - """ - return x - y - -NfsEventCounters = [ - 'inoderevalidates', - 'dentryrevalidates', - 'datainvalidates', - 'attrinvalidates', - 'vfsopen', - 'vfslookup', - 'vfspermission', - 'vfsupdatepage', - 'vfsreadpage', - 'vfsreadpages', - 'vfswritepage', - 'vfswritepages', - 'vfsreaddir', - 'vfssetattr', - 'vfsflush', - 'vfsfsync', - 'vfslock', - 'vfsrelease', - 'congestionwait', - 'setattrtrunc', - 'extendwrite', - 'sillyrenames', - 'shortreads', - 'shortwrites', - 'delay', - 'pnfsreads', - 'pnfswrites' -] - -NfsByteCounters = [ - 'normalreadbytes', - 'normalwritebytes', - 'directreadbytes', - 'directwritebytes', - 'serverreadbytes', - 'serverwritebytes', - 'readpages', - 'writepages' -] - -XprtUdpCounters = [ - 'port', - 'bind_count', - 'rpcsends', - 'rpcreceives', - 'badxids', - 'inflightsends', - 'backlogutil', - 'maxslots', - 'sendutil', - 'pendutil' -] - -XprtTcpCounters = [ - 'port', - 'bind_count', - 'connect_count', - 'connect_time', - 'idle_time', - 'rpcsends', - 'rpcreceives', - 'badxids', - 'inflightsends', - 'backlogutil', - 'maxslots', - 'sendutil', - 'pendutil' -] - -XprtRdmaCounters = [ - 'port', - 'bind_count', - 'connect_count', - 'connect_time', - 'idle_time', - 'rpcsends', - 'rpcreceives', - 'badxids', - 'inflightsends', - 'backlogutil', - 'read_segments', - 'write_segments', - 'reply_segments', - 'total_rdma_req', - 'total_rdma_rep', - 'pullup', - 'fixup', - 'hardway', - 'failed_marshal', - 'bad_reply', - 'nomsg_calls', - 'recovered_mrs', - 'orphaned_mrs', - 'allocated_mrs', - 'local_invalidates', - 'empty_sendctx_q', - 'reply_waits_for_send', -] - -Nfsv3ops = [ - 'NULL', - 'GETATTR', - 'SETATTR', - 'LOOKUP', - 'ACCESS', - 'READLINK', - 'READ', - 'WRITE', - 'CREATE', - 'MKDIR', - 'SYMLINK', - 'MKNOD', - 'REMOVE', - 'RMDIR', - 'RENAME', - 'LINK', - 'READDIR', - 'READDIRPLUS', - 'FSSTAT', - 'FSINFO', - 'PATHCONF', - 'COMMIT' -] - -# This list should be kept in-sync with the NFSPROC4_CLNT_* enum in -# include/linux/nfs4.h in the kernel. -Nfsv4ops = [ - 'NULL', - 'READ', - 'WRITE', - 'COMMIT', - 'OPEN', - 'OPEN_CONFIRM', - 'OPEN_NOATTR', - 'OPEN_DOWNGRADE', - 'CLOSE', - 'SETATTR', - 'FSINFO', - 'RENEW', - 'SETCLIENTID', - 'SETCLIENTID_CONFIRM', - 'LOCK', - 'LOCKT', - 'LOCKU', - 'ACCESS', - 'GETATTR', - 'LOOKUP', - 'LOOKUP_ROOT', - 'REMOVE', - 'RENAME', - 'LINK', - 'SYMLINK', - 'CREATE', - 'PATHCONF', - 'STATFS', - 'READLINK', - 'READDIR', - 'SERVER_CAPS', - 'DELEGRETURN', - 'GETACL', - 'SETACL', - 'FS_LOCATIONS', - 'RELEASE_LOCKOWNER', - 'SECINFO', - 'FSID_PRESENT', - 'EXCHANGE_ID', - 'CREATE_SESSION', - 'DESTROY_SESSION', - 'SEQUENCE', - 'GET_LEASE_TIME', - 'RECLAIM_COMPLETE', - 'LAYOUTGET', - 'GETDEVICEINFO', - 'LAYOUTCOMMIT', - 'LAYOUTRETURN', - 'SECINFO_NO_NAME', - 'TEST_STATEID', - 'FREE_STATEID', - 'GETDEVICELIST', - 'BIND_CONN_TO_SESSION', - 'DESTROY_CLIENTID', - 'SEEK', - 'ALLOCATE', - 'DEALLOCATE', - 'LAYOUTSTATS', - 'CLONE', - 'COPY', - 'OFFLOAD_CANCEL', - 'LOOKUPP', - 'LAYOUTERROR', - 'COPY_NOTIFY' -] - -class DeviceData: - """DeviceData objects provide methods for parsing and displaying - data for a single mount grabbed from /proc/self/mountstats - """ - def __init__(self): - self.__nfs_data = dict() - self.__rpc_data = dict() - self.__rpc_data['ops'] = [] - - def __parse_nfs_line(self, words): - if words[0] == 'device': - self.__nfs_data['export'] = words[1] - self.__nfs_data['mountpoint'] = words[4] - self.__nfs_data['fstype'] = words[7] - if words[7].find('nfs') != -1 and words[7] != 'nfsd': - self.__nfs_data['statvers'] = words[8] - elif 'nfs' in words or 'nfs4' in words: - self.__nfs_data['export'] = words[0] - self.__nfs_data['mountpoint'] = words[3] - self.__nfs_data['fstype'] = words[6] - if words[6].find('nfs') != -1 and words[6] != 'nfsd': - self.__nfs_data['statvers'] = words[7] - elif words[0] == 'age:': - self.__nfs_data['age'] = int(words[1]) - elif words[0] == 'opts:': - self.__nfs_data['mountoptions'] = ''.join(words[1:]).split(',') - elif words[0] == 'caps:': - self.__nfs_data['servercapabilities'] = ''.join(words[1:]).split(',') - elif words[0] == 'nfsv4:': - self.__nfs_data['nfsv4flags'] = ''.join(words[1:]).split(',') - elif words[0] == 'sec:': - keys = ''.join(words[1:]).split(',') - self.__nfs_data['flavor'] = int(keys[0].split('=')[1]) - self.__nfs_data['pseudoflavor'] = 0 - if self.__nfs_data['flavor'] == 6: - self.__nfs_data['pseudoflavor'] = int(keys[1].split('=')[1]) - elif words[0] == 'events:': - i = 1 - for key in NfsEventCounters: - try: - self.__nfs_data[key] = int(words[i]) - except IndexError as err: - self.__nfs_data[key] = 0 - i += 1 - elif words[0] == 'bytes:': - i = 1 - for key in NfsByteCounters: - self.__nfs_data[key] = int(words[i]) - i += 1 - - def __parse_rpc_line(self, words): - if words[0] == 'RPC': - self.__rpc_data['statsvers'] = float(words[3]) - self.__rpc_data['programversion'] = words[5] - elif words[0] == 'xprt:': - self.__rpc_data['protocol'] = words[1] - if words[1] == 'udp': - i = 2 - for key in XprtUdpCounters: - if i < len(words): - self.__rpc_data[key] = int(words[i]) - i += 1 - elif words[1] == 'tcp': - i = 2 - for key in XprtTcpCounters: - if i < len(words): - self.__rpc_data[key] = int(words[i]) - i += 1 - elif words[1] == 'rdma': - i = 2 - for key in XprtRdmaCounters: - if i < len(words): - self.__rpc_data[key] = int(words[i]) - i += 1 - elif words[0] == 'per-op': - self.__rpc_data['per-op'] = words - else: - op = words[0][:-1] - self.__rpc_data['ops'] += [op] - self.__rpc_data[op] = [int(word) for word in words[1:]] - if len(self.__rpc_data[op]) < 9: - self.__rpc_data[op] += [0] - - def parse_stats(self, lines): - """Turn a list of lines from a mount stat file into a - dictionary full of stats, keyed by name - """ - found = False - for line in lines: - words = line.split() - if len(words) == 0: - continue - if (not found and words[0] != 'RPC'): - self.__parse_nfs_line(words) - continue - - found = True - self.__parse_rpc_line(words) - - def is_nfs_mountpoint(self): - """Return True if this is an NFS or NFSv4 mountpoint, - otherwise return False - """ - if self.__nfs_data['fstype'] == 'nfs': - return True - elif self.__nfs_data['fstype'] == 'nfs4': - return True - return False - - def nfs_version(self): - if self.is_nfs_mountpoint(): - prog, vers = self.__rpc_data['programversion'].split('/') - return int(vers) - - def display_raw_stats(self): - """Prints out stats in the same format as /proc/self/mountstats - """ - print('device %s mounted on %s with fstype %s %s' % \ - (self.__nfs_data['export'], self.__nfs_data['mountpoint'], \ - self.__nfs_data['fstype'], self.__nfs_data['statvers'])) - print('\topts:\t%s' % ','.join(self.__nfs_data['mountoptions'])) - print('\tage:\t%d' % self.__nfs_data['age']) - print('\tcaps:\t%s' % ','.join(self.__nfs_data['servercapabilities'])) - print('\tsec:\tflavor=%d,pseudoflavor=%d' % (self.__nfs_data['flavor'], \ - self.__nfs_data['pseudoflavor'])) - print('\tevents:\t%s' % " ".join([str(self.__nfs_data[key]) for key in NfsEventCounters])) - print('\tbytes:\t%s' % " ".join([str(self.__nfs_data[key]) for key in NfsByteCounters])) - print('\tRPC iostats version: %1.1f p/v: %s (nfs)' % (self.__rpc_data['statsvers'], \ - self.__rpc_data['programversion'])) - if self.__rpc_data['protocol'] == 'udp': - print('\txprt:\tudp %s' % " ".join([str(self.__rpc_data[key]) for key in XprtUdpCounters])) - elif self.__rpc_data['protocol'] == 'tcp': - print('\txprt:\ttcp %s' % " ".join([str(self.__rpc_data[key]) for key in XprtTcpCounters])) - elif self.__rpc_data['protocol'] == 'rdma': - print('\txprt:\trdma %s' % " ".join([str(self.__rpc_data[key]) for key in XprtRdmaCounters])) - else: - raise Exception('Unknown RPC transport protocol %s' % self.__rpc_data['protocol']) - print('\tper-op statistics') - prog, vers = self.__rpc_data['programversion'].split('/') - if vers == '3': - for op in Nfsv3ops: - print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) - elif vers == '4': - for op in Nfsv4ops: - print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) - else: - print('\tnot implemented for version %d' % vers) - print() - - def display_stats_header(self): - print('Stats for %s mounted on %s:' % \ - (self.__nfs_data['export'], self.__nfs_data['mountpoint'])) - print() - - def display_nfs_options(self): - """Pretty-print the NFS options - """ - print(' NFS mount options: %s' % ','.join(self.__nfs_data['mountoptions'])) - print(' NFS mount age: %s' % datetime.timedelta(seconds = self.__nfs_data['age'])) - print(' NFS server capabilities: %s' % ','.join(self.__nfs_data['servercapabilities'])) - if 'nfsv4flags' in self.__nfs_data: - print(' NFSv4 capability flags: %s' % ','.join(self.__nfs_data['nfsv4flags'])) - if 'pseudoflavor' in self.__nfs_data: - print(' NFS security flavor: %d pseudoflavor: %d' % \ - (self.__nfs_data['flavor'], self.__nfs_data['pseudoflavor'])) - else: - print(' NFS security flavor: %d' % self.__nfs_data['flavor']) - - def display_nfs_events(self): - """Pretty-print the NFS event counters - """ - print() - print('Cache events:') - print(' data cache invalidated %d times' % self.__nfs_data['datainvalidates']) - print(' attribute cache invalidated %d times' % self.__nfs_data['attrinvalidates']) - print() - print('VFS calls:') - print(' VFS requested %d inode revalidations' % self.__nfs_data['inoderevalidates']) - print(' VFS requested %d dentry revalidations' % self.__nfs_data['dentryrevalidates']) - print() - print(' VFS called nfs_readdir() %d times' % self.__nfs_data['vfsreaddir']) - print(' VFS called nfs_lookup() %d times' % self.__nfs_data['vfslookup']) - print(' VFS called nfs_permission() %d times' % self.__nfs_data['vfspermission']) - print(' VFS called nfs_file_open() %d times' % self.__nfs_data['vfsopen']) - print(' VFS called nfs_file_flush() %d times' % self.__nfs_data['vfsflush']) - print(' VFS called nfs_lock() %d times' % self.__nfs_data['vfslock']) - print(' VFS called nfs_fsync() %d times' % self.__nfs_data['vfsfsync']) - print(' VFS called nfs_file_release() %d times' % self.__nfs_data['vfsrelease']) - print() - print('VM calls:') - print(' VFS called nfs_readpage() %d times' % self.__nfs_data['vfsreadpage']) - print(' VFS called nfs_readpages() %d times' % self.__nfs_data['vfsreadpages']) - print(' VFS called nfs_writepage() %d times' % self.__nfs_data['vfswritepage']) - print(' VFS called nfs_writepages() %d times' % self.__nfs_data['vfswritepages']) - print() - print('Generic NFS counters:') - print(' File size changing operations:') - print(' truncating SETATTRs: %d extending WRITEs: %d' % \ - (self.__nfs_data['setattrtrunc'], self.__nfs_data['extendwrite'])) - print(' %d silly renames' % self.__nfs_data['sillyrenames']) - print(' short reads: %d short writes: %d' % \ - (self.__nfs_data['shortreads'], self.__nfs_data['shortwrites'])) - print(' NFSERR_DELAYs from server: %d' % self.__nfs_data['delay']) - print(' pNFS READs: %d' % self.__nfs_data['pnfsreads']) - print(' pNFS WRITEs: %d' % self.__nfs_data['pnfswrites']) - - def display_nfs_bytes(self): - """Pretty-print the NFS event counters - """ - print() - print('NFS byte counts:') - print(' applications read %d bytes via read(2)' % self.__nfs_data['normalreadbytes']) - print(' applications wrote %d bytes via write(2)' % self.__nfs_data['normalwritebytes']) - print(' applications read %d bytes via O_DIRECT read(2)' % self.__nfs_data['directreadbytes']) - print(' applications wrote %d bytes via O_DIRECT write(2)' % self.__nfs_data['directwritebytes']) - print(' client read %d bytes via NFS READ' % self.__nfs_data['serverreadbytes']) - print(' client wrote %d bytes via NFS WRITE' % self.__nfs_data['serverwritebytes']) - - def display_rpc_generic_stats(self): - """Pretty-print the generic RPC stats - """ - sends = self.__rpc_data['rpcsends'] - - print('RPC statistics:') - - print(' %d RPC requests sent, %d RPC replies received (%d XIDs not found)' % \ - (sends, self.__rpc_data['rpcreceives'], self.__rpc_data['badxids'])) - if sends != 0: - print(' average backlog queue length: %d' % \ - (float(self.__rpc_data['backlogutil']) / sends)) - - def display_rpc_op_stats(self): - """Pretty-print the per-op stats - """ - sends = self.__rpc_data['rpcsends'] - - allstats = [] - for op in self.__rpc_data['ops']: - allstats.append([op] + self.__rpc_data[op]) - - print() - for stats in sorted(allstats, key=itemgetter(1), reverse=True): - count = stats[1] - if count != 0: - print('%s:' % stats[0]) - print('\t%d ops (%d%%)' % \ - (count, ((count * 100) / sends)), end=' ') - retrans = stats[2] - count - if retrans != 0: - print('\t%d retrans (%d%%)' % (retrans, ((retrans * 100) / count)), end=' ') - print('\t%d major timeouts' % stats[3], end='') - if len(stats) >= 10 and stats[9] != 0: - print('\t%d errors (%d%%)' % (stats[9], ((stats[9] * 100) / count))) - else: - print('') - print('\tavg bytes sent per op: %d\tavg bytes received per op: %d' % \ - (stats[4] / count, stats[5] / count)) - print('\tbacklog wait: %f' % (float(stats[6]) / count), end=' ') - print('\tRTT: %f' % (float(stats[7]) / count), end=' ') - print('\ttotal execute time: %f (milliseconds)' % \ - (float(stats[8]) / count)) - - def client_rpc_stats(self): - """Tally high-level rpc stats for the nfsstat command - """ - sends = 0 - trans = 0 - authrefrsh = 0 - for op in self.__rpc_data['ops']: - sends += self.__rpc_data[op][0] - trans += self.__rpc_data[op][1] - retrans = trans - sends - # authrefresh stats don't actually get captured in - # /proc/self/mountstats, so we fudge it here - authrefrsh = sends - return (sends, retrans, authrefrsh) - - def display_nfsstat_stats(self): - """Pretty-print nfsstat-style stats - """ - sends = 0 - for op in self.__rpc_data['ops']: - sends += self.__rpc_data[op][0] - if sends == 0: - return - print() - vers = self.nfs_version() - print('Client nfs v%d' % vers) - info = [] - for op in self.__rpc_data['ops']: - print('%-13s' % str.lower(op)[:12], end='') - count = self.__rpc_data[op][0] - pct = (count * 100) / sends - info.append((count, pct)) - if (self.__rpc_data['ops'].index(op) + 1) % 6 == 0: - print() - for (count, pct) in info: - print('%-8u%3u%% ' % (count, pct), end='') - print() - info = [] - print() - if len(info) > 0: - for (count, pct) in info: - print('%-8u%3u%% ' % (count, pct), end='') - print() - - def compare_iostats(self, old_stats): - """Return the difference between two sets of stats - """ - if old_stats.__nfs_data['age'] > self.__nfs_data['age']: - return self - - result = DeviceData() - protocol = self.__rpc_data['protocol'] - - # copy self into result - for key, value in self.__nfs_data.items(): - result.__nfs_data[key] = value - for key, value in self.__rpc_data.items(): - result.__rpc_data[key] = value - - # compute the difference of each item in the list - # note the copy loop above does not copy the lists, just - # the reference to them. so we build new lists here - # for the result object. - for op in result.__rpc_data['ops']: - try: - result.__rpc_data[op] = list(map(difference, self.__rpc_data[op], old_stats.__rpc_data[op])) - except KeyError: - continue - - # update the remaining keys - if protocol == 'udp': - for key in XprtUdpCounters: - result.__rpc_data[key] -= old_stats.__rpc_data[key] - elif protocol == 'tcp': - for key in XprtTcpCounters: - result.__rpc_data[key] -= old_stats.__rpc_data[key] - elif protocol == 'rdma': - for key in XprtRdmaCounters: - result.__rpc_data[key] -= old_stats.__rpc_data[key] - result.__nfs_data['age'] -= old_stats.__nfs_data['age'] - for key in NfsEventCounters: - result.__nfs_data[key] -= old_stats.__nfs_data[key] - for key in NfsByteCounters: - result.__nfs_data[key] -= old_stats.__nfs_data[key] - return result - - def setup_accumulator(self, ops): - """Initialize a DeviceData instance to tally stats for all mountpoints - with the same major version. This is for the nfsstat command. - """ - if ops == Nfsv3ops: - self.__rpc_data['programversion'] = '100003/3' - self.__nfs_data['fstype'] = 'nfs' - elif ops == Nfsv4ops: - self.__rpc_data['programversion'] = '100003/4' - self.__nfs_data['fstype'] = 'nfs4' - self.__rpc_data['ops'] = ops - for op in ops: - self.__rpc_data[op] = [0 for i in range(9)] - - def accumulate_iostats(self, new_stats): - """Accumulate counters from all RPC op buckets in new_stats. This is - for the nfsstat command. - """ - for op in new_stats.__rpc_data['ops']: - try: - self.__rpc_data[op] = list(map(add, self.__rpc_data[op], new_stats.__rpc_data[op])) - except KeyError: - continue - - def __print_rpc_op_stats(self, op, sample_time): - """Print generic stats for one RPC op - """ - if op not in self.__rpc_data: - return - - rpc_stats = self.__rpc_data[op] - ops = float(rpc_stats[0]) - retrans = float(rpc_stats[1] - rpc_stats[0]) - kilobytes = float(rpc_stats[3] + rpc_stats[4]) / 1024 - queued_for = float(rpc_stats[5]) - rtt = float(rpc_stats[6]) - exe = float(rpc_stats[7]) - if len(rpc_stats) >= 9: - errs = int(rpc_stats[8]) - - # prevent floating point exceptions - if ops != 0: - kb_per_op = kilobytes / ops - retrans_percent = (retrans * 100) / ops - rtt_per_op = rtt / ops - exe_per_op = exe / ops - queued_for_per_op = queued_for / ops - if len(rpc_stats) >= 9: - errs_percent = (errs * 100) / ops - else: - kb_per_op = 0.0 - retrans_percent = 0.0 - rtt_per_op = 0.0 - exe_per_op = 0.0 - queued_for_per_op = 0.0 - errs_percent = 0.0 - - op += ':' - print(format(op.lower(), '<16s'), end='') - print(format('ops/s', '>8s'), end='') - print(format('kB/s', '>16s'), end='') - print(format('kB/op', '>16s'), end='') - print(format('retrans', '>16s'), end='') - print(format('avg RTT (ms)', '>16s'), end='') - print(format('avg exe (ms)', '>16s'), end='') - print(format('avg queue (ms)', '>16s'), end='') - if len(rpc_stats) >= 9: - print(format('errors', '>16s'), end='') - print() - - print(format((ops / sample_time), '>24.3f'), end='') - print(format((kilobytes / sample_time), '>16.3f'), end='') - print(format(kb_per_op, '>16.3f'), end='') - retransmits = '{0:>10.0f} ({1:>3.1f}%)'.format(retrans, retrans_percent).strip() - print(format(retransmits, '>16'), end='') - print(format(rtt_per_op, '>16.3f'), end='') - print(format(exe_per_op, '>16.3f'), end='') - print(format(queued_for_per_op, '>16.3f'), end='') - if len(rpc_stats) >= 9: - errors = '{0:>10.0f} ({1:>3.1f}%)'.format(errs, errs_percent).strip() - print(format(errors, '>16'), end='') - print() - - def display_iostats(self, sample_time): - """Display NFS and RPC stats in an iostat-like way - """ - sends = float(self.__rpc_data['rpcsends']) - if sample_time == 0: - sample_time = float(self.__nfs_data['age']) - # sample_time could still be zero if the export was just mounted. - # Set it to 1 to avoid divide by zero errors in this case since we'll - # likely still have relevant mount statistics to show. - # - if sample_time == 0: - sample_time = 1; - if sends != 0: - backlog = (float(self.__rpc_data['backlogutil']) / sends) / sample_time - else: - backlog = 0.0 - - print() - print('%s mounted on %s:' % \ - (self.__nfs_data['export'], self.__nfs_data['mountpoint'])) - print() - - print(format('ops/s', '>16') + format('rpc bklog', '>16')) - print(format((sends / sample_time), '>16.3f'), end='') - print(format(backlog, '>16.3f')) - print() - - self.__print_rpc_op_stats('READ', sample_time) - self.__print_rpc_op_stats('WRITE', sample_time) - sys.stdout.flush() - - def display_xprt_stats(self): - """Pretty-print the xprt statistics - """ - if self.__rpc_data['protocol'] == 'udp': - print('\tTransport protocol: udp') - print('\tSource port: %d' % self.__rpc_data['port']) - print('\tBind count: %d' % self.__rpc_data['bind_count']) - print('\tRPC requests: %d' % self.__rpc_data['rpcsends']) - print('\tRPC replies: %d' % self.__rpc_data['rpcreceives']) - print('\tXIDs not found: %d' % self.__rpc_data['badxids']) - print('\tMax slots: %d' % self.__rpc_data['maxslots']) - if self.__rpc_data['rpcsends'] != 0: - print('\tAvg backlog length: %d' % \ - (float(self.__rpc_data['backlogutil']) / self.__rpc_data['rpcsends'])) - print('\tAvg send queue length: %d' % \ - (float(self.__rpc_data['sendutil']) / self.__rpc_data['rpcsends'])) - print('\tAvg pending queue length: %d' % \ - (float(self.__rpc_data['pendutil']) / self.__rpc_data['rpcsends'])) - elif self.__rpc_data['protocol'] == 'tcp': - print('\tTransport protocol: tcp') - print('\tSource port: %d' % self.__rpc_data['port']) - print('\tBind count: %d' % self.__rpc_data['bind_count']) - print('\tConnect count: %d' % self.__rpc_data['connect_count']) - print('\tConnect time: %d seconds' % self.__rpc_data['connect_time']) - print('\tIdle time: %d seconds' % self.__rpc_data['idle_time']) - print('\tRPC requests: %d' % self.__rpc_data['rpcsends']) - print('\tRPC replies: %d' % self.__rpc_data['rpcreceives']) - print('\tXIDs not found: %d' % self.__rpc_data['badxids']) - print('\tMax slots: %d' % self.__rpc_data['maxslots']) - if self.__rpc_data['rpcsends'] != 0: - print('\tAvg backlog length: %d' % \ - (float(self.__rpc_data['backlogutil']) / self.__rpc_data['rpcsends'])) - print('\tAvg send queue length: %d' % \ - (float(self.__rpc_data['sendutil']) / self.__rpc_data['rpcsends'])) - print('\tAvg pending queue length: %d' % \ - (float(self.__rpc_data['pendutil']) / self.__rpc_data['rpcsends'])) - elif self.__rpc_data['protocol'] == 'rdma': - print('\tTransport protocol: rdma') - print('\tConnect count: %d' % self.__rpc_data['connect_count']) - print('\tConnect time: %d seconds' % self.__rpc_data['connect_time']) - print('\tIdle time: %d seconds' % self.__rpc_data['idle_time']) - sends = self.__rpc_data['rpcsends'] - print('\tRPC requests: %d' % self.__rpc_data['rpcsends']) - print('\tRPC replies: %d' % self.__rpc_data['rpcreceives']) - print('\tXIDs not found: %d' % self.__rpc_data['badxids']) - if self.__rpc_data['rpcsends'] != 0: - print('\tAvg backlog length: %d' % \ - (float(self.__rpc_data['backlogutil']) / self.__rpc_data['rpcsends'])) - print('\tRead segments: %d' % self.__rpc_data['read_segments']) - print('\tWrite segments: %d' % self.__rpc_data['write_segments']) - print('\tReply segments: %d' % self.__rpc_data['reply_segments']) - print('\tRegistered: %d bytes' % self.__rpc_data['total_rdma_req']) - print('\tRDMA received: %d bytes' % self.__rpc_data['total_rdma_rep']) - print('\tTotal pull-up: %d bytes' % self.__rpc_data['pullup']) - print('\tTotal fix-up: %d bytes' % self.__rpc_data['fixup']) - print('\tHardway allocations: %d bytes' % self.__rpc_data['hardway']) - print('\tFailed marshals: %d' % self.__rpc_data['failed_marshal']) - print('\tBad replies: %d' % self.__rpc_data['bad_reply']) - - """ Counters not present in all kernels """ - if 'nomsg_calls' in self.__rpc_data: - print('\tRDMA_NOMSG calls: %d' % self.__rpc_data['nomsg_calls']) - if 'allocated_mrs' in self.__rpc_data: - print('\tAllocated MRs: %d' % self.__rpc_data['allocated_mrs']) - if 'recovered_mrs' in self.__rpc_data: - print('\tRecovered MRs: %d' % self.__rpc_data['recovered_mrs']) - if 'orphaned_mrs' in self.__rpc_data: - print('\tOrphaned MRs: %d' % self.__rpc_data['orphaned_mrs']) - if 'local_invalidates' in self.__rpc_data: - print('\tLocal Invalidates needed: %d' % self.__rpc_data['local_invalidates']) - if 'empty_sendctx_q' in self.__rpc_data: - print('\tEmpty sendctx queue count: %d' % self.__rpc_data['empty_sendctx_q']) - if 'reply_waits_for_send' in self.__rpc_data: - print('\tReplies that waited for Send completion: %d' % self.__rpc_data['reply_waits_for_send']) - else: - raise Exception('Unknown RPC transport protocol %s' % self.__rpc_data['protocol']) - -def parse_stats_file(f): - """pop the contents of a mountstats file into a dictionary, - keyed by mount point. each value object is a list of the - lines in the mountstats file corresponding to the mount - point named in the key. - """ - ms_dict = dict() - key = '' - - f.seek(0) - for line in f.readlines(): - words = line.split() - if len(words) == 0: - continue - if words[0] == 'device': - key = words[4] - new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] - else: - new += [ line.strip() ] - ms_dict[key] = new - - return ms_dict - -def print_mountstats(stats, nfs_only, rpc_only, raw, xprt_only): - if nfs_only: - stats.display_stats_header() - stats.display_nfs_options() - stats.display_nfs_events() - stats.display_nfs_bytes() - elif rpc_only: - stats.display_stats_header() - stats.display_rpc_generic_stats() - stats.display_rpc_op_stats() - elif raw: - stats.display_raw_stats() - elif xprt_only: - stats.display_stats_header() - stats.display_xprt_stats() - else: - stats.display_stats_header() - stats.display_nfs_options() - stats.display_nfs_bytes() - stats.display_rpc_generic_stats() - stats.display_rpc_op_stats() - print() - -def mountstats_command(args): - """Mountstats command - """ - mountstats = parse_stats_file(args.infile) - mountpoints = [os.path.normpath(mp) for mp in args.mountpoints] - - # make certain devices contains only NFS mount points - if len(mountpoints) > 0: - check = [] - for device in mountpoints: - stats = DeviceData() - try: - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - check += [device] - except KeyError: - continue - mountpoints = check - else: - for device, descr in mountstats.items(): - stats = DeviceData() - stats.parse_stats(descr) - if stats.is_nfs_mountpoint(): - mountpoints += [device] - if len(mountpoints) == 0: - print('No NFS mount points were found') - return 1 - - if args.since: - old_mountstats = parse_stats_file(args.since) - - for mp in mountpoints: - stats = DeviceData() - stats.parse_stats(mountstats[mp]) - if not args.since: - print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only) - elif args.since and mp not in old_mountstats: - print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only) - else: - old_stats = DeviceData() - old_stats.parse_stats(old_mountstats[mp]) - diff_stats = stats.compare_iostats(old_stats) - print_mountstats(diff_stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only) - - args.infile.close() - if args.since: - args.since.close() - return 0 - -def nfsstat_command(args): - """nfsstat-like command for NFS mount points - """ - mountstats = parse_stats_file(args.infile) - mountpoints = [os.path.normpath(mp) for mp in args.mountpoints] - v3stats = DeviceData() - v3stats.setup_accumulator(Nfsv3ops) - v4stats = DeviceData() - v4stats.setup_accumulator(Nfsv4ops) - - # ensure stats get printed if neither v3 nor v4 was specified - if args.show_v3 or args.show_v4: - show_both = False - else: - show_both = True - - # make certain devices contains only NFS mount points - if len(mountpoints) > 0: - check = [] - for device in mountpoints: - stats = DeviceData() - try: - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - check += [device] - except KeyError: - continue - mountpoints = check - else: - for device, descr in mountstats.items(): - stats = DeviceData() - stats.parse_stats(descr) - if stats.is_nfs_mountpoint(): - mountpoints += [device] - if len(mountpoints) == 0: - print('No NFS mount points were found') - return 1 - - if args.since: - old_mountstats = parse_stats_file(args.since) - - for mp in mountpoints: - stats = DeviceData() - stats.parse_stats(mountstats[mp]) - vers = stats.nfs_version() - - if not args.since: - acc_stats = stats - elif args.since and mp not in old_mountstats: - acc_stats = stats - else: - old_stats = DeviceData() - old_stats.parse_stats(old_mountstats[mp]) - acc_stats = stats.compare_iostats(old_stats) - - if vers == 3 and (show_both or args.show_v3): - v3stats.accumulate_iostats(acc_stats) - elif vers == 4 and (show_both or args.show_v4): - v4stats.accumulate_iostats(acc_stats) - - sends, retrans, authrefrsh = map(add, v3stats.client_rpc_stats(), v4stats.client_rpc_stats()) - print('Client rpc stats:') - print('calls retrans authrefrsh') - print('%-11u%-11u%-11u' % (sends, retrans, authrefrsh)) - - if show_both or args.show_v3: - v3stats.display_nfsstat_stats() - if show_both or args.show_v4: - v4stats.display_nfsstat_stats() - - args.infile.close() - if args.since: - args.since.close() - return 0 - -def print_iostat_summary(old, new, devices, time): - for device in devices: - stats = DeviceData() - stats.parse_stats(new[device]) - if not old or device not in old: - stats.display_iostats(time) - else: - if ("fstype autofs" not in str(old[device])) and ("fstype autofs" not in str(new[device])): - old_stats = DeviceData() - old_stats.parse_stats(old[device]) - diff_stats = stats.compare_iostats(old_stats) - diff_stats.display_iostats(time) - -def iostat_command(args): - """iostat-like command for NFS mount points - """ - mountstats = parse_stats_file(args.infile) - devices = [os.path.normpath(mp) for mp in args.mountpoints] - - if args.since: - old_mountstats = parse_stats_file(args.since) - else: - old_mountstats = None - - # make certain devices contains only NFS mount points - if len(devices) > 0: - check = [] - for device in devices: - stats = DeviceData() - try: - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - check += [device] - except KeyError: - continue - devices = check - else: - for device, descr in mountstats.items(): - stats = DeviceData() - stats.parse_stats(descr) - if stats.is_nfs_mountpoint(): - devices += [device] - if len(devices) == 0: - print('No NFS mount points were found') - return 1 - - sample_time = 0 - - if args.interval is None: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) - return - - if args.count is not None: - count = args.count - while count != 0: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) - old_mountstats = mountstats - time.sleep(args.interval) - sample_time = args.interval - mountstats = parse_stats_file(args.infile) - count -= 1 - else: - while True: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) - old_mountstats = mountstats - time.sleep(args.interval) - sample_time = args.interval - mountstats = parse_stats_file(args.infile) - - args.infile.close() - if args.since: - args.since.close() - return 0 - -class ICMAction(argparse.Action): - """Custom action to deal with interval, count, and mountpoints. - """ - def __call__(self, parser, namespace, values, option_string=None): - if namespace.mountpoints is None: - namespace.mountpoints = [] - if values is None: - return - elif (type(values) == type([])): - for value in values: - self._handle_one(namespace, value) - else: - self._handle_one(namespace, values) - - def _handle_one(self, namespace, value): - try: - intval = int(value) - if namespace.infile.name != '/proc/self/mountstats': - raise argparse.ArgumentError(self, "not allowed with argument -f/--file or -S/--since") - self._handle_int(namespace, intval) - except ValueError: - namespace.mountpoints.append(value) - - def _handle_int(self, namespace, value): - if namespace.interval is None: - namespace.interval = value - elif namespace.count is None: - namespace.count = value - else: - raise argparse.ArgumentError(self, "too many integer arguments") - -def main(): - parser = argparse.ArgumentParser(epilog='For specific sub-command help, ' - 'run \'mountstats SUB-COMMAND -h|--help\'') - subparsers = parser.add_subparsers(help='sub-command help') - - common_parser = argparse.ArgumentParser(add_help=False) - common_parser.add_argument('-v', '--version', action='version', - version='mountstats ' + Mountstats_version) - common_parser.add_argument('-f', '--file', default=open('/proc/self/mountstats', 'r'), - type=argparse.FileType('r'), dest='infile', - help='Read stats from %(dest)s instead of /proc/self/mountstats') - common_parser.add_argument('-S', '--since', type=argparse.FileType('r'), - metavar='SINCEFILE', - help='Show difference between current stats and those in SINCEFILE') - - mountstats_parser = subparsers.add_parser('mountstats', - parents=[common_parser], - help='Display a combination of per-op RPC statistics, NFS event counts, and NFS byte counts. ' - 'This is the default sub-command if no sub-command is given.') - group = mountstats_parser.add_mutually_exclusive_group() - group.add_argument('-n', '--nfs', action='store_true', dest='nfs_only', - help='Display only the NFS statistics') - group.add_argument('-r', '--rpc', action='store_true', dest='rpc_only', - help='Display only the RPC statistics') - group.add_argument('-R', '--raw', action='store_true', - help='Display only the raw statistics') - group.add_argument('-x', '--xprt', action='store_true', dest='xprt_only', - help='Display only the xprt statistics') - # The mountpoints argument cannot be moved into the common_parser because - # it will screw up the parsing of the iostat arguments (interval and count) - mountstats_parser.add_argument('mountpoints', nargs='*', metavar='mountpoint', - help='Display statistics for this mountpoint. More than one may be specified. ' - 'If absent, statistics for all NFS mountpoints will be generated.') - mountstats_parser.set_defaults(func=mountstats_command) - - nfsstat_parser = subparsers.add_parser('nfsstat', - parents=[common_parser], - help='Display nfsstat-like statistics.') - nfsstat_parser.add_argument('-3', action='store_true', dest='show_v3', - help='Show NFS version 3 statistics') - nfsstat_parser.add_argument('-4', action='store_true', dest='show_v4', - help='Show NFS version 4 statistics') - # The mountpoints argument cannot be moved into the common_parser because - # it will screw up the parsing of the iostat arguments (interval and count) - nfsstat_parser.add_argument('mountpoints', nargs='*', metavar='mountpoint', - help='Display statistics for this mountpoint. More than one may be specified. ' - 'If absent, statistics for all NFS mountpoints will be generated.') - nfsstat_parser.set_defaults(func=nfsstat_command) - - iostat_parser = subparsers.add_parser('iostat', - parents=[common_parser], - help='Display iostat-like statistics.') - iostat_parser.add_argument('interval', nargs='?', action=ICMAction, - help='Number of seconds between reports. If absent, only one report will ' - 'be generated.') - iostat_parser.add_argument('count', nargs='?', action=ICMAction, - help='Number of reports generated at seconds apart. If absent, ' - 'reports will be generated continuously.') - # The mountpoints argument cannot be moved into the common_parser because - # it will screw up the parsing of the iostat arguments (interval and count) - iostat_parser.add_argument('mountpoints', nargs='*', action=ICMAction, metavar='mountpoint', - help='Display statsistics for this mountpoint. More than one may be specified. ' - 'If absent, statistics for all NFS mountpoints will be generated.') - iostat_parser.set_defaults(func=iostat_command) - - args = parser.parse_args() - return args.func(args) - -try: - if __name__ == '__main__': - # Run the mounstats sub-command if no sub-command (or the help flag) - # is given. If the argparse module ever gets support for optional - # (default) sub-commands, then this can be changed. - if len(sys.argv) == 1: - sys.argv.insert(1, 'mountstats') - elif sys.argv[1] not in ['-h', '--help', 'mountstats', 'iostat', 'nfsstat']: - sys.argv.insert(1, 'mountstats') - res = main() - sys.stdout.close() - sys.stderr.close() - sys.exit(res) -except (KeyboardInterrupt, RuntimeError): - sys.exit(1) -except IOError: - pass - diff --git a/nfs-utils-2.5.2/tools/nfs-iostat/Makefile.am b/nfs-utils-2.5.2/tools/nfs-iostat/Makefile.am deleted file mode 100644 index 3ae0f29..0000000 --- a/nfs-utils-2.5.2/tools/nfs-iostat/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -## Process this file with automake to produce Makefile.in -PYTHON_FILES = nfs-iostat.py - -man8_MANS = nfsiostat.man - -EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) - -all-local: $(PYTHON_FILES) - -install-data-hook: - $(INSTALL) -m 755 nfs-iostat.py $(DESTDIR)$(sbindir)/nfsiostat - -MAINTAINERCLEANFILES=Makefile.in diff --git a/nfs-utils-2.5.2/tools/nfs-iostat/nfs-iostat.py b/nfs-utils-2.5.2/tools/nfs-iostat/nfs-iostat.py deleted file mode 100755 index 1df74ba..0000000 --- a/nfs-utils-2.5.2/tools/nfs-iostat/nfs-iostat.py +++ /dev/null @@ -1,675 +0,0 @@ -#!/usr/bin/python3 -# -*- python-mode -*- -"""Emulate iostat for NFS mount points using /proc/self/mountstats -""" - -from __future__ import print_function - -__copyright__ = """ -Copyright (C) 2005, Chuck Lever - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301 USA -""" - -import sys, os, time -from optparse import OptionParser, OptionGroup - -Iostats_version = '0.2' - -def difference(x, y): - """Used for a map() function - """ - return x - y - -NfsEventCounters = [ - 'inoderevalidates', - 'dentryrevalidates', - 'datainvalidates', - 'attrinvalidates', - 'vfsopen', - 'vfslookup', - 'vfspermission', - 'vfsupdatepage', - 'vfsreadpage', - 'vfsreadpages', - 'vfswritepage', - 'vfswritepages', - 'vfsreaddir', - 'vfssetattr', - 'vfsflush', - 'vfsfsync', - 'vfslock', - 'vfsrelease', - 'congestionwait', - 'setattrtrunc', - 'extendwrite', - 'sillyrenames', - 'shortreads', - 'shortwrites', - 'delay' -] - -NfsByteCounters = [ - 'normalreadbytes', - 'normalwritebytes', - 'directreadbytes', - 'directwritebytes', - 'serverreadbytes', - 'serverwritebytes', - 'readpages', - 'writepages' -] - -class DeviceData: - """DeviceData objects provide methods for parsing and displaying - data for a single mount grabbed from /proc/self/mountstats - """ - def __init__(self): - self.__nfs_data = dict() - self.__rpc_data = dict() - self.__rpc_data['ops'] = [] - - def __parse_nfs_line(self, words): - if words[0] == 'device': - self.__nfs_data['export'] = words[1] - self.__nfs_data['mountpoint'] = words[4] - self.__nfs_data['fstype'] = words[7] - if words[7] == 'nfs': - self.__nfs_data['statvers'] = words[8] - elif 'nfs' in words or 'nfs4' in words: - self.__nfs_data['export'] = words[0] - self.__nfs_data['mountpoint'] = words[3] - self.__nfs_data['fstype'] = words[6] - if words[6] == 'nfs': - self.__nfs_data['statvers'] = words[7] - elif words[0] == 'age:': - self.__nfs_data['age'] = int(words[1]) - elif words[0] == 'opts:': - self.__nfs_data['mountoptions'] = ''.join(words[1:]).split(',') - elif words[0] == 'caps:': - self.__nfs_data['servercapabilities'] = ''.join(words[1:]).split(',') - elif words[0] == 'nfsv4:': - self.__nfs_data['nfsv4flags'] = ''.join(words[1:]).split(',') - elif words[0] == 'sec:': - keys = ''.join(words[1:]).split(',') - self.__nfs_data['flavor'] = int(keys[0].split('=')[1]) - self.__nfs_data['pseudoflavor'] = 0 - if self.__nfs_data['flavor'] == 6: - self.__nfs_data['pseudoflavor'] = int(keys[1].split('=')[1]) - elif words[0] == 'events:': - i = 1 - for key in NfsEventCounters: - self.__nfs_data[key] = int(words[i]) - i += 1 - elif words[0] == 'bytes:': - i = 1 - for key in NfsByteCounters: - self.__nfs_data[key] = int(words[i]) - i += 1 - - def __parse_rpc_line(self, words): - if words[0] == 'RPC': - self.__rpc_data['statsvers'] = float(words[3]) - self.__rpc_data['programversion'] = words[5] - elif words[0] == 'xprt:': - self.__rpc_data['protocol'] = words[1] - if words[1] == 'udp': - self.__rpc_data['port'] = int(words[2]) - self.__rpc_data['bind_count'] = int(words[3]) - self.__rpc_data['rpcsends'] = int(words[4]) - self.__rpc_data['rpcreceives'] = int(words[5]) - self.__rpc_data['badxids'] = int(words[6]) - self.__rpc_data['inflightsends'] = int(words[7]) - self.__rpc_data['backlogutil'] = int(words[8]) - elif words[1] == 'tcp': - self.__rpc_data['port'] = words[2] - self.__rpc_data['bind_count'] = int(words[3]) - self.__rpc_data['connect_count'] = int(words[4]) - self.__rpc_data['connect_time'] = int(words[5]) - self.__rpc_data['idle_time'] = int(words[6]) - self.__rpc_data['rpcsends'] = int(words[7]) - self.__rpc_data['rpcreceives'] = int(words[8]) - self.__rpc_data['badxids'] = int(words[9]) - self.__rpc_data['inflightsends'] = int(words[10]) - self.__rpc_data['backlogutil'] = int(words[11]) - elif words[1] == 'rdma': - self.__rpc_data['port'] = words[2] - self.__rpc_data['bind_count'] = int(words[3]) - self.__rpc_data['connect_count'] = int(words[4]) - self.__rpc_data['connect_time'] = int(words[5]) - self.__rpc_data['idle_time'] = int(words[6]) - self.__rpc_data['rpcsends'] = int(words[7]) - self.__rpc_data['rpcreceives'] = int(words[8]) - self.__rpc_data['badxids'] = int(words[9]) - self.__rpc_data['backlogutil'] = int(words[10]) - self.__rpc_data['read_chunks'] = int(words[11]) - self.__rpc_data['write_chunks'] = int(words[12]) - self.__rpc_data['reply_chunks'] = int(words[13]) - self.__rpc_data['total_rdma_req'] = int(words[14]) - self.__rpc_data['total_rdma_rep'] = int(words[15]) - self.__rpc_data['pullup'] = int(words[16]) - self.__rpc_data['fixup'] = int(words[17]) - self.__rpc_data['hardway'] = int(words[18]) - self.__rpc_data['failed_marshal'] = int(words[19]) - self.__rpc_data['bad_reply'] = int(words[20]) - elif words[0] == 'per-op': - self.__rpc_data['per-op'] = words - else: - op = words[0][:-1] - self.__rpc_data['ops'] += [op] - self.__rpc_data[op] = [int(word) for word in words[1:]] - - def parse_stats(self, lines): - """Turn a list of lines from a mount stat file into a - dictionary full of stats, keyed by name - """ - found = False - for line in lines: - words = line.split() - if len(words) == 0: - continue - if (not found and words[0] != 'RPC'): - self.__parse_nfs_line(words) - continue - - found = True - self.__parse_rpc_line(words) - - def is_nfs_mountpoint(self): - """Return True if this is an NFS or NFSv4 mountpoint, - otherwise return False - """ - if self.__nfs_data['fstype'] == 'nfs': - return True - elif self.__nfs_data['fstype'] == 'nfs4': - return True - return False - - def compare_iostats(self, old_stats): - """Return the difference between two sets of stats - """ - result = DeviceData() - - # copy self into result - for key, value in self.__nfs_data.items(): - result.__nfs_data[key] = value - for key, value in self.__rpc_data.items(): - result.__rpc_data[key] = value - - # compute the difference of each item in the list - # note the copy loop above does not copy the lists, just - # the reference to them. so we build new lists here - # for the result object. - for op in result.__rpc_data['ops']: - try: - result.__rpc_data[op] = list(map( - difference, self.__rpc_data[op], old_stats.__rpc_data[op])) - except KeyError: - continue - - # update the remaining keys we care about - result.__rpc_data['rpcsends'] -= old_stats.__rpc_data['rpcsends'] - result.__rpc_data['backlogutil'] -= old_stats.__rpc_data['backlogutil'] - - for key in NfsEventCounters: - result.__nfs_data[key] -= old_stats.__nfs_data[key] - for key in NfsByteCounters: - result.__nfs_data[key] -= old_stats.__nfs_data[key] - - return result - - def __print_data_cache_stats(self): - """Print the data cache hit rate - """ - nfs_stats = self.__nfs_data - app_bytes_read = float(nfs_stats['normalreadbytes']) - if app_bytes_read != 0: - client_bytes_read = float(nfs_stats['serverreadbytes'] - nfs_stats['directreadbytes']) - ratio = ((app_bytes_read - client_bytes_read) * 100) / app_bytes_read - - print() - print('app bytes: %f client bytes %f' % (app_bytes_read, client_bytes_read)) - print('Data cache hit ratio: %4.2f%%' % ratio) - - def __print_attr_cache_stats(self, sample_time): - """Print attribute cache efficiency stats - """ - nfs_stats = self.__nfs_data - - print() - print('%d VFS opens' % (nfs_stats['vfsopen'])) - print('%d inoderevalidates (forced GETATTRs)' % \ - (nfs_stats['inoderevalidates'])) - print('%d page cache invalidations' % \ - (nfs_stats['datainvalidates'])) - print('%d attribute cache invalidations' % \ - (nfs_stats['attrinvalidates'])) - - def __print_dir_cache_stats(self, sample_time): - """Print directory stats - """ - nfs_stats = self.__nfs_data - lookup_ops = self.__rpc_data['LOOKUP'][0] - readdir_ops = self.__rpc_data['READDIR'][0] - if 'READDIRPLUS' in self.__rpc_data: - readdir_ops += self.__rpc_data['READDIRPLUS'][0] - - dentry_revals = nfs_stats['dentryrevalidates'] - opens = nfs_stats['vfsopen'] - lookups = nfs_stats['vfslookup'] - getdents = nfs_stats['vfsreaddir'] - - print() - print('%d open operations (pathname lookups)' % opens) - print('%d dentry revalidates and %d vfs lookup requests' % \ - (dentry_revals, lookups)) - print('resulted in %d LOOKUPs on the wire' % lookup_ops) - print('%d vfs getdents calls resulted in %d READDIRs on the wire' % \ - (getdents, readdir_ops)) - - def __print_page_stats(self, sample_time): - """Print page cache stats - """ - nfs_stats = self.__nfs_data - - vfsreadpage = nfs_stats['vfsreadpage'] - vfsreadpages = nfs_stats['vfsreadpages'] - pages_read = nfs_stats['readpages'] - vfswritepage = nfs_stats['vfswritepage'] - vfswritepages = nfs_stats['vfswritepages'] - pages_written = nfs_stats['writepages'] - - print() - print('%d nfs_readpage() calls read %d pages' % \ - (vfsreadpage, vfsreadpage)) - print('%d nfs_readpages() calls read %d pages' % \ - (vfsreadpages, pages_read - vfsreadpage)) - if vfsreadpages != 0: - print('(%.1f pages per call)' % \ - (float(pages_read - vfsreadpage) / vfsreadpages)) - else: - print() - - print() - print('%d nfs_updatepage() calls' % nfs_stats['vfsupdatepage']) - print('%d nfs_writepage() calls wrote %d pages' % \ - (vfswritepage, vfswritepage)) - print('%d nfs_writepages() calls wrote %d pages' % \ - (vfswritepages, pages_written - vfswritepage)) - if (vfswritepages) != 0: - print('(%.1f pages per call)' % \ - (float(pages_written - vfswritepage) / vfswritepages)) - else: - print() - - congestionwaits = nfs_stats['congestionwait'] - if congestionwaits != 0: - print() - print('%d congestion waits' % congestionwaits) - - def __print_rpc_op_stats(self, op, sample_time): - """Print generic stats for one RPC op - """ - if op not in self.__rpc_data: - return - - rpc_stats = self.__rpc_data[op] - ops = float(rpc_stats[0]) - retrans = float(rpc_stats[1] - rpc_stats[0]) - kilobytes = float(rpc_stats[3] + rpc_stats[4]) / 1024 - queued_for = float(rpc_stats[5]) - rtt = float(rpc_stats[6]) - exe = float(rpc_stats[7]) - if len(rpc_stats) >= 9: - errs = float(rpc_stats[8]) - - # prevent floating point exceptions - if ops != 0: - kb_per_op = kilobytes / ops - retrans_percent = (retrans * 100) / ops - rtt_per_op = rtt / ops - exe_per_op = exe / ops - queued_for_per_op = queued_for / ops - if len(rpc_stats) >= 9: - errs_percent = (errs * 100) / ops - else: - kb_per_op = 0.0 - retrans_percent = 0.0 - rtt_per_op = 0.0 - exe_per_op = 0.0 - queued_for_per_op = 0.0 - if len(rpc_stats) >= 9: - errs_percent = 0.0 - - op += ':' - print(format(op.lower(), '<16s'), end='') - print(format('ops/s', '>8s'), end='') - print(format('kB/s', '>16s'), end='') - print(format('kB/op', '>16s'), end='') - print(format('retrans', '>16s'), end='') - print(format('avg RTT (ms)', '>16s'), end='') - print(format('avg exe (ms)', '>16s'), end='') - print(format('avg queue (ms)', '>16s'), end='') - if len(rpc_stats) >= 9: - print(format('errors', '>16s'), end='') - print() - - print(format((ops / sample_time), '>24.3f'), end='') - print(format((kilobytes / sample_time), '>16.3f'), end='') - print(format(kb_per_op, '>16.3f'), end='') - retransmits = '{0:>10.0f} ({1:>3.1f}%)'.format(retrans, retrans_percent).strip() - print(format(retransmits, '>16'), end='') - print(format(rtt_per_op, '>16.3f'), end='') - print(format(exe_per_op, '>16.3f'), end='') - print(format(queued_for_per_op, '>16.3f'), end='') - if len(rpc_stats) >= 9: - errors = '{0:>10.0f} ({1:>3.1f}%)'.format(errs, errs_percent).strip() - print(format(errors, '>16'), end='') - print() - - def ops(self, sample_time): - sends = float(self.__rpc_data['rpcsends']) - if sample_time == 0: - sample_time = float(self.__nfs_data['age']) - if sample_time == 0: - sample_time = 1; - return (sends / sample_time) - - def display_iostats(self, sample_time, which): - """Display NFS and RPC stats in an iostat-like way - """ - sends = float(self.__rpc_data['rpcsends']) - if sample_time == 0: - sample_time = float(self.__nfs_data['age']) - # sample_time could still be zero if the export was just mounted. - # Set it to 1 to avoid divide by zero errors in this case since we'll - # likely still have relevant mount statistics to show. - # - if sample_time == 0: - sample_time = 1; - if sends != 0: - backlog = (float(self.__rpc_data['backlogutil']) / sends) / sample_time - else: - backlog = 0.0 - - print() - print('%s mounted on %s:' % \ - (self.__nfs_data['export'], self.__nfs_data['mountpoint'])) - print() - - print(format('ops/s', '>16') + format('rpc bklog', '>16')) - print(format((sends / sample_time), '>16.3f'), end='') - print(format(backlog, '>16.3f')) - print() - - if which == 0: - self.__print_rpc_op_stats('READ', sample_time) - self.__print_rpc_op_stats('WRITE', sample_time) - elif which == 1: - self.__print_rpc_op_stats('GETATTR', sample_time) - self.__print_rpc_op_stats('ACCESS', sample_time) - self.__print_attr_cache_stats(sample_time) - elif which == 2: - self.__print_rpc_op_stats('LOOKUP', sample_time) - self.__print_rpc_op_stats('READDIR', sample_time) - if 'READDIRPLUS' in self.__rpc_data: - self.__print_rpc_op_stats('READDIRPLUS', sample_time) - self.__print_dir_cache_stats(sample_time) - elif which == 3: - self.__print_rpc_op_stats('READ', sample_time) - self.__print_rpc_op_stats('WRITE', sample_time) - self.__print_page_stats(sample_time) - - sys.stdout.flush() - -# -# Functions -# - -def parse_stats_file(filename): - """pop the contents of a mountstats file into a dictionary, - keyed by mount point. each value object is a list of the - lines in the mountstats file corresponding to the mount - point named in the key. - """ - ms_dict = dict() - key = '' - - f = open(filename) - for line in f.readlines(): - words = line.split() - if len(words) == 0: - continue - if line.startswith("no device mounted"): - continue - if words[0] == 'device': - key = words[4] - new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] - else: - new += [ line.strip() ] - ms_dict[key] = new - f.close - - return ms_dict - -def print_iostat_summary(old, new, devices, time, options): - stats = {} - diff_stats = {} - devicelist = [] - if old: - # Trim device list to only include intersection of old and new data, - # this addresses umounts due to autofs mountpoints - for device in devices: - if "fstype autofs" not in str(old[device]): - devicelist.append(device) - else: - devicelist = devices - - for device in devicelist: - stats[device] = DeviceData() - stats[device].parse_stats(new[device]) - if old: - old_stats = DeviceData() - old_stats.parse_stats(old[device]) - diff_stats[device] = stats[device].compare_iostats(old_stats) - - if options.sort: - if old: - # We now have compared data and can print a comparison - # ordered by mountpoint ops per second - devicelist.sort(key=lambda x: diff_stats[x].ops(time), reverse=True) - else: - # First iteration, just sort by newly parsed ops/s - devicelist.sort(key=lambda x: stats[x].ops(time), reverse=True) - - count = 1 - for device in devicelist: - if old: - diff_stats[device].display_iostats(time, options.which) - else: - stats[device].display_iostats(time, options.which) - - count += 1 - if (count > options.list): - return - - -def list_nfs_mounts(givenlist, mountstats): - """return a list of NFS mounts given a list to validate or - return a full list if the given list is empty - - may return an empty list if none found - """ - devicelist = [] - if len(givenlist) > 0: - for device in givenlist: - stats = DeviceData() - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - devicelist += [device] - else: - for device, descr in mountstats.items(): - stats = DeviceData() - stats.parse_stats(descr) - if stats.is_nfs_mountpoint(): - devicelist += [device] - return devicelist - -def iostat_command(name): - """iostat-like command for NFS mount points - """ - mountstats = parse_stats_file('/proc/self/mountstats') - devices = [] - origdevices = [] - interval_seen = False - count_seen = False - - mydescription= """ -Sample iostat-like program to display NFS client per-mount' -statistics. The parameter specifies the amount of time in seconds -between each report. The first report contains statistics for the time since -each file system was mounted. Each subsequent report contains statistics -collected during the interval since the previous report. If the -parameter is specified, the value of determines the number of reports -generated at seconds apart. If the interval parameter is specified -without the parameter, the command generates reports continuously. -If one or more names are specified, statistics for only these -mount points will be displayed. Otherwise, all NFS mount points on the -client are listed. -""" - parser = OptionParser( - usage="usage: %prog [ [ ] ] [ ] [ ]", - description=mydescription, - version='version %s' % Iostats_version) - parser.set_defaults(which=0, sort=False, list=sys.maxsize) - - statgroup = OptionGroup(parser, "Statistics Options", - 'File I/O is displayed unless one of the following is specified:') - statgroup.add_option('-a', '--attr', - action="store_const", - dest="which", - const=1, - help='displays statistics related to the attribute cache') - statgroup.add_option('-d', '--dir', - action="store_const", - dest="which", - const=2, - help='displays statistics related to directory operations') - statgroup.add_option('-p', '--page', - action="store_const", - dest="which", - const=3, - help='displays statistics related to the page cache') - parser.add_option_group(statgroup) - displaygroup = OptionGroup(parser, "Display Options", - 'Options affecting display format:') - displaygroup.add_option('-s', '--sort', - action="store_true", - dest="sort", - help="Sort NFS mount points by ops/second") - displaygroup.add_option('-l','--list', - action="store", - type="int", - dest="list", - help="only print stats for first LIST mount points") - parser.add_option_group(displaygroup) - - (options, args) = parser.parse_args(sys.argv) - for arg in args: - - if arg == sys.argv[0]: - continue - - if arg in mountstats: - origdevices += [arg] - elif not interval_seen: - try: - interval = int(arg) - except: - print('Illegal value %s' % arg) - return - if interval > 0: - interval_seen = True - else: - print('Illegal value %s' % arg) - return - elif not count_seen: - try: - count = int(arg) - except: - print('Ilegal value %s' % arg) - return - if count > 0: - count_seen = True - else: - print('Illegal value %s' % arg) - return - - # make certain devices contains only NFS mount points - devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return - - - old_mountstats = None - sample_time = 0.0 - - if not interval_seen: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) - return - - if count_seen: - while count != 0: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) - old_mountstats = mountstats - time.sleep(interval) - sample_time = interval - mountstats = parse_stats_file('/proc/self/mountstats') - # automount mountpoints add and drop, if automount is involved - # we need to recheck the devices list when reparsing - devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return - count -= 1 - else: - while True: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) - old_mountstats = mountstats - time.sleep(interval) - sample_time = interval - mountstats = parse_stats_file('/proc/self/mountstats') - # automount mountpoints add and drop, if automount is involved - # we need to recheck the devices list when reparsing - devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return - -# -# Main -# -prog = os.path.basename(sys.argv[0]) - -try: - iostat_command(prog) -except KeyboardInterrupt: - print('Caught ^C... exiting') - sys.exit(1) - -sys.exit(0) diff --git a/nfs-utils-2.5.2/tools/nfs-iostat/nfsiostat.man b/nfs-utils-2.5.2/tools/nfs-iostat/nfsiostat.man deleted file mode 100644 index 940c043..0000000 --- a/nfs-utils-2.5.2/tools/nfs-iostat/nfsiostat.man +++ /dev/null @@ -1,141 +0,0 @@ -.\" -.\" nfsiostat(8) -.\" -.TH nfsiostat 8 "15 Apr 2010" -.SH NAME -nfsiostat \- Emulate iostat for NFS mount points using /proc/self/mountstats -.SH SYNOPSIS -.BI "nfsiostat [[" "] [" "]] [" "][" "] -.SH DESCRIPTION -The -.B nfsiostat -command displays NFS client per-mount statisitics. -.TP - -specifies the amount of time in seconds between each report. -The first report contains statistics for the time since each file -system was mounted. Each subsequent report contains statistics collected -during the interval since the previous report. -.TP - -If the -.I -parameter is -specified, the value of -.I -determines the number of reports generated at -.I -seconds apart. if the interval parameter is -specified without the -.I -parameter, the command generates reports continuously. -.TP - -Define below -.TP - -If one or more -.I -names are specified, statistics for only these mount points will -be displayed. Otherwise, all NFS mount points on the client are listed. -.TP -The meaning of each column of \fBnfsiostat\fR's output is the following: -.RS 8 -- \fBop/s\fR -.RS -This is the number of operations per second. -.RS -.RE -.RE -.RE -.RS 8 -- \fBrpc bklog\fR -.RS -This is the length of the backlog queue. -.RE -.RE -.RE -.RS 8 -- \fBkB/s\fR -.RS -This is the number of kB written/read per second. -.RE -.RE -.RE -.RS 8 -- \fBkB/op\fR -.RS -This is the number of kB written/read per each operation. -.RE -.RE -.RE -.RS 8 -- \fBretrans\fR -.RS -This is the number of retransmissions. -.RE -.RE -.RE -.RS 8 -- \fBavg RTT (ms)\fR -.RS -This is the duration from the time that client's kernel sends the RPC request until the time it receives the reply. -.RE -.RE -.RE -.RS 8 -- \fBavg exe (ms)\fR -.RS -This is the duration from the time that NFS client does the RPC request to its kernel until the RPC request is completed, this includes the RTT time above. -.RE -.RE -.RE -.RS 8 -- \fBavg queue (ms)\fR -.RS -This is the duration from the time the NFS client created the RPC request task to the time the request is transmitted. -.RE -.RE -.RE -.RS 8 -- \fBerrors\fR -.RS -This is the number of operations that completed with an error status (status < 0). This count is only available on kernels with RPC iostats version 1.1 or above. -.RS -.RE -.RE -.RE -.TP -Note that if an interval is used as argument to \fBnfsiostat\fR, then the diffrence from previous interval will be displayed, otherwise the results will be from the time that the share was mounted. - -.SH OPTIONS -.TP -.B \-a " or " \-\-attr -displays statistics related to the attribute cache -.TP -.B \-d " or " \-\-dir -displays statistics related to directory operations -.TP -.B \-h " or " \-\-help -shows help message and exit -.TP -.B \-l LIST or " \-\-list=LIST -only print stats for first LIST mount points -.TP -.B \-p " or " \-\-page -displays statistics related to the page cache -.TP -.B \-s " or " \-\-sort -Sort NFS mount points by ops/second -.TP -.B \-\-version -show program's version number and exit -.SH FILES -.TP -.B /proc/self/mountstats -.SH SEE ALSO -.BR iostat (8), -.BR mountstats (8), -.BR nfsstat(8) -.SH AUTHOR -Chuck Lever diff --git a/nfs-utils-2.5.2/tools/nfsconf/Makefile.am b/nfs-utils-2.5.2/tools/nfsconf/Makefile.am deleted file mode 100644 index b3c1495..0000000 --- a/nfs-utils-2.5.2/tools/nfsconf/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = nfsconf.man -EXTRA_DIST = $(man8_MANS) - -sbin_PROGRAMS = nfsconf - -nfsconf_SOURCES = nfsconfcli.c -nfsconf_LDADD = ../../support/nfs/libnfsconf.la - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/tools/nfsconf/nfsconf.man b/nfs-utils-2.5.2/tools/nfsconf/nfsconf.man deleted file mode 100644 index 3079198..0000000 --- a/nfs-utils-2.5.2/tools/nfsconf/nfsconf.man +++ /dev/null @@ -1,112 +0,0 @@ -.\" -.\" nfsconf(8) -.\" -.TH nfsconf 8 "2 May 2018" -.SH NAME -nfsconf \- Query various NFS configuration settings -.SH SYNOPSIS -.B nfsconf \-\-dump -.RB [ \-v | \-\-verbose ] -.RB [ \-f | \-\-file -.IR infile.conf ] -.RI [ outfile ] -.P -.B nfsconf \-\-get -.RB [ \-v | \-\-verbose ] -.RB [ \-f | \-\-file -.IR infile.conf ] -.RB [ \-a | \-\-arg -.IR subsection ] -.IR section -.IR tag -.P -.B nfsconf \-\-isset -.RB [ \-v | \-\-verbose ] -.RB [ \-f | \-\-file -.IR infile.conf ] -.RB [ \-a | \-\-arg -.IR subsection ] -.IR section -.IR tag -.P -.B nfsconf \-\-set -.RB [ \-v | \-\-verbose ] -.RB [ \-m | \-\-modified -.IR "Modified by text" ] -.RB [ \-f | \-\-file -.IR infile.conf ] -.RB [ \-a | \-\-arg -.IR subsection ] -.IR section -.IR tag -.IR value -.P -.B nfsconf \-\-unset -.RB [ \-v | \-\-verbose ] -.RB [ \-f | \-\-file -.IR infile.conf ] -.RB [ \-a | \-\-arg -.IR subsection ] -.IR section -.IR tag -.SH DESCRIPTION -The -.B nfsconf -command can be used to test for and retrieve configuration settings -from a range of nfs-utils configuration files. -.SS Modes -The following modes are available: -.IP "\fB\-d, \-\-dump\fP" -Output an alphabetically sorted dump of the current configuration in conf file format. Accepts an optional filename in which to write the output. -.IP "\fB\-i, \-\-isset\fP" -Test if a specific tag has a value set. -.IP "\fB\-g, \-\-get\fP" -Output the current value of the specified tag. -.IP "\fB\-s, \-\-set\fP" -Update or Add a tag and value to the config file in a specified section, creating the tag, section, and file if necessary. If the section is defined as '#' then a comment is appended to the file. If a comment is set with a tag name then any exiting tagged comment with a matching name is replaced. -.IP "\fB\-u, \-\-unset\fP" -Remove the specified tag and its value from the config file. -.SH OPTIONS -.SS Options valid in all modes -.TP -.B \-v, \-\-verbose -Increase verbosity and print debugging information. -.TP -.B \-f, \-\-file \fIinfile\fR -Select a different config file to operate upon, default is -.I /etc/nfs.conf -.SS Options only valid in \fB\-\-get\fR and \fB\-\-isset\fR modes. -.TP -.B \-a, \-\-arg \fIsubsection\fR -Select a specific sub-section -.SS Options only valid in \fB\-\-set\fR mode. -.B \-m, \-\-modified \fI"Modified by nfsconf"\fR -Set the text on the Modified date comment in the file. Set to empty to remove. -.SH EXIT STATUS -.SS \fB\-\-isset\fR mode -In this mode the command will return success (0) if the selected tag has a value, any other exit code indicates the value is not set, or some other error has occurred. -.SS all other modes -Success is indicated by an exit status of zero, any other status indicates an error. Error messages are output on stderr, and increasing verbosity will give more detailed explanations if any are available. -.SH EXAMPLES -.TP -.B nfsconf -v --dump --file /tmp/testconf.conf sorted.conf -Check a new config file for syntax errors and output a sorted version for ease of comparison with existing settings. -.TP -.B if ! nfsconf --isset gssd preferred-realm ; then echo 'No preferred realm configured for gss'; fi -The tool allows for easy testing of configuration values from shell scripts, here we test if a specific value has been set. -.TP -.B nfsconf --file /etc/nfsmount.conf --get --arg /home MountPoint background -Show default value for \fIbackground\fR option for NFS mounts of the \fI/home\fR path. -.TP -.B nfsconf --file /etc/nfs.conf --set nfsd debug 1 -Enable debugging in nfsd -.SH FILES -.TP -.B /etc/nfs.conf -.SH SEE ALSO -.BR nfsd (8), -.BR exportfs (8), -.BR idmapd (8), -.BR statd (8) -.SH AUTHOR -Justin Mitchell diff --git a/nfs-utils-2.5.2/tools/nfsconf/nfsconfcli.c b/nfs-utils-2.5.2/tools/nfsconf/nfsconfcli.c deleted file mode 100644 index 361d386..0000000 --- a/nfs-utils-2.5.2/tools/nfsconf/nfsconfcli.c +++ /dev/null @@ -1,243 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "config.h" -#include "conffile.h" -#include "xlog.h" - -typedef enum { - MODE_NONE, - MODE_GET, - MODE_ISSET, - MODE_DUMP, - MODE_SET, - MODE_UNSET -} confmode_t; - -static void usage(const char *name) -{ - fprintf(stderr, "Usage: %s [-v] [--file filename.conf] ...\n", name); - fprintf(stderr, "Options:\n"); - fprintf(stderr, " -v Increase Verbosity\n"); - fprintf(stderr, " --file filename.conf Load this config file\n"); - fprintf(stderr, " (Default config file: " NFS_CONFFILE "\n"); - fprintf(stderr, " --modified \"info\" Use \"info\" in file modified header\n"); - fprintf(stderr, "Modes:\n"); - fprintf(stderr, " --dump [outputfile]\n"); - fprintf(stderr, " Outputs the configuration to the named file\n"); - fprintf(stderr, " --get [--arg subsection] {section} {tag}\n"); - fprintf(stderr, " Output one specific config value\n"); - fprintf(stderr, " --isset [--arg subsection] {section} {tag}\n"); - fprintf(stderr, " Return code indicates if config value is present\n"); - fprintf(stderr, " --set [--arg subsection] {section} {tag} {value}\n"); - fprintf(stderr, " Set and Write a config value\n"); - fprintf(stderr, " --unset [--arg subsection] {section} {tag}\n"); - fprintf(stderr, " Remove an existing config value\n"); -} - -int main(int argc, char **argv) -{ - char * confpath = NFS_CONFFILE; - char * arg = NULL; - int verbose=0; - int ret = 0; - char * dumpfile = NULL; - - confmode_t mode = MODE_NONE; - - modified_by = "Modified by nfsconf"; - - while (1) { - int c; - int index = 0; - struct option long_options[] = { - {"get", no_argument, 0, 'g' }, - {"set", no_argument, 0, 's' }, - {"unset", no_argument, 0, 'u' }, - {"arg", required_argument, 0, 'a' }, - {"isset", no_argument, 0, 'i' }, - {"dump", optional_argument, 0, 'd' }, - {"file", required_argument, 0, 'f' }, - {"verbose", no_argument, 0, 'v' }, - {"modified", required_argument, 0, 'm' }, - {NULL, 0, 0, 0 } - }; - - c = getopt_long(argc, argv, "gsua:id::f:vm:", long_options, &index); - if (c == -1) break; - - switch (c) { - case 0: - break; - case 'f': - /* user specified source path for config */ - confpath = optarg; - break; - case 'a': - /* user supplied a sub-section name */ - arg = optarg; - break; - case 'v': - verbose++; - break; - case 'g': - mode = MODE_GET; - break; - case 's': - mode = MODE_SET; - break; - case 'u': - mode = MODE_UNSET; - break; - case 'i': - mode = MODE_ISSET; - break; - case 'd': - /* check if user supplied a filename for dump */ - if (optarg == NULL && argv[optind] != NULL - && argv[optind][0] != '-') - optarg = argv[optind++]; - mode = MODE_DUMP; - dumpfile = optarg; - break; - case 'm': - if (optarg == NULL || *optarg == 0) - modified_by = NULL; - else - modified_by = optarg; - break; - default: - usage(argv[0]); - return 1; - } - } - - /* configure the logging that conffile.c uses */ - if (verbose) - xlog_config(D_ALL, 1); - xlog_stderr(1); - xlog_syslog(0); - xlog_open("nfsconf"); - - if (mode == MODE_NONE) { - fprintf(stderr, "Error: No MODE selected.\n"); - usage(argv[0]); - return 1; - } - - if (mode != MODE_SET && mode != MODE_UNSET) { - if (conf_init_file(confpath)) { - /* config file was missing or had an error, warn about it */ - if (verbose || mode != MODE_ISSET) { - fprintf(stderr, "Error loading config file %s\n", - confpath); - } - - /* this isnt fatal for --isset */ - if (mode != MODE_ISSET) - return 1; - } - } - - /* --dump mode, output the current configuration */ - if (mode == MODE_DUMP) { - /* default to writing it to stdout */ - FILE *out = stdout; - - /* user specified a file to write to instead */ - if (dumpfile) { - out = fopen(dumpfile, "w"); - if (out == NULL) { - fprintf(stderr, "Error opening dumpfile %s: %s\n", - dumpfile, strerror(errno)); - ret = 2; - goto cleanup; - } - if (verbose) - printf("Dumping config to %s\n", dumpfile); - } - - /* output the configuration */ - conf_report(out); - - /* close that user specified file */ - if (dumpfile) - fclose(out); - } else - /* --iset and --get share a lot of code */ - if (mode == MODE_GET || mode == MODE_ISSET) { - char * section = NULL; - char * tag = NULL; - const char * val; - - /* test they supplied section and tag names */ - if (optind+1 >= argc) { - fprintf(stderr, "Error: insufficient arguments for mode\n"); - usage(argv[0]); - ret = 2; - goto cleanup; - } - - /* now we have a section and tag name */ - section = argv[optind++]; - tag = argv[optind++]; - - /* retrieve the specified tags value */ - val = conf_get_section(section, arg, tag); - if (val != NULL) { - /* ret=0, success, mode --get wants to output the value as well */ - if (mode == MODE_GET) - printf("%s\n", val); - } else { - /* ret=1, no value found, tell the user if they asked */ - if (mode == MODE_GET && verbose) - fprintf(stderr, "Tag '%s' not found\n", tag); - ret = 1; - } - } else - if (mode == MODE_SET || mode == MODE_UNSET) { - char * section = NULL; - char * tag = NULL; - char * val = NULL; - int need = 2; - - if (mode == MODE_UNSET) - need = 1; - - /* test they supplied section and tag names */ - if (optind+need >= argc) { - fprintf(stderr, "Error: insufficient arguments for mode\n"); - usage(argv[0]); - ret = 2; - goto cleanup; - } - - /* now we have a section and tag name */ - section = argv[optind++]; - tag = argv[optind++]; - if (mode == MODE_SET) - val = argv[optind++]; - - /* setting an empty string is same as unsetting */ - if (val!=NULL && *val == '\0') { - mode = MODE_UNSET; - val = NULL; - } - - if (conf_write(confpath, section, arg, tag, val)) { - if (verbose) - fprintf(stderr, "Error writing config\n"); - ret = 1; - } - } else { - fprintf(stderr, "Mode not yet implemented.\n"); - ret = 2; - } - -cleanup: - conf_cleanup(); - return ret; -} diff --git a/nfs-utils-2.5.2/tools/nfsdclddb/Makefile.am b/nfs-utils-2.5.2/tools/nfsdclddb/Makefile.am deleted file mode 100644 index 18263fb..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclddb/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -## Process this file with automake to produce Makefile.in -PYTHON_FILES = nfsdclddb.py - -man8_MANS = nfsdclddb.man - -EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) - -all-local: $(PYTHON_FILES) - -install-data-hook: - $(INSTALL) -m 755 nfsdclddb.py $(DESTDIR)$(sbindir)/nfsdclddb - -MAINTAINERCLEANFILES=Makefile.in diff --git a/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.man b/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.man deleted file mode 100644 index 8ec7b18..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.man +++ /dev/null @@ -1,83 +0,0 @@ -.\" -.\" nfsdclddb(8) -.\" -.TH nfsdclddb 8 "07 Aug 2019" -.SH NAME -nfsdclddb \- Tool for manipulating the nfsdcld sqlite database -.SH SYNOPSIS -.B nfsdclddb -.RB [ \-h | \-\-help ] -.P -.B nfsdclddb -.RB [ \-p | \-\-path -.IR dbpath ] -.B fix-table-names -.RB [ \-h | \-\-help ] -.P -.B nfsdclddb -.RB [ \-p | \-\-path -.IR dbpath ] -.B downgrade-schema -.RB [ \-h | \-\-help ] -.RB [ \-v | \-\-version -.IR to-version ] -.P -.B nfsdclddb -.RB [ \-p | \-\-path -.IR dbpath ] -.B print -.RB [ \-h | \-\-help ] -.RB [ \-s | \-\-summary ] -.P - -.SH DESCRIPTION -.RB "The " nfsdclddb " command is provided to perform some manipulation of the nfsdcld sqlite database schema and to print the contents of the database." -.SS Sub-commands -Valid -.B nfsdclddb -subcommands are: -.IP "\fBfix-table-names\fP" -.RB "A previous version of " nfsdcld "(8) contained a bug that corrupted the reboot epoch table names. This sub-command will fix those table names." -.IP "\fBdowngrade-schema\fP" -Downgrade the database schema. Currently the schema can only to downgraded from version 4 to version 3. -.IP "\fBprint\fP" -Display the contents of the database. Prints the schema version and the values of the current and recovery epochs. If the -.BR \-s | \-\-summary -option is not given, also prints the clients in the reboot epoch tables. -.SH OPTIONS -.SS Options valid for all sub-commands -.TP -.B \-h, \-\-help -Show the help message and exit -.TP -\fB\-p \fIdbpath\fR, \fB\-\-path \fIdbpath\fR -Open the sqlite database located at -.I dbpath -instead of -.IR /var/lib/nfs/nfsdcld/main.sqlite ". " -This is mainly for testing purposes. -.SS Options specific to the downgrade-schema sub-command -.TP -\fB\-v \fIto-version\fR, \fB\-\-version \fIto-version\fR -The schema version to downgrade to. Currently the schema can only be downgraded to version 3. -.SS Options specific to the print sub-command -.TP -.B \-s, \-\-summary -Do not list the clients in the reboot epoch tables in the output. -.SH NOTES -The -.B nfsdclddb -command will not allow the -.B fix-table-names -or -.B downgrade-schema -subcommands to be used if -.BR nfsdcld (8) -is running. -.SH FILES -.TP -.B /var/lib/nfs/nfsdcld/main.sqlite -.SH SEE ALSO -.BR nfsdcld (8) -.SH AUTHOR -Scott Mayhew diff --git a/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.py b/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.py deleted file mode 100644 index 8a66131..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclddb/nfsdclddb.py +++ /dev/null @@ -1,266 +0,0 @@ -#!/usr/bin/python3 -"""Tool for manipulating the nfsdcld sqlite database -""" - -__copyright__ = """ -Copyright (C) 2019 Scott Mayhew - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. -""" - -import argparse -import os -import sqlite3 -import sys - - -class CldDb(): - def __init__(self, path): - self.con = sqlite3.connect(path) - self.con.row_factory = sqlite3.Row - for row in self.con.execute('select value from parameters ' - 'where key = "version"'): - self.version = int(row['value']) - for row in self.con.execute('select * from grace'): - self.current = int(row['current']) - self.recovery = int(row['recovery']) - - def __del__(self): - self.con.close() - - def __str__(self): - return ('Schema version: {self.version} ' - 'current epoch: {self.current} ' - 'recovery epoch: {self.recovery}'.format(self=self)) - - def _print_clients(self, epoch): - if epoch: - for row in self.con.execute('select * from "rec-{:016x}"' - .format(epoch)): - if self.version >= 4: - if row['princhash'] is not None: - princhash = row['princhash'].hex() - else: - princhash = "(null)" - print('id = {}, princhash = {}' - .format(row['id'].decode(), princhash)) - else: - print('id = {}'.format(row['id'].decode())) - - def print_current_clients(self): - print('Clients in current epoch:') - self._print_clients(self.current) - - def print_recovery_clients(self): - if self.recovery: - print('Clients in recovery epoch:') - self._print_clients(self.recovery) - - def check_bad_table_names(self): - bad_names = [] - for row in self.con.execute('select name from sqlite_master ' - 'where type = "table" ' - 'and name like "%rec-%" ' - 'and length(name) < 20'): - bad_names.append(row['name']) - return bad_names - - def fix_bad_table_names(self): - try: - self.con.execute('begin exclusive transaction') - bad_names = self.check_bad_table_names() - for bad_name in bad_names: - epoch = int(bad_name.split('-')[1], base=16) - if epoch == self.current or epoch == self.recovery: - if epoch == self.current: - which = 'current' - else: - which = 'recovery' - print('found invalid table name {} for {} epoch' - .format(bad_name, which)) - self.con.execute('alter table "{}" ' - 'rename to "rec-{:016x}"' - .format(bad_name, epoch)) - print('renamed to rec-{:016x}'.format(epoch)) - else: - print('found invalid table name {} for unknown epoch {}' - .format(bad_name, epoch)) - self.con.execute('drop table "{}"'.format(bad_name)) - print('dropped table {}'.format(bad_name)) - except sqlite3.Error: - self.con.rollback() - else: - self.con.commit() - - def has_princ_data(self): - if self.version < 4: - return False - for row in self.con.execute('select count(*) ' - 'from "rec-{:016x}" ' - 'where princhash not null' - .format(self.current)): - count = row[0] - if self.recovery: - for row in self.con.execute('select count(*) ' - 'from "rec-{:016x}" ' - 'where princhash not null' - .format(self.current)): - count = count + row[0] - if count: - return True - return False - - def _downgrade_table_v4_to_v3(self, epoch): - if not self.con.in_transaction: - raise sqlite3.Error - try: - self.con.execute('create table "new_rec-{:016x}" ' - '(id blob primary key)'.format(epoch)) - self.con.execute('insert into "new_rec-{:016x}" ' - 'select id from "rec-{:016x}"' - .format(epoch, epoch)) - self.con.execute('drop table "rec-{:016x}"'.format(epoch)) - self.con.execute('alter table "new_rec-{:016x}" ' - 'rename to "rec-{:016x}"' - .format(epoch, epoch)) - except sqlite3.Error: - raise - - def downgrade_schema_v4_to_v3(self): - try: - self.con.execute('begin exclusive transaction') - for row in self.con.execute('select value from parameters ' - 'where key = "version"'): - version = int(row['value']) - if version != self.version: - raise sqlite3.Error - for row in self.con.execute('select * from grace'): - current = int(row['current']) - recovery = int(row['recovery']) - if current != self.current: - raise sqlite3.Error - if recovery != self.recovery: - raise sqlite3.Error - self._downgrade_table_v4_to_v3(current) - if recovery: - self._downgrade_table_v4_to_v3(recovery) - self.con.execute('update parameters ' - 'set value = "3" ' - 'where key = "version"') - self.version = 3 - except sqlite3.Error: - self.con.rollback() - print('Downgrade failed') - else: - self.con.commit() - print('Downgrade successful') - - -def nfsdcld_active(): - rc = os.system('ps -C nfsdcld >/dev/null 2>/dev/null') - if rc == 0: - return True - return False - - -def fix_table_names_command(db, args): - if nfsdcld_active(): - print('Warning: nfsdcld is running!') - ans = input('Continue? ') - if ans.lower() not in ['y', 'yes']: - print('Operation canceled.') - return - bad_names = db.check_bad_table_names() - if not bad_names: - print('No invalid table names found.') - return - db.fix_bad_table_names() - - -def downgrade_schema_command(db, args): - if nfsdcld_active(): - print('Warning: nfsdcld is running!') - ans = input('Continue? ') - if ans.lower() not in ['y', 'yes']: - print('Operation canceled') - return - if db.version != 4: - print('Cannot downgrade database from schema version {}.' - .format(db.version)) - return - if args.version != 3: - print('Cannot downgrade to version {}.'.format(args.version)) - return - bad_names = db.check_bad_table_names() - if bad_names: - print('Invalid table names detected.') - print('Please run "{} fix-table-names" before downgrading the schema.' - .format(sys.argv[0])) - return - if db.has_princ_data(): - print('Warning: database has principal data, which will be erased.') - ans = input('Continue? ') - if ans.lower() not in ['y', 'yes']: - print('Operation canceled') - return - db.downgrade_schema_v4_to_v3() - - -def print_command(db, args): - print(str(db)) - if not args.summary: - bad_names = db.check_bad_table_names() - if bad_names: - print('Invalid table names detected.') - print('Please run "{} fix-table-names".'.format(sys.argv[0])) - return - db.print_current_clients() - db.print_recovery_clients() - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('-p', '--path', - default='/var/lib/nfs/nfsdcld/main.sqlite', - help='path to the database ' - '(default: /var/lib/nfs/nfsdcld/main.sqlite)') - subparsers = parser.add_subparsers(help='sub-command help') - fix_parser = subparsers.add_parser('fix-table-names', - help='fix invalid table names') - fix_parser.set_defaults(func=fix_table_names_command) - downgrade_parser = subparsers.add_parser('downgrade-schema', - help='downgrade database schema') - downgrade_parser.add_argument('-v', '--version', type=int, choices=[3], - default=3, - help='version to downgrade to') - downgrade_parser.set_defaults(func=downgrade_schema_command) - print_parser = subparsers.add_parser('print', - help='print database info') - print_parser.add_argument('-s', '--summary', default=False, - action='store_true', - help='print summary only') - print_parser.set_defaults(func=print_command) - args = parser.parse_args() - if not os.path.exists(args.path): - return parser.print_usage() - clddb = CldDb(args.path) - return args.func(clddb, args) - - -if __name__ == '__main__': - if len(sys.argv) == 1: - sys.argv.extend(['print', '--summary']) - main() diff --git a/nfs-utils-2.5.2/tools/nfsdclnts/Makefile.am b/nfs-utils-2.5.2/tools/nfsdclnts/Makefile.am deleted file mode 100644 index d513edb..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclnts/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -## Process this file with automake to produce Makefile.in -PYTHON_FILES = nfsdclnts.py - -man8_MANS = nfsdclnts.man - -EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) - -all-local: $(PYTHON_FILES) - -install-data-hook: - $(INSTALL) -m 755 nfsdclnts.py $(DESTDIR)$(sbindir)/nfsdclnts - -MAINTAINERCLEANFILES=Makefile.in diff --git a/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.man b/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.man deleted file mode 100644 index c7efbd7..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.man +++ /dev/null @@ -1,180 +0,0 @@ -.\" -.\" nfsdclnts(8) -.\" -.TH "NFSDCLTS" "8" "2020-05-09" "nfsdclnts" "nfsdclnts" -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.ss \n[.ss] 0 -.nh -.ad l -.de URL -\fI\\$2\fP <\\$1>\\$3 -.. -.als MTO URL -.if \n[.g] \{\ -. mso www.tmac -. am URL -. ad l -. . -. am MTO -. ad l -. . -. LINKSTYLE blue R < > -.\} -.SH "NAME" -nfsdclnts \- print various nfs client information for knfsd server. -.SH "SYNOPSIS" -.sp -\fBnfsdclnts\fP [\fI\-h\fP] [\fI\-t type\fP] [\fI\-\-clientinfo\fP] [\fI\-\-hostname\fP] [\fI\-q\fP] -.SH "DESCRIPTION" -.sp -The nfsdclnts(8) command parses the content present in /proc/fs/nfsd/clients/ directories. nfsdclnts(8) displays files which are open, locked, delegated by the nfs\-client. It also prints useful client information such as hostname, clientID, NFS version mounted by the nfs\-client. -.SH "OPTIONS" -.sp -\fB\-t, \-\-type\fP=TYPE -.RS 4 -Specify the type of file to be displayed. Takes only one TYPE at a time. -.sp -\fIopen\fP, \fIlock\fP, \fIdeleg\fP, \fIlayout\fP, or \fIall\fP -.sp -open: displays the open files by nfs\-client(s). -.sp -lock: displays the files locked by nfs\-client(s). -.sp -layout: displays the files for which layout is given. -.sp -deleg: displays delegated files information and delegation type. -.sp -all: prints all the above type. -.RE -.sp -\fB\-\-clientinfo\fP -.RS 4 -displays various nfs\-client info fields such as version of nfs mounted at nfs\-client and clientID. -.RE -.sp -\fB\-\-hostname\fP -.RS 4 -Print hostname of nfs\-client instead of ip-address. -.RE -.sp -\fB\-q, \-\-quiet\fP -.RS 4 -Hide the header information. -.RE -.sp -\fB\-v, \-\-verbose\fP -.RS 4 -Verbose operation, show debug messages. -.RE -.sp -\fB\-f, \-\-file\fP -.RS 4 -Instead of processing all client directories under /proc/fs/nfsd/clients, one can provide a specific -states file to process. One should make sure that info file resides in the same directory as states file. -If the info file is not valid or present the fields would be marked as "N/A". -.RE -.sp -\fB\-h, \-\-help\fP -.RS 4 -Print help explaining the command line options. -.SH "EXAMPLES" -.sp -\fBnfsdclnts \-\-type open\fP -.RS 4 -List all files with open type only. -.RE -.sp -.if n .RS 4 -.nf -Inode number | Type | Access | Deny | ip address | Filename -33823232 | open | r\- | \-\- | [::1]:757 | testfile -.fi -.if n .RE -.sp -\fBnfsdclnts \-\-type deleg\fP -.RS 4 -List all files with deleg type only. -.RE -.sp -.if n .RS 4 -.nf -Inode number | Type | Access | ip address | Filename -33823232 | deleg | r | [::1]:757 | testfile -.fi -.if n .RE -.sp -\fBnfsdclnts \-\-hostname\fP -.RS 4 -Print hostname instead of ip\-address. -.RE -.sp -.if n .RS 4 -.nf -Inode number | Type | Access | Deny | Hostname | Filename -33823232 | open | r\- | \-\- | nfs\-server | testfile -33823232 | deleg | r | | nfs\-server | testfile -.fi -.if n .RE -.sp -\fBnfsdclnts \-\-clientinfo\fP -.RS 4 -Print client information. -.RE -.sp -.if n .RS 4 -.nf -Inode number | Type | Access | Deny | ip address | Client ID | vers | Filename -33823232 | open | r\- | \-\- | [::1]:757 | 0xc79a009f5eb65e84 | 4.2 | testfile -33823232 | deleg | r | | [::1]:757 | 0xc79a009f5eb65e84 | 4.2 | testfile -.fi -.if n .RE -.sp -\fBnfsdclnts \-\-file /proc/fs/nfsd/clients/3/states -t open\fP -.RS 4 -Process specific states file. -.RE -.sp -.if n .RS 4 -.nf -Inode number | Type | Access | Deny | ip address | Client ID | vers | Filename -33823232 | open | r\- | \-\- | [::1]:757 | 0xc79a009f5eb65e84 | 4.2 | testfile -.fi -.if n .RE -.sp -\fBnfsdclnts \-\-quiet \-\-hostname\fP -.RS 4 -Hide the header information. -.RE -.sp -.if n .RS 4 -.nf -33823232 | open | r\- | \-\- | nfs\-server | testfile -33823232 | deleg | r | | nfs\-server | testfile -.fi -.if n .RE -.SH "FILES" -.sp -\fB/proc/fs/nfsd/clients/\fP -.sp -Displays basic information about each NFSv4 client. -.sp -\fB/proc/fs/nfsd/clients/#/info\fP -.sp -Displays information about all the opens held by the given client, including open modes, device numbers, inode numbers, and open owners. -.sp -\fB/proc/fs/nfsd/clients/#/states\fP -.SH "NOTES" -.sp -/proc/fs/nfsd/clients/ support was initially introduced in 5.3 kernel and is only implemented for mount points using NFSv4. -.SH "BUGS" -Please report any BUGs to \c -.MTO "linux\-nfs\(atvger.kernel.org" "" "" -.SH SEE ALSO -.BR nfsd (8), -.BR exportfs (8), -.BR idmapd (8), -.BR statd (8) -.SH "AUTHORS" -Achilles Gaikwad and -Kenneth D'souza diff --git a/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.py b/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.py deleted file mode 100755 index 5e7e03c..0000000 --- a/nfs-utils-2.5.2/tools/nfsdclnts/nfsdclnts.py +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/python3 -# -*- python-mode -*- -''' - Copyright (C) 2020 - Authors: Achilles Gaikwad - Kenneth D'souza - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -''' - -import multiprocessing as mp -import os -import signal -import sys - -try: - import argparse -except ImportError: - print('%s: Failed to import argparse - make sure argparse is installed!' - % sys.argv[0]) - sys.exit(1) -try: - import yaml -except ImportError: - print('%s: Failed to import yaml - make sure python3-pyyaml is installed!' - % sys.argv[0]) - sys.exit(1) - -BBOLD = '\033[1;30;47m' #Bold black text with white background. -ENDC = '\033[m' #Rest to defaults - -def init_worker(): - signal.signal(signal.SIGINT, signal.SIG_IGN) - -# this function converts the info file to a dictionary format, sorta. -def file_to_dict(path): - client_info = {} - try: - with open(path) as f: - for line in f: - try: - (key, val) = line.split(':', 1) - client_info[key] = val.strip() - # FIXME: There has to be a better way of converting the info file to a dictionary. - except ValueError as reason: - if verbose: - print('Exception occured, %s' % reason) - - if len(client_info) == 0 and verbose: - print("Provided %s file is not valid" %path) - return client_info - - except OSError as reason: - if verbose: - print('%s' % reason) - -# this function gets the paths from /proc/fs/nfsd/clients/ -# returns a list of paths for each client which has nfs-share mounted. -def getpaths(): - path = [] - try: - dirs = os.listdir('/proc/fs/nfsd/clients/') - except OSError as reason: - exit('%s' % reason) - if len(dirs) !=0: - for i in dirs: - path.append('/proc/fs/nfsd/clients/' + i + '/states') - return (path) - else: - exit('Nothing to process') - -# A single function to rule them all, in this function we gather all the data -# from already populated data_list and client_info. -def printer(data_list, argument): - client_info_path = data_list.pop() - client_info = file_to_dict(client_info_path) - for i in data_list: - for key in i: - inode = i[key]['superblock'].split(':')[-1] - # The ip address is quoted, so we dequote it. - try: - client_ip = client_info['address'][1:-1] - except: - client_ip = "N/A" - try: - # if the nfs-server reboots while the nfs-client holds the files open, - # the nfs-server would print the filename as '/'. For such instaces we - # print the output as disconnected dentry instead of '/'. - if(i[key]['filename']=='/'): - fname = 'disconnected dentry' - else: - fname = i[key]['filename'].split('/')[-1] - except KeyError: - # for older kernels which do not have the fname patch in kernel, they - # won't be able to see the fname field. Therefore post it as N/A. - fname = "N/A" - otype = i[key]['type'] - try: - access = i[key]['access'] - except: - access = '' - try: - deny = i[key]['deny'] - except: - deny = '' - try: - hostname = client_info['name'].split()[-1].split('"')[0] - hostname = hostname.split('.')[0] - # if the hostname is too long, it messes up with the output being in columns, - # therefore we truncate the hostname followed by two '..' as suffix. - if len(hostname) > 20: - hostname = hostname[0:20] + '..' - except: - hostname = "N/A" - try: - clientid = client_info['clientid'] - except: - clientid = "N/A" - try: - minorversion = "4." + client_info['minor version'] - except: - minorversion = "N/A" - - otype = i[key]['type'] - # since some fields do not have deny column, we drop those if -t is either - # layout or lock. - drop = ['layout', 'lock'] - - # Printing the output this way instead of a single string which is concatenated - # this makes it better to quickly add more columns in future. - if(otype == argument.type or argument.type == 'all'): - print('%-13s' %inode, end='| ') - print('%-7s' %otype, end='| ') - if (argument.type not in drop): - print('%-7s' %access, end='| ') - if (argument.type not in drop and argument.type !='deleg'): - print('%-5s' %deny, end='| ') - if (argument.hostname == True): - print('%-22s' %hostname, end='| ') - else: - print('%-22s' %client_ip, end='| ') - if (argument.clientinfo == True) : - print('%-20s' %clientid, end='| ') - print('%-5s' %minorversion, end='| ') - print(fname) - -def opener(path): - try: - with open(path, 'r') as nfsdata: - try: - data = yaml.load(nfsdata, Loader = yaml.BaseLoader) - if data is not None: - clientinfo = path.rsplit('/', 1)[0] + '/info' - data.append(clientinfo) - return data - except: - if verbose: - print("Exception occurred, Please make sure %s is a YAML file" %path) - - except OSError as reason: - if verbose: - print('%s' % reason) - -def print_cols(argument): - title_inode = 'Inode number' - title_otype = 'Type' - title_access = 'Access' - title_deny = 'Deny' - title_fname = 'Filename' - title_clientID = 'Client ID' - title_hostname = 'Hostname' - title_ip = 'ip address' - title_nfsvers = 'vers' - - drop = ['lock', 'layout'] - print(BBOLD, end='') - print('%-13s' %title_inode, end='| ') - print('%-7s' %title_otype, end='| ') - if (argument.type not in drop): - print('%-7s' %title_access, end='| ') - if (argument.type not in drop and argument.type !='deleg'): - print('%-5s' %title_deny, end='| ') - if (argument.hostname == True): - print('%-22s' %title_hostname, end='| ') - else: - print('%-22s' %title_ip, end='| ') - if (argument.clientinfo == True): - print('%-20s' %title_clientID, end='| ') - print('%-5s' %title_nfsvers, end='| ') - print(title_fname, end='') - print(ENDC) - -def nfsd4_show(): - - parser = argparse.ArgumentParser(description = 'Parse the nfsd states and clientinfo files.') - parser.add_argument('-t', '--type', metavar = 'type', type = str, choices = ['open', - 'deleg', 'lock', 'layout', 'all'], - default = 'all', - help = 'Input the type that you want to be printed: open, lock, deleg, layout, all') - parser.add_argument('--clientinfo', action = 'store_true', - help = 'output clients information, --hostname is implied.') - parser.add_argument('--hostname', action = 'store_true', - help = 'print hostname of client instead of its ip address. Longer hostnames are truncated.') - parser.add_argument('-v', '--verbose', action = 'store_true', - help = 'Verbose operation, show debug messages.') - parser.add_argument('-f', '--file', nargs='+', type = str, metavar='', - help = 'pass client states file, provided that info file resides in the same directory.') - parser.add_argument('-q', '--quiet', action = 'store_true', - help = 'don\'t print the header information') - - args = parser.parse_args() - - global verbose - verbose = False - if args.verbose: - verbose = True - - if args.file: - paths = args.file - else: - paths = getpaths() - - p = mp.Pool(mp.cpu_count(), init_worker) - try: - result = p.map(opener, paths) - ### Drop None entries from list - final_result = list(filter(None, result)) - p.close() - p.join() - - if len(final_result) !=0 and not args.quiet: - print_cols(args) - - for item in final_result: - printer(item, args) - - except KeyboardInterrupt: - print('Caught KeyboardInterrupt, terminating workers') - p.terminate() - p.join() - -if __name__ == "__main__": - nfsd4_show() diff --git a/nfs-utils-2.5.2/tools/nlmtest/Makefile.am b/nfs-utils-2.5.2/tools/nlmtest/Makefile.am deleted file mode 100644 index fbf9fb3..0000000 --- a/nfs-utils-2.5.2/tools/nlmtest/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = \ - README \ - host.h \ - nlm_prot.x \ - nlmtest.c diff --git a/nfs-utils-2.5.2/tools/nlmtest/README b/nfs-utils-2.5.2/tools/nlmtest/README deleted file mode 100644 index b54cb43..0000000 --- a/nfs-utils-2.5.2/tools/nlmtest/README +++ /dev/null @@ -1,5 +0,0 @@ - -This is a simple tool to test your lockd server. This is a very -primitive program. To use it on your system, you have to edit -host.h and adjust the inode and device numbers in nltest.c to -suit your nfs server. diff --git a/nfs-utils-2.5.2/tools/nlmtest/host.h b/nfs-utils-2.5.2/tools/nlmtest/host.h deleted file mode 100644 index b4f30df..0000000 --- a/nfs-utils-2.5.2/tools/nlmtest/host.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * host.h - * - * Defaults for nlmtest - */ - -#ifndef NLMTEST_HOST_H -#define NLMTEST_HOST_H - -/* - * The host on which lockd runs - */ -#define NLMTEST_HOST "crutch" - -/* - * NFS mount point - */ -#define NLMTEST_DIR "../../mount/" - -/* - * The default file name and its inode version number. - * There's no way the test program can find out the version number, - * so you have to add it here. - */ -#define NLMTEST_FILE NLMTEST_DIR "COPYING" -#define NLMTEST_VERSION 1 - -#endif /* NLMTEST_HOST_H */ diff --git a/nfs-utils-2.5.2/tools/nlmtest/nlm_prot.x b/nfs-utils-2.5.2/tools/nlmtest/nlm_prot.x deleted file mode 100644 index a425912..0000000 --- a/nfs-utils-2.5.2/tools/nlmtest/nlm_prot.x +++ /dev/null @@ -1,183 +0,0 @@ -/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */ - -/* - * Network lock manager protocol definition - * Copyright (C) 1986 Sun Microsystems, Inc. - * - * protocol used between local lock manager and remote lock manager - */ - -#ifdef RPC_CLNT -%#include -#endif - -#ifdef RPC_HDR -%#define LM_MAXSTRLEN 1024 -%#define MAXNAMELEN LM_MAXSTRLEN+1 -#endif - -/* - * status of a call to the lock manager - */ -enum nlm_stats { - nlm_granted = 0, - nlm_denied = 1, - nlm_denied_nolocks = 2, - nlm_blocked = 3, - nlm_denied_grace_period = 4 -}; - -struct nlm_holder { - bool exclusive; - int svid; - netobj oh; - unsigned l_offset; - unsigned l_len; -}; - -union nlm_testrply switch (nlm_stats stat) { - case nlm_denied: - struct nlm_holder holder; - default: - void; -}; - -struct nlm_stat { - nlm_stats stat; -}; - -struct nlm_res { - netobj cookie; - nlm_stat stat; -}; - -struct nlm_testres { - netobj cookie; - nlm_testrply stat; -}; - -struct nlm_lock { - string caller_name; - netobj fh; /* identify a file */ - netobj oh; /* identify owner of a lock */ - int svid; /* generated from pid for svid */ - unsigned l_offset; - unsigned l_len; -}; - -struct nlm_lockargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; - bool reclaim; /* used for recovering locks */ - int state; /* specify local status monitor state */ -}; - -struct nlm_cancargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_testargs { - netobj cookie; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_unlockargs { - netobj cookie; - struct nlm_lock alock; -}; - - -#ifdef RPC_HDR -%/* -% * The following enums are actually bit encoded for efficient -% * boolean algebra.... DON'T change them..... -% */ -#endif -enum fsh_mode { - fsm_DN = 0, /* deny none */ - fsm_DR = 1, /* deny read */ - fsm_DW = 2, /* deny write */ - fsm_DRW = 3 /* deny read/write */ -}; - -enum fsh_access { - fsa_NONE = 0, /* for completeness */ - fsa_R = 1, /* read only */ - fsa_W = 2, /* write only */ - fsa_RW = 3 /* read/write */ -}; - -struct nlm_share { - string caller_name; - netobj fh; - netobj oh; - fsh_mode mode; - fsh_access access; -}; - -struct nlm_shareargs { - netobj cookie; - nlm_share share; - bool reclaim; -}; - -struct nlm_shareres { - netobj cookie; - nlm_stats stat; - int sequence; -}; - -struct nlm_notify { - string name; - long state; -}; - -/* - * Over-the-wire protocol used between the network lock managers - */ - -program NLM_PROG { - version NLM_VERS { - - nlm_testres NLM_TEST(struct nlm_testargs) = 1; - - nlm_res NLM_LOCK(struct nlm_lockargs) = 2; - - nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; - nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; - - /* - * remote lock manager call-back to grant lock - */ - nlm_res NLM_GRANTED(struct nlm_testargs)= 5; - /* - * message passing style of requesting lock - */ - void NLM_TEST_MSG(struct nlm_testargs) = 6; - void NLM_LOCK_MSG(struct nlm_lockargs) = 7; - void NLM_CANCEL_MSG(struct nlm_cancargs) =8; - void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; - void NLM_GRANTED_MSG(struct nlm_testargs) = 10; - void NLM_TEST_RES(nlm_testres) = 11; - void NLM_LOCK_RES(nlm_res) = 12; - void NLM_CANCEL_RES(nlm_res) = 13; - void NLM_UNLOCK_RES(nlm_res) = 14; - void NLM_GRANTED_RES(nlm_res) = 15; - } = 1; - - version NLM_VERSX { - nlm_shareres NLM_SHARE(nlm_shareargs) = 20; - nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; - nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; - void NLM_FREE_ALL(nlm_notify) = 23; - } = 3; - -} = 100021; - diff --git a/nfs-utils-2.5.2/tools/nlmtest/nlmtest.c b/nfs-utils-2.5.2/tools/nlmtest/nlmtest.c deleted file mode 100644 index d0acc47..0000000 --- a/nfs-utils-2.5.2/tools/nlmtest/nlmtest.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * nlmtest - * - * Simple tool for NLM testing. You will have to adjust the values in - * host.h to your test system. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include "nlm_prot.h" -#include "host.h" - -static char myhostname[256]; -static int hostnamelen; - -static void makelock(struct nlm_lock *, u_int32_t, off_t, off_t); -static void makeowner(struct netobj *, u_int32_t); -static void makefileh(struct netobj *); -static char * nlm_stat_name(int status); -static char * holderstr(struct netobj *oh); - -int -main(int argc, char **argv) -{ - CLIENT *client; - nlm_testargs testargs; - nlm_lockargs lockargs; - nlm_unlockargs unlockargs; - nlm_lock alock; - nlm_testres *testres; - nlm_res *lockres; - char *filename = NLMTEST_FILE; - char *svchost = NLMTEST_HOST; - unsigned long offset = 0, length = 0; - int exclusive = 0; - int blocking = 0; - int unlock = 0; - u_int32_t cookie = 4321; - u_int32_t mypid = 1234; - int c; - - while ((c = getopt(argc, argv, "bf:h:l:o:p:ux")) != EOF) { - switch(c) { - case 'b': - blocking = 1; - break; - case 'f': - filename = optarg; - break; - case 'h': - svchost = optarg; - break; - case 'l': - length = atoi(optarg); - break; - case 'o': - offset = atoi(optarg); - break; - case 'p': - mypid = atoi(optarg); - break; - case 'u': - unlock = 1; - break; - case 'x': - exclusive = 1; - break; - default: - fprintf(stderr, "nlmtest: bad option %c\n", c); - exit (2); - } - } - - client = clnt_create(svchost, NLM_PROG, NLM_VERS, "udp"); - if (client == NULL) { - clnt_pcreateerror("localhost"); - exit(1); - } - - /* Get local host name */ - if (gethostname(myhostname, sizeof(myhostname)) < 0) - strcpy(myhostname, "unknown"); - hostnamelen = strlen(myhostname); - - makelock(&alock, mypid, offset, length); - - testargs.cookie.n_bytes = (void*)&cookie; - testargs.cookie.n_len = 4; - testargs.exclusive = exclusive; - testargs.alock = alock; - - if ((testres = nlm_test_1(&testargs, client)) == NULL) { - clnt_perror(client, "nlm_test call failed:"); - exit (1); - } - printf ("nlm_test reply:\n" - "\tcookie: %d\n" - "\tstatus: %s\n", - *(int*)(testres->cookie.n_bytes), - nlm_stat_name(testres->stat.stat) - ); - - if (testres->stat.stat == nlm_denied) { - nlm_holder *holder = &(testres->stat.nlm_testrply_u.holder); - printf ("\tconflicting lock:\n" - "\t oh: %s\n" - "\t pid: %d\n" - "\t offset: %d\n" - "\t length: %d\n" - "\t exclusive: %d\n", - holderstr(&holder->oh), - holder->svid, - holder->l_offset, - holder->l_len, - holder->exclusive); - } - - if (testres->stat.stat != nlm_granted && !unlock && !blocking) - return 1; - - if (unlock) { - unlockargs.cookie.n_bytes = (void*)&cookie; - unlockargs.cookie.n_len = sizeof(cookie); - unlockargs.alock = alock; - - if ((lockres = nlm_unlock_1(&unlockargs, client)) == NULL) { - clnt_perror(client, "nlm_unlock call failed:"); - exit (1); - } - printf ("nlm_unlock reply:\n" - "\tcookie: %d\n" - "\tstatus: %s\n", - *(int*)(lockres->cookie.n_bytes), - nlm_stat_name(lockres->stat.stat) - ); - } else { - lockargs.cookie.n_bytes = (void*)&cookie; - lockargs.cookie.n_len = sizeof(cookie); - lockargs.exclusive = exclusive; - lockargs.alock = alock; - lockargs.reclaim = 0; - lockargs.state = 0; - - if ((lockres = nlm_lock_1(&lockargs, client)) == NULL) { - clnt_perror(client, "nlm_lock call failed:"); - exit (1); - } - printf ("nlm_lock reply:\n" - "\tcookie: %d\n" - "\tstatus: %s\n", - *(int*)(lockres->cookie.n_bytes), - nlm_stat_name(lockres->stat.stat) - ); - } - - return 0; -} - -static char * -nlm_stat_name(int status) -{ - static char buf[12]; - - switch (status) { - case nlm_granted: - return "nlm_granted"; - case nlm_denied: - return "nlm_denied"; - case nlm_denied_nolocks: - return "nlm_denied_nolocks"; - case nlm_blocked: - return "nlm_blocked"; - case nlm_denied_grace_period: - return "nlm_denied_grace_period"; - } - sprintf(buf, "%d", status); - return buf; -} - -static char * -holderstr(struct netobj *oh) -{ - static char buffer[4096]; - unsigned char c, *sp; - int i; - - for (i = 0, sp = buffer; i < oh->n_len; i++) { - c = (unsigned char) oh->n_bytes[i]; - if (c < 0x20 || c > 0x7f) - sp += sprintf(sp, "\\%03o", c); - else - *sp++ = c; - } - *sp++ = '\0'; - - return buffer; -} - -static void -makelock(struct nlm_lock *alock, u_int32_t mypid, off_t offset, off_t length) -{ - makeowner(&alock->oh, mypid); /* Create owner handle */ - makefileh(&alock->fh); /* Create file handle */ - - alock->caller_name = myhostname; - alock->svid = mypid; - alock->l_offset = offset; - alock->l_len = length; -} - -static void -makeowner(struct netobj *oh, u_int32_t mypid) -{ - static char ohdata[1024]; - - oh->n_bytes = ohdata; - oh->n_len = hostnamelen + 1 + 4; - - strcpy(ohdata, myhostname); - memcpy(ohdata + hostnamelen + 1, &mypid, 4); -} - -static void -makefileh(struct netobj *fh) -{ - static struct knfs_fh f; - struct stat stb; -#error this needs updating if it is still wanted - memset(&f, 0, sizeof(f)); -#if 0 - if (stat(NLMTEST_DIR, &stb) < 0) { - perror("couldn't stat mount point " NLMTEST_DIR); - exit(1); - } - f.fh_xdev = stb.st_dev; - f.fh_xino = stb.st_ino; - - if (stat(NLMTEST_DIR, &stb) < 0) { - perror("couldn't stat mount point " NLMTEST_DIR); - exit(1); - } - f.fh_dev = stb.st_dev; - f.fh_ino = stb.st_ino; - - f.fh_version = NLMTEST_VERSION; -#else - f.fh_xdev = 0x801; - f.fh_xino = 37596; - f.fh_dev = 0x801; - f.fh_ino = 37732; -#endif - - fh->n_len = 32; - fh->n_bytes = (void *) &f; -} diff --git a/nfs-utils-2.5.2/tools/rpcdebug/Makefile.am b/nfs-utils-2.5.2/tools/rpcdebug/Makefile.am deleted file mode 100644 index b0a3e1f..0000000 --- a/nfs-utils-2.5.2/tools/rpcdebug/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = rpcdebug.man -EXTRA_DIST = $(man8_MANS) - -sbin_PROGRAMS = rpcdebug -rpcdebug_SOURCES = rpcdebug.c - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.c b/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.c deleted file mode 100644 index 68206cc..0000000 --- a/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Get or set RPC debug flags. - * - * I would have loved to write this without recourse to the sysctl - * interface, but the only plausible approach (reading and writing - * /dev/kmem at the offsets indicated by the _debug symbols from - * /proc/ksyms) didn't work, because /dev/kmem doesn't translate virtual - * addresses on write. Unfortunately, modules are stuffed into memory - * allocated via vmalloc. - * - * Copyright (C) 1996, 1997, Olaf Kirch - * (C) 2004 - * - * 06/15/2004: updated for NFSv4 - * - */ - -/* #include "config.h" */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* RPC debug flags - #include */ -/* NFS debug flags - #include */ -/* NFSD and NLM debug flags - #include */ -#include - -static int verbose = 0; -static char* cdename; - -static unsigned int find_flag(char **module, char *name); -static unsigned int get_flags(char *); -static unsigned int set_flags(char *, unsigned int value); -static void print_flags(FILE *, char *, unsigned int, int); -static char * strtolower(char *str); -static void usage(int excode, char *module); - -int -main(int argc, char **argv) -{ - int opt_s = 0, - opt_c = 0; - unsigned int flags = 0, oflags; - char * module = NULL; - int c; - - cdename = malloc(strlen(basename(argv[0]))); - if (cdename == NULL) { - fprintf(stderr, "failed in malloc\n"); - exit(1); - } - strcpy(cdename, basename(argv[0])); - - if (!strcmp(cdename, "nfsdebug")) { - module = "nfs"; - } - else if (!strcmp(cdename, "nfsddebug")) { - module = "nfsd"; - } - - while ((c = getopt(argc, argv, "chm:sv")) != EOF) { - switch (c) { - case 'c': - opt_c = 1; - break; - case 'h': - usage(0, module); /* usage does not return */ - break; - case 'm': - module = optarg; - break; - case 's': - opt_s = 1; - break; - case 'v': - verbose++; - break; - default: - fprintf(stderr, "%s: unknown option -%c\n", cdename, optopt); - usage(1, module); - } - } - - if (opt_c + opt_s > 1) { - fprintf(stderr, "You can use at most one of -c and -s\n"); - usage(1, module); - } - - if (!module) { - fprintf(stderr, "%s: no module name specified.\n", cdename); - usage(1, module); - } - - if (strcmp(module, "nfsd") && - strcmp(module, "nfs") && - strcmp(module, "nlm") && - strcmp(module, "rpc")) { - fprintf(stderr, "%s: unknown module: %s\n", cdename, module); - usage(1, module); - } - - if (argc == optind) { - flags = ~(unsigned int) 0; - } else { - for (; optind < argc; optind++) - flags |= find_flag(&module, argv[optind]); - if (flags && !opt_c) - opt_s = 1; - } - - oflags = get_flags(module); - - if (opt_c) { - oflags = set_flags(module, oflags & ~flags); - } else if (opt_s) { - oflags = set_flags(module, oflags | flags); - } - print_flags(stdout, module, oflags, 0); - if (verbose) { - fprintf(stdout, "\nModule Valid flags\n"); - print_flags(stdout, module, ~(unsigned int) 0, 1); - } - - return 0; -} - -#define FLAG(mname, fname) \ - { #mname, #fname, mname##DBG_##fname } - -static struct flagmap { - char * module; - char * name; - unsigned int value; -} flagmap[] = { - /* rpc */ - FLAG(RPC, XPRT), - FLAG(RPC, CALL), - FLAG(RPC, DEBUG), - FLAG(RPC, NFS), - FLAG(RPC, AUTH), - FLAG(RPC, BIND), - FLAG(RPC, SCHED), - FLAG(RPC, TRANS), - FLAG(RPC, SVCSOCK), - FLAG(RPC, SVCDSP), - FLAG(RPC, MISC), - FLAG(RPC, CACHE), - FLAG(RPC, ALL), - - /* nfs */ - FLAG(NFS, VFS), - FLAG(NFS, DIRCACHE), - FLAG(NFS, LOOKUPCACHE), - FLAG(NFS, PAGECACHE), - FLAG(NFS, PROC), - FLAG(NFS, XDR), - FLAG(NFS, FILE), - FLAG(NFS, ROOT), - FLAG(NFS, CALLBACK), - FLAG(NFS, CLIENT), - FLAG(NFS, MOUNT), - FLAG(NFS, FSCACHE), - FLAG(NFS, PNFS), - FLAG(NFS, PNFS_LD), - FLAG(NFS, STATE), - FLAG(NFS, ALL), - - /* nfsd */ - FLAG(NFSD, SOCK), - FLAG(NFSD, FH), - FLAG(NFSD, EXPORT), - FLAG(NFSD, SVC), - FLAG(NFSD, PROC), - FLAG(NFSD, FILEOP), - FLAG(NFSD, AUTH), - FLAG(NFSD, REPCACHE), - FLAG(NFSD, XDR), - FLAG(NFSD, LOCKD), - FLAG(NFSD, ALL), - - /* lockd */ - FLAG(NLM, SVC), - FLAG(NLM, CLIENT), - FLAG(NLM, CLNTLOCK), - FLAG(NLM, SVCLOCK), - FLAG(NLM, MONITOR), - FLAG(NLM, CLNTSUBS), - FLAG(NLM, SVCSUBS), - FLAG(NLM, HOSTCACHE), - FLAG(NLM, XDR), - FLAG(NLM, ALL), - - { NULL, NULL, 0 } -}; - -static unsigned int -find_flag(char **module, char *name) -{ - char *mod = *module; - unsigned int value = 0; - int i; - - for (i = 0; flagmap[i].module; i++) { - if ((mod && strcasecmp(mod, flagmap[i].module)) - || strcasecmp(name, flagmap[i].name)) - continue; - if (value) { - fprintf(stderr, - "%s: ambiguous symbol name %s.\n" - "This name is used by more than one module, " - "please specify the module name using\n" - "the -m option.\n", - cdename, name); - exit(1); - } - value = flagmap[i].value; - if (*module) - return value; - mod = flagmap[i].module; - } - - if (!value) { - if (*module) - fprintf(stderr, - "%s: unknown module or flag %s/%s\n", - cdename, *module, name); - else - fprintf(stderr, - "%s: unknown flag %s\n", - cdename, name); - exit(1); - } - - *module = mod; - return value; -} - -static unsigned int -get_flags(char *module) -{ - char buffer[256], filename[256]; - int sysfd, len; - - snprintf(filename, 256, "/proc/sys/sunrpc/%s_debug", module); - - if ((sysfd = open(filename, O_RDONLY)) < 0) { - perror(filename); - exit(1); - } - if ((len = read(sysfd, buffer, sizeof(buffer))) < 0) { - perror("read"); - exit(1); - } - close(sysfd); - buffer[len - 1] = '\0'; - - return strtoul(buffer, NULL, 0); -} - -static unsigned int -set_flags(char *module, unsigned int value) -{ - char buffer[64], filename[256]; - int sysfd, len, ret; - - snprintf(filename, 256, "/proc/sys/sunrpc/%s_debug", module); - - len = sprintf(buffer, "%d", value); - if ((sysfd = open(filename, O_WRONLY)) < 0) { - perror(filename); - exit(1); - } - if ((ret = write(sysfd, buffer, len)) < 0) { - perror("write"); - exit(1); - } - if (ret < len) { - fprintf(stderr, "error: short write in set_flags!\n"); - exit(1); - } - close(sysfd); - return value; -} - - -static char * -strtolower(char *str) -{ - static char temp[64]; - char *sp; - - strcpy(temp, str); - for (sp = temp; *sp; sp++) - *sp = tolower(*sp); - return temp; -} - -static void -print_flags(FILE *ofp, char *module, unsigned int flags, int show_all) -{ - char *lastmod = NULL; - unsigned int shown = 0; - int i; - - if (module) { - fprintf(ofp, "%-10s", strtolower(module)); - if (!flags) { - fprintf(ofp, "\n"); - return; - } - } - - for (i = 0, shown = 0; flagmap[i].module; i++) { - if (module) { - if (strcasecmp(flagmap[i].module, module)) - continue; - } else if (!lastmod || strcmp(lastmod, flagmap[i].module)) { - if (lastmod) { - fprintf(ofp, "\n"); - shown = 0; - } - fprintf(ofp, "%-10s", strtolower(flagmap[i].module)); - lastmod = flagmap[i].module; - } - if (!(flags & flagmap[i].value) - || (!show_all && (shown & flagmap[i].value)) - || (module && !strcasecmp(flagmap[i].name, "all"))) - continue; - fprintf(ofp, " %s", strtolower(flagmap[i].name)); - shown |= flagmap[i].value; - } - fprintf(ofp, "\n"); -} - -static void -usage(int excode, char *module) -{ - if (module) - fprintf(stderr, "usage: %s [-v] [-h] [-s flags...|-c flags...]\n", cdename); - else - fprintf(stderr, "usage: %s [-v] [-h] [-m module] [-s flags...|-c flags...]\n", cdename); - fprintf(stderr, " set or cancel debug flags.\n"); - if (verbose) { - fprintf(stderr, "\nModule Valid flags\n"); - print_flags(stderr, module, ~(unsigned int) 0, 1); - } else { - if (module) - fprintf(stderr, " (use %s -vh to get a list of valid flags)\n", cdename); - else - fprintf(stderr, " (use %s -vh to get a list of modules and valid flags)\n", cdename); - } - exit (excode); -} - diff --git a/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.man b/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.man deleted file mode 100644 index e65598a..0000000 --- a/nfs-utils-2.5.2/tools/rpcdebug/rpcdebug.man +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" rpcdebug(8) -.\" -.\" By Greg Banks -.\" Copyright (c) 2006 Silicon Graphics, Inc. -.\" Derived from nfsstat.man which bore the message: -.\" Copyright (C) 1996-2005 Olaf Kirch -.TH rpcdebug 8 "5 Jul 2006" -.SH NAME -rpcdebug \- set and clear NFS and RPC kernel debug flags -.SH SYNOPSIS -\fBrpcdebug\fP \fB\-vh\fP -.br -\fBrpcdebug\fP \fB\-m\fP \fImodule\fP -.br -\fBrpcdebug\fP \fB\-m\fP \fImodule\fP \fB\-s\fP \fIflags\fP... -.br -\fBrpcdebug\fP \fB\-m\fP \fImodule\fP \fB\-c\fP \fIflags\fP... -.br -.SH DESCRIPTION -The \fBrpcdebug\fP command allows an administrator to set and clear -the Linux kernel's NFS client and server debug flags. Setting these -flags causes the kernel to emit messages to the system log in response -to NFS activity; this is typically useful when debugging NFS problems. -.PP -The first form in the synopsis can be used to list all available -debug flags. The second form shows the currently set debug flags -for the given module. The third form sets one or more flags, and -the fourth form clears one or more flags. -.PP -The value \fBall\fP may be used to set or clear all the flags for -the given module. -.SH OPTIONS -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.TP -.B \-c -Clear the given debug flags. -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.TP -.B \-h -Print a help message and exit. When combined with the \fB\-v\fP -option, also prints the available debug flags. -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.TP -.BI \-m " module" -Specify which module's flags to set or clear. Available -modules are: -.RS -.TP -.BR nfsd -The NFS server. -.TP -.BR nfs -The NFS client. -.TP -.BR nlm -The Network Lock Manager, in either an NFS client or server. -.TP -.BR rpc -The Remote Procedure Call module, in either an NFS client or server. -.RE -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.TP -.B \-s -Set the given debug flags. -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.TP -.B \-v -Increase the verbosity of \fBrpcdebug\fP's output. -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.SH FILES -.TP -.B /proc/sys/sunrpc/{rpc,nfs,nfsd,nlm}_debug -procfs\-based interface to kernel debug flags. -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.SH SEE ALSO -.BR rpc.nfsd (8), -.BR nfs (5), -.BR syslogd (8). -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.SH BUGS -Bugs can be found or reported at -.BR http://nfs.sf.net/ . -.\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -.SH AUTHOR -Program by Olaf Kirch and -. -Manpage by Greg Banks . diff --git a/nfs-utils-2.5.2/tools/rpcgen/Makefile.am b/nfs-utils-2.5.2/tools/rpcgen/Makefile.am deleted file mode 100644 index 457cd50..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -CLEANFILES = *~ - -bin_PROGRAMS = rpcgen -man_MANS = rpcgen.1 - -EXTRA_DIST=${MANS} - -noinst_HEADERS = proto.h rpc_parse.h rpc_scan.h rpc_util.h - -rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ - rpc_parse.c rpc_sample.c rpc_scan.c rpc_svcout.c rpc_tblout.c \ - rpc_util.c -rpcgen_LDADD = $(LIBINTL) diff --git a/nfs-utils-2.5.2/tools/rpcgen/README b/nfs-utils-2.5.2/tools/rpcgen/README deleted file mode 100644 index 2f6bbf3..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/README +++ /dev/null @@ -1,8 +0,0 @@ - - This directory contains the source for rpcgen.new from Sun TIRPC - source distribution. I cleaned it up a little so that it will - compile with gcc (without using -traditional), and modified the - output to avoid those silly warnings you usually get when compiling - an rpcgen-generated C file. - - Olaf Kirch 8 Oct 1996 diff --git a/nfs-utils-2.5.2/tools/rpcgen/proto.h b/nfs-utils-2.5.2/tools/rpcgen/proto.h deleted file mode 100644 index ea28565..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/proto.h +++ /dev/null @@ -1,65 +0,0 @@ -/****** rpc_clntout.c ******/ - -void write_stubs(void); -void printarglist(proc_list *proc, const char *result, - const char *addargname, const char *addargtype); - -/****** rpc_cout.c ******/ - -void emit (definition *def); - -/****** rpc_hout.c ******/ - -void print_datadef(definition *def); -void print_funcdef(definition *def); -void pxdrfuncdecl(const char *name, int pointerp); -void pprocdef(proc_list *proc, version_list *vp, - const char *addargtype, int server_p, int mode); -void pdeclaration(const char *name, declaration *dec, int tab, - const char *separator); -void print_xdr_func_def (char* name, int pointerp, int i); - -/****** rpc_main.c ******/ - /* nil */ - -/****** rpc_parse.c ******/ -definition *get_definition(void); - -/****** rpc_sample.c ******/ -void write_sample_svc(definition *def); -int write_sample_clnt(definition *def); -void add_sample_msg(void); -void write_sample_clnt_main(void); - -/****** rpc_scan.c ******/ - /* see rpc_scan.h */ - -/****** rpc_svcout.c ******/ -int nullproc(const proc_list *proc); -void write_svc_aux(int nomain); -void write_msg_out(void); - -/****** rpc_tblout.c ******/ -void write_tables(void); - -/****** rpc_util.c ******/ -void reinitialize(void); -int streq(const char *a, const char *b); -void error(const char *msg) __attribute__ ((noreturn)); -void crash(void) __attribute__ ((noreturn)); -void tabify(FILE *f, int tab); -char *make_argname(const char *pname, const char *vname); -void add_type(int len, const char *type); - -/* This header is the last one included in all rpc_*.c files, - so we define stuff for cross-rpcgen here to avoid conflicts with - $build's C library and $host's glibc. */ - -#ifdef IS_IN_build - -/* Disable translated messages when built for $build and used in - building glibc. */ -#define _(X) (X) -#define textdomain(X) ((void) 0) - -#endif diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_clntout.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_clntout.c deleted file mode 100644 index 9b6a4aa..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_clntout.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -// #include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define DEFAULT_TIMEOUT 25 /* in seconds */ -static const char RESULT[] = "clnt_res"; - -static void write_program (definition * def); -static void printbody (proc_list * proc); -static const char *ampr (const char *type); -static void printbody (proc_list * proc); - - -void -write_stubs (void) -{ - list *l; - definition *def; - - fprintf (fout, - "\n/* Default timeout can be changed using clnt_control() */\n"); - fprintf (fout, "static struct timeval TIMEOUT = { %d, 0 };\n", - DEFAULT_TIMEOUT); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_program (def); - } - } -} - -static void -write_program (definition * def) -{ - version_list *vp; - proc_list *proc; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - fprintf (fout, "\n"); - if (mtflag == 0) - { - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*\n"); - pvname (proc->proc_name, vp->vers_num); - printarglist (proc, RESULT, "clnt", "CLIENT *"); - } - else - { - fprintf (fout, "enum clnt_stat \n"); - pvname (proc->proc_name, vp->vers_num); - printarglist (proc, RESULT, "clnt", "CLIENT *"); - } - fprintf (fout, "{\n"); - printbody (proc); - fprintf (fout, "}\n"); - } - } -} - -/* Writes out declarations of procedure's argument list. - In either ANSI C style, in one of old rpcgen style (pass by reference), - or new rpcgen style (multiple arguments, pass by value); - */ - -/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */ - -void -printarglist (proc_list * proc, const char *result, - const char *addargname, const char *addargtype) -{ - - decl_list *l; - - if (!newstyle) - { /* old style: always pass argument by reference */ - if (Cflag) - { /* C++ style heading */ - fprintf (fout, "("); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - - if (mtflag) - {/* Generate result field */ - fprintf (fout, "*argp, "); - ptype(proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname); - } - else - fprintf (fout, "*argp, %s%s)\n", addargtype, addargname); - } - else - { - if (!mtflag) - fprintf (fout, "(argp, %s)\n", addargname); - else - fprintf (fout, "(argp, %s, %s)\n", result, addargname); - fprintf (fout, "\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - fprintf (fout, "*argp;\n"); - if (mtflag) - { - fprintf (fout, "\t"); - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s;\n", result); - } - } - } - else if (streq (proc->args.decls->decl.type, "void")) - { - /* newstyle, 0 argument */ - if (mtflag) - { - fprintf (fout, "("); - if (Cflag) - { - ptype(proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname); - } - else - fprintf (fout, "(%s)\n", addargname); - } - else if (Cflag) - fprintf (fout, "(%s%s)\n", addargtype, addargname); - else - fprintf (fout, "(%s)\n", addargname); - } - else - { - /* new style, 1 or multiple arguments */ - if (!Cflag) - { - fprintf (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - fprintf (fout, "%s, ", l->decl.name); - if (mtflag) - fprintf (fout, "%s, ", result); - fprintf (fout, "%s)\n", addargname); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pdeclaration (proc->args.argname, &l->decl, 1, ";\n"); - } - if (mtflag) - { - fprintf (fout, "\t"); - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s;\n", result); - } - } - else - { /* C++ style header */ - fprintf (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pdeclaration (proc->args.argname, &l->decl, 0, ", "); - } - if (mtflag) - { - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, ", result); - } - fprintf (fout, " %s%s)\n", addargtype, addargname); - } - } - - if (!Cflag) - fprintf (fout, "\t%s%s;\n", addargtype, addargname); -} - - -static -const char * -ampr (const char *type) -{ - if (isvectordef (type, REL_ALIAS)) - { - return ""; - } - else - { - return "&"; - } -} - -static void -printbody (proc_list * proc) -{ - decl_list *l; - int args2 = (proc->arg_num > 1); -/* int i; */ - - /* For new style with multiple arguments, need a structure in which - to stuff the arguments. */ - if (newstyle && args2) - { - fprintf (fout, "\t%s", proc->args.argname); - fprintf (fout, " arg;\n"); - } - if (!mtflag) - { - fprintf (fout, "\tstatic "); - if (streq (proc->res_type, "void")) - { - fprintf (fout, "char "); - } - else - { - ptype (proc->res_prefix, proc->res_type, 0); - } - fprintf (fout, "%s;\n", RESULT); - fprintf (fout, "\n"); - fprintf (fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n", - ampr (proc->res_type), RESULT, RESULT); - } - if (newstyle && !args2 && (streq (proc->args.decls->decl.type, "void"))) - { - /* newstyle, 0 arguments */ - if (mtflag) - fprintf (fout, "\t return "); - else - fprintf (fout, "\t if "); - fprintf (fout, - "(clnt_call (clnt, %s, (xdrproc_t) xdr_void, ", proc->proc_name); - - fprintf (fout, - "(caddr_t) NULL,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,", - stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type), - RESULT); - if (mtflag) - fprintf (fout, "\n\t\tTIMEOUT));\n\n"); - else - fprintf (fout, "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); - } - else if (newstyle && args2) - { - /* newstyle, multiple arguments: stuff arguments into structure */ - for (l = proc->args.decls; l != NULL; l = l->next) - { - fprintf (fout, "\targ.%s = %s;\n", - l->decl.name, l->decl.name); - } - if (mtflag) - fprintf (fout, "\treturn "); - else - fprintf (fout, "\tif "); - - fprintf (fout, - "(clnt_call (clnt, %s, (xdrproc_t) xdr_%s", proc->proc_name, - proc->args.argname); - fprintf (fout, - ", (caddr_t) &arg,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,", - stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type), - RESULT); - if (mtflag) - fprintf (fout, "\n\t\tTIMEOUT));\n"); - else - fprintf (fout, "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); - } - else - { /* single argument, new or old style */ - if (!mtflag) - fprintf (fout, - "\tif (clnt_call (clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT) != RPC_SUCCESS) {\n", - proc->proc_name, - stringfix (proc->args.decls->decl.type), - (newstyle ? "&" : ""), - (newstyle ? proc->args.decls->decl.name : "argp"), - stringfix (proc->res_type), ampr (proc->res_type), - RESULT); - else - fprintf(fout, - "\treturn (clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT));\n", - proc->proc_name, - stringfix (proc->args.decls->decl.type), - (newstyle ? "&" : ""), - (newstyle ? proc->args.decls->decl.name : "argp"), - stringfix (proc->res_type), "", - RESULT); - } - if (!mtflag) - { - fprintf (fout, "\t\treturn (NULL);\n"); - fprintf (fout, "\t}\n"); - if (streq (proc->res_type, "void")) - { - fprintf (fout, "\treturn ((void *)%s%s);\n", - ampr (proc->res_type), RESULT); - } - else - { - fprintf (fout, "\treturn (%s%s);\n", ampr (proc->res_type), RESULT); - } - } -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_cout.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_cout.c deleted file mode 100644 index 4627110..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_cout.c +++ /dev/null @@ -1,813 +0,0 @@ -/* - * From: @(#)rpc_cout.c 1.13 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_cout.c, XDR routine outputter for the RPC protocol compiler - */ -#include -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static void emit_enum (definition * def); -static void emit_program (const definition * def); -static void emit_union (const definition * def); -static void emit_struct (definition * def); -static void emit_typedef (const definition * def); -static void emit_inline (int indent, declaration * decl, int flag); -static void emit_single_in_line (int indent, declaration *decl, int flag, - relation rel); -static int findtype (const definition * def, const char *type); -static int undefined (const char *type); -static void print_generic_header (const char *procname, int pointerp); -static void print_ifopen (int indent, const char *name); -static void print_ifarg (const char *arg); -static void print_ifsizeof (int indent, const char *prefix, const char *type); -static void print_ifclose (int indent); -static void print_ifstat (int indent, const char *prefix, const char *type, - relation rel, const char *amax, - const char *objname, const char *name); -static void print_stat (int indent, const declaration * dec); -static void print_header (const definition * def); -static void print_trailer (void); -static char *upcase (const char *str); - -/* - * Emit the C-routine for the given definition - */ -void -emit (definition * def) -{ - if (def->def_kind == DEF_CONST) - { - return; - } - if (def->def_kind == DEF_PROGRAM) - { - emit_program (def); - return; - } - if (def->def_kind == DEF_TYPEDEF) - { - /* now we need to handle declarations like - struct typedef foo foo; - since we don't want this to be expanded - into 2 calls to xdr_foo */ - - if (strcmp (def->def.ty.old_type, def->def_name) == 0) - return; - }; - - print_header (def); - switch (def->def_kind) - { - case DEF_UNION: - emit_union (def); - break; - case DEF_ENUM: - emit_enum (def); - break; - case DEF_STRUCT: - emit_struct (def); - break; - case DEF_TYPEDEF: - emit_typedef (def); - break; - default: - /* can't happen */ - break; - } - print_trailer (); -} - -static int -findtype (const definition * def, const char *type) -{ - if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) - { - return 0; - } - else - { - return (streq (def->def_name, type)); - } -} - -static int -undefined (const char *type) -{ - definition *def; - def = (definition *) FINDVAL (defined, type, findtype); - return (def == NULL); -} - - -static void -print_generic_header (const char *procname, int pointerp) -{ - f_print (fout, "\n"); - f_print (fout, "bool_t\n"); - if (Cflag) - { - f_print (fout, "xdr_%s (", procname); - f_print (fout, "XDR *xdrs, "); - f_print (fout, "%s ", procname); - if (pointerp) - f_print (fout, "*"); - f_print (fout, "objp)\n{\n"); - } - else - { - f_print (fout, "xdr_%s (xdrs, objp)\n", procname); - f_print (fout, "\tXDR *xdrs;\n"); - f_print (fout, "\t%s ", procname); - if (pointerp) - f_print (fout, "*"); - f_print (fout, "objp;\n{\n"); - } -} - -static void -print_header (const definition * def) -{ - print_generic_header (def->def_name, - def->def_kind != DEF_TYPEDEF || - !isvectordef (def->def.ty.old_type, - def->def.ty.rel)); - - /* Now add Inline support */ - - if (inlineflag == 0) - return; - /*May cause lint to complain. but ... */ - f_print (fout, "\tregister int32_t *buf;\n\n"); -} - -static void -print_prog_header (const proc_list * plist) -{ - print_generic_header (plist->args.argname, 1); -} - -static void -print_trailer (void) -{ - f_print (fout, "\treturn TRUE;\n"); - f_print (fout, "}\n"); -} - - -static void -print_ifopen (int indent, const char *name) -{ - tabify (fout, indent); - f_print (fout, " if (!xdr_%s (xdrs", name); -} - -static void -print_ifarg (const char *arg) -{ - f_print (fout, ", %s", arg); -} - -static void -print_ifsizeof (int indent, const char *prefix, const char *type) -{ - if (indent) - { - fprintf (fout, ",\n"); - tabify (fout, indent); - } - else - fprintf (fout, ", "); - - if (streq (type, "bool")) - fprintf (fout, "sizeof (bool_t), (xdrproc_t) xdr_bool"); - else - { - fprintf (fout, "sizeof ("); - if (undefined (type) && prefix) - { - f_print (fout, "%s ", prefix); - } - fprintf (fout, "%s), (xdrproc_t) xdr_%s", type, type); - } -} - -static void -print_ifclose (int indent) -{ - f_print (fout, "))\n"); - tabify (fout, indent); - f_print (fout, "\t return FALSE;\n"); -} - -static void -print_ifstat (int indent, const char *prefix, const char *type, relation rel, - const char *amax, const char *objname, const char *name) -{ - const char *alt = NULL; - - switch (rel) - { - case REL_POINTER: - print_ifopen (indent, "pointer"); - print_ifarg ("(char **)"); - f_print (fout, "%s", objname); - print_ifsizeof (0, prefix, type); - break; - case REL_VECTOR: - if (streq (type, "string")) - { - alt = "string"; - } - else if (streq (type, "opaque")) - { - alt = "opaque"; - } - if (alt) - { - print_ifopen (indent, alt); - print_ifarg (objname); - } - else - { - print_ifopen (indent, "vector"); - print_ifarg ("(char *)"); - f_print (fout, "%s", objname); - } - print_ifarg (amax); - if (!alt) - { - print_ifsizeof (indent + 1, prefix, type); - } - break; - case REL_ARRAY: - if (streq (type, "string")) - { - alt = "string"; - } - else if (streq (type, "opaque")) - { - alt = "bytes"; - } - if (streq (type, "string")) - { - print_ifopen (indent, alt); - print_ifarg (objname); - } - else - { - if (alt) - { - print_ifopen (indent, alt); - } - else - { - print_ifopen (indent, "array"); - } - print_ifarg ("(char **)"); - if (*objname == '&') - { - f_print (fout, "%s.%s_val, (u_int *) %s.%s_len", - objname, name, objname, name); - } - else - { - f_print (fout, "&%s->%s_val, (u_int *) &%s->%s_len", - objname, name, objname, name); - } - } - print_ifarg (amax); - if (!alt) - { - print_ifsizeof (indent + 1, prefix, type); - } - break; - case REL_ALIAS: - print_ifopen (indent, type); - print_ifarg (objname); - break; - } - print_ifclose (indent); -} - -static void -emit_enum (definition * def) -{ - (void) def; - - print_ifopen (1, "enum"); - print_ifarg ("(enum_t *) objp"); - print_ifclose (1); -} - -static void -emit_program (const definition * def) -{ - decl_list *dl; - version_list *vlist; - proc_list *plist; - - for (vlist = def->def.pr.versions; vlist != NULL; vlist = vlist->next) - for (plist = vlist->procs; plist != NULL; plist = plist->next) - { - if (!newstyle || plist->arg_num < 2) - continue; /* old style, or single argument */ - print_prog_header (plist); - for (dl = plist->args.decls; dl != NULL; - dl = dl->next) - print_stat (1, &dl->decl); - print_trailer (); - } -} - -#pragma GCC diagnostic ignored "-Wformat-nonliteral" -static void -emit_union (const definition * def) -{ - declaration *dflt; - case_list *cl; - declaration *cs; - char *object; - const char *vecformat = "objp->%s_u.%s"; - const char *format = "&objp->%s_u.%s"; - - print_stat (1, &def->def.un.enum_decl); - f_print (fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); - for (cl = def->def.un.cases; cl != NULL; cl = cl->next) - { - - f_print (fout, "\tcase %s:\n", cl->case_name); - if (cl->contflag == 1) /* a continued case statement */ - continue; - cs = &cl->case_decl; - if (!streq (cs->type, "void")) - { - object = alloc (strlen (def->def_name) + strlen (format) + - strlen (cs->name) + 1); - if (isvectordef (cs->type, cs->rel)) - { - s_print (object, vecformat, def->def_name, - cs->name); - } - else - { - s_print (object, format, def->def_name, - cs->name); - } - print_ifstat (2, cs->prefix, cs->type, cs->rel, cs->array_max, - object, cs->name); - free (object); - } - f_print (fout, "\t\tbreak;\n"); - } - dflt = def->def.un.default_decl; - if (dflt != NULL) - { - if (!streq (dflt->type, "void")) - { - f_print (fout, "\tdefault:\n"); - object = alloc (strlen (def->def_name) + strlen (format) + - strlen (dflt->name) + 1); - if (isvectordef (dflt->type, dflt->rel)) - { - s_print (object, vecformat, def->def_name, - dflt->name); - } - else - { - s_print (object, format, def->def_name, - dflt->name); - } - - print_ifstat (2, dflt->prefix, dflt->type, dflt->rel, - dflt->array_max, object, dflt->name); - free (object); - f_print (fout, "\t\tbreak;\n"); - } - else - { - f_print (fout, "\tdefault:\n"); - f_print (fout, "\t\tbreak;\n"); - } - } - else - { - f_print (fout, "\tdefault:\n"); - f_print (fout, "\t\treturn FALSE;\n"); - } - - f_print (fout, "\t}\n"); -} -#pragma GCC diagnostic warning "-Wformat-nonliteral" - -static void -inline_struct (definition *def, int flag) -{ - decl_list *dl; - int i, size; - decl_list *cur = NULL; - decl_list *psav; - bas_type *ptr; - char *sizestr; - const char *plus; - char ptemp[256]; - int indent = 1; - - if (flag == PUT) - f_print (fout, "\n\tif (xdrs->x_op == XDR_ENCODE) {\n"); - else - f_print (fout, - "\t\treturn TRUE;\n\t} else if (xdrs->x_op == XDR_DECODE) {\n"); - - i = 0; - size = 0; - sizestr = NULL; - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - { /* xxx */ - /* now walk down the list and check for basic types */ - if ((dl->decl.prefix == NULL) && - ((ptr = find_type (dl->decl.type)) != NULL) && - ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) - { - if (i == 0) - cur = dl; - ++i; - - if (dl->decl.rel == REL_ALIAS) - size += ptr->length; - else - { - /* this is required to handle arrays */ - if (sizestr == NULL) - plus = ""; - else - plus = "+ "; - - if (ptr->length != 1) - s_print (ptemp, " %s %s * %d", plus, dl->decl.array_max, - ptr->length); - else - s_print (ptemp, " %s%s ", plus, dl->decl.array_max); - - /*now concatenate to sizestr !!!! */ - if (sizestr == NULL) - sizestr = strdup (ptemp); - else - { - sizestr = realloc (sizestr, strlen (sizestr) + - strlen (ptemp) + 1); - if (sizestr == NULL) - { - f_print (stderr, "Fatal error : no memory \n"); - crash (); - }; - sizestr = strcat (sizestr, ptemp); - /*build up length of array */ - } - } - } - else - { - if (i > 0) - { - if (sizestr == NULL && size < inlineflag) - { - /* don't expand into inline code if size < inlineflag */ - while (cur != dl) - { - print_stat (indent + 1, &cur->decl); - cur = cur->next; - } - } - else - { - /* were already looking at a xdr_inlineable structure */ - tabify (fout, indent + 1); - if (sizestr == NULL) - f_print (fout, "buf = XDR_INLINE (xdrs, %d * BYTES_PER_XDR_UNIT);", size); - else if (size == 0) - f_print (fout, - "buf = XDR_INLINE (xdrs, (%s) * BYTES_PER_XDR_UNIT);", - sizestr); - else - f_print (fout, - "buf = XDR_INLINE (xdrs, (%d + (%s)) * BYTES_PER_XDR_UNIT);", - size, sizestr); - f_print (fout, "\n"); - tabify (fout, indent + 1); - fprintf (fout, "if (buf == NULL) {\n"); - psav = cur; - while (cur != dl) - { - print_stat (indent + 2, &cur->decl); - cur = cur->next; - } - - f_print (fout, "\n\t\t} else {\n"); - cur = psav; - while (cur != dl) - { - emit_inline (indent + 1, &cur->decl, flag); - cur = cur->next; - } - tabify (fout, indent + 1); - f_print (fout, "}\n"); - } - } - size = 0; - i = 0; - free (sizestr); - sizestr = NULL; - print_stat (indent + 1, &dl->decl); - } - } - if (i > 0) - { - if (sizestr == NULL && size < inlineflag) - { - /* don't expand into inline code if size < inlineflag */ - while (cur != dl) - { - print_stat (indent + 1, &cur->decl); - cur = cur->next; - } - } - else - { - /* were already looking at a xdr_inlineable structure */ - if (sizestr == NULL) - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, %d * BYTES_PER_XDR_UNIT);", - size); - else if (size == 0) - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, (%s) * BYTES_PER_XDR_UNIT);", - sizestr); - else - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", - size, sizestr); - f_print (fout, "\n\t\tif (buf == NULL) {\n"); - psav = cur; - while (cur != NULL) - { - print_stat (indent + 2, &cur->decl); - cur = cur->next; - } - f_print (fout, "\t\t} else {\n"); - - cur = psav; - while (cur != dl) - { - emit_inline (indent + 2, &cur->decl, flag); - cur = cur->next; - } - f_print (fout, "\t\t}\n"); - } - } -} - -/* this may be const. i haven't traced this one through yet. */ - -static void -emit_struct (definition * def) -{ - decl_list *dl; - int j, size, flag; - bas_type *ptr; - int can_inline; - - - if (inlineflag == 0) - { - /* No xdr_inlining at all */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); - return; - } - - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - if (dl->decl.rel == REL_VECTOR) - { - f_print (fout, "\tint i;\n"); - break; - } - - size = 0; - can_inline = 0; - /* - * Make a first pass and see if inling is possible. - */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - if ((dl->decl.prefix == NULL) && - ((ptr = find_type (dl->decl.type)) != NULL) && - ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) - { - if (dl->decl.rel == REL_ALIAS) - size += ptr->length; - else - { - can_inline = 1; - break; /* can be inlined */ - } - } - else - { - if (size >= inlineflag) - { - can_inline = 1; - break; /* can be inlined */ - } - size = 0; - } - if (size > inlineflag) - can_inline = 1; - - if (can_inline == 0) - { /* can not inline, drop back to old mode */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); - return; - }; - - flag = PUT; - for (j = 0; j < 2; j++) - { - inline_struct (def, flag); - if (flag == PUT) - flag = GET; - } - - f_print (fout, "\t return TRUE;\n\t}\n\n"); - - /* now take care of XDR_FREE case */ - - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); -} - -static void -emit_typedef (const definition * def) -{ - const char *prefix = def->def.ty.old_prefix; - const char *type = def->def.ty.old_type; - const char *amax = def->def.ty.array_max; - relation rel = def->def.ty.rel; - - print_ifstat (1, prefix, type, rel, amax, "objp", def->def_name); -} - -static void -print_stat (int indent, const declaration * dec) -{ - const char *prefix = dec->prefix; - const char *type = dec->type; - const char *amax = dec->array_max; - relation rel = dec->rel; - char name[256]; - - if (isvectordef (type, rel)) - { - s_print (name, "objp->%s", dec->name); - } - else - { - s_print (name, "&objp->%s", dec->name); - } - print_ifstat (indent, prefix, type, rel, amax, name, dec->name); -} - - -static void -emit_inline (int indent, declaration * decl, int flag) -{ - switch (decl->rel) - { - case REL_ALIAS: - emit_single_in_line (indent, decl, flag, REL_ALIAS); - break; - case REL_VECTOR: - tabify (fout, indent); - f_print (fout, "{\n"); - tabify (fout, indent + 1); - f_print (fout, "register %s *genp;\n\n", decl->type); - tabify (fout, indent + 1); - f_print (fout, - "for (i = 0, genp = objp->%s;\n", decl->name); - tabify (fout, indent + 2); - f_print (fout, "i < %s; ++i) {\n", decl->array_max); - emit_single_in_line (indent + 2, decl, flag, REL_VECTOR); - tabify (fout, indent + 1); - f_print (fout, "}\n"); - tabify (fout, indent); - f_print (fout, "}\n"); - break; - default: - break; - /* ?... do nothing I guess */ - } -} - -static void -emit_single_in_line (int indent, declaration *decl, int flag, relation rel) -{ - char *upp_case; - int freed = 0; - - tabify (fout, indent); - if (flag == PUT) - f_print (fout, "IXDR_PUT_"); - else - { - if (rel == REL_ALIAS) - f_print (fout, "objp->%s = IXDR_GET_", decl->name); - else - f_print (fout, "*genp++ = IXDR_GET_"); - } - - upp_case = upcase (decl->type); - - /* hack - XX */ - if (!strcmp (upp_case, "INT")) - { - free (upp_case); - freed = 1; - /* Casting is safe since the `freed' flag is set. */ - upp_case = (char *) "LONG"; - } - - if (!strcmp (upp_case, "U_INT")) - { - free (upp_case); - freed = 1; - /* Casting is safe since the `freed' flag is set. */ - upp_case = (char *) "U_LONG"; - } - - if (flag == PUT) - { - if (rel == REL_ALIAS) - f_print (fout, "%s(buf, objp->%s);\n", upp_case, decl->name); - else - f_print (fout, "%s(buf, *genp++);\n", upp_case); - } - else - { - f_print (fout, "%s(buf);\n", upp_case); - } - - if (!freed) - free (upp_case); -} - - -static char * -upcase (const char *str) -{ - char *ptr, *hptr; - ptr = malloc (strlen (str) + 1); - if (ptr == NULL) - { - f_print (stderr, "malloc failed\n"); - exit (1); - } - hptr = ptr; - while (*str != '\0') - *ptr++ = toupper (*str++); - - *ptr = '\0'; - return hptr; -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_hout.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_hout.c deleted file mode 100644 index 10f793d..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_hout.c +++ /dev/null @@ -1,607 +0,0 @@ -/* - * From: @(#)rpc_hout.c 1.12 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_hout.c, Header file outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static void pconstdef (definition * def); -static void pargdef (definition * def); -static void pstructdef (definition * def); -static void puniondef (definition * def); -static void pdefine (const char *name, const char *num); -static int define_printed (proc_list * stop, version_list * start); -static void pprogramdef (definition * def); -static void parglist (proc_list * proc, const char *addargtype); -static void penumdef (definition * def); -static void ptypedef (definition * def); -static int undefined2 (const char *type, const char *stop); - -/* store away enough information to allow the XDR functions to be spat - out at the end of the file */ - -static void -storexdrfuncdecl (const char *name, int pointerp) -{ - xdrfunc * xdrptr; - - xdrptr = (xdrfunc *) malloc(sizeof (struct xdrfunc)); - - xdrptr->name = (char *)name; - xdrptr->pointerp = pointerp; - xdrptr->next = NULL; - - if (xdrfunc_tail == NULL) - { - xdrfunc_head = xdrptr; - xdrfunc_tail = xdrptr; - } - else - { - xdrfunc_tail->next = xdrptr; - xdrfunc_tail = xdrptr; - } -} - -/* - * Print the C-version of an xdr definition - */ -void -print_datadef (definition *def) -{ - - if (def->def_kind == DEF_PROGRAM) /* handle data only */ - return; - - if (def->def_kind != DEF_CONST) - { - f_print (fout, "\n"); - } - switch (def->def_kind) - { - case DEF_STRUCT: - pstructdef (def); - break; - case DEF_UNION: - puniondef (def); - break; - case DEF_ENUM: - penumdef (def); - break; - case DEF_TYPEDEF: - ptypedef (def); - break; - case DEF_PROGRAM: - pprogramdef (def); - break; - case DEF_CONST: - pconstdef (def); - break; - } - if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) - { - storexdrfuncdecl(def->def_name, - def->def_kind != DEF_TYPEDEF || - !isvectordef(def->def.ty.old_type, - def->def.ty.rel)); - } -} - - -void -print_funcdef (definition *def) -{ - switch (def->def_kind) - { - case DEF_PROGRAM: - f_print (fout, "\n"); - pprogramdef (def); - break; - default: - break; - /* ?... shouldn't happen I guess */ - } -} - -void -print_xdr_func_def (char *name, int pointerp, int i) -{ - if (i == 2) - { - f_print (fout, "extern bool_t xdr_%s ();\n", name); - return; - } - else - f_print(fout, "extern bool_t xdr_%s (XDR *, %s%s);\n", name, - name, pointerp ? "*" : ""); -} - -static void -pconstdef (definition *def) -{ - pdefine (def->def_name, def->def.co); -} - -/* print out the definitions for the arguments of functions in the - header file - */ -static void -pargdef (definition * def) -{ - decl_list *l; - version_list *vers; - const char *name; - proc_list *plist; - - for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) - { - for (plist = vers->procs; plist != NULL; - plist = plist->next) - { - - if (!newstyle || plist->arg_num < 2) - { - continue; /* old style or single args */ - } - name = plist->args.argname; - f_print (fout, "struct %s {\n", name); - for (l = plist->args.decls; - l != NULL; l = l->next) - { - pdeclaration (name, &l->decl, 1, ";\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); - storexdrfuncdecl (name, 1); - f_print (fout, "\n"); - } - } - -} - -static void -pstructdef (definition *def) -{ - decl_list *l; - const char *name = def->def_name; - - f_print (fout, "struct %s {\n", name); - for (l = def->def.st.decls; l != NULL; l = l->next) - { - pdeclaration (name, &l->decl, 1, ";\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); -} - -static void -puniondef (definition *def) -{ - case_list *l; - const char *name = def->def_name; - declaration *decl; - - f_print (fout, "struct %s {\n", name); - decl = &def->def.un.enum_decl; - if (streq (decl->type, "bool")) - { - f_print (fout, "\tbool_t %s;\n", decl->name); - } - else - { - f_print (fout, "\t%s %s;\n", decl->type, decl->name); - } - f_print (fout, "\tunion {\n"); - for (l = def->def.un.cases; l != NULL; l = l->next) - { - if (l->contflag == 0) - pdeclaration (name, &l->case_decl, 2, ";\n"); - } - decl = def->def.un.default_decl; - if (decl && !streq (decl->type, "void")) - { - pdeclaration (name, decl, 2, ";\n"); - } - f_print (fout, "\t} %s_u;\n", name); - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); -} - -static void -pdefine (const char *name, const char *num) -{ - f_print (fout, "#define %s %s\n", name, num); -} - -static int -define_printed (proc_list *stop, version_list *start) -{ - version_list *vers; - proc_list *proc; - - for (vers = start; vers != NULL; vers = vers->next) - { - for (proc = vers->procs; proc != NULL; proc = proc->next) - { - if (proc == stop) - { - return 0; - } - else if (streq (proc->proc_name, stop->proc_name)) - { - return 1; - } - } - } - abort (); - /* NOTREACHED */ -} - -static void -pfreeprocdef (const char *name, const char *vers, int mode) -{ - f_print (fout, "extern int "); - pvname (name, vers); - if (mode == 1) - f_print (fout,"_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n"); - else - f_print (fout,"_freeresult ();\n"); -} - -static void -pprogramdef (definition *def) -{ - version_list *vers; - proc_list *proc; - int i; - const char *ext; - - pargdef (def); - - pdefine (def->def_name, def->def.pr.prog_num); - for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) - { - if (tblflag) - { - f_print (fout, "extern struct rpcgen_table %s_%s_table[];\n", - locase (def->def_name), vers->vers_num); - f_print (fout, "extern %s_%s_nproc;\n", - locase (def->def_name), vers->vers_num); - } - pdefine (vers->vers_name, vers->vers_num); - - /* - * Print out 2 definitions, one for ANSI-C, another for - * old K & R C - */ - - if(!Cflag) - { - ext = "extern "; - for (proc = vers->procs; proc != NULL; - proc = proc->next) - { - if (!define_printed(proc, def->def.pr.versions)) - { - pdefine (proc->proc_name, proc->proc_num); - } - f_print (fout, "%s", ext); - pprocdef (proc, vers, NULL, 0, 2); - - if (mtflag) - { - f_print(fout, "%s", ext); - pprocdef (proc, vers, NULL, 1, 2); - } - } - pfreeprocdef (def->def_name, vers->vers_num, 2); - } - else - { - for (i = 1; i < 3; i++) - { - if (i == 1) - { - f_print (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n"); - ext = "extern "; - } - else - { - f_print (fout, "\n#else /* K&R C */\n"); - ext = "extern "; - } - - for (proc = vers->procs; proc != NULL; proc = proc->next) - { - if (!define_printed(proc, def->def.pr.versions)) - { - pdefine(proc->proc_name, proc->proc_num); - } - f_print (fout, "%s", ext); - pprocdef (proc, vers, "CLIENT *", 0, i); - f_print (fout, "%s", ext); - pprocdef (proc, vers, "struct svc_req *", 1, i); - } - pfreeprocdef (def->def_name, vers->vers_num, i); - } - f_print (fout, "#endif /* K&R C */\n"); - } - } -} - -void -pprocdef (proc_list * proc, version_list * vp, - const char *addargtype, int server_p, int mode) -{ - if (mtflag) - {/* Print MT style stubs */ - if (server_p) - f_print (fout, "bool_t "); - else - f_print (fout, "enum clnt_stat "); - } - else - { - ptype (proc->res_prefix, proc->res_type, 1); - f_print (fout, "* "); - } - if (server_p) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - - /* - * mode 1 = ANSI-C, mode 2 = K&R C - */ - if (mode == 1) - parglist (proc, addargtype); - else - f_print (fout, "();\n"); -} - -/* print out argument list of procedure */ -static void -parglist (proc_list *proc, const char *addargtype) -{ - decl_list *dl; - - f_print(fout,"("); - if (proc->arg_num < 2 && newstyle && - streq (proc->args.decls->decl.type, "void")) - { - /* 0 argument in new style: do nothing */ - } - else - { - for (dl = proc->args.decls; dl != NULL; dl = dl->next) - { - ptype (dl->decl.prefix, dl->decl.type, 1); - if (!newstyle) - f_print (fout, "*"); /* old style passes by reference */ - - f_print (fout, ", "); - } - } - if (mtflag) - { - ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*, "); - } - - f_print (fout, "%s);\n", addargtype); -} - -static void -penumdef (definition *def) -{ - const char *name = def->def_name; - enumval_list *l; - const char *last = NULL; - int count = 0; - - f_print (fout, "enum %s {\n", name); - for (l = def->def.en.vals; l != NULL; l = l->next) - { - f_print (fout, "\t%s", l->name); - if (l->assignment) - { - f_print (fout, " = %s", l->assignment); - last = l->assignment; - count = 1; - } - else - { - if (last == NULL) - { - f_print (fout, " = %d", count++); - } - else - { - f_print (fout, " = %s + %d", last, count++); - } - } - f_print (fout, ",\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef enum %s %s;\n", name, name); -} - -static void -ptypedef (definition *def) -{ - const char *name = def->def_name; - const char *old = def->def.ty.old_type; - char prefix[8]; /* enough to contain "struct ", including NUL */ - relation rel = def->def.ty.rel; - - if (!streq (name, old)) - { - if (streq (old, "string")) - { - old = "char"; - rel = REL_POINTER; - } - else if (streq (old, "opaque")) - { - old = "char"; - } - else if (streq (old, "bool")) - { - old = "bool_t"; - } - if (undefined2 (old, name) && def->def.ty.old_prefix) - { - s_print (prefix, "%s ", def->def.ty.old_prefix); - } - else - { - prefix[0] = 0; - } - f_print (fout, "typedef "); - switch (rel) - { - case REL_ARRAY: - f_print (fout, "struct {\n"); - f_print (fout, "\tu_int %s_len;\n", name); - f_print (fout, "\t%s%s *%s_val;\n", prefix, old, name); - f_print (fout, "} %s", name); - break; - case REL_POINTER: - f_print (fout, "%s%s *%s", prefix, old, name); - break; - case REL_VECTOR: - f_print (fout, "%s%s %s[%s]", prefix, old, name, - def->def.ty.array_max); - break; - case REL_ALIAS: - f_print (fout, "%s%s %s", prefix, old, name); - break; - } - f_print (fout, ";\n"); - } -} - -void -pdeclaration (const char *name, declaration * dec, int tab, - const char *separator) -{ - char buf[8]; /* enough to hold "struct ", include NUL */ - const char *prefix; - const char *type; - - if (streq (dec->type, "void")) - { - return; - } - tabify (fout, tab); - if (streq (dec->type, name) && !dec->prefix) - { - f_print (fout, "struct "); - } - if (streq (dec->type, "string")) - { - f_print (fout, "char *%s", dec->name); - } - else - { - prefix = ""; - if (streq (dec->type, "bool")) - { - type = "bool_t"; - } - else if (streq (dec->type, "opaque")) - { - type = "char"; - } - else - { - if (dec->prefix) - { - s_print (buf, "%s ", dec->prefix); - prefix = buf; - } - type = dec->type; - } - switch (dec->rel) - { - case REL_ALIAS: - f_print (fout, "%s%s %s", prefix, type, dec->name); - break; - case REL_VECTOR: - f_print (fout, "%s%s %s[%s]", prefix, type, dec->name, - dec->array_max); - break; - case REL_POINTER: - f_print (fout, "%s%s *%s", prefix, type, dec->name); - break; - case REL_ARRAY: - f_print (fout, "struct {\n"); - tabify (fout, tab); - f_print (fout, "\tu_int %s_len;\n", dec->name); - tabify (fout, tab); - f_print (fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); - tabify (fout, tab); - f_print (fout, "} %s", dec->name); - break; - } - } - f_print (fout, "%s", separator); -} - -static int -undefined2 (const char *type, const char *stop) -{ - list *l; - definition *def; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - if (streq (def->def_name, stop)) - { - return 1; - } - else if (streq (def->def_name, type)) - { - return 0; - } - } - } - return 1; -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_main.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_main.c deleted file mode 100644 index e97940b..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_main.c +++ /dev/null @@ -1,1453 +0,0 @@ -/* - * From @(#)rpc_main.c 1.30 89/03/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_main.c, Top level of the RPC protocol compiler. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "rpc_scan.h" -#include "proto.h" -#include "nls.h" - -#ifndef _ -#define _(String) gettext (String) -#endif - -#define EXTEND 1 /* alias for TRUE */ -#define DONT_EXTEND 0 /* alias for FALSE */ - -struct commandline - { - int cflag; /* xdr C routines */ - int hflag; /* header file */ - int lflag; /* client side stubs */ - int mflag; /* server side stubs */ - int nflag; /* netid flag */ - int sflag; /* server stubs for the given transport */ - int tflag; /* dispatch Table file */ - int Ssflag; /* produce server sample code */ - int Scflag; /* produce client sample code */ - int makefileflag; /* Generate a template Makefile */ - const char *infile; /* input module name */ - const char *outfile; /* output module name */ - }; - - -static const char *cmdname; - -static const char *svcclosetime = "120"; -static int cppDefined; /* explicit path for C preprocessor */ -static const char *CPP = "/lib/cpp"; -static const char CPPFLAGS[] = "-C"; -static char *pathbuf; -static int cpp_pid; -static const char *allv[] = -{ - "rpcgen", "-s", "udp", "-s", "tcp" -}; -static int allc = sizeof (allv) / sizeof (allv[0]); -static const char *allnv[] = -{ - "rpcgen", "-s", "netpath", -}; -static int allnc = sizeof (allnv) / sizeof (allnv[0]); - -/* - * machinations for handling expanding argument list - */ -static void addarg (const char *); /* add another argument to the list */ -static void putarg (int, const char *); /* put argument at specified location */ -static void clear_args (void); /* clear argument list */ -static void checkfiles (const char *, const char *); - /* check if out file already exists */ - -static void clear_args (void); -static char *extendfile (const char *file, const char *ext); -static void open_output (const char *infile, const char *outfile); -static void add_warning (void); -static void clear_args (void); -static void find_cpp (void); -static void open_input (const char *infile, const char *define); -static int check_nettype (const char *name, const char *list_to_check[]); -static void c_output (const char *infile, const char *define, - int extend, const char *outfile); -static void h_output (const char *infile, const char *define, - int extend, const char *outfile); -static void s_output (int argc, const char *argv[], const char *infile, - const char *define, int extend, - const char *outfile, int nomain, int netflag); -static void l_output (const char *infile, const char *define, - int extend, const char *outfile); -static void t_output (const char *infile, const char *define, - int extend, const char *outfile); -static void svc_output (const char *infile, const char *define, - int extend, const char *outfile); -static void clnt_output (const char *infile, const char *define, - int extend, const char *outfile); -static void mkfile_output (struct commandline *cmd); -static int do_registers (int argc, const char *argv[]); -static void addarg (const char *cp); -static void putarg (int whereto, const char *cp); -static void checkfiles (const char *infile, const char *outfile); -static int parseargs (int argc, const char *argv[], struct commandline *cmd); -static void usage (FILE *stream, int status) __attribute__ ((noreturn)); -static void options_usage (FILE *stream, int status) __attribute__ ((noreturn)); -static void print_version (void); -static void c_initialize (void); -static char *generate_guard (const char *pathname); - - -#define ARGLISTLEN 20 -#define FIXEDARGS 2 - -static const char *arglist[ARGLISTLEN]; -static int argcount = FIXEDARGS; - - -int nonfatalerrors; /* errors */ -int inetdflag /* = 1 */ ; /* Support for inetd *//* is now the default */ -int pmflag; /* Support for port monitors */ -int logflag; /* Use syslog instead of fprintf for errors */ -int tblflag; /* Support for dispatch table file */ -int mtflag; /* Support for MT */ - -#define INLINE 3 -/*length at which to start doing an inline */ - -int inlineflag = INLINE; /* length at which to start doing an inline. 3 = default - if 0, no xdr_inline code */ - -int indefinitewait; /* If started by port monitors, hang till it wants */ -int exitnow; /* If started by port monitors, exit after the call */ -int timerflag; /* TRUE if !indefinite && !exitnow */ -int newstyle; /* newstyle of passing arguments (by value) */ -int Cflag = 1; /* ANSI C syntax */ -int CCflag; /* C++ files */ -static int allfiles; /* generate all files */ -int tirpcflag; /* generating code for tirpc, default is backward compatibility */ -xdrfunc *xdrfunc_head; /* xdr function list */ -xdrfunc *xdrfunc_tail; /* xdr function list */ - -int -main (int argc, const char *argv[]) -{ - struct commandline cmd; - - setlocale (LC_ALL, ""); - textdomain (PACKAGE); - - (void) memset ((char *) &cmd, 0, sizeof (struct commandline)); - clear_args (); - if (!parseargs (argc, argv, &cmd)) - usage (stderr, 1); - - if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag || - cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) - { - checkfiles (cmd.infile, cmd.outfile); - } - else - checkfiles (cmd.infile, NULL); - - if (cmd.cflag) - c_output (cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile); - else if (cmd.hflag) - h_output (cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile); - else if (cmd.lflag) - l_output (cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile); - else if (cmd.sflag || cmd.mflag || (cmd.nflag)) - s_output (argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND, - cmd.outfile, cmd.mflag, cmd.nflag); - else if (cmd.tflag) - t_output (cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile); - else if (cmd.Ssflag) - svc_output (cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile); - else if (cmd.Scflag) - clnt_output (cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile); - else if (cmd.makefileflag) - mkfile_output (&cmd); - else - { - /* the rescans are required, since cpp may effect input */ - c_output (cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); - reinitialize (); - h_output (cmd.infile, "-DRPC_HDR", EXTEND, ".h"); - reinitialize (); - l_output (cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); - reinitialize (); - if (inetdflag || !tirpcflag) - s_output (allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, - "_svc.c", cmd.mflag, cmd.nflag); - else - s_output (allnc, allnv, cmd.infile, "-DRPC_SVC", - EXTEND, "_svc.c", cmd.mflag, cmd.nflag); - if (tblflag) - { - reinitialize (); - t_output (cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i"); - } - if (allfiles) - { - reinitialize (); - svc_output (cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c"); - reinitialize (); - clnt_output (cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c"); - } - if (allfiles || (cmd.makefileflag == 1)) - { - reinitialize (); - mkfile_output (&cmd); - } - } - - return nonfatalerrors; -} - -/* - * add extension to filename - */ -static char * -extendfile (const char *file, const char *ext) -{ - char *res; - const char *p; - - res = alloc (strlen (file) + strlen (ext) + 1); - if (res == NULL) - abort (); - p = strrchr (file, '.'); - if (p == NULL) - p = file + strlen (file); - strcpy (res, file); - strcpy (res + (p - file), ext); - return res; -} - -/* - * Open output file with given extension - */ -static void -open_output (const char *infile, const char *outfile) -{ - if (outfile == NULL) - { - fout = stdout; - return; - } - - if (infile != NULL && streq (outfile, infile)) - { - fprintf (stderr, _("%s: output would overwrite %s\n"), cmdname, - infile); - crash (); - } - fout = fopen (outfile, "w"); - if (fout == NULL) - { - fprintf (stderr, _("%s: unable to open %s: %m\n"), cmdname, outfile); - crash (); - } - record_open (outfile); -} - -/* Close the output file and check for write errors. */ -static void -close_output (const char *outfile) -{ - if (fclose (fout) == EOF) - { - fprintf (stderr, _("%s: while writing output %s: %m"), cmdname, - outfile ?: ""); - crash (); - } -} - -static void -add_warning (void) -{ - fprintf (fout, "/*\n"); - fprintf (fout, " * Please do not edit this file.\n"); - fprintf (fout, " * It was generated using rpcgen.\n"); - fprintf (fout, " */\n\n"); -} - -/* clear list of arguments */ -static void -clear_args (void) -{ - int i; - for (i = FIXEDARGS; i < ARGLISTLEN; ++i) - arglist[i] = NULL; - argcount = FIXEDARGS; -} - -/* make sure that a CPP exists */ -static void -find_cpp (void) -{ - struct stat64 buf; - - if (stat64 (CPP, &buf) == 0) - return; - - if (cppDefined) /* user specified cpp but it does not exist */ - { - fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); - crash (); - } - - /* fall back to system CPP */ - CPP = "cpp"; -} - -/* - * Open input file with given define for C-preprocessor - */ -static void -open_input (const char *infile, const char *define) -{ - int pd[2]; - - infilename = (infile == NULL) ? "" : infile; - if (pipe (pd) != 0) - { - perror ("pipe"); - exit (1); - } - cpp_pid = fork (); - switch (cpp_pid) - { - case 0: - find_cpp (); - putarg (0, CPP); - putarg (1, CPPFLAGS); - addarg (define); - if (infile) - addarg (infile); - addarg ((char *) NULL); - close (1); - dup2 (pd[1], 1); - close (pd[0]); - execvp (arglist[0], (char **) arglist); - if (errno == ENOENT) - { - fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); - exit (1); - } - perror ("execvp"); - exit (1); - case -1: - perror ("fork"); - exit (1); - } - close (pd[1]); - fin = fdopen (pd[0], "r"); - if (fin == NULL) - { - fprintf (stderr, "%s: ", cmdname); - perror (infilename); - crash (); - } -} - -/* Close the connection to the C-preprocessor and check for successfull - termination. */ -static void -close_input (void) -{ - int status; - - fclose (fin); - /* Check the termination status. */ - if (waitpid (cpp_pid, &status, 0) < 0) - { - perror ("waitpid"); - crash (); - } - if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) - { - if (WIFSIGNALED (status)) - fprintf (stderr, _("%s: C preprocessor failed with signal %d\n"), - cmdname, WTERMSIG (status)); - else - fprintf (stderr, _("%s: C preprocessor failed with exit code %d\n"), - cmdname, WEXITSTATUS (status)); - crash (); - } -} - -/* valid tirpc nettypes */ -static const char *valid_ti_nettypes[] = -{ - "netpath", - "visible", - "circuit_v", - "datagram_v", - "circuit_n", - "datagram_n", - "udp", - "tcp", - "raw", - NULL -}; - -/* valid inetd nettypes */ -static const char *valid_i_nettypes[] = -{ - "udp", - "tcp", - NULL -}; - -static int -check_nettype (const char *name, const char *list_to_check[]) -{ - int i; - for (i = 0; list_to_check[i] != NULL; i++) - { - if (strcmp (name, list_to_check[i]) == 0) - { - return 1; - } - } - fprintf (stderr, _ ("illegal nettype: `%s'\n"), name); - return 0; -} - -/* - * Compile into an XDR routine output file - */ - -static void -c_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - - c_initialize (); - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - /* .h file already contains rpc/rpc.h */ - } - else - fprintf (fout, "#include \n"); - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - emit (def); - - if (extend && tell == ftell (fout)) - unlink (outfilename); - close_input (); - close_output (outfilename); -} - -void -c_initialize (void) -{ - - /* add all the starting basic types */ - - add_type (1, "int"); - add_type (1, "long"); - add_type (1, "short"); - add_type (1, "bool"); - - add_type (1, "u_int"); - add_type (1, "u_long"); - add_type (1, "u_short"); - -} - -char rpcgen_table_dcl[] = "struct rpcgen_table {\n\ - char *(*proc)();\n\ - xdrproc_t xdr_arg;\n\ - unsigned len_arg;\n\ - xdrproc_t xdr_res;\n\ - unsigned len_res;\n\ -};\n"; - - -static char * -generate_guard (const char *pathname) -{ - const char *filename; - char *guard, *tmp; - - filename = strrchr (pathname, '/'); /* find last component */ - filename = ((filename == NULL) ? pathname : filename + 1); - guard = extendfile (filename, "_H_RPCGEN"); - /* convert to upper case */ - tmp = guard; - while (*tmp) - { - if (islower (*tmp)) - *tmp = toupper (*tmp); - tmp++; - } - - return guard; -} - -/* - * Compile into an XDR header file - */ - - -static void -h_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - xdrfunc *xdrfuncp; - definition *def; - const char *ifilename; - const char *outfilename; - long tell; - char *guard; - list *l; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - ifilename = (infile == NULL) ? "STDIN" : infile; - guard = generate_guard (outfilename ? outfilename : ifilename); - - fprintf (fout, "#ifndef _%s\n#define _%s\n\n", guard, - guard); - - fprintf (fout, "#include \n\n"); - - if (mtflag) - { - fprintf (fout, "#include \n"); - } - - /* put the C++ support */ - if (Cflag && !CCflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "extern \"C\" {\n"); - fprintf (fout, "#endif\n\n"); - } - - tell = ftell (fout); - /* print data definitions */ - while ((def = get_definition ()) != NULL) - { - print_datadef (def); - } - - /* print function declarations. - Do this after data definitions because they might be used as - arguments for functions */ - for (l = defined; l != NULL; l = l->next) - { - print_funcdef (l->val); - } - /* Now print all xdr func declarations */ - if (xdrfunc_head != NULL) - { - fprintf (fout, "\n/* the xdr functions */\n"); - if (CCflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "extern \"C\" {\n"); - fprintf (fout, "#endif\n"); - } - if (!Cflag) - { - xdrfuncp = xdrfunc_head; - while (xdrfuncp != NULL) - { - print_xdr_func_def (xdrfuncp->name, - xdrfuncp->pointerp, 2); - xdrfuncp = xdrfuncp->next; - } - } - else - { - int i; - - for (i = 1; i < 3; ++i) - { - if (i == 1) - fprintf (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n"); - else - fprintf (fout, "\n#else /* K&R C */\n"); - - xdrfuncp = xdrfunc_head; - while (xdrfuncp != NULL) - { - print_xdr_func_def (xdrfuncp->name, - xdrfuncp->pointerp, i); - xdrfuncp = xdrfuncp->next; - } - } - fprintf (fout, "\n#endif /* K&R C */\n"); - } - } - - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - else if (tblflag) - { - fprintf (fout, "%s", rpcgen_table_dcl); - } - - if (Cflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "}\n"); - fprintf (fout, "#endif\n"); - } - - fprintf (fout, "\n#endif /* !_%s */\n", guard); - free (guard); - close_input (); - close_output (outfilename); -} - -/* - * Compile into an RPC service - */ -static void -s_output (int argc, const char *argv[], const char *infile, const char *define, - int extend, const char *outfile, int nomain, int netflag) -{ - char *include; - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - if (Cflag) - fprintf (fout, "#include \n"); - if (strcmp (svcclosetime, "-1") == 0) - indefinitewait = 1; - else if (strcmp (svcclosetime, "0") == 0) - exitnow = 1; - else if (inetdflag || pmflag) - { - fprintf (fout, "#include \n"); - timerflag = 1; - } - - if (!tirpcflag && inetdflag) - fprintf (fout, "#include /* ioctl, TIOCNOTTY */\n"); - if (Cflag && (inetdflag || pmflag)) - { - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* getdtablesize */\n"); - } - if (tirpcflag && !(Cflag && (inetdflag || pmflag))) - fprintf (fout, "#include \n"); - - fprintf (fout, "#include \n"); - if (inetdflag || !tirpcflag) - { - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - } - - if ((netflag || pmflag) && tirpcflag && !nomain) - { - fprintf (fout, "#include \n"); - } - if ( /*timerflag && */ tirpcflag) - fprintf (fout, "#include /* rlimit */\n"); - if (logflag || inetdflag || pmflag) - { - fprintf (fout, "#include \n"); - } - - /* for ANSI-C */ - if (Cflag) - fprintf (fout, "\n#ifndef SIG_PF\n#define SIG_PF void(*)(int)\n#endif\n"); - - if (timerflag) - fprintf (fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_most (infile, netflag, nomain); - if (!nomain) - { - if (!do_registers (argc, argv)) - { - if (outfilename) - unlink (outfilename); - usage (stderr, 1); - } - write_rest (); - } - close_input (); - close_output (outfilename); -} - -/* - * generate client side stubs - */ -static void -l_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - char *include; - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (Cflag) - fprintf (fout, "#include /* for memset */\n"); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_stubs (); - close_input (); - close_output (outfilename); -} - -/* - * generate the dispatch table - */ -static void -t_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_tables (); - close_input (); - close_output (outfilename); -} - -/* sample routine for the server template */ -static void -svc_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - checkfiles (infile, outfilename); - /*check if outfile already exists. - if so, print an error message and exit */ - open_output (infile, outfilename); - add_sample_msg (); - - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - { - write_sample_svc (def); - } - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - close_input (); - close_output (outfilename); -} - - -/* sample main routine for client */ -static void -clnt_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - int has_program = 0; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - checkfiles (infile, outfilename); - /*check if outfile already exists. - if so, print an error message and exit */ - - open_output (infile, outfilename); - add_sample_msg (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - { - has_program += write_sample_clnt (def); - } - - if (has_program) - write_sample_clnt_main (); - - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - close_input (); - close_output (outfilename); -} - -static const char space[] = " "; - -static char * -file_name (const char *file, const char *ext) -{ - char *temp; - temp = extendfile (file, ext); - - if (access (temp, F_OK) != -1) - return (temp); - - free (temp); - return (char *) space; -} - -static void -mkfile_output (struct commandline *cmd) -{ - char *mkfilename; - char *clientname, *clntname, *xdrname, *hdrname; - char *servername, *svcname, *servprogname, *clntprogname; - - svcname = file_name (cmd->infile, "_svc.c"); - clntname = file_name (cmd->infile, "_clnt.c"); - xdrname = file_name (cmd->infile, "_xdr.c"); - hdrname = file_name (cmd->infile, ".h"); - - if (allfiles) - { - servername = extendfile (cmd->infile, "_server.c"); - clientname = extendfile (cmd->infile, "_client.c"); - } - else - { - servername = (char *) space; - clientname = (char *) space; - } - servprogname = extendfile (cmd->infile, "_server"); - clntprogname = extendfile (cmd->infile, "_client"); - - if (allfiles) - { - char *cp, *temp; - - mkfilename = alloc (strlen ("Makefile.") + strlen (cmd->infile) + 1); - if (mkfilename == NULL) - abort (); - temp = rindex (cmd->infile, '.'); - cp = stpcpy (mkfilename, "Makefile."); - if (temp != NULL) - *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0'; - else - stpcpy (cp, cmd->infile); - - } - else - mkfilename = (char *) cmd->outfile; - - checkfiles (NULL, mkfilename); - open_output (NULL, mkfilename); - - fprintf (fout, "\n# This is a template Makefile generated by rpcgen\n"); - - f_print (fout, "\n# Parameters\n\n"); - - f_print (fout, "CLIENT = %s\nSERVER = %s\n\n", clntprogname, servprogname); - f_print (fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n"); - f_print (fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n"); - f_print (fout, "SOURCES.x = %s\n\n", cmd->infile); - f_print (fout, "TARGETS_SVC.c = %s %s %s \n", - svcname, servername, xdrname); - f_print (fout, "TARGETS_CLNT.c = %s %s %s \n", - clntname, clientname, xdrname); - f_print (fout, "TARGETS = %s %s %s %s %s %s\n\n", - hdrname, xdrname, clntname, - svcname, clientname, servername); - - f_print (fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \ -$(TARGETS_CLNT.c:%%.c=%%.o)"); - - f_print (fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \ -$(TARGETS_SVC.c:%%.c=%%.o)"); - - f_print (fout, "\n# Compiler flags \n"); - if (mtflag) - fprintf (fout, "\nCPPFLAGS += -D_REENTRANT\nCFLAGS += -g \nLDLIBS \ -+= -lnsl -lpthread \n "); - else - f_print (fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n"); - f_print (fout, "RPCGENFLAGS = \n"); - - f_print (fout, "\n# Targets \n\n"); - - f_print (fout, "all : $(CLIENT) $(SERVER)\n\n"); - f_print (fout, "$(TARGETS) : $(SOURCES.x) \n"); - f_print (fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n"); - f_print (fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \ -$(TARGETS_CLNT.c) \n\n"); - - f_print (fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \ -$(TARGETS_SVC.c) \n\n"); - f_print (fout, "$(CLIENT) : $(OBJECTS_CLNT) \n"); - f_print (fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \ -$(LDLIBS) \n\n"); - f_print (fout, "$(SERVER) : $(OBJECTS_SVC) \n"); - f_print (fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n "); - f_print (fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \ -$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n"); - close_output (mkfilename); - - free (clntprogname); - free (servprogname); - if (servername != space) - free (servername); - if (clientname != space) - free (clientname); - if (mkfilename != (char *) cmd->outfile) - free (mkfilename); - if (svcname != space) - free (svcname); - if (clntname != space) - free (clntname); - if (xdrname != space) - free (xdrname); - if (hdrname != space) - free (hdrname); -} - -/* - * Perform registrations for service output - * Return 0 if failed; 1 otherwise. - */ -static int -do_registers (int argc, const char *argv[]) -{ - int i; - - if (inetdflag || !tirpcflag) - { - for (i = 1; i < argc; i++) - { - if (streq (argv[i], "-s")) - { - if (!check_nettype (argv[i + 1], valid_i_nettypes)) - return 0; - write_inetd_register (argv[i + 1]); - i++; - } - } - } - else - { - for (i = 1; i < argc; i++) - if (streq (argv[i], "-s")) - { - if (!check_nettype (argv[i + 1], valid_ti_nettypes)) - return 0; - write_nettype_register (argv[i + 1]); - i++; - } - else if (streq (argv[i], "-n")) - { - write_netid_register (argv[i + 1]); - i++; - } - } - return 1; -} - -/* - * Add another argument to the arg list - */ -static void -addarg (const char *cp) -{ - if (argcount >= ARGLISTLEN) - { - fprintf (stderr, _("rpcgen: too many defines\n")); - crash (); - /*NOTREACHED */ - } - arglist[argcount++] = cp; -} - -static void -putarg (int whereto, const char *cp) -{ - if (whereto >= ARGLISTLEN) - { - fprintf (stderr, _("rpcgen: arglist coding error\n")); - crash (); - /*NOTREACHED */ - } - arglist[whereto] = cp; -} - -/* - * if input file is stdin and an output file is specified then complain - * if the file already exists. Otherwise the file may get overwritten - * If input file does not exist, exit with an error - */ - -static void -checkfiles (const char *infile, const char *outfile) -{ - struct stat64 buf; - - if (infile) /* infile ! = NULL */ - if (stat64 (infile, &buf) < 0) - { - perror (infile); - crash (); - } - if (outfile) - { - if (stat64 (outfile, &buf) < 0) - return; /* file does not exist */ - else - { - fprintf (stderr, - /* TRANS: the file will not be removed; this is an - TRANS: informative message. */ - _("file `%s' already exists and may be overwritten\n"), - outfile); - crash (); - } - } -} - -/* - * Parse command line arguments - */ -static int -parseargs (int argc, const char *argv[], struct commandline *cmd) -{ - int i; - int j; - int c; - char flag[(1 << 8 * sizeof (char))]; - int nflags; - - cmdname = argv[0]; - cmd->infile = cmd->outfile = NULL; - if (argc < 2) - { - return (0); - } - allfiles = 0; - flag['c'] = 0; - flag['h'] = 0; - flag['l'] = 0; - flag['m'] = 0; - flag['o'] = 0; - flag['s'] = 0; - flag['n'] = 0; - flag['t'] = 0; - flag['S'] = 0; - flag['C'] = 0; - flag['M'] = 0; - - for (i = 1; i < argc; i++) - { - if (argv[i][0] != '-') - { - if (cmd->infile) - { - fprintf (stderr, - _("Cannot specify more than one input file!\n")); - return 0; - } - cmd->infile = argv[i]; - } - else if (strcmp (argv[i], "--help") == 0) - usage (stdout, 0); - else if (strcmp (argv[i], "--version") == 0) - print_version (); - else - { - for (j = 1; argv[i][j] != 0; j++) - { - c = argv[i][j]; - switch (c) - { - case 'a': - allfiles = 1; - break; - case 'c': - case 'h': - case 'l': - case 'm': - case 't': - if (flag[c]) - return 0; - flag[c] = 1; - break; - case 'S': - /* sample flag: Ss or Sc. - Ss means set flag['S']; - Sc means set flag['C']; - Sm means set flag['M']; */ - c = argv[i][++j]; /* get next char */ - if (c == 's') - c = 'S'; - else if (c == 'c') - c = 'C'; - else if (c == 'm') - c = 'M'; - else - return 0; - - if (flag[c]) - return 0; - flag[c] = 1; - break; - case 'C': /* ANSI C syntax */ - Cflag = 1; - break; - - case 'k': /* K&R C syntax */ - Cflag = 0; - break; - - case 'b': /* turn TIRPC flag off for - generating backward compatible - */ - tirpcflag = 0; - break; - - case '5': /* turn TIRPC flag on for - generating SysVr4 compatible - */ - tirpcflag = 1; - break; - case 'I': - inetdflag = 1; - break; - case 'N': - newstyle = 1; - break; - case 'L': - logflag = 1; - break; - case 'K': - if (++i == argc) - { - return (0); - } - svcclosetime = argv[i]; - goto nextarg; - case 'T': - tblflag = 1; - break; - case 'M': - mtflag = 1; - break; - case 'i': - if (++i == argc) - { - return (0); - } - inlineflag = atoi (argv[i]); - goto nextarg; - case 'n': - case 'o': - case 's': - if (argv[i][j - 1] != '-' || - argv[i][j + 1] != 0) - { - return (0); - } - flag[c] = 1; - if (++i == argc) - { - return (0); - } - if (c == 's') - { - if (!streq (argv[i], "udp") && - !streq (argv[i], "tcp")) - return 0; - } - else if (c == 'o') - { - if (cmd->outfile) - return 0; - cmd->outfile = argv[i]; - } - goto nextarg; - case 'D': - if (argv[i][j - 1] != '-') - return 0; - addarg (argv[i]); - goto nextarg; - case 'Y': - if (++i == argc) - return 0; - { - size_t len = strlen (argv[i]); - pathbuf = malloc (len + 5); - if (pathbuf == NULL) - { - perror (cmdname); - crash (); - } - stpcpy (stpcpy (pathbuf, - argv[i]), - "/cpp"); - CPP = pathbuf; - cppDefined = 1; - goto nextarg; - } - - default: - return 0; - } - } - nextarg: - ; - } - } - - cmd->cflag = flag['c']; - cmd->hflag = flag['h']; - cmd->lflag = flag['l']; - cmd->mflag = flag['m']; - cmd->nflag = flag['n']; - cmd->sflag = flag['s']; - cmd->tflag = flag['t']; - cmd->Ssflag = flag['S']; - cmd->Scflag = flag['C']; - cmd->makefileflag = flag['M']; - - if (tirpcflag) - { - pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */ - if ((inetdflag && cmd->nflag)) - { /* netid not allowed with inetdflag */ - fprintf (stderr, _("Cannot use netid flag with inetd flag!\n")); - return 0; - } - } - else - { /* 4.1 mode */ - pmflag = 0; /* set pmflag only in tirpcmode */ - if (cmd->nflag) - { /* netid needs TIRPC */ - f_print (stderr, _("Cannot use netid flag without TIRPC!\n")); - return (0); - } - } - - if (newstyle && (tblflag || cmd->tflag)) - { - f_print (stderr, _("Cannot use table flags with newstyle!\n")); - return (0); - } - - /* check no conflicts with file generation flags */ - nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag + - cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag; - - if (nflags == 0) - { - if (cmd->outfile != NULL || cmd->infile == NULL) - { - return (0); - } - } - else if (cmd->infile == NULL && - (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) - { - fprintf (stderr, - _("\"infile\" is required for template generation flags.\n")); - return 0; - } - if (nflags > 1) - { - fprintf (stderr, _("Cannot have more than one file generation flag!\n")); - return 0; - } - return 1; -} - -static void -usage (FILE *stream, int status) -{ - fprintf (stream, _("usage: %s infile\n"), cmdname); - fprintf (stream, _("\t%s [-abkCLNTM][-Dname[=value]] [-i size] \ -[-I [-K seconds]] [-Y path] infile\n"), cmdname); - fprintf (stream, _("\t%s [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm] \ -[-o outfile] [infile]\n"), cmdname); - fprintf (stream, _("\t%s [-s nettype]* [-o outfile] [infile]\n"), cmdname); - fprintf (stream, _("\t%s [-n netid]* [-o outfile] [infile]\n"), cmdname); - options_usage (stream, status); - exit (status); -} - -static void -options_usage (FILE *stream, int status) -{ - f_print (stream, _("options:\n")); - f_print (stream, _("-a\t\tgenerate all files, including samples\n")); - f_print (stream, _("-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n")); - f_print (stream, _("-c\t\tgenerate XDR routines\n")); - f_print (stream, _("-C\t\tANSI C mode\n")); - f_print (stream, _("-Dname[=value]\tdefine a symbol (same as #define)\n")); - f_print (stream, _("-h\t\tgenerate header file\n")); - f_print (stream, _("-i size\t\tsize at which to start generating inline code\n")); - f_print (stream, _("-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n")); - f_print (stream, _("-K seconds\tserver exits after K seconds of inactivity\n")); - f_print (stream, _("-l\t\tgenerate client side stubs\n")); - f_print (stream, _("-L\t\tserver errors will be printed to syslog\n")); - f_print (stream, _("-m\t\tgenerate server side stubs\n")); - f_print (stream, _("-M\t\tgenerate MT-safe code\n")); - f_print (stream, _("-n netid\tgenerate server code that supports named netid\n")); - f_print (stream, _("-N\t\tsupports multiple arguments and call-by-value\n")); - f_print (stream, _("-o outfile\tname of the output file\n")); - f_print (stream, _("-s nettype\tgenerate server code that supports named nettype\n")); - f_print (stream, _("-Sc\t\tgenerate sample client code that uses remote procedures\n")); - f_print (stream, _("-Ss\t\tgenerate sample server code that defines remote procedures\n")); - f_print (stream, _("-Sm \t\tgenerate makefile template \n")); - f_print (stream, _("-t\t\tgenerate RPC dispatch table\n")); - f_print (stream, _("-T\t\tgenerate code to support RPC dispatch tables\n")); - f_print (stream, _("-Y path\t\tdirectory name to find C preprocessor (cpp)\n")); - f_print (stream, _("-5\t\tSysVr4 compatibility mode\n")); - f_print (stream, _("--help\t\tgive this help list\n")); - f_print (stream, _("--version\tprint program version\n")); - - exit (status); -} - -static void -print_version (void) -{ - printf ("rpcgen (%s) %s\n", PACKAGE, VERSION); - exit (0); -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_output.h b/nfs-utils-2.5.2/tools/rpcgen/rpc_output.h deleted file mode 100644 index eb25a60..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_output.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * rpc_output.h - * - * Declarations for output functions - * - */ - -#ifndef RPCGEN_NEW_OUTPUT_H -#define RPCGEN_NEW_OUTPUT_H - -void write_msg_out(void); -int nullproc(proc_list *); -void printarglist(proc_list *, char *, char *); -void pdeclaration(char *, declaration *, int, char *); - -#endif /* RPCGEN_NEW_OUTPUT_H */ diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.c deleted file mode 100644 index ee37430..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.c +++ /dev/null @@ -1,686 +0,0 @@ -/* - * From: @(#)rpc_parse.c 1.8 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_parse.c, Parser for the RPC protocol compiler - * Copyright (C) 1987 Sun Microsystems, Inc. - */ -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define ARGNAME "arg" - -static void isdefined (definition * defp); -static void def_struct (definition * defp); -static void def_program (definition * defp); -static void def_enum (definition * defp); -static void def_const (definition * defp); -static void def_union (definition * defp); -static void check_type_name (const char *name, int new_type); -static void def_typedef (definition * defp); -static void get_declaration (declaration * dec, defkind dkind); -static void get_prog_declaration (declaration * dec, defkind dkind, int num); -static void get_type (const char **prefixp, const char **typep, defkind dkind); -static void unsigned_dec (const char **typep); - -/* - * return the next definition you see - */ -definition * -get_definition (void) -{ - definition *defp; - token tok; - - defp = ALLOC (definition); - get_token (&tok); - switch (tok.kind) - { - case TOK_STRUCT: - def_struct (defp); - break; - case TOK_UNION: - def_union (defp); - break; - case TOK_TYPEDEF: - def_typedef (defp); - break; - case TOK_ENUM: - def_enum (defp); - break; - case TOK_PROGRAM: - def_program (defp); - break; - case TOK_CONST: - def_const (defp); - break; - case TOK_EOF: - free (defp); - return (NULL); - default: - error ("definition keyword expected"); - } - scan (TOK_SEMICOLON, &tok); - isdefined (defp); - return (defp); -} - -static void -isdefined (definition * defp) -{ - STOREVAL (&defined, defp); -} - -static void -def_struct (definition * defp) -{ - token tok; - declaration dec; - decl_list *decls; - decl_list **tailp; - - defp->def_kind = DEF_STRUCT; - - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - tailp = &defp->def.st.decls; - do - { - get_declaration (&dec, DEF_STRUCT); - decls = ALLOC (decl_list); - decls->decl = dec; - *tailp = decls; - tailp = &decls->next; - scan (TOK_SEMICOLON, &tok); - peek (&tok); - } - while (tok.kind != TOK_RBRACE); - get_token (&tok); - *tailp = NULL; -} - -static void -def_program (definition * defp) -{ - token tok; - declaration dec; - decl_list *decls; - decl_list **tailp; - version_list *vlist; - version_list **vtailp; - proc_list *plist; - proc_list **ptailp; - int num_args; - int isvoid = 0; /* whether first argument is void */ - defp->def_kind = DEF_PROGRAM; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - vtailp = &defp->def.pr.versions; - tailp = &defp->def.st.decls; - scan (TOK_VERSION, &tok); - do - { - scan (TOK_IDENT, &tok); - vlist = ALLOC (version_list); - vlist->vers_name = tok.str; - scan (TOK_LBRACE, &tok); - ptailp = &vlist->procs; - do - { - /* get result type */ - plist = ALLOC (proc_list); - get_type (&plist->res_prefix, &plist->res_type, - DEF_PROGRAM); - if (streq (plist->res_type, "opaque")) - { - error ("illegal result type"); - } - scan (TOK_IDENT, &tok); - plist->proc_name = tok.str; - scan (TOK_LPAREN, &tok); - /* get args - first one */ - num_args = 1; - isvoid = 0; - /* type of DEF_PROGRAM in the first - * get_prog_declaration and DEF_STURCT in the next - * allows void as argument if it is the only argument - */ - get_prog_declaration (&dec, DEF_PROGRAM, num_args); - if (streq (dec.type, "void")) - isvoid = 1; - decls = ALLOC (decl_list); - plist->args.decls = decls; - decls->decl = dec; - tailp = &decls->next; - /* get args */ - while (peekscan (TOK_COMMA, &tok)) - { - num_args++; - get_prog_declaration (&dec, DEF_STRUCT, - num_args); - decls = ALLOC (decl_list); - decls->decl = dec; - *tailp = decls; - if (streq (dec.type, "void")) - isvoid = 1; - tailp = &decls->next; - } - /* multiple arguments are only allowed in newstyle */ - if (!newstyle && num_args > 1) - { - error ("only one argument is allowed"); - } - if (isvoid && num_args > 1) - { - error ("illegal use of void in program definition"); - } - *tailp = NULL; - scan (TOK_RPAREN, &tok); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - scan (TOK_SEMICOLON, &tok); - plist->proc_num = tok.str; - plist->arg_num = num_args; - *ptailp = plist; - ptailp = &plist->next; - peek (&tok); - } - while (tok.kind != TOK_RBRACE); - *ptailp = NULL; - *vtailp = vlist; - vtailp = &vlist->next; - scan (TOK_RBRACE, &tok); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - vlist->vers_num = tok.str; - /* make the argument structure name for each arg */ - for (plist = vlist->procs; plist != NULL; - plist = plist->next) - { - plist->args.argname = make_argname (plist->proc_name, - vlist->vers_num); - /* free the memory ?? */ - } - scan (TOK_SEMICOLON, &tok); - scan2 (TOK_VERSION, TOK_RBRACE, &tok); - } - while (tok.kind == TOK_VERSION); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - defp->def.pr.prog_num = tok.str; - *vtailp = NULL; -} - - -static void -def_enum (definition * defp) -{ - token tok; - enumval_list *elist; - enumval_list **tailp; - - defp->def_kind = DEF_ENUM; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - tailp = &defp->def.en.vals; - do - { - scan (TOK_IDENT, &tok); - elist = ALLOC (enumval_list); - elist->name = tok.str; - elist->assignment = NULL; - scan3 (TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok); - if (tok.kind == TOK_EQUAL) - { - scan_num (&tok); - elist->assignment = tok.str; - scan2 (TOK_COMMA, TOK_RBRACE, &tok); - } - *tailp = elist; - tailp = &elist->next; - } - while (tok.kind != TOK_RBRACE); - *tailp = NULL; -} - -static void -def_const (definition * defp) -{ - token tok; - - defp->def_kind = DEF_CONST; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_EQUAL, &tok); - scan2 (TOK_IDENT, TOK_STRCONST, &tok); - defp->def.co = tok.str; -} - -static void -def_union (definition *defp) -{ - token tok; - declaration dec; - case_list *cases; -/* case_list *tcase; */ - case_list **tailp; -#if 0 - int flag; -#endif - - defp->def_kind = DEF_UNION; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_SWITCH, &tok); - scan (TOK_LPAREN, &tok); - get_declaration (&dec, DEF_UNION); - defp->def.un.enum_decl = dec; - tailp = &defp->def.un.cases; - scan (TOK_RPAREN, &tok); - scan (TOK_LBRACE, &tok); - scan (TOK_CASE, &tok); - while (tok.kind == TOK_CASE) - { - scan2 (TOK_IDENT, TOK_CHARCONST, &tok); - cases = ALLOC (case_list); - cases->case_name = tok.str; - scan (TOK_COLON, &tok); - /* now peek at next token */ -#if 0 - flag = 0; -#endif - if (peekscan (TOK_CASE, &tok)) - { - - do - { - scan2 (TOK_IDENT, TOK_CHARCONST, &tok); - cases->contflag = 1; /* continued case statement */ - *tailp = cases; - tailp = &cases->next; - cases = ALLOC (case_list); - cases->case_name = tok.str; - scan (TOK_COLON, &tok); - - } - while (peekscan (TOK_CASE, &tok)); - } -#if 0 - else if (flag) - { - - *tailp = cases; - tailp = &cases->next; - cases = ALLOC (case_list); - }; -#endif - - get_declaration (&dec, DEF_UNION); - cases->case_decl = dec; - cases->contflag = 0; /* no continued case statement */ - *tailp = cases; - tailp = &cases->next; - scan (TOK_SEMICOLON, &tok); - - scan3 (TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok); - } - *tailp = NULL; - if (tok.kind == TOK_DEFAULT) - { - scan (TOK_COLON, &tok); - get_declaration (&dec, DEF_UNION); - defp->def.un.default_decl = ALLOC (declaration); - *defp->def.un.default_decl = dec; - scan (TOK_SEMICOLON, &tok); - scan (TOK_RBRACE, &tok); - } - else - { - defp->def.un.default_decl = NULL; - } -} - -static const char *reserved_words[] = -{ - "array", - "bytes", - "destroy", - "free", - "getpos", - "inline", - "pointer", - "reference", - "setpos", - "sizeof", - "union", - "vector", - NULL -}; - -static const char *reserved_types[] = -{ - "opaque", - "string", - NULL -}; - -/* - * check that the given name is not one that would eventually result in - * xdr routines that would conflict with internal XDR routines. - */ -static void -check_type_name (const char *name, int new_type) -{ - int i; - char tmp[100]; - - for (i = 0; reserved_words[i] != NULL; i++) - { - if (strcmp (name, reserved_words[i]) == 0) - { - sprintf (tmp, - "illegal (reserved) name :\'%s\' in type definition", name); - error (tmp); - } - } - if (new_type) - { - for (i = 0; reserved_types[i] != NULL; i++) - { - if (strcmp (name, reserved_types[i]) == 0) - { - sprintf (tmp, - "illegal (reserved) name :\'%s\' in type definition", name); - error (tmp); - } - } - } -} - - - -static void -def_typedef (definition * defp) -{ - declaration dec; - - defp->def_kind = DEF_TYPEDEF; - get_declaration (&dec, DEF_TYPEDEF); - defp->def_name = dec.name; - check_type_name (dec.name, 1); - defp->def.ty.old_prefix = dec.prefix; - defp->def.ty.old_type = dec.type; - defp->def.ty.rel = dec.rel; - defp->def.ty.array_max = dec.array_max; -} - -static void -get_declaration (declaration * dec, defkind dkind) -{ - token tok; - - get_type (&dec->prefix, &dec->type, dkind); - dec->rel = REL_ALIAS; - if (streq (dec->type, "void")) - { - return; - } - - check_type_name (dec->type, 0); - - scan2 (TOK_STAR, TOK_IDENT, &tok); - if (tok.kind == TOK_STAR) - { - dec->rel = REL_POINTER; - scan (TOK_IDENT, &tok); - } - dec->name = tok.str; - if (peekscan (TOK_LBRACKET, &tok)) - { - if (dec->rel == REL_POINTER) - { - error ("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_VECTOR; - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RBRACKET, &tok); - } - else if (peekscan (TOK_LANGLE, &tok)) - { - if (dec->rel == REL_POINTER) - { - error ("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_ARRAY; - if (peekscan (TOK_RANGLE, &tok)) - { - dec->array_max = "~0"; /* unspecified size, use max */ - } - else - { - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RANGLE, &tok); - } - } - if (streq (dec->type, "opaque")) - { - if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) - { - error ("array declaration expected"); - } - } - else if (streq (dec->type, "string")) - { - if (dec->rel != REL_ARRAY) - { - error ("variable-length array declaration expected"); - } - } -} - -static void -get_prog_declaration (declaration * dec, defkind dkind, int num /* arg number */ ) -{ - token tok; - char name[MAXLINESIZE]; /* argument name */ - - if (dkind == DEF_PROGRAM) - { - peek (&tok); - if (tok.kind == TOK_RPAREN) - { /* no arguments */ - dec->rel = REL_ALIAS; - dec->type = "void"; - dec->prefix = NULL; - dec->name = NULL; - return; - } - } - get_type (&dec->prefix, &dec->type, dkind); - dec->rel = REL_ALIAS; - if (peekscan (TOK_IDENT, &tok)) /* optional name of argument */ - strcpy (name, tok.str); - else - sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */ - - dec->name = (char *) strdup (name); - - if (streq (dec->type, "void")) - { - return; - } - - if (streq (dec->type, "opaque")) - { - error ("opaque -- illegal argument type"); - } - if (peekscan (TOK_STAR, &tok)) - { - if (streq (dec->type, "string")) - { - error ("pointer to string not allowed in program arguments\n"); - } - dec->rel = REL_POINTER; - if (peekscan (TOK_IDENT, &tok)) /* optional name of argument */ - dec->name = strdup (tok.str); - } - if (peekscan (TOK_LANGLE, &tok)) - { - if (!streq (dec->type, "string")) - { - error ("arrays cannot be declared as arguments to procedures -- use typedef"); - } - dec->rel = REL_ARRAY; - if (peekscan (TOK_RANGLE, &tok)) - { - dec->array_max = "~0"; /* unspecified size, use max */ - } - else - { - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RANGLE, &tok); - } - } - if (streq (dec->type, "string")) - { - if (dec->rel != REL_ARRAY) - { /* .x specifies just string as - * type of argument - * - make it string<> - */ - dec->rel = REL_ARRAY; - dec->array_max = "~0"; /* unspecified size, use max */ - } - } -} - -static void -get_type (const char **prefixp, const char **typep, defkind dkind) -{ - token tok; - - *prefixp = NULL; - get_token (&tok); - switch (tok.kind) - { - case TOK_IDENT: - *typep = tok.str; - break; - case TOK_STRUCT: - case TOK_ENUM: - case TOK_UNION: - *prefixp = tok.str; - scan (TOK_IDENT, &tok); - *typep = tok.str; - break; - case TOK_UNSIGNED: - unsigned_dec (typep); - break; - case TOK_SHORT: - *typep = "short"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_LONG: - *typep = "long"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_HYPER: - *typep = "quad_t"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_VOID: - if (dkind != DEF_UNION && dkind != DEF_PROGRAM) - { - error ("voids allowed only inside union and program definitions with one argument"); - } - *typep = tok.str; - break; - case TOK_STRING: - case TOK_OPAQUE: - case TOK_CHAR: - case TOK_INT: - case TOK_FLOAT: - case TOK_DOUBLE: - case TOK_BOOL: - *typep = tok.str; - break; - default: - error ("expected type specifier"); - } -} - -static void -unsigned_dec (const char **typep) -{ - token tok; - - peek (&tok); - switch (tok.kind) - { - case TOK_CHAR: - get_token (&tok); - *typep = "u_char"; - break; - case TOK_SHORT: - get_token (&tok); - *typep = "u_short"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_LONG: - get_token (&tok); - *typep = "u_long"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_HYPER: - get_token (&tok); - *typep = "u_quad_t"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_INT: - get_token (&tok); - *typep = "u_int"; - break; - default: - *typep = "u_int"; - break; - } -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.h b/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.h deleted file mode 100644 index e2e2f1e..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_parse.h +++ /dev/null @@ -1,165 +0,0 @@ -/* @(#)rpc_parse.h 1.3 90/08/29 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_parse.h, Definitions for the RPCL parser - */ - -enum defkind { - DEF_CONST, - DEF_STRUCT, - DEF_UNION, - DEF_ENUM, - DEF_TYPEDEF, - DEF_PROGRAM -}; -typedef enum defkind defkind; - -typedef const char *const_def; - -enum relation { - REL_VECTOR, /* fixed length array */ - REL_ARRAY, /* variable length array */ - REL_POINTER, /* pointer */ - REL_ALIAS /* simple */ -}; -typedef enum relation relation; - -struct typedef_def { - const char *old_prefix; - const char *old_type; - relation rel; - const char *array_max; -}; -typedef struct typedef_def typedef_def; - -struct enumval_list { - const char *name; - const char *assignment; - struct enumval_list *next; -}; -typedef struct enumval_list enumval_list; - -struct enum_def { - enumval_list *vals; -}; -typedef struct enum_def enum_def; - -struct declaration { - const char *prefix; - const char *type; - const char *name; - relation rel; - const char *array_max; -}; -typedef struct declaration declaration; - -struct decl_list { - declaration decl; - struct decl_list *next; -}; -typedef struct decl_list decl_list; - -struct struct_def { - decl_list *decls; -}; -typedef struct struct_def struct_def; - -struct case_list { - const char *case_name; - int contflag; - declaration case_decl; - struct case_list *next; -}; -typedef struct case_list case_list; - -struct union_def { - declaration enum_decl; - case_list *cases; - declaration *default_decl; -}; -typedef struct union_def union_def; - -struct arg_list { - const char *argname; /* name of struct for arg*/ - decl_list *decls; -}; - -typedef struct arg_list arg_list; - -struct proc_list { - const char *proc_name; - const char *proc_num; - arg_list args; - int arg_num; - const char *res_type; - const char *res_prefix; - struct proc_list *next; -}; -typedef struct proc_list proc_list; - -struct version_list { - const char *vers_name; - const char *vers_num; - proc_list *procs; - struct version_list *next; -}; -typedef struct version_list version_list; - -struct program_def { - const char *prog_num; - version_list *versions; -}; -typedef struct program_def program_def; - -struct definition { - const char *def_name; - defkind def_kind; - union { - const_def co; - struct_def st; - union_def un; - enum_def en; - typedef_def ty; - program_def pr; - } def; -}; -typedef struct definition definition; - -definition *get_definition(void); - - -struct bas_type -{ - const char *name; - int length; - struct bas_type *next; -}; - -typedef struct bas_type bas_type; diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_sample.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_sample.c deleted file mode 100644 index e90b58c..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_sample.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * From: @(#)rpc_sample.c 1.1 90/08/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_sample.c, Sample client-server code outputter for the RPC protocol compiler - */ - -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - - -static const char RQSTP[] = "rqstp"; - -static void write_sample_client (const char *program_name, version_list * vp); -static void write_sample_server (definition * def); -static void return_type (proc_list * plist); - - -void -write_sample_svc (definition * def) -{ - - if (def->def_kind != DEF_PROGRAM) - return; - write_sample_server (def); -} - - -int -write_sample_clnt (definition * def) -{ - version_list *vp; - int count = 0; - - if (def->def_kind != DEF_PROGRAM) - return 0; - /* generate sample code for each version */ - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - write_sample_client (def->def_name, vp); - ++count; - } - return count; -} - - -static void -write_sample_client (const char *program_name, version_list * vp) -{ - proc_list *proc; - int i; - decl_list *l; - - f_print (fout, "\n\nvoid\n"); - pvname (program_name, vp->vers_num); - if (Cflag) - f_print (fout, "(char *host)\n{\n"); - else - f_print (fout, "(host)\nchar *host;\n{\n"); - f_print (fout, "\tCLIENT *clnt;\n"); - - i = 0; - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\t"); - ++i; - if (mtflag) - { - f_print (fout, "enum clnt_stat retval_%d;\n\t", i); - ptype (proc->res_prefix, proc->res_type, 1); - if (!streq (proc->res_type, "void")) - f_print (fout, "result_%d;\n", i); - else - fprintf (fout, "*result_%d;\n", i); - } - else - { - ptype (proc->res_prefix, proc->res_type, 1); - f_print (fout, " *result_%d;\n", i); - } - /* print out declarations for arguments */ - if (proc->arg_num < 2 && !newstyle) - { - f_print (fout, "\t"); - if (!streq (proc->args.decls->decl.type, "void")) - { - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - f_print (fout, " "); - } - else - f_print (fout, "char *"); /* cannot have "void" type */ - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - } - else if (!streq (proc->args.decls->decl.type, "void")) - { - for (l = proc->args.decls; l != NULL; l = l->next) - { - f_print (fout, "\t"); - ptype (l->decl.prefix, l->decl.type, 1); - if (strcmp (l->decl.type, "string") == 1) - f_print (fout, " "); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_%s;\n", l->decl.name); - } - } - } - - /* generate creation of client handle */ - f_print(fout, "\n#ifndef\tDEBUG\n"); - f_print (fout, "\tclnt = clnt_create (host, %s, %s, \"%s\");\n", - program_name, vp->vers_name, tirpcflag ? "netpath" : "udp"); - f_print (fout, "\tif (clnt == NULL) {\n"); - f_print (fout, "\t\tclnt_pcreateerror (host);\n"); - f_print (fout, "\t\texit (1);\n\t}\n"); - f_print(fout, "#endif\t/* DEBUG */\n\n"); - - /* generate calls to procedures */ - i = 0; - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - if (mtflag) - f_print(fout, "\tretval_%d = ",++i); - else - f_print (fout, "\tresult_%d = ", ++i); - pvname (proc->proc_name, vp->vers_num); - if (proc->arg_num < 2 && !newstyle) - { - f_print (fout, "("); - if (streq (proc->args.decls->decl.type, "void"))/* cast to void* */ - f_print (fout, "(void*)"); - f_print (fout, "&"); - pvname (proc->proc_name, vp->vers_num); - if (mtflag) - f_print(fout, "_arg, &result_%d, clnt);\n", i); - else - f_print (fout, "_arg, clnt);\n"); - } - else if (streq (proc->args.decls->decl.type, "void")) - { - if (mtflag) - f_print (fout, "(&result_%d, clnt);\n", i); - else - f_print (fout, "(clnt);\n"); - } - else - { - f_print (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_%s, ", l->decl.name); - } - if (mtflag) - f_print(fout, "&result_%d, ", i); - f_print (fout, "clnt);\n"); - } - if (mtflag) - { - f_print(fout, "\tif (retval_%d != RPC_SUCCESS) {\n", i); - } - else - { - f_print(fout, "\tif (result_%d == (", i); - ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*) NULL) {\n"); - } - f_print(fout, "\t\tclnt_perror (clnt, \"call failed\");\n"); - f_print(fout, "\t}\n"); - } - - f_print (fout, "#ifndef\tDEBUG\n"); - f_print (fout, "\tclnt_destroy (clnt);\n"); - f_print (fout, "#endif\t /* DEBUG */\n"); - f_print (fout, "}\n"); -} - -static void -write_sample_server (definition * def) -{ - version_list *vp; - proc_list *proc; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\n"); - if (!mtflag) - { - return_type (proc); - f_print (fout, "*\n"); - } - else - f_print (fout, "bool_t\n"); - if (Cflag || mtflag) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname(proc->proc_name, vp->vers_num); - printarglist(proc, "result", RQSTP, "struct svc_req *"); - f_print(fout, "{\n"); - if (!mtflag) - { - f_print(fout, "\tstatic "); - if(!streq(proc->res_type, "void")) - return_type(proc); - else - f_print(fout, "char *"); - /* cannot have void type */ - /* f_print(fout, " result;\n", proc->res_type); */ - f_print(fout, " result;\n"); - } - else - f_print(fout, "\tbool_t retval;\n"); - fprintf (fout, "\n\t/*\n\t * insert server code here\n\t */\n\n"); - - if (!mtflag) - { - if (!streq(proc->res_type, "void")) - f_print(fout, "\treturn &result;\n}\n"); - else /* cast back to void * */ - f_print(fout, "\treturn (void *) &result;\n}\n"); - } - else - f_print(fout, "\treturn retval;\n}\n"); - } - - /* put in sample freeing routine */ - if (mtflag) - { - f_print(fout, "\nint\n"); - pvname(def->def_name, vp->vers_num); - if (Cflag) - f_print(fout,"_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)\n"); - else - { - f_print(fout,"_freeresult (transp, xdr_result, result)\n"); - f_print(fout,"\tSVCXPRT *transp;\n"); - f_print(fout,"\txdrproc_t xdr_result;\n"); - f_print(fout,"\tcaddr_t result;\n"); - } - f_print(fout, "{\n"); - f_print(fout, "\txdr_free (xdr_result, result);\n"); - f_print(fout, - "\n\t/*\n\t * Insert additional freeing code here, if needed\n\t */\n"); - f_print(fout, "\n\treturn 1;\n}\n"); - } - } -} - - - -static void -return_type (proc_list * plist) -{ - ptype (plist->res_prefix, plist->res_type, 1); -} - -void -add_sample_msg (void) -{ - f_print (fout, "/*\n"); - f_print (fout, " * This is sample code generated by rpcgen.\n"); - f_print (fout, " * These are only templates and you can use them\n"); - f_print (fout, " * as a guideline for developing your own functions.\n"); - f_print (fout, " */\n\n"); -} - -void -write_sample_clnt_main (void) -{ - list *l; - definition *def; - version_list *vp; - - f_print (fout, "\n\n"); - if (Cflag) - f_print (fout, "int\nmain (int argc, char *argv[])\n{\n"); - else - f_print (fout, "int\nmain (argc, argv)\nint argc;\nchar *argv[];\n{\n"); - - f_print (fout, "\tchar *host;"); - f_print (fout, "\n\n\tif (argc < 2) {"); - f_print (fout, "\n\t\tprintf (\"usage: %%s server_host\\n\", argv[0]);\n"); - f_print (fout, "\t\texit (1);\n\t}"); - f_print (fout, "\n\thost = argv[1];\n"); - - for (l = defined; l != NULL; l = l->next) - { - def = l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\t"); - pvname (def->def_name, vp->vers_num); - f_print (fout, " (host);\n"); - } - } - f_print (fout, "exit (0);\n}\n"); -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.c deleted file mode 100644 index 7de6112..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * From: @(#)rpc_scan.c 1.11 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_scan.c, Scanner for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" -#include "nls.h" - -#ifndef _ -#define _(String) gettext (String) -#endif - -#define startcomment(where) (where[0] == '/' && where[1] == '*') -#define endcomment(where) (where[-1] == '*' && where[0] == '/') - -static int pushed = 0; /* is a token pushed */ -static token lasttok; /* last token, if pushed */ - -static void unget_token (token * tokp); -static void findstrconst (const char **str, const char **val); -static void findchrconst (const char **str, const char **val); -static void findconst (const char **str, const char **val); -static void findkind (const char **mark, token * tokp); -static int cppline (const char *line); -static int directive (const char *line); -static void printdirective (const char *line); -static void docppline (const char *line, int *lineno, const char **fname); - -/* - * scan expecting 1 given token - */ -void -scan (tok_kind expect, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect) - expected1 (expect); -} - -/* - * scan expecting any of the 2 given tokens - */ -void -scan2 (tok_kind expect1, tok_kind expect2, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect1 && tokp->kind != expect2) - { - expected2 (expect1, expect2); - } -} - -/* - * scan expecting any of the 3 given token - */ -void -scan3 (tok_kind expect1, tok_kind expect2, tok_kind expect3, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect1 && tokp->kind != expect2 - && tokp->kind != expect3) - { - expected3 (expect1, expect2, expect3); - } -} - -/* - * scan expecting a constant, possibly symbolic - */ -void -scan_num (token *tokp) -{ - get_token (tokp); - switch (tokp->kind) - { - case TOK_IDENT: - break; - default: - error (_("constant or identifier expected")); - } -} - -/* - * Peek at the next token - */ -void -peek (token *tokp) -{ - get_token (tokp); - unget_token (tokp); -} - -/* - * Peek at the next token and scan it if it matches what you expect - */ -int -peekscan (tok_kind expect, token *tokp) -{ - peek (tokp); - if (tokp->kind == expect) - { - get_token (tokp); - return 1; - } - return 0; -} - -/* - * Get the next token, printing out any directive that are encountered. - */ -void -get_token (token *tokp) -{ - int commenting; - - if (pushed) - { - pushed = 0; - *tokp = lasttok; - return; - } - commenting = 0; - for (;;) - { - if (*where == 0) - { - for (;;) - { - if (!fgets (curline, MAXLINESIZE, fin)) - { - tokp->kind = TOK_EOF; - *curline = 0; - where = curline; - return; - } - linenum++; - if (commenting) - { - break; - } - else if (cppline (curline)) - { - docppline (curline, &linenum, - &infilename); - } - else if (directive (curline)) - { - printdirective (curline); - } - else - { - break; - } - } - where = curline; - } - else if (isspace (*where)) - { - while (isspace (*where)) - { - where++; /* eat */ - } - } - else if (commenting) - { - for (where++; *where; where++) - { - if (endcomment (where)) - { - where++; - commenting--; - break; - } - } - } - else if (startcomment (where)) - { - where += 2; - commenting++; - } - else - { - break; - } - } - - /* - * 'where' is not whitespace, comment or directive Must be a token! - */ - switch (*where) - { - case ':': - tokp->kind = TOK_COLON; - where++; - break; - case ';': - tokp->kind = TOK_SEMICOLON; - where++; - break; - case ',': - tokp->kind = TOK_COMMA; - where++; - break; - case '=': - tokp->kind = TOK_EQUAL; - where++; - break; - case '*': - tokp->kind = TOK_STAR; - where++; - break; - case '[': - tokp->kind = TOK_LBRACKET; - where++; - break; - case ']': - tokp->kind = TOK_RBRACKET; - where++; - break; - case '{': - tokp->kind = TOK_LBRACE; - where++; - break; - case '}': - tokp->kind = TOK_RBRACE; - where++; - break; - case '(': - tokp->kind = TOK_LPAREN; - where++; - break; - case ')': - tokp->kind = TOK_RPAREN; - where++; - break; - case '<': - tokp->kind = TOK_LANGLE; - where++; - break; - case '>': - tokp->kind = TOK_RANGLE; - where++; - break; - - case '"': - tokp->kind = TOK_STRCONST; - findstrconst (&where, &tokp->str); - break; - case '\'': - tokp->kind = TOK_CHARCONST; - findchrconst (&where, &tokp->str); - break; - - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - tokp->kind = TOK_IDENT; - findconst (&where, &tokp->str); - break; - - default: - if (!(isalpha (*where) || *where == '_')) - { - char buf[100]; - char *p; - - s_print (buf, _("illegal character in file: ")); - p = buf + strlen (buf); - if (isprint (*where)) - { - s_print (p, "%c", *where); - } - else - { - s_print (p, "%d", *where); - } - error (buf); - } - findkind (&where, tokp); - break; - } -} - -static void -unget_token (token * tokp) -{ - lasttok = *tokp; - pushed = 1; -} - -static void -findstrconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - do - { - p++; - } - while (*p && *p != '"'); - if (*p == 0) - { - error (_("unterminated string constant")); - } - p++; - size = p - *str; - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static void -findchrconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - do - { - p++; - } - while (*p && *p != '\''); - if (*p == 0) - { - error (_("unterminated string constant")); - } - p++; - size = p - *str; - if (size != 3) - { - error (_("empty char string")); - } - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static void -findconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - if (*p == '0' && *(p + 1) == 'x') - { - p++; - do - { - p++; - } - while (isxdigit (*p)); - } - else - { - do - { - p++; - } - while (isdigit (*p)); - } - size = p - *str; - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static const token symbols[] = -{ - {TOK_CONST, "const"}, - {TOK_UNION, "union"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_STRUCT, "struct"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_ENUM, "enum"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_CHAR, "char"}, - {TOK_INT, "int"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_HYPER, "hyper"}, - {TOK_FLOAT, "float"}, - {TOK_DOUBLE, "double"}, - {TOK_STRING, "string"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"}, -}; - -static void -findkind (const char **mark, token *tokp) -{ - int len; - const token *s; - const char *str; - char *tmp; - - str = *mark; - for (s = symbols; s->kind != TOK_EOF; s++) - { - len = strlen (s->str); - if (strncmp (str, s->str, len) == 0) - { - if (!isalnum (str[len]) && str[len] != '_') - { - tokp->kind = s->kind; - tokp->str = s->str; - *mark = str + len; - return; - } - } - } - tokp->kind = TOK_IDENT; - for (len = 0; isalnum (str[len]) || str[len] == '_'; len++); - tmp = alloc (len + 1); - strncpy (tmp, str, len); - tmp[len] = 0; - tokp->str = tmp; - *mark = str + len; -} - -static int -cppline (const char *line) -{ - return line == curline && *line == '#'; -} - -static int -directive (const char *line) -{ - return line == curline && *line == '%'; -} - -static void -printdirective (const char *line) -{ - f_print (fout, "%s", line + 1); -} - -static void -docppline (const char *line, int *lineno, const char **fname) -{ - char *file; - int num; - char *p; - - line++; - while (isspace (*line)) - { - line++; - } - num = atoi (line); - while (isdigit (*line)) - { - line++; - } - while (isspace (*line)) - { - line++; - } - if (*line != '"') - { - error (_("preprocessor error")); - } - line++; - p = file = alloc (strlen (line) + 1); - while (*line && *line != '"') - { - *p++ = *line++; - } - if (*line == 0) - { - error (_("preprocessor error")); - } - *p = 0; - if (*file == 0) - { - free (file); - *fname = NULL; - } - else - { - *fname = file; - } - *lineno = num - 1; -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.h b/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.h deleted file mode 100644 index 9786a51..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_scan.h +++ /dev/null @@ -1,104 +0,0 @@ -/* @(#)rpc_scan.h 1.3 90/08/29 */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_scan.h, Definitions for the RPCL scanner - */ - -/* - * kinds of tokens - */ -enum tok_kind { - TOK_IDENT, - TOK_CHARCONST, - TOK_STRCONST, - TOK_LPAREN, - TOK_RPAREN, - TOK_LBRACE, - TOK_RBRACE, - TOK_LBRACKET, - TOK_RBRACKET, - TOK_LANGLE, - TOK_RANGLE, - TOK_STAR, - TOK_COMMA, - TOK_EQUAL, - TOK_COLON, - TOK_SEMICOLON, - TOK_CONST, - TOK_STRUCT, - TOK_UNION, - TOK_SWITCH, - TOK_CASE, - TOK_DEFAULT, - TOK_ENUM, - TOK_TYPEDEF, - TOK_INT, - TOK_SHORT, - TOK_LONG, - TOK_HYPER, - TOK_UNSIGNED, - TOK_FLOAT, - TOK_DOUBLE, - TOK_OPAQUE, - TOK_CHAR, - TOK_STRING, - TOK_BOOL, - TOK_VOID, - TOK_PROGRAM, - TOK_VERSION, - TOK_EOF -}; -typedef enum tok_kind tok_kind; - -/* - * a token - */ -struct token { - tok_kind kind; - const char *str; -}; -typedef struct token token; - - -/* - * routine interface - */ -void scan(tok_kind expect, token *tokp); -void scan2(tok_kind expect1, tok_kind expect2, token *tokp); -void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp); -void scan_num(token *tokp); -void peek(token *tokp); -int peekscan(tok_kind expect, token *tokp); -void get_token(token *tokp); -void expected1(tok_kind exp1) __attribute__ ((noreturn)); -void expected2(tok_kind exp1, tok_kind exp2) __attribute__ ((noreturn)); -void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3) - __attribute__ ((noreturn)); diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_svcout.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_svcout.c deleted file mode 100644 index 4f12a81..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_svcout.c +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * From: @(#)rpc_svcout.c 1.29 89/03/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static const char RQSTP[] = "rqstp"; -static const char TRANSP[] = "transp"; -static const char ARG[] = "argument"; -static const char RESULT[] = "result"; -static const char ROUTINE[] = "local"; -static char RETVAL[] = "retval"; - -char _errbuf[256]; /* For all messages */ - -static void internal_proctype (const proc_list * plist); -static void p_xdrfunc (const char *rname, const char *typename); -static void write_real_program (const definition * def); -static void write_program (const definition * def, const char *storage); -static void printerr (const char *err, const char *transp); -static void printif (const char *proc, const char *transp, const char *arg); -static void write_inetmost (const char *infile); -static void print_return (const char *space); -static void print_pmapunset (const char *space); -static void print_err_message (const char *space); -static void write_timeout_func (void); -static void write_pm_most (const char *infile, int netflag); -static void write_rpc_svc_fg (const char *infile, const char *sp); -static void open_log_file (const char *infile, const char *sp); - -static void -p_xdrfunc (const char *rname, const char *typename) -{ - if (Cflag) - f_print (fout, "\t\t_xdr_%s = (xdrproc_t) xdr_%s;\n", rname, - stringfix (typename)); - else - f_print (fout, "\t\t_xdr_%s = xdr_%s;\n", rname, stringfix (typename)); -} - -void -internal_proctype (const proc_list * plist) -{ - f_print (fout, "static "); - ptype (plist->res_prefix, plist->res_type, 1); - f_print (fout, "*"); -} - - -/* - * write most of the service, that is, everything but the registrations. - */ -void -write_most (const char *infile /* our name */ , int netflag, int nomain) -{ - if (inetdflag || pmflag) - { - const char *var_type; - /* WHY? */ - var_type = (nomain ? "extern" : ""); - f_print (fout, "%s int _rpcpmstart;", var_type); - f_print (fout, "\t\t/* Started by a port monitor ? */\n"); - if (!tirpcflag) - { - f_print (fout, "%s int _rpcfdtype;", var_type); - f_print (fout, "\t\t/* Whether Stream or Datagram ? */\n"); - } - if (timerflag) - { -#if 0 - f_print (fout, "%s int _rpcsvcdirty;", var_type); - f_print (fout, "\t/* Still serving ? */\n"); -#else - f_print(fout, " /* States a server can be in wrt request */\n\n"); - f_print(fout, "#define\t_IDLE 0\n"); - f_print(fout, "#define\t_SERVED 1\n"); - f_print(fout, "#define\t_SERVING 2\n\n"); - f_print(fout, "static int _rpcsvcstate = _IDLE;"); - f_print(fout, "\t /* Set when a request is serviced */\n"); - - if (mtflag) - { - f_print (fout, "mutex_t _svcstate_lock;"); - f_print (fout, - "\t\t\t/* Mutex lock for variable_rpcsvcstate */\n"); - } -#endif - } - write_svc_aux (nomain); - } - /* write out dispatcher and stubs */ - write_programs (nomain ? NULL : "static"); - - if (nomain) - return; - - if (Cflag) - f_print (fout, "\nint\nmain (int argc, char **argv)\n"); - else - { - f_print (fout, "\nint\nmain (argc, argv)\n"); - f_print (fout, "\tint argc;\n"); - f_print (fout, "\tchar **argv;\n"); - } - f_print (fout, "{\n"); - if (inetdflag) - { - write_inetmost (infile); /* Includes call to write_rpc_svc_fg() */ - } - else - { - if (tirpcflag) - { - if (netflag) - { - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\tstruct netconfig *nconf = NULL;\n"); - } - f_print (fout, "\tpid_t pid;\n"); - f_print (fout, "\tint i;\n"); - f_print (fout, "\tchar mname[FMNAMESZ + 1];\n\n"); - - if (mtflag & timerflag) - f_print (fout, - "\tmutex_init (&_svcstate_lock, USYNC_THREAD, NULL);\n"); - - write_pm_most (infile, netflag); - f_print (fout, "\telse {\n"); - write_rpc_svc_fg (infile, "\t\t"); - f_print (fout, "\t}\n"); - } - else - { - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\n"); - print_pmapunset ("\t"); - } - } - - if (logflag && !inetdflag) - { - open_log_file (infile, "\t"); - } -} - -/* - * write a registration for the given transport - */ -void -write_netid_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - const char *sp; - char tmpbuf[32]; - - sp = ""; - f_print (fout, "\n"); - f_print (fout, "%s\tnconf = getnetconfigent (\"%s\");\n", sp, transp); - f_print (fout, "%s\tif (nconf == NULL) {\n", sp); - (void) sprintf (_errbuf, "cannot find %s netid.", transp); - sprintf (tmpbuf, "%s\t\t", sp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - f_print (fout, "%s\t%s = svc_tli_create (RPC_ANYFD, nconf, 0, 0, 0);\n", - sp, TRANSP /*, transp *//* ?!?... */ ); - f_print (fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); - sprintf (_errbuf, "cannot create %s service.", transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "%s\t(void) rpcb_unset (%s, %s, nconf);\n", - sp, def->def_name, vp->vers_name); - f_print (fout, "%s\tif (!svc_reg (%s, %s, %s, ", - sp, TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", nconf)) {\n"); - (void) sprintf (_errbuf, "unable to register (%s, %s, %s).", - def->def_name, vp->vers_name, transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - } - } - f_print (fout, "%s\tfreenetconfigent (nconf);\n", sp); -} - -/* - * write a registration for the given transport for TLI - */ -void -write_nettype_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\tif (!svc_create ("); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", %s, %s, \"%s\")) {\n ", - def->def_name, vp->vers_name, transp); - (void) sprintf (_errbuf, - "unable to create (%s, %s) for %s.", - def->def_name, vp->vers_name, transp); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - } - } -} - -/* - * write the rest of the service - */ -void -write_rest (void) -{ - f_print (fout, "\n"); - if (inetdflag) - { - f_print (fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP); - (void) sprintf (_errbuf, "could not create a handle"); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - if (timerflag) - { - f_print (fout, "\tif (_rpcpmstart) {\n"); - f_print (fout, - "\t\t(void) signal (SIGALRM, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\t\t(void) alarm (_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "\t}\n"); - } - } - f_print (fout, "\tsvc_run ();\n"); - (void) sprintf (_errbuf, "svc_run returned"); - print_err_message ("\t"); - f_print (fout, "\texit (1);\n"); - f_print (fout, "\t/* NOTREACHED */\n"); - f_print (fout, "}\n"); -} - -void -write_programs (const char *storage) -{ - list *l; - definition *def; - - /* write out stubs for procedure definitions */ - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_real_program (def); - } - } - - /* write out dispatcher for each program */ - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_program (def, storage); - } - } -} - -/* write out definition of internal function (e.g. _printmsg_1(...)) - which calls server's defintion of actual function (e.g. printmsg_1(...)). - Unpacks single user argument of printmsg_1 to call-by-value format - expected by printmsg_1. */ -static void -write_real_program (const definition * def) -{ - version_list *vp; - proc_list *proc; - decl_list *l; - - if (!newstyle) - return; /* not needed for old style */ - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - fprintf (fout, "\n"); - if (!mtflag) - internal_proctype (proc); - else - f_print (fout, "int"); - f_print (fout, "\n_"); - pvname (proc->proc_name, vp->vers_num); - if (Cflag) - { - f_print (fout, " ("); - /* arg name */ - if (proc->arg_num > 1) - f_print (fout, "%s", proc->args.argname); - else - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - if (mtflag) - { - f_print(fout, " *argp, void *%s, struct svc_req *%s)\n", - RESULT, RQSTP); - } - else - f_print (fout, " *argp, struct svc_req *%s)\n", - RQSTP); - } - else - { - if (mtflag) - f_print(fout, " (argp, %s, %s)\n", RESULT, RQSTP); - else - f_print (fout, " (argp, %s)\n", RQSTP); - /* arg name */ - if (proc->arg_num > 1) - f_print (fout, "\t%s *argp;\n", proc->args.argname); - else - { - f_print (fout, "\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - f_print (fout, " *argp;\n"); - } - f_print (fout, " struct svc_req *%s;\n", RQSTP); - } - - f_print (fout, "{\n"); - f_print (fout, "\treturn ("); - if (Cflag || mtflag) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "("); - if (proc->arg_num < 2) - { /* single argument */ - if (!streq (proc->args.decls->decl.type, "void")) - f_print (fout, "*argp, "); /* non-void */ - } - else - { - for (l = proc->args.decls; l != NULL; l = l->next) - f_print (fout, "argp->%s, ", l->decl.name); - } - if (mtflag) - f_print (fout, "%s, ", RESULT); - f_print (fout, "%s));\n}\n", RQSTP); - } - } -} - -static void -write_program (const definition * def, const char *storage) -{ - version_list *vp; - proc_list *proc; - int filled; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\n"); - if (storage != NULL) - { - f_print (fout, "%s ", storage); - } - f_print (fout, "void\n"); - pvname (def->def_name, vp->vers_num); - - if (Cflag) - { - f_print (fout, "(struct svc_req *%s, ", RQSTP); - f_print (fout, "register SVCXPRT *%s)\n", TRANSP); - } - else - { - f_print (fout, "(%s, %s)\n", RQSTP, TRANSP); - f_print (fout, " struct svc_req *%s;\n", RQSTP); - f_print (fout, " register SVCXPRT *%s;\n", TRANSP); - } - - f_print (fout, "{\n"); - - filled = 0; - f_print (fout, "\tunion {\n"); - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - if (proc->arg_num < 2) - { /* single argument */ - if (streq (proc->args.decls->decl.type, - "void")) - { - continue; - } - filled = 1; - f_print (fout, "\t\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - - } - else - { - filled = 1; - f_print (fout, "\t\t%s", proc->args.argname); - f_print (fout, " "); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - } - } - if (!filled) - { - f_print (fout, "\t\tint fill;\n"); - } - f_print (fout, "\t} %s;\n", ARG); - if (mtflag) - { - f_print(fout, "\tunion {\n"); - for (proc = vp->procs; proc != NULL; proc = proc->next) - if (!streq (proc->res_type, "void")) - { - f_print(fout, "\t\t"); - ptype(proc->res_prefix, proc->res_type, 0); - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_res;\n"); - } - f_print(fout, "\t} %s;\n", RESULT); - f_print(fout, "\tbool_t %s;\n", RETVAL); - - } else - f_print (fout, "\tchar *%s;\n", RESULT); - - if (Cflag) - { - f_print (fout, "\txdrproc_t _xdr_%s, _xdr_%s;\n", ARG, RESULT); - if (mtflag) - f_print(fout, - "\tbool_t (*%s)(char *, void *, struct svc_req *);\n", - ROUTINE); - else - f_print (fout, "\tchar *(*%s)(char *, struct svc_req *);\n", - ROUTINE); - } - else - { - f_print (fout, "\tbool_t (*_xdr_%s)(), (*_xdr_%s)();\n", ARG, RESULT); - if (mtflag) - f_print(fout, "\tbool_t (*%s)();\n", ROUTINE); - else - f_print (fout, "\tchar *(*%s)();\n", ROUTINE); - } - f_print (fout, "\n"); - - if (timerflag) -#if 0 - f_print (fout, "\t_rpcsvcdirty = 1;\n"); -#else - { - if (mtflag) - f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); - f_print(fout, "\t_rpcsvcstate = _SERVING;\n"); - if (mtflag) - f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); - } -#endif - - f_print (fout, "\tswitch (%s->rq_proc) {\n", RQSTP); - if (!nullproc (vp->procs)) - { - f_print (fout, "\tcase NULLPROC:\n"); - f_print (fout, - "\t\t(void) svc_sendreply (%s, (xdrproc_t) xdr_void, (char *)NULL);\n", - TRANSP); - print_return ("\t\t"); - f_print (fout, "\n"); - } - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\tcase %s:\n", proc->proc_name); - if (proc->arg_num < 2) - { /* single argument */ - p_xdrfunc (ARG, proc->args.decls->decl.type); - } - else - { - p_xdrfunc (ARG, proc->args.argname); - } - p_xdrfunc (RESULT, proc->res_type); - if (Cflag) - { - if (mtflag) - f_print(fout, - "\t\t%s = (bool_t (*) (char *, void *, struct svc_req *))", - ROUTINE); - else - f_print (fout, - "\t\t%s = (char *(*)(char *, struct svc_req *)) ", - ROUTINE); - } - else - if (mtflag) - f_print(fout, "\t\t%s = (bool_t (*)()) ", ROUTINE); - else - f_print (fout, "\t\t%s = (char *(*)()) ", ROUTINE); - - if (newstyle) - { /* new style: calls internal routine */ - f_print (fout, "_"); - } - if ((Cflag || mtflag) && !newstyle) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - f_print (fout, ";\n"); - f_print (fout, "\t\tbreak;\n\n"); - } - f_print (fout, "\tdefault:\n"); - printerr ("noproc", TRANSP); - print_return ("\t\t"); - f_print (fout, "\t}\n"); - - f_print (fout, "\tmemset ((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); - printif ("getargs", TRANSP, ARG); - printerr ("decode", TRANSP); - print_return ("\t\t"); - f_print (fout, "\t}\n"); - - if (!mtflag) - { - if (Cflag) - f_print (fout, "\t%s = (*%s)((char *)&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); - else - f_print (fout, "\t%s = (*%s)(&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); - } - else - if (Cflag) - f_print(fout, "\t%s = (bool_t) (*%s)((char *)&%s, (void *)&%s, %s);\n", - RETVAL, ROUTINE, ARG, RESULT, RQSTP); - else - f_print(fout, "\t%s = (bool_t) (*%s)(&%s, &%s, %s);\n", - RETVAL, ROUTINE, ARG, RESULT, RQSTP); - if (mtflag) - f_print(fout, - "\tif (%s > 0 && !svc_sendreply(%s, (xdrproc_t) _xdr_%s, (char *)&%s)) {\n", - RETVAL, TRANSP, RESULT, RESULT); - else - f_print(fout, - "\tif (%s != NULL && !svc_sendreply(%s, (xdrproc_t) _xdr_%s, %s)) {\n", - RESULT, TRANSP, RESULT, RESULT); - - printerr ("systemerr", TRANSP); - f_print (fout, "\t}\n"); - - printif ("freeargs", TRANSP, ARG); - - sprintf (_errbuf, "unable to free arguments"); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - /* print out free routine */ - if (mtflag) - { - f_print(fout,"\tif (!"); - pvname(def->def_name, vp->vers_num); - f_print(fout,"_freeresult (%s, _xdr_%s, (caddr_t) &%s))\n", - TRANSP, RESULT, RESULT); - (void) sprintf(_errbuf, "unable to free results"); - print_err_message("\t\t"); - f_print(fout, "\n"); - } - print_return ("\t"); - f_print (fout, "}\n"); - } -} - -static void -printerr (const char *err, const char *transp) -{ - f_print (fout, "\t\tsvcerr_%s (%s);\n", err, transp); -} - -static void -printif (const char *proc, const char *transp, const char *arg) -{ - f_print (fout, "\tif (!svc_%s (%s, (xdrproc_t) _xdr_%s, (caddr_t) &%s)) {\n", - proc, transp, arg, arg); -} - -int -nullproc (const proc_list * proc) -{ - for (; proc != NULL; proc = proc->next) - { - if (streq (proc->proc_num, "0")) - { - return 1; - } - } - return 0; -} - -static void -write_inetmost (const char *infile) -{ - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\tint sock;\n"); - f_print (fout, "\tint proto;\n"); - f_print (fout, "\tstruct sockaddr_in saddr;\n"); - f_print (fout, "\tint asize = sizeof (saddr);\n"); - f_print (fout, "\n"); - f_print (fout, - "\tif (getsockname (0, (struct sockaddr *)&saddr, &asize) == 0) {\n"); - f_print (fout, "\t\tint ssize = sizeof (int);\n\n"); - f_print (fout, "\t\tif (saddr.sin_family != AF_INET)\n"); - f_print (fout, "\t\t\texit (1);\n"); - f_print (fout, "\t\tif (getsockopt (0, SOL_SOCKET, SO_TYPE,\n"); - f_print (fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n"); - f_print (fout, "\t\t\texit (1);\n"); - f_print (fout, "\t\tsock = 0;\n"); - f_print (fout, "\t\t_rpcpmstart = 1;\n"); - f_print (fout, "\t\tproto = 0;\n"); - open_log_file (infile, "\t\t"); - f_print (fout, "\t} else {\n"); - write_rpc_svc_fg (infile, "\t\t"); - f_print (fout, "\t\tsock = RPC_ANYSOCK;\n"); - print_pmapunset ("\t\t"); - f_print (fout, "\t}\n"); -} - -static void -print_return (const char *space) -{ - if (exitnow) - f_print (fout, "%sexit (0);\n", space); - else - { - if (timerflag) - { -#if 0 - f_print (fout, "%s_rpcsvcdirty = 0;\n", space); -#else - if (mtflag) - f_print(fout, "%smutex_lock(&_svcstate_lock);\n", space); - f_print(fout, "%s_rpcsvcstate = _SERVED;\n", space); - if (mtflag) - f_print(fout, "%smutex_unlock(&_svcstate_lock);\n", space); -#endif - } - f_print (fout, "%sreturn;\n", space); - } -} - -static void -print_pmapunset (const char *space) -{ - list *l; - definition *def; - version_list *vp; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - for (vp = def->def.pr.versions; vp != NULL; - vp = vp->next) - { - f_print (fout, "%spmap_unset (%s, %s);\n", - space, def->def_name, vp->vers_name); - } - } - } -} - -static void -print_err_message (const char *space) -{ - if (logflag) - f_print (fout, "%ssyslog (LOG_ERR, \"%%s\", \"%s\");\n", space, _errbuf); - else if (inetdflag || pmflag) - f_print (fout, "%s_msgout (\"%s\");\n", space, _errbuf); - else - f_print (fout, "%sfprintf (stderr, \"%%s\", \"%s\");\n", space, _errbuf); -} - -/* - * Write the server auxiliary function ( _msgout, timeout) - */ -void -write_svc_aux (int nomain) -{ - if (!logflag) - write_msg_out (); - if (!nomain) - write_timeout_func (); -} - -/* - * Write the _msgout function - */ - -void -write_msg_out (void) -{ - f_print (fout, "\n"); - f_print (fout, "static\n"); - if (!Cflag) - { - f_print (fout, "void _msgout (msg)\n"); - f_print (fout, "\tchar *msg;\n"); - } - else - { - f_print (fout, "void _msgout (char* msg)\n"); - } - f_print (fout, "{\n"); - f_print (fout, "#ifdef RPC_SVC_FG\n"); - if (inetdflag || pmflag) - f_print (fout, "\tif (_rpcpmstart)\n"); - f_print (fout, "\t\tsyslog (LOG_ERR, \"%%s\", msg);\n"); - f_print (fout, "\telse\n"); - f_print (fout, "\t\tfprintf (stderr, \"%%s\\n\", msg);\n"); - f_print (fout, "#else\n"); - f_print (fout, "\tsyslog (LOG_ERR, \"%%s\", msg);\n"); - f_print (fout, "#endif\n"); - f_print (fout, "}\n"); -} - -/* - * Write the timeout function - */ -static void -write_timeout_func (void) -{ - if (!timerflag) - return; - f_print (fout, "\n"); - f_print (fout, "static void\n"); - if (Cflag) - f_print (fout, "closedown (int sig)\n"); - else - f_print (fout, "closedown (sig)\n\tint sig;\n"); - f_print (fout, "{\n"); - -#if 0 - f_print (fout, "\t(void) signal (sig, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); -#endif - if (mtflag) - f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); -#if 0 - f_print (fout, "\tif (_rpcsvcdirty == 0) {\n"); -#else - f_print(fout, "\tif (_rpcsvcstate == _IDLE) {\n"); -#endif - f_print (fout, "\t\textern fd_set svc_fdset;\n"); - f_print (fout, "\t\tstatic int size;\n"); - f_print (fout, "\t\tint i, openfd;\n"); - if (tirpcflag && pmflag) - { - f_print (fout, "\t\tstruct t_info tinfo;\n\n"); - f_print (fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n"); - } - else - { - f_print (fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n"); - } - f_print (fout, "\t\t\texit (0);\n"); - f_print (fout, "\t\tif (size == 0) {\n"); - if (tirpcflag) - { - f_print (fout, "\t\t\tstruct rlimit rl;\n\n"); - f_print (fout, "\t\t\trl.rlim_max = 0;\n"); - f_print (fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n"); - f_print (fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n"); - if (mtflag) - f_print(fout, "\t\t\t\tmutex_unlock(&_svcstate_lock);\n"); - f_print (fout, "\t\t\t\treturn;\n\t\t\t}\n"); - } - else - { - f_print (fout, "\t\t\tsize = getdtablesize();\n"); - } - f_print (fout, "\t\t}\n"); - f_print (fout, "\t\tfor (i = 0, openfd = 0; i < size && openfd < 2; i++)\n"); - f_print (fout, "\t\t\tif (FD_ISSET(i, &svc_fdset))\n"); - f_print (fout, "\t\t\t\topenfd++;\n"); - f_print (fout, "\t\tif (openfd <= 1)\n"); - f_print (fout, "\t\t\texit (0);\n"); - f_print (fout, "\t}\n"); - f_print(fout, "\tif (_rpcsvcstate == _SERVED)\n"); - f_print(fout, "\t\t_rpcsvcstate = _IDLE;\n\n"); - if (mtflag) - f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); - f_print(fout, "\t(void) signal(SIGALRM, %s closedown);\n", - Cflag? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\talarm (_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "}\n"); -} - -/* - * Write the most of port monitor support - */ -static void -write_pm_most (const char *infile, int netflag) -{ - list *l; - definition *def; - version_list *vp; - - f_print (fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n"); - f_print (fout, "\t\t(!strcmp(mname, \"sockmod\") ||"); - f_print (fout, " !strcmp(mname, \"timod\"))) {\n"); - f_print (fout, "\t\tchar *netid;\n"); - if (!netflag) - { /* Not included by -n option */ - f_print (fout, "\t\tstruct netconfig *nconf = NULL;\n"); - f_print (fout, "\t\tSVCXPRT *%s;\n", TRANSP); - } - if (timerflag) - f_print (fout, "\t\tint pmclose;\n"); -/* not necessary, defined in /usr/include/stdlib */ -/* f_print(fout, "\t\textern char *getenv();\n"); */ - f_print (fout, "\n"); - f_print (fout, "\t\t_rpcpmstart = 1;\n"); - if (logflag) - open_log_file (infile, "\t\t"); - f_print (fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n"); - sprintf (_errbuf, "cannot get transport name"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n"); - sprintf (_errbuf, "cannot get transport info"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t}\n"); - /* - * A kludgy support for inetd services. Inetd only works with - * sockmod, and RPC works only with timod, hence all this jugglery - */ - f_print (fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n"); - f_print (fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n"); - sprintf (_errbuf, "could not get the right module"); - print_err_message ("\t\t\t\t"); - f_print (fout, "\t\t\t\texit(1);\n"); - f_print (fout, "\t\t\t}\n"); - f_print (fout, "\t\t}\n"); - if (timerflag) - f_print (fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n"); - f_print (fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n", - TRANSP); - sprintf (_errbuf, "cannot create server handle"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t\texit(1);\n"); - f_print (fout, "\t\t}\n"); - f_print (fout, "\t\tif (nconf)\n"); - f_print (fout, "\t\t\tfreenetconfigent(nconf);\n"); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, - "\t\tif (!svc_reg(%s, %s, %s, ", - TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", 0)) {\n"); - (void) sprintf (_errbuf, "unable to register (%s, %s).", - def->def_name, vp->vers_name); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t\texit(1);\n"); - f_print (fout, "\t\t}\n"); - } - } - if (timerflag) - { - f_print (fout, "\t\tif (pmclose) {\n"); - f_print (fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "\t\t}\n"); - } - f_print (fout, "\t\tsvc_run();\n"); - f_print (fout, "\t\texit(1);\n"); - f_print (fout, "\t\t/* NOTREACHED */\n"); - f_print (fout, "\t}\n"); -} - -/* - * Support for backgrounding the server if self started. - */ -static void -write_rpc_svc_fg (const char *infile, const char *sp) -{ - f_print (fout, "#ifndef RPC_SVC_FG\n"); - f_print (fout, "%sint size;\n", sp); - if (tirpcflag) - f_print (fout, "%sstruct rlimit rl;\n", sp); - if (inetdflag) - f_print (fout, "%sint pid, i;\n\n", sp); - f_print (fout, "%spid = fork();\n", sp); - f_print (fout, "%sif (pid < 0) {\n", sp); - f_print (fout, "%s\tperror(\"cannot fork\");\n", sp); - f_print (fout, "%s\texit(1);\n", sp); - f_print (fout, "%s}\n", sp); - f_print (fout, "%sif (pid)\n", sp); - f_print (fout, "%s\texit(0);\n", sp); - /* get number of file descriptors */ - if (tirpcflag) - { - f_print (fout, "%srl.rlim_max = 0;\n", sp); - f_print (fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp); - f_print (fout, "%sif ((size = rl.rlim_max) == 0)\n", sp); - f_print (fout, "%s\texit(1);\n", sp); - } - else - { - f_print (fout, "%ssize = getdtablesize();\n", sp); - } - - f_print (fout, "%sfor (i = 0; i < size; i++)\n", sp); - f_print (fout, "%s\t(void) close(i);\n", sp); - /* Redirect stderr and stdout to console */ - f_print (fout, "%si = open(\"/dev/console\", 2);\n", sp); - f_print (fout, "%s(void) dup2(i, 1);\n", sp); - f_print (fout, "%s(void) dup2(i, 2);\n", sp); - /* This removes control of the controlling terminal */ - if (tirpcflag) - f_print (fout, "%ssetsid();\n", sp); - else - { - f_print (fout, "%si = open(\"/dev/tty\", 2);\n", sp); - f_print (fout, "%sif (i >= 0) {\n", sp); - f_print (fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);; - f_print (fout, "%s\t(void) close(i);\n", sp); - f_print (fout, "%s}\n", sp); - } - if (!logflag) - open_log_file (infile, sp); - f_print (fout, "#endif\n"); - if (logflag) - open_log_file (infile, sp); -} - -static void -open_log_file (const char *infile, const char *sp) -{ - char *s; - - s = strrchr (infile, '.'); - if (s) - *s = '\0'; - f_print (fout, "%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile); - if (s) - *s = '.'; -} - -/* - * write a registration for the given transport for Inetd - */ -void -write_inetd_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - const char *sp; - int isudp; - char tmpbuf[32]; - - if (inetdflag) - sp = "\t"; - else - sp = ""; - if (streq (transp, "udp") || streq (transp, "udp6")) - isudp = 1; - else - isudp = 0; - f_print (fout, "\n"); - if (inetdflag) - { - f_print (fout, "\tif ((_rpcfdtype == 0) || (_rpcfdtype == %s)) {\n", - isudp ? "SOCK_DGRAM" : "SOCK_STREAM"); - } - f_print (fout, "%s\t%s = svc%s_create(%s", - sp, TRANSP, transp, inetdflag ? "sock" : "RPC_ANYSOCK"); - if (!isudp) - f_print (fout, ", 0, 0"); - f_print (fout, ");\n"); - f_print (fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); - (void) sprintf (_errbuf, "cannot create %s service.", transp); - (void) sprintf (tmpbuf, "%s\t\t", sp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); - f_print (fout, "%s\t}\n", sp); - - if (inetdflag) - { - f_print (fout, "%s\tif (!_rpcpmstart)\n\t", sp); - f_print (fout, "%s\tproto = IPPROTO_%s;\n", - sp, isudp ? "UDP" : "TCP"); - } - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "%s\tif (!svc_register(%s, %s, %s, ", - sp, TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - if (inetdflag) - f_print (fout, ", proto)) {\n"); - else - f_print (fout, ", IPPROTO_%s)) {\n", - isudp ? "UDP" : "TCP"); - (void) sprintf (_errbuf, "unable to register (%s, %s, %s).", - def->def_name, vp->vers_name, transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); - f_print (fout, "%s\t}\n", sp); - } - } - if (inetdflag) - f_print (fout, "\t}\n"); -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_tblout.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_tblout.c deleted file mode 100644 index a7d2f43..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_tblout.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * From: @(#)rpc_tblout.c 1.4 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define TABSIZE 8 -#define TABCOUNT 5 -#define TABSTOP (TABSIZE*TABCOUNT) - -static const char tabstr[TABCOUNT + 1] = "\t\t\t\t\t"; - -static const char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n"; -static const char tbl_end[] = "};\n"; - -static const char null_entry[] = "\n\t(char *(*)())0,\n\ - \t(xdrproc_t) xdr_void,\t\t\t0,\n\ - \t(xdrproc_t) xdr_void,\t\t\t0,\n"; - - -static const char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n"; - -static void write_table (const definition * def); -static void printit (const char *prefix, const char *type); - -void -write_tables (void) -{ - list *l; - definition *def; - - f_print (fout, "\n"); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_table (def); - } - } -} - -static void -write_table (const definition * def) -{ - version_list *vp; - proc_list *proc; - int current; - int expected; - char progvers[100]; - int warning; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - warning = 0; - s_print (progvers, "%s_%s", - locase (def->def_name), vp->vers_num); - /* print the table header */ - f_print (fout, tbl_hdr, progvers); - - if (nullproc (vp->procs)) - { - expected = 0; - } - else - { - expected = 1; - f_print (fout, null_entry); - } - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - current = atoi (proc->proc_num); - if (current != expected++) - { - f_print (fout, - "\n/*\n * WARNING: table out of order\n */\n"); - if (warning == 0) - { - f_print (stderr, - "WARNING %s table is out of order\n", - progvers); - warning = 1; - nonfatalerrors = 1; - } - expected = current + 1; - } - f_print (fout, "\n\t(char *(*)())RPCGEN_ACTION("); - - /* routine to invoke */ - if (Cflag && !newstyle) - pvname_svc (proc->proc_name, vp->vers_num); - else - { - if (newstyle) - f_print (fout, "_"); /* calls internal func */ - pvname (proc->proc_name, vp->vers_num); - } - f_print (fout, "),\n"); - - /* argument info */ - if (proc->arg_num > 1) - printit ((char *) NULL, proc->args.argname); - else - /* do we have to do something special for newstyle */ - printit (proc->args.decls->decl.prefix, - proc->args.decls->decl.type); - /* result info */ - printit (proc->res_prefix, proc->res_type); - } - - /* print the table trailer */ - f_print (fout, tbl_end); - f_print (fout, tbl_nproc, progvers, progvers, progvers); - } -} - -static void -printit (const char *prefix, const char *type) -{ - int len; - int tabs; - - - len = fprintf (fout, "\txdr_%s,", stringfix (type)); - /* account for leading tab expansion */ - len += TABSIZE - 1; - /* round up to tabs required */ - tabs = (TABSTOP - len + TABSIZE - 1) / TABSIZE; - f_print (fout, "%s", &tabstr[TABCOUNT - tabs]); - - if (streq (type, "void")) - { - f_print (fout, "0"); - } - else - { - f_print (fout, "sizeof ( "); - /* XXX: should "follow" be 1 ??? */ - ptype (prefix, type, 0); - f_print (fout, ")"); - } - f_print (fout, ",\n"); -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_util.c b/nfs-utils-2.5.2/tools/rpcgen/rpc_util.c deleted file mode 100644 index 52aa697..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_util.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * From: @(#)rpc_util.c 1.11 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_util.c, Utility routines for the RPC protocol compiler - */ -#include -#include -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define ARGEXT "argument" - -char curline[MAXLINESIZE]; /* current read line */ -const char *where = curline; /* current point in line */ -int linenum = 0; /* current line number */ - -const char *infilename; /* input filename */ - -#define NFILES 7 -const char *outfiles[NFILES]; /* output file names */ -int nfiles; - -FILE *fout; /* file pointer of current output */ -FILE *fin; /* file pointer of current input */ - -list *defined; /* list of defined things */ - -static int findit (const definition * def, const char *type); -static const char *fixit (const char *type, const char *orig); -static int typedefed (const definition * def, const char *type); -static const char *toktostr (tok_kind kind); -static void printbuf (void); -static void printwhere (void); - -/* - * Reinitialize the world - */ -void -reinitialize (void) -{ - memset (curline, 0, MAXLINESIZE); - where = curline; - linenum = 0; - defined = NULL; -} - -/* - * string equality - */ -int -streq (const char *a, const char *b) -{ - return strcmp (a, b) == 0; -} - -/* - * find a value in a list - */ -definition * -findval (list *lst, const char *val, - int (*cmp) (const definition *, const char *)) -{ - - for (; lst != NULL; lst = lst->next) - { - if (cmp (lst->val, val)) - { - return lst->val; - } - } - return NULL; -} - -/* - * store a value in a list - */ -void -storeval (list **lstp, definition *val) -{ - list **l; - list *lst; - - - for (l = lstp; *l != NULL; l = (list **) & (*l)->next); - lst = ALLOC (list); - lst->val = val; - lst->next = NULL; - *l = lst; -} - -static int -findit (const definition * def, const char *type) -{ - return streq (def->def_name, type); -} - -static const char * -fixit (const char *type, const char *orig) -{ - definition *def; - - def = findval (defined, type, findit); - if (def == NULL || def->def_kind != DEF_TYPEDEF) - { - return orig; - } - switch (def->def.ty.rel) - { - case REL_VECTOR: - if (streq (def->def.ty.old_type, "opaque")) - return ("char"); - else - return (def->def.ty.old_type); - case REL_ALIAS: - return (fixit (def->def.ty.old_type, orig)); - default: - return orig; - } -} - -const char * -fixtype (const char *type) -{ - return fixit (type, type); -} - -const char * -stringfix (const char *type) -{ - if (streq (type, "string")) - { - return "wrapstring"; - } - else - { - return type; - } -} - -void -ptype (const char *prefix, const char *type, int follow) -{ - if (prefix != NULL) - { - if (streq (prefix, "enum")) - { - f_print (fout, "enum "); - } - else - { - f_print (fout, "struct "); - } - } - if (streq (type, "bool")) - { - f_print (fout, "bool_t "); - } - else if (streq (type, "string")) - { - f_print (fout, "char *"); - } - else - { - f_print (fout, "%s ", follow ? fixtype (type) : type); - } -} - -static int -typedefed (const definition * def, const char *type) -{ - if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) - { - return 0; - } - else - { - return streq (def->def_name, type); - } -} - -int -isvectordef (const char *type, relation rel) -{ - definition *def; - - for (;;) - { - switch (rel) - { - case REL_VECTOR: - return !streq (type, "string"); - case REL_ARRAY: - return 0; - case REL_POINTER: - return 0; - case REL_ALIAS: - def = findval (defined, type, typedefed); - if (def == NULL) - { - return 0; - } - type = def->def.ty.old_type; - rel = def->def.ty.rel; - } - } -} - -char * -locase (const char *str) -{ - char c; - static char buf[100]; - char *p = buf; - - while ((c = *str++) != 0) - { - *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; - } - *p = 0; - return buf; -} - -void -pvname_svc (const char *pname, const char *vnum) -{ - f_print (fout, "%s_%s_svc", locase (pname), vnum); -} - -void -pvname (const char *pname, const char *vnum) -{ - f_print (fout, "%s_%s", locase (pname), vnum); -} - -/* - * print a useful (?) error message, and then die - */ -void -error (const char *msg) -{ - printwhere (); - f_print (stderr, "%s, line %d: ", infilename, linenum); - f_print (stderr, "%s\n", msg); - crash (); -} - -/* - * Something went wrong, unlink any files that we may have created and then - * die. - */ -void -crash (void) -{ - int i; - - for (i = 0; i < nfiles; i++) - { - unlink (outfiles[i]); - } - exit (1); -} - -void -record_open (const char *file) -{ - if (nfiles < NFILES) - { - outfiles[nfiles++] = file; - } - else - { - f_print (stderr, "too many files!\n"); - crash (); - } -} - -static char expectbuf[100]; - -/* - * error, token encountered was not the expected one - */ -void -expected1 (tok_kind exp1) -{ - s_print (expectbuf, "expected '%s'", - toktostr (exp1)); - error (expectbuf); -} - -/* - * error, token encountered was not one of two expected ones - */ -void -expected2 (tok_kind exp1, tok_kind exp2) -{ - s_print (expectbuf, "expected '%s' or '%s'", - toktostr (exp1), - toktostr (exp2)); - error (expectbuf); -} - -/* - * error, token encountered was not one of 3 expected ones - */ -void -expected3 (tok_kind exp1, tok_kind exp2, tok_kind exp3) -{ - s_print (expectbuf, "expected '%s', '%s' or '%s'", - toktostr (exp1), - toktostr (exp2), - toktostr (exp3)); - error (expectbuf); -} - -void -tabify (FILE * f, int tab) -{ - while (tab--) - { - (void) fputc ('\t', f); - } -} - - -static const token tokstrings[] = -{ - {TOK_IDENT, "identifier"}, - {TOK_CONST, "const"}, - {TOK_RPAREN, ")"}, - {TOK_LPAREN, "("}, - {TOK_RBRACE, "}"}, - {TOK_LBRACE, "{"}, - {TOK_LBRACKET, "["}, - {TOK_RBRACKET, "]"}, - {TOK_STAR, "*"}, - {TOK_COMMA, ","}, - {TOK_EQUAL, "="}, - {TOK_COLON, ":"}, - {TOK_SEMICOLON, ";"}, - {TOK_UNION, "union"}, - {TOK_STRUCT, "struct"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_ENUM, "enum"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_INT, "int"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_DOUBLE, "double"}, - {TOK_FLOAT, "float"}, - {TOK_CHAR, "char"}, - {TOK_STRING, "string"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"} -}; - -static const char * -toktostr (tok_kind kind) -{ - const token *sp; - - for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++); - return sp->str; -} - -static void -printbuf (void) -{ - char c; - int i; - int cnt; - -#define TABSIZE 4 - - for (i = 0; (c = curline[i]) != 0; i++) - { - if (c == '\t') - { - cnt = 8 - (i % TABSIZE); - c = ' '; - } - else - { - cnt = 1; - } - while (cnt--) - { - (void) fputc (c, stderr); - } - } -} - -static void -printwhere (void) -{ - int i; - char c; - int cnt; - - printbuf (); - for (i = 0; i < where - curline; i++) - { - c = curline[i]; - if (c == '\t') - { - cnt = 8 - (i % TABSIZE); - } - else - { - cnt = 1; - } - while (cnt--) - { - (void) fputc ('^', stderr); - } - } - (void) fputc ('\n', stderr); -} - -char * -make_argname (const char *pname, const char *vname) -{ - char *name; - - name = malloc (strlen (pname) + strlen (vname) + strlen (ARGEXT) + 3); - if (!name) - { - fprintf (stderr, "failed in malloc"); - exit (1); - } - sprintf (name, "%s_%s_%s", locase (pname), vname, ARGEXT); - return name; -} - -bas_type *typ_list_h; -bas_type *typ_list_t; - -void -add_type (int len, const char *type) -{ - bas_type *ptr; - - - if ((ptr = malloc (sizeof (bas_type))) == NULL) - { - fprintf (stderr, "failed in malloc"); - exit (1); - } - - ptr->name = type; - ptr->length = len; - ptr->next = NULL; - if (typ_list_t == NULL) - { - - typ_list_t = ptr; - typ_list_h = ptr; - } - else - { - - typ_list_t->next = ptr; - typ_list_t = ptr; - } - -} - - -bas_type * -find_type (const char *type) -{ - bas_type *ptr; - - ptr = typ_list_h; - - - while (ptr != NULL) - { - if (strcmp (ptr->name, type) == 0) - return ptr; - else - ptr = ptr->next; - }; - return NULL; -} diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpc_util.h b/nfs-utils-2.5.2/tools/rpcgen/rpc_util.h deleted file mode 100644 index 53316d9..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpc_util.h +++ /dev/null @@ -1,154 +0,0 @@ -/* @(#)rpc_util.h 1.5 90/08/29 */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_util.h, Useful definitions for the RPC protocol compiler - */ - -#include - -#define alloc(size) malloc((unsigned)(size)) -#define ALLOC(object) (object *) malloc(sizeof(object)) - -#define s_print (void) sprintf -#define f_print (void) fprintf - -struct list { - definition *val; - struct list *next; -}; -typedef struct list list; - -struct xdrfunc { - char *name; - int pointerp; - struct xdrfunc *next; -}; -typedef struct xdrfunc xdrfunc; - -#define PUT 1 -#define GET 2 - -/* - * Global variables - */ -#define MAXLINESIZE 1024 -extern char curline[MAXLINESIZE]; -extern const char *where; -extern int linenum; - -extern const char *infilename; -extern FILE *fout; -extern FILE *fin; - -extern list *defined; - -extern bas_type *typ_list_h; -extern bas_type *typ_list_t; -extern xdrfunc *xdrfunc_head, *xdrfunc_tail; - -/* - * All the option flags - */ -extern int inetdflag; -extern int pmflag; -extern int tblflag; -extern int logflag; -extern int newstyle; -extern int Cflag; /* C++ flag */ -extern int CCflag; /* C++ flag */ -extern int tirpcflag; /* flag for generating tirpc code */ -extern int inlineflag; /* if this is 0, then do not generate inline code */ -extern int mtflag; - -/* - * Other flags related with inetd jumpstart. - */ -extern int indefinitewait; -extern int exitnow; -extern int timerflag; - -extern int nonfatalerrors; - -/* - * rpc_util routines - */ -void storeval(list **lstp, definition *val); -#define STOREVAL(list,item) storeval(list,item) - -definition *findval(list *lst, const char *val, - int (*cmp)(const definition *, const char *)); -#define FINDVAL(list,item,finder) findval(list, item, finder) - -const char *fixtype(const char *type); -const char *stringfix(const char *type); -char *locase(const char *str); -void pvname_svc(const char *pname, const char *vnum); -void pvname(const char *pname, const char *vnum); -void ptype(const char *prefix, const char *type, int follow); -int isvectordef(const char *type, relation rel); -int streq(const char *a, const char *b); -void error(const char *msg); -void tabify(FILE *f, int tab); -void record_open(const char *file); -bas_type *find_type(const char *type); - - -/* - * rpc_cout routines - */ -void emit(definition *def); - -/* - * rpc_hout routines - */ -void print_datadef(definition *def); -void print_funcdef(definition *def); - -/* - * rpc_svcout routines - */ -void write_most(const char *infile, int netflag, int nomain); -void write_register(void); -void write_rest(void); -void write_programs(const char *storage); -void write_svc_aux(int nomain); -void write_inetd_register(const char *transp); -void write_netid_register(const char *); -void write_nettype_register(const char *); -/* - * rpc_clntout routines - */ -void write_stubs(void); - -/* - * rpc_tblout routines - */ -void write_tables(void); diff --git a/nfs-utils-2.5.2/tools/rpcgen/rpcgen.1 b/nfs-utils-2.5.2/tools/rpcgen/rpcgen.1 deleted file mode 100644 index 9db1b4a..0000000 --- a/nfs-utils-2.5.2/tools/rpcgen/rpcgen.1 +++ /dev/null @@ -1,442 +0,0 @@ -.\" @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89 -.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved. -.nr X -.if \nX=0 .ds x} rpcgen 1 "" "\&" -.if \nX=1 .ds x} rpcgen 1 "" -.if \nX=2 .ds x} rpcgen 1 "" "\&" -.if \nX=3 .ds x} rpcgen "" "" "\&" -.TH \*(x} -.SH NAME -\f4rpcgen\f1 \- an RPC protocol compiler -.SH SYNOPSIS -.ft 4 -.nf -rpcgen \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen [\-D\f2name\f4[=\f2value\f4]] [\-T] [\-K \f2secs\fP] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen \-c|\-h|\-l|\-m|\-M|\-t [\-o \f2outfile\f4 ] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen [\-I] \-s \f2nettype\f4 [\-o \f2outfile\f4] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen \-n \f2netid\f4 [\-o \f2outfile\f4] \f2infile\f4 -.ft 1 -.SH DESCRIPTION -.P -\f4rpcgen\f1 -is a tool that generates C code to implement an RPC protocol. -The input to -\f4rpcgen\f1 -is a language similar to C known as -RPC Language (Remote Procedure Call Language). -.P -\f4rpcgen\f1 -is normally used as in the first synopsis where -it takes an input file and generates up to four output files. -If the -\f2infile\f1 -is named -\f4proto.x\f1, -then -\f4rpcgen\f1 -will generate a header file in -\f4proto.h\f1, -XDR routines in -\f4proto_xdr.c\f1, -server-side stubs in -\f4proto_svc.c\f1, -and client-side stubs in -\f4proto_clnt.c\f1. -With the -\f4\-T\f1 -option, -it will also generate the RPC dispatch table in -\f4proto_tbl.i\f1. -With the -\f4\-Sc\f1 -option, -it will also generate sample code which would illustrate how to use the -remote procedures on the client side. This code would be created in -\f4proto_client.c\f1. -With the -\f4\-Ss\f1 -option, -it will also generate a sample server code which would illustrate how to write -the remote procedures. This code would be created in -\f4proto_server.c\f1. -.P -The server created can be started both by the port monitors -(for example, \f4inetd\f1 or \f4listen\f1) -or by itself. -When it is started by a port monitor, -it creates servers only for the transport for which -the file descriptor \f40\fP was passed. -The name of the transport must be specified -by setting up the environmental variable -\f4PM_TRANSPORT\f1. -When the server generated by -\f4rpcgen\f1 -is executed, -it creates server handles for all the transports -specified in -\f4NETPATH\f1 -environment variable, -or if it is unset, -it creates server handles for all the visible transports from -\f4/etc/netconfig\f1 -file. -Note: -the transports are chosen at run time and not at compile time. -.P -When built for a port monitor (\f4rpcgen\f1 \f4\-I\f1), and that the server -is self-started, it backgrounds itself by default. A special define symbol -\f4RPC_SVC_FG\f1 can be used to run the server process in foreground. -.P -The second synopsis provides special features which allow -for the creation of more sophisticated RPC servers. -These features include support for user provided -\f4#defines\f1 -and RPC dispatch tables. -The entries in the RPC dispatch table contain: -.RS -.PD 0 -.TP 3 -\(bu -pointers to the service routine corresponding to that procedure, -.TP -\(bu -a pointer to the input and output arguments -.TP -\(bu -the size of these routines -.PD -.RE -A server can use the dispatch table to check authorization -and then to execute the service routine; -a client library may use it to deal with the details of storage -management and XDR data conversion. -.P -The other three synopses shown above are used when -one does not want to generate all the output files, -but only a particular one. -Some examples of their usage is described in the -EXAMPLE -section below. -When -\f4rpcgen\f1 -is executed with the -\f4\-s\f1 -option, -it creates servers for that particular class of transports. -When -executed with the -\f4\-n\f1 -option, -it creates a server for the transport specified by -\f2netid\f1. -If -\f2infile\f1 -is not specified, -\f4rpcgen\f1 -accepts the standard input. -.P -The C preprocessor, -\f4cc \-E\f1 -[see \f4cc\fP(1)], -is run on the input file before it is actually interpreted by -\f4rpcgen\f1. -For each type of output file, -\f4rpcgen\f1 -defines a special preprocessor symbol for use by the -\f4rpcgen\f1 -programmer: -.P -.PD 0 -.TP 12 -\f4RPC_HDR\f1 -defined when compiling into header files -.TP -\f4RPC_XDR\f1 -defined when compiling into XDR routines -.TP -\f4RPC_SVC\f1 -defined when compiling into server-side stubs -.TP -\f4RPC_CLNT\f1 -defined when compiling into client-side stubs -.TP -\f4RPC_TBL\f1 -defined when compiling into RPC dispatch tables -.PD -.P -Any line beginning with -`\f4%\f1' -is passed directly into the output file, -uninterpreted by -\f4rpcgen\f1. -.P -For every data type referred to in -\f2infile\f1, -\f4rpcgen\f1 -assumes that there exists a -routine with the string -\f4xdr_\f1 -prepended to the name of the data type. -If this routine does not exist in the RPC/XDR -library, it must be provided. -Providing an undefined data type -allows customization of XDR routines. -.br -.ne 10 -.P -The following options are available: -.TP -\f4\-a\f1 -Generate all the files including sample code for client and server side. -.TP -\f4\-b\f1 -This generates code for the SunOS4.1 style of rpc. It is -for backward compatibility. This is the default. -.TP -\f4\-5\f1 -This generates code for the SysVr4 style of rpc. It is used by the -Transport Independent RPC that is in Svr4 systems. -By default rpcgen generates code for SunOS4.1 stype of rpc. -.TP -\f4\-c\f1 -Compile into XDR routines. -.TP -\f4\-C\f1 -Generate code in ANSI C. This option also generates code that could be -compiled with the C++ compiler. This is the default. -.TP -\f4\-k\f1 -Generate code in K&R C. The default is ANSI C. -.TP -\f4\-D\f2name\f4[=\f2value\f4]\f1 -Define a symbol -\f2name\f1. -Equivalent to the -\f4#define\f1 -directive in the source. -If no -\f2value\f1 -is given, -\f2value\f1 -is defined as \f41\f1. -This option may be specified more than once. -.TP -\f4\-h\f1 -Compile into -\f4C\f1 -data-definitions (a header file). -\f4\-T\f1 -option can be used in conjunction to produce a -header file which supports RPC dispatch tables. -.TP -\f4\-I\f1 -Generate a service that can be started from inetd. The default is -to generate a static service that handles transports selected with \f4\-s\f1. -Using \f4\-I\f1 allows starting a service by either method. -.TP -\f4-K\f2 secs\f1 -By default, services created using \f4rpcgen\fP wait \f4120\fP seconds -after servicing a request before exiting. -That interval can be changed using the \f4-K\fP flag. -To create a server that exits immediately upon servicing a request, -\f4-K\ 0\fP can be used. -To create a server that never exits, the appropriate argument is -\f4-K\ -1\fP. -.IP -When monitoring for a server, -some portmonitors, like -\f4listen\fP(1M), -.I always -spawn a new process in response to a service request. -If it is known that a server will be used with such a monitor, the -server should exit immediately on completion. -For such servers, \f4rpcgen\fP should be used with \f4-K\ -1\fP. -.TP -\f4\-l\f1 -Compile into client-side stubs. -.TP -\f4\-m\f1 -Compile into server-side stubs, -but do not generate a \(lqmain\(rq routine. -This option is useful for doing callback-routines -and for users who need to write their own -\(lqmain\(rq routine to do initialization. -.TP -\f4\-M\f1 -Generate multithread-safe stubs for passing arguments -and results between rpcgen-generated code and user written code. -This option is useful for users who want to use threads in their code. -.TP -\f4\-n \f2netid\f1 -Compile into server-side stubs for the transport -specified by -\f2netid\f1. -There should be an entry for -\f2netid\f1 -in the -netconfig database. -This option may be specified more than once, -so as to compile a server that serves multiple transports. -.TP -\f4\-N\f1 -Use the newstyle of rpcgen. This allows procedures to have multiple arguments. -It also uses the style of parameter passing that closely resembles C. So, when -passing an argument to a remote procedure you do not have to pass a pointer to -the argument but the argument itself. This behaviour is different from the oldstyle -of rpcgen generated code. The newstyle is not the default case because of -backward compatibility. -.TP -\f4\-o \f2outfile\f1 -Specify the name of the output file. -If none is specified, -standard output is used -(\f4\-c\f1, -\f4\-h\f1, -\f4\-l\f1, -\f4\-m\f1, -\f4\-n\f1, -\f4\-s\f1, -\f4\-Sc\f1, -\f4\-Sm\f1, -\f4\-Ss\f1, -and -\f4\-t\f1 -modes only). -.TP -\f4\-s \f2nettype\f1 -Compile into server-side stubs for all the -transports belonging to the class -\f2nettype\f1. -The supported classes are -\f4netpath\f1, -\f4visible\f1, -\f4circuit_n\f1, -\f4circuit_v\f1, -\f4datagram_n\f1, -\f4datagram_v\f1, -\f4tcp\f1, -and -\f4udp\f1 -[see \f4rpc\fP(3N) -for the meanings associated with these classes]. -This option may be specified more than once. -Note: -the transports are chosen at run time and not at compile time. -.TP -\f4\-Sc\f1 -Generate sample code to show the use of remote procedure and how to bind -to the server before calling the client side stubs generated by rpcgen. -.TP -\f4\-Sm\f1 -Generate a sample Makefile which can be used for compiling the application. -.TP -\f4\-Ss\f1 -Generate skeleton code for the remote procedures on the server side. You would need -to fill in the actual code for the remote procedures. -.TP -\f4\-t\f1 -Compile into RPC dispatch table. -.TP -\f4\-T\f1 -Generate the code to support RPC dispatch tables. -.P -The options -\f4\-c\f1, -\f4\-h\f1, -\f4\-l\f1, -\f4\-m\f1, -\f4\-s\f1 -and -\f4\-t\f1 -are used exclusively to generate a particular type of file, -while the options -\f4\-D\f1 -and -\f4\-T\f1 -are global and can be used with the other options. -.br -.ne 5 -.SH NOTES -The RPC Language does not support nesting of structures. -As a work-around, -structures can be declared at the top-level, -and their name used inside other structures in -order to achieve the same effect. -.P -Name clashes can occur when using program definitions, -since the apparent scoping does not really apply. -Most of these can be avoided by giving -unique names for programs, -versions, -procedures and types. -.P -The server code generated with -\f4\-n\f1 -option refers to the transport indicated by -\f2netid\f1 -and hence is very site specific. -.SH EXAMPLE -The following example: -.IP -.ft 4 -$ rpcgen \-T prot.x -.ft 1 -.P -generates the five files: -\f4prot.h\f1, -\f4prot_clnt.c\f1, -\f4prot_svc.c\f1, -\f4prot_xdr.c\f1 -and -\f4prot_tbl.i\f1. -.P -The following example sends the C data-definitions (header file) -to the standard output. -.IP -.ft 4 -$ rpcgen \-h prot.x -.ft 1 -.P -To send the test version of the -\f4-DTEST\f1, -server side stubs for -all the transport belonging to the class -\f4datagram_n\f1 -to standard output, use: -.IP -.ft 4 -$ rpcgen \-s datagram_n \-DTEST prot.x -.ft 1 -.P -To create the server side stubs for the transport indicated -by -\f2netid\f1 -\f4tcp\f1, -use: -.IP -.ft 4 -$ rpcgen \-n tcp \-o prot_svc.c prot.x -.ft 1 -.SH "SEE ALSO" -\f4cc\fP(1). diff --git a/nfs-utils-2.5.2/utils/Makefile.am b/nfs-utils-2.5.2/utils/Makefile.am deleted file mode 100644 index 4c930a4..0000000 --- a/nfs-utils-2.5.2/utils/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -## Process this file with automake to produce Makefile.in - -OPTDIRS = - -if CONFIG_NFSV4 -OPTDIRS += idmapd -OPTDIRS += nfsidmap -endif - -if CONFIG_NFSV41 -OPTDIRS += blkmapd -endif - -if CONFIG_GSS -OPTDIRS += gssd -endif - -if CONFIG_MOUNT -OPTDIRS += mount -endif - -if CONFIG_NFSDCLD -OPTDIRS += nfsdcld -endif - -if CONFIG_NFSDCLTRACK -OPTDIRS += nfsdcltrack -endif - -if CONFIG_JUNCTION -OPTDIRS += nfsref -endif - -SUBDIRS = \ - exportfs \ - mountd \ - nfsd \ - nfsstat \ - showmount \ - statd \ - $(OPTDIRS) - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/utils/blkmapd/Makefile.am b/nfs-utils-2.5.2/utils/blkmapd/Makefile.am deleted file mode 100644 index 56c8a4b..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = blkmapd.man -EXTRA_DIST = $(man8_MANS) - -AM_CFLAGS += -D_LARGEFILE64_SOURCE -sbin_PROGRAMS = blkmapd - -blkmapd_SOURCES = \ - device-discovery.c \ - device-inq.c \ - device-process.c \ - dm-device.c \ - device-discovery.h - -blkmapd_LDADD = -ldevmapper ../../support/nfs/libnfs.la - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/utils/blkmapd/blkmapd.man b/nfs-utils-2.5.2/utils/blkmapd/blkmapd.man deleted file mode 100644 index 4b3d3f0..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/blkmapd.man +++ /dev/null @@ -1,72 +0,0 @@ -.\" -.\" Copyright 2011, Jim Rees. -.\" -.\" You may distribute under the terms of the GNU General Public -.\" License as specified in the file COPYING that comes with the -.\" nfs-utils distribution. -.\" -.TH blkmapd 8 "11 August 2011" -.SH NAME -blkmapd \- pNFS block layout mapping daemon -.SH SYNOPSIS -.B "blkmapd [-h] [-d] [-f]" -.SH DESCRIPTION -The -.B blkmapd -daemon performs device discovery and mapping for the parallel NFS (pNFS) block layout -client [RFC5663]. -.PP -The pNFS block layout protocol builds a complex storage hierarchy from a set -of -.I simple volumes. -These simple volumes are addressed by content, using a signature on the -volume to uniquely name each one. -The daemon locates a volume by examining each block device in the system for -the given signature. -.PP -The topology typically consists of a hierarchy of volumes built by striping, -slicing, and concatenating the simple volumes. -The -.B blkmapd -daemon uses the device-mapper driver to construct logical devices that -reflect the server topology, and passes these devices to the kernel for use -by the pNFS block layout client. -.SH OPTIONS -.TP -.B -h -Display usage message. -.TP -.B -d -Performs device discovery only then exits. -.TP -.B -f -Runs -.B blkmapd -in the foreground and sends output to stderr (as opposed to syslogd) -.SH CONFIGURATION FILE -The -.B blkmapd -daemon recognizes the following value from the -.B [general] -section of the -.I /etc/nfs.conf -configuration file: -.TP -.B pipefs-directory -Tells -.B blkmapd -where to look for the rpc_pipefs filesystem. The default value is -.IR /var/lib/nfs/rpc_pipefs . -.SH SEE ALSO -.BR nfs (5), -.BR dmsetup (8), -.BR nfs.conf (5) -.sp -RFC 5661 for the NFS version 4.1 specification. -.br -RFC 5663 for the pNFS block layout specification. -.SH AUTHORS -.br -Haiying Tang -.br -Jim Rees diff --git a/nfs-utils-2.5.2/utils/blkmapd/device-discovery.c b/nfs-utils-2.5.2/utils/blkmapd/device-discovery.c deleted file mode 100644 index f5f9b10..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/device-discovery.c +++ /dev/null @@ -1,573 +0,0 @@ -/* - * device-discovery.c: main function, discovering device and processing - * pipe request from kernel. - * - * Copyright (c) 2010 EMC Corporation, Haiying Tang - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "device-discovery.h" -#include "xcommon.h" -#include "nfslib.h" -#include "conffile.h" - -#define EVENT_SIZE (sizeof(struct inotify_event)) -#define EVENT_BUFSIZE (1024 * EVENT_SIZE) - -#define RPCPIPE_DIR "/var/lib/nfs/rpc_pipefs" -#define PID_FILE "/var/run/blkmapd.pid" - -#define CONF_SAVE(w, f) do { \ - char *p = f; \ - if (p != NULL) \ - (w) = p; \ -} while (0) - -static char bl_pipe_file[PATH_MAX]; -static char nfspipe_dir[PATH_MAX]; -static char rpcpipe_dir[PATH_MAX]; - -struct bl_disk *visible_disk_list; -int bl_watch_fd, bl_pipe_fd, nfs_pipedir_wfd, rpc_pipedir_wfd; -int pidfd = -1; - - -static struct bl_disk_path *bl_get_path(const char *filepath, - struct bl_disk_path *paths) -{ - struct bl_disk_path *tmp = paths; - - while (tmp) { - if (!strcmp(tmp->full_path, filepath)) - break; - tmp = tmp->next; - } - return tmp; -} - -/* - * For multipath devices, devices state could be PASSIVE/ACTIVE/PSEUDO, - * where PSEUDO > ACTIVE > PASSIVE. Device with highest state is used to - * create pseudo device. So if state is higher, the device path needs to - * be updated. - * If device-mapper multipath support is a must, pseudo devices should - * exist for each multipath device. If not, active device path will be - * chosen for device creation. - */ -static int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk) -{ - struct bl_disk_path *valid_path = disk->valid_path; - - if (valid_path && valid_path->state >= state) - return 0; - return 1; -} - -static void bl_release_disk(void) -{ - struct bl_disk *disk; - struct bl_disk_path *path = NULL; - - while (visible_disk_list) { - disk = visible_disk_list; - path = disk->paths; - while (path) { - disk->paths = path->next; - free(path->full_path); - free(path); - path = disk->paths; - } - if (disk->serial) - free(disk->serial); - visible_disk_list = disk->next; - free(disk); - } -} - -static void bl_add_disk(char *filepath) -{ - struct bl_disk *disk = NULL; - int fd = 0; - struct stat sb; - off_t size = 0; - struct bl_serial *serial = NULL; - enum bl_path_state_e ap_state; - struct bl_disk_path *diskpath = NULL, *path = NULL; - dev_t dev; - - fd = open(filepath, O_RDONLY | O_LARGEFILE); - if (fd < 0) - return; - - if (fstat(fd, &sb)) { - close(fd); - return; - } - - if (!sb.st_size) - ioctl(fd, BLKGETSIZE, &size); - else - size = sb.st_size; - - if (!size) { - close(fd); - return; - } - - dev = sb.st_rdev; - serial = bldev_read_serial(fd, filepath); - if (!serial) { - BL_LOG_ERR("%s: no serial found for %s\n", - __func__, filepath); - ap_state = BL_PATH_STATE_PASSIVE; - } else if (dm_is_dm_major(major(dev))) - ap_state = BL_PATH_STATE_PSEUDO; - else - ap_state = bldev_read_ap_state(fd); - close(fd); - - for (disk = visible_disk_list; disk != NULL; disk = disk->next) { - /* Already scanned or a partition? - * XXX: if released each time, maybe not need to compare - */ - if ((serial->len == disk->serial->len) && - !memcmp(serial->data, disk->serial->data, serial->len)) { - diskpath = bl_get_path(filepath, disk->paths); - break; - } - } - - if (disk && diskpath) { - if (serial) { - free(serial->data); - free(serial); - } - return; - } - - /* add path */ - path = malloc(sizeof(struct bl_disk_path)); - if (!path) { - BL_LOG_ERR("%s: Out of memory!\n", __func__); - goto out_err; - } - path->next = NULL; - path->state = ap_state; - path->full_path = strdup(filepath); - if (!path->full_path) - goto out_err; - - if (!disk) { /* add disk */ - disk = malloc(sizeof(struct bl_disk)); - if (!disk) { - BL_LOG_ERR("%s: Out of memory!\n", __func__); - goto out_err; - } - disk->next = visible_disk_list; - disk->dev = dev; - disk->size = size; - disk->serial = serial; - disk->valid_path = path; - disk->paths = path; - visible_disk_list = disk; - } else { - path->next = disk->paths; - disk->paths = path; - /* check whether we need to update disk info */ - if (bl_update_path(path->state, disk)) { - disk->dev = dev; - disk->size = size; - disk->valid_path = path; - } - if (serial) { - free(serial->data); - free(serial); - } - } - return; - - out_err: - if (path) { - if (path->full_path) - free(path->full_path); - free(path); - } - if (serial) { - free(serial->data); - free(serial); - } - return; -} - -int bl_discover_devices(void) -{ - FILE *f; - int n; - char buf[PATH_MAX], devname[NAME_MAX], fulldevname[PATH_MAX]; - - /* release previous list */ - bl_release_disk(); - - /* scan all block devices */ - f = fopen("/proc/partitions", "r"); - if (f == NULL) - return 0; - - while (1) { - if (fgets(buf, sizeof buf, f) == NULL) - break; - n = sscanf(buf, "%*d %*d %*d %31s", devname); - if (n != 1) - continue; - snprintf(fulldevname, sizeof fulldevname, "/sys/block/%s", - devname); - if (access(fulldevname, F_OK) < 0) - continue; - snprintf(fulldevname, sizeof fulldevname, "/dev/%s", devname); - bl_add_disk(fulldevname); - } - - fclose(f); - - return 0; -} - -/* process kernel request - * return 0: request processed, and no more request waiting; - * return 1: request processed, and more requests waiting; - * return < 0: error - */ -static int bl_disk_inquiry_process(int fd) -{ - int ret = 0; - struct bl_pipemsg_hdr head; - char *buf = NULL; - uint32_t major, minor; - uint16_t buflen; - struct bl_dev_msg reply; - - /* read request */ - if (atomicio(read, fd, &head, sizeof(head)) != sizeof(head)) { - /* Note that an error in this or the next read is pretty - * catastrophic, as there is no good way to resync into - * the pipe's stream. - */ - BL_LOG_ERR("Read pipefs head error!\n"); - ret = -EIO; - goto out; - } - - buflen = head.totallen; - buf = malloc(buflen); - if (!buf) { - BL_LOG_ERR("%s: Out of memory!\n", __func__); - ret = -ENOMEM; - goto out; - } - - if (atomicio(read, fd, buf, buflen) != buflen) { - BL_LOG_ERR("Read pipefs content error!\n"); - ret = -EIO; - goto out; - } - - reply.status = BL_DEVICE_REQUEST_PROC; - - switch (head.type) { - case BL_DEVICE_MOUNT: - /* - * It shouldn't be necessary to discover devices here, since - * process_deviceinfo() will re-discover if it can't find - * the devices it needs. But in the case of multipath - * devices (ones that appear more than once, for example an - * active and a standby LUN), this will re-order them in the - * correct priority. - */ - bl_discover_devices(); - if (!process_deviceinfo(buf, buflen, &major, &minor)) { - reply.status = BL_DEVICE_REQUEST_ERR; - break; - } - reply.major = major; - reply.minor = minor; - break; - case BL_DEVICE_UMOUNT: - if (!dm_device_remove_all((uint64_t *) buf)) - reply.status = BL_DEVICE_REQUEST_ERR; - break; - default: - reply.status = BL_DEVICE_REQUEST_ERR; - break; - } - - /* write to pipefs */ - if (atomicio((void *)write, fd, &reply, sizeof(reply)) - != sizeof(reply)) { - BL_LOG_ERR("Write pipefs error!\n"); - ret = -EIO; - } - - out: - if (buf) - free(buf); - return ret; -} - -static void bl_watch_dir(const char* dir, int *wd) -{ - *wd = inotify_add_watch(bl_watch_fd, dir, IN_CREATE|IN_DELETE); - if (*wd < 0) - BL_LOG_ERR("failed to watch %s: %s\n", dir, strerror(errno)); -} - -static void bl_rpcpipe_cb(void) -{ - int rc, curr_byte = 0; - char eventArr[EVENT_BUFSIZE]; - struct inotify_event *event; - - rc = read(bl_watch_fd, &eventArr, EVENT_BUFSIZE); - if (rc < 0) - BL_LOG_ERR("read event fail: %s", strerror(errno)); - - while (rc > curr_byte) { - event = (struct inotify_event *)&eventArr[curr_byte]; - curr_byte += EVENT_SIZE + event->len; - if (event->wd == rpc_pipedir_wfd) { - if (strncmp(event->name, "nfs", 3)) - continue; - if (event->mask & IN_CREATE) { - BL_LOG_WARNING("nfs pipe dir created\n"); - bl_watch_dir(nfspipe_dir, &nfs_pipedir_wfd); - if (bl_pipe_fd >= 0) - close(bl_pipe_fd); - bl_pipe_fd = open(bl_pipe_file, O_RDWR); - if (bl_pipe_fd < 0) - BL_LOG_ERR("open %s failed: %s\n", - event->name, strerror(errno)); - } else if (event->mask & IN_DELETE) { - BL_LOG_WARNING("nfs pipe dir deleted\n"); - inotify_rm_watch(bl_watch_fd, nfs_pipedir_wfd); - close(bl_pipe_fd); - nfs_pipedir_wfd = -1; - bl_pipe_fd = -1; - } - } else if (event->wd == nfs_pipedir_wfd) { - if (strncmp(event->name, "blocklayout", 11)) - continue; - if (event->mask & IN_CREATE) { - BL_LOG_WARNING("blocklayout pipe file created\n"); - if (bl_pipe_fd >= 0) - close(bl_pipe_fd); - bl_pipe_fd = open(bl_pipe_file, O_RDWR); - if (bl_pipe_fd < 0) - BL_LOG_ERR("open %s failed: %s\n", - event->name, strerror(errno)); - } else if (event->mask & IN_DELETE) { - BL_LOG_WARNING("blocklayout pipe file deleted\n"); - close(bl_pipe_fd); - bl_pipe_fd = -1; - } - } - } -} - -static int bl_event_helper(void) -{ - fd_set rset; - int ret = 0, maxfd; - - for (;;) { - FD_ZERO(&rset); - FD_SET(bl_watch_fd, &rset); - if (bl_pipe_fd > 0) - FD_SET(bl_pipe_fd, &rset); - maxfd = (bl_watch_fd>bl_pipe_fd)?bl_watch_fd:bl_pipe_fd; - switch (select(maxfd + 1, &rset, NULL, NULL, NULL)) { - case -1: - if (errno == EINTR) - continue; - else { - ret = -errno; - goto out; - } - case 0: - goto out; - default: - if (FD_ISSET(bl_watch_fd, &rset)) - bl_rpcpipe_cb(); - else if (bl_pipe_fd > 0 && FD_ISSET(bl_pipe_fd, &rset)) - ret = bl_disk_inquiry_process(bl_pipe_fd); - if (ret) - goto out; - } - } - out: - return ret; -} - -static void sig_die(int signal) -{ - if (pidfd >= 0) { - close(pidfd); - unlink(PID_FILE); - } - BL_LOG_ERR("exit on signal(%d)\n", signal); - exit(1); -} -static void usage(void) -{ - fprintf(stderr, "Usage: blkmapd [-hdf]\n" ); -} -/* Daemon */ -int main(int argc, char **argv) -{ - int opt, dflag = 0, fg = 0, ret = 1; - char pidbuf[64]; - char *xrpcpipe_dir = NULL; - - strncpy(rpcpipe_dir, RPCPIPE_DIR, sizeof(rpcpipe_dir)); - conf_init_file(NFS_CONFFILE); - CONF_SAVE(xrpcpipe_dir, conf_get_str("general", "pipefs-directory")); - if (xrpcpipe_dir != NULL) - strlcpy(rpcpipe_dir, xrpcpipe_dir, sizeof(rpcpipe_dir)); - - strncpy(nfspipe_dir, rpcpipe_dir, sizeof(nfspipe_dir)); - strlcat(nfspipe_dir, "/nfs", sizeof(nfspipe_dir)); - strncpy(bl_pipe_file, rpcpipe_dir, sizeof(bl_pipe_file)); - strlcat(bl_pipe_file, "/nfs/blocklayout", sizeof(bl_pipe_file)); - - while ((opt = getopt(argc, argv, "hdf")) != -1) { - switch (opt) { - case 'd': - dflag = 1; - break; - case 'f': - fg = 1; - break; - case 'h': - usage(); - exit(0); - default: - usage(); - exit(1); - - } - } - - if (fg) { - openlog("blkmapd", LOG_PERROR, 0); - } else { - if (daemon(0, 0) != 0) { - fprintf(stderr, "Daemonize failed\n"); - exit(1); - } - - openlog("blkmapd", LOG_PID, 0); - pidfd = open(PID_FILE, O_WRONLY | O_CREAT, 0644); - if (pidfd < 0) { - BL_LOG_ERR("Create pid file %s failed\n", PID_FILE); - exit(1); - } - - if (lockf(pidfd, F_TLOCK, 0) < 0) { - BL_LOG_ERR("Already running; Exiting!"); - close(pidfd); - exit(1); - } - if (ftruncate(pidfd, 0) < 0) - BL_LOG_WARNING("ftruncate on %s failed: m\n", PID_FILE); - sprintf(pidbuf, "%d\n", getpid()); - if (write(pidfd, pidbuf, strlen(pidbuf)) != (ssize_t)strlen(pidbuf)) - BL_LOG_WARNING("write on %s failed: m\n", PID_FILE); - } - - signal(SIGINT, sig_die); - signal(SIGTERM, sig_die); - signal(SIGHUP, SIG_IGN); - - if (dflag) { - ret = bl_discover_devices(); - goto out; - } - - if ((bl_watch_fd = inotify_init()) < 0) { - BL_LOG_ERR("init inotify failed %s\n", strerror(errno)); - goto out; - } - - /* open pipe file */ - bl_watch_dir(rpcpipe_dir, &rpc_pipedir_wfd); - bl_watch_dir(nfspipe_dir, &nfs_pipedir_wfd); - - bl_pipe_fd = open(bl_pipe_file, O_RDWR); - if (bl_pipe_fd < 0) - BL_LOG_ERR("open pipe file %s failed: %s\n", bl_pipe_file, strerror(errno)); - - while (1) { - /* discover device when needed */ - bl_discover_devices(); - - ret = bl_event_helper(); - if (ret < 0) { - /* what should we do with process error? */ - BL_LOG_ERR("inquiry process return %d\n", ret); - } - } -out: - if (pidfd >= 0) { - close(pidfd); - unlink(PID_FILE); - } - - exit(ret); -} diff --git a/nfs-utils-2.5.2/utils/blkmapd/device-discovery.h b/nfs-utils-2.5.2/utils/blkmapd/device-discovery.h deleted file mode 100644 index a86eed9..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/device-discovery.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * bl-device-discovery.h - * - * Copyright (c) 2010 EMC Corporation, Haiying Tang - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef BL_DEVICE_DISCOVERY_H -#define BL_DEVICE_DISCOVERY_H - -#include - -enum blk_vol_type { - BLOCK_VOLUME_SIMPLE = 0, /* maps to a single LU */ - BLOCK_VOLUME_SLICE = 1, /* slice of another volume */ - BLOCK_VOLUME_CONCAT = 2, /* concatenation of multiple volumes */ - BLOCK_VOLUME_STRIPE = 3, /* striped across multiple volumes */ - BLOCK_VOLUME_PSEUDO = 4, -}; - -/* All disk offset/lengths are stored in 512-byte sectors */ -struct bl_volume { - uint32_t bv_type; - off_t bv_size; - struct bl_volume **bv_vols; - int bv_vol_n; - union { - dev_t bv_dev; /* for BLOCK_VOLUME_SIMPLE(PSEUDO) */ - off_t bv_stripe_unit; /* for BLOCK_VOLUME_STRIPE(CONCAT) */ - off_t bv_offset; /* for BLOCK_VOLUME_SLICE */ - } param; -}; - -struct bl_sig_comp { - int64_t bs_offset; /* In bytes */ - uint32_t bs_length; /* In bytes */ - char *bs_string; -}; - -/* Maximum number of signatures components in a simple volume */ -# define BLOCK_MAX_SIG_COMP 16 - -struct bl_sig { - int si_num_comps; - struct bl_sig_comp si_comps[BLOCK_MAX_SIG_COMP]; -}; - -/* - * Multipath support: ACTIVE or PSEUDO device is valid, - * PASSIVE is a standby for ACTIVE. - */ -enum bl_path_state_e { - BL_PATH_STATE_PASSIVE = 1, - BL_PATH_STATE_ACTIVE = 2, - BL_PATH_STATE_PSEUDO = 3, -}; - -struct bl_serial { - int len; - char *data; -}; - -struct bl_disk_path { - struct bl_disk_path *next; - char *full_path; - enum bl_path_state_e state; -}; - -struct bl_disk { - struct bl_disk *next; - struct bl_serial *serial; - dev_t dev; - off_t size; /* in 512-byte sectors */ - struct bl_disk_path *valid_path; - struct bl_disk_path *paths; -}; - -struct bl_dev_id { - unsigned char type; - unsigned char ids; - unsigned char reserve; - unsigned char len; - char data[0]; -}; - -struct bl_dev_msg { - int status; - uint32_t major, minor; -}; - -struct bl_pipemsg_hdr { - uint8_t type; - uint16_t totallen; /* length of message excluding hdr */ -}; - -#define BL_DEVICE_UMOUNT 0x0 /* Umount--delete devices */ -#define BL_DEVICE_MOUNT 0x1 /* Mount--create devices */ -#define BL_DEVICE_REQUEST_INIT 0x0 /* Start request */ -#define BL_DEVICE_REQUEST_PROC 0x1 /* User process succeeds */ -#define BL_DEVICE_REQUEST_ERR 0x2 /* User process fails */ - -uint32_t *blk_overflow(uint32_t * p, uint32_t * end, size_t nbytes); - -#define BLK_READBUF(p, e, nbytes) do { \ - p = blk_overflow(p, e, nbytes); \ - if (!p) {\ - goto out_err;\ - } \ -} while (0) - -#define READ32(x) (x) = ntohl(*p++) - -#define READ64(x) do { \ - (x) = (uint64_t)ntohl(*p++) << 32; \ - (x) |= ntohl(*p++); \ -} while (0) - -#define READ_SECTOR(x) do { \ - READ64(tmp); \ - if (tmp & 0x1ff) { \ - goto out_err; \ - } \ - (x) = tmp >> 9; \ -} while (0) - -extern struct bl_disk *visible_disk_list; -uint64_t dm_device_create(struct bl_volume *vols, int num_vols); -int dm_device_remove_all(uint64_t *dev); -uint64_t process_deviceinfo(const char *dev_addr_buf, - unsigned int dev_addr_len, - uint32_t *major, uint32_t *minor); - -extern ssize_t atomicio(ssize_t(*f) (int, void *, size_t), - int fd, void *_s, size_t n); -extern struct bl_serial *bldev_read_serial(int fd, const char *filename); -extern enum bl_path_state_e bldev_read_ap_state(int fd); -extern int bl_discover_devices(void); - -#define BL_LOG_INFO(fmt...) syslog(LOG_INFO, fmt) -#define BL_LOG_WARNING(fmt...) syslog(LOG_WARNING, fmt) -#define BL_LOG_ERR(fmt...) syslog(LOG_ERR, fmt) -#define BL_LOG_DEBUG(fmt...) syslog(LOG_DEBUG, fmt) -#endif diff --git a/nfs-utils-2.5.2/utils/blkmapd/device-inq.c b/nfs-utils-2.5.2/utils/blkmapd/device-inq.c deleted file mode 100644 index c7952c3..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/device-inq.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * device-inq.c: inquire SCSI device information. - * - * Copyright (c) 2010 EMC Corporation, Haiying Tang - * All rights reserved. - * - * This program refers to "SCSI Primary Commands - 3 (SPC-3) - * at http://www.t10.org and sg_inq.c in sg3_utils-1.26 for - * Linux OS SCSI subsystem, by D. Gilbert. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "device-discovery.h" - -#define DEF_ALLOC_LEN 255 -#define MX_ALLOC_LEN (0xc000 + 0x80) - -static struct bl_serial *bl_create_scsi_string(int len, const char *bytes) -{ - struct bl_serial *s; - - s = malloc(sizeof(*s) + len); - if (s) { - s->data = (char *)&s[1]; - s->len = len; - memcpy(s->data, bytes, len); - } - return s; -} - -static void bl_free_scsi_string(struct bl_serial *str) -{ - if (str) - free(str); -} - -#define sg_io_ok(io_hdr) \ - ((((io_hdr).status & 0x7e) == 0) && \ - ((io_hdr).host_status == 0) && \ - (((io_hdr).driver_status & 0x0f) == 0)) - -static int sg_timeout = 1 * 1000; - -static int bldev_inquire_page(int fd, int page, char *buffer, int len) -{ - unsigned char cmd[] = { INQUIRY, 0, 0, 0, 0, 0 }; - unsigned char sense_b[28]; - struct sg_io_hdr io_hdr; - if (page >= 0) { - cmd[1] = 1; - cmd[2] = page; - } - cmd[3] = (unsigned char)((len >> 8) & 0xff); - cmd[4] = (unsigned char)(len & 0xff); - - memset(&io_hdr, 0, sizeof(struct sg_io_hdr)); - io_hdr.interface_id = 'S'; - io_hdr.cmd_len = sizeof(cmd); - io_hdr.mx_sb_len = sizeof(sense_b); - io_hdr.dxfer_direction = SG_DXFER_FROM_DEV; - io_hdr.dxfer_len = len; - io_hdr.dxferp = buffer; - io_hdr.cmdp = cmd; - io_hdr.sbp = sense_b; - io_hdr.timeout = sg_timeout; - if (ioctl(fd, SG_IO, &io_hdr) < 0) - return -1; - - if (sg_io_ok(io_hdr)) - return 0; - return -1; -} - -static int bldev_inquire_pages(int fd, int page, char **buffer) -{ - int status = 0; - char *tmp; - int len; - - *buffer = calloc(DEF_ALLOC_LEN, sizeof(char)); - if (!*buffer) { - BL_LOG_ERR("%s: Out of memory!\n", __func__); - return -ENOMEM; - } - - status = bldev_inquire_page(fd, page, *buffer, DEF_ALLOC_LEN); - if (status) - goto out; - - status = -1; - if ((*(*buffer + 1) & 0xff) != page) - goto out; - - len = (*(*buffer + 2) << 8) + *(*buffer + 3) + 4; - if (len > MX_ALLOC_LEN) { - BL_LOG_ERR("SCSI response length too long: %d\n", len); - goto out; - } - if (len > DEF_ALLOC_LEN) { - tmp = realloc(*buffer, len); - if (!tmp) { - BL_LOG_ERR("%s: Out of memory!\n", __func__); - status = -ENOMEM; - goto out; - } - *buffer = tmp; - status = bldev_inquire_page(fd, page, *buffer, len); - if (status) - goto out; - } - status = 0; - out: - return status; -} - -/* For EMC multipath devices, use VPD page (0xc0) to get status. - * For other devices, return ACTIVE for now - */ -extern enum bl_path_state_e bldev_read_ap_state(int fd) -{ - int status = 0; - char *buffer = NULL; - enum bl_path_state_e ap_state = BL_PATH_STATE_ACTIVE; - - status = bldev_inquire_pages(fd, 0xc0, &buffer); - if (status) - goto out; - - if (buffer[4] < 0x02) - ap_state = BL_PATH_STATE_PASSIVE; - out: - if (buffer) - free(buffer); - return ap_state; -} - -struct bl_serial *bldev_read_serial(int fd, const char *filename) -{ - struct bl_serial *serial_out = NULL; - int status = 0; - char *buffer; - struct bl_dev_id *dev_root, *dev_id; - unsigned int pos, len, current_id = 0; - size_t devid_len = sizeof(struct bl_dev_id) - sizeof(unsigned char); - - status = bldev_inquire_pages(fd, 0x83, &buffer); - if (status) - goto out; - - dev_root = (struct bl_dev_id *)buffer; - - pos = 0; - current_id = 0; - len = dev_root->len; - - if (len < devid_len) - goto out; - - while (pos < (len - devid_len)) { - dev_id = (struct bl_dev_id *)&(dev_root->data[pos]); - pos += (dev_id->len + devid_len); - - /* Some targets export zero length EVPD pages, - * skip them to not confuse the device id - * cache. - */ - if (!dev_id->len) - continue; - - if ((dev_id->ids & 0xf) < current_id) - continue; - switch (dev_id->ids & 0xf) { - /* We process SCSI ID with four ID cases: 0, 1, 2 and 3. - * When more than one ID is available, priority is - * 3>2>1>0. - */ - case 2: /* EUI-64 based */ - if ((dev_id->len != 8) && (dev_id->len != 12) && - (dev_id->len != 16)) - break; - /* FALLTHRU */ - case 3: /* NAA */ - /* TODO: NAA validity judgement too complicated, - * so just ingore it here. - */ - if ((dev_id->type & 0xf) != 1) { - BL_LOG_ERR("Binary code_set expected\n"); - break; - } - /* FALLTHRU */ - case 0: /* vendor specific */ - case 1: /* T10 vendor identification */ - current_id = dev_id->ids & 0xf; - if (serial_out) - bl_free_scsi_string(serial_out); - serial_out = bl_create_scsi_string(dev_id->len, - dev_id->data); - break; - } - if (current_id == 3) - break; - } - out: - if (!serial_out) - serial_out = bl_create_scsi_string(strlen(filename), filename); - if (buffer) - free(buffer); - return serial_out; -} diff --git a/nfs-utils-2.5.2/utils/blkmapd/device-process.c b/nfs-utils-2.5.2/utils/blkmapd/device-process.c deleted file mode 100644 index f53a616..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/device-process.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * device-process.c: detailed processing of device information sent - * from kernel. - * - * Copyright (c) 2006 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * Fred Isaman - * - * Copyright (c) 2010 EMC Corporation, Haiying Tang - * - * Used codes in linux/fs/nfs/blocklayout/blocklayoutdev.c. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "device-discovery.h" - -uint32_t *blk_overflow(uint32_t * p, uint32_t * end, size_t nbytes) -{ - uint32_t *q = p + ((nbytes + 3) >> 2); - - if (q > end || q < p) - return NULL; - return p; -} - -static int decode_blk_signature(uint32_t **pp, uint32_t * end, - struct bl_sig *sig) -{ - int i; - uint32_t siglen, *p = *pp; - - BLK_READBUF(p, end, 4); - READ32(sig->si_num_comps); - if (sig->si_num_comps == 0) { - BL_LOG_ERR("0 components in sig\n"); - goto out_err; - } - if (sig->si_num_comps >= BLOCK_MAX_SIG_COMP) { - BL_LOG_ERR("number of sig comps %i >= BLOCK_MAX_SIG_COMP\n", - sig->si_num_comps); - goto out_err; - } - for (i = 0; i < sig->si_num_comps; i++) { - struct bl_sig_comp *comp = &sig->si_comps[i]; - - BLK_READBUF(p, end, 12); - READ64(comp->bs_offset); - READ32(siglen); - comp->bs_length = siglen; - BLK_READBUF(p, end, siglen); - /* Note we rely here on fact that sig is used immediately - * for mapping, then thrown away. - */ - comp->bs_string = (char *)p; - p += ((siglen + 3) >> 2); - } - *pp = p; - return 0; - out_err: - return -EIO; -} - -/* - * Read signature from device and compare to sig_comp - * return: 0=match, 1=no match, -1=error - */ -static int -read_cmp_blk_sig(struct bl_disk *disk, int fd, struct bl_sig_comp *comp) -{ - const char *dev_name = disk->valid_path->full_path; - int ret = -1; - ssize_t siglen = comp->bs_length; - int64_t bs_offset = comp->bs_offset; - char *sig = NULL; - - sig = (char *)malloc(siglen); - if (!sig) { - BL_LOG_ERR("%s: Out of memory\n", __func__); - goto out; - } - - if (bs_offset < 0) - bs_offset += (((int64_t) disk->size) << 9); - if (lseek64(fd, bs_offset, SEEK_SET) == -1) { - BL_LOG_ERR("File %s lseek error\n", dev_name); - goto out; - } - - if (read(fd, sig, siglen) != siglen) { - BL_LOG_ERR("File %s read error\n", dev_name); - goto out; - } - - ret = memcmp(sig, comp->bs_string, siglen); - - out: - if (sig) - free(sig); - return ret; -} - -/* - * All signatures in sig must be found on disk for verification. - * Returns True if sig matches, False otherwise. - */ -static int verify_sig(struct bl_disk *disk, struct bl_sig *sig) -{ - const char *dev_name = disk->valid_path->full_path; - int fd, i, rv; - - fd = open(dev_name, O_RDONLY | O_LARGEFILE); - if (fd < 0) { - BL_LOG_ERR("%s: %s could not be opened for read\n", __func__, - dev_name); - return 0; - } - - rv = 1; - - for (i = 0; i < sig->si_num_comps; i++) { - if (read_cmp_blk_sig(disk, fd, &sig->si_comps[i])) { - rv = 0; - break; - } - } - - if (fd >= 0) - close(fd); - return rv; -} - -/* - * map_sig_to_device() - * Given a signature, walk the list of visible disks searching for - * a match. Returns True if mapping was done, False otherwise. - * - * While we're at it, fill in the vol->bv_size. - */ -static int map_sig_to_device(struct bl_sig *sig, struct bl_volume *vol) -{ - int mapped = 0; - struct bl_disk *disk; - - /* scan disk list to find out match device */ - for (disk = visible_disk_list; disk; disk = disk->next) { - /* FIXME: should we use better algorithm for disk scan? */ - mapped = verify_sig(disk, sig); - if (mapped) { - BL_LOG_INFO("%s: using device %s\n", - __func__, disk->valid_path->full_path); - vol->param.bv_dev = disk->dev; - vol->bv_size = disk->size; - break; - } - } - return mapped; -} - -/* We are given an array of XDR encoded array indices, each of which should - * refer to a previously decoded device. Translate into a list of pointers - * to the appropriate pnfs_blk_volume's. - */ -static int set_vol_array(uint32_t **pp, uint32_t *end, - struct bl_volume *vols, int working) -{ - int i, index; - uint32_t *p = *pp; - struct bl_volume **array = vols[working].bv_vols; - - for (i = 0; i < vols[working].bv_vol_n; i++) { - BLK_READBUF(p, end, 4); - READ32(index); - if ((index < 0) || (index >= working)) { - BL_LOG_ERR("set_vol_array: Id %i out of range\n", - index); - goto out_err; - } - array[i] = &vols[index]; - } - *pp = p; - return 0; - out_err: - return -EIO; -} - -static uint64_t sum_subvolume_sizes(struct bl_volume *vol) -{ - int i; - uint64_t sum = 0; - - for (i = 0; i < vol->bv_vol_n; i++) - sum += vol->bv_vols[i]->bv_size; - return sum; -} - -static int -decode_blk_volume(uint32_t **pp, uint32_t *end, struct bl_volume *vols, int voln, - int *array_cnt) -{ - int status = 0, j; - struct bl_sig sig; - uint32_t *p = *pp; - struct bl_volume *vol = &vols[voln]; - uint64_t tmp; - - BLK_READBUF(p, end, 4); - READ32(vol->bv_type); - - switch (vol->bv_type) { - case BLOCK_VOLUME_SIMPLE: - *array_cnt = 0; - status = decode_blk_signature(&p, end, &sig); - if (status) - return status; - status = map_sig_to_device(&sig, vol); - if (!status) { - BL_LOG_ERR("Could not find disk for device\n"); - return -ENXIO; - } - BL_LOG_INFO("%s: simple %d\n", __func__, voln); - status = 0; - break; - case BLOCK_VOLUME_SLICE: - BLK_READBUF(p, end, 16); - READ_SECTOR(vol->param.bv_offset); - READ_SECTOR(vol->bv_size); - *array_cnt = vol->bv_vol_n = 1; - BL_LOG_INFO("%s: slice %d\n", __func__, voln); - status = set_vol_array(&p, end, vols, voln); - break; - case BLOCK_VOLUME_STRIPE: - BLK_READBUF(p, end, 8); - READ_SECTOR(vol->param.bv_stripe_unit); - off_t stripe_unit = vol->param.bv_stripe_unit; - /* Check limitations imposed by device-mapper */ - if ((stripe_unit & (stripe_unit - 1)) != 0 - || stripe_unit < (off_t) (sysconf(_SC_PAGE_SIZE) >> 9)) - return -EIO; - BLK_READBUF(p, end, 4); - READ32(vol->bv_vol_n); - if (!vol->bv_vol_n) - return -EIO; - *array_cnt = vol->bv_vol_n; - BL_LOG_INFO("%s: stripe %d nvols=%d unit=%ld\n", __func__, voln, - vol->bv_vol_n, (long)stripe_unit); - status = set_vol_array(&p, end, vols, voln); - if (status) - return status; - for (j = 1; j < vol->bv_vol_n; j++) { - if (vol->bv_vols[j]->bv_size != - vol->bv_vols[0]->bv_size) { - BL_LOG_ERR("varying subvol size\n"); - return -EIO; - } - } - vol->bv_size = vol->bv_vols[0]->bv_size * vol->bv_vol_n; - break; - case BLOCK_VOLUME_CONCAT: - BLK_READBUF(p, end, 4); - READ32(vol->bv_vol_n); - if (!vol->bv_vol_n) - return -EIO; - *array_cnt = vol->bv_vol_n; - BL_LOG_INFO("%s: concat %d %d\n", __func__, voln, - vol->bv_vol_n); - status = set_vol_array(&p, end, vols, voln); - if (status) - return status; - vol->bv_size = sum_subvolume_sizes(vol); - break; - default: - BL_LOG_ERR("Unknown volume type %i\n", vol->bv_type); - out_err: - return -EIO; - } - *pp = p; - return status; -} - -uint64_t process_deviceinfo(const char *dev_addr_buf, - unsigned int dev_addr_len, - uint32_t *major, uint32_t *minor) -{ - int num_vols, i, status, count; - uint32_t *p, *end; - struct bl_volume *vols = NULL, **arrays = NULL, **arrays_ptr = NULL; - uint64_t dev = 0; - - p = (uint32_t *) dev_addr_buf; - end = (uint32_t *) ((char *)p + dev_addr_len); - - /* Decode block volume */ - BLK_READBUF(p, end, 4); - READ32(num_vols); - BL_LOG_INFO("%s: %d vols\n", __func__, num_vols); - if (num_vols <= 0) - goto out_err; - - vols = (struct bl_volume *)malloc(num_vols * sizeof(struct bl_volume)); - if (!vols) { - BL_LOG_ERR("%s: Out of memory\n", __func__); - goto out_err; - } - - /* Each volume in vols array needs its own array. Save time by - * allocating them all in one large hunk. Because each volume - * array can only reference previous volumes, and because once - * a concat or stripe references a volume, it may never be - * referenced again, the volume arrays are guaranteed to fit - * in the suprisingly small space allocated. - */ - arrays_ptr = arrays = - (struct bl_volume **)malloc(num_vols * 2 * - sizeof(struct bl_volume *)); - if (!arrays) { - BL_LOG_ERR("%s: Out of memory\n", __func__); - goto out_err; - } - - for (i = 0; i < num_vols; i++) { - vols[i].bv_vols = arrays_ptr; - status = decode_blk_volume(&p, end, vols, i, &count); - if (status) - goto out_err; - arrays_ptr += count; - } - - if (p != end) { - BL_LOG_ERR("p is not equal to end!\n"); - goto out_err; - } - - dev = dm_device_create(vols, num_vols); - if (dev) { - *major = MAJOR(dev); - *minor = MINOR(dev); - } - - out_err: - if (vols) - free(vols); - if (arrays) - free(arrays); - return dev; -} diff --git a/nfs-utils-2.5.2/utils/blkmapd/dm-device.c b/nfs-utils-2.5.2/utils/blkmapd/dm-device.c deleted file mode 100644 index ee20d54..0000000 --- a/nfs-utils-2.5.2/utils/blkmapd/dm-device.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * dm-device.c: create or remove device via device mapper API. - * - * Copyright (c) 2010 EMC Corporation, Haiying Tang - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "device-discovery.h" - -#define DM_DEV_NAME_LEN 256 - -#ifndef DM_MAX_TYPE_NAME -#define DM_MAX_TYPE_NAME 16 -#endif - -#define DM_PARAMS_LEN 512 /* XXX: is this enough for target? */ -#define TYPE_HAS_DEV(type) ((type == BLOCK_VOLUME_SIMPLE) || \ - (type == BLOCK_VOLUME_PSEUDO)) - -struct bl_dm_table { - uint64_t offset; - uint64_t size; - char target_type[DM_MAX_TYPE_NAME]; - char params[DM_PARAMS_LEN]; - struct bl_dm_table *next; -}; - -struct bl_dm_tree { - uint64_t dev; - struct dm_tree *tree; - struct bl_dm_tree *next; -}; - -static const char dm_name[] = "pnfs_vol_%u"; - -static unsigned int dev_count; - -static inline struct bl_dm_table *bl_dm_table_alloc(void) -{ - return (struct bl_dm_table *)calloc(1, sizeof(struct bl_dm_table)); -} - -static void bl_dm_table_free(struct bl_dm_table *bl_table_head) -{ - struct bl_dm_table *p; - - while (bl_table_head) { - p = bl_table_head->next; - free(bl_table_head); - bl_table_head = p; - } -} - -static void add_to_bl_dm_table(struct bl_dm_table **bl_table_head, - struct bl_dm_table *table) -{ - struct bl_dm_table *p; - - if (!*bl_table_head) { - *bl_table_head = table; - return; - } - p = *bl_table_head; - while (p->next) - p = p->next; - p->next = table; -} - -struct bl_dm_tree *bl_tree_head; - -static struct bl_dm_tree *find_bl_dm_tree(uint64_t dev) -{ - struct bl_dm_tree *p; - - for (p = bl_tree_head; p; p = p->next) { - if (p->dev == dev) - break; - } - return p; -} - -static void del_from_bl_dm_tree(uint64_t dev) -{ - struct bl_dm_tree *p, *pre = bl_tree_head; - - for (p = pre; p; p = p->next) { - if (p->dev == dev) { - pre->next = p->next; - if (p == bl_tree_head) - bl_tree_head = bl_tree_head->next; - free(p); - break; - } - pre = p; - } -} - -static void add_to_bl_dm_tree(struct bl_dm_tree *tree) -{ - struct bl_dm_tree *p; - - if (!bl_tree_head) { - bl_tree_head = tree; - return; - } - p = bl_tree_head; - while (p->next) - p = p->next; - p->next = tree; - return; -} - -/* - * Create device via device mapper - * return 0 when creation failed - * return dev no for created device - */ -static uint64_t -dm_device_create_mapped(const char *dev_name, struct bl_dm_table *p) -{ - struct dm_task *dmt; - struct dm_info dminfo; - int ret = 0; - - dmt = dm_task_create(DM_DEVICE_CREATE); - if (!dmt) { - BL_LOG_ERR("Create dm_task for %s failed\n", dev_name); - return 0; - } - ret = dm_task_set_name(dmt, dev_name); - if (!ret) - goto err_out; - - while (p) { - ret = - dm_task_add_target(dmt, p->offset, p->size, p->target_type, - p->params); - if (!ret) - goto err_out; - p = p->next; - } - - ret = dm_task_run(dmt) && dm_task_get_info(dmt, &dminfo) - && dminfo.exists; - - if (!ret) - goto err_out; - - dm_task_update_nodes(); - - err_out: - dm_task_destroy(dmt); - - if (!ret) { - BL_LOG_ERR("Create device %s failed\n", dev_name); - return 0; - } - return MKDEV(dminfo.major, dminfo.minor); -} - -static int dm_device_remove_byname(const char *dev_name) -{ - struct dm_task *dmt; - int ret = 0; - - BL_LOG_INFO("%s: %s\n", __func__, dev_name); - - dmt = dm_task_create(DM_DEVICE_REMOVE); - if (!dmt) - return 0; - - ret = dm_task_set_name(dmt, dev_name) && dm_task_run(dmt); - - dm_task_update_nodes(); - dm_task_destroy(dmt); - - return ret; -} - -static int dm_device_remove(uint64_t dev) -{ - struct dm_task *dmt; - struct dm_names *dmnames; - char *name = NULL; - int ret = 0; - - /* Look for dev_name via dev, if dev_name could be transferred here, - we could jump to DM_DEVICE_REMOVE directly */ - - dmt = dm_task_create(DM_DEVICE_LIST); - if (!dmt) { - BL_LOG_ERR("dm_task creation failed\n"); - goto out; - } - - ret = dm_task_run(dmt); - if (!ret) { - BL_LOG_ERR("dm_task_run failed\n"); - goto out; - } - - dmnames = dm_task_get_names(dmt); - if (!dmnames || !dmnames->dev) { - BL_LOG_ERR("dm_task_get_names failed\n"); - goto out; - } - - while (dmnames) { - if (dmnames->dev == dev) { - name = strdup(dmnames->name); - break; - } - dmnames = (void *)dmnames + dmnames->next; - } - - if (!name) { - BL_LOG_ERR("Could not find device\n"); - goto out; - } - - dm_task_update_nodes(); - - out: - if (dmt) - dm_task_destroy(dmt); - - /* Start to remove device */ - if (name) { - ret = dm_device_remove_byname(name); - free(name); - } - - return ret; -} - -static void dm_devicelist_remove(unsigned int start, unsigned int end) -{ - char dev_name[DM_DEV_NAME_LEN]; - unsigned int count; - - if (start >= dev_count || end <= 1 || start >= end - 1) - return; - - for (count = end - 1; count > start; count--) { - snprintf(dev_name, sizeof dev_name, dm_name, count - 1); - dm_device_remove_byname(dev_name); - } - - return; -} - -static void bl_dm_remove_tree(uint64_t dev) -{ - struct bl_dm_tree *p; - - p = find_bl_dm_tree(dev); - if (!p) - return; - - dm_tree_free(p->tree); - del_from_bl_dm_tree(dev); -} - -static int bl_dm_create_tree(uint64_t dev) -{ - struct dm_tree *tree; - struct bl_dm_tree *bl_tree; - - bl_tree = find_bl_dm_tree(dev); - if (bl_tree) - return 1; - - tree = dm_tree_create(); - if (!tree) - return 0; - - if (!dm_tree_add_dev(tree, MAJOR(dev), MINOR(dev))) { - dm_tree_free(tree); - return 0; - } - - bl_tree = malloc(sizeof(struct bl_dm_tree)); - if (!bl_tree) { - dm_tree_free(tree); - return 0; - } - - bl_tree->dev = dev; - bl_tree->tree = tree; - bl_tree->next = NULL; - add_to_bl_dm_tree(bl_tree); - - return 1; -} - -int dm_device_remove_all(uint64_t *dev) -{ - struct bl_dm_tree *p; - struct dm_tree_node *node; - const char *uuid; - int ret = 0; - uint32_t major, minor; - uint64_t bl_dev; - - memcpy(&major, dev, sizeof(uint32_t)); - memcpy(&minor, (void *)dev + sizeof(uint32_t), sizeof(uint32_t)); - bl_dev = MKDEV(major, minor); - p = find_bl_dm_tree(bl_dev); - if (!p) - return ret; - - node = dm_tree_find_node(p->tree, MAJOR(bl_dev), MINOR(bl_dev)); - if (!node) - return ret; - - uuid = dm_tree_node_get_uuid(node); - if (!uuid) - return ret; - - dm_device_remove(bl_dev); - ret = dm_tree_deactivate_children(node, uuid, strlen(uuid)); - dm_task_update_nodes(); - bl_dm_remove_tree(bl_dev); - - return ret; -} - -static int dm_device_exists(char *dev_name) -{ - char fullname[DM_DEV_NAME_LEN]; - - snprintf(fullname, sizeof fullname, "/dev/mapper/%s", dev_name); - return (access(fullname, F_OK) >= 0); -} - -/* TODO: check the value for DM_DEV_NAME_LEN, DM_TYPE_LEN, DM_PARAMS_LEN */ -uint64_t dm_device_create(struct bl_volume *vols, int num_vols) -{ - uint64_t size, stripe_unit, dev = 0; - unsigned int count = dev_count; - int volnum, i, pos; - struct bl_volume *node; - char *tmp; - struct bl_dm_table *table = NULL; - struct bl_dm_table *bl_table_head = NULL; - unsigned int len; - char *dev_name = NULL; - - /* Create pseudo device here */ - for (volnum = 0; volnum < num_vols; volnum++) { - node = &vols[volnum]; - switch (node->bv_type) { - case BLOCK_VOLUME_SIMPLE: - /* Do not need to create device here */ - dev = node->param.bv_dev; - goto continued; - case BLOCK_VOLUME_SLICE: - table = bl_dm_table_alloc(); - if (!table) - goto out; - table->offset = 0; - table->size = node->bv_size; - strcpy(table->target_type, "linear"); - if (!TYPE_HAS_DEV(node->bv_vols[0]->bv_type)) { - free(table); - goto out; - } - dev = node->bv_vols[0]->param.bv_dev; - tmp = table->params; - BL_LOG_INFO("%s: major %llu minor %llu", __func__, - (long long unsigned)MAJOR(dev), - (long long unsigned)MINOR(dev)); - if (!dm_format_dev(tmp, DM_PARAMS_LEN, - MAJOR(dev), MINOR(dev))) { - free(table); - goto out; - } - tmp += strlen(tmp); - sprintf(tmp, " %llu", - (long long unsigned)node->param.bv_offset); - add_to_bl_dm_table(&bl_table_head, table); - break; - case BLOCK_VOLUME_STRIPE: - table = bl_dm_table_alloc(); - if (!table) - goto out; - table->offset = 0; - /* Truncate size to a stripe unit boundary */ - stripe_unit = node->param.bv_stripe_unit; - table->size = - node->bv_size - (node->bv_size % stripe_unit); - strcpy(table->target_type, "striped"); - sprintf(table->params, "%d %llu %n", node->bv_vol_n, - (long long unsigned) stripe_unit, &pos); - /* Copy subdev major:minor to params */ - tmp = table->params + pos; - len = DM_PARAMS_LEN - pos; - for (i = 0; i < node->bv_vol_n; i++) { - if (!TYPE_HAS_DEV(node->bv_vols[i]->bv_type)) { - free(table); - goto out; - } - dev = node->bv_vols[i]->param.bv_dev; - if (!dm_format_dev(tmp, len, MAJOR(dev), - MINOR(dev))) { - free(table); - goto out; - } - pos = strlen(tmp); - tmp += pos; - len -= pos; - sprintf(tmp, " %d ", 0); - tmp += 3; - len -= 3; - } - add_to_bl_dm_table(&bl_table_head, table); - break; - case BLOCK_VOLUME_CONCAT: - size = 0; - for (i = 0; i < node->bv_vol_n; i++) { - table = bl_dm_table_alloc(); - if (!table) - goto out; - table->offset = size; - table->size = node->bv_vols[i]->bv_size; - if (!TYPE_HAS_DEV(node->bv_vols[i]->bv_type)) { - free(table); - goto out; - } - strcpy(table->target_type, "linear"); - tmp = table->params; - dev = node->bv_vols[i]->param.bv_dev; - BL_LOG_INFO("%s: major %lu minor %lu", __func__, - (long unsigned int)MAJOR(dev), - (long unsigned int)MINOR(dev)); - if (!dm_format_dev(tmp, DM_PARAMS_LEN, - MAJOR(dev), MINOR(dev))) { - free(table); - goto out; - } - tmp += strlen(tmp); - sprintf(tmp, " %d", 0); - size += table->size; - add_to_bl_dm_table(&bl_table_head, table); - } - break; - default: - /* Delete previous temporary devices */ - dm_devicelist_remove(count, dev_count); - goto out; - } /* end of swtich */ - /* Create dev_name here. Name of device is pnfs_vol_XXX */ - if (dev_name) - free(dev_name); - dev_name = (char *)calloc(DM_DEV_NAME_LEN, sizeof(char)); - if (!dev_name) { - BL_LOG_ERR("%s: Out of memory\n", __func__); - goto out; - } - do { - snprintf(dev_name, DM_DEV_NAME_LEN, dm_name, - dev_count++); - } while (dm_device_exists(dev_name)); - - dev = dm_device_create_mapped(dev_name, bl_table_head); - BL_LOG_INFO("%s: %d %s %d:%d\n", __func__, volnum, dev_name, - (int) MAJOR(dev), (int) MINOR(dev)); - if (!dev) { - /* Delete previous temporary devices */ - dm_devicelist_remove(count, dev_count); - goto out; - } - node->param.bv_dev = dev; - /* TODO: extend use with PSEUDO later */ - node->bv_type = BLOCK_VOLUME_PSEUDO; - - continued: - if (bl_table_head) - bl_dm_table_free(bl_table_head); - bl_table_head = NULL; - } - out: - if (bl_table_head) { - bl_dm_table_free(bl_table_head); - bl_table_head = NULL; - } - if (dev) - bl_dm_create_tree(dev); - if (dev_name) - free(dev_name); - return dev; -} diff --git a/nfs-utils-2.5.2/utils/exportfs/Makefile.am b/nfs-utils-2.5.2/utils/exportfs/Makefile.am deleted file mode 100644 index 96524c7..0000000 --- a/nfs-utils-2.5.2/utils/exportfs/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man5_MANS = exports.man -man7_MANS = nfsd.man -man8_MANS = exportfs.man - -EXTRA_DIST = $(man5_MANS) $(man7_MANS) $(man8_MANS) -sbin_PROGRAMS = exportfs -exportfs_SOURCES = exportfs.c -exportfs_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a \ - $(LIBWRAP) $(LIBNSL) $(LIBPTHREAD) - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/utils/exportfs/exportfs.c b/nfs-utils-2.5.2/utils/exportfs/exportfs.c deleted file mode 100644 index 9d5e575..0000000 --- a/nfs-utils-2.5.2/utils/exportfs/exportfs.c +++ /dev/null @@ -1,780 +0,0 @@ -/* - * utils/exportfs/exportfs.c - * - * Export file systems to knfsd - * - * Copyright (C) 1995, 1996, 1997 Olaf Kirch - * - * Extensive changes, 1999, Neil Brown - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define INT_TO_LONG_THRESHOLD_SECS (INT_MAX - (60 * 60 * 24)) - -#include "sockaddr.h" -#include "misc.h" -#include "nfsd_path.h" -#include "nfslib.h" -#include "exportfs.h" -#include "xlog.h" -#include "conffile.h" - -static void export_all(int verbose); -static void exportfs(char *arg, char *options, int verbose); -static void unexportfs(char *arg, int verbose); -static void dump(int verbose, int export_format); -static void usage(const char *progname, int n); -static void validate_export(nfs_export *exp); -static int matchhostname(const char *hostname1, const char *hostname2); -static void grab_lockfile(void); -static void release_lockfile(void); - -static const char *lockfile = EXP_LOCKFILE; -static int _lockfd = -1; - -struct state_paths etab; - -static ssize_t exportfs_write(int fd, const char *buf, size_t len) -{ - return nfsd_path_write(fd, buf, len); -} - -/* - * If we aren't careful, changes made by exportfs can be lost - * when multiple exports process run at once: - * - * exportfs process 1 exportfs process 2 - * ------------------------------------------ - * reads etab version A reads etab version A - * adds new export B adds new export C - * writes A+B writes A+C - * - * The locking in support/export/xtab.c will prevent mountd from - * seeing a partially written version of etab, and will prevent - * the two writers above from writing simultaneously and - * corrupting etab, but to prevent problems like the above we - * need these additional lockfile() routines. - */ -static void -grab_lockfile() -{ - _lockfd = open(lockfile, O_CREAT|O_RDWR, 0666); - if (_lockfd != -1) - lockf(_lockfd, F_LOCK, 0); -} -static void -release_lockfile() -{ - if (_lockfd != -1) { - lockf(_lockfd, F_ULOCK, 0); - close(_lockfd); - _lockfd = -1; - } -} - -int -main(int argc, char **argv) -{ - char *options = NULL; - char *progname = NULL; - int f_export = 1; - int f_all = 0; - int f_verbose = 0; - int f_export_format = 0; - int f_reexport = 0; - int f_ignore = 0; - int i, c; - int force_flush = 0; - char *s; - - if ((progname = strrchr(argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; - - xlog_open(progname); - xlog_stderr(1); - xlog_syslog(0); - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("exportfs"); - nfsd_path_init(); - - /* NOTE: following uses "mountd" section of nfs.conf !!!! */ - s = conf_get_str("mountd", "state-directory-path"); - if (s && !state_setup_basedir(argv[0], s)) - exit(1); - - while ((c = getopt(argc, argv, "ad:fhio:ruvs")) != EOF) { - switch(c) { - case 'a': - f_all = 1; - break; - case 'd': - xlog_sconfig(optarg, 1); - break; - case 'f': - force_flush = 1; - break; - case 'h': - usage(progname, 0); - break; - case 'i': - f_ignore = 1; - break; - case 'o': - options = optarg; - break; - case 'r': - f_reexport = 1; - f_all = 1; - break; - case 'u': - f_export = 0; - break; - case 'v': - f_verbose = 1; - break; - case 's': - f_export_format = 1; - break; - default: - usage(progname, 1); - break; - } - } - - if (optind != argc && f_all) { - xlog(L_ERROR, "extra arguments are not permitted with -a or -r"); - return 1; - } - if (f_ignore && (f_all || ! f_export)) { - xlog(L_ERROR, "-i not meaningful with -a, -r or -u"); - return 1; - } - if (f_reexport && ! f_export) { - xlog(L_ERROR, "-r and -u are incompatible"); - return 1; - } -printf("point 1\n"); - if (!setup_state_path_names(progname, ETAB, ETABTMP, ETABLCK, &etab)) - return 1; -printf("point 2\n"); - if (optind == argc && ! f_all) { - if (force_flush) { - cache_flush(1); - free_state_path_names(&etab); - return 0; - } else { - xtab_export_read(); - dump(f_verbose, f_export_format); - free_state_path_names(&etab); - export_freeall(); - return 0; - } - } -printf("point 3\n"); - - /* - * Serialize things as best we can - */ - grab_lockfile(); - atexit(release_lockfile); - - if (f_export && ! f_ignore) { - if (! (export_read(_PATH_EXPORTS, 0) + - export_d_read(_PATH_EXPORTS_D, 0))) { - if (f_verbose) - xlog(L_WARNING, "No file systems exported!"); - } - } - if (f_export) { - if (f_all) - export_all(f_verbose); - else - for (i = optind; i < argc ; i++) - exportfs(argv[i], options, f_verbose); - } - /* If we are unexporting everything, then - * don't care about what should be exported, as that - * may require DNS lookups.. - */ - if (! ( !f_export && f_all)) { - /* note: xtab_*_read does not update entries if they already exist, - * so this will not lose new options - */ - if (!f_reexport) - xtab_export_read(); - if (!f_export) - for (i = optind ; i < argc ; i++) - unexportfs(argv[i], f_verbose); - } - xtab_export_write(); - cache_flush(force_flush); - free_state_path_names(&etab); - export_freeall(); - - return export_errno; -} - -/* - * export_all finds all entries and - * marks them xtabent and mayexport so that they get exported - */ -static void -export_all(int verbose) -{ - nfs_export *exp; - int i; - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (verbose) - printf("exporting %s:%s\n", - exp->m_client->m_hostname, - exp->m_export.e_path); - exp->m_xtabent = 1; - exp->m_mayexport = 1; - exp->m_changed = 1; - exp->m_warned = 0; - validate_export(exp); - } - } -} - - -static void -exportfs_parsed(char *hname, char *path, char *options, int verbose) -{ - struct exportent *eep; - nfs_export *exp = NULL; - struct addrinfo *ai = NULL; - int htype; - - if ((htype = client_gettype(hname)) == MCL_FQDN) { - ai = host_addrinfo(hname); - if (ai != NULL) { - exp = export_find(ai, path); - hname = ai->ai_canonname; - } - } else - exp = export_lookup(hname, path, 0); - - if (!exp) { - if (!(eep = mkexportent(hname, path, options)) || - !(exp = export_create(eep, 0))) - goto out; - } else if (!updateexportent(&exp->m_export, options)) - goto out; - - if (verbose) - printf("exporting %s:%s\n", exp->m_client->m_hostname, - exp->m_export.e_path); - exp->m_xtabent = 1; - exp->m_mayexport = 1; - exp->m_changed = 1; - exp->m_warned = 0; - validate_export(exp); - -out: - nfs_freeaddrinfo(ai); -} - -static int exportfs_generic(char *arg, char *options, int verbose) -{ - char *path; - - if ((path = strchr(arg, ':')) != NULL) - *path++ = '\0'; - - if (!path || *path != '/') - return 1; - - exportfs_parsed(arg, path, options, verbose); - return 0; -} - -static int exportfs_ipv6(char *arg, char *options, int verbose) -{ - char *path, *c; - - arg++; - c = strchr(arg, ']'); - if (c == NULL) - return 1; - - /* no colon means this is a wildcarded DNS hostname */ - if (memchr(arg, ':', c - arg) == NULL) - return exportfs_generic(--arg, options, verbose); - - path = strstr(c, ":/"); - if (path == NULL) - return 1; - *path++ = '\0'; - - /* if there's anything between the closing brace and the - * path separator, it's probably a prefix length */ - memmove(c, c + 1, path - c); - - exportfs_parsed(arg, path, options, verbose); - return 0; -} - -static void -exportfs(char *arg, char *options, int verbose) -{ - int failed; - - if (*arg == '[') - failed = exportfs_ipv6(arg, options, verbose); - else - failed = exportfs_generic(arg, options, verbose); - if (failed) - xlog(L_ERROR, "Invalid export syntax: %s", arg); -} - -static void -unexportfs_parsed(char *hname, char *path, int verbose) -{ - nfs_export *exp; - struct addrinfo *ai = NULL; - int htype; - int success = 0; - - if ((htype = client_gettype(hname)) == MCL_FQDN) { - ai = host_addrinfo(hname); - if (ai) - hname = ai->ai_canonname; - } - - /* - * It's possible the specified path ends with a '/'. But - * the entry from exportlist won't has the trailing '/', - * so need to deal with it. - */ - size_t nlen = strlen(path); - while (path[nlen - 1] == '/') - nlen--; - - for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { - if (strlen(exp->m_export.e_path) != nlen) - continue; - if (path && strncmp(path, exp->m_export.e_path, nlen)) - continue; - if (htype != exp->m_client->m_type) - continue; - if (htype == MCL_FQDN - && !matchhostname(exp->m_export.e_hostname, - hname)) - continue; - if (htype != MCL_FQDN - && strcasecmp(exp->m_export.e_hostname, hname)) - continue; - if (verbose) { -#if 0 - if (exp->m_exported) { - printf("unexporting %s:%s from kernel\n", - exp->m_client->m_hostname, - exp->m_export.e_path); - } - else -#endif - printf("unexporting %s:%s\n", - exp->m_client->m_hostname, - exp->m_export.e_path); - } - exp->m_xtabent = 0; - exp->m_mayexport = 0; - success = 1; - } - if (!success) - xlog(L_ERROR, "Could not find '%s:%s' to unexport.", hname, path); - - nfs_freeaddrinfo(ai); -} - -static int unexportfs_generic(char *arg, int verbose) -{ - char *path; - - if ((path = strchr(arg, ':')) != NULL) - *path++ = '\0'; - - if (!path || *path != '/') - return 1; - - unexportfs_parsed(arg, path, verbose); - return 0; -} - -static int unexportfs_ipv6(char *arg, int verbose) -{ - char *path, *c; - - arg++; - c = strchr(arg, ']'); - if (c == NULL) - return 1; - - /* no colon means this is a wildcarded DNS hostname */ - if (memchr(arg, ':', c - arg) == NULL) - return unexportfs_generic(--arg, verbose); - - path = strstr(c, ":/"); - if (path == NULL) - return 1; - *path++ = '\0'; - - /* if there's anything between the closing brace and the - * path separator, it's probably a prefix length */ - memmove(c, c + 1, path - c); - - unexportfs_parsed(arg, path, verbose); - return 0; -} - -static void -unexportfs(char *arg, int verbose) -{ - int failed; - - if (*arg == '[') - failed = unexportfs_ipv6(arg, verbose); - else - failed = unexportfs_generic(arg, verbose); - if (failed) - xlog(L_ERROR, "Invalid export syntax: %s", arg); -} - -static int can_test(void) -{ - char buf[1024] = { 0 }; - int fd; - int n; - size_t bufsiz = sizeof(buf); - - fd = open("/proc/net/rpc/auth.unix.ip/channel", O_WRONLY); - if (fd < 0) - return 0; - - /* - * We introduce tolerance of 1 day to ensure that we use a - * LONG_MAX for the expiry timestamp before it is actually - * needed. To use LONG_MAX, the kernel code must have - * commit 2f74f972 (sunrpc: prepare NFS for 2038). - */ - if (time(NULL) > INT_TO_LONG_THRESHOLD_SECS) - snprintf(buf, bufsiz-1, "nfsd 0.0.0.0 %ld -test-client-\n", LONG_MAX); - else - snprintf(buf, bufsiz-1, "nfsd 0.0.0.0 %d -test-client-\n", INT_MAX); - - n = write(fd, buf, strlen(buf)); - close(fd); - if (n < 0) - return 0; - - fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY); - if (fd < 0) - return 0; - close(fd); - return 1; -} - -static int test_export(nfs_export *exp, int with_fsid) -{ - char *path = exp->m_export.e_path; - int flags = exp->m_export.e_flags | (with_fsid ? NFSEXP_FSID : 0); - /* beside max path, buf size should take protocol str into account */ - char buf[NFS_MAXPATHLEN+1+64] = { 0 }; - char *bp = buf; - int len = sizeof(buf); - int fd, n; - - n = snprintf(buf, len, "-test-client- "); - bp += n; - len -= n; - qword_add(&bp, &len, path); - if (len < 1) - return 0; - snprintf(bp, len, " 3 %d 65534 65534 0\n", flags); - fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY); - if (fd < 0) - return 0; - n = exportfs_write(fd, buf, strlen(buf)); - close(fd); - if (n < 0) - return 0; - return 1; -} - -static void -validate_export(nfs_export *exp) -{ - /* Check that the given export point is potentially exportable. - * We just give warnings here, don't cause anything to fail. - * If a path doesn't exist, or is not a dir or file, give an warning - * otherwise trial-export to '-test-client-' and check for failure. - */ - struct stat stb; - char *path = exportent_realpath(&exp->m_export); - struct statfs64 stf; - int fs_has_fsid = 0; - - if (stat(path, &stb) < 0) { - xlog(L_ERROR, "Failed to stat %s: %m", path); - return; - } - if (!S_ISDIR(stb.st_mode)) { - xlog(L_ERROR, "%s is not a directory. " - "Remote access will fail", path); - return; - } - if (!can_test()) - return; - - if (!statfs64(path, &stf) && - (stf.f_fsid.__val[0] || stf.f_fsid.__val[1])) - fs_has_fsid = 1; - - if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid || - fs_has_fsid) { - if ( !test_export(exp, 1)) { - xlog(L_ERROR, "%s does not support NFS export", path); - return; - } - } else if ( !test_export(exp, 0)) { - if (test_export(exp, 1)) - xlog(L_ERROR, "%s requires fsid= for NFS export", path); - else - xlog(L_ERROR, "%s does not support NFS export", path); - return; - - } -} - -static _Bool -is_hostname(const char *sp) -{ - if (*sp == '\0' || *sp == '@') - return false; - - for (; *sp != '\0'; sp++) { - if (*sp == '*' || *sp == '?' || *sp == '[' || *sp == '/') - return false; - if (*sp == '\\' && sp[1] != '\0') - sp++; - } - - return true; -} - -/* - * Take care to perform an explicit reverse lookup on presentation - * addresses. Otherwise we don't get a real canonical name or a - * complete list of addresses. - */ -static struct addrinfo * -address_list(const char *hostname) -{ - struct addrinfo *ai; - char *cname; - - ai = host_pton(hostname); - if (ai != NULL) { - /* @hostname was a presentation address */ - cname = host_canonname(ai->ai_addr); - nfs_freeaddrinfo(ai); - if (cname != NULL) - goto out; - } - /* @hostname was a hostname or had no reverse mapping */ - cname = strdup(hostname); - if (cname == NULL) - return NULL; - -out: - ai = host_addrinfo(cname); - free(cname); - return ai; -} - -static int -matchhostname(const char *hostname1, const char *hostname2) -{ - struct addrinfo *results1 = NULL, *results2 = NULL; - struct addrinfo *ai1, *ai2; - int result = 0; - - if (strcasecmp(hostname1, hostname2) == 0) - return 1; - - /* - * Don't pass export wildcards or netgroup names to DNS - */ - if (!is_hostname(hostname1) || !is_hostname(hostname2)) - return 0; - - results1 = address_list(hostname1); - if (results1 == NULL) - goto out; - results2 = address_list(hostname2); - if (results2 == NULL) - goto out; - - if (strcasecmp(results1->ai_canonname, results2->ai_canonname) == 0) { - result = 1; - goto out; - } - - for (ai1 = results1; ai1 != NULL; ai1 = ai1->ai_next) - for (ai2 = results2; ai2 != NULL; ai2 = ai2->ai_next) - if (nfs_compare_sockaddr(ai1->ai_addr, ai2->ai_addr)) { - result = 1; - break; - } - -out: - nfs_freeaddrinfo(results1); - nfs_freeaddrinfo(results2); - return result; -} - -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -__attribute__((format (printf, 2, 3))) -#endif -static char -dumpopt(char c, char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - printf("%c", c); - vprintf(fmt, ap); - va_end(ap); - return ','; -} - -static void -dump(int verbose, int export_format) -{ - /* buf[] size should >= sizeof(struct exportent->e_path) */ - char buf[NFS_MAXPATHLEN+1] = { 0 }; - char *bp; - int len; - nfs_export *exp; - struct exportent *ep; - int htype; - char *hname, c; - - for (htype = 0; htype < MCL_MAXTYPES; htype++) { - for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { - ep = &exp->m_export; - if (!exp->m_xtabent) - continue; /* neilb */ - if (htype == MCL_ANONYMOUS) - hname = (export_format) ? "*" : ""; - else - hname = ep->e_hostname; - if (strlen(ep->e_path) > 14 && !export_format) - printf("%-14s\n\t\t%s", ep->e_path, hname); - else - if (export_format) { - bp = buf; - len = sizeof(buf) - 1; - qword_add(&bp, &len, ep->e_path); - *bp = '\0'; - printf("%s %s", buf, hname); - } else { - printf("%-14s\t%s", ep->e_path, hname); - } - - if (!verbose && !export_format) { - printf("\n"); - continue; - } - c = '('; - if (ep->e_flags & NFSEXP_ASYNC) - c = dumpopt(c, "async"); - else - c = dumpopt(c, "sync"); - if (ep->e_flags & NFSEXP_GATHERED_WRITES) - c = dumpopt(c, "wdelay"); - else - c = dumpopt(c, "no_wdelay"); - if (ep->e_flags & NFSEXP_NOHIDE) - c = dumpopt(c, "nohide"); - else - c = dumpopt(c, "hide"); - if (ep->e_flags & NFSEXP_CROSSMOUNT) - c = dumpopt(c, "crossmnt"); - if (ep->e_flags & NFSEXP_NOSUBTREECHECK) - c = dumpopt(c, "no_subtree_check"); - if (ep->e_flags & NFSEXP_NOAUTHNLM) - c = dumpopt(c, "insecure_locks"); - if (ep->e_flags & NFSEXP_NOREADDIRPLUS) - c = dumpopt(c, "nordirplus"); - if (ep->e_flags & NFSEXP_SECURITY_LABEL) - c = dumpopt(c, "security_label"); - if (ep->e_flags & NFSEXP_NOACL) - c = dumpopt(c, "no_acl"); - if (ep->e_flags & NFSEXP_PNFS) - c = dumpopt(c, "pnfs"); - if (ep->e_flags & NFSEXP_FSID) - c = dumpopt(c, "fsid=%d", ep->e_fsid); - if (ep->e_uuid) - c = dumpopt(c, "fsid=%s", ep->e_uuid); - if (ep->e_mountpoint) - c = dumpopt(c, "mountpoint%s%s", - ep->e_mountpoint[0]?"=":"", - ep->e_mountpoint); - if (ep->e_anonuid != 65534) - c = dumpopt(c, "anonuid=%d", ep->e_anonuid); - if (ep->e_anongid != 65534) - c = dumpopt(c, "anongid=%d", ep->e_anongid); - switch(ep->e_fslocmethod) { - case FSLOC_NONE: - break; - case FSLOC_REFER: - c = dumpopt(c, "refer=%s", ep->e_fslocdata); - break; - case FSLOC_REPLICA: - c = dumpopt(c, "replicas=%s", ep->e_fslocdata); - break; -#ifdef DEBUG - case FSLOC_STUB: - c = dumpopt(c, "fsloc=stub"); - break; -#endif - } - secinfo_show(stdout, ep); - printf("%c\n", (c != '(')? ')' : ' '); - } - } -} - -static void -usage(const char *progname, int n) -{ - fprintf(stderr, "usage: %s [-adfhioruvs] [host:/path]\n", progname); - exit(n); -} diff --git a/nfs-utils-2.5.2/utils/exportfs/exportfs.man b/nfs-utils-2.5.2/utils/exportfs/exportfs.man deleted file mode 100644 index 91d3589..0000000 --- a/nfs-utils-2.5.2/utils/exportfs/exportfs.man +++ /dev/null @@ -1,334 +0,0 @@ -.\"@(#)exportfs.8" -.\" -.\" Copyright (C) 1995 Olaf Kirch -.\" Modifications 1999-2003 Neil Brown -.\" -.TH exportfs 8 "30 September 2013" -.SH NAME -exportfs \- maintain table of exported NFS file systems -.SH SYNOPSIS -.BI "/usr/sbin/exportfs [-avi] [-o " "options,.." "] [" "client:/path" " ..] -.br -.BI "/usr/sbin/exportfs -r [-v]" -.br -.BI "/usr/sbin/exportfs [-av] -u [" "client:/path" " ..] -.br -.BI "/usr/sbin/exportfs [-v] -.br -.BI "/usr/sbin/exportfs -f" -.br -.BI "/usr/sbin/exportfs -s" -.br -.SH DESCRIPTION -An NFS server maintains a table of local physical file systems -that are accessible to NFS clients. -Each file system in this table is referred to as an -.IR "exported file system" , -or -.IR export , -for short. -.PP -The -.B exportfs -command maintains the current table of exports for the NFS server. -The master export table is kept in a file named -.IR /var/lib/nfs/etab . -This file is read by -.B rpc.mountd -when a client sends an NFS MOUNT request. -.PP -Normally the master export table is initialized with the contents of -.I /etc/exports -and files under -.I /etc/exports.d -by invoking -.BR "exportfs -a" . -However, a system administrator can choose to add or delete -exports without modifying -.I /etc/exports -or files under -.I /etc/exports.d -by using the -.B exportfs -command. -.PP -.B exportfs -and its partner program -.B rpc.mountd -work in one of two modes: a legacy mode which applies to 2.4 and -earlier versions of the Linux kernel, and a new mode which applies to -2.6 and later versions, providing the -.B nfsd -virtual filesystem has been mounted at -.I /proc/fs/nfsd -or -.IR /proc/fs/nfs . -On 2.6 kernels, if this filesystem is not mounted, the legacy mode is used. -.PP -In the new mode, -.B exportfs -does not give any information to the kernel, but provides it only to -.B rpc.mountd -through the -.I /var/lib/nfs/etab -file. -.B rpc.mountd -then manages kernel requests for information about exports, as needed. -.PP -In the legacy mode, -exports which identify a specific host, rather than a subnet or netgroup, -are entered directly into the kernel's export table, -as well as being written to -.IR /var/lib/nfs/etab . -Further, exports listed in -.I /var/lib/nfs/rmtab -which match a non host-specific export request will cause an -appropriate export entry for the host given in -.I rmtab -to be added to the kernel's export table. -.SH OPTIONS -.TP -.B \-d kind " or " \-\-debug kind -Turn on debugging. Valid kinds are: all, auth, call, general and parse. -Debugging can also be turned on by setting -.B debug= -in the -.B [exportfs] -section of -.IR /etc/nfs.conf . - -.TP -.B -a -Export or unexport all directories. -.TP -.BI "-o " options,... -Specify a list of export options in the same manner as in -.BR exports (5). -.TP -.B -i -Ignore the -.I /etc/exports -file and files under -.I /etc/exports.d -directory. Only default options and options given on the command line are used. -.TP -.B -r -Reexport all directories, synchronizing -.I /var/lib/nfs/etab -with -.IR /etc/exports -and files under -.IR /etc/exports.d . -This option removes entries in -.I /var/lib/nfs/etab -which have been deleted from -.I /etc/exports -or files under -.IR /etc/exports.d , -and removes any entries from the -kernel export table which are no longer valid. -.TP -.B -u -Unexport one or more directories. -.TP -.B -f -If -.I /proc/fs/nfsd -or -.I /proc/fs/nfs -is mounted, flush everything out of the kernel's export table. -Fresh entries for active clients are added to the kernel's export table by -.B rpc.mountd -when they make their next NFS mount request. -.TP -.B -v -Be verbose. When exporting or unexporting, show what's going on. When -displaying the current export list, also display the list of export -options. -.TP -.B -s -Display the current export list suitable for /etc/exports. - -.SH CONFIGURATION FILE -The -.B [exportfs] -section of the -.I /etc/nfs.conf -configuration file can contain a -.B debug -value, which can be one or more from the list -.BR general , -.BR call , -.BR auth , -.BR parse , -.BR all . -When a list is given, the members should be comma-separated. - -.B exportfs -will also recognize the -.B state-directory-path -value from the -.B [mountd] -section. - -.SH DISCUSSION -.SS Exporting Directories -The first synopsis shows how to invoke -.B exportfs -when adding new entries to the export table. When using -.BR "exportfs -a" , -all exports listed in -.I /etc/exports -and files under -.I /etc/exports.d -are added to -.IR /var/lib/nfs/etab . -The kernel's export table is also updated as needed. -.PP -The -.I host:/path -argument specifies a local directory to export, -along with the client or clients who are permitted to access it. -See -.B exports(5) -for a description of supported options and access list formats. -.PP -IPv6 presentation addresses contain colons, which are already used -to separate the "host" and "path" command line arguments. -When specifying a client using a raw IPv6 address, -enclose the address in square brackets. -For IPv6 network addresses, place the prefix just after the closing -bracket. -.PP -To export a directory to the world, simply specify -.IR :/path . -.PP -The export options for a particular host/directory pair derive from -several sources. -The default export options are -.BR sync,ro,root_squash,wdelay . -These can be overridden by entries in -.IR /etc/exports -or files under -.IR /etc/exports.d . -.PP -A system administrator may override options from these sources using the -.B -o -command-line option on -.BR exportfs . -This option takes a comma-separated list of options in the same fashion -as one would specify them in -.IR /etc/exports . -In this way -.B exportfs -can be used to modify the export options of an already exported directory. -.SS Unexporting Directories -The third synopsis shows how to unexport a currently exported directory. -When using -.BR "exportfs -ua" , -all entries listed in -.I /var/lib/nfs/etab -are removed from the kernel export tables, and the file is cleared. This -effectively shuts down all NFS activity. -.PP -To remove an export, specify a -.I host:/path -pair. This deletes the specified entry from -.I /var/lib/nfs/etab -and removes the corresponding kernel entry (if any). -.PP -.SS Dumping the Export Table -Invoking -.B exportfs -without options shows the current list of exported file systems. -Adding the -.B -v -option causes -.B exportfs -to display the export options for each export. -.SH EXAMPLES -The following adds all directories listed in -.I /etc/exports -and files under -.I /etc/exports.d -to -.I /var/lib/nfs/etab -and pushes the resulting export entries into the kernel: -.PP -.nf -.B "# exportfs -a -.fi -.PP -To export the -.I /usr/tmp -directory to host -.BR django , -allowing insecure file locking requests from clients: -.PP -.nf -.B "# exportfs -o insecure_locks django:/usr/tmp -.fi -.PP -To unexport the -.I /usr/tmp -directory: -.PP -.nf -.B "# exportfs -u django:/usr/tmp -.fi -.PP -To unexport all exports listed in -.IR /etc/exports -and files under -.IR /etc/exports.d : -.PP -.nf -.B "# exportfs -au -.fi -.PP -To export the -.I /usr/tmp -directory to IPv6 link-local clients: -.PP -.nf -.B "# exportfs [fe80::]/64:/usr/tmp -.fi -.SH USAGE NOTES -Exporting to IP networks or DNS and NIS domains does not enable clients -from these groups to access NFS immediately. -Rather, these sorts of exports are hints to -.BR rpc.mountd (8) -to grant any mount requests from these clients. -This is usually not a problem, because any existing mounts are preserved in -.I rmtab -across reboots. -.PP -When unexporting a network or domain entry, any current exports to members -of this group will be checked against the remaining valid exports and -if they themselves are no longer valid they will be removed. -.SH FILES -.TP 2.5i -.I /etc/exports -input file listing exports, export options, and access control lists -.TP 2.5i -.I /etc/exports.d -directory where extra input files are stored. -.B Note: -only files that end with -.I .exports -are used. -.TP 2.5i -.I /var/lib/nfs/etab -master table of exports -.TP 2.5i -.I /var/lib/nfs/rmtab -table of clients accessing server's exports -.SH SEE ALSO -.BR exports (5), -.BR nfs.conf (5), -.BR rpc.mountd (8), -.BR netgroup (5) -.SH AUTHORS -Olaf Kirch -.br -Neil Brown diff --git a/nfs-utils-2.5.2/utils/exportfs/exports.man b/nfs-utils-2.5.2/utils/exportfs/exports.man deleted file mode 100644 index 1d17184..0000000 --- a/nfs-utils-2.5.2/utils/exportfs/exports.man +++ /dev/null @@ -1,605 +0,0 @@ -.\"@(#)exports.5" -.\" -.TH exports 5 "31 December 2009" -.SH NAME -exports \- NFS server export table -.SH DESCRIPTION -The file -.I /etc/exports -contains a table of local physical file systems on an NFS server -that are accessible to NFS clients. -The contents of the file are maintained by the server's system -administrator. -.PP -Each file system in this table has a list of options and an -access control list. -The table is used by -.BR exportfs (8) -to give information to -.BR mountd (8). -.PP -The file format is similar to the SunOS -.I exports -file. Each line contains an export point and a whitespace-separated list -of clients allowed to mount the file system at that point. Each listed -client may be immediately followed by a parenthesized, comma-separated -list of export options for that client. No whitespace is permitted -between a client and its option list. -.PP -Also, each line may have one or more specifications for default options -after the path name, in the form of a dash ("\-") followed by an option -list. The option list is used for all subsequent exports on that line -only. -.PP -Blank lines are ignored. A pound sign ("#") introduces a comment to the -end of the line. Entries may be continued across newlines using a -backslash. If an export name contains spaces it should be quoted using -double quotes. You can also specify spaces or other unusual character in -the export name using a backslash followed by the character code as three -octal digits. -.PP -To apply changes to this file, run -.BR "exportfs \-ra" -or restart the NFS server. -.PP -.SS Machine Name Formats -NFS clients may be specified in a number of ways: -.IP "single host -You may specify a host either by an -abbreviated name recognized be the resolver, the fully qualified domain -name, an IPv4 address, or an IPv6 address. IPv6 addresses must not be -inside square brackets in /etc/exports lest they be confused with -character-class wildcard matches. -.IP "IP networks -You can also export directories to all hosts on an IP (sub-) network -simultaneously. This is done by specifying an IP address and netmask pair -as -.IR address/netmask -where the netmask can be specified in dotted-decimal format, or as a -contiguous mask length. -For example, either `/255.255.252.0' or `/22' appended -to the network base IPv4 address results in identical subnetworks with 10 bits -of host. IPv6 addresses must use a contiguous mask length and must not be inside square brackets to avoid confusion with character-class wildcards. Wildcard characters generally do not work on IP addresses, though they -may work by accident when reverse DNS lookups fail. -.IP "wildcards -Machine names may contain the wildcard characters \fI*\fR and \fI?\fR, or may contain character class lists within [square brackets]. -This can be used to make the \fIexports\fR file more compact; for instance, -\fI*.cs.foo.edu\fR matches all hosts in the domain -\fIcs.foo.edu\fR. As these characters also match the dots in a domain -name, the given pattern will also match all hosts within any subdomain -of \fIcs.foo.edu\fR. -.IP "netgroups -NIS netgroups may be given as -.IR @group . -Only the host part of each -netgroup members is consider in checking for membership. Empty host -parts or those containing a single dash (\-) are ignored. -.IP "anonymous -This is specified by a single -.I * -character (not to be confused with the -.I wildcard -entry above) and will match all clients. -.\".TP -.\".B =public -.\"This is a special ``hostname'' that identifies the given directory name -.\"as the public root directory (see the section on WebNFS in -.\".BR nfsd (8) -.\"for a discussion of WebNFS and the public root handle). When using this -.\"convention, -.\".B =public -.\"must be the only entry on this line, and must have no export options -.\"associated with it. Note that this does -.\".I not -.\"actually export the named directory; you still have to set the exports -.\"options in a separate entry. -.\".PP -.\"The public root path can also be specified by invoking -.\".I nfsd -.\"with the -.\".B \-\-public\-root -.\"option. Multiple specifications of a public root will be ignored. -.PP -If a client matches more than one of the specifications above, then -the first match from the above list order takes precedence - regardless of -the order they appear on the export line. However, if a client matches -more than one of the same type of specification (e.g. two netgroups), -then the first match from the order they appear on the export line takes -precedence. -.SS RPCSEC_GSS security -You may use the special strings "gss/krb5", "gss/krb5i", or "gss/krb5p" -to restrict access to clients using rpcsec_gss security. However, this -syntax is deprecated; on linux kernels since 2.6.23, you should instead -use the "sec=" export option: -.TP -.IR sec= -The sec= option, followed by a colon-delimited list of security flavors, -restricts the export to clients using those flavors. Available security -flavors include sys (the default--no cryptographic security), krb5 -(authentication only), krb5i (integrity protection), and krb5p (privacy -protection). For the purposes of security flavor negotiation, order -counts: preferred flavors should be listed first. The order of the sec= -option with respect to the other options does not matter, unless you -want some options to be enforced differently depending on flavor. -In that case you may include multiple sec= options, and following options -will be enforced only for access using flavors listed in the immediately -preceding sec= option. The only options that are permitted to vary in -this way are ro, rw, no_root_squash, root_squash, and all_squash. -.PP -.SS General Options -.BR exportfs -understands the following export options: -.TP -.IR secure -This option requires that requests not using gss originate on an -Internet port less than IPPORT_RESERVED (1024). This option is on by default. -To turn it off, specify -.IR insecure . -(NOTE: older kernels (before upstream kernel version 4.17) enforced this -requirement on gss requests as well.) -.TP -.IR rw -Allow both read and write requests on this NFS volume. The -default is to disallow any request which changes the filesystem. -This can also be made explicit by using -the -.IR ro " option. -.TP -.IR async -This option allows the NFS server to violate the NFS protocol and -reply to requests before any changes made by that request have been -committed to stable storage (e.g. disc drive). - -Using this option usually improves performance, but at the cost that -an unclean server restart (i.e. a crash) can cause data to be lost or -corrupted. - -.TP -.IR sync -Reply to requests only after the changes have been committed to stable -storage (see -.IR async -above). - -In releases of nfs-utils up to and including 1.0.0, the -.I async -option was the -default. In all releases after 1.0.0, -.I sync -is the default, and -.I async -must be explicitly requested if needed. -To help make system administrators aware of this change, -.B exportfs -will issue a warning if neither -.I sync -nor -.I async -is specified. -.TP -.IR no_wdelay -This option has no effect if -.I async -is also set. The NFS server will normally delay committing a write request -to disc slightly if it suspects that another related write request may be in -progress or may arrive soon. This allows multiple write requests to -be committed to disc with the one operation which can improve -performance. If an NFS server received mainly small unrelated -requests, this behaviour could actually reduce performance, so -.IR no_wdelay -is available to turn it off. -The default can be explicitly requested with the -.IR wdelay " option. -.TP -.IR nohide -This option is based on the option of the same name provided in IRIX -NFS. Normally, if a server exports two filesystems one of which is -mounted on the other, then the client will have to mount both -filesystems explicitly to get access to them. If it just mounts the -parent, it will see an empty directory at the place where the other -filesystem is mounted. That filesystem is "hidden". - -Setting the -.I nohide -option on a filesystem causes it not to be hidden, and an -appropriately authorised client will be able to move from the parent to -that filesystem without noticing the change. - -However, some NFS clients do not cope well with this situation as, for -instance, it is then possible for two files in the one apparent -filesystem to have the same inode number. - -The -.I nohide -option is currently only effective on -.I "single host -exports. It does not work reliably with netgroup, subnet, or wildcard -exports. - -This option can be very useful in some situations, but it should be -used with due care, and only after confirming that the client system -copes with the situation effectively. - -The option can be explicitly disabled for NFSv2 and NFSv3 with -.IR hide . - -This option is not relevant when NFSv4 is use. NFSv4 never hides -subordinate filesystems. Any filesystem that is exported will be -visible where expected when using NFSv4. -.TP -.I crossmnt -This option is similar to -.I nohide -but it makes it possible for clients to access all filesystems mounted -on a filesystem marked with -.IR crossmnt . -Thus when a child filesystem "B" is mounted on a parent "A", setting -crossmnt on "A" has a similar effect to setting "nohide" on B. - -With -.I nohide -the child filesystem needs to be explicitly exported. With -.I crossmnt -it need not. If a child of a -.I crossmnt -file is not explicitly exported, then it will be implicitly exported -with the same export options as the parent, except for -.IR fsid= . -This makes it impossible to -.B not -export a child of a -.I crossmnt -filesystem. If some but not all subordinate filesystems of a parent -are to be exported, then they must be explicitly exported and the -parent should not have -.I crossmnt -set. - -The -.I nocrossmnt -option can explictly disable -.I crossmnt -if it was previously set. This is rarely useful. -.TP -.IR no_subtree_check -This option disables subtree checking, which has mild security -implications, but can improve reliability in some circumstances. - -If a subdirectory of a filesystem is exported, but the whole -filesystem isn't then whenever a NFS request arrives, the server must -check not only that the accessed file is in the appropriate filesystem -(which is easy) but also that it is in the exported tree (which is -harder). This check is called the -.IR subtree_check . - -In order to perform this check, the server must include some -information about the location of the file in the "filehandle" that is -given to the client. This can cause problems with accessing files that -are renamed while a client has them open (though in many simple cases -it will still work). - -subtree checking is also used to make sure that files inside -directories to which only root has access can only be accessed if the -filesystem is exported with -.I no_root_squash -(see below), even if the file itself allows more general access. - -As a general guide, a home directory filesystem, which is normally -exported at the root and may see lots of file renames, should be -exported with subtree checking disabled. A filesystem which is mostly -readonly, and at least doesn't see many file renames (e.g. /usr or -/var) and for which subdirectories may be exported, should probably be -exported with subtree checks enabled. - -The default of having subtree checks enabled, can be explicitly -requested with -.IR subtree_check . - -From release 1.1.0 of nfs-utils onwards, the default will be -.I no_subtree_check -as subtree_checking tends to cause more problems than it is worth. -If you genuinely require subtree checking, you should explicitly put -that option in the -.B exports -file. If you put neither option, -.B exportfs -will warn you that the change is pending. - -.TP -.IR insecure_locks -.TP -.IR no_auth_nlm -This option (the two names are synonymous) tells the NFS server not to require authentication of -locking requests (i.e. requests which use the NLM protocol). Normally -the NFS server will require a lock request to hold a credential for a -user who has read access to the file. With this flag no access checks -will be performed. - -Early NFS client implementations did not send credentials with lock -requests, and many current NFS clients still exist which are based on -the old implementations. Use this flag if you find that you can only -lock files which are world readable. - -The default behaviour of requiring authentication for NLM requests can -be explicitly requested with either of the synonymous -.IR auth_nlm , -or -.IR secure_locks . -.\".TP -.\".I noaccess -.\"This makes everything below the directory inaccessible for the named -.\"client. This is useful when you want to export a directory hierarchy to -.\"a client, but exclude certain subdirectories. The client's view of a -.\"directory flagged with noaccess is very limited; it is allowed to read -.\"its attributes, and lookup `.' and `..'. These are also the only entries -.\"returned by a readdir. -.\".TP -.\".IR link_relative -.\"Convert absolute symbolic links (where the link contents start with a -.\"slash) into relative links by prepending the necessary number of ../'s -.\"to get from the directory containing the link to the root on the -.\"server. This has subtle, perhaps questionable, semantics when the file -.\"hierarchy is not mounted at its root. -.\".TP -.\".IR link_absolute -.\"Leave all symbolic link as they are. This is the default operation. - -.TP -.IR mountpoint= path -.TP -.I mp -This option makes it possible to only export a directory if it has -successfully been mounted. -If no path is given (e.g. -.IR mountpoint " or " mp ) -then the export point must also be a mount point. If it isn't then -the export point is not exported. This allows you to be sure that the -directory underneath a mountpoint will never be exported by accident -if, for example, the filesystem failed to mount due to a disc error. - -If a path is given (e.g. -.IR mountpoint= "/path or " mp= /path) -then the nominated path must be a mountpoint for the exportpoint to be -exported. - -.TP -.IR fsid= num|root|uuid -NFS needs to be able to identify each filesystem that it exports. -Normally it will use a UUID for the filesystem (if the filesystem has -such a thing) or the device number of the device holding the -filesystem (if the filesystem is stored on the device). - -As not all filesystems are stored on devices, and not all filesystems -have UUIDs, it is sometimes necessary to explicitly tell NFS how to -identify a filesystem. This is done with the -.I fsid= -option. - -For NFSv4, there is a distinguished filesystem which is the root of -all exported filesystem. This is specified with -.I fsid=root -or -.I fsid=0 -both of which mean exactly the same thing. - -Other filesystems can be identified with a small integer, or a UUID -which should contain 32 hex digits and arbitrary punctuation. - -Linux kernels version 2.6.20 and earlier do not understand the UUID -setting so a small integer must be used if an fsid option needs to be -set for such kernels. Setting both a small number and a UUID is -supported so the same configuration can be made to work on old and new -kernels alike. - -.TP -.IR nordirplus -This option will disable READDIRPLUS request handling. When set, -READDIRPLUS requests from NFS clients return NFS3ERR_NOTSUPP, and -clients fall back on READDIR. This option affects only NFSv3 clients. -.TP -.IR refer= path@host[+host][:path@host[+host]] -A client referencing the export point will be directed to choose from -the given list an alternative location for the filesystem. -(Note that the server must have a mountpoint here, though a different -filesystem is not required; so, for example, -.IR "mount --bind" " /path /path" -is sufficient.) -.TP -.IR replicas= path@host[+host][:path@host[+host]] -If the client asks for alternative locations for the export point, it -will be given this list of alternatives. (Note that actual replication -of the filesystem must be handled elsewhere.) - -.TP -.IR pnfs -This option enables the use of the pNFS extension if the protocol level -is NFSv4.1 or higher, and the filesystem supports pNFS exports. With -pNFS clients can bypass the server and perform I/O directly to storage -devices. The default can be explicitly requested with the -.I no_pnfs -option. - -.TP -.IR security_label -With this option set, clients using NFSv4.2 or higher will be able to -set and retrieve security labels (such as those used by SELinux). This -will only work if all clients use a consistent security policy. Note -that early kernels did not support this export option, and instead -enabled security labels by default. - -.SS User ID Mapping -.PP -.B nfsd -bases its access control to files on the server machine on the uid and -gid provided in each NFS RPC request. The normal behavior a user would -expect is that she can access her files on the server just as she would -on a normal file system. This requires that the same uids and gids are -used on the client and the server machine. This is not always true, nor -is it always desirable. -.PP -Very often, it is not desirable that the root user on a client machine -is also treated as root when accessing files on the NFS server. To this -end, uid 0 is normally mapped to a different id: the so-called -anonymous or -.I nobody -uid. This mode of operation (called `root squashing') is the default, -and can be turned off with -.IR no_root_squash . -.PP -By default, -.\".B nfsd -.\"tries to obtain the anonymous uid and gid by looking up user -.\".I nobody -.\"in the password file at startup time. If it isn't found, a uid and gid -.B exportfs -chooses a uid and gid -of 65534 for squashed access. These values can also be overridden by -the -.IR anonuid " and " anongid -options. -.\".PP -.\"In addition to this, -.\".B nfsd -.\"lets you specify arbitrary uids and gids that should be mapped to user -.\"nobody as well. -Finally, you can map all user requests to the -anonymous uid by specifying the -.IR all_squash " option. -.PP -Here's the complete list of mapping options: -.TP -.IR root_squash -Map requests from uid/gid 0 to the anonymous uid/gid. Note that this does -not apply to any other uids or gids that might be equally sensitive, such as -user -.IR bin -or group -.IR staff . -.TP -.IR no_root_squash -Turn off root squashing. This option is mainly useful for diskless clients. -.TP -.IR all_squash -Map all uids and gids to the anonymous user. Useful for NFS-exported -public FTP directories, news spool directories, etc. The opposite option -is -.IR no_all_squash , -which is the default setting. -.TP -.IR anonuid " and " anongid -These options explicitly set the uid and gid of the anonymous account. -This option is primarily useful for PC/NFS clients, where you might want -all requests appear to be from one user. As an example, consider the -export entry for -.B /home/joe -in the example section below, which maps all requests to uid 150 (which -is supposedly that of user joe). - -.SS Subdirectory Exports - -Normally you should only export only the root of a filesystem. The NFS -server will also allow you to export a subdirectory of a filesystem, -however, this has drawbacks: - -First, it may be possible for a malicious user to access files on the -filesystem outside of the exported subdirectory, by guessing filehandles -for those other files. The only way to prevent this is by using the -.IR no_subtree_check -option, which can cause other problems. - -Second, export options may not be enforced in the way that you would -expect. For example, the -.IR security_label -option will not work on subdirectory exports, and if nested subdirectory -exports change the -.IR security_label -or -.IR sec= -options, NFSv4 clients will normally see only the options on the parent -export. Also, where security options differ, a malicious client may use -filehandle-guessing attacks to access the files from one subdirectory -using the options from another. - - -.SS Extra Export Tables -After reading -.I /etc/exports -.B exportfs -reads files in the -.I /etc/exports.d -directory as extra export tables. Only files ending in -.I .exports -are considered. Files beginning with a dot are ignored. -The format for extra export tables is the same as -.I /etc/exports -. -.IP -.SH EXAMPLE -.PP -.nf -.ta +3i -# sample /etc/exports file -/ master(rw) trusty(rw,no_root_squash) -/projects proj*.local.domain(rw) -/usr *.local.domain(ro) @trusted(rw) -/home/joe pc001(rw,all_squash,anonuid=150,anongid=100) -/pub *(ro,insecure,all_squash) -/srv/www \-sync,rw server @trusted @external(ro) -/foo 2001:db8:9:e54::/64(rw) 192.0.2.0/24(rw) -/build buildhost[0-9].local.domain(rw) -.\"/pub/private (noaccess) -.fi -.PP -The first line exports the entire filesystem to machines master and trusty. -In addition to write access, all uid squashing is turned off for host -trusty. The second and third entry show examples for wildcard hostnames -and netgroups (this is the entry `@trusted'). The fourth line shows the -entry for the PC/NFS client discussed above. Line 5 exports the -public FTP directory to every host in the world, executing all requests -under the nobody account. The -.I insecure -option in this entry also allows clients with NFS implementations that -don't use a reserved port for NFS. -The sixth line exports a directory read-write to the machine 'server' -as well as the `@trusted' netgroup, and read-only to netgroup `@external', -all three mounts with the `sync' option enabled. The seventh line exports -a directory to both an IPv6 and an IPv4 subnet. The eighth line demonstrates -a character class wildcard match. -.\" The last line denies all NFS clients -.\"access to the private directory. -.\".SH CAVEATS -.\"Unlike other NFS server implementations, this -.\".B nfsd -.\"allows you to export both a directory and a subdirectory thereof to -.\"the same host, for instance -.\".IR /usr " and " /usr/X11R6 . -.\"In this case, the mount options of the most specific entry apply. For -.\"instance, when a user on the client host accesses a file in -.\".IR /usr/X11R6 , -.\"the mount options given in the -.\".I /usr/X11R6 -.\"entry apply. This is also true when the latter is a wildcard or netgroup -.\"entry. -.SH FILES -/etc/exports -/etc/exports.d -.SH SEE ALSO -.BR exportfs (8), -.BR netgroup (5), -.BR mountd (8), -.BR nfsd (8), -.BR showmount (8). -.\".SH DIAGNOSTICS -.\"An error parsing the file is reported using syslogd(8) as level NOTICE from -.\"a DAEMON whenever -.\".BR nfsd (8) -.\"or -.\".BR mountd (8) -.\"is started up. Any unknown -.\"host is reported at that time, but often not all hosts are not yet known -.\"to -.\".BR named (8) -.\"at boot time, thus as hosts are found they are reported -.\"with the same -.\".BR syslogd (8) -.\"parameters. diff --git a/nfs-utils-2.5.2/utils/exportfs/nfsd.man b/nfs-utils-2.5.2/utils/exportfs/nfsd.man deleted file mode 100644 index 514153f..0000000 --- a/nfs-utils-2.5.2/utils/exportfs/nfsd.man +++ /dev/null @@ -1,214 +0,0 @@ -.\" -.\" nfsd(7) - The nfsd filesystem -.\" -.\" Copyright (C) 2003 Neil Brown -.\" Licensed for public use under the terms of the FSF -.\" General Public License (GPL) version 2. -.TH nfsd 7 "3 July 2003" -.SH NAME -nfsd \- special filesystem for controlling Linux NFS server -.SH SYNPOSIS -.B "mount -t nfsd nfsd /proc/fs/nfsd" -.SH DESCRIPTION -The -.B nfsd -filesystem is a special filesystem which provides access to the Linux -NFS server. Writing to files in this filesystem can affect the server. -Reading from them can provide information about the server. -.P -As well as this filesystem, there are a collection of files in the -.B procfs -filesystem (normally mounted at -.BR /proc ) -which are used to control the NFS server. -This manual page describes all of these files. -.P -The -.I exportfs -and -.I mountd -programs (part of the nfs-utils package) expect to find this -filesystem mounted at -.B /proc/fs/nfsd -or -.BR /proc/fs/nfs . -.SH DETAILS -Files in the -.B nfsd -filesystem include: -.TP -.B exports -This file contains a list of filesystems that are currently exported -and clients that each filesystem is exported to, together with a list -of export options for that client/filesystem pair. This is similar -to the -.B /proc/fs/nfs/exports -file in 2.4. -One difference is that a client doesn't necessarily correspond to just -one host. It can respond to a large collection of hosts that are -being treated identically. - -Each line of the file contains a path name, a client name, and a -number of options in parentheses. Any space, tab, newline or -back-slash character in the path name or client name will be replaced -by a backslash followed by the octal ASCII code for that character. - -.TP -.B threads -This file represents the number of -.B nfsd -thread currently running. Reading it will show the number of -threads. Writing an ASCII decimal number will cause the number of -threads to be changed (increased or decreased as necessary) to achieve -that number. - -.TP -.B filehandle -This is a somewhat unusual file in that what is read from it depends -on what was just written to it. It provides a transactional interface -where a program can open the file, write a request, and read a -response. If two separate programs open, write, and read at the same -time, their requests will not be mixed up. - -The request written to -.B filehandle -should be a client name, a path name, and a number of bytes. This -should be followed by a newline, with white-space separating the -fields, and octal quoting of special characters. - -On writing this, the program will be able to read back a filehandle -for that path as exported to the given client. The filehandle's length -will be at most the number of bytes given. - -The filehandle will be represented in hex with a leading '\ex'. - -.TP -.B clients/ -This directory contains a subdirectory for each NFSv4 client. Each file -under that subdirectory gives some details about the client in YAML -format. In addition, writing "expire\\n" to the -.B ctl -file will force the server to immediately revoke all state held by that -client. - -.PP -The directory -.B /proc/net/rpc -in the -.B procfs -filesystem contains a number of files and directories. -The files contain statistics that can be display using the -.I nfsstat -program. -The directories contain information about various caches that the NFS -server maintains to keep track of access permissions that different -clients have for different filesystems. -The caches are: - -.TP -.B auth.unix.ip -This cache contains a mapping from IP address to the name of the -authentication domain that the ipaddress should be treated as part of. - -.TP -.B nfsd.export -This cache contains a mapping from directory and domain to export -options. - -.TP -.B nfsd.fh -This cache contains a mapping from domain and a filesystem identifier -to a directory. The filesystem identifier is stored in the -filehandles and consists of a number indicating the type of identifier -and a number of hex bytes indicating the content of the identifier. - -.PP -Each directory representing a cache can hold from 1 to 3 files. They -are: -.TP -.B flush -When a number of seconds since epoch (1 Jan 1970) is written to this -file, all entries in the cache that were last updated before that file -become invalidated and will be flushed out. Writing a time in the -future (in seconds since epoch) will flush -everything. This is the only file that will always be present. - -.TP -.B content -This file, if present, contains a textual representation of ever entry -in the cache, one per line. If an entry is still in the cache -(because it is actively being used) but has expired or is otherwise -invalid, it will be presented as a comment (with a leading hash -character). - -.TP -.B channel -This file, if present, acts a channel for request from the kernel-based -nfs server to be passed to a user-space program for handling. - -When the kernel needs some information which isn't in the cache, it -makes a line appear in the -.B channel -file giving the key for the information. A user-space program should -read this, find the answer, and write a line containing the key, an -expiry time, and the content. -For example the kernel might make -.ti +5 -nfsd 127.0.0.1 -.br -appear in the -.B auth.unix.ip/content -file. The user-space program might then write -.ti +5 -nfsd 127.0.0.1 1057206953 localhost -.br -to indicate that 127.0.0.1 should map to localhost, at least for now. - -If the program uses select(2) or poll(2) to discover if it can read -from the -.B channel -then it will never see and end-of-file but when all requests have been -answered, it will block until another request appears. - -.PP -In the -.B /proc -filesystem there are 4 files that can be used to enabled extra tracing -of nfsd and related code. They are: -.in +5 -.B /proc/sys/sunrpc/nfs_debug -.br -.B /proc/sys/sunrpc/nfsd_debug -.br -.B /proc/sys/sunrpc/nlm_debug -.br -.B /proc/sys/sunrpc/rpc_debug -.br -.in -5 -They control tracing for the NFS client, the NFS server, the Network -Lock Manager (lockd) and the underlying RPC layer respectively. -Decimal numbers can be read from or written to these files. Each -number represents a bit-pattern where bits that are set cause certain -classes of tracing to be enabled. Consult the kernel header files to -find out what number correspond to what tracing. - -.SH NOTES -This file system is only available in Linux 2.6 and later series -kernels (and in the later parts of the 2.5 development series leading -up to 2.6). This man page does not apply to 2.4 and earlier. -.P -Previously the nfsctl systemcall was used for communication between nfsd -and user utilities. That systemcall was removed in kernel version 3.1. -Older nfs-utils versions were able to fall back to nfsctl if necessary; -that was removed from nfs-utils 1.3.5. - -.SH SEE ALSO -.BR nfsd (8), -.BR rpc.nfsd (8), -.BR exports (5), -.BR nfsstat (8), -.BR mountd (8) -.BR exportfs (8). - -.SH AUTHOR -NeilBrown diff --git a/nfs-utils-2.5.2/utils/gssd/.gitignore b/nfs-utils-2.5.2/utils/gssd/.gitignore deleted file mode 100644 index aba7b13..0000000 --- a/nfs-utils-2.5.2/utils/gssd/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -gss_clnt_send_err -gssd -svcgssd diff --git a/nfs-utils-2.5.2/utils/gssd/Makefile.am b/nfs-utils-2.5.2/utils/gssd/Makefile.am deleted file mode 100644 index 21d3bb8..0000000 --- a/nfs-utils-2.5.2/utils/gssd/Makefile.am +++ /dev/null @@ -1,130 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = gssd.man -if CONFIG_SVCGSS -man8_MANS += svcgssd.man -endif - -AM_CPPFLAGS += -I ../../support/nfsidmap - -RPCPREFIX = rpc. -KPREFIX = @kprefix@ -sbin_PREFIXED = gssd -if CONFIG_SVCGSS -sbin_PREFIXED += svcgssd -endif - -sbin_PROGRAMS = $(sbin_PREFIXED) - -EXTRA_DIST = \ - $(man8_MANS) - -COMMON_SRCS = \ - context.c \ - context_mit.c \ - context_heimdal.c \ - context_lucid.c \ - gss_util.c \ - gss_oids.c \ - gss_names.c \ - err_util.c \ - \ - context.h \ - err_util.h \ - gss_oids.h \ - gss_names.h \ - gss_util.h - -gssd_SOURCES = \ - $(COMMON_SRCS) \ - gssd.c \ - gssd_proc.c \ - krb5_util.c \ - \ - gssd.h \ - krb5_util.h \ - write_bytes.h - -gssd_LDADD = \ - ../../support/nfs/libnfs.la \ - $(LIBEVENT) \ - $(RPCSECGSS_LIBS) \ - $(KRBLIBS) \ - $(GSSAPI_LIBS) \ - $(LIBTIRPC) \ - $(LIBPTHREAD) - -gssd_LDFLAGS = \ - $(KRBLDFLAGS) - -gssd_CFLAGS = \ - $(AM_CFLAGS) \ - $(CFLAGS) \ - $(RPCSECGSS_CFLAGS) \ - $(KRBCFLAGS) \ - $(GSSAPI_CFLAGS) - -svcgssd_SOURCES = \ - $(COMMON_SRCS) \ - svcgssd.c \ - svcgssd_mech2file.c \ - svcgssd_proc.c \ - svcgssd_krb5.c \ - \ - svcgssd_krb5.h \ - svcgssd.h - -svcgssd_LDADD = \ - ../../support/nfs/libnfs.la \ - ../../support/nfsidmap/libnfsidmap.la \ - $(LIBEVENT) \ - $(RPCSECGSS_LIBS) \ - $(KRBLIBS) $(GSSAPI_LIBS) $(LIBTIRPC) - -svcgssd_LDFLAGS = $(KRBLDFLAGS) - -svcgssd_CFLAGS = $(AM_CFLAGS) $(CFLAGS) \ - $(RPCSECGSS_CFLAGS) $(KRBCFLAGS) $(GSSAPI_CFLAGS) - -MAINTAINERCLEANFILES = Makefile.in - -####################################################################### -# The following allows the current practice of having -# daemons renamed during the install to include RPCPREFIX -# and the KPREFIX -# This could all be done much easier with program_transform_name -# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) -# but that also renames the man pages, which the current -# practice does not do. -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PREFIXED); do \ - mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PREFIXED); do \ - rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) - - -# XXX This makes some assumptions about what automake does. -# XXX But there is no install-man-hook or install-man-local. -install-man: install-man8 install-man-links -uninstall-man: uninstall-man8 uninstall-man-links - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/gssd/context.c b/nfs-utils-2.5.2/utils/gssd/context.c deleted file mode 100644 index 7757a77..0000000 --- a/nfs-utils-2.5.2/utils/gssd/context.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include "gss_util.h" -#include "gss_oids.h" -#include "err_util.h" -#include "context.h" - -int -serialize_context_for_kernel(gss_ctx_id_t *ctx, - gss_buffer_desc *buf, - gss_OID mech, - int32_t *endtime) -{ - if (g_OID_equal(&krb5oid, mech)) - return serialize_krb5_ctx(ctx, buf, endtime); - else { - printerr(0, "ERROR: attempting to serialize context with " - "unknown/unsupported mechanism oid\n"); - return -1; - } -} diff --git a/nfs-utils-2.5.2/utils/gssd/context.h b/nfs-utils-2.5.2/utils/gssd/context.h deleted file mode 100644 index 3b55c8e..0000000 --- a/nfs-utils-2.5.2/utils/gssd/context.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (c) 2004,2008 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _CONTEXT_H_ -#define _CONTEXT_H_ - -#include - -/* Hopefully big enough to hold any serialized context */ -#define MAX_CTX_LEN 4096 - -/* New context format flag values */ -#define KRB5_CTX_FLAG_INITIATOR 0x00000001 -#define KRB5_CTX_FLAG_CFX 0x00000002 -#define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 - -int serialize_context_for_kernel(gss_ctx_id_t *ctx, gss_buffer_desc *buf, - gss_OID mech, int32_t *endtime); -int serialize_krb5_ctx(gss_ctx_id_t *ctx, gss_buffer_desc *buf, - int32_t *endtime); - -#endif /* _CONTEXT_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/context_heimdal.c b/nfs-utils-2.5.2/utils/gssd/context_heimdal.c deleted file mode 100644 index d07103b..0000000 --- a/nfs-utils-2.5.2/utils/gssd/context_heimdal.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (c) 2004-2006 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef HAVE_LUCID_CONTEXT_SUPPORT -#ifdef HAVE_HEIMDAL - -#include -#include -#include -#include -#include -#include -#include /* Must use the heimdal copy! */ -#ifdef HAVE_COM_ERR_H -#include -#endif -#include "err_util.h" -#include "gss_oids.h" -#include "write_bytes.h" - -int write_heimdal_keyblock(char **p, char *end, krb5_keyblock *key) -{ - gss_buffer_desc tmp; - int code = -1; - - if (WRITE_BYTES(p, end, key->keytype)) goto out_err; - tmp.length = key->keyvalue.length; - tmp.value = key->keyvalue.data; - if (write_buffer(p, end, &tmp)) goto out_err; - code = 0; - out_err: - return(code); -} - -int write_heimdal_enc_key(char **p, char *end, gss_ctx_id_t ctx) -{ - krb5_keyblock enc_key, *key; - krb5_context context; - krb5_error_code ret; - int i; - char *skd, *dkd, *k5err = NULL; - int code = -1; - - if ((ret = krb5_init_context(&context))) { - k5err = gssd_k5_err_msg(NULL, ret); - printerr(0, "ERROR: initializing krb5_context: %s\n", k5err); - goto out_err; - } - - if ((ret = krb5_auth_con_getlocalsubkey(context, - ctx->auth_context, &key))){ - k5err = gssd_k5_err_msg(context, ret); - printerr(0, "ERROR: getting auth_context key: %s\n", k5err); - goto out_err_free_context; - } - - memset(&enc_key, 0, sizeof(enc_key)); - enc_key.keytype = key->keytype; - /* XXX current kernel code only handles des-cbc-raw (4) */ - if (enc_key.keytype != 4) { - printerr(1, "WARN: write_heimdal_enc_key: " - "overriding heimdal keytype (%d => %d)\n", - enc_key.keytype, 4); - enc_key.keytype = 4; - } - enc_key.keyvalue.length = key->keyvalue.length; - if ((enc_key.keyvalue.data = - calloc(1, enc_key.keyvalue.length)) == NULL) { - k5err = gssd_k5_err_msg(context, ENOMEM); - printerr(0, "ERROR: allocating memory for enc key: %s\n", - k5err); - goto out_err_free_key; - } - skd = (char *) key->keyvalue.data; - dkd = (char *) enc_key.keyvalue.data; - for (i = 0; i < enc_key.keyvalue.length; i++) - dkd[i] = skd[i] ^ 0xf0; - if (write_heimdal_keyblock(p, end, &enc_key)) { - goto out_err_free_enckey; - } - - code = 0; - - out_err_free_enckey: - krb5_free_keyblock_contents(context, &enc_key); - out_err_free_key: - krb5_free_keyblock(context, key); - out_err_free_context: - krb5_free_context(context); - out_err: - free(k5err); - printerr(2, "write_heimdal_enc_key: %s\n", code ? "FAILED" : "SUCCESS"); - return(code); -} - -int write_heimdal_seq_key(char **p, char *end, gss_ctx_id_t ctx) -{ - krb5_keyblock *key; - krb5_context context; - krb5_error_code ret; - char *k5err = NULL; - int code = -1; - - if ((ret = krb5_init_context(&context))) { - k5err = gssd_k5_err_msg(NULL, ret); - printerr(0, "ERROR: initializing krb5_context: %s\n", k5err); - goto out_err; - } - - if ((ret = krb5_auth_con_getlocalsubkey(context, - ctx->auth_context, &key))){ - k5err = gssd_k5_err_msg(context, ret); - printerr(0, "ERROR: getting auth_context key: %s\n", k5err); - goto out_err_free_context; - } - - /* XXX current kernel code only handles des-cbc-raw (4) */ - if (key->keytype != 4) { - printerr(1, "WARN: write_heimdal_seq_key: " - "overriding heimdal keytype (%d => %d)\n", - key->keytype, 4); - key->keytype = 4; - } - - if (write_heimdal_keyblock(p, end, key)) { - goto out_err_free_key; - } - - code = 0; - - out_err_free_key: - krb5_free_keyblock(context, key); - out_err_free_context: - krb5_free_context(context); - out_err: - free(k5err); - printerr(2, "write_heimdal_seq_key: %s\n", code ? "FAILED" : "SUCCESS"); - return(code); -} - -/* - * The following is the kernel structure that we are filling in: - * - * struct krb5_ctx { - * int initiate; - * int seed_init; - * unsigned char seed[16]; - * int signalg; - * int sealalg; - * struct crypto_tfm *enc; - * struct crypto_tfm *seq; - * s32 endtime; - * u32 seq_send; - * struct xdr_netobj mech_used; - * }; - * - * However, note that we do not send the data fields in the - * order they appear in the structure. The order they are - * sent down in is: - * - * initiate - * seed_init - * seed - * signalg - * sealalg - * endtime - * seq_send - * mech_used - * enc key - * seq key - * - */ - -int -serialize_krb5_ctx(gss_ctx_id_t *_ctx, gss_buffer_desc *buf, int32_t *endtime) -{ - gss_ctx_id_t ctx = *_ctx; - char *p, *end; - static int constant_one = 1; - static int constant_zero = 0; - unsigned char fakeseed[16]; - uint32_t algorithm; - - if (!(buf->value = calloc(1, MAX_CTX_LEN))) - goto out_err; - p = buf->value; - end = buf->value + MAX_CTX_LEN; - - - /* initiate: 1 => initiating 0 => accepting */ - if (ctx->more_flags & LOCAL) { - if (WRITE_BYTES(&p, end, constant_one)) goto out_err; - } - else { - if (WRITE_BYTES(&p, end, constant_zero)) goto out_err; - } - - /* seed_init: not used by kernel code */ - if (WRITE_BYTES(&p, end, constant_zero)) goto out_err; - - /* seed: not used by kernel code */ - memset(&fakeseed, 0, sizeof(fakeseed)); - if (write_bytes(&p, end, &fakeseed, 16)) goto out_err; - - /* signalg */ - algorithm = 0; /* SGN_ALG_DES_MAC_MD5 XXX */ - if (WRITE_BYTES(&p, end, algorithm)) goto out_err; - - /* sealalg */ - algorithm = 0; /* SEAL_ALG_DES XXX */ - if (WRITE_BYTES(&p, end, algorithm)) goto out_err; - - /* endtime */ - if (WRITE_BYTES(&p, end, ctx->lifetime)) goto out_err; - - if (endtime) - *endtime = ctx->lifetime; - - /* seq_send */ - if (WRITE_BYTES(&p, end, ctx->auth_context->local_seqnumber)) - goto out_err; - /* mech_used */ - if (write_buffer(&p, end, (gss_buffer_desc*)&krb5oid)) goto out_err; - - /* enc: derive the encryption key and copy it into buffer */ - if (write_heimdal_enc_key(&p, end, ctx)) goto out_err; - - /* seq: get the sequence number key and copy it into buffer */ - if (write_heimdal_seq_key(&p, end, ctx)) goto out_err; - - buf->length = p - (char *)buf->value; - printerr(4, "serialize_krb5_ctx: returning buffer " - "with %d bytes\n", buf->length); - - return 0; -out_err: - printerr(0, "ERROR: failed exporting Heimdal krb5 ctx to kernel\n"); - if (buf->value) free(buf->value); - buf->length = 0; - return -1; -} - -#endif /* HAVE_HEIMDAL */ -#endif /* HAVE_LUCID_CONTEXT_SUPPORT */ diff --git a/nfs-utils-2.5.2/utils/gssd/context_lucid.c b/nfs-utils-2.5.2/utils/gssd/context_lucid.c deleted file mode 100644 index 5d77c21..0000000 --- a/nfs-utils-2.5.2/utils/gssd/context_lucid.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * COPYRIGHT (c) 2006 - * The Regents of the University of Michigan - * ALL RIGHTS RESERVED - * - * Permission is granted to use, copy, create derivative works - * and redistribute this software and such derivative works - * for any purpose, so long as the name of The University of - * Michigan is not used in any advertising or publicity - * pertaining to the use of distribution of this software - * without specific, written prior authorization. If the - * above copyright notice or any other identification of the - * University of Michigan is included in any copy of any - * portion of this software, then the disclaimer below must - * also be included. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION - * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY - * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF - * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING - * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE - * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING - * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN - * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifdef HAVE_LUCID_CONTEXT_SUPPORT - -/* - * Newer versions of MIT and Heimdal have lucid context support. - * We can use common code if it is supported. - */ - -#include -#include -#include -#include - -#include - -#include "gss_util.h" -#include "gss_oids.h" -#include "err_util.h" -#include "context.h" - -#ifndef OM_uint64 -typedef uint64_t OM_uint64; -#endif - -static int -write_lucid_keyblock(char **p, char *end, gss_krb5_lucid_key_t *key) -{ - gss_buffer_desc tmp; - - if (WRITE_BYTES(p, end, key->type)) return -1; - tmp.length = key->length; - tmp.value = key->data; - if (write_buffer(p, end, &tmp)) return -1; - return 0; -} - -static int -prepare_krb5_rfc1964_buffer(gss_krb5_lucid_context_v1_t *lctx, - gss_buffer_desc *buf, int32_t *endtime) -{ -#define FAKESEED_SIZE 16 - char *p, *end; - static int constant_zero = 0; - unsigned char fakeseed[FAKESEED_SIZE]; - uint32_t word_send_seq; - gss_krb5_lucid_key_t enc_key; - uint32_t i; - char *skd, *dkd; - gss_buffer_desc fakeoid; - int err; - - /* - * The new Kerberos interface to get the gss context - * does not include the seed or seed_init fields - * because we never really use them. But for now, - * send down a fake buffer so we can use the same - * interface to the kernel. - */ - memset(&enc_key, 0, sizeof(enc_key)); - memset(&fakeoid, 0, sizeof(fakeoid)); - memset(fakeseed, 0, FAKESEED_SIZE); - - if (!(buf->value = calloc(1, MAX_CTX_LEN))) - goto out_err; - p = buf->value; - end = buf->value + MAX_CTX_LEN; - - if (WRITE_BYTES(&p, end, lctx->initiate)) goto out_err; - - /* seed_init and seed not used by kernel anyway */ - if (WRITE_BYTES(&p, end, constant_zero)) goto out_err; - if (write_bytes(&p, end, &fakeseed, FAKESEED_SIZE)) goto out_err; - - if (WRITE_BYTES(&p, end, lctx->rfc1964_kd.sign_alg)) goto out_err; - if (WRITE_BYTES(&p, end, lctx->rfc1964_kd.seal_alg)) goto out_err; - if (WRITE_BYTES(&p, end, lctx->endtime)) goto out_err; - if (endtime) - *endtime = lctx->endtime; - word_send_seq = lctx->send_seq; /* XXX send_seq is 64-bit */ - if (WRITE_BYTES(&p, end, word_send_seq)) goto out_err; - if (write_oid(&p, end, &krb5oid)) goto out_err; - -#ifdef HAVE_HEIMDAL - /* - * The kernel gss code expects des-cbc-raw for all flavors of des. - * The keytype from MIT has this type, but Heimdal does not. - * Force the Heimdal keytype to 4 (des-cbc-raw). - * Note that the rfc1964 version only supports DES enctypes. - */ - if (lctx->rfc1964_kd.ctx_key.type != 4) { - printerr(2, "%s: overriding heimdal keytype (%d => %d)\n", - __FUNCTION__, lctx->rfc1964_kd.ctx_key.type, 4); - lctx->rfc1964_kd.ctx_key.type = 4; - } -#endif - printerr(2, "%s: serializing keys with enctype %d and length %d\n", - __FUNCTION__, lctx->rfc1964_kd.ctx_key.type, - lctx->rfc1964_kd.ctx_key.length); - - /* derive the encryption key and copy it into buffer */ - enc_key.type = lctx->rfc1964_kd.ctx_key.type; - enc_key.length = lctx->rfc1964_kd.ctx_key.length; - if ((enc_key.data = calloc(1, enc_key.length)) == NULL) - goto out_err; - skd = (char *) lctx->rfc1964_kd.ctx_key.data; - dkd = (char *) enc_key.data; - for (i = 0; i < enc_key.length; i++) - dkd[i] = skd[i] ^ 0xf0; - err = write_lucid_keyblock(&p, end, &enc_key); - free(enc_key.data); - if (err) - goto out_err; - - if (write_lucid_keyblock(&p, end, &lctx->rfc1964_kd.ctx_key)) - goto out_err; - - buf->length = p - (char *)buf->value; - return 0; -out_err: - printerr(0, "ERROR: failed serializing krb5 context for kernel\n"); - if (buf->value) free(buf->value); - buf->length = 0; - return -1; -} - -/* Flags for version 2 context flags */ -#define KRB5_CTX_FLAG_INITIATOR 0x00000001 -#define KRB5_CTX_FLAG_CFX 0x00000002 -#define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 - -/* - * Prepare a new-style buffer, as defined in rfc4121 (a.k.a. cfx), - * to send to the kernel for newer encryption types -- or for DES3. - * - * The new format is: - * - * u32 flags; - * #define KRB5_CTX_FLAG_INITIATOR 0x00000001 - * #define KRB5_CTX_FLAG_CFX 0x00000002 - * #define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 - * s32 endtime; - * u64 seq_send; - * u32 enctype; ( encrption type of key ) - * raw key; ( raw key bytes (kernel will derive)) - * - */ -static int -prepare_krb5_rfc4121_buffer(gss_krb5_lucid_context_v1_t *lctx, - gss_buffer_desc *buf, int32_t *endtime) -{ - char *p, *end; - uint32_t v2_flags = 0; - uint32_t enctype; - uint32_t keysize; - - if (!(buf->value = calloc(1, MAX_CTX_LEN))) - goto out_err; - p = buf->value; - end = buf->value + MAX_CTX_LEN; - - /* Version 2 */ - if (lctx->initiate) - v2_flags |= KRB5_CTX_FLAG_INITIATOR; - if (lctx->protocol != 0) - v2_flags |= KRB5_CTX_FLAG_CFX; - if (lctx->protocol != 0 && lctx->cfx_kd.have_acceptor_subkey == 1) - v2_flags |= KRB5_CTX_FLAG_ACCEPTOR_SUBKEY; - - if (WRITE_BYTES(&p, end, v2_flags)) goto out_err; - if (WRITE_BYTES(&p, end, lctx->endtime)) goto out_err; - if (endtime) - *endtime = lctx->endtime; - if (WRITE_BYTES(&p, end, lctx->send_seq)) goto out_err; - - /* Protocol 0 here implies DES3 or RC4 */ - printerr(4, "%s: protocol %d\n", __FUNCTION__, lctx->protocol); - if (lctx->protocol == 0) { - enctype = lctx->rfc1964_kd.ctx_key.type; - keysize = lctx->rfc1964_kd.ctx_key.length; - } else { - if (lctx->cfx_kd.have_acceptor_subkey) { - enctype = lctx->cfx_kd.acceptor_subkey.type; - keysize = lctx->cfx_kd.acceptor_subkey.length; - } else { - enctype = lctx->cfx_kd.ctx_key.type; - keysize = lctx->cfx_kd.ctx_key.length; - } - } - printerr(4, "%s: serializing key with enctype %d and size %d\n", - __FUNCTION__, enctype, keysize); - - if (WRITE_BYTES(&p, end, enctype)) goto out_err; - - if (lctx->protocol == 0) { - if (write_bytes(&p, end, lctx->rfc1964_kd.ctx_key.data, - lctx->rfc1964_kd.ctx_key.length)) - goto out_err; - } else { - if (lctx->cfx_kd.have_acceptor_subkey) { - if (write_bytes(&p, end, - lctx->cfx_kd.acceptor_subkey.data, - lctx->cfx_kd.acceptor_subkey.length)) - goto out_err; - } else { - if (write_bytes(&p, end, lctx->cfx_kd.ctx_key.data, - lctx->cfx_kd.ctx_key.length)) - goto out_err; - } - } - - buf->length = p - (char *)buf->value; - return 0; - -out_err: - printerr(0, "ERROR: %s: failed serializing krb5 context for kernel\n", - __FUNCTION__); - if (buf->value) { - free(buf->value); - buf->value = NULL; - } - buf->length = 0; - return -1; -} - - -int -serialize_krb5_ctx(gss_ctx_id_t *ctx, gss_buffer_desc *buf, int32_t *endtime) -{ - OM_uint32 maj_stat, min_stat; - void *return_ctx = 0; - OM_uint32 vers; - gss_krb5_lucid_context_v1_t *lctx = 0; - int retcode = 0; - - printerr(4, "DEBUG: %s: lucid version!\n", __FUNCTION__); - maj_stat = gss_export_lucid_sec_context(&min_stat, ctx, - 1, &return_ctx); - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("gss_export_lucid_sec_context", - maj_stat, min_stat, &krb5oid); - goto out_err; - } - - /* Check the version returned, we only support v1 right now */ - vers = ((gss_krb5_lucid_context_version_t *)return_ctx)->version; - switch (vers) { - case 1: - lctx = (gss_krb5_lucid_context_v1_t *) return_ctx; - break; - default: - printerr(0, "ERROR: unsupported lucid sec context version %d\n", - vers); - goto out_err; - break; - } - - /* - * Now lctx points to a lucid context that we can send down to kernel - * - * Note: we send down different information to the kernel depending - * on the protocol version and the enctyption type. - * For protocol version 0 with all enctypes besides DES3, we use - * the original format. For protocol version != 0 or DES3, we - * send down the new style information. - */ - - if (lctx->protocol == 0 && lctx->rfc1964_kd.ctx_key.type <= 4) - retcode = prepare_krb5_rfc1964_buffer(lctx, buf, endtime); - else - retcode = prepare_krb5_rfc4121_buffer(lctx, buf, endtime); - - maj_stat = gss_free_lucid_sec_context(&min_stat, ctx, return_ctx); - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("gss_free_lucid_sec_context", - maj_stat, min_stat, &krb5oid); - printerr(0, "WARN: failed to free lucid sec context\n"); - } - - if (retcode) { - printerr(1, "%s: prepare_krb5_*_buffer failed (retcode = %d)\n", - __FUNCTION__, retcode); - goto out_err; - } - - return 0; - -out_err: - printerr(0, "ERROR: failed serializing krb5 context for kernel\n"); - return -1; -} - - - -#endif /* HAVE_LUCID_CONTEXT_SUPPORT */ diff --git a/nfs-utils-2.5.2/utils/gssd/context_mit.c b/nfs-utils-2.5.2/utils/gssd/context_mit.c deleted file mode 100644 index fad6756..0000000 --- a/nfs-utils-2.5.2/utils/gssd/context_mit.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (c) 2004-2006 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef HAVE_LUCID_CONTEXT_SUPPORT -#ifdef HAVE_KRB5 - -#include -#include -#include -#include -#include -#include -#include -#include "gss_util.h" -#include "gss_oids.h" -#include "err_util.h" -#include "context.h" - -#include - -#if (KRB5_VERSION > 131) -/* XXX argggg, there's gotta be a better way than just duplicating this - * whole struct. Unfortunately, this is in a "private" header file, - * so this is our best choice at this point :-/ - */ - -typedef struct _krb5_gss_ctx_id_rec { - unsigned int initiate : 1; /* nonzero if initiating, zero if accepting */ - unsigned int established : 1; - unsigned int big_endian : 1; - unsigned int have_acceptor_subkey : 1; - unsigned int seed_init : 1; /* XXX tested but never actually set */ -#ifdef CFX_EXERCISE - unsigned int testing_unknown_tokid : 1; /* for testing only */ -#endif - OM_uint32 gss_flags; - unsigned char seed[16]; - krb5_principal here; - krb5_principal there; - krb5_keyblock *subkey; - int signalg; - size_t cksum_size; - int sealalg; - krb5_keyblock *enc; - krb5_keyblock *seq; - krb5_timestamp endtime; - krb5_flags krb_flags; - /* XXX these used to be signed. the old spec is inspecific, and - the new spec specifies unsigned. I don't believe that the change - affects the wire encoding. */ - uint64_t seq_send; /* gssint_uint64 */ - uint64_t seq_recv; /* gssint_uint64 */ - void *seqstate; - krb5_auth_context auth_context; - gss_OID_desc *mech_used; /* gss_OID_desc */ - /* Protocol spec revision - 0 => RFC 1964 with 3DES and RC4 enhancements - 1 => draft-ietf-krb-wg-gssapi-cfx-01 - No others defined so far. */ - int proto; - krb5_cksumtype cksumtype; /* for "main" subkey */ - krb5_keyblock *acceptor_subkey; /* CFX only */ - krb5_cksumtype acceptor_subkey_cksumtype; -#ifdef CFX_EXERCISE - gss_buffer_desc init_token; -#endif -} krb5_gss_ctx_id_rec, *krb5_gss_ctx_id_t; - -#else /* KRB5_VERSION > 131 */ - -typedef struct _krb5_gss_ctx_id_rec { - int initiate; - u_int32_t gss_flags; - int seed_init; - unsigned char seed[16]; - krb5_principal here; - krb5_principal there; - krb5_keyblock *subkey; - int signalg; - int cksum_size; - int sealalg; - krb5_keyblock *enc; - krb5_keyblock *seq; - krb5_timestamp endtime; - krb5_flags krb_flags; - krb5_ui_4 seq_send; - krb5_ui_4 seq_recv; - void *seqstate; - int established; - int big_endian; - krb5_auth_context auth_context; - gss_OID_desc *mech_used; - int nctypes; - krb5_cksumtype *ctypes; -} krb5_gss_ctx_id_rec, *krb5_gss_ctx_id_t; - -#endif /* KRB5_VERSION */ - - -static int -write_keyblock(char **p, char *end, struct _krb5_keyblock *arg) -{ - gss_buffer_desc tmp; - - if (WRITE_BYTES(p, end, arg->enctype)) return -1; - tmp.length = arg->length; - tmp.value = arg->contents; - if (write_buffer(p, end, &tmp)) return -1; - return 0; -} - -/* - * We really shouldn't know about glue-layer context structure, but - * we need to get at the real krb5 context pointer. This should be - * removed as soon as we say there is no support for MIT Kerberos - * prior to 1.4 -- which gives us "legal" access to the context info. - */ -typedef struct gss_union_ctx_id_t { - gss_OID mech_type; - gss_ctx_id_t internal_ctx_id; -} gss_union_ctx_id_desc, *gss_union_ctx_id_t; - -int -serialize_krb5_ctx(gss_ctx_id_t *ctx, gss_buffer_desc *buf, int32_t *endtime) -{ - krb5_gss_ctx_id_t kctx = ((gss_union_ctx_id_t)(*ctx))->internal_ctx_id; - char *p, *end; - static int constant_zero = 0; - static int constant_one = 1; - static int constant_two = 2; - uint32_t word_seq_send; - u_int64_t seq_send_64bit; - uint32_t v2_flags = 0; - - if (!(buf->value = calloc(1, MAX_CTX_LEN))) - goto out_err; - p = buf->value; - end = buf->value + MAX_CTX_LEN; - - switch (kctx->enc->enctype) { - case ENCTYPE_DES_CBC_CRC: - case ENCTYPE_DES_CBC_MD4: - case ENCTYPE_DES_CBC_MD5: - case ENCTYPE_DES_CBC_RAW: - /* Old format of context to the kernel */ - if (kctx->initiate) { - if (WRITE_BYTES(&p, end, constant_one)) goto out_err; - } - else { - if (WRITE_BYTES(&p, end, constant_zero)) goto out_err; - } - if (kctx->seed_init) { - if (WRITE_BYTES(&p, end, constant_one)) goto out_err; - } - else { - if (WRITE_BYTES(&p, end, constant_zero)) goto out_err; - } - if (write_bytes(&p, end, &kctx->seed, sizeof(kctx->seed))) - goto out_err; - if (WRITE_BYTES(&p, end, kctx->signalg)) goto out_err; - if (WRITE_BYTES(&p, end, kctx->sealalg)) goto out_err; - if (WRITE_BYTES(&p, end, kctx->endtime)) goto out_err; - if (endtime) - *endtime = kctx->endtime; - word_seq_send = kctx->seq_send; - if (WRITE_BYTES(&p, end, word_seq_send)) goto out_err; - if (write_oid(&p, end, kctx->mech_used)) goto out_err; - - printerr(2, "serialize_krb5_ctx: serializing keys with " - "enctype %d and length %d\n", - kctx->enc->enctype, kctx->enc->length); - - if (write_keyblock(&p, end, kctx->enc)) goto out_err; - if (write_keyblock(&p, end, kctx->seq)) goto out_err; - break; - case ENCTYPE_DES3_CBC_RAW: - case ENCTYPE_DES3_CBC_SHA1: - case ENCTYPE_ARCFOUR_HMAC: - case ENCTYPE_ARCFOUR_HMAC_EXP: - case ENCTYPE_AES128_CTS_HMAC_SHA1_96: - case ENCTYPE_AES256_CTS_HMAC_SHA1_96: - /* New format of context to the kernel */ - /* u32 flags; - * #define KRB5_CTX_FLAG_INITIATOR 0x00000001 - * #define KRB5_CTX_FLAG_CFX 0x00000002 - * #define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 - * s32 endtime; - * u64 seq_send; - * u32 enctype; - * rawkey data - */ - - if (kctx->initiate) - v2_flags |= KRB5_CTX_FLAG_INITIATOR; - if (kctx->proto == 1) - v2_flags |= KRB5_CTX_FLAG_CFX; - if (kctx->have_acceptor_subkey) - v2_flags |= KRB5_CTX_FLAG_ACCEPTOR_SUBKEY; - if (WRITE_BYTES(&p, end, v2_flags)) goto out_err; - if (WRITE_BYTES(&p, end, kctx->endtime)) goto out_err; - - seq_send_64bit = kctx->seq_send; - if (WRITE_BYTES(&p, end, seq_send_64bit)) goto out_err; - - if (kctx->have_acceptor_subkey) { - if (WRITE_BYTES(&p, end, kctx->acceptor_subkey->enctype)) - goto out_err; - printerr(2, "serialize_krb5_ctx: serializing subkey " - "with enctype %d and size %d\n", - kctx->acceptor_subkey->enctype, - kctx->acceptor_subkey->length); - - if (write_bytes(&p, end, - kctx->acceptor_subkey->contents, - kctx->acceptor_subkey->length)) - goto out_err; - } else { - if (WRITE_BYTES(&p, end, kctx->enc->enctype)) - goto out_err; - printerr(2, "serialize_krb5_ctx: serializing key " - "with enctype %d and size %d\n", - kctx->enc->enctype, kctx->enc->length); - - if (write_bytes(&p, end, kctx->enc->contents, - kctx->enc->length)) - goto out_err; - } - break; - default: - printerr(0, "ERROR: serialize_krb5_ctx: unsupported encryption " - "algorithm %d\n", kctx->enc->enctype); - goto out_err; - } - - buf->length = p - (char *)buf->value; - return 0; - -out_err: - printerr(0, "ERROR: failed serializing krb5 context for kernel\n"); - if (buf->value) { - free(buf->value); - } - buf->value = NULL; - buf->length = 0; - return -1; -} - -#endif /* HAVE_KRB5 */ -#endif /* HAVE_LUCID_CONTEXT_SUPPORT */ diff --git a/nfs-utils-2.5.2/utils/gssd/err_util.c b/nfs-utils-2.5.2/utils/gssd/err_util.c deleted file mode 100644 index 2b1132a..0000000 --- a/nfs-utils-2.5.2/utils/gssd/err_util.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include "xlog.h" -#include "err_util.h" - -static int verbosity = 0; -static int fg = 0; - -void initerr(char *progname, int set_verbosity, int set_fg) -{ - verbosity = set_verbosity; - fg = set_fg; - if (!fg) - xlog_open(progname); -} - - -void printerr(int priority, char *format, ...) -{ - va_list args; - - /* Don't bother formatting a message we're never going to print! */ - if (priority > verbosity) - return; - - va_start(args, format); - if (fg) - vfprintf(stderr, format, args); - else - xlog_backend(L_ERROR, format, args); - va_end(args); -} - -int get_verbosity(void) -{ - return verbosity; -} diff --git a/nfs-utils-2.5.2/utils/gssd/err_util.h b/nfs-utils-2.5.2/utils/gssd/err_util.h deleted file mode 100644 index c4df32d..0000000 --- a/nfs-utils-2.5.2/utils/gssd/err_util.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _ERR_UTIL_H_ -#define _ERR_UTIL_H_ - -void initerr(char *progname, int verbosity, int fg); -void printerr(int priority, char *format, ...); -int get_verbosity(void); - -#endif /* _ERR_UTIL_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/gss_names.c b/nfs-utils-2.5.2/utils/gssd/gss_names.c deleted file mode 100644 index 982b96f..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_names.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2002 Bruce Fields - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "svcgssd.h" -#include "gss_util.h" -#include "gss_names.h" -#include "err_util.h" -#include "context.h" -#include "misc.h" -#include "gss_oids.h" -#include "svcgssd_krb5.h" - -static int -get_krb5_hostbased_name(gss_buffer_desc *name, char **hostbased_name) -{ - char *p, *sname = NULL; - if (strchr(name->value, '@') && strchr(name->value, '/')) { - if ((sname = calloc(name->length, 1)) == NULL) { - printerr(0, "ERROR: get_krb5_hostbased_name failed " - "to allocate %d bytes\n", name->length); - return -1; - } - /* read in name and instance and replace '/' with '@' */ - sscanf(name->value, "%[^@]", sname); - p = strrchr(sname, '/'); - if (p == NULL) { /* The '@' preceeded the '/' */ - free(sname); - return -1; - } - *p = '@'; - } - *hostbased_name = sname; - return 0; -} - -int -get_hostbased_client_name(gss_name_t client_name, gss_OID mech, - char **hostbased_name) -{ - u_int32_t maj_stat, min_stat; - gss_buffer_desc name; - gss_OID name_type = GSS_C_NO_OID; - char *cname; - int res = -1; - - *hostbased_name = NULL; /* preset in case we fail */ - - /* Get the client's gss authenticated name */ - maj_stat = gss_display_name(&min_stat, client_name, &name, &name_type); - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("get_hostbased_client_name: gss_display_name", - maj_stat, min_stat, mech); - goto out_err; - } - if (name.length >= 0xffff) { /* don't overflow */ - printerr(0, "ERROR: get_hostbased_client_name: " - "received gss_name is too long (%d bytes)\n", - name.length); - goto out_rel_buf; - } - - /* For Kerberos, transform the NT_KRB5_PRINCIPAL name to - * an NT_HOSTBASED_SERVICE name */ - if (g_OID_equal(&krb5oid, mech)) { - if (get_krb5_hostbased_name(&name, &cname) != 0) - goto out_rel_buf; - *hostbased_name = cname; - } else { - printerr(1, "WARNING: unknown/unsupport mech OID\n"); - goto out_rel_buf; - } - - res = 0; -out_rel_buf: - gss_release_buffer(&min_stat, &name); -out_err: - return res; -} - -void -get_hostbased_client_buffer(gss_name_t client_name, gss_OID mech, - gss_buffer_t buf) -{ - char *hname; - - if (!get_hostbased_client_name(client_name, mech, &hname)) { - buf->length = strlen(hname) + 1; - buf->value = hname; - } else { - buf->length = 0; - buf->value = NULL; - } -} diff --git a/nfs-utils-2.5.2/utils/gssd/gss_names.h b/nfs-utils-2.5.2/utils/gssd/gss_names.h deleted file mode 100644 index ce182f7..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_names.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2002 Bruce Fields - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -extern int get_hostbased_client_name(gss_name_t client_name, gss_OID mech, - char **hostbased_name); -extern void get_hostbased_client_buffer(gss_name_t client_name, - gss_OID mech, gss_buffer_t buf); diff --git a/nfs-utils-2.5.2/utils/gssd/gss_oids.c b/nfs-utils-2.5.2/utils/gssd/gss_oids.c deleted file mode 100644 index 4362de2..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_oids.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include - -/* from kerberos source, gssapi_krb5.c */ -gss_OID_desc krb5oid = - {9, "\052\206\110\206\367\022\001\002\002"}; diff --git a/nfs-utils-2.5.2/utils/gssd/gss_oids.h b/nfs-utils-2.5.2/utils/gssd/gss_oids.h deleted file mode 100644 index fde8532..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_oids.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _GSS_OIDS_H_ -#define _GSS_OIDS_H_ - -#include - -extern gss_OID_desc krb5oid; - -#ifndef g_OID_equal -#define g_OID_equal(o1,o2) \ - (((o1)->length == (o2)->length) && \ - (memcmp((o1)->elements,(o2)->elements,(unsigned int) (o1)->length) == 0)) -#endif - -#endif /* _GSS_OIDS_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/gss_util.c b/nfs-utils-2.5.2/utils/gssd/gss_util.c deleted file mode 100644 index a4b2777..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_util.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Adapted in part from MIT Kerberos 5-1.2.1 slave/kprop.c and from - * http://docs.sun.com/?p=/doc/816-1331/6m7oo9sms&a=view - * - * Copyright (c) 2002 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * J. Bruce Fields - * Marius Aamodt Eriksen - */ - -/* - * slave/kprop.c - * - * Copyright 1990,1991 by the Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -/* - * Copyright 1994 by OpenVision Technologies, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of OpenVision not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. OpenVision makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(HAVE_KRB5) && !defined(GSS_C_NT_HOSTBASED_SERVICE) -#include -#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name -#endif -#include "gss_util.h" -#include "err_util.h" -#include "gssd.h" -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#ifdef HAVE_COM_ERR_H -#include -#endif - -/* Global gssd_credentials handle */ -gss_cred_id_t gssd_creds; - -gss_OID g_mechOid = GSS_C_NULL_OID; - -#if 0 -static void -display_status_1(char *m, u_int32_t code, int type, const gss_OID mech) -{ - u_int32_t maj_stat, min_stat; - gss_buffer_desc msg = GSS_C_EMPTY_BUFFER; - u_int32_t msg_ctx = 0; - char *typestr; - - switch (type) { - case GSS_C_GSS_CODE: - typestr = "GSS"; - break; - case GSS_C_MECH_CODE: - typestr = "mechanism"; - break; - default: - return; - /* NOTREACHED */ - } - - for (;;) { - maj_stat = gss_display_status(&min_stat, code, - type, mech, &msg_ctx, &msg); - if (maj_stat != GSS_S_COMPLETE) { - printerr(0, "ERROR: in call to " - "gss_display_status called from %s\n", m); - break; - } else { - printerr(0, "ERROR: GSS-API: (%s) error in %s(): %s\n", - typestr, m, (char *)msg.value); - } - - if (msg.length != 0) - (void) gss_release_buffer(&min_stat, &msg); - - if (msg_ctx == 0) - break; - } -} -#endif -static char * -gss_display_error(OM_uint32 status) -{ - char *error = NULL; - - switch(status) { - case GSS_S_COMPLETE: - error = "GSS_S_COMPLETE"; - break; - case GSS_S_CALL_INACCESSIBLE_READ: - error = "GSS_S_CALL_INACCESSIBLE_READ"; - break; - case GSS_S_CALL_INACCESSIBLE_WRITE: - error = "GSS_S_CALL_INACCESSIBLE_WRITE"; - break; - case GSS_S_CALL_BAD_STRUCTURE: - error = "GSS_S_CALL_BAD_STRUCTURE"; - break; - case GSS_S_BAD_MECH: - error = "GSS_S_BAD_MECH"; - break; - case GSS_S_BAD_NAME: - error = "GSS_S_BAD_NAME"; - break; - case GSS_S_BAD_NAMETYPE: - error = "GSS_S_BAD_NAMETYPE"; - break; - case GSS_S_BAD_BINDINGS: - error = "GSS_S_BAD_BINDINGS"; - break; - case GSS_S_BAD_STATUS: - error = "GSS_S_BAD_STATUS"; - break; - case GSS_S_BAD_SIG: - error = "GSS_S_BAD_SIG"; - break; - case GSS_S_NO_CRED: - error = "GSS_S_NO_CRED"; - break; - case GSS_S_NO_CONTEXT: - error = "GSS_S_NO_CONTEXT"; - break; - case GSS_S_DEFECTIVE_TOKEN: - error = "GSS_S_DEFECTIVE_TOKEN"; - break; - case GSS_S_DEFECTIVE_CREDENTIAL: - error = "GSS_S_DEFECTIVE_CREDENTIAL"; - break; - case GSS_S_CREDENTIALS_EXPIRED: - error = "GSS_S_CREDENTIALS_EXPIRED"; - break; - case GSS_S_CONTEXT_EXPIRED: - error = "GSS_S_CONTEXT_EXPIRED"; - break; - case GSS_S_FAILURE: - error = "GSS_S_FAILURE"; - break; - case GSS_S_BAD_QOP: - error = "GSS_S_BAD_QOP"; - break; - case GSS_S_UNAUTHORIZED: - error = "GSS_S_UNAUTHORIZED"; - break; - case GSS_S_UNAVAILABLE: - error = "GSS_S_UNAVAILABLE"; - break; - case GSS_S_DUPLICATE_ELEMENT: - error = "GSS_S_DUPLICATE_ELEMENT"; - break; - case GSS_S_NAME_NOT_MN: - error = "GSS_S_NAME_NOT_MN"; - break; - default: - error = "Not defined"; - } - return error; -} - -static void -display_status_2(char *m, u_int32_t major, u_int32_t minor, const gss_OID mech) -{ - u_int32_t maj_stat1, min_stat1; - u_int32_t maj_stat2, min_stat2; - gss_buffer_desc maj_gss_buf = GSS_C_EMPTY_BUFFER; - gss_buffer_desc min_gss_buf = GSS_C_EMPTY_BUFFER; - char maj_buf[30], min_buf[30]; - char *maj, *min; - u_int32_t msg_ctx = 0; - int msg_verbosity = 0; - - /* Get major status message */ - maj_stat1 = gss_display_status(&min_stat1, major, - GSS_C_GSS_CODE, mech, &msg_ctx, &maj_gss_buf); - - if (maj_stat1 != GSS_S_COMPLETE) { - snprintf(maj_buf, sizeof(maj_buf), "(0x%08x)", major); - maj = &maj_buf[0]; - } else { - maj = maj_gss_buf.value; - } - - /* Get minor status message */ - maj_stat2 = gss_display_status(&min_stat2, minor, - GSS_C_MECH_CODE, mech, &msg_ctx, &min_gss_buf); - - if (maj_stat2 != GSS_S_COMPLETE) { - snprintf(min_buf, sizeof(min_buf), "(0x%08x)", minor); - min = &min_buf[0]; - } else { - min = min_gss_buf.value; - } - - if (major == GSS_S_CREDENTIALS_EXPIRED) - msg_verbosity = 1; - - printerr(msg_verbosity, "ERROR: GSS-API: error in %s(): %s (%s) - %s\n", - m, gss_display_error(major), maj, min); - - if (maj_gss_buf.length != 0) - (void) gss_release_buffer(&min_stat1, &maj_gss_buf); - if (min_gss_buf.length != 0) - (void) gss_release_buffer(&min_stat2, &min_gss_buf); -} - -void -pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat, const gss_OID mech) -{ - display_status_2(msg, maj_stat, min_stat, mech); -} - -int -gssd_acquire_cred(char *server_name, const gss_OID oid) -{ - gss_buffer_desc name; - gss_name_t target_name; - u_int32_t maj_stat, min_stat; - u_int32_t ignore_maj_stat, ignore_min_stat; - gss_buffer_desc pbuf; - - /* If server_name is NULL, get cred for GSS_C_NO_NAME */ - if (server_name == NULL) { - target_name = GSS_C_NO_NAME; - } else { - name.value = (void *)server_name; - name.length = strlen(server_name); - - maj_stat = gss_import_name(&min_stat, &name, - oid, - &target_name); - - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("gss_import_name", maj_stat, min_stat, g_mechOid); - return (FALSE); - } - } - - maj_stat = gss_acquire_cred(&min_stat, target_name, GSS_C_INDEFINITE, - GSS_C_NO_OID_SET, GSS_C_ACCEPT, - &gssd_creds, NULL, NULL); - - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("gss_acquire_cred", maj_stat, min_stat, g_mechOid); - ignore_maj_stat = gss_display_name(&ignore_min_stat, - target_name, &pbuf, NULL); - if (ignore_maj_stat == GSS_S_COMPLETE) { - printerr(1, "Unable to obtain credentials for '%.*s'\n", - pbuf.length, pbuf.value); - ignore_maj_stat = gss_release_buffer(&ignore_min_stat, - &pbuf); - } - } - - ignore_maj_stat = gss_release_name(&ignore_min_stat, &target_name); - - return (maj_stat == GSS_S_COMPLETE); -} - -int gssd_check_mechs(void) -{ - u_int32_t maj_stat, min_stat; - gss_OID_set supported_mechs = GSS_C_NO_OID_SET; - int retval = -1; - - maj_stat = gss_indicate_mechs(&min_stat, &supported_mechs); - if (maj_stat != GSS_S_COMPLETE) { - printerr(0, "Unable to obtain list of supported mechanisms. " - "Check that gss library is properly configured.\n"); - goto out; - } - if (supported_mechs == GSS_C_NO_OID_SET || - supported_mechs->count == 0) { - printerr(0, "Unable to obtain list of supported mechanisms. " - "Check that gss library is properly configured.\n"); - goto out; - } - maj_stat = gss_release_oid_set(&min_stat, &supported_mechs); - retval = 0; -out: - return retval; -} - -void -gssd_cleanup(void) -{ - u_int32_t min_stat; - gss_release_cred(&min_stat, &gssd_creds); -} diff --git a/nfs-utils-2.5.2/utils/gssd/gss_util.h b/nfs-utils-2.5.2/utils/gssd/gss_util.h deleted file mode 100644 index 4da64e3..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gss_util.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _GSS_UTIL_H_ -#define _GSS_UTIL_H_ - -#include -#include -#include "write_bytes.h" - -extern gss_cred_id_t gssd_creds; - -int gssd_acquire_cred(char *server_name, const gss_OID oid); -void pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat, - const gss_OID mech); -int gssd_check_mechs(void); -void gssd_cleanup(void); - -#ifndef HAVE_LIBGSSGLUE -#include -#define gss_free_lucid_sec_context(min, ctx, ret) \ - gss_krb5_free_lucid_sec_context(min, ret) - -#define gss_export_lucid_sec_context gss_krb5_export_lucid_sec_context -#define gss_set_allowable_enctypes(min, cred, oid, num, types) \ - gss_krb5_set_allowable_enctypes(min, cred, num, types) -#endif - -#endif /* _GSS_UTIL_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/gssd.c b/nfs-utils-2.5.2/utils/gssd/gssd.c deleted file mode 100644 index 85bc4b0..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gssd.c +++ /dev/null @@ -1,1169 +0,0 @@ -/* - gssd.c - - Copyright (c) 2000, 2004 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - Copyright (c) 2002 Andy Adamson . - Copyright (c) 2002 Marius Aamodt Eriksen . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gssd.h" -#include "err_util.h" -#include "gss_util.h" -#include "krb5_util.h" -#include "nfslib.h" -#include "conffile.h" - -static char *pipefs_path = GSSD_PIPEFS_DIR; -static DIR *pipefs_dir; -static int pipefs_fd; -static int inotify_fd; -struct event *inotify_ev; - -char *keytabfile = GSSD_DEFAULT_KEYTAB_FILE; -char **ccachesearch; -int use_memcache = 0; -int root_uses_machine_creds = 1; -unsigned int context_timeout = 0; -unsigned int rpc_timeout = 5; -char *preferred_realm = NULL; -char *ccachedir = NULL; -/* Avoid DNS reverse lookups on server names */ -static bool avoid_dns = true; -static bool use_gssproxy = false; -pthread_mutex_t clp_lock = PTHREAD_MUTEX_INITIALIZER; -static bool signal_received = false; -static struct event_base *evbase = NULL; - -TAILQ_HEAD(topdir_list_head, topdir) topdir_list; - -struct topdir { - TAILQ_ENTRY(topdir) list; - TAILQ_HEAD(clnt_list_head, clnt_info) clnt_list; - int wd; - char name[]; -}; - -/* - * topdir_list: - * linked list of struct topdir with basic data about a topdir. - * - * clnt_list: - * linked list of struct clnt_info with basic data about a clntXXX dir, - * one per topdir. - * - * Directory structure: created by the kernel - * {rpc_pipefs}/{topdir}/clntXX : one per rpc_clnt struct in the kernel - * {rpc_pipefs}/{topdir}/clntXX/krb5 : read uid for which kernel wants - * a context, write the resulting context - * {rpc_pipefs}/{topdir}/clntXX/info : stores info such as server name - * {rpc_pipefs}/{topdir}/clntXX/gssd : pipe for all gss mechanisms using - * a text-based string of parameters - * - * Algorithm: - * Poll all {rpc_pipefs}/{topdir}/clntXX/YYYY files. When data is ready, - * read and process; performs rpcsec_gss context initialization protocol to - * get a cred for that user. Writes result to corresponding krb5 file - * in a form the kernel code will understand. - * In addition, we make sure we are notified whenever anything is - * created or destroyed in {rpc_pipefs} or in any of the clntXX directories, - * and rescan the whole {rpc_pipefs} when this happens. - */ - -/* - * convert a presentation address string to a sockaddr_storage struct. Returns - * true on success or false on failure. - * - * Note that we do not populate the sin6_scope_id field here for IPv6 addrs. - * gssd nececessarily relies on hostname resolution and DNS AAAA records - * do not generally contain scope-id's. This means that GSSAPI auth really - * can't work with IPv6 link-local addresses. - * - * We *could* consider changing this if we did something like adopt the - * Microsoft "standard" of using the ipv6-literal.net domainname, but it's - * not really feasible at present. - */ -static bool -gssd_addrstr_to_sockaddr(struct sockaddr *sa, const char *node, const char *port) -{ - int rc; - struct addrinfo *res; - struct addrinfo hints = { .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV }; - -#ifndef IPV6_SUPPORTED - hints.ai_family = AF_INET; -#endif /* IPV6_SUPPORTED */ - - rc = getaddrinfo(node, port, &hints, &res); - if (rc) { - printerr(0, "ERROR: unable to convert %s|%s to sockaddr: %s\n", - node, port, - rc == EAI_SYSTEM ? strerror(errno) : gai_strerror(rc)); - return false; - } - -#ifdef IPV6_SUPPORTED - /* - * getnameinfo ignores the scopeid. If the address turns out to have - * a non-zero scopeid, we can't use it -- the resolved host might be - * completely different from the one intended. - */ - if (res->ai_addr->sa_family == AF_INET6) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)res->ai_addr; - if (sin6->sin6_scope_id) { - printerr(0, "ERROR: address %s has non-zero " - "sin6_scope_id!\n", node); - nfs_freeaddrinfo(res); - return false; - } - } -#endif /* IPV6_SUPPORTED */ - - memcpy(sa, res->ai_addr, res->ai_addrlen); - nfs_freeaddrinfo(res); - return true; -} - -/* - * convert a sockaddr to a hostname - */ -static char * -gssd_get_servername(const char *name, const struct sockaddr *sa, const char *addr) -{ - socklen_t addrlen; - int err; - char hbuf[NI_MAXHOST]; - unsigned char buf[sizeof(struct in6_addr)]; - - while (avoid_dns) { - /* - * Determine if this is a server name, or an IP address. - * If it is an IP address, do the DNS lookup otherwise - * skip the DNS lookup. - */ - if (strchr(name, '.') == NULL) - break; /* local name */ - else if (inet_pton(AF_INET, name, buf) == 1) - break; /* IPv4 address */ - else if (inet_pton(AF_INET6, name, buf) == 1) - break; /* IPv6 addrss */ - - return strdup(name); - } - - switch (sa->sa_family) { - case AF_INET: - addrlen = sizeof(struct sockaddr_in); - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - addrlen = sizeof(struct sockaddr_in6); - break; -#endif /* IPV6_SUPPORTED */ - default: - printerr(0, "ERROR: unrecognized addr family %d\n", - sa->sa_family); - return NULL; - } - - err = getnameinfo(sa, addrlen, hbuf, sizeof(hbuf), NULL, 0, - NI_NAMEREQD); - if (err) { - printerr(0, "ERROR: unable to resolve %s to hostname: %s\n", - addr, err == EAI_SYSTEM ? strerror(errno) : - gai_strerror(err)); - return NULL; - } - - return strdup(hbuf); -} - -static void -gssd_read_service_info(int dirfd, struct clnt_info *clp) -{ - int fd; - FILE *info = NULL; - int numfields; - char *server = NULL; - char *service = NULL; - int program; - int version; - char *address = NULL; - char *protoname = NULL; - char *port = NULL; - char *servername = NULL; - - fd = openat(dirfd, "info", O_RDONLY); - if (fd < 0) { - printerr(0, "ERROR: can't open %s/info: %s\n", - clp->relpath, strerror(errno)); - goto fail; - } - - info = fdopen(fd, "r"); - if (!info) { - printerr(0, "ERROR: can't fdopen %s/info: %s\n", - clp->relpath, strerror(errno)); - close(fd); - goto fail; - } - - /* - * Some history: - * - * The first three lines were added with rpc_pipefs in 2003-01-13. - * (commit af2f003391786fb632889c02142c941b212ba4ff) - * - * The 'protocol' line was added in 2003-06-11. - * (commit 9bd741ae48785d0c0e75cf906ff66f893d600c2d) - * - * The 'port' line was added in 2007-09-26. - * (commit bf19aacecbeebccb2c3d150a8bd9416b7dba81fe) - */ - numfields = fscanf(info, - "RPC server: %ms\n" - "service: %ms (%d) version %d\n" - "address: %ms\n" - "protocol: %ms\n" - "port: %ms\n", - &server, - &service, &program, &version, - &address, - &protoname, - &port); - - - switch (numfields) { - case 5: - protoname = strdup("tcp"); - if (!protoname) - goto fail; - /* fall through */ - case 6: - /* fall through */ - case 7: - break; - default: - goto fail; - } - - /* - * The user space RPC library has no support for - * RPC-over-RDMA at this time, so change 'rdma' - * to 'tcp', and '20049' to '2049'. - */ - if (strcmp(protoname, "rdma") == 0) { - free(protoname); - protoname = strdup("tcp"); - if (!protoname) - goto fail; - free(port); - port = strdup("2049"); - if (!port) - goto fail; - } - - if (!gssd_addrstr_to_sockaddr((struct sockaddr *)&clp->addr, - address, port ? port : "")) - goto fail; - - servername = gssd_get_servername(server, (struct sockaddr *)&clp->addr, address); - if (!servername) - goto fail; - - if (asprintf(&clp->servicename, "%s@%s", service, servername) < 0) - goto fail; - - clp->servername = servername; - clp->prog = program; - clp->vers = version; - clp->protocol = protoname; - - goto out; - -fail: - printerr(0, "ERROR: failed to parse %s/info\n", clp->relpath); - free(servername); - free(protoname); - clp->servicename = NULL; - clp->servername = NULL; - clp->prog = 0; - clp->vers = 0; - clp->protocol = NULL; -out: - if (info) - fclose(info); - - free(server); - free(service); - free(address); - free(port); -} - -/* Actually frees clp and fields that might be used from other - * threads if was last reference. - */ -static void -gssd_free_client(struct clnt_info *clp) -{ - int refcnt; - - pthread_mutex_lock(&clp_lock); - refcnt = --clp->refcount; - pthread_mutex_unlock(&clp_lock); - if (refcnt > 0) - return; - - printerr(3, "freeing client %s\n", clp->relpath); - - if (clp->krb5_fd >= 0) - close(clp->krb5_fd); - - if (clp->gssd_fd >= 0) - close(clp->gssd_fd); - - free(clp->relpath); - free(clp->servicename); - free(clp->servername); - free(clp->protocol); - free(clp); -} - -/* Called when removing from clnt_list to tear down event handling. - * Will then free clp if was last reference. - */ -static void -gssd_destroy_client(struct clnt_info *clp) -{ - printerr(3, "destroying client %s\n", clp->relpath); - - if (clp->krb5_ev) { - event_del(clp->krb5_ev); - event_free(clp->krb5_ev); - clp->krb5_ev = NULL; - } - - if (clp->gssd_ev) { - event_del(clp->gssd_ev); - event_free(clp->gssd_ev); - clp->gssd_ev = NULL; - } - - inotify_rm_watch(inotify_fd, clp->wd); - gssd_free_client(clp); -} - -static void gssd_scan(void); - -static int -start_upcall_thread(void (*func)(struct clnt_upcall_info *), void *info) -{ - pthread_attr_t attr; - pthread_t th; - int ret; - - ret = pthread_attr_init(&attr); - if (ret != 0) { - printerr(0, "ERROR: failed to init pthread attr: ret %d: %s\n", - ret, strerror(errno)); - return ret; - } - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (ret != 0) { - printerr(0, "ERROR: failed to create pthread attr: ret %d: " - "%s\n", ret, strerror(errno)); - return ret; - } - - ret = pthread_create(&th, &attr, (void *)func, (void *)info); - if (ret != 0) - printerr(0, "ERROR: pthread_create failed: ret %d: %s\n", - ret, strerror(errno)); - return ret; -} - -static struct clnt_upcall_info *alloc_upcall_info(struct clnt_info *clp) -{ - struct clnt_upcall_info *info; - - info = malloc(sizeof(struct clnt_upcall_info)); - if (info == NULL) - return NULL; - - pthread_mutex_lock(&clp_lock); - clp->refcount++; - pthread_mutex_unlock(&clp_lock); - info->clp = clp; - - return info; -} - -void free_upcall_info(struct clnt_upcall_info *info) -{ - gssd_free_client(info->clp); - free(info); -} - -/* For each upcall read the upcall info into the buffer, then create a - * thread in a detached state so that resources are released back into - * the system without the need for a join. - */ -static void -gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data) -{ - struct clnt_info *clp = data; - struct clnt_upcall_info *info; - - info = alloc_upcall_info(clp); - if (info == NULL) - return; - - info->lbuflen = read(clp->gssd_fd, info->lbuf, sizeof(info->lbuf)); - if (info->lbuflen <= 0 || info->lbuf[info->lbuflen-1] != '\n') { - printerr(0, "WARNING: %s: failed reading request\n", __func__); - free_upcall_info(info); - return; - } - info->lbuf[info->lbuflen-1] = 0; - - if (start_upcall_thread(handle_gssd_upcall, info)) - free_upcall_info(info); -} - -static void -gssd_clnt_krb5_cb(int UNUSED(fd), short UNUSED(which), void *data) -{ - struct clnt_info *clp = data; - struct clnt_upcall_info *info; - - info = alloc_upcall_info(clp); - if (info == NULL) - return; - - if (read(clp->krb5_fd, &info->uid, - sizeof(info->uid)) < (ssize_t)sizeof(info->uid)) { - printerr(0, "WARNING: %s: failed reading uid from krb5 " - "upcall pipe: %s\n", __func__, strerror(errno)); - free_upcall_info(info); - return; - } - - if (start_upcall_thread(handle_krb5_upcall, info)) - free_upcall_info(info); -} - -static struct clnt_info * -gssd_get_clnt(struct topdir *tdi, const char *name) -{ - struct clnt_info *clp; - - TAILQ_FOREACH(clp, &tdi->clnt_list, list) - if (!strcmp(clp->name, name)) - return clp; - - printerr(3, "creating client %s/%s\n", tdi->name, name); - - clp = calloc(1, sizeof(struct clnt_info)); - if (!clp) { - printerr(0, "ERROR: can't malloc clnt_info: %s\n", - strerror(errno)); - return NULL; - } - - if (asprintf(&clp->relpath, "%s/%s", tdi->name, name) < 0) { - clp->relpath = NULL; - goto out; - } - - clp->wd = inotify_add_watch(inotify_fd, clp->relpath, IN_CREATE | IN_DELETE); - if (clp->wd < 0) { - if (errno != ENOENT) - printerr(0, "ERROR: %s: inotify_add_watch failed for %s: %s\n", - __FUNCTION__, clp->relpath, strerror(errno)); - goto out; - } - - clp->name = clp->relpath + strlen(tdi->name) + 1; - clp->krb5_fd = -1; - clp->gssd_fd = -1; - clp->refcount = 1; - - TAILQ_INSERT_HEAD(&tdi->clnt_list, clp, list); - return clp; - -out: - free(clp->relpath); - free(clp); - return NULL; -} - -static int -gssd_scan_clnt(struct clnt_info *clp) -{ - int clntfd; - - printerr(3, "scanning client %s\n", clp->relpath); - - clntfd = openat(pipefs_fd, clp->relpath, O_RDONLY); - if (clntfd < 0) { - if (errno != ENOENT) - printerr(0, "ERROR: %s: can't openat %s: %s\n", - __FUNCTION__, clp->relpath, strerror(errno)); - return -1; - } - - if (clp->gssd_fd == -1) - clp->gssd_fd = openat(clntfd, "gssd", O_RDWR | O_NONBLOCK); - - if (clp->gssd_fd == -1 && clp->krb5_fd == -1) - clp->krb5_fd = openat(clntfd, "krb5", O_RDWR | O_NONBLOCK); - - if (!clp->gssd_ev && clp->gssd_fd >= 0) { - clp->gssd_ev = event_new(evbase, clp->gssd_fd, EV_READ | EV_PERSIST, - gssd_clnt_gssd_cb, clp); - if (!clp->gssd_ev) { - printerr(0, "ERROR: %s: can't create gssd event for %s: %s\n", - __FUNCTION__, clp->relpath, strerror(errno)); - close(clp->gssd_fd); - clp->gssd_fd = -1; - } else { - event_add(clp->gssd_ev, NULL); - } - } - - if (!clp->krb5_ev && clp->krb5_fd >= 0) { - clp->krb5_ev = event_new(evbase, clp->krb5_fd, EV_READ | EV_PERSIST, - gssd_clnt_krb5_cb, clp); - if (!clp->krb5_ev) { - printerr(0, "ERROR: %s: can't create krb5 event for %s: %s\n", - __FUNCTION__, clp->relpath, strerror(errno)); - close(clp->krb5_fd); - clp->krb5_fd = -1; - } else { - event_add(clp->krb5_ev, NULL); - } - } - - if (clp->krb5_fd == -1 && clp->gssd_fd == -1) - /* not fatal, files might appear later */ - goto out; - - if (clp->prog == 0) - gssd_read_service_info(clntfd, clp); - -out: - close(clntfd); - clp->scanned = true; - return 0; -} - -static int -gssd_create_clnt(struct topdir *tdi, const char *name) -{ - struct clnt_info *clp; - - clp = gssd_get_clnt(tdi, name); - if (!clp) - return -1; - - return gssd_scan_clnt(clp); -} - -static struct topdir * -gssd_get_topdir(const char *name) -{ - struct topdir *tdi; - - TAILQ_FOREACH(tdi, &topdir_list, list) - if (!strcmp(tdi->name, name)) - return tdi; - - tdi = malloc(sizeof(*tdi) + strlen(name) + 1); - if (!tdi) { - printerr(0, "ERROR: Couldn't allocate struct topdir\n"); - return NULL; - } - - tdi->wd = inotify_add_watch(inotify_fd, name, IN_CREATE); - if (tdi->wd < 0) { - printerr(0, "ERROR: %s: inotify_add_watch failed for top dir %s: %s\n", - __FUNCTION__, tdi->name, strerror(errno)); - free(tdi); - return NULL; - } - - strcpy(tdi->name, name); - TAILQ_INIT(&tdi->clnt_list); - - TAILQ_INSERT_HEAD(&topdir_list, tdi, list); - return tdi; -} - -static void -gssd_scan_topdir(const char *name) -{ - struct topdir *tdi; - int dfd; - DIR *dir; - struct clnt_info *clp; - struct dirent *d; - - tdi = gssd_get_topdir(name); - if (!tdi) - return; - - dfd = openat(pipefs_fd, tdi->name, O_RDONLY); - if (dfd < 0) { - if (errno != ENOENT) - printerr(0, "ERROR: %s: can't openat %s: %s\n", - __FUNCTION__, tdi->name, strerror(errno)); - return; - } - - dir = fdopendir(dfd); - if (!dir) { - printerr(0, "ERROR: can't fdopendir %s: %s\n", - tdi->name, strerror(errno)); - return; - } - - TAILQ_FOREACH(clp, &tdi->clnt_list, list) - clp->scanned = false; - - while ((d = readdir(dir))) { - if (d->d_type != DT_DIR) - continue; - - if (strncmp(d->d_name, "clnt", strlen("clnt"))) - continue; - - gssd_create_clnt(tdi, d->d_name); - } - - closedir(dir); - - TAILQ_FOREACH(clp, &tdi->clnt_list, list) { - void *saveprev; - - if (clp->scanned) - continue; - - printerr(3, "orphaned client %s\n", clp->relpath); - saveprev = clp->list.tqe_prev; - TAILQ_REMOVE(&tdi->clnt_list, clp, list); - gssd_destroy_client(clp); - clp = saveprev; - } -} - -static void -gssd_scan(void) -{ - struct dirent *d; - - printerr(3, "doing a full rescan\n"); - rewinddir(pipefs_dir); - - while ((d = readdir(pipefs_dir))) { - if (d->d_type != DT_DIR) - continue; - - if (d->d_name[0] == '.') - continue; - - gssd_scan_topdir(d->d_name); - } - - if (TAILQ_EMPTY(&topdir_list)) { - printerr(0, "ERROR: the rpc_pipefs directory is empty!\n"); - exit(EXIT_FAILURE); - } -} - -static void -gssd_scan_cb(int UNUSED(fd), short UNUSED(which), void *UNUSED(data)) -{ - gssd_scan(); -} - -static bool -gssd_inotify_topdir(struct topdir *tdi, const struct inotify_event *ev) -{ - printerr(5, "inotify event for topdir (%s) - " - "ev->wd (%d) ev->name (%s) ev->mask (0x%08x)\n", - tdi->name, ev->wd, ev->len > 0 ? ev->name : "", ev->mask); - - if (ev->mask & IN_IGNORED) { - printerr(0, "ERROR: topdir disappeared!\n"); - return false; - } - - if (ev->len == 0) - return false; - - if (ev->mask & IN_CREATE) { - if (!(ev->mask & IN_ISDIR)) - return true; - - if (strncmp(ev->name, "clnt", strlen("clnt"))) - return true; - - if (gssd_create_clnt(tdi, ev->name)) - return false; - - return true; - } - - return false; -} - -static bool -gssd_inotify_clnt(struct topdir *tdi, struct clnt_info *clp, const struct inotify_event *ev) -{ - printerr(5, "inotify event for clntdir (%s) - " - "ev->wd (%d) ev->name (%s) ev->mask (0x%08x)\n", - clp->relpath, ev->wd, ev->len > 0 ? ev->name : "", ev->mask); - - if (ev->mask & IN_IGNORED) { - TAILQ_REMOVE(&tdi->clnt_list, clp, list); - gssd_destroy_client(clp); - return true; - } - - if (ev->len == 0) - return false; - - if (ev->mask & IN_CREATE) { - if (!strcmp(ev->name, "gssd") || - !strcmp(ev->name, "krb5") || - !strcmp(ev->name, "info")) - if (gssd_scan_clnt(clp)) - return false; - - return true; - - } else if (ev->mask & IN_DELETE) { - if (!strcmp(ev->name, "gssd") && clp->gssd_fd >= 0) { - close(clp->gssd_fd); - event_del(clp->gssd_ev); - event_free(clp->gssd_ev); - clp->gssd_ev = NULL; - clp->gssd_fd = -1; - - } else if (!strcmp(ev->name, "krb5") && clp->krb5_fd >= 0) { - close(clp->krb5_fd); - event_del(clp->krb5_ev); - event_free(clp->krb5_ev); - clp->krb5_ev = NULL; - clp->krb5_fd = -1; - } - - return true; - } - - return false; -} - -static void -gssd_inotify_cb(int ifd, short UNUSED(which), void *UNUSED(data)) -{ - bool rescan = false; - struct topdir *tdi; - struct clnt_info *clp; - - while (true) { - char buf[4096] __attribute__ ((aligned(__alignof__(struct inotify_event)))); - const struct inotify_event *ev; - ssize_t len; - char *ptr; - - len = read(ifd, buf, sizeof(buf)); - if (len == -1 && errno == EINTR) - continue; - - if (len <= 0) - break; - - for (ptr = buf; ptr < buf + len; - ptr += sizeof(struct inotify_event) + ev->len) { - ev = (const struct inotify_event *)ptr; - - if (ev->mask & IN_Q_OVERFLOW) { - printerr(0, "ERROR: inotify queue overflow\n"); - rescan = true; - break; - } - - TAILQ_FOREACH(tdi, &topdir_list, list) { - if (tdi->wd == ev->wd) { - if (!gssd_inotify_topdir(tdi, ev)) - rescan = true; - goto found; - } - - TAILQ_FOREACH(clp, &tdi->clnt_list, list) { - if (clp->wd == ev->wd) { - if (!gssd_inotify_clnt(tdi, clp, ev)) - rescan = true; - goto found; - } - } - } - -found: - if (!tdi) { - printerr(5, "inotify event for unknown wd!!! - " - "ev->wd (%d) ev->name (%s) ev->mask (0x%08x)\n", - ev->wd, ev->len > 0 ? ev->name : "", ev->mask); - rescan = true; - } - } - } - - if (rescan) - gssd_scan(); -} - -static void -sig_die(int signal) -{ - if (signal_received) { - gssd_destroy_krb5_principals(root_uses_machine_creds); - printerr(1, "forced exiting on signal %d\n", signal); - exit(0); - } - - signal_received = true; - printerr(1, "exiting on signal %d\n", signal); - event_base_loopexit(evbase, NULL); -} - -static void -usage(char *progname) -{ - fprintf(stderr, "usage: %s [-f] [-l] [-M] [-n] [-v] [-r] [-p pipefsdir] [-k keytab] [-d ccachedir] [-t timeout] [-R preferred realm] [-D]\n", - progname); - exit(1); -} - -inline static void -read_gss_conf(void) -{ - char *s; - - conf_init_file(NFS_CONFFILE); - use_memcache = conf_get_bool("gssd", "use-memcache", use_memcache); - root_uses_machine_creds = conf_get_bool("gssd", "use-machine-creds", - root_uses_machine_creds); - avoid_dns = conf_get_bool("gssd", "avoid-dns", avoid_dns); -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES - limit_to_legacy_enctypes = conf_get_bool("gssd", "limit-to-legacy-enctypes", - limit_to_legacy_enctypes); -#endif - context_timeout = conf_get_num("gssd", "context-timeout", context_timeout); - rpc_timeout = conf_get_num("gssd", "rpc-timeout", rpc_timeout); - s = conf_get_str("gssd", "pipefs-directory"); - if (!s) - s = conf_get_str("general", "pipefs-directory"); - else - printerr(0, "WARNING: Specifying pipefs-directory in the [gssd] " - "section of %s is deprecated. Use the [general] " - "section instead.", NFS_CONFFILE); - if (s) - pipefs_path = s; - s = conf_get_str("gssd", "keytab-file"); - if (s) - keytabfile = s; - s = conf_get_str("gssd", "cred-cache-directory"); - if (s) - ccachedir = s; - s = conf_get_str("gssd", "preferred-realm"); - if (s) - preferred_realm = s; - - use_gssproxy = conf_get_bool("gssd", "use-gss-proxy", use_gssproxy); -} - -int -main(int argc, char *argv[]) -{ - int fg = 0; - int verbosity = 0; - int rpc_verbosity = 0; - int opt; - int i; - int rc; - extern char *optarg; - char *progname; - struct event *sighup_ev; - - read_gss_conf(); - - verbosity = conf_get_num("gssd", "verbosity", verbosity); - rpc_verbosity = conf_get_num("gssd", "rpc-verbosity", rpc_verbosity); - - while ((opt = getopt(argc, argv, "DfvrlmnMp:k:d:t:T:R:")) != -1) { - switch (opt) { - case 'f': - fg = 1; - break; - case 'm': - /* Accept but ignore this. Now the default. */ - break; - case 'M': - use_memcache = 1; - break; - case 'n': - root_uses_machine_creds = 0; - break; - case 'v': - verbosity++; - break; - case 'r': - rpc_verbosity++; - break; - case 'p': - pipefs_path = optarg; - break; - case 'k': - keytabfile = optarg; - break; - case 'd': - ccachedir = optarg; - break; - case 't': - context_timeout = atoi(optarg); - break; - case 'T': - rpc_timeout = atoi(optarg); - break; - case 'R': - preferred_realm = strdup(optarg); - break; - case 'l': -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES - limit_to_legacy_enctypes = 1; -#else - errx(1, "Encryption type limits not supported by Kerberos libraries."); -#endif - break; - case 'D': - avoid_dns = false; - break; - default: - usage(argv[0]); - break; - } - } - - /* - * Some krb5 routines try to scrape info out of files in the user's - * home directory. This can easily deadlock when that homedir is on a - * kerberized NFS mount. By setting $HOME unconditionally to "/", we - * prevent this behavior in routines that use $HOME in preference to - * the results of getpw*. - */ - if (setenv("HOME", "/", 1)) { - printerr(0, "gssd: Unable to set $HOME: %s\n", strerror(errno)); - exit(1); - } - - if (use_gssproxy) { - if (setenv("GSS_USE_PROXY", "yes", 1) < 0) { - printerr(0, "gssd: Unable to set $GSS_USE_PROXY: %s\n", - strerror(errno)); - exit(EXIT_FAILURE); - } - } - - if (ccachedir) { - char *ccachedir_copy; - char *ptr; - - for (ptr = ccachedir, i = 2; *ptr; ptr++) - if (*ptr == ':') - i++; - - ccachesearch = malloc(i * sizeof(char *)); - ccachedir_copy = strdup(ccachedir); - if (!ccachedir_copy || !ccachesearch) { - printerr(0, "malloc failure\n"); - exit(EXIT_FAILURE); - } - - i = 0; - ccachesearch[i++] = strtok(ccachedir, ":"); - while(ccachesearch[i - 1]) - ccachesearch[i++] = strtok(NULL, ":"); - - } else { - ccachesearch = malloc(3 * sizeof(char *)); - if (!ccachesearch) { - printerr(0, "malloc failure\n"); - exit(EXIT_FAILURE); - } - - ccachesearch[0] = GSSD_DEFAULT_CRED_DIR; - ccachesearch[1] = GSSD_USER_CRED_DIR; - ccachesearch[2] = NULL; - } - - if (preferred_realm == NULL) - gssd_k5_get_default_realm(&preferred_realm); - - if ((progname = strrchr(argv[0], '/'))) - progname++; - else - progname = argv[0]; - - initerr(progname, verbosity, fg); -#ifdef HAVE_LIBTIRPC_SET_DEBUG - /* - * Only set the libtirpc debug level if explicitly requested via -r. - */ - if (rpc_verbosity > 0) - libtirpc_set_debug(progname, rpc_verbosity, fg); -#else - if (rpc_verbosity > 0) - printerr(0, "Warning: libtirpc does not " - "support setting debug levels\n"); -#endif - - daemon_init(fg); - - if (gssd_check_mechs() != 0) - errx(1, "Problem with gssapi library"); - - evbase = event_base_new(); - if (!evbase) { - printerr(0, "ERROR: failed to create event base: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - pipefs_dir = opendir(pipefs_path); - if (!pipefs_dir) { - printerr(0, "ERROR: opendir(%s) failed: %s\n", pipefs_path, strerror(errno)); - exit(EXIT_FAILURE); - } - - pipefs_fd = dirfd(pipefs_dir); - if (fchdir(pipefs_fd)) { - printerr(0, "ERROR: fchdir(%s) failed: %s\n", pipefs_path, strerror(errno)); - exit(EXIT_FAILURE); - } - - inotify_fd = inotify_init1(IN_NONBLOCK); - if (inotify_fd == -1) { - printerr(0, "ERROR: inotify_init1 failed: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - signal(SIGINT, sig_die); - signal(SIGTERM, sig_die); - sighup_ev = evsignal_new(evbase, SIGHUP, gssd_scan_cb, NULL); - if (!sighup_ev) { - printerr(0, "ERROR: failed to create SIGHUP event: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - evsignal_add(sighup_ev, NULL); - inotify_ev = event_new(evbase, inotify_fd, EV_READ | EV_PERSIST, - gssd_inotify_cb, NULL); - if (!inotify_ev) { - printerr(0, "ERROR: failed to create inotify event: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - event_add(inotify_ev, NULL); - - TAILQ_INIT(&topdir_list); - gssd_scan(); - daemon_ready(); - - rc = event_base_dispatch(evbase); - - printerr(0, "event_dispatch() returned %i!\n", rc); - - gssd_destroy_krb5_principals(root_uses_machine_creds); - - while (!TAILQ_EMPTY(&topdir_list)) { - struct topdir *tdi = TAILQ_FIRST(&topdir_list); - TAILQ_REMOVE(&topdir_list, tdi, list); - while (!TAILQ_EMPTY(&tdi->clnt_list)) { - struct clnt_info *clp = TAILQ_FIRST(&tdi->clnt_list); - TAILQ_REMOVE(&tdi->clnt_list, clp, list); - gssd_destroy_client(clp); - } - free(tdi); - } - - event_free(inotify_ev); - event_free(sighup_ev); - event_base_free(evbase); - - close(inotify_fd); - close(pipefs_fd); - closedir(pipefs_dir); - - free(preferred_realm); - free(ccachesearch); - - return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS; -} diff --git a/nfs-utils-2.5.2/utils/gssd/gssd.h b/nfs-utils-2.5.2/utils/gssd/gssd.h deleted file mode 100644 index 1e8c58d..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gssd.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _RPC_GSSD_H_ -#define _RPC_GSSD_H_ - -#include -#include -#include -#include -#include -#include - -#ifndef GSSD_PIPEFS_DIR -#define GSSD_PIPEFS_DIR "/var/lib/nfs/rpc_pipefs" -#endif -#define DNOTIFY_SIGNAL (SIGRTMIN + 3) - -#define GSSD_DEFAULT_CRED_DIR "/tmp" -#define GSSD_USER_CRED_DIR "/run/user/%U" -#define GSSD_DEFAULT_CRED_PREFIX "krb5cc" -#define GSSD_DEFAULT_MACHINE_CRED_SUFFIX "machine" -#define GSSD_DEFAULT_KEYTAB_FILE "/etc/krb5.keytab" -#define GSSD_SERVICE_NAME "nfs" -#define RPC_CHAN_BUF_SIZE 32768 -/* - * The gss mechanisms that we can handle - */ -enum {AUTHTYPE_KRB5, AUTHTYPE_LIPKEY}; - -extern char *keytabfile; -extern char **ccachesearch; -extern int use_memcache; -extern int root_uses_machine_creds; -extern unsigned int context_timeout; -extern unsigned int rpc_timeout; -extern char *preferred_realm; - -struct clnt_info { - TAILQ_ENTRY(clnt_info) list; - int refcount; - int wd; - bool scanned; - char *name; - char *relpath; - char *servicename; - char *servername; - int prog; - int vers; - char *protocol; - int krb5_fd; - struct event *krb5_ev; - int gssd_fd; - struct event *gssd_ev; - struct sockaddr_storage addr; -}; - -struct clnt_upcall_info { - struct clnt_info *clp; - char lbuf[RPC_CHAN_BUF_SIZE]; - int lbuflen; - uid_t uid; -}; - -void handle_krb5_upcall(struct clnt_upcall_info *clp); -void handle_gssd_upcall(struct clnt_upcall_info *clp); -void free_upcall_info(struct clnt_upcall_info *info); - - -#endif /* _RPC_GSSD_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/gssd.man b/nfs-utils-2.5.2/utils/gssd/gssd.man deleted file mode 100644 index 26095a8..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gssd.man +++ /dev/null @@ -1,364 +0,0 @@ -.\" -.\" rpc.gssd(8) -.\" -.\" Copyright (C) 2003 J. Bruce Fields -.\" -.TH rpc.gssd 8 "20 Feb 2013" -.SH NAME -rpc.gssd \- RPCSEC_GSS daemon -.SH SYNOPSIS -.B rpc.gssd -.RB [ \-DfMnlvr ] -.RB [ \-k -.IR keytab ] -.RB [ \-p -.IR pipefsdir ] -.RB [ \-d -.IR ccachedir ] -.RB [ \-t -.IR timeout ] -.RB [ \-R -.IR realm ] -.SH INTRODUCTION -The RPCSEC_GSS protocol, defined in RFC 5403, is used to provide -strong security for RPC-based protocols such as NFS. -.P -Before exchanging RPC requests using RPCSEC_GSS, an RPC client must -establish a GSS -.IR "security context" . -A security context is shared state on each -end of a network transport that enables GSS-API security services. -.P -Security contexts are established using -.IR "security credentials" . -A credential grants temporary access to a secure network service, -much as a railway ticket grants temporary access to use a rail service. -.P -A user typically obtains a credential by providing a password to the -.BR kinit (1) -command, or via a PAM library at login time. -A credential acquired with a -.I user principal -is known as a -.I user credential -(see -.BR kerberos (1) -for more on principals). -.P -Certain operations require a credential that -represents no particular user -or -represents the host itself. -This kind of credential is called a -.IR "machine credential" . -.P -A host establishes its machine credential using a -.I "service principal" -whose encrypted password is stored in a local file known as a -.IR keytab . -A machine credential remains effective -without user intervention -as long as the host can renew it. -.P -Once obtained, credentials are typically stored in local temporary files -with well-known pathnames. -.SH DESCRIPTION -To establish GSS security contexts using these credential files, -the Linux kernel RPC client depends on a userspace daemon called -.BR rpc.gssd . -The -.B rpc.gssd -daemon uses the rpc_pipefs filesystem to communicate with the kernel. -.SS User Credentials -When a user authenticates using a command such as -.BR kinit (1), -the resulting credential is stored in a file with a well-known name -constructed using the user's UID. -.P -To interact with an NFS server -on behalf of a particular Kerberos-authenticated user, -the Linux kernel RPC client requests that -.B rpc.gssd -initialize a security context with the credential -in that user's credential file. -.P -Typically, credential files are placed in -.IR /tmp . -However, -.B rpc.gssd -can search for credential files in more than one directory. -See the description of the -.B -d -option for details. -.SS Machine Credentials -.B rpc.gssd -searches the default keytab, -.IR /etc/krb5.keytab , -in the following order for a principal and password to use -when establishing the machine credential. -For the search, rpc.gssd replaces and with the local -system's hostname and Kerberos realm. -.sp - $@ -.br - root/@ -.br - nfs/@ -.br - host/@ -.br - root/@ -.br - nfs/@ -.br - host/@ -.sp -rpc.gssd selects one of the entries if it does not find -a service principal matching the local hostname, -e.g. if DHCP assigns the local hostname dynamically. -The facility enables the use of the same keytab on multiple systems. -However, using the same service principal to establish a machine credential -on multiple hosts can create unwanted security exposures -and is therefore not recommended. -.P -Note that $@ is a user principal -that enables Kerberized NFS when the local system is joined -to an Active Directory domain using Samba. -The keytab provides the password for this principal. -.P -You can specify a different keytab by using the -.B -k -option if -.I /etc/krb5.keytab -does not exist or does not provide one of these principals. -.SS Credentials for UID 0 -UID 0 is a special case. -By default -.B rpc.gssd -uses the system's machine credentials for UID 0 accesses -that require GSS authentication. -This limits the privileges of the root user -when accessing network resources that require authentication. -.P -Specify the -.B -n -option when starting -.B rpc.gssd -if you'd like to force the root user to obtain a user credential -rather than use the local system's machine credential. -.P -When -.B -n -is specified, -the kernel continues to request a GSS context established -with a machine credential for NFSv4 operations, -such as SETCLIENTID or RENEW, that manage state. -If -.B rpc.gssd -cannot obtain a machine credential (say, the local system has -no keytab), NFSv4 operations that require machine credentials will fail. -.SS Encryption types -A realm administrator can choose to add keys encoded in a number of different -encryption types to the local system's keytab. -For instance, a host/ principal might have keys for the -.BR aes256-cts-hmac-sha1-96 , -.BR aes128-cts-hmac-sha1-96 , -.BR des3-cbc-sha1 ", and" -.BR arcfour-hmac " encryption types." -This permits -.B rpc.gssd -to choose an appropriate encryption type that the target NFS server -supports. -.P -These encryption types are stronger than legacy single-DES encryption types. -To interoperate in environments where servers support -only weak encryption types, -you can restrict your client to use only single-DES encryption types -by specifying the -.B -l -option when starting -.BR rpc.gssd . -.SH OPTIONS -.TP -.B \-D -The server name passed to GSSAPI for authentication is normally the -name exactly as requested. e.g. for NFS -it is the server name in the "servername:/path" mount request. Only if this -servername appears to be an IP address (IPv4 or IPv6) or an -unqualified name (no dots) will a reverse DNS lookup -will be performed to get the canoncial server name. - -If -.B \-D -is present, a reverse DNS lookup will -.I always -be used, even if the server name looks like a canonical name. So it -is needed if partially qualified, or non canonical names are regularly -used. - -Using -.B \-D -can introduce a security vulnerability, so it is recommended that -.B \-D -not be used, and that canonical names always be used when requesting -services. -.TP -.B -f -Runs -.B rpc.gssd -in the foreground and sends output to stderr (as opposed to syslogd) -.TP -.B -n -When specified, UID 0 is forced to obtain user credentials -which are used instead of the local system's machine credentials. -.TP -.BI "-k " keytab -Tells -.B rpc.gssd -to use the keys found in -.I keytab -to obtain machine credentials. -The default value is -.IR /etc/krb5.keytab . -.TP -.B -l -When specified, restricts -.B rpc.gssd -to sessions to weak encryption types such as -.BR des-cbc-crc . -This option is available only when the local system's Kerberos library -supports settable encryption types. -.TP -.BI "-p " path -Tells -.B rpc.gssd -where to look for the rpc_pipefs filesystem. The default value is -.IR /var/lib/nfs/rpc_pipefs . -.TP -.BI "-d " search-path -This option specifies a colon separated list of directories that -.B rpc.gssd -searches for credential files. The default value is -.IR /tmp:/run/user/%U . -The literal sequence "%U" can be specified to substitue the UID -of the user for whom credentials are being searched. -.TP -.B -M -By default, machine credentials are stored in files in the first -directory in the credential directory search path (see the -.B -d -option). When -.B -M -is set, -.B rpc.gssd -stores machine credentials in memory instead. -.TP -.B -v -Increases the verbosity of the output (can be specified multiple times). -.TP -.B -r -If the RPCSEC_GSS library supports setting debug level, -increases the verbosity of the output (can be specified multiple times). -.TP -.BI "-R " realm -Kerberos tickets from this -.I realm -will be preferred when scanning available credentials cache files to be -used to create a context. By default, the default realm, as configured -in the Kerberos configuration file, is preferred. -.TP -.BI "-t " timeout -Timeout, in seconds, for kernel GSS contexts. This option allows you to force -new kernel contexts to be negotiated after -.I timeout -seconds, which allows changing Kerberos tickets and identities frequently. -The default is no explicit timeout, which means the kernel context will live -the lifetime of the Kerberos service ticket used in its creation. -.TP -.B -T timeout -Timeout, in seconds, to create an RPC connection with a server while -establishing an authenticated gss context for a user. -The default timeout is set to 5 seconds. -If you get messages like "WARNING: can't create tcp rpc_clnt to server -%servername% for user with uid %uid%: RPC: Remote system error - -Connection timed out", you should consider an increase of this timeout. -.SH CONFIGURATION FILE -Many of the options that can be set on the command line can also be -controlled through values set in the -.B [gssd] -section of the -.I /etc/nfs.conf -configuration file. Values recognized include: -.TP -.B verbosity -Value which is equivalent to the number of -.BR -v . -.TP -.B rpc-verbosity -Value which is equivalent to the number of -.BR -r . -.TP -.B use-memcache -A Boolean flag equivalent to -.BR -M . -.TP -.B use-machine-creds -A Boolean flag. Setting to -.B false -is equivalent to giving the -.B -n -flag. -.TP -.B avoid-dns -Setting to -.B false -is equivalent to providing the -.B -D -flag. -.TP -.B limit-to-legacy-enctypes -Equivalent to -.BR -l . -.TP -.B context-timeout -Equivalent to -.BR -t . -.TP -.B rpc-timeout -Equivalent to -.BR -T . -.TP -.B keytab-file -Equivalent to -.BR -k . -.TP -.BR cred-cache-directory -Equivalent to -.BR -d . -.TP -.B preferred-realm -Equivalent to -.BR -R . -.P -In addtion, the following value is recognized from the -.B [general] -section: -.TP -.B pipefs-directory -Equivalent to -.BR -p . - -.SH SEE ALSO -.BR rpc.svcgssd (8), -.BR kerberos (1), -.BR kinit (1), -.BR krb5.conf (5) -.SH AUTHORS -.br -Dug Song -.br -Andy Adamson -.br -Marius Aamodt Eriksen -.br -J. Bruce Fields diff --git a/nfs-utils-2.5.2/utils/gssd/gssd_proc.c b/nfs-utils-2.5.2/utils/gssd/gssd_proc.c deleted file mode 100644 index e830f49..0000000 --- a/nfs-utils-2.5.2/utils/gssd/gssd_proc.c +++ /dev/null @@ -1,838 +0,0 @@ -/* - gssd_proc.c - - Copyright (c) 2000-2004 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - Copyright (c) 2001 Andy Adamson . - Copyright (c) 2002 Marius Aamodt Eriksen . - Copyright (c) 2002 Bruce Fields - Copyright (c) 2004 Kevin Coffman - Copyright (c) 2014 David H?rdeman - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gssd.h" -#include "err_util.h" -#include "gss_util.h" -#include "krb5_util.h" -#include "context.h" -#include "nfsrpc.h" -#include "nfslib.h" -#include "gss_names.h" - -/* Encryption types supported by the kernel rpcsec_gss code */ -int num_krb5_enctypes = 0; -krb5_enctype *krb5_enctypes = NULL; - -/* - * Parse the supported encryption type information - */ -static int -parse_enctypes(char *enctypes) -{ - int n = 0; - char *curr, *comma; - int i; - static char *cached_types; - - if (cached_types && strcmp(cached_types, enctypes) == 0) - return 0; - free(cached_types); - - if (krb5_enctypes != NULL) { - free(krb5_enctypes); - krb5_enctypes = NULL; - num_krb5_enctypes = 0; - } - - /* count the number of commas */ - for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) { - comma = strchr(curr, ','); - if (comma != NULL) - n++; - else - break; - } - /* If no more commas and we're not at the end, there's one more value */ - if (*curr != '\0') - n++; - - /* Empty string, return an error */ - if (n == 0) - return ENOENT; - - /* Allocate space for enctypes array */ - if ((krb5_enctypes = (int *) calloc(n, sizeof(int))) == NULL) { - return ENOMEM; - } - - /* Now parse each value into the array */ - for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) { - krb5_enctypes[i++] = atoi(curr); - comma = strchr(curr, ','); - if (comma == NULL) - break; - } - - num_krb5_enctypes = n; - if ((cached_types = malloc(strlen(enctypes)+1))) - strcpy(cached_types, enctypes); - - return 0; -} - -static void -do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd, - gss_buffer_desc *context_token, OM_uint32 lifetime_rec, - gss_buffer_desc *acceptor) -{ - char *buf = NULL, *p = NULL, *end = NULL; - unsigned int timeout = context_timeout; - unsigned int buf_size = 0; - pthread_t tid = pthread_self(); - - printerr(2, "do_downcall(0x%x): lifetime_rec=%u acceptor=%.*s\n", - tid, lifetime_rec, acceptor->length, acceptor->value); - buf_size = sizeof(uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) + - sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + - sizeof(context_token->length) + context_token->length + - sizeof(acceptor->length) + acceptor->length; - p = buf = malloc(buf_size); - if (!buf) - goto out_err; - - end = buf + buf_size; - - /* context_timeout set by -t option overrides context lifetime */ - if (timeout == 0) - timeout = lifetime_rec; - if (WRITE_BYTES(&p, end, uid)) goto out_err; - if (WRITE_BYTES(&p, end, timeout)) goto out_err; - if (WRITE_BYTES(&p, end, pd->pd_seq_win)) goto out_err; - if (write_buffer(&p, end, &pd->pd_ctx_hndl)) goto out_err; - if (write_buffer(&p, end, context_token)) goto out_err; - if (write_buffer(&p, end, acceptor)) goto out_err; - - if (write(k5_fd, buf, p - buf) < p - buf) goto out_err; - free(buf); - return; -out_err: - free(buf); - printerr(1, "do_downcall(0x%x): Failed to write downcall!\n", tid); - return; -} - -static int -do_error_downcall(int k5_fd, uid_t uid, int err) -{ - char buf[1024]; - char *p = buf, *end = buf + 1024; - unsigned int timeout = 0; - int zero = 0; - - printerr(2, "doing error downcall\n"); - - if (WRITE_BYTES(&p, end, uid)) goto out_err; - if (WRITE_BYTES(&p, end, timeout)) goto out_err; - /* use seq_win = 0 to indicate an error: */ - if (WRITE_BYTES(&p, end, zero)) goto out_err; - if (WRITE_BYTES(&p, end, err)) goto out_err; - - if (write(k5_fd, buf, p - buf) < p - buf) goto out_err; - return 0; -out_err: - printerr(1, "Failed to write error downcall!\n"); - return -1; -} - -/* - * If the port isn't already set, do an rpcbind query to the remote server - * using the program and version and get the port. - * - * Newer kernels send the value of the port= mount option in the "info" - * file for the upcall or '0' for NFSv2/3. For NFSv4 it sends the value - * of the port= option or '2049'. The port field in a new sockaddr should - * reflect the value that was sent by the kernel. - */ -static int -populate_port(struct sockaddr *sa, const socklen_t salen, - const rpcprog_t program, const rpcvers_t version, - const unsigned short protocol) -{ - struct sockaddr_in *s4 = (struct sockaddr_in *) sa; -#ifdef IPV6_SUPPORTED - struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa; -#endif /* IPV6_SUPPORTED */ - unsigned short port; - - /* - * Newer kernels send the port in the upcall. If we already have - * the port, there's no need to look it up. - */ - switch (sa->sa_family) { - case AF_INET: - if (s4->sin_port != 0) { - printerr(4, "DEBUG: port already set to %d\n", - ntohs(s4->sin_port)); - return 1; - } - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - if (s6->sin6_port != 0) { - printerr(4, "DEBUG: port already set to %d\n", - ntohs(s6->sin6_port)); - return 1; - } - break; -#endif /* IPV6_SUPPORTED */ - default: - printerr(0, "ERROR: unsupported address family %d\n", - sa->sa_family); - return 0; - } - - /* - * Newer kernels that send the port in the upcall set the value to - * 2049 for NFSv4 mounts when one isn't specified. The check below is - * only for kernels that don't send the port in the upcall. For those - * we either have to do an rpcbind query or set it to the standard - * port. Doing a query could be problematic (firewalls, etc), so take - * the latter approach. - */ - if (program == 100003 && version == 4) { - port = 2049; - goto set_port; - } - - port = nfs_getport(sa, salen, program, version, protocol); - if (!port) { - printerr(0, "ERROR: unable to obtain port for prog %ld " - "vers %ld\n", program, version); - return 0; - } - -set_port: - printerr(2, "DEBUG: setting port to %hu for prog %lu vers %lu\n", port, - program, version); - - switch (sa->sa_family) { - case AF_INET: - s4->sin_port = htons(port); - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - s6->sin6_port = htons(port); - break; -#endif /* IPV6_SUPPORTED */ - } - - return 1; -} - -/* - * Create an RPC connection and establish an authenticated - * gss context with a server. - */ -static int -create_auth_rpc_client(struct clnt_info *clp, - char *tgtname, - CLIENT **clnt_return, - AUTH **auth_return, - uid_t uid, - int authtype, - gss_cred_id_t cred) -{ - CLIENT *rpc_clnt = NULL; - struct rpc_gss_sec sec; - AUTH *auth = NULL; - int retval = -1; - OM_uint32 min_stat; - char rpc_errmsg[1024]; - int protocol; - struct timeval timeout; - struct sockaddr *addr = (struct sockaddr *) &clp->addr; - socklen_t salen; - - sec.qop = GSS_C_QOP_DEFAULT; - sec.svc = RPCSEC_GSS_SVC_NONE; - sec.cred = cred; - sec.req_flags = 0; - if (authtype == AUTHTYPE_KRB5) { - sec.mech = (gss_OID)&krb5oid; - sec.req_flags = GSS_C_MUTUAL_FLAG; - } - else { - printerr(0, "ERROR: Invalid authentication type (%d) " - "in create_auth_rpc_client\n", authtype); - goto out_fail; - } - - - if (authtype == AUTHTYPE_KRB5) { -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES - /* - * Do this before creating rpc connection since we won't need - * rpc connection if it fails! - */ - if (limit_krb5_enctypes(&sec)) { - printerr(1, "WARNING: Failed while limiting krb5 " - "encryption types for user with uid %d\n", - uid); - goto out_fail; - } -#endif - } - - /* create an rpc connection to the nfs server */ - - printerr(2, "creating %s client for server %s\n", clp->protocol, - clp->servername); - - protocol = IPPROTO_TCP; - if ((strcmp(clp->protocol, "udp")) == 0) - protocol = IPPROTO_UDP; - - switch (addr->sa_family) { - case AF_INET: - salen = sizeof(struct sockaddr_in); - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - salen = sizeof(struct sockaddr_in6); - break; -#endif /* IPV6_SUPPORTED */ - default: - printerr(1, "ERROR: Unknown address family %d\n", - addr->sa_family); - goto out_fail; - } - - if (!populate_port(addr, salen, clp->prog, clp->vers, protocol)) - goto out_fail; - - /* set the timeout according to the requested valued */ - timeout.tv_sec = (long) rpc_timeout; - timeout.tv_usec = (long) 0; - - rpc_clnt = nfs_get_rpcclient(addr, salen, protocol, clp->prog, - clp->vers, &timeout); - if (!rpc_clnt) { - snprintf(rpc_errmsg, sizeof(rpc_errmsg), - "WARNING: can't create %s rpc_clnt to server %s for " - "user with uid %d", - protocol == IPPROTO_TCP ? "tcp" : "udp", - clp->servername, uid); - printerr(0, "%s\n", - clnt_spcreateerror(rpc_errmsg)); - goto out_fail; - } - if (!tgtname) - tgtname = clp->servicename; - - printerr(2, "creating context with server %s\n", tgtname); - auth = authgss_create_default(rpc_clnt, tgtname, &sec); - if (!auth) { - /* Our caller should print appropriate message */ - printerr(2, "WARNING: Failed to create krb5 context for " - "user with uid %d for server %s\n", - uid, tgtname); - goto out_fail; - } - - /* Success !!! */ - rpc_clnt->cl_auth = auth; - *clnt_return = rpc_clnt; - *auth_return = auth; - retval = 0; - - out: - if (sec.cred != GSS_C_NO_CREDENTIAL) - gss_release_cred(&min_stat, &sec.cred); - return retval; - - out_fail: - /* Only destroy here if failure. Otherwise, caller is responsible */ - if (rpc_clnt) clnt_destroy(rpc_clnt); - - goto out; -} - -/* - * Create the context as the user (not as root). - * - * Note that we change the *real* uid here, as changing the effective uid is - * not sufficient. This is due to an unfortunate historical error in the MIT - * krb5 libs, where they used %{uid} in the default_ccache_name. Changing that - * now might break some applications so we're sort of stuck with it. - * - * Unfortunately, doing this leaves the forked child vulnerable to signals and - * renicing, but this is the best we can do. In the event that a child is - * signalled before downcalling, the kernel will just eventually time out the - * upcall attempt. - */ -static int -change_identity(uid_t uid) -{ - struct passwd *pw; - int res; - - /* drop list of supplimentary groups first */ -#ifdef __NR_setgroups32 - if (syscall(SYS_setgroups32, 0, 0) != 0) { -#else - if (syscall(SYS_setgroups, 0, 0) != 0) { -#endif - printerr(0, "WARNING: unable to drop supplimentary groups!"); - return errno; - } - - /* try to get pwent for user */ - pw = getpwuid(uid); - if (!pw) { - /* if that doesn't work, try to get one for "nobody" */ - errno = 0; - pw = getpwnam("nobody"); - if (!pw) { - printerr(0, "WARNING: unable to determine gid for uid %u\n", uid); - return errno ? errno : ENOENT; - } - } - - /* Switch the UIDs and GIDs. */ - /* For the threaded version we have to set uid,gid per thread instead - * of per process. glibc setresuid() when called from a thread, it'll - * send a signal to all other threads to synchronize the uid in all - * other threads. To bypass this, we have to call syscall() directly. - */ -#ifdef __NR_setresgid32 - res = syscall(SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); -#else - res = syscall(SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); -#endif - if (res != 0) { - printerr(0, "WARNING: failed to set gid to %u!\n", pw->pw_gid); - return errno; - } - -#ifdef __NR_setresuid32 - res = syscall(SYS_setresuid32, uid, uid, uid); -#else - res = syscall(SYS_setresuid, uid, uid, uid); -#endif - if (res != 0) { - printerr(0, "WARNING: Failed to setuid for user with uid %u\n", uid); - return errno; - } - - return 0; -} - -static AUTH * -krb5_not_machine_creds(struct clnt_info *clp, uid_t uid, char *tgtname, - int *downcall_err, int *chg_err, CLIENT **rpc_clnt) -{ - AUTH *auth = NULL; - gss_cred_id_t gss_cred; - char **dname; - int err, resp = -1; - - printerr(2, "krb5_not_machine_creds: uid %d tgtname %s\n", - uid, tgtname); - - *chg_err = change_identity(uid); - if (*chg_err) { - printerr(0, "WARNING: failed to change identity: %s", - strerror(*chg_err)); - goto out; - } - - /** Tell krb5 gss which credentials cache to use. - * Try first to acquire credentials directly via GSSAPI - */ - err = gssd_acquire_user_cred(&gss_cred); - if (err == 0) - resp = create_auth_rpc_client(clp, tgtname, rpc_clnt, - &auth, uid, - AUTHTYPE_KRB5, gss_cred); - - /** if create_auth_rplc_client fails try the traditional - * method of trolling for credentials - */ - for (dname = ccachesearch; resp != 0 && *dname != NULL; dname++) { - err = gssd_setup_krb5_user_gss_ccache(uid, clp->servername, - *dname); - if (err == -EKEYEXPIRED) - *downcall_err = -EKEYEXPIRED; - else if (err == 0) - resp = create_auth_rpc_client(clp, tgtname, rpc_clnt, - &auth, uid,AUTHTYPE_KRB5, - GSS_C_NO_CREDENTIAL); - } - -out: - return auth; -} - -static AUTH * -krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, - char *srchost, char *tgtname, char *service, - CLIENT **rpc_clnt) -{ - AUTH *auth = NULL; - char **credlist = NULL; - char **ccname; - int nocache = 0; - int success = 0; - - printerr(2, "krb5_use_machine_creds: uid %d tgtname %s\n", - uid, tgtname); - - do { - gssd_refresh_krb5_machine_credential(clp->servername, - service, srchost); - /* - * Get a list of credential cache names and try each - * of them until one works or we've tried them all - */ - if (gssd_get_krb5_machine_cred_list(&credlist)) { - printerr(0, "ERROR: No credentials found " - "for connection to server %s\n", - clp->servername); - goto out; - } - for (ccname = credlist; ccname && *ccname; ccname++) { - u_int min_stat; - - if (gss_krb5_ccache_name(&min_stat, *ccname, NULL) != - GSS_S_COMPLETE) { - printerr(1, "WARNING: gss_krb5_ccache_name " - "with name '%s' failed (%s)\n", - *ccname, error_message(min_stat)); - continue; - } - if ((create_auth_rpc_client(clp, tgtname, rpc_clnt, - &auth, uid, - AUTHTYPE_KRB5, - GSS_C_NO_CREDENTIAL)) == 0) { - /* Success! */ - success++; - break; - } - printerr(2, "WARNING: Failed to create machine krb5 " - "context with cred cache %s for server %s\n", - *ccname, clp->servername); - } - gssd_free_krb5_machine_cred_list(credlist); - if (!success) { - if(nocache == 0) { - nocache++; - printerr(2, "WARNING: Machine cache prematurely " - "expired or corrupted trying to " - "recreate cache for server %s\n", - clp->servername); - } else { - printerr(1, "ERROR: Failed to create machine " - "krb5 context with any credentials " - "cache for server %s\n", - clp->servername); - goto out; - } - } - } while(!success); - -out: - return auth; -} - -/* - * this code uses the userland rpcsec gss library to create a krb5 - * context on behalf of the kernel - */ -static void -process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *srchost, - char *tgtname, char *service) -{ - CLIENT *rpc_clnt = NULL; - AUTH *auth = NULL; - struct authgss_private_data pd; - gss_buffer_desc token; - int err, downcall_err = -EACCES; - OM_uint32 maj_stat, min_stat, lifetime_rec; - gss_name_t gacceptor = GSS_C_NO_NAME; - gss_OID mech; - gss_buffer_desc acceptor = {0}; - - token.length = 0; - token.value = NULL; - memset(&pd, 0, sizeof(struct authgss_private_data)); - - /* - * If "service" is specified, then the kernel is indicating that - * we must use machine credentials for this request. (Regardless - * of the uid value or the setting of root_uses_machine_creds.) - * If the service value is "*", then any service name can be used. - * Otherwise, it specifies the service name that should be used. - * (For now, the values of service will only be "*" or "nfs".) - * - * Restricting gssd to use "nfs" service name is needed for when - * the NFS server is doing a callback to the NFS client. In this - * case, the NFS server has to authenticate itself as "nfs" -- - * even if there are other service keys such as "host" or "root" - * in the keytab. - * - * Another case when the kernel may specify the service attribute - * is when gssd is being asked to create the context for a - * SETCLIENT_ID operation. In this case, machine credentials - * must be used for the authentication. However, the service name - * used for this case is not important. - * - */ - if (uid != 0 || (uid == 0 && root_uses_machine_creds == 0 && - service == NULL)) { - - auth = krb5_not_machine_creds(clp, uid, tgtname, &downcall_err, - &err, &rpc_clnt); - if (err) - goto out_return_error; - } - if (auth == NULL) { - if (uid == 0 && (root_uses_machine_creds == 1 || - service != NULL)) { - auth = krb5_use_machine_creds(clp, uid, srchost, tgtname, - service, &rpc_clnt); - if (auth == NULL) - goto out_return_error; - } else { - /* krb5_not_machine_creds logs the error */ - goto out_return_error; - } - } - - if (!authgss_get_private_data(auth, &pd)) { - printerr(1, "WARNING: Failed to obtain authentication " - "data for user with uid %d for server %s\n", - uid, clp->servername); - goto out_return_error; - } - - /* Grab the context lifetime and acceptor name out of the ctx. */ - maj_stat = gss_inquire_context(&min_stat, pd.pd_ctx, NULL, &gacceptor, - &lifetime_rec, &mech, NULL, NULL, NULL); - - if (maj_stat != GSS_S_COMPLETE) { - printerr(1, "WARNING: Failed to inquire context " - "maj_stat (0x%x)\n", maj_stat); - lifetime_rec = 0; - } else { - get_hostbased_client_buffer(gacceptor, mech, &acceptor); - gss_release_name(&min_stat, &gacceptor); - } - - /* - * The serialization can mean turning pd.pd_ctx into a lucid context. If - * that happens then the pd.pd_ctx will be unusable, so we must never - * try to use it after this point. - */ - if (serialize_context_for_kernel(&pd.pd_ctx, &token, &krb5oid, NULL)) { - printerr(1, "WARNING: Failed to serialize krb5 context for " - "user with uid %d for server %s\n", - uid, clp->servername); - goto out_return_error; - } - - do_downcall(fd, uid, &pd, &token, lifetime_rec, &acceptor); - -out: - gss_release_buffer(&min_stat, &acceptor); - if (token.value) - free(token.value); -#ifdef HAVE_AUTHGSS_FREE_PRIVATE_DATA - if (pd.pd_ctx_hndl.length != 0 || pd.pd_ctx != 0) - authgss_free_private_data(&pd); -#endif - if (auth) - AUTH_DESTROY(auth); - if (rpc_clnt) - clnt_destroy(rpc_clnt); - - return; - -out_return_error: - do_error_downcall(fd, uid, downcall_err); - goto out; -} - -void -handle_krb5_upcall(struct clnt_upcall_info *info) -{ - struct clnt_info *clp = info->clp; - - printerr(2, "\n%s: uid %d (%s)\n", __func__, info->uid, clp->relpath); - - process_krb5_upcall(clp, info->uid, clp->krb5_fd, NULL, NULL, NULL); - free_upcall_info(info); -} - -void -handle_gssd_upcall(struct clnt_upcall_info *info) -{ - struct clnt_info *clp = info->clp; - uid_t uid; - char *p; - char *mech = NULL; - char *uidstr = NULL; - char *target = NULL; - char *service = NULL; - char *srchost = NULL; - char *enctypes = NULL; - char *upcall_str; - char *pbuf = info->lbuf; - pthread_t tid = pthread_self(); - - printerr(2, "\n%s(0x%x): '%s' (%s)\n", __func__, tid, - info->lbuf, clp->relpath); - - upcall_str = strdup(info->lbuf); - if (upcall_str == NULL) { - printerr(0, "ERROR: malloc failure\n"); - goto out_nomem; - } - - while ((p = strsep(&pbuf, " "))) { - if (!strncmp(p, "mech=", strlen("mech="))) - mech = p + strlen("mech="); - else if (!strncmp(p, "uid=", strlen("uid="))) - uidstr = p + strlen("uid="); - else if (!strncmp(p, "enctypes=", strlen("enctypes="))) - enctypes = p + strlen("enctypes="); - else if (!strncmp(p, "target=", strlen("target="))) - target = p + strlen("target="); - else if (!strncmp(p, "service=", strlen("service="))) - service = p + strlen("service="); - else if (!strncmp(p, "srchost=", strlen("srchost="))) - srchost = p + strlen("srchost="); - } - - if (!mech || strlen(mech) < 1) { - printerr(0, "WARNING: handle_gssd_upcall: " - "failed to find gss mechanism name " - "in upcall string '%s'\n", upcall_str); - goto out; - } - - if (uidstr) { - uid = (uid_t)strtol(uidstr, &p, 10); - if (p == uidstr || *p != '\0') - uidstr = NULL; - } - - if (!uidstr) { - printerr(0, "WARNING: handle_gssd_upcall: " - "failed to find uid " - "in upcall string '%s'\n", upcall_str); - goto out; - } - - if (enctypes && parse_enctypes(enctypes) != 0) { - printerr(0, "WARNING: handle_gssd_upcall: " - "parsing encryption types failed: errno %d\n", errno); - goto out; - } - - if (target && strlen(target) < 1) { - printerr(0, "WARNING: handle_gssd_upcall: " - "failed to parse target name " - "in upcall string '%s'\n", upcall_str); - goto out; - } - - /* - * The presence of attribute "service=" indicates that machine - * credentials should be used for this request. If the value - * is "*", then any machine credentials available can be used. - * If the value is anything else, then machine credentials for - * the specified service name (always "nfs" for now) should be - * used. - */ - if (service && strlen(service) < 1) { - printerr(0, "WARNING: handle_gssd_upcall: " - "failed to parse service type " - "in upcall string '%s'\n", upcall_str); - goto out; - } - - if (strcmp(mech, "krb5") == 0 && clp->servername) - process_krb5_upcall(clp, uid, clp->gssd_fd, srchost, target, service); - else { - if (clp->servername) - printerr(0, "WARNING: handle_gssd_upcall: " - "received unknown gss mech '%s'\n", mech); - do_error_downcall(clp->gssd_fd, uid, -EACCES); - } -out: - free(upcall_str); -out_nomem: - free_upcall_info(info); - return; -} diff --git a/nfs-utils-2.5.2/utils/gssd/krb5_util.c b/nfs-utils-2.5.2/utils/gssd/krb5_util.c deleted file mode 100644 index 28b60ba..0000000 --- a/nfs-utils-2.5.2/utils/gssd/krb5_util.c +++ /dev/null @@ -1,1578 +0,0 @@ -/* - * Adapted in part from MIT Kerberos 5-1.2.1 slave/kprop.c and from - * http://docs.sun.com/?p=/doc/816-1331/6m7oo9sms&a=view - * - * Copyright (c) 2002-2004 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson - * J. Bruce Fields - * Marius Aamodt Eriksen - * Kevin Coffman - */ - -/* - * slave/kprop.c - * - * Copyright 1990,1991 by the Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -/* - * Copyright 1994 by OpenVision Technologies, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of OpenVision not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. OpenVision makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -/* - krb5_util.c - - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_PRIVATE_KRB5_FUNCTIONS -#include -#endif -#include -#include - -#include -#include - -#include "nfslib.h" -#include "gssd.h" -#include "err_util.h" -#include "gss_util.h" -#include "krb5_util.h" - -/* - * List of principals from our keytab that we - * will try to use to obtain credentials - * (known as a principal list entry (ple)) - */ -struct gssd_k5_kt_princ { - struct gssd_k5_kt_princ *next; - // Only protect against deletion, not modification - int refcount; - // Only set during creation in new_ple() - krb5_principal princ; - char *realm; - // Modified during usage by gssd_get_single_krb5_cred() - char *ccname; - krb5_timestamp endtime; -}; - - -/* Global list of principals/cache file names for machine credentials */ -static struct gssd_k5_kt_princ *gssd_k5_kt_princ_list = NULL; -/* This mutex protects list modification & ple->ccname */ -static pthread_mutex_t ple_lock = PTHREAD_MUTEX_INITIALIZER; - -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES -int limit_to_legacy_enctypes = 0; -#endif - -/*==========================*/ -/*=== Internal routines ===*/ -/*==========================*/ - -static int select_krb5_ccache(const struct dirent *d); -static int gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, - const char **cctype, struct dirent **d); -static int gssd_get_single_krb5_cred(krb5_context context, - krb5_keytab kt, struct gssd_k5_kt_princ *ple); -static int query_krb5_ccache(const char* cred_cache, char **ret_princname, - char **ret_realm); - -static void release_ple(krb5_context context, struct gssd_k5_kt_princ *ple) -{ - if (--ple->refcount) - return; - - printerr(3, "freeing cached principal (ccname=%s, realm=%s)\n", ple->ccname, ple->realm); - krb5_free_principal(context, ple->princ); - free(ple->ccname); - free(ple->realm); - free(ple); -} - -/* - * Called from the scandir function to weed out potential krb5 - * credentials cache files - * - * Returns: - * 0 => don't select this one - * 1 => select this one - */ -static int -select_krb5_ccache(const struct dirent *d) -{ - /* - * Note: We used to check d->d_type for DT_REG here, - * but apparenlty reiser4 always has DT_UNKNOWN. - * Check for IS_REG after stat() call instead. - */ - if (strstr(d->d_name, GSSD_DEFAULT_CRED_PREFIX)) - return 1; - else - return 0; -} - -/* - * Look in directory "dirname" for files that look like they - * are Kerberos Credential Cache files for a given UID. - * - * Returns 0 if a valid-looking entry is found. "*cctype" is - * set to the name of the cache type. A pointer to the dirent - * is planted in "*d". Caller must free "*d" with free(3). - * - * Otherwise, a negative errno is returned. - */ -static int -gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, - const char **cctype, struct dirent **d) -{ - struct dirent **namelist; - int n; - int i; - int found = 0; - struct dirent *best_match_dir = NULL; - struct stat best_match_stat, tmp_stat; - /* dirname + cctype + d_name + NULL */ - char buf[PATH_MAX+5+256+1]; - char *princname = NULL; - char *realm = NULL; - int score, best_match_score = 0, err = -EACCES; - - memset(&best_match_stat, 0, sizeof(best_match_stat)); - *cctype = NULL; - *d = NULL; - n = scandir(dirname, &namelist, select_krb5_ccache, 0); - if (n < 0) { - printerr(1, "Error doing scandir on directory '%s': %s\n", - dirname, strerror(errno)); - } - else if (n > 0) { - for (i = 0; i < n; i++) { - snprintf(buf, sizeof(buf), - "%s/%s", dirname, namelist[i]->d_name); - printerr(3, "CC '%s' being considered, " - "with preferred realm '%s'\n", - buf, preferred_realm ? - preferred_realm : ""); - if (lstat(buf, &tmp_stat)) { - printerr(0, "Error doing stat on '%s'\n", buf); - free(namelist[i]); - continue; - } - /* Only pick caches owned by the user (uid) */ - if (tmp_stat.st_uid != uid) { - printerr(3, "CC '%s' owned by %u, not %u\n", - buf, tmp_stat.st_uid, uid); - free(namelist[i]); - continue; - } - if (!S_ISREG(tmp_stat.st_mode) && - !S_ISDIR(tmp_stat.st_mode)) { - printerr(3, "CC '%s' is not a regular " - "file or directory\n", buf); - free(namelist[i]); - continue; - } - if (uid == 0 && !root_uses_machine_creds && - strstr(namelist[i]->d_name, "machine_")) { - printerr(3, "CC '%s' not available to root\n", buf); - free(namelist[i]); - continue; - } - if (S_ISDIR(tmp_stat.st_mode)) { - *cctype = "DIR"; - } else - if (S_ISREG(tmp_stat.st_mode)) { - *cctype = "FILE"; - } else { - continue; - } - snprintf(buf, sizeof(buf), "%s:%s/%s", *cctype, - dirname, namelist[i]->d_name); - if (!query_krb5_ccache(buf, &princname, &realm)) { - printerr(3, "CC '%s' is expired or corrupt\n", - buf); - free(namelist[i]); - err = -EKEYEXPIRED; - continue; - } - - score = 0; - if (preferred_realm && - strcmp(realm, preferred_realm) == 0) - score++; - - printerr(3, "CC '%s'(%s@%s) passed all checks and" - " has mtime of %u\n", - buf, princname, realm, - tmp_stat.st_mtime); - /* - * if more than one match is found, return the most - * recent (the one with the latest mtime), and - * don't free the dirent - */ - if (!found) { - best_match_dir = namelist[i]; - best_match_stat = tmp_stat; - best_match_score = score; - found++; - } - else { - /* - * If current score is higher than best match - * score, we use the current match. Otherwise, - * if the current match has an mtime later - * than the one we are looking at, then use - * the current match. Otherwise, we still - * have the best match. - */ - if (best_match_score < score || - (best_match_score == score && - tmp_stat.st_mtime > - best_match_stat.st_mtime)) { - free(best_match_dir); - best_match_dir = namelist[i]; - best_match_stat = tmp_stat; - best_match_score = score; - } - else { - free(namelist[i]); - } - printerr(3, "CC '%s:%s/%s' is our " - "current best match " - "with mtime of %u\n", - cctype, dirname, - best_match_dir->d_name, - best_match_stat.st_mtime); - } - free(princname); - free(realm); - } - free(namelist); - } - if (found) { - *d = best_match_dir; - return 0; - } - - return err; -} - -/* check if the ticket cache exists, if not set nocache=1 so that new - * tgt is gotten - */ -static int -gssd_check_if_cc_exists(struct gssd_k5_kt_princ *ple) -{ - int fd; - char cc_name[BUFSIZ]; - - snprintf(cc_name, sizeof(cc_name), "%s/%s%s_%s", - ccachesearch[0], GSSD_DEFAULT_CRED_PREFIX, - GSSD_DEFAULT_MACHINE_CRED_SUFFIX, ple->realm); - fd = open(cc_name, O_RDONLY); - if (fd < 0) - return 1; - close(fd); - return 0; -} - -/* - * Obtain credentials via a key in the keytab given - * a keytab handle and a gssd_k5_kt_princ structure. - * Checks to see if current credentials are expired, - * if not, uses the keytab to obtain new credentials. - * - * Returns: - * 0 => success (or credentials have not expired) - * nonzero => error - */ -static int -gssd_get_single_krb5_cred(krb5_context context, - krb5_keytab kt, - struct gssd_k5_kt_princ *ple) -{ -#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS - krb5_get_init_creds_opt *init_opts = NULL; -#else - krb5_get_init_creds_opt options; -#endif - krb5_get_init_creds_opt *opts; - krb5_creds my_creds; - krb5_ccache ccache = NULL; - char kt_name[BUFSIZ]; - char cc_name[BUFSIZ]; - int code; - time_t now = time(0); - char *cache_type; - char *pname = NULL; - char *k5err = NULL; - int nocache = 0; - - memset(&my_creds, 0, sizeof(my_creds)); - - if (!use_memcache) - nocache = gssd_check_if_cc_exists(ple); - /* - * Workaround for clock skew among NFS server, NFS client and KDC - * 300 because clock skew must be within 300sec for kerberos - */ - now += 300; - pthread_mutex_lock(&ple_lock); - if (ple->ccname && ple->endtime > now && !nocache) { - printerr(3, "INFO: Credentials in CC '%s' are good until %d\n", - ple->ccname, ple->endtime); - code = 0; - pthread_mutex_unlock(&ple_lock); - goto out; - } - pthread_mutex_unlock(&ple_lock); - - if ((code = krb5_kt_get_name(context, kt, kt_name, BUFSIZ))) { - printerr(0, "ERROR: Unable to get keytab name in " - "gssd_get_single_krb5_cred\n"); - goto out; - } - - if ((krb5_unparse_name(context, ple->princ, &pname))) - pname = NULL; - -#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS - code = krb5_get_init_creds_opt_alloc(context, &init_opts); - if (code) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s allocating gic options\n", k5err); - goto out; - } - if (krb5_get_init_creds_opt_set_addressless(context, init_opts, 1)) - printerr(1, "WARNING: Unable to set option for addressless " - "tickets. May have problems behind a NAT.\n"); -#ifdef TEST_SHORT_LIFETIME - /* set a short lifetime (for debugging only!) */ - printerr(1, "WARNING: Using (debug) short machine cred lifetime!\n"); - krb5_get_init_creds_opt_set_tkt_life(init_opts, 5*60); -#endif - opts = init_opts; - -#else /* HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS */ - - krb5_get_init_creds_opt_init(&options); - krb5_get_init_creds_opt_set_address_list(&options, NULL); -#ifdef TEST_SHORT_LIFETIME - /* set a short lifetime (for debugging only!) */ - printerr(0, "WARNING: Using (debug) short machine cred lifetime!\n"); - krb5_get_init_creds_opt_set_tkt_life(&options, 5*60); -#endif - opts = &options; -#endif - - if ((code = krb5_get_init_creds_keytab(context, &my_creds, ple->princ, - kt, 0, NULL, opts))) { - k5err = gssd_k5_err_msg(context, code); - printerr(1, "WARNING: %s while getting initial ticket for " - "principal '%s' using keytab '%s'\n", k5err, - pname ? pname : "", kt_name); - goto out; - } - - /* - * Initialize cache file which we're going to be using - */ - - pthread_mutex_lock(&ple_lock); - if (use_memcache) - cache_type = "MEMORY"; - else - cache_type = "FILE"; - snprintf(cc_name, sizeof(cc_name), "%s:%s/%s%s_%s", - cache_type, - ccachesearch[0], GSSD_DEFAULT_CRED_PREFIX, - GSSD_DEFAULT_MACHINE_CRED_SUFFIX, ple->realm); - ple->endtime = my_creds.times.endtime; - if (ple->ccname == NULL || strcmp(ple->ccname, cc_name) != 0) { - free(ple->ccname); - ple->ccname = strdup(cc_name); - if (ple->ccname == NULL) { - printerr(0, "ERROR: no storage to duplicate credentials " - "cache name '%s'\n", cc_name); - code = ENOMEM; - pthread_mutex_unlock(&ple_lock); - goto out; - } - } - pthread_mutex_unlock(&ple_lock); - if ((code = krb5_cc_resolve(context, cc_name, &ccache))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s while opening credential cache '%s'\n", - k5err, cc_name); - goto out; - } - if ((code = krb5_cc_initialize(context, ccache, ple->princ))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s while initializing credential " - "cache '%s'\n", k5err, cc_name); - goto out; - } - if ((code = krb5_cc_store_cred(context, ccache, &my_creds))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s while storing credentials in '%s'\n", - k5err, cc_name); - goto out; - } - - code = 0; - printerr(2, "%s: principal '%s' ccache:'%s'\n", __func__, pname, cc_name); - out: -#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS - if (init_opts) - krb5_get_init_creds_opt_free(context, init_opts); -#endif - if (pname) - k5_free_unparsed_name(context, pname); - if (ccache) - krb5_cc_close(context, ccache); - krb5_free_cred_contents(context, &my_creds); - free(k5err); - return (code); -} - -/* - * Given a principal, find a matching ple structure - * Called with mutex held - */ -static struct gssd_k5_kt_princ * -find_ple_by_princ(krb5_context context, krb5_principal princ) -{ - struct gssd_k5_kt_princ *ple; - - for (ple = gssd_k5_kt_princ_list; ple != NULL; ple = ple->next) { - if (krb5_principal_compare(context, ple->princ, princ)) - return ple; - } - /* no match found */ - return NULL; -} - -/* - * Create, initialize, and add a new ple structure to the global list - * Called with mutex held - */ -static struct gssd_k5_kt_princ * -new_ple(krb5_context context, krb5_principal princ) -{ - struct gssd_k5_kt_princ *ple = NULL, *p; - krb5_error_code code; - char *default_realm; - int is_default_realm = 0; - - ple = malloc(sizeof(struct gssd_k5_kt_princ)); - if (ple == NULL) - goto outerr; - memset(ple, 0, sizeof(*ple)); - -#ifdef HAVE_KRB5 - ple->realm = strndup(princ->realm.data, - princ->realm.length); -#else - ple->realm = strdup(princ->realm); -#endif - if (ple->realm == NULL) - goto outerr; - code = krb5_copy_principal(context, princ, &ple->princ); - if (code) - goto outerr; - - /* - * Add new entry onto the list (if this is the default - * realm, always add to the front of the list) - */ - - code = krb5_get_default_realm(context, &default_realm); - if (code == 0) { - if (strcmp(ple->realm, default_realm) == 0) - is_default_realm = 1; - k5_free_default_realm(context, default_realm); - } - - if (is_default_realm) { - ple->next = gssd_k5_kt_princ_list; - gssd_k5_kt_princ_list = ple; - } else { - p = gssd_k5_kt_princ_list; - while (p != NULL && p->next != NULL) - p = p->next; - if (p == NULL) - gssd_k5_kt_princ_list = ple; - else - p->next = ple; - } - - ple->refcount = 1; - return ple; -outerr: - if (ple) { - if (ple->realm) - free(ple->realm); - free(ple); - } - return NULL; -} - -/* - * Given a principal, find an existing ple structure, or create one - */ -static struct gssd_k5_kt_princ * -get_ple_by_princ(krb5_context context, krb5_principal princ) -{ - struct gssd_k5_kt_princ *ple; - - pthread_mutex_lock(&ple_lock); - ple = find_ple_by_princ(context, princ); - if (ple == NULL) { - ple = new_ple(context, princ); - } - if (ple != NULL) { - ple->refcount++; - } - pthread_mutex_unlock(&ple_lock); - - return ple; -} - -/* - * Given a (possibly unqualified) hostname, - * return the fully qualified (lower-case!) hostname - */ -static int -get_full_hostname(const char *inhost, char *outhost, int outhostlen) -{ - struct addrinfo *addrs = NULL; - struct addrinfo hints; - int retval; - char *c; - - memset(&hints, 0, sizeof(hints)); - hints.ai_socktype = SOCK_STREAM; - hints.ai_family = PF_UNSPEC; - hints.ai_flags = AI_CANONNAME; - - /* Get full target hostname */ - retval = getaddrinfo(inhost, NULL, &hints, &addrs); - if (retval) { - printerr(1, "%s while getting full hostname for '%s'\n", - gai_strerror(retval), inhost); - goto out; - } - strncpy(outhost, addrs->ai_canonname, outhostlen); - nfs_freeaddrinfo(addrs); - for (c = outhost; *c != '\0'; c++) - *c = tolower(*c); - - printerr(3, "Full hostname for '%s' is '%s'\n", inhost, outhost); - retval = 0; -out: - return retval; -} - -/* - * If principal matches the given realm and service name, - * and has *any* instance (hostname), return 1. - * Otherwise return 0, indicating no match. - */ -#ifdef HAVE_KRB5 -static int -realm_and_service_match(krb5_principal p, const char *realm, const char *service) -{ - /* Must have two components */ - if (p->length != 2) - return 0; - - if ((strlen(realm) == p->realm.length) - && (strncmp(realm, p->realm.data, p->realm.length) == 0) - && (strlen(service) == p->data[0].length) - && (strncmp(service, p->data[0].data, p->data[0].length) == 0)) - return 1; - - return 0; -} -#else -static int -realm_and_service_match(krb5_context context, krb5_principal p, - const char *realm, const char *service) -{ - const char *name, *inst; - - if (p->name.name_string.len != 2) - return 0; - - name = krb5_principal_get_comp_string(context, p, 0); - inst = krb5_principal_get_comp_string(context, p, 1); - if (name == NULL || inst == NULL) - return 0; - if ((strcmp(realm, p->realm) == 0) - && (strcmp(service, name) == 0)) - return 1; - - return 0; -} -#endif - -/* - * Search the given keytab file looking for an entry with the given - * service name and realm, ignoring hostname (instance). - * - * Returns: - * 0 => No error - * non-zero => An error occurred - * - * If a keytab entry is found, "found" is set to one, and the keytab - * entry is returned in "kte". Otherwise, "found" is zero, and the - * value of "kte" is unpredictable. - */ -static int -gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt, - const char *realm, const char *service, - int *found, krb5_keytab_entry *kte) -{ - krb5_kt_cursor cursor; - krb5_error_code code; - struct gssd_k5_kt_princ *ple; - int retval = -1, status; - char kt_name[BUFSIZ]; - char *pname; - char *k5err = NULL; - - if (found == NULL) { - retval = EINVAL; - goto out; - } - *found = 0; - - /* - * Look through each entry in the keytab file and determine - * if we might want to use it as machine credentials. If so, - * save info in the global principal list (gssd_k5_kt_princ_list). - */ - if ((code = krb5_kt_get_name(context, kt, kt_name, BUFSIZ))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s attempting to get keytab name\n", k5err); - retval = code; - goto out; - } - if ((code = krb5_kt_start_seq_get(context, kt, &cursor))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s while beginning keytab scan " - "for keytab '%s'\n", k5err, kt_name); - retval = code; - goto out; - } - - printerr(4, "Scanning keytab for %s/*@%s\n", service, realm); - while ((code = krb5_kt_next_entry(context, kt, kte, &cursor)) == 0) { - if ((code = krb5_unparse_name(context, kte->principal, - &pname))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "WARNING: Skipping keytab entry because " - "we failed to unparse principal name: %s\n", - k5err); - k5_free_kt_entry(context, kte); - free(k5err); - k5err = NULL; - continue; - } - printerr(4, "Processing keytab entry for principal '%s'\n", - pname); - /* Use the first matching keytab entry found */ -#ifdef HAVE_KRB5 - status = realm_and_service_match(kte->principal, realm, service); -#else - status = realm_and_service_match(context, kte->principal, realm, service); -#endif - if (status) { - printerr(4, "We WILL use this entry (%s)\n", pname); - ple = get_ple_by_princ(context, kte->principal); - /* - * Return, don't free, keytab entry if - * we were successful! - */ - if (ple == NULL) { - retval = ENOMEM; - k5_free_kt_entry(context, kte); - } else { - release_ple(context, ple); - ple = NULL; - retval = 0; - *found = 1; - } - k5_free_unparsed_name(context, pname); - break; - } - else { - printerr(4, "We will NOT use this entry (%s)\n", - pname); - } - k5_free_unparsed_name(context, pname); - k5_free_kt_entry(context, kte); - } - - if ((code = krb5_kt_end_seq_get(context, kt, &cursor))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "WARNING: %s while ending keytab scan for " - "keytab '%s'\n", k5err, kt_name); - } - - /* Only clear the retval if has not been set */ - if (retval < 0) - retval = 0; - out: - free(k5err); - return retval; -} - -/* - * Find a keytab entry to use for a given target realm. - * Tries to find the most appropriate keytab to use given the - * name of the host we are trying to connect with. - * - * Note: the tgtname contains a hostname in the realm that we - * are authenticating to. It may, or may not be the same as - * the server hostname. - */ -static int -find_keytab_entry(krb5_context context, krb5_keytab kt, - const char *srchost, const char *tgtname, - krb5_keytab_entry *kte, const char **svcnames) -{ - krb5_error_code code; - char **realmnames = NULL; - char myhostname[NI_MAXHOST], targethostname[NI_MAXHOST]; - char myhostad[NI_MAXHOST+1]; - int i, j, k, retval; - char *default_realm = NULL; - char *realm; - char *k5err = NULL; - int tried_all = 0, tried_default = 0, tried_upper = 0; - krb5_principal princ; - const char *notsetstr = "not set"; - char *adhostoverride = NULL; - - - /* Get full target hostname */ - retval = get_full_hostname(tgtname, targethostname, - sizeof(targethostname)); - if (retval) - goto out; - - /* Get full local hostname */ - if (srchost) { - strcpy(myhostname, srchost); - strcpy(myhostad, myhostname); - } else { - /* Borrow myhostad for gethostname(), we need it later anyways */ - if (gethostname(myhostad, sizeof(myhostad)-1) == -1) { - retval = errno; - k5err = gssd_k5_err_msg(context, retval); - printerr(1, "%s while getting local hostname\n", k5err); - goto out; - } - retval = get_full_hostname(myhostad, myhostname, sizeof(myhostname)); - if (retval) { - /* Don't use myhostname */ - myhostname[0] = 0; - } - } - - /* Compute the active directory machine name HOST$ */ - krb5_appdefault_string(context, "nfs", NULL, "ad_principal_name", - notsetstr, &adhostoverride); - if (adhostoverride && strcmp(adhostoverride, notsetstr) != 0) { - printerr(1, - "AD host string overridden with \"%s\" from appdefaults\n", - adhostoverride); - /* No overflow: Windows cannot handle strings longer than 19 chars */ - strcpy(myhostad, adhostoverride); - } else { - /* In this case, it's been pre-filled above */ - for (i = 0; myhostad[i] != 0; ++i) { - if (myhostad[i] == '.') break; - } - myhostad[i] = '$'; - myhostad[i+1] = 0; - } - if (adhostoverride) - krb5_free_string(context, adhostoverride); - - code = krb5_get_default_realm(context, &default_realm); - if (code) { - retval = code; - k5err = gssd_k5_err_msg(context, code); - printerr(1, "%s while getting default realm name\n", k5err); - goto out; - } - - /* - * Get the realm name(s) for the target hostname. - * In reality, this function currently only returns a - * single realm, but we code with the assumption that - * someday it may actually return a list. - */ - code = krb5_get_host_realm(context, targethostname, &realmnames); - if (code) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s while getting realm(s) for host '%s'\n", - k5err, targethostname); - retval = code; - goto out; - } - - /* - * Make sure the preferred_realm, which may have been explicitly set - * on the command line, is tried first. If nothing is found go on with - * the host and local default realm (if that hasn't already been tried). - */ - i = 0; - realm = realmnames[i]; - - if (preferred_realm && strcmp (realm, preferred_realm) != 0) { - realm = preferred_realm; - /* resetting the realmnames index */ - i = -1; - } - - while (1) { - if (realm == NULL) { - tried_all = 1; - if (!tried_default) - realm = default_realm; - } - if (tried_all && tried_default) - break; - if (strcmp(realm, default_realm) == 0) - tried_default = 1; - for (j = 0; svcnames[j] != NULL; j++) { - char spn[NI_MAXHOST+2]; - - /* - * The special svcname "$" means 'try the active - * directory machine account' - */ - if (strcmp(svcnames[j],"$") == 0) { - snprintf(spn, sizeof(spn), "%s@%s", myhostad, realm); - code = krb5_build_principal_ext(context, &princ, - strlen(realm), - realm, - strlen(myhostad), - myhostad, - NULL); - } else { - if (!myhostname[0]) - continue; - snprintf(spn, sizeof(spn), "%s/%s@%s", - svcnames[j], myhostname, realm); - code = krb5_build_principal_ext(context, &princ, - strlen(realm), - realm, - strlen(svcnames[j]), - svcnames[j], - strlen(myhostname), - myhostname, - NULL); - } - - if (code) { - k5err = gssd_k5_err_msg(context, code); - printerr(1, "%s while building principal for '%s'\n", - k5err, spn); - free(k5err); - k5err = NULL; - continue; - } - code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte); - krb5_free_principal(context, princ); - if (code) { - k5err = gssd_k5_err_msg(context, code); - printerr(3, "%s while getting keytab entry for '%s'\n", - k5err, spn); - free(k5err); - k5err = NULL; - /* - * We tried the active directory machine account - * with the hostname part as-is and failed... - * convert it to uppercase and try again before - * moving on to the svcname - */ - if (strcmp(svcnames[j],"$") == 0 && !tried_upper) { - for (k = 0; myhostad[k] != '$'; ++k) { - myhostad[k] = toupper(myhostad[k]); - } - j--; - tried_upper = 1; - } - } else { - printerr(2, "Success getting keytab entry for '%s'\n",spn); - retval = 0; - goto out; - } - retval = code; - } - /* - * Nothing found with our hostname instance, now look for - * names with any instance (they must have an instance) - */ - for (j = 0; svcnames[j] != NULL; j++) { - int found = 0; - if (strcmp(svcnames[j],"$") == 0) - continue; - code = gssd_search_krb5_keytab(context, kt, realm, - svcnames[j], &found, kte); - if (!code && found) { - printerr(3, "Success getting keytab entry for " - "%s/*@%s\n", svcnames[j], realm); - retval = 0; - goto out; - } - } - if (!tried_all) { - i++; - realm = realmnames[i]; - } - } -out: - if (default_realm) - k5_free_default_realm(context, default_realm); - if (realmnames) - krb5_free_host_realm(context, realmnames); - free(k5err); - return retval; -} - - -static inline int data_is_equal(krb5_data d1, krb5_data d2) -{ - return (d1.length == d2.length - && memcmp(d1.data, d2.data, d1.length) == 0); -} - -static int -check_for_tgt(krb5_context context, krb5_ccache ccache, - krb5_principal principal) -{ - krb5_error_code ret; - krb5_creds creds; - krb5_cc_cursor cur; - int found = 0; - - ret = krb5_cc_start_seq_get(context, ccache, &cur); - if (ret) - return 0; - - while (!found && - (ret = krb5_cc_next_cred(context, ccache, &cur, &creds)) == 0) { - if (creds.server->length == 2 && - data_is_equal(creds.server->realm, - principal->realm) && - creds.server->data[0].length == 6 && - memcmp(creds.server->data[0].data, - "krbtgt", 6) == 0 && - data_is_equal(creds.server->data[1], - principal->realm) && - creds.times.endtime > time(NULL)) - found = 1; - krb5_free_cred_contents(context, &creds); - } - krb5_cc_end_seq_get(context, ccache, &cur); - - return found; -} - -static int -query_krb5_ccache(const char* cred_cache, char **ret_princname, - char **ret_realm) -{ - krb5_error_code ret; - krb5_context context; - krb5_ccache ccache; - krb5_principal principal; - int found = 0; - char *str = NULL; - char *princstring; - - *ret_princname = *ret_realm = NULL; - - ret = krb5_init_context(&context); - if (ret) - return 0; - - if(!cred_cache || krb5_cc_resolve(context, cred_cache, &ccache)) - goto err_cache; - - if (krb5_cc_set_flags(context, ccache, 0)) - goto err_princ; - - ret = krb5_cc_get_principal(context, ccache, &principal); - if (ret) - goto err_princ; - - found = check_for_tgt(context, ccache, principal); - if (found) { - ret = krb5_unparse_name(context, principal, &princstring); - if (ret == 0) { - if ((str = strchr(princstring, '@')) != NULL) { - *str = '\0'; - *ret_princname = strdup(princstring); - *ret_realm = strdup(str+1); - } - k5_free_unparsed_name(context, princstring); - } - } - krb5_free_principal(context, principal); -err_princ: - krb5_cc_set_flags(context, ccache, KRB5_TC_OPENCLOSE); - krb5_cc_close(context, ccache); -err_cache: - krb5_free_context(context); - return (*ret_princname && *ret_realm); -} - -/* - * Obtain (or refresh if necessary) Kerberos machine credentials - * If a ple is passed in, it's reference will be released - */ -static int -gssd_refresh_krb5_machine_credential_internal(char *hostname, - struct gssd_k5_kt_princ *ple, - char *service, char *srchost) -{ - krb5_error_code code = 0; - krb5_context context; - krb5_keytab kt = NULL;; - int retval = 0; - char *k5err = NULL; - const char *svcnames[] = { "$", "root", "nfs", "host", NULL }; - - printerr(2, "%s: hostname=%s ple=%p service=%s srchost=%s\n", - __func__, hostname, ple, service, srchost); - - /* - * If a specific service name was specified, use it. - * Otherwise, use the default list. - */ - if (service != NULL && strcmp(service, "*") != 0) { - svcnames[0] = service; - svcnames[1] = NULL; - } - if (hostname == NULL && ple == NULL) - return EINVAL; - - code = krb5_init_context(&context); - if (code) { - k5err = gssd_k5_err_msg(NULL, code); - printerr(0, "ERROR: %s: %s while initializing krb5 context\n", - __func__, k5err); - retval = code; - goto out; - } - - if ((code = krb5_kt_resolve(context, keytabfile, &kt))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "ERROR: %s: %s while resolving keytab '%s'\n", - __func__, k5err, keytabfile); - goto out_free_context; - } - - if (ple == NULL) { - krb5_keytab_entry kte; - - code = find_keytab_entry(context, kt, srchost, hostname, - &kte, svcnames); - if (code) { - printerr(0, "ERROR: %s: no usable keytab entry found " - "in keytab %s for connection with host %s\n", - __FUNCTION__, keytabfile, hostname); - retval = code; - goto out_free_kt; - } - - ple = get_ple_by_princ(context, kte.principal); - k5_free_kt_entry(context, &kte); - if (ple == NULL) { - char *pname; - if ((krb5_unparse_name(context, kte.principal, &pname))) { - pname = NULL; - } - printerr(0, "ERROR: %s: Could not locate or create " - "ple struct for principal %s for connection " - "with host %s\n", - __FUNCTION__, pname ? pname : "", - hostname); - if (pname) k5_free_unparsed_name(context, pname); - goto out_free_kt; - } - } - retval = gssd_get_single_krb5_cred(context, kt, ple); -out_free_kt: - krb5_kt_close(context, kt); -out_free_context: - if (ple) - release_ple(context, ple); - krb5_free_context(context); -out: - free(k5err); - return retval; -} - -/*==========================*/ -/*=== External routines ===*/ -/*==========================*/ - -/* - * Attempt to find the best match for a credentials cache file - * given only a UID. We really need more information, but we - * do the best we can. - * - * Returns 0 if a ccache was found, or a negative errno otherwise. - */ -int -gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern) -{ - /* dirname + cctype + d_name + NULL */ - char buf[PATH_MAX+5+256+1], dirname[PATH_MAX]; - const char *cctype; - struct dirent *d; - int err, i, j; - u_int maj_stat, min_stat; - - printerr(3, "looking for client creds with uid %u for " - "server %s in %s\n", uid, servername, dirpattern); - - for (i = 0, j = 0; dirpattern[i] != '\0'; i++) { - switch (dirpattern[i]) { - case '%': - switch (dirpattern[i + 1]) { - case '%': - dirname[j++] = dirpattern[i]; - i++; - break; - case 'U': - j += sprintf(dirname + j, "%lu", - (unsigned long) uid); - i++; - break; - } - break; - default: - dirname[j++] = dirpattern[i]; - break; - } - } - dirname[j] = '\0'; - - err = gssd_find_existing_krb5_ccache(uid, dirname, &cctype, &d); - if (err) - return err; - - snprintf(buf, sizeof(buf), "%s:%s/%s", cctype, dirname, d->d_name); - free(d); - - printerr(2, "using %s as credentials cache for client with " - "uid %u for server %s\n", buf, uid, servername); - - printerr(3, "using gss_krb5_ccache_name to select krb5 ccache %s\n", - buf); - maj_stat = gss_krb5_ccache_name(&min_stat, buf, NULL); - if (maj_stat != GSS_S_COMPLETE) { - printerr(0, "ERROR: unable to get user cred cache '%s' " - "failed (%s)\n", buf, error_message(min_stat)); - return maj_stat; - } - return 0; -} - -/* - * Return an array of pointers to names of credential cache files - * which can be used to try to create gss contexts with a server. - * - * Returns: - * 0 => list is attached - * nonzero => error - */ -int -gssd_get_krb5_machine_cred_list(char ***list) -{ - char **l; - int listinc = 10; - int listsize = listinc; - int i = 0; - int retval; - struct gssd_k5_kt_princ *ple; - - /* Assume failure */ - retval = -1; - *list = (char **) NULL; - - if ((l = (char **) malloc(listsize * sizeof(char *))) == NULL) { - retval = ENOMEM; - goto out; - } - - pthread_mutex_lock(&ple_lock); - for (ple = gssd_k5_kt_princ_list; ple; ple = ple->next) { - if (!ple->ccname) - continue; - - /* Take advantage of the fact we only remove the ple - * from the list during shutdown. If it's modified - * concurrently at worst we'll just miss a new entry - * before the current ple - * - * gssd_refresh_krb5_machine_credential_internal() will - * release the ple refcount - */ - ple->refcount++; - pthread_mutex_unlock(&ple_lock); - /* Make sure cred is up-to-date before returning it */ - retval = gssd_refresh_krb5_machine_credential_internal(NULL, ple, - NULL, NULL); - pthread_mutex_lock(&ple_lock); - if (gssd_k5_kt_princ_list == NULL) { - /* Looks like we did shutdown... abort */ - l[i] = NULL; - gssd_free_krb5_machine_cred_list(l); - retval = ENOMEM; - goto out_lock; - } - if (retval) - continue; - if (i + 1 > listsize) { - listsize += listinc; - l = (char **) - realloc(l, listsize * sizeof(char *)); - if (l == NULL) { - retval = ENOMEM; - goto out_lock; - } - } - if ((l[i++] = strdup(ple->ccname)) == NULL) { - retval = ENOMEM; - goto out_lock; - } - } - if (i > 0) { - l[i] = NULL; - *list = l; - retval = 0; - } else - free((void *)l); -out_lock: - pthread_mutex_unlock(&ple_lock); - out: - return retval; -} - -/* - * Frees the list of names returned in get_krb5_machine_cred_list() - */ -void -gssd_free_krb5_machine_cred_list(char **list) -{ - char **n; - - if (list == NULL) - return; - for (n = list; n && *n; n++) { - free(*n); - } - free(list); -} - -/* - * Called upon exit. Destroys machine credentials. - */ -void -gssd_destroy_krb5_principals(int destroy_machine_creds) -{ - krb5_context context; - krb5_error_code code = 0; - krb5_ccache ccache; - struct gssd_k5_kt_princ *ple; - char *k5err = NULL; - - code = krb5_init_context(&context); - if (code) { - k5err = gssd_k5_err_msg(NULL, code); - printerr(0, "ERROR: %s while initializing krb5\n", k5err); - free(k5err); - return; - } - - pthread_mutex_lock(&ple_lock); - while (gssd_k5_kt_princ_list) { - ple = gssd_k5_kt_princ_list; - gssd_k5_kt_princ_list = ple->next; - - if (destroy_machine_creds && ple->ccname) { - if ((code = krb5_cc_resolve(context, ple->ccname, &ccache))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "WARNING: %s while resolving credential " - "cache '%s' for destruction\n", k5err, - ple->ccname); - free(k5err); - k5err = NULL; - } - - if (!code && (code = krb5_cc_destroy(context, ccache))) { - k5err = gssd_k5_err_msg(context, code); - printerr(0, "WARNING: %s while destroying credential " - "cache '%s'\n", k5err, ple->ccname); - free(k5err); - k5err = NULL; - } - } - - release_ple(context, ple); - } - pthread_mutex_unlock(&ple_lock); - krb5_free_context(context); -} - -/* - * Obtain (or refresh if necessary) Kerberos machine credentials - */ -int -gssd_refresh_krb5_machine_credential(char *hostname, - char *service, char *srchost) -{ - return gssd_refresh_krb5_machine_credential_internal(hostname, NULL, - service, srchost); -} - -/* - * A common routine for getting the Kerberos error message - */ -char * -gssd_k5_err_msg(krb5_context context, krb5_error_code code) -{ - const char *origmsg; - char *msg = NULL; - -#if HAVE_KRB5_GET_ERROR_MESSAGE - if (context != NULL) { - origmsg = krb5_get_error_message(context, code); - msg = strdup(origmsg); - krb5_free_error_message(context, origmsg); - } -#endif - if (msg != NULL) - return msg; -#if HAVE_KRB5 - return strdup(error_message(code)); -#else - if (context != NULL) - return strdup(krb5_get_err_text(context, code)); - else - return strdup(error_message(code)); -#endif -} - -/* - * Return default Kerberos realm - */ -void -gssd_k5_get_default_realm(char **def_realm) -{ - krb5_context context; - - if (krb5_init_context(&context)) - return; - - krb5_get_default_realm(context, def_realm); - - krb5_free_context(context); -} - -static int -gssd_acquire_krb5_cred(gss_cred_id_t *gss_cred) -{ - OM_uint32 maj_stat, min_stat; - gss_OID_set_desc desired_mechs = { 1, &krb5oid }; - - maj_stat = gss_acquire_cred(&min_stat, GSS_C_NO_NAME, GSS_C_INDEFINITE, - &desired_mechs, GSS_C_INITIATE, - gss_cred, NULL, NULL); - - if (maj_stat != GSS_S_COMPLETE) { - if (get_verbosity() > 0) - pgsserr("gss_acquire_cred", - maj_stat, min_stat, &krb5oid); - return -1; - } - - return 0; -} - -int -gssd_acquire_user_cred(gss_cred_id_t *gss_cred) -{ - OM_uint32 maj_stat, min_stat; - int ret; - - ret = gssd_acquire_krb5_cred(gss_cred); - if (ret) - return ret; - - /* force validation of cred to check for expiry */ - maj_stat = gss_inquire_cred(&min_stat, *gss_cred, - NULL, NULL, NULL, NULL); - if (maj_stat != GSS_S_COMPLETE) { - if (get_verbosity() > 0) - pgsserr("gss_inquire_cred", - maj_stat, min_stat, &krb5oid); - ret = -1; - } - - return ret; -} - -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES -/* - * this routine obtains a credentials handle via gss_acquire_cred() - * then calls gss_krb5_set_allowable_enctypes() to limit the encryption - * types negotiated. - * - * XXX Should call some function to determine the enctypes supported - * by the kernel. (Only need to do that once!) - * - * Returns: - * 0 => all went well - * -1 => there was an error - */ - -int -limit_krb5_enctypes(struct rpc_gss_sec *sec) -{ - u_int maj_stat, min_stat; - krb5_enctype enctypes[] = { ENCTYPE_DES_CBC_CRC, - ENCTYPE_DES_CBC_MD5, - ENCTYPE_DES_CBC_MD4 }; - int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]); - extern int num_krb5_enctypes; - extern krb5_enctype *krb5_enctypes; - int err = -1; - - if (sec->cred == GSS_C_NO_CREDENTIAL) { - err = gssd_acquire_krb5_cred(&sec->cred); - if (err) - return -1; - } - - /* - * If we failed for any reason to produce global - * list of supported enctypes, use local default here. - */ - if (krb5_enctypes == NULL || limit_to_legacy_enctypes) - maj_stat = gss_set_allowable_enctypes(&min_stat, sec->cred, - &krb5oid, num_enctypes, enctypes); - else - maj_stat = gss_set_allowable_enctypes(&min_stat, sec->cred, - &krb5oid, num_krb5_enctypes, krb5_enctypes); - - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("gss_set_allowable_enctypes", - maj_stat, min_stat, &krb5oid); - return -1; - } - - return 0; -} -#endif /* HAVE_SET_ALLOWABLE_ENCTYPES */ diff --git a/nfs-utils-2.5.2/utils/gssd/krb5_util.h b/nfs-utils-2.5.2/utils/gssd/krb5_util.h deleted file mode 100644 index 2415205..0000000 --- a/nfs-utils-2.5.2/utils/gssd/krb5_util.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef KRB5_UTIL_H -#define KRB5_UTIL_H - -#include - -#ifdef HAVE_LIBTIRPC -#include -#else -#include "gss_oids.h" -#endif - - -int gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, - char *dirname); -int gssd_get_krb5_machine_cred_list(char ***list); -void gssd_free_krb5_machine_cred_list(char **list); -void gssd_destroy_krb5_principals(int destroy_machine_creds); -int gssd_refresh_krb5_machine_credential(char *hostname, - char *service, char *srchost); -char *gssd_k5_err_msg(krb5_context context, krb5_error_code code); -void gssd_k5_get_default_realm(char **def_realm); - -int gssd_acquire_user_cred(gss_cred_id_t *gss_cred); - -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES -extern int limit_to_legacy_enctypes; -int limit_krb5_enctypes(struct rpc_gss_sec *sec); -#endif - -/* - * Hide away some of the MIT vs. Heimdal differences - * here with macros... - */ - -#ifdef HAVE_KRB5 -#define k5_free_unparsed_name(ctx, name) krb5_free_unparsed_name((ctx), (name)) -#define k5_free_default_realm(ctx, realm) krb5_free_default_realm((ctx), (realm)) -#define k5_free_kt_entry(ctx, kte) krb5_free_keytab_entry_contents((ctx),(kte)) -#else /* Heimdal */ -#define k5_free_unparsed_name(ctx, name) free(name) -#define k5_free_default_realm(ctx, realm) free(realm) -#define k5_free_kt_entry(ctx, kte) krb5_kt_free_entry((ctx),(kte)) -#endif - -#endif /* KRB5_UTIL_H */ diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd.c b/nfs-utils-2.5.2/utils/gssd/svcgssd.c deleted file mode 100644 index 3ab2100..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - gssd.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2000 Dug Song . - Copyright (c) 2002 Andy Adamson . - Copyright (c) 2002 Marius Aamodt Eriksen . - Copyright (c) 2002 J. Bruce Fields . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "svcgssd.h" -#include "gss_util.h" -#include "err_util.h" -#include "conffile.h" -#include "misc.h" -#include "svcgssd_krb5.h" - -struct state_paths etab; /* from cacheio.c */ -static bool signal_received = false; -static struct event_base *evbase = NULL; -static int nullrpc_fd = -1; -static struct event *nullrpc_event = NULL; -static struct event *wait_event = NULL; - -#define NULLRPC_FILE "/proc/net/rpc/auth.rpcsec.init/channel" - -static void -sig_die(int signal) -{ - if (signal_received) { - /* destroy krb5 machine creds */ - printerr(1, "forced exiting on signal %d\n", signal); - exit(0); - } - signal_received = true; - printerr(1, "exiting on signal %d\n", signal); - event_base_loopexit(evbase, NULL); -} - -static void -sig_hup(int signal) -{ - /* don't exit on SIGHUP */ - printerr(1, "Received SIGHUP(%d)... Ignoring.\n", signal); - return; -} - -static void -usage(char *progname) -{ - fprintf(stderr, "usage: %s [-n] [-f] [-v] [-r] [-i] [-p principal]\n", - progname); - exit(1); -} - -static void -svcgssd_nullrpc_cb(int fd, short UNUSED(which), void *UNUSED(data)) -{ - char lbuf[RPC_CHAN_BUF_SIZE]; - int lbuflen = 0; - - printerr(1, "reading null request\n"); - - lbuflen = read(fd, lbuf, sizeof(lbuf)); - if (lbuflen <= 0 || lbuf[lbuflen-1] != '\n') { - printerr(0, "WARNING: handle_nullreq: failed reading request\n"); - return; - } - lbuf[lbuflen-1] = 0; - - handle_nullreq(lbuf); -} - -static void -svcgssd_nullrpc_close(void) -{ - if (nullrpc_event) { - printerr(2, "closing nullrpc channel %s\n", NULLRPC_FILE); - event_free(nullrpc_event); - nullrpc_event = NULL; - } - if (nullrpc_fd != -1) { - close(nullrpc_fd); - nullrpc_fd = -1; - } -} - -static void -svcgssd_nullrpc_open(void) -{ - nullrpc_fd = open(NULLRPC_FILE, O_RDWR); - if (nullrpc_fd < 0) { - printerr(0, "failed to open %s: %s\n", - NULLRPC_FILE, strerror(errno)); - return; - } - nullrpc_event = event_new(evbase, nullrpc_fd, EV_READ | EV_PERSIST, - svcgssd_nullrpc_cb, NULL); - if (!nullrpc_event) { - printerr(0, "failed to create event for %s: %s\n", - NULLRPC_FILE, strerror(errno)); - close(nullrpc_fd); - nullrpc_fd = -1; - return; - } - event_add(nullrpc_event, NULL); - printerr(2, "opened nullrpc channel %s\n", NULLRPC_FILE); -} - -static void -svcgssd_wait_cb(int UNUSED(fd), short UNUSED(which), void *UNUSED(data)) -{ - static int times = 0; - int rc; - - rc = access(NULLRPC_FILE, R_OK | W_OK); - if (rc != 0) { - struct timeval t = {times < 10 ? 1 : 10, 0}; - times++; - if (times % 30 == 0) - printerr(2, "still waiting for nullrpc channel: %s\n", - NULLRPC_FILE); - evtimer_add(wait_event, &t); - return; - } - - svcgssd_nullrpc_open(); - event_free(wait_event); - wait_event = NULL; -} - - - -int -main(int argc, char *argv[]) -{ - int get_creds = 1; - int fg = 0; - int verbosity = 0; - int rpc_verbosity = 0; - int idmap_verbosity = 0; - int opt, status; - extern char *optarg; - char *progname; - char *principal = NULL; - char *s; - int rc; - - conf_init_file(NFS_CONFFILE); - - s = conf_get_str("svcgssd", "principal"); - if (!s) - ; - else if (strcmp(s, "system")== 0) - get_creds = 0; - else - principal = s; - - verbosity = conf_get_num("svcgssd", "Verbosity", verbosity); - rpc_verbosity = conf_get_num("svcgssd", "RPC-Verbosity", rpc_verbosity); - idmap_verbosity = conf_get_num("svcgssd", "IDMAP-Verbosity", idmap_verbosity); - - /* We don't need the config anymore */ - conf_cleanup(); - - while ((opt = getopt(argc, argv, "fivrnp:")) != -1) { - switch (opt) { - case 'f': - fg = 1; - break; - case 'i': - idmap_verbosity++; - break; - case 'n': - get_creds = 0; - break; - case 'v': - verbosity++; - break; - case 'r': - rpc_verbosity++; - break; - case 'p': - principal = optarg; - break; - default: - usage(argv[0]); - break; - } - } - - if ((progname = strrchr(argv[0], '/'))) - progname++; - else - progname = argv[0]; - - initerr(progname, verbosity, fg); -#ifdef HAVE_AUTHGSS_SET_DEBUG_LEVEL - if (verbosity && rpc_verbosity == 0) - rpc_verbosity = verbosity; - authgss_set_debug_level(rpc_verbosity); -#elif HAVE_LIBTIRPC_SET_DEBUG - /* - * Only set the libtirpc debug level if explicitly requested via -r... - * svcgssd is chatty enough as it is. - */ - if (rpc_verbosity > 0) - libtirpc_set_debug(progname, rpc_verbosity, fg); -#else - if (rpc_verbosity > 0) - printerr(0, "Warning: rpcsec_gss library does not " - "support setting debug level\n"); -#endif -#ifdef HAVE_NFS4_SET_DEBUG - if (verbosity && idmap_verbosity == 0) - idmap_verbosity = verbosity; - nfs4_set_debug(idmap_verbosity, NULL); -#else - if (idmap_verbosity > 0) - printerr(0, "Warning: your nfsidmap library does not " - "support setting debug level\n"); -#endif - - if (gssd_check_mechs() != 0) { - printerr(0, "ERROR: Problem with gssapi library\n"); - exit(1); - } - - daemon_init(fg); - - evbase = event_base_new(); - if (!evbase) { - printerr(0, "ERROR: failed to create event base: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - signal(SIGINT, sig_die); - signal(SIGTERM, sig_die); - signal(SIGHUP, sig_hup); - - if (get_creds) { - if (principal) - status = gssd_acquire_cred(principal, - ((const gss_OID)GSS_C_NT_USER_NAME)); - else - status = gssd_acquire_cred(GSSD_SERVICE_NAME, - (const gss_OID)GSS_C_NT_HOSTBASED_SERVICE); - if (status == FALSE) { - printerr(0, "unable to obtain root (machine) credentials\n"); - printerr(0, "do you have a keytab entry for " - "nfs/@ in " - "/etc/krb5.keytab?\n"); - exit(1); - } - } else { - status = gssd_acquire_cred(NULL, - (const gss_OID)GSS_C_NT_HOSTBASED_SERVICE); - if (status == FALSE) { - printerr(0, "unable to obtain nameless credentials\n"); - exit(1); - } - } - - svcgssd_nullrpc_open(); - if (!nullrpc_event) { - struct timeval t = {1, 0}; - - printerr(2, "waiting for nullrpc channel to appear\n"); - wait_event = evtimer_new(evbase, svcgssd_wait_cb, NULL); - if (!wait_event) { - printerr(0, "ERROR: failed to create wait event: %s\n", - strerror(errno)); - exit(EXIT_FAILURE); - } - evtimer_add(wait_event, &t); - } - - daemon_ready(); - - nfs4_init_name_mapping(NULL); /* XXX: should only do this once */ - - rc = event_base_dispatch(evbase); - if (rc < 0) - printerr(0, "event_base_dispatch() returned %i!\n", rc); - - svcgssd_nullrpc_close(); - if (wait_event) - event_free(wait_event); - - event_base_free(evbase); - - nfs4_term_name_mapping(); - svcgssd_free_enctypes(); - gssd_cleanup(); - - return EXIT_SUCCESS; -} diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd.h b/nfs-utils-2.5.2/utils/gssd/svcgssd.h deleted file mode 100644 index e229b98..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _RPC_SVCGSSD_H_ -#define _RPC_SVCGSSD_H_ - -#include -#include -#include - -void handle_nullreq(char *cp); - -#define GSSD_SERVICE_NAME "nfs" - -#endif /* _RPC_SVCGSSD_H_ */ diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd.man b/nfs-utils-2.5.2/utils/gssd/svcgssd.man deleted file mode 100644 index 15ef4c9..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd.man +++ /dev/null @@ -1,75 +0,0 @@ -.\" -.\" rpc.svcgssd(8) -.\" -.\" Copyright (C) 2003 J. Bruce Fields -.TH rpc.svcgssd 8 "12 Jan 2007" -.SH NAME -rpc.svcgssd \- server-side rpcsec_gss daemon -.SH SYNOPSIS -.B "rpc.svcgssd [-n] [-v] [-r] [-i] [-f] [-p principal]" -.SH DESCRIPTION -The rpcsec_gss protocol gives a means of using the gss-api generic security -api to provide security for protocols using rpc (in particular, nfs). Before -exchanging any rpc requests using rpcsec_gss, the rpc client must first -establish a security context with the rpc server. The linux kernel's -implementation of rpcsec_gss depends on the userspace daemon -.B rpc.svcgssd -to handle context establishment on the rpc server. The -daemon uses files in the proc filesystem to communicate with -the kernel. - -.SH OPTIONS -.TP -.B -f -Runs -.B rpc.svcgssd -in the foreground and sends output to stderr (as opposed to syslogd) -.TP -.B -v -Increases the verbosity of the output (can be specified multiple times). -.TP -.B -r -If the rpcsec_gss library supports setting debug level, -increases the verbosity of the output (can be specified multiple times). -.TP -.B -i -If the nfsidmap library supports setting debug level, -increases the verbosity of the output (can be specified multiple times). -.TP -.B -p -Use \fIprincipal\fR instead of the default -.RI nfs/ FQDN @ REALM . -.TP -.B -n -Use the system default credentials -.RI (host/ FQDN @ REALM ) -rather than the default -.RI nfs/ FQDN @ REALM . -.SH CONFIGURATION FILE -Some of the options that can be set on the command line can also be -controlled through values set in the -.B [svcgssd] -section of the -.I /etc/nfs.conf -configuration file. Values recognized include: -.TP -.B principal -If set to -.B system -this is equivalent to the -.B -n -option. If set to any other value, that is used like the -.B -p -option. - -.SH SEE ALSO -.BR rpc.gssd(8), -.SH AUTHORS -.br -Dug Song -.br -Andy Adamson -.br -Marius Aamodt Eriksen -.br -J. Bruce Fields diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.c b/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.c deleted file mode 100644 index 305d475..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * COPYRIGHT (c) 2011 - * The Regents of the University of Michigan - * ALL RIGHTS RESERVED - * - * Permission is granted to use, copy, create derivative works - * and redistribute this software and such derivative works - * for any purpose, so long as the name of The University of - * Michigan is not used in any advertising or publicity - * pertaining to the use of distribution of this software - * without specific, written prior authorization. If the - * above copyright notice or any other identification of the - * University of Michigan is included in any copy of any - * portion of this software, then the disclaimer below must - * also be included. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION - * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY - * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF - * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING - * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE - * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING - * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN - * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include - -#include "gss_util.h" -#include "gss_oids.h" -#include "err_util.h" -#include "svcgssd_krb5.h" -#include "../mount/version.h" - -#define MYBUFLEN 1024 - -char *supported_enctypes_filename = "/proc/fs/nfsd/supported_krb5_enctypes"; -int parsed_num_enctypes = 0; -krb5_enctype *parsed_enctypes = NULL; -char *cached_enctypes = NULL; - -/*==========================*/ -/*=== Internal routines ===*/ -/*==========================*/ - -/* - * Parse the supported encryption type information - */ -static int -parse_enctypes(char *enctypes) -{ - int n = 0; - char *curr, *comma; - int i; - - /* Don't parse the same string over and over... */ - if (cached_enctypes && strcmp(cached_enctypes, enctypes) == 0) - return 0; - - /* Free any existing cached_enctypes */ - svcgssd_free_enctypes(); - - /* count the number of commas */ - for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) { - comma = strchr(curr, ','); - if (comma != NULL) - n++; - else - break; - } - - /* If no more commas and we're not at the end, there's one more value */ - if (*curr != '\0') - n++; - - /* Empty string, return an error */ - if (n == 0) - return ENOENT; - - /* Skip pass any non digits */ - while (*enctypes && isdigit(*enctypes) == 0) - enctypes++; - if (*enctypes == '\0') - return EINVAL; - - /* Allocate space for enctypes array */ - if ((parsed_enctypes = (int *) calloc(n, sizeof(int))) == NULL) { - return ENOMEM; - } - - /* Now parse each value into the array */ - for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) { - parsed_enctypes[i++] = atoi(curr); - comma = strchr(curr, ','); - if (comma == NULL) - break; - } - - parsed_num_enctypes = n; - if ((cached_enctypes = malloc(strlen(enctypes)+1))) - strcpy(cached_enctypes, enctypes); - - return 0; -} - -static void -get_kernel_supported_enctypes(void) -{ - FILE *s_e; - int ret; - char buffer[MYBUFLEN + 1]; - - memset(buffer, '\0', sizeof(buffer)); - - s_e = fopen(supported_enctypes_filename, "r"); - if (s_e == NULL) - goto out_clean_parsed; - - ret = fread(buffer, 1, MYBUFLEN, s_e); - if (ret < 0) { - fclose(s_e); - goto out_clean_parsed; - } - fclose(s_e); - if (parse_enctypes(buffer)) { - goto out_clean_parsed; - } -out: - return; - -out_clean_parsed: - if (parsed_enctypes != NULL) { - free(parsed_enctypes); - parsed_num_enctypes = 0; - } - goto out; -} - -/*==========================*/ -/*=== External routines ===*/ -/*==========================*/ - -void -svcgssd_free_enctypes(void) -{ - free(cached_enctypes); - cached_enctypes = NULL; - - if (parsed_enctypes != NULL) { - free(parsed_enctypes); - parsed_enctypes = NULL; - parsed_num_enctypes = 0; - } -} - -/* - * Get encryption types supported by the kernel, and then - * call gss_krb5_set_allowable_enctypes() to limit the - * encryption types negotiated. - * - * Returns: - * 0 => all went well - * -1 => there was an error - */ - -int -svcgssd_limit_krb5_enctypes(void) -{ -#ifdef HAVE_SET_ALLOWABLE_ENCTYPES - u_int maj_stat, min_stat; - krb5_enctype old_kernel_enctypes[] = { - ENCTYPE_DES_CBC_CRC, - ENCTYPE_DES_CBC_MD5, - ENCTYPE_DES_CBC_MD4 }; - krb5_enctype new_kernel_enctypes[] = { - ENCTYPE_AES256_CTS_HMAC_SHA1_96, - ENCTYPE_AES128_CTS_HMAC_SHA1_96, - ENCTYPE_DES3_CBC_SHA1, - ENCTYPE_ARCFOUR_HMAC, - ENCTYPE_DES_CBC_CRC, - ENCTYPE_DES_CBC_MD5, - ENCTYPE_DES_CBC_MD4 }; - krb5_enctype *default_enctypes, *enctypes; - int default_num_enctypes, num_enctypes; - - - if (linux_version_code() < MAKE_VERSION(2, 6, 35)) { - default_enctypes = old_kernel_enctypes; - default_num_enctypes = - sizeof(old_kernel_enctypes) / sizeof(old_kernel_enctypes[0]); - } else { - default_enctypes = new_kernel_enctypes; - default_num_enctypes = - sizeof(new_kernel_enctypes) / sizeof(new_kernel_enctypes[0]); - } - - get_kernel_supported_enctypes(); - - if (parsed_enctypes != NULL) { - enctypes = parsed_enctypes; - num_enctypes = parsed_num_enctypes; - printerr(2, "%s: Calling gss_set_allowable_enctypes with %d " - "enctypes from the kernel\n", __func__, num_enctypes); - } else { - enctypes = default_enctypes; - num_enctypes = default_num_enctypes; - printerr(2, "%s: Calling gss_set_allowable_enctypes with %d " - "enctypes from defaults\n", __func__, num_enctypes); - } - - maj_stat = gss_set_allowable_enctypes(&min_stat, gssd_creds, - &krb5oid, num_enctypes, enctypes); - if (maj_stat != GSS_S_COMPLETE) { - printerr(1, "WARNING: gss_set_allowable_enctypes failed\n"); - pgsserr("svcgssd_limit_krb5_enctypes: gss_set_allowable_enctypes", - maj_stat, min_stat, &krb5oid); - return -1; - } -#endif - return 0; -} diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.h b/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.h deleted file mode 100644 index 78a90e9..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd_krb5.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * COPYRIGHT (c) 2011 - * The Regents of the University of Michigan - * ALL RIGHTS RESERVED - * - * Permission is granted to use, copy, create derivative works - * and redistribute this software and such derivative works - * for any purpose, so long as the name of The University of - * Michigan is not used in any advertising or publicity - * pertaining to the use of distribution of this software - * without specific, written prior authorization. If the - * above copyright notice or any other identification of the - * University of Michigan is included in any copy of any - * portion of this software, then the disclaimer below must - * also be included. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION - * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY - * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF - * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING - * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE - * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING - * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN - * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES. - */ - -#ifndef SVCGSSD_KRB5_H -#define SVCGSSD_KRB5_H - -int svcgssd_limit_krb5_enctypes(void); -void svcgssd_free_enctypes(void); - -#endif /* SVCGSSD_KRB5_H */ diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd_mech2file.c b/nfs-utils-2.5.2/utils/gssd/svcgssd_mech2file.c deleted file mode 100644 index c26b435..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd_mech2file.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - linux_downcall.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2004 Andy Adamson . - All rights reserved, all wrongs reversed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include - -char * mech2file(gss_OID mech); - -#define g_OID_equal(o1,o2) \ - (((o1)->length == (o2)->length) && \ - (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)) - -struct mech2file { - gss_OID_desc mech; - char filename[8]; -}; - -struct mech2file m2f[] = { - {{9, "\052\206\110\206\367\022\001\002\002"}, "krb5"}, - {{0,0},""}, -}; - -/* - * Find the Linux svcgssd downcall file name given the mechanism - */ -char * -mech2file(gss_OID mech) -{ - struct mech2file *m2fp = m2f; - - while(m2fp->mech.length != 0) { - if (g_OID_equal(mech,&m2fp->mech)) - return(m2fp->filename); - m2fp++; - } - return NULL; -} diff --git a/nfs-utils-2.5.2/utils/gssd/svcgssd_proc.c b/nfs-utils-2.5.2/utils/gssd/svcgssd_proc.c deleted file mode 100644 index b403143..0000000 --- a/nfs-utils-2.5.2/utils/gssd/svcgssd_proc.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - svc_in_gssd_proc.c - - Copyright (c) 2000 The Regents of the University of Michigan. - All rights reserved. - - Copyright (c) 2002 Bruce Fields - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "svcgssd.h" -#include "gss_util.h" -#include "err_util.h" -#include "context.h" -#include "misc.h" -#include "gss_oids.h" -#include "svcgssd_krb5.h" -#include "gss_names.h" - -extern char * mech2file(gss_OID mech); -#define SVCGSSD_CONTEXT_CHANNEL "/proc/net/rpc/auth.rpcsec.context/channel" -#define SVCGSSD_INIT_CHANNEL "/proc/net/rpc/auth.rpcsec.init/channel" - -#define TOKEN_BUF_SIZE 8192 - -struct svc_cred { - uid_t cr_uid; - gid_t cr_gid; - int cr_ngroups; - gid_t cr_groups[NGROUPS]; -}; - -static int -do_svc_downcall(gss_buffer_desc *out_handle, struct svc_cred *cred, - gss_OID mech, gss_buffer_desc *context_token, - int32_t endtime, char *client_name) -{ - char buf[RPC_CHAN_BUF_SIZE], *bp; - int i, f, err, blen; - char *fname = NULL; - - printerr(1, "doing downcall\n"); - if ((fname = mech2file(mech)) == NULL) - goto out_err; - - f = open(SVCGSSD_CONTEXT_CHANNEL, O_WRONLY); - if (f < 0) { - printerr(0, "WARNING: unable to open downcall channel " - "%s: %s\n", - SVCGSSD_CONTEXT_CHANNEL, strerror(errno)); - goto out_err; - } - bp = buf, blen = sizeof(buf); - qword_addhex(&bp, &blen, out_handle->value, out_handle->length); - /* XXX are types OK for the rest of this? */ - /* For context cache, use the actual context endtime */ - qword_addint(&bp, &blen, endtime); - qword_addint(&bp, &blen, cred->cr_uid); - qword_addint(&bp, &blen, cred->cr_gid); - qword_addint(&bp, &blen, cred->cr_ngroups); - printerr(2, "mech: %s, hndl len: %d, ctx len %d, timeout: %d (%d from now), " - "clnt: %s, uid: %d, gid: %d, num aux grps: %d:\n", - fname, out_handle->length, context_token->length, - endtime, endtime - time(0), - client_name ? client_name : "", - cred->cr_uid, cred->cr_gid, cred->cr_ngroups); - for (i=0; i < cred->cr_ngroups; i++) { - qword_addint(&bp, &blen, cred->cr_groups[i]); - printerr(2, " (%4d) %d\n", i+1, cred->cr_groups[i]); - } - qword_add(&bp, &blen, fname); - qword_addhex(&bp, &blen, context_token->value, context_token->length); - if (client_name) - qword_add(&bp, &blen, client_name); - qword_addeol(&bp, &blen); - err = 0; - if (blen <= 0 || write(f, buf, bp - buf) != bp - buf) { - printerr(1, "WARNING: error writing to downcall channel " - "%s: %s\n", SVCGSSD_CONTEXT_CHANNEL, strerror(errno)); - err = -1; - } - close(f); - return err; -out_err: - printerr(1, "WARNING: downcall failed\n"); - return -1; -} - -struct gss_verifier { - u_int32_t flav; - gss_buffer_desc body; -}; - -#define RPCSEC_GSS_SEQ_WIN 5 - -static int -send_response(gss_buffer_desc *in_handle, gss_buffer_desc *in_token, - u_int32_t maj_stat, u_int32_t min_stat, - gss_buffer_desc *out_handle, gss_buffer_desc *out_token) -{ - char buf[2 * TOKEN_BUF_SIZE]; - char *bp = buf; - int blen = sizeof(buf); - /* XXXARG: */ - int g; - - printerr(1, "sending null reply\n"); - - qword_addhex(&bp, &blen, in_handle->value, in_handle->length); - qword_addhex(&bp, &blen, in_token->value, in_token->length); - /* For init cache, only needed for a short time */ - qword_addint(&bp, &blen, time(0) + 60); - qword_adduint(&bp, &blen, maj_stat); - qword_adduint(&bp, &blen, min_stat); - qword_addhex(&bp, &blen, out_handle->value, out_handle->length); - qword_addhex(&bp, &blen, out_token->value, out_token->length); - qword_addeol(&bp, &blen); - if (blen <= 0) { - printerr(0, "WARNING: send_respsonse: message too long\n"); - return -1; - } - g = open(SVCGSSD_INIT_CHANNEL, O_WRONLY); - if (g == -1) { - printerr(0, "WARNING: open %s failed: %s\n", - SVCGSSD_INIT_CHANNEL, strerror(errno)); - return -1; - } - *bp = '\0'; - printerr(3, "writing message: %s", buf); - if (write(g, buf, bp - buf) == -1) { - printerr(0, "WARNING: failed to write message\n"); - close(g); - return -1; - } - close(g); - return 0; -} - -#define rpc_auth_ok 0 -#define rpc_autherr_badcred 1 -#define rpc_autherr_rejectedcred 2 -#define rpc_autherr_badverf 3 -#define rpc_autherr_rejectedverf 4 -#define rpc_autherr_tooweak 5 -#define rpcsec_gsserr_credproblem 13 -#define rpcsec_gsserr_ctxproblem 14 - -static void -add_supplementary_groups(char *secname, char *name, struct svc_cred *cred) -{ - int ret; - static gid_t *groups = NULL; - - cred->cr_ngroups = NGROUPS; - ret = nfs4_gss_princ_to_grouplist(secname, name, - cred->cr_groups, &cred->cr_ngroups); - if (ret < 0) { - groups = realloc(groups, cred->cr_ngroups*sizeof(gid_t)); - ret = nfs4_gss_princ_to_grouplist(secname, name, - groups, &cred->cr_ngroups); - if (ret < 0) - cred->cr_ngroups = 0; - else { - if (cred->cr_ngroups > NGROUPS) - cred->cr_ngroups = NGROUPS; - memcpy(cred->cr_groups, groups, - cred->cr_ngroups*sizeof(gid_t)); - } - } -} - -static int -get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred) -{ - u_int32_t maj_stat, min_stat; - gss_buffer_desc name; - char *sname; - int res = -1; - uid_t uid, gid; - gss_OID name_type = GSS_C_NO_OID; - char *secname; - - maj_stat = gss_display_name(&min_stat, client_name, &name, &name_type); - if (maj_stat != GSS_S_COMPLETE) { - pgsserr("get_ids: gss_display_name", - maj_stat, min_stat, mech); - goto out; - } - if (name.length >= 0xffff || /* be certain name.length+1 doesn't overflow */ - !(sname = calloc(name.length + 1, 1))) { - printerr(0, "WARNING: get_ids: error allocating %d bytes " - "for sname\n", name.length + 1); - gss_release_buffer(&min_stat, &name); - goto out; - } - memcpy(sname, name.value, name.length); - printerr(1, "sname = %s\n", sname); - gss_release_buffer(&min_stat, &name); - - res = -EINVAL; - if ((secname = mech2file(mech)) == NULL) { - printerr(0, "WARNING: get_ids: error mapping mech to " - "file for name '%s'\n", sname); - goto out_free; - } - - res = nfs4_gss_princ_to_ids(secname, sname, &uid, &gid); - if (res < 0) { - /* - * -ENOENT means there was no mapping, any other error - * value means there was an error trying to do the - * mapping. - * If there was no mapping, we send down the value -1 - * to indicate that the anonuid/anongid for the export - * should be used. - */ - if (res == -ENOENT) { - cred->cr_uid = -1; - cred->cr_gid = -1; - cred->cr_ngroups = 0; - res = 0; - goto out_free; - } - printerr(1, "WARNING: get_ids: failed to map name '%s' " - "to uid/gid: %s\n", sname, strerror(-res)); - goto out_free; - } - cred->cr_uid = uid; - cred->cr_gid = gid; - add_supplementary_groups(secname, sname, cred); - res = 0; -out_free: - free(sname); -out: - return res; -} - -#ifdef DEBUG -void -print_hexl(const char *description, unsigned char *cp, int length) -{ - int i, j, jm; - unsigned char c; - - printf("%s (length %d)\n", description, length); - - for (i = 0; i < length; i += 0x10) { - printf(" %04x: ", (u_int)i); - jm = length - i; - jm = jm > 16 ? 16 : jm; - - for (j = 0; j < jm; j++) { - if ((j % 2) == 1) - printf("%02x ", (u_int)cp[i+j]); - else - printf("%02x", (u_int)cp[i+j]); - } - for (; j < 16; j++) { - if ((j % 2) == 1) - printf(" "); - else - printf(" "); - } - printf(" "); - - for (j = 0; j < jm; j++) { - c = cp[i+j]; - c = isprint(c) ? c : '.'; - printf("%c", c); - } - printf("\n"); - } -} -#endif - -void -handle_nullreq(char *cp) { - /* XXX initialize to a random integer to reduce chances of unnecessary - * invalidation of existing ctx's on restarting svcgssd. */ - static u_int32_t handle_seq = 0; - char in_tok_buf[TOKEN_BUF_SIZE]; - char in_handle_buf[15]; - char out_handle_buf[15]; - gss_buffer_desc in_tok = {.value = in_tok_buf}, - out_tok = {.value = NULL}, - in_handle = {.value = in_handle_buf}, - out_handle = {.value = out_handle_buf}, - ctx_token = {.value = NULL}, - ignore_out_tok = {.value = NULL}, - /* XXX isn't there a define for this?: */ - null_token = {.value = NULL}; - u_int32_t ret_flags; - gss_ctx_id_t ctx = GSS_C_NO_CONTEXT; - gss_name_t client_name = NULL; - gss_OID mech = GSS_C_NO_OID; - u_int32_t maj_stat = GSS_S_FAILURE, min_stat = 0; - u_int32_t ignore_min_stat; - struct svc_cred cred; - int32_t ctx_endtime; - char *hostbased_name = NULL; - - printerr(1, "handling null request\n"); - - in_handle.length = (size_t) qword_get(&cp, in_handle.value, - sizeof(in_handle_buf)); -#ifdef DEBUG - print_hexl("in_handle", in_handle.value, in_handle.length); -#endif - - in_tok.length = (size_t) qword_get(&cp, in_tok.value, - sizeof(in_tok_buf)); -#ifdef DEBUG - print_hexl("in_tok", in_tok.value, in_tok.length); -#endif - - if (in_handle.length != 0) { /* CONTINUE_INIT case */ - if (in_handle.length != sizeof(ctx)) { - printerr(0, "WARNING: handle_nullreq: " - "input handle has unexpected length %d\n", - in_handle.length); - goto out_err; - } - /* in_handle is the context id stored in the out_handle - * for the GSS_S_CONTINUE_NEEDED case below. */ - memcpy(&ctx, in_handle.value, in_handle.length); - } - - if (svcgssd_limit_krb5_enctypes()) { - goto out_err; - } - - maj_stat = gss_accept_sec_context(&min_stat, &ctx, gssd_creds, - &in_tok, GSS_C_NO_CHANNEL_BINDINGS, &client_name, - &mech, &out_tok, &ret_flags, NULL, NULL); - - if (maj_stat == GSS_S_CONTINUE_NEEDED) { - printerr(1, "gss_accept_sec_context GSS_S_CONTINUE_NEEDED\n"); - - /* Save the context handle for future calls */ - out_handle.length = sizeof(ctx); - memcpy(out_handle.value, &ctx, sizeof(ctx)); - goto continue_needed; - } - else if (maj_stat != GSS_S_COMPLETE) { - printerr(1, "WARNING: gss_accept_sec_context failed\n"); - pgsserr("handle_nullreq: gss_accept_sec_context", - maj_stat, min_stat, mech); - goto out_err; - } - if (get_ids(client_name, mech, &cred)) { - /* get_ids() prints error msg */ - maj_stat = GSS_S_BAD_NAME; /* XXX ? */ - goto out_err; - } - if (get_hostbased_client_name(client_name, mech, &hostbased_name)) { - /* get_hostbased_client_name() prints error msg */ - maj_stat = GSS_S_BAD_NAME; /* XXX ? */ - goto out_err; - } - - /* Context complete. Pass handle_seq in out_handle to use - * for context lookup in the kernel. */ - handle_seq++; - out_handle.length = sizeof(handle_seq); - memcpy(out_handle.value, &handle_seq, sizeof(handle_seq)); - - /* kernel needs ctx to calculate verifier on null response, so - * must give it context before doing null call: */ - if (serialize_context_for_kernel(&ctx, &ctx_token, mech, &ctx_endtime)) { - printerr(0, "WARNING: handle_nullreq: " - "serialize_context_for_kernel failed\n"); - maj_stat = GSS_S_FAILURE; - goto out_err; - } - /* We no longer need the gss context */ - gss_delete_sec_context(&ignore_min_stat, &ctx, &ignore_out_tok); - - do_svc_downcall(&out_handle, &cred, mech, &ctx_token, ctx_endtime, - hostbased_name); -continue_needed: - send_response(&in_handle, &in_tok, maj_stat, min_stat, - &out_handle, &out_tok); -out: - if (ctx_token.value != NULL) - free(ctx_token.value); - if (out_tok.value != NULL) - gss_release_buffer(&ignore_min_stat, &out_tok); - if (client_name) - gss_release_name(&ignore_min_stat, &client_name); - free(hostbased_name); - printerr(1, "finished handling null request\n"); - return; - -out_err: - if (ctx != GSS_C_NO_CONTEXT) - gss_delete_sec_context(&ignore_min_stat, &ctx, &ignore_out_tok); - send_response(&in_handle, &in_tok, maj_stat, min_stat, - &null_token, &null_token); - goto out; -} diff --git a/nfs-utils-2.5.2/utils/gssd/write_bytes.h b/nfs-utils-2.5.2/utils/gssd/write_bytes.h deleted file mode 100644 index b3f342b..0000000 --- a/nfs-utils-2.5.2/utils/gssd/write_bytes.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - Copyright (c) 2004 The Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _WRITE_BYTES_H_ -#define _WRITE_BYTES_H_ - -#include -#include -#include -#include /* for ntohl */ - -inline static int -write_bytes(char **ptr, const char *end, const void *arg, int arg_len) -{ - char *p = *ptr, *arg_end; - - arg_end = p + arg_len; - if (arg_end > end || arg_end < p) - return -1; - memcpy(p, arg, arg_len); - *ptr = arg_end; - return 0; -} - -#define WRITE_BYTES(p, end, arg) write_bytes(p, end, &arg, sizeof(arg)) - -inline static int -write_buffer(char **p, char *end, gss_buffer_desc *arg) -{ - int len = (int)arg->length; /* make an int out of size_t */ - if (WRITE_BYTES(p, end, len)) - return -1; - if (*p + len > end) - return -1; - memcpy(*p, arg->value, len); - *p += len; - return 0; -} - -inline static int -write_oid(char **p, char *end, gss_OID_desc *arg) -{ - int len = (int)arg->length; /* make an int out of size_t */ - if (WRITE_BYTES(p, end, len)) - return -1; - if (*p + arg->length > end) - return -1; - memcpy(*p, arg->elements, len); - *p += len; - return 0; -} - -static inline int -get_bytes(char **ptr, const char *end, void *res, int len) -{ - char *p, *q; - p = *ptr; - q = p + len; - if (q > end || q < p) - return -1; - memcpy(res, p, len); - *ptr = q; - return 0; -} - -static inline int -get_buffer(char **ptr, const char *end, gss_buffer_desc *res) -{ - char *p, *q; - p = *ptr; - int len; - if (get_bytes(&p, end, &len, sizeof(len))) - return -1; - res->length = len; /* promote to size_t if necessary */ - q = p + res->length; - if (q > end || q < p) - return -1; - if (!(res->value = malloc(res->length))) - return -1; - memcpy(res->value, p, res->length); - *ptr = q; - return 0; -} - -static inline int -xdr_get_u32(u_int32_t **ptr, const u_int32_t *end, u_int32_t *res) -{ - if (get_bytes((char **)ptr, (char *)end, res, sizeof(res))) - return -1; - *res = ntohl(*res); - return 0; -} - -static inline int -xdr_get_buffer(u_int32_t **ptr, const u_int32_t *end, gss_buffer_desc *res) -{ - u_int32_t *p, *q; - u_int32_t len; - p = *ptr; - if (xdr_get_u32(&p, end, &len)) - return -1; - res->length = len; - q = p + ((res->length + 3) >> 2); - if (q > end || q < p) - return -1; - if (!(res->value = malloc(res->length))) - return -1; - memcpy(res->value, p, res->length); - *ptr = q; - return 0; -} - -static inline int -xdr_write_u32(u_int32_t **ptr, const u_int32_t *end, u_int32_t arg) -{ - u_int32_t tmp; - - tmp = htonl(arg); - return WRITE_BYTES((char **)ptr, (char *)end, tmp); -} - -static inline int -xdr_write_buffer(u_int32_t **ptr, const u_int32_t *end, gss_buffer_desc *arg) -{ - int len = arg->length; - if (xdr_write_u32(ptr, end, len)) - return -1; - return write_bytes((char **)ptr, (char *)end, arg->value, - (arg->length + 3) & ~3); -} - -#endif /* _WRITE_BYTES_H_ */ diff --git a/nfs-utils-2.5.2/utils/idmapd/Makefile.am b/nfs-utils-2.5.2/utils/idmapd/Makefile.am deleted file mode 100644 index e09e8c5..0000000 --- a/nfs-utils-2.5.2/utils/idmapd/Makefile.am +++ /dev/null @@ -1,65 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = idmapd.man - -AM_CPPFLAGS += -I ../../support/nfsidmap - -RPCPREFIX = rpc. -KPREFIX = @kprefix@ -sbin_PROGRAMS = idmapd - -EXTRA_DIST = \ - $(man8_MANS) - -idmapd_SOURCES = \ - idmapd.c \ - \ - nfs_idmap.h \ - queue.h - -idmapd_LDADD = ../../support/nfs/libnfs.la \ - ../../support/nfsidmap/libnfsidmap.la \ - $(LIBEVENT) - -MAINTAINERCLEANFILES = Makefile.in - -####################################################################### -# The following allows the current practice of having -# daemons renamed during the install to include RPCPREFIX -# and the KPREFIX -# This could all be done much easier with program_transform_name -# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) -# but that also renames the man pages, which the current -# practice does not do. -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) - - -# XXX This makes some assumptions about what automake does. -# XXX But there is no install-man-hook or install-man-local. -install-man: install-man8 install-man-links -uninstall-man: uninstall-man8 uninstall-man-links - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/idmapd/idmapd.c b/nfs-utils-2.5.2/utils/idmapd/idmapd.c deleted file mode 100644 index 51c71fb..0000000 --- a/nfs-utils-2.5.2/utils/idmapd/idmapd.c +++ /dev/null @@ -1,1091 +0,0 @@ -/* - * idmapd.c - * - * Userland daemon for idmap. - * - * Copyright (c) 2002 The Regents of the University of Michigan. - * All rights reserved. - * - * Marius Aamodt Eriksen - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include - -#include "nfs_idmap.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "conffile.h" -#include "queue.h" -#include "nfslib.h" - -#ifndef PIPEFS_DIR -#define PIPEFS_DIR "/var/lib/nfs/rpc_pipefs/" -#endif - -#ifndef NFSD_DIR -#define NFSD_DIR "/proc/net/rpc" -#endif - -#ifndef CLIENT_CACHE_TIMEOUT_FILE -#define CLIENT_CACHE_TIMEOUT_FILE "/proc/sys/fs/nfs/idmap_cache_timeout" -#endif - -#ifndef NFS4NOBODY_USER -#define NFS4NOBODY_USER "nobody" -#endif - -#ifndef NFS4NOBODY_GROUP -#define NFS4NOBODY_GROUP "nobody" -#endif - -/* From Niels */ -#define CONF_SAVE(w, f) do { \ - char *p = f; \ - if (p != NULL) \ - (w) = p; \ -} while (0) - -#define IC_IDNAME 0 -#define IC_IDNAME_CHAN NFSD_DIR "/nfs4.idtoname/channel" -#define IC_IDNAME_FLUSH NFSD_DIR "/nfs4.idtoname/flush" - -#define IC_NAMEID 1 -#define IC_NAMEID_CHAN NFSD_DIR "/nfs4.nametoid/channel" -#define IC_NAMEID_FLUSH NFSD_DIR "/nfs4.nametoid/flush" - -struct idmap_client { - short ic_which; - char ic_clid[30]; - char *ic_id; - char ic_path[PATH_MAX]; - int ic_fd; - int ic_dirfd; - int ic_scanned; - struct event *ic_event; - TAILQ_ENTRY(idmap_client) ic_next; -}; -static struct idmap_client nfsd_ic[2] = { -{ - .ic_which = IC_IDNAME, - .ic_clid = "", - .ic_id = "Server", - .ic_path = IC_IDNAME_CHAN, - .ic_fd = -1, - .ic_dirfd = -1, - .ic_scanned = 0 -}, -{ - .ic_which = IC_NAMEID, - .ic_clid = "", - .ic_id = "Server", - .ic_path = IC_NAMEID_CHAN, - .ic_fd = -1, - .ic_dirfd = -1, - .ic_scanned = 0 -}, -}; - -TAILQ_HEAD(idmap_clientq, idmap_client); - -static void dirscancb(int, short, void *); -static void clntscancb(int, short, void *); -static void svrreopen(int, short, void *); -static int nfsopen(struct idmap_client *); -static void nfscb(int, short, void *); -static void nfsdcb(int, short, void *); -static int addfield(char **, ssize_t *, char *); -static int getfield(char **, char *, size_t); - -static void imconv(struct idmap_client *, struct idmap_msg *); -static void idtonameres(struct idmap_msg *); -static void nametoidres(struct idmap_msg *); - -static int nfsdopen(void); -static void nfsdclose(void); -static int nfsdopenone(struct idmap_client *); -static void nfsdreopen_one(struct idmap_client *); -static void nfsdreopen(void); - -static int verbose = 0; -#define DEFAULT_IDMAP_CACHE_EXPIRY 600 /* seconds */ -static int cache_entry_expiration = 0; -static char pipefsdir[PATH_MAX]; -static char *nobodyuser, *nobodygroup; -static uid_t nobodyuid; -static gid_t nobodygid; -static struct event_base *evbase = NULL; -static bool signal_received = false; -static int inotify_fd = -1; - -static void -sig_die(int signal) -{ - if (signal_received) { - xlog_warn("forced exiting on signal %d\n", signal); - exit(0); - } - - signal_received = true; - xlog_warn("exiting on signal %d\n", signal); - event_base_loopexit(evbase, NULL); -} - -static int -flush_nfsd_cache(char *path, time_t now) -{ - int fd; - char stime[32]; - - sprintf(stime, "%" PRId64 "\n", (int64_t)now); - fd = open(path, O_RDWR); - if (fd == -1) - return -1; - if (write(fd, stime, strlen(stime)) != (ssize_t)strlen(stime)) { - errx(1, "Flushing nfsd cache failed: errno %d (%s)", - errno, strerror(errno)); - } - close(fd); - return 0; -} - -static int -flush_nfsd_idmap_cache(void) -{ - time_t now = time(NULL); - int ret; - - ret = flush_nfsd_cache(IC_IDNAME_FLUSH, now); - if (ret) - return ret; - ret = flush_nfsd_cache(IC_NAMEID_FLUSH, now); - return ret; -} - -static void usage(char *progname) -{ - fprintf(stderr, "Usage: %s [-hfvCS] [-p path] [-c path]\n", - basename(progname)); -} - -int -main(int argc, char **argv) -{ - int wd = -1, opt, fg = 0, nfsdret = -1; - struct idmap_clientq icq; - struct event *rootdirev = NULL, *clntdirev = NULL, - *svrdirev = NULL, *inotifyev = NULL; - struct event *initialize = NULL; - struct passwd *pw; - struct group *gr; - struct stat sb; - char *xpipefsdir = NULL; - int serverstart = 1, clientstart = 1; - int ret; - char *progname; - char *conf_path = NULL; - - nobodyuser = NFS4NOBODY_USER; - nobodygroup = NFS4NOBODY_GROUP; - strlcpy(pipefsdir, PIPEFS_DIR, sizeof(pipefsdir)); - - if ((progname = strrchr(argv[0], '/'))) - progname++; - else - progname = argv[0]; - xlog_open(progname); - -#define GETOPTSTR "hvfd:p:U:G:c:CS" - opterr=0; /* Turn off error messages */ - while ((opt = getopt(argc, argv, GETOPTSTR)) != -1) { - if (opt == 'c') { - warnx("-c is deprecated and may be removed in the " - "future. See idmapd(8)."); - conf_path = optarg; - } - if (opt == '?') { - if (strchr(GETOPTSTR, optopt)) - warnx("'-%c' option requires an argument.", optopt); - else - warnx("'-%c' is an invalid argument.", optopt); - usage(progname); - exit(1); - } - } - optind = 1; - - if (conf_path) { /* deprecated -c option was specified */ - if (stat(conf_path, &sb) == -1 && (errno == ENOENT || errno == EACCES)) { - warn("Skipping configuration file \"%s\"", conf_path); - conf_path = NULL; - } else { - conf_init_file(conf_path); - verbose = conf_get_num("General", "Verbosity", 0); - cache_entry_expiration = conf_get_num("General", - "Cache-Expiration", DEFAULT_IDMAP_CACHE_EXPIRY); - CONF_SAVE(xpipefsdir, conf_get_str("General", "Pipefs-Directory")); - if (xpipefsdir != NULL) - strlcpy(pipefsdir, xpipefsdir, sizeof(pipefsdir)); - CONF_SAVE(nobodyuser, conf_get_str("Mapping", "Nobody-User")); - CONF_SAVE(nobodygroup, conf_get_str("Mapping", "Nobody-Group")); - if (conf_get_bool("General", "server-only", false)) - clientstart = 0; - if (conf_get_bool("General", "client-only", false)) - serverstart = 0; - } - } else { - conf_path = NFS_CONFFILE; - conf_init_file(conf_path); - CONF_SAVE(xpipefsdir, conf_get_str("General", "Pipefs-Directory")); - if (xpipefsdir != NULL) - strlcpy(pipefsdir, xpipefsdir, sizeof(pipefsdir)); - - conf_path = _PATH_IDMAPDCONF; - conf_init_file(conf_path); - verbose = conf_get_num("General", "Verbosity", 0); - cache_entry_expiration = conf_get_num("General", - "cache-expiration", DEFAULT_IDMAP_CACHE_EXPIRY); - CONF_SAVE(nobodyuser, conf_get_str("Mapping", "Nobody-User")); - CONF_SAVE(nobodygroup, conf_get_str("Mapping", "Nobody-Group")); - if (conf_get_bool("General", "server-only", false)) - clientstart = 0; - if (conf_get_bool("General", "client-only", false)) - serverstart = 0; - } - - while ((opt = getopt(argc, argv, GETOPTSTR)) != -1) - switch (opt) { - case 'v': - verbose++; - break; - case 'f': - fg = 1; - break; - case 'p': - strlcpy(pipefsdir, optarg, sizeof(pipefsdir)); - break; - case 'd': - case 'U': - case 'G': - errx(1, "the -d, -U, and -G options have been removed;" - " please use the configuration file instead."); - case 'C': - serverstart = 0; - break; - case 'S': - clientstart = 0; - break; - case 'h': - usage(progname); - exit(0); - default: - break; - } - - if (!serverstart && !clientstart) - errx(1, "it is illegal to specify both -C and -S"); - - strncat(pipefsdir, "/nfs", sizeof(pipefsdir)-1); - - daemon_init(fg); - - if ((pw = getpwnam(nobodyuser)) == NULL) - errx(1, "Could not find user \"%s\"", nobodyuser); - nobodyuid = pw->pw_uid; - - if ((gr = getgrnam(nobodygroup)) == NULL) - errx(1, "Could not find group \"%s\"", nobodygroup); - nobodygid = gr->gr_gid; - -#ifdef HAVE_NFS4_SET_DEBUG - nfs4_set_debug(verbose, xlog_warn); -#endif - if (conf_path == NULL) - conf_path = _PATH_IDMAPDCONF; - if (nfs4_init_name_mapping(conf_path)) - errx(1, "Unable to create name to user id mappings."); - - evbase = event_base_new(); - if (evbase == NULL) - errx(1, "Failed to create event base."); - - if (verbose > 1) - xlog_warn("Expiration time is %d seconds.", - cache_entry_expiration); - if (serverstart) { - nfsdret = nfsdopen(); - if (nfsdret == 0) { - ret = flush_nfsd_idmap_cache(); - if (ret) - xlog_err("main: Failed to flush nfsd idmap cache\n: %s", strerror(errno)); - } - } - - if (clientstart) { - struct timeval now = { - .tv_sec = 0, - .tv_usec = 0, - }; - - if (cache_entry_expiration != DEFAULT_IDMAP_CACHE_EXPIRY) { - int timeout_fd, len; - char timeout_buf[12]; - if ((timeout_fd = open(CLIENT_CACHE_TIMEOUT_FILE, - O_RDWR)) == -1) { - xlog_warn("Unable to open '%s' to set " - "client cache expiration time " - "to %d seconds\n", - CLIENT_CACHE_TIMEOUT_FILE, - cache_entry_expiration); - } else { - len = snprintf(timeout_buf, sizeof(timeout_buf), - "%d", cache_entry_expiration); - if ((write(timeout_fd, timeout_buf, len)) != len) - xlog_warn("Error writing '%s' to " - "'%s' to set client " - "cache expiration time\n", - timeout_buf, - CLIENT_CACHE_TIMEOUT_FILE); - close(timeout_fd); - } - } - - inotify_fd = inotify_init1(IN_NONBLOCK); - if (inotify_fd == -1) { - xlog_err("Unable to initialise inotify_init1: %s\n", strerror(errno)); - } else { - wd = inotify_add_watch(inotify_fd, pipefsdir, IN_CREATE | IN_DELETE); - if (wd < 0) - xlog_err("Unable to inotify_add_watch(%s): %s\n", pipefsdir, strerror(errno)); - } - - TAILQ_INIT(&icq); - - signal(SIGINT, sig_die); - signal(SIGTERM, sig_die); - - /* These events are persistent */ - rootdirev = evsignal_new(evbase, SIGUSR1, dirscancb, &icq); - if (rootdirev == NULL) - errx(1, "Failed to create SIGUSR1 event."); - evsignal_add(rootdirev, NULL); - clntdirev = evsignal_new(evbase, SIGUSR2, clntscancb, &icq); - if (clntdirev == NULL) - errx(1, "Failed to create SIGUSR2 event."); - evsignal_add(clntdirev, NULL); - svrdirev = evsignal_new(evbase, SIGHUP, svrreopen, NULL); - if (svrdirev == NULL) - errx(1, "Failed to create SIGHUP event."); - evsignal_add(svrdirev, NULL); - if ( wd >= 0) { - inotifyev = event_new(evbase, inotify_fd, - EV_READ | EV_PERSIST, dirscancb, &icq); - if (inotifyev == NULL) - errx(1, "Failed to create inotify read event."); - event_add(inotifyev, NULL); - } - - /* Fetch current state */ - /* (Delay till start of event_dispatch to avoid possibly losing - * a SIGUSR1 between here and the call to event_dispatch().) */ - initialize = evtimer_new(evbase, dirscancb, &icq); - if (initialize == NULL) - errx(1, "Failed to create initialize event."); - evtimer_add(initialize, &now); - } - - if (nfsdret != 0 && wd < 0) - xlog_err("main: Neither NFS client nor NFSd found"); - - daemon_ready(); - - if (event_base_dispatch(evbase) < 0) - xlog_err("main: event_dispatch returns errno %d (%s)", - errno, strerror(errno)); - - nfs4_term_name_mapping(); - nfsdclose(); - - if (inotifyev) - event_free(inotifyev); - if (inotify_fd != -1) - close(inotify_fd); - - if (initialize) - event_free(initialize); - if (rootdirev) - event_free(rootdirev); - if (clntdirev) - event_free(clntdirev); - if (svrdirev) - event_free(svrdirev); - event_base_free(evbase); - - return 1; -} - -static void -flush_inotify(int fd) -{ - while (true) { - char buf[4096] __attribute__ ((aligned(__alignof__(struct inotify_event)))); - const struct inotify_event *ev; - ssize_t len; - char *ptr; - - len = read(fd, buf, sizeof(buf)); - if (len == -1 && errno == EINTR) - continue; - - if (len <= 0) - break; - - for (ptr = buf; ptr < buf + len; - ptr += sizeof(struct inotify_event) + ev->len) { - - ev = (const struct inotify_event *)ptr; - if (verbose > 2) - xlog_warn("pipefs inotify: wd=%i, mask=0x%08x, len=%i, name=%s", - ev->wd, ev->mask, ev->len, ev->len ? ev->name : ""); - } - } -} - -static void -dirscancb(int fd, short UNUSED(which), void *data) -{ - int nent, i; - struct dirent **ents; - struct idmap_client *ic, *nextic; - char path[PATH_MAX+256]; /* + sizeof(d_name) */ - struct idmap_clientq *icq = data; - - if (fd != -1) - flush_inotify(fd); - - TAILQ_FOREACH(ic, icq, ic_next) { - ic->ic_scanned = 0; - } - - nent = scandir(pipefsdir, &ents, NULL, alphasort); - if (nent == -1) { - xlog_warn("dirscancb: scandir(%s): %s", pipefsdir, strerror(errno)); - return; - } - - for (i = 0; i < nent; i++) { - if (ents[i]->d_reclen > 4 && - strncmp(ents[i]->d_name, "clnt", 4) == 0) { - TAILQ_FOREACH(ic, icq, ic_next) - if (strcmp(ents[i]->d_name + 4, ic->ic_clid) == 0) - break; - if (ic != NULL) - goto next; - - if ((ic = calloc(1, sizeof(*ic))) == NULL) - goto out; - strlcpy(ic->ic_clid, ents[i]->d_name + 4, - sizeof(ic->ic_clid)); - path[0] = '\0'; - snprintf(path, sizeof(path), "%s/%s", - pipefsdir, ents[i]->d_name); - - if ((ic->ic_dirfd = open(path, O_RDONLY, 0)) == -1) { - if (verbose > 0) - xlog_warn("dirscancb: open(%s): %s", path, strerror(errno)); - free(ic); - goto out; - } - - strlcat(path, "/idmap", sizeof(path)); - strlcpy(ic->ic_path, path, sizeof(ic->ic_path)); - - if (nfsopen(ic) == -1) { - close(ic->ic_dirfd); - free(ic); - goto out; - } - - if (verbose > 2) - xlog_warn("New client: %s", ic->ic_clid); - - ic->ic_id = "Client"; - - TAILQ_INSERT_TAIL(icq, ic, ic_next); - - next: - ic->ic_scanned = 1; - } - } - - ic = TAILQ_FIRST(icq); - while(ic != NULL) { - nextic=TAILQ_NEXT(ic, ic_next); - if (!ic->ic_scanned) { - if (ic->ic_event) - event_free(ic->ic_event); - if (ic->ic_fd != -1) - close(ic->ic_fd); - if (ic->ic_dirfd != -1) - close(ic->ic_dirfd); - TAILQ_REMOVE(icq, ic, ic_next); - if (verbose > 2) { - xlog_warn("Stale client: %s", ic->ic_clid); - xlog_warn("\t-> closed %s", ic->ic_path); - } - free(ic); - } - ic = nextic; - } - -out: - for (i = 0; i < nent; i++) - free(ents[i]); - free(ents); - return; -} - -static void -svrreopen(int UNUSED(fd), short UNUSED(which), void *UNUSED(data)) -{ - nfsdreopen(); -} - -static void -clntscancb(int UNUSED(fd), short UNUSED(which), void *data) -{ - struct idmap_clientq *icq = data; - struct idmap_client *ic, *ic_next; - - for (ic = TAILQ_FIRST(icq); ic != NULL; ic = ic_next) { - ic_next = TAILQ_NEXT(ic, ic_next); - if (ic->ic_fd == -1 && nfsopen(ic) == -1) { - close(ic->ic_dirfd); - TAILQ_REMOVE(icq, ic, ic_next); - free(ic); - } - } -} - -static void -nfsdcb(int UNUSED(fd), short which, void *data) -{ - struct idmap_client *ic = data; - struct idmap_msg im; - u_char buf[IDMAP_MAXMSGSZ + 1]; - ssize_t len; - ssize_t bsiz; - char *bp, typebuf[IDMAP_MAXMSGSZ], - buf1[IDMAP_MAXMSGSZ], authbuf[IDMAP_MAXMSGSZ], *p; - unsigned long tmp; - - if (which != EV_READ) - return; - - len = read(ic->ic_fd, buf, sizeof(buf)); - if (len == 0) - /* No upcall to read; not necessarily a problem: */ - return; - if (len < 0) { - xlog_warn("nfsdcb: read(%s) failed: errno %d (%s)", - ic->ic_path, errno, - strerror(errno)); - nfsdreopen_one(ic); - return; - } - - /* Get rid of newline and terminate buffer*/ - buf[len - 1] = '\0'; - bp = (char *)buf; - - memset(&im, 0, sizeof(im)); - - /* Authentication name -- ignored for now*/ - if (getfield(&bp, authbuf, sizeof(authbuf)) == -1) { - xlog_warn("nfsdcb: bad authentication name in upcall\n"); - return; - } - if (getfield(&bp, typebuf, sizeof(typebuf)) == -1) { - xlog_warn("nfsdcb: bad type in upcall\n"); - return; - } - if (verbose > 2) - xlog_warn("nfsdcb: authbuf=%s authtype=%s", - authbuf, typebuf); - - im.im_type = strcmp(typebuf, "user") == 0 ? - IDMAP_TYPE_USER : IDMAP_TYPE_GROUP; - - switch (ic->ic_which) { - case IC_NAMEID: - im.im_conv = IDMAP_CONV_NAMETOID; - if (getfield(&bp, im.im_name, sizeof(im.im_name)) == -1) { - xlog_warn("nfsdcb: bad name in upcall\n"); - return; - } - break; - case IC_IDNAME: - im.im_conv = IDMAP_CONV_IDTONAME; - if (getfield(&bp, buf1, sizeof(buf1)) == -1) { - xlog_warn("nfsdcb: bad id in upcall\n"); - return; - } - tmp = strtoul(buf1, (char **)NULL, 10); - im.im_id = (u_int32_t)tmp; - if ((tmp == ULONG_MAX && errno == ERANGE) - || (unsigned long)im.im_id != tmp) { - xlog_warn("nfsdcb: id '%s' too big!\n", buf1); - return; - } - break; - default: - xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which); - return; - } - - imconv(ic, &im); - - buf[0] = '\0'; - bp = (char *)buf; - bsiz = sizeof(buf); - - /* Authentication name */ - addfield(&bp, &bsiz, authbuf); - - switch (ic->ic_which) { - case IC_NAMEID: - /* Type */ - p = im.im_type == IDMAP_TYPE_USER ? "user" : "group"; - addfield(&bp, &bsiz, p); - /* Name */ - addfield(&bp, &bsiz, im.im_name); - /* expiry */ - snprintf(buf1, sizeof(buf1), "%" PRId64, - (int64_t)time(NULL) + cache_entry_expiration); - addfield(&bp, &bsiz, buf1); - /* Note that we don't want to write the id if the mapping - * failed; instead, by leaving it off, we write a negative - * cache entry which will result in an error returned to - * the client. We don't want a chown or setacl referring - * to an unknown user to result in giving permissions to - * "nobody"! */ - if (im.im_status == IDMAP_STATUS_SUCCESS) { - /* ID */ - snprintf(buf1, sizeof(buf1), "%u", im.im_id); - addfield(&bp, &bsiz, buf1); - - } - //if (bsiz == sizeof(buf)) /* XXX */ - - bp[-1] = '\n'; - - break; - case IC_IDNAME: - /* Type */ - p = im.im_type == IDMAP_TYPE_USER ? "user" : "group"; - addfield(&bp, &bsiz, p); - /* ID */ - snprintf(buf1, sizeof(buf1), "%u", im.im_id); - addfield(&bp, &bsiz, buf1); - /* expiry */ - snprintf(buf1, sizeof(buf1), "%" PRId64, - (int64_t)time(NULL) + cache_entry_expiration); - addfield(&bp, &bsiz, buf1); - /* Note we're ignoring the status field in this case; we'll - * just map to nobody instead. */ - /* Name */ - addfield(&bp, &bsiz, im.im_name); - - bp[-1] = '\n'; - - break; - default: - xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which); - return; - } - - bsiz = sizeof(buf) - bsiz; - - if (atomicio((void*)write, ic->ic_fd, buf, bsiz) != bsiz) - xlog_warn("nfsdcb: write(%s) failed: errno %d (%s)", - ic->ic_path, errno, strerror(errno)); -} - -static void -imconv(struct idmap_client *ic, struct idmap_msg *im) -{ - u_int32_t len; - - switch (im->im_conv) { - case IDMAP_CONV_IDTONAME: - idtonameres(im); - if (verbose > 1) - xlog_warn("%s %s: (%s) id \"%d\" -> name \"%s\"", - ic->ic_id, ic->ic_clid, - im->im_type == IDMAP_TYPE_USER ? "user" : "group", - im->im_id, im->im_name); - break; - case IDMAP_CONV_NAMETOID: - len = strnlen(im->im_name, IDMAP_NAMESZ - 1); - /* Check for NULL termination just to be careful */ - if (im->im_name[len+1] != '\0') - return; - nametoidres(im); - if (verbose > 1) - xlog_warn("%s %s: (%s) name \"%s\" -> id \"%d\"", - ic->ic_id, ic->ic_clid, - im->im_type == IDMAP_TYPE_USER ? "user" : "group", - im->im_name, im->im_id); - break; - default: - xlog_warn("imconv: Invalid conversion type (%d) in message", - im->im_conv); - im->im_status |= IDMAP_STATUS_INVALIDMSG; - break; - } -} - -static void -nfscb(int UNUSED(fd), short which, void *data) -{ - struct idmap_client *ic = data; - struct idmap_msg im; - - if (which != EV_READ) - return; - - if (atomicio(read, ic->ic_fd, &im, sizeof(im)) != sizeof(im)) { - if (verbose > 0) - xlog_warn("nfscb: read(%s): %s", ic->ic_path, strerror(errno)); - return; - } - - imconv(ic, &im); - - /* XXX: I don't like ignoring this error in the id->name case, - * but we've never returned it, and I need to check that the client - * can handle it gracefully before starting to return it now. */ - - if (im.im_status == IDMAP_STATUS_LOOKUPFAIL) - im.im_status = IDMAP_STATUS_SUCCESS; - - if (atomicio((void*)write, ic->ic_fd, &im, sizeof(im)) != sizeof(im)) - xlog_warn("nfscb: write(%s): %s", ic->ic_path, strerror(errno)); -} - -static void -nfsdclose_one(struct idmap_client *ic) -{ - if (ic->ic_event) { - event_free(ic->ic_event); - ic->ic_event = NULL; - } - if (ic->ic_fd != -1) { - close(ic->ic_fd); - ic->ic_fd = -1; - } -} - -static void -nfsdreopen_one(struct idmap_client *ic) -{ - int fd; - - if (verbose > 2) - xlog_warn("ReOpening %s", ic->ic_path); - - if ((fd = open(ic->ic_path, O_RDWR, 0)) != -1) { - nfsdclose_one(ic); - - ic->ic_fd = fd; - ic->ic_event = event_new(evbase, ic->ic_fd, EV_READ | EV_PERSIST, nfsdcb, ic); - if (ic->ic_event == NULL) { - xlog_warn("nfsdreopen: Failed to create event for '%s'", - ic->ic_path); - close(ic->ic_fd); - ic->ic_fd = -1; - return; - } - event_add(ic->ic_event, NULL); - } else { - xlog_warn("nfsdreopen: Opening '%s' failed: errno %d (%s)", - ic->ic_path, errno, strerror(errno)); - } -} - -static void -nfsdreopen() -{ - nfsdreopen_one(&nfsd_ic[IC_NAMEID]); - nfsdreopen_one(&nfsd_ic[IC_IDNAME]); - return; -} - -static int -nfsdopen(void) -{ - return ((nfsdopenone(&nfsd_ic[IC_NAMEID]) == 0 && - nfsdopenone(&nfsd_ic[IC_IDNAME]) == 0) ? 0 : -1); -} - -static void -nfsdclose(void) -{ - nfsdclose_one(&nfsd_ic[IC_NAMEID]); - nfsdclose_one(&nfsd_ic[IC_IDNAME]); -} - -static int -nfsdopenone(struct idmap_client *ic) -{ - if ((ic->ic_fd = open(ic->ic_path, O_RDWR, 0)) == -1) { - if (verbose > 0) - xlog_warn("nfsdopenone: Opening %s failed: " - "errno %d (%s)", - ic->ic_path, errno, strerror(errno)); - return (-1); - } - - ic->ic_event = event_new(evbase, ic->ic_fd, EV_READ | EV_PERSIST, nfsdcb, ic); - if (ic->ic_event == NULL) { - if (verbose > 0) - xlog_warn("nfsdopenone: Create event for %s failed", - ic->ic_path); - close(ic->ic_fd); - ic->ic_fd = -1; - return (-1); - } - event_add(ic->ic_event, NULL); - - if (verbose > 2) - xlog_warn("Opened %s", ic->ic_path); - - return (0); -} - -static int -nfsopen(struct idmap_client *ic) -{ - if ((ic->ic_fd = open(ic->ic_path, O_RDWR, 0)) == -1) { - if (errno == ENOENT) { - char *slash; - - slash = strrchr(ic->ic_path, '/'); - if (!slash) - return -1; - *slash = 0; - inotify_add_watch(inotify_fd, ic->ic_path, IN_CREATE | IN_ONLYDIR | IN_ONESHOT); - *slash = '/'; - if (verbose > 2) - xlog_warn("Path %s not available. waiting...", ic->ic_path); - return -1; - } - - xlog_warn("nfsopen: open(%s): %s", ic->ic_path, strerror(errno)); - return (-1); - } - - ic->ic_event = event_new(evbase, ic->ic_fd, EV_READ | EV_PERSIST, nfscb, ic); - if (ic->ic_event == NULL) { - xlog_warn("nfsopen: Create event for %s failed", ic->ic_path); - close(ic->ic_fd); - ic->ic_fd = -1; - return -1; - } - event_add(ic->ic_event, NULL); - if (verbose > 2) - xlog_warn("Opened %s", ic->ic_path); - - return (0); -} - -static void -idtonameres(struct idmap_msg *im) -{ - char domain[NFS4_MAX_DOMAIN_LEN]; - int ret = 0; - - ret = nfs4_get_default_domain(NULL, domain, sizeof(domain)); - switch (im->im_type) { - case IDMAP_TYPE_USER: - ret = nfs4_uid_to_name(im->im_id, domain, im->im_name, - sizeof(im->im_name)); - if (ret) { - if (strlen(nobodyuser) < sizeof(im->im_name)) - strcpy(im->im_name, nobodyuser); - else - strcpy(im->im_name, NFS4NOBODY_USER); - } - break; - case IDMAP_TYPE_GROUP: - ret = nfs4_gid_to_name(im->im_id, domain, im->im_name, - sizeof(im->im_name)); - if (ret) { - if (strlen(nobodygroup) < sizeof(im->im_name)) - strcpy(im->im_name, nobodygroup); - else - strcpy(im->im_name, NFS4NOBODY_GROUP); - } - break; - } - if (ret) - im->im_status = IDMAP_STATUS_LOOKUPFAIL; - else - im->im_status = IDMAP_STATUS_SUCCESS; -} - -static void -nametoidres(struct idmap_msg *im) -{ - uid_t uid; - gid_t gid; - int ret = 0; - - /* XXX: move nobody stuff to library calls - * (nfs4_get_nobody_user(domain), nfs4_get_nobody_group(domain)) */ - - im->im_status = IDMAP_STATUS_SUCCESS; - - switch (im->im_type) { - case IDMAP_TYPE_USER: - ret = nfs4_name_to_uid(im->im_name, &uid); - im->im_id = (u_int32_t) uid; - if (ret) { - im->im_status = IDMAP_STATUS_LOOKUPFAIL; - im->im_id = nobodyuid; - } - return; - case IDMAP_TYPE_GROUP: - ret = nfs4_name_to_gid(im->im_name, &gid); - im->im_id = (u_int32_t) gid; - if (ret) { - im->im_status = IDMAP_STATUS_LOOKUPFAIL; - im->im_id = nobodygid; - } - return; - } -} - -static int -addfield(char **bpp, ssize_t *bsizp, char *fld) -{ - char ch, *bp = *bpp; - ssize_t bsiz = *bsizp; - - while ((ch = *fld++) != '\0' && bsiz > 0) { - switch(ch) { - case ' ': - case '\t': - case '\n': - case '\\': - if (bsiz >= 4) { - bp += snprintf(bp, bsiz, "\\%03o", ch); - bsiz -= 4; - } - break; - default: - *bp++ = ch; - bsiz--; - break; - } - } - - if (bsiz < 1 || ch != '\0') - return (-1); - - *bp++ = ' '; - bsiz--; - - *bpp = bp; - *bsizp = bsiz; - - return (0); -} - -static int -getfield(char **bpp, char *fld, size_t fldsz) -{ - char *bp; - unsigned int val; - int n; - - while ((bp = strsep(bpp, " ")) != NULL && bp[0] == '\0') - ; - - if (bp == NULL || bp[0] == '\0' || bp[0] == '\n') - return (-1); - - while (*bp != '\0' && fldsz > 1) { - if (*bp == '\\') { - if ((n = sscanf(bp, "\\%03o", &val)) != 1) - return (-1); - if (val > UCHAR_MAX) - return (-1); - *fld++ = val; - bp += 4; - } else { - *fld++ = *bp; - bp++; - } - fldsz--; - } - - if (*bp != '\0') - return (-1); - *fld = '\0'; - - return (0); -} diff --git a/nfs-utils-2.5.2/utils/idmapd/idmapd.man b/nfs-utils-2.5.2/utils/idmapd/idmapd.man deleted file mode 100644 index 5f34d2b..0000000 --- a/nfs-utils-2.5.2/utils/idmapd/idmapd.man +++ /dev/null @@ -1,134 +0,0 @@ -.\" $OpenBSD: mdoc.template,v 1.6 2001/02/03 08:22:44 niklas Exp $ -.\" -.\" The following requests are required for all man pages. -.Dd February 3, 2003 -.Dt RPC.IDMAPD 8 -.Os -.Sh NAME -.Nm rpc.idmapd -.Nd NFSv4 ID <-> Name Mapper -.Sh SYNOPSIS -.\" For a program: program [-abc] file ... -.Nm rpc.idmapd -.Op Fl h -.Op Fl f -.Op Fl v -.Op Fl C -.Op Fl S -.Op Fl p Ar path -.Op Fl c Ar path -.Sh DESCRIPTION -.Nm -is the NFSv4 ID <-> name mapping daemon. It provides functionality to -the NFSv4 kernel client and server, to which it communicates via -upcalls, by translating user and group IDs to names, and vice versa. -.Pp -The system derives the -.I user -part of the string by performing a password or group lookup. -The lookup mechanism is configured in -.Pa /etc/idmapd.conf -.Pp -By default, the -.I domain -part of the string is the system's DNS domain name. -It can also be specified in -.Pa /etc/idmapd.conf -if the system is multi-homed, -or if the system's DNS domain name does -not match the name of the system's Kerberos realm. -.Pp -When the domain is not specified in /etc/idmapd.conf -the local DNS server will be queried for the -.Sy _nfsv4idmapdomain -text record. If the record exists -that will be used as the domain. When the record -does not exist, the domain part of the DNS domain -will used. -.Pp -Note that on more recent kernels only the NFSv4 server uses -.Nm . -The NFSv4 client instead uses -.Xr nfsidmap 8 , -and only falls back to -.Nm -if there was a problem running the -.Xr nfsidmap 8 -program. -.Pp -The options are as follows: -.Bl -tag -width Ds_imagedir -.It Fl h -Display usage message. -.It Fl v -Increases the verbosity level (can be specified multiple times). -.It Fl f -Runs -.Nm -in the foreground and prints all output to the terminal. -.It Fl p Ar path -Specifies the location of the RPC pipefs to be -.Ar path . -The default value is \&"/var/lib/nfs/rpc_pipefs\&". -.It Fl c Ar path -Use configuration file -.Ar path . -This option is deprecated. -.It Fl C -Client-only: perform no idmapping for any NFS server, even if one is detected. -.It Fl S -Server-only: perform no idmapping for any NFS client, even if one is detected. -.El -.Sh CONFIGURATION FILES -.Nm -recognizes the following value from the -.Sy [general] -section of the -.Pa /etc/nfs.conf -configuration file: -.Bl -tag -width Ds_imagedir -.It Sy pipefs-directory -Equivalent to -.Sy -p . -.El -.Pp -All other settings related to id mapping are found in the -.Pa /etc/idmapd.conf -configuration file. -.Sh EXAMPLES -.Cm rpc.idmapd -f -vvv -.Pp -Runs -.Nm -printing all -messages to console, and with a verbosity level of 3. -.\" This next request is for sections 2 and 3 function return values only. -.\" .Sh RETURN VALUES -.\" The next request is for sections 2 and 3 error and signal handling only. -.\" .Sh ERRORS -.\" This next request is for section 4 only. -.\" .Sh DIAGNOSTICS -.\" This next request is for sections 1, 6, 7 & 8 only. -.\" .Sh ENVIRONMENT -.Sh FILES -.Pa /etc/idmapd.conf , -.Pa /etc/nfs.conf -.Sh SEE ALSO -.Xr idmapd.conf 5 , -.Xr nfs.conf 5 , -.Xr nfsidmap 8 -.\".Sh SEE ALSO -.\".Xr nylon.conf 4 -.\" .Sh COMPATIBILITY -.\".Sh STANDARDS -.\".Sh ACKNOWLEDGEMENTS -.Sh AUTHORS -The -.Nm -software has been developed by Marius Aamodt Eriksen -.Aq marius@citi.umich.edu . -.\" .Sh HISTORY -.\".Sh BUGS -.\"Please report any bugs to Marius Aamodt Eriksen -.\".Aq marius@monkey.org . -.\" .Sh CAVEATS diff --git a/nfs-utils-2.5.2/utils/idmapd/nfs_idmap.h b/nfs-utils-2.5.2/utils/idmapd/nfs_idmap.h deleted file mode 100644 index 59bced3..0000000 --- a/nfs-utils-2.5.2/utils/idmapd/nfs_idmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * include/linux/nfs_idmap.h - * - * UID and GID to name mapping for clients. - * - * Copyright (c) 2002 The Regents of the University of Michigan. - * All rights reserved. - * - * Marius Aamodt Eriksen - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NFS_IDMAP_H -#define NFS_IDMAP_H - -/* XXX from bits/utmp.h */ -#define IDMAP_NAMESZ 128 - -#define IDMAP_TYPE_USER 0 -#define IDMAP_TYPE_GROUP 1 - -#define IDMAP_CONV_IDTONAME 0 -#define IDMAP_CONV_NAMETOID 1 - -#define IDMAP_STATUS_INVALIDMSG 0x01 -#define IDMAP_STATUS_AGAIN 0x02 -#define IDMAP_STATUS_LOOKUPFAIL 0x04 -#define IDMAP_STATUS_SUCCESS 0x08 - -#define IDMAP_MAXMSGSZ 256 - -struct idmap_msg { - u_int8_t im_type; - u_int8_t im_conv; - char im_name[IDMAP_NAMESZ]; - u_int32_t im_id; - u_int8_t im_status; -}; - -#endif /* NFS_IDMAP_H */ diff --git a/nfs-utils-2.5.2/utils/idmapd/queue.h b/nfs-utils-2.5.2/utils/idmapd/queue.h deleted file mode 100644 index 2823fe7..0000000 --- a/nfs-utils-2.5.2/utils/idmapd/queue.h +++ /dev/null @@ -1,499 +0,0 @@ -/* $OpenBSD: queue.h,v 1.22 2001/06/23 04:39:35 angelos Exp $ */ -/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* - * This file defines five types of data structures: singly-linked lists, - * lists, simple queues, tail queues, and circular queues. - * - * - * A singly-linked list is headed by a single forward pointer. The elements - * are singly linked for minimum space and pointer manipulation overhead at - * the expense of O(n) removal for arbitrary elements. New elements can be - * added to the list after an existing element or at the head of the list. - * Elements being removed from the head of the list should use the explicit - * macro for this purpose for optimum efficiency. A singly-linked list may - * only be traversed in the forward direction. Singly-linked lists are ideal - * for applications with large datasets and few or no removals or for - * implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * A circle queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the list. - * A circle queue may be traversed in either direction, but has a more - * complex end of list detection. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -/* - * Singly-linked List definitions. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List access methods. - */ -#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_END(head) NULL -#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head)) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_FOREACH(var, head, field) \ - for((var) = SLIST_FIRST(head); \ - (var) != SLIST_END(head); \ - (var) = SLIST_NEXT(var, field)) - -/* - * Singly-linked List functions. - */ -#define SLIST_INIT(head) { \ - SLIST_FIRST(head) = SLIST_END(head); \ -} - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (0) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if ((head)->slh_first == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = (head)->slh_first; \ - while( curelm->field.sle_next != (elm) ) \ - curelm = curelm->field.sle_next; \ - curelm->field.sle_next = \ - curelm->field.sle_next->field.sle_next; \ - } \ -} while (0) - -/* - * List definitions. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List access methods - */ -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_END(head) NULL -#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_FOREACH(var, head, field) \ - for((var) = LIST_FIRST(head); \ - (var)!= LIST_END(head); \ - (var) = LIST_NEXT(var, field)) - -/* - * List functions. - */ -#define LIST_INIT(head) do { \ - LIST_FIRST(head) = LIST_END(head); \ -} while (0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (0) - -#define LIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (0) - -#define LIST_REPLACE(elm, elm2, field) do { \ - if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ - (elm2)->field.le_next->field.le_prev = \ - &(elm2)->field.le_next; \ - (elm2)->field.le_prev = (elm)->field.le_prev; \ - *(elm2)->field.le_prev = (elm2); \ -} while (0) - -/* - * Simple queue definitions. - */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue access methods. - */ -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_END(head) NULL -#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head)) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for((var) = SIMPLEQ_FIRST(head); \ - (var) != SIMPLEQ_END(head); \ - (var) = SIMPLEQ_NEXT(var, field)) - -/* - * Simple queue functions. - */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (0) - -#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \ - if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (0) - -/* - * Tail queue definitions. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ -} - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ -} - -/* - * tail queue access methods - */ -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_END(head) NULL -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -/* XXX */ -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_EMPTY(head) \ - (TAILQ_FIRST(head) == TAILQ_END(head)) - -#define TAILQ_FOREACH(var, head, field) \ - for((var) = TAILQ_FIRST(head); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_NEXT(var, field)) - -#define TAILQ_FOREACH_REVERSE(var, head, field, headname) \ - for((var) = TAILQ_LAST(head, headname); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_PREV(var, headname, field)) - -/* - * Tail queue functions. - */ -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (0) - -#define TAILQ_REPLACE(head, elm, elm2, field) do { \ - if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ - (elm2)->field.tqe_next->field.tqe_prev = \ - &(elm2)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm2)->field.tqe_next; \ - (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ - *(elm2)->field.tqe_prev = (elm2); \ -} while (0) - -/* - * Circular queue definitions. - */ -#define CIRCLEQ_HEAD(name, type) \ -struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ -} - -#define CIRCLEQ_HEAD_INITIALIZER(head) \ - { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } - -#define CIRCLEQ_ENTRY(type) \ -struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ -} - -/* - * Circular queue access methods - */ -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -#define CIRCLEQ_END(head) ((void *)(head)) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) -#define CIRCLEQ_EMPTY(head) \ - (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head)) - -#define CIRCLEQ_FOREACH(var, head, field) \ - for((var) = CIRCLEQ_FIRST(head); \ - (var) != CIRCLEQ_END(head); \ - (var) = CIRCLEQ_NEXT(var, field)) - -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ - for((var) = CIRCLEQ_LAST(head); \ - (var) != CIRCLEQ_END(head); \ - (var) = CIRCLEQ_PREV(var, field)) - -/* - * Circular queue functions. - */ -#define CIRCLEQ_INIT(head) do { \ - (head)->cqh_first = CIRCLEQ_END(head); \ - (head)->cqh_last = CIRCLEQ_END(head); \ -} while (0) - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ -} while (0) - -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ -} while (0) - -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = CIRCLEQ_END(head); \ - if ((head)->cqh_last == CIRCLEQ_END(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ -} while (0) - -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.cqe_next = CIRCLEQ_END(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == CIRCLEQ_END(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ -} while (0) - -#define CIRCLEQ_REMOVE(head, elm, field) do { \ - if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ -} while (0) - -#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \ - if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \ - CIRCLEQ_END(head)) \ - (head).cqh_last = (elm2); \ - else \ - (elm2)->field.cqe_next->field.cqe_prev = (elm2); \ - if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \ - CIRCLEQ_END(head)) \ - (head).cqh_first = (elm2); \ - else \ - (elm2)->field.cqe_prev->field.cqe_next = (elm2); \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */ diff --git a/nfs-utils-2.5.2/utils/mount/Makefile.am b/nfs-utils-2.5.2/utils/mount/Makefile.am deleted file mode 100644 index ad0be93..0000000 --- a/nfs-utils-2.5.2/utils/mount/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# These binaries go in /sbin (not /usr/sbin), and that cannot be -# overridden at config time. -sbindir = /sbin - -man8_MANS = mount.nfs.man umount.nfs.man -man5_MANS = nfs.man - -sbin_PROGRAMS = mount.nfs -EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS) -mount_common = error.c network.c token.c \ - parse_opt.c parse_dev.c \ - nfsmount.c nfs4mount.c stropts.c\ - mount_constants.h error.h network.h token.h \ - parse_opt.h parse_dev.h \ - nfs4_mount.h stropts.h version.h \ - mount_config.h utils.c utils.h \ - nfs_mount.h - -if MOUNT_CONFIG -mount_common += configfile.c -man5_MANS += nfsmount.conf.man -else -EXTRA_DIST += nfsmount.conf.man -endif - -mount_nfs_LDADD = ../../support/nfs/libnfs.la \ - ../../support/export/libexport.a \ - ../../support/misc/libmisc.a \ - $(LIBTIRPC) - -mount_nfs_SOURCES = $(mount_common) - -if CONFIG_LIBMOUNT -mount_nfs_SOURCES += mount_libmount.c -mount_nfs_LDADD += $(LIBMOUNT) -else -mount_nfs_SOURCES += mount.c fstab.c nfsumount.c fstab.h - -endif - -MAINTAINERCLEANFILES = Makefile.in - -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - ln -sf mount.nfs mount.nfs4 && \ - ln -sf mount.nfs umount.nfs && \ - ln -sf mount.nfs umount.nfs4 && \ - chmod 4511 mount.nfs ) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - rm -f mount.nfs4 umount.nfs umount.nfs4) - - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $$inst ; \ - done) - (cd $(DESTDIR)$(man5dir) && \ - for m in $(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/5/'`; \ - rm -f $$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $$inst ; \ - done) - (cd $(DESTDIR)$(man5dir) && \ - for m in $(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/5/'`; \ - rm -f $$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/mount/configfile.c b/nfs-utils-2.5.2/utils/mount/configfile.c deleted file mode 100644 index 93fe500..0000000 --- a/nfs-utils-2.5.2/utils/mount/configfile.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * configfile.c -- mount configuration file manipulation - * Copyright (C) 2008 Red Hat, Inc - * - * - Routines use to create mount options from the mount - * configuration file. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "mount.h" -#include "parse_opt.h" -#include "network.h" -#include "conffile.h" - -char *mountopts_convert(char *value); -char *is_alias(char *opt); -char *conf_get_mntopts(char *spec, char *mount_point, char *mount_opts); - -#define KBYTES(x) ((x) * (1024)) -#define MEGABYTES(x) ((x) * (1048576)) -#define GIGABYTES(x) ((x) * (1073741824)) - -#ifndef NFSMOUNT_GLOBAL_OPTS -#define NFSMOUNT_GLOBAL_OPTS "NFSMount_Global_Options" -#endif - -#ifndef NFSMOUNT_MOUNTPOINT -#define NFSMOUNT_MOUNTPOINT "MountPoint" -#endif - -#ifndef NFSMOUNT_SERVER -#define NFSMOUNT_SERVER "Server" -#endif - -enum { - MNT_NOARG=0, - MNT_INTARG, - MNT_STRARG, - MNT_SPEC, - MNT_UNSET -}; -struct mnt_alias { - char *alias; - char *opt; - int argtype; -} mnt_alias_tab[] = { - {"background", "bg", MNT_NOARG}, - {"foreground", "fg", MNT_NOARG}, - {"sloppy", "sloppy", MNT_NOARG}, - {"nfsvers", "vers", MNT_UNSET}, -}; -int mnt_alias_sz = (sizeof(mnt_alias_tab)/sizeof(mnt_alias_tab[0])); - -static int strict; - -/* - * See if the option is an alias, if so return the - * real mount option along with the argument type. - */ -inline static -char *mountopts_alias(char *opt, int *argtype) -{ - int i; - - *argtype = MNT_UNSET; - for (i=0; i < mnt_alias_sz; i++) { - if (strcasecmp(opt, mnt_alias_tab[i].alias) != 0) - continue; - *argtype = mnt_alias_tab[i].argtype; - return mnt_alias_tab[i].opt; - } - /* Make option names case-insensitive */ - upper2lower(opt); - - return opt; -} -/* - * Convert numeric strings that end with 'k', 'm' or 'g' - * into numeric strings with the real value. - * Meaning '8k' becomes '8094'. - */ -char *mountopts_convert(char *value) -{ - unsigned long long factor, num; - static char buf[64]; - char *ch; - - ch = &value[strlen(value)-1]; - switch (tolower(*ch)) { - case 'k': - factor = KBYTES(1); - break; - case 'm': - factor = MEGABYTES(1); - break; - case 'g': - factor = GIGABYTES(1); - break; - default: - return value; - } - *ch = '\0'; - if (strncmp(value, "0x", 2) == 0) { - num = strtol(value, (char **)NULL, 16); - } else if (strncmp(value, "0", 1) == 0) { - num = strtol(value, (char **)NULL, 8); - } else { - num = strtol(value, (char **)NULL, 10); - } - num *= factor; - snprintf(buf, 64, "%lld", num); - - return buf; -} - -struct entry { - SLIST_ENTRY(entry) entries; - char *opt; -}; -static SLIST_HEAD(shead, entry) head = SLIST_HEAD_INITIALIZER(head); -static int list_size; - -/* - * Add option to the link list - */ -inline static void -add_entry(char *opt) -{ - struct entry *entry; - - entry = calloc(1, sizeof(struct entry)); - if (entry == NULL) { - xlog_warn("Unable calloc memory for mount configs"); - return; - } - entry->opt = strdup(opt); - if (entry->opt == NULL) { - xlog_warn("Unable calloc memory for mount opts"); - free(entry); - return; - } - SLIST_INSERT_HEAD(&head, entry, entries); -} -/* - * Check the alias list to see if the given - * opt is a alias - */ -char *is_alias(char *opt) -{ - int i; - - for (i=0; i < mnt_alias_sz; i++) { - if (strcasecmp(opt, mnt_alias_tab[i].alias) == 0) - return mnt_alias_tab[i].opt; - } - return NULL; -} -/* - * See if the given entry exists if the link list, - * if so return that entry - */ -inline static -char *lookup_entry(char *opt) -{ - struct entry *entry; - char *alias = is_alias(opt); - char *ptr; - - SLIST_FOREACH(entry, &head, entries) { - /* - * Only check the left side or options that use '=' - */ - if ((ptr = strchr(entry->opt, '=')) != 0) { - int len = (int) (ptr - entry->opt); - - if (strncasecmp(entry->opt, opt, len) == 0) - return opt; - } - if (strcasecmp(entry->opt, opt) == 0) - return opt; - if (alias && strcasecmp(entry->opt, alias) == 0) - return opt; - if (alias && strcasecmp(alias, "fg") == 0) { - if (strcasecmp(entry->opt, "bg") == 0) - return opt; - } - if (alias && strcasecmp(alias, "bg") == 0) { - if (strcasecmp(entry->opt, "fg") == 0) - return opt; - } - } - return NULL; -} -/* - * Free all entries on the link list - */ -inline static -void free_all(void) -{ - struct entry *entry; - - while (!SLIST_EMPTY(&head)) { - entry = SLIST_FIRST(&head); - SLIST_REMOVE_HEAD(&head, entries); - free(entry->opt); - free(entry); - } -} - -struct nfs_version config_default_vers; -unsigned long config_default_proto; -extern sa_family_t config_default_family; - -/* - * Check to see if a default value is being set. - * If so, set the appropriate global value which will - * be used as the initial value in the server negation. - */ -static int -default_value(char *mopt) -{ - struct mount_options *options = NULL; - int dftlen = strlen("default"); - char *field; - - if (strncasecmp(mopt, "default", dftlen) != 0) - return 0; - - field = mopt + dftlen; - if (strncasecmp(field, "proto", strlen("proto")) == 0) { - if ((options = po_split(field)) != NULL) { - if (!nfs_nfs_protocol(options, &config_default_proto)) { - xlog_warn("Unable to set default protocol : %s", - strerror(errno)); - } - if (!nfs_nfs_proto_family(options, &config_default_family)) { - xlog_warn("Unable to set default family : %s", - strerror(errno)); - } - } else { - xlog_warn("Unable to alloc memory for default protocol"); - } - } else if (strncasecmp(field, "vers", strlen("vers")) == 0) { - if ((options = po_split(field)) != NULL) { - if (!nfs_nfs_version("nfs", options, &config_default_vers)) { - xlog_warn("Unable to set default version: %s", - strerror(errno)); - - } - } else { - xlog_warn("Unable to alloc memory for default version"); - } - } else - xlog_warn("Invalid default setting: '%s'", mopt); - - if (options) - po_destroy(options); - - return 1; -} -/* - * Parse the given section of the configuration - * file to if there are any mount options set. - * If so, added them to link list. - */ -static void -conf_parse_mntopts(char *section, char *arg, char *opts) -{ - struct conf_list *list; - struct conf_list_node *node; - char buf[BUFSIZ], *value, *field; - char *nvalue, *ptr; - int argtype; - - list = conf_get_tag_list(section, arg); - TAILQ_FOREACH(node, &list->fields, link) { - /* check first if this is an alias for another option */ - field = mountopts_alias(node->field, &argtype); - /* - * Do not overwrite options if already exists - */ - snprintf(buf, BUFSIZ, "%s=", field); - if (opts && strcasestr(opts, buf) != NULL) - continue; - - if (lookup_entry(field) != NULL) - continue; - buf[0] = '\0'; - value = conf_get_section(section, arg, node->field); - if (value == NULL) - continue; - if (strcasecmp(value, "false") == 0) { - if (argtype != MNT_NOARG) - snprintf(buf, BUFSIZ, "no%s", field); - else if (strcasecmp(field, "bg") == 0) - snprintf(buf, BUFSIZ, "fg"); - else if (strcasecmp(field, "fg") == 0) - snprintf(buf, BUFSIZ, "bg"); - else if (strcasecmp(field, "sloppy") == 0) - strict = 1; - } else if (strcasecmp(value, "true") == 0) { - if ((strcasecmp(field, "sloppy") == 0) && strict) - continue; - snprintf(buf, BUFSIZ, "%s", field); - } else { - nvalue = strdup(value); - ptr = mountopts_convert(nvalue); - snprintf(buf, BUFSIZ, "%s=%s", field, ptr); - free(nvalue); - } - if (buf[0] == '\0') - continue; - /* - * Keep a running tally of the list size adding - * one for the ',' that will be appened later - */ - list_size += strlen(buf) + 1; - add_entry(buf); - } - conf_free_list(list); -} - -/* - * Concatenate options from the configuration file with the - * given options by building a link list of options from the - * different sections in the conf file. Options that exists - * in the either the given options or link list are not - * overwritten so it matter which when each section is - * parsed. - */ -char *conf_get_mntopts(char *spec, char *mount_point, - char *mount_opts) -{ - struct entry *entry; - char *ptr, *server, *config_opts; - int optlen = 0; - - strict = 0; - SLIST_INIT(&head); - list_size = 0; - /* - * First see if there are any mount options relative - * to the mount point. - */ - conf_parse_mntopts(NFSMOUNT_MOUNTPOINT, mount_point, mount_opts); - - /* - * Next, see if there are any mount options relative - * to the server - */ - server = strdup(spec); - if (server == NULL) { - xlog_warn("conf_get_mountops: Unable calloc memory for server"); - free_all(); - return mount_opts; - } - if ((ptr = strchr(server, ':')) != NULL) - *ptr='\0'; - conf_parse_mntopts(NFSMOUNT_SERVER, server, mount_opts); - free(server); - - /* - * Finally process all the global mount options. - */ - conf_parse_mntopts(NFSMOUNT_GLOBAL_OPTS, NULL, mount_opts); - - /* - * If no mount options were found in the configuration file - * just return what was passed in . - */ - if (SLIST_EMPTY(&head)) - return mount_opts; - - /* - * Found options in the configuration file. So - * concatenate the configuration options with the - * options that were passed in - */ - if (mount_opts) - optlen = strlen(mount_opts); - - /* list_size + optlen + ',' + '\0' */ - config_opts = calloc(1, (list_size+optlen+2)); - if (config_opts == NULL) { - xlog_warn("conf_get_mountops: Unable calloc memory for config_opts"); - free_all(); - return mount_opts; - } - - if (mount_opts) { - strcpy(config_opts, mount_opts); - strcat(config_opts, ","); - } - SLIST_FOREACH(entry, &head, entries) { - if (default_value(entry->opt)) - continue; - strcat(config_opts, entry->opt); - strcat(config_opts, ","); - } - if ((ptr = strrchr(config_opts, ',')) != NULL) - *ptr = '\0'; - - free_all(); - if (mount_opts) - free(mount_opts); - - return config_opts; -} diff --git a/nfs-utils-2.5.2/utils/mount/error.c b/nfs-utils-2.5.2/utils/mount/error.c deleted file mode 100644 index 73295bf..0000000 --- a/nfs-utils-2.5.2/utils/mount/error.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * error.c -- Common error handling functions - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - * To Do: - * + Proper support for internationalization - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xcommon.h" -#include "nls.h" -#include "mount.h" -#include "error.h" - -#ifdef HAVE_RPCSVC_NFS_PROT_H -#include -#else -#include -#define nfsstat nfs_stat -#endif - -extern char *progname; - -static char errbuf[PATH_MAX]; -static char *erreob = &errbuf[PATH_MAX]; - -/* Convert RPC errors into strings */ -static int rpc_strerror(int spos) -{ - int cf_stat = rpc_createerr.cf_stat; - int pos = 0, cf_errno = rpc_createerr.cf_error.re_errno; - char *ptr, *estr = clnt_sperrno(cf_stat); - char *tmp; - - if (estr) { - if ((ptr = strchr(estr, ':'))) - estr = ++ptr; - - tmp = &errbuf[spos]; - if (cf_stat == RPC_SYSTEMERROR) - pos = snprintf(tmp, (erreob - tmp), - _("System Error: %s"), - strerror(cf_errno)); - else { - if (cf_errno) - pos = snprintf(tmp, (erreob - tmp), - _("RPC Error:%s; errno = %s"), - estr, strerror(cf_errno)); - else - pos = snprintf(tmp, (erreob - tmp), - _("RPC Error:%s"), estr); - } - } - return pos; -} - -/** - * rpc_mount_errors - log an RPC error that occurred during a user-space mount - * @server: C string containing name of server we are attempting to mount - * @will_retry: one indicates mount will retry at some later point - * @bg: one indicates this is a background mount - * - * Extracts the error code from the user-space RPC library, and reports it - * on stderr (fg mount) or in the system log (bg mount). - */ -void rpc_mount_errors(char *server, int will_retry, int bg) -{ - int pos = 0; - char *tmp; - static int onlyonce = 0; - - tmp = &errbuf[pos]; - if (bg) - pos = snprintf(tmp, (erreob - tmp), - _("mount to NFS server '%s' failed: "), - server); - else - pos = snprintf(tmp, (erreob - tmp), - _("%s: mount to NFS server '%s' failed: "), - progname, server); - - tmp = &errbuf[pos]; - if (rpc_createerr.cf_stat == RPC_TIMEDOUT) { - if (will_retry) - pos = snprintf(tmp, (erreob - tmp), - _("timed out, retrying")); - else - pos = snprintf(tmp, (erreob - tmp), - _("timed out, giving up")); - } else { - pos += rpc_strerror(pos); - tmp = &errbuf[pos]; - if (bg) { - if (will_retry) - pos = snprintf(tmp, (erreob - tmp), - _(", retrying")); - else - pos = snprintf(tmp, (erreob - tmp), - _(", giving up")); - } - } - - if (bg) { - if (onlyonce++ < 1) - openlog("mount", LOG_CONS|LOG_PID, LOG_AUTH); - syslog(LOG_ERR, "%s", errbuf); - } else - fprintf(stderr, "%s\n", errbuf); -} - -/** - * sys_mount_errors - log an error that occurred during a mount system call - * @server: C string containing name of server we are attempting to mount - * @error: errno value to report - * @will_retry: one indicates mount will retry at some later point - * @bg: one indicates this is a background mount - * - * Passed an errno value generated by a mount system call, and reports it - * on stderr (fg mount) or in the system log (bg mount). - */ -void sys_mount_errors(char *server, int error, int will_retry, int bg) -{ - int pos = 0; - char *tmp; - static int onlyonce = 0; - - tmp = &errbuf[pos]; - if (bg) - pos = snprintf(tmp, (erreob - tmp), - _("mount to NFS server '%s' failed: "), - server); - else - pos = snprintf(tmp, (erreob - tmp), - _("%s: mount to NFS server '%s' failed: "), - progname, server); - - tmp = &errbuf[pos]; - if (error == ETIMEDOUT) { - if (will_retry) - pos = snprintf(tmp, (erreob - tmp), - _("timed out, retrying")); - else - pos = snprintf(tmp, (erreob - tmp), - _("timed out, giving up")); - } else { - if (bg) { - if (will_retry) - pos = snprintf(tmp, (erreob - tmp), - _("%s, retrying"), - strerror(error)); - else - pos = snprintf(tmp, (erreob - tmp), - _("%s, giving up"), - strerror(error)); - } - } - - if (bg) { - if (onlyonce++ < 1) - openlog("mount", LOG_CONS|LOG_PID, LOG_AUTH); - syslog(LOG_ERR, "%s", errbuf); - } else - fprintf(stderr, "%s\n", errbuf); -} - -/** - * mount_error - report a foreground mount error - * @spec: C string containing the device name being mounted - * @mount_point: C string containing the pathname of the local mounted on dir - * @error: errno value to report - * - */ -void mount_error(const char *spec, const char *mount_point, int error) -{ - switch(error) { - case EACCES: - nfs_error(_("%s: access denied by server while mounting %s"), - progname, spec); - break; - case EINVAL: - nfs_error(_("%s: an incorrect mount option was specified"), progname); - break; - case EOPNOTSUPP: - nfs_error(_("%s: requested NFS version or transport protocol is not supported"), - progname); - break; - case ENOTDIR: - if (spec) - nfs_error(_("%s: mount spec %s or point %s is not a " - "directory"), progname, spec, mount_point); - else - nfs_error(_("%s: mount point %s is not a directory"), - progname, mount_point); - break; - case EBUSY: - nfs_error(_("%s: %s is busy or already mounted or sharecache fail"), - progname, mount_point); - break; - case ENOENT: - if (spec) - nfs_error(_("%s: mounting %s failed, " - "reason given by server: %s"), - progname, spec, strerror(error)); - else - nfs_error(_("%s: mount point %s does not exist"), - progname, mount_point); - break; - case ESPIPE: - rpc_mount_errors((char *)spec, 0, 0); - break; - case EIO: - nfs_error(_("%s: mount system call failed"), progname); - break; - case EFAULT: - nfs_error(_("%s: encountered unexpected error condition."), - progname); - nfs_error(_("%s: please report the error to" PACKAGE_BUGREPORT), - progname); - break; - case EALREADY: - /* Error message has already been provided */ - break; - default: - nfs_error(_("%s: %s"), - progname, strerror(error)); - } -} - -/* - * umount_error - report a failed umount request - * @err: errno value to report - * @dev: C string containing the pathname of the local mounted on dir - * - */ -void umount_error(int err, const char *dev) -{ - switch (err) { - case ENXIO: - nfs_error(_("%s: %s: invalid block device"), - progname, dev); - break; - case EINVAL: - nfs_error(_("%s: %s: not mounted"), - progname, dev); - break; - case EIO: - nfs_error(_("%s: %s: can't write superblock"), - progname, dev); - break; - case EBUSY: - nfs_error(_("%s: %s: device is busy"), - progname, dev); - break; - case ENOENT: - nfs_error(_("%s: %s: not found"), - progname, dev); - break; - case EPERM: - nfs_error(_("%s: %s: must be superuser to umount"), - progname, dev); - break; - case EACCES: - nfs_error(_("%s: %s: block devices not permitted on fs"), - progname, dev); - break; - default: - nfs_error(_("%s: %s: %s"), - progname, dev, strerror(err)); - break; - } -} - -/* - * We need to translate between nfs status return values and - * the local errno values which may not be the same. - * - * Andreas Schwab : change errno: - * "after #include the symbol errno is reserved for any use, - * it cannot even be used as a struct tag or field name". - */ - -#ifndef EDQUOT -#define EDQUOT ENOSPC -#endif - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - -static struct { - enum nfsstat stat; - int errnum; -} nfs_errtbl[] = { - { NFS_OK, 0 }, - { NFSERR_PERM, EPERM }, - { NFSERR_NOENT, ENOENT }, - { NFSERR_IO, EIO }, - { NFSERR_NXIO, ENXIO }, - { NFSERR_ACCES, EACCES }, - { NFSERR_EXIST, EEXIST }, - { NFSERR_NODEV, ENODEV }, - { NFSERR_NOTDIR, ENOTDIR }, - { NFSERR_ISDIR, EISDIR }, -#ifdef NFSERR_INVAL - { NFSERR_INVAL, EINVAL }, /* that Sun forgot */ -#endif - { NFSERR_FBIG, EFBIG }, - { NFSERR_NOSPC, ENOSPC }, - { NFSERR_ROFS, EROFS }, - { NFSERR_NAMETOOLONG, ENAMETOOLONG }, - { NFSERR_NOTEMPTY, ENOTEMPTY }, - { NFSERR_DQUOT, EDQUOT }, - { NFSERR_STALE, ESTALE }, -#ifdef EWFLUSH - { NFSERR_WFLUSH, EWFLUSH }, -#endif - /* Throw in some NFSv3 values for even more fun (HP returns these) */ - { 71, EREMOTE }, -}; - -char *nfs_strerror(unsigned int stat) -{ - unsigned int i; - static char buf[256]; - - for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) { - if (nfs_errtbl[i].stat == stat) - return strerror(nfs_errtbl[i].errnum); - } - sprintf(buf, _("unknown nfs status return value: %u"), stat); - return buf; -} diff --git a/nfs-utils-2.5.2/utils/mount/error.h b/nfs-utils-2.5.2/utils/mount/error.h deleted file mode 100644 index ef80fd0..0000000 --- a/nfs-utils-2.5.2/utils/mount/error.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * error.h: Common error handling functions - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_ERROR_H -#define _NFS_UTILS_MOUNT_ERROR_H - -char *nfs_strerror(unsigned int); - -void mount_error(const char *, const char *, int); -void rpc_mount_errors(char *, int, int); -void sys_mount_errors(char *, int, int, int); - -void umount_error(int, const char *); - -#endif /* _NFS_UTILS_MOUNT_ERROR_H */ diff --git a/nfs-utils-2.5.2/utils/mount/fstab.c b/nfs-utils-2.5.2/utils/mount/fstab.c deleted file mode 100644 index 146d8f4..0000000 --- a/nfs-utils-2.5.2/utils/mount/fstab.c +++ /dev/null @@ -1,653 +0,0 @@ -/* 1999-02-22 Arkadiusz Miskiewicz - * - added Native Language Support - * Sun Mar 21 1999 - Arnaldo Carvalho de Melo - * - fixed strerr(errno) in gettext calls - * - * 2006-06-08 Amit Gud - * - Moved code to nfs-utils/support/nfs from util-linux/mount. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "fstab.h" -#include "xcommon.h" -#include "nfs_mntent.h" -#include "nfs_paths.h" -#include "nls.h" - -#define LOCK_TIMEOUT 10 -#define streq(s, t) (strcmp ((s), (t)) == 0) -#define PROC_MOUNTS "/proc/mounts" - -extern char *progname; -extern int verbose; - -/* Information about mtab. ------------------------------------*/ -static int have_mtab_info = 0; -static int var_mtab_does_not_exist = 0; -static int var_mtab_is_a_symlink = 0; - -static void -get_mtab_info(void) { - struct stat mtab_stat; - - if (!have_mtab_info) { - if (lstat(MOUNTED, &mtab_stat)) - var_mtab_does_not_exist = 1; - else if (S_ISLNK(mtab_stat.st_mode)) - var_mtab_is_a_symlink = 1; - have_mtab_info = 1; - } -} - -void -reset_mtab_info(void) { - have_mtab_info = 0; -} - -int -mtab_does_not_exist(void) { - get_mtab_info(); - return var_mtab_does_not_exist; -} - -int -mtab_is_a_symlink(void) { - get_mtab_info(); - return var_mtab_is_a_symlink; -} - -int -mtab_is_writable() { - int fd; - - /* Should we write to /etc/mtab upon an update? - Probably not if it is a symlink to /proc/mounts, since that - would create a file /proc/mounts in case the proc filesystem - is not mounted. */ - if (mtab_is_a_symlink()) - return 0; - - fd = open(MOUNTED, O_RDWR | O_CREAT, 0644); - if (fd >= 0) { - close(fd); - return 1; - } else - return 0; -} - -/* Contents of mtab and fstab ---------------------------------*/ - -struct mntentchn mounttable; -static int got_mtab = 0; -struct mntentchn procmounts; -static int got_procmounts = 0; -struct mntentchn fstab; -static int got_fstab = 0; - -static void read_mounttable(void); -static void read_procmounts(void); -static void read_fstab(void); - -static struct mntentchn * -mtab_head(void) -{ - if (!got_mtab) - read_mounttable(); - return &mounttable; -} - -static struct mntentchn * -procmounts_head(void) -{ - if (!got_procmounts) - read_procmounts(); - return &procmounts; -} - -static struct mntentchn * -fstab_head(void) -{ - if (!got_fstab) - read_fstab(); - return &fstab; -} - -#if 0 -static void -my_free(const void *s) { - if (s) - free((void *) s); -} - -static void -discard_mntentchn(struct mntentchn *mc0) { - struct mntentchn *mc, *mc1; - - for (mc = mc0->nxt; mc && mc != mc0; mc = mc1) { - mc1 = mc->nxt; - my_free(mc->m.mnt_fsname); - my_free(mc->m.mnt_dir); - my_free(mc->m.mnt_type); - my_free(mc->m.mnt_opts); - free(mc); - } -} -#endif - -static void -read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) { - struct mntentchn *mc = mc0; - struct mntent *mnt; - - while ((mnt = nfs_getmntent(mfp)) != NULL) { - if (!streq(mnt->mnt_type, MNTTYPE_IGNORE)) { - mc->nxt = (struct mntentchn *) xmalloc(sizeof(*mc)); - mc->nxt->prev = mc; - mc = mc->nxt; - mc->m = *mnt; - mc->nxt = mc0; - } - } - mc0->prev = mc; - if (ferror(mfp->mntent_fp)) { - int errsv = errno; - nfs_error(_("warning: error reading %s: %s"), - fnam, strerror (errsv)); - mc0->nxt = mc0->prev = NULL; - } - nfs_endmntent(mfp); -} - -/* - * Read /etc/mtab. If that fails, try /proc/mounts. - * This produces a linked list. The list head mounttable is a dummy. - * Return 0 on success. - */ -static void -read_mounttable() { - mntFILE *mfp; - const char *fnam; - struct mntentchn *mc = &mounttable; - - got_mtab = 1; - mc->nxt = mc->prev = NULL; - - fnam = MOUNTED; - mfp = nfs_setmntent (fnam, "r"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - int errsv = errno; - fnam = PROC_MOUNTS; - mfp = nfs_setmntent (fnam, "r"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - nfs_error(_("warning: can't open %s: %s"), - MOUNTED, strerror (errsv)); - return; - } - if (verbose) - printf(_("%s: could not open %s; using %s instead\n"), - progname, MOUNTED, PROC_MOUNTS); - } - read_mntentchn(mfp, fnam, mc); -} - -/* - * Read /proc/mounts. - * This produces a linked list. The list head procmounts is a dummy. - * Return 0 on success. - */ -static void -read_procmounts() { - mntFILE *mfp; - const char *fnam; - struct mntentchn *mc = &procmounts; - - got_procmounts = 1; - mc->nxt = mc->prev = NULL; - - fnam = PROC_MOUNTS; - mfp = nfs_setmntent(fnam, "r"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - nfs_error(_("warning: can't open %s: %s"), - PROC_MOUNTS, strerror (errno)); - return; - } - read_mntentchn(mfp, fnam, mc); -} - -static void -read_fstab() -{ - mntFILE *mfp = NULL; - const char *fnam; - struct mntentchn *mc = &fstab; - - got_fstab = 1; - mc->nxt = mc->prev = NULL; - - fnam = _PATH_FSTAB; - mfp = nfs_setmntent (fnam, "r"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - int errsv = errno; - nfs_error(_("warning: can't open %s: %s"), - _PATH_FSTAB, strerror (errsv)); - return; - } - read_mntentchn(mfp, fnam, mc); -} - -/* - * Given the directory name NAME, and the place MCPREV we found it last time, - * try to find more occurrences. - */ -struct mntentchn * -getmntdirbackward (const char *name, struct mntentchn *mcprev) { - struct mntentchn *mc, *mc0; - - mc0 = mtab_head(); - if (!mcprev) - mcprev = mc0; - for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) - if (streq(mc->m.mnt_dir, name)) - return mc; - return NULL; -} - -/* - * Given the directory name NAME, and the place MCPREV we found it last time, - * try to find more occurrences. - */ -struct mntentchn * -getprocmntdirbackward (const char *name, struct mntentchn *mcprev) { - struct mntentchn *mc, *mc0; - - mc0 = procmounts_head(); - if (!mcprev) - mcprev = mc0; - for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) - if (streq(mc->m.mnt_dir, name)) - return mc; - return NULL; -} - -/* - * Given the device name NAME, and the place MCPREV we found it last time, - * try to find more occurrences. - */ -struct mntentchn * -getmntdevbackward (const char *name, struct mntentchn *mcprev) { - struct mntentchn *mc, *mc0; - - mc0 = mtab_head(); - if (!mcprev) - mcprev = mc0; - for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) - if (streq(mc->m.mnt_fsname, name)) - return mc; - return NULL; -} - -/* Find the dir FILE in fstab. */ -struct mntentchn * -getfsfile (const char *file) -{ - struct mntentchn *mc, *mc0; - - mc0 = fstab_head(); - for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) - if (streq(mc->m.mnt_dir, file)) - return mc; - return NULL; -} - -/* Find the device SPEC in fstab. */ -struct mntentchn * -getfsspec (const char *spec) -{ - struct mntentchn *mc, *mc0; - - mc0 = fstab_head(); - for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) - if (streq(mc->m.mnt_fsname, spec)) - return mc; - return NULL; -} - -/* Updating mtab ----------------------------------------------*/ - -/* Flag for already existing lock file. */ -static int we_created_lockfile = 0; -static int lockfile_fd = -1; - -/* Flag to indicate that signals have been set up. */ -static int signals_have_been_setup = 0; - -/* Ensure that the lock is released if we are interrupted. */ -extern char *strsignal(int sig); /* not always in */ - -static void -handler (int sig) { - die(EX_USER, "%s", strsignal(sig)); -} - -static void -setlkw_timeout (__attribute__((unused)) int sig) { - /* nothing, fcntl will fail anyway */ -} - -/* Remove lock file. */ -void -unlock_mtab (void) { - if (we_created_lockfile) { - close(lockfile_fd); - lockfile_fd = -1; - unlink (MOUNTED_LOCK); - we_created_lockfile = 0; - } -} - -/* Create the lock file. - The lock file will be removed if we catch a signal or when we exit. */ -/* The old code here used flock on a lock file /etc/mtab~ and deleted - this lock file afterwards. However, as rgooch remarks, that has a - race: a second mount may be waiting on the lock and proceed as - soon as the lock file is deleted by the first mount, and immediately - afterwards a third mount comes, creates a new /etc/mtab~, applies - flock to that, and also proceeds, so that the second and third mount - now both are scribbling in /etc/mtab. - The new code uses a link() instead of a creat(), where we proceed - only if it was us that created the lock, and hence we always have - to delete the lock afterwards. Now the use of flock() is in principle - superfluous, but avoids an arbitrary sleep(). */ - -/* Where does the link point to? Obvious choices are mtab and mtab~~. - HJLu points out that the latter leads to races. Right now we use - mtab~. instead. Use 20 as upper bound for the length of %d. */ -#define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "%d" -#define MOUNTLOCK_LINKTARGET_LTH (sizeof(MOUNTED_LOCK)+20) - -void -lock_mtab (void) { - int tries = 100000, i; - char linktargetfile[MOUNTLOCK_LINKTARGET_LTH]; - - at_die = unlock_mtab; - - if (!signals_have_been_setup) { - int sig = 0; - struct sigaction sa; - - sa.sa_flags = 0; - sigfillset (&sa.sa_mask); - - while (sigismember (&sa.sa_mask, ++sig) != -1) { - switch(sig) { - case SIGCHLD: - case SIGKILL: - case SIGCONT: - case SIGSTOP: - /* The cannot be caught, or should not, - * so don't even try. - */ - continue; - case SIGALRM: - sa.sa_handler = setlkw_timeout; - break; - case SIGHUP: - case SIGINT: - case SIGQUIT: - case SIGWINCH: - case SIGTSTP: - case SIGTTIN: - case SIGTTOU: - case SIGPIPE: - case SIGXFSZ: - case SIGXCPU: - /* non-priv user can cause these to be - * generated, so ignore them. - */ - sa.sa_handler = SIG_IGN; - break; - default: - /* The rest should not be possible, so just - * print a message and unlock mtab. - */ - sa.sa_handler = handler; - } - sigaction (sig, &sa, (struct sigaction *) 0); - } - signals_have_been_setup = 1; - } - - sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ()); - - i = open (linktargetfile, O_WRONLY|O_CREAT, 0); - if (i < 0) { - int errsv = errno; - /* linktargetfile does not exist (as a file) - and we cannot create it. Read-only filesystem? - Too many files open in the system? - Filesystem full? */ - die (EX_FILEIO, _("can't create lock file %s: %s " - "(use -n flag to override)"), - linktargetfile, strerror (errsv)); - } - close(i); - - /* Repeat until it was us who made the link */ - while (!we_created_lockfile) { - struct flock flock; - int j; - - j = link(linktargetfile, MOUNTED_LOCK); - - { - int errsv = errno; - - if (j == 0) - we_created_lockfile = 1; - - if (j < 0 && errsv != EEXIST) { - (void) unlink(linktargetfile); - die (EX_FILEIO, _("can't link lock file %s: %s " - "(use -n flag to override)"), - MOUNTED_LOCK, strerror (errsv)); - } - } - - lockfile_fd = open (MOUNTED_LOCK, O_WRONLY); - - if (lockfile_fd < 0) { - int errsv = errno; - /* Strange... Maybe the file was just deleted? */ - if (errno == ENOENT && tries-- > 0) { - if (tries % 200 == 0) - usleep(30); - continue; - } - (void) unlink(linktargetfile); - die (EX_FILEIO, _("can't open lock file %s: %s " - "(use -n flag to override)"), - MOUNTED_LOCK, strerror (errsv)); - } - - flock.l_type = F_WRLCK; - flock.l_whence = SEEK_SET; - flock.l_start = 0; - flock.l_len = 0; - - if (j == 0) { - /* We made the link. Now claim the lock. */ - if (fcntl (lockfile_fd, F_SETLK, &flock) == -1) { - if (verbose) { - int errsv = errno; - nfs_error(_("%s: Can't lock lock file " - "%s: %s"), progname, - MOUNTED_LOCK, - strerror (errsv)); - } - /* proceed anyway */ - } - (void) unlink(linktargetfile); - } else { - static int retries = 0; - - /* Someone else made the link. Wait. */ - alarm(LOCK_TIMEOUT); - if (fcntl (lockfile_fd, F_SETLKW, &flock) == -1) { - int errsv = errno; - (void) unlink(linktargetfile); - die (EX_FILEIO, _("can't lock lock file %s: %s"), - MOUNTED_LOCK, (errno == EINTR) ? - _("timed out") : strerror (errsv)); - } - alarm(0); - /* Limit the number of iterations - maybe there - still is some old /etc/mtab~ */ - ++retries; - if (retries % 200 == 0) - usleep(30); - if (retries > 100000) { - (void) unlink(linktargetfile); - close(lockfile_fd); - die (EX_FILEIO, _("Cannot create link %s\n" - "Perhaps there is a stale lock file?\n"), - MOUNTED_LOCK); - } - close(lockfile_fd); - } - } -} - -/* - * Update the mtab. - * Used by umount with null INSTEAD: remove the last DIR entry. - * Used by mount upon a remount: update option part, - * and complain if a wrong device or type was given. - * [Note that often a remount will be a rw remount of / - * where there was no entry before, and we'll have to believe - * the values given in INSTEAD.] - */ - -void -update_mtab (const char *dir, struct mntent *instead) -{ - mntFILE *mfp, *mftmp; - const char *fnam = MOUNTED; - struct mntentchn mtabhead; /* dummy */ - struct mntentchn *mc, *mc0, *absent = NULL; - - if (mtab_does_not_exist() || !mtab_is_writable()) - return; - - lock_mtab(); - - /* having locked mtab, read it again */ - mc0 = mc = &mtabhead; - mc->nxt = mc->prev = NULL; - - mfp = nfs_setmntent(fnam, "r"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - int errsv = errno; - nfs_error (_("cannot open %s (%s) - mtab not updated"), - fnam, strerror (errsv)); - goto leave; - } - - read_mntentchn(mfp, fnam, mc); - - /* find last occurrence of dir */ - for (mc = mc0->prev; mc && mc != mc0; mc = mc->prev) - if (streq(mc->m.mnt_dir, dir)) - break; - if (mc && mc != mc0) { - if (instead == NULL) { - /* An umount - remove entry */ - if (mc && mc != mc0) { - mc->prev->nxt = mc->nxt; - mc->nxt->prev = mc->prev; - free(mc); - } - } else { - /* A remount */ - mc->m.mnt_opts = instead->mnt_opts; - } - } else if (instead) { - /* not found, add a new entry */ - absent = xmalloc(sizeof(*absent)); - absent->m = *instead; - absent->nxt = mc0; - absent->prev = mc0->prev; - mc0->prev = absent; - if (mc0->nxt == NULL) - mc0->nxt = absent; - } - - /* write chain to mtemp */ - mftmp = nfs_setmntent (MOUNTED_TEMP, "w"); - if (mftmp == NULL || mftmp->mntent_fp == NULL) { - int errsv = errno; - nfs_error (_("cannot open %s (%s) - mtab not updated"), - MOUNTED_TEMP, strerror (errsv)); - goto leave; - } - - for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) { - if (nfs_addmntent(mftmp, &(mc->m)) == 1) { - int errsv = errno; - die (EX_FILEIO, _("error writing %s: %s"), - MOUNTED_TEMP, strerror (errsv)); - } - } - -#if 0 - /* the chain might have strings copied from 'instead', - * so we cannot safely free it. - * And there is no need anyway because we are going to exit - * shortly. So just don't call discard_mntentchn.... - */ - discard_mntentchn(mc0); -#endif - if (fchmod (fileno (mftmp->mntent_fp), - S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) { - int errsv = errno; - nfs_error(_("%s: error changing mode of %s: %s"), - progname, MOUNTED_TEMP, strerror (errsv)); - } - nfs_endmntent (mftmp); - - { /* - * If mount is setuid and some non-root user mounts sth, - * then mtab.tmp might get the group of this user. Copy uid/gid - * from the present mtab before renaming. - */ - struct stat sbuf; - if (stat (MOUNTED, &sbuf) == 0) { - if (chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid) < 0) { - nfs_error(_("%s: error changing owner of %s: %s"), - progname, MOUNTED_TEMP, strerror (errno)); - } - } - } - - /* rename mtemp to mtab */ - if (rename (MOUNTED_TEMP, MOUNTED) < 0) { - int errsv = errno; - nfs_error(_("%s: can't rename %s to %s: %s\n"), - progname, MOUNTED_TEMP, MOUNTED, - strerror(errsv)); - } - - leave: - unlock_mtab(); -} diff --git a/nfs-utils-2.5.2/utils/mount/fstab.h b/nfs-utils-2.5.2/utils/mount/fstab.h deleted file mode 100644 index 8676c8c..0000000 --- a/nfs-utils-2.5.2/utils/mount/fstab.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _NFS_UTILS_MOUNT_FSTAB_H -#define _NFS_UTILS_MOUNT_FSTAB_H - -#include "nfs_mntent.h" - -#ifndef _PATH_FSTAB -#define _PATH_FSTAB "/etc/fstab" -#endif - -int mtab_is_a_symlink(void); -int mtab_is_writable(void); -int mtab_does_not_exist(void); -void reset_mtab_info(void); - -struct mntentchn { - struct mntentchn *nxt, *prev; - struct mntent m; -}; - -struct mntentchn *getmntoptfile (const char *file); -struct mntentchn *getmntdirbackward (const char *dir, struct mntentchn *mc); -struct mntentchn *getprocmntdirbackward (const char *name, struct mntentchn *mc); -struct mntentchn *getmntdevbackward (const char *dev, struct mntentchn *mc); - -struct mntentchn *getfsfile (const char *file); -struct mntentchn *getfsspec (const char *spec); - -void lock_mtab (void); -void unlock_mtab (void); -void update_mtab (const char *special, struct mntent *with); - -#endif /* _NFS_UTILS_MOUNT_FSTAB_H */ diff --git a/nfs-utils-2.5.2/utils/mount/mount.c b/nfs-utils-2.5.2/utils/mount/mount.c deleted file mode 100644 index b98f9e0..0000000 --- a/nfs-utils-2.5.2/utils/mount/mount.c +++ /dev/null @@ -1,558 +0,0 @@ -/* - * mount.c -- Linux NFS mount - * - * Copyright (C) 2006 Amit Gud - * - * - Basic code and wrapper around mount and umount code of NFS. - * Based on util-linux/mount/mount.c. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fstab.h" -#include "xcommon.h" -#include "nls.h" -#include "mount_constants.h" -#include "mount_config.h" -#include "nfs_paths.h" -#include "nfs_mntent.h" - -#include "nfs_mount.h" -#include "nfs4_mount.h" -#include "mount.h" -#include "error.h" -#include "stropts.h" -#include "utils.h" - -char *progname; -int nfs_mount_data_version; -int nomtab; -int verbose; -int sloppy; -int string; - -#define FOREGROUND (0) -#define BACKGROUND (1) - -static struct option longopts[] = { - { "fake", 0, 0, 'f' }, - { "help", 0, 0, 'h' }, - { "no-mtab", 0, 0, 'n' }, - { "read-only", 0, 0, 'r' }, - { "ro", 0, 0, 'r' }, - { "verbose", 0, 0, 'v' }, - { "version", 0, 0, 'V' }, - { "read-write", 0, 0, 'w' }, - { "rw", 0, 0, 'w' }, - { "options", 1, 0, 'o' }, - { NULL, 0, 0, 0 } -}; - -/* - * Map from -o and fstab option strings to the flag argument to mount(2). - */ -struct opt_map { - const char *opt; /* option name */ - int skip; /* skip in mtab option string */ - int inv; /* true if flag value should be inverted */ - int mask; /* flag mask value */ -}; - -static const struct opt_map opt_map[] = { - { "defaults", 0, 0, 0 }, /* default options */ - { "ro", 1, 0, MS_RDONLY }, /* read-only */ - { "rw", 1, 1, MS_RDONLY }, /* read-write */ - { "exec", 0, 1, MS_NOEXEC }, /* permit execution of binaries */ - { "noexec", 0, 0, MS_NOEXEC }, /* don't execute binaries */ - { "suid", 0, 1, MS_NOSUID }, /* honor suid executables */ - { "nosuid", 0, 0, MS_NOSUID }, /* don't honor suid executables */ - { "dev", 0, 1, MS_NODEV }, /* interpret device files */ - { "nodev", 0, 0, MS_NODEV }, /* don't interpret devices */ - { "sync", 0, 0, MS_SYNCHRONOUS}, /* synchronous I/O */ - { "async", 0, 1, MS_SYNCHRONOUS}, /* asynchronous I/O */ - { "dirsync", 0, 0, MS_DIRSYNC}, /* synchronous directory modifications */ - { "remount", 0, 0, MS_REMOUNT}, /* Alter flags of mounted FS */ - { "bind", 0, 0, MS_BIND }, /* Remount part of tree elsewhere */ - { "rbind", 0, 0, MS_BIND|MS_REC }, /* Idem, plus mounted subtrees */ - { "auto", 0, 0, MS_DUMMY }, /* Can be mounted using -a */ - { "noauto", 0, 0, MS_DUMMY }, /* Can only be mounted explicitly */ - { "users", 1, 0, MS_USERS }, /* Allow ordinary user to mount */ - { "nousers", 0, 1, MS_DUMMY }, /* Forbid ordinary user to mount */ - { "user", 1, 0, MS_USER }, /* Allow ordinary user to mount */ - { "nouser", 0, 1, MS_DUMMY }, /* Forbid ordinary user to mount */ - { "owner", 0, 0, MS_DUMMY }, /* Let the owner of the device mount */ - { "noowner", 0, 0, MS_DUMMY }, /* Device owner has no special privs */ - { "group", 0, 0, MS_DUMMY }, /* Let the group of the device mount */ - { "nogroup", 0, 0, MS_DUMMY }, /* Device group has no special privs */ - { "_netdev", 0, 0, MS_DUMMY}, /* Device requires network */ - { "comment", 0, 0, MS_DUMMY}, /* fstab comment only (kudzu,_netdev)*/ - - /* add new options here */ -#ifdef MS_NOSUB - { "sub", 0, 1, MS_NOSUB }, /* allow submounts */ - { "nosub", 0, 0, MS_NOSUB }, /* don't allow submounts */ -#endif -#ifdef MS_SILENT - { "quiet", 0, 0, MS_SILENT }, /* be quiet */ - { "loud", 0, 1, MS_SILENT }, /* print out messages. */ -#endif -#ifdef MS_MANDLOCK - { "mand", 0, 0, MS_MANDLOCK }, /* Allow mandatory locks on this FS */ - { "nomand", 0, 1, MS_MANDLOCK }, /* Forbid mandatory locks on this FS */ -#endif - { "loop", 1, 0, MS_DUMMY }, /* use a loop device */ -#ifdef MS_NOATIME - { "atime", 0, 1, MS_NOATIME }, /* Update access time */ - { "noatime", 0, 0, MS_NOATIME }, /* Do not update access time */ -#endif -#ifdef MS_NODIRATIME - { "diratime", 0, 1, MS_NODIRATIME }, /* Update dir access times */ - { "nodiratime", 0, 0, MS_NODIRATIME },/* Do not update dir access times */ -#endif -#ifdef MS_RELATIME - { "relatime", 0, 0, MS_RELATIME }, /* Update access times relative to - mtime/ctime */ - { "norelatime", 0, 1, MS_RELATIME }, /* Update access time without regard - to mtime/ctime */ -#endif - { "noquota", 0, 0, MS_DUMMY }, /* Don't enforce quota */ - { "quota", 0, 0, MS_DUMMY }, /* Enforce user quota */ - { "usrquota", 0, 0, MS_DUMMY }, /* Enforce user quota */ - { "grpquota", 0, 0, MS_DUMMY }, /* Enforce group quota */ - { NULL, 0, 0, 0 } -}; - -static void parse_opts(const char *options, int *flags, char **extra_opts); - -/* - * Build a canonical mount option string for /etc/mtab. - */ -static char *fix_opts_string(int flags, const char *extra_opts) -{ - const struct opt_map *om; - char *new_opts; - - new_opts = xstrdup((flags & MS_RDONLY) ? "ro" : "rw"); - if (flags & MS_USER) { - /* record who mounted this so they can unmount */ - struct passwd *pw = getpwuid(getuid()); - if(pw) - new_opts = xstrconcat3(new_opts, ",user=", pw->pw_name); - } - if (flags & MS_USERS) - new_opts = xstrconcat3(new_opts, ",users", ""); - - for (om = opt_map; om->opt != NULL; om++) { - if (om->skip) - continue; - if (om->inv || !om->mask || (flags & om->mask) != om->mask) - continue; - new_opts = xstrconcat3(new_opts, ",", om->opt); - flags &= ~om->mask; - } - if (extra_opts && *extra_opts) { - new_opts = xstrconcat3(new_opts, ",", extra_opts); - } - return new_opts; -} - -static void -init_mntent(struct mntent *mnt, char *fsname, char *dir, char *type, - int flags, char *opts) -{ - mnt->mnt_fsname = fsname; - mnt->mnt_dir = dir; - mnt->mnt_type = type; - mnt->mnt_opts = fix_opts_string(flags & ~MS_NOMTAB, opts); - - /* these are always zero for NFS */ - mnt->mnt_freq = 0; - mnt->mnt_passno = 0; -} - -/* Create mtab with a root entry. */ -static void -create_mtab (void) { - struct mntentchn *fstab; - struct mntent mnt; - int flags; - mntFILE *mfp; - - /* Avoid writing if the mtab is a symlink to /proc/mounts, since - that would create a file /proc/mounts in case the proc filesystem - is not mounted, and the fchmod below would also fail. */ - if (mtab_is_a_symlink()) { - return; - } - - lock_mtab(); - - mfp = nfs_setmntent (MOUNTED, "a+"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - int errsv = errno; - die (EX_FILEIO, _("mount: can't open %s for writing: %s"), - MOUNTED, strerror (errsv)); - } - - /* Find the root entry by looking it up in fstab */ - if ((fstab = getfsfile ("/")) || (fstab = getfsfile ("root"))) { - char *extra_opts; - parse_opts (fstab->m.mnt_opts, &flags, &extra_opts); - init_mntent(&mnt, xstrdup(fstab->m.mnt_fsname), "/", - fstab->m.mnt_type, flags, extra_opts); - free(extra_opts); - - if (nfs_addmntent (mfp, &mnt) == 1) { - int errsv = errno; - die (EX_FILEIO, _("mount: error writing %s: %s"), - _PATH_MOUNTED, strerror (errsv)); - } - } - if (fchmod (fileno (mfp->mntent_fp), 0644) < 0) - if (errno != EROFS) { - int errsv = errno; - die (EX_FILEIO, - _("mount: error changing mode of %s: %s"), - _PATH_MOUNTED, strerror (errsv)); - } - nfs_endmntent (mfp); - - unlock_mtab(); - - reset_mtab_info(); -} - -static int add_mtab(char *spec, char *mount_point, char *fstype, - int flags, char *opts) -{ - struct mntent ment; - int result = EX_SUCCESS; - - init_mntent(&ment, spec, mount_point, fstype, flags, opts); - - if (!nomtab && mtab_does_not_exist()) { - if (verbose > 1) - printf(_("mount: no %s found - creating it..\n"), - MOUNTED); - create_mtab (); - } - - if (!nomtab && mtab_is_writable()) { - if (flags & MS_REMOUNT) - update_mtab(ment.mnt_dir, &ment); - else { - mntFILE *mtab; - - lock_mtab(); - mtab = nfs_setmntent(MOUNTED, "a+"); - if (mtab == NULL || mtab->mntent_fp == NULL) { - nfs_error(_("Can't open mtab: %s"), - strerror(errno)); - result = EX_FILEIO; - } else { - if (nfs_addmntent(mtab, &ment) == 1) { - nfs_error(_("Can't write mount entry to mtab: %s"), - strerror(errno)); - result = EX_FILEIO; - } - } - nfs_endmntent(mtab); - unlock_mtab(); - } - } - - free(ment.mnt_opts); - - return result; -} - -static void parse_opt(const char *opt, int *mask, char *extra_opts, size_t len) -{ - const struct opt_map *om; - - for (om = opt_map; om->opt != NULL; om++) { - if (!strcmp (opt, om->opt)) { - if (om->inv) - *mask &= ~om->mask; - else - *mask |= om->mask; - return; - } - } - - len -= strlen(extra_opts); - - if (*extra_opts && --len > 0) - strcat(extra_opts, ","); - - if ((len -= strlen(opt)) > 0) - strcat(extra_opts, opt); -} - -/* - * Convert the provided mount command-line options into the 4th & - * 5th arguments to mount(2). Output parameter "@flags" gets the - * standard options (indicated by MS_ bits), and output parameter - * "@extra_opts" gets all the filesystem-specific options. - */ -static void parse_opts(const char *options, int *flags, char **extra_opts) -{ - if (options != NULL) { - char *opts = xstrdup(options); - char *opt, *p; - size_t len = strlen(opts) + 1; /* include room for a null */ - int open_quote = 0; - - *extra_opts = xmalloc(len); - **extra_opts = '\0'; - - for (p = opts, opt = NULL; p && *p; p++) { - if (!opt) - opt = p; /* begin of the option item */ - if (*p == '"') - open_quote ^= 1; /* reverse the status */ - if (open_quote) - continue; /* still in a quoted block */ - if (*p == ',') - *p = '\0'; /* terminate the option item */ - - /* end of option item or last item */ - if (*p == '\0' || *(p + 1) == '\0') { - parse_opt(opt, flags, *extra_opts, len); - opt = NULL; - } - } - free(opts); - } -} - -static int try_mount(char *spec, char *mount_point, int flags, - char *fs_type, char **extra_opts, char *mount_opts, - int fake, int bg) -{ - int ret; - - if (string) - ret = nfsmount_string(spec, mount_point, fs_type, flags, - extra_opts, fake, bg); - else { - if (strcmp(fs_type, "nfs4") == 0) - ret = nfs4mount(spec, mount_point, flags, - extra_opts, fake, bg); - else - ret = nfsmount(spec, mount_point, flags, - extra_opts, fake, bg); - } - - if (ret) - return ret; - - if (!fake) - print_one(spec, mount_point, fs_type, mount_opts); - - return add_mtab(spec, mount_point, fs_type, flags, *extra_opts); -} - -int main(int argc, char *argv[]) -{ - int c, flags = 0, mnt_err = 1, fake = 0; - char *spec = NULL, *mount_point = NULL, *fs_type = "nfs"; - char *extra_opts = NULL, *mount_opts = NULL; - uid_t uid = getuid(); - - progname = basename(argv[0]); - - nfs_mount_data_version = discover_nfs_mount_data_version(&string); - - if(!strncmp(progname, "umount", strlen("umount"))) - exit(nfsumount(argc, argv)); - - mount_config_init(progname); - - while ((c = getopt_long(argc, argv, "rvVwfno:hs", - longopts, NULL)) != -1) { - switch (c) { - case 'r': - flags |= MS_RDONLY; - break; - case 'v': - ++verbose; - break; - case 'V': - printf("%s: ("PACKAGE_STRING")\n", progname); - exit(EX_SUCCESS); - case 'w': - flags &= ~MS_RDONLY; - break; - case 'f': - ++fake; - break; - case 'n': - ++nomtab; - break; - case 'o': /* specify mount options */ - if (mount_opts) - mount_opts = xstrconcat3(mount_opts, ",", optarg); - else - mount_opts = xstrdup(optarg); - break; - case 's': - ++sloppy; - break; - case 'h': - default: - mount_usage(); - goto out_usage; - } - } - - if ((argc < 3)) { - mount_usage(); - exit(EX_USAGE); - } - - /* - * Extra non-option words at the end are bogus... - */ - if (optind != argc - 2) { - mount_usage(); - goto out_usage; - } else { - while (optind < argc) { - if (!spec) - spec = argv[optind]; - else - mount_point = argv[optind]; - optind++; - } - } - - if (strcmp(progname, "mount.nfs4") == 0) - fs_type = "nfs4"; - - /* - * If a non-root user is attempting to mount, make sure the - * user's requested options match the options specified in - * /etc/fstab; otherwise, don't allow the mount. - */ - if (uid != 0) { - struct mntentchn *mc; - - if ((mc = getfsfile(mount_point)) == NULL || - strcmp(mc->m.mnt_fsname, spec) != 0 || - strcmp(mc->m.mnt_type, fs_type) != 0) { - nfs_error(_("%s: permission denied: no match for %s " - "found in /etc/fstab"), progname, mount_point); - goto out_usage; - } - - /* - * 'mount' munges the options from fstab before passing them - * to us, so it is non-trivial to test that we have the correct - * set of options and we don't want to trust what the user - * gave us, so just take whatever is in /etc/fstab. - */ - mount_opts = strdup(mc->m.mnt_opts); - } - - mount_point = canonicalize(mount_point); - if (!mount_point) { - nfs_error(_("%s: no mount point provided"), progname); - goto out_usage; - } - if (mount_point[0] != '/') { - nfs_error(_("%s: unrecognized mount point %s"), - progname, mount_point); - mnt_err = EX_USAGE; - goto out; - } - /* - * Concatenate mount options from the configuration file - */ - mount_opts = mount_config_opts(spec, mount_point, mount_opts); - - parse_opts(mount_opts, &flags, &extra_opts); - - if (uid != 0) { - if (!(flags & (MS_USERS|MS_USER))) { - nfs_error(_("%s: permission denied"), progname); - mnt_err = EX_USAGE; - goto out; - } - - if (geteuid() != 0) { - nfs_error(_("%s: not installed setuid - " - "\"user\" NFS mounts not supported."), progname); - exit(EX_FAIL); - } - } - - if (chk_mountpoint(mount_point)) { - mnt_err = EX_USAGE; - goto out; - } - - mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts, - mount_opts, fake, FOREGROUND); - if (mnt_err == EX_BG) { - printf(_("%s: backgrounding \"%s\"\n"), - progname, spec); - printf(_("%s: mount options: \"%s\"\n"), - progname, extra_opts); - - fflush(stdout); - - /* - * Parent exits immediately with success. - */ - if (daemon(0, 0)) { - nfs_error(_("%s: failed to start " - "background process: %s\n"), - progname, strerror(errno)); - exit(EX_FAIL); - } - - mnt_err = try_mount(spec, mount_point, flags, fs_type, - &extra_opts, mount_opts, fake, - BACKGROUND); - if (verbose && mnt_err) - printf(_("%s: giving up \"%s\"\n"), - progname, spec); - } - -out: - free(mount_opts); - free(extra_opts); - free(mount_point); - exit(mnt_err); - -out_usage: - free(mount_opts); - exit(EX_USAGE); -} diff --git a/nfs-utils-2.5.2/utils/mount/mount.nfs.man b/nfs-utils-2.5.2/utils/mount/mount.nfs.man deleted file mode 100644 index 0409c96..0000000 --- a/nfs-utils-2.5.2/utils/mount/mount.nfs.man +++ /dev/null @@ -1,93 +0,0 @@ -.\"@(#)mount.nfs.8" -.TH MOUNT.NFS 8 "5 Jun 2006" -.SH NAME -mount.nfs, mount.nfs4 \- mount a Network File System -.SH SYNOPSIS -.BI "mount.nfs" " remotetarget dir" " [\-rvVwfnsh ] [\-o " options "] -.SH DESCRIPTION -.BR mount.nfs -is a part of -.BR nfs (5) -utilities package, which provides NFS client functionality. - -.BR mount.nfs -is meant to be used by the -.BR mount (8) -command for mounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. - -.I remotetarget -is a server share usually in the form of -.BR servername:/path/to/share. -.I dir -is the directory on which the file system is to be mounted. - -Under Linux 2.6.32 and later kernel versions, -.BR mount.nfs -can mount all NFS file system versions. Under earlier Linux kernel versions, -.BR mount.nfs4 -must be used for mounting NFSv4 file systems while -.BR mount.nfs -must be used for NFSv3 and v2. - -.SH OPTIONS -.TP -.BI "\-r" -Mount file system readonly. -.TP -.BI "\-v" -Be verbose. -.TP -.BI "\-V" -Print version. -.TP -.BI "\-w" -Mount file system read-write. -.TP -.BI "\-f" -Fake mount. Don't actually call the mount system call. -.TP -.BI "\-n" -Do not update -.I /etc/mtab. -By default, an entry is created in -.I /etc/mtab -for every mounted file system. Use this option to skip making an entry. -.TP -.BI "\-s" -Tolerate sloppy mount options rather than fail. -.TP -.BI "\-h" -Print help message. -.TP -.BI "nfsoptions" -Refer to -.BR nfs (5) -or -.BR mount (8) -manual pages. - -.SH NOTE -For further information please refer -.BR nfs (5) -and -.BR mount (8) -manual pages. - -.SH FILES -.TP 18n -.I /etc/fstab -file system table -.TP -.I /etc/mtab -table of mounted file systems -.TP -.I /etc/nfsmount.conf -Configuration file for NFS mounts -.PD -.SH "SEE ALSO" -.BR nfs (5), -.BR nfsmount.conf (5), -.BR mount (8), - -.SH "AUTHOR" -Amit Gud diff --git a/nfs-utils-2.5.2/utils/mount/mount_config.h b/nfs-utils-2.5.2/utils/mount/mount_config.h deleted file mode 100644 index 7cc72fc..0000000 --- a/nfs-utils-2.5.2/utils/mount/mount_config.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _LINUX_MOUNT_CONFIG_H -#define _LINUX_MOUNT_CONFIG_H -/* - * mount_config.h -- mount configuration file routines - * Copyright (C) 2008 Red Hat, Inc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifdef MOUNT_CONFIG -#include "conffile.h" -#include "xlog.h" - -#ifndef MOUNTOPTS_CONFFILE -#define MOUNTOPTS_CONFFILE "/etc/nfsmount.conf" -#endif - -extern char *conf_get_mntopts(char *, char *, char *); - -static inline void mount_config_init(char *program) -{ - xlog_open(program); - /* - * Read the the default mount options - */ - conf_init_file(MOUNTOPTS_CONFFILE); -} - -static inline char *mount_config_opts(char *spec, - char *mount_point, char *mount_opts) -{ - return conf_get_mntopts(spec, mount_point, mount_opts); -} - -#else /* MOUNT_CONFIG */ - -static inline void mount_config_init(__attribute__ ((unused)) char *program) { } - -static inline char *mount_config_opts(__attribute__ ((unused)) char *spec, - __attribute__ ((unused)) char *mount_point, char *mount_opts) -{ - return mount_opts; -} -#endif /* MOUNT_CONFIG */ - -#endif /* _LINUX_MOUNT_CONFIG_H */ diff --git a/nfs-utils-2.5.2/utils/mount/mount_constants.h b/nfs-utils-2.5.2/utils/mount/mount_constants.h deleted file mode 100644 index 4d050d8..0000000 --- a/nfs-utils-2.5.2/utils/mount/mount_constants.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _NFS_UTILS_MOUNT_CONSTANTS_H -#define _NFS_UTILS_MOUNT_CONSTANTS_H - -#ifndef MS_DIRSYNC -#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ -#endif - -#ifndef MS_ACTION_MASK -#define MS_ACTION_MASK 0x380 -/* Remount, but new filesystem may be different from old. Atomic - (i.e. there is no interval when nothing is mounted at the mountpoint). - If new fs differs from the old one and old is busy - -EBUSY. */ -#define MS_REPLACE 0x080 /* 128 */ -/* After, Before: as soon as we get unions these will add a new member - in the end or beginning of the chain. Fail if there is a stack - on the mountpoint. */ -#define MS_AFTER 0x100 /* 256 */ -#define MS_BEFORE 0x180 -/* Over: if nothing mounted on a mountpoint - same as if none of these -flags had been set; if we have a union with more than one element - fail; -if we have a stack or plain mount - mount atop of it, forming a stack. */ -#define MS_OVER 0x200 /* 512 */ -#endif -#ifndef MS_NOATIME -#define MS_NOATIME 0x400 /* 1024: Do not update access times. */ -#endif -#ifndef MS_NODIRATIME -#define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */ -#endif -#ifndef MS_BIND -#define MS_BIND 0x1000 /* 4096: Mount existing tree also elsewhere */ -#endif -#ifndef MS_MOVE -#define MS_MOVE 0x2000 /* 8192: Atomically move tree */ -#endif -#ifndef MS_REC -#define MS_REC 0x4000 /* 16384: Recursive loopback */ -#endif -#ifndef MS_VERBOSE -#define MS_VERBOSE 0x8000 /* 32768 */ -#endif -#ifndef MS_RELATIME -#define MS_RELATIME 0x200000 /* 200000: Update access times relative - to mtime/ctime */ -#endif -/* - * NFS fs-specific mount option flags - * - * MS_DUMMY is assigned to mount options that are not to be - * passed to the kernel via the "flags" argument. These are - * generally ignored or handled entirely in user space. - */ -#define MS_DUMMY 0x00000000 -#define MS_USERS 0x40000000 -#define MS_USER 0x80000000 - -/* - * Magic mount flag number. Had to be or-ed to the flag values. - */ -#ifndef MS_MGC_VAL -#define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ -#endif -#ifndef MS_MGC_MSK -#define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ -#endif - -/* Generic options that are prevented from appearing - * in the options field in /etc/mtab. */ -#define MS_NOMTAB (MS_REMOUNT) - -#endif /* _NFS_UTILS_MOUNT_CONSTANTS_H */ diff --git a/nfs-utils-2.5.2/utils/mount/mount_libmount.c b/nfs-utils-2.5.2/utils/mount/mount_libmount.c deleted file mode 100644 index aa4ac5c..0000000 --- a/nfs-utils-2.5.2/utils/mount/mount_libmount.c +++ /dev/null @@ -1,461 +0,0 @@ -/* - * mount_libmount.c -- Linux NFS [u]mount based on libmount - * - * Copyright (C) 2011 Karel Zak - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include "nls.h" -#include "mount_config.h" - -#include "nfs_mount.h" -#include "nfs4_mount.h" -#include "stropts.h" -#include "version.h" -#include "xcommon.h" - -#include "error.h" -#include "utils.h" - -char *retrieve_mount_options(struct libmnt_fs *fs); - -char *progname; -int nfs_mount_data_version; -int verbose; -int sloppy; -int string; -int nomtab; - -#define FOREGROUND (0) -#define BACKGROUND (1) - -/* - * Store mount options to mtab (or /dev/.mount/utab), called from mount.nfs. - * - * Note that on systems without /etc/mtab the fs-specific options are not - * managed by libmount at all. We have to use "mount attributes" that are - * private for mount. helpers. - */ -static void store_mount_options(struct libmnt_fs *fs, const char *nfs_opts) -{ - char *o = NULL; - - mnt_fs_set_attributes(fs, nfs_opts); /* for non-mtab systems */ - - /* for mtab create a new options list */ - mnt_optstr_append_option(&o, mnt_fs_get_vfs_options(fs), NULL); - mnt_optstr_append_option(&o, nfs_opts, NULL); - mnt_optstr_append_option(&o, mnt_fs_get_user_options(fs), NULL); - - mnt_fs_set_options(fs, o); - free(o); -} - -/* - * Retrieve mount options from mtab (or /dev/.mount/utab) called from umount.nfs. - * - * The result can passed to free(). - */ -char *retrieve_mount_options(struct libmnt_fs *fs) -{ - const char *opts; - - if (!fs) - return NULL; - - opts = mnt_fs_get_attributes(fs); /* /dev/.mount/utab */ - if (opts) - return strdup(opts); - - return mnt_fs_strdup_options(fs); /* /etc/mtab */ -} - -static int try_mount(struct libmnt_context *cxt, int bg) -{ - struct libmnt_fs *fs; - const char *p; - char *src = NULL, *tgt = NULL, *type = NULL, *opts = NULL; - unsigned long flags = 0; - int fake, ret = 0; - - fs = mnt_context_get_fs(cxt); - - /* libmount returns read-only pointers (const char) - * so, reallocate for nfsmount() functions. - */ - if ((p = mnt_fs_get_source(fs))) /* spec */ - src = strdup(p); - if ((p = mnt_fs_get_target(fs))) /* mountpoint */ - tgt = strdup(p); - if ((p = mnt_fs_get_fstype(fs))) /* FS type */ - type = strdup(p); - if ((p = mnt_fs_get_fs_options(fs))) /* mount options */ - opts = strdup(p); - - mnt_context_get_mflags(cxt, &flags); /* mount(2) flags */ - fake = mnt_context_is_fake(cxt); - - if (string) - ret = nfsmount_string(src, tgt, type, flags, &opts, fake, bg); - - else if (strcmp(type, "nfs4") == 0) - ret = nfs4mount(src, tgt, flags, &opts, fake, bg); - else - ret = nfsmount(src, tgt, flags, &opts, fake, bg); - - /* Store mount options if not called with mount --no-mtab */ - if (!ret && !mnt_context_is_nomtab(cxt)) - store_mount_options(fs, opts); - - free(src); - free(tgt); - free(type); - free(opts); - - return ret; -} - -/* returns: error = -1, success = 1 , not vers4 == 0 */ -static int is_vers4(struct libmnt_context *cxt) -{ - struct libmnt_fs *fs = mnt_context_get_fs(cxt); - struct libmnt_table *tb = NULL; - const char *src = mnt_context_get_source(cxt), - *tgt = mnt_context_get_target(cxt); - int rc = 0; - - if (!src || !tgt) - return -1; - - if (!mnt_fs_is_kernel(fs)) { - struct libmnt_table *tb = mnt_new_table_from_file("/proc/mounts"); - - if (!tb) - return -1; - fs = mnt_table_find_pair(tb, src, tgt, MNT_ITER_BACKWARD); - } - - if (fs) { - const char *type = mnt_fs_get_fstype(fs); - if (type && strcmp(type, "nfs4") == 0) - rc = 1; - } - mnt_free_table(tb); - return rc; -} - -static int umount_main(struct libmnt_context *cxt, int argc, char **argv) -{ - int rc, c; - char *spec = NULL, *opts = NULL; - int ret = EX_FAIL, verbose = 0; - - static const struct option longopts[] = { - { "force", 0, 0, 'f' }, - { "help", 0, 0, 'h' }, - { "no-mtab", 0, 0, 'n' }, - { "verbose", 0, 0, 'v' }, - { "read-only", 0, 0, 'r' }, - { "lazy", 0, 0, 'l' }, - { "types", 1, 0, 't' }, - { NULL, 0, 0, 0 } - }; - - mnt_context_init_helper(cxt, MNT_ACT_UMOUNT, 0); - mnt_context_disable_canonicalize(cxt, 1); - - while ((c = getopt_long (argc, argv, "fvnrlh", longopts, NULL)) != -1) { - - rc = mnt_context_helper_setopt(cxt, c, optarg); - if (rc == 0) /* valid option */ - continue; - if (rc < 0) /* error (probably ENOMEM) */ - goto err; - /* rc==1 means unknow option */ - umount_usage(); - return EX_USAGE; - } - - verbose = mnt_context_is_verbose(cxt); - - if (optind < argc) - spec = argv[optind++]; - - if (!spec || (*spec != '/' && strchr(spec,':') == NULL)) { - nfs_error(_("%s: no mount point provided"), progname); - umount_usage(); - return EX_USAGE; - } - - if (mnt_context_set_target(cxt, spec)) - goto err; - - /* read mtab/fstab, evaluate permissions, etc. */ - rc = mnt_context_prepare_umount(cxt); - if (rc) { - nfs_error(_("%s: failed to prepare umount: %s\n"), - progname, strerror(-rc)); - goto err; - } - - if (mnt_context_get_fstype(cxt) && - !mnt_match_fstype(mnt_context_get_fstype(cxt), "nfs,nfs4")) { - - nfs_error(_("%s: %s: is not an NFS filesystem"), progname, spec); - ret = EX_USAGE; - goto err; - } - - if (verbose) - printf(_("%s: %s mount point detected\n"), spec, - mnt_context_get_fstype(cxt)); - - opts = retrieve_mount_options(mnt_context_get_fs(cxt)); - - if (!mnt_context_is_lazy(cxt)) { - if (opts) { - /* we have full FS description (e.g. from mtab or /proc) */ - switch (is_vers4(cxt)) { - case 0: - /* We ignore the error from nfs_umount23. - * If the actual umount succeeds (in del_mtab), - * we don't want to signal an error, as that - * could cause /sbin/mount to retry! - */ - nfs_umount23(mnt_context_get_source(cxt), opts); - break; - case 1: /* unknown */ - break; - default: /* error */ - goto err; - } - } else - /* strange, no entry in mtab or /proc not mounted */ - nfs_umount23(spec, "tcp,v3"); - } - - ret = EX_FILEIO; - rc = mnt_context_do_umount(cxt); /* call umount(2) syscall */ - mnt_context_finalize_mount(cxt); /* mtab update */ - - if (rc && !mnt_context_get_status(cxt)) { - /* mnt_context_do_umount() returns errno if umount(2) failed */ - umount_error(rc, spec); - goto err; - } - ret = EX_SUCCESS; -err: - if (verbose) { - if (ret == EX_SUCCESS) - printf(_("%s: umounted\n"), spec); - else - printf(_("%s: umount failed\n"), spec); - } - free(opts); - return ret; -} - -static int mount_main(struct libmnt_context *cxt, int argc, char **argv) -{ - int rc, c; - struct libmnt_fs *fs; - char *spec = NULL, *mount_point = NULL, *opts = NULL; - - static const struct option longopts[] = { - { "fake", 0, 0, 'f' }, - { "help", 0, 0, 'h' }, - { "no-mtab", 0, 0, 'n' }, - { "read-only", 0, 0, 'r' }, - { "ro", 0, 0, 'r' }, - { "verbose", 0, 0, 'v' }, - { "version", 0, 0, 'V' }, - { "read-write", 0, 0, 'w' }, - { "rw", 0, 0, 'w' }, - { "options", 1, 0, 'o' }, - { "sloppy", 0, 0, 's' }, - { NULL, 0, 0, 0 } - }; - - mount_config_init(progname); - mnt_context_init_helper(cxt, MNT_ACT_MOUNT, 0); - - while ((c = getopt_long(argc, argv, "fhnrVvwo:s", longopts, NULL)) != -1) { - - rc = mnt_context_helper_setopt(cxt, c, optarg); - if (rc == 0) /* valid option */ - continue; - if (rc < 0) /* error (probably ENOMEM) */ - goto err; - /* rc==1 means unknow option */ - switch (c) { - case 'V': - printf("%s: ("PACKAGE_STRING")\n", progname); - return EX_SUCCESS; - case 'h': - default: - mount_usage(); - return EX_USAGE; - } - } - - if (optind < argc) - spec = argv[optind++]; - if (optind < argc) - mount_point = argv[optind++]; - - if (!mount_point) { - nfs_error(_("%s: no mount point provided"), progname); - mount_usage(); - goto err; - } - if (!spec) { - nfs_error(_("%s: no mount spec provided"), progname); - goto err; - } - - if (geteuid() != 0) { - nfs_error(_("%s: not installed setuid - " - "\"user\" NFS mounts not supported."), progname); - goto err; - } - - verbose = mnt_context_is_verbose(cxt); - sloppy = mnt_context_is_sloppy(cxt); - nomtab = mnt_context_is_nomtab(cxt); - - if (strcmp(progname, "mount.nfs4") == 0) - mnt_context_set_fstype(cxt, "nfs4"); - else - mnt_context_set_fstype(cxt, "nfs"); /* default */ - - rc = mnt_context_set_source(cxt, spec); - if (!rc) - mnt_context_set_target(cxt, mount_point); - if (rc) { - nfs_error(_("%s: failed to set spec or mountpoint: %s"), - progname, strerror(errno)); - goto err; - } - - mount_point = mnt_resolve_path(mount_point, - mnt_context_get_cache(cxt)); - - if (chk_mountpoint(mount_point)) - goto err; - - /* - * The libmount strictly uses only options from fstab if running in - * restricted mode (suid, non-root user). This is done in - * mnt_context_prepare_mount() by default. - * - * We have to read fstab before nfsmount.conf, otherwise the options - * from nfsmount.conf will be ignored (overwrited). - */ - rc = mnt_context_apply_fstab(cxt); - if (rc) { - nfs_error(_("%s: failed to apply fstab options\n"), progname); - goto err; - } - - /* - * Concatenate mount options from the configuration file - */ - fs = mnt_context_get_fs(cxt); - if (fs) { - opts = mnt_fs_strdup_options(fs); - - opts = mount_config_opts(spec, mount_point, opts); - mnt_fs_set_options(fs, opts); - } - - rc = mnt_context_prepare_mount(cxt); - if (rc) { - nfs_error(_("%s: failed to prepare mount: %s\n"), - progname, strerror(-rc)); - goto err; - } - - rc = try_mount(cxt, FOREGROUND); - - if (rc == EX_BG) { - printf(_("%s: backgrounding \"%s\"\n"), - progname, mnt_context_get_source(cxt)); - printf(_("%s: mount options: \"%s\"\n"), - progname, opts); - - fflush(stdout); - - if (daemon(0, 0)) { - nfs_error(_("%s: failed to start " - "background process: %s\n"), - progname, strerror(errno)); - exit(EX_FAIL); - } - - rc = try_mount(cxt, BACKGROUND); - - if (verbose && rc) - printf(_("%s: giving up \"%s\"\n"), - progname, mnt_context_get_source(cxt)); - } - - mnt_context_set_syscall_status(cxt, rc == EX_SUCCESS ? 0 : -1); - mnt_context_finalize_mount(cxt); /* mtab update */ - return rc; -err: - return EX_FAIL; -} - -int main(int argc, char *argv[]) -{ - struct libmnt_context *cxt; - int rc; - - mnt_init_debug(0); - cxt = mnt_new_context(); - if (!cxt) { - nfs_error(_("Can't initilize libmount: %s"), - strerror(errno)); - rc = EX_FAIL; - goto done; - } - - progname = basename(argv[0]); - nfs_mount_data_version = discover_nfs_mount_data_version(&string); - - if(strncmp(progname, "umount", 6) == 0) - rc = umount_main(cxt, argc, argv); - else - rc = mount_main(cxt, argc, argv); -done: - mnt_free_context(cxt); - return rc; -} diff --git a/nfs-utils-2.5.2/utils/mount/network.c b/nfs-utils-2.5.2/utils/mount/network.c deleted file mode 100644 index d9c0b51..0000000 --- a/nfs-utils-2.5.2/utils/mount/network.c +++ /dev/null @@ -1,1808 +0,0 @@ -/* - * network.c -- Provide common network functions for NFS mount/umount - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)) -/* Cannot safely include linux/in6.h in old glibc, so hardcode the needed values */ -# define IPV6_PREFER_SRC_PUBLIC 2 -# define IPV6_ADDR_PREFERENCES 72 -#else -# include -#endif -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "xcommon.h" -#include "mount.h" -#include "nls.h" -#include "nfs_mount.h" -#include "mount_constants.h" -#include "nfsrpc.h" -#include "parse_opt.h" -#include "network.h" -#include "conffile.h" -#include "nfslib.h" - -#define PMAP_TIMEOUT (10) -#define CONNECT_TIMEOUT (20) -#define MOUNT_TIMEOUT (30) -#define STATD_TIMEOUT (10) - -#define SAFE_SOCKADDR(x) (struct sockaddr *)(char *)(x) - -extern int nfs_mount_data_version; -extern char *progname; -extern int verbose; - -static const char *nfs_mnt_pgmtbl[] = { - "mount", - "mountd", - NULL, -}; - -static const char *nfs_nfs_pgmtbl[] = { - "nfs", - "nfsprog", - NULL, -}; - -static const char *nfs_transport_opttbl[] = { - "udp", - "tcp", - "rdma", - "proto", - NULL, -}; - -static const char *nfs_version_opttbl[] = { - "v2", - "v3", - "v4", - "vers", - "nfsvers", - NULL, -}; - -static const unsigned long nfs_to_mnt[] = { - 0, - 0, - 1, - 3, -}; - -static const unsigned long mnt_to_nfs[] = { - 0, - 2, - 2, - 3, -}; - -/* - * Map an NFS version into the corresponding Mountd version - */ -unsigned long nfsvers_to_mnt(const unsigned long vers) -{ - if (vers <= 3) - return nfs_to_mnt[vers]; - return 0; -} - -/* - * Map a Mountd version into the corresponding NFS version - */ -static unsigned long mntvers_to_nfs(const unsigned long vers) -{ - if (vers <= 3) - return mnt_to_nfs[vers]; - return 0; -} - -static const unsigned int probe_udp_only[] = { - IPPROTO_UDP, - 0, -}; - -static const unsigned int probe_udp_first[] = { - IPPROTO_UDP, - IPPROTO_TCP, - 0, -}; - -static const unsigned int probe_tcp_first[] = { - IPPROTO_TCP, - IPPROTO_UDP, - 0, -}; - -static const unsigned long probe_nfs2_only[] = { - 2, - 0, -}; - -static const unsigned long probe_nfs3_only[] = { - 3, - 0, -}; - -static const unsigned long probe_mnt1_first[] = { - 1, - 2, - 0, -}; - -static const unsigned long probe_mnt3_only[] = { - 3, - 0, -}; - -static const unsigned int *nfs_default_proto(void); -#ifdef MOUNT_CONFIG -static const unsigned int *nfs_default_proto() -{ - extern unsigned long config_default_proto; - /* - * If the default proto has been set and - * its not TCP, start with UDP - */ - if (config_default_proto && config_default_proto != IPPROTO_TCP) - return probe_udp_first; - - return probe_tcp_first; -} -#else -static const unsigned int *nfs_default_proto() -{ - return probe_tcp_first; -} -#endif /* MOUNT_CONFIG */ - -/** - * nfs_lookup - resolve hostname to an IPv4 or IPv6 socket address - * @hostname: pointer to C string containing DNS hostname to resolve - * @family: address family hint - * @sap: pointer to buffer to fill with socket address - * @len: IN: size of buffer to fill; OUT: size of socket address - * - * Returns 1 and places a socket address at @sap if successful; - * otherwise zero. - */ -int nfs_lookup(const char *hostname, const sa_family_t family, - struct sockaddr *sap, socklen_t *salen) -{ - struct addrinfo *gai_results; - struct addrinfo gai_hint = { - .ai_family = family, - }; - socklen_t len = *salen; - int error, ret = 0; - - *salen = 0; - - error = getaddrinfo(hostname, NULL, &gai_hint, &gai_results); - switch (error) { - case 0: - break; - case EAI_SYSTEM: - nfs_error(_("%s: DNS resolution failed for %s: %s"), - progname, hostname, strerror(errno)); - return ret; - default: - nfs_error(_("%s: DNS resolution failed for %s: %s"), - progname, hostname, gai_strerror(error)); - return ret; - } - - switch (gai_results->ai_addr->sa_family) { - case AF_INET: - case AF_INET6: - if (len >= gai_results->ai_addrlen) { - *salen = gai_results->ai_addrlen; - memcpy(sap, gai_results->ai_addr, *salen); - ret = 1; - } - break; - default: - /* things are really broken if we get here, so warn */ - nfs_error(_("%s: unrecognized DNS resolution results for %s"), - progname, hostname); - break; - } - - nfs_freeaddrinfo(gai_results); - return ret; -} - -/** - * nfs_gethostbyname - resolve a hostname to an IPv4 address - * @hostname: pointer to a C string containing a DNS hostname - * @sin: returns an IPv4 address - * - * Returns 1 if successful, otherwise zero. - */ -int nfs_gethostbyname(const char *hostname, struct sockaddr_in *sin) -{ - socklen_t len = sizeof(*sin); - - return nfs_lookup(hostname, AF_INET, (struct sockaddr *)sin, &len); -} - -/** - * nfs_string_to_sockaddr - convert string address to sockaddr - * @address: pointer to presentation format address to convert - * @sap: pointer to socket address buffer to fill in - * @salen: IN: length of address buffer - * OUT: length of converted socket address - * - * Convert a presentation format address string to a socket address. - * Similar to nfs_lookup(), but the DNS query is squelched, and it - * won't make any noise if the getaddrinfo() call fails. - * - * Returns 1 and fills in @sap and @salen if successful; otherwise zero. - * - * See RFC 4038 section 5.1 or RFC 3513 section 2.2 for more details - * on presenting IPv6 addresses as text strings. - */ -int nfs_string_to_sockaddr(const char *address, struct sockaddr *sap, - socklen_t *salen) -{ - struct addrinfo *gai_results; - struct addrinfo gai_hint = { - .ai_flags = AI_NUMERICHOST, - }; - socklen_t len = *salen; - int ret = 0; - - *salen = 0; - - if (getaddrinfo(address, NULL, &gai_hint, &gai_results) == 0) { - switch (gai_results->ai_addr->sa_family) { - case AF_INET: - case AF_INET6: - if (len >= gai_results->ai_addrlen) { - *salen = gai_results->ai_addrlen; - memcpy(sap, gai_results->ai_addr, *salen); - ret = 1; - } - break; - } - nfs_freeaddrinfo(gai_results); - } - - return ret; -} - -/** - * nfs_present_sockaddr - convert sockaddr to string - * @sap: pointer to socket address to convert - * @salen: length of socket address - * @buf: pointer to buffer to fill in - * @buflen: length of buffer - * - * Convert the passed-in sockaddr-style address to presentation format. - * The presentation format address is placed in @buf and is - * '\0'-terminated. - * - * Returns 1 if successful; otherwise zero. - * - * See RFC 4038 section 5.1 or RFC 3513 section 2.2 for more details - * on presenting IPv6 addresses as text strings. - */ -int nfs_present_sockaddr(const struct sockaddr *sap, const socklen_t salen, - char *buf, const size_t buflen) -{ -#ifdef HAVE_GETNAMEINFO - int result; - - result = getnameinfo(sap, salen, buf, buflen, - NULL, 0, NI_NUMERICHOST); - if (!result) - return 1; - - nfs_error(_("%s: invalid server address: %s"), progname, - gai_strerror(result)); - return 0; -#else /* HAVE_GETNAMEINFO */ - char *addr; - - if (sap->sa_family == AF_INET) { - addr = inet_ntoa(((struct sockaddr_in *)sap)->sin_addr); - if (addr && strlen(addr) < buflen) { - strcpy(buf, addr); - return 1; - } - } - - nfs_error(_("%s: invalid server address"), progname); - return 0; -#endif /* HAVE_GETNAMEINFO */ -} - -/* - * Attempt to connect a socket, but time out after "timeout" seconds. - * - * On error return, caller closes the socket. - */ -static int connect_to(int fd, struct sockaddr *addr, - socklen_t addrlen, int timeout) -{ - int ret, saved; - fd_set rset, wset; - struct timeval tv = { - .tv_sec = timeout, - }; - - saved = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, saved | O_NONBLOCK); - - ret = connect(fd, addr, addrlen); - if (ret < 0 && errno != EINPROGRESS) - return -1; - if (ret == 0) - goto out; - - FD_ZERO(&rset); - FD_SET(fd, &rset); - wset = rset; - ret = select(fd + 1, &rset, &wset, NULL, &tv); - if (ret == 0) { - errno = ETIMEDOUT; - return -1; - } - if (FD_ISSET(fd, &rset) || FD_ISSET(fd, &wset)) { - int error; - socklen_t len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) - return -1; - if (error) { - errno = error; - return -1; - } - } else - return -1; - -out: - fcntl(fd, F_SETFL, saved); - return 0; -} - -/* - * Create a socket that is locally bound to a reserved or non-reserved port. - * - * The caller should check rpc_createerr to determine the cause of any error. - */ -static int get_socket(struct sockaddr_in *saddr, unsigned int p_prot, - unsigned int timeout, int resvp, int conn) -{ - int so, cc, type; - struct sockaddr_in laddr; - socklen_t namelen = sizeof(laddr); - - type = (p_prot == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM); - if ((so = socket (AF_INET, type, p_prot)) < 0) - goto err_socket; - - laddr.sin_family = AF_INET; - laddr.sin_port = 0; - laddr.sin_addr.s_addr = htonl(INADDR_ANY); - if (resvp) { - if (bindresvport(so, &laddr) < 0) - goto err_bindresvport; - } else { - cc = bind(so, SAFE_SOCKADDR(&laddr), namelen); - if (cc < 0) - goto err_bind; - } - if (type == SOCK_STREAM || (conn && type == SOCK_DGRAM)) { - cc = connect_to(so, SAFE_SOCKADDR(saddr), namelen, - timeout); - if (cc < 0) - goto err_connect; - } - return so; - -err_socket: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - if (verbose) { - nfs_error(_("%s: Unable to create %s socket: errno %d (%s)\n"), - progname, p_prot == IPPROTO_UDP ? _("UDP") : _("TCP"), - errno, strerror(errno)); - } - return RPC_ANYSOCK; - -err_bindresvport: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - if (verbose) { - nfs_error(_("%s: Unable to bindresvport %s socket: errno %d" - " (%s)\n"), - progname, p_prot == IPPROTO_UDP ? _("UDP") : _("TCP"), - errno, strerror(errno)); - } - close(so); - return RPC_ANYSOCK; - -err_bind: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - if (verbose) { - nfs_error(_("%s: Unable to bind to %s socket: errno %d (%s)\n"), - progname, p_prot == IPPROTO_UDP ? _("UDP") : _("TCP"), - errno, strerror(errno)); - } - close(so); - return RPC_ANYSOCK; - -err_connect: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - if (verbose) { - nfs_error(_("%s: Unable to connect to %s:%d, errno %d (%s)\n"), - progname, inet_ntoa(saddr->sin_addr), - ntohs(saddr->sin_port), errno, strerror(errno)); - } - close(so); - return RPC_ANYSOCK; -} - -static void nfs_pp_debug(const struct sockaddr *sap, const socklen_t salen, - const rpcprog_t program, const rpcvers_t version, - const unsigned short protocol, - const unsigned short port) -{ - char buf[NI_MAXHOST]; - - if (!verbose) - return; - - if (nfs_present_sockaddr(sap, salen, buf, sizeof(buf)) == 0) { - buf[0] = '\0'; - strcat(buf, "unknown host"); - } - - fprintf(stderr, _("%s: trying %s prog %lu vers %lu prot %s port %d\n"), - progname, buf, (unsigned long)program, - (unsigned long)version, - (protocol == IPPROTO_UDP ? _("UDP") : _("TCP")), - port); -} - -static void nfs_pp_debug2(const char *str) -{ - if (!verbose) - return; - - if (rpc_createerr.cf_error.re_status == RPC_CANTRECV || - rpc_createerr.cf_error.re_status == RPC_CANTSEND) - nfs_error(_("%s: portmap query %s%s - %s"), - progname, str, clnt_spcreateerror(""), - strerror(rpc_createerr.cf_error.re_errno)); - else - nfs_error(_("%s: portmap query %s%s"), - progname, str, clnt_spcreateerror("")); -} - -/* - * Use the portmapper to discover whether or not the service we want is - * available. The lists 'versions' and 'protos' define ordered sequences - * of service versions and udp/tcp protocols to probe for. - * - * Returns 1 if the requested service port is unambiguous and pingable; - * @pmap is filled in with the version, port, and transport protocol used - * during the successful ping. Note that if a port is already specified - * in @pmap and it matches the rpcbind query result, nfs_probe_port() does - * not perform an RPC ping. - * - * If an error occurs or the requested service isn't available, zero is - * returned; rpccreateerr.cf_stat is set to reflect the nature of the error. - */ -static int nfs_probe_port(const struct sockaddr *sap, const socklen_t salen, - struct pmap *pmap, const unsigned long *versions, - const unsigned int *protos) -{ - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - const unsigned long prog = pmap->pm_prog, *p_vers; - const unsigned int prot = (u_int)pmap->pm_prot, *p_prot; - const u_short port = (u_short) pmap->pm_port; - unsigned long vers = pmap->pm_vers; - unsigned short p_port; - - memcpy(saddr, sap, salen); - p_prot = prot ? &prot : protos; - p_vers = vers ? &vers : versions; - - for (;;) { - if (verbose) - printf(_("%s: prog %lu, trying vers=%lu, prot=%u\n"), - progname, prog, *p_vers, *p_prot); - p_port = nfs_getport(saddr, salen, prog, *p_vers, *p_prot); - if (p_port) { - if (!port || port == p_port) { - nfs_set_port(saddr, p_port); - nfs_pp_debug(saddr, salen, prog, *p_vers, - *p_prot, p_port); - if (nfs_rpc_ping(saddr, salen, prog, - *p_vers, *p_prot, NULL)) - goto out_ok; - } else - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - } - if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED && - rpc_createerr.cf_stat != RPC_TIMEDOUT && - rpc_createerr.cf_stat != RPC_CANTRECV && - rpc_createerr.cf_stat != RPC_PROGVERSMISMATCH) - break; - - if (!prot) { - if (*++p_prot) { - nfs_pp_debug2("retrying"); - continue; - } - p_prot = protos; - } - if (rpc_createerr.cf_stat == RPC_TIMEDOUT || - rpc_createerr.cf_stat == RPC_CANTRECV) - break; - - if (vers || !*++p_vers) - break; - } - - nfs_pp_debug2("failed"); - return 0; - -out_ok: - if (!vers) - pmap->pm_vers = *p_vers; - if (!prot) - pmap->pm_prot = *p_prot; - if (!port) - pmap->pm_port = p_port; - nfs_clear_rpc_createerr(); - return 1; -} -/* - * Probe a server's NFS service to determine which versions and - * transport protocols are supported. - * - * Returns 1 if the requested service port is unambiguous and pingable; - * @pmap is filled in with the version, port, and transport protocol used - * during the successful ping. If all three are already specified, simply - * return success without an rpcbind query or RPC ping (we may be trying - * to mount an NFS service that is not advertised via rpcbind). - * - * If an error occurs or the requested service isn't available, zero is - * returned; rpccreateerr.cf_stat is set to reflect the nature of the error. - */ -static int nfs_probe_nfsport(const struct sockaddr *sap, const socklen_t salen, - struct pmap *pmap, int checkv4) -{ - if (pmap->pm_vers && pmap->pm_prot && pmap->pm_port) - return 1; - - if (nfs_mount_data_version >= 4) { - const unsigned int *probe_proto; - int ret; - struct sockaddr_storage save_sa; - - probe_proto = nfs_default_proto(); - memcpy(&save_sa, sap, salen); - - ret = nfs_probe_port(sap, salen, pmap, - probe_nfs3_only, probe_proto); - if (!ret || !checkv4 || probe_proto != probe_tcp_first) - return ret; - - nfs_set_port((struct sockaddr *)&save_sa, NFS_PORT); - ret = nfs_rpc_ping((struct sockaddr *)&save_sa, salen, - NFS_PROGRAM, 4, IPPROTO_TCP, NULL); - if (ret) { - rpc_createerr.cf_stat = RPC_FAILED; - rpc_createerr.cf_error.re_errno = EAGAIN; - return 0; - } - return 1; - } else - return nfs_probe_port(sap, salen, pmap, - probe_nfs2_only, probe_udp_only); -} - -/* - * Probe a server's mountd service to determine which versions and - * transport protocols are supported. - * - * Returns 1 if the requested service port is unambiguous and pingable; - * @pmap is filled in with the version, port, and transport protocol used - * during the successful ping. If all three are already specified, simply - * return success without an rpcbind query or RPC ping (we may be trying - * to mount an NFS service that is not advertised via rpcbind). - * - * If an error occurs or the requested service isn't available, zero is - * returned; rpccreateerr.cf_stat is set to reflect the nature of the error. - */ -static int nfs_probe_mntport(const struct sockaddr *sap, const socklen_t salen, - struct pmap *pmap) -{ - if (pmap->pm_vers && pmap->pm_prot && pmap->pm_port) - return 1; - - if (nfs_mount_data_version >= 4) - return nfs_probe_port(sap, salen, pmap, - probe_mnt3_only, probe_udp_first); - else - return nfs_probe_port(sap, salen, pmap, - probe_mnt1_first, probe_udp_only); -} - -/* - * Probe a server's mountd service to determine which versions and - * transport protocols are supported. Invoked when the protocol - * version is already known for both the NFS and mountd service. - * - * Returns 1 and fills in both @pmap structs if the requested service - * ports are unambiguous and pingable. Otherwise zero is returned; - * rpccreateerr.cf_stat is set to reflect the nature of the error. - */ -static int nfs_probe_version_fixed(const struct sockaddr *mnt_saddr, - const socklen_t mnt_salen, - struct pmap *mnt_pmap, - const struct sockaddr *nfs_saddr, - const socklen_t nfs_salen, - struct pmap *nfs_pmap) -{ - if (!nfs_probe_nfsport(nfs_saddr, nfs_salen, nfs_pmap, 0)) - return 0; - return nfs_probe_mntport(mnt_saddr, mnt_salen, mnt_pmap); -} - -/** - * nfs_probe_bothports - discover the RPC endpoints of mountd and NFS server - * @mnt_saddr: pointer to socket address of mountd server - * @mnt_salen: length of mountd server's address - * @mnt_pmap: IN: partially filled-in mountd RPC service tuple; - * OUT: fully filled-in mountd RPC service tuple - * @nfs_saddr: pointer to socket address of NFS server - * @nfs_salen: length of NFS server's address - * @nfs_pmap: IN: partially filled-in NFS RPC service tuple; - * OUT: fully filled-in NFS RPC service tuple - * @checkv4: Flag indicating that if v3 is available we must also - * check v4, and if that is available, set re_errno to EAGAIN. - * - * Returns 1 and fills in both @pmap structs if the requested service - * ports are unambiguous and pingable. Otherwise zero is returned; - * rpccreateerr.cf_stat is set to reflect the nature of the error. - */ -int nfs_probe_bothports(const struct sockaddr *mnt_saddr, - const socklen_t mnt_salen, - struct pmap *mnt_pmap, - const struct sockaddr *nfs_saddr, - const socklen_t nfs_salen, - struct pmap *nfs_pmap, - int checkv4) -{ - struct pmap save_nfs, save_mnt; - const unsigned long *probe_vers; - - if (mnt_pmap->pm_vers && !nfs_pmap->pm_vers) - nfs_pmap->pm_vers = mntvers_to_nfs(mnt_pmap->pm_vers); - else if (nfs_pmap->pm_vers && !mnt_pmap->pm_vers) - mnt_pmap->pm_vers = nfsvers_to_mnt(nfs_pmap->pm_vers); - - if (nfs_pmap->pm_vers) - return nfs_probe_version_fixed(mnt_saddr, mnt_salen, mnt_pmap, - nfs_saddr, nfs_salen, nfs_pmap); - - memcpy(&save_nfs, nfs_pmap, sizeof(save_nfs)); - memcpy(&save_mnt, mnt_pmap, sizeof(save_mnt)); - probe_vers = (nfs_mount_data_version >= 4) ? - probe_mnt3_only : probe_mnt1_first; - - for (; *probe_vers; probe_vers++) { - nfs_pmap->pm_vers = mntvers_to_nfs(*probe_vers); - if (nfs_probe_nfsport(nfs_saddr, nfs_salen, nfs_pmap, checkv4) != 0) { - mnt_pmap->pm_vers = *probe_vers; - if (nfs_probe_mntport(mnt_saddr, mnt_salen, mnt_pmap) != 0) - return 1; - memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap)); - } - switch (rpc_createerr.cf_stat) { - case RPC_PROGVERSMISMATCH: - case RPC_PROGNOTREGISTERED: - break; - default: - return 0; - } - memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap)); - } - - return 0; -} - -/** - * probe_bothports - discover the RPC endpoints of mountd and NFS server - * @mnt_server: pointer to address and pmap argument for mountd results - * @nfs_server: pointer to address and pmap argument for NFS server - * - * This is the legacy API that takes "clnt_addr_t" for both servers, - * but supports only AF_INET addresses. - * - * Returns 1 and fills in the pmap field in both clnt_addr_t structs - * if the requested service ports are unambiguous and pingable. - * Otherwise zero is returned; rpccreateerr.cf_stat is set to reflect - * the nature of the error. - */ -int probe_bothports(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server) -{ - struct sockaddr *mnt_addr = SAFE_SOCKADDR(&mnt_server->saddr); - struct sockaddr *nfs_addr = SAFE_SOCKADDR(&nfs_server->saddr); - - return nfs_probe_bothports(mnt_addr, sizeof(mnt_server->saddr), - &mnt_server->pmap, - nfs_addr, sizeof(nfs_server->saddr), - &nfs_server->pmap, 0); -} - -/** - * start_statd - attempt to start rpc.statd - * - * Returns 1 if statd is running; otherwise zero. - */ -int start_statd(void) -{ -#ifdef START_STATD - struct stat stb; -#endif - - if (nfs_probe_statd()) - return 1; - -#ifdef START_STATD - if (stat(START_STATD, &stb) == 0) { - if (S_ISREG(stb.st_mode) && (stb.st_mode & S_IXUSR)) { - int cnt = STATD_TIMEOUT * 10; - int status = 0; - char * const envp[1] = { NULL }; - const struct timespec ts = { - .tv_sec = 0, - .tv_nsec = 100000000, - }; - pid_t pid = fork(); - switch (pid) { - case 0: /* child */ - setgroups(0, NULL); - if (setgid(0) < 0) - nfs_error(_("%s: setgid(0) failed: %s"), - progname, strerror(errno)); - if (setuid(0) < 0) - nfs_error(_("%s: setuid(0) failed: %s"), - progname, strerror(errno)); - execle(START_STATD, START_STATD, NULL, envp); - exit(1); - case -1: /* error */ - nfs_error(_("%s: fork failed: %s"), - progname, strerror(errno)); - break; - default: /* parent */ - if (waitpid(pid, &status,0) == pid && - status == 0) - /* assume it worked */ - return 1; - break; - } - while (1) { - if (nfs_probe_statd()) - return 1; - if (! cnt--) - return 0; - nanosleep(&ts, NULL); - } - } - } -#endif - - return 0; -} - -/** - * nfs_advise_umount - ask the server to remove a share from it's rmtab - * @sap: pointer to IP address of server to call - * @salen: length of server address - * @pmap: partially filled-in mountd RPC service tuple - * @argp: directory path of share to "unmount" - * - * Returns one if the unmount call succeeded; zero if the unmount - * failed for any reason; rpccreateerr.cf_stat is set to reflect - * the nature of the error. - * - * We use a fast timeout since this call is advisory only. - */ -int nfs_advise_umount(const struct sockaddr *sap, const socklen_t salen, - const struct pmap *pmap, const dirpath *argp) -{ - union nfs_sockaddr address; - struct sockaddr *saddr = &address.sa; - struct pmap mnt_pmap = *pmap; - struct timeval timeout = { - .tv_sec = MOUNT_TIMEOUT >> 3, - }; - CLIENT *client; - enum clnt_stat res = 0; - - memcpy(saddr, sap, salen); - if (nfs_probe_mntport(saddr, salen, &mnt_pmap) == 0) { - if (verbose) - nfs_error(_("%s: Failed to discover mountd port%s"), - progname, clnt_spcreateerror("")); - return 0; - } - nfs_set_port(saddr, mnt_pmap.pm_port); - - client = nfs_get_priv_rpcclient(saddr, salen, mnt_pmap.pm_prot, - mnt_pmap.pm_prog, mnt_pmap.pm_vers, - &timeout); - if (client == NULL) { - if (verbose) - nfs_error(_("%s: Failed to create RPC client%s"), - progname, clnt_spcreateerror("")); - return 0; - } - - client->cl_auth = nfs_authsys_create(); - if (client->cl_auth == NULL) { - if (verbose) - nfs_error(_("%s: Failed to create RPC auth handle"), - progname); - CLNT_DESTROY(client); - return 0; - } - - res = CLNT_CALL(client, MOUNTPROC_UMNT, - (xdrproc_t)xdr_dirpath, (caddr_t)argp, - (xdrproc_t)xdr_void, NULL, - timeout); - if (res != RPC_SUCCESS) { - rpc_createerr.cf_stat = res; - CLNT_GETERR(client, &rpc_createerr.cf_error); - if (verbose) - nfs_error(_("%s: UMNT call failed: %s"), - progname, clnt_sperrno(res)); - - } - auth_destroy(client->cl_auth); - CLNT_DESTROY(client); - - if (res != RPC_SUCCESS) - return 0; - return 1; -} - -/** - * nfs_call_umount - ask the server to remove a share from it's rmtab - * @mnt_server: address of RPC MNT program server - * @argp: directory path of share to "unmount" - * - * Returns one if the unmount call succeeded; zero if the unmount - * failed for any reason. - * - * Note that a side effect of calling this function is that rpccreateerr - * is set. - */ -int nfs_call_umount(clnt_addr_t *mnt_server, dirpath *argp) -{ - struct sockaddr *sap = SAFE_SOCKADDR(&mnt_server->saddr); - socklen_t salen = sizeof(mnt_server->saddr); - struct pmap *pmap = &mnt_server->pmap; - CLIENT *clnt; - enum clnt_stat res = 0; - int msock; - - if (!nfs_probe_mntport(sap, salen, pmap)) - return 0; - clnt = mnt_openclnt(mnt_server, &msock); - if (!clnt) - return 0; - res = clnt_call(clnt, MOUNTPROC_UMNT, - (xdrproc_t)xdr_dirpath, (caddr_t)argp, - (xdrproc_t)xdr_void, NULL, - TIMEOUT); - mnt_closeclnt(clnt, msock); - - if (res == RPC_SUCCESS) - return 1; - return 0; -} - -/** - * mnt_openclnt - get a handle for a remote mountd service - * @mnt_server: address and pmap arguments of mountd service - * @msock: returns a file descriptor of the underlying transport socket - * - * Returns an active handle for the remote's mountd service - */ -CLIENT *mnt_openclnt(clnt_addr_t *mnt_server, int *msock) -{ - struct sockaddr_in *mnt_saddr = &mnt_server->saddr; - struct pmap *mnt_pmap = &mnt_server->pmap; - CLIENT *clnt = NULL; - - mnt_saddr->sin_port = htons((u_short)mnt_pmap->pm_port); - *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, MOUNT_TIMEOUT, - TRUE, FALSE); - if (*msock == RPC_ANYSOCK) { - if (rpc_createerr.cf_error.re_errno == EADDRINUSE) - /* - * Probably in-use by a TIME_WAIT connection, - * It is worth waiting a while and trying again. - */ - rpc_createerr.cf_stat = RPC_TIMEDOUT; - return NULL; - } - - switch (mnt_pmap->pm_prot) { - case IPPROTO_UDP: - clnt = clntudp_bufcreate(mnt_saddr, - mnt_pmap->pm_prog, mnt_pmap->pm_vers, - RETRY_TIMEOUT, msock, - MNT_SENDBUFSIZE, MNT_RECVBUFSIZE); - break; - case IPPROTO_TCP: - clnt = clnttcp_create(mnt_saddr, - mnt_pmap->pm_prog, mnt_pmap->pm_vers, - msock, - MNT_SENDBUFSIZE, MNT_RECVBUFSIZE); - break; - } - if (clnt) { - /* try to mount hostname:dirname */ - clnt->cl_auth = nfs_authsys_create(); - if (clnt->cl_auth) - return clnt; - CLNT_DESTROY(clnt); - } - return NULL; -} - -/** - * mnt_closeclnt - terminate a handle for a remote mountd service - * @clnt: pointer to an active handle for a remote mountd service - * @msock: file descriptor of the underlying transport socket - * - */ -void mnt_closeclnt(CLIENT *clnt, int msock) -{ - auth_destroy(clnt->cl_auth); - clnt_destroy(clnt); - close(msock); -} - -/** - * clnt_ping - send an RPC ping to the remote RPC service endpoint - * @saddr: server's address - * @prog: target RPC program number - * @vers: target RPC version number - * @prot: target RPC protocol - * @caddr: filled in with our network address - * - * Sigh... GETPORT queries don't actually check the version number. - * In order to make sure that the server actually supports the service - * we're requesting, we open an RPC client, and fire off a NULL - * RPC call. - * - * caddr is the network address that the server will use to call us back. - * On multi-homed clients, this address depends on which NIC we use to - * route requests to the server. - * - * Returns one if successful, otherwise zero. - */ -int clnt_ping(struct sockaddr_in *saddr, const unsigned long prog, - const unsigned long vers, const unsigned int prot, - struct sockaddr_in *caddr) -{ - CLIENT *clnt = NULL; - int sock, status; - static char clnt_res; - struct sockaddr dissolve; - - rpc_createerr.cf_stat = status = 0; - sock = get_socket(saddr, prot, CONNECT_TIMEOUT, FALSE, TRUE); - if (sock == RPC_ANYSOCK) { - if (rpc_createerr.cf_error.re_errno == ETIMEDOUT) { - /* - * TCP timeout. Bubble up the error to see - * how it should be handled. - */ - rpc_createerr.cf_stat = RPC_TIMEDOUT; - } - return 0; - } - - if (caddr) { - /* Get the address of our end of this connection */ - socklen_t len = sizeof(*caddr); - if (getsockname(sock, (struct sockaddr *) caddr, &len) != 0) - caddr->sin_family = 0; - } - - switch(prot) { - case IPPROTO_UDP: - /* The socket is connected (so we could getsockname successfully), - * but some servers on multi-homed hosts reply from - * the wrong address, so if we stay connected, we lose the reply. - */ - dissolve.sa_family = AF_UNSPEC; - connect(sock, &dissolve, sizeof(dissolve)); - - clnt = clntudp_bufcreate(saddr, prog, vers, - RETRY_TIMEOUT, &sock, - RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - break; - case IPPROTO_TCP: - clnt = clnttcp_create(saddr, prog, vers, &sock, - RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - break; - } - if (!clnt) { - close(sock); - return 0; - } - memset(&clnt_res, 0, sizeof(clnt_res)); - status = clnt_call(clnt, NULLPROC, - (xdrproc_t)xdr_void, (caddr_t)NULL, - (xdrproc_t)xdr_void, (caddr_t)&clnt_res, - TIMEOUT); - if (status) { - clnt_geterr(clnt, &rpc_createerr.cf_error); - rpc_createerr.cf_stat = status; - } - clnt_destroy(clnt); - close(sock); - - if (status == RPC_SUCCESS) - return 1; - else - return 0; -} - -/* - * Try a getsockname() on a connected datagram socket. - * - * Returns 1 and fills in @buf if successful; otherwise, zero. - * - * A connected datagram socket prevents leaving a socket in TIME_WAIT. - * This conserves the ephemeral port number space, helping reduce failed - * socket binds during mount storms. - */ -static int nfs_ca_sockname(const struct sockaddr *sap, const socklen_t salen, - struct sockaddr *buf, socklen_t *buflen) -{ - struct sockaddr_in sin = { - .sin_family = AF_INET, - .sin_addr.s_addr = htonl(INADDR_ANY), - }; - struct sockaddr_in6 sin6 = { - .sin6_family = AF_INET6, - .sin6_addr = IN6ADDR_ANY_INIT, - }; - int sock, result = 0; - int val; - - sock = socket(sap->sa_family, SOCK_DGRAM, IPPROTO_UDP); - if (sock < 0) - return 0; - - switch (sap->sa_family) { - case AF_INET: - if (bind(sock, SAFE_SOCKADDR(&sin), sizeof(sin)) < 0) - goto out; - break; - case AF_INET6: - /* Make sure the call-back address is public/permanent */ - val = IPV6_PREFER_SRC_PUBLIC; - setsockopt(sock, SOL_IPV6, IPV6_ADDR_PREFERENCES, &val, sizeof(val)); - if (bind(sock, SAFE_SOCKADDR(&sin6), sizeof(sin6)) < 0) - goto out; - break; - default: - errno = EAFNOSUPPORT; - goto out; - } - - if (connect(sock, sap, salen) < 0) - goto out; - - result = !getsockname(sock, buf, buflen); - -out: - close(sock); - return result; -} - -/* - * Try to generate an address that prevents the server from calling us. - * - * Returns 1 and fills in @buf if successful; otherwise, zero. - */ -static int nfs_ca_gai(const struct sockaddr *sap, - struct sockaddr *buf, socklen_t *buflen) -{ - struct addrinfo *gai_results; - struct addrinfo gai_hint = { - .ai_family = sap->sa_family, - .ai_flags = AI_PASSIVE, /* ANYADDR */ - }; - - if (getaddrinfo(NULL, "", &gai_hint, &gai_results)) - return 0; - - *buflen = gai_results->ai_addrlen; - memcpy(buf, gai_results->ai_addr, *buflen); - - nfs_freeaddrinfo(gai_results); - - return 1; -} - -/** - * nfs_callback_address - acquire our local network address - * @sap: pointer to address of remote - * @sap_len: length of address - * @buf: pointer to buffer to be filled in with local network address - * @buflen: IN: length of buffer to fill in; OUT: length of filled-in address - * - * Discover a network address that an NFSv4 server can use to call us back. - * On multi-homed clients, this address depends on which NIC we use to - * route requests to the server. - * - * Returns 1 and fills in @buf if an unambiguous local address is - * available; returns 1 and fills in an appropriate ANYADDR address - * if a local address isn't available; otherwise, returns zero. - */ -int nfs_callback_address(const struct sockaddr *sap, const socklen_t salen, - struct sockaddr *buf, socklen_t *buflen) -{ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf; - - if (nfs_ca_sockname(sap, salen, buf, buflen) == 0) - if (nfs_ca_gai(sap, buf, buflen) == 0) - goto out_failed; - - /* - * The server can't use an interface ID that was generated - * here on the client, so always clear sin6_scope_id. - */ - if (sin6->sin6_family == AF_INET6) - sin6->sin6_scope_id = 0; - - return 1; - -out_failed: - *buflen = 0; - if (verbose) - nfs_error(_("%s: failed to construct callback address"), - progname); - return 0; -} - -/* - * "nfsprog" is supported only by the legacy mount command. The - * kernel mount client does not support this option. - * - * Returns TRUE if @program contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -static int -nfs_nfs_program(struct mount_options *options, unsigned long *program) -{ - long tmp; - - switch (po_get_numeric(options, "nfsprog", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp > 0) { - *program = tmp; - return 1; - } - /* FALLTHRU */ - case PO_BAD_VALUE: - nfs_error(_("%s: invalid value for 'nfsprog=' option"), - progname); - return 0; - } - - /* - * NFS RPC program wasn't specified. The RPC program - * cannot be determined via an rpcbind query. - */ - *program = nfs_getrpcbyname(NFSPROG, nfs_nfs_pgmtbl); - return 1; -} - -/* - * Returns TRUE if @version contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -int -nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *version) -{ - char *version_key, *version_val = NULL, *cptr; - int i, found = 0; - - version->v_mode = V_DEFAULT; - - for (i = 0; nfs_version_opttbl[i]; i++) { - if (po_contains_prefix(options, nfs_version_opttbl[i], - &version_key) == PO_FOUND) { - found++; - break; - } - } - - if (!found && strcmp(type, "nfs4") == 0) - version_val = type + 3; - else if (!found) - return 1; - else if (i <= 2 ) { - /* v2, v3, v4 */ - version_val = version_key + 1; - version->v_mode = V_SPECIFIC; - } else if (i > 2 ) { - /* vers=, nfsvers= */ - version_val = po_get(options, version_key); - } - - if (!version_val) - goto ret_error; - - version->major = strtol(version_val, &cptr, 10); - if (cptr == version_val || (*cptr && *cptr != '.')) - goto ret_error; - if (version->major == 4 && *cptr != '.' && - (version_val = po_get(options, "minorversion")) != NULL) { - version->minor = strtol(version_val, &cptr, 10); - i = -1; - if (*cptr) - goto ret_error; - version->v_mode = V_SPECIFIC; - } else if (version->major < 4) - version->v_mode = V_SPECIFIC; - else if (*cptr == '.') { - version_val = ++cptr; - if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val) - goto ret_error; - version->v_mode = V_SPECIFIC; - } else if (version->major > 3 && *cptr == '\0') { - version_val = po_get(options, "minorversion"); - if (version_val != NULL) { - version->minor = strtol(version_val, &cptr, 10); - version->v_mode = V_SPECIFIC; - } else - version->v_mode = V_GENERAL; - } - if (*cptr != '\0') - goto ret_error; - - return 1; - -ret_error: - if (i < 0) { - nfs_error(_("%s: parsing error on 'minorversion=' option"), - progname); - } else if (i <= 2 ) { - nfs_error(_("%s: parsing error on 'v' option"), - progname); - } else if (i == 3 ) { - nfs_error(_("%s: parsing error on 'vers=' option"), - progname); - } else if (i == 4) { - nfs_error(_("%s: parsing error on 'nfsvers=' option"), - progname); - } - version->v_mode = V_PARSE_ERR; - errno = EINVAL; - return 0; -} - -/* - * Returns TRUE if @protocol contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. On - * error, errno is set. - */ -int -nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol) -{ - sa_family_t family; - char *option; - - switch (po_rightmost(options, nfs_transport_opttbl)) { - case 0: /* udp */ - *protocol = IPPROTO_UDP; - return 1; - case 1: /* tcp */ - *protocol = IPPROTO_TCP; - return 1; - case 2: /* rdma */ - *protocol = NFSPROTO_RDMA; - return 1; - case 3: /* proto */ - option = po_get(options, "proto"); - if (option != NULL) { - if (!nfs_get_proto(option, &family, protocol)) { - errno = EPROTONOSUPPORT; - nfs_error(_("%s: Failed to find '%s' protocol"), - progname, option); - return 0; - } - return 1; - } - } - - /* - * NFS transport protocol wasn't specified. The pmap - * protocol value will be filled in later by an rpcbind - * query in this case. - */ - *protocol = 0; - return 1; -} - -/* - * Returns TRUE if @port contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -static int -nfs_nfs_port(struct mount_options *options, unsigned long *port) -{ - long tmp; - - switch (po_get_numeric(options, "port", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp >= 0 && tmp <= 65535) { - *port = tmp; - return 1; - } - /* FALLTHRU */ - case PO_BAD_VALUE: - nfs_error(_("%s: invalid value for 'port=' option"), - progname); - return 0; - } - - /* - * NFS service port wasn't specified. The pmap port value - * will be filled in later by an rpcbind query in this case. - */ - *port = 0; - return 1; -} - -#ifdef IPV6_SUPPORTED -sa_family_t config_default_family = AF_UNSPEC; - -static int -nfs_verify_family(sa_family_t UNUSED(family)) -{ - return 1; -} -#else /* IPV6_SUPPORTED */ -sa_family_t config_default_family = AF_INET; - -static int -nfs_verify_family(sa_family_t family) -{ - if (family != AF_INET) - return 0; - - return 1; -} -#endif /* IPV6_SUPPORTED */ - -/* - * Returns TRUE and fills in @family if a valid NFS protocol option - * is found, or FALSE if the option was specified with an invalid value - * or if the protocol family isn't supported. On error, errno is set. - */ -int nfs_nfs_proto_family(struct mount_options *options, - sa_family_t *family) -{ - unsigned long protocol; - char *option; - sa_family_t tmp_family = config_default_family; - - switch (po_rightmost(options, nfs_transport_opttbl)) { - case 0: /* udp */ - case 1: /* tcp */ - case 2: /* rdma */ - /* for compatibility; these are always AF_INET */ - *family = AF_INET; - return 1; - case 3: /* proto */ - option = po_get(options, "proto"); - if (option != NULL && - !nfs_get_proto(option, &tmp_family, &protocol)) { - - nfs_error(_("%s: Failed to find '%s' protocol"), - progname, option); - errno = EPROTONOSUPPORT; - return 0; - } - } - - if (!nfs_verify_family(tmp_family)) - goto out_err; - *family = tmp_family; - return 1; -out_err: - errno = EAFNOSUPPORT; - return 0; -} - -/* - * "mountprog" is supported only by the legacy mount command. The - * kernel mount client does not support this option. - * - * Returns TRUE if @program contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -static int -nfs_mount_program(struct mount_options *options, unsigned long *program) -{ - long tmp; - - switch (po_get_numeric(options, "mountprog", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp > 0) { - *program = tmp; - return 1; - } - /* FALLTHRU */ - case PO_BAD_VALUE: - nfs_error(_("%s: invalid value for 'mountprog=' option"), - progname); - return 0; - } - - /* - * MNT RPC program wasn't specified. The RPC program - * cannot be determined via an rpcbind query. - */ - *program = nfs_getrpcbyname(MOUNTPROG, nfs_mnt_pgmtbl); - return 1; -} - -/* - * Returns TRUE if @version contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -static int -nfs_mount_version(struct mount_options *options, unsigned long *version) -{ - long tmp; - - switch (po_get_numeric(options, "mountvers", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp >= 1 && tmp <= 4) { - *version = tmp; - return 1; - } - /* FALLTHRU */ - case PO_BAD_VALUE: - nfs_error(_("%s: invalid value for 'mountvers=' option"), - progname); - return 0; - } - - /* - * MNT version wasn't specified. The pmap version value - * will be filled in later by an rpcbind query in this case. - */ - *version = 0; - return 1; -} - -/* - * Returns TRUE if @protocol contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. On - * error, errno is set. - */ -static int -nfs_mount_protocol(struct mount_options *options, unsigned long *protocol) -{ - sa_family_t family; - char *option; - - option = po_get(options, "mountproto"); - if (option != NULL) { - if (!nfs_get_proto(option, &family, protocol)) { - errno = EPROTONOSUPPORT; - nfs_error(_("%s: Failed to find '%s' protocol"), - progname, option); - return 0; - } - return 1; - } - - /* - * MNT transport protocol wasn't specified. If the NFS - * transport protocol was specified, use that; otherwise - * set @protocol to zero. The pmap protocol value will - * be filled in later by an rpcbind query in this case. - */ - if (!nfs_nfs_protocol(options, protocol)) - return 0; - if (*protocol == NFSPROTO_RDMA) - *protocol = IPPROTO_TCP; - return 1; -} - -/* - * Returns TRUE if @port contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. - */ -static int -nfs_mount_port(struct mount_options *options, unsigned long *port) -{ - long tmp; - - switch (po_get_numeric(options, "mountport", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp >= 0 && tmp <= 65535) { - *port = tmp; - return 1; - } - /* FALLTHRU */ - case PO_BAD_VALUE: - nfs_error(_("%s: invalid value for 'mountport=' option"), - progname); - return 0; - } - - /* - * MNT service port wasn't specified. The pmap port value - * will be filled in later by an rpcbind query in this case. - */ - *port = 0; - return 1; -} - -/* - * Returns TRUE and fills in @family if a valid MNT protocol option - * is found, or FALSE if the option was specified with an invalid value - * or if the protocol family isn't supported. On error, errno is set. - */ -int nfs_mount_proto_family(struct mount_options *options, - sa_family_t *family) -{ - unsigned long protocol; - char *option; - sa_family_t tmp_family = config_default_family; - - option = po_get(options, "mountproto"); - if (option != NULL) { - if (!nfs_get_proto(option, &tmp_family, &protocol)) { - nfs_error(_("%s: Failed to find '%s' protocol"), - progname, option); - errno = EPROTONOSUPPORT; - goto out_err; - } - if (!nfs_verify_family(tmp_family)) - goto out_err; - *family = tmp_family; - return 1; - } - - /* - * MNT transport protocol wasn't specified. If the NFS - * transport protocol was specified, derive the family - * from that; otherwise, return the default family for - * NFS. - */ - return nfs_nfs_proto_family(options, family); -out_err: - errno = EAFNOSUPPORT; - return 0; -} - -/** - * nfs_options2pmap - set up pmap structs based on mount options - * @options: pointer to mount options - * @nfs_pmap: OUT: pointer to pmap arguments for NFS server - * @mnt_pmap: OUT: pointer to pmap arguments for mountd server - * - * Returns TRUE if the pmap options specified in @options have valid - * values; otherwise FALSE is returned. - */ -int nfs_options2pmap(struct mount_options *options, - struct pmap *nfs_pmap, struct pmap *mnt_pmap) -{ - struct nfs_version version; - memset(&version, 0, sizeof(version)); - - if (!nfs_nfs_program(options, &nfs_pmap->pm_prog)) - return 0; - if (!nfs_nfs_version("nfs", options, &version)) - return 0; - if (version.v_mode == V_DEFAULT) - nfs_pmap->pm_vers = 0; - else - nfs_pmap->pm_vers = version.major; - if (!nfs_nfs_protocol(options, &nfs_pmap->pm_prot)) - return 0; - if (!nfs_nfs_port(options, &nfs_pmap->pm_port)) - return 0; - - if (!nfs_mount_program(options, &mnt_pmap->pm_prog)) - return 0; - if (!nfs_mount_version(options, &mnt_pmap->pm_vers)) - return 0; - if (!nfs_mount_protocol(options, &mnt_pmap->pm_prot)) - return 0; - if (!nfs_mount_port(options, &mnt_pmap->pm_port)) - return 0; - - return 1; -} - -/* - * Discover mount server's hostname/address by examining mount options - * - * Returns a pointer to a string that the caller must free, on - * success; otherwise NULL is returned. - */ -static char *nfs_umount_hostname(struct mount_options *options, - char *hostname) -{ - char *option; - - option = po_get(options, "mountaddr"); - if (option) - goto out; - option = po_get(options, "mounthost"); - if (option) - goto out; - option = po_get(options, "addr"); - if (option) - goto out; - - return hostname; - -out: - free(hostname); - return strdup(option); -} - - -/* - * Returns EX_SUCCESS if mount options and device name have been - * parsed successfully; otherwise EX_FAIL. - */ -int nfs_umount_do_umnt(struct mount_options *options, - char **hostname, char **dirname) -{ - union nfs_sockaddr address; - struct sockaddr *sap = &address.sa; - socklen_t salen = sizeof(address); - struct pmap nfs_pmap, mnt_pmap; - sa_family_t family; - - if (!nfs_options2pmap(options, &nfs_pmap, &mnt_pmap)) - return EX_FAIL; - - /* Skip UMNT call for vers=4 mounts */ - if (nfs_pmap.pm_vers == 4) - return EX_SUCCESS; - - *hostname = nfs_umount_hostname(options, *hostname); - if (!*hostname) { - nfs_error(_("%s: out of memory"), progname); - return EX_FAIL; - } - - if (!nfs_mount_proto_family(options, &family)) - return 0; - if (!nfs_lookup(*hostname, family, sap, &salen)) - /* nfs_lookup reports any errors */ - return EX_FAIL; - - if (nfs_advise_umount(sap, salen, &mnt_pmap, dirname) == 0) - /* nfs_advise_umount reports any errors */ - return EX_FAIL; - - return EX_SUCCESS; -} - -int nfs_is_inaddr_any(struct sockaddr *nfs_saddr) -{ - switch (nfs_saddr->sa_family) { - case AF_INET: { - if (((struct sockaddr_in *)nfs_saddr)->sin_addr.s_addr == - INADDR_ANY) - return 1; - break; - } - case AF_INET6: - if (!memcmp(&((struct sockaddr_in6 *)nfs_saddr)->sin6_addr, - &in6addr_any, sizeof(in6addr_any))) - return 1; - break; - } - return 0; -} - -int nfs_addr_matches_localips(struct sockaddr *nfs_saddr) -{ - struct ifaddrs *myaddrs, *ifa; - int found = 0; - - /* acquire exiting network interfaces */ - if (getifaddrs(&myaddrs) != 0) - return 0; - - /* interate over the available interfaces and check if we - * we find a match to the supplied clientaddr value - */ - for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr == NULL) - continue; - if (!(ifa->ifa_flags & IFF_UP)) - continue; - if (!memcmp(ifa->ifa_addr, nfs_saddr, - sizeof(struct sockaddr))) { - found = 1; - break; - } - } - freeifaddrs(myaddrs); - return found; -} diff --git a/nfs-utils-2.5.2/utils/mount/network.h b/nfs-utils-2.5.2/utils/mount/network.h deleted file mode 100644 index 0fc98ac..0000000 --- a/nfs-utils-2.5.2/utils/mount/network.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * network.h -- Provide common network functions for NFS mount/umount - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_NETWORK_H -#define _NFS_UTILS_MOUNT_NETWORK_H - -#include - -#define MNT_SENDBUFSIZE (2048U) -#define MNT_RECVBUFSIZE (1024U) - -typedef struct { - char **hostname; - struct sockaddr_in saddr; - struct pmap pmap; -} clnt_addr_t; - -/* RPC call timeout values */ -static const struct timeval TIMEOUT = { 20, 0 }; -static const struct timeval RETRY_TIMEOUT = { 3, 0 }; - -int probe_bothports(clnt_addr_t *, clnt_addr_t *); -int nfs_probe_bothports(const struct sockaddr *, const socklen_t, - struct pmap *, const struct sockaddr *, - const socklen_t, struct pmap *, int); -int nfs_gethostbyname(const char *, struct sockaddr_in *); -int nfs_lookup(const char *hostname, const sa_family_t family, - struct sockaddr *sap, socklen_t *salen); -int nfs_string_to_sockaddr(const char *, struct sockaddr *, socklen_t *); -int nfs_present_sockaddr(const struct sockaddr *, - const socklen_t, char *, const size_t); -int nfs_callback_address(const struct sockaddr *, const socklen_t, - struct sockaddr *, socklen_t *); -int clnt_ping(struct sockaddr_in *, const unsigned long, - const unsigned long, const unsigned int, - struct sockaddr_in *); -int nfs_is_inaddr_any(struct sockaddr *); -int nfs_addr_matches_localips(struct sockaddr *); - -struct mount_options; - -enum { - V_DEFAULT = 0, - V_GENERAL, - V_SPECIFIC, - V_PARSE_ERR, -}; - -struct nfs_version { - unsigned long major; - unsigned long minor; - int v_mode; -}; - -int nfs_nfs_proto_family(struct mount_options *options, sa_family_t *family); -int nfs_mount_proto_family(struct mount_options *options, sa_family_t *family); -int nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *version); -int nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol); - -int nfs_options2pmap(struct mount_options *, - struct pmap *, struct pmap *); - -int start_statd(void); - -unsigned long nfsvers_to_mnt(const unsigned long); - -int nfs_call_umount(clnt_addr_t *, dirpath *); -int nfs_advise_umount(const struct sockaddr *, const socklen_t, - const struct pmap *, const dirpath *); -CLIENT *mnt_openclnt(clnt_addr_t *, int *); -void mnt_closeclnt(CLIENT *, int); - -int nfs_umount_do_umnt(struct mount_options *options, - char **hostname, char **dirname); - -#endif /* _NFS_UTILS_MOUNT_NETWORK_H */ diff --git a/nfs-utils-2.5.2/utils/mount/nfs.man b/nfs-utils-2.5.2/utils/mount/nfs.man deleted file mode 100644 index 19fe22f..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfs.man +++ /dev/null @@ -1,1904 +0,0 @@ -.\"@(#)nfs.5" -.TH NFS 5 "9 October 2012" -.SH NAME -nfs \- fstab format and options for the -.B nfs -file systems -.SH SYNOPSIS -.I /etc/fstab -.SH DESCRIPTION -NFS is an Internet Standard protocol -created by Sun Microsystems in 1984. NFS was developed -to allow file sharing between systems residing -on a local area network. -Depending on kernel configuration, the Linux NFS client may -support NFS versions 2, 3, 4.0, 4.1, or 4.2. -.P -The -.BR mount (8) -command attaches a file system to the system's -name space hierarchy at a given mount point. -The -.I /etc/fstab -file describes how -.BR mount (8) -should assemble a system's file name hierarchy -from various independent file systems -(including file systems exported by NFS servers). -Each line in the -.I /etc/fstab -file describes a single file system, its mount point, -and a set of default mount options for that mount point. -.P -For NFS file system mounts, a line in the -.I /etc/fstab -file specifies the server name, -the path name of the exported server directory to mount, -the local directory that is the mount point, -the type of file system that is being mounted, -and a list of mount options that control -the way the filesystem is mounted and -how the NFS client behaves when accessing -files on this mount point. -The fifth and sixth fields on each line are not used -by NFS, thus conventionally each contain the digit zero. For example: -.P -.nf -.ta 8n +14n +14n +9n +20n - server:path /mountpoint fstype option,option,... 0 0 -.fi -.P -The server's hostname and export pathname -are separated by a colon, while -the mount options are separated by commas. The remaining fields -are separated by blanks or tabs. -.P -The server's hostname can be an unqualified hostname, -a fully qualified domain name, -a dotted quad IPv4 address, or -an IPv6 address enclosed in square brackets. -Link-local and site-local IPv6 addresses must be accompanied by an -interface identifier. -See -.BR ipv6 (7) -for details on specifying raw IPv6 addresses. -.P -The -.I fstype -field contains "nfs". Use of the "nfs4" fstype in -.I /etc/fstab -is deprecated. -.SH "MOUNT OPTIONS" -Refer to -.BR mount (8) -for a description of generic mount options -available for all file systems. If you do not need to -specify any mount options, use the generic option -.B defaults -in -.IR /etc/fstab . -.DT -.SS "Options supported by all versions" -These options are valid to use with any NFS version. -.TP 1.5i -.BI nfsvers= n -The NFS protocol version number used to contact the server's NFS service. -If the server does not support the requested version, the mount request -fails. -If this option is not specified, the client tries version 4.2 first, -then negotiates down until it finds a version supported by the server. -.TP 1.5i -.BI vers= n -This option is an alternative to the -.B nfsvers -option. -It is included for compatibility with other operating systems -.TP 1.5i -.BR soft " / " hard -Determines the recovery behavior of the NFS client -after an NFS request times out. -If neither option is specified (or if the -.B hard -option is specified), NFS requests are retried indefinitely. -If the -.B soft -option is specified, then the NFS client fails an NFS request -after -.B retrans -retransmissions have been sent, -causing the NFS client to return an error -to the calling application. -.IP -.I NB: -A so-called "soft" timeout can cause -silent data corruption in certain cases. As such, use the -.B soft -option only when client responsiveness -is more important than data integrity. -Using NFS over TCP or increasing the value of the -.B retrans -option may mitigate some of the risks of using the -.B soft -option. -.TP 1.5i -.BR softreval " / " nosoftreval -In cases where the NFS server is down, it may be useful to -allow the NFS client to continue to serve up paths and -attributes from cache after -.B retrans -attempts to revalidate that cache have timed out. -This may, for instance, be helpful when trying to unmount a -filesystem tree from a server that is permanently down. -.IP -It is possible to combine -.BR softreval -with the -.B soft -mount option, in which case operations that cannot be served up -from cache will time out and return an error after -.B retrans -attempts. The combination with the default -.B hard -mount option implies those uncached operations will continue to -retry until a response is received from the server. -.IP -Note: the default mount option is -.BR nosoftreval -which disallows fallback to cache when revalidation fails, and -instead follows the behavior dictated by the -.B hard -or -.B soft -mount option. -.TP 1.5i -.BR intr " / " nointr -This option is provided for backward compatibility. -It is ignored after kernel 2.6.25. -.TP 1.5i -.BI timeo= n -The time in deciseconds (tenths of a second) the NFS client waits for a -response before it retries an NFS request. -.IP -For NFS over TCP the default -.B timeo -value is 600 (60 seconds). -The NFS client performs linear backoff: After each retransmission the -timeout is increased by -.BR timeo -up to the maximum of 600 seconds. -.IP -However, for NFS over UDP, the client uses an adaptive -algorithm to estimate an appropriate timeout value for frequently used -request types (such as READ and WRITE requests), but uses the -.B timeo -setting for infrequently used request types (such as FSINFO requests). -If the -.B timeo -option is not specified, -infrequently used request types are retried after 1.1 seconds. -After each retransmission, the NFS client doubles the timeout for -that request, -up to a maximum timeout length of 60 seconds. -.TP 1.5i -.BI retrans= n -The number of times the NFS client retries a request before -it attempts further recovery action. If the -.B retrans -option is not specified, the NFS client tries each UDP request -three times and each TCP request twice. -.IP -The NFS client generates a "server not responding" message -after -.B retrans -retries, then attempts further recovery (depending on whether the -.B hard -mount option is in effect). -.TP 1.5i -.BI rsize= n -The maximum number of bytes in each network READ request -that the NFS client can receive when reading data from a file -on an NFS server. -The actual data payload size of each NFS READ request is equal to -or smaller than the -.B rsize -setting. The largest read payload supported by the Linux NFS client -is 1,048,576 bytes (one megabyte). -.IP -The -.B rsize -value is a positive integral multiple of 1024. -Specified -.B rsize -values lower than 1024 are replaced with 4096; values larger than -1048576 are replaced with 1048576. If a specified value is within the supported -range but not a multiple of 1024, it is rounded down to the nearest -multiple of 1024. -.IP -If an -.B rsize -value is not specified, or if the specified -.B rsize -value is larger than the maximum that either client or server can support, -the client and server negotiate the largest -.B rsize -value that they can both support. -.IP -The -.B rsize -mount option as specified on the -.BR mount (8) -command line appears in the -.I /etc/mtab -file. However, the effective -.B rsize -value negotiated by the client and server is reported in the -.I /proc/mounts -file. -.TP 1.5i -.BI wsize= n -The maximum number of bytes per network WRITE request -that the NFS client can send when writing data to a file -on an NFS server. The actual data payload size of each -NFS WRITE request is equal to -or smaller than the -.B wsize -setting. The largest write payload supported by the Linux NFS client -is 1,048,576 bytes (one megabyte). -.IP -Similar to -.B rsize -, the -.B wsize -value is a positive integral multiple of 1024. -Specified -.B wsize -values lower than 1024 are replaced with 4096; values larger than -1048576 are replaced with 1048576. If a specified value is within the supported -range but not a multiple of 1024, it is rounded down to the nearest -multiple of 1024. -.IP -If a -.B wsize -value is not specified, or if the specified -.B wsize -value is larger than the maximum that either client or server can support, -the client and server negotiate the largest -.B wsize -value that they can both support. -.IP -The -.B wsize -mount option as specified on the -.BR mount (8) -command line appears in the -.I /etc/mtab -file. However, the effective -.B wsize -value negotiated by the client and server is reported in the -.I /proc/mounts -file. -.TP 1.5i -.BR ac " / " noac -Selects whether the client may cache file attributes. If neither -option is specified (or if -.B ac -is specified), the client caches file -attributes. -.IP -To improve performance, NFS clients cache file -attributes. Every few seconds, an NFS client checks the server's version of each -file's attributes for updates. Changes that occur on the server in -those small intervals remain undetected until the client checks the -server again. The -.B noac -option prevents clients from caching file -attributes so that applications can more quickly detect file changes -on the server. -.IP -In addition to preventing the client from caching file attributes, -the -.B noac -option forces application writes to become synchronous so -that local changes to a file become visible on the server -immediately. That way, other clients can quickly detect recent -writes when they check the file's attributes. -.IP -Using the -.B noac -option provides greater cache coherence among NFS clients -accessing the same files, -but it extracts a significant performance penalty. -As such, judicious use of file locking is encouraged instead. -The DATA AND METADATA COHERENCE section contains a detailed discussion -of these trade-offs. -.TP 1.5i -.BI acregmin= n -The minimum time (in seconds) that the NFS client caches -attributes of a regular file before it requests -fresh attribute information from a server. -If this option is not specified, the NFS client uses -a 3-second minimum. -See the DATA AND METADATA COHERENCE section -for a full discussion of attribute caching. -.TP 1.5i -.BI acregmax= n -The maximum time (in seconds) that the NFS client caches -attributes of a regular file before it requests -fresh attribute information from a server. -If this option is not specified, the NFS client uses -a 60-second maximum. -See the DATA AND METADATA COHERENCE section -for a full discussion of attribute caching. -.TP 1.5i -.BI acdirmin= n -The minimum time (in seconds) that the NFS client caches -attributes of a directory before it requests -fresh attribute information from a server. -If this option is not specified, the NFS client uses -a 30-second minimum. -See the DATA AND METADATA COHERENCE section -for a full discussion of attribute caching. -.TP 1.5i -.BI acdirmax= n -The maximum time (in seconds) that the NFS client caches -attributes of a directory before it requests -fresh attribute information from a server. -If this option is not specified, the NFS client uses -a 60-second maximum. -See the DATA AND METADATA COHERENCE section -for a full discussion of attribute caching. -.TP 1.5i -.BI actimeo= n -Using -.B actimeo -sets all of -.BR acregmin , -.BR acregmax , -.BR acdirmin , -and -.B acdirmax -to the same value. -If this option is not specified, the NFS client uses -the defaults for each of these options listed above. -.TP 1.5i -.BR bg " / " fg -Determines how the -.BR mount (8) -command behaves if an attempt to mount an export fails. -The -.B fg -option causes -.BR mount (8) -to exit with an error status if any part of the mount request -times out or fails outright. -This is called a "foreground" mount, -and is the default behavior if neither the -.B fg -nor -.B bg -mount option is specified. -.IP -If the -.B bg -option is specified, a timeout or failure causes the -.BR mount (8) -command to fork a child which continues to attempt -to mount the export. -The parent immediately returns with a zero exit code. -This is known as a "background" mount. -.IP -If the local mount point directory is missing, the -.BR mount (8) -command acts as if the mount request timed out. -This permits nested NFS mounts specified in -.I /etc/fstab -to proceed in any order during system initialization, -even if some NFS servers are not yet available. -Alternatively these issues can be addressed -using an automounter (refer to -.BR automount (8) -for details). -.TP 1.5i -.BR nconnect= n -When using a connection oriented protocol such as TCP, it may -sometimes be advantageous to set up multiple connections between -the client and server. For instance, if your clients and/or servers -are equipped with multiple network interface cards (NICs), using multiple -connections to spread the load may improve overall performance. -In such cases, the -.BR nconnect -option allows the user to specify the number of connections -that should be established between the client and server up to -a limit of 16. -.IP -Note that the -.BR nconnect -option may also be used by some pNFS drivers to decide how many -connections to set up to the data servers. -.TP 1.5i -.BR rdirplus " / " nordirplus -Selects whether to use NFS v3 or v4 READDIRPLUS requests. -If this option is not specified, the NFS client uses READDIRPLUS requests -on NFS v3 or v4 mounts to read small directories. -Some applications perform better if the client uses only READDIR requests -for all directories. -.TP 1.5i -.BI retry= n -The number of minutes that the -.BR mount (8) -command retries an NFS mount operation -in the foreground or background before giving up. -If this option is not specified, the default value for foreground mounts -is 2 minutes, and the default value for background mounts is 10000 minutes -(80 minutes shy of one week). -If a value of zero is specified, the -.BR mount (8) -command exits immediately after the first failure. -.IP -Note that this only affects how many retries are made and doesn't -affect the delay caused by each retry. For UDP each retry takes the -time determined by the -.BR timeo -and -.BR retrans -options, which by default will be about 7 seconds. For TCP the -default is 3 minutes, but system TCP connection timeouts will -sometimes limit the timeout of each retransmission to around 2 minutes. -.TP 1.5i -.BI sec= flavors -A colon-separated list of one or more security flavors to use for accessing -files on the mounted export. If the server does not support any of these -flavors, the mount operation fails. -If -.B sec= -is not specified, the client attempts to find -a security flavor that both the client and the server supports. -Valid -.I flavors -are -.BR none , -.BR sys , -.BR krb5 , -.BR krb5i , -and -.BR krb5p . -Refer to the SECURITY CONSIDERATIONS section for details. -.TP 1.5i -.BR sharecache " / " nosharecache -Determines how the client's data cache and attribute cache are shared -when mounting the same export more than once concurrently. Using the -same cache reduces memory requirements on the client and presents -identical file contents to applications when the same remote file is -accessed via different mount points. -.IP -If neither option is specified, or if the -.B sharecache -option is -specified, then a single cache is used for all mount points that -access the same export. If the -.B nosharecache -option is specified, -then that mount point gets a unique cache. Note that when data and -attribute caches are shared, the mount options from the first mount -point take effect for subsequent concurrent mounts of the same export. -.IP -As of kernel 2.6.18, the behavior specified by -.B nosharecache -is legacy caching behavior. This -is considered a data risk since multiple cached copies -of the same file on the same client can become out of sync -following a local update of one of the copies. -.TP 1.5i -.BR resvport " / " noresvport -Specifies whether the NFS client should use a privileged source port -when communicating with an NFS server for this mount point. -If this option is not specified, or the -.B resvport -option is specified, the NFS client uses a privileged source port. -If the -.B noresvport -option is specified, the NFS client uses a non-privileged source port. -This option is supported in kernels 2.6.28 and later. -.IP -Using non-privileged source ports helps increase the maximum number of -NFS mount points allowed on a client, but NFS servers must be configured -to allow clients to connect via non-privileged source ports. -.IP -Refer to the SECURITY CONSIDERATIONS section for important details. -.TP 1.5i -.BI lookupcache= mode -Specifies how the kernel manages its cache of directory entries -for a given mount point. -.I mode -can be one of -.BR all , -.BR none , -.BR pos , -or -.BR positive . -This option is supported in kernels 2.6.28 and later. -.IP -The Linux NFS client caches the result of all NFS LOOKUP requests. -If the requested directory entry exists on the server, -the result is referred to as -.IR positive . -If the requested directory entry does not exist on the server, -the result is referred to as -.IR negative . -.IP -If this option is not specified, or if -.B all -is specified, the client assumes both types of directory cache entries -are valid until their parent directory's cached attributes expire. -.IP -If -.BR pos " or " positive -is specified, the client assumes positive entries are valid -until their parent directory's cached attributes expire, but -always revalidates negative entires before an application -can use them. -.IP -If -.B none -is specified, -the client revalidates both types of directory cache entries -before an application can use them. -This permits quick detection of files that were created or removed -by other clients, but can impact application and server performance. -.IP -The DATA AND METADATA COHERENCE section contains a -detailed discussion of these trade-offs. -.TP 1.5i -.BR fsc " / " nofsc -Enable/Disables the cache of (read-only) data pages to the local disk -using the FS-Cache facility. See cachefilesd(8) -and /Documentation/filesystems/caching -for detail on how to configure the FS-Cache facility. -Default value is nofsc. -.SS "Options for NFS versions 2 and 3 only" -Use these options, along with the options in the above subsection, -for NFS versions 2 and 3 only. -.TP 1.5i -.BI proto= netid -The -.I netid -determines the transport that is used to communicate with the NFS -server. Available options are -.BR udp ", " udp6 ", "tcp ", " tcp6 ", and " rdma . -Those which end in -.B 6 -use IPv6 addresses and are only available if support for TI-RPC is -built in. Others use IPv4 addresses. -.IP -Each transport protocol uses different default -.B retrans -and -.B timeo -settings. -Refer to the description of these two mount options for details. -.IP -In addition to controlling how the NFS client transmits requests to -the server, this mount option also controls how the -.BR mount (8) -command communicates with the server's rpcbind and mountd services. -Specifying a netid that uses TCP forces all traffic from the -.BR mount (8) -command and the NFS client to use TCP. -Specifying a netid that uses UDP forces all traffic types to use UDP. -.IP -.B Before using NFS over UDP, refer to the TRANSPORT METHODS section. -.IP -If the -.B proto -mount option is not specified, the -.BR mount (8) -command discovers which protocols the server supports -and chooses an appropriate transport for each service. -Refer to the TRANSPORT METHODS section for more details. -.TP 1.5i -.B udp -The -.B udp -option is an alternative to specifying -.BR proto=udp. -It is included for compatibility with other operating systems. -.IP -.B Before using NFS over UDP, refer to the TRANSPORT METHODS section. -.TP 1.5i -.B tcp -The -.B tcp -option is an alternative to specifying -.BR proto=tcp. -It is included for compatibility with other operating systems. -.TP 1.5i -.B rdma -The -.B rdma -option is an alternative to specifying -.BR proto=rdma. -.TP 1.5i -.BI port= n -The numeric value of the server's NFS service port. -If the server's NFS service is not available on the specified port, -the mount request fails. -.IP -If this option is not specified, or if the specified port value is 0, -then the NFS client uses the NFS service port number -advertised by the server's rpcbind service. -The mount request fails if the server's rpcbind service is not available, -the server's NFS service is not registered with its rpcbind service, -or the server's NFS service is not available on the advertised port. -.TP 1.5i -.BI mountport= n -The numeric value of the server's mountd port. -If the server's mountd service is not available on the specified port, -the mount request fails. -.IP -If this option is not specified, -or if the specified port value is 0, then the -.BR mount (8) -command uses the mountd service port number -advertised by the server's rpcbind service. -The mount request fails if the server's rpcbind service is not available, -the server's mountd service is not registered with its rpcbind service, -or the server's mountd service is not available on the advertised port. -.IP -This option can be used when mounting an NFS server -through a firewall that blocks the rpcbind protocol. -.TP 1.5i -.BI mountproto= netid -The transport the NFS client uses -to transmit requests to the NFS server's mountd service when performing -this mount request, and when later unmounting this mount point. -.IP -.I netid -may be one of -.BR udp ", and " tcp -which use IPv4 address or, if TI-RPC is built into the -.B mount.nfs -command, -.BR udp6 ", and " tcp6 -which use IPv6 addresses. -.IP -This option can be used when mounting an NFS server -through a firewall that blocks a particular transport. -When used in combination with the -.B proto -option, different transports for mountd requests and NFS requests -can be specified. -If the server's mountd service is not available via the specified -transport, the mount request fails. -.IP -Refer to the TRANSPORT METHODS section for more on how the -.B mountproto -mount option interacts with the -.B proto -mount option. -.TP 1.5i -.BI mounthost= name -The hostname of the host running mountd. -If this option is not specified, the -.BR mount (8) -command assumes that the mountd service runs -on the same host as the NFS service. -.TP 1.5i -.BI mountvers= n -The RPC version number used to contact the server's mountd. -If this option is not specified, the client uses a version number -appropriate to the requested NFS version. -This option is useful when multiple NFS services -are running on the same remote server host. -.TP 1.5i -.BI namlen= n -The maximum length of a pathname component on this mount. -If this option is not specified, the maximum length is negotiated -with the server. In most cases, this maximum length is 255 characters. -.IP -Some early versions of NFS did not support this negotiation. -Using this option ensures that -.BR pathconf (3) -reports the proper maximum component length to applications -in such cases. -.TP 1.5i -.BR lock " / " nolock -Selects whether to use the NLM sideband protocol to lock files on the server. -If neither option is specified (or if -.B lock -is specified), NLM locking is used for this mount point. -When using the -.B nolock -option, applications can lock files, -but such locks provide exclusion only against other applications -running on the same client. -Remote applications are not affected by these locks. -.IP -NLM locking must be disabled with the -.B nolock -option when using NFS to mount -.I /var -because -.I /var -contains files used by the NLM implementation on Linux. -Using the -.B nolock -option is also required when mounting exports on NFS servers -that do not support the NLM protocol. -.TP 1.5i -.BR cto " / " nocto -Selects whether to use close-to-open cache coherence semantics. -If neither option is specified (or if -.B cto -is specified), the client uses close-to-open -cache coherence semantics. If the -.B nocto -option is specified, the client uses a non-standard heuristic to determine when -files on the server have changed. -.IP -Using the -.B nocto -option may improve performance for read-only mounts, -but should be used only if the data on the server changes only occasionally. -The DATA AND METADATA COHERENCE section discusses the behavior -of this option in more detail. -.TP 1.5i -.BR acl " / " noacl -Selects whether to use the NFSACL sideband protocol on this mount point. -The NFSACL sideband protocol is a proprietary protocol -implemented in Solaris that manages Access Control Lists. NFSACL was never -made a standard part of the NFS protocol specification. -.IP -If neither -.B acl -nor -.B noacl -option is specified, -the NFS client negotiates with the server -to see if the NFSACL protocol is supported, -and uses it if the server supports it. -Disabling the NFSACL sideband protocol may be necessary -if the negotiation causes problems on the client or server. -Refer to the SECURITY CONSIDERATIONS section for more details. -.TP 1.5i -.BR local_lock= mechanism -Specifies whether to use local locking for any or both of the flock and the -POSIX locking mechanisms. -.I mechanism -can be one of -.BR all , -.BR flock , -.BR posix , -or -.BR none . -This option is supported in kernels 2.6.37 and later. -.IP -The Linux NFS client provides a way to make locks local. This means, the -applications can lock files, but such locks provide exclusion only against -other applications running on the same client. Remote applications are not -affected by these locks. -.IP -If this option is not specified, or if -.B none -is specified, the client assumes that the locks are not local. -.IP -If -.BR all -is specified, the client assumes that both flock and POSIX locks are local. -.IP -If -.BR flock -is specified, the client assumes that only flock locks are local and uses -NLM sideband protocol to lock files when POSIX locks are used. -.IP -If -.BR posix -is specified, the client assumes that POSIX locks are local and uses NLM -sideband protocol to lock files when flock locks are used. -.IP -To support legacy flock behavior similar to that of NFS clients < 2.6.12, -use 'local_lock=flock'. This option is required when exporting NFS mounts via -Samba as Samba maps Windows share mode locks as flock. Since NFS clients > -2.6.12 implement flock by emulating POSIX locks, this will result in -conflicting locks. -.IP -NOTE: When used together, the 'local_lock' mount option will be overridden -by 'nolock'/'lock' mount option. -.SS "Options for NFS version 4 only" -Use these options, along with the options in the first subsection above, -for NFS version 4.0 and newer. -.TP 1.5i -.BI proto= netid -The -.I netid -determines the transport that is used to communicate with the NFS -server. Supported options are -.BR tcp ", " tcp6 ", and " rdma . -.B tcp6 -use IPv6 addresses and is only available if support for TI-RPC is -built in. Both others use IPv4 addresses. -.IP -All NFS version 4 servers are required to support TCP, -so if this mount option is not specified, the NFS version 4 client -uses the TCP protocol. -Refer to the TRANSPORT METHODS section for more details. -.TP 1.5i -.BI minorversion= n -Specifies the protocol minor version number. -NFSv4 introduces "minor versioning," where NFS protocol enhancements can -be introduced without bumping the NFS protocol version number. -Before kernel 2.6.38, the minor version is always zero, and this -option is not recognized. -After this kernel, specifying "minorversion=1" enables a number of -advanced features, such as NFSv4 sessions. -.IP -Recent kernels allow the minor version to be specified using the -.B vers= -option. -For example, specifying -.B vers=4.1 -is the same as specifying -.BR vers=4,minorversion=1 . -.TP 1.5i -.BI port= n -The numeric value of the server's NFS service port. -If the server's NFS service is not available on the specified port, -the mount request fails. -.IP -If this mount option is not specified, -the NFS client uses the standard NFS port number of 2049 -without first checking the server's rpcbind service. -This allows an NFS version 4 client to contact an NFS version 4 -server through a firewall that may block rpcbind requests. -.IP -If the specified port value is 0, -then the NFS client uses the NFS service port number -advertised by the server's rpcbind service. -The mount request fails if the server's rpcbind service is not available, -the server's NFS service is not registered with its rpcbind service, -or the server's NFS service is not available on the advertised port. -.TP 1.5i -.BR cto " / " nocto -Selects whether to use close-to-open cache coherence semantics -for NFS directories on this mount point. -If neither -.B cto -nor -.B nocto -is specified, -the default is to use close-to-open cache coherence -semantics for directories. -.IP -File data caching behavior is not affected by this option. -The DATA AND METADATA COHERENCE section discusses -the behavior of this option in more detail. -.TP 1.5i -.BI clientaddr= n.n.n.n -.TP 1.5i -.BI clientaddr= n:n: ... :n -Specifies a single IPv4 address (in dotted-quad form), -or a non-link-local IPv6 address, -that the NFS client advertises to allow servers -to perform NFS version 4.0 callback requests against -files on this mount point. If the server is unable to -establish callback connections to clients, performance -may degrade, or accesses to files may temporarily hang. -Can specify a value of IPv4_ANY (0.0.0.0) or equivalent -IPv6 any address which will signal to the NFS server that -this NFS client does not want delegations. -.IP -If this option is not specified, the -.BR mount (8) -command attempts to discover an appropriate callback address automatically. -The automatic discovery process is not perfect, however. -In the presence of multiple client network interfaces, -special routing policies, -or atypical network topologies, -the exact address to use for callbacks may be nontrivial to determine. -.IP -NFS protocol versions 4.1 and 4.2 use the client-established -TCP connection for callback requests, so do not require the server to -connect to the client. This option is therefore only affect NFS version -4.0 mounts. -.TP 1.5i -.BR migration " / " nomigration -Selects whether the client uses an identification string that is compatible -with NFSv4 Transparent State Migration (TSM). -If the mounted server supports NFSv4 migration with TSM, specify the -.B migration -option. -.IP -Some server features misbehave in the face of a migration-compatible -identification string. -The -.B nomigration -option retains the use of a traditional client indentification string -which is compatible with legacy NFS servers. -This is also the behavior if neither option is specified. -A client's open and lock state cannot be migrated transparently -when it identifies itself via a traditional identification string. -.IP -This mount option has no effect with NFSv4 minor versions newer than zero, -which always use TSM-compatible client identification strings. -.SH nfs4 FILE SYSTEM TYPE -The -.BR nfs4 -file system type is an old syntax for specifying NFSv4 usage. It can still -be used with all NFSv4-specific and common options, excepted the -.B nfsvers -mount option. -.SH MOUNT CONFIGURATION FILE -If the mount command is configured to do so, all of the mount options -described in the previous section can also be configured in the -.I /etc/nfsmount.conf -file. See -.BR nfsmount.conf(5) -for details. -.SH EXAMPLES -To mount an export using NFS version 2, -use the -.B nfs -file system type and specify the -.B nfsvers=2 -mount option. -To mount using NFS version 3, -use the -.B nfs -file system type and specify the -.B nfsvers=3 -mount option. -To mount using NFS version 4, -use either the -.B nfs -file system type, with the -.B nfsvers=4 -mount option, or the -.B nfs4 -file system type. -.P -The following example from an -.I /etc/fstab -file causes the mount command to negotiate -reasonable defaults for NFS behavior. -.P -.nf -.ta 8n +16n +6n +6n +30n - server:/export /mnt nfs defaults 0 0 -.fi -.P -Here is an example from an /etc/fstab file for an NFS version 2 mount over UDP. -.P -.nf -.ta 8n +16n +6n +6n +30n - server:/export /mnt nfs nfsvers=2,proto=udp 0 0 -.fi -.P -This example shows how to mount using NFS version 4 over TCP -with Kerberos 5 mutual authentication. -.P -.nf -.ta 8n +16n +6n +6n +30n - server:/export /mnt nfs4 sec=krb5 0 0 -.fi -.P -This example shows how to mount using NFS version 4 over TCP -with Kerberos 5 privacy or data integrity mode. -.P -.nf -.ta 8n +16n +6n +6n +30n - server:/export /mnt nfs4 sec=krb5p:krb5i 0 0 -.fi -.P -This example can be used to mount /usr over NFS. -.P -.nf -.ta 8n +16n +6n +6n +30n - server:/export /usr nfs ro,nolock,nocto,actimeo=3600 0 0 -.fi -.P -This example shows how to mount an NFS server -using a raw IPv6 link-local address. -.P -.nf -.ta 8n +40n +5n +4n +9n - [fe80::215:c5ff:fb3e:e2b1%eth0]:/export /mnt nfs defaults 0 0 -.fi -.SH "TRANSPORT METHODS" -NFS clients send requests to NFS servers via -Remote Procedure Calls, or -.IR RPCs . -The RPC client discovers remote service endpoints automatically, -handles per-request authentication, -adjusts request parameters for different byte endianness on client and server, -and retransmits requests that may have been lost by the network or server. -RPC requests and replies flow over a network transport. -.P -In most cases, the -.BR mount (8) -command, NFS client, and NFS server -can automatically negotiate proper transport -and data transfer size settings for a mount point. -In some cases, however, it pays to specify -these settings explicitly using mount options. -.P -Traditionally, NFS clients used the UDP transport exclusively for -transmitting requests to servers. Though its implementation is -simple, NFS over UDP has many limitations that prevent smooth -operation and good performance in some common deployment -environments. Even an insignificant packet loss rate results in the -loss of whole NFS requests; as such, retransmit timeouts are usually -in the subsecond range to allow clients to recover quickly from -dropped requests, but this can result in extraneous network traffic -and server load. -.P -However, UDP can be quite effective in specialized settings where -the networks MTU is large relative to NFSs data transfer size (such -as network environments that enable jumbo Ethernet frames). In such -environments, trimming the -.B rsize -and -.B wsize -settings so that each -NFS read or write request fits in just a few network frames (or even -in a single frame) is advised. This reduces the probability that -the loss of a single MTU-sized network frame results in the loss of -an entire large read or write request. -.P -TCP is the default transport protocol used for all modern NFS -implementations. It performs well in almost every conceivable -network environment and provides excellent guarantees against data -corruption caused by network unreliability. TCP is often a -requirement for mounting a server through a network firewall. -.P -Under normal circumstances, networks drop packets much more -frequently than NFS servers drop requests. As such, an aggressive -retransmit timeout setting for NFS over TCP is unnecessary. Typical -timeout settings for NFS over TCP are between one and ten minutes. -After the client exhausts its retransmits (the value of the -.B retrans -mount option), it assumes a network partition has occurred, -and attempts to reconnect to the server on a fresh socket. Since -TCP itself makes network data transfer reliable, -.B rsize -and -.B wsize -can safely be allowed to default to the largest values supported by -both client and server, independent of the network's MTU size. -.SS "Using the mountproto mount option" -This section applies only to NFS version 2 and version 3 mounts -since NFS version 4 does not use a separate protocol for mount -requests. -.P -The Linux NFS client can use a different transport for -contacting an NFS server's rpcbind service, its mountd service, -its Network Lock Manager (NLM) service, and its NFS service. -The exact transports employed by the Linux NFS client for -each mount point depends on the settings of the transport -mount options, which include -.BR proto , -.BR mountproto , -.BR udp ", and " tcp . -.P -The client sends Network Status Manager (NSM) notifications -via UDP no matter what transport options are specified, but -listens for server NSM notifications on both UDP and TCP. -The NFS Access Control List (NFSACL) protocol shares the same -transport as the main NFS service. -.P -If no transport options are specified, the Linux NFS client -uses UDP to contact the server's mountd service, and TCP to -contact its NLM and NFS services by default. -.P -If the server does not support these transports for these services, the -.BR mount (8) -command attempts to discover what the server supports, and then retries -the mount request once using the discovered transports. -If the server does not advertise any transport supported by the client -or is misconfigured, the mount request fails. -If the -.B bg -option is in effect, the mount command backgrounds itself and continues -to attempt the specified mount request. -.P -When the -.B proto -option, the -.B udp -option, or the -.B tcp -option is specified but the -.B mountproto -option is not, the specified transport is used to contact -both the server's mountd service and for the NLM and NFS services. -.P -If the -.B mountproto -option is specified but none of the -.BR proto ", " udp " or " tcp -options are specified, then the specified transport is used for the -initial mountd request, but the mount command attempts to discover -what the server supports for the NFS protocol, preferring TCP if -both transports are supported. -.P -If both the -.BR mountproto " and " proto -(or -.BR udp " or " tcp ) -options are specified, then the transport specified by the -.B mountproto -option is used for the initial mountd request, and the transport -specified by the -.B proto -option (or the -.BR udp " or " tcp " options)" -is used for NFS, no matter what order these options appear. -No automatic service discovery is performed if these options are -specified. -.P -If any of the -.BR proto ", " udp ", " tcp ", " -or -.B mountproto -options are specified more than once on the same mount command line, -then the value of the rightmost instance of each of these options -takes effect. -.SS "Using NFS over UDP on high-speed links" -Using NFS over UDP on high-speed links such as Gigabit -.BR "can cause silent data corruption" . -.P -The problem can be triggered at high loads, and is caused by problems in -IP fragment reassembly. NFS read and writes typically transmit UDP packets -of 4 Kilobytes or more, which have to be broken up into several fragments -in order to be sent over the Ethernet link, which limits packets to 1500 -bytes by default. This process happens at the IP network layer and is -called fragmentation. -.P -In order to identify fragments that belong together, IP assigns a 16bit -.I IP ID -value to each packet; fragments generated from the same UDP packet -will have the same IP ID. The receiving system will collect these -fragments and combine them to form the original UDP packet. This process -is called reassembly. The default timeout for packet reassembly is -30 seconds; if the network stack does not receive all fragments of -a given packet within this interval, it assumes the missing fragment(s) -got lost and discards those it already received. -.P -The problem this creates over high-speed links is that it is possible -to send more than 65536 packets within 30 seconds. In fact, with -heavy NFS traffic one can observe that the IP IDs repeat after about -5 seconds. -.P -This has serious effects on reassembly: if one fragment gets lost, -another fragment -.I from a different packet -but with the -.I same IP ID -will arrive within the 30 second timeout, and the network stack will -combine these fragments to form a new packet. Most of the time, network -layers above IP will detect this mismatched reassembly - in the case -of UDP, the UDP checksum, which is a 16 bit checksum over the entire -packet payload, will usually not match, and UDP will discard the -bad packet. -.P -However, the UDP checksum is 16 bit only, so there is a chance of 1 in -65536 that it will match even if the packet payload is completely -random (which very often isn't the case). If that is the case, -silent data corruption will occur. -.P -This potential should be taken seriously, at least on Gigabit -Ethernet. -Network speeds of 100Mbit/s should be considered less -problematic, because with most traffic patterns IP ID wrap around -will take much longer than 30 seconds. -.P -It is therefore strongly recommended to use -.BR "NFS over TCP where possible" , -since TCP does not perform fragmentation. -.P -If you absolutely have to use NFS over UDP over Gigabit Ethernet, -some steps can be taken to mitigate the problem and reduce the -probability of corruption: -.TP +1.5i -.I Jumbo frames: -Many Gigabit network cards are capable of transmitting -frames bigger than the 1500 byte limit of traditional Ethernet, typically -9000 bytes. Using jumbo frames of 9000 bytes will allow you to run NFS over -UDP at a page size of 8K without fragmentation. Of course, this is -only feasible if all involved stations support jumbo frames. -.IP -To enable a machine to send jumbo frames on cards that support it, -it is sufficient to configure the interface for a MTU value of 9000. -.TP +1.5i -.I Lower reassembly timeout: -By lowering this timeout below the time it takes the IP ID counter -to wrap around, incorrect reassembly of fragments can be prevented -as well. To do so, simply write the new timeout value (in seconds) -to the file -.BR /proc/sys/net/ipv4/ipfrag_time . -.IP -A value of 2 seconds will greatly reduce the probability of IPID clashes on -a single Gigabit link, while still allowing for a reasonable timeout -when receiving fragmented traffic from distant peers. -.SH "DATA AND METADATA COHERENCE" -Some modern cluster file systems provide -perfect cache coherence among their clients. -Perfect cache coherence among disparate NFS clients -is expensive to achieve, especially on wide area networks. -As such, NFS settles for weaker cache coherence that -satisfies the requirements of most file sharing types. -.SS "Close-to-open cache consistency" -Typically file sharing is completely sequential. -First client A opens a file, writes something to it, then closes it. -Then client B opens the same file, and reads the changes. -.P -When an application opens a file stored on an NFS version 3 server, -the NFS client checks that the file exists on the server -and is permitted to the opener by sending a GETATTR or ACCESS request. -The NFS client sends these requests -regardless of the freshness of the file's cached attributes. -.P -When the application closes the file, -the NFS client writes back any pending changes -to the file so that the next opener can view the changes. -This also gives the NFS client an opportunity to report -write errors to the application via the return code from -.BR close (2). -.P -The behavior of checking at open time and flushing at close time -is referred to as -.IR "close-to-open cache consistency" , -or -.IR CTO . -It can be disabled for an entire mount point using the -.B nocto -mount option. -.SS "Weak cache consistency" -There are still opportunities for a client's data cache -to contain stale data. -The NFS version 3 protocol introduced "weak cache consistency" -(also known as WCC) which provides a way of efficiently checking -a file's attributes before and after a single request. -This allows a client to help identify changes -that could have been made by other clients. -.P -When a client is using many concurrent operations -that update the same file at the same time -(for example, during asynchronous write behind), -it is still difficult to tell whether it was -that client's updates or some other client's updates -that altered the file. -.SS "Attribute caching" -Use the -.B noac -mount option to achieve attribute cache coherence -among multiple clients. -Almost every file system operation checks -file attribute information. -The client keeps this information cached -for a period of time to reduce network and server load. -When -.B noac -is in effect, a client's file attribute cache is disabled, -so each operation that needs to check a file's attributes -is forced to go back to the server. -This permits a client to see changes to a file very quickly, -at the cost of many extra network operations. -.P -Be careful not to confuse the -.B noac -option with "no data caching." -The -.B noac -mount option prevents the client from caching file metadata, -but there are still races that may result in data cache incoherence -between client and server. -.P -The NFS protocol is not designed to support -true cluster file system cache coherence -without some type of application serialization. -If absolute cache coherence among clients is required, -applications should use file locking. Alternatively, applications -can also open their files with the O_DIRECT flag -to disable data caching entirely. -.SS "File timestamp maintenance" -NFS servers are responsible for managing file and directory timestamps -.RB ( atime , -.BR ctime ", and" -.BR mtime ). -When a file is accessed or updated on an NFS server, -the file's timestamps are updated just like they would be on a filesystem -local to an application. -.P -NFS clients cache file attributes, including timestamps. -A file's timestamps are updated on NFS clients when its attributes -are retrieved from the NFS server. -Thus there may be some delay before timestamp updates -on an NFS server appear to applications on NFS clients. -.P -To comply with the POSIX filesystem standard, the Linux NFS client -relies on NFS servers to keep a file's -.B mtime -and -.B ctime -timestamps properly up to date. -It does this by flushing local data changes to the server -before reporting -.B mtime -to applications via system calls such as -.BR stat (2). -.P -The Linux client handles -.B atime -updates more loosely, however. -NFS clients maintain good performance by caching data, -but that means that application reads, which normally update -.BR atime , -are not reflected to the server where a file's -.B atime -is actually maintained. -.P -Because of this caching behavior, -the Linux NFS client does not support generic atime-related mount options. -See -.BR mount (8) -for details on these options. -.P -In particular, the -.BR atime / noatime , -.BR diratime / nodiratime , -.BR relatime / norelatime , -and -.BR strictatime / nostrictatime -mount options have no effect on NFS mounts. -.P -.I /proc/mounts -may report that the -.B relatime -mount option is set on NFS mounts, but in fact the -.B atime -semantics are always as described here, and are not like -.B relatime -semantics. -.SS "Directory entry caching" -The Linux NFS client caches the result of all NFS LOOKUP requests. -If the requested directory entry exists on the server, -the result is referred to as a -.IR positive " lookup result. -If the requested directory entry does not exist on the server -(that is, the server returned ENOENT), -the result is referred to as -.IR negative " lookup result. -.P -To detect when directory entries have been added or removed -on the server, -the Linux NFS client watches a directory's mtime. -If the client detects a change in a directory's mtime, -the client drops all cached LOOKUP results for that directory. -Since the directory's mtime is a cached attribute, it may -take some time before a client notices it has changed. -See the descriptions of the -.BR acdirmin ", " acdirmax ", and " noac -mount options for more information about -how long a directory's mtime is cached. -.P -Caching directory entries improves the performance of applications that -do not share files with applications on other clients. -Using cached information about directories can interfere -with applications that run concurrently on multiple clients and -need to detect the creation or removal of files quickly, however. -The -.B lookupcache -mount option allows some tuning of directory entry caching behavior. -.P -Before kernel release 2.6.28, -the Linux NFS client tracked only positive lookup results. -This permitted applications to detect new directory entries -created by other clients quickly while still providing some of the -performance benefits of caching. -If an application depends on the previous lookup caching behavior -of the Linux NFS client, you can use -.BR lookupcache=positive . -.P -If the client ignores its cache and validates every application -lookup request with the server, -that client can immediately detect when a new directory -entry has been either created or removed by another client. -You can specify this behavior using -.BR lookupcache=none . -The extra NFS requests needed if the client does not -cache directory entries can exact a performance penalty. -Disabling lookup caching -should result in less of a performance penalty than using -.BR noac , -and has no effect on how the NFS client caches the attributes of files. -.P -.SS "The sync mount option" -The NFS client treats the -.B sync -mount option differently than some other file systems -(refer to -.BR mount (8) -for a description of the generic -.B sync -and -.B async -mount options). -If neither -.B sync -nor -.B async -is specified (or if the -.B async -option is specified), -the NFS client delays sending application -writes to the server -until any of these events occur: -.IP -Memory pressure forces reclamation of system memory resources. -.IP -An application flushes file data explicitly with -.BR sync (2), -.BR msync (2), -or -.BR fsync (3). -.IP -An application closes a file with -.BR close (2). -.IP -The file is locked/unlocked via -.BR fcntl (2). -.P -In other words, under normal circumstances, -data written by an application may not immediately appear -on the server that hosts the file. -.P -If the -.B sync -option is specified on a mount point, -any system call that writes data to files on that mount point -causes that data to be flushed to the server -before the system call returns control to user space. -This provides greater data cache coherence among clients, -but at a significant performance cost. -.P -Applications can use the O_SYNC open flag to force application -writes to individual files to go to the server immediately without -the use of the -.B sync -mount option. -.SS "Using file locks with NFS" -The Network Lock Manager protocol is a separate sideband protocol -used to manage file locks in NFS version 2 and version 3. -To support lock recovery after a client or server reboot, -a second sideband protocol -- -known as the Network Status Manager protocol -- -is also required. -In NFS version 4, -file locking is supported directly in the main NFS protocol, -and the NLM and NSM sideband protocols are not used. -.P -In most cases, NLM and NSM services are started automatically, -and no extra configuration is required. -Configure all NFS clients with fully-qualified domain names -to ensure that NFS servers can find clients to notify them of server reboots. -.P -NLM supports advisory file locks only. -To lock NFS files, use -.BR fcntl (2) -with the F_GETLK and F_SETLK commands. -The NFS client converts file locks obtained via -.BR flock (2) -to advisory locks. -.P -When mounting servers that do not support the NLM protocol, -or when mounting an NFS server through a firewall -that blocks the NLM service port, -specify the -.B nolock -mount option. NLM locking must be disabled with the -.B nolock -option when using NFS to mount -.I /var -because -.I /var -contains files used by the NLM implementation on Linux. -.P -Specifying the -.B nolock -option may also be advised to improve the performance -of a proprietary application which runs on a single client -and uses file locks extensively. -.SS "NFS version 4 caching features" -The data and metadata caching behavior of NFS version 4 -clients is similar to that of earlier versions. -However, NFS version 4 adds two features that improve -cache behavior: -.I change attributes -and -.IR "file delegation" . -.P -The -.I change attribute -is a new part of NFS file and directory metadata -which tracks data changes. -It replaces the use of a file's modification -and change time stamps -as a way for clients to validate the content -of their caches. -Change attributes are independent of the time stamp -resolution on either the server or client, however. -.P -A -.I file delegation -is a contract between an NFS version 4 client -and server that allows the client to treat a file temporarily -as if no other client is accessing it. -The server promises to notify the client (via a callback request) if another client -attempts to access that file. -Once a file has been delegated to a client, the client can -cache that file's data and metadata aggressively without -contacting the server. -.P -File delegations come in two flavors: -.I read -and -.IR write . -A -.I read -delegation means that the server notifies the client -about any other clients that want to write to the file. -A -.I write -delegation means that the client gets notified about -either read or write accessors. -.P -Servers grant file delegations when a file is opened, -and can recall delegations at any time when another -client wants access to the file that conflicts with -any delegations already granted. -Delegations on directories are not supported. -.P -In order to support delegation callback, the server -checks the network return path to the client during -the client's initial contact with the server. -If contact with the client cannot be established, -the server simply does not grant any delegations to -that client. -.SH "SECURITY CONSIDERATIONS" -NFS servers control access to file data, -but they depend on their RPC implementation -to provide authentication of NFS requests. -Traditional NFS access control mimics -the standard mode bit access control provided in local file systems. -Traditional RPC authentication uses a number -to represent each user -(usually the user's own uid), -a number to represent the user's group (the user's gid), -and a set of up to 16 auxiliary group numbers -to represent other groups of which the user may be a member. -.P -Typically, file data and user ID values appear unencrypted -(i.e. "in the clear") on the network. -Moreover, NFS versions 2 and 3 use -separate sideband protocols for mounting, -locking and unlocking files, -and reporting system status of clients and servers. -These auxiliary protocols use no authentication. -.P -In addition to combining these sideband protocols with the main NFS protocol, -NFS version 4 introduces more advanced forms of access control, -authentication, and in-transit data protection. -The NFS version 4 specification mandates support for -strong authentication and security flavors -that provide per-RPC integrity checking and encryption. -Because NFS version 4 combines the -function of the sideband protocols into the main NFS protocol, -the new security features apply to all NFS version 4 operations -including mounting, file locking, and so on. -RPCGSS authentication can also be used with NFS versions 2 and 3, -but it does not protect their sideband protocols. -.P -The -.B sec -mount option specifies the security flavor used for operations -on behalf of users on that NFS mount point. -Specifying -.B sec=krb5 -provides cryptographic proof of a user's identity in each RPC request. -This provides strong verification of the identity of users -accessing data on the server. -Note that additional configuration besides adding this mount option -is required in order to enable Kerberos security. -Refer to the -.BR rpc.gssd (8) -man page for details. -.P -Two additional flavors of Kerberos security are supported: -.B krb5i -and -.BR krb5p . -The -.B krb5i -security flavor provides a cryptographically strong guarantee -that the data in each RPC request has not been tampered with. -The -.B krb5p -security flavor encrypts every RPC request -to prevent data exposure during network transit; however, -expect some performance impact -when using integrity checking or encryption. -Similar support for other forms of cryptographic security -is also available. -.SS "NFS version 4 filesystem crossing" -The NFS version 4 protocol allows -a client to renegotiate the security flavor -when the client crosses into a new filesystem on the server. -The newly negotiated flavor effects only accesses of the new filesystem. -.P -Such negotiation typically occurs when a client crosses -from a server's pseudo-fs -into one of the server's exported physical filesystems, -which often have more restrictive security settings than the pseudo-fs. -.SS "NFS version 4 Leases" -In NFS version 4, a lease is a period during which a server -irrevocably grants a client file locks. -Once the lease expires, the server may revoke those locks. -Clients periodically renew their leases to prevent lock revocation. -.P -After an NFS version 4 server reboots, each client tells the -server about existing file open and lock state under its lease -before operation can continue. -If a client reboots, the server frees all open and lock state -associated with that client's lease. -.P -When establishing a lease, therefore, -a client must identify itself to a server. -Each client presents an arbitrary string -to distinguish itself from other clients. -The client administrator can -supplement the default identity string using the -.I nfs4.nfs4_unique_id -module parameter to avoid collisions -with other client identity strings. -.P -A client also uses a unique security flavor and principal -when it establishes its lease. -If two clients present the same identity string, -a server can use client principals to distinguish between them, -thus securely preventing one client from interfering with the other's lease. -.P -The Linux NFS client establishes one lease on each NFS version 4 server. -Lease management operations, such as lease renewal, are not -done on behalf of a particular file, lock, user, or mount -point, but on behalf of the client that owns that lease. -A client uses a consistent identity string, security flavor, -and principal across client reboots to ensure that the server -can promptly reap expired lease state. -.P -When Kerberos is configured on a Linux NFS client -(i.e., there is a -.I /etc/krb5.keytab -on that client), the client attempts to use a Kerberos -security flavor for its lease management operations. -Kerberos provides secure authentication of each client. -By default, the client uses the -.I host/ -or -.I nfs/ -service principal in its -.I /etc/krb5.keytab -for this purpose, as described in -.BR rpc.gssd (8). -.P -If the client has Kerberos configured, but the server -does not, or if the client does not have a keytab or -the requisite service principals, the client uses -.I AUTH_SYS -and UID 0 for lease management. -.SS "Using non-privileged source ports" -NFS clients usually communicate with NFS servers via network sockets. -Each end of a socket is assigned a port value, which is simply a number -between 1 and 65535 that distinguishes socket endpoints at the same -IP address. -A socket is uniquely defined by a tuple that includes the transport -protocol (TCP or UDP) and the port values and IP addresses of both -endpoints. -.P -The NFS client can choose any source port value for its sockets, -but usually chooses a -.I privileged -port. -A privileged port is a port value less than 1024. -Only a process with root privileges may create a socket -with a privileged source port. -.P -The exact range of privileged source ports that can be chosen is -set by a pair of sysctls to avoid choosing a well-known port, such as -the port used by ssh. -This means the number of source ports available for the NFS client, -and therefore the number of socket connections that can be used -at the same time, -is practically limited to only a few hundred. -.P -As described above, the traditional default NFS authentication scheme, -known as AUTH_SYS, relies on sending local UID and GID numbers to identify -users making NFS requests. -An NFS server assumes that if a connection comes from a privileged port, -the UID and GID numbers in the NFS requests on this connection have been -verified by the client's kernel or some other local authority. -This is an easy system to spoof, but on a trusted physical network between -trusted hosts, it is entirely adequate. -.P -Roughly speaking, one socket is used for each NFS mount point. -If a client could use non-privileged source ports as well, -the number of sockets allowed, -and thus the maximum number of concurrent mount points, -would be much larger. -.P -Using non-privileged source ports may compromise server security somewhat, -since any user on AUTH_SYS mount points can now pretend to be any other -when making NFS requests. -Thus NFS servers do not support this by default. -They explicitly allow it usually via an export option. -.P -To retain good security while allowing as many mount points as possible, -it is best to allow non-privileged client connections only if the server -and client both require strong authentication, such as Kerberos. -.SS "Mounting through a firewall" -A firewall may reside between an NFS client and server, -or the client or server may block some of its own ports via IP -filter rules. -It is still possible to mount an NFS server through a firewall, -though some of the -.BR mount (8) -command's automatic service endpoint discovery mechanisms may not work; this -requires you to provide specific endpoint details via NFS mount options. -.P -NFS servers normally run a portmapper or rpcbind daemon to advertise -their service endpoints to clients. Clients use the rpcbind daemon to determine: -.IP -What network port each RPC-based service is using -.IP -What transport protocols each RPC-based service supports -.P -The rpcbind daemon uses a well-known port number (111) to help clients find a service endpoint. -Although NFS often uses a standard port number (2049), -auxiliary services such as the NLM service can choose -any unused port number at random. -.P -Common firewall configurations block the well-known rpcbind port. -In the absense of an rpcbind service, -the server administrator fixes the port number -of NFS-related services so that the firewall -can allow access to specific NFS service ports. -Client administrators then specify the port number -for the mountd service via the -.BR mount (8) -command's -.B mountport -option. -It may also be necessary to enforce the use of TCP or UDP -if the firewall blocks one of those transports. -.SS "NFS Access Control Lists" -Solaris allows NFS version 3 clients direct access -to POSIX Access Control Lists stored in its local file systems. -This proprietary sideband protocol, known as NFSACL, -provides richer access control than mode bits. -Linux implements this protocol -for compatibility with the Solaris NFS implementation. -The NFSACL protocol never became a standard part -of the NFS version 3 specification, however. -.P -The NFS version 4 specification mandates a new version -of Access Control Lists that are semantically richer than POSIX ACLs. -NFS version 4 ACLs are not fully compatible with POSIX ACLs; as such, -some translation between the two is required -in an environment that mixes POSIX ACLs and NFS version 4. -.SH "THE REMOUNT OPTION" -Generic mount options such as -.BR rw " and " sync -can be modified on NFS mount points using the -.BR remount -option. -See -.BR mount (8) -for more information on generic mount options. -.P -With few exceptions, NFS-specific options -are not able to be modified during a remount. -The underlying transport or NFS version -cannot be changed by a remount, for example. -.P -Performing a remount on an NFS file system mounted with the -.B noac -option may have unintended consequences. -The -.B noac -option is a combination of the generic option -.BR sync , -and the NFS-specific option -.BR actimeo=0 . -.SS "Unmounting after a remount" -For mount points that use NFS versions 2 or 3, the NFS umount subcommand -depends on knowing the original set of mount options used to perform the -MNT operation. -These options are stored on disk by the NFS mount subcommand, -and can be erased by a remount. -.P -To ensure that the saved mount options are not erased during a remount, -specify either the local mount directory, or the server hostname and -export pathname, but not both, during a remount. For example, -.P -.nf -.ta 8n - mount -o remount,ro /mnt -.fi -.P -merges the mount option -.B ro -with the mount options already saved on disk for the NFS server mounted at /mnt. -.SH FILES -.TP 1.5i -.I /etc/fstab -file system table -.TP 1.5i -.I /etc/nfsmount.conf -Configuration file for NFS mounts -.SH NOTES -Before 2.4.7, the Linux NFS client did not support NFS over TCP. -.P -Before 2.4.20, the Linux NFS client used a heuristic -to determine whether cached file data was still valid -rather than using the standard close-to-open cache coherency method -described above. -.P -Starting with 2.4.22, the Linux NFS client employs -a Van Jacobsen-based RTT estimator to determine retransmit -timeout values when using NFS over UDP. -.P -Before 2.6.0, the Linux NFS client did not support NFS version 4. -.P -Before 2.6.8, the Linux NFS client used only synchronous reads and writes -when the -.BR rsize " and " wsize -settings were smaller than the system's page size. -.P -The Linux client's support for protocol versions depend on whether the -kernel was built with options CONFIG_NFS_V2, CONFIG_NFS_V3, -CONFIG_NFS_V4, CONFIG_NFS_V4_1, and CONFIG_NFS_V4_2. -.SH "SEE ALSO" -.BR fstab (5), -.BR mount (8), -.BR umount (8), -.BR mount.nfs (5), -.BR umount.nfs (5), -.BR exports (5), -.BR nfsmount.conf (5), -.BR netconfig (5), -.BR ipv6 (7), -.BR nfsd (8), -.BR sm-notify (8), -.BR rpc.statd (8), -.BR rpc.idmapd (8), -.BR rpc.gssd (8), -.BR rpc.svcgssd (8), -.BR kerberos (1) -.sp -RFC 768 for the UDP specification. -.br -RFC 793 for the TCP specification. -.br -RFC 1094 for the NFS version 2 specification. -.br -RFC 1813 for the NFS version 3 specification. -.br -RFC 1832 for the XDR specification. -.br -RFC 1833 for the RPC bind specification. -.br -RFC 2203 for the RPCSEC GSS API protocol specification. -.br -RFC 7530 for the NFS version 4.0 specification. -.br -RFC 5661 for the NFS version 4.1 specification. -.br -RFC 7862 for the NFS version 4.2 specification. diff --git a/nfs-utils-2.5.2/utils/mount/nfs4_mount.h b/nfs-utils-2.5.2/utils/mount/nfs4_mount.h deleted file mode 100644 index b03792e..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfs4_mount.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _LINUX_NFS4_MOUNT_H -#define _LINUX_NFS4_MOUNT_H - -/* - * linux/include/linux/nfs4_mount.h - * - * Copyright (C) 2002 Trond Myklebust - * - * structure passed from user-space to kernel-space during an nfsv4 mount - */ - -/* - * WARNING! Do not delete or change the order of these fields. If - * a new field is required then add it to the end. The version field - * tracks which fields are present. This will ensure some measure of - * mount-to-kernel version compatibility. Some of these aren't used yet - * but here they are anyway. - */ -#define NFS4_MOUNT_VERSION 1 - -struct nfs_string { - unsigned int len; - const char* data; -}; - -struct nfs4_mount_data { - int version; /* 1 */ - int flags; /* 1 */ - int rsize; /* 1 */ - int wsize; /* 1 */ - int timeo; /* 1 */ - int retrans; /* 1 */ - int acregmin; /* 1 */ - int acregmax; /* 1 */ - int acdirmin; /* 1 */ - int acdirmax; /* 1 */ - - /* see the definition of 'struct clientaddr4' in RFC3010 */ - struct nfs_string client_addr; /* 1 */ - - /* Mount path */ - struct nfs_string mnt_path; /* 1 */ - - /* Server details */ - struct nfs_string hostname; /* 1 */ - /* Server IP address */ - unsigned int host_addrlen; /* 1 */ - struct sockaddr* host_addr; /* 1 */ - - /* Transport protocol to use */ - int proto; /* 1 */ - - /* Pseudo-flavours to use for authentication. See RFC2623 */ - int auth_flavourlen; /* 1 */ - int *auth_flavours; /* 1 */ -}; - -/* bits in the flags field */ -/* Note: the fields that correspond to existing NFSv2/v3 mount options - * should mirror the values from include/linux/nfs_mount.h - */ - -#define NFS4_MOUNT_SOFT 0x0001 /* 1 */ -#define NFS4_MOUNT_INTR 0x0002 /* 1 */ -#define NFS4_MOUNT_NOCTO 0x0010 /* 1 */ -#define NFS4_MOUNT_NOAC 0x0020 /* 1 */ -#define NFS4_MOUNT_STRICTLOCK 0x1000 /* 1 */ -#define NFS4_MOUNT_UNSHARED 0x8000 /* 5 */ -#define NFS4_MOUNT_FLAGMASK 0xFFFF - -int nfs4mount(const char *, const char *, int, char **, int, int); - -#endif diff --git a/nfs-utils-2.5.2/utils/mount/nfs4mount.c b/nfs-utils-2.5.2/utils/mount/nfs4mount.c deleted file mode 100644 index 3e4f1e2..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfs4mount.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * nfs4mount.c -- Linux NFS mount - * Copyright (C) 2002 Trond Myklebust - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Note: this file based on the original nfsmount.c - * - * 2006-06-06 Amit Gud - * - Moved to nfs-utils/utils/mount from util-linux/mount. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_RPCSVC_NFS_PROT_H -#include -#else -#include -#define nfsstat nfs_stat -#endif - -#include "pseudoflavors.h" -#include "nls.h" -#include "xcommon.h" - -#include "mount.h" -#include "mount_constants.h" -#include "nfs4_mount.h" -#include "nfs_mount.h" -#include "error.h" -#include "network.h" - -#if defined(VAR_LOCK_DIR) -#define DEFAULT_DIR VAR_LOCK_DIR -#else -#define DEFAULT_DIR "/var/lock/subsys" -#endif - -extern char *progname; -extern int verbose; -extern int sloppy; - -char *IDMAPLCK = DEFAULT_DIR "/rpcidmapd"; -#define idmapd_check() do { \ - if (access(IDMAPLCK, F_OK)) { \ - printf(_("Warning: rpc.idmapd appears not to be running.\n" \ - " All uids will be mapped to the nobody uid.\n")); \ - } \ -} while(0); - -char *GSSDLCK = DEFAULT_DIR "/rpcgssd"; -#define gssd_check() do { \ - if (access(GSSDLCK, F_OK)) { \ - printf(_("Warning: rpc.gssd appears not to be running.\n")); \ - } \ -} while(0); - -#ifndef NFS_PORT -#define NFS_PORT 2049 -#endif - -#define MAX_USER_FLAVOUR 16 - -static int parse_sec(char *sec, int *pseudoflavour) -{ - int i, num_flavour = 0; - - for (sec = strtok(sec, ":"); sec; sec = strtok(NULL, ":")) { - if (num_flavour >= MAX_USER_FLAVOUR) { - nfs_error(_("%s: maximum number of security flavors " - "exceeded"), progname); - return 0; - } - for (i = 0; i < flav_map_size; i++) { - if (strcmp(sec, flav_map[i].flavour) == 0) { - pseudoflavour[num_flavour++] = flav_map[i].fnum; - break; - } - } - if (i == flav_map_size) { - nfs_error(_("%s: unknown security type %s\n"), - progname, sec); - return 0; - } - } - if (!num_flavour) - nfs_error(_("%s: no security flavors passed to sec= option"), - progname); - return num_flavour; -} - -static int parse_devname(char *hostdir, char **hostname, char **dirname) -{ - char *s; - - if (!(s = strchr(hostdir, ':'))) { - nfs_error(_("%s: directory to mount not in host:dir format"), - progname); - return -1; - } - *hostname = hostdir; - *dirname = s + 1; - *s = '\0'; - /* Ignore all but first hostname in replicated mounts - until they can be fully supported. (mack@sgi.com) */ - if ((s = strchr(hostdir, ','))) { - *s = '\0'; - nfs_error(_("%s: warning: multiple hostnames not supported"), - progname); - } - return 0; -} - -static int fill_ipv4_sockaddr(const char *hostname, struct sockaddr_in *addr) -{ - struct hostent *hp; - addr->sin_family = AF_INET; - - if (inet_aton(hostname, &addr->sin_addr)) - return 0; - if ((hp = gethostbyname(hostname)) == NULL) { - nfs_error(_("%s: can't get address for %s\n"), - progname, hostname); - return -1; - } - if (hp->h_length > (int)sizeof(struct in_addr)) { - nfs_error(_("%s: got bad hp->h_length"), progname); - hp->h_length = sizeof(struct in_addr); - } - memcpy(&addr->sin_addr, hp->h_addr, hp->h_length); - return 0; -} - -static int get_my_ipv4addr(char *ip_addr, int len) -{ - char myname[1024]; - struct sockaddr_in myaddr; - - if (gethostname(myname, sizeof(myname))) { - nfs_error(_("%s: can't determine client address\n"), - progname); - return -1; - } - if (fill_ipv4_sockaddr(myname, &myaddr)) - return -1; - snprintf(ip_addr, len, "%s", inet_ntoa(myaddr.sin_addr)); - ip_addr[len-1] = '\0'; - return 0; -} - -int nfs4mount(const char *spec, const char *node, int flags, - char **extra_opts, int fake, int running_bg) -{ - static struct nfs4_mount_data data; - static char hostdir[1024]; - static char ip_addr[16] = "127.0.0.1"; - static struct sockaddr_in server_addr, client_addr; - static int pseudoflavour[MAX_USER_FLAVOUR]; - int num_flavour = 0; - int ip_addr_in_opts = 0; - - char *hostname, *dirname, *old_opts; - char new_opts[1024]; - char *opt, *opteq; - char *s; - int val; - int bg, soft, intr; - int nocto, noac, unshared; - int retry; - int retval = EX_FAIL; - time_t timeout, t; - - if (strlen(spec) >= sizeof(hostdir)) { - nfs_error(_("%s: excessively long host:dir argument\n"), - progname); - goto fail; - } - strcpy(hostdir, spec); - if (parse_devname(hostdir, &hostname, &dirname)) - goto fail; - - if (fill_ipv4_sockaddr(hostname, &server_addr)) - goto fail; - if (get_my_ipv4addr(ip_addr, sizeof(ip_addr))) - goto fail; - - /* add IP address to mtab options for use when unmounting */ - s = inet_ntoa(server_addr.sin_addr); - old_opts = *extra_opts; - if (!old_opts) - old_opts = ""; - if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { - nfs_error(_("%s: excessively long option argument\n"), - progname); - goto fail; - } - if (running_bg) - strncpy(new_opts, old_opts, sizeof(new_opts)-1); - else - snprintf(new_opts, sizeof(new_opts), "%s%saddr=%s", - old_opts, *old_opts ? "," : "", s); - *extra_opts = xstrdup(new_opts); - - /* Set default options. - * rsize/wsize and timeo are left 0 in order to - * let the kernel decide. - */ - memset(&data, 0, sizeof(data)); - data.retrans = 3; - data.acregmin = 3; - data.acregmax = 60; - data.acdirmin = 30; - data.acdirmax = 60; - data.proto = IPPROTO_TCP; - - bg = 0; - soft = 0; - intr = NFS4_MOUNT_INTR; - nocto = 0; - noac = 0; - unshared = 0; - retry = -1; - - /* - * NFSv4 specifies that the default port should be 2049 - */ - server_addr.sin_port = htons(NFS_PORT); - - /* parse options */ - - for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) { - if ((opteq = strchr(opt, '='))) { - val = atoi(opteq + 1); - *opteq = '\0'; - if (!strcmp(opt, "rsize")) - data.rsize = val; - else if (!strcmp(opt, "wsize")) - data.wsize = val; - else if (!strcmp(opt, "timeo")) - data.timeo = val; - else if (!strcmp(opt, "retrans")) - data.retrans = val; - else if (!strcmp(opt, "acregmin")) - data.acregmin = val; - else if (!strcmp(opt, "acregmax")) - data.acregmax = val; - else if (!strcmp(opt, "acdirmin")) - data.acdirmin = val; - else if (!strcmp(opt, "acdirmax")) - data.acdirmax = val; - else if (!strcmp(opt, "actimeo")) { - data.acregmin = val; - data.acregmax = val; - data.acdirmin = val; - data.acdirmax = val; - } - else if (!strcmp(opt, "retry")) - retry = val; - else if (!strcmp(opt, "port")) - server_addr.sin_port = htons(val); - else if (!strcmp(opt, "proto")) { - if (!strncmp(opteq+1, "tcp", 3)) - data.proto = IPPROTO_TCP; - else if (!strncmp(opteq+1, "udp", 3)) - data.proto = IPPROTO_UDP; - else - printf(_("Warning: Unrecognized proto= option.\n")); - } else if (!strcmp(opt, "clientaddr")) { - if (strlen(opteq+1) >= sizeof(ip_addr)) - printf(_("Invalid client address %s"), - opteq+1); - strncpy(ip_addr,opteq+1, sizeof(ip_addr)); - ip_addr[sizeof(ip_addr)-1] = '\0'; - ip_addr_in_opts = 1; - } else if (!strcmp(opt, "sec")) { - num_flavour = parse_sec(opteq+1, pseudoflavour); - if (!num_flavour) - goto fail; - } else if (!strcmp(opt, "addr") || sloppy) { - /* ignore */; - } else { - printf(_("unknown nfs mount parameter: " - "%s=%d\n"), opt, val); - goto fail; - } - } else { - val = 1; - if (!strncmp(opt, "no", 2)) { - val = 0; - opt += 2; - } - if (!strcmp(opt, "bg")) - bg = val; - else if (!strcmp(opt, "fg")) - bg = !val; - else if (!strcmp(opt, "soft")) - soft = val; - else if (!strcmp(opt, "hard")) - soft = !val; - else if (!strcmp(opt, "intr")) - intr = val; - else if (!strcmp(opt, "cto")) - nocto = !val; - else if (!strcmp(opt, "ac")) - noac = !val; - else if (!strcmp(opt, "sharecache")) - unshared = !val; - else if (!sloppy) { - printf(_("unknown nfs mount option: %s%s\n"), - val ? "" : "no", opt); - goto fail; - } - } - } - - /* if retry is still -1, then it wasn't set via an option */ - if (retry == -1) { - if (bg) - retry = 10000; /* 10000 mins == ~1 week */ - else - retry = 2; /* 2 min default on fg mounts */ - } - - data.flags = (soft ? NFS4_MOUNT_SOFT : 0) - | (intr ? NFS4_MOUNT_INTR : 0) - | (nocto ? NFS4_MOUNT_NOCTO : 0) - | (noac ? NFS4_MOUNT_NOAC : 0) - | (unshared ? NFS4_MOUNT_UNSHARED : 0); - - /* - * Give a warning if the rpc.idmapd daemon is not running - */ -#if 0 - /* We shouldn't have these checks as nothing in this package - * creates the files that are checked - */ - idmapd_check(); - - if (num_flavour == 0) - pseudoflavour[num_flavour++] = AUTH_UNIX; - else { - /* - * ditto with rpc.gssd daemon - */ - gssd_check(); - } -#endif - data.auth_flavourlen = num_flavour; - data.auth_flavours = pseudoflavour; - - data.client_addr.data = ip_addr; - data.client_addr.len = strlen(ip_addr); - - data.mnt_path.data = dirname; - data.mnt_path.len = strlen(dirname); - - data.hostname.data = hostname; - data.hostname.len = strlen(hostname); - data.host_addr = (struct sockaddr *)&server_addr; - data.host_addrlen = sizeof(server_addr); - -#ifdef NFS_MOUNT_DEBUG - printf(_("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n"), - data.rsize, data.wsize, data.timeo, data.retrans); - printf(_("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n"), - data.acregmin, data.acregmax, data.acdirmin, data.acdirmax); - printf(_("port = %d, bg = %d, retry = %d, flags = %.8x\n"), - ntohs(server_addr.sin_port), bg, retry, data.flags); - printf(_("soft = %d, intr = %d, nocto = %d, noac = %d, " - "nosharecache = %d\n"), - (data.flags & NFS4_MOUNT_SOFT) != 0, - (data.flags & NFS4_MOUNT_INTR) != 0, - (data.flags & NFS4_MOUNT_NOCTO) != 0, - (data.flags & NFS4_MOUNT_NOAC) != 0, - (data.flags & NFS4_MOUNT_UNSHARED) != 0); - - if (num_flavour > 0) { - int pf_cnt, i; - - printf(_("sec = ")); - for (pf_cnt = 0; pf_cnt < num_flavour; pf_cnt++) { - for (i = 0; i < flav_map_size; i++) { - if (flav_map[i].fnum == pseudoflavour[pf_cnt]) { - printf("%s", flav_map[i].flavour); - break; - } - } - printf("%s", (pf_cnt < num_flavour-1) ? ":" : "\n"); - } - } - printf(_("proto = %s\n"), (data.proto == IPPROTO_TCP) ? _("tcp") : _("udp")); -#endif - - timeout = time(NULL) + 60 * retry; - data.version = NFS4_MOUNT_VERSION; - for (;;) { - if (verbose) { - printf(_("%s: pinging: prog %d vers %d prot %s port %d\n"), - progname, NFS_PROGRAM, 4, - data.proto == IPPROTO_UDP ? "udp" : "tcp", - ntohs(server_addr.sin_port)); - } - client_addr.sin_family = 0; - client_addr.sin_addr.s_addr = 0; - clnt_ping(&server_addr, NFS_PROGRAM, 4, data.proto, &client_addr); - if (rpc_createerr.cf_stat == RPC_SUCCESS) { - if (!ip_addr_in_opts && - client_addr.sin_family != 0 && - client_addr.sin_addr.s_addr != 0) { - snprintf(ip_addr, sizeof(ip_addr), "%s", - inet_ntoa(client_addr.sin_addr)); - data.client_addr.len = strlen(ip_addr); - } - break; - } - - if (!bg) { - switch(rpc_createerr.cf_stat) { - case RPC_TIMEDOUT: - break; - case RPC_SYSTEMERROR: - if (errno == ETIMEDOUT) - break; - /* FALLTHRU */ - default: - rpc_mount_errors(hostname, 0, bg); - goto fail; - } - } - - if (bg && !running_bg) { - if (retry > 0) - retval = EX_BG; - goto fail; - } - - t = time(NULL); - if (t >= timeout) { - rpc_mount_errors(hostname, 0, bg); - goto fail; - } - rpc_mount_errors(hostname, 1, bg); - continue; - } - - if (!fake) { - if (mount(spec, node, "nfs4", - flags & ~(MS_USER|MS_USERS), &data)) { - mount_error(spec, node, errno); - goto fail; - } - } - - return EX_SUCCESS; - -fail: - return retval; -} diff --git a/nfs-utils-2.5.2/utils/mount/nfs_mount.h b/nfs-utils-2.5.2/utils/mount/nfs_mount.h deleted file mode 100644 index ec30c9b..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfs_mount.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * We want to be able to compile mount on old kernels in such a way - * that the binary will work well on more recent kernels. - * Thus, if necessary we teach nfsmount.c the structure of new fields - * that will come later. - * - * Moreover, the new kernel includes conflict with glibc includes - * so it is easiest to ignore the kernel altogether (at compile time). - */ - -#ifndef _NFS_UTILS_MOUNT_NFS_MOUNT_H -#define _NFS_UTILS_MOUNT_NFS_MOUNT_H - -#include -#include - -#define NFS_MOUNT_VERSION 6 -#define NFS_MAX_CONTEXT_LEN 256 - -struct nfs2_fh { - char data[32]; -}; -struct nfs3_fh { - unsigned short size; - unsigned char data[64]; -}; - -struct nfs_mount_data { - int version; /* 1 */ - int fd; /* 1 */ - struct nfs2_fh old_root; /* 1 */ - int flags; /* 1 */ - int rsize; /* 1 */ - int wsize; /* 1 */ - int timeo; /* 1 */ - int retrans; /* 1 */ - int acregmin; /* 1 */ - int acregmax; /* 1 */ - int acdirmin; /* 1 */ - int acdirmax; /* 1 */ - struct sockaddr_in addr; /* 1 */ - char hostname[256]; /* 1 */ - int namlen; /* 2 */ - unsigned int bsize; /* 3 */ - struct nfs3_fh root; /* 4 */ - int pseudoflavor; /* 5 */ - char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */ - -}; - -/* bits in the flags field */ - -#define NFS_MOUNT_SOFT 0x0001 /* 1 */ -#define NFS_MOUNT_INTR 0x0002 /* 1 */ -#define NFS_MOUNT_SECURE 0x0004 /* 1 */ -#define NFS_MOUNT_POSIX 0x0008 /* 1 */ -#define NFS_MOUNT_NOCTO 0x0010 /* 1 */ -#define NFS_MOUNT_NOAC 0x0020 /* 1 */ -#define NFS_MOUNT_TCP 0x0040 /* 2 */ -#define NFS_MOUNT_VER3 0x0080 /* 3 */ -#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */ -#define NFS_MOUNT_NONLM 0x0200 /* 3 */ -#define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */ -#define NFS_MOUNT_NOACL 0x0800 /* 4 */ -#define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */ -#define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */ -#define NFS_MOUNT_UNSHARED 0x8000 /* 5 */ - -/* security pseudoflavors */ - -#ifndef AUTH_GSS_KRB5 -#define AUTH_GSS_KRB5 390003 -#define AUTH_GSS_KRB5I 390004 -#define AUTH_GSS_KRB5P 390005 -#define AUTH_GSS_LKEY 390006 -#define AUTH_GSS_LKEYI 390007 -#define AUTH_GSS_LKEYP 390008 -#endif - -int nfsmount(const char *, const char *, int , char **, int, int); -int nfsumount(int, char **); - -#endif /* _NFS_UTILS_MOUNT_NFS_MOUNT_H */ diff --git a/nfs-utils-2.5.2/utils/mount/nfsmount.c b/nfs-utils-2.5.2/utils/mount/nfsmount.c deleted file mode 100644 index 3d95da9..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfsmount.c +++ /dev/null @@ -1,873 +0,0 @@ -/* - * nfsmount.c -- Linux NFS mount - * Copyright (C) 1993 Rick Sladkey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port - * numbers to be specified on the command line. - * - * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler : - * Omit the call to connect() for Linux version 1.3.11 or later. - * - * Wed Oct 1 23:55:28 1997: Dick Streefland - * Implemented the "bg", "fg" and "retry" mount options for NFS. - * - * 1999-02-22 Arkadiusz Miskiewicz - * - added Native Language Support - * - * Modified by Olaf Kirch and Trond Myklebust for new NFS code, - * plus NFSv3 stuff. - * - * 2006-06-06 Amit Gud - * - Moved with modifcations to nfs-utils/utils/mount from util-linux/mount. - */ - -/* - * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xcommon.h" -#include "mount.h" -#include "nfs_mount.h" -#include "mount_constants.h" -#include "nls.h" -#include "error.h" -#include "network.h" -#include "version.h" - -#ifdef HAVE_RPCSVC_NFS_PROT_H -#include -#else -#include -#define nfsstat nfs_stat -#endif - -#ifndef NFS_PORT -#define NFS_PORT 2049 -#endif -#ifndef NFS_FHSIZE -#define NFS_FHSIZE 32 -#endif - -#ifndef HAVE_INET_ATON -#define inet_aton(a,b) (0) -#endif - -typedef dirpath mnt2arg_t; -typedef dirpath mnt3arg_t; -typedef dirpath mntarg_t; - -typedef struct fhstatus mnt2res_t; -typedef struct mountres3 mnt3res_t; -typedef union { - mnt2res_t nfsv2; - mnt3res_t nfsv3; -} mntres_t; - -extern int nfs_mount_data_version; -extern char *progname; -extern int verbose; -extern int sloppy; - -static inline enum clnt_stat -nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res) -{ - return clnt_call(clnt, MOUNTPROC3_MNT, - (xdrproc_t) xdr_dirpath, (caddr_t) mnt3arg, - (xdrproc_t) xdr_mountres3, (caddr_t) mnt3res, - TIMEOUT); -} - -static inline enum clnt_stat -nfs2_mount(CLIENT *clnt, mnt2arg_t *mnt2arg, mnt2res_t *mnt2res) -{ - return clnt_call(clnt, MOUNTPROC_MNT, - (xdrproc_t) xdr_dirpath, (caddr_t) mnt2arg, - (xdrproc_t) xdr_fhstatus, (caddr_t) mnt2res, - TIMEOUT); -} - -static int -nfs_call_mount(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server, - mntarg_t *mntarg, mntres_t *mntres) -{ - CLIENT *clnt; - enum clnt_stat stat; - int msock; - - if (!probe_bothports(mnt_server, nfs_server)) - goto out_bad; - - clnt = mnt_openclnt(mnt_server, &msock); - if (!clnt) - goto out_bad; - /* make pointers in xdr_mountres3 NULL so - * that xdr_array allocates memory for us - */ - memset(mntres, 0, sizeof(*mntres)); - switch (mnt_server->pmap.pm_vers) { - case 3: - stat = nfs3_mount(clnt, mntarg, &mntres->nfsv3); - break; - case 2: - case 1: - stat = nfs2_mount(clnt, mntarg, &mntres->nfsv2); - break; - default: - goto out_bad; - } - if (stat != RPC_SUCCESS) { - clnt_geterr(clnt, &rpc_createerr.cf_error); - rpc_createerr.cf_stat = stat; - } - mnt_closeclnt(clnt, msock); - if (stat == RPC_SUCCESS) - return 1; - out_bad: - return 0; -} - -static int -parse_options(char *old_opts, struct nfs_mount_data *data, - int *bg, int *retry, clnt_addr_t *mnt_server, - clnt_addr_t *nfs_server, char *new_opts, const int opt_size) -{ - struct sockaddr_in *mnt_saddr = &mnt_server->saddr; - struct pmap *mnt_pmap = &mnt_server->pmap; - struct pmap *nfs_pmap = &nfs_server->pmap; - int len; - char *opt, *opteq, *p, *opt_b, *tmp_opts; - char *mounthost = NULL; - char cbuf[128]; - int open_quote = 0; - - data->flags = 0; - *bg = 0; - - len = strlen(new_opts); - tmp_opts = xstrdup(old_opts); - for (p=tmp_opts, opt_b=NULL; p && *p; p++) { - if (!opt_b) - opt_b = p; /* begin of the option item */ - if (*p == '"') - open_quote ^= 1; /* reverse the status */ - if (open_quote) - continue; /* still in a quoted block */ - if (*p == ',') - *p = '\0'; /* terminate the option item */ - if (*p == '\0' || *(p+1) == '\0') { - opt = opt_b; /* opt is useful now */ - opt_b = NULL; - } - else - continue; /* still somewhere in the option item */ - - if (strlen(opt) >= sizeof(cbuf)) - goto bad_parameter; - if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) { - int val = atoi(opteq + 1); - *opteq = '\0'; - if (!strcmp(opt, "rsize")) - data->rsize = val; - else if (!strcmp(opt, "wsize")) - data->wsize = val; - else if (!strcmp(opt, "timeo")) - data->timeo = val; - else if (!strcmp(opt, "retrans")) - data->retrans = val; - else if (!strcmp(opt, "acregmin")) - data->acregmin = val; - else if (!strcmp(opt, "acregmax")) - data->acregmax = val; - else if (!strcmp(opt, "acdirmin")) - data->acdirmin = val; - else if (!strcmp(opt, "acdirmax")) - data->acdirmax = val; - else if (!strcmp(opt, "actimeo")) { - data->acregmin = val; - data->acregmax = val; - data->acdirmin = val; - data->acdirmax = val; - } - else if (!strcmp(opt, "retry")) - *retry = val; - else if (!strcmp(opt, "port")) - nfs_pmap->pm_port = val; - else if (!strcmp(opt, "mountport")) - mnt_pmap->pm_port = val; - else if (!strcmp(opt, "mountprog")) - mnt_pmap->pm_prog = val; - else if (!strcmp(opt, "mountvers")) - mnt_pmap->pm_vers = val; - else if (!strcmp(opt, "mounthost")) - mounthost=xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,")); - else if (!strcmp(opt, "nfsprog")) - nfs_pmap->pm_prog = val; - else if (!strcmp(opt, "nfsvers") || - !strcmp(opt, "vers")) { - nfs_pmap->pm_vers = val; - opt = "nfsvers"; -#if NFS_MOUNT_VERSION >= 2 - } else if (!strcmp(opt, "namlen")) { - if (nfs_mount_data_version >= 2) - data->namlen = val; - else if (sloppy) - continue; - else - goto bad_parameter; -#endif - } else if (!strcmp(opt, "addr")) { - /* ignore */; - continue; - } else if (sloppy) - continue; - else - goto bad_parameter; - sprintf(cbuf, "%s=%s,", opt, opteq+1); - } else if (opteq) { - *opteq = '\0'; - if (!strcmp(opt, "proto")) { - if (!strcmp(opteq+1, "udp")) { - nfs_pmap->pm_prot = IPPROTO_UDP; - mnt_pmap->pm_prot = IPPROTO_UDP; -#if NFS_MOUNT_VERSION >= 2 - data->flags &= ~NFS_MOUNT_TCP; - } else if (!strcmp(opteq+1, "tcp") && - nfs_mount_data_version > 2) { - nfs_pmap->pm_prot = IPPROTO_TCP; - mnt_pmap->pm_prot = IPPROTO_TCP; - data->flags |= NFS_MOUNT_TCP; -#endif - } else if (sloppy) - continue; - else - goto bad_parameter; -#if NFS_MOUNT_VERSION >= 5 - } else if (!strcmp(opt, "sec")) { - char *secflavor = opteq+1; - /* see RFC 2623 */ - if (nfs_mount_data_version < 5) { - printf(_("Warning: ignoring sec=%s option\n"), - secflavor); - continue; - } else if (!strcmp(secflavor, "none")) - data->pseudoflavor = AUTH_NONE; - else if (!strcmp(secflavor, "sys")) - data->pseudoflavor = AUTH_SYS; - else if (!strcmp(secflavor, "krb5")) - data->pseudoflavor = AUTH_GSS_KRB5; - else if (!strcmp(secflavor, "krb5i")) - data->pseudoflavor = AUTH_GSS_KRB5I; - else if (!strcmp(secflavor, "krb5p")) - data->pseudoflavor = AUTH_GSS_KRB5P; - else if (sloppy) - continue; - else { - printf(_("Warning: Unrecognized security flavor %s.\n"), - secflavor); - goto bad_parameter; - } - data->flags |= NFS_MOUNT_SECFLAVOUR; -#endif - } else if (!strcmp(opt, "mounthost")) - mounthost=xstrndup(opteq+1, - strcspn(opteq+1," \t\n\r,")); - else if (!strcmp(opt, "context")) { - char *context = opteq + 1; - int ctxlen = strlen(context); - - if (ctxlen > NFS_MAX_CONTEXT_LEN) { - nfs_error(_("context parameter exceeds" - " limit of %d"), - NFS_MAX_CONTEXT_LEN); - goto bad_parameter; - } - /* The context string is in the format of - * "system_u:object_r:...". We only want - * the context str between the quotes. - */ - if (*context == '"') - strncpy(data->context, context+1, - ctxlen-2); - else - strncpy(data->context, context, - NFS_MAX_CONTEXT_LEN); - } else if (sloppy) - continue; - else - goto bad_parameter; - sprintf(cbuf, "%s=%s,", opt, opteq+1); - } else { - int val = 1; - if (!strncmp(opt, "no", 2)) { - val = 0; - opt += 2; - } - if (!strcmp(opt, "bg")) - *bg = val; - else if (!strcmp(opt, "fg")) - *bg = !val; - else if (!strcmp(opt, "soft")) { - data->flags &= ~NFS_MOUNT_SOFT; - if (val) - data->flags |= NFS_MOUNT_SOFT; - } else if (!strcmp(opt, "hard")) { - data->flags &= ~NFS_MOUNT_SOFT; - if (!val) - data->flags |= NFS_MOUNT_SOFT; - } else if (!strcmp(opt, "intr")) { - data->flags &= ~NFS_MOUNT_INTR; - if (val) - data->flags |= NFS_MOUNT_INTR; - } else if (!strcmp(opt, "posix")) { - data->flags &= ~NFS_MOUNT_POSIX; - if (val) - data->flags |= NFS_MOUNT_POSIX; - } else if (!strcmp(opt, "cto")) { - data->flags &= ~NFS_MOUNT_NOCTO; - if (!val) - data->flags |= NFS_MOUNT_NOCTO; - } else if (!strcmp(opt, "ac")) { - data->flags &= ~NFS_MOUNT_NOAC; - if (!val) - data->flags |= NFS_MOUNT_NOAC; -#if NFS_MOUNT_VERSION >= 2 - } else if (!strcmp(opt, "tcp")) { - data->flags &= ~NFS_MOUNT_TCP; - if (val) { - if (nfs_mount_data_version < 2) - goto bad_option; - nfs_pmap->pm_prot = IPPROTO_TCP; - mnt_pmap->pm_prot = IPPROTO_TCP; - data->flags |= NFS_MOUNT_TCP; - } else { - mnt_pmap->pm_prot = IPPROTO_UDP; - nfs_pmap->pm_prot = IPPROTO_UDP; - } - } else if (!strcmp(opt, "udp")) { - data->flags &= ~NFS_MOUNT_TCP; - if (!val) { - if (nfs_mount_data_version < 2) - goto bad_option; - nfs_pmap->pm_prot = IPPROTO_TCP; - mnt_pmap->pm_prot = IPPROTO_TCP; - data->flags |= NFS_MOUNT_TCP; - } else { - nfs_pmap->pm_prot = IPPROTO_UDP; - mnt_pmap->pm_prot = IPPROTO_UDP; - } -#endif -#if NFS_MOUNT_VERSION >= 3 - } else if (!strcmp(opt, "lock")) { - data->flags &= ~NFS_MOUNT_NONLM; - if (!val) { - if (nfs_mount_data_version < 3) - goto bad_option; - data->flags |= NFS_MOUNT_NONLM; - } -#endif -#if NFS_MOUNT_VERSION >= 4 - } else if (!strcmp(opt, "broken_suid")) { - data->flags &= ~NFS_MOUNT_BROKEN_SUID; - if (val) { - if (nfs_mount_data_version < 4) - goto bad_option; - data->flags |= NFS_MOUNT_BROKEN_SUID; - } - } else if (!strcmp(opt, "acl")) { - data->flags &= ~NFS_MOUNT_NOACL; - if (!val) - data->flags |= NFS_MOUNT_NOACL; - } else if (!strcmp(opt, "rdirplus")) { - data->flags &= ~NFS_MOUNT_NORDIRPLUS; - if (!val) - data->flags |= NFS_MOUNT_NORDIRPLUS; - } else if (!strcmp(opt, "sharecache")) { - data->flags &= ~NFS_MOUNT_UNSHARED; - if (!val) - data->flags |= NFS_MOUNT_UNSHARED; -#endif - } else { - bad_option: - if (sloppy) - continue; - nfs_error(_("%s: Unsupported nfs mount option:" - " %s%s"), progname, - val ? "" : "no", opt); - goto out_bad; - } - sprintf(cbuf, val ? "%s," : "no%s,", opt); - } - len += strlen(cbuf); - if (len >= opt_size) { - nfs_error(_("%s: excessively long option argument"), - progname); - goto out_bad; - } - strcat(new_opts, cbuf); - } - /* See if the nfs host = mount host. */ - if (mounthost) { - if (!nfs_gethostbyname(mounthost, mnt_saddr)) - goto out_bad; - *mnt_server->hostname = mounthost; - } - free(tmp_opts); - return 1; - bad_parameter: - nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt); - out_bad: - free(tmp_opts); - free(mounthost); - return 0; -} - -static int nfsmnt_check_compat(const struct pmap *nfs_pmap, - const struct pmap *mnt_pmap) -{ - unsigned int max_nfs_vers = (nfs_mount_data_version >= 4) ? 3 : 2; - unsigned int max_mnt_vers = (nfs_mount_data_version >= 4) ? 3 : 2; - - if (nfs_pmap->pm_vers == 4) { - nfs_error(_("%s: Please use '-t nfs4' " - "instead of '-o vers=4'"), progname); - goto out_bad; - } - - if (nfs_pmap->pm_vers) { - if (nfs_pmap->pm_vers > max_nfs_vers || nfs_pmap->pm_vers < 2) { - nfs_error(_("%s: NFS version %ld is not supported"), - progname, nfs_pmap->pm_vers); - goto out_bad; - } - } - - if (mnt_pmap->pm_vers > max_mnt_vers) { - nfs_error(_("%s: NFS mount version %ld is not supported"), - progname, mnt_pmap->pm_vers); - goto out_bad; - } - - return 1; - -out_bad: - return 0; -} - -int -nfsmount(const char *spec, const char *node, int flags, - char **extra_opts, int fake, int running_bg) -{ - char hostdir[1024]; - char *hostname, *dirname, *old_opts, *mounthost = NULL; - char new_opts[1024], cbuf[1024]; - static struct nfs_mount_data data; - int val; - static int doonce = 0; - - clnt_addr_t mnt_server = { - .hostname = &mounthost - }; - clnt_addr_t nfs_server = { - .hostname = &hostname - }; - struct sockaddr_in *nfs_saddr = &nfs_server.saddr; - struct pmap *mnt_pmap = &mnt_server.pmap, - *nfs_pmap = &nfs_server.pmap; - struct pmap save_mnt, save_nfs; - - int fsock = -1; - - mntres_t mntres; - - struct stat statbuf; - char *s; - int bg, retry; - int retval = EX_FAIL; - time_t t; - time_t prevt; - time_t timeout; - - if (strlen(spec) >= sizeof(hostdir)) { - nfs_error(_("%s: excessively long host:dir argument"), - progname); - goto fail; - } - strcpy(hostdir, spec); - if ((s = strchr(hostdir, ':'))) { - hostname = hostdir; - dirname = s + 1; - *s = '\0'; - /* Ignore all but first hostname in replicated mounts - until they can be fully supported. (mack@sgi.com) */ - if ((s = strchr(hostdir, ','))) { - *s = '\0'; - nfs_error(_("%s: warning: " - "multiple hostnames not supported"), - progname); - } - } else { - nfs_error(_("%s: directory to mount not in host:dir format"), - progname); - goto fail; - } - - if (!nfs_gethostbyname(hostname, nfs_saddr)) - goto fail; - mounthost = hostname; - memcpy (&mnt_server.saddr, nfs_saddr, sizeof (mnt_server.saddr)); - - /* add IP address to mtab options for use when unmounting */ - - s = inet_ntoa(nfs_saddr->sin_addr); - old_opts = *extra_opts; - if (!old_opts) - old_opts = ""; - - /* Set default options. - * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to - * let the kernel decide. - * timeo is filled in after we know whether it'll be TCP or UDP. */ - memset(&data, 0, sizeof(data)); - data.acregmin = 3; - data.acregmax = 60; - data.acdirmin = 30; - data.acdirmax = 60; -#if NFS_MOUNT_VERSION >= 2 - data.namlen = NAME_MAX; -#endif - - bg = 0; - retry = -1; - - memset(mnt_pmap, 0, sizeof(*mnt_pmap)); - mnt_pmap->pm_prog = MOUNTPROG; - memset(nfs_pmap, 0, sizeof(*nfs_pmap)); - nfs_pmap->pm_prog = NFS_PROGRAM; - - /* parse options */ - new_opts[0] = 0; - if (!parse_options(old_opts, &data, &bg, &retry, &mnt_server, &nfs_server, - new_opts, sizeof(new_opts))) - goto fail; - if (!nfsmnt_check_compat(nfs_pmap, mnt_pmap)) - goto fail; - - if (retry == -1) { - if (bg) - retry = 10000; /* 10000 mins == ~1 week*/ - else - retry = 2; /* 2 min default on fg mounts */ - } - -#ifdef NFS_MOUNT_DEBUG - printf(_("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n"), - data.rsize, data.wsize, data.timeo, data.retrans); - printf(_("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n"), - data.acregmin, data.acregmax, data.acdirmin, data.acdirmax); - printf(_("port = %lu, bg = %d, retry = %d, flags = %.8x\n"), - nfs_pmap->pm_port, bg, retry, data.flags); - printf(_("mountprog = %lu, mountvers = %lu, nfsprog = %lu, nfsvers = %lu\n"), - mnt_pmap->pm_prog, mnt_pmap->pm_vers, - nfs_pmap->pm_prog, nfs_pmap->pm_vers); - printf(_("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d"), - (data.flags & NFS_MOUNT_SOFT) != 0, - (data.flags & NFS_MOUNT_INTR) != 0, - (data.flags & NFS_MOUNT_POSIX) != 0, - (data.flags & NFS_MOUNT_NOCTO) != 0, - (data.flags & NFS_MOUNT_NOAC) != 0); -#if NFS_MOUNT_VERSION >= 2 - printf(_(", tcp = %d"), - (data.flags & NFS_MOUNT_TCP) != 0); -#endif -#if NFS_MOUNT_VERSION >= 4 - printf(_(", noacl = %d"), (data.flags & NFS_MOUNT_NOACL) != 0); -#endif -#if NFS_MOUNT_VERSION >= 5 - printf(_(", sec = %u"), data.pseudoflavor); - printf(_(", readdirplus = %d"), (data.flags & NFS_MOUNT_NORDIRPLUS) != 0); -#endif - printf("\n"); -#endif - - data.version = nfs_mount_data_version; - - if (flags & MS_REMOUNT) - goto out_ok; - - /* create mount deamon client */ - - /* - * The following loop implements the mount retries. On the first - * call, "running_bg" is 0. When the mount times out, and the - * "bg" option is set, the exit status EX_BG will be returned. - * For a backgrounded mount, there will be a second call by the - * child process with "running_bg" set to 1. - * - * The case where the mount point is not present and the "bg" - * option is set, is treated as a timeout. This is done to - * support nested mounts. - * - * The "retry" count specified by the user is the number of - * minutes to retry before giving up. - * - * Only the first error message will be displayed. - */ - timeout = time(NULL) + 60 * retry; - prevt = 0; - t = 30; - val = 1; - - memcpy(&save_nfs, nfs_pmap, sizeof(save_nfs)); - memcpy(&save_mnt, mnt_pmap, sizeof(save_mnt)); - for (;;) { - if (bg && stat(node, &statbuf) == -1) { - /* no mount point yet - sleep */ - if (running_bg) { - sleep(val); /* 1, 2, 4, 8, 16, 30, ... */ - val *= 2; - if (val > 30) - val = 30; - } - } else { - int stat; - /* be careful not to use too many CPU cycles */ - if (t - prevt < 30) - sleep(30); - - stat = nfs_call_mount(&mnt_server, &nfs_server, - &dirname, &mntres); - if (stat) - break; - memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap)); - memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap)); - prevt = t; - } - if (!bg) { - switch(rpc_createerr.cf_stat){ - case RPC_TIMEDOUT: - break; - case RPC_SYSTEMERROR: - if (errno == ETIMEDOUT) - break; - /* FALLTHRU */ - default: - rpc_mount_errors(*nfs_server.hostname, 0, bg); - goto fail; - } - t = time(NULL); - if (t >= timeout) { - rpc_mount_errors(*nfs_server.hostname, 0, bg); - goto fail; - } - rpc_mount_errors(*nfs_server.hostname, 1, bg); - continue; - } - if (!running_bg) { - if (retry > 0) - retval = EX_BG; - goto fail; - } - t = time(NULL); - if (t >= timeout) { - rpc_mount_errors(*nfs_server.hostname, 0, bg); - goto fail; - } - if (doonce++ < 1) - rpc_mount_errors(*nfs_server.hostname, 1, bg); - } - - if (mnt_pmap->pm_vers <= 2) { - if (mntres.nfsv2.fhs_status != 0) { - nfs_error(_("%s: %s:%s failed, reason given by server: %s"), - progname, hostname, dirname, - nfs_strerror(mntres.nfsv2.fhs_status)); - goto fail; - } - memcpy(data.root.data, - (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle, - NFS_FHSIZE); -#if NFS_MOUNT_VERSION >= 4 - data.root.size = NFS_FHSIZE; - memcpy(data.old_root.data, - (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle, - NFS_FHSIZE); -#endif - } else { -#if NFS_MOUNT_VERSION >= 4 - mountres3_ok *mountres; - fhandle3 *fhandle; - int i, n_flavors, *flavor, yum = 0; - if (mntres.nfsv3.fhs_status != 0) { - nfs_error(_("%s: %s:%s failed, reason given by server: %s"), - progname, hostname, dirname, - nfs_strerror(mntres.nfsv3.fhs_status)); - goto fail; - } -#if NFS_MOUNT_VERSION >= 5 - mountres = &mntres.nfsv3.mountres3_u.mountinfo; - n_flavors = mountres->auth_flavors.auth_flavors_len; - if (n_flavors <= 0) - goto noauth_flavors; - - flavor = mountres->auth_flavors.auth_flavors_val; - for (i = 0; i < n_flavors; ++i) { - /* - * Per RFC2623, section 2.7, we should prefer the - * flavour listed first. - * If no flavour requested, use the first simple - * flavour that is offered. - */ - if (! (data.flags & NFS_MOUNT_SECFLAVOUR) && - (flavor[i] == AUTH_SYS || - flavor[i] == AUTH_NONE)) { - data.pseudoflavor = flavor[i]; - data.flags |= NFS_MOUNT_SECFLAVOUR; - } - if (flavor[i] == data.pseudoflavor) - yum = 1; -#ifdef NFS_MOUNT_DEBUG - printf(_("auth flavor %d: %d\n"), i, flavor[i]); -#endif - } - if (!yum) { - nfs_error(_("%s: %s:%s failed, security flavor " - "not supported"), - progname, hostname, dirname); - /* server has registered us in rmtab, send umount */ - nfs_call_umount(&mnt_server, &dirname); - goto fail; - } -noauth_flavors: -#endif - fhandle = &mntres.nfsv3.mountres3_u.mountinfo.fhandle; - memset(data.old_root.data, 0, NFS_FHSIZE); - memset(&data.root, 0, sizeof(data.root)); - data.root.size = fhandle->fhandle3_len; - memcpy(data.root.data, - (char *) fhandle->fhandle3_val, - fhandle->fhandle3_len); - - data.flags |= NFS_MOUNT_VER3; -#endif - } - - if (nfs_mount_data_version == 1) { - /* create nfs socket for kernel */ - if (nfs_pmap->pm_prot == IPPROTO_TCP) - fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - else - fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (fsock < 0) { - perror(_("nfs socket")); - goto fail; - } - if (bindresvport(fsock, 0) < 0) { - perror(_("nfs bindresvport")); - goto fail; - } - } - -#ifdef NFS_MOUNT_DEBUG - printf(_("using port %lu for nfs deamon\n"), nfs_pmap->pm_port); -#endif - nfs_saddr->sin_port = htons(nfs_pmap->pm_port); - /* - * connect() the socket for kernels 1.3.10 and below only, - * to avoid problems with multihomed hosts. - * --Swen - */ - if (linux_version_code() <= MAKE_VERSION(1, 3, 10) && fsock != -1 - && connect(fsock, (struct sockaddr *) nfs_saddr, - sizeof (*nfs_saddr)) < 0) { - perror(_("nfs connect")); - goto fail; - } - -#if NFS_MOUNT_VERSION >= 2 - if (nfs_pmap->pm_prot == IPPROTO_TCP) - data.flags |= NFS_MOUNT_TCP; - else - data.flags &= ~NFS_MOUNT_TCP; -#endif - - /* prepare data structure for kernel */ - - data.fd = fsock; - memcpy((char *) &data.addr, (char *) nfs_saddr, sizeof(data.addr)); - strncpy(data.hostname, hostname, sizeof(data.hostname)-1); - - out_ok: - /* Ensure we have enough padding for the following strcat()s */ - if (strlen(new_opts) + strlen(s) + 30 >= sizeof(new_opts)) { - nfs_error(_("%s: excessively long option argument"), - progname); - goto fail; - } - - snprintf(cbuf, sizeof(cbuf)-1, "addr=%s", s); - strcat(new_opts, cbuf); - - *extra_opts = xstrdup(new_opts); - - if (!fake && !(data.flags & NFS_MOUNT_NONLM)) { - if (!start_statd()) { - nfs_error(_("%s: rpc.statd is not running but is " - "required for remote locking.\n" - " Either use '-o nolock' to keep " - "locks local, or start statd."), - progname); - goto fail; - } - } - - if (!fake) { - if (mount(spec, node, "nfs", - flags & ~(MS_USER|MS_USERS), &data)) { - mount_error(spec, node, errno); - goto fail; - } - } - - return EX_SUCCESS; - - /* abort */ - fail: - if (fsock != -1) - close(fsock); - return retval; -} diff --git a/nfs-utils-2.5.2/utils/mount/nfsmount.conf b/nfs-utils-2.5.2/utils/mount/nfsmount.conf deleted file mode 100644 index 6bdc225..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfsmount.conf +++ /dev/null @@ -1,144 +0,0 @@ -# -# /etc/nfsmount.conf - see nfsmount.conf(5) for details -# -# This is an NFS mount configuration file. This file can be broken -# up into three different sections: Mount, Server and Global -# -# [ MountPoint "Mount_point" ] -# This section defines all the mount options that -# should be used on a particular mount point. The '' -# string need to be an exact match of the path in the mount -# command. Example: -# [ MountPoint "/export/home" ] -# background=True -# Would cause all mount to /export/home would be done in -# the background -# -# [ Server "Server_Name" ] -# This section defines all the mount options that -# should be used on mounts to a particular NFS server. -# Example: -# [ Server "nfsserver.foo.com" ] -# rsize=32k -# wsize=32k -# All reads and writes to the 'nfsserver.foo.com' server -# will be done with 32k (32768 bytes) block sizes. -# -[ NFSMount_Global_Options ] -# This statically named section defines global mount -# options that can be applied on all NFS mount. -# -# Protocol Version [2,3,4] -# This defines the default protocol version which will -# be used to start the negotiation with the server. -# Defaultvers=4 -# -# Setting this option makes it mandatory the server supports the -# given version. The mount will fail if the given version is -# not support by the server. -# Nfsvers=4 -# -# Network Protocol [udp,tcp,rdma] (Note: values are case sensitive) -# This defines the default network protocol which will -# be used to start the negotiation with the server. -# Defaultproto=tcp -# -# Setting this option makes it mandatory the server supports the -# given network protocol. The mount will fail if the given network -# protocol is not supported by the server. -# Proto=tcp -# -# The number of times a request will be retired before -# generating a timeout -# Retrans=2 -# -# The number of minutes that will retry mount -# Retry=2 -# -# The minimum time (in seconds) file attributes are cached -# acregmin=30 -# -# The Maximum time (in seconds) file attributes are cached -# acregmin=60 -# -# The minimum time (in seconds) directory attributes are cached -# acregmin=30 -# -# The Maximum time (in seconds) directory attributes are cached -# acregmin=60 -# -# Enable Access Control Lists -# Acl=False -# -# Enable Attribute Caching -# Ac=True -# -# Do mounts in background (i.e. asynchronously) -# Background=False -# -# Close-To-Open cache coherence -# Cto=True -# -# Do mounts in foreground (i.e. synchronously) -# Foreground=True -# -# How to handle times out from servers (Hard is STRONGLY suggested) -# Hard=True -# Soft=False -# -# Enable File Locking -# Lock=True -# -# Enable READDIRPLUS on NFS version 3 mounts -# Rdirplus=True -# -# Maximum Read Size (in Bytes) -# Rsize=8k -# -# Maximum Write Size (in Bytes) -# Wsize=8k -# -# Maximum Server Block Size (in Bytes) -# Bsize=8k -# -# Ignore unknown mount options -# Sloppy=False -# -# Share Data and Attribute Caches -# Sharecache=True -# -# The amount of time, in tenths of a seconds, the client -# will wait for a response from the server before retransmitting -# the request. -# Timeo=600 -# -# Sets all attributes times to the same time (in seconds) -# actimeo=30 -# -# Server Mountd port mountport -# mountport=4001 -# -# Server Mountd Protocol -# mountproto=tcp -# -# Server Mountd Version -# mountvers=3 -# -# Server Mountd Host -# mounthost=hostname -# -# Server Port -# Port=2049 -# -# RPCGSS security flavors -# [none, sys, krb5, krb5i, krb5p ] -# Sec=sys -# -# Allow Signals to interrupt file operations -# Intr=True -# -# Specifies how the kernel manages its cache of directory -# Lookupcache=all|none|pos|positive -# -# Turn of the caching of that access time -# noatime=True diff --git a/nfs-utils-2.5.2/utils/mount/nfsmount.conf.man b/nfs-utils-2.5.2/utils/mount/nfsmount.conf.man deleted file mode 100644 index 3aa3456..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfsmount.conf.man +++ /dev/null @@ -1,94 +0,0 @@ -.\"@(#)nfsmount.conf.5" -.TH NFSMOUNT.CONF 5 "9 October 2012" -.SH NAME -nfsmount.conf - Configuration file for NFS mounts -.SH SYNOPSIS -Configuration file for NFS mounts that allows options -to be set globally, per server or per mount point. -.SH DESCRIPTION -The configuration file is made up of multiple sections -followed by variables associated with that section. -A section is defined by a string enclosed by -.BR [ -and -.BR ] -branches. -Variables are assignment statements that assign values -to particular variables using the -.BR = -operator, as in -.BR Proto=Tcp . -The variables that can be assigned are exactly the set of NFS specific -mount options listed in -.BR nfs (5). -.PP -Sections are broken up into three basic categories: -Global options, Server options and Mount Point options. -.HP -.B [ NFSMount_Global_Options ] -- This statically named section -defines all of the global mount options that can be -applied to every NFS mount. -.HP -.B [ Server \(lqServer_Name\(rq ] -- This section defines all the mount options that should -be used on mounts to a particular NFS server. The -.I \(lqServer_Name\(rq -strings needs to be surrounded by '\(lq' and -be an exact match of the server name used in the -.B mount -command. -.HP -.B [ MountPoint \(lqMount_Point\(rq ] -- This section defines all the mount options that -should be used on a particular mount point. -The -.I \(lqMount_Point\(rq -string needs to be surrounded by '\(lq' and be an -exact match of the mount point used in the -.BR mount -command. -.SH EXAMPLES -.PP -These are some example lines of how sections and variables -are defined in the configuration file. -.PP -[ NFSMount_Global_Options ] -.br - Proto=Tcp -.RS -.HP -The TCP/IPv4 protocol will be used on every NFS mount. -.HP -.RE -[ Server \(lqnfsserver.foo.com\(rq ] -.br - rsize=32k -.br - wsize=32k -.br - proto=udp6 -.HP -.RS -A 32k (32768 bytes) block size will be used as the read and write -size on all mounts to the 'nfsserver.foo.com' server. UDP/IPv6 -is the protocol to be used. -.HP -.RE -.BR -[ MountPoint \(lq/export/home\(rq ] -.br - Background=True -.RS -.HP -All mounts to the '/export/home' export will be performed in -the background (i.e. done asynchronously). -.HP -.SH FILES -.TP 10n -.I /etc/nfsmount.conf -Default NFS mount configuration file -.PD -.SH SEE ALSO -.BR nfs (5), -.BR mount (8), diff --git a/nfs-utils-2.5.2/utils/mount/nfsumount.c b/nfs-utils-2.5.2/utils/mount/nfsumount.c deleted file mode 100644 index e16fb6a..0000000 --- a/nfs-utils-2.5.2/utils/mount/nfsumount.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * nfsumount.c -- Linux NFS umount - * Copyright (C) 2006 Amit Gud - * - * - Basic code and wrapper around NFS umount code originally - * in util-linux/mount/nfsmount.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xcommon.h" -#include "fstab.h" -#include "nls.h" - -#include "mount_constants.h" -#include "nfs_mount.h" -#include "mount.h" -#include "error.h" -#include "network.h" -#include "parse_opt.h" -#include "parse_dev.h" -#include "utils.h" - -#define MOUNTSFILE "/proc/mounts" -#define LINELEN (4096) - -#if !defined(MNT_FORCE) -/* dare not try to include -- lots of errors */ -#define MNT_FORCE 1 -#endif - -#if !defined(MNT_DETACH) -#define MNT_DETACH 2 -#endif - -extern char *progname; -extern int nomtab; -extern int verbose; -int force; -int lazy; -int remount; - - -static int try_remount(const char *spec, const char *node) -{ - int res; - - res = mount(spec, node, NULL, - MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); - if (res == 0) { - struct mntent remnt; - nfs_error(_("%s: %s busy - remounted read-only"), - progname, spec); - remnt.mnt_type = remnt.mnt_fsname = NULL; - remnt.mnt_dir = xstrdup(node); - remnt.mnt_opts = xstrdup("ro"); - if (!nomtab) - update_mtab(node, &remnt); - } else if (errno != EBUSY) { /* hmm ... */ - perror(_("remount")); - nfs_error(_("%s: could not remount %s read-only"), - progname, spec); - } - return res; -} - -static int del_mtab(const char *spec, const char *node) -{ - int umnt_err, res; - - umnt_err = 0; - if (lazy) { - res = umount2 (node, MNT_DETACH); - if (res < 0) - umnt_err = errno; - goto writemtab; - } - - if (force) { - res = umount2 (node, MNT_FORCE); - if (res == -1) { - int errsv = errno; - perror(_("umount2")); - errno = errsv; - if (errno == ENOSYS) { - if (verbose) - printf(_("no umount2, trying umount...\n")); - res = umount (node); - } - } - } else - res = umount (node); - - if (res < 0) { - if (remount && errno == EBUSY && spec) { - res = try_remount(spec, node); - if (res) - goto writemtab; - return EX_SUCCESS; - } else - umnt_err = errno; - } - - if (res >= 0) { - /* Umount succeeded */ - if (verbose) - printf(_("%s umounted\n"), spec ? spec : node); - } - - writemtab: - if (!nomtab && - (umnt_err == 0 || umnt_err == EINVAL || umnt_err == ENOENT)) { - update_mtab(node, NULL); - } - - if (res >= 0) - return EX_SUCCESS; - - if (umnt_err) - umount_error(umnt_err, node); - return EX_FILEIO; -} - -/* - * Detect NFSv4 mounts. - * - * Consult /proc/mounts to determine if the mount point - * is an NFSv4 mount. The kernel is authoritative about - * what type of mount this is. - * - * Returns 1 if "mc" is an NFSv4 mount, zero if not, and - * -1 if some error occurred. - */ -static int nfs_umount_is_vers4(const struct mntentchn *mc) -{ - struct mntentchn *pmc; - struct mount_options *options; - int retval; - - retval = -1; - pmc = getprocmntdirbackward(mc->m.mnt_dir, NULL); - if (!pmc) - goto not_found; - - do { - size_t nlen = strlen(pmc->m.mnt_fsname); - - /* - * It's possible the mount location string in /proc/mounts - * ends with a '/'. In this case, if the entry came from - * /etc/mtab, it won't have the trailing '/' so deal with - * it. - */ - while (pmc->m.mnt_fsname[nlen - 1] == '/') - nlen--; - if (strncmp(pmc->m.mnt_fsname, mc->m.mnt_fsname, nlen) != 0) - continue; - - if (strcmp(pmc->m.mnt_type, "nfs4") == 0) - goto out_nfs4; - - options = po_split(pmc->m.mnt_opts); - if (options != NULL) { - struct nfs_version version; - int rc = nfs_nfs_version("nfs", options, &version); - po_destroy(options); - if (rc && version.major == 4) - goto out_nfs4; - } - - if (strcmp(pmc->m.mnt_type, "nfs") == 0) - goto out_nfs; - } while ((pmc = getprocmntdirbackward(mc->m.mnt_dir, pmc)) != NULL); - - if (retval == -1) { -not_found: - fprintf(stderr, "%s was not found in %s\n", - mc->m.mnt_dir, MOUNTSFILE); - goto out; - } - -out_nfs4: - if (verbose) - fprintf(stderr, "NFSv4 mount point detected\n"); - retval = 1; - goto out; - -out_nfs: - if (verbose) - fprintf(stderr, "Legacy NFS mount point detected\n"); - retval = 0; - -out: - return retval; -} - -static struct option umount_longopts[] = -{ - { "force", 0, 0, 'f' }, - { "help", 0, 0, 'h' }, - { "no-mtab", 0, 0, 'n' }, - { "verbose", 0, 0, 'v' }, - { "read-only", 0, 0, 'r' }, - { NULL, 0, 0, 0 } -}; - -int nfsumount(int argc, char *argv[]) -{ - int c, ret; - char *spec; - struct mntentchn *mc; - - if (argc < 2) { - umount_usage(); - return EX_USAGE; - } - - spec = argv[1]; - - argv += 1; - argc -= 1; - - argv[0] = argv[-1]; /* So that getopt error messages are correct */ - while ((c = getopt_long (argc, argv, "fvnrlh", - umount_longopts, NULL)) != -1) { - - switch (c) { - case 'f': - ++force; - break; - case 'v': - ++verbose; - break; - case 'n': - ++nomtab; - break; - case 'r': - ++remount; - break; - case 'l': - ++lazy; - break; - case 'h': - default: - umount_usage(); - return EX_USAGE; - } - } - if (optind != argc) { - umount_usage(); - return EX_USAGE; - } - - if (spec == NULL || (*spec != '/' && strchr(spec,':') == NULL)) { - nfs_error(_("%s: %s: not found\n"), progname, spec); - return EX_USAGE; - } - - if (*spec == '/') - mc = getmntdirbackward(spec, NULL); - else - mc = getmntdevbackward(spec, NULL); - if (!mc && verbose) - printf(_("Could not find %s in mtab\n"), spec); - - if (mc && strcmp(mc->m.mnt_type, "nfs") != 0 && - strcmp(mc->m.mnt_type, "nfs4") != 0) { - nfs_error(_("%s: %s on %s is not an NFS filesystem"), - progname, mc->m.mnt_fsname, mc->m.mnt_dir); - return EX_USAGE; - } - - if (getuid() != 0) { - /* only permitted if "user=" or "users" is in mount options */ - if (!mc) { - /* umount might call us twice. The second time there will - * be no entry in mtab and we should just exit quietly - */ - return EX_SUCCESS; - - only_root: - nfs_error(_("%s: You are not permitted to unmount %s"), - progname, spec); - return EX_USAGE; - } - if (hasmntopt(&mc->m, "users") == NULL) { - char *opt = hasmntopt(&mc->m, "user"); - struct passwd *pw; - char *comma; - size_t len; - if (!opt) - goto only_root; - if (opt[4] != '=') - goto only_root; - comma = strchr(opt, ','); - if (comma) - len = comma - (opt + 5); - else - len = strlen(opt+5); - pw = getpwuid(getuid()); - if (pw == NULL || strlen(pw->pw_name) != len - || strncmp(pw->pw_name, opt+5, len) != 0) - goto only_root; - } - } - - ret = EX_SUCCESS; - if (mc) { - if (!lazy) { - switch (nfs_umount_is_vers4(mc)) { - case 0: - /* We ignore the error from nfs_umount23. - * If the actual umount succeeds (in del_mtab), - * we don't want to signal an error, as that - * could cause /sbin/mount to retry! - */ - nfs_umount23(mc->m.mnt_fsname, mc->m.mnt_opts); - break; - case 1: - break; - default: - return EX_FAIL; - } - } - ret = del_mtab(mc->m.mnt_fsname, mc->m.mnt_dir); - } else if (*spec != '/') { - if (!lazy) - ret = nfs_umount23(spec, "tcp,v3"); - } else - ret = del_mtab(NULL, spec); - - return ret; -} diff --git a/nfs-utils-2.5.2/utils/mount/parse_dev.c b/nfs-utils-2.5.2/utils/mount/parse_dev.c deleted file mode 100644 index 0d3bcb9..0000000 --- a/nfs-utils-2.5.2/utils/mount/parse_dev.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * parse_dev.c -- parse device name into hostname and export path - * - * Copyright (C) 2008 Oracle. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "xcommon.h" -#include "nls.h" -#include "parse_dev.h" - -#ifndef NFS_MAXHOSTNAME -#define NFS_MAXHOSTNAME (255) -#endif - -#ifndef NFS_MAXPATHNAME -#define NFS_MAXPATHNAME (1024) -#endif - -extern char *progname; -extern int verbose; - -static int nfs_pdn_no_devname_err(void) -{ - nfs_error(_("%s: no device name was provided"), progname); - return 0; -} - -static int nfs_pdn_hostname_too_long_err(void) -{ - nfs_error(_("%s: server hostname is too long"), progname); - return 0; -} - -static int nfs_pdn_pathname_too_long_err(void) -{ - nfs_error(_("%s: export pathname is too long"), progname); - return 0; -} - -static int nfs_pdn_bad_format_err(void) -{ - nfs_error(_("%s: remote share not in 'host:dir' format"), progname); - return 0; -} - -static int nfs_pdn_nomem_err(void) -{ - nfs_error(_("%s: no memory available to parse devname"), progname); - return 0; -} - -static int nfs_pdn_missing_brace_err(void) -{ - nfs_error(_("%s: closing bracket missing from server address"), - progname); - return 0; -} - -/* - * Standard hostname:path format - */ -static int nfs_parse_simple_hostname(const char *dev, - char **hostname, char **pathname) -{ - size_t host_len, path_len; - char *colon, *comma; - - /* Must have a colon */ - colon = strchr(dev, ':'); - if (colon == NULL) - return nfs_pdn_bad_format_err(); - *colon = '\0'; - host_len = colon - dev; - - if (host_len > NFS_MAXHOSTNAME) - return nfs_pdn_hostname_too_long_err(); - - /* If there's a comma before the colon, take only the - * first name in list */ - comma = strchr(dev, ','); - if (comma != NULL) { - *comma = '\0'; - host_len = comma - dev; - nfs_error(_("%s: warning: multiple hostnames not supported"), - progname); - } else - - colon++; - path_len = strlen(colon); - if (path_len > NFS_MAXPATHNAME) - return nfs_pdn_pathname_too_long_err(); - - if (hostname) { - *hostname = strndup(dev, host_len); - if (*hostname == NULL) - return nfs_pdn_nomem_err(); - } - if (pathname) { - *pathname = strndup(colon, path_len); - if (*pathname == NULL) { - if (hostname) - free(*hostname); - return nfs_pdn_nomem_err(); - } - } - return 1; -} - -/* - * To handle raw IPv6 addresses (which contain colons), the - * server's address is enclosed in square brackets. Return - * what's between the brackets. - * - * There could be anything in between the brackets, but we'll - * let DNS resolution sort it out later. - */ -static int nfs_parse_square_bracket(const char *dev, - char **hostname, char **pathname) -{ - size_t host_len, path_len; - char *cbrace; - - dev++; - - /* Must have a closing square bracket */ - cbrace = strchr(dev, ']'); - if (cbrace == NULL) - return nfs_pdn_missing_brace_err(); - *cbrace = '\0'; - host_len = cbrace - dev; - - /* Must have a colon just after the closing bracket */ - cbrace++; - if (*cbrace != ':') - return nfs_pdn_bad_format_err(); - - if (host_len > NFS_MAXHOSTNAME) - return nfs_pdn_hostname_too_long_err(); - - cbrace++; - path_len = strlen(cbrace); - if (path_len > NFS_MAXPATHNAME) - return nfs_pdn_pathname_too_long_err(); - - if (hostname) { - *hostname = strndup(dev, host_len); - if (*hostname == NULL) - return nfs_pdn_nomem_err(); - } - if (pathname) { - *pathname = strndup(cbrace, path_len); - if (*pathname == NULL) { - free(*hostname); - return nfs_pdn_nomem_err(); - } - } - return 1; -} - -/* - * RFC 2224 says an NFS client must grok "public file handles" to - * support NFS URLs. Linux doesn't do that yet. Print a somewhat - * helpful error message in this case instead of pressing forward - * with the mount request and failing with a cryptic error message - * later. - */ -static int nfs_parse_nfs_url(__attribute__((unused)) const char *dev, - __attribute__((unused)) char **hostname, - __attribute__((unused)) char **pathname) -{ - nfs_error(_("%s: NFS URLs are not supported"), progname); - return 0; -} - -/** - * nfs_parse_devname - Determine the server's hostname by looking at "devname". - * @devname: pointer to mounted device name (first argument of mount command) - * @hostname: OUT: pointer to server's hostname - * @pathname: OUT: pointer to export path on server - * - * Returns 1 if succesful, or zero if some error occurred. On success, - * @hostname and @pathname point to dynamically allocated buffers containing - * the hostname of the server and the export pathname (both '\0'-terminated). - * - * @hostname or @pathname may be NULL if caller doesn't want a copy of those - * parts of @devname. - * - * Note that this will not work if @devname is a wide-character string. - */ -int nfs_parse_devname(const char *devname, - char **hostname, char **pathname) -{ - char *dev; - int result; - - if (devname == NULL) - return nfs_pdn_no_devname_err(); - - /* Parser is destructive, so operate on a copy of the device name. */ - dev = strdup(devname); - if (dev == NULL) - return nfs_pdn_nomem_err(); - if (*dev == '[') - result = nfs_parse_square_bracket(dev, hostname, pathname); - else if (strncmp(dev, "nfs://", 6) == 0) - result = nfs_parse_nfs_url(dev, hostname, pathname); - else - result = nfs_parse_simple_hostname(dev, hostname, pathname); - - free(dev); - return result; -} diff --git a/nfs-utils-2.5.2/utils/mount/parse_dev.h b/nfs-utils-2.5.2/utils/mount/parse_dev.h deleted file mode 100644 index f9857bc..0000000 --- a/nfs-utils-2.5.2/utils/mount/parse_dev.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * parse_dev.c -- parse device name into hostname and export path - * - * Copyright (C) 2008 Oracle. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef __NFS_UTILS_PARSE_DEV_HEADER -#define __NFS_UTILS_PARSE_DEV_HEADER - -extern int nfs_parse_devname(const char *, char **, char **); - -#endif /* __NFS_UTILS_PARSE_DEV */ diff --git a/nfs-utils-2.5.2/utils/mount/parse_opt.c b/nfs-utils-2.5.2/utils/mount/parse_opt.c deleted file mode 100644 index 7ba61c4..0000000 --- a/nfs-utils-2.5.2/utils/mount/parse_opt.c +++ /dev/null @@ -1,571 +0,0 @@ -/* - * parse_opt.c -- mount option string parsing helpers - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -/* - * Converting a C string containing mount options to a data object - * and manipulating that object is cleaner in C than manipulating - * the C string itself. This is similar to the way Python handles - * string manipulation. - * - * The current implementation uses a linked list as the data object - * since lists are simple, and we don't need to worry about more - * than ten or twenty options at a time. - * - * Hopefully the interface is abstract enough that the underlying - * data structure can be replaced if needed without changing the API. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "parse_opt.h" -#include "token.h" - - -struct mount_option { - struct mount_option *next, *prev; - char *keyword; - char *value; -}; - -struct mount_options { - struct mount_option *head, *tail; - unsigned int count; -}; - -static struct mount_option *option_create(char *str) -{ - struct mount_option *option; - char *opteq; - - if (!str) - return NULL; - - option = malloc(sizeof(*option)); - if (!option) - return NULL; - - option->next = NULL; - option->prev = NULL; - - opteq = strchr(str, '='); - if (opteq) { - option->keyword = strndup(str, opteq - str); - if (!option->keyword) - goto fail; - option->value = strdup(opteq + 1); - if (!option->value) { - free(option->keyword); - goto fail; - } - } else { - option->keyword = strdup(str); - if (!option->keyword) - goto fail; - option->value = NULL; - } - - return option; - -fail: - free(option); - return NULL; -} - -static struct mount_option *option_dup(const struct mount_option *option) -{ - struct mount_option *new; - - new = malloc(sizeof(*new)); - if (!new) - return NULL; - - new->next = NULL; - new->prev = NULL; - - new->keyword = strdup(option->keyword); - if (!new->keyword) - goto fail; - - new->value = NULL; - if (option->value) { - new->value = strdup(option->value); - if (!new->value) { - free(new->keyword); - goto fail; - } - } - - return new; - -fail: - free(new); - return NULL; -} - -static void option_destroy(struct mount_option *option) -{ - free(option->keyword); - free(option->value); - free(option); -} - -static void options_init(struct mount_options *options) -{ - options->head = options->tail = NULL; - options->count = 0; -} - -static struct mount_options *options_create(void) -{ - struct mount_options *options; - - options = malloc(sizeof(*options)); - if (options) - options_init(options); - - return options; -} - -static int options_empty(struct mount_options *options) -{ - return options->count == 0; -} - -static void options_tail_insert(struct mount_options *options, - struct mount_option *option) -{ - struct mount_option *prev = options->tail; - - option->next = NULL; - option->prev = prev; - - if (prev) - prev->next = option; - else - options->head = option; - options->tail = option; - - options->count++; -} - -static void options_delete(struct mount_options *options, - struct mount_option *option) -{ - struct mount_option *prev = option->prev; - struct mount_option *next = option->next; - - if (!options_empty(options)) { - if (prev) - prev->next = option->next; - if (next) - next->prev = option->prev; - - if (options->head == option) - options->head = option->next; - if (options->tail == option) - options->tail = prev; - - options->count--; - - option_destroy(option); - } -} - - -/** - * po_destroy - deallocate a group of mount options - * @options: pointer to mount options to free - * - */ -void po_destroy(struct mount_options *options) -{ - if (options) { - while (!options_empty(options)) - options_delete(options, options->head); - free(options); - } -} - -/** - * po_split - split options string into group of options - * @options: pointer to C string containing zero or more comma-delimited options - * - * Convert our mount options string to a list to make it easier - * to adjust the options as we go. This is just an exercise in - * lexical parsing -- this function doesn't pay attention to the - * meaning of the options themselves. - * - * Returns a new group of mount options if successful; otherwise NULL - * is returned if some failure occurred. - */ -struct mount_options *po_split(char *str) -{ - struct mount_options *options; - struct tokenizer_state *tstate; - char *opt; - - if (!str) - return options_create(); - - options = options_create(); - if (options) { - tstate = init_tokenizer(str, ','); - for (opt = next_token(tstate); opt; opt = next_token(tstate)) { - struct mount_option *option = option_create(opt); - free(opt); - if (!option) - goto fail; - options_tail_insert(options, option); - } - if (tokenizer_error(tstate)) - goto fail; - end_tokenizer(tstate); - } - return options; - -fail: - end_tokenizer(tstate); - po_destroy(options); - return NULL; -} - -/** - * po_dup - duplicate an existing list of options - * @options: pointer to mount options - * - */ -struct mount_options *po_dup(struct mount_options *source) -{ - struct mount_options *target; - struct mount_option *current; - - if (!source) - return NULL; - - target = options_create(); - if (options_empty(source) || target == NULL) - return target; - - current = source->head; - while (target->count < source->count) { - struct mount_option *option; - - option = option_dup(current); - if (!option) { - po_destroy(target); - return NULL; - } - - options_tail_insert(target, option); - current = current->next; - } - - return target; -} - -/** - * po_replace - replace mount options in one mount_options object with another - * @target: pointer to previously instantiated object to replace - * @source: pointer to object containing source mount options - * - * Side effect: the object referred to by source is emptied. - */ -void po_replace(struct mount_options *target, struct mount_options *source) -{ - if (target) { - while (!options_empty(target)) - options_delete(target, target->head); - - if (source) { - target->head = source->head; - target->tail = source->tail; - target->count = source->count; - - options_init(source); - } - } -} - -/** - * po_join - recombine group of mount options into a C string - * @options: pointer to mount options to recombine - * @str: handle on string to replace (input and output) - * - * Convert our mount options object back into a string that the - * rest of the world can use. - * - * Upon return, @string contains the address of a replacement - * C string containing a comma-delimited list of mount options - * and values; or the passed-in string is freed and NULL is - * returned if some failure occurred. - */ -po_return_t po_join(struct mount_options *options, char **str) -{ - size_t len = 0; - struct mount_option *option; - - if (!str || !options) - return PO_FAILED; - - free(*str); - *str = NULL; - - if (options_empty(options)) { - *str = strdup(""); - return *str ? PO_SUCCEEDED : PO_FAILED; - } - - for (option = options->head; option; option = option->next) { - len += strlen(option->keyword); - if (option->value) - len +=strlen(option->value) + 1; /* equals sign */ - if (option->next) - len++; /* comma */ - } - - len++; /* NULL on the end */ - - *str = malloc(len); - if (!*str) - return PO_FAILED; - *str[0] = '\0'; - - for (option = options->head; option; option = option->next) { - strcat(*str, option->keyword); - if (option->value) { - strcat(*str, "="); - strcat(*str, option->value); - } - if (option->next) - strcat(*str, ","); - } - - return PO_SUCCEEDED; -} - -/** - * po_append - concatenate an option onto a group of options - * @options: pointer to mount options - * @option: pointer to a C string containing the option to add - * - */ -po_return_t po_append(struct mount_options *options, char *str) -{ - struct mount_option *option = option_create(str); - - if (option) { - options_tail_insert(options, option); - return PO_SUCCEEDED; - } - return PO_FAILED; -} - -/** - * po_contains - check for presence of an option in a group - * @options: pointer to mount options - * @keyword: pointer to a C string containing option keyword for which to search - * - */ -po_found_t po_contains(struct mount_options *options, char *keyword) -{ - struct mount_option *option; - - if (options && keyword) { - for (option = options->head; option; option = option->next) - if (strcmp(option->keyword, keyword) == 0) - return PO_FOUND; - } - - return PO_NOT_FOUND; -} - -/** - * po_contains_prefix - check for presence of an option matching a prefix - * @options: pointer to mount options - * @prefix: pointer to prefix to match against a keyword - * @keyword: pointer to a C string containing the option keyword if found - * - * On success, *keyword contains the pointer of the matching option's keyword. - */ -po_found_t po_contains_prefix(struct mount_options *options, - const char *prefix, char **keyword) -{ - struct mount_option *option; - - if (options && prefix) { - for (option = options->head; option; option = option->next) - if (strncmp(option->keyword, prefix, strlen(prefix)) == 0) { - *keyword = option->keyword; - return PO_FOUND; - } - } - - return PO_NOT_FOUND; -} - -/** - * po_get - return the value of the rightmost instance of an option - * @options: pointer to mount options - * @keyword: pointer to a C string containing option keyword for which to search - * - * If multiple instances of the same option are present in a mount option - * list, the rightmost instance is always the effective one. - * - * Returns pointer to C string containing the value of the option. - * Returns NULL if the option isn't found, or if the option doesn't - * have a value. - */ -char *po_get(struct mount_options *options, char *keyword) -{ - struct mount_option *option; - - if (options && keyword) { - for (option = options->tail; option; option = option->prev) - if (strcmp(option->keyword, keyword) == 0) - return option->value; - } - - return NULL; -} - -/** - * po_get_numeric - return numeric value of rightmost instance of keyword option - * @options: pointer to mount options - * @keyword: pointer to a C string containing option keyword for which to search - * @value: OUT: set to the value of the keyword - * - * This is specifically for parsing keyword options that take only a numeric - * value. If multiple instances of the same option are present in a mount - * option list, the rightmost instance is always the effective one. - * - * Returns: - * * PO_FOUND if the keyword was found and the value is numeric; @value is - * set to the keyword's value - * * PO_NOT_FOUND if the keyword was not found - * * PO_BAD_VALUE if the keyword was found, but the value is not numeric - * - * These last two are separate in case the caller wants to warn about bad mount - * options instead of silently using a default. - */ -#ifdef HAVE_STRTOL -po_found_t po_get_numeric(struct mount_options *options, char *keyword, long *value) -{ - char *option, *endptr; - long tmp; - - option = po_get(options, keyword); - if (option == NULL) - return PO_NOT_FOUND; - - errno = 0; - tmp = strtol(option, &endptr, 10); - if (errno == 0 && endptr != option) { - *value = tmp; - return PO_FOUND; - } - return PO_BAD_VALUE; -} -#else /* HAVE_STRTOL */ -po_found_t po_get_numeric(struct mount_options *options, char *keyword, long *value) -{ - char *option; - - option = po_get(options, keyword); - if (option == NULL) - return PO_NOT_FOUND; - - *value = atoi(option); - return PO_FOUND; -} -#endif /* HAVE_STRTOL */ - -/** - * po_rightmost - determine the relative position of several options - * @options: pointer to mount options - * @keys: pointer to an array of C strings containing option keywords - * - * This function can be used to determine which of several similar - * options will be the one to take effect. - * - * The kernel parses the mount option string from left to right. - * If an option is specified more than once (for example, "intr" - * and "nointr", the rightmost option is the last to be parsed, - * and it therefore takes precedence over previous similar options. - * - * This can also distinguish among multiple synonymous options, such - * as "proto=," "udp" and "tcp." - * - * Returns the index into @keys of the option that is rightmost. - * If none of the options listed in @keys is present in @options, or - * if @options is NULL, returns -1. - */ -int po_rightmost(struct mount_options *options, const char *keys[]) -{ - struct mount_option *option; - int i; - - if (options) { - for (option = options->tail; option; option = option->prev) { - for (i = 0; keys[i] != NULL; i++) - if (strcmp(option->keyword, keys[i]) == 0) - return i; - } - } - - return -1; -} - -/** - * po_remove_all - remove instances of an option from a group - * @options: pointer to mount options - * @keyword: pointer to a C string containing an option keyword to remove - * - * Side-effect: the passed-in list is truncated on success. - */ -po_found_t po_remove_all(struct mount_options *options, char *keyword) -{ - struct mount_option *option, *next; - int found = PO_NOT_FOUND; - - if (options && keyword) { - for (option = options->head; option; option = next) { - next = option->next; - if (strcmp(option->keyword, keyword) == 0) { - options_delete(options, option); - found = PO_FOUND; - } - } - } - - return found; -} diff --git a/nfs-utils-2.5.2/utils/mount/parse_opt.h b/nfs-utils-2.5.2/utils/mount/parse_opt.h deleted file mode 100644 index 0745e0f..0000000 --- a/nfs-utils-2.5.2/utils/mount/parse_opt.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * parse_opt.h -- mount option string parsing helpers - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_PARSE_OPT_H -#define _NFS_UTILS_PARSE_OPT_H - -typedef enum { - PO_FAILED = 0, - PO_SUCCEEDED = 1, -} po_return_t; - -typedef enum { - PO_NOT_FOUND = 0, - PO_FOUND = 1, - PO_BAD_VALUE = 2, -} po_found_t; - -struct mount_options; - -struct mount_options * po_split(char *); -struct mount_options * po_dup(struct mount_options *); -void po_replace(struct mount_options *, - struct mount_options *); -po_return_t po_join(struct mount_options *, char **); - -po_return_t po_append(struct mount_options *, char *); -po_found_t po_contains(struct mount_options *, char *); -po_found_t po_contains_prefix(struct mount_options *options, - const char *prefix, char **keyword); -char * po_get(struct mount_options *, char *); -po_found_t po_get_numeric(struct mount_options *, - char *, long *); -int po_rightmost(struct mount_options *, - const char *keys[]); -po_found_t po_remove_all(struct mount_options *, char *); -void po_destroy(struct mount_options *); - -#endif /* _NFS_UTILS_PARSE_OPT_H */ diff --git a/nfs-utils-2.5.2/utils/mount/stropts.c b/nfs-utils-2.5.2/utils/mount/stropts.c deleted file mode 100644 index 174a05f..0000000 --- a/nfs-utils-2.5.2/utils/mount/stropts.c +++ /dev/null @@ -1,1292 +0,0 @@ -/* - * stropts.c -- NFS mount using C string to pass options to kernel - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "nfslib.h" -#include "sockaddr.h" -#include "xcommon.h" -#include "mount.h" -#include "nls.h" -#include "nfsrpc.h" -#include "mount_constants.h" -#include "stropts.h" -#include "error.h" -#include "network.h" -#include "parse_opt.h" -#include "version.h" -#include "parse_dev.h" -#include "conffile.h" -#include "misc.h" - -#ifndef NFS_PROGRAM -#define NFS_PROGRAM (100003) -#endif - -#ifndef NFS_PORT -#define NFS_PORT (2049) -#endif - -#ifndef NFS_MAXHOSTNAME -#define NFS_MAXHOSTNAME (255) -#endif - -#ifndef NFS_MAXPATHNAME -#define NFS_MAXPATHNAME (1024) -#endif - -#ifndef NFS_DEF_FG_TIMEOUT_MINUTES -#define NFS_DEF_FG_TIMEOUT_MINUTES (2u) -#endif - -#ifndef NFS_DEF_BG_TIMEOUT_MINUTES -#define NFS_DEF_BG_TIMEOUT_MINUTES (10000u) -#endif - -#ifndef NFS_DEFAULT_MAJOR -#define NFS_DEFAULT_MAJOR 4 -#endif -#ifndef NFS_DEFAULT_MINOR -#define NFS_DEFAULT_MINOR 2 -#endif - -extern int nfs_mount_data_version; -extern char *progname; -extern int verbose; -extern int sloppy; - -struct nfsmount_info { - const char *spec, /* server:/path */ - *node; /* mounted-on dir */ - char *type; /* "nfs" or "nfs4" */ - char *hostname; /* server's hostname */ - struct addrinfo *address; /* server's addresses */ - sa_family_t family; /* Address family */ - - struct mount_options *options; /* parsed mount options */ - char **extra_opts; /* string for /etc/mtab */ - - struct nfs_version version; /* NFS version */ - int flags, /* MS_ flags */ - fake, /* actually do the mount? */ - child; /* forked bg child? */ -}; - - -static void nfs_default_version(struct nfsmount_info *mi) -{ -#ifdef MOUNT_CONFIG - extern struct nfs_version config_default_vers; - /* - * Use the default value set in the config file when - * the version has not been explicitly set. - */ - if (config_default_vers.v_mode == V_PARSE_ERR) { - mi->version.v_mode = V_PARSE_ERR; - return; - } - - if (mi->version.v_mode == V_DEFAULT && - config_default_vers.v_mode != V_DEFAULT) { - mi->version.major = config_default_vers.major; - if (config_default_vers.v_mode == V_SPECIFIC) - mi->version.minor = config_default_vers.minor; - else - mi->version.minor = NFS_DEFAULT_MINOR; - return; - } - - if (mi->version.v_mode == V_GENERAL) { - if (config_default_vers.v_mode != V_DEFAULT && - mi->version.major == config_default_vers.major) { - if (config_default_vers.v_mode == V_SPECIFIC) - mi->version.minor = config_default_vers.minor; - else - mi->version.minor = NFS_DEFAULT_MINOR; - } else - mi->version.minor = NFS_DEFAULT_MINOR; - return; - } - -#endif /* MOUNT_CONFIG */ - mi->version.major = NFS_DEFAULT_MAJOR; - mi->version.minor = NFS_DEFAULT_MINOR; -} - -/* - * Obtain a retry timeout value based on the value of the "retry=" option. - * - * Returns a time_t timeout timestamp, in seconds. - */ -static time_t nfs_parse_retry_option(struct mount_options *options, - const time_t default_timeout) -{ - time_t timeout_minutes; - long tmp; - - timeout_minutes = default_timeout; - switch (po_get_numeric(options, "retry", &tmp)) { - case PO_NOT_FOUND: - break; - case PO_FOUND: - if (tmp >= 0) { - timeout_minutes = tmp; - break; - } - /*FALLTHROUGH*/ - case PO_BAD_VALUE: - if (verbose) - nfs_error(_("%s: invalid retry timeout was specified; " - "using default timeout"), progname); - break; - } - - return time(NULL) + (timeout_minutes * 60); -} - -/* - * Convert the passed-in sockaddr-style address to presentation - * format, then append an option of the form "keyword=address". - * - * Returns 1 if the option was appended successfully; otherwise zero. - */ -static int nfs_append_generic_address_option(const struct sockaddr *sap, - const socklen_t salen, - const char *keyword, - struct mount_options *options) -{ - char address[NI_MAXHOST]; - char new_option[512]; - int len; - - if (!nfs_present_sockaddr(sap, salen, address, sizeof(address))) - goto out_err; - - len = snprintf(new_option, sizeof(new_option), "%s=%s", - keyword, address); - if (len < 0 || (size_t)len >= sizeof(new_option)) - goto out_err; - - if (po_append(options, new_option) != PO_SUCCEEDED) - goto out_err; - - return 1; - -out_err: - nfs_error(_("%s: failed to construct %s option"), progname, keyword); - return 0; -} - -/* - * Append the 'addr=' option to the options string to pass a resolved - * server address to the kernel. After a successful mount, this address - * is also added to /etc/mtab for use when unmounting. - * - * If 'addr=' is already present, we strip it out. This prevents users - * from setting a bogus 'addr=' option themselves, and also allows bg - * retries to recompute the server's address, in case it has changed. - * - * Returns 1 if 'addr=' option appended successfully; - * otherwise zero. - */ -static int nfs_append_addr_option(const struct sockaddr *sap, - socklen_t salen, - struct mount_options *options) -{ - po_remove_all(options, "addr"); - return nfs_append_generic_address_option(sap, salen, "addr", options); -} - -/* - * Called to discover our address and append an appropriate 'clientaddr=' - * option to the options string. If the supplied 'clientaddr=' value does - * not match either IPV4/IPv6 any or a local address, then fail the mount. - * - * Returns 1 if 'clientaddr=' option created successfully or if - * 'clientaddr=' option is already present; otherwise zero. - */ -static int nfs_append_clientaddr_option(const struct sockaddr *sap, - socklen_t salen, - struct mount_options *options) -{ - union nfs_sockaddr address; - struct sockaddr *my_addr = &address.sa; - socklen_t my_len = sizeof(address); - - if (po_contains(options, "clientaddr") == PO_FOUND) { - char *addr = po_get(options, "clientaddr"); - union nfs_sockaddr nfs_address; - struct sockaddr *nfs_saddr = &nfs_address.sa; - socklen_t nfs_salen = sizeof(nfs_address); - - /* translate the input for clientaddr to nfs_sockaddr */ - if (!nfs_string_to_sockaddr(addr, nfs_saddr, &nfs_salen)) - return 0; - - /* check for IPV4_ANY and IPV6_ANY */ - if (nfs_is_inaddr_any(nfs_saddr)) - return 1; - - /* check if ip matches local network addresses */ - if (!nfs_addr_matches_localips(nfs_saddr)) - nfs_error(_("%s: [warning] supplied clientaddr=%s " - "does not match any existing network " - "addresses"), progname, addr); - return 1; - } - - nfs_callback_address(sap, salen, my_addr, &my_len); - - return nfs_append_generic_address_option(my_addr, my_len, - "clientaddr", options); -} - -/* - * Determine whether to append a 'mountaddr=' option. The option is needed if: - * - * 1. "mounthost=" was specified, or - * 2. The address families for proto= and mountproto= are different. - */ -static int nfs_fix_mounthost_option(struct mount_options *options, - const char *nfs_hostname) -{ - union nfs_sockaddr address; - struct sockaddr *sap = &address.sa; - socklen_t salen = sizeof(address); - sa_family_t nfs_family, mnt_family; - char *mounthost; - - if (!nfs_nfs_proto_family(options, &nfs_family)) - return 0; - if (!nfs_mount_proto_family(options, &mnt_family)) - return 0; - - mounthost = po_get(options, "mounthost"); - if (mounthost == NULL) { - if (nfs_family == mnt_family) - return 1; - mounthost = (char *)nfs_hostname; - } - - if (!nfs_lookup(mounthost, mnt_family, sap, &salen)) { - nfs_error(_("%s: unable to determine mount server's address"), - progname); - return 0; - } - - return nfs_append_generic_address_option(sap, salen, - "mountaddr", options); -} - -/* - * Returns zero if the "lock" option is in effect, but statd - * can't be started. Otherwise, returns 1. - */ -static const char *nfs_lock_opttbl[] = { - "nolock", - "lock", - NULL, -}; - -static int nfs_verify_lock_option(struct mount_options *options) -{ - if (po_rightmost(options, nfs_lock_opttbl) == 0) - return 1; - - if (!start_statd()) { - nfs_error(_("%s: rpc.statd is not running but is " - "required for remote locking."), progname); - nfs_error(_("%s: Either use '-o nolock' to keep " - "locks local, or start statd."), progname); - errno = EALREADY; /* Don't print further error message */ - return 0; - } - - return 1; -} - -static int nfs_append_sloppy_option(struct mount_options *options) -{ - if (!sloppy || linux_version_code() < MAKE_VERSION(2, 6, 27)) - return 1; - - if (po_append(options, "sloppy") == PO_FAILED) - return 0; - return 1; -} - -static int nfs_set_version(struct nfsmount_info *mi) -{ - if (!nfs_nfs_version(mi->type, mi->options, &mi->version)) - return 0; - - /* - * Before 2.6.32, the kernel NFS client didn't - * support "-t nfs vers=4" mounts, so NFS version - * 4 cannot be included when autonegotiating - * while running on those kernels. - */ - if (mi->version.v_mode == V_DEFAULT && - linux_version_code() <= MAKE_VERSION(2, 6, 31)) { - mi->version.major = 3; - mi->version.v_mode = V_SPECIFIC; - } - - /* - * If we still don't know, check for version-specific - * mount options. - */ - if (mi->version.v_mode == V_DEFAULT) { - if (po_contains(mi->options, "mounthost") || - po_contains(mi->options, "mountaddr") || - po_contains(mi->options, "mountvers") || - po_contains(mi->options, "mountproto")) { - mi->version.major = 3; - mi->version.v_mode = V_SPECIFIC; - } - } - - /* - * If enabled, see if the default version was - * set in the config file - */ - if (mi->version.v_mode != V_SPECIFIC) { - nfs_default_version(mi); - /* - * If the version was not specifically set, it will - * be set by autonegotiation later, so remove it now: - */ - po_remove_all(mi->options, "v4"); - po_remove_all(mi->options, "vers"); - po_remove_all(mi->options, "nfsvers"); - } - - if (mi->version.v_mode == V_PARSE_ERR) - return 0; - - return 1; -} - -/* - * Set up mandatory non-version specific NFS mount options. - * - * Returns 1 if successful; otherwise zero. - */ -static int nfs_validate_options(struct nfsmount_info *mi) -{ - /* For remount, ignore mi->spec: the kernel will. */ - if (!(mi->flags & MS_REMOUNT) && - !nfs_parse_devname(mi->spec, &mi->hostname, NULL)) - return 0; - - if (!nfs_nfs_proto_family(mi->options, &mi->family)) - return 0; - - /* - * A remount is not going to be able to change the server's address, - * nor should we try to resolve another address for the server as we - * may end up with a different address. - * A non-remount will set 'addr' from ->hostname - */ - po_remove_all(mi->options, "addr"); - - if (!nfs_set_version(mi)) - return 0; - - if (!nfs_append_sloppy_option(mi->options)) - return 0; - - return 1; -} - -/* - * Get NFS/mnt server addresses from mount options - * - * Returns 1 and fills in @nfs_saddr, @nfs_salen, @mnt_saddr, and @mnt_salen - * if all goes well; otherwise zero. - */ -static int nfs_extract_server_addresses(struct mount_options *options, - struct sockaddr *nfs_saddr, - socklen_t *nfs_salen, - struct sockaddr *mnt_saddr, - socklen_t *mnt_salen) -{ - char *option; - - option = po_get(options, "addr"); - if (option == NULL) - return 0; - if (!nfs_string_to_sockaddr(option, nfs_saddr, nfs_salen)) - return 0; - - option = po_get(options, "mountaddr"); - if (option == NULL) { - memcpy(mnt_saddr, nfs_saddr, *nfs_salen); - *mnt_salen = *nfs_salen; - } else if (!nfs_string_to_sockaddr(option, mnt_saddr, mnt_salen)) - return 0; - - return 1; -} - -static int nfs_construct_new_options(struct mount_options *options, - struct sockaddr *nfs_saddr, - struct pmap *nfs_pmap, - struct sockaddr *mnt_saddr, - struct pmap *mnt_pmap) -{ - char new_option[64]; - char *netid; - - po_remove_all(options, "nfsprog"); - po_remove_all(options, "mountprog"); - - po_remove_all(options, "v2"); - po_remove_all(options, "v3"); - po_remove_all(options, "vers"); - po_remove_all(options, "nfsvers"); - snprintf(new_option, sizeof(new_option) - 1, - "vers=%lu", nfs_pmap->pm_vers); - if (po_append(options, new_option) == PO_FAILED) - return 0; - - po_remove_all(options, "proto"); - po_remove_all(options, "udp"); - po_remove_all(options, "tcp"); - netid = nfs_get_netid(nfs_saddr->sa_family, nfs_pmap->pm_prot); - if (netid == NULL) - return 0; - snprintf(new_option, sizeof(new_option) - 1, - "proto=%s", netid); - free(netid); - if (po_append(options, new_option) == PO_FAILED) - return 0; - - if(po_remove_all(options, "port") == PO_FOUND || - nfs_pmap->pm_port != NFS_PORT) { - snprintf(new_option, sizeof(new_option) - 1, - "port=%lu", nfs_pmap->pm_port); - if (po_append(options, new_option) == PO_FAILED) - return 0; - } - - po_remove_all(options, "mountvers"); - snprintf(new_option, sizeof(new_option) - 1, - "mountvers=%lu", mnt_pmap->pm_vers); - if (po_append(options, new_option) == PO_FAILED) - return 0; - - po_remove_all(options, "mountproto"); - netid = nfs_get_netid(mnt_saddr->sa_family, mnt_pmap->pm_prot); - if (netid == NULL) - return 0; - snprintf(new_option, sizeof(new_option) - 1, - "mountproto=%s", netid); - free(netid); - if (po_append(options, new_option) == PO_FAILED) - return 0; - - po_remove_all(options, "mountport"); - snprintf(new_option, sizeof(new_option) - 1, - "mountport=%lu", mnt_pmap->pm_port); - if (po_append(options, new_option) == PO_FAILED) - return 0; - - return 1; -} - -/* - * Reconstruct the mount option string based on a portmapper probe - * of the server. Returns one if the server's portmapper returned - * something we can use, otherwise zero. - * - * To handle version and transport protocol fallback properly, we - * need to parse some of the mount options in order to set up a - * portmap probe. Mount options that nfs_rewrite_pmap_mount_options() - * doesn't recognize are left alone. - * - * Returns TRUE if rewriting was successful; otherwise - * FALSE is returned if some failure occurred. - */ -static int -nfs_rewrite_pmap_mount_options(struct mount_options *options, int checkv4) -{ - union nfs_sockaddr nfs_address; - struct sockaddr *nfs_saddr = &nfs_address.sa; - socklen_t nfs_salen = sizeof(nfs_address); - struct pmap nfs_pmap; - union nfs_sockaddr mnt_address; - struct sockaddr *mnt_saddr = &mnt_address.sa; - socklen_t mnt_salen = sizeof(mnt_address); - unsigned long protocol; - struct pmap mnt_pmap; - - /* initialize structs */ - memset(&nfs_pmap, 0, sizeof(struct pmap)); - memset(&mnt_pmap, 0, sizeof(struct pmap)); - - /* - * Version and transport negotiation is not required - * and does not work for RDMA mounts. - */ - if (!nfs_nfs_protocol(options, &protocol)) { - errno = EINVAL; - return 0; - } - if (protocol == NFSPROTO_RDMA) - goto out; - - /* - * Extract just the options needed to contact server. - * Bail now if any of these have bad values. - */ - if (!nfs_extract_server_addresses(options, nfs_saddr, &nfs_salen, - mnt_saddr, &mnt_salen)) { - errno = EINVAL; - return 0; - } - if (!nfs_options2pmap(options, &nfs_pmap, &mnt_pmap)) { - errno = EINVAL; - return 0; - } - - /* - * The kernel NFS client doesn't support changing the RPC - * program number for these services, so force the value of - * these fields before probing the server's ports. - */ - nfs_pmap.pm_prog = NFS_PROGRAM; - mnt_pmap.pm_prog = MOUNTPROG; - - /* - * If the server's rpcbind service isn't available, we can't - * negotiate. Bail now if we can't contact it. - */ - if (!nfs_probe_bothports(mnt_saddr, mnt_salen, &mnt_pmap, - nfs_saddr, nfs_salen, &nfs_pmap, checkv4)) { - errno = ESPIPE; - if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) - errno = EOPNOTSUPP; - else if (rpc_createerr.cf_stat == RPC_AUTHERROR) - errno = EACCES; - else if (rpc_createerr.cf_stat == RPC_TIMEDOUT) - errno = ETIMEDOUT; - else if (rpc_createerr.cf_stat == RPC_PROGVERSMISMATCH) - errno = EPROTONOSUPPORT; - else if (rpc_createerr.cf_error.re_errno != 0) - errno = rpc_createerr.cf_error.re_errno; - return 0; - } - - if (!nfs_construct_new_options(options, nfs_saddr, &nfs_pmap, - mnt_saddr, &mnt_pmap)) { - if (rpc_createerr.cf_stat == RPC_UNKNOWNPROTO) - errno = EPROTONOSUPPORT; - else - errno = EINVAL; - return 0; - } - -out: - errno = 0; - return 1; -} - -/* - * Do the mount(2) system call. - * - * Returns TRUE if successful, otherwise FALSE. - * "errno" is set to reflect the individual error. - */ -static int nfs_sys_mount(struct nfsmount_info *mi, struct mount_options *opts) -{ - char *options = NULL; - int result; - - if (mi->fake) - return 1; - - if (po_join(opts, &options) == PO_FAILED) { - errno = EIO; - return 0; - } - - result = mount(mi->spec, mi->node, mi->type, - mi->flags & ~(MS_USER|MS_USERS), options); - free(options); - - if (verbose && result) { - int save = errno; - nfs_error(_("%s: mount(2): %s"), progname, strerror(save)); - errno = save; - } - return !result; -} - -static int nfs_do_mount_v3v2(struct nfsmount_info *mi, - struct sockaddr *sap, socklen_t salen, - int checkv4) -{ - struct mount_options *options = po_dup(mi->options); - int result = 0; - - if (!options) { - errno = ENOMEM; - return result; - } - errno = 0; - if (!nfs_append_addr_option(sap, salen, options)) { - if (errno == 0) - errno = EINVAL; - goto out_fail; - } - - if (!nfs_fix_mounthost_option(options, mi->hostname)) { - if (errno == 0) - errno = EINVAL; - goto out_fail; - } - if (!mi->fake && !nfs_verify_lock_option(options)) { - if (errno == 0) - errno = EINVAL; - goto out_fail; - } - - /* - * Options we negotiate below may be stale by the time this - * file system is unmounted. In order to force umount.nfs - * to renegotiate with the server, only write the user- - * specified options, and not negotiated options, to /etc/mtab. - */ - if (po_join(options, mi->extra_opts) == PO_FAILED) { - errno = ENOMEM; - goto out_fail; - } - - if (verbose) - printf(_("%s: trying text-based options '%s'\n"), - progname, *mi->extra_opts); - - if (!nfs_rewrite_pmap_mount_options(options, checkv4)) - goto out_fail; - - result = nfs_sys_mount(mi, options); - -out_fail: - po_destroy(options); - return result; -} - -/* - * Attempt a "-t nfs vers=2" or "-t nfs vers=3" mount. - * - * Returns TRUE if successful, otherwise FALSE. - * "errno" is set to reflect the individual error. - */ -static int nfs_try_mount_v3v2(struct nfsmount_info *mi, int checkv4) -{ - struct addrinfo *ai; - int ret = 0; - - for (ai = mi->address; ai != NULL; ai = ai->ai_next) { - ret = nfs_do_mount_v3v2(mi, ai->ai_addr, ai->ai_addrlen, checkv4); - if (ret != 0) - return ret; - - switch (errno) { - case ECONNREFUSED: - case EOPNOTSUPP: - case EHOSTUNREACH: - case ETIMEDOUT: - case EACCES: - continue; - default: - goto out; - } - } -out: - return ret; -} - -static int nfs_do_mount_v4(struct nfsmount_info *mi, - struct sockaddr *sap, socklen_t salen) -{ - struct mount_options *options = po_dup(mi->options); - int result = 0; - char version_opt[32]; - char *extra_opts = NULL; - - if (!options) { - errno = ENOMEM; - return result; - } - - if (po_contains(options, "mounthost") || - po_contains(options, "mountaddr") || - po_contains(options, "mountvers") || - po_contains(options, "mountport") || - po_contains(options, "mountproto")) { - /* - * Since these mountd options are set assume version 3 - * is wanted so error out with EPROTONOSUPPORT so the - * protocol negation starts with v3. - */ - if (verbose) { - printf(_("%s: Unsupported nfs4 mount option(s) passed '%s'\n"), - progname, *mi->extra_opts); - } - errno = EPROTONOSUPPORT; - goto out_fail; - } - - if (mi->version.v_mode != V_SPECIFIC) { - char *fmt; - switch (mi->version.minor) { - /* Old kernels don't support the new "vers=x.y" - * option, but do support old versions of NFS4. - * So use the format that is most widely understood. - */ - case 0: - fmt = "vers=%lu"; - break; - case 1: - fmt = "vers=%lu,minorversion=%lu"; - break; - default: - fmt = "vers=%lu.%lu"; - break; - } -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - snprintf(version_opt, sizeof(version_opt) - 1, - fmt, mi->version.major, - mi->version.minor); -#pragma GCC diagnostic warning "-Wformat-nonliteral" - - if (po_append(options, version_opt) == PO_FAILED) { - errno = EINVAL; - goto out_fail; - } - } else if (po_get(options, "minorversion") && - linux_version_code() > MAKE_VERSION(3, 4, 0)) { - /* - * convert minorversion= into vers=4.x - */ - po_remove_all(options, "minorversion"); - - snprintf(version_opt, sizeof(version_opt) - 1, - "vers=%lu.%lu", mi->version.major, - mi->version.minor); - - if (po_append(options, version_opt) == PO_FAILED) { - errno = EINVAL; - goto out_fail; - } - } - - if (!nfs_append_addr_option(sap, salen, options)) { - errno = EINVAL; - goto out_fail; - } - - if (!nfs_append_clientaddr_option(sap, salen, options)) { - errno = EINVAL; - goto out_fail; - } - - if (po_join(options, &extra_opts) == PO_FAILED) { - errno = ENOMEM; - goto out_fail; - } - - if (verbose) - printf(_("%s: trying text-based options '%s'\n"), - progname, extra_opts); - - result = nfs_sys_mount(mi, options); - - /* - * If success, update option string to be recorded in /etc/mtab. - */ - if (result) { - free(*mi->extra_opts); - *mi->extra_opts = extra_opts; - } else - free(extra_opts); - -out_fail: - po_destroy(options); - return result; -} - -/* - * Attempt a "-t nfs -o vers=4" or "-t nfs4" mount. - * - * Returns TRUE if successful, otherwise FALSE. - * "errno" is set to reflect the individual error. - */ -static int nfs_try_mount_v4(struct nfsmount_info *mi) -{ - struct addrinfo *ai; - int ret = 0; - - for (ai = mi->address; ai != NULL; ai = ai->ai_next) { - ret = nfs_do_mount_v4(mi, ai->ai_addr, ai->ai_addrlen); - if (ret != 0) - return ret; - - switch (errno) { - case ECONNREFUSED: - case EHOSTUNREACH: - case ETIMEDOUT: - case EACCES: - continue; - default: - goto out; - } - } -out: - return ret; -} - -/* - * Handle NFS version and transport protocol - * autonegotiation. - * - * When no version or protocol is specified on the - * command line, mount.nfs negotiates with the server - * to determine appropriate settings for the new - * mount point. - * - * Returns TRUE if successful, otherwise FALSE. - * "errno" is set to reflect the individual error. - */ -static int nfs_autonegotiate(struct nfsmount_info *mi) -{ - int result, olderrno; - - result = nfs_try_mount_v4(mi); -check_result: - if (result) - return result; - - switch (errno) { - case EPROTONOSUPPORT: - /* A clear indication that the server or our - * client does not support NFS version 4 and minor */ - case EINVAL: - /* A less clear indication that our client - * does not support NFSv4 minor version. */ - case EACCES: - /* An unclear indication that the server - * may not support NFSv4 minor version. */ - if (mi->version.v_mode != V_SPECIFIC) { - if (mi->version.minor > 0) { - mi->version.minor--; - result = nfs_try_mount_v4(mi); - goto check_result; - } - } - - goto fall_back; - case ENOENT: - /* Legacy Linux servers don't export an NFS - * version 4 pseudoroot. */ - goto fall_back; - case EPERM: - /* Linux servers prior to 2.6.25 may return - * EPERM when NFS version 4 is not supported. */ - goto fall_back; - case ECONNREFUSED: - /* UDP-Only servers won't support v4, but maybe it - * just isn't ready yet. So try v3, but double-check - * with rpcbind for v4. */ - if (mi->version.v_mode == V_GENERAL) - /* Mustn't try v2,v3 */ - return result; - result = nfs_try_mount_v3v2(mi, TRUE); - if (result == 0 && errno == EAGAIN) { - /* v4 server seems to be registered now. */ - result = nfs_try_mount_v4(mi); - if (result == 0 && errno != ECONNREFUSED) - goto check_result; - } else if (result == 0) - /* Restore original errno with v3 failures */ - errno = ECONNREFUSED; - - return result; - default: - return result; - } - -fall_back: - if (mi->version.v_mode == V_GENERAL) - /* v2,3 fallback not allowed */ - return result; - - /* - * Save the original errno in case the v3 - * mount fails from one of the fall_back cases. - * Report the first failure not the v3 mount failure - */ - olderrno = errno; - if ((result = nfs_try_mount_v3v2(mi, FALSE))) - return result; - - errno = olderrno; - return result; -} - -/* - * This is a single pass through the fg/bg loop. - * - * Returns TRUE if successful, otherwise FALSE. - * "errno" is set to reflect the individual error. - */ -static int nfs_try_mount(struct nfsmount_info *mi) -{ - int result = 0; - - if (mi->address == NULL) { - struct addrinfo hint = { - .ai_protocol = (int)IPPROTO_UDP, - }; - int error; - struct addrinfo *address; - - hint.ai_family = (int)mi->family; - error = getaddrinfo(mi->hostname, NULL, &hint, &address); - if (error != 0) { - if (error == EAI_AGAIN) - errno = EAGAIN; - else { - nfs_error(_("%s: Failed to resolve server %s: %s"), - progname, mi->hostname, gai_strerror(error)); - errno = EALREADY; - } - return 0; - } - - if (!nfs_append_addr_option(address->ai_addr, - address->ai_addrlen, mi->options)) { - nfs_freeaddrinfo(address); - errno = ENOMEM; - return 0; - } - mi->address = address; - } - - switch (mi->version.major) { - case 2: - case 3: - result = nfs_try_mount_v3v2(mi, FALSE); - break; - case 4: - if (mi->version.v_mode != V_SPECIFIC) - result = nfs_autonegotiate(mi); - else - result = nfs_try_mount_v4(mi); - break; - default: - errno = EIO; - } - - return result; -} - -/* - * Distinguish between permanent and temporary errors. - * - * Basically, we retry if communication with the server has - * failed so far, but fail immediately if there is a local - * error (like a bad mount option). - * - * If there is a remote error, like ESTALE or RPC_PROGNOTREGISTERED - * then it is probably permanent, but there is a small chance - * the it is temporary can we caught the server at an awkward - * time during start-up. So require that we see three of those - * before treating them as permanent. - * For ECONNREFUSED, wait a bit longer as there is often a longer - * gap between the network being ready and the NFS server starting. - * - * Returns 1 if we should fail immediately, or 0 if we - * should retry. - */ -static int nfs_is_permanent_error(int error) -{ - static int prev_error; - static int rpt_cnt; - - if (error == prev_error) - rpt_cnt += 1; - else - rpt_cnt = 1; - prev_error = error; - - switch (error) { - case ESTALE: - case EOPNOTSUPP: /* aka RPC_PROGNOTREGISTERED */ - /* If two in a row, assume permanent */ - return rpt_cnt >= 3; - case ECONNREFUSED: - /* Like the above, this can be temporary during a - * small window. However it is typically a larger - * window than for the others, and we have historically - * treated this as a temporary (i.e. long timeout) - * error with no complaints, so continue to treat - * it as temporary. - */ - return 0; /* temporary */ - case ETIMEDOUT: - case EHOSTUNREACH: - case EAGAIN: - return 0; /* temporary */ - default: - return 1; /* permanent */ - } -} - -/* - * Handle "foreground" NFS mounts. - * - * Retry the mount request for as long as the 'retry=' option says. - * - * Returns a valid mount command exit code. - */ -static int nfsmount_fg(struct nfsmount_info *mi) -{ - unsigned int secs = 1; - time_t timeout; - - timeout = nfs_parse_retry_option(mi->options, - NFS_DEF_FG_TIMEOUT_MINUTES); - if (verbose) - printf(_("%s: timeout set for %s"), - progname, ctime(&timeout)); - - for (;;) { - if (nfs_try_mount(mi)) - return EX_SUCCESS; - - if (errno == EBUSY && is_mountpoint(mi->node)) { - /* - * EBUSY can happen when mounting a filesystem that - * is already mounted or when the context= are - * different when using the -o sharecache - * - * Only error out in the latter case. - */ - return EX_SUCCESS; - } - - if (nfs_is_permanent_error(errno)) - break; - - if (time(NULL) > timeout) - break; - - if (errno != ETIMEDOUT) { - if (sleep(secs)) - break; - secs <<= 1; - if (secs > 10) - secs = 10; - } - } - - mount_error(mi->spec, mi->node, errno); - return EX_FAIL; -} - -/* - * Handle "background" NFS mount [first try] - * - * Returns a valid mount command exit code. - * - * EX_BG should cause the caller to fork and invoke nfsmount_child. - */ -static int nfsmount_parent(struct nfsmount_info *mi) -{ - if (nfs_try_mount(mi)) - return EX_SUCCESS; - - if (nfs_is_permanent_error(errno)) { - mount_error(mi->spec, mi->node, errno); - return EX_FAIL; - } - - sys_mount_errors(mi->hostname, errno, 1, 1); - return EX_BG; -} - -/* - * Handle "background" NFS mount [retry daemon] - * - * Returns a valid mount command exit code: EX_SUCCESS if successful, - * EX_FAIL if a failure occurred. There's nothing to catch the - * error return, though, so we use sys_mount_errors to log the - * failure. - */ -static int nfsmount_child(struct nfsmount_info *mi) -{ - unsigned int secs = 1; - time_t timeout; - - timeout = nfs_parse_retry_option(mi->options, - NFS_DEF_BG_TIMEOUT_MINUTES); - - for (;;) { - if (sleep(secs)) - break; - secs <<= 1; - if (secs > 120) - secs = 120; - - if (nfs_try_mount(mi)) - return EX_SUCCESS; - - if (nfs_is_permanent_error(errno)) - break; - - if (time(NULL) > timeout) - break; - - sys_mount_errors(mi->hostname, errno, 1, 1); - }; - - sys_mount_errors(mi->hostname, errno, 1, 0); - return EX_FAIL; -} - -/* - * Handle "background" NFS mount - * - * Returns a valid mount command exit code. - */ -static int nfsmount_bg(struct nfsmount_info *mi) -{ - if (!mi->child) - return nfsmount_parent(mi); - else - return nfsmount_child(mi); -} - -/* - * Usually all that is needed for an NFS remount is to change - * generic mount options like "sync" or "ro". These generic - * options are controlled by mi->flags, not by text-based - * options, and no contact with the server is needed. - * - * Take care with the /etc/mtab entry for this mount; just - * calling update_mtab() will change an "-t nfs -o vers=4" - * mount to an "-t nfs -o remount" mount, and that will - * confuse umount.nfs. - * - * Returns a valid mount command exit code. - */ -static int nfs_remount(struct nfsmount_info *mi) -{ - if (nfs_sys_mount(mi, mi->options)) - return EX_SUCCESS; - mount_error(mi->spec, mi->node, errno); - return EX_FAIL; -} - -/* - * Process mount options and try a mount system call. - * - * Returns a valid mount command exit code. - */ -static const char *nfs_background_opttbl[] = { - "bg", - "fg", - NULL, -}; - -static int nfsmount_start(struct nfsmount_info *mi) -{ - if (!nfs_validate_options(mi)) - return EX_FAIL; - - /* - * Avoid retry and negotiation logic when remounting - */ - if (mi->flags & MS_REMOUNT) - return nfs_remount(mi); - - if (po_rightmost(mi->options, nfs_background_opttbl) == 0) - return nfsmount_bg(mi); - else - return nfsmount_fg(mi); -} - -/** - * nfsmount_string - Mount an NFS file system using C string options - * @spec: C string specifying remote share to mount ("hostname:path") - * @node: C string pathname of local mounted-on directory - * @type: C string that represents file system type ("nfs" or "nfs4") - * @flags: MS_ style mount flags - * @extra_opts: pointer to C string containing fs-specific mount options - * (input and output argument) - * @fake: flag indicating whether to carry out the whole operation - * @child: one if this is a mount daemon (bg) - * - * Returns a valid mount command exit code. - */ -int nfsmount_string(const char *spec, const char *node, char *type, - int flags, char **extra_opts, int fake, int child) -{ - struct nfsmount_info mi = { - .spec = spec, - .node = node, - .address = NULL, - .type = type, - .extra_opts = extra_opts, - .flags = flags, - .fake = fake, - .child = child, - }; - int retval = EX_FAIL; - - mi.options = po_split(*extra_opts); - if (mi.options) { - retval = nfsmount_start(&mi); - po_destroy(mi.options); - } else - nfs_error(_("%s: internal option parsing error"), progname); - - nfs_freeaddrinfo(mi.address); - free(mi.hostname); - return retval; -} diff --git a/nfs-utils-2.5.2/utils/mount/stropts.h b/nfs-utils-2.5.2/utils/mount/stropts.h deleted file mode 100644 index 6acd2ac..0000000 --- a/nfs-utils-2.5.2/utils/mount/stropts.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * stropts.h -- Provide common network functions for NFS mount/umount - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_STROPTS_H -#define _NFS_UTILS_MOUNT_STROPTS_H - -int nfsmount_string(const char *, const char *, char *, int, - char **, int, int); - -#endif /* _NFS_UTILS_MOUNT_STROPTS_H */ diff --git a/nfs-utils-2.5.2/utils/mount/token.c b/nfs-utils-2.5.2/utils/mount/token.c deleted file mode 100644 index d7e2f4a..0000000 --- a/nfs-utils-2.5.2/utils/mount/token.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * token.c -- tokenize strings, a la strtok(3) - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -/* - * We've constructed a simple string tokenizer that is better than - * strtok(3) in several ways: - * - * 1. It doesn't interfere with ongoing tokenizations using strtok(3). - * 2. It's re-entrant so we can nest tokenizations, if needed. - * 3. It can handle double-quoted delimiters (needed for 'context="sd,fslj"'). - * 4. It doesn't alter the string we're tokenizing, so it can work - * on write-protected strings as well as writable strings. - */ - - -#include -#include -#include -#include -#include -#include - -#include "token.h" - - -struct tokenizer_state { - char *pos; - char delimiter; - int error; -}; - -static void find_next_nondelimiter(struct tokenizer_state *tstate) -{ - while (*tstate->pos != '\0' && *tstate->pos == tstate->delimiter) - tstate->pos++; -} - -static size_t find_next_delimiter(struct tokenizer_state *tstate) -{ - size_t len = 0; - int quote_seen = 0; - - while (*tstate->pos != '\0') { - if (*tstate->pos == '"') - quote_seen ^= 1; - - if (!quote_seen && *tstate->pos == tstate->delimiter) - break; - - len++; - tstate->pos++; - } - - /* did the string terminate before the close quote? */ - if (quote_seen) { - tstate->error = EINVAL; - return 0; - } - - return len; -} - -/** - * next_token - find the next token in a string and return it - * @tstate: pointer to tokenizer context object - * - * Returns the next token found in the current string. - * Returns NULL if there are no more tokens in the string, - * or if an error occurs. - * - * Side effect: tstate is updated - */ -char *next_token(struct tokenizer_state *tstate) -{ - char *token; - size_t len; - - if (!tstate || !tstate->pos || tstate->error) - return NULL; - - find_next_nondelimiter(tstate); - if (*tstate->pos == '\0') - goto fail; - token = tstate->pos; - - len = find_next_delimiter(tstate); - if (len) { - token = strndup(token, len); - if (token) - return token; - tstate->error = ENOMEM; - } - -fail: - tstate->pos = NULL; - return NULL; /* no tokens found in this string */ -} - -/** - * init_tokenizer - return an initialized tokenizer context object - * @string: pointer to C string - * @delimiter: single character that delimits tokens in @string - * - * Returns an initialized tokenizer context object - */ -struct tokenizer_state *init_tokenizer(char *string, char delimiter) -{ - struct tokenizer_state *tstate; - - tstate = malloc(sizeof(*tstate)); - if (tstate) { - tstate->pos = string; - tstate->delimiter = delimiter; - tstate->error = 0; - } - return tstate; -} - -/** - * tokenizer_error - digs error value out of tokenizer context - * @tstate: pointer to tokenizer context object - * - */ -int tokenizer_error(struct tokenizer_state *tstate) -{ - return tstate ? tstate->error : 0; -} - -/** - * end_tokenizer - free a tokenizer context object - * @tstate: pointer to tokenizer context object - * - */ -void end_tokenizer(struct tokenizer_state *tstate) -{ - free(tstate); -} diff --git a/nfs-utils-2.5.2/utils/mount/token.h b/nfs-utils-2.5.2/utils/mount/token.h deleted file mode 100644 index 17a9c15..0000000 --- a/nfs-utils-2.5.2/utils/mount/token.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * token.h -- tokenize strings, a la strtok(3) - * - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_TOKEN_H -#define _NFS_UTILS_MOUNT_TOKEN_H - -struct tokenizer_state; - -char *next_token(struct tokenizer_state *); -struct tokenizer_state *init_tokenizer(char *, char); -int tokenizer_error(struct tokenizer_state *); -void end_tokenizer(struct tokenizer_state *); - -#endif /* _NFS_UTILS_MOUNT_TOKEN_H */ diff --git a/nfs-utils-2.5.2/utils/mount/umount.nfs.man b/nfs-utils-2.5.2/utils/mount/umount.nfs.man deleted file mode 100644 index 15addfa..0000000 --- a/nfs-utils-2.5.2/utils/mount/umount.nfs.man +++ /dev/null @@ -1,70 +0,0 @@ -.\"@(#)umount.nfs.8" -.TH UMOUNT.NFS 8 "6 Jun 2006" -.SH NAME -umount.nfs, umount.nfs4 \- unmount a Network File System -.SH SYNOPSIS -.BI "umount.nfs" " dir" " [\-fvnrlh ]" -.SH DESCRIPTION -.BR umount.nfs -and -.BR umount.nfs4 -are a part of -.BR nfs (5) -utilities package, which provides NFS client functionality. - -.BR umount.nfs4 -and -.BR umount.nfs -are meant to be used by the -.BR umount (8) -command for unmounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. - -.I dir -is the directory on which the file system is mounted. - -.SH OPTIONS -.TP -.BI "\-f" -Force unmount the file system in case of unreachable NFS system. -.TP -.BI "\-v" -Be verbose. -.TP -.BI "\-n" -Do not update -.I /etc/mtab. -By default, an entry is created in -.I /etc/mtab -for every mounted file system. Use this option to skip deleting an entry. -.TP -.BI "\-r" -In case unmounting fails, try to mount read-only. -.TP -.BI "\-l" -Lazy unmount. Detach the file system from the file system hierarchy now, and cleanup all references to the file system as soon as it is not busy anymore. -.TP -.BI "\-h" -Print help message. - -.SH NOTE -For further information please refer -.BR nfs (5) -and -.BR umount (8) -manual pages. - -.SH FILES -.TP 18n -.I /etc/fstab -file system table -.TP -.I /etc/mtab -table of mounted file systems - -.PD -.SH "SEE ALSO" -.BR nfs (5), -.BR umount (8), - -.SH "AUTHOR" -Amit Gud diff --git a/nfs-utils-2.5.2/utils/mount/utils.c b/nfs-utils-2.5.2/utils/mount/utils.c deleted file mode 100644 index 865a4a0..0000000 --- a/nfs-utils-2.5.2/utils/mount/utils.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2010 Karel Zak - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "nfs_mount.h" -#include "nls.h" -#include "xcommon.h" -#include "version.h" -#include "error.h" -#include "utils.h" -#include "mount.h" -#include "network.h" -#include "parse_dev.h" - -extern int verbose; -extern char *progname; - -/* - * Choose the version of the nfs_mount_data structure that is appropriate - * for the kernel that is doing the mount. - * - * NFS_MOUNT_VERSION: maximum version supported by these sources - * nfs_mount_data_version: maximum version supported by the running kernel - */ -int discover_nfs_mount_data_version(int *string_ver) -{ - unsigned int kernel_version = linux_version_code(); - int ver = 0; - - *string_ver = 0; - - if (kernel_version) { - if (kernel_version < MAKE_VERSION(2, 1, 32)) - ver = 1; - else if (kernel_version < MAKE_VERSION(2, 2, 18)) - ver = 3; - else if (kernel_version < MAKE_VERSION(2, 3, 0)) - ver = 4; - else if (kernel_version < MAKE_VERSION(2, 3, 99)) - ver = 3; - else if (kernel_version < MAKE_VERSION(2, 6, 3)) - ver = 4; - else - ver = 6; - } - if (ver > NFS_MOUNT_VERSION) - ver = NFS_MOUNT_VERSION; - else - if (kernel_version > MAKE_VERSION(2, 6, 22)) - (*string_ver)++; - - return ver; -} - -void print_one(char *spec, char *node, char *type, char *opts) -{ - if (!verbose) - return; - - if (opts) - printf(_("%s on %s type %s (%s)\n"), spec, node, type, opts); - else - printf(_("%s on %s type %s\n"), spec, node, type); -} - -void mount_usage(void) -{ - printf(_("usage: %s remotetarget dir [-rvVwfnsh] [-o nfsoptions]\n"), - progname); - printf(_("options:\n")); - printf(_("\t-r\t\tMount file system readonly\n")); - printf(_("\t-v\t\tVerbose\n")); - printf(_("\t-V\t\tPrint version\n")); - printf(_("\t-w\t\tMount file system read-write\n")); - printf(_("\t-f\t\tFake mount, do not actually mount\n")); - printf(_("\t-n\t\tDo not update /etc/mtab\n")); - printf(_("\t-s\t\tTolerate sloppy mount options rather than fail\n")); - printf(_("\t-h\t\tPrint this help\n")); - printf(_("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n")); -} - -void umount_usage(void) -{ - printf(_("usage: %s dir [-fvnrlh]\n"), progname); - printf(_("options:\n\t-f\tforce unmount\n")); - printf(_("\t-v\tverbose\n")); - printf(_("\t-n\tDo not update /etc/mtab\n")); - printf(_("\t-r\tremount\n")); - printf(_("\t-l\tlazy unmount\n")); - printf(_("\t-h\tprint this help\n\n")); -} - -int chk_mountpoint(const char *mount_point) -{ - struct stat sb; - - if (stat(mount_point, &sb) < 0){ - mount_error(NULL, mount_point, errno); - return 1; - } - if (S_ISDIR(sb.st_mode) == 0){ - mount_error(NULL, mount_point, ENOTDIR); - return 1; - } - if (getuid() != 0 && geteuid() != 0 && access(mount_point, X_OK) < 0) { - mount_error(NULL, mount_point, errno); - return 1; - } - - return 0; -} - -/* - * Pick up certain mount options used during the original mount - * from /etc/mtab. The basics include the server's IP address and - * the server pathname of the share to unregister. - * - * These options might also describe the mount port, mount protocol - * version, and transport protocol used to punch through a firewall. - * We will need this information to get through the firewall again - * to do the umount. - * - * Note that option parsing failures won't necessarily cause the - * umount request to fail. Those values will be left zero in the - * pmap tuple. If the GETPORT call later fails to disambiguate them, - * then we fail. - */ -int nfs_umount23(const char *devname, char *string) -{ - char *hostname = NULL, *dirname = NULL; - struct mount_options *options; - int result = EX_FAIL; - - if (!nfs_parse_devname(devname, &hostname, &dirname)) - return EX_USAGE; - - options = po_split(string); - if (options) { - result = nfs_umount_do_umnt(options, &hostname, &dirname); - po_destroy(options); - } else - nfs_error(_("%s: option parsing error"), progname); - - free(hostname); - free(dirname); - return result; -} diff --git a/nfs-utils-2.5.2/utils/mount/utils.h b/nfs-utils-2.5.2/utils/mount/utils.h deleted file mode 100644 index 224918a..0000000 --- a/nfs-utils-2.5.2/utils/mount/utils.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * utils.h -- misc utils for mount and umount - * - * Copyright (C) 2010 Karel Zak - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_UTILS_H -#define _NFS_UTILS_MOUNT_UTILS_H - -#include "parse_opt.h" - -int discover_nfs_mount_data_version(int *string_ver); -void print_one(char *spec, char *node, char *type, char *opts); -void mount_usage(void); -void umount_usage(void); -int chk_mountpoint(const char *mount_point); - -int nfs_umount23(const char *devname, char *string); - -#endif /* !_NFS_UTILS_MOUNT_UTILS_H */ diff --git a/nfs-utils-2.5.2/utils/mount/version.h b/nfs-utils-2.5.2/utils/mount/version.h deleted file mode 100644 index d7cf680..0000000 --- a/nfs-utils-2.5.2/utils/mount/version.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * version.h -- get running kernel version - * - * Copyright (C) 2008 Oracle. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -#ifndef _NFS_UTILS_MOUNT_VERSION_H -#define _NFS_UTILS_MOUNT_VERSION_H - -#include -#include - -#include - -static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q, - unsigned int r) -{ - return (65536 * p) + (256 * q) + r; -} - -static inline unsigned int linux_version_code(void) -{ - struct utsname my_utsname; - unsigned int p, q = 0, r = 0; - - /* UINT_MAX as backward compatibility code should not be run */ - if (uname(&my_utsname)) - return UINT_MAX; - - /* UINT_MAX as future versions might not start with an integer */ - if (sscanf(my_utsname.release, "%u.%u.%u", &p, &q, &r) < 1) - return UINT_MAX; - - return MAKE_VERSION(p, q, r); -} - -#endif /* _NFS_UTILS_MOUNT_VERSION_H */ diff --git a/nfs-utils-2.5.2/utils/mountd/Makefile.am b/nfs-utils-2.5.2/utils/mountd/Makefile.am deleted file mode 100644 index 18610f1..0000000 --- a/nfs-utils-2.5.2/utils/mountd/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -## Process this file with automake to produce Makefile.in - -OPTLIBS = -if CONFIG_JUNCTION -OPTLIBS += ../../support/junction/libjunction.la $(LIBXML2) -endif - -man8_MANS = mountd.man -EXTRA_DIST = $(man8_MANS) - -RPCPREFIX = rpc. -KPREFIX = @kprefix@ -sbin_PROGRAMS = mountd - -noinst_HEADERS = fsloc.h -mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \ - svc_run.c fsloc.c v4root.c mountd.h -mountd_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a \ - $(OPTLIBS) \ - $(LIBBSD) $(LIBWRAP) $(LIBNSL) $(LIBBLKID) $(LIBTIRPC) \ - $(LIBPTHREAD) -mountd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \ - -I$(top_builddir)/support/include \ - -I$(top_srcdir)/support/export - -MAINTAINERCLEANFILES = Makefile.in - -####################################################################### -# The following allows the current practice of having -# daemons renamed during the install to include RPCPREFIX -# and the KPREFIX -# This could all be done much easier with program_transform_name -# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) -# but that also renames the man pages, which the current -# practice does not do. -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) - - -# XXX This makes some assumptions about what automake does. -# XXX But there is no install-man-hook or install-man-local. -install-man: install-man8 install-man-links -uninstall-man: uninstall-man8 uninstall-man-links - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/mountd/auth.c b/nfs-utils-2.5.2/utils/mountd/auth.c deleted file mode 100644 index 67627f7..0000000 --- a/nfs-utils-2.5.2/utils/mountd/auth.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * utils/mountd/auth.c - * - * Authentication procedures for mountd. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "misc.h" -#include "nfslib.h" -#include "exportfs.h" -#include "mountd.h" -#include "v4root.h" - -enum auth_error -{ - bad_path, - unknown_host, - no_entry, - not_exported, - illegal_port, - success -}; - -static void auth_fixpath(char *path); -static nfs_export my_exp; -static nfs_client my_client; - -extern int use_ipaddr; - -extern struct state_paths etab; - -void -auth_init(void) -{ - auth_reload(); -} - -/* - * A client can match many different netgroups and it's tough to know - * beforehand whether it will. If the concatenated string of netgroup - * m_hostnames is >512 bytes, then enable the "use_ipaddr" mode. This - * makes mountd change how it matches a client ip address when a mount - * request comes in. It's more efficient at handling netgroups at the - * expense of larger kernel caches. - */ -static void -check_useipaddr(void) -{ - nfs_client *clp; - int old_use_ipaddr = use_ipaddr; - unsigned int len = 0; - - /* add length of m_hostname + 1 for the comma */ - for (clp = clientlist[MCL_NETGROUP]; clp; clp = clp->m_next) - len += (strlen(clp->m_hostname) + 1); - - if (len > (NFSCLNT_IDMAX / 2)) - use_ipaddr = 1; - else - use_ipaddr = 0; - - if (use_ipaddr != old_use_ipaddr) - cache_flush(1); -} - -unsigned int -auth_reload() -{ - struct stat stb; - static ino_t last_inode; - static int last_fd = -1; - static unsigned int counter; - int fd; - - if ((fd = open(etab.statefn, O_RDONLY)) < 0) { - xlog(L_FATAL, "couldn't open %s", etab.statefn); - } else if (fstat(fd, &stb) < 0) { - xlog(L_FATAL, "couldn't stat %s", etab.statefn); - close(fd); - } else if (last_fd != -1 && stb.st_ino == last_inode) { - /* We opened the etab file before, and its inode - * number hasn't changed since then. - */ - close(fd); - return counter; - } else { - /* Need to process entries from the etab file. Close - * the file descriptor from the previous open (last_fd), - * and keep the current file descriptor open to prevent - * the file system reusing the current inode number - * (last_inode). - */ - if (last_fd != -1) - close(last_fd); - last_fd = fd; - last_inode = stb.st_ino; - } - - export_freeall(); - memset(&my_client, 0, sizeof(my_client)); - xtab_export_read(); - check_useipaddr(); - v4root_set(); - - ++counter; - - return counter; -} - -static char *get_client_ipaddr_name(const struct sockaddr *caller) -{ - char buf[INET6_ADDRSTRLEN + 1]; - - buf[0] = '$'; - host_ntop(caller, buf + 1, sizeof(buf) - 1); - return strdup(buf); -} - -static char * -get_client_hostname(const struct sockaddr *caller, struct addrinfo *ai, - enum auth_error *error) -{ - char *n; - - if (use_ipaddr) - return get_client_ipaddr_name(caller); - n = client_compose(ai); - *error = unknown_host; - if (!n) - return NULL; - if (*n) - return n; - free(n); - return strdup("DEFAULT"); -} - -bool ipaddr_client_matches(nfs_export *exp, struct addrinfo *ai) -{ - return client_check(exp->m_client, ai); -} - -bool namelist_client_matches(nfs_export *exp, char *dom) -{ - return client_member(dom, exp->m_client->m_hostname); -} - -bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai) -{ - if (is_ipaddr_client(dom)) - return ipaddr_client_matches(exp, ai); - return namelist_client_matches(exp, dom); -} - -/* return static nfs_export with details filled in */ -static nfs_export * -auth_authenticate_newcache(const struct sockaddr *caller, - const char *path, struct addrinfo *ai, - enum auth_error *error) -{ - nfs_export *exp; - int i; - - free(my_client.m_hostname); - - my_client.m_hostname = get_client_hostname(caller, ai, error); - if (my_client.m_hostname == NULL) - return NULL; - - my_client.m_naddr = 1; - set_addrlist(&my_client, 0, caller); - my_exp.m_client = &my_client; - - exp = NULL; - for (i = 0; !exp && i < MCL_MAXTYPES; i++) - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (strcmp(path, exp->m_export.e_path)) - continue; - if (!client_matches(exp, my_client.m_hostname, ai)) - continue; - if (exp->m_export.e_flags & NFSEXP_V4ROOT) - /* not acceptable for v[23] export */ - continue; - break; - } - *error = not_exported; - if (!exp) - return NULL; - - my_exp.m_export = exp->m_export; - exp = &my_exp; - return exp; -} - -static nfs_export * -auth_authenticate_internal(const struct sockaddr *caller, const char *path, - struct addrinfo *ai, enum auth_error *error) -{ - nfs_export *exp; - - exp = auth_authenticate_newcache(caller, path, ai, error); - if (!exp) - return NULL; - if (!(exp->m_export.e_flags & NFSEXP_INSECURE_PORT) && - nfs_get_port(caller) >= IPPORT_RESERVED) { - *error = illegal_port; - return NULL; - } - *error = success; - - return exp; -} - -nfs_export * -auth_authenticate(const char *what, const struct sockaddr *caller, - const char *path) -{ - nfs_export *exp = NULL; - char epath[MAXPATHLEN+1]; - char *p = NULL; - char buf[INET6_ADDRSTRLEN]; - struct addrinfo *ai = NULL; - enum auth_error error = bad_path; - - if (path[0] != '/') { - xlog(L_WARNING, "Bad path in %s request from %s: \"%s\"", - what, host_ntop(caller, buf, sizeof(buf)), path); - return exp; - } - - strncpy(epath, path, sizeof (epath) - 1); - epath[sizeof (epath) - 1] = '\0'; - auth_fixpath(epath); /* strip duplicate '/' etc */ - - ai = client_resolve(caller); - if (ai == NULL) - return exp; - - /* Try the longest matching exported pathname. */ - while (1) { - exp = auth_authenticate_internal(caller, epath, ai, &error); - if (exp || (error != not_exported && error != no_entry)) - break; - /* We have to treat the root, "/", specially. */ - if (p == &epath[1]) break; - p = strrchr(epath, '/'); - if (p == epath) p++; - *p = '\0'; - } - - host_ntop(caller, buf, sizeof(buf)); - switch (error) { - case bad_path: - xlog(L_WARNING, "bad path in %s request from %s: \"%s\"", - what, buf, path); - break; - - case unknown_host: - xlog(L_WARNING, "refused %s request from %s for %s (%s): unmatched host", - what, buf, path, epath); - break; - - case no_entry: - xlog(L_WARNING, "refused %s request from %s for %s (%s): no export entry", - what, buf, path, epath); - break; - - case not_exported: - xlog(L_WARNING, "refused %s request from %s for %s (%s): not exported", - what, buf, path, epath); - break; - - case illegal_port: - xlog(L_WARNING, "refused %s request from %s for %s (%s): illegal port %u", - what, buf, path, epath, nfs_get_port(caller)); - break; - - case success: - xlog(L_NOTICE, "authenticated %s request from %s:%u for %s (%s)", - what, buf, nfs_get_port(caller), path, epath); - break; - default: - xlog(L_NOTICE, "%s request from %s:%u for %s (%s) gave %d", - what, buf, nfs_get_port(caller), path, epath, error); - } - - nfs_freeaddrinfo(ai); - return exp; -} - -static void -auth_fixpath(char *path) -{ - char *sp, *cp; - - for (sp = cp = path; *sp; sp++) { - if (*sp != '/' || sp[1] != '/') - *cp++ = *sp; - } - while (cp > path+1 && cp[-1] == '/') - cp--; - *cp = '\0'; -} diff --git a/nfs-utils-2.5.2/utils/mountd/cache.c b/nfs-utils-2.5.2/utils/mountd/cache.c deleted file mode 100644 index a81e820..0000000 --- a/nfs-utils-2.5.2/utils/mountd/cache.c +++ /dev/null @@ -1,1651 +0,0 @@ - -/* - * Handle communication with knfsd internal cache - * - * We open /proc/net/rpc/{auth.unix.ip,nfsd.export,nfsd.fh}/channel - * and listen for requests (using my_svc_run) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "misc.h" -#include "nfsd_path.h" -#include "nfslib.h" -#include "exportfs.h" -#include "mountd.h" -#include "fsloc.h" -#include "pseudoflavors.h" -#include "xcommon.h" - -#ifdef USE_BLKID -#include "blkid/blkid.h" -#endif - -/* - * Invoked by RPC service loop - */ -void cache_set_fds(fd_set *fdset); -int cache_process_req(fd_set *readfds); - -enum nfsd_fsid { - FSID_DEV = 0, - FSID_NUM, - FSID_MAJOR_MINOR, - FSID_ENCODE_DEV, - FSID_UUID4_INUM, - FSID_UUID8, - FSID_UUID16, - FSID_UUID16_INUM, -}; - -#undef is_mountpoint -static int is_mountpoint(const char *path) -{ - return check_is_mountpoint(path, nfsd_path_lstat); -} - -static ssize_t cache_read(int fd, char *buf, size_t len) -{ - return nfsd_path_read(fd, buf, len); -} - -static ssize_t cache_write(int fd, const char *buf, size_t len) -{ - return nfsd_path_write(fd, buf, len); -} - -static bool path_lookup_error(int err) -{ - switch (err) { - case ELOOP: - case ENAMETOOLONG: - case ENOENT: - case ENOTDIR: - return 1; - } - return 0; -} - -/* - * Support routines for text-based upcalls. - * Fields are separated by spaces. - * Fields are either mangled to quote space tab newline slosh with slosh - * or a hexified with a leading \x - * Record is terminated with newline. - * - */ -static int cache_export_ent(char *buf, int buflen, char *domain, struct exportent *exp, char *path); - -#define INITIAL_MANAGED_GROUPS 100 - -extern int use_ipaddr; - -static void auth_unix_ip(int f) -{ - /* requests are - * class IP-ADDR - * Ignore if class != "nfsd" - * Otherwise find domainname and write back: - * - * "nfsd" IP-ADDR expiry domainname - */ - char class[20]; - char ipaddr[INET6_ADDRSTRLEN + 1]; - char *client = NULL; - struct addrinfo *tmp = NULL; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen; - - blen = read(f, buf, sizeof(buf)); - if (blen <= 0 || buf[blen-1] != '\n') return; - buf[blen-1] = 0; - - xlog(D_CALL, "auth_unix_ip: inbuf '%s'", buf); - - bp = buf; - - if (qword_get(&bp, class, 20) <= 0 || - strcmp(class, "nfsd") != 0) - return; - - if (qword_get(&bp, ipaddr, sizeof(ipaddr) - 1) <= 0) - return; - - tmp = host_pton(ipaddr); - if (tmp == NULL) - return; - - auth_reload(); - - /* addr is a valid, interesting address, find the domain name... */ - if (!use_ipaddr) { - struct addrinfo *ai = NULL; - - ai = client_resolve(tmp->ai_addr); - if (ai) { - client = client_compose(ai); - nfs_freeaddrinfo(ai); - } - } - bp = buf; blen = sizeof(buf); - qword_add(&bp, &blen, "nfsd"); - qword_add(&bp, &blen, ipaddr); - qword_adduint(&bp, &blen, time(0) + DEFAULT_TTL); - if (use_ipaddr) { - memmove(ipaddr + 1, ipaddr, strlen(ipaddr) + 1); - ipaddr[0] = '$'; - qword_add(&bp, &blen, ipaddr); - } else if (client) - qword_add(&bp, &blen, *client?client:"DEFAULT"); - qword_addeol(&bp, &blen); - if (blen <= 0 || write(f, buf, bp - buf) != bp - buf) - xlog(L_ERROR, "auth_unix_ip: error writing reply"); - - xlog(D_CALL, "auth_unix_ip: client %p '%s'", client, client?client: "DEFAULT"); - - free(client); - nfs_freeaddrinfo(tmp); - -} - -static void auth_unix_gid(int f) -{ - /* Request are - * uid - * reply is - * uid expiry count list of group ids - */ - uid_t uid; - struct passwd *pw; - static gid_t *groups = NULL; - static int groups_len = 0; - gid_t *more_groups; - int ngroups; - int rv, i; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen; - - if (groups_len == 0) { - groups = malloc(sizeof(gid_t) * INITIAL_MANAGED_GROUPS); - if (!groups) - return; - - groups_len = INITIAL_MANAGED_GROUPS; - } - - ngroups = groups_len; - - blen = read(f, buf, sizeof(buf)); - if (blen <= 0 || buf[blen-1] != '\n') return; - buf[blen-1] = 0; - - bp = buf; - if (qword_get_uint(&bp, &uid) != 0) - return; - - pw = getpwuid(uid); - if (!pw) - rv = -1; - else { - rv = getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); - if (rv == -1 && ngroups >= groups_len) { - more_groups = realloc(groups, sizeof(gid_t)*ngroups); - if (!more_groups) - rv = -1; - else { - groups = more_groups; - groups_len = ngroups; - rv = getgrouplist(pw->pw_name, pw->pw_gid, - groups, &ngroups); - } - } - } - - bp = buf; blen = sizeof(buf); - qword_adduint(&bp, &blen, uid); - qword_adduint(&bp, &blen, time(0) + DEFAULT_TTL); - if (rv >= 0) { - qword_adduint(&bp, &blen, ngroups); - for (i=0; if_fsid. The rest are network or - * pseudo filesystems. (See for the basic IDs.) - */ -static const unsigned long nonblkid_filesystems[] = { - 0x2fc12fc1, /* ZFS_SUPER_MAGIC */ - 0x9123683E, /* BTRFS_SUPER_MAGIC */ - 0xFF534D42, /* CIFS_MAGIC_NUMBER */ - 0x1373, /* DEVFS_SUPER_MAGIC */ - 0x73757245, /* CODA_SUPER_MAGIC */ - 0x564C, /* NCP_SUPER_MAGIC */ - 0x6969, /* NFS_SUPER_MAGIC */ - 0x9FA0, /* PROC_SUPER_MAGIC */ - 0x62656572, /* SYSFS_MAGIC */ - 0x517B, /* SMB_SUPER_MAGIC */ - 0x01021994, /* TMPFS_SUPER_MAGIC */ - 0 /* last */ -}; - -static int uuid_by_path(char *path, int type, size_t uuidlen, char *uuid) -{ - /* get a uuid for the filesystem found at 'path'. - * There are several possible ways of generating the - * uuids (types). - * Type 0 is used for new filehandles, while other types - * may be used to interpret old filehandle - to ensure smooth - * forward migration. - * We return 1 if a uuid was found (and it might be worth - * trying the next type) or 0 if no more uuid types can be - * extracted. - */ - - /* Possible sources of uuid are - * - blkid uuid - * - statfs64 uuid - * - * On some filesystems (e.g. vfat) the statfs64 uuid is simply an - * encoding of the device that the filesystem is mounted from, so - * it we be very bad to use that (as device numbers change). blkid - * must be preferred. - * On other filesystems (e.g. btrfs) the statfs64 uuid contains - * important info that the blkid uuid cannot contain: This happens - * when multiple subvolumes are exported (they have the same - * blkid uuid but different statfs64 uuids). - * We rely on get_uuid_blkdev *knowing* which is which and not returning - * a uuid for filesystems where the statfs64 uuid is better. - * - */ - struct statfs64 st; - char fsid_val[17]; - const char *blkid_val = NULL; - const char *val; - int rc; - - rc = nfsd_path_statfs64(path, &st); - - if (type == 0 && rc == 0) { - const unsigned long *bad; - for (bad = nonblkid_filesystems; *bad; bad++) { - if (*bad == (unsigned long)st.f_type) - break; - } - if (*bad == 0) - blkid_val = get_uuid_blkdev(path); - } - - if (rc == 0 && - (st.f_fsid.__val[0] || st.f_fsid.__val[1])) - snprintf(fsid_val, 17, "%08x%08x", - st.f_fsid.__val[0], st.f_fsid.__val[1]); - else - fsid_val[0] = 0; - - if (blkid_val && (type--) == 0) - val = blkid_val; - else if (fsid_val[0] && (type--) == 0) - val = fsid_val; - else - return 0; - - get_uuid(val, uuidlen, uuid); - return 1; -} - -/* Iterate through /etc/mtab, finding mountpoints - * at or below a given path - */ -static char *next_mnt(void **v, char *p) -{ - FILE *f; - struct mntent *me; - size_t l = strlen(p); - - if (*v == NULL) { - f = setmntent("/etc/mtab", "r"); - *v = f; - } else - f = *v; - while ((me = getmntent(f)) != NULL && l > 1) { - char *mnt_dir = nfsd_path_strip_root(me->mnt_dir); - - if (!mnt_dir) - continue; - - if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] == '/') - return mnt_dir; - } - endmntent(f); - *v = NULL; - return NULL; -} - -/* same_path() check is two paths refer to the same directory. - * We don't rely on 'strcmp()' as some filesystems support case-insensitive - * names and we might have two different names for the one directory. - * Theoretically the lengths of the names could be different, but the - * number of components must be the same. - * So if the paths have the same number of components (but aren't identical) - * we ask the kernel if they are the same thing. - * By preference we use name_to_handle_at(), as the mntid it returns - * will distinguish between bind-mount points. If that isn't available - * we fall back on lstat, which is usually good enough. - */ -static inline int count_slashes(char *p) -{ - int cnt = 0; - while (*p) - if (*p++ == '/') - cnt++; - return cnt; -} - -#if defined(HAVE_STRUCT_FILE_HANDLE) -static int check_same_path_by_handle(const char *child, const char *parent) -{ - struct { - struct file_handle fh; - unsigned char handle[128]; - } fchild, fparent; - int mnt_child, mnt_parent; - - fchild.fh.handle_bytes = 128; - fparent.fh.handle_bytes = 128; - - /* This process should have the CAP_DAC_READ_SEARCH capability */ - if (nfsd_name_to_handle_at(AT_FDCWD, child, &fchild.fh, &mnt_child, 0) < 0) - return -1; - if (nfsd_name_to_handle_at(AT_FDCWD, parent, &fparent.fh, &mnt_parent, 0) < 0) { - /* If the child resolved, but the parent did not, they differ */ - if (path_lookup_error(errno)) - return 0; - /* Otherwise, we just don't know */ - return -1; - } - - if (mnt_child != mnt_parent || - fchild.fh.handle_bytes != fparent.fh.handle_bytes || - fchild.fh.handle_type != fparent.fh.handle_type || - memcmp(fchild.handle, fparent.handle, - fchild.fh.handle_bytes) != 0) - return 0; - - return 1; -} -#else -static int check_same_path_by_handle(const char *child, const char *parent) -{ - errno = ENOSYS; - return -1; -} -#endif - -static int check_same_path_by_inode(const char *child, const char *parent) -{ - struct stat sc, sp; - - /* This is nearly good enough. However if a directory is - * bind-mounted in two places and both are exported, it - * could give a false positive - */ - if (nfsd_path_lstat(child, &sc) != 0) - return 0; - if (nfsd_path_lstat(parent, &sp) != 0) - return 0; - if (sc.st_dev != sp.st_dev) - return 0; - if (sc.st_ino != sp.st_ino) - return 0; - - return 1; -} - -static int same_path(char *child, char *parent, int len) -{ - static char p[PATH_MAX]; - int err; - - if (len <= 0) - len = strlen(child); - strncpy(p, child, len); - p[len] = 0; - if (strcmp(p, parent) == 0) - return 1; - - /* If number of '/' are different, they must be different */ - if (count_slashes(p) != count_slashes(parent)) - return 0; - - /* Try to use filehandle approach before falling back to stat() */ - err = check_same_path_by_handle(p, parent); - if (err != -1) - return err; - return check_same_path_by_inode(p, parent); -} - -static int is_subdirectory(char *child, char *parent) -{ - /* Check is child is strictly a subdirectory of - * parent or a more distant descendant. - */ - size_t l = strlen(parent); - - if (strcmp(parent, "/") == 0 && child[1] != 0) - return 1; - - return (same_path(child, parent, l) && child[l] == '/'); -} - -static int path_matches(nfs_export *exp, char *path) -{ - /* Does the path match the export? I.e. is it an - * exact match, or does the export have CROSSMOUNT, and path - * is a descendant? - */ - return same_path(path, exp->m_export.e_path, 0) - || ((exp->m_export.e_flags & NFSEXP_CROSSMOUNT) - && is_subdirectory(path, exp->m_export.e_path)); -} - -static int -export_matches(nfs_export *exp, char *dom, char *path, struct addrinfo *ai) -{ - return path_matches(exp, path) && client_matches(exp, dom, ai); -} - -/* True iff e1 is a child of e2 (or descendant) and e2 has crossmnt set: */ -static bool subexport(struct exportent *e1, struct exportent *e2) -{ - char *p1 = e1->e_path, *p2 = e2->e_path; - - return e2->e_flags & NFSEXP_CROSSMOUNT - && is_subdirectory(p1, p2); -} - -struct parsed_fsid { - int fsidtype; - /* We could use a union for this, but it would be more - * complicated; why bother? */ - uint64_t inode; - unsigned int minor; - unsigned int major; - uint32_t fsidnum; - size_t uuidlen; - char *fhuuid; -}; - -static int parse_fsid(int fsidtype, int fsidlen, char *fsid, - struct parsed_fsid *parsed) -{ - uint32_t dev; - uint32_t inode32; - - memset(parsed, 0, sizeof(*parsed)); - parsed->fsidtype = fsidtype; - switch(fsidtype) { - case FSID_DEV: /* 4 bytes: 2 major, 2 minor, 4 inode */ - if (fsidlen != 8) - return -1; - memcpy(&dev, fsid, 4); - memcpy(&inode32, fsid+4, 4); - parsed->inode = inode32; - parsed->major = ntohl(dev)>>16; - parsed->minor = ntohl(dev) & 0xFFFF; - break; - - case FSID_NUM: /* 4 bytes - fsid */ - if (fsidlen != 4) - return -1; - memcpy(&parsed->fsidnum, fsid, 4); - break; - - case FSID_MAJOR_MINOR: /* 12 bytes: 4 major, 4 minor, 4 inode - * This format is never actually used but was - * an historical accident - */ - if (fsidlen != 12) - return -1; - memcpy(&dev, fsid, 4); - parsed->major = ntohl(dev); - memcpy(&dev, fsid+4, 4); - parsed->minor = ntohl(dev); - memcpy(&inode32, fsid+8, 4); - parsed->inode = inode32; - break; - - case FSID_ENCODE_DEV: /* 8 bytes: 4 byte packed device number, 4 inode */ - /* This is *host* endian, not net-byte-order, because - * no-one outside this host has any business interpreting it - */ - if (fsidlen != 8) - return -1; - memcpy(&dev, fsid, 4); - memcpy(&inode32, fsid+4, 4); - parsed->inode = inode32; - parsed->major = (dev & 0xfff00) >> 8; - parsed->minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); - break; - - case FSID_UUID4_INUM: /* 4 byte inode number and 4 byte uuid */ - if (fsidlen != 8) - return -1; - memcpy(&inode32, fsid, 4); - parsed->inode = inode32; - parsed->uuidlen = 4; - parsed->fhuuid = fsid+4; - break; - case FSID_UUID8: /* 8 byte uuid */ - if (fsidlen != 8) - return -1; - parsed->uuidlen = 8; - parsed->fhuuid = fsid; - break; - case FSID_UUID16: /* 16 byte uuid */ - if (fsidlen != 16) - return -1; - parsed->uuidlen = 16; - parsed->fhuuid = fsid; - break; - case FSID_UUID16_INUM: /* 8 byte inode number and 16 byte uuid */ - if (fsidlen != 24) - return -1; - memcpy(&parsed->inode, fsid, 8); - parsed->uuidlen = 16; - parsed->fhuuid = fsid+8; - break; - } - return 0; -} - -static int match_fsid(struct parsed_fsid *parsed, nfs_export *exp, char *path) -{ - struct stat stb; - int type; - char u[16]; - - if (nfsd_path_stat(path, &stb) != 0) - goto path_error; - if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) - goto nomatch; - - switch (parsed->fsidtype) { - case FSID_DEV: - case FSID_MAJOR_MINOR: - case FSID_ENCODE_DEV: - if (stb.st_ino != parsed->inode) - goto nomatch; - if (parsed->major != major(stb.st_dev) || - parsed->minor != minor(stb.st_dev)) - goto nomatch; - goto match; - case FSID_NUM: - if (((exp->m_export.e_flags & NFSEXP_FSID) == 0 || - exp->m_export.e_fsid != parsed->fsidnum)) - goto nomatch; - goto match; - case FSID_UUID4_INUM: - case FSID_UUID16_INUM: - if (stb.st_ino != parsed->inode) - goto nomatch; - goto check_uuid; - case FSID_UUID8: - case FSID_UUID16: - errno = 0; - if (!is_mountpoint(path)) { - if (!errno) - goto nomatch; - goto path_error; - } - check_uuid: - if (exp->m_export.e_uuid) { - get_uuid(exp->m_export.e_uuid, parsed->uuidlen, u); - if (memcmp(u, parsed->fhuuid, parsed->uuidlen) == 0) - goto match; - } - else - for (type = 0; - uuid_by_path(path, type, parsed->uuidlen, u); - type++) - if (memcmp(u, parsed->fhuuid, parsed->uuidlen) == 0) - goto match; - } -nomatch: - return 0; -match: - return 1; -path_error: - if (path_lookup_error(errno)) - goto nomatch; - return -1; -} - -static struct addrinfo *lookup_client_addr(char *dom) -{ - struct addrinfo *ret; - struct addrinfo *tmp; - - dom++; /* skip initial "$" */ - - tmp = host_pton(dom); - if (tmp == NULL) - return NULL; - ret = client_resolve(tmp->ai_addr); - nfs_freeaddrinfo(tmp); - return ret; -} - -static void nfsd_fh(int f) -{ - /* request are: - * domain fsidtype fsid - * interpret fsid, find export point and options, and write: - * domain fsidtype fsid expiry path - */ - char *dom; - int fsidtype; - int fsidlen; - char fsid[32]; - struct parsed_fsid parsed; - struct exportent *found = NULL; - struct addrinfo *ai = NULL; - char *found_path = NULL; - nfs_export *exp; - int i; - int dev_missing = 0; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen; - - blen = cache_read(f, buf, sizeof(buf)); - if (blen <= 0 || buf[blen-1] != '\n') return; - buf[blen-1] = 0; - - xlog(D_CALL, "nfsd_fh: inbuf '%s'", buf); - - bp = buf; - - dom = malloc(blen); - if (dom == NULL) - return; - if (qword_get(&bp, dom, blen) <= 0) - goto out; - if (qword_get_int(&bp, &fsidtype) != 0) - goto out; - if (fsidtype < 0 || fsidtype > 7) - goto out; /* unknown type */ - if ((fsidlen = qword_get(&bp, fsid, 32)) <= 0) - goto out; - if (parse_fsid(fsidtype, fsidlen, fsid, &parsed)) - goto out; - - auth_reload(); - - if (is_ipaddr_client(dom)) { - ai = lookup_client_addr(dom); - if (!ai) - goto out; - } - - /* Now determine export point for this fsid/domain */ - for (i=0 ; i < MCL_MAXTYPES; i++) { - nfs_export *next_exp; - for (exp = exportlist[i].p_head; exp; exp = next_exp) { - char *path; - - if (exp->m_export.e_flags & NFSEXP_CROSSMOUNT) { - static nfs_export *prev = NULL; - static void *mnt = NULL; - - if (prev == exp) { - /* try a submount */ - path = next_mnt(&mnt, exp->m_export.e_path); - if (!path) { - next_exp = exp->m_next; - prev = NULL; - continue; - } - next_exp = exp; - } else { - prev = exp; - mnt = NULL; - path = exp->m_export.e_path; - next_exp = exp; - } - } else { - path = exp->m_export.e_path; - next_exp = exp->m_next; - } - - if (!is_ipaddr_client(dom) - && !namelist_client_matches(exp, dom)) - continue; - if (exp->m_export.e_mountpoint && - !is_mountpoint(exp->m_export.e_mountpoint[0]? - exp->m_export.e_mountpoint: - exp->m_export.e_path)) - dev_missing ++; - - switch(match_fsid(&parsed, exp, path)) { - case 0: - continue; - case -1: - goto out; - } - if (is_ipaddr_client(dom) - && !ipaddr_client_matches(exp, ai)) - continue; - if (!found || subexport(&exp->m_export, found)) { - found = &exp->m_export; - free(found_path); - found_path = strdup(path); - if (found_path == NULL) - goto out; - } else if (strcmp(found->e_path, exp->m_export.e_path) != 0 - && !subexport(found, &exp->m_export)) - { - xlog(L_WARNING, "%s and %s have same filehandle for %s, using first", - found_path, path, dom); - } else { - /* same path, if one is V4ROOT, choose the other */ - if (found->e_flags & NFSEXP_V4ROOT) { - found = &exp->m_export; - free(found_path); - found_path = strdup(path); - if (found_path == NULL) - goto out; - } - } - } - } - - if (!found) { - /* The missing dev could be what we want, so just be - * quiet rather than returning stale yet - */ - if (dev_missing) - goto out; - } else if (found->e_mountpoint && - !is_mountpoint(found->e_mountpoint[0]? - found->e_mountpoint: - found->e_path)) { - /* Cannot export this yet - * should log a warning, but need to rate limit - xlog(L_WARNING, "%s not exported as %d not a mountpoint", - found->e_path, found->e_mountpoint); - */ - /* FIXME we need to make sure we re-visit this later */ - goto out; - } else if (cache_export_ent(buf, sizeof(buf), dom, found, found_path) < 0) { - if (!path_lookup_error(errno)) - goto out; - /* The kernel is saying the path is unexportable */ - found = NULL; - } - - bp = buf; blen = sizeof(buf); - qword_add(&bp, &blen, dom); - qword_addint(&bp, &blen, fsidtype); - qword_addhex(&bp, &blen, fsid, fsidlen); - /* The fsid -> path lookup can be quite expensive as it - * potentially stats and reads lots of devices, and some of those - * might have spun-down. The Answer is not likely to - * change underneath us, and an 'exportfs -f' can always - * remove this from the kernel, so use a really log - * timeout. Maybe this should be configurable on the command - * line. - */ - qword_addint(&bp, &blen, 0x7fffffff); - if (found) - qword_add(&bp, &blen, found_path); - qword_addeol(&bp, &blen); - if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf) - xlog(L_ERROR, "nfsd_fh: error writing reply"); -out: - if (found_path) - free(found_path); - nfs_freeaddrinfo(ai); - free(dom); - xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL); -} - -static void write_fsloc(char **bp, int *blen, struct exportent *ep) -{ - struct servers *servers; - - if (ep->e_fslocmethod == FSLOC_NONE) - return; - - servers = replicas_lookup(ep->e_fslocmethod, ep->e_fslocdata); - if (!servers) - return; - qword_add(bp, blen, "fsloc"); - qword_addint(bp, blen, servers->h_num); - if (servers->h_num >= 0) { - int i; - for (i=0; ih_num; i++) { - qword_add(bp, blen, servers->h_mp[i]->h_host); - qword_add(bp, blen, servers->h_mp[i]->h_path); - } - } - qword_addint(bp, blen, servers->h_referral); - release_replicas(servers); -} - -static void write_secinfo(char **bp, int *blen, struct exportent *ep, int flag_mask) -{ - struct sec_entry *p; - - for (p = ep->e_secinfo; p->flav; p++) - ; /* Do nothing */ - if (p == ep->e_secinfo) { - /* There was no sec= option */ - return; - } - fix_pseudoflavor_flags(ep); - qword_add(bp, blen, "secinfo"); - qword_addint(bp, blen, p - ep->e_secinfo); - for (p = ep->e_secinfo; p->flav; p++) { - qword_addint(bp, blen, p->flav->fnum); - qword_addint(bp, blen, p->flags & flag_mask); - } - -} - -static int dump_to_cache(int f, char *buf, int blen, char *domain, - char *path, struct exportent *exp, int ttl) -{ - char *bp = buf; - time_t now = time(0); - size_t buflen; - ssize_t err; - - if (ttl <= 1) - ttl = DEFAULT_TTL; - - qword_add(&bp, &blen, domain); - qword_add(&bp, &blen, path); - if (exp) { - int different_fs = strcmp(path, exp->e_path) != 0; - int flag_mask = different_fs ? ~NFSEXP_FSID : ~0; - - qword_adduint(&bp, &blen, now + exp->e_ttl); - qword_addint(&bp, &blen, exp->e_flags & flag_mask); - qword_addint(&bp, &blen, exp->e_anonuid); - qword_addint(&bp, &blen, exp->e_anongid); - qword_addint(&bp, &blen, exp->e_fsid); - write_fsloc(&bp, &blen, exp); - write_secinfo(&bp, &blen, exp, flag_mask); - if (exp->e_uuid == NULL || different_fs) { - char u[16]; - if (uuid_by_path(path, 0, 16, u)) { - qword_add(&bp, &blen, "uuid"); - qword_addhex(&bp, &blen, u, 16); - } - } else { - char u[16]; - get_uuid(exp->e_uuid, 16, u); - qword_add(&bp, &blen, "uuid"); - qword_addhex(&bp, &blen, u, 16); - } - } else - qword_adduint(&bp, &blen, now + ttl); - qword_addeol(&bp, &blen); - if (blen <= 0) { - errno = ENOBUFS; - return -1; - } - buflen = bp - buf; - err = cache_write(f, buf, buflen); - if (err < 0) - return err; - if ((size_t)err != buflen) { - errno = ENOSPC; - return -1; - } - return 0; -} - -static nfs_export * -lookup_export(char *dom, char *path, struct addrinfo *ai) -{ - nfs_export *exp; - nfs_export *found = NULL; - int found_type = 0; - int i; - - for (i=0 ; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (!export_matches(exp, dom, path, ai)) - continue; - if (!found) { - found = exp; - found_type = i; - continue; - } - /* Always prefer non-V4ROOT exports */ - if (exp->m_export.e_flags & NFSEXP_V4ROOT) - continue; - if (found->m_export.e_flags & NFSEXP_V4ROOT) { - found = exp; - found_type = i; - continue; - } - - /* If one is a CROSSMOUNT, then prefer the longest path */ - if (((found->m_export.e_flags & NFSEXP_CROSSMOUNT) || - (exp->m_export.e_flags & NFSEXP_CROSSMOUNT)) && - strlen(found->m_export.e_path) != - strlen(exp->m_export.e_path)) { - - if (strlen(exp->m_export.e_path) > - strlen(found->m_export.e_path)) { - found = exp; - found_type = i; - } - continue; - - } else if (found_type == i && found->m_warned == 0) { - xlog(L_WARNING, "%s exported to both %s and %s, " - "arbitrarily choosing options from first", - path, found->m_client->m_hostname, exp->m_client->m_hostname); - found->m_warned = 1; - } - } - } - return found; -} - -#ifdef HAVE_JUNCTION_SUPPORT - -#include -#include "junction.h" - -struct nfs_fsloc_set { - int ns_ttl; - struct nfs_fsloc *ns_current; - struct nfs_fsloc *ns_list; -}; - -/* - * Find the export entry for the parent of "pathname". - * Caller must not free returned exportent. - */ -static struct exportent *lookup_parent_export(char *dom, - const char *pathname, struct addrinfo *ai) -{ - char *parent, *slash; - nfs_export *result; - - parent = strdup(pathname); - if (parent == NULL) { - xlog(D_GENERAL, "%s: failed to allocate parent path buffer", - __func__); - goto out_default; - } - xlog(D_CALL, "%s: pathname = '%s'", __func__, pathname); - -again: - /* shorten pathname by one component */ - slash = strrchr(parent, '/'); - if (slash == NULL) { - xlog(D_GENERAL, "%s: no slash found in pathname", - __func__); - goto out_default; - } - *slash = '\0'; - - if (strlen(parent) == 0) { - result = lookup_export(dom, "/", ai); - if (result == NULL) { - xlog(L_ERROR, "%s: no root export found.", __func__); - goto out_default; - } - goto out; - } - - result = lookup_export(dom, parent, ai); - if (result == NULL) { - xlog(D_GENERAL, "%s: lookup_export(%s) found nothing", - __func__, parent); - goto again; - } - -out: - xlog(D_CALL, "%s: found export for %s", __func__, parent); - free(parent); - return &result->m_export; - -out_default: - free(parent); - return mkexportent("*", "/", "insecure"); -} - -static int get_next_location(struct nfs_fsloc_set *locset, - char **hostname, char **export_path, int *ttl) -{ - char *hostname_tmp, *export_path_tmp; - struct nfs_fsloc *fsloc; - - if (locset->ns_current == NULL) - return ENOENT; - fsloc = locset->ns_current; - - hostname_tmp = strdup(fsloc->nfl_hostname); - if (hostname_tmp == NULL) - return ENOMEM; - - if (nsdb_path_array_to_posix(fsloc->nfl_rootpath, - &export_path_tmp)) { - free(hostname_tmp); - return EINVAL; - } - - *hostname = hostname_tmp; - *export_path = export_path_tmp; - *ttl = locset->ns_ttl; - locset->ns_current = locset->ns_current->nfl_next; - return 0; -} - -/* - * Walk through a set of FS locations and build an e_fslocdata string. - * Returns true if all went to plan; otherwise, false. - */ -static bool locations_to_fslocdata(struct nfs_fsloc_set *locations, - char *fslocdata, size_t remaining, int *ttl) -{ - char *server, *last_path, *rootpath, *ptr; - _Bool seen = false; - - last_path = NULL; - rootpath = NULL; - server = NULL; - ptr = fslocdata; - *ttl = 0; - - for (;;) { - int len, status; - - status = get_next_location(locations, &server, - &rootpath, ttl); - if (status == ENOENT) - break; - if (status) { - xlog(D_GENERAL, "%s: failed to parse location: %s", - __func__, strerror(status)); - goto out_false; - } - xlog(D_GENERAL, "%s: Location: %s:%s", - __func__, server, rootpath); - - if (last_path && strcmp(rootpath, last_path) == 0) { - len = snprintf(ptr, remaining, "+%s", server); - if (len < 0) { - xlog(D_GENERAL, "%s: snprintf: %m", __func__); - goto out_false; - } - if ((size_t)len >= remaining) { - xlog(D_GENERAL, "%s: fslocdata buffer overflow", __func__); - goto out_false; - } - remaining -= (size_t)len; - ptr += len; - } else { - if (last_path == NULL) - len = snprintf(ptr, remaining, "%s@%s", - rootpath, server); - else - len = snprintf(ptr, remaining, ":%s@%s", - rootpath, server); - if (len < 0) { - xlog(D_GENERAL, "%s: snprintf: %m", __func__); - goto out_false; - } - if ((size_t)len >= remaining) { - xlog(D_GENERAL, "%s: fslocdata buffer overflow", - __func__); - goto out_false; - } - remaining -= (size_t)len; - ptr += len; - last_path = rootpath; - } - - seen = true; - free(rootpath); - free(server); - } - - xlog(D_CALL, "%s: fslocdata='%s', ttl=%d", - __func__, fslocdata, *ttl); - return seen; - -out_false: - free(rootpath); - free(server); - return false; -} - -/* - * Duplicate the junction's parent's export options and graft in - * the fslocdata we constructed from the locations list. - */ -static struct exportent *create_junction_exportent(struct exportent *parent, - const char *junction, const char *fslocdata, int ttl) -{ - static struct exportent *eep; - - eep = (struct exportent *)malloc(sizeof(*eep)); - if (eep == NULL) - goto out_nomem; - - dupexportent(eep, parent); - strcpy(eep->e_path, junction); - eep->e_hostname = strdup(parent->e_hostname); - if (eep->e_hostname == NULL) { - free(eep); - goto out_nomem; - } - free(eep->e_uuid); - eep->e_uuid = NULL; - eep->e_ttl = (unsigned int)ttl; - - free(eep->e_fslocdata); - eep->e_fslocdata = strdup(fslocdata); - if (eep->e_fslocdata == NULL) { - free(eep->e_hostname); - free(eep); - goto out_nomem; - } - eep->e_fslocmethod = FSLOC_REFER; - return eep; - -out_nomem: - xlog(L_ERROR, "%s: No memory", __func__); - return NULL; -} - -/* - * Walk through the set of FS locations and build an exportent. - * Returns pointer to an exportent if "junction" refers to a junction. - */ -static struct exportent *locations_to_export(struct nfs_fsloc_set *locations, - const char *junction, struct exportent *parent) -{ - static char fslocdata[BUFSIZ]; - int ttl; - - fslocdata[0] = '\0'; - if (!locations_to_fslocdata(locations, fslocdata, sizeof(fslocdata), &ttl)) - return NULL; - return create_junction_exportent(parent, junction, fslocdata, ttl); -} - -static int -nfs_get_basic_junction(const char *junct_path, struct nfs_fsloc_set **locset) -{ - struct nfs_fsloc_set *new; - FedFsStatus retval; - - new = calloc(1, sizeof(struct nfs_fsloc_set)); - if (new == NULL) - return ENOMEM; - - retval = nfs_get_locations(junct_path, &new->ns_list); - if (retval) { - nfs_free_locations(new->ns_list); - free(new); - return EINVAL; - } - - new->ns_current = new->ns_list; - new->ns_ttl = 300; - *locset = new; - return 0; -} - -static struct exportent *lookup_junction(char *dom, const char *pathname, - struct addrinfo *ai) -{ - struct exportent *parent, *exp = NULL; - struct nfs_fsloc_set *locations; - int status; - - xmlInitParser(); - - if (nfs_is_junction(pathname)) { - xlog(D_GENERAL, "%s: %s is not a junction", - __func__, pathname); - goto out; - } - status = nfs_get_basic_junction(pathname, &locations); - if (status) { - xlog(L_WARNING, "Dangling junction %s: %s", - pathname, strerror(status)); - goto out; - } - - parent = lookup_parent_export(dom, pathname, ai); - if (parent == NULL) - goto free_locations; - - exp = locations_to_export(locations, pathname, parent); - -free_locations: - nfs_free_locations(locations->ns_list); - free(locations); - -out: - xmlCleanupParser(); - return exp; -} - -static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path, - struct addrinfo *ai) -{ - struct exportent *eep; - - eep = lookup_junction(dom, path, ai); - dump_to_cache(f, buf, buflen, dom, path, eep, 0); - if (eep == NULL) - return; - exportent_release(eep); - free(eep); -} - -#else /* !HAVE_JUNCTION_SUPPORT */ - -static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path, - struct addrinfo *UNUSED(ai)) -{ - dump_to_cache(f, buf, buflen, dom, path, NULL, 0); -} - -#endif /* !HAVE_JUNCTION_SUPPORT */ - -static void nfsd_export(int f) -{ - /* requests are: - * domain path - * determine export options and return: - * domain path expiry flags anonuid anongid fsid - */ - - char *dom, *path; - nfs_export *found = NULL; - struct addrinfo *ai = NULL; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen; - - blen = cache_read(f, buf, sizeof(buf)); - if (blen <= 0 || buf[blen-1] != '\n') return; - buf[blen-1] = 0; - - xlog(D_CALL, "nfsd_export: inbuf '%s'", buf); - - bp = buf; - dom = malloc(blen); - path = malloc(blen); - - if (!dom || !path) - goto out; - - if (qword_get(&bp, dom, blen) <= 0) - goto out; - if (qword_get(&bp, path, blen) <= 0) - goto out; - - auth_reload(); - - if (is_ipaddr_client(dom)) { - ai = lookup_client_addr(dom); - if (!ai) - goto out; - } - - found = lookup_export(dom, path, ai); - - if (found) { - char *mp = found->m_export.e_mountpoint; - - if (mp && !*mp) - mp = found->m_export.e_path; - errno = 0; - if (mp && !is_mountpoint(mp)) { - if (errno != 0 && !path_lookup_error(errno)) - goto out; - /* Exportpoint is not mounted, so tell kernel it is - * not available. - * This will cause it not to appear in the V4 Pseudo-root - * and so a "mount" of this path will fail, just like with - * V3. - * And filehandle for this mountpoint from an earlier - * mount will block in nfsd.fh lookup. - */ - xlog(L_WARNING, - "Cannot export path '%s': not a mountpoint", - path); - dump_to_cache(f, buf, sizeof(buf), dom, path, - NULL, 60); - } else if (dump_to_cache(f, buf, sizeof(buf), dom, path, - &found->m_export, 0) < 0) { - xlog(L_WARNING, - "Cannot export %s, possibly unsupported filesystem" - " or fsid= required", path); - dump_to_cache(f, buf, sizeof(buf), dom, path, NULL, 0); - } - } else - lookup_nonexport(f, buf, sizeof(buf), dom, path, ai); - - out: - xlog(D_CALL, "nfsd_export: found %p path %s", found, path ? path : NULL); - if (dom) free(dom); - if (path) free(path); - nfs_freeaddrinfo(ai); -} - - -struct { - char *cache_name; - void (*cache_handle)(int f); - int f; -} cachelist[] = { - { "auth.unix.ip", auth_unix_ip, -1 }, - { "auth.unix.gid", auth_unix_gid, -1 }, - { "nfsd.export", nfsd_export, -1 }, - { "nfsd.fh", nfsd_fh, -1 }, - { NULL, NULL, -1 } -}; - -extern int manage_gids; - -/** - * cache_open - prepare communications channels with kernel RPC caches - * - */ -void cache_open(void) -{ - int i; - - for (i=0; cachelist[i].cache_name; i++ ) { - char path[100]; - if (!manage_gids && cachelist[i].cache_handle == auth_unix_gid) - continue; - sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name); - cachelist[i].f = open(path, O_RDWR); - } -} - -/** - * cache_set_fds - prepare cache file descriptors for one iteration of the service loop - * @fdset: pointer to fd_set to prepare - */ -void cache_set_fds(fd_set *fdset) -{ - int i; - for (i=0; cachelist[i].cache_name; i++) { - if (cachelist[i].f >= 0) - FD_SET(cachelist[i].f, fdset); - } -} - -/** - * cache_process_req - process any active cache file descriptors during service loop iteration - * @fdset: pointer to fd_set to examine for activity - */ -int cache_process_req(fd_set *readfds) -{ - int i; - int cnt = 0; - for (i=0; cachelist[i].cache_name; i++) { - if (cachelist[i].f >= 0 && - FD_ISSET(cachelist[i].f, readfds)) { - cnt++; - cachelist[i].cache_handle(cachelist[i].f); - FD_CLR(cachelist[i].f, readfds); - } - } - return cnt; -} - - -/* - * Give IP->domain and domain+path->options to kernel - * % echo nfsd $IP $[now+DEFAULT_TTL] $domain > /proc/net/rpc/auth.unix.ip/channel - * % echo $domain $path $[now+DEFAULT_TTL] $options $anonuid $anongid $fsid > /proc/net/rpc/nfsd.export/channel - */ - -static int cache_export_ent(char *buf, int buflen, char *domain, struct exportent *exp, char *path) -{ - int f, err; - - f = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY); - if (f < 0) return -1; - - err = dump_to_cache(f, buf, buflen, domain, exp->e_path, exp, 0); - if (err) { - xlog(L_WARNING, - "Cannot export %s, possibly unsupported filesystem or" - " fsid= required", exp->e_path); - } - - while (err == 0 && (exp->e_flags & NFSEXP_CROSSMOUNT) && path) { - /* really an 'if', but we can break out of - * a 'while' more easily */ - /* Look along 'path' for other filesystems - * and export them with the same options - */ - struct stat stb; - size_t l = strlen(exp->e_path); - dev_t dev; - - if (strlen(path) <= l || path[l] != '/' || - strncmp(exp->e_path, path, l) != 0) - break; - if (nfsd_path_stat(exp->e_path, &stb) != 0) - break; - dev = stb.st_dev; - while(path[l] == '/') { - char c; - /* errors for submount should fail whole filesystem */ - int err2; - - l++; - while (path[l] != '/' && path[l]) - l++; - c = path[l]; - path[l] = 0; - err2 = nfsd_path_lstat(path, &stb); - path[l] = c; - if (err2 < 0) - break; - if (stb.st_dev == dev) - continue; - dev = stb.st_dev; - path[l] = 0; - dump_to_cache(f, buf, buflen, domain, path, exp, 0); - path[l] = c; - } - break; - } - - close(f); - return err; -} - -/** - * cache_export - Inform kernel of a new nfs_export - * @exp: target nfs_export - * @path: NUL-terminated C string containing export path - */ -int cache_export(nfs_export *exp, char *path) -{ - char ip[INET6_ADDRSTRLEN]; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen, f; - - f = open("/proc/net/rpc/auth.unix.ip/channel", O_WRONLY); - if (f < 0) - return -1; - - bp = buf, blen = sizeof(buf); - qword_add(&bp, &blen, "nfsd"); - qword_add(&bp, &blen, host_ntop(get_addrlist(exp->m_client, 0), ip, sizeof(ip))); - qword_adduint(&bp, &blen, time(0) + exp->m_export.e_ttl); - qword_add(&bp, &blen, exp->m_client->m_hostname); - qword_addeol(&bp, &blen); - if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf) blen = -1; - close(f); - if (blen < 0) return -1; - - return cache_export_ent(buf, sizeof(buf), exp->m_client->m_hostname, &exp->m_export, path); -} - -/** - * cache_get_filehandle - given an nfs_export, get its root filehandle - * @exp: target nfs_export - * @len: length of requested file handle - * @p: NUL-terminated C string containing export path - * - * Returns pointer to NFS file handle of root directory of export - * - * { - * echo $domain $path $length - * read filehandle <&0 - * } <> /proc/fs/nfsd/filehandle - */ -struct nfs_fh_len * -cache_get_filehandle(nfs_export *exp, int len, char *p) -{ - static struct nfs_fh_len fh; - char buf[RPC_CHAN_BUF_SIZE], *bp; - int blen, f; - - f = open("/proc/fs/nfsd/filehandle", O_RDWR); - if (f < 0) { - f = open("/proc/fs/nfs/filehandle", O_RDWR); - if (f < 0) return NULL; - } - - bp = buf, blen = sizeof(buf); - qword_add(&bp, &blen, exp->m_client->m_hostname); - qword_add(&bp, &blen, p); - qword_addint(&bp, &blen, len); - qword_addeol(&bp, &blen); - if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf) { - close(f); - return NULL; - } - bp = buf; - blen = cache_read(f, buf, sizeof(buf)); - close(f); - - if (blen <= 0 || buf[blen-1] != '\n') - return NULL; - buf[blen-1] = 0; - - memset(fh.fh_handle, 0, sizeof(fh.fh_handle)); - fh.fh_size = qword_get(&bp, (char *)fh.fh_handle, NFS3_FHSIZE); - return &fh; -} diff --git a/nfs-utils-2.5.2/utils/mountd/fsloc.c b/nfs-utils-2.5.2/utils/mountd/fsloc.c deleted file mode 100644 index 1b869b6..0000000 --- a/nfs-utils-2.5.2/utils/mountd/fsloc.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * COPYRIGHT (c) 2006 - * THE REGENTS OF THE UNIVERSITY OF MICHIGAN - * ALL RIGHTS RESERVED - * - * Permission is granted to use, copy, create derivative works - * and redistribute this software and such derivative works - * for any purpose, so long as the name of The University of - * Michigan is not used in any advertising or publicity - * pertaining to the use of distribution of this software - * without specific, written prior authorization. If the - * above copyright notice or any other identification of the - * University of Michigan is included in any copy of any - * portion of this software, then the disclaimer below must - * also be included. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION - * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY - * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF - * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING - * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE - * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING - * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN - * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES. - */ - -#include -#include -#include - -#include "fsloc.h" -#include "exportfs.h" - -/* Debugging tool: prints out @servers info to syslog */ -static void replicas_print(struct servers *sp) -{ - int i; - if (!sp) { - xlog(L_NOTICE, "NULL replicas pointer"); - return; - } - xlog(L_NOTICE, "replicas listsize=%i", sp->h_num); - for (i=0; ih_num; i++) { - xlog(L_NOTICE, " %s:%s", - sp->h_mp[i]->h_host, sp->h_mp[i]->h_path); - } -} - -#ifdef DEBUG -/* Called by setting 'Method = stub' in config file. Just returns - * some syntactically correct gibberish for testing purposes. - */ -static struct servers *method_stub(char *key) -{ - struct servers *sp; - struct mount_point *mp; - - xlog(L_NOTICE, "called method_stub\n"); - sp = malloc(sizeof(struct servers)); - if (!sp) - return NULL; - mp = calloc(1, sizeof(struct mount_point)); - if (!mp) { - free(sp); - return NULL; - } - sp->h_num = 1; - sp->h_mp[0] = mp; - mp->h_host = strdup("stub_server"); - mp->h_path = strdup("/my/test/path"); - sp->h_referral = 1; - return sp; -} -#endif /* DEBUG */ - -/* Scan @list, which is a NULL-terminated array of strings of the - * form path@host[+host], and return corresponding servers structure. - */ -static struct servers *parse_list(char **list) -{ - int i; - struct servers *res; - struct mount_point *mp; - char *cp; - - res = malloc(sizeof(struct servers)); - if (!res) - return NULL; - res->h_num = 0; - - /* parse each of the answers in sucession. */ - for (i=0; list[i] && ih_mp[i] = mp; - res->h_num++; - mp->h_path = strndup(list[i], cp - list[i]); - cp++; - mp->h_host = strdup(cp); - /* hosts are '+' separated, kernel expects ':' separated */ - while ( (cp = strchr(mp->h_host, '+')) ) - *cp = ':'; - } - return res; -} - -/* @data is a string of form path@host[+host][:path@host[+host]] - */ -static struct servers *method_list(char *data) -{ - char *copy, *ptr=data, *p; - char **list; - int i, listsize; - struct servers *rv=NULL; - bool v6esc = false; - - xlog(L_NOTICE, "method_list(%s)", data); - for (ptr--, listsize=1; ptr; ptr=strchr(ptr, ':'), listsize++) - ptr++; - list = malloc(listsize * sizeof(char *)); - copy = strdup(data); - if (copy) - xlog(L_NOTICE, "converted to %s", copy); - if (list && copy) { - ptr = copy; - for (p = ptr, i = 0; *p && i < listsize; p++) { - if (*p == '[') - v6esc = true; - else if (*p == ']') - v6esc = false; - - if (!v6esc && *p == ':') { - *p = '\0'; - if (*ptr) - list[i++] = ptr; - ptr = p + 1; - } - } - if (*ptr) - list[i++] = ptr; - list[i] = NULL; - rv = parse_list(list); - } - free(copy); - free(list); - replicas_print(rv); - return rv; -} - -/* Returns appropriately filled struct servers, or NULL if had a problem */ -struct servers *replicas_lookup(int method, char *data) -{ - struct servers *sp=NULL; - switch(method) { - case FSLOC_NONE: - break; - case FSLOC_REFER: - sp = method_list(data); - if (sp) - sp->h_referral = 1; - break; - case FSLOC_REPLICA: - sp = method_list(data); - if (sp) - sp->h_referral = 0; - break; -#ifdef DEBUG - case FSLOC_STUB: - sp = method_stub(data); - break; -#endif - default: - xlog(L_WARNING, "Unknown method = %i", method); - } - replicas_print(sp); - return sp; -} - -void release_replicas(struct servers *server) -{ - int i; - - if (!server) return; - for (i = 0; i < server->h_num; i++) { - free(server->h_mp[i]->h_host); - free(server->h_mp[i]->h_path); - free(server->h_mp[i]); - } - free(server); -} diff --git a/nfs-utils-2.5.2/utils/mountd/fsloc.h b/nfs-utils-2.5.2/utils/mountd/fsloc.h deleted file mode 100644 index 1605df4..0000000 --- a/nfs-utils-2.5.2/utils/mountd/fsloc.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * COPYRIGHT (c) 2006 - * THE REGENTS OF THE UNIVERSITY OF MICHIGAN - * ALL RIGHTS RESERVED - * - * Permission is granted to use, copy, create derivative works - * and redistribute this software and such derivative works - * for any purpose, so long as the name of The University of - * Michigan is not used in any advertising or publicity - * pertaining to the use of distribution of this software - * without specific, written prior authorization. If the - * above copyright notice or any other identification of the - * University of Michigan is included in any copy of any - * portion of this software, then the disclaimer below must - * also be included. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION - * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY - * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF - * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING - * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE - * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING - * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN - * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGES. - */ - -#ifndef FSLOC_H -#define FSLOC_H - -#define FSLOC_MAX_LIST 40 - -struct mount_point { - char *h_host; - char *h_path; -}; - -struct servers { - int h_num; - struct mount_point *h_mp[FSLOC_MAX_LIST]; - int h_referral; /* 0=replica, 1=referral */ -}; - -struct servers *replicas_lookup(int method, char *data); -void release_replicas(struct servers *server); - -#endif /* FSLOC_H */ diff --git a/nfs-utils-2.5.2/utils/mountd/mount_dispatch.c b/nfs-utils-2.5.2/utils/mountd/mount_dispatch.c deleted file mode 100644 index ba6981d..0000000 --- a/nfs-utils-2.5.2/utils/mountd/mount_dispatch.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * mount_dispatch This file contains the function dispatch table. - * - * Copyright (C) 1995 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_TCP_WRAPPER -#include "tcpwrapper.h" -#endif - -#include "mountd.h" -#include "rpcmisc.h" - -/* - * Procedures for MNTv1 - */ -static struct rpc_dentry mnt_1_dtable[] = { - dtable_ent(mount_null,1,void,void), /* NULL */ - dtable_ent(mount_mnt,1,dirpath,fhstatus), /* MNT */ - dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ - dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ - dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ - dtable_ent(mount_export,1,void,exports), /* EXPORT */ - dtable_ent(mount_exportall,1,void,exports), /* EXPORTALL */ -}; - -/* - * Procedures for MNTv2 - */ -static struct rpc_dentry mnt_2_dtable[] = { - dtable_ent(mount_null,1,void,void), /* NULL */ - dtable_ent(mount_mnt,1,dirpath,fhstatus), /* MNT */ - dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ - dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ - dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ - dtable_ent(mount_export,1,void,exports), /* EXPORT */ - dtable_ent(mount_exportall,1,void,exports), /* EXPORTALL */ - dtable_ent(mount_pathconf,2,dirpath,ppathcnf), /* PATHCONF */ -}; - -/* - * Procedures for MNTv3 - */ -static struct rpc_dentry mnt_3_dtable[] = { - dtable_ent(mount_null,1,void,void), /* NULL */ - dtable_ent(mount_mnt,3,dirpath,mountres3), /* MNT */ - dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ - dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ - dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ - dtable_ent(mount_export,1,void,exports), /* EXPORT */ -}; - -#define number_of(x) (sizeof(x)/sizeof(x[0])) - -static struct rpc_dtable dtable[] = { - { mnt_1_dtable, number_of(mnt_1_dtable) }, - { mnt_2_dtable, number_of(mnt_2_dtable) }, - { mnt_3_dtable, number_of(mnt_3_dtable) }, -}; - -/* - * The main dispatch routine. - */ -void -mount_dispatch(struct svc_req *rqstp, SVCXPRT *transp) -{ - union mountd_arguments argument; - union mountd_results result; - -#ifdef HAVE_TCP_WRAPPER - /* remote host authorization check */ - if (!check_default("mountd", nfs_getrpccaller(transp), MOUNTPROG)) { - svcerr_auth (transp, AUTH_FAILED); - return; - } -#endif - - rpc_dispatch(rqstp, transp, dtable, number_of(dtable), - &argument, &result); -} diff --git a/nfs-utils-2.5.2/utils/mountd/mountd.c b/nfs-utils-2.5.2/utils/mountd/mountd.c deleted file mode 100644 index 07bcdc5..0000000 --- a/nfs-utils-2.5.2/utils/mountd/mountd.c +++ /dev/null @@ -1,914 +0,0 @@ -/* - * utils/mountd/mountd.c - * - * Authenticate mount requests and retrieve file handle. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "xmalloc.h" -#include "misc.h" -#include "mountd.h" -#include "rpcmisc.h" -#include "pseudoflavors.h" -#include "nfsd_path.h" -#include "nfslib.h" - -extern void my_svc_run(void); - -static void usage(const char *, int exitcode); -static exports get_exportlist(void); -static struct nfs_fh_len *get_rootfh(struct svc_req *, dirpath *, nfs_export **, mountstat3 *, int v3); - -int reverse_resolve = 0; -int manage_gids; -int use_ipaddr = -1; - -struct state_paths etab; -struct state_paths rmtab; - -/* PRC: a high-availability callout program can be specified with -H - * When this is done, the program will receive callouts whenever clients - * send mount or unmount requests -- the callout is not needed for 2.6 kernel */ -char *ha_callout_prog = NULL; - -/* Number of mountd threads to start. Default is 1 and - * that's probably enough unless you need hundreds of - * clients to be able to mount at once. */ -static int num_threads = 1; -/* Arbitrary limit on number of threads */ -#define MAX_THREADS 64 - -static struct option longopts[] = -{ - { "foreground", 0, 0, 'F' }, - { "descriptors", 1, 0, 'o' }, - { "debug", 1, 0, 'd' }, - { "help", 0, 0, 'h' }, - { "nfs-version", 1, 0, 'V' }, - { "no-nfs-version", 1, 0, 'N' }, - { "version", 0, 0, 'v' }, - { "port", 1, 0, 'p' }, - { "no-tcp", 0, 0, 'n' }, - { "ha-callout", 1, 0, 'H' }, - { "state-directory-path", 1, 0, 's' }, - { "num-threads", 1, 0, 't' }, - { "reverse-lookup", 0, 0, 'r' }, - { "manage-gids", 0, 0, 'g' }, - { "no-udp", 0, 0, 'u' }, - { NULL, 0, 0, 0 } -}; - -#define NFSVERSBIT(vers) (0x1 << (vers - 1)) -#define NFSVERSBIT_ALL (NFSVERSBIT(2) | NFSVERSBIT(3) | NFSVERSBIT(4)) - -static int nfs_version = NFSVERSBIT_ALL; - -static int version2(void) -{ - return nfs_version & NFSVERSBIT(2); -} - -static int version3(void) -{ - return nfs_version & NFSVERSBIT(3); -} - -static int version23(void) -{ - return nfs_version & (NFSVERSBIT(2) | NFSVERSBIT(3)); -} - -static int version_any(void) -{ - return nfs_version & NFSVERSBIT_ALL; -} - -static void -unregister_services (void) -{ - nfs_svc_unregister(MOUNTPROG, MOUNTVERS); - nfs_svc_unregister(MOUNTPROG, MOUNTVERS_POSIX); - nfs_svc_unregister(MOUNTPROG, MOUNTVERS_NFSV3); -} - -static void -cleanup_lockfiles (void) -{ - unlink(etab.lockfn); - unlink(rmtab.lockfn); -} - -/* Wait for all worker child processes to exit and reap them */ -static void -wait_for_workers (void) -{ - int status; - pid_t pid; - - for (;;) { - - pid = waitpid(0, &status, 0); - - if (pid < 0) { - if (errno == ECHILD) - return; /* no more children */ - xlog(L_FATAL, "mountd: can't wait: %s\n", - strerror(errno)); - } - - /* Note: because we SIG_IGN'd SIGCHLD earlier, this - * does not happen on 2.6 kernels, and waitpid() blocks - * until all the children are dead then returns with - * -ECHILD. But, we don't need to do anything on the - * death of individual workers, so we don't care. */ - xlog(L_NOTICE, "mountd: reaped child %d, status %d\n", - (int)pid, status); - } -} - -/* Fork num_threads worker children and wait for them */ -static void -fork_workers(void) -{ - int i; - pid_t pid; - - xlog(L_NOTICE, "mountd: starting %d threads\n", num_threads); - - for (i = 0 ; i < num_threads ; i++) { - pid = fork(); - if (pid < 0) { - xlog(L_FATAL, "mountd: cannot fork: %s\n", - strerror(errno)); - } - if (pid == 0) { - /* worker child */ - - /* Re-enable the default action on SIGTERM et al - * so that workers die naturally when sent them. - * Only the parent unregisters with pmap and - * hence needs to do special SIGTERM handling. */ - struct sigaction sa; - sa.sa_handler = SIG_DFL; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - - /* fall into my_svc_run in caller */ - return; - } - } - - /* in parent */ - wait_for_workers(); - unregister_services(); - cleanup_lockfiles(); - free_state_path_names(&etab); - free_state_path_names(&rmtab); - xlog(L_NOTICE, "mountd: no more workers, exiting\n"); - exit(0); -} - -/* - * Signal handler. - */ -static void -killer (int sig) -{ - unregister_services(); - if (num_threads > 1) { - /* play Kronos and eat our children */ - kill(0, SIGTERM); - wait_for_workers(); - } - cleanup_lockfiles(); - free_state_path_names(&etab); - free_state_path_names(&rmtab); - xlog (L_NOTICE, "Caught signal %d, un-registering and exiting.", sig); - exit(0); -} - -static void -sig_hup (int UNUSED(sig)) -{ - /* don't exit on SIGHUP */ - xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n"); - return; -} - -bool_t -mount_null_1_svc(struct svc_req *rqstp, void *UNUSED(argp), - void *UNUSED(resp)) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received NULL request from %s", - host_ntop(sap, buf, sizeof(buf))); - - return 1; -} - -bool_t -mount_mnt_1_svc(struct svc_req *rqstp, dirpath *path, fhstatus *res) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - struct nfs_fh_len *fh; - - xlog(D_CALL, "Received MNT1(%s) request from %s", *path, - host_ntop(sap, buf, sizeof(buf))); - - fh = get_rootfh(rqstp, path, NULL, &res->fhs_status, 0); - if (fh) - memcpy(&res->fhstatus_u.fhs_fhandle, fh->fh_handle, 32); - return 1; -} - -bool_t -mount_dump_1_svc(struct svc_req *rqstp, void *UNUSED(argp), mountlist *res) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received DUMP request from %s", - host_ntop(sap, buf, sizeof(buf))); - - *res = mountlist_list(); - - return 1; -} - -bool_t -mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *UNUSED(resp)) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - nfs_export *exp; - char *p = *argp; - char rpath[MAXPATHLEN+1]; - char buf[INET6_ADDRSTRLEN]; - - if (*p == '\0') - p = "/"; - - if (nfsd_realpath(p, rpath) != NULL) { - rpath[sizeof (rpath) - 1] = '\0'; - p = rpath; - } - - xlog(D_CALL, "Received UMNT(%s) request from %s", p, - host_ntop(sap, buf, sizeof(buf))); - - exp = auth_authenticate("unmount", sap, p); - if (exp == NULL) - return 1; - - mountlist_del(host_ntop(sap, buf, sizeof(buf)), p); - return 1; -} - -bool_t -mount_umntall_1_svc(struct svc_req *rqstp, void *UNUSED(argp), - void *UNUSED(resp)) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received UMNTALL request from %s", - host_ntop(sap, buf, sizeof(buf))); - - /* Reload /etc/exports if necessary */ - auth_reload(); - - mountlist_del_all(nfs_getrpccaller(rqstp->rq_xprt)); - return 1; -} - -bool_t -mount_export_1_svc(struct svc_req *rqstp, void *UNUSED(argp), exports *resp) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received EXPORT request from %s.", - host_ntop(sap, buf, sizeof(buf))); - - *resp = get_exportlist(); - - return 1; -} - -bool_t -mount_exportall_1_svc(struct svc_req *rqstp, void *UNUSED(argp), exports *resp) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received EXPORTALL request from %s.", - host_ntop(sap, buf, sizeof(buf))); - - *resp = get_exportlist(); - - return 1; -} - -/* - * MNTv2 pathconf procedure - * - * The protocol doesn't include a status field, so Sun apparently considers - * it good practice to let anyone snoop on your system, even if it's - * pretty harmless data such as pathconf. We don't. - * - * Besides, many of the pathconf values don't make much sense on NFS volumes. - * FIFOs and tty device files represent devices on the *client*, so there's - * no point in getting the server's buffer sizes etc. - */ -bool_t -mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - struct stat stb; - nfs_export *exp; - char rpath[MAXPATHLEN+1]; - char *p = *path; - char buf[INET6_ADDRSTRLEN]; - - memset(res, 0, sizeof(*res)); - - if (*p == '\0') - p = "/"; - - /* Reload /etc/exports if necessary */ - auth_reload(); - - /* Resolve symlinks */ - if (nfsd_realpath(p, rpath) != NULL) { - rpath[sizeof (rpath) - 1] = '\0'; - p = rpath; - } - - xlog(D_CALL, "Received PATHCONF(%s) request from %s", p, - host_ntop(sap, buf, sizeof(buf))); - - /* Now authenticate the intruder... */ - exp = auth_authenticate("pathconf", sap, p); - if (exp == NULL) - return 1; - else if (nfsd_path_stat(p, &stb) < 0) { - xlog(L_WARNING, "can't stat exported dir %s: %s", - p, strerror(errno)); - return 1; - } - - res->pc_link_max = pathconf(p, _PC_LINK_MAX); - res->pc_max_canon = pathconf(p, _PC_MAX_CANON); - res->pc_max_input = pathconf(p, _PC_MAX_INPUT); - res->pc_name_max = pathconf(p, _PC_NAME_MAX); - res->pc_path_max = pathconf(p, _PC_PATH_MAX); - res->pc_pipe_buf = pathconf(p, _PC_PIPE_BUF); - res->pc_vdisable = pathconf(p, _PC_VDISABLE); - - /* Can't figure out what to do with pc_mask */ - res->pc_mask[0] = 0; - res->pc_mask[1] = 0; - - return 1; -} - -/* - * We should advertise the preferred flavours first. (See RFC 2623 - * section 2.7.) We leave that to the administrator, by advertising - * flavours in the order they were listed in /etc/exports. AUTH_NULL is - * dropped from the list to avoid backward compatibility issue with - * older Linux clients, who inspect the list in reversed order. - * - * XXX: It might be more helpful to rearrange these so that flavors - * giving more access (as determined from readonly and id-squashing - * options) come first. (If we decide to do that we should probably do - * that when reading the exports rather than here.) - */ -static void set_authflavors(struct mountres3_ok *ok, nfs_export *exp) -{ - struct sec_entry *s; - static int flavors[SECFLAVOR_COUNT]; - int i = 0; - - for (s = exp->m_export.e_secinfo; s->flav; s++) { - if (s->flav->fnum == AUTH_NULL) - continue; - flavors[i] = s->flav->fnum; - i++; - } - if (i == 0) { - /* default when there is no sec= option: */ - i = 1; - flavors[0] = AUTH_UNIX; - } - ok->auth_flavors.auth_flavors_val = flavors; - ok->auth_flavors.auth_flavors_len = i; -} - -/* - * NFSv3 MOUNT procedure - */ -bool_t -mount_mnt_3_svc(struct svc_req *rqstp, dirpath *path, mountres3 *res) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - struct mountres3_ok *ok = &res->mountres3_u.mountinfo; - char buf[INET6_ADDRSTRLEN]; - nfs_export *exp; - struct nfs_fh_len *fh; - - xlog(D_CALL, "Received MNT3(%s) request from %s", *path, - host_ntop(sap, buf, sizeof(buf))); - - fh = get_rootfh(rqstp, path, &exp, &res->fhs_status, 1); - if (!fh) - return 1; - - ok->fhandle.fhandle3_len = fh->fh_size; - ok->fhandle.fhandle3_val = (char *)fh->fh_handle; - set_authflavors(ok, exp); - return 1; -} - -static struct nfs_fh_len * -get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, - mountstat3 *error, int v3) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - struct stat stb, estb; - nfs_export *exp; - struct nfs_fh_len *fh; - char rpath[MAXPATHLEN+1]; - char *p = *path; - char buf[INET6_ADDRSTRLEN]; - - if (*p == '\0') - p = "/"; - - /* Reload /var/lib/nfs/etab if necessary */ - auth_reload(); - - /* Resolve symlinks */ - if (nfsd_realpath(p, rpath) != NULL) { - rpath[sizeof (rpath) - 1] = '\0'; - p = rpath; - } - - /* Now authenticate the intruder... */ - exp = auth_authenticate("mount", sap, p); - if (exp == NULL) { - *error = MNT3ERR_ACCES; - return NULL; - } - if (nfsd_path_stat(p, &stb) < 0) { - xlog(L_WARNING, "can't stat exported dir %s: %s", - p, strerror(errno)); - if (errno == ENOENT) - *error = MNT3ERR_NOENT; - else - *error = MNT3ERR_ACCES; - return NULL; - } - if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) { - xlog(L_WARNING, "%s is not a directory or regular file", p); - *error = MNT3ERR_NOTDIR; - return NULL; - } - if (nfsd_path_stat(exp->m_export.e_path, &estb) < 0) { - xlog(L_WARNING, "can't stat export point %s: %s", - p, strerror(errno)); - *error = MNT3ERR_NOENT; - return NULL; - } - if (estb.st_dev != stb.st_dev - && !(exp->m_export.e_flags & NFSEXP_CROSSMOUNT)) { - xlog(L_WARNING, "request to export directory %s below nearest filesystem %s", - p, exp->m_export.e_path); - *error = MNT3ERR_ACCES; - return NULL; - } - if (exp->m_export.e_mountpoint && - !check_is_mountpoint(exp->m_export.e_mountpoint[0]? - exp->m_export.e_mountpoint: - exp->m_export.e_path, - nfsd_path_lstat)) { - xlog(L_WARNING, "request to export an unmounted filesystem: %s", - p); - *error = MNT3ERR_NOENT; - return NULL; - } - - /* This will be a static private nfs_export with just one - * address. We feed it to kernel then extract the filehandle, - */ - - if (cache_export(exp, p)) { - *error = MNT3ERR_ACCES; - return NULL; - } - fh = cache_get_filehandle(exp, v3?64:32, p); - if (fh == NULL) { - *error = MNT3ERR_ACCES; - return NULL; - } - *error = MNT_OK; - mountlist_add(host_ntop(sap, buf, sizeof(buf)), p); - if (expret) - *expret = exp; - return fh; -} - -static void remove_all_clients(exportnode *e) -{ - struct groupnode *g, *ng; - - for (g = e->ex_groups; g; g = ng) { - ng = g->gr_next; - xfree(g->gr_name); - xfree(g); - } - e->ex_groups = NULL; -} - -static void free_exportlist(exports *elist) -{ - struct exportnode *e, *ne; - - for (e = *elist; e != NULL; e = ne) { - ne = e->ex_next; - remove_all_clients(e); - xfree(e->ex_dir); - xfree(e); - } - *elist = NULL; -} - -static void prune_clients(nfs_export *exp, struct exportnode *e) -{ - struct addrinfo *ai = NULL; - struct groupnode *c, **cp; - - cp = &e->ex_groups; - while ((c = *cp) != NULL) { - if (client_gettype(c->gr_name) == MCL_FQDN - && (ai = host_addrinfo(c->gr_name))) { - if (client_check(exp->m_client, ai)) { - *cp = c->gr_next; - xfree(c->gr_name); - xfree(c); - nfs_freeaddrinfo(ai); - continue; - } - nfs_freeaddrinfo(ai); - } - cp = &(c->gr_next); - } -} - -static exportnode *lookup_or_create_elist_entry(exports *elist, nfs_export *exp) -{ - exportnode *e; - - for (e = *elist; e != NULL; e = e->ex_next) { - if (!strcmp(exp->m_export.e_path, e->ex_dir)) - return e; - } - e = xmalloc(sizeof(*e)); - e->ex_next = *elist; - e->ex_groups = NULL; - e->ex_dir = xstrdup(exp->m_export.e_path); - *elist = e; - return e; -} - -static void insert_group(struct exportnode *e, char *newname) -{ - struct groupnode *g; - - for (g = e->ex_groups; g; g = g->gr_next) - if (!strcmp(g->gr_name, newname)) - return; - - g = xmalloc(sizeof(*g)); - g->gr_name = xstrdup(newname); - g->gr_next = e->ex_groups; - e->ex_groups = g; -} - -static exports -get_exportlist(void) -{ - static exports elist = NULL; - struct exportnode *e; - nfs_export *exp; - int i; - static unsigned int ecounter; - unsigned int acounter; - - acounter = auth_reload(); - if (elist && acounter == ecounter) - return elist; - - ecounter = acounter; - - free_exportlist(&elist); - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - /* Don't show pseudo exports */ - if (exp->m_export.e_flags & NFSEXP_V4ROOT) - continue; - e = lookup_or_create_elist_entry(&elist, exp); - - /* exports to "*" absorb any others */ - if (i == MCL_ANONYMOUS && e->ex_groups) { - remove_all_clients(e); - continue; - } - /* non-FQDN's absorb FQDN's they contain: */ - if (i != MCL_FQDN && e->ex_groups) - prune_clients(exp, e); - - if (exp->m_export.e_hostname[0] != '\0') - insert_group(e, exp->m_export.e_hostname); - } - } - - return elist; -} - -int -main(int argc, char **argv) -{ - char *progname; - char *s; - unsigned int listeners = 0; - int foreground = 0; - int port = 0; - int descriptors = 0; - int c; - int vers; - struct sigaction sa; - struct rlimit rlim; - - /* Set the basename */ - if ((progname = strrchr(argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; - - /* Initialize logging. */ - xlog_open(progname); - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("mountd"); - manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids); - descriptors = conf_get_num("mountd", "descriptors", descriptors); - port = conf_get_num("mountd", "port", port); - num_threads = conf_get_num("mountd", "threads", num_threads); - reverse_resolve = conf_get_bool("mountd", "reverse-lookup", reverse_resolve); - ha_callout_prog = conf_get_str("mountd", "ha-callout"); - - s = conf_get_str("mountd", "state-directory-path"); - if (s && !state_setup_basedir(argv[0], s)) - exit(1); - - /* NOTE: following uses "nfsd" section of nfs.conf !!!! */ - if (conf_get_bool("nfsd", "udp", NFSCTL_UDPISSET(_rpcprotobits))) - NFSCTL_UDPSET(_rpcprotobits); - else - NFSCTL_UDPUNSET(_rpcprotobits); - if (conf_get_bool("nfsd", "tcp", NFSCTL_TCPISSET(_rpcprotobits))) - NFSCTL_TCPSET(_rpcprotobits); - else - NFSCTL_TCPUNSET(_rpcprotobits); - for (vers = 2; vers <= 4; vers++) { - char tag[20]; - sprintf(tag, "vers%d", vers); - if (conf_get_bool("nfsd", tag, NFSCTL_VERISSET(nfs_version, vers))) - NFSCTL_VERSET(nfs_version, vers); - else - NFSCTL_VERUNSET(nfs_version, vers); - } - - - /* Parse the command line options and arguments. */ - opterr = 0; - while ((c = getopt_long(argc, argv, "o:nFd:p:P:hH:N:V:vurs:t:g", longopts, NULL)) != EOF) - switch (c) { - case 'g': - manage_gids = 1; - break; - case 'o': - descriptors = atoi(optarg); - if (descriptors <= 0) { - fprintf(stderr, "%s: bad descriptors: %s\n", - progname, optarg); - usage(progname, 1); - } - break; - case 'F': - foreground = 1; - break; - case 'd': - xlog_sconfig(optarg, 1); - break; - case 'H': /* PRC: specify a high-availability callout program */ - ha_callout_prog = optarg; - break; - case 'h': - usage(progname, 0); - break; - case 'P': /* XXX for nfs-server compatibility */ - case 'p': - port = atoi(optarg); - if (port <= 0 || port > 65535) { - fprintf(stderr, "%s: bad port number: %s\n", - progname, optarg); - usage(progname, 1); - } - break; - case 'N': - vers = atoi(optarg); - if (vers < 2 || vers > 4) { - fprintf(stderr, "%s: bad version number: %s\n", - argv[0], optarg); - usage(argv[0], 1); - } - nfs_version &= ~NFSVERSBIT(vers); - break; - case 'n': - NFSCTL_TCPUNSET(_rpcprotobits); - break; - case 'r': - reverse_resolve = 1; - break; - case 's': - if (!state_setup_basedir(argv[0], optarg)) - exit(1); - break; - case 't': - num_threads = atoi (optarg); - break; - case 'V': - vers = atoi(optarg); - if (vers < 2 || vers > 4) { - fprintf(stderr, "%s: bad version number: %s\n", - argv[0], optarg); - usage(argv[0], 1); - } - nfs_version |= NFSVERSBIT(vers); - break; - case 'v': - printf("%s version " VERSION "\n", progname); - exit(0); - case 'u': - NFSCTL_UDPUNSET(_rpcprotobits); - break; - case 0: - break; - case '?': - default: - usage(progname, 1); - } - - /* No more arguments allowed. */ - if (optind != argc || !version_any()) { - fprintf(stderr, "%s: No protocol versions specified!\n", progname); - usage(progname, 1); - } - if (!setup_state_path_names(progname, ETAB, ETABTMP, ETABLCK, &etab)) - return 1; - if (!setup_state_path_names(progname, RMTAB, RMTABTMP, RMTABLCK, &rmtab)) - return 1; - - if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) - fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n", - progname, strerror(errno)); - else { - /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */ - if ((descriptors == 0 && rlim.rlim_cur > FD_SETSIZE) || - descriptors > FD_SETSIZE) - descriptors = FD_SETSIZE; - if (descriptors) { - rlim.rlim_cur = descriptors; - if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) { - fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n", - progname, strerror(errno)); - exit(1); - } - } - } - if (!foreground) xlog_stderr(0); - - sa.sa_handler = SIG_IGN; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); - /* WARNING: the following works on Linux and SysV, but not BSD! */ - sigaction(SIGCHLD, &sa, NULL); - - unregister_services(); - if (version2()) { - listeners += nfs_svc_create("mountd", MOUNTPROG, - MOUNTVERS, mount_dispatch, port); - listeners += nfs_svc_create("mountd", MOUNTPROG, - MOUNTVERS_POSIX, mount_dispatch, port); - } - if (version3()) - listeners += nfs_svc_create("mountd", MOUNTPROG, - MOUNTVERS_NFSV3, mount_dispatch, port); - if (version23() && listeners == 0) - xlog(L_WARNING, "mountd: No V2 or V3 listeners created!"); - - sa.sa_handler = killer; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sa.sa_handler = sig_hup; - sigaction(SIGHUP, &sa, NULL); - - if (!foreground) { - /* We first fork off a child. */ - if ((c = fork()) > 0) - exit(0); - if (c < 0) { - xlog(L_FATAL, "mountd: cannot fork: %s\n", - strerror(errno)); - } - /* Now we remove ourselves from the foreground. - Redirect stdin/stdout/stderr first. */ - { - int fd = open("/dev/null", O_RDWR); - (void) dup2(fd, 0); - (void) dup2(fd, 1); - (void) dup2(fd, 2); - if (fd > 2) (void) close(fd); - } - setsid(); - } - - /* silently bounds check num_threads */ - if (foreground) - num_threads = 1; - else if (num_threads < 1) - num_threads = 1; - else if (num_threads > MAX_THREADS) - num_threads = MAX_THREADS; - - if (num_threads > 1) - fork_workers(); - - nfsd_path_init(); - /* Open files now to avoid sharing descriptors among forked processes */ - cache_open(); - - xlog(L_NOTICE, "Version " VERSION " starting"); - my_svc_run(); - - xlog(L_ERROR, "RPC service loop terminated unexpectedly. Exiting...\n"); - unregister_services(); - free_state_path_names(&etab); - free_state_path_names(&rmtab); - exit(1); -} - -static void -usage(const char *prog, int n) -{ - fprintf(stderr, -"Usage: %s [-F|--foreground] [-h|--help] [-v|--version] [-d kind|--debug kind]\n" -" [-o num|--descriptors num]\n" -" [-p|--port port] [-V version|--nfs-version version]\n" -" [-N version|--no-nfs-version version] [-n|--no-tcp]\n" -" [-H prog |--ha-callout prog] [-r |--reverse-lookup]\n" -" [-s|--state-directory-path path] [-g|--manage-gids]\n" -" [-t num|--num-threads=num] [-u|--no-udp]\n", prog); - exit(n); -} diff --git a/nfs-utils-2.5.2/utils/mountd/mountd.h b/nfs-utils-2.5.2/utils/mountd/mountd.h deleted file mode 100644 index f058f01..0000000 --- a/nfs-utils-2.5.2/utils/mountd/mountd.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * utils/mountd/mountd.h - * - * Declarations for mountd. - * - * Copyright (C) 1996, Olaf Kirch - */ - -#ifndef MOUNTD_H -#define MOUNTD_H - -#include -#include -#include "nfslib.h" -#include "exportfs.h" -#include "mount.h" - -union mountd_arguments { - dirpath dirpath; -}; - -union mountd_results { - fhstatus fstatus; - mountlist mountlist; - exports exports; -}; - -/* - * Global Function prototypes. - */ -bool_t mount_null_1_svc(struct svc_req *, void *, void *); -bool_t mount_mnt_1_svc(struct svc_req *, dirpath *, fhstatus *); -bool_t mount_dump_1_svc(struct svc_req *, void *, mountlist *); -bool_t mount_umnt_1_svc(struct svc_req *, dirpath *, void *); -bool_t mount_umntall_1_svc(struct svc_req *, void *, void *); -bool_t mount_export_1_svc(struct svc_req *, void *, exports *); -bool_t mount_exportall_1_svc(struct svc_req *, void *, exports *); -bool_t mount_pathconf_2_svc(struct svc_req *, dirpath *, ppathcnf *); -bool_t mount_mnt_3_svc(struct svc_req *, dirpath *, mountres3 *); - -void mount_dispatch(struct svc_req *, SVCXPRT *); -void auth_init(void); -unsigned int auth_reload(void); -nfs_export * auth_authenticate(const char *what, - const struct sockaddr *caller, - const char *path); -void auth_export(nfs_export *exp); - -void mountlist_add(char *host, const char *path); -void mountlist_del(char *host, const char *path); -void mountlist_del_all(const struct sockaddr *sap); -mountlist mountlist_list(void); - -void cache_open(void); -struct nfs_fh_len * - cache_get_filehandle(nfs_export *exp, int len, char *p); -int cache_export(nfs_export *exp, char *path); - -bool ipaddr_client_matches(nfs_export *exp, struct addrinfo *ai); -bool namelist_client_matches(nfs_export *exp, char *dom); -bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai); - -static inline bool is_ipaddr_client(char *dom) -{ - return dom[0] == '$'; -} - -#endif /* MOUNTD_H */ diff --git a/nfs-utils-2.5.2/utils/mountd/mountd.man b/nfs-utils-2.5.2/utils/mountd/mountd.man deleted file mode 100644 index 9978afc..0000000 --- a/nfs-utils-2.5.2/utils/mountd/mountd.man +++ /dev/null @@ -1,299 +0,0 @@ -.\"@(#)rpc.mountd.8" -.\" -.\" Copyright (C) 1999 Olaf Kirch -.\" Modified by Paul Clements, 2004. -.\" -.TH rpc.mountd 8 "31 Dec 2009" -.SH NAME -rpc.mountd \- NFS mount daemon -.SH SYNOPSIS -.BI "/usr/sbin/rpc.mountd [" options "]" -.SH DESCRIPTION -The -.B rpc.mountd -daemon implements the server side of the NFS MOUNT protocol, -an NFS side protocol used by NFS version 2 [RFC1094] and NFS version 3 [RFC1813]. -.PP -An NFS server maintains a table of local physical file systems -that are accessible to NFS clients. -Each file system in this table is referred to as an -.IR "exported file system" , -or -.IR export , -for short. -.PP -Each file system in the export table has an access control list. -.B rpc.mountd -uses these access control lists to determine -whether an NFS client is permitted to access a given file system. -For details on how to manage your NFS server's export table, see the -.BR exports (5) -and -.BR exportfs (8) -man pages. -.SS Mounting exported NFS File Systems -The NFS MOUNT protocol has several procedures. -The most important of these are -MNT (mount an export) and -UMNT (unmount an export). -.PP -A MNT request has two arguments: an explicit argument that -contains the pathname of the root directory of the export to be mounted, -and an implicit argument that is the sender's IP address. -.PP -When receiving a MNT request from an NFS client, -.B rpc.mountd -checks both the pathname and the sender's IP address against its export table. -If the sender is permitted to access the requested export, -.B rpc.mountd -returns an NFS file handle for the export's root directory to the client. -The client can then use the root file handle and NFS LOOKUP requests -to navigate the directory structure of the export. -.SS The rmtab File -The -.B rpc.mountd -daemon registers every successful MNT request by adding an entry to the -.I /var/lib/nfs/rmtab -file. -When receivng a UMNT request from an NFS client, -.B rpc.mountd -simply removes the matching entry from -.IR /var/lib/nfs/rmtab , -as long as the access control list for that export allows that sender -to access the export. -.PP -Clients can discover the list of file systems an NFS server is -currently exporting, or the list of other clients that have mounted -its exports, by using the -.BR showmount (8) -command. -.BR showmount (8) -uses other procedures in the NFS MOUNT protocol to report information -about the server's exported file systems. -.PP -Note, however, that there is little to guarantee that the contents of -.I /var/lib/nfs/rmtab -are accurate. -A client may continue accessing an export even after invoking UMNT. -If the client reboots without sending a UMNT request, stale entries -remain for that client in -.IR /var/lib/nfs/rmtab . -.SH OPTIONS -.TP -.B \-d kind " or " \-\-debug kind -Turn on debugging. Valid kinds are: all, auth, call, general and parse. -.TP -.B \-F " or " \-\-foreground -Run in foreground (do not daemonize) -.TP -.B \-h " or " \-\-help -Display usage message. -.TP -.B \-o num " or " \-\-descriptors num -Set the limit of the number of open file descriptors to num. The -default is to leave the limit unchanged. -.TP -.B \-N mountd-version " or " \-\-no-nfs-version mountd-version -This option can be used to request that -.B rpc.mountd -do not offer certain versions of NFS. The current version of -.B rpc.mountd -can support both NFS version 2, 3 and 4. If the -either one of these version should not be offered, -.B rpc.mountd -must be invoked with the option -.B "\-\-no-nfs-version " . -.TP -.B \-n " or " \-\-no-tcp -Don't advertise TCP for mount. -.TP -.B \-p num " or " \-P num " or " \-\-port num -Specifies the port number used for RPC listener sockets. -If this option is not specified, -.B rpc.mountd -will try to consult -.IR /etc/services , -if gets port succeed, set the same port for all listener socket, -otherwise chooses a random ephemeral port for each listener socket. -.IP -This option can be used to fix the port value of -.BR rpc.mountd 's -listeners when NFS MOUNT requests must traverse a firewall -between clients and servers. -.TP -.B \-H " prog or " \-\-ha-callout prog -Specify a high availability callout program. -This program receives callouts for all MOUNT and UNMOUNT requests. -This allows -.B rpc.mountd -to be used in a High Availability NFS (HA-NFS) environment. -.IP -The callout program is run with 4 arguments. -The first is -.B mount -or -.B unmount -depending on the reason for the callout. -The second will be the name of the client performing the mount. -The third will be the path that the client is mounting. -The last is the number of concurrent mounts that we believe the client -has of that path. -.IP -This callout is not needed with 2.6 and later kernels. -Instead, mount the nfsd filesystem on -.IR /proc/fs/nfsd . -.TP -.BI "\-s," "" " \-\-state\-directory\-path " directory -Specify a directory in which to place state information (etab and rmtab). -If this option is not specified the default of -.I /var/lib/nfs -is used. -.TP -.BI "\-r," "" " \-\-reverse\-lookup" -.B rpc.mountd -tracks IP addresses in the -.I rmtab -file. When a DUMP request is made (by -someone running -.BR "showmount -a" , -for instance), it returns IP addresses instead -of hostnames by default. This option causes -.B rpc.mountd -to perform a reverse lookup on each IP address and return that hostname instead. -Enabling this can have a substantial negative effect on performance -in some situations. -.TP -.BR "\-t N" " or " "\-\-num\-threads=N " or " \-\-num\-threads N " -This option specifies the number of worker threads that rpc.mountd -spawns. The default is 1 thread, which is probably enough. More -threads are usually only needed for NFS servers which need to handle -mount storms of hundreds of NFS mounts in a few seconds, or when -your DNS server is slow or unreliable. -.TP -.B \-u " or " \-\-no-udp -Don't advertise UDP for mounting -.TP -.B \-V version " or " \-\-nfs-version version -This option can be used to request that -.B rpc.mountd -offer certain versions of NFS. The current version of -.B rpc.mountd -can support both NFS version 2 and the newer version 3. -.TP -.B \-v " or " \-\-version -Print the version of -.B rpc.mountd -and exit. -.TP -.B \-g " or " \-\-manage-gids -Accept requests from the kernel to map user id numbers into lists of -group id numbers for use in access control. An NFS request will -normally (except when using Kerberos or other cryptographic -authentication) contains a user-id and a list of group-ids. Due to a -limitation in the NFS protocol, at most 16 groups ids can be listed. -If you use the -.B \-g -flag, then the list of group ids received from the client will be -replaced by a list of group ids determined by an appropriate lookup on -the server. Note that the 'primary' group id is not affected so a -.B newgroup -command on the client will still be effective. This function requires -a Linux Kernel with version at least 2.6.21. - -.SH CONFIGURATION FILE -Many of the options that can be set on the command line can also be -controlled through values set in the -.B [mountd] -or, in some cases, the -.B [nfsd] -sections of the -.I /etc/nfs.conf -configuration file. -Values recognized in the -.B [mountd] -section include -.BR manage-gids , -.BR descriptors , -.BR port , -.BR threads , -.BR reverse-lookup ", and" -.BR state-directory-path , -.B ha-callout -which each have the same effect as the option with the same name. - -The values recognized in the -.B [nfsd] -section include -.BR TCP , -.BR UDP , -.BR vers2 , -.BR vers3 ", and" -.B vers4 -which each have same same meaning as given by -.BR rpc.nfsd (8). - -.SH TCP_WRAPPERS SUPPORT -You can protect your -.B rpc.mountd -listeners using the -.B tcp_wrapper -library or -.BR iptables (8). -.PP -Note that the -.B tcp_wrapper -library supports only IPv4 networking. -.PP -Add the hostnames of NFS peers that are allowed to access -.B rpc.mountd -to -.IR /etc/hosts.allow . -Use the daemon name -.B mountd -even if the -.B rpc.mountd -binary has a different name. -.PP -Hostnames used in either access file will be ignored when -they can not be resolved into IP addresses. -For further information see the -.BR tcpd (8) -and -.BR hosts_access (5) -man pages. -.SS IPv6 and TI-RPC support -TI-RPC is a pre-requisite for supporting NFS on IPv6. -If TI-RPC support is built into -.BR rpc.mountd , -it attempts to start listeners on network transports marked 'visible' in -.IR /etc/netconfig . -As long as at least one network transport listener starts successfully, -.B rpc.mountd -will operate. -.SH FILES -.TP 2.5i -.I /etc/exports -input file for -.BR exportfs , -listing exports, export options, and access control lists -.TP 2.5i -.I /var/lib/nfs/rmtab -table of clients accessing server's exports -.SH SEE ALSO -.BR exportfs (8), -.BR exports (5), -.BR showmount (8), -.BR rpc.nfsd (8), -.BR rpc.rquotad (8), -.BR nfs (5), -.BR nfs.conf (5), -.BR tcpd (8), -.BR hosts_access (5), -.BR iptables (8), -.BR netconfig (5) -.sp -RFC 1094 - "NFS: Network File System Protocol Specification" -.br -RFC 1813 - "NFS Version 3 Protocol Specification" -.SH AUTHOR -Olaf Kirch, H. J. Lu, G. Allan Morris III, and a host of others. diff --git a/nfs-utils-2.5.2/utils/mountd/rmtab.c b/nfs-utils-2.5.2/utils/mountd/rmtab.c deleted file mode 100644 index c896243..0000000 --- a/nfs-utils-2.5.2/utils/mountd/rmtab.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * utils/mountd/rmtab.c - * - * Manage the rmtab file for mountd. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "misc.h" -#include "exportfs.h" -#include "xio.h" -#include "mountd.h" -#include "ha-callout.h" - -#include /* PATH_MAX */ -#include - -extern int reverse_resolve; - -extern struct state_paths rmtab; - -/* If new path is a link do not destroy it but place the - * file where the link points. - */ - -static int -slink_safe_rename(const char * oldpath, const char * newpath) -{ - int r; - struct stat s; - char slink_path[PATH_MAX]; - const char *real_newpath = newpath; - - if ((lstat(newpath, &s) == 0) && S_ISLNK(s.st_mode)) { - /* New path is a symbolic link, do not destroy but follow */ - if ((r = readlink(newpath, slink_path, PATH_MAX - 1)) == -1) - return -1; - slink_path[r] = '\0'; - real_newpath = slink_path; - } - - return rename(oldpath, real_newpath); -} - -void -mountlist_add(char *host, const char *path) -{ - struct rmtabent xe; - struct rmtabent *rep; - int lockid; - long pos; - - if ((lockid = xflock(rmtab.lockfn, "a")) < 0) - return; - setrmtabent("r+"); - while ((rep = getrmtabent(1, &pos)) != NULL) { - if (strcmp (rep->r_client, - host) == 0 - && strcmp(rep->r_path, path) == 0) { - rep->r_count++; - /* PRC: do the HA callout: */ - ha_callout("mount", rep->r_client, rep->r_path, rep->r_count); - putrmtabent(rep, &pos); - endrmtabent(); - xfunlock(lockid); - return; - } - } - endrmtabent(); - strncpy(xe.r_client, host, - sizeof (xe.r_client) - 1); - xe.r_client [sizeof (xe.r_client) - 1] = '\0'; - strncpy(xe.r_path, path, sizeof (xe.r_path) - 1); - xe.r_path [sizeof (xe.r_path) - 1] = '\0'; - xe.r_count = 1; - if (setrmtabent("a")) { - /* PRC: do the HA callout: */ - ha_callout("mount", xe.r_client, xe.r_path, xe.r_count); - putrmtabent(&xe, NULL); - endrmtabent(); - } - xfunlock(lockid); -} - -void -mountlist_del(char *hname, const char *path) -{ - struct rmtabent *rep; - FILE *fp; - int lockid; - int match; - - if ((lockid = xflock(rmtab.lockfn, "w")) < 0) - return; - if (!setrmtabent("r")) { - xfunlock(lockid); - return; - } - if (!(fp = fsetrmtabent(rmtab.tmpfn, "w"))) { - endrmtabent(); - xfunlock(lockid); - return; - } - while ((rep = getrmtabent(1, NULL)) != NULL) { - match = !strcmp (rep->r_client, hname) - && !strcmp(rep->r_path, path); - if (match) { - rep->r_count--; - /* PRC: do the HA callout: */ - ha_callout("unmount", rep->r_client, rep->r_path, rep->r_count); - } - if (!match || rep->r_count) - fputrmtabent(fp, rep, NULL); - } - if (slink_safe_rename(rmtab.tmpfn, rmtab.statefn) < 0) { - xlog(L_ERROR, "couldn't rename %s to %s", - rmtab.tmpfn, rmtab.statefn); - } - endrmtabent(); /* close & unlink */ - fendrmtabent(fp); - xfunlock(lockid); -} - -void -mountlist_del_all(const struct sockaddr *sap) -{ - char *hostname; - struct rmtabent *rep; - FILE *fp; - int lockid; - - if ((lockid = xflock(rmtab.lockfn, "w")) < 0) - return; - hostname = host_canonname(sap); - if (hostname == NULL) { - char buf[INET6_ADDRSTRLEN]; - xlog(L_ERROR, "can't get hostname of %s", - host_ntop(sap, buf, sizeof(buf))); - goto out_unlock; - } - - if (!setrmtabent("r")) - goto out_free; - - if (!(fp = fsetrmtabent(rmtab.tmpfn, "w"))) - goto out_close; - - while ((rep = getrmtabent(1, NULL)) != NULL) { - if (strcmp(rep->r_client, hostname) == 0 && - auth_authenticate("umountall", sap, rep->r_path) != NULL) - continue; - fputrmtabent(fp, rep, NULL); - } - if (slink_safe_rename(rmtab.tmpfn, rmtab.statefn) < 0) { - xlog(L_ERROR, "couldn't rename %s to %s", - rmtab.tmpfn, rmtab.statefn); - } - fendrmtabent(fp); -out_close: - endrmtabent(); /* close & unlink */ -out_free: - free(hostname); -out_unlock: - xfunlock(lockid); -} - -static void -mountlist_freeall(mountlist list) -{ - while (list != NULL) { - mountlist m = list; - list = m->ml_next; - free(m->ml_hostname); - free(m->ml_directory); - free(m); - } -} - -mountlist -mountlist_list(void) -{ - static mountlist mlist = NULL; - static time_t last_mtime = 0; - mountlist m; - struct rmtabent *rep; - struct stat stb; - int lockid; - - if ((lockid = xflock(rmtab.lockfn, "r")) < 0) - return NULL; - if (stat(rmtab.statefn, &stb) < 0) { - xlog(L_ERROR, "can't stat %s: %s", - rmtab.statefn, strerror(errno)); - xfunlock(lockid); - return NULL; - } - if (stb.st_mtime != last_mtime) { - mountlist_freeall(mlist); - mlist = NULL; - last_mtime = stb.st_mtime; - - setrmtabent("r"); - while ((rep = getrmtabent(1, NULL)) != NULL) { - m = calloc(1, sizeof(*m)); - if (m == NULL) { - mountlist_freeall(mlist); - mlist = NULL; - xlog(L_ERROR, "%s: memory allocation failed", - __func__); - break; - } - - if (reverse_resolve) { - struct addrinfo *ai; - ai = host_pton(rep->r_client); - if (ai != NULL) { - m->ml_hostname = host_canonname(ai->ai_addr); - nfs_freeaddrinfo(ai); - } - } - if (m->ml_hostname == NULL) - m->ml_hostname = strdup(rep->r_client); - - m->ml_directory = strdup(rep->r_path); - - if (m->ml_hostname == NULL || m->ml_directory == NULL) { - mountlist_freeall(mlist); - mlist = NULL; - xlog(L_ERROR, "%s: memory allocation failed", - __func__); - break; - } - - m->ml_next = mlist; - mlist = m; - } - endrmtabent(); - } - xfunlock(lockid); - - return mlist; -} diff --git a/nfs-utils-2.5.2/utils/mountd/svc_run.c b/nfs-utils-2.5.2/utils/mountd/svc_run.c deleted file mode 100644 index 41b96d7..0000000 --- a/nfs-utils-2.5.2/utils/mountd/svc_run.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 1984 Sun Microsystems, Inc. - * Based on svc_run.c from statd which claimed: - * Modified by Jeffrey A. Uphoff, 1995, 1997-1999. - * Modified by Olaf Kirch, 1996. - * - */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Allow svc_run to listen to other file descriptors as well - */ - -/* - * This is the RPC server side idle loop. - * Wait for input, call server program. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include "xlog.h" -#include -#include - -#ifdef HAVE_LIBTIRPC -#include -#endif - -void my_svc_run(void); -void cache_set_fds(fd_set *fdset); -int cache_process_req(fd_set *readfds); - -#if defined(__GLIBC__) && LONG_MAX != INT_MAX -/* bug in glibc 2.3.6 and earlier, we need - * our own svc_getreqset - */ -static void -my_svc_getreqset (fd_set *readfds) -{ - fd_mask mask; - fd_mask *maskp; - int setsize; - int sock; - int bit; - - setsize = _rpc_dtablesize (); - if (setsize > FD_SETSIZE) - setsize = FD_SETSIZE; - maskp = readfds->fds_bits; - for (sock = 0; sock < setsize; sock += NFDBITS) - for (mask = *maskp++; - (bit = ffsl (mask)); - mask ^= (1L << (bit - 1))) - svc_getreq_common (sock + bit - 1); -} -#define svc_getreqset my_svc_getreqset - -#endif - -/* - * The heart of the server. A crib from libc for the most part... - */ -void -my_svc_run(void) -{ - fd_set readfds; - int selret; - - for (;;) { - - readfds = svc_fdset; - cache_set_fds(&readfds); - - selret = select(FD_SETSIZE, &readfds, - (void *) 0, (void *) 0, (struct timeval *) 0); - - - switch (selret) { - case -1: - if (errno == EINTR || errno == ECONNREFUSED - || errno == ENETUNREACH || errno == EHOSTUNREACH) - continue; - xlog(L_ERROR, "my_svc_run() - select: %m"); - return; - - default: - selret -= cache_process_req(&readfds); - if (selret) - svc_getreqset(&readfds); - } - } -} diff --git a/nfs-utils-2.5.2/utils/mountd/v4root.c b/nfs-utils-2.5.2/utils/mountd/v4root.c deleted file mode 100644 index dd9828e..0000000 --- a/nfs-utils-2.5.2/utils/mountd/v4root.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat - * - * support/export/v4root.c - * - * Routines used to support NFSv4 pseudo roots - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "xlog.h" -#include "exportfs.h" -#include "nfslib.h" -#include "misc.h" -#include "v4root.h" -#include "pseudoflavors.h" - -static nfs_export pseudo_root = { - .m_next = NULL, - .m_client = NULL, - .m_export = { - .e_hostname = "*", - .e_path = "/", - .e_flags = NFSEXP_READONLY | NFSEXP_ROOTSQUASH - | NFSEXP_NOSUBTREECHECK | NFSEXP_FSID - | NFSEXP_V4ROOT, - .e_anonuid = 65534, - .e_anongid = 65534, - .e_squids = NULL, - .e_nsquids = 0, - .e_sqgids = NULL, - .e_nsqgids = 0, - .e_fsid = 0, - .e_mountpoint = NULL, - .e_ttl = DEFAULT_TTL, - }, - .m_exported = 0, - .m_xtabent = 1, - .m_mayexport = 1, - .m_changed = 0, - .m_warned = 0, -}; - -static void -set_pseudofs_security(struct exportent *pseudo, int flags) -{ - struct flav_info *flav; - int i; - - if (flags & NFSEXP_INSECURE_PORT) - pseudo->e_flags |= NFSEXP_INSECURE_PORT; - if ((flags & NFSEXP_ROOTSQUASH) == 0) - pseudo->e_flags &= ~NFSEXP_ROOTSQUASH; - for (flav = flav_map; flav < flav_map + flav_map_size; flav++) { - struct sec_entry *new; - - if (!flav->fnum) - continue; - - i = secinfo_addflavor(flav, pseudo); - new = &pseudo->e_secinfo[i]; - - if (flags & NFSEXP_INSECURE_PORT) - new->flags |= NFSEXP_INSECURE_PORT; - } -} - -/* - * Create a pseudo export - */ -static struct exportent * -v4root_create(char *path, nfs_export *export) -{ - nfs_export *exp; - struct exportent eep; - struct exportent *curexp = &export->m_export; - - dupexportent(&eep, &pseudo_root.m_export); - eep.e_hostname = curexp->e_hostname; - strncpy(eep.e_path, path, sizeof(eep.e_path)-1); - if (strcmp(path, "/") != 0) - eep.e_flags &= ~NFSEXP_FSID; - set_pseudofs_security(&eep, curexp->e_flags); - exp = export_create(&eep, 0); - if (exp == NULL) - return NULL; - xlog(D_CALL, "v4root_create: path '%s' flags 0x%x", - exp->m_export.e_path, exp->m_export.e_flags); - return &exp->m_export; -} - -/* - * Make sure the kernel has pseudo root support. - */ -static int -v4root_support(void) -{ - struct export_features *ef; - static int warned = 0; - - ef = get_export_features(); - - if (ef->flags & NFSEXP_V4ROOT) - return 1; - if (!warned) { - xlog(L_WARNING, "Kernel does not have pseudo root support."); - xlog(L_WARNING, "NFS v4 mounts will be disabled unless fsid=0"); - xlog(L_WARNING, "is specfied in /etc/exports file."); - warned++; - } - return 0; -} - -static int -pseudofs_update(char *hostname, char *path, nfs_export *source) -{ - nfs_export *exp; - - exp = export_lookup(hostname, path, 0); - if (exp && !(exp->m_export.e_flags & NFSEXP_V4ROOT)) - return 0; - if (!exp) { - if (v4root_create(path, source) == NULL) { - xlog(L_WARNING, "v4root_set: Unable to create " - "pseudo export for '%s'", path); - return -ENOMEM; - } - return 0; - } - /* Update an existing V4ROOT export: */ - set_pseudofs_security(&exp->m_export, source->m_export.e_flags); - return 0; -} - -static int v4root_add_parents(nfs_export *exp) -{ - char *hostname = exp->m_export.e_hostname; - char *path; - char *ptr; - int ret = 0; - - path = strdup(exp->m_export.e_path); - if (!path) { - xlog(L_WARNING, "v4root_add_parents: Unable to create " - "pseudo export for '%s'", exp->m_export.e_path); - return -ENOMEM; - } - for (ptr = path; ptr; ptr = strchr(ptr, '/')) { - char saved; - - saved = *ptr; - *ptr = '\0'; - ret = pseudofs_update(hostname, *path ? path : "/", exp); - if (ret) - break; - *ptr = saved; - ptr++; - } - free(path); - return ret; -} - -/* - * Create pseudo exports by running through the real export - * looking at the components of the path that make up the export. - * Those path components, if not exported, will become pseudo - * exports allowing them to be found when the kernel does an upcall - * looking for components of the v4 mount. - */ -void -v4root_set() -{ - nfs_export *exp; - int i; - - if (!v4root_needed) - return; - if (!v4root_support()) - return; - - for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { - if (exp->m_export.e_flags & NFSEXP_V4ROOT) - /* - * We just added this one, so its - * parents are already dealt with! - */ - continue; - - if (strcmp(exp->m_export.e_path, "/") == 0 && - !(exp->m_export.e_flags & NFSEXP_FSID)) { - /* Force '/' to be exported as fsid == 0*/ - exp->m_export.e_flags |= NFSEXP_FSID; - exp->m_export.e_fsid = 0; - } - - v4root_add_parents(exp); - /* XXX: error handling! */ - } - } -} diff --git a/nfs-utils-2.5.2/utils/nfsd/Makefile.am b/nfs-utils-2.5.2/utils/nfsd/Makefile.am deleted file mode 100644 index 8acc9a0..0000000 --- a/nfs-utils-2.5.2/utils/nfsd/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = nfsd.man -EXTRA_DIST = $(man8_MANS) - -RPCPREFIX = rpc. -KPREFIX = @kprefix@ -sbin_PROGRAMS = nfsd - -noinst_HEADERS = nfssvc.h -nfsd_SOURCES = nfsd.c nfssvc.c -nfsd_LDADD = ../../support/nfs/libnfs.la $(LIBTIRPC) - -MAINTAINERCLEANFILES = Makefile.in - -####################################################################### -# The following allows the current practice of having -# daemons renamed during the install to include RPCPREFIX -# and the KPREFIX -# This could all be done much easier with program_transform_name -# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) -# but that also renames the man pages, which the current -# practice does not do. -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) - - -# XXX This makes some assumptions about what automake does. -# XXX But there is no install-man-hook or install-man-local. -install-man: install-man8 install-man-links -uninstall-man: uninstall-man8 uninstall-man-links - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/nfsd/nfsd.c b/nfs-utils-2.5.2/utils/nfsd/nfsd.c deleted file mode 100644 index a412a02..0000000 --- a/nfs-utils-2.5.2/utils/nfsd/nfsd.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * nfsd - * - * This is the user level part of nfsd. This is very primitive, because - * all the work is now done in the kernel module. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "nfslib.h" -#include "nfssvc.h" -#include "xlog.h" -#include "xcommon.h" - -#ifndef NFSD_NPROC -#define NFSD_NPROC 8 -#endif - -static void usage(const char *); - -static struct option longopts[] = -{ - { "host", 1, 0, 'H' }, - { "help", 0, 0, 'h' }, - { "no-nfs-version", 1, 0, 'N' }, - { "nfs-version", 1, 0, 'V' }, - { "tcp", 0, 0, 't' }, - { "no-tcp", 0, 0, 'T' }, - { "udp", 0, 0, 'u' }, - { "no-udp", 0, 0, 'U' }, - { "port", 1, 0, 'P' }, - { "port", 1, 0, 'p' }, - { "debug", 0, 0, 'd' }, - { "syslog", 0, 0, 's' }, - { "rdma", 2, 0, 'R' }, - { "grace-time", 1, 0, 'G'}, - { "lease-time", 1, 0, 'L'}, - { NULL, 0, 0, 0 } -}; - -int -main(int argc, char **argv) -{ - int count = NFSD_NPROC, c, i, error = 0, portnum, fd, found_one; - char *p, *progname, *port, *rdma_port = NULL; - char **haddr = NULL; - int hcounter = 0; - struct conf_list *hosts; - int socket_up = 0; - unsigned int minorvers = NFSCTL_MINDEFAULT; - unsigned int minorversset = NFSCTL_MINDEFAULT; - unsigned int minormask = 0; - unsigned int versbits = NFSCTL_VERDEFAULT; - unsigned int protobits = NFSCTL_PROTODEFAULT; - int grace = -1; - int lease = -1; - int force4dot0 = 0; - - progname = basename(argv[0]); - haddr = xmalloc(sizeof(char *)); - haddr[0] = NULL; - - xlog_syslog(0); - xlog_stderr(1); - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("nfsd"); - - nfssvc_get_minormask(&minormask); - - count = conf_get_num("nfsd", "threads", count); - grace = conf_get_num("nfsd", "grace-time", grace); - lease = conf_get_num("nfsd", "lease-time", lease); - port = conf_get_str("nfsd", "port"); - if (!port) - port = "nfs"; - if (conf_get_bool("nfsd", "rdma", false)) { - rdma_port = conf_get_str("nfsd", "rdma-port"); - if (!rdma_port) - rdma_port = "nfsrdma"; - } - /* backward compatibility - nfs.conf used to set rdma port directly */ - if (!rdma_port) - rdma_port = conf_get_str("nfsd", "rdma"); - if (conf_get_bool("nfsd", "udp", NFSCTL_UDPISSET(protobits))) - NFSCTL_UDPSET(protobits); - else - NFSCTL_UDPUNSET(protobits); - if (conf_get_bool("nfsd", "tcp", NFSCTL_TCPISSET(protobits))) - NFSCTL_TCPSET(protobits); - else - NFSCTL_TCPUNSET(protobits); - for (i = 2; i <= 4; i++) { - char tag[20]; - sprintf(tag, "vers%d", i); - if (conf_get_bool("nfsd", tag, NFSCTL_VERISSET(versbits, i))) { - NFSCTL_VERSET(versbits, i); - if (i == 4) - minorvers = minorversset = minormask; - } else { - NFSCTL_VERUNSET(versbits, i); - if (i == 4) { - minorvers = 0; - minorversset = minormask; - } - } - } - - /* We assume the kernel will default all minor versions to 'on', - * and allow the config file to disable some. - */ - for (i = NFS4_MINMINOR; i <= NFS4_MAXMINOR; i++) { - char tag[20]; - sprintf(tag, "vers4.%d", i); - /* The default for minor version support is to let the - * kernel decide. We could ask the kernel what that choice - * will be, but that is needlessly complex. - * Instead, perform a config-file lookup using each of the - * two possible default. If the result is different from the - * default, then impose that value, else don't make a change - * (i.e. don't set the bit in minorversset). - */ - if (!conf_get_bool("nfsd", tag, 1)) { - NFSCTL_MINORSET(minorversset, i); - NFSCTL_MINORUNSET(minorvers, i); - if (i == 0) - force4dot0 = 1; - } - if (conf_get_bool("nfsd", tag, 0)) { - NFSCTL_MINORSET(minorversset, i); - NFSCTL_MINORSET(minorvers, i); - if (i == 0) - force4dot0 = 1; - } - } - - hosts = conf_get_list("nfsd", "host"); - if (hosts && hosts->cnt) { - struct conf_list_node *n; - haddr = realloc(haddr, sizeof(char*) * hosts->cnt); - TAILQ_FOREACH(n, &(hosts->fields), link) { - haddr[hcounter] = n->field; - hcounter++; - } - } - - while ((c = getopt_long(argc, argv, "dH:hN:V:p:P:stTituUrG:L:", longopts, NULL)) != EOF) { - switch(c) { - case 'd': - xlog_config(D_ALL, 1); - break; - case 'H': - if (hosts) { - hosts = NULL; - hcounter = 0; - } - if (hcounter) { - haddr = realloc(haddr, sizeof(char*) * hcounter+1); - if(!haddr) { - fprintf(stderr, "%s: unable to allocate " - "memory.\n", progname); - exit(1); - } - } - haddr[hcounter] = optarg; - hcounter++; - break; - case 'P': /* XXX for nfs-server compatibility */ - case 'p': - /* only the last -p option has any effect */ - port = optarg; - break; - case 'r': - rdma_port = "nfsrdma"; - break; - case 'R': /* --rdma */ - if (optarg) - rdma_port = optarg; - else - rdma_port = "nfsrdma"; - break; - - case 'N': - switch((c = strtol(optarg, &p, 0))) { - case 4: - if (*p == '.') { - int i = atoi(p+1); - if (i < 0 || i > NFS4_MAXMINOR) { - fprintf(stderr, "%s: unsupported minor version\n", optarg); - exit(1); - } - NFSCTL_MINORSET(minorversset, i); - NFSCTL_MINORUNSET(minorvers, i); - if (i == 0) - force4dot0 = 1; - if (minorvers != 0) - break; - } else { - minorvers = 0; - minorversset = minormask; - } - /* FALLTHRU */ - case 3: - case 2: - NFSCTL_VERUNSET(versbits, c); - break; - default: - fprintf(stderr, "%s: Unsupported version\n", optarg); - exit(1); - } - break; - case 'V': - switch((c = strtol(optarg, &p, 0))) { - case 4: - if (*p == '.') { - int i = atoi(p+1); - if (i < 0 || i > NFS4_MAXMINOR) { - fprintf(stderr, "%s: unsupported minor version\n", optarg); - exit(1); - } - NFSCTL_MINORSET(minorversset, i); - NFSCTL_MINORSET(minorvers, i); - if (i == 0) - force4dot0 = 1; - } else - minorvers = minorversset = minormask; - /* FALLTHRU */ - case 3: - case 2: - NFSCTL_VERSET(versbits, c); - break; - default: - fprintf(stderr, "%s: Unsupported version\n", optarg); - exit(1); - } - break; - case 's': - xlog_syslog(1); - xlog_stderr(0); - break; - case 't': - NFSCTL_TCPSET(protobits); - break; - case 'T': - NFSCTL_TCPUNSET(protobits); - break; - case 'u': - NFSCTL_UDPSET(protobits); - break; - case 'U': - NFSCTL_UDPUNSET(protobits); - break; - case 'G': - grace = strtol(optarg, &p, 0); - if (*p || grace <= 0) { - fprintf(stderr, "%s: Unrecognized grace time.\n", optarg); - exit(1); - } - break; - case 'L': - lease = strtol(optarg, &p, 0); - if (*p || lease <= 0) { - fprintf(stderr, "%s: Unrecognized lease time.\n", optarg); - exit(1); - } - break; - default: - fprintf(stderr, "Invalid argument: '%c'\n", c); - /* FALLTHRU */ - case 'h': - usage(progname); - } - } - - if (optind < argc) { - if ((count = atoi(argv[optind])) < 0) { - /* insane # of servers */ - fprintf(stderr, - "%s: invalid server count (%d), using 1\n", - argv[0], count); - count = 1; - } else if (count == 0) { - /* - * don't bother setting anything else if the threads - * are coming down anyway. - */ - socket_up = 1; - goto set_threads; - } - } - - xlog_open(progname); - - portnum = strtol(port, &p, 0); - if (!*p && (portnum <= 0 || portnum > 65535)) { - /* getaddrinfo will catch other errors, but not - * out-of-range numbers. - */ - xlog(L_ERROR, "invalid port number: %s", port); - exit(1); - } - - /* make sure that at least one version is enabled */ - found_one = 0; - for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) { - if (NFSCTL_VERISSET(versbits, c)) - found_one = 1; - } - if (!found_one) { - xlog(L_ERROR, "no version specified"); - exit(1); - } - - if (NFSCTL_VERISSET(versbits, 4) && - !NFSCTL_TCPISSET(protobits)) { - xlog(L_ERROR, "version 4 requires the TCP protocol"); - exit(1); - } - - if (chdir(NFS_STATEDIR)) { - xlog(L_ERROR, "chdir(%s) failed: %m", NFS_STATEDIR); - exit(1); - } - - /* make sure nfsdfs is mounted if it's available */ - nfssvc_mount_nfsdfs(progname); - - /* can only change number of threads if nfsd is already up */ - if (nfssvc_inuse()) { - socket_up = 1; - goto set_threads; - } - - /* - * Must set versions before the fd's so that the right versions get - * registered with rpcbind. Note that on older kernels w/o the right - * interfaces, these are a no-op. - * Timeouts must also be set before ports are created else we get - * EBUSY. - */ - nfssvc_setvers(versbits, minorvers, minorversset, force4dot0); - if (grace > 0) - nfssvc_set_time("grace", grace); - if (lease > 0) - nfssvc_set_time("lease", lease); - - i = 0; - do { - error = nfssvc_set_sockets(protobits, haddr[i], port); - if (!error) - socket_up = 1; - } while (++i < hcounter); - - if (rdma_port) { - error = nfssvc_set_rdmaport(rdma_port); - if (!error) - socket_up = 1; - } -set_threads: - /* don't start any threads if unable to hand off any sockets */ - if (!socket_up) { - xlog(L_ERROR, "unable to set any sockets for nfsd"); - goto out; - } - error = 0; - - /* - * KLUDGE ALERT: - * Some kernels let nfsd kernel threads inherit open files - * from the program that spawns them (i.e. us). So close - * everything before spawning kernel threads. --Chip - */ - fd = open("/dev/null", O_RDWR); - if (fd == -1) - xlog(L_ERROR, "Unable to open /dev/null: %m"); - else { - /* switch xlog output to syslog since stderr is being closed */ - xlog_syslog(1); - xlog_stderr(0); - (void) dup2(fd, 0); - (void) dup2(fd, 1); - (void) dup2(fd, 2); - } - closeall(3); - - if ((error = nfssvc_threads(count)) < 0) - xlog(L_ERROR, "error starting threads: errno %d (%m)", errno); -out: - free(haddr); - return (error != 0); -} - -static void -usage(const char *prog) -{ - fprintf(stderr, "Usage:\n" - "%s [-d|--debug] [-H hostname] [-p|-P|--port port]\n" - " [-N|--no-nfs-version version] [-V|--nfs-version version]\n" - " [-s|--syslog] [-t|--tcp] [-T|--no-tcp] [-u|--udp] [-U|--no-udp]\n" - " [-r|--rdma=] [-G|--grace-time secs] [-L|--leasetime secs] nrservs\n", - prog); - exit(2); -} diff --git a/nfs-utils-2.5.2/utils/nfsd/nfsd.man b/nfs-utils-2.5.2/utils/nfsd/nfsd.man deleted file mode 100644 index 2701ba7..0000000 --- a/nfs-utils-2.5.2/utils/nfsd/nfsd.man +++ /dev/null @@ -1,192 +0,0 @@ -.\" -.\" nfsd(8) -.\" -.\" Copyright (C) 1999 Olaf Kirch -.TH rpc.nfsd 8 "20 Feb 2014" -.SH NAME -rpc.nfsd \- NFS server process -.SH SYNOPSIS -.BI "/usr/sbin/rpc.nfsd [" options "]" " "nproc -.SH DESCRIPTION -The -.B rpc.nfsd -program implements the user level part of the NFS service. The -main functionality is handled by the -.B nfsd -kernel module. The user space program merely specifies what sort of sockets -the kernel service should listen on, what NFS versions it should support, and -how many kernel threads it should use. -.P -The -.B rpc.mountd -server provides an ancillary service needed to satisfy mount requests -by NFS clients. -.SH OPTIONS -.TP -.B \-d " or " \-\-debug -enable logging of debugging messages -.TP -.B \-H " or " \-\-host hostname -specify a particular hostname (or address) that NFS requests will -be accepted on. By default, -.B rpc.nfsd -will accept NFS requests on all known network addresses. -Note that -.B lockd -(which performs file locking services for NFS) may still accept -request on all known network addresses. This may change in future -releases of the Linux Kernel. This option can be used multiple time -to listen to more than one interface. -.TP -.B \-p " or " \-\-port port -specify a different port to listen on for NFS requests. By default, -.B rpc.nfsd -will listen on port 2049. -.TP -.B \-r " or " \-\-rdma -specify that NFS requests on the standard RDMA port ("nfsrdma", port -20049) should be honored. -.TP -.BI \-\-rdma= port -Listen for RDMA requests on an alternate port - may be a number or a -name listed in -.BR /etc/services . -.TP -.B \-N " or " \-\-no-nfs-version vers -This option can be used to request that -.B rpc.nfsd -does not offer certain versions of NFS. The current version of -.B rpc.nfsd -can support major NFS versions 2,3,4 and the minor versions 4.0, 4.1 and 4.2. -.TP -.B \-s " or " \-\-syslog -By default, -.B rpc.nfsd -logs error messages (and debug messages, if enabled) to stderr. This option makes -.B rpc.nfsd -log these messages to syslog instead. Note that errors encountered during -option processing will still be logged to stderr regardless of this option. -.TP -.B \-t " or " \-\-tcp -Instruct the kernel nfs server to open and listen on a TCP socket. This is the default. -.TP -.B \-T " or " \-\-no-tcp -Instruct the kernel nfs server not to open and listen on a TCP socket. -.TP -.B \-u " or " \-\-udp -Instruct the kernel nfs server to open and listen on a UDP socket. -.TP -.B \-U " or " \-\-no-udp -Instruct the kernel nfs server not to open and listen on a UDP socket. This is the default. -.TP -.B \-V " or " \-\-nfs-version vers -This option can be used to request that -.B rpc.nfsd -offer certain versions of NFS. The current version of -.B rpc.nfsd -can support major NFS versions 2,3,4 and the minor versions 4.0, 4.1 and 4.2. -.TP -.B \-L " or " \-\-lease-time seconds -Set the lease-time used for NFSv4. This corresponds to how often -clients need to confirm their state with the server. Valid range is -from 10 to 3600 seconds. -.TP -.B \-G " or " \-\-grace-time seconds -Set the grace-time used for NFSv4 and NLM (for NFSv2 and NFSv3). -New file open requests (NFSv4) and new file locks (NLM) will not be -allowed until after this time has passed to allow clients to recover state. -.TP -.I nproc -specify the number of NFS server threads. By default, eight -threads are started. However, for optimum performance several threads -should be used. The actual figure depends on the number of and the work -load created by the NFS clients, but a useful starting point is -eight threads. Effects of modifying that number can be checked using -the -.BR nfsstat (8) -program. -.P -Note that if the NFS server is already running, then the options for -specifying host, port, and protocol will be ignored. The number of -processes given will be the only option considered, and the number of -active -.B nfsd -processes will be increased or decreased to match this number. -In particular -.B rpc.nfsd 0 -will stop all threads and thus close any open connections. - -.SH CONFIGURATION FILE -Many of the options that can be set on the command line can also be -controlled through values set in the -.B [nfsd] -section of the -.I /etc/nfs.conf -configuration file. Values recognized include: -.TP -.B threads -The number of threads to start. -.TP -.B host -A host name, or comma separated list of host names, that -.I rpc.nfsd -will listen on. Use of the -.B --host -option replaces all host names listed here. -.TP -.B grace-time -The grace time, for both NFSv4 and NLM, in seconds. -.TP -.B lease-time -The lease time for NFSv4, in seconds. -.TP -.B port -Set the port for TCP/UDP to bind to. -.TP -.B rdma -Enable RDMA port (with "on" or "yes" etc) on the standard port -("nfsrdma", port 20049). -.TP -.B rdma-port -Set an alternate RDMA port. -.TP -.B UDP -Enable (with "on" or "yes" etc) or disable ("off", "no") UDP support. -.TP -.B TCP -Enable or disable TCP support. -.TP -.B vers2 -.TP -.B vers3 -.TP -.B vers4 -Enable or disable a major NFS version. 3 and 4 are normally enabled -by default. -.TP -.B vers4.1 -.TP -.B vers4.2 -Setting these to "off" or similar will disable the selected minor -versions. Setting to "on" will enable them. The default values -are determined by the kernel, and usually minor versions default to -being enabled once the implementation is sufficiently complete. - -.SH NOTES -If the program is built with TI-RPC support, it will enable any protocol and -address family combinations that are marked visible in the -.B netconfig -database. - -.SH SEE ALSO -.BR nfsd (7), -.BR rpc.mountd (8), -.BR exports (5), -.BR exportfs (8), -.BR nfs.conf (5), -.BR rpc.rquotad (8), -.BR nfsstat (8), -.BR netconfig(5). -.SH AUTHOR -Olaf Kirch, Bill Hawes, H. J. Lu, G. Allan Morris III, -and a host of others. diff --git a/nfs-utils-2.5.2/utils/nfsd/nfssvc.c b/nfs-utils-2.5.2/utils/nfsd/nfssvc.c deleted file mode 100644 index 720bdd9..0000000 --- a/nfs-utils-2.5.2/utils/nfsd/nfssvc.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * utils/nfsd/nfssvc.c - * - * Run an NFS daemon. - * - * Copyright (C) 1995, 1996 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "xlog.h" -#include "nfssvc.h" -#include "../mount/version.h" - -#ifndef NFSD_FS_DIR -#define NFSD_FS_DIR "/proc/fs/nfsd" -#endif - -#define NFSD_PORTS_FILE NFSD_FS_DIR "/portlist" -#define NFSD_VERS_FILE NFSD_FS_DIR "/versions" -#define NFSD_THREAD_FILE NFSD_FS_DIR "/threads" - -/* - * declaring a common static scratch buffer here keeps us from having to - * continually thrash the stack. The value of 128 bytes here is really just a - * SWAG and can be increased if necessary. It ought to be enough for the - * routines below however. - */ -char buf[128]; - -/* - * Using the "new" interfaces for nfsd requires that /proc/fs/nfsd is - * actually mounted. Make an attempt to mount it here if it doesn't appear - * to be. - */ -void -nfssvc_mount_nfsdfs(char *progname) -{ - int err; - struct stat statbuf; - - err = stat(NFSD_THREAD_FILE, &statbuf); - if (err == 0) - return; - - if (errno != ENOENT) { - xlog(L_ERROR, "Unable to stat %s: errno %d (%m)", - NFSD_THREAD_FILE, errno); - return; - } - - /* - * this call can return an error if modprobe is set up to automatically - * mount nfsdfs when nfsd.ko is plugged in. So, ignore the return - * code from it and just check for the "threads" file afterward. - */ - err = system("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1"); - - err = stat(NFSD_THREAD_FILE, &statbuf); - if (err == 0) - return; - - xlog(L_WARNING, "Unable to access " NFSD_FS_DIR " errno %d (%m)." - "\nPlease try, as root, 'mount -t nfsd nfsd " NFSD_FS_DIR - "' and then restart %s to correct the problem", errno, progname); - - return; -} - -/* - * Are there already sockets configured? If not, then it is safe to try to - * open some and pass them through. - * - * Note: If the user explicitly asked for 'udp', then we should probably check - * if that is open, and should open it if not. However we don't yet. All - * sockets have to be opened when the first daemon is started. - */ -int -nfssvc_inuse(void) -{ - int fd, n; - - fd = open(NFSD_PORTS_FILE, O_RDONLY); - - /* problem opening file, assume that nothing is configured */ - if (fd < 0) - return 0; - - n = read(fd, buf, sizeof(buf)); - close(fd); - - xlog(D_GENERAL, "knfsd is currently %s", (n > 0) ? "up" : "down"); - - return (n > 0); -} - -static int -nfssvc_setfds(const struct addrinfo *hints, const char *node, const char *port) -{ - int fd, on = 1, fac = L_ERROR; - int sockfd = -1, rc = 0, bounded = 0; - struct addrinfo *addrhead = NULL, *addr; - char *proto, *family; - - /* - * if file can't be opened, fail. - */ - fd = open(NFSD_PORTS_FILE, O_WRONLY); - if (fd < 0) - return 0; - - rc = getaddrinfo(node, port, hints, &addrhead); - if (rc == EAI_NONAME && !strcmp(port, "nfs")) { - snprintf(buf, sizeof(buf), "%d", NFS_PORT); - rc = getaddrinfo(node, buf, hints, &addrhead); - } - - if (rc != 0) { - xlog(L_ERROR, "unable to resolve %s:%s: %s", - node ? node : "ANYADDR", port, - rc == EAI_SYSTEM ? strerror(errno) : - gai_strerror(rc)); - goto error; - } - - addr = addrhead; - while(addr) { - /* skip non-TCP / non-UDP sockets */ - switch(addr->ai_protocol) { - case IPPROTO_UDP: - proto = "UDP"; - break; - case IPPROTO_TCP: - proto = "TCP"; - break; - default: - addr = addr->ai_next; - continue; - } - - switch(addr->ai_addr->sa_family) { - case AF_INET: - family = "AF_INET"; - break; -#ifdef IPV6_SUPPORTED - case AF_INET6: - family = "AF_INET6"; - break; -#endif /* IPV6_SUPPORTED */ - default: - addr = addr->ai_next; - continue; - } - - /* open socket and prepare to hand it off to kernel */ - sockfd = socket(addr->ai_family, addr->ai_socktype, - addr->ai_protocol); - if (sockfd < 0) { - if (errno != EAFNOSUPPORT) { - xlog(L_ERROR, "unable to create %s %s socket: " - "errno %d (%m)", family, proto, errno); - rc = errno; - goto error; - } - addr = addr->ai_next; - continue; - } - - xlog(D_GENERAL, "Created %s %s socket.", family, proto); - -#ifdef IPV6_SUPPORTED - if (addr->ai_family == AF_INET6 && - setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on))) { - xlog(L_ERROR, "unable to set IPV6_V6ONLY: " - "errno %d (%m)\n", errno); - rc = errno; - goto error; - } -#endif /* IPV6_SUPPORTED */ - if (addr->ai_protocol == IPPROTO_TCP && - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) { - xlog(L_ERROR, "unable to set SO_REUSEADDR on %s " - "socket: errno %d (%m)", family, errno); - rc = errno; - goto error; - } - if (bind(sockfd, addr->ai_addr, addr->ai_addrlen)) { - xlog(L_ERROR, "unable to bind %s %s socket: " - "errno %d (%m)", family, proto, errno); - rc = errno; - goto error; - } - if (addr->ai_protocol == IPPROTO_TCP && listen(sockfd, 64)) { - xlog(L_ERROR, "unable to create listening socket: " - "errno %d (%m)", errno); - rc = errno; - goto error; - } - - if (fd < 0) - fd = open(NFSD_PORTS_FILE, O_WRONLY); - - if (fd < 0) { - xlog(L_ERROR, "couldn't open ports file: errno " - "%d (%m)", errno); - goto error; - } - - snprintf(buf, sizeof(buf), "%d\n", sockfd); - if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) { - /* - * this error may be common on older kernels that don't - * support IPv6, so turn into a debug message. - */ - if (errno == EAFNOSUPPORT) - fac = D_ALL; - xlog(fac, "writing fd to kernel failed: errno %d (%m)", - errno); - rc = errno; - goto error; - } - bounded++; - - close(fd); - close(sockfd); - sockfd = fd = -1; - addr = addr->ai_next; - } -error: - if (fd >= 0) - close(fd); - if (sockfd >= 0) - close(sockfd); - nfs_freeaddrinfo(addrhead); - return (bounded ? 0 : rc); -} - -int -nfssvc_set_sockets(const unsigned int protobits, - const char *host, const char *port) -{ - struct addrinfo hints = { .ai_flags = AI_PASSIVE }; - -#ifdef IPV6_SUPPORTED - hints.ai_family = AF_UNSPEC; -#else /* IPV6_SUPPORTED */ - hints.ai_family = AF_INET; -#endif /* IPV6_SUPPORTED */ - - if (!NFSCTL_ANYPROTO(protobits)) - return EPROTOTYPE; - else if (!NFSCTL_UDPISSET(protobits)) - hints.ai_protocol = IPPROTO_TCP; - else if (!NFSCTL_TCPISSET(protobits)) - hints.ai_protocol = IPPROTO_UDP; - - return nfssvc_setfds(&hints, host, port); -} - -int -nfssvc_set_rdmaport(const char *port) -{ - struct servent *sv = getservbyname(port, "tcp"); - int nport; - char buf[20]; - int ret; - int fd; - - if (sv) - nport = ntohs(sv->s_port); - else { - char *ep; - nport = strtol(port, &ep, 10); - if (!*port || *ep) { - xlog(L_ERROR, "unable to interpret port name %s", - port); - return 1; - } - } - - fd = open(NFSD_PORTS_FILE, O_WRONLY); - if (fd < 0) - return 1; - snprintf(buf, sizeof(buf), "rdma %d", nport); - ret = 0; - if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) { - ret= errno; - xlog(L_ERROR, "Unable to request RDMA services: %m"); - } - close(fd); - return ret; -} - -void -nfssvc_set_time(const char *type, const int seconds) -{ - char pathbuf[40]; - char nbuf[10]; - int fd; - - snprintf(pathbuf, sizeof(pathbuf), NFSD_FS_DIR "/nfsv4%stime", type); - snprintf(nbuf, sizeof(nbuf), "%d", seconds); - fd = open(pathbuf, O_WRONLY); - if (fd >= 0) { - if (write(fd, nbuf, strlen(nbuf)) != (ssize_t)strlen(nbuf)) - xlog(L_ERROR, "Unable to set nfsv4%stime: %m", type); - close(fd); - } - if (strcmp(type, "grace") == 0) { - /* set same value for lockd */ - fd = open("/proc/sys/fs/nfs/nlm_grace_period", O_WRONLY); - if (fd >= 0) { - if (write(fd, nbuf, strlen(nbuf)) != (ssize_t)strlen(nbuf)) - xlog(L_ERROR, "Unable to write nlm_grace_period : %m"); - close(fd); - } - } -} - -void -nfssvc_get_minormask(unsigned int *mask) -{ - int fd; - char *ptr = buf; - ssize_t size; - - fd = open(NFSD_VERS_FILE, O_RDONLY); - if (fd < 0) - return; - - size = read(fd, buf, sizeof(buf)); - if (size < 0) { - xlog(L_ERROR, "Getting versions failed: errno %d (%m)", errno); - goto out; - } - ptr[size] = '\0'; - for (;;) { - unsigned vers, minor = 0; - char *token = strtok(ptr, " "); - - if (!token) - break; - ptr = NULL; - if (*token != '+' && *token != '-') - continue; - if (sscanf(++token, "%u.%u", &vers, &minor) > 0 && - vers == 4 && minor <= NFS4_MAXMINOR) - NFSCTL_MINORSET(*mask, minor); - } -out: - close(fd); - return; -} - -static int -nfssvc_print_vers(char *ptr, unsigned size, unsigned vers, unsigned minorvers, - int isset, int force4dot0) -{ - char sign = isset ? '+' : '-'; - if (minorvers == 0) - if (linux_version_code() < MAKE_VERSION(4, 11, 0) || !force4dot0) - return snprintf(ptr, size, "%c%u ", sign, vers); - return snprintf(ptr, size, "%c%u.%u ", sign, vers, minorvers); -} - -void -nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset, - int force4dot0) -{ - int fd, n, off; - - off = 0; - fd = open(NFSD_VERS_FILE, O_WRONLY); - if (fd < 0) - return; - - for (n = NFSD_MINVERS; n <= ((NFSD_MAXVERS < 3) ? NFSD_MAXVERS : 3); n++) - off += nfssvc_print_vers(&buf[off], sizeof(buf) - off, - n, 0, NFSCTL_VERISSET(ctlbits, n), 0); - - for (n = 0; n <= NFS4_MAXMINOR; n++) { - if (!NFSCTL_MINORISSET(minorversset, n)) - continue; - off += nfssvc_print_vers(&buf[off], sizeof(buf) - off, - 4, n, NFSCTL_MINORISSET(minorvers, n), - (n == 0) ? force4dot0 : 0); - } - if (!off--) - goto out; - buf[off] = '\0'; - xlog(D_GENERAL, "Writing version string to kernel: %s", buf); - snprintf(&buf[off], sizeof(buf) - off, "\n"); - if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) - xlog(L_ERROR, "Setting version failed: errno %d (%m)", errno); -out: - close(fd); - - return; -} - -int -nfssvc_threads(const int nrservs) -{ - ssize_t n; - int fd; - - fd = open(NFSD_THREAD_FILE, O_WRONLY); - if (fd < 0) - fd = open("/proc/fs/nfs/threads", O_WRONLY); - if (fd >= 0) { - /* 2.5+ kernel with nfsd filesystem mounted. - * Just write the number of threads. - */ - snprintf(buf, sizeof(buf), "%d\n", nrservs); - n = write(fd, buf, strlen(buf)); - close(fd); - if (n != (ssize_t)strlen(buf)) - return -1; - else - return 0; - } - return -1; -} diff --git a/nfs-utils-2.5.2/utils/nfsd/nfssvc.h b/nfs-utils-2.5.2/utils/nfsd/nfssvc.h deleted file mode 100644 index 4d53af1..0000000 --- a/nfs-utils-2.5.2/utils/nfsd/nfssvc.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * utils/nfsd/nfssvc.h -- nfs service control routines for rpc.nfsd - * - * Copyright (C) 2009 Red Hat, Inc . - * Copyright (C) 2009 Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA - * - */ - -void nfssvc_mount_nfsdfs(char *progname); -int nfssvc_inuse(void); -int nfssvc_set_sockets(const unsigned int protobits, - const char *host, const char *port); -void nfssvc_set_time(const char *type, const int seconds); -int nfssvc_set_rdmaport(const char *port); -void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, - unsigned int minorvers4set, int force4dot0); -int nfssvc_threads(int nrservs); -void nfssvc_get_minormask(unsigned int *mask); diff --git a/nfs-utils-2.5.2/utils/nfsdcld/Makefile.am b/nfs-utils-2.5.2/utils/nfsdcld/Makefile.am deleted file mode 100644 index 273d64f..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = nfsdcld.man -EXTRA_DIST = $(man8_MANS) - -AM_CFLAGS += -D_LARGEFILE64_SOURCE -sbin_PROGRAMS = nfsdcld - -nfsdcld_SOURCES = nfsdcld.c sqlite.c legacy.c -nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) - -noinst_HEADERS = sqlite.h cld-internal.h legacy.h - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/utils/nfsdcld/cld-internal.h b/nfs-utils-2.5.2/utils/nfsdcld/cld-internal.h deleted file mode 100644 index 3576515..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/cld-internal.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _CLD_INTERNAL_H_ -#define _CLD_INTERNAL_H_ - -#if CLD_UPCALL_VERSION >= 2 -#define UPCALL_VERSION 2 -#else -#define UPCALL_VERSION 1 -#endif - -struct cld_client { - int cl_fd; - struct event *cl_event; - union { - struct cld_msg cl_msg; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 cl_msg_v2; -#endif - } cl_u; -}; - -extern uint64_t current_epoch; -extern uint64_t recovery_epoch; -extern int first_time; -extern int num_cltrack_records; -extern int num_legacy_records; - -#endif /* _CLD_INTERNAL_H_ */ diff --git a/nfs-utils-2.5.2/utils/nfsdcld/legacy.c b/nfs-utils-2.5.2/utils/nfsdcld/legacy.c deleted file mode 100644 index b89374c..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/legacy.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cld.h" -#include "sqlite.h" -#include "xlog.h" -#include "legacy.h" - -#define NFSD_RECDIR_FILE "/proc/fs/nfsd/nfsv4recoverydir" - -/* - * Loads client records from the v4recovery directory into the database. - * Records are prefixed with the string "hash:" and include the '\0' byte. - * - * Called during database initialization as part of a one-time "upgrade". - */ -void -legacy_load_clients_from_recdir(int *num_records) -{ - int fd; - DIR *v4recovery; - struct dirent *entry; - char recdirname[PATH_MAX+1]; - char buf[NFS4_OPAQUE_LIMIT]; - char *nl; - ssize_t n; - - fd = open(NFSD_RECDIR_FILE, O_RDONLY); - if (fd < 0) { - xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE); - return; - } - n = read(fd, recdirname, PATH_MAX); - close(fd); - if (n < 0) { - xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); - return; - } - /* the output from the proc file isn't null-terminated */ - recdirname[PATH_MAX] = '\0'; - nl = strchr(recdirname, '\n'); - if (!nl) - return; - *nl = '\0'; - v4recovery = opendir(recdirname); - if (!v4recovery) - return; - while ((entry = readdir(v4recovery))) { - int ret; - - /* skip "." and ".." */ - if (entry->d_name[0] == '.') { - switch (entry->d_name[1]) { - case '\0': - continue; - case '.': - if (entry->d_name[2] == '\0') - continue; - } - } - /* prefix legacy records with the string "hash:" */ - ret = snprintf(buf, sizeof(buf), "hash:%s", entry->d_name); - /* if there's a problem, then skip this entry */ - if (ret < 0 || (size_t)ret >= sizeof(buf)) { - xlog(L_WARNING, "%s: unable to build client string for %s!", - __func__, entry->d_name); - continue; - } - /* legacy client records need to include the null terminator */ - ret = sqlite_insert_client((unsigned char *)buf, strlen(buf) + 1); - if (ret) - xlog(L_WARNING, "%s: unable to insert %s: %d", __func__, - entry->d_name, ret); - else - (*num_records)++; - } - closedir(v4recovery); -} - -/* - * Cleans out the v4recovery directory. - * - * Called upon receipt of the first "GraceDone" upcall only. - */ -void -legacy_clear_recdir(void) -{ - int fd; - DIR *v4recovery; - struct dirent *entry; - char recdirname[PATH_MAX+1]; - char dirname[PATH_MAX]; - char *nl; - ssize_t n; - - fd = open(NFSD_RECDIR_FILE, O_RDONLY); - if (fd < 0) { - xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE); - return; - } - n = read(fd, recdirname, PATH_MAX); - close(fd); - if (n < 0) { - xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); - return; - } - /* the output from the proc file isn't null-terminated */ - recdirname[PATH_MAX] = '\0'; - nl = strchr(recdirname, '\n'); - if (!nl) - return; - *nl = '\0'; - v4recovery = opendir(recdirname); - if (!v4recovery) - return; - while ((entry = readdir(v4recovery))) { - int len; - - /* skip "." and ".." */ - if (entry->d_name[0] == '.') { - switch (entry->d_name[1]) { - case '\0': - continue; - case '.': - if (entry->d_name[2] == '\0') - continue; - } - } - len = snprintf(dirname, sizeof(dirname), "%s/%s", recdirname, - entry->d_name); - /* if there's a problem, then skip this entry */ - if (len < 0 || (size_t)len >= sizeof(dirname)) { - xlog(L_WARNING, "%s: unable to build filename for %s!", - __func__, entry->d_name); - continue; - } - len = rmdir(dirname); - if (len) - xlog(L_WARNING, "%s: unable to rmdir %s: %d", __func__, - dirname, len); - } - closedir(v4recovery); -} diff --git a/nfs-utils-2.5.2/utils/nfsdcld/legacy.h b/nfs-utils-2.5.2/utils/nfsdcld/legacy.h deleted file mode 100644 index 8988f6e..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/legacy.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _LEGACY_H_ -#define _LEGACY_H_ - -void legacy_load_clients_from_recdir(int *); -void legacy_clear_recdir(void); - -#endif /* _LEGACY_H_ */ diff --git a/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.c b/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.c deleted file mode 100644 index 636c398..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.c +++ /dev/null @@ -1,922 +0,0 @@ -/* - * nfsdcld.c -- NFSv4 client name tracking daemon - * - * Copyright (C) 2011 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_CAPABILITY_H -#include -#include -#endif - -#include "xlog.h" -#include "nfslib.h" -#include "cld.h" -#include "cld-internal.h" -#include "sqlite.h" -#include "../mount/version.h" -#include "conffile.h" -#include "legacy.h" - -#ifndef DEFAULT_PIPEFS_DIR -#define DEFAULT_PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs" -#endif - -#define DEFAULT_CLD_PATH "/nfsd/cld" - -#ifndef CLD_DEFAULT_STORAGEDIR -#define CLD_DEFAULT_STORAGEDIR NFS_STATEDIR "/nfsdcld" -#endif - -#define NFSD_END_GRACE_FILE "/proc/fs/nfsd/v4_end_grace" - -/* private data structures */ - -/* global variables */ -static char pipefs_dir[PATH_MAX] = DEFAULT_PIPEFS_DIR; -static char pipepath[PATH_MAX]; -static int inotify_fd = -1; -static struct event *pipedir_event; -static struct event_base *evbase; -static bool old_kernel = false; -static bool signal_received = false; - -uint64_t current_epoch; -uint64_t recovery_epoch; -int first_time; -int num_cltrack_records; -int num_legacy_records; - -static struct option longopts[] = -{ - { "help", 0, NULL, 'h' }, - { "foreground", 0, NULL, 'F' }, - { "debug", 0, NULL, 'd' }, - { "pipefsdir", 1, NULL, 'p' }, - { "storagedir", 1, NULL, 's' }, - { NULL, 0, 0, 0 }, -}; - -/* forward declarations */ -static void cldcb(int UNUSED(fd), short which, void *data); - -static void -sig_die(int signal) -{ - if (signal_received) { - xlog(D_GENERAL, "forced exiting on signal %d\n", signal); - exit(0); - } - - signal_received = true; - xlog(D_GENERAL, "exiting on signal %d\n", signal); - event_base_loopexit(evbase, NULL); -} - -static void -usage(char *progname) -{ - printf("%s [ -hFd ] [ -p pipefsdir ] [ -s storagedir ]\n", progname); -} - -static int -cld_set_caps(void) -{ - int ret = 0; -#ifdef HAVE_SYS_CAPABILITY_H - unsigned long i; - cap_t caps; - - if (getuid() != 0) { - xlog(L_ERROR, "Not running as root. Daemon won't be able to " - "open the pipe after dropping capabilities!"); - return -EINVAL; - } - - /* prune the bounding set to nothing */ - for (i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0 ; ++i) { - ret = prctl(PR_CAPBSET_DROP, i, 0, 0, 0); - if (ret) { - xlog(L_ERROR, "Unable to prune capability %lu from " - "bounding set: %m", i); - return -errno; - } - } - - /* get a blank capset */ - caps = cap_init(); - if (caps == NULL) { - xlog(L_ERROR, "Unable to get blank capability set: %m"); - return -errno; - } - - /* reset the process capabilities */ - if (cap_set_proc(caps) != 0) { - xlog(L_ERROR, "Unable to set process capabilities: %m"); - ret = -errno; - } - cap_free(caps); -#endif - return ret; -} - -#define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX) - -static int -cld_pipe_open(struct cld_client *clnt) -{ - int fd; - struct event *ev; - - xlog(D_GENERAL, "%s: opening upcall pipe %s", __func__, pipepath); - fd = open(pipepath, O_RDWR, 0); - if (fd < 0) { - xlog(D_GENERAL, "%s: open of %s failed: %m", __func__, pipepath); - return -errno; - } - - ev = event_new(evbase, fd, EV_READ, cldcb, clnt); - if (ev == NULL) { - xlog(D_GENERAL, "%s: failed to create event for %s", __func__, pipepath); - close(fd); - return -ENOMEM; - } - - if (clnt->cl_event && event_initialized(clnt->cl_event)) { - event_del(clnt->cl_event); - event_free(clnt->cl_event); - } - if (clnt->cl_fd >= 0) - close(clnt->cl_fd); - - clnt->cl_fd = fd; - clnt->cl_event = ev; - /* event_add is done by the caller */ - return 0; -} - -static void -cld_inotify_cb(int UNUSED(fd), short which, void *data) -{ - int ret; - size_t elen; - ssize_t rret; - char evbuf[INOTIFY_EVENT_MAX]; - char *dirc = NULL, *pname; - struct inotify_event *event = (struct inotify_event *)evbuf; - struct cld_client *clnt = data; - - if (which != EV_READ) - return; - - xlog(D_GENERAL, "%s: called for EV_READ", __func__); - - dirc = strndup(pipepath, PATH_MAX); - if (!dirc) { - xlog(L_ERROR, "%s: unable to allocate memory", __func__); - goto out; - } - - rret = read(inotify_fd, evbuf, INOTIFY_EVENT_MAX); - if (rret < 0) { - xlog(L_ERROR, "%s: read from inotify fd failed: %m", __func__); - goto out; - } - - /* check to see if we have a filename in the evbuf */ - if (!event->len) { - xlog(D_GENERAL, "%s: no filename in inotify event", __func__); - goto out; - } - - pname = basename(dirc); - elen = strnlen(event->name, event->len); - - /* does the filename match our pipe? */ - if (strlen(pname) != elen || memcmp(pname, event->name, elen)) { - xlog(D_GENERAL, "%s: wrong filename (%s)", __func__, - event->name); - goto out; - } - - ret = cld_pipe_open(clnt); - switch (ret) { - case 0: - /* readd the event for the cl_event pipe */ - event_add(clnt->cl_event, NULL); - break; - case -ENOENT: - /* pipe must have disappeared, wait for it to come back */ - goto out; - default: - /* anything else is fatal */ - xlog(L_FATAL, "%s: unable to open new pipe (%d). Aborting.", - __func__, ret); - exit(ret); - } - -out: - event_add(pipedir_event, NULL); - free(dirc); -} - -static int -cld_inotify_setup(void) -{ - int ret; - char *dirc, *dname; - - dirc = strndup(pipepath, PATH_MAX); - if (!dirc) { - xlog_err("%s: unable to allocate memory", __func__); - ret = -ENOMEM; - goto out_free; - } - - dname = dirname(dirc); - - inotify_fd = inotify_init(); - if (inotify_fd < 0) { - xlog_err("%s: inotify_init failed: %m", __func__); - ret = -errno; - goto out_free; - } - - ret = inotify_add_watch(inotify_fd, dname, IN_CREATE); - if (ret < 0) { - xlog_err("%s: inotify_add_watch failed: %m", __func__); - ret = -errno; - goto out_err; - } else - ret = 0; - -out_free: - free(dirc); - return ret; -out_err: - close(inotify_fd); - goto out_free; -} - -/* - * Set an inotify watch on the directory that should contain the pipe, and then - * try to open it. If it fails with anything but -ENOENT, return the error - * immediately. - * - * If it succeeds, then set up the pipe event handler. At that point, set up - * the inotify event handler and go ahead and return success. - */ -static int -cld_pipe_init(struct cld_client *clnt) -{ - int ret; - - xlog(D_GENERAL, "%s: init pipe handlers", __func__); - - ret = cld_inotify_setup(); - if (ret != 0) - goto out; - - clnt->cl_fd = -1; - ret = cld_pipe_open(clnt); - switch (ret) { - case 0: - /* add the event and we're good to go */ - event_add(clnt->cl_event, NULL); - break; - case -ENOENT: - /* ignore this error -- cld_inotify_cb will handle it */ - ret = 0; - break; - default: - /* anything else is fatal */ - close(inotify_fd); - goto out; - } - - /* set event for inotify read */ - pipedir_event = event_new(evbase, inotify_fd, EV_READ, cld_inotify_cb, clnt); - if (pipedir_event == NULL) { - close(inotify_fd); - return -ENOMEM; - } - event_add(pipedir_event, NULL); -out: - return ret; -} - -/* - * Older kernels will not tell nfsdcld when a grace period has started. - * Therefore we have to peek at the /proc/fs/nfsd/v4_end_grace file to - * see if nfsd is in grace. We have to do this for create and remove - * upcalls to ensure that the correct table is being updated - otherwise - * we could lose client records when the grace period is lifted. - */ -static int -cld_check_grace_period(void) -{ - int fd, ret = 0; - char c; - - if (!old_kernel) - return 0; - if (recovery_epoch != 0) - return 0; - fd = open(NFSD_END_GRACE_FILE, O_RDONLY); - if (fd < 0) { - xlog(L_WARNING, "Unable to open %s: %m", - NFSD_END_GRACE_FILE); - return 1; - } - if (read(fd, &c, 1) < 0) { - xlog(L_WARNING, "Unable to read from %s: %m", - NFSD_END_GRACE_FILE); - close(fd); - return 1; - } - close(fd); - if (c == 'N') { - xlog(L_WARNING, "nfsd is in grace but didn't send a gracestart upcall, " - "please update the kernel"); - ret = sqlite_grace_start(); - } - return ret; -} - -#if UPCALL_VERSION >= 2 -static ssize_t cld_message_size(void *msg) -{ - struct cld_msg_hdr *hdr = (struct cld_msg_hdr *)msg; - - switch (hdr->cm_vers) { - case 1: - return sizeof(struct cld_msg); - case 2: - return sizeof(struct cld_msg_v2); - default: - xlog(L_FATAL, "%s invalid upcall version %d", __func__, - hdr->cm_vers); - exit(-EINVAL); - } -} -#else -static ssize_t cld_message_size(void *UNUSED(msg)) -{ - return sizeof(struct cld_msg); -} -#endif - -static void -cld_not_implemented(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - xlog(D_GENERAL, "%s: downcalling with not implemented error", __func__); - - /* set up reply */ - cmsg->cm_status = -EOPNOTSUPP; - - bsize = cld_message_size(cmsg); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - - /* reopen pipe, just to be sure */ - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", __func__, ret); - exit(ret); - } -} - -static void -cld_get_version(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - xlog(D_GENERAL, "%s: version = %u.", __func__, UPCALL_VERSION); - - cmsg->cm_u.cm_version = UPCALL_VERSION; - cmsg->cm_status = 0; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "Doing downcall with status %d", cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static void -cld_create(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - ret = cld_check_grace_period(); - if (ret) - goto reply; - - xlog(D_GENERAL, "%s: create client record.", __func__); - -#if UPCALL_VERSION >= 2 - if (cmsg->cm_vers >= 2) - ret = sqlite_insert_client_and_princhash( - cmsg->cm_u.cm_clntinfo.cc_name.cn_id, - cmsg->cm_u.cm_clntinfo.cc_name.cn_len, - cmsg->cm_u.cm_clntinfo.cc_princhash.cp_data, - cmsg->cm_u.cm_clntinfo.cc_princhash.cp_len); - else - ret = sqlite_insert_client(cmsg->cm_u.cm_name.cn_id, - cmsg->cm_u.cm_name.cn_len); -#else - ret = sqlite_insert_client(cmsg->cm_u.cm_name.cn_id, - cmsg->cm_u.cm_name.cn_len); -#endif - -reply: - cmsg->cm_status = ret ? -EREMOTEIO : ret; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "Doing downcall with status %d", cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static void -cld_remove(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - ret = cld_check_grace_period(); - if (ret) - goto reply; - - xlog(D_GENERAL, "%s: remove client record.", __func__); - - ret = sqlite_remove_client(cmsg->cm_u.cm_name.cn_id, - cmsg->cm_u.cm_name.cn_len); - -reply: - cmsg->cm_status = ret ? -EREMOTEIO : ret; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "%s: downcall with status %d", __func__, - cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static void -cld_check(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - /* - * If we get a check upcall at all, it means we're talking to an old - * kernel. Furthermore, if we're not in grace it means this is the - * first client to do a reclaim. Log a message and use - * sqlite_grace_start() to advance the epoch numbers. - */ - if (recovery_epoch == 0) { - xlog(D_GENERAL, "%s: received a check upcall, please update the kernel", - __func__); - ret = sqlite_grace_start(); - if (ret) - goto reply; - } - - xlog(D_GENERAL, "%s: check client record", __func__); - - ret = sqlite_check_client(cmsg->cm_u.cm_name.cn_id, - cmsg->cm_u.cm_name.cn_len); - -reply: - /* set up reply */ - cmsg->cm_status = ret ? -EACCES : ret; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "%s: downcall with status %d", __func__, - cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static void -cld_gracedone(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - /* - * If we got a "gracedone" upcall while we're not in grace, then - * 1) we must be talking to an old kernel - * 2) no clients attempted to reclaim - * In that case, log a message and use sqlite_grace_start() to - * advance the epoch numbers, and then proceed as normal. - */ - if (recovery_epoch == 0) { - xlog(D_GENERAL, "%s: received gracedone upcall " - "while not in grace, please update the kernel", - __func__); - ret = sqlite_grace_start(); - if (ret) - goto reply; - } - - xlog(D_GENERAL, "%s: grace done.", __func__); - - ret = sqlite_grace_done(); - - if (first_time) { - if (num_cltrack_records > 0) - sqlite_delete_cltrack_records(); - if (num_legacy_records > 0) - legacy_clear_recdir(); - sqlite_first_time_done(); - first_time = 0; - } - -reply: - /* set up reply: downcall with 0 status */ - cmsg->cm_status = ret ? -EREMOTEIO : ret; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "Doing downcall with status %d", cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static int -gracestart_callback(struct cld_client *clnt) { - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - cmsg->cm_status = -EINPROGRESS; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "Sending client %.*s", - cmsg->cm_u.cm_name.cn_len, cmsg->cm_u.cm_name.cn_id); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) - return -EIO; - return 0; -} - -static void -cld_gracestart(struct cld_client *clnt) -{ - int ret; - ssize_t bsize, wsize; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - xlog(D_GENERAL, "%s: updating grace epochs", __func__); - - ret = sqlite_grace_start(); - if (ret) - goto reply; - - xlog(D_GENERAL, "%s: sending client records to the kernel", __func__); - - ret = sqlite_iterate_recovery(&gracestart_callback, clnt); - -reply: - /* set up reply: downcall with 0 status */ - cmsg->cm_status = ret ? -EREMOTEIO : ret; - - bsize = cld_message_size(cmsg); - xlog(D_GENERAL, "Doing downcall with status %d", cmsg->cm_status); - wsize = atomicio((void *)write, clnt->cl_fd, cmsg, bsize); - if (wsize != bsize) { - xlog(L_ERROR, "%s: problem writing to cld pipe (%zd): %m", - __func__, wsize); - ret = cld_pipe_open(clnt); - if (ret) { - xlog(L_FATAL, "%s: unable to reopen pipe: %d", - __func__, ret); - exit(ret); - } - } -} - -static void -cldcb(int UNUSED(fd), short which, void *data) -{ - ssize_t len; - struct cld_client *clnt = data; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - if (which != EV_READ) - goto out; - - len = atomicio(read, clnt->cl_fd, cmsg, sizeof(*cmsg)); - if (len <= 0) { - xlog(L_ERROR, "%s: pipe read failed: %m", __func__); - cld_pipe_open(clnt); - goto out; - } - - if (cmsg->cm_vers > UPCALL_VERSION) { - xlog(L_ERROR, "%s: unsupported upcall version: %hu", - __func__, cmsg->cm_vers); - cld_pipe_open(clnt); - goto out; - } - - switch(cmsg->cm_cmd) { - case Cld_Create: - cld_create(clnt); - break; - case Cld_Remove: - cld_remove(clnt); - break; - case Cld_Check: - cld_check(clnt); - break; - case Cld_GraceDone: - cld_gracedone(clnt); - break; - case Cld_GraceStart: - cld_gracestart(clnt); - break; - case Cld_GetVersion: - cld_get_version(clnt); - break; - default: - xlog(L_WARNING, "%s: command %u is not yet implemented", - __func__, cmsg->cm_cmd); - cld_not_implemented(clnt); - } -out: - event_add(clnt->cl_event, NULL); -} - -int -main(int argc, char **argv) -{ - int arg; - int rc = 0; - bool foreground = false; - char *progname; - char *storagedir = CLD_DEFAULT_STORAGEDIR; - struct cld_client clnt; - char *s; - first_time = 0; - num_cltrack_records = 0; - num_legacy_records = 0; - - memset(&clnt, 0, sizeof(clnt)); - - progname = strdup(basename(argv[0])); - if (!progname) { - fprintf(stderr, "%s: unable to allocate memory.\n", argv[0]); - return 1; - } - - evbase = event_base_new(); - if (evbase == NULL) { - fprintf(stderr, "%s: unable to allocate event base.\n", argv[0]); - return 1; - } - xlog_syslog(0); - xlog_stderr(1); - - conf_init_file(NFS_CONFFILE); - s = conf_get_str("general", "pipefs-directory"); - if (s) - strlcpy(pipefs_dir, s, sizeof(pipefs_dir)); - s = conf_get_str("nfsdcld", "storagedir"); - if (s) - storagedir = s; - rc = conf_get_num("nfsdcld", "debug", 0); - if (rc > 0) - xlog_config(D_ALL, 1); - - /* process command-line options */ - while ((arg = getopt_long(argc, argv, "hdFp:s:", longopts, - NULL)) != EOF) { - switch (arg) { - case 'd': - xlog_config(D_ALL, 1); - break; - case 'F': - foreground = true; - break; - case 'p': - strlcpy(pipefs_dir, optarg, sizeof(pipefs_dir)); - break; - case 's': - storagedir = optarg; - break; - default: - usage(progname); - free(progname); - return 0; - } - } - - strlcpy(pipepath, pipefs_dir, sizeof(pipepath)); - strlcat(pipepath, DEFAULT_CLD_PATH, sizeof(pipepath)); - - xlog_open(progname); - if (!foreground) { - xlog_syslog(1); - xlog_stderr(0); - rc = daemon(0, 0); - if (rc) { - xlog(L_ERROR, "Unable to daemonize: %m"); - goto out; - } - } - - /* drop all capabilities */ - rc = cld_set_caps(); - if (rc) - goto out; - - /* - * now see if the storagedir is writable by root w/o CAP_DAC_OVERRIDE. - * If it isn't then give the user a warning but proceed as if - * everything is OK. If the DB has already been created, then - * everything might still work. If it doesn't exist at all, then - * assume that the maindb init will be able to create it. Fail on - * anything else. - */ - if (access(storagedir, W_OK) == -1) { - switch (errno) { - case EACCES: - xlog(L_WARNING, "Storage directory %s is not writable. " - "Should be owned by root and writable " - "by owner!", storagedir); - break; - case ENOENT: - /* ignore and assume that we can create dir as root */ - break; - default: - xlog(L_ERROR, "Unexpected error when checking access " - "on %s: %m", storagedir); - rc = -errno; - goto out; - } - } - - if (linux_version_code() < MAKE_VERSION(4, 20, 0)) - old_kernel = true; - - /* set up storage db */ - rc = sqlite_prepare_dbh(storagedir); - if (rc) { - xlog(L_ERROR, "Failed to open main database: %d", rc); - goto out; - } - - /* set up event handler */ - rc = cld_pipe_init(&clnt); - if (rc) - goto out; - - signal(SIGINT, sig_die); - signal(SIGTERM, sig_die); - - xlog(D_GENERAL, "%s: Starting event dispatch handler.", __func__); - rc = event_base_dispatch(evbase); - if (rc < 0) - xlog(L_ERROR, "%s: event_dispatch failed: %m", __func__); - -out: - if (clnt.cl_event) - event_free(clnt.cl_event); - if (clnt.cl_fd != -1) - close(clnt.cl_fd); - if (pipedir_event) - event_free(pipedir_event); - if (inotify_fd != -1) - close(inotify_fd); - - event_base_free(evbase); - sqlite_shutdown(); - - free(progname); - return rc; -} diff --git a/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.man b/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.man deleted file mode 100644 index 861f1c4..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/nfsdcld.man +++ /dev/null @@ -1,221 +0,0 @@ -.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "NFSDCLD 8" -.TH NFSDCLD 8 "2011-12-21" "" "" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -nfsdcld \- NFSv4 Client Tracking Daemon -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -nfsdcld [\-d] [\-F] [\-p path] [\-s stable storage dir] -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -nfsdcld is the NFSv4 client tracking daemon. It is not necessary to run -this daemon on machines that are not acting as NFSv4 servers. -.PP -When a network partition is combined with a server reboot, there are -edge conditions that can cause the server to grant lock reclaims when -other clients have taken conflicting locks in the interim. A more detailed -explanation of this issue is described in \s-1RFC\s0 3530, section 8.6.3. -.PP -In order to prevent these problems, the server must track a small amount -of per-client information on stable storage. This daemon provides the -userspace piece of that functionality. -.SH "OPTIONS" -.IX Header "OPTIONS" -.IP "\fB\-d\fR, \fB\-\-debug\fR" 4 -.IX Item "-d, --debug" -Enable debug level logging. -.IP "\fB\-F\fR, \fB\-\-foreground\fR" 4 -.IX Item "-F, --foreground" -Runs the daemon in the foreground and prints all output to stderr -.IP "\fB\-p\fR \fIpath\fR, \fB\-\-pipefsdir\fR=\fIpath\fR" 4 -.IX Item "-p path, --pipefsdir=path" -Location of the rpc_pipefs filesystem. The default value is -\&\fI/var/lib/nfs/rpc_pipefs\fR. -.IP "\fB\-s\fR \fIstorage_dir\fR, \fB\-\-storagedir\fR=\fIstorage_dir\fR" 4 -.IX Item "-s storagedir, --storagedir=storage_dir" -Directory where stable storage information should be kept. The default -value is \fI/var/lib/nfs/nfsdcld\fR. -.SH "CONFIGURATION FILE" -.IX Header "CONFIGURATION FILE" -The following values are recognized in the \fB[nfsdcld]\fR section -of the \fI/etc/nfs.conf\fR configuration file: -.IP "\fBstoragedir\fR" 4 -.IX Item "storagedir" -Equivalent to \fB\-s\fR/\fB\-\-storagedir\fR. -.IP "\fBdebug\fR" 4 -.IX Item "debug" -Setting "debug = 1" is equivalent to \fB\-d\fR/\fB\-\-debug\fR. -.LP -In addition, the following value is recognized from the \fB[general]\fR section: -.IP "\fBpipefs\-directory\fR" 4 -.IX Item "pipefs-directory" -Equivalent to \fB\-p\fR/\fB\-\-pipefsdir\fR. -.SH "NOTES" -.IX Header "NOTES" -The Linux kernel NFSv4 server has historically tracked this information -on stable storage by manipulating information on the filesystem -directly, in the directory to which \fI/proc/fs/nfsd/nfsv4recoverydir\fR -points. -.PP -This changed with the original introduction of \fBnfsdcld\fR upcall in kernel version 3.4, -which was later deprecated in favor of the \fBnfsdcltrack\fR(8) usermodehelper -program, support for which was added in kernel version 3.8. However, since the -usermodehelper upcall does not work in containers, support for a new version of -the \fBnfsdcld\fR upcall was added in kernel version 5.2. -.PP -This daemon requires a kernel that supports the \fBnfsdcld\fR upcall. On older kernels, if -the legacy client name tracking code was in use, then the kernel would not create the -pipe that \fBnfsdcld\fR uses to talk to the kernel. On newer kernels, nfsd attempts to -initialize client tracking in the following order: First, the \fBnfsdcld\fR upcall. Second, -the \fBnfsdcltrack\fR usermodehelper upcall. Finally, the legacy client tracking. -.PP -This daemon should be run as root, as the pipe that it uses to communicate -with the kernel is only accessable by root. The daemon however does drop all -superuser capabilities after starting. Because of this, the \fIstoragedir\fR -should be owned by root, and be readable and writable by owner. -.PP -The daemon now supports different upcall versions to allow the kernel to pass additional -data to be stored in the on-disk database. The kernel will query the supported upcall -version from \fBnfsdcld\fR during client tracking initialization. A restart of \fBnfsd\fR is -not necessary after upgrading \fBnfsdcld\fR, however \fBnfsd\fR will not use a later upcall -version until restart. A restart of \fBnfsd is necessary\fR after downgrading \fBnfsdcld\fR, -to ensure that \fBnfsd\fR does not use an upcall version that \fBnfsdcld\fR does not support. -Additionally, a downgrade of \fBnfsdcld\fR requires the schema of the on-disk database to -be downgraded as well. That can be accomplished using the \fBnfsdclddb\fR(8) utility. -.SH FILES -.TP -.B /var/lib/nfs/nfsdcld/main.sqlite -.SH SEE ALSO -.BR nfsdcltrack "(8), " nfsdclddb (8) -.SH "AUTHORS" -.IX Header "AUTHORS" -The nfsdcld daemon was developed by Jeff Layton -with modifications from Scott Mayhew . diff --git a/nfs-utils-2.5.2/utils/nfsdcld/sqlite.c b/nfs-utils-2.5.2/utils/nfsdcld/sqlite.c deleted file mode 100644 index 03016fb..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/sqlite.c +++ /dev/null @@ -1,1427 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Explanation: - * - * This file contains the code to manage the sqlite backend database for the - * nfsdcld client tracking daemon. - * - * The main database is called main.sqlite and contains the following tables: - * - * parameters: simple key/value pairs for storing database info - * - * grace: a "current" column containing an INTEGER representing the current - * epoch (where should new values be stored) and a "recovery" column - * containing an INTEGER representing the recovery epoch (from what - * epoch are we allowed to recover). A recovery epoch of 0 means - * normal operation (grace period not in force). Note: sqlite stores - * integers as signed values, so these must be cast to a uint64_t when - * retrieving them from the database and back to an int64_t when storing - * them in the database. - * - * rec-CCCCCCCCCCCCCCCC (where C is the hex representation of the epoch value): - * an "id" column containing a BLOB with the long-form clientid - * as sent by the client, and a "princhash" column containing a BLOB - * with the sha256 hash of the kerberos principal (if available). - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "sqlite.h" -#include "cld.h" -#include "cld-internal.h" -#include "conffile.h" -#include "legacy.h" -#include "nfslib.h" - -#define CLD_SQLITE_LATEST_SCHEMA_VERSION 4 -#define CLTRACK_DEFAULT_STORAGEDIR NFS_STATEDIR "/nfsdcltrack" - -/* in milliseconds */ -#define CLD_SQLITE_BUSY_TIMEOUT 10000 - -/* private data structures */ - -/* global variables */ -static char *cltrack_storagedir = CLTRACK_DEFAULT_STORAGEDIR; - -/* reusable pathname and sql command buffer */ -static char buf[PATH_MAX]; - -/* global database handle */ -static sqlite3 *dbh; - -/* forward declarations */ - -/* make a directory, ignoring EEXIST errors unless it's not a directory */ -static int -mkdir_if_not_exist(const char *dirname) -{ - int ret; - struct stat statbuf; - - ret = mkdir(dirname, S_IRWXU); - if (ret && errno != EEXIST) - return -errno; - - ret = stat(dirname, &statbuf); - if (ret) - return -errno; - - if (!S_ISDIR(statbuf.st_mode)) - ret = -ENOTDIR; - - return ret; -} - -static int -sqlite_query_schema_version(void) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - /* prepare select query */ - ret = sqlite3_prepare_v2(dbh, - "SELECT value FROM parameters WHERE key == \"version\";", - -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(D_GENERAL, "Unable to prepare select statement: %s", - sqlite3_errmsg(dbh)); - ret = 0; - goto out; - } - - /* query schema version */ - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(D_GENERAL, "Select statement execution failed: %s", - sqlite3_errmsg(dbh)); - ret = 0; - goto out; - } - - ret = sqlite3_column_int(stmt, 0); -out: - sqlite3_finalize(stmt); - return ret; -} - -static int -sqlite_query_first_time(int *first_time) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - /* prepare select query */ - ret = sqlite3_prepare_v2(dbh, - "SELECT value FROM parameters WHERE key == \"first_time\";", - -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(D_GENERAL, "Unable to prepare select statement: %s", - sqlite3_errmsg(dbh)); - goto out; - } - - /* query first_time */ - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(D_GENERAL, "Select statement execution failed: %s", - sqlite3_errmsg(dbh)); - goto out; - } - - *first_time = sqlite3_column_int(stmt, 0); - ret = 0; -out: - sqlite3_finalize(stmt); - return ret; -} - -static int -sqlite_add_princ_col_cb(void *UNUSED(arg), int ncols, char **cols, - char **UNUSED(colnames)) -{ - int ret; - char *err; - - if (ncols > 1) - return -EINVAL; - ret = snprintf(buf, sizeof(buf), "ALTER TABLE \"%s\" " - "ADD COLUMN princhash BLOB;", cols[0]); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return -EINVAL; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to add princhash column to table %s: %s", - cols[0], err); - goto out; - } - xlog(D_GENERAL, "Added princhash column to table %s", cols[0]); -out: - sqlite3_free(err); - return ret; -} - -static int -sqlite_maindb_update_v3_to_v4(void) -{ - int ret; - char *err; - - ret = sqlite3_exec(dbh, "SELECT name FROM sqlite_master " - "WHERE type=\"table\" AND name LIKE \"%rec-%\";", - sqlite_add_princ_col_cb, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: Failed to update tables!: %s", __func__, err); - } - sqlite3_free(err); - return ret; -} - -static int -sqlite_maindb_update_v1v2_to_v4(void) -{ - int ret; - char *err; - - /* create grace table */ - ret = sqlite3_exec(dbh, "CREATE TABLE grace " - "(current INTEGER , recovery INTEGER);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create grace table: %s", err); - goto out; - } - - /* insert initial epochs into grace table */ - ret = sqlite3_exec(dbh, "INSERT OR FAIL INTO grace " - "values (1, 0);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to set initial epochs: %s", err); - goto out; - } - - /* create recovery table for current epoch */ - ret = sqlite3_exec(dbh, "CREATE TABLE \"rec-0000000000000001\" " - "(id BLOB PRIMARY KEY, princhash BLOB);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create recovery table " - "for current epoch: %s", err); - goto out; - } - - /* copy records from old clients table */ - ret = sqlite3_exec(dbh, "INSERT INTO \"rec-0000000000000001\" (id) " - "SELECT id FROM clients;", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to copy client records: %s", err); - goto out; - } - - /* drop the old clients table */ - ret = sqlite3_exec(dbh, "DROP TABLE clients;", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to drop old clients table: %s", err); - } -out: - sqlite3_free(err); - return ret; -} - -static int -sqlite_maindb_update_schema(int oldversion) -{ - int ret, ret2; - char *err; - - /* begin transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - - /* - * Check schema version again. This time, under an exclusive - * transaction to guard against racing DB setup attempts - */ - ret = sqlite_query_schema_version(); - if (ret != oldversion) { - if (ret == CLD_SQLITE_LATEST_SCHEMA_VERSION) - /* Someone else raced in and set it up */ - ret = 0; - else - /* Something went wrong -- fail! */ - ret = -EINVAL; - goto rollback; - } - - /* Still at old version -- do conversion */ - - switch (oldversion) { - case 3: - case 2: - ret = sqlite_maindb_update_v3_to_v4(); - break; - case 1: - ret = sqlite_maindb_update_v1v2_to_v4(); - break; - default: - ret = -EINVAL; - } - if (ret != SQLITE_OK) - goto rollback; - - ret = snprintf(buf, sizeof(buf), "UPDATE parameters SET value = %d " - "WHERE key = \"version\";", - CLD_SQLITE_LATEST_SCHEMA_VERSION); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to update schema version: %s", err); - goto rollback; - } - - ret = sqlite_query_first_time(&first_time); - if (ret != SQLITE_OK) { - /* insert first_time into parameters table */ - ret = sqlite3_exec(dbh, "INSERT OR FAIL INTO parameters " - "values (\"first_time\", \"1\");", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to insert into parameter table: %s", err); - goto rollback; - } - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } -out: - sqlite3_free(err); - return ret; -rollback: - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - -/* - * Start an exclusive transaction and recheck the DB schema version. If it's - * still zero (indicating a new database) then set it up. If that all works, - * then insert schema version into the parameters table and commit the - * transaction. On any error, rollback the transaction. - */ -static int -sqlite_maindb_init_v4(void) -{ - int ret, ret2; - char *err = NULL; - - /* Start a transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto out; - } - - /* - * Check schema version again. This time, under an exclusive - * transaction to guard against racing DB setup attempts - */ - ret = sqlite_query_schema_version(); - switch (ret) { - case 0: - /* Query failed again -- set up DB */ - break; - case CLD_SQLITE_LATEST_SCHEMA_VERSION: - /* Someone else raced in and set it up */ - ret = 0; - goto rollback; - default: - /* Something went wrong -- fail! */ - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, "CREATE TABLE parameters " - "(key TEXT PRIMARY KEY, value TEXT);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create parameter table: %s", err); - goto rollback; - } - - /* create grace table */ - ret = sqlite3_exec(dbh, "CREATE TABLE grace " - "(current INTEGER , recovery INTEGER);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create grace table: %s", err); - goto rollback; - } - - /* insert initial epochs into grace table */ - ret = sqlite3_exec(dbh, "INSERT OR FAIL INTO grace " - "values (1, 0);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to set initial epochs: %s", err); - goto rollback; - } - - /* create recovery table for current epoch */ - ret = sqlite3_exec(dbh, "CREATE TABLE \"rec-0000000000000001\" " - "(id BLOB PRIMARY KEY, princhash BLOB);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create recovery table " - "for current epoch: %s", err); - goto rollback; - } - - /* insert version into parameters table */ - ret = snprintf(buf, sizeof(buf), "INSERT OR FAIL INTO parameters " - "values (\"version\", \"%d\");", - CLD_SQLITE_LATEST_SCHEMA_VERSION); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to insert into parameter table: %s", err); - goto rollback; - } - - /* insert first_time into parameters table */ - ret = sqlite3_exec(dbh, "INSERT OR FAIL INTO parameters " - "values (\"first_time\", \"1\");", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to insert into parameter table: %s", err); - goto rollback; - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } -out: - sqlite3_free(err); - return ret; - -rollback: - /* Attempt to rollback the transaction */ - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - -static int -sqlite_startup_query_grace(void) -{ - int ret; - uint64_t tcur; - uint64_t trec; - sqlite3_stmt *stmt = NULL; - - /* prepare select query */ - ret = sqlite3_prepare_v2(dbh, "SELECT * FROM grace;", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(D_GENERAL, "Unable to prepare select statement: %s", - sqlite3_errmsg(dbh)); - goto out; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(D_GENERAL, "Select statement execution failed: %s", - sqlite3_errmsg(dbh)); - goto out; - } - - tcur = (uint64_t)sqlite3_column_int64(stmt, 0); - trec = (uint64_t)sqlite3_column_int64(stmt, 1); - - current_epoch = tcur; - recovery_epoch = trec; - ret = 0; - xlog(D_GENERAL, "%s: current_epoch=%"PRIu64" recovery_epoch=%"PRIu64, - __func__, current_epoch, recovery_epoch); -out: - sqlite3_finalize(stmt); - return ret; -} - -/* - * Helper for renaming a recovery table to fix the padding. - */ -static int -sqlite_fix_table_name(const char *name) -{ - int ret; - uint64_t val; - char *err; - - if (sscanf(name, "rec-%" PRIx64, &val) != 1) - return -EINVAL; - ret = snprintf(buf, sizeof(buf), "ALTER TABLE \"%s\" " - "RENAME TO \"rec-%016" PRIx64 "\";", - name, val); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return -EINVAL; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to fix table for epoch %"PRIu64": %s", - val, err); - goto out; - } - xlog(D_GENERAL, "Renamed table %s to rec-%016" PRIx64, name, val); -out: - sqlite3_free(err); - return ret; -} - -/* - * Callback for the sqlite_exec statement in sqlite_check_table_names. - * If the epoch encoded in the table name matches either the current - * epoch or the recovery epoch, then try to fix the padding. Otherwise, - * we bail. - */ -static int -sqlite_check_table_names_cb(void *UNUSED(arg), int ncols, char **cols, - char **UNUSED(colnames)) -{ - int ret = SQLITE_OK; - uint64_t val; - - if (ncols > 1) - return -EINVAL; - if (sscanf(cols[0], "rec-%" PRIx64, &val) != 1) - return -EINVAL; - if (val == current_epoch || val == recovery_epoch) { - xlog(D_GENERAL, "found invalid table name %s for %s epoch", - cols[0], val == current_epoch ? "current" : "recovery"); - ret = sqlite_fix_table_name(cols[0]); - } else { - xlog(L_ERROR, "found invalid table name %s for unknown epoch %" - PRId64, cols[0], val); - return -EINVAL; - } - return ret; -} - -/* - * Look for recovery table names where the epoch isn't zero-padded - */ -static int -sqlite_check_table_names(void) -{ - int ret; - char *err; - - ret = sqlite3_exec(dbh, "SELECT name FROM sqlite_master " - "WHERE type=\"table\" AND name LIKE \"%rec-%\" " - "AND length(name) < 20;", - sqlite_check_table_names_cb, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Table names check failed: %s", err); - } - sqlite3_free(err); - return ret; -} - -/* - * Simple db health check. For now we're just making sure that the recovery - * table names are of the format "rec-CCCCCCCCCCCCCCCC" (where C is the hex - * representation of the epoch value) and that epoch value matches either - * the current epoch or the recovery epoch. - */ -static int -sqlite_check_db_health(void) -{ - int ret, ret2; - char *err; - - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - - ret = sqlite_check_table_names(); - if (ret != SQLITE_OK) - goto rollback; - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } - -cleanup: - sqlite3_free(err); - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - return ret; -rollback: - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto cleanup; -} - -static int -sqlite_attach_db(const char *path) -{ - int ret; - char dbpath[PATH_MAX]; - struct stat stb; - sqlite3_stmt *stmt = NULL; - - ret = snprintf(dbpath, PATH_MAX - 1, "%s/main.sqlite", path); - if (ret < 0) - return ret; - - dbpath[PATH_MAX - 1] = '\0'; - ret = stat(dbpath, &stb); - if (ret < 0) - return ret; - - xlog(D_GENERAL, "attaching %s", dbpath); - ret = sqlite3_prepare_v2(dbh, "ATTACH DATABASE ? AS attached;", - -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: unable to prepare attach statement: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_text(stmt, 1, dbpath, strlen(dbpath), SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind text failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from attach: %s", - __func__, sqlite3_errmsg(dbh)); - - sqlite3_finalize(stmt); - stmt = NULL; - return ret; -} - -static int -sqlite_detach_db(void) -{ - int ret; - char *err = NULL; - - xlog(D_GENERAL, "detaching database"); - ret = sqlite3_exec(dbh, "DETACH DATABASE attached;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to detach attached db: %s", err); - } - - sqlite3_free(err); - return ret; -} - -/* - * Copies client records from the nfsdcltrack database as part of a one-time - * "upgrade". - * - * Returns a non-zero sqlite error code, or SQLITE_OK (aka 0). - * Returns the number of records copied via "num_rec". - */ -static int -sqlite_copy_cltrack_records(int *num_rec) -{ - int ret, ret2; - char *s; - char *err = NULL; - sqlite3_stmt *stmt = NULL; - - s = conf_get_str("nfsdcltrack", "storagedir"); - if (s) - cltrack_storagedir = s; - ret = sqlite_attach_db(cltrack_storagedir); - if (ret) - goto out; - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - ret = snprintf(buf, sizeof(buf), "DELETE FROM \"rec-%016" PRIx64 "\";", - current_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to clear records from current epoch: %s", err); - goto rollback; - } - ret = snprintf(buf, sizeof(buf), "INSERT INTO \"rec-%016" PRIx64 "\" (id) " - "SELECT id FROM attached.clients;", - current_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: insert statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto rollback; - } - ret = sqlite3_step(stmt); - if (ret != SQLITE_DONE) { - xlog(L_ERROR, "%s: unexpected return code from insert: %s", - __func__, sqlite3_errmsg(dbh)); - goto rollback; - } - *num_rec = sqlite3_changes(dbh); - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } -cleanup: - sqlite3_finalize(stmt); - sqlite3_free(err); - sqlite_detach_db(); -out: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - return ret; -rollback: - *num_rec = 0; - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto cleanup; -} - -/* Open the database and set up the database handle for it */ -int -sqlite_prepare_dbh(const char *topdir) -{ - int ret; - - /* Do nothing if the database handle is already set up */ - if (dbh) - return 0; - - ret = snprintf(buf, PATH_MAX - 1, "%s/main.sqlite", topdir); - if (ret < 0) - return ret; - - buf[PATH_MAX - 1] = '\0'; - - /* open a new DB handle */ - ret = sqlite3_open(buf, &dbh); - if (ret != SQLITE_OK) { - /* try to create the dir */ - ret = mkdir_if_not_exist(topdir); - if (ret) - goto out_close; - - /* retry open */ - ret = sqlite3_open(buf, &dbh); - if (ret != SQLITE_OK) - goto out_close; - } - - /* set busy timeout */ - ret = sqlite3_busy_timeout(dbh, CLD_SQLITE_BUSY_TIMEOUT); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to set sqlite busy timeout: %s", - sqlite3_errmsg(dbh)); - goto out_close; - } - - ret = sqlite_query_schema_version(); - switch (ret) { - case CLD_SQLITE_LATEST_SCHEMA_VERSION: - /* DB is already set up. Do nothing */ - break; - case 3: - /* Old DB -- update to new schema */ - ret = sqlite_maindb_update_schema(3); - if (ret) - goto out_close; - break; - case 2: - /* Old DB -- update to new schema */ - ret = sqlite_maindb_update_schema(2); - if (ret) - goto out_close; - break; - - case 1: - /* Old DB -- update to new schema */ - ret = sqlite_maindb_update_schema(1); - if (ret) - goto out_close; - break; - case 0: - /* Query failed -- try to set up new DB */ - ret = sqlite_maindb_init_v4(); - if (ret) - goto out_close; - break; - default: - /* Unknown DB version -- downgrade? Fail */ - xlog(L_ERROR, "Unsupported database schema version! " - "Expected %d, got %d.", - CLD_SQLITE_LATEST_SCHEMA_VERSION, ret); - ret = -EINVAL; - goto out_close; - } - - ret = sqlite_startup_query_grace(); - if (ret) - goto out_close; - - ret = sqlite_query_first_time(&first_time); - if (ret) - goto out_close; - - ret = sqlite_check_db_health(); - if (ret) { - xlog(L_ERROR, "Database health check failed! " - "Database must be fixed manually."); - goto out_close; - } - - /* one-time "upgrade" from older client tracking methods */ - if (first_time) { - sqlite_copy_cltrack_records(&num_cltrack_records); - xlog(D_GENERAL, "%s: num_cltrack_records = %d\n", - __func__, num_cltrack_records); - legacy_load_clients_from_recdir(&num_legacy_records); - xlog(D_GENERAL, "%s: num_legacy_records = %d\n", - __func__, num_legacy_records); - if (num_cltrack_records > 0 && num_legacy_records > 0) - xlog(L_WARNING, "%s: first-time upgrade detected " - "both cltrack and legacy records!\n", __func__); - } - - return ret; -out_close: - sqlite3_close(dbh); - dbh = NULL; - return ret; -} - -/* - * Create a client record - * - * Returns a non-zero sqlite error code, or SQLITE_OK (aka 0) - */ -int -sqlite_insert_client(const unsigned char *clname, const size_t namelen) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = snprintf(buf, sizeof(buf), "INSERT OR REPLACE INTO \"rec-%016" PRIx64 "\" (id) " - "VALUES (?);", current_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: insert statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from insert: %s", - __func__, sqlite3_errmsg(dbh)); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -#if UPCALL_VERSION >= 2 -/* - * Create a client record including hash the kerberos principal - * - * Returns a non-zero sqlite error code, or SQLITE_OK (aka 0) - */ -int -sqlite_insert_client_and_princhash(const unsigned char *clname, const size_t namelen, - const unsigned char *clprinchash, const size_t princhashlen) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - if (princhashlen > 0) - ret = snprintf(buf, sizeof(buf), "INSERT OR REPLACE INTO \"rec-%016" PRIx64 "\" " - "VALUES (?, ?);", current_epoch); - else - ret = snprintf(buf, sizeof(buf), "INSERT OR REPLACE INTO \"rec-%016" PRIx64 "\" (id) " - "VALUES (?);", current_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: insert statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - if (princhashlen > 0) { - ret = sqlite3_bind_blob(stmt, 2, (const void *)clprinchash, princhashlen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from insert: %s", - __func__, sqlite3_errmsg(dbh)); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} -#else -int -sqlite_insert_client_and_princhash(const unsigned char *clname, const size_t namelen, - const unsigned char *clprinchash, const size_t princhashlen) -{ - return -EINVAL; -} -#endif - -/* Remove a client record */ -int -sqlite_remove_client(const unsigned char *clname, const size_t namelen) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = snprintf(buf, sizeof(buf), "DELETE FROM \"rec-%016" PRIx64 "\" " - "WHERE id==?;", current_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from delete: %d", - __func__, ret); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -/* - * Is the given clname in the clients table? If so, then update its timestamp - * and return success. If the record isn't present, or the update fails, then - * return an error. - */ -int -sqlite_check_client(const unsigned char *clname, const size_t namelen) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = snprintf(buf, sizeof(buf), "SELECT count(*) FROM \"rec-%016" PRIx64 "\" " - "WHERE id==?;", recovery_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: select statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(L_ERROR, "%s: unexpected return code from select: %d", - __func__, ret); - goto out_err; - } - - ret = sqlite3_column_int(stmt, 0); - xlog(D_GENERAL, "%s: select returned %d rows", __func__, ret); - if (ret != 1) { - ret = -EACCES; - goto out_err; - } - - sqlite3_finalize(stmt); - - /* Now insert the client into the table for the current epoch */ - return sqlite_insert_client(clname, namelen); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -int -sqlite_grace_start(void) -{ - int ret, ret2; - char *err; - uint64_t tcur = current_epoch; - uint64_t trec = recovery_epoch; - - /* begin transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - - if (trec == 0) { - /* - * A normal grace start - update the epoch values in the grace - * table and create a new table for the current reboot epoch. - */ - trec = tcur; - tcur++; - - ret = snprintf(buf, sizeof(buf), "UPDATE grace " - "SET current = %" PRId64 ", recovery = %" PRId64 ";", - (int64_t)tcur, (int64_t)trec); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", - ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to update epochs: %s", err); - goto rollback; - } - - ret = snprintf(buf, sizeof(buf), "CREATE TABLE \"rec-%016" PRIx64 "\" " - "(id BLOB PRIMARY KEY, princhash blob);", - tcur); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", - ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create table for current epoch: %s", - err); - goto rollback; - } - } else { - /* Server restarted while in grace - don't update the epoch - * values in the grace table, just clear out the records for - * the current reboot epoch. - */ - ret = snprintf(buf, sizeof(buf), "DELETE FROM \"rec-%016" PRIx64 "\";", - tcur); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to clear table for current epoch: %s", - err); - goto rollback; - } - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } - - current_epoch = tcur; - recovery_epoch = trec; - xlog(D_GENERAL, "%s: current_epoch=%"PRIu64" recovery_epoch=%"PRIu64, - __func__, current_epoch, recovery_epoch); - -out: - sqlite3_free(err); - return ret; -rollback: - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - -int -sqlite_grace_done(void) -{ - int ret, ret2; - char *err; - - /* begin transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - - ret = sqlite3_exec(dbh, "UPDATE grace SET recovery = \"0\";", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to clear recovery epoch: %s", err); - goto rollback; - } - - ret = snprintf(buf, sizeof(buf), "DROP TABLE \"rec-%016" PRIx64 "\";", - recovery_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to drop table for recovery epoch: %s", - err); - goto rollback; - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } - - recovery_epoch = 0; - xlog(D_GENERAL, "%s: current_epoch=%"PRIu64" recovery_epoch=%"PRIu64, - __func__, current_epoch, recovery_epoch); - -out: - sqlite3_free(err); - return ret; -rollback: - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - - -int -sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *clnt) -{ - int ret; - sqlite3_stmt *stmt = NULL; -#if UPCALL_VERSION >= 2 - struct cld_msg_v2 *cmsg = &clnt->cl_u.cl_msg_v2; -#else - struct cld_msg *cmsg = &clnt->cl_u.cl_msg; -#endif - - if (recovery_epoch == 0) { - xlog(D_GENERAL, "%s: not in grace!", __func__); - return -EINVAL; - } - - ret = snprintf(buf, sizeof(buf), "SELECT * FROM \"rec-%016" PRIx64 "\";", - recovery_epoch); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(dbh, buf, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: select statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) { - const void *id; - int id_len; - - id = sqlite3_column_blob(stmt, 0); - id_len = sqlite3_column_bytes(stmt, 0); - if (id_len > NFS4_OPAQUE_LIMIT) - id_len = NFS4_OPAQUE_LIMIT; - - memset(&cmsg->cm_u, 0, sizeof(cmsg->cm_u)); -#if UPCALL_VERSION >= 2 - memcpy(&cmsg->cm_u.cm_clntinfo.cc_name.cn_id, id, id_len); - cmsg->cm_u.cm_clntinfo.cc_name.cn_len = id_len; - if (sqlite3_column_bytes(stmt, 1) > 0) { - memcpy(&cmsg->cm_u.cm_clntinfo.cc_princhash.cp_data, - sqlite3_column_blob(stmt, 1), SHA256_DIGEST_SIZE); - cmsg->cm_u.cm_clntinfo.cc_princhash.cp_len = sqlite3_column_bytes(stmt, 1); - } -#else - memcpy(&cmsg->cm_u.cm_name.cn_id, id, id_len); - cmsg->cm_u.cm_name.cn_len = id_len; -#endif - cb(clnt); - } - if (ret == SQLITE_DONE) - ret = 0; - sqlite3_finalize(stmt); - return ret; -} - -/* - * Cleans out the old nfsdcltrack database. - * - * Called upon receipt of the first "GraceDone" upcall only. - */ -int -sqlite_delete_cltrack_records(void) -{ - int ret; - char *s; - char *err = NULL; - - s = conf_get_str("nfsdcltrack", "storagedir"); - if (s) - cltrack_storagedir = s; - ret = sqlite_attach_db(cltrack_storagedir); - if (ret) - goto out; - ret = sqlite3_exec(dbh, "DELETE FROM attached.clients;", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to clear records from cltrack db: %s", - err); - } - sqlite_detach_db(); -out: - sqlite3_free(err); - return ret; -} - -/* - * Sets first_time to 0 in the parameters table to ensure we only - * copy old client tracking records into the database one time. - * - * Called upon receipt of the first "GraceDone" upcall only. - */ -int -sqlite_first_time_done(void) -{ - int ret; - char *err = NULL; - - ret = sqlite3_exec(dbh, "UPDATE parameters SET value = \"0\" " - "WHERE key = \"first_time\";", - NULL, NULL, &err); - if (ret != SQLITE_OK) - xlog(L_ERROR, "Unable to clear first_time: %s", err); - - sqlite3_free(err); - return ret; -} - -/* - * Closes all sqlite3 resources and shuts down the library. - * - */ -void -sqlite_shutdown(void) -{ - if (dbh != NULL) { - sqlite3_close(dbh); - dbh = NULL; - } - - sqlite3_shutdown(); -} diff --git a/nfs-utils-2.5.2/utils/nfsdcld/sqlite.h b/nfs-utils-2.5.2/utils/nfsdcld/sqlite.h deleted file mode 100644 index 044236c..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcld/sqlite.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _SQLITE_H_ -#define _SQLITE_H_ - -struct cld_client; - -int sqlite_prepare_dbh(const char *topdir); -int sqlite_insert_client(const unsigned char *clname, const size_t namelen); -int sqlite_insert_client_and_princhash(const unsigned char *clname, const size_t namelen, - const unsigned char *clprinchash, const size_t princhashlen); -int sqlite_remove_client(const unsigned char *clname, const size_t namelen); -int sqlite_check_client(const unsigned char *clname, const size_t namelen); -int sqlite_grace_start(void); -int sqlite_grace_done(void); -int sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *clnt); -int sqlite_delete_cltrack_records(void); -int sqlite_first_time_done(void); - -void sqlite_shutdown(void); -#endif /* _SQLITE_H */ diff --git a/nfs-utils-2.5.2/utils/nfsdcltrack/Makefile.am b/nfs-utils-2.5.2/utils/nfsdcltrack/Makefile.am deleted file mode 100644 index 2f7fe3d..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcltrack/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# These binaries go in /sbin (not /usr/sbin), and that cannot be -# overridden at config time. The kernel "knows" the /sbin name. -sbindir = /sbin - -man8_MANS = nfsdcltrack.man -EXTRA_DIST = $(man8_MANS) - -AM_CFLAGS += -D_LARGEFILE64_SOURCE -sbin_PROGRAMS = nfsdcltrack - -noinst_HEADERS = sqlite.h - -nfsdcltrack_SOURCES = nfsdcltrack.c sqlite.c -nfsdcltrack_LDADD = ../../support/nfs/libnfs.la $(LIBSQLITE) $(LIBCAP) - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.c b/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.c deleted file mode 100644 index b45a904..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * nfsdcltrack.c -- NFSv4 client name tracking program - * - * Copyright (C) 2012 Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_CAPABILITY_H -#include -#include -#endif - -#include "conffile.h" -#include "xlog.h" -#include "sqlite.h" - -#ifndef CLD_DEFAULT_STORAGEDIR -#define CLD_DEFAULT_STORAGEDIR NFS_STATEDIR "/nfsdcltrack" -#endif - -#define NFSD_END_GRACE_FILE "/proc/fs/nfsd/v4_end_grace" - -/* defined by RFC 3530 */ -#define NFS4_OPAQUE_LIMIT 1024 - -/* private data structures */ -struct cltrack_cmd { - char *name; - bool needs_arg; - int (*func)(const char *arg); -}; - -/* forward declarations */ -static int cltrack_init(const char *unused); -static int cltrack_create(const char *id); -static int cltrack_remove(const char *id); -static int cltrack_check(const char *id); -static int cltrack_gracedone(const char *gracetime); - -/* global variables */ -static struct option longopts[] = -{ - { "help", 0, NULL, 'h' }, - { "debug", 0, NULL, 'd' }, - { "foreground", 0, NULL, 'f' }, - { "storagedir", 1, NULL, 's' }, - { NULL, 0, 0, 0 }, -}; - -static struct cltrack_cmd commands[] = -{ - { "init", false, cltrack_init }, - { "create", true, cltrack_create }, - { "remove", true, cltrack_remove }, - { "check", true, cltrack_check }, - { "gracedone", true, cltrack_gracedone }, - { NULL, false, NULL }, -}; - -static char *storagedir = CLD_DEFAULT_STORAGEDIR; - -/* common buffer for holding id4 blobs */ -static unsigned char blob[NFS4_OPAQUE_LIMIT]; - -static void -usage(char *progname) -{ - printf("Usage: %s [ -hfd ] [ -s dir ] < cmd > < arg >\n", progname); - printf("Where < cmd > is one of the following and takes the following < arg >:\n"); - printf(" init\n"); - printf(" create \n"); - printf(" remove \n"); - printf(" check \n"); - printf(" gracedone \n"); -} - - -/** - * hex_to_bin - convert a hex digit to its real value - * @ch: ascii character represents hex digit - * - * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad - * input. - * - * Note: borrowed from lib/hexdump.c in the Linux kernel sources. - */ -static int -hex_to_bin(char ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - ch = tolower(ch); - if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - return -1; -} - -/** - * hex_str_to_bin - convert a hexidecimal string into a binary blob - * - * @src: string of hex digit pairs - * @dst: destination buffer to hold binary data - * @dstsize: size of the destination buffer - * - * Walk a string of hex digit pairs and convert them into binary data. Returns - * the resulting length of the binary data or a negative error code. If the - * data will not fit in the buffer, it returns -ENOBUFS (but will likely have - * clobbered the dst buffer in the process of determining that). If there are - * non-hexidecimal characters in the src, or an odd number of them then it - * returns -EINVAL. - */ -static ssize_t -hex_str_to_bin(const char *src, unsigned char *dst, ssize_t dstsize) -{ - unsigned char *tmpdst = dst; - - while (*src) { - int hi, lo; - - /* make sure we don't overrun the dst buffer */ - if ((tmpdst - dst) >= dstsize) - return -ENOBUFS; - - hi = hex_to_bin(*src++); - - /* did we get an odd number of characters? */ - if (!*src) - return -EINVAL; - lo = hex_to_bin(*src++); - - /* one of the characters isn't a hex digit */ - if (hi < 0 || lo < 0) - return -EINVAL; - - /* now place it in the dst buffer */ - *tmpdst++ = (hi << 4) | lo; - } - - return (ssize_t)(tmpdst - dst); -} - -/* - * This program will almost always be run with root privileges since the - * kernel will call out to run it. Drop all capabilities prior to doing - * anything important to limit the exposure to potential compromise. - * - * FIXME: should we setuid to a different user early on instead? - */ -static int -cltrack_set_caps(void) -{ - int ret = 0; -#ifdef HAVE_SYS_CAPABILITY_H - unsigned long i; - cap_t caps; - - /* prune the bounding set to nothing */ - for (i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0 ; ++i) { - ret = prctl(PR_CAPBSET_DROP, i, 0, 0, 0); - if (ret) { - xlog(L_ERROR, "Unable to prune capability %lu from " - "bounding set: %m", i); - return -errno; - } - } - - /* get a blank capset */ - caps = cap_init(); - if (caps == NULL) { - xlog(L_ERROR, "Unable to get blank capability set: %m"); - return -errno; - } - - /* reset the process capabilities */ - if (cap_set_proc(caps) != 0) { - xlog(L_ERROR, "Unable to set process capabilities: %m"); - ret = -errno; - } - cap_free(caps); -#endif - return ret; -} - -/* Inform the kernel that it's OK to lift nfsd's grace period */ -static void -cltrack_lift_grace_period(void) -{ - int fd; - - fd = open(NFSD_END_GRACE_FILE, O_WRONLY); - if (fd < 0) { - /* Don't warn if file isn't present */ - if (errno != ENOENT) - xlog(L_WARNING, "Unable to open %s: %m", - NFSD_END_GRACE_FILE); - return; - } - - if (write(fd, "Y", 1) < 0) - xlog(L_WARNING, "Unable to write to %s: %m", - NFSD_END_GRACE_FILE); - - close(fd); - return; -} - -/* - * Fetch the contents of the NFSDCLTRACK_GRACE_START env var. If it's not set - * or there's an error converting it to time_t, then return LONG_MAX. - */ -static time_t -cltrack_get_grace_start(void) -{ - time_t grace_start; - char *end; - char *grace_start_str = getenv("NFSDCLTRACK_GRACE_START"); - - if (!grace_start_str) - return LONG_MAX; - - errno = 0; - grace_start = strtol(grace_start_str, &end, 0); - /* Problem converting or value is too large? */ - if (errno) - return LONG_MAX; - - return grace_start; -} - -static bool -cltrack_reclaims_complete(void) -{ - time_t grace_start = cltrack_get_grace_start(); - - /* Don't query DB if we didn't get a valid boot time */ - if (grace_start == LONG_MAX) - return false; - - return !sqlite_query_reclaiming(grace_start); -} - -static int -cltrack_init(const char __attribute__((unused)) *unused) -{ - int ret; - - /* - * see if the storagedir is writable by root w/o CAP_DAC_OVERRIDE. - * If it isn't then give the user a warning but proceed as if - * everything is OK. If the DB has already been created, then - * everything might still work. If it doesn't exist at all, then - * assume that the maindb init will be able to create it. Fail on - * anything else. - */ - if (access(storagedir, W_OK) == -1) { - switch (errno) { - case EACCES: - xlog(L_WARNING, "Storage directory %s is not writable. " - "Should be owned by root and writable " - "by owner!", storagedir); - break; - case ENOENT: - /* ignore and assume that we can create dir as root */ - break; - default: - xlog(L_ERROR, "Unexpected error when checking access " - "on %s: %m", storagedir); - return -errno; - } - } - - /* set up storage db */ - ret = sqlite_prepare_dbh(storagedir); - if (ret) { - xlog(L_ERROR, "Failed to init database: %d", ret); - /* - * Convert any error here into -EACCES. It's not truly - * accurate in all cases, but it should cause the kernel to - * stop upcalling until the problem is resolved. - */ - ret = -EACCES; - } else { - if (cltrack_reclaims_complete()) - cltrack_lift_grace_period(); - } - - return ret; -} - -/* - * Fetch the contents of the NFSDCLTRACK_CLIENT_HAS_SESSION env var. If - * it's set and the first character is 'Y' then return true. Otherwise - * return false. - */ -static bool -cltrack_client_has_session(void) -{ - char *has_session = getenv("NFSDCLTRACK_CLIENT_HAS_SESSION"); - - if (has_session && *has_session == 'Y') - return true; - - return false; -} - -static int -cltrack_create(const char *id) -{ - int ret; - ssize_t len; - bool has_session; - - xlog(D_GENERAL, "%s: create client record.", __func__); - - ret = sqlite_prepare_dbh(storagedir); - if (ret) - return ret; - - len = hex_str_to_bin(id, blob, sizeof(blob)); - if (len < 0) - return (int)len; - - has_session = cltrack_client_has_session(); - - ret = sqlite_insert_client(blob, len, has_session, false); - - if (!ret && has_session && cltrack_reclaims_complete()) - cltrack_lift_grace_period(); - - return ret ? -EREMOTEIO : ret; -} - -static int -cltrack_remove(const char *id) -{ - int ret; - ssize_t len; - - xlog(D_GENERAL, "%s: remove client record.", __func__); - - ret = sqlite_prepare_dbh(storagedir); - if (ret) - return ret; - - len = hex_str_to_bin(id, blob, sizeof(blob)); - if (len < 0) - return (int)len; - - ret = sqlite_remove_client(blob, len); - - return ret ? -EREMOTEIO : ret; -} - -static int -cltrack_check_legacy(const unsigned char *blob, const ssize_t len, - bool has_session) -{ - int ret; - struct stat st; - char *recdir = getenv("NFSDCLTRACK_LEGACY_RECDIR"); - - if (!recdir) { - xlog(D_GENERAL, "No NFSDCLTRACK_LEGACY_RECDIR env var"); - return -EOPNOTSUPP; - } - - /* fail recovery on any stat failure */ - ret = stat(recdir, &st); - if (ret) { - xlog(D_GENERAL, "Unable to stat %s: %d", recdir, errno); - return -errno; - } - - /* fail if it isn't a directory */ - if (!S_ISDIR(st.st_mode)) { - xlog(D_GENERAL, "%s is not a directory: mode=0%o", recdir - , st.st_mode); - return -ENOTDIR; - } - - /* Dir exists, try to insert record into db */ - ret = sqlite_insert_client(blob, len, has_session, has_session); - if (ret) { - xlog(D_GENERAL, "Failed to insert client: %d", ret); - return -EREMOTEIO; - } - - /* remove the legacy recoverydir */ - ret = rmdir(recdir); - if (ret) { - xlog(D_GENERAL, "Failed to rmdir %s: %d", recdir, errno); - return -errno; - } - return 0; -} - -static int -cltrack_check(const char *id) -{ - int ret; - ssize_t len; - bool has_session; - - xlog(D_GENERAL, "%s: check client record", __func__); - - ret = sqlite_prepare_dbh(storagedir); - if (ret) - return ret; - - len = hex_str_to_bin(id, blob, sizeof(blob)); - if (len < 0) - return (int)len; - - has_session = cltrack_client_has_session(); - - ret = sqlite_check_client(blob, len, has_session); - if (ret) - ret = cltrack_check_legacy(blob, len, has_session); - - return ret ? -EPERM : ret; -} - -/* Clean out the v4recoverydir -- best effort here */ -static void -cltrack_legacy_gracedone(void) -{ - DIR *v4recovery; - struct dirent *entry; - char *dirname = getenv("NFSDCLTRACK_LEGACY_TOPDIR"); - - if (!dirname) - return; - - v4recovery = opendir(dirname); - if (!v4recovery) - return; - - while ((entry = readdir(v4recovery))) { - int len; - - /* skip "." and ".." */ - if (entry->d_name[0] == '.') { - switch (entry->d_name[1]) { - case '\0': - continue; - case '.': - if (entry->d_name[2] == '\0') - continue; - } - } - - /* borrow the clientid blob for this */ - len = snprintf((char *)blob, sizeof(blob), "%s/%s", dirname, - entry->d_name); - - /* if there's a problem, then skip this entry */ - if (len < 0 || (size_t)len >= sizeof(blob)) { - xlog(L_WARNING, "%s: unable to build filename for %s!", - __func__, entry->d_name); - continue; - } - - len = rmdir((char *)blob); - if (len) - xlog(L_WARNING, "%s: unable to rmdir %s: %d", __func__, - (char *)blob, len); - } - - closedir(v4recovery); -} - -static int -cltrack_gracedone(const char *timestr) -{ - int ret; - char *tail; - time_t gracetime; - - - ret = sqlite_prepare_dbh(storagedir); - if (ret) - return ret; - - errno = 0; - gracetime = strtol(timestr, &tail, 0); - - /* did the resulting value overflow? (Probably -ERANGE here) */ - if (errno) - return -errno; - - /* string wasn't fully converted */ - if (*tail) - return -EINVAL; - - xlog(D_GENERAL, "%s: grace done. gracetime=%ld", __func__, gracetime); - - ret = sqlite_remove_unreclaimed(gracetime); - - cltrack_legacy_gracedone(); - - return ret ? -EREMOTEIO : ret; -} - -static struct cltrack_cmd * -find_cmd(char *cmdname) -{ - struct cltrack_cmd *current = &commands[0]; - - while (current->name) { - if (!strcmp(cmdname, current->name)) - return current; - ++current; - } - - xlog(L_ERROR, "%s: '%s' doesn't match any known command", - __func__, cmdname); - return NULL; -} - -int -main(int argc, char **argv) -{ - int arg; - char *val; - int rc = 0; - char *progname, *cmdarg = NULL; - struct cltrack_cmd *cmd; - - progname = basename(argv[0]); - - xlog_syslog(1); - xlog_stderr(0); - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("nfsdcltrack"); - val = conf_get_str("nfsdcltrack", "storagedir"); - if (val) - storagedir = val; - rc = conf_get_num("nfsdcltrack", "debug", 0); - if (rc > 0) - xlog_config(D_ALL, 1); - - /* process command-line options */ - while ((arg = getopt_long(argc, argv, "hdfs:", longopts, - NULL)) != EOF) { - switch (arg) { - case 'd': - xlog_config(D_ALL, 1); - break; - case 'f': - xlog_syslog(0); - xlog_stderr(1); - break; - case 's': - storagedir = optarg; - break; - default: - usage(progname); - return 1; - } - } - - xlog_open(progname); - - /* we expect a command, at least */ - if (optind >= argc) { - xlog(L_ERROR, "Missing command name\n"); - rc = -EINVAL; - goto out; - } - - /* drop all capabilities */ - rc = cltrack_set_caps(); - if (rc) - goto out; - - cmd = find_cmd(argv[optind]); - if (!cmd) { - /* - * In the event that we get a command that we don't understand - * then return a distinct error. The kernel can use this to - * determine a new kernel/old userspace situation and cope - * with it. - */ - rc = -ENOSYS; - goto out; - } - - /* populate arg var if command needs it */ - if (cmd->needs_arg) { - if (optind + 1 >= argc) { - xlog(L_ERROR, "Command %s requires an argument\n", - cmd->name); - rc = -EINVAL; - goto out; - } - cmdarg = argv[optind + 1]; - } - rc = cmd->func(cmdarg); -out: - return rc; -} diff --git a/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.man b/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.man deleted file mode 100644 index cc24b7a..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcltrack/nfsdcltrack.man +++ /dev/null @@ -1,112 +0,0 @@ -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.IX Title "NFSDCLTRACK 8" -.TH NFSDCLTRACK 8 "2012-10-24" "" "" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -nfsdcltrack \- NFSv4 Client Tracking Callout Program -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -nfsdcltrack [\-d] [\-f] [\-s stable storage dir] -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -nfsdcltrack is the NFSv4 client tracking callout program. It is not necessary -to install this program on machines that are not acting as NFSv4 servers. -.PP -When a network partition is combined with a server reboot, there are -edge conditions that can cause the server to grant lock reclaims when -other clients have taken conflicting locks in the interim. A more detailed -explanation of this issue is described in \s-1RFC\s0 3530, section 8.6.3 -and in \s-1RFC\s0 5661, section 8.4.3. -.PP -In order to prevent these problems, the server must track a small amount -of per-client information on stable storage. This program provides the -userspace piece of that functionality. When the kernel needs to manipulate -the database that stores this info, it will execute this program to handle -it. -.SH "OPTIONS" -.IX Header "OPTIONS" -.IP "\fB\-d\fR, \fB\-\-debug\fR" 4 -.IX Item "-d, --debug" -Enable debug level logging. -.IP "\fB\-f\fR, \fB\-\-foreground\fR" 4 -.IX Item "-f, --foreground" -Log to stderr instead of syslog. -.IP "\fB\-s\fR \fIstoragedir\fR, \fB\-\-storagedir\fR=\fIstorage_dir\fR" 4 -.IX Item "-s storagedir, --storagedir=storage_dir" -Directory where stable storage information should be kept. The default -value is \fI/var/lib/nfs/nfsdcltrack\fR. -.SH "COMMANDS" -.IX Header "COMMANDS" -nfsdcltrack requires a command for each invocation. Supported commands -are: -.IP "\fBinit\fR" 4 -.IX Item "init" -Initialize the database. This command requires no argument. -.IP "\fBcreate\fR" 4 -.IX Item "create" -Create a new client record (or update the timestamp on an existing one). This command requires a hex-encoded nfs_client_id4 as an argument. -.IP "\fBremove\fR" 4 -.IX Item "remove" -Remove a client record from the database. This command requires a hex-encoded nfs_client_id4 as an argument. -.IP "\fBcheck\fR" 4 -.IX Item "check" -Check to see if a nfs_client_id4 is allowed to reclaim. This command requires a hex-encoded nfs_client_id4 as an argument. -.IP "\fBgracedone\fR" 4 -.IX Item "gracedone" -Remove any unreclaimed client records from the database. This command requires a epoch boot time as an argument. -.SH "EXTERNAL CONFIGURATION" -The directory for stable storage information can be set via the file -.B /etc/nfs.conf -by setting the -.B storagedir -value in the -.B nfsdcltrack -section. For example: -.in +5 -[nfsdcltrack] -.br - storagedir = /shared/nfs/nfsdcltrack -.in -5 -Debuging to syslog can also be enabled by setting "debug = 1" in this file. -.SH "LEGACY TRANSITION MECHANISM" -.IX Header "LEGACY TRANSITION MECHANISM" -The Linux kernel NFSv4 server has historically tracked this information -on stable storage by manipulating information on the filesystem -directly, in the directory to which \fI/proc/fs/nfsd/nfsv4recoverydir\fR -points. If the kernel passes the correct information, then nfsdcltrack -can use it to allow a seamless transition from the old client tracking -scheme to the new one. -.PP -On a \fBcheck\fR operation, if there is no record of the client in the -database, nfsdcltrack will look to see if the \fB\s-1NFSDCLTRACK_LEGACY_RECDIR\s0\fR -environment variable is set. If it is, then it will fetch that value and -see if a directory exists by that name. If it does, then the check -operation will succeed and the directory will be removed. -.PP -On a \fBgracedone\fR operation, nfsdcltrack will look to see if the -\&\fB\s-1NFSDCLTRACK_LEGACY_TOPDIR\s0\fR environment variable is set. If it is, then -it will attempt to clean out that directory prior to exiting. -.PP -Note that this transition is one-way. If the machine subsequently reboots -back into an older kernel that does not support the nfsdcltrack upcall -then the clients will not be able to recover their state. -.SH "NOTES" -.IX Header "NOTES" -This program requires a kernel that supports the nfsdcltrack usermodehelper -upcall. This support was first added to mainline kernels in 3.8. -.SH "AUTHORS" -.IX Header "AUTHORS" -nfsdcltrack was developed by Jeff Layton . diff --git a/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.c b/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.c deleted file mode 100644 index f79aebb..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.c +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Explanation: - * - * This file contains the code to manage the sqlite backend database for the - * nfsdcltrack usermodehelper upcall program. - * - * The main database is called main.sqlite and contains the following tables: - * - * parameters: simple key/value pairs for storing database info - * - * clients: an "id" column containing a BLOB with the long-form clientid as - * sent by the client, a "time" column containing a timestamp (in - * epoch seconds) of when the record was last updated, and a - * "has_session" column containing a boolean value indicating - * whether the client has sessions (v4.1+) or not (v4.0). - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xlog.h" -#include "sqlite.h" - -#define CLTRACK_SQLITE_LATEST_SCHEMA_VERSION 2 - -/* in milliseconds */ -#define CLTRACK_SQLITE_BUSY_TIMEOUT 10000 - -/* private data structures */ - -/* global variables */ - -/* reusable pathname and sql command buffer */ -static char buf[PATH_MAX]; - -/* global database handle */ -static sqlite3 *dbh; - -/* forward declarations */ - -/* make a directory, ignoring EEXIST errors unless it's not a directory */ -static int -mkdir_if_not_exist(const char *dirname) -{ - int ret; - struct stat statbuf; - - ret = mkdir(dirname, S_IRWXU); - if (ret && errno != EEXIST) - return -errno; - - ret = stat(dirname, &statbuf); - if (ret) - return -errno; - - if (!S_ISDIR(statbuf.st_mode)) - ret = -ENOTDIR; - - return ret; -} - -static int -sqlite_query_schema_version(void) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - /* prepare select query */ - ret = sqlite3_prepare_v2(dbh, - "SELECT value FROM parameters WHERE key == \"version\";", - -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(D_GENERAL, "Unable to prepare select statement: %s", - sqlite3_errmsg(dbh)); - ret = 0; - goto out; - } - - /* query schema version */ - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(D_GENERAL, "Select statement execution failed: %s", - sqlite3_errmsg(dbh)); - ret = 0; - goto out; - } - - ret = sqlite3_column_int(stmt, 0); -out: - sqlite3_finalize(stmt); - return ret; -} - -static int -sqlite_maindb_update_v1_to_v2(void) -{ - int ret, ret2; - char *err; - - /* begin transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - goto rollback; - } - - /* - * Check schema version again. This time, under an exclusive - * transaction to guard against racing DB setup attempts - */ - ret = sqlite_query_schema_version(); - switch (ret) { - case 1: - /* Still at v1 -- do conversion */ - break; - case CLTRACK_SQLITE_LATEST_SCHEMA_VERSION: - /* Someone else raced in and set it up */ - ret = 0; - goto rollback; - default: - /* Something went wrong -- fail! */ - ret = -EINVAL; - goto rollback; - } - - /* create v2 clients table */ - ret = sqlite3_exec(dbh, "ALTER TABLE clients ADD COLUMN " - "has_session INTEGER;", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to update clients table: %s", err); - goto rollback; - } - - ret = snprintf(buf, sizeof(buf), "UPDATE parameters SET value = %d " - "WHERE key = \"version\";", - CLTRACK_SQLITE_LATEST_SCHEMA_VERSION); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to update schema version: %s", err); - goto rollback; - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } -out: - sqlite3_free(err); - return ret; -rollback: - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - -/* - * Start an exclusive transaction and recheck the DB schema version. If it's - * still zero (indicating a new database) then set it up. If that all works, - * then insert schema version into the parameters table and commit the - * transaction. On any error, rollback the transaction. - */ -static int -sqlite_maindb_init_v2(void) -{ - int ret, ret2; - char *err = NULL; - - /* Start a transaction */ - ret = sqlite3_exec(dbh, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, - &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to begin transaction: %s", err); - if (err) - sqlite3_free(err); - return ret; - } - - /* - * Check schema version again. This time, under an exclusive - * transaction to guard against racing DB setup attempts - */ - ret = sqlite_query_schema_version(); - switch (ret) { - case 0: - /* Query failed again -- set up DB */ - break; - case CLTRACK_SQLITE_LATEST_SCHEMA_VERSION: - /* Someone else raced in and set it up */ - ret = 0; - goto rollback; - default: - /* Something went wrong -- fail! */ - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, "CREATE TABLE parameters " - "(key TEXT PRIMARY KEY, value TEXT);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create parameter table: %s", err); - goto rollback; - } - - /* create the "clients" table */ - ret = sqlite3_exec(dbh, "CREATE TABLE clients (id BLOB PRIMARY KEY, " - "time INTEGER, has_session INTEGER);", - NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to create clients table: %s", err); - goto rollback; - } - - - /* insert version into parameters table */ - ret = snprintf(buf, sizeof(buf), "INSERT OR FAIL INTO parameters " - "values (\"version\", \"%d\");", - CLTRACK_SQLITE_LATEST_SCHEMA_VERSION); - if (ret < 0) { - xlog(L_ERROR, "sprintf failed!"); - goto rollback; - } else if ((size_t)ret >= sizeof(buf)) { - xlog(L_ERROR, "sprintf output too long! (%d chars)", ret); - ret = -EINVAL; - goto rollback; - } - - ret = sqlite3_exec(dbh, (const char *)buf, NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to insert into parameter table: %s", err); - goto rollback; - } - - ret = sqlite3_exec(dbh, "COMMIT TRANSACTION;", NULL, NULL, &err); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to commit transaction: %s", err); - goto rollback; - } -out: - sqlite3_free(err); - return ret; - -rollback: - /* Attempt to rollback the transaction */ - ret2 = sqlite3_exec(dbh, "ROLLBACK TRANSACTION;", NULL, NULL, &err); - if (ret2 != SQLITE_OK) - xlog(L_ERROR, "Unable to rollback transaction: %s", err); - goto out; -} - -/* Open the database and set up the database handle for it */ -int -sqlite_prepare_dbh(const char *topdir) -{ - int ret; - - /* Do nothing if the database handle is already set up */ - if (dbh) - return 0; - - ret = snprintf(buf, PATH_MAX - 1, "%s/main.sqlite", topdir); - if (ret < 0) - return ret; - - buf[PATH_MAX - 1] = '\0'; - - /* open a new DB handle */ - ret = sqlite3_open(buf, &dbh); - if (ret != SQLITE_OK) { - /* try to create the dir */ - ret = mkdir_if_not_exist(topdir); - if (ret) - goto out_close; - - /* retry open */ - ret = sqlite3_open(buf, &dbh); - if (ret != SQLITE_OK) - goto out_close; - } - - /* set busy timeout */ - ret = sqlite3_busy_timeout(dbh, CLTRACK_SQLITE_BUSY_TIMEOUT); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "Unable to set sqlite busy timeout: %s", - sqlite3_errmsg(dbh)); - goto out_close; - } - - ret = sqlite_query_schema_version(); - switch (ret) { - case CLTRACK_SQLITE_LATEST_SCHEMA_VERSION: - /* DB is already set up. Do nothing */ - ret = 0; - break; - case 1: - /* Old DB -- update to new schema */ - ret = sqlite_maindb_update_v1_to_v2(); - if (ret) - goto out_close; - break; - case 0: - /* Query failed -- try to set up new DB */ - ret = sqlite_maindb_init_v2(); - if (ret) - goto out_close; - break; - default: - /* Unknown DB version -- downgrade? Fail */ - xlog(L_ERROR, "Unsupported database schema version! " - "Expected %d, got %d.", - CLTRACK_SQLITE_LATEST_SCHEMA_VERSION, ret); - ret = -EINVAL; - goto out_close; - } - - return ret; -out_close: - sqlite3_close(dbh); - dbh = NULL; - return ret; -} - -/* - * Create a client record - * - * Returns a non-zero sqlite error code, or SQLITE_OK (aka 0) - */ -int -sqlite_insert_client(const unsigned char *clname, const size_t namelen, - const bool has_session, const bool zerotime) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - if (zerotime) - ret = sqlite3_prepare_v2(dbh, "INSERT OR REPLACE INTO clients " - "VALUES (?, 0, ?);", -1, &stmt, NULL); - else - ret = sqlite3_prepare_v2(dbh, "INSERT OR REPLACE INTO clients " - "VALUES (?, strftime('%s', 'now'), ?);", -1, - &stmt, NULL); - - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: insert statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_bind_int(stmt, 2, (int)has_session); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind int failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from insert: %s", - __func__, sqlite3_errmsg(dbh)); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -/* Remove a client record */ -int -sqlite_remove_client(const unsigned char *clname, const size_t namelen) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = sqlite3_prepare_v2(dbh, "DELETE FROM clients WHERE id==?", -1, - &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: statement prepare failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", __func__, - sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from delete: %d", - __func__, ret); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -/* - * Is the given clname in the clients table? If so, then update its timestamp - * and return success. If the record isn't present, or the update fails, then - * return an error. - */ -int -sqlite_check_client(const unsigned char *clname, const size_t namelen, - const bool has_session) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = sqlite3_prepare_v2(dbh, "SELECT count(*) FROM clients WHERE " - "id==?", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: unable to prepare update statement: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(L_ERROR, "%s: unexpected return code from select: %d", - __func__, ret); - goto out_err; - } - - ret = sqlite3_column_int(stmt, 0); - xlog(D_GENERAL, "%s: select returned %d rows", __func__, ret); - if (ret != 1) { - ret = -EACCES; - goto out_err; - } - - /* Only update timestamp for v4.0 clients */ - if (has_session) { - ret = SQLITE_OK; - goto out_err; - } - - sqlite3_finalize(stmt); - stmt = NULL; - ret = sqlite3_prepare_v2(dbh, "UPDATE OR FAIL clients SET " - "time=strftime('%s', 'now') WHERE id==?", - -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: unable to prepare update statement: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_bind_blob(stmt, 1, (const void *)clname, namelen, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind blob failed: %s", - __func__, sqlite3_errmsg(dbh)); - goto out_err; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_DONE) - ret = SQLITE_OK; - else - xlog(L_ERROR, "%s: unexpected return code from update: %s", - __func__, sqlite3_errmsg(dbh)); - -out_err: - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_finalize(stmt); - return ret; -} - -/* - * remove any client records that were not reclaimed since grace_start. - */ -int -sqlite_remove_unreclaimed(time_t grace_start) -{ - int ret; - char *err = NULL; - - ret = snprintf(buf, sizeof(buf), "DELETE FROM clients WHERE time < %ld", - grace_start); - if (ret < 0) { - return ret; - } else if ((size_t)ret >= sizeof(buf)) { - ret = -EINVAL; - return ret; - } - - ret = sqlite3_exec(dbh, buf, NULL, NULL, &err); - if (ret != SQLITE_OK) - xlog(L_ERROR, "%s: delete failed: %s", __func__, err); - - xlog(D_GENERAL, "%s: returning %d", __func__, ret); - sqlite3_free(err); - return ret; -} - -/* - * Are there any clients that are possibly still reclaiming? Return a positive - * integer (usually number of clients) if so. If not, then return 0. On any - * error, return non-zero. - */ -int -sqlite_query_reclaiming(const time_t grace_start) -{ - int ret; - sqlite3_stmt *stmt = NULL; - - ret = sqlite3_prepare_v2(dbh, "SELECT count(*) FROM clients WHERE " - "time < ? OR has_session != 1", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: unable to prepare select statement: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_bind_int64(stmt, 1, (sqlite3_int64)grace_start); - if (ret != SQLITE_OK) { - xlog(L_ERROR, "%s: bind int64 failed: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_ROW) { - xlog(L_ERROR, "%s: unexpected return code from select: %s", - __func__, sqlite3_errmsg(dbh)); - return ret; - } - - ret = sqlite3_column_int(stmt, 0); - sqlite3_finalize(stmt); - xlog(D_GENERAL, "%s: there are %d clients that have not completed " - "reclaim", __func__, ret); - return ret; -} diff --git a/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.h b/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.h deleted file mode 100644 index 06e7c04..0000000 --- a/nfs-utils-2.5.2/utils/nfsdcltrack/sqlite.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat, Jeff Layton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _SQLITE_H_ -#define _SQLITE_H_ - -int sqlite_prepare_dbh(const char *topdir); -int sqlite_insert_client(const unsigned char *clname, const size_t namelen, - const bool has_session, const bool zerotime); -int sqlite_remove_client(const unsigned char *clname, const size_t namelen); -int sqlite_check_client(const unsigned char *clname, const size_t namelen, - const bool has_session); -int sqlite_remove_unreclaimed(const time_t grace_start); -int sqlite_query_reclaiming(const time_t grace_start); - -#endif /* _SQLITE_H */ diff --git a/nfs-utils-2.5.2/utils/nfsidmap/Makefile.am b/nfs-utils-2.5.2/utils/nfsidmap/Makefile.am deleted file mode 100644 index e5d7d04..0000000 --- a/nfs-utils-2.5.2/utils/nfsidmap/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = nfsidmap.man -sbin_PROGRAMS = nfsidmap - -AM_CPPFLAGS += -I ../../support/nfsidmap - -nfsidmap_SOURCES = nfsidmap.c -nfsidmap_LDADD = -lkeyutils \ - ../../support/nfs/libnfs.la \ - ../../support/nfsidmap/libnfsidmap.la - -MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = id_resolver.conf $(man8_MANS) diff --git a/nfs-utils-2.5.2/utils/nfsidmap/id_resolver.conf b/nfs-utils-2.5.2/utils/nfsidmap/id_resolver.conf deleted file mode 100644 index 2c156c6..0000000 --- a/nfs-utils-2.5.2/utils/nfsidmap/id_resolver.conf +++ /dev/null @@ -1 +0,0 @@ -create id_resolver * * /usr/sbin/nfsidmap -t 600 %k %d diff --git a/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.c b/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.c deleted file mode 100644 index cf7f65e..0000000 --- a/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.c +++ /dev/null @@ -1,478 +0,0 @@ -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include "xlog.h" -#include "conffile.h" -#include "xcommon.h" - -int verbose = 0; -#define USAGE "Usage: %s [-vh] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]" - -#define MAX_ID_LEN 11 -#define IDMAP_NAMESZ 128 -#define USER 1 -#define GROUP 0 - -#define PROCKEYS "/proc/keys" -#ifndef DEFAULT_KEYRING -#define DEFAULT_KEYRING ".id_resolver" -#endif - -#ifndef PATH_IDMAPDCONF -#define PATH_IDMAPDCONF "/etc/idmapd.conf" -#endif - -#define UIDKEYS 0x1 -#define GIDKEYS 0x2 - -#ifndef HAVE_FIND_KEY_BY_TYPE_AND_DESC -static key_serial_t find_key_by_type_and_desc(const char *type, - const char *desc, key_serial_t destringid) -{ - char buf[BUFSIZ]; - key_serial_t key; - FILE *fp; - - if ((fp = fopen(PROCKEYS, "r")) == NULL) { - xlog_err("fopen(%s) failed: %m", PROCKEYS); - return -1; - } - - key = -1; - while(fgets(buf, BUFSIZ, fp) != NULL) { - unsigned int id; - - if (strstr(buf, type) == NULL) - continue; - if (strstr(buf, desc) == NULL) - continue; - if (sscanf(buf, "%x %*s", &id) != 1) { - xlog_err("Unparsable keyring entry in %s", PROCKEYS); - continue; - } - - key = (key_serial_t)id; - break; - } - - fclose(fp); - return key; -} -#endif - -/* - * Clear all the keys on the given keyring - */ -static int keyring_clear(const char *keyring) -{ - key_serial_t key; - - key = find_key_by_type_and_desc("keyring", keyring, 0); - if (key == -1) { - if (verbose) - xlog_warn("'%s' keyring was not found.", keyring); - return EXIT_SUCCESS; - } - - if (keyctl_clear(key) < 0) { - xlog_err("keyctl_clear(0x%x) failed: %m", - (unsigned int)key); - return EXIT_FAILURE; - } - - if (verbose) - xlog_warn("'%s' cleared", keyring); - return EXIT_SUCCESS; -} - -static int display_default_domain(void) -{ - char domain[NFS4_MAX_DOMAIN_LEN]; - int rc; - - rc = nfs4_get_default_domain(NULL, domain, NFS4_MAX_DOMAIN_LEN); - if (rc) { - xlog_errno(rc, "nfs4_get_default_domain failed: %m"); - return EXIT_FAILURE; - } - - printf("%s\n", domain); - return EXIT_SUCCESS; -} - -static void list_key(key_serial_t key) -{ - char *buffer, *c; - int rc; - - rc = keyctl_describe_alloc(key, &buffer); - if (rc < 0) { - switch (errno) { - case EKEYEXPIRED: - printf("Expired key not displayed\n"); - break; - default: - xlog_err("Failed to describe key: %m"); - } - return; - } - - c = strrchr(buffer, ';'); - if (!c) { - xlog_err("Unparsable key not displayed\n"); - goto out_free; - } - printf(" %s\n", ++c); - -out_free: - free(buffer); -} - -static void list_keys(const char *ring_name, key_serial_t ring_id) -{ - key_serial_t *key; - void *keylist; - int count; - - count = keyctl_read_alloc(ring_id, &keylist); - if (count < 0) { - xlog_err("Failed to read keyring %s: %m", ring_name); - return; - } - count /= (int)sizeof(*key); - - switch (count) { - case 0: - printf("No %s keys found.\n", ring_name); - break; - case 1: - printf("1 %s key found:\n", ring_name); - break; - default: - printf("%u %s keys found:\n", count, ring_name); - } - - for (key = keylist; count--; key++) - list_key(*key); - - free(keylist); -} - -/* - * List all keys on a keyring - */ -static int list_keyring(const char *keyring) -{ - key_serial_t key; - - key = find_key_by_type_and_desc("keyring", keyring, 0); - if (key == -1) { - xlog_err("'%s' keyring was not found.", keyring); - return EXIT_FAILURE; - } - - list_keys(keyring, key); - return EXIT_SUCCESS; -} - -/* - * Find either a user or group id based on the name@domain string - */ -static int id_lookup(char *name_at_domain, key_serial_t key, int type) -{ - char id[MAX_ID_LEN]; - uid_t uid = 0; - gid_t gid = 0; - int rc; - - if (type == USER) { - rc = nfs4_owner_to_uid(name_at_domain, &uid); - sprintf(id, "%u", uid); - } else { - rc = nfs4_group_owner_to_gid(name_at_domain, &gid); - sprintf(id, "%u", gid); - } - if (rc < 0) { - xlog_errno(rc, "id_lookup: %s: for %s failed: %m", - (type == USER ? "nfs4_owner_to_uid" : "nfs4_group_owner_to_gid"), - name_at_domain); - return EXIT_FAILURE; - } - - rc = EXIT_SUCCESS; - if (keyctl_instantiate(key, id, strlen(id) + 1, 0)) { - switch (errno) { - case EDQUOT: - case ENFILE: - case ENOMEM: - /* - * The keyring is full. Clear the keyring and try again - */ - rc = keyring_clear(DEFAULT_KEYRING); - if (rc) - break; - if (keyctl_instantiate(key, id, strlen(id) + 1, 0)) { - rc = EXIT_FAILURE; - xlog_err("id_lookup: keyctl_instantiate failed: %m"); - } - break; - default: - rc = EXIT_FAILURE; - break; - } - } - - return rc; -} - -/* - * Find the name@domain string from either a user or group id - */ -static int name_lookup(char *id, key_serial_t key, int type) -{ - char name[IDMAP_NAMESZ]; - char domain[NFS4_MAX_DOMAIN_LEN]; - uid_t uid; - gid_t gid; - int rc; - - rc = nfs4_get_default_domain(NULL, domain, NFS4_MAX_DOMAIN_LEN); - if (rc) { - xlog_errno(rc, - "name_lookup: nfs4_get_default_domain failed: %m"); - return EXIT_FAILURE; - } - - if (type == USER) { - uid = atoi(id); - rc = nfs4_uid_to_name(uid, domain, name, IDMAP_NAMESZ); - } else { - gid = atoi(id); - rc = nfs4_gid_to_name(gid, domain, name, IDMAP_NAMESZ); - } - if (rc) { - xlog_errno(rc, "name_lookup: %s: for %u failed: %m", - (type == USER ? "nfs4_uid_to_name" : "nfs4_gid_to_name"), - (type == USER ? uid : gid)); - return EXIT_FAILURE; - } - - rc = EXIT_SUCCESS; - if (keyctl_instantiate(key, &name, strlen(name), 0)) { - rc = EXIT_FAILURE; - xlog_err("name_lookup: keyctl_instantiate failed: %m"); - } - - return rc; -} - -/* - * Revoke a key - */ -static int key_invalidate(char *keystr, int keymask) -{ - FILE *fp; - char buf[BUFSIZ], *ptr; - unsigned int key; - int mask; - - xlog_syslog(0); - - if ((fp = fopen(PROCKEYS, "r")) == NULL) { - xlog_err("fopen(%s) failed: %m", PROCKEYS); - return EXIT_FAILURE; - } - - while(fgets(buf, BUFSIZ, fp) != NULL) { - if (strstr(buf, "keyring") != NULL) - continue; - - mask = 0; - if ((ptr = strstr(buf, "uid:")) != NULL) - mask = UIDKEYS; - else if ((ptr = strstr(buf, "gid:")) != NULL) - mask = GIDKEYS; - else - continue; - - if ((keymask & mask) == 0) - continue; - - if (strncmp(ptr+4, keystr, strlen(keystr)) != 0) - continue; - - if (verbose) { - *(strchr(buf, '\n')) = '\0'; - xlog_warn("invalidating '%s'", buf); - } - /* - * The key is the first arugment in the string - */ - *(strchr(buf, ' ')) = '\0'; - sscanf(buf, "%x", &key); - -/* older libkeyutils compatibility */ -#ifndef KEYCTL_INVALIDATE -#define KEYCTL_INVALIDATE 21 /* invalidate a key */ -#endif - if (keyctl(KEYCTL_INVALIDATE, key) < 0) { - if (errno != EOPNOTSUPP) { - xlog_err("keyctl_invalidate(0x%x) failed: %m", key); - fclose(fp); - return EXIT_FAILURE; - } else { - /* older kernel compatibility attempt: */ - if (keyctl_revoke(key) < 0) { - xlog_err("keyctl_revoke(0x%x) failed: %m", key); - fclose(fp); - return EXIT_FAILURE; - } - } - } - - keymask &= ~mask; - if (keymask == 0) { - fclose(fp); - return EXIT_SUCCESS; - } - } - xlog_err("'%s' key was not found.", keystr); - fclose(fp); - return EXIT_FAILURE; -} - -int main(int argc, char **argv) -{ - char *arg; - char *value; - char *type; - int rc = 1, opt; - int timeout = 600; - key_serial_t key; - char *progname, *keystr = NULL; - int clearing = 0, keymask = 0, display = 0, list = 0; - - /* Set the basename */ - if ((progname = strrchr(argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; - - xlog_open(progname); - - while ((opt = getopt(argc, argv, "hdu:g:r:ct:vl")) != -1) { - switch (opt) { - case 'd': - display++; - break; - case 'l': - list++; - break; - case 'u': - keymask = UIDKEYS; - keystr = strdup(optarg); - break; - case 'g': - keymask = GIDKEYS; - keystr = strdup(optarg); - break; - case 'r': - keymask = GIDKEYS|UIDKEYS; - keystr = strdup(optarg); - break; - case 'c': - clearing++; - break; - case 'v': - verbose++; - break; - case 't': - timeout = atoi(optarg); - break; - case 'h': - default: - xlog_warn(USAGE, progname); - exit(opt == 'h' ? 0 : 1); - } - } - - if (geteuid() != 0) { - xlog_err("Must be run as root."); - return EXIT_FAILURE; - } - - if ((rc = nfs4_init_name_mapping(PATH_IDMAPDCONF))) { - xlog_errno(rc, "Unable to create name to user id mappings."); - return EXIT_FAILURE; - } - if (!verbose) - verbose = conf_get_num("General", "Verbosity", 0); - - if (display) - return display_default_domain(); - if (list) - return list_keyring(DEFAULT_KEYRING); - if (keystr) { - return key_invalidate(keystr, keymask); - } - if (clearing) { - xlog_syslog(0); - return keyring_clear(DEFAULT_KEYRING); - } - - xlog_stderr(verbose); - if ((argc - optind) != 2) { - xlog_warn("Bad arg count. Check /etc/request-key.conf"); - xlog_warn(USAGE, progname); - return EXIT_FAILURE; - } - - if (verbose) - nfs4_set_debug(verbose, NULL); - - key = strtol(argv[optind++], NULL, 10); - - arg = xstrdup(argv[optind]); - type = strtok(arg, ":"); - value = strtok(NULL, ":"); - if (value == NULL) { - free(arg); - xlog_err("Error: Null uid/gid value."); - return EXIT_FAILURE; - } - if (verbose) { - xlog_warn("key: 0x%x type: %s value: %s timeout %d", - key, type, value, timeout); - } - - /* Become a possesor of the to-be-instantiated key to set the key's timeout */ - request_key("keyring", DEFAULT_KEYRING, NULL, KEY_SPEC_THREAD_KEYRING); - - if (strcmp(type, "uid") == 0) - rc = id_lookup(value, key, USER); - else if (strcmp(type, "gid") == 0) - rc = id_lookup(value, key, GROUP); - else if (strcmp(type, "user") == 0) - rc = name_lookup(value, key, USER); - else if (strcmp(type, "group") == 0) - rc = name_lookup(value, key, GROUP); - - /* Set timeout to 10 (600 seconds) minutes */ - if (rc == EXIT_SUCCESS) - keyctl_set_timeout(key, timeout); - - free(arg); - return rc; -} diff --git a/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.man b/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.man deleted file mode 100644 index 2af16f3..0000000 --- a/nfs-utils-2.5.2/utils/nfsidmap/nfsidmap.man +++ /dev/null @@ -1,159 +0,0 @@ -.\" -.\"@(#)nfsidmap(8) - The NFS idmapper upcall program -.\" -.\" Copyright (C) 2010 Bryan Schumaker -.TH nfsidmap 5 "1 October 2010" -.SH NAME -nfsidmap \- The NFS idmapper upcall program -.SH SYNOPSIS -.B "nfsidmap [-v] [-t timeout] key desc" -.br -.B "nfsidmap [-v] [-c]" -.br -.B "nfsidmap [-v] [-u|-g|-r user]" -.br -.B "nfsidmap -d" -.br -.B "nfsidmap -l" -.br -.B "nfsidmap -h" -.SH DESCRIPTION -The NFSv4 protocol represents the local system's UID and GID values -on the wire as strings of the form -.IR user@domain . -The process of translating from UID to string and string to UID is -referred to as "ID mapping." -.PP -The system derives the -.I user -part of the string by performing a password or group lookup. -The lookup mechanism is configured in -.IR /etc/idmapd.conf . -.PP -By default, the -.I domain -part of the string is the system's DNS domain name. -It can also be specified in -.I /etc/idmapd.conf -if the system is multi-homed, -or if the system's DNS domain name does -not match the name of the system's Kerberos realm. -.PP -When the domain is not specified in -.I /etc/idmapd.conf -the local DNS server will be queried for the -.I _nfsv4idmapdomain -text record. If the record exists -that will be used as the domain. When the record -does not exist, the domain part of the DNS domain -will used. -.PP -The -.I /usr/sbin/nfsidmap -program performs translations on behalf of the kernel. -The kernel uses the request-key mechanism to perform -an upcall. -.I /usr/sbin/nfsidmap -is invoked by /sbin/request-key, performs the translation, -and initializes a key with the resulting information. -The kernel then caches the translation results in the key. -.PP -.I nfsidmap -can also clear cached ID map results in the kernel, -or revoke one particular key. -An incorrect cached key can result in file and directory ownership -reverting to "nobody" on NFSv4 mount points. -.PP -In addition, the -.B -d -and -.B -l -options are available to help diagnose misconfigurations. -They have no effect on the keyring containing ID mapping results. -.SH OPTIONS -.TP -.B -c -Clear the keyring of all the keys. -.TP -.B -d -Display the system's effective NFSv4 domain name on -.IR stdout . -.TP -.B -g user -Revoke the gid key of the given user. -.TP -.B -h -Display usage message. -.TP -.B -l -Display on -.I stdout -all keys currently in the keyring used to cache ID mapping results. -These keys are visible only to the superuser. -.TP -.B -r user -Revoke both the uid and gid key of the given user. -.TP -.B -t timeout -Set the expiration timer, in seconds, on the key. -The default is 600 seconds (10 mins). -.TP -.B -u user -Revoke the uid key of the given user. -.TP -.B -v -Increases the verbosity of the output to syslog -(can be specified multiple times). -.SH CONFIGURING -The file -.I /etc/request-key.conf -will need to be modified so -.I /sbin/request-key -can properly direct the upcall. The following line should be added before a call -to keyctl negate: -.PP -create id_resolver * * /usr/sbin/nfsidmap -t 600 %k %d -.PP -This will direct all id_resolver requests to the program -.I /usr/sbin/nfsidmap. -The -.B -t 600 -defines how many seconds into the future the key will -expire. This is an optional parameter for -.I /usr/sbin/nfsidmap -and will default to 600 seconds when not specified. -.PP -The idmapper system uses four key descriptions: -.PP - uid: Find the UID for the given user -.br - gid: Find the GID for the given group -.br - user: Find the user name for the given UID -.br - group: Find the group name for the given GID -.PP -You can choose to handle any of these individually, rather than using the -generic upcall program. If you would like to use your own program for a uid -lookup then you would edit your request-key.conf so it looks similar to this: -.PP -create id_resolver uid:* * /some/other/program %k %d -.br -create id_resolver * * /usr/sbin/nfsidmap %k %d -.PP -Notice that the new line was added above the line for the generic program. -request-key will find the first matching line and run the corresponding program. -In this case, /some/other/program will handle all uid lookups, and -/usr/sbin/nfsidmap will handle gid, user, and group lookups. -.SH FILES -.TP -.I /etc/idmapd.conf -ID mapping configuration file -.TP -.I /etc/request-key.conf -Request key configuration file -.SH "SEE ALSO" -.BR idmapd.conf (5), -.BR request-key (8) -.SH AUTHOR -Bryan Schumaker, diff --git a/nfs-utils-2.5.2/utils/nfsref/Makefile.am b/nfs-utils-2.5.2/utils/nfsref/Makefile.am deleted file mode 100644 index 2409dd0..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -## -## @file utils/nfsref/Makefile.am -## @brief Process this file with automake to produce utils/nfsref/Makefile.in -## - -## -## Copyright 2011, 2018 Oracle. All rights reserved. -## -## This file is part of nfs-utils. -## -## nfs-utils is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License version 2.0 as -## published by the Free Software Foundation. -## -## nfs-utils is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License version 2.0 for more details. -## -## You should have received a copy of the GNU General Public License -## version 2.0 along with nfs-utils. If not, see: -## -## http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt -## - -noinst_HEADERS = nfsref.h - -sbin_PROGRAMS = nfsref -nfsref_SOURCES = add.c lookup.c nfsref.c remove.c -LDADD = ../../support/nfs/libnfs.la \ - ../../support/junction/libjunction.la \ - $(LIBXML2) $(LIBCAP) - -man8_MANS = nfsref.man - -MAINTAINERCLEANFILES = Makefile.in - diff --git a/nfs-utils-2.5.2/utils/nfsref/add.c b/nfs-utils-2.5.2/utils/nfsref/add.c deleted file mode 100644 index 781aeee..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/add.c +++ /dev/null @@ -1,272 +0,0 @@ -/** - * @file utils/nfsref/add.c - * @brief Add junction metadata to a local file system object - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "junction.h" -#include "xlog.h" -#include "nfsref.h" - -/** - * Default cache expiration for FSN information - */ -#define FSN_DEFAULT_TTL (300) - -/** - * Display help message for "add" subcommand - * - * @param progname NUL-terminated C string containing name of program - * @return program exit status - */ -int -nfsref_add_help(const char *progname) -{ - fprintf(stderr, " \n"); - - fprintf(stderr, "Usage: %s [ -t type ] add " - " [ ... ]\n\n", - progname); - - fprintf(stderr, "Add a new junction containing the specified list " - "of fileset locations.\n"); - fprintf(stderr, " is the filename of the new junction. " - " is the hostname\n"); - fprintf(stderr, "or IP address of an NFS server where the fileset is " - "located. is the\n"); - fprintf(stderr, "export pathname of the fileset on that server.\n\n"); - - fprintf(stderr, "For NFS basic junctions, the location list is stored " - "locally in the junction.\n"); - fprintf(stderr, "For FedFS junctions, the location list is stored " - "as new FSN and FSL records\n"); - fprintf(stderr, "on an NSDB.\n"); - - return EXIT_SUCCESS; -} - -/** - * Fill in default settings for NFSv4.0 fs_locations4 - * - * @param new NFS location structure to fill in - * - * See section 5.1.3.2 of the NSDB protocol draft. - */ -static void -nfsref_add_fsloc_defaults(struct nfs_fsloc *new) -{ - new->nfl_hostport = 0; - new->nfl_flags.nfl_varsub = false; - new->nfl_currency = -1; - new->nfl_validfor = 0; - new->nfl_genflags.nfl_writable = false; - new->nfl_genflags.nfl_going = false; - new->nfl_genflags.nfl_split = true; - new->nfl_transflags.nfl_rdma = true; - new->nfl_info.nfl_simul = 0; - new->nfl_info.nfl_handle = 0; - new->nfl_info.nfl_fileid = 0; - new->nfl_info.nfl_writever = 0; - new->nfl_info.nfl_change = 0; - new->nfl_info.nfl_readdir = 0; - new->nfl_info.nfl_readrank = 0; - new->nfl_info.nfl_readorder = 0; - new->nfl_info.nfl_writerank = 0; - new->nfl_info.nfl_writeorder = 0; -} - -/** - * Convert a pair of command line arguments to one nfs_fsloc structure - * - * @param server NUL-terminated C string containing file server hostname - * @param rootpath NUL-terminated C string containing POSIX-style export path - * @param fsloc OUT: NFS location structure - * @return a FedFsStatus code - * - * If nfsref_add_build_fsloc() returns FEDFS_OK, caller must free the - * returned fsloc with nfs_free_location(). - */ -static FedFsStatus -nfsref_add_build_fsloc(const char *server, const char *rootpath, - struct nfs_fsloc **fsloc) -{ - struct nfs_fsloc *new; - FedFsStatus retval; - - if (server == NULL || rootpath == NULL) - return FEDFS_ERR_INVAL; - - xlog(D_GENERAL, "%s: Building fsloc for %s:%s", - __func__, server, rootpath); - - new = nfs_new_location(); - if (new == NULL) { - xlog(D_GENERAL, "%s: No memory", __func__); - return FEDFS_ERR_SVRFAULT; - } - - new->nfl_hostname = strdup(server); - if (new->nfl_hostname == NULL) { - nfs_free_location(new); - xlog(D_GENERAL, "%s: No memory", __func__); - return FEDFS_ERR_SVRFAULT; - } - - retval = nsdb_posix_to_path_array(rootpath, &new->nfl_rootpath); - if (retval != FEDFS_OK) { - nfs_free_location(new); - return retval; - } - - nfsref_add_fsloc_defaults(new); - *fsloc = new; - return FEDFS_OK; -} - -/** - * Convert array of command line arguments to list of nfs_fsloc structures - * - * @param argv array of pointers to NUL-terminated C strings contains arguments - * @param optind index of "argv" where "add" subcommand arguments start - * @param fslocs OUT: list of NFS locations - * @return a FedFsStatus code - * - * If nfsref_add_build_fsloc_list() returns FEDFS_OK, caller must free the - * returned list of fslocs with nfs_free_locations(). - */ -static FedFsStatus -nfsref_add_build_fsloc_list(char **argv, int optind, struct nfs_fsloc **fslocs) -{ - struct nfs_fsloc *fsloc, *result = NULL; - FedFsStatus retval; - int i; - - for (i = optind + 2; argv[i] != NULL; i += 2) { - retval = nfsref_add_build_fsloc(argv[i], argv[i + 1], &fsloc); - if (retval != FEDFS_OK) { - nfs_free_locations(result); - return retval; - } - if (result == NULL) - result = fsloc; - else - result->nfl_next = fsloc; - } - if (result == NULL) - return FEDFS_ERR_INVAL; - - *fslocs = result; - return FEDFS_OK; -} - -/** - * Add NFS locations to a junction - * - * @param junct_path NUL-terminated C string containing pathname of junction - * @param argv array of pointers to NUL-terminated C strings contains arguments - * @param optind index of "argv" where "add" subcommand arguments start - * @return program exit status - */ -static int -nfsref_add_nfs_basic(const char *junct_path, char **argv, int optind) -{ - struct nfs_fsloc *fslocs = NULL; - FedFsStatus retval; - - xlog(D_GENERAL, "%s: Adding basic junction to %s", - __func__, junct_path); - - retval = nfsref_add_build_fsloc_list(argv, optind, &fslocs); - switch (retval) { - case FEDFS_OK: - break; - case FEDFS_ERR_INVAL: - xlog(L_ERROR, "Missing arguments"); - return EXIT_FAILURE; - case FEDFS_ERR_SVRFAULT: - xlog(L_ERROR, "No memory"); - return EXIT_FAILURE; - default: - xlog(L_ERROR, "Failed to add NFS location metadata to %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - return EXIT_FAILURE; - } - - retval = nfs_add_junction(junct_path, fslocs); - nfs_free_locations(fslocs); - switch (retval) { - case FEDFS_OK: - break; - case FEDFS_ERR_EXIST: - xlog(L_ERROR, "%s already contains junction metadata", - junct_path); - return EXIT_FAILURE; - default: - xlog(L_ERROR, "Failed to add NFS location metadata to %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - return EXIT_FAILURE; - } - - printf("Created junction %s\n", junct_path); - return EXIT_SUCCESS; -} - -/** - * Add locations to a junction - * - * @param type type of junction to add - * @param junct_path NUL-terminated C string containing pathname of junction - * @param argv array of pointers to NUL-terminated C strings contains arguments - * @param optind index of "argv" where "add" subcommand arguments start - * @return program exit status - */ -int -nfsref_add(enum nfsref_type type, const char *junct_path, char **argv, int optind) -{ - if (mkdir(junct_path, 0755) == -1) - if (errno != EEXIST) { - xlog(L_ERROR, "Failed to create junction object: %m"); - return EXIT_FAILURE; - } - - switch (type) { - case NFSREF_TYPE_UNSPECIFIED: - case NFSREF_TYPE_NFS_BASIC: - return nfsref_add_nfs_basic(junct_path, argv, optind); - default: - xlog(L_ERROR, "Unrecognized junction type"); - } - return EXIT_FAILURE; -} diff --git a/nfs-utils-2.5.2/utils/nfsref/lookup.c b/nfs-utils-2.5.2/utils/nfsref/lookup.c deleted file mode 100644 index 16fca2e..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/lookup.c +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file utils/nfsref/lookup.c - * @brief Examine junction metadata from a local file system object - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include -#include -#include - -#include - -#include "junction.h" -#include "xlog.h" -#include "nfsref.h" - -/** - * Display help message for "lookup" subcommand - * - * @param progname NUL-terminated C string containing name of program - * @return program exit status - */ -int -nfsref_lookup_help(const char *progname) -{ - fprintf(stderr, " \n"); - - fprintf(stderr, "Usage: %s [ -t type ] lookup \n\n", - progname); - - fprintf(stderr, "Display the contents of the junction at " - ". For NFS basic\n"); - fprintf(stderr, "junctions, the local contents of the junction " - "are displayed. For FedFS\n"); - fprintf(stderr, "junctions, FSL records are retrieved from the " - "NSDB and displayed.\n"); - - return EXIT_SUCCESS; -} - -/** - * Convert a boolean value into a displayable string constant - * - * @param value boolean value - * @return NUL-terminated static constant C string - */ -static const char * -nfsref_lookup_display_boolean(_Bool value) -{ - return value ? "true" : "false"; -} - -/** - * Display a single NFS location - * - * @param fsloc pointer to an NFS location structure - */ -static void -nfsref_lookup_display_nfs_location(struct nfs_fsloc *fsloc) -{ - char *rootpath; - - if (nsdb_path_array_to_posix(fsloc->nfl_rootpath, &rootpath) == FEDFS_OK) { - printf("%s:%s\n", fsloc->nfl_hostname, rootpath); - free(rootpath); - } else - printf("%s: - Invalid root path -\n", fsloc->nfl_hostname); - printf("\n"); - - printf("\tNFS port:\t%u\n", fsloc->nfl_hostport); - printf("\tValid for:\t%d\n", fsloc->nfl_validfor); - printf("\tCurrency:\t%d\n", fsloc->nfl_currency); - printf("\tFlags:\t\tvarsub(%s)\n", - nfsref_lookup_display_boolean(fsloc->nfl_flags.nfl_varsub)); - - printf("\tGenFlags:\twritable(%s), going(%s), split(%s)\n", - nfsref_lookup_display_boolean(fsloc->nfl_genflags.nfl_writable), - nfsref_lookup_display_boolean(fsloc->nfl_genflags.nfl_going), - nfsref_lookup_display_boolean(fsloc->nfl_genflags.nfl_split)); - printf("\tTransFlags:\trdma(%s)\n", - nfsref_lookup_display_boolean(fsloc->nfl_transflags.nfl_rdma)); - - printf("\tClass:\t\tsimul(%u), handle(%u), fileid(%u)\n", - fsloc->nfl_info.nfl_simul, - fsloc->nfl_info.nfl_handle, - fsloc->nfl_info.nfl_fileid); - printf("\tClass:\t\twritever(%u), change(%u), readdir(%u)\n", - fsloc->nfl_info.nfl_writever, - fsloc->nfl_info.nfl_change, - fsloc->nfl_info.nfl_readdir); - printf("\tRead:\t\trank(%u), order(%u)\n", - fsloc->nfl_info.nfl_readrank, fsloc->nfl_info.nfl_readorder); - printf("\tWrite:\t\trank(%u), order(%u)\n", - fsloc->nfl_info.nfl_writerank, fsloc->nfl_info.nfl_writeorder); - - printf("\n"); -} - -/** - * Display a list of NFS locations - * - * @param fslocs list of NFS locations to display - */ -static void -nfsref_lookup_display_nfs_locations(struct nfs_fsloc *fslocs) -{ - struct nfs_fsloc *fsloc; - - for (fsloc = fslocs; fsloc != NULL; fsloc = fsloc->nfl_next) - nfsref_lookup_display_nfs_location(fsloc); -} - -/** - * List NFS locations in an nfs-basic junction - * - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -static int -nfsref_lookup_nfs_basic(const char *junct_path) -{ - struct nfs_fsloc *fslocs = NULL; - FedFsStatus retval; - - xlog(D_GENERAL, "%s: Looking up basic junction in %s", - __func__, junct_path); - - retval = nfs_is_junction(junct_path); - switch (retval) { - case FEDFS_OK: - break; - case FEDFS_ERR_NOTJUNCT: - xlog(L_ERROR, "%s is not an nfs-basic junction", junct_path); - return EXIT_FAILURE; - default: - xlog(L_ERROR, "Failed to access %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - return EXIT_FAILURE; - } - - retval = nfs_get_locations(junct_path, &fslocs); - if (retval != FEDFS_OK) { - xlog(L_ERROR, "Failed to access %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - return EXIT_FAILURE; - } - - nfsref_lookup_display_nfs_locations(fslocs); - - nfs_free_locations(fslocs); - return EXIT_SUCCESS; -} - -/** - * Resolve either a FedFS or NFS basic junction - * - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -static int -nfsref_lookup_unspecified(const char *junct_path) -{ - FedFsStatus retval; - - retval = nfs_is_junction(junct_path); - if (retval == FEDFS_OK) - return nfsref_lookup_nfs_basic(junct_path); - xlog(L_ERROR, "%s is not a junction", junct_path); - return EXIT_FAILURE; -} - -/** - * Enumerate metadata of a junction - * - * @param type type of junction to add - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -int -nfsref_lookup(enum nfsref_type type, const char *junct_path) -{ - switch (type) { - case NFSREF_TYPE_UNSPECIFIED: - return nfsref_lookup_unspecified(junct_path); - case NFSREF_TYPE_NFS_BASIC: - return nfsref_lookup_nfs_basic(junct_path); - default: - xlog(L_ERROR, "Unrecognized junction type"); - } - return EXIT_FAILURE; -} diff --git a/nfs-utils-2.5.2/utils/nfsref/nfsref.c b/nfs-utils-2.5.2/utils/nfsref/nfsref.c deleted file mode 100644 index 7f97d01..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/nfsref.c +++ /dev/null @@ -1,189 +0,0 @@ -/** - * @file utils/nfsref/nfsref.c - * @brief Manage NFS referrals - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "junction.h" -#include "xlog.h" -#include "nfsref.h" - -/** - * Short form command line options - */ -static const char nfsref_opts[] = "?dt:"; - -/** - * Long form command line options - */ -static const struct option nfsref_longopts[] = { - { "debug", 0, NULL, 'd', }, - { "help", 0, NULL, '?', }, - { "type", 1, NULL, 't', }, - { NULL, 0, NULL, 0, }, -}; - -/** - * Display program synopsis - * - * @param progname NUL-terminated C string containing name of program - */ -static void -nfsref_usage(const char *progname) -{ - fprintf(stderr, "Usage: %s [ -t type ] SUBCOMMAND [ ARGUMENTS ]\n\n", - progname); - - fprintf(stderr, "SUBCOMMAND is one of:\n"); - fprintf(stderr, "\tadd Add a new junction\n"); - fprintf(stderr, "\tremove Remove an existing junction\n"); - fprintf(stderr, "\tlookup Enumerate a junction\n"); - - fprintf(stderr, "\nUse \"%s SUBCOMMAND -?\" for details.\n", progname); -} - -/** - * Program entry point - * - * @param argc count of command line arguments - * @param argv array of NUL-terminated C strings containing command line arguments - * @return program exit status - */ -int -main(int argc, char **argv) -{ - char *progname, *subcommand, *junct_path; - enum nfsref_type type; - int arg, exit_status; - _Bool help; - - (void)setlocale(LC_ALL, ""); - (void)umask(S_IWGRP | S_IWOTH); - - exit_status = EXIT_FAILURE; - - /* Set the basename */ - if ((progname = strrchr(argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; - - xlog_stderr(1); - xlog_syslog(0); - xlog_open(progname); - - if (argc < 2) { - nfsref_usage(progname); - goto out; - } - - help = false; - type = NFSREF_TYPE_UNSPECIFIED; - while ((arg = getopt_long(argc, argv, nfsref_opts, - nfsref_longopts, NULL)) != -1) { - switch (arg) { - case 'd': - xlog_config(D_ALL, 1); - break; - case 't': - if (strcmp(optarg, "nfs-basic") == 0) - type = NFSREF_TYPE_NFS_BASIC; - else if (strcmp(optarg, "nfs-fedfs") == 0) - type = NFSREF_TYPE_NFS_FEDFS; - else { - xlog(L_ERROR, - "Unrecognized junction type: %s", - optarg); - exit(EXIT_FAILURE); - } - break; - case '?': - help = true; - } - } - - if (argc < optind + 1) { - nfsref_usage(progname); - goto out; - } - - if (!help && geteuid() != 0) { - xlog(L_ERROR, "Root permission is required"); - goto out; - } - - subcommand = argv[optind]; - junct_path = argv[optind + 1]; - - if (strcasecmp(subcommand, "add") == 0) { - if (help) { - exit_status = nfsref_add_help(progname); - goto out; - } - if (argc < optind + 3) { - xlog(L_ERROR, "Not enough positional parameters"); - nfsref_usage(progname); - goto out; - } - exit_status = nfsref_add(type, junct_path, argv, optind); - if (exit_status == EXIT_SUCCESS) - (void)junction_flush_exports_cache(); - } else if (strcasecmp(subcommand, "remove") == 0) { - if (help) { - exit_status = nfsref_remove_help(progname); - goto out; - } - exit_status = nfsref_remove(type, junct_path); - if (exit_status == EXIT_SUCCESS) - (void)junction_flush_exports_cache(); - } else if (strcasecmp(subcommand, "lookup") == 0) { - if (help) { - exit_status = nfsref_lookup_help(progname); - goto out; - } - exit_status = nfsref_lookup(type, junct_path); - } else { - xlog(L_ERROR, "Unrecognized subcommand: %s", subcommand); - nfsref_usage(progname); - } - -out: - exit(exit_status); -} diff --git a/nfs-utils-2.5.2/utils/nfsref/nfsref.h b/nfs-utils-2.5.2/utils/nfsref/nfsref.h deleted file mode 100644 index bf0e70e..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/nfsref.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file support/nfsref/nfsref.h - * @brief Declarations and definitions for nfsref command line tool - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef UTILS_NFSREF_H -#define UTILS_NFSREF_H - -/** - * Junction types supported by the "nfsref" command - */ -enum nfsref_type { - NFSREF_TYPE_UNSPECIFIED = 1, - NFSREF_TYPE_NFS_BASIC, - NFSREF_TYPE_NFS_FEDFS -}; - -int nfsref_add(enum nfsref_type type, const char *junct_path, char **argv, - int optind); -int nfsref_remove(enum nfsref_type type, const char *junct_path); -int nfsref_lookup(enum nfsref_type type, const char *junct_path); - -int nfsref_add_help(const char *progname); -int nfsref_remove_help(const char *progname); -int nfsref_lookup_help(const char *progname); - -#endif /* !UTILS_NFSREF_H */ diff --git a/nfs-utils-2.5.2/utils/nfsref/nfsref.man b/nfs-utils-2.5.2/utils/nfsref/nfsref.man deleted file mode 100644 index 1261549..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/nfsref.man +++ /dev/null @@ -1,180 +0,0 @@ -.\"@(#)nfsref.8" -.\" -.\" @file utils/nfsref/nfsref.man -.\" @brief man page for nfsref command -.\" - -.\" -.\" Copyright 2011, 2018 Oracle. All rights reserved. -.\" -.\" This file is part of nfs-utils. -.\" -.\" nfs-utils is free software; you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License version 2.0 as -.\" published by the Free Software Foundation. -.\" -.\" nfs-utils is distributed in the hope that it will be useful, but -.\" WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License version 2.0 for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" version 2.0 along with nfs-utils. If not, see: -.\" -.\" http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt -.\" -.TH NFSREF 8 "9 Jan 2018" -.SH NAME -nfsref \- manage NFS referrals -.SH SYNOPSIS -.B nfsref -.RB [ \-?d ] -.RB [ \-t -.IB type ] -.B add -.I pathname server export -.RI [ " server" -.IR export " ... ]" -.P -.B nfsref -.RB [ \-?d ] -.RB [ \-t -.IB type ] -.B remove -.I pathname -.P -.B nfsref -.RB [ \-?d ] -.RB [ \-t -.IB type ] -.B lookup -.I pathname -.SH INTRODUCTION -NFS version 4 introduces the concept of -.I file system referrals -to NFS. -A file system referral is like a symbolic link on a file server -to another file system share, possibly on another file server. -On an NFS client, a referral behaves like an automounted directory. -The client, under the server's direction, mounts a new NFS export -automatically when an application first accesses that directory. -.P -Referrals are typically used to construct a single file name space -across multiple file servers. -Because file servers control the shape of the name space, -no client configuration is required, -and all clients see the same referral information. -.P -The Linux NFS server supports NFS version 4 referrals. -Administrators can specify the -.B refer= -export option in -.I /etc/exports -to configure a list of exports from which the client can choose. -See -.BR exports (5) -for details. -.P -.SH DESCRIPTION -The -.BR nfsref (8) -command is a simple way to get started managing junction metadata. -Other administrative commands provide richer access to junction information. -.SS Subcommands -Valid -.BR nfsref (8) -subcommands are: -.IP "\fBadd\fP" -Adds junction information to the directory named by -.IR pathname . -The named directory must already exist, -and must not already contain junction information. -Regular directory contents are obscured to NFS clients by this operation. -.IP -A list of one or more file server and export path pairs -is also specified on the command line. -When creating an NFS basic junction, this list is -stored in an extended attribute of the directory. -.IP -If junction creation is successful, the -.BR nfsref (8) -command flushes the kernel's export cache -to remove previously cached junction information. -.IP "\fBremove\fP" -Removes junction information from the directory named by -.IR pathname . -The named directory must exist, -and must contain junction information. -Regular directory contents are made visible to NFS clients again by this operation. -.IP -If junction deletion is successful, the -.BR nfsref (8) -command flushes the kernel's export cache -to remove previously cached junction information. -.IP "\fBlookup\fP" -Displays junction information stored in the directory named by -.IR pathname . -The named directory must exist, -and must contain junction information. -.IP -When looking up an NFS basic junction, the junction information -in the directory is listed on -.IR stdout . -.SS Command line options -.IP "\fB\-d, \-\-debug" -Enables debugging messages during operation. -.IP "\fB\-t, \-\-type=\fIjunction-type\fP" -Specifies the junction type for the operation. Valid values for -.I junction-type -are -.B nfs-basic -or -.BR nfs-fedfs . -.IP -For the -.B add -subcommand, the default value if this option is not specified is -.BR nfs-basic . -For the -.B remove -and -.B lookup -subcommands, the -.B \-\-type -option is not required. The -.BR nfsref (8) -command operates on whatever junction contents are available. -.SH EXAMPLES -Suppose you have two file servers, -.I top.example.net -and -.IR home.example.net . -You want all your clients to mount -.I top.example.net:/ -and then see the files under -.I home.example.net:/ -automatically in -.IR top:/home . -.P -On -.IR top.example.net , -you might issue this command as root: -.RS -.sp -# mkdir /home -.br -# nfsref --type=nfs-basic add /home home.example.net / -.br -Created junction /home. -.sp -.RE -.SH FILES -.TP -.I /etc/exports -NFS server export table -.SH "SEE ALSO" -.BR exports (5) -.sp -RFC 5661 for a description of NFS version 4 referrals -.SH "AUTHOR" -Chuck Lever diff --git a/nfs-utils-2.5.2/utils/nfsref/remove.c b/nfs-utils-2.5.2/utils/nfsref/remove.c deleted file mode 100644 index 1a4e371..0000000 --- a/nfs-utils-2.5.2/utils/nfsref/remove.c +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @file utils/nfsref/remove.c - * @brief Remove junction metadata from a local file system object - */ - -/* - * Copyright 2011, 2018 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * nfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with nfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include -#include -#include - -#include -#include - -#include "junction.h" -#include "xlog.h" -#include "nfsref.h" - -/** - * Display help message for "remove" subcommand - * - * @param progname NUL-terminated C string containing name of program - * @return program exit status - */ -int -nfsref_remove_help(const char *progname) -{ - fprintf(stderr, " \n"); - - fprintf(stderr, "Usage: %s [ -t type ] remove \n\n", - progname); - - fprintf(stderr, "Remove the junction at . For FedFS " - "junctions, FSL and FSN\n"); - fprintf(stderr, "records are removed from the NSDB.\n"); - - return EXIT_SUCCESS; -} - -/** - * Remove an NFS locations-style junction - * - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -static int -nfsref_remove_nfs_basic(const char *junct_path) -{ - int status = EXIT_FAILURE; - FedFsStatus retval; - - xlog(D_GENERAL, "%s: Removing FedFS junction from %s", - __func__, junct_path); - - retval = nfs_delete_junction(junct_path); - switch (retval) { - case FEDFS_OK: - printf("Removed nfs-basic junction from %s\n", junct_path); - status = EXIT_SUCCESS; - break; - case FEDFS_ERR_NOTJUNCT: - xlog(L_ERROR, "%s is not an nfs-basic junction", junct_path); - break; - default: - xlog(L_ERROR, "Failed to delete %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - } - - return status; -} - -/** - * Remove any NFS junction information - * - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -static int -nfsref_remove_unspecified(const char *junct_path) -{ - FedFsStatus retval; - - xlog(D_GENERAL, "%s: Removing junction from %s", - __func__, junct_path); - - retval = nfs_delete_junction(junct_path); - if (retval != FEDFS_OK) { - if (retval != FEDFS_ERR_NOTJUNCT) - goto out_err; - } - - printf("Removed junction from %s\n", junct_path); - return EXIT_SUCCESS; - -out_err: - switch (retval) { - case FEDFS_ERR_NOTJUNCT: - xlog(L_ERROR, "No junction information found in %s", junct_path); - break; - default: - xlog(L_ERROR, "Failed to delete %s: %s", - junct_path, nsdb_display_fedfsstatus(retval)); - } - return EXIT_FAILURE; -} - -/** - * Remove an NFS junction - * - * @param type type of junction to add - * @param junct_path NUL-terminated C string containing pathname of junction - * @return program exit status - */ -int -nfsref_remove(enum nfsref_type type, const char *junct_path) -{ - switch (type) { - case NFSREF_TYPE_UNSPECIFIED: - return nfsref_remove_unspecified(junct_path); - case NFSREF_TYPE_NFS_BASIC: - return nfsref_remove_nfs_basic(junct_path); - default: - xlog(L_ERROR, "Unrecognized junction type"); - } - return EXIT_FAILURE; -} diff --git a/nfs-utils-2.5.2/utils/nfsstat/Makefile.am b/nfs-utils-2.5.2/utils/nfsstat/Makefile.am deleted file mode 100644 index d1555a7..0000000 --- a/nfs-utils-2.5.2/utils/nfsstat/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = nfsstat.man -EXTRA_DIST = $(man8_MANS) - -sbin_PROGRAMS = nfsstat -nfsstat_SOURCES = nfsstat.c -nfsstat_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/utils/nfsstat/nfsstat.c b/nfs-utils-2.5.2/utils/nfsstat/nfsstat.c deleted file mode 100644 index ca84532..0000000 --- a/nfs-utils-2.5.2/utils/nfsstat/nfsstat.c +++ /dev/null @@ -1,1183 +0,0 @@ -/* - * nfsstat.c Output NFS statistics - * - * Copyright (C) 1995-2005 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#define NFSSRVSTAT "/proc/net/rpc/nfsd" -#define NFSCLTSTAT "/proc/net/rpc/nfs" - -#define MOUNTSFILE "/proc/mounts" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXNRVALS 32 - -enum { - SRVPROC2_SZ = 18, - CLTPROC2_SZ = 18, - SRVPROC3_SZ = 22, - CLTPROC3_SZ = 22, - SRVPROC4_SZ = 2, - CLTPROC4_SZ = 59, - SRVPROC4OPS_SZ = 71, -}; - -static unsigned int srvproc2info[SRVPROC2_SZ+2], - srvproc2info_old[SRVPROC2_SZ+2]; /* NFSv2 call counts ([0] == 18) */ -static unsigned int cltproc2info[CLTPROC2_SZ+2], - cltproc2info_old[CLTPROC2_SZ+2]; /* NFSv2 call counts ([0] == 18) */ -static unsigned int srvproc3info[SRVPROC3_SZ+2], - srvproc3info_old[SRVPROC3_SZ+2]; /* NFSv3 call counts ([0] == 22) */ -static unsigned int cltproc3info[CLTPROC3_SZ+2], - cltproc3info_old[CLTPROC3_SZ+2]; /* NFSv3 call counts ([0] == 22) */ -static unsigned int srvproc4info[SRVPROC4_SZ+2], - srvproc4info_old[SRVPROC4_SZ+2]; /* NFSv4 call counts ([0] == 2) */ -static unsigned int cltproc4info[CLTPROC4_SZ+2], - cltproc4info_old[CLTPROC4_SZ+2]; /* NFSv4 call counts ([0] == 49) */ -static unsigned int srvproc4opsinfo[SRVPROC4OPS_SZ+2], - srvproc4opsinfo_old[SRVPROC4OPS_SZ+2]; /* NFSv4 call counts ([0] == 59) */ -static unsigned int srvnetinfo[5], srvnetinfo_old[5]; /* 0 # of received packets - * 1 UDP packets - * 2 TCP packets - * 3 TCP connections - */ -static unsigned int cltnetinfo[5], cltnetinfo_old[5]; /* 0 # of received packets - * 1 UDP packets - * 2 TCP packets - * 3 TCP connections - */ - -static unsigned int srvrpcinfo[6], srvrpcinfo_old[6]; /* 0 total # of RPC calls - * 1 total # of bad calls - * 2 bad format - * 3 authentication failed - * 4 unknown client - */ -static unsigned int cltrpcinfo[4], cltrpcinfo_old[4]; /* 0 total # of RPC calls - * 1 retransmitted calls - * 2 cred refreshs - */ - -static unsigned int srvrcinfo[9], srvrcinfo_old[9]; /* 0 repcache hits - * 1 repcache hits - * 2 uncached reqs - * (for pre-2.4 kernels:) - * 3 FH lookups - * 4 'anon' FHs - * 5 noncached non-directories - * 6 noncached directories - * 7 stale - */ - -static unsigned int srvfhinfo[7], srvfhinfo_old[7]; /* (for kernels >= 2.4.0) - * 0 stale - * 1 FH lookups - * 2 'anon' FHs - * 3 noncached directories - * 4 noncached non-directories - * leave hole to relocate stale for order - * compatability. - */ - -static unsigned int srvioinfo[3], srvioinfo_old[3]; /* 0 bytes read - * 1 bytes written - */ - -static unsigned int srvrainfo[13], srvrainfo_old[13]; /* 0 ra cache size - * 1..11 depth of ra cache hit - * 12 ra cache misses - */ - -static const char * nfsv2name[SRVPROC2_SZ] = { - "null", "getattr", "setattr", "root", "lookup", "readlink", - "read", "wrcache", "write", "create", "remove", "rename", - "link", "symlink", "mkdir", "rmdir", "readdir", "fsstat" -}; - -static const char * nfsv3name[SRVPROC3_SZ] = { - "null", "getattr", "setattr", "lookup", "access", "readlink", - "read", "write", "create", "mkdir", "symlink", "mknod", - "remove", "rmdir", "rename", "link", "readdir", "readdirplus", - "fsstat", "fsinfo", "pathconf", "commit" -}; - -static const char * nfssrvproc4name[SRVPROC4_SZ] = { - "null", - "compound", -}; - -static const char * nfscltproc4name[CLTPROC4_SZ] = { - "null", "read", "write", "commit", "open", "open_conf", - "open_noat", "open_dgrd", "close", "setattr", "fsinfo", "renew", - "setclntid", "confirm", "lock", - "lockt", "locku", "access", "getattr", "lookup", "lookup_root", - "remove", "rename", "link", "symlink", "create", "pathconf", - "statfs", "readlink", "readdir", "server_caps", "delegreturn", "getacl", - "setacl", "fs_locations", - "rel_lkowner", "secinfo", "fsid_present", - /* nfsv4.1 client ops */ - "exchange_id", - "create_session", - "destroy_session", - "sequence", - "get_lease_time", - "reclaim_comp", - "layoutget", - "getdevinfo", - "layoutcommit", - "layoutreturn", - "secinfo_no", - "test_stateid", - "free_stateid", - "getdevicelist", - "bind_conn_to_ses", - "destroy_clientid", - /* nfsv4.2 client ops */ - "seek", - "allocate", - "deallocate", - "layoutstats", - "clone", -}; - -static const char * nfssrvproc4opname[SRVPROC4OPS_SZ] = { - "op0-unused", "op1-unused", "op2-future", "access", "close", "commit", - "create", "delegpurge", "delegreturn", "getattr", "getfh", "link", - "lock", "lockt", "locku", "lookup", "lookup_root", "nverify", - "open", "openattr", "open_conf", "open_dgrd", "putfh", "putpubfh", - "putrootfh", "read", "readdir", "readlink", "remove", "rename", - "renew", "restorefh", "savefh", "secinfo", "setattr", "setcltid", - "setcltidconf", "verify", "write", "rellockowner", - /* nfsv4.1 server ops */ - "bc_ctl", - "bind_conn", - "exchange_id", - "create_ses", - "destroy_ses", - "free_stateid", - "getdirdeleg", - "getdevinfo", - "getdevlist", - "layoutcommit", - "layoutget", - "layoutreturn", - "secinfononam", - "sequence", - "set_ssv", - "test_stateid", - "want_deleg", - "destroy_clid", - "reclaim_comp", - /* nfsv4.2 server ops */ - "allocate", - "copy", - "copy_notify", - "deallocate", - "ioadvise", - "layouterror", - "layoutstats", - "offloadcancel", - "offloadstatus", - "readplus", - "seek", - "write_same", -}; - -#define LABEL_srvnet "Server packet stats:\n" -#define LABEL_srvrpc "Server rpc stats:\n" -#define LABEL_srvrc "Server reply cache:\n" -#define LABEL_srvfh "Server file handle cache:\n" -#define LABEL_srvio "Server io stats:\n" -#define LABEL_srvra "Server read ahead cache:\n" -#define LABEL_srvproc2 "Server nfs v2:\n" -#define LABEL_srvproc3 "Server nfs v3:\n" -#define LABEL_srvproc4 "Server nfs v4:\n" -#define LABEL_srvproc4ops "Server nfs v4 operations:\n" -#define LABEL_cltnet "Client packet stats:\n" -#define LABEL_cltrpc "Client rpc stats:\n" -#define LABEL_cltproc2 "Client nfs v2:\n" -#define LABEL_cltproc3 "Client nfs v3:\n" -#define LABEL_cltproc4 "Client nfs v4:\n" - -typedef struct statinfo { - char *tag; - char *label; - int nrvals; - unsigned int * valptr; -} statinfo; - -/* - * We now build the arrays of statinfos using macros, which will make it easier - * to add new variables for --sleep. e.g., SRV(net) expands into the struct - * statinfo: { "net", "Server packet stats:\n", 5, srvnetinfo } - */ -#define ARRAYSIZE(x) sizeof(x)/sizeof(*x) -#define STATINFO(k, t, s...) { #t, LABEL_##k##t, ARRAYSIZE(k##t##info##s), k##t##info##s } -#define SRV(t, s...) STATINFO(srv, t, s) -#define CLT(t, s...) STATINFO(clt, t, s) -#define DECLARE_SRV(n, s...) static statinfo n##s[] = { \ - SRV(net,s), \ - SRV(rpc,s), \ - SRV(rc,s), \ - SRV(fh,s), \ - SRV(io,s), \ - SRV(ra,s), \ - SRV(proc2,s), \ - SRV(proc3,s),\ - SRV(proc4,s), \ - SRV(proc4ops,s),\ - { NULL, NULL, 0, NULL }\ - } -#define DECLARE_CLT(n, s...) static statinfo n##s[] = { \ - CLT(net,s), \ - CLT(rpc,s), \ - CLT(proc2,s),\ - CLT(proc3,s), \ - CLT(proc4,s),\ - { NULL, NULL, 0, NULL }\ - } -DECLARE_SRV(srvinfo); -DECLARE_SRV(srvinfo, _old); -DECLARE_CLT(cltinfo); -DECLARE_CLT(cltinfo, _old); - -static void print_all_stats(int, int, int); -static void print_server_stats(int); -static void print_client_stats(int); -static void print_stats_list(int, int, int); -static void print_numbers(const char *, unsigned int *, - unsigned int); -static void print_callstats(const char *, const char **, - unsigned int *, unsigned int); -static void print_callstats_list(const char *, const char **, - unsigned int *, unsigned int); -static int parse_raw_statfile(const char *, struct statinfo *); -static int parse_pretty_statfile(const char *, struct statinfo *); - -static statinfo *get_stat_info(const char *, struct statinfo *); - -static int mounts(const char *); - -static void get_stats(const char *, struct statinfo *, int *, int, - int); -static int has_stats(const unsigned int *, int); -static int has_rpcstats(const unsigned int *, int); -static void diff_stats(struct statinfo *, struct statinfo *, int); -static void unpause(int); -static void update_old_counters(struct statinfo *, struct statinfo *); - -static time_t starttime; - -#define PRNT_CALLS 0x0001 -#define PRNT_RPC 0x0002 -#define PRNT_NET 0x0004 -#define PRNT_FH 0x0008 -#define PRNT_RC 0x0010 -#define PRNT_IO 0x0020 -#define PRNT_RA 0x0040 -#define PRNT_AUTO 0x1000 -#define PRNT_V2 0x2000 -#define PRNT_V3 0x4000 -#define PRNT_V4 0x8000 -#define PRNT_ALL 0x0fff - -int versions[] = { - PRNT_V2, - PRNT_V3, - PRNT_V4 -}; - -static void usage(char *name) -{ - printf("Usage: %s [OPTION]...\n\ -\n\ - -m, --mounts Show statistics on mounted NFS filesystems\n\ - -c, --client Show NFS client statistics\n\ - -s, --server Show NFS server statistics\n\ - -2 Show NFS version 2 statistics\n\ - -3 Show NFS version 3 statistics\n\ - -4 Show NFS version 4 statistics\n\ - -o [facility] Show statistics on particular facilities.\n\ - nfs NFS protocol information\n\ - rpc General RPC information\n\ - net Network layer statistics\n\ - fh Usage information on the server's file handle cache\n\ - io Usage information on the server's io statistics\n\ - ra Usage information on the server's read ahead cache\n\ - rc Usage information on the server's request reply cache\n\ - all Select all of the above\n\ - -v, --verbose, --all Same as '-o all'\n\ - -r, --rpc Show RPC statistics\n\ - -n, --nfs Show NFS statistics\n\ - -Z[#], --sleep[=#] Collects stats until interrupted.\n\ - Cumulative stats are then printed\n\ - If # is provided, stats will be output every\n\ - # seconds.\n\ - -S, --since file Shows difference between current stats and those in 'file'\n\ - -l, --list Prints stats in list format\n\ - --version Show program version\n\ - --help What you just did\n\ -\n", name); - exit(0); -} - -static struct option longopts[] = -{ - { "acl", 0, 0, 'a' }, - { "all", 0, 0, 'v' }, - { "auto", 0, 0, '\3' }, - { "client", 0, 0, 'c' }, - { "mounts", 0, 0, 'm' }, - { "nfs", 0, 0, 'n' }, - { "rpc", 0, 0, 'r' }, - { "server", 0, 0, 's' }, - { "verbose", 0, 0, 'v' }, - { "zero", 0, 0, 'z' }, - { "help", 0, 0, '\1' }, - { "version", 0, 0, '\2' }, - { "sleep", 2, 0, 'Z' }, - { "since", 1, 0, 'S' }, - { "list", 0, 0, 'l' }, - { NULL, 0, 0, 0 } -}; -int opt_sleep; - -int -main(int argc, char **argv) -{ - int opt_all = 0, - opt_srv = 0, - opt_clt = 0, - opt_prt = 0, - sleep_time = 0, - opt_list =0, - opt_since = 0; - int c; - char *progname, - *serverfile = NFSSRVSTAT, - *clientfile = NFSCLTSTAT; - - struct statinfo *serverinfo = srvinfo, - *serverinfo_tmp = srvinfo_old, - *clientinfo = cltinfo, - *clientinfo_tmp = cltinfo_old; - - struct sigaction act = { - .sa_handler = unpause, - .sa_flags = SA_RESETHAND, - }; - - if ((progname = strrchr(argv[0], '/'))) - progname++; - else - progname = argv[0]; - - while ((c = getopt_long(argc, argv, "234acmno:Z::S:vrslz\1\2", longopts, NULL)) != EOF) { - switch (c) { - case 'a': - fprintf(stderr, "nfsstat: nfs acls are not yet supported.\n"); - return 1; - case 'c': - opt_clt = 1; - break; - case 'n': - opt_prt |= PRNT_CALLS; - break; - case 'o': - if (!strcmp(optarg, "nfs")) - opt_prt |= PRNT_CALLS; - else if (!strcmp(optarg, "rpc")) - opt_prt |= PRNT_RPC; - else if (!strcmp(optarg, "net")) - opt_prt |= PRNT_NET; - else if (!strcmp(optarg, "rc")) - opt_prt |= PRNT_RC; - else if (!strcmp(optarg, "fh")) - opt_prt |= PRNT_FH; - else if (!strcmp(optarg, "io")) - opt_prt |= PRNT_IO; - else if (!strcmp(optarg, "ra")) - opt_prt |= PRNT_RA; - else if (!strcmp(optarg, "all")) - opt_prt |= PRNT_CALLS | PRNT_RPC | PRNT_NET | PRNT_RC | PRNT_FH | PRNT_IO | PRNT_RA; - else { - fprintf(stderr, "nfsstat: unknown category: " - "%s\n", optarg); - return 2; - } - break; - case 'Z': - opt_sleep = 1; - if (optarg) { - sleep_time = atoi(optarg); - } - break; - case 'S': - opt_since = 1; - serverfile = optarg; - clientfile = optarg; - break; - case '2': - case '3': - case '4': - opt_prt |= versions[c - '2']; - break; - case 'v': - opt_all = 1; - break; - case '\3': - opt_prt |= PRNT_AUTO; - break; - case 'r': - opt_prt |= PRNT_RPC; - break; - case 's': - opt_srv = 1; - break; - case 'l': - opt_list = 1; - break; - case 'z': - fprintf(stderr, "nfsstat: zeroing of nfs statistics " - "not yet supported\n"); - return 2; - case 'm': - return ! mounts(MOUNTSFILE); - case '\1': - usage(progname); - return 0; - case '\2': - fprintf(stdout, "nfsstat: " VERSION "\n"); - return 0; - default: - printf("Try `%s --help' for more information.\n", progname); - return 1; - } - } - - if (opt_all) { - opt_srv = opt_clt = 1; - opt_prt |= PRNT_ALL; - } - if (!(opt_srv + opt_clt)) - opt_srv = opt_clt = 1; - if (!(opt_prt & 0xfff)) { - opt_prt |= PRNT_CALLS + PRNT_RPC; - } - if (!(opt_prt & 0xe000)) { - opt_prt |= PRNT_AUTO; - } - if ((opt_prt & (PRNT_FH|PRNT_RC|PRNT_IO|PRNT_RA)) && !opt_srv) { - fprintf(stderr, - "You requested fh/io/ra/rc " - "statistics while using the -c option.\n" - "This information is available only for the NFS " - "server.\n"); - } - - if (opt_since || opt_sleep) { - serverinfo = srvinfo_old; - serverinfo_tmp = srvinfo; - clientinfo = cltinfo_old; - clientinfo_tmp = cltinfo; - } - - if (opt_srv) - get_stats(serverfile, serverinfo, &opt_srv, opt_clt, 1); - if (opt_clt) - get_stats(clientfile, clientinfo, &opt_clt, opt_srv, 0); - - if (opt_sleep && !sleep_time) { - starttime = time(NULL); - printf("Collecting statistics; press CTRL-C to view results from interval (i.e., from pause to CTRL-C).\n"); - if (sigaction(SIGINT, &act, NULL) != 0) { - fprintf(stderr, "Error: couldn't register for signal and pause.\n"); - return 1; - } - pause(); - } - - if (opt_since || (opt_sleep && !sleep_time)) { - if (opt_srv) { - get_stats(NFSSRVSTAT, serverinfo_tmp, &opt_srv, opt_clt, 1); - diff_stats(serverinfo_tmp, serverinfo, 1); - } - if (opt_clt) { - get_stats(NFSCLTSTAT, clientinfo_tmp, &opt_clt, opt_srv, 0); - diff_stats(clientinfo_tmp, clientinfo, 0); - } - } - if(sleep_time) { - while(1) { - if (opt_srv) { - get_stats(NFSSRVSTAT, serverinfo_tmp , &opt_srv, opt_clt, 1); - diff_stats(serverinfo_tmp, serverinfo, 1); - } - if (opt_clt) { - get_stats(NFSCLTSTAT, clientinfo_tmp, &opt_clt, opt_srv, 0); - diff_stats(clientinfo_tmp, clientinfo, 0); - } - if (opt_list) { - print_stats_list(opt_srv, opt_clt, opt_prt); - } else { - print_all_stats(opt_srv, opt_clt, opt_prt); - } - fflush(stdout); - - if (opt_srv) - update_old_counters(serverinfo_tmp, serverinfo); - if (opt_clt) - update_old_counters(clientinfo_tmp, clientinfo); - - sleep(sleep_time); - } - } else { - if (opt_list) { - print_stats_list(opt_srv, opt_clt, opt_prt); - } else { - print_all_stats(opt_srv, opt_clt, opt_prt); - } - } - - return 0; -} - -static void -print_all_stats (int opt_srv, int opt_clt, int opt_prt) -{ - if (opt_srv) - print_server_stats(opt_prt); - - if (opt_clt) - print_client_stats(opt_prt); -} - -static void -print_server_stats(int opt_prt) -{ - if (opt_prt & PRNT_NET) { - if (opt_sleep && !has_rpcstats(srvnetinfo, 4)) { - } else { - print_numbers( LABEL_srvnet - "packets udp tcp tcpconn\n", - srvnetinfo, 4); - printf("\n"); - } - } - if (opt_prt & PRNT_RPC) { - if (opt_sleep && !has_rpcstats(srvrpcinfo, 5)) { - ; - } else { - print_numbers(LABEL_srvrpc - "calls badcalls badfmt badauth badclnt\n", - srvrpcinfo, 5); - printf("\n"); - } - } - if (opt_prt & PRNT_RC) { - if (opt_sleep && !has_rpcstats(srvrcinfo, 3)) { - ; - } else { - print_numbers(LABEL_srvrc - "hits misses nocache\n", - srvrcinfo, 3); - printf("\n"); - } - } - if (opt_prt & PRNT_IO) { - if (opt_sleep && !has_rpcstats(srvioinfo, 3)) { - ; - } else { - print_numbers(LABEL_srvio - "read write\n", - srvioinfo, 2); - printf("\n"); - } - } - if (opt_prt & PRNT_RA) { - if (opt_sleep && !has_rpcstats(srvrainfo, 3)) { - ; - } else { - print_numbers(LABEL_srvra - "size 0-10% 10-20% 20-30% 30-40% 40-50% 50-60% 60-70% 70-80% 80-90% 90-100% notfound\n", - srvrainfo, 12); - printf("\n"); - } - } - - /* - * 2.2 puts all fh-related info after the 'rc' header - * 2.4 puts all fh-related info after the 'fh' header, but relocates - * 'stale' to the start and swaps dir and nondir :-( - * We preseve the 2.2 order - */ - if (opt_prt & PRNT_FH) { - if (get_stat_info("fh", srvinfo)) { /* >= 2.4 */ - int t = srvfhinfo[3]; - srvfhinfo[3]=srvfhinfo[4]; - srvfhinfo[4]=t; - - srvfhinfo[5]=srvfhinfo[0]; /* relocate 'stale' */ - - print_numbers( - LABEL_srvfh - "lookup anon ncachedir ncachenondir stale\n", - srvfhinfo + 1, 5); - } else /* < 2.4 */ - print_numbers( - LABEL_srvfh - "lookup anon ncachedir ncachedir stale\n", - srvrcinfo + 3, 5); - printf("\n"); - } - if (opt_prt & PRNT_CALLS) { - int has_v2_stats = has_stats(srvproc2info, SRVPROC2_SZ+2); - int has_v3_stats = has_stats(srvproc3info, SRVPROC3_SZ+2); - int has_v4_stats = has_stats(srvproc4info, SRVPROC4_SZ+2); - - if ((opt_prt & PRNT_V2) || - ((opt_prt & PRNT_AUTO) && has_v2_stats)) { - if (!opt_sleep || has_v2_stats) { - print_callstats(LABEL_srvproc2, - nfsv2name, srvproc2info + 1, - sizeof(nfsv2name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V3) || - ((opt_prt & PRNT_AUTO) && has_v3_stats)) { - if (!opt_sleep || has_v3_stats) { - print_callstats(LABEL_srvproc3, - nfsv3name, srvproc3info + 1, - sizeof(nfsv3name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V4) || - ((opt_prt & PRNT_AUTO) && has_v4_stats)) { - if (!opt_sleep || has_v4_stats) { - print_callstats( LABEL_srvproc4, - nfssrvproc4name, srvproc4info + 1, - sizeof(nfssrvproc4name)/sizeof(char *)); - print_callstats(LABEL_srvproc4ops, - nfssrvproc4opname, srvproc4opsinfo + 1, - sizeof(nfssrvproc4opname)/sizeof(char *)); - } - } - } -} -static void -print_client_stats(int opt_prt) -{ - if (opt_prt & PRNT_NET) { - if (opt_sleep && !has_rpcstats(cltnetinfo, 4)) { - ; - } else { - print_numbers(LABEL_cltnet - "packets udp tcp tcpconn\n", - cltnetinfo, 4); - printf("\n"); - } - } - if (opt_prt & PRNT_RPC) { - if (opt_sleep && !has_rpcstats(cltrpcinfo, 3)) { - ; - } else { - print_numbers(LABEL_cltrpc - "calls retrans authrefrsh\n", - cltrpcinfo, 3); - printf("\n"); - } - } - if (opt_prt & PRNT_CALLS) { - int has_v2_stats = has_stats(cltproc2info, CLTPROC2_SZ+2); - int has_v3_stats = has_stats(cltproc3info, CLTPROC3_SZ+2); - int has_v4_stats = has_stats(cltproc4info, CLTPROC4_SZ+2); - if ((opt_prt & PRNT_V2) || - ((opt_prt & PRNT_AUTO) && has_v2_stats)) { - if (!opt_sleep || has_v2_stats) { - print_callstats(LABEL_cltproc2, - nfsv2name, cltproc2info + 1, - sizeof(nfsv2name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V3) || - ((opt_prt & PRNT_AUTO) && has_v3_stats)) { - if (!opt_sleep || has_v3_stats) { - print_callstats(LABEL_cltproc3, - nfsv3name, cltproc3info + 1, - sizeof(nfsv3name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V4) || - ((opt_prt & PRNT_AUTO) && has_v4_stats)) { - if (!opt_sleep || has_v4_stats) { - print_callstats(LABEL_cltproc4, - nfscltproc4name, cltproc4info + 1, - sizeof(nfscltproc4name)/sizeof(char *)); - } - } - } -} - -static void -print_clnt_list(int opt_prt) -{ - if (opt_prt & PRNT_CALLS) { - int has_v2_stats = has_stats(cltproc2info, CLTPROC2_SZ+2); - int has_v3_stats = has_stats(cltproc3info, CLTPROC3_SZ+2); - int has_v4_stats = has_stats(cltproc4info, CLTPROC4_SZ+2); - if ((opt_prt & PRNT_V2) || - ((opt_prt & PRNT_AUTO) && has_v2_stats)) { - if (!opt_sleep || has_v2_stats) { - print_callstats_list("nfs v2 client", - nfsv2name, cltproc2info + 1, - sizeof(nfsv2name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V3) || - ((opt_prt & PRNT_AUTO) && has_v3_stats)) { - if (!opt_sleep || has_v3_stats) { - print_callstats_list("nfs v3 client", - nfsv3name, cltproc3info + 1, - sizeof(nfsv3name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V4) || - ((opt_prt & PRNT_AUTO) && has_v4_stats)) { - if (!opt_sleep || has_v4_stats) { - print_callstats_list("nfs v4 client", - nfscltproc4name, cltproc4info + 1, - sizeof(nfscltproc4name)/sizeof(char *)); - } - } - } -} -static void -print_serv_list(int opt_prt) -{ - if (opt_prt & PRNT_CALLS) { - int has_v2_stats = has_stats(srvproc2info, SRVPROC2_SZ+2); - int has_v3_stats = has_stats(srvproc3info, SRVPROC3_SZ+2); - int has_v4_stats = has_stats(srvproc4info, SRVPROC4_SZ+2); - if ((opt_prt & PRNT_V2) || - ((opt_prt & PRNT_AUTO) && has_v2_stats)) { - if (!opt_sleep || has_v2_stats) { - print_callstats_list("nfs v2 server", - nfsv2name, srvproc2info + 1, - sizeof(nfsv2name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V3) || - ((opt_prt & PRNT_AUTO) && has_v3_stats)) { - if (!opt_sleep || has_v3_stats) { - print_callstats_list("nfs v3 server", - nfsv3name, srvproc3info + 1, - sizeof(nfsv3name)/sizeof(char *)); - } - } - if ((opt_prt & PRNT_V4) || - ((opt_prt & PRNT_AUTO) && has_v4_stats)) { - if (!opt_sleep || has_v4_stats) { - print_callstats_list("nfs v4 server", - nfssrvproc4name, srvproc4info + 1, - sizeof(nfssrvproc4name)/sizeof(char *)); - print_callstats_list("nfs v4 servop", - nfssrvproc4opname, srvproc4opsinfo + 1, - sizeof(nfssrvproc4opname)/sizeof(char *)); - } - } - } -} -static void -print_stats_list(int opt_srv, int opt_clt, int opt_prt) -{ - if (opt_srv) - print_serv_list(opt_prt); - - if (opt_clt) - print_clnt_list(opt_prt); -} - -static statinfo * -get_stat_info(const char *sp, struct statinfo *statp) -{ - struct statinfo *ip; - - for (ip = statp; ip->tag; ip++) { - if (!strcmp(sp, ip->tag)) - return ip; - } - - return NULL; -} - -static void -print_numbers(const char *hdr, unsigned int *info, unsigned int nr) -{ - unsigned int i; - - fputs(hdr, stdout); - for (i = 0; i < nr; i++) - printf("%s%-8u", i? " " : "", info[i]); - printf("\n"); -} - -static void -print_callstats(const char *hdr, const char **names, - unsigned int *info, unsigned int nr) -{ - unsigned long long total; - unsigned long long pct; - unsigned int i, j; - - fputs(hdr, stdout); - for (i = 0, total = 0; i < nr; i++) - total += info[i]; - if (!total) - total = 1; - for (i = 0; i < nr; i += 5) { - for (j = 0; j < 5 && i + j < nr; j++) - printf("%-17s", names[i+j]); - printf("\n"); - for (j = 0; j < 5 && i + j < nr; j++) { - pct = ((unsigned long long) info[i+j]*100)/total; - printf("%-8u%3llu%% ", info[i+j], pct); - } - printf("\n"); - } - printf("\n"); -} - -static void -print_callstats_list(const char *hdr, const char **names, - unsigned int *callinfo, unsigned int nr) -{ - unsigned long long calltotal; - unsigned int i; - - for (i = 0, calltotal = 0; i < nr; i++) { - calltotal += callinfo[i]; - } - if (!calltotal) - return; - printf("%13s %13s %8llu \n", hdr, "total:", calltotal); - printf("------------- ------------- --------\n"); - for (i = 0; i < nr; i++) { - if (callinfo[i]) - printf("%13s %12s: %8u \n", hdr, names[i], callinfo[i]); - } - printf("\n"); - -} - - -/* returns 0 on success, 1 otherwise */ -static int -parse_raw_statfile(const char *name, struct statinfo *statp) -{ - char buffer[4096], *next; - FILE *fp; - - /* Being unable to read e.g. the nfsd stats file shouldn't - * be a fatal error -- it usually means the module isn't loaded. - */ - if ((fp = fopen(name, "r")) == NULL) { - // fprintf(stderr, "Warning: %s: %m\n", name); - return 1; - } - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - struct statinfo *ip; - char *sp, *line = buffer; - unsigned int i, cnt; - unsigned int total = 0; - - if ((next = strchr(line, '\n')) != NULL) - *next++ = '\0'; - if (!(sp = strtok(line, " \t"))) - continue; - - ip = get_stat_info(sp, statp); - if (!ip) - continue; - - cnt = ip->nrvals; - - for (i = 0; i < cnt; i++) { - if (!(sp = strtok(NULL, " \t"))) - break; - ip->valptr[i] = (unsigned int) strtoul(sp, NULL, 0); - total += ip->valptr[i]; - } - ip->valptr[cnt - 1] = total; - } - - fclose(fp); - return 0; -} - -/* returns 0 on success, 1 otherwise */ -static int -parse_pretty_statfile(const char *filename, struct statinfo *info) -{ - int numvals, curindex, numconsumed, n, err = 1; - unsigned int sum; - char buf[4096], *bufp, *fmt, is_proc; - FILE *fp = NULL; - struct statinfo *ip; - - if ((fp = fopen(filename, "r")) == NULL) - //err(2, "Unable to open statfile '%s'.\n", filename); - goto out; - - while (fgets(buf, sizeof(buf), fp) != NULL) { - for (ip = info; ip->tag; ip++) { - if (strcmp(buf, ip->label)) - continue; - - sum = 0; - numvals = ip->nrvals - 1; - is_proc = strncmp("proc", ip->tag, 4) ? 0 : 1; - if (is_proc) { - fmt = " %u %*u%% %n"; - curindex = 1; - ip->valptr[0] = 0; - } else { - fmt = " %u %n"; - curindex = 0; - } -more_stats: - /* get (and skip) header */ - if (fgets(buf, sizeof(buf), fp) == NULL) { - fprintf(stderr, "Failed to locate header after " - "label for '%s' in %s.\n", - ip->tag, filename); - goto out; - } - /* no header -- done with this "tag" */ - if (*buf == '\n') { - ip->valptr[numvals] = sum; - break; - } - /* get stats */ - if (fgets(buf, sizeof(buf), fp) == NULL) { - fprintf(stderr, "Failed to locate stats after " - "header for '%s' in %s.\n", - ip->tag, filename); - goto out; - } - bufp = buf; - for (; curindex < numvals; curindex++) { -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - n = sscanf(bufp, fmt, &ip->valptr[curindex], - &numconsumed); -#pragma GCC diagnostic warning "-Wformat-nonliteral" - if (n != 1) - break; - if (is_proc) { - ip->valptr[0]++; - sum++; - } - sum += ip->valptr[curindex]; - bufp += numconsumed; - } - goto more_stats; - } - } - err = 0; -out: - if (fp) - fclose(fp); - return err; -} - -static int -mounts(const char *name) -{ - char buffer[4096], *next; - FILE *fp; - - /* Being unable to read e.g. the nfsd stats file shouldn't - * be a fatal error -- it usually means the module isn't loaded. - */ - if ((fp = fopen(name, "r")) == NULL) { - fprintf(stderr, "Warning: %s: %s\n", name, strerror(errno)); - return 0; - } - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - char *line = buffer; - char *device, *mount, *type, *flags; - - if ((next = strchr(line, '\n')) != NULL) - *next = '\0'; - - if (!(device = strtok(line, " \t"))) - continue; - - if (!(mount = strtok(NULL, " \t"))) - continue; - - if (!(type = strtok(NULL, " \t"))) - continue; - - if (strcmp(type, "nfs") && strcmp(type,"nfs4")) { - continue; - } - - if (!(flags = strtok(NULL, " \t"))) - continue; - - printf("%s from %s\n", mount, device); - printf(" Flags:\t%s\n", flags); - printf("\n"); - - continue; - } - - fclose(fp); - return 1; -} - -static void -get_stats(const char *file, struct statinfo *info, int *opt, int other_opt, - int is_srv) -{ - FILE *fp; - char buf[10]; - int err = 1; - char *label = is_srv ? "Server" : "Client"; - - /* try to guess what type of stat file we're dealing with */ - if ((fp = fopen(file, "r")) == NULL) - goto out; - if (fgets(buf, 10, fp) == NULL) - goto out; - if (!strncmp(buf, "net ", 4)) { - /* looks like raw client stats */ - if (is_srv) { - fprintf(stderr, "Warning: no server info present in " - "raw client stats file.\n"); - *opt = 0; - } else - err = parse_raw_statfile(file, info); - } else if (!strncmp(buf, "rc ", 3)) { - /* looks like raw server stats */ - if (!is_srv) { - fprintf(stderr, "Warning: no client info present in " - "raw server stats file.\n"); - *opt = 0; - } else - err = parse_raw_statfile(file, info); - } else - /* looks like pretty client and server stats */ - err = parse_pretty_statfile(file, info); -out: - if (fp) - fclose(fp); - if (err) { - if (!other_opt) { - fprintf(stderr, "Error: No %s Stats (%s: %s). \n", - label, file, strerror(errno)); - exit(2); - } - *opt = 0; - } -} - -/* - * This is for proc2/3/4-type stats, where, in the /proc files, the first entry's value - * denotes the number of subsequent entries. statinfo value arrays contain an additional - * field at the end which contains the sum of all previous elements in the array -- so, - * there are stats if the sum's greater than the entry-count. - */ -static int -has_stats(const unsigned int *info, int nr) -{ - return (info[0] && info[nr-1] > info[0]); -} -static int -has_rpcstats(const unsigned int *info, int size) -{ - int i, cnt; - - for (i=0, cnt=0; i < size; i++) - cnt += info[i]; - return cnt; -} - -/* - * take the difference of each individual stat value in 'new' and 'old' - * and store the results back into 'new' - */ -static void -diff_stats(struct statinfo *new, struct statinfo *old, int is_srv) -{ - int i, j, nodiff_first_index, should_diff; - - /* - * Different stat types have different formats in the /proc - * files: for the proc2/3/4-type stats, the first entry has - * the total number of subsequent entries; one does not want - * to diff that first entry. The other stat types aren't like - * this. So, we diff a given entry if it's not of one of the - * procX types ("i" < 2 for clt, < 4 for srv), or if it's not - * the first entry ("j" > 0). - */ - nodiff_first_index = 2 + (2 * is_srv); - - for (i = 0; old[i].tag; i++) { - for (j = 0; j < new[i].nrvals; j++) { - should_diff = (i < nodiff_first_index || j > 0); - if (should_diff) - new[i].valptr[j] -= old[i].valptr[j]; - } - - /* - * Make sure that the "totals" entry (last value in - * each stat array) for the procX-type stats has the - * "numentries" entry's (first value in procX-type - * stat arrays) constant value added-back after the - * diff -- i.e., it should always be included in the - * total. - */ - if (!strncmp("proc", new[i].tag, 4) && old[i].valptr[0]) - new[i].valptr[new[i].nrvals - 1] += new[i].valptr[0]; - } -} - -static void -unpause(int sig) -{ - double time_diff; - int minutes, seconds; - time_t endtime; - - endtime = time(NULL); - time_diff = difftime(endtime, starttime); - minutes = time_diff / 60; - seconds = (int)time_diff % 60; - printf("Signal %d received; displaying (only) statistics gathered over the last %d minutes, %d seconds:\n\n", sig, minutes, seconds); -} - -static void -update_old_counters(struct statinfo *new, struct statinfo *old) -{ - int z, i; - for (z = 0; old[z].tag; z++) - for (i = 0; i <= old[z].nrvals; i++) - old[z].valptr[i] += new[z].valptr[i]; - -} diff --git a/nfs-utils-2.5.2/utils/nfsstat/nfsstat.man b/nfs-utils-2.5.2/utils/nfsstat/nfsstat.man deleted file mode 100644 index 2e52935..0000000 --- a/nfs-utils-2.5.2/utils/nfsstat/nfsstat.man +++ /dev/null @@ -1,173 +0,0 @@ -.\" -.\" nfsstat(8) -.\" -.\" Copyright (C) 1996-2005 Olaf Kirch -.TH nfsstat 8 "7 Aug 2007" -.SH NAME -nfsstat \- list NFS statistics -.SH SYNOPSIS -.B nfsstat -[\fIOPTION\fR]... -.SH DESCRIPTION -The -.B nfsstat -displays statistics kept about NFS client and server activity. -.SH OPTIONS -.TP -.B \-s, \-\-server -Print only server-side statistics. The default is to print both server and -client statistics. -.TP -.B \-c, \-\-client -Print only client-side statistics. -.TP -.B \-n, \-\-nfs -Print only NFS statistics. The default is to print both NFS and RPC -information. -.TP -.B \-2 -Print only NFS v2 statistics. The default is to only print information -about the versions of \fBNFS\fR that have non-zero counts. -.TP -.B \-3 -Print only NFS v3 statistics. The default is to only print information -about the versions of \fBNFS\fR that have non-zero counts. -.TP -.B \-4 -Print only NFS v4 statistics. The default is to only print information -about the versions of \fBNFS\fR that have non-zero counts. -.TP -.B \-m, \-\-mounts -Print information about each of the mounted \fBNFS\fR file systems. - -If this option is used, all other options are ignored. -.TP -.B \-r, \-\-rpc -Print only RPC statistics. -.TP -.BI \-o " facility -Display statistics for the specified facility, which must be one of: -.RS -.TP -.B nfs -NFS protocol information, split up by RPC call. -.TP -.B rpc -General RPC information. -.TP -.B net -Network layer statistics, such as the number of received packets, number -of TCP connections, etc. -.TP -.B fh -Usage information on the server's file handle cache, including the -total number of lookups, and the number of hits and misses. -.TP -.B rc -Usage information on the server's request reply cache, including the -total number of lookups, and the number of hits and misses. -.TP -.B io -Usage information on the server's io statistics; bytes read and -written. -.TP -.B ra -Usage information on the server's read ahead cache, including the -ra cache size, the depth of ra cache hits, and ra cache misses. -.TP -.B all -Display all of the above facilities. -.RE -.TP -.B \-v, \-\-verbose -This is equivalent to \fB\-o all\fR. -.TP -.B \-l, \-\-list -Print information in list form. -.TP -.BI "\-S, \-\-since " file -Instead of printing current statistics, -.B nfsstat -imports statistics from -.I file -and displays the difference between those and the current statistics. -Valid input -.IR file "s may be in the form of " -.B /proc/net/rpc/nfs -(raw client stats), -.B /proc/net/rpc/nfsd -(raw server stats), or saved output from -.B nfsstat -itself (client and/or server stats). Any statistics missing from a saved -.B nfsstat -output -.I file -are treated as zeroes. -.TP -.B \-Z[interval], \-\-sleep=[interval] -Instead of printing current statistics and immediately exiting, -.B nfsstat -takes a snapshot of the current statistics and pauses until it receives -.B SIGINT -(typically from -.BR Ctrl-C ), -at which point it takes another snapshot and displays the difference -between the two. -If \fIinterval\fR is specified, -.B nfsstat -will print the number of \fBNFS\fR calls made since the previous report. -Stats will be printed repeatedly every \fIinterval\fR seconds. -.\" --------------------- EXAMPLES ------------------------------- -.SH EXAMPLES -.TP -.B nfsstat \-o all \-234 -Show all information about all versions of \fBNFS\fR. -.TP -.B nfsstat \-\-verbose \-234 -Same as above. -.TP -.B nfsstat \-o all -Show all information about active versions of \fBNFS\fR. -.TP -.B nfsstat \-\-nfs \-\-server \-3 -Show statistics for \fBNFS\fR version 3 server. -.TP -.B nfsstat \-m -Show information about mounted \fBNFS\fR filesystems. -.\" --------------------- DISPLAY -------------------------------- -.SH DISPLAY -The \fBFlags\fR output from the \fB\-m\fR option is the same as the -flags give to the \fBmount\fR command. -.\" --------------------- FILES ---------------------------------- -.SH FILES -.TP -.B /proc/net/rpc/nfsd -.BR procfs -based -interface to kernel NFS server statistics. -.TP -.B /proc/net/rpc/nfs -.BR procfs -based -interface to kernel NFS client statistics. -.TP -.B /proc/mounts -.BR procfs -based -interface to the mounted filesystems. -.\" -------------------- SEE ALSO -------------------------------- -.SH SEE ALSO -.BR rpc.nfsd (8). -.BR nfs (5). -.\" ---------------------- BUGS ---------------------------------- -.SH BUGS -The default output has been changed. To get the old default output you must run \fBnfsstat \-\-auto \-2\fR. -.P -The function of the \fB\-v\fR and \fB\-a\fR options have changed. The \fB\-a\fR option -is now reserved for future use. The \fB\-v\fR does what the \fB\-a\fR option used to do, -and the new \fB\-[234]\fR options replace the \fB\-v\fR option. -.P -The \fBDisplay\fR section should be more complete. -.P -Further bugs can be found or reported at -.BR http://nfs.sf.net/ . -.\" -------------------- AUTHOR ---------------------------------- -.SH AUTHOR -Olaf Kirch, diff --git a/nfs-utils-2.5.2/utils/showmount/Makefile.am b/nfs-utils-2.5.2/utils/showmount/Makefile.am deleted file mode 100644 index d0a16b2..0000000 --- a/nfs-utils-2.5.2/utils/showmount/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = showmount.man -EXTRA_DIST = $(man8_MANS) - -sbin_PROGRAMS = showmount -showmount_SOURCES = showmount.c -showmount_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a \ - $(LIBTIRPC) -showmount_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \ - -I$(top_builddir)/support/export - -MAINTAINERCLEANFILES = Makefile.in diff --git a/nfs-utils-2.5.2/utils/showmount/showmount.c b/nfs-utils-2.5.2/utils/showmount/showmount.c deleted file mode 100644 index 394f528..0000000 --- a/nfs-utils-2.5.2/utils/showmount/showmount.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * showmount.c -- show mount information for an NFS server - * Copyright (C) 1993 Rick Sladkey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nfsrpc.h" - -#define TIMEOUT_UDP 3 -#define TOTAL_TIMEOUT 20 - -static char * version = "showmount for " VERSION; -static char * program_name; -static int headers = 1; -static int hflag = 0; -static int aflag = 0; -static int dflag = 0; -static int eflag = 0; - -static struct option longopts[] = -{ - { "all", 0, 0, 'a' }, - { "directories", 0, 0, 'd' }, - { "exports", 0, 0, 'e' }, - { "no-headers", 0, &headers, 0 }, - { "version", 0, 0, 'v' }, - { "help", 0, 0, 'h' }, - { NULL, 0, 0, 0 } -}; - -#define MAXHOSTLEN 256 - -static int dump_cmp(const void *pv, const void *qv) -{ - const char **p = (const char **)pv; - const char **q = (const char **)qv; - return strcmp(*p, *q); -} - -static void usage(FILE *fp, int n) -{ - fprintf(fp, "Usage: %s [-adehv]\n", program_name); - fprintf(fp, " [--all] [--directories] [--exports]\n"); - fprintf(fp, " [--no-headers] [--help] [--version] [host]\n"); - exit(n); -} - -static const char *mount_pgm_tbl[] = { - "showmount", - "mount", - "mountd", - NULL, -}; - -static const rpcvers_t mount_vers_tbl[] = { - MOUNTVERS_NFSV3, - MOUNTVERS_POSIX, - MOUNTVERS, -}; -static const unsigned int max_vers_tblsz = - (sizeof(mount_vers_tbl)/sizeof(mount_vers_tbl[0])); - -/* - * Generate an RPC client handle connected to the mountd service - * at @hostname, or die trying. - * - * Supports both AF_INET and AF_INET6 server addresses. - */ -static CLIENT *nfs_get_mount_client(const char *hostname, rpcvers_t vers) -{ - rpcprog_t program = nfs_getrpcbyname(MOUNTPROG, mount_pgm_tbl); - CLIENT *client; - - client = clnt_create(hostname, program, vers, "tcp"); - if (client) - return client; - client = clnt_create(hostname, program, vers, "udp"); - if (client) - return client; - - clnt_pcreateerror("clnt_create"); - exit(1); -} - -int main(int argc, char **argv) -{ - char hostname_buf[MAXHOSTLEN]; - char *hostname; - enum clnt_stat clnt_stat; - struct timeval total_timeout; - int c; - CLIENT *mclient; - groups grouplist; - exports exportlist, exl; - mountlist dumplist; - mountlist list; - int i; - int n; - int maxlen; - int unsigned vers=0; - char **dumpv; - - program_name = argv[0]; - while ((c = getopt_long(argc, argv, "adehv", longopts, NULL)) != EOF) { - switch (c) { - case 'a': - aflag = 1; - break; - case 'd': - dflag = 1; - break; - case 'e': - eflag = 1; - break; - case 'h': - usage(stdout, 0); - break; - case 'v': - printf("%s\n", version); - exit(0); - case 0: - break; - case '?': - default: - usage(stderr, 1); - break; - } - } - argc -= optind; - argv += optind; - - switch (aflag + dflag + eflag) { - case 0: - hflag = 1; - break; - case 1: - break; - default: - fprintf(stderr, "%s: only one of -a, -d or -e is allowed\n", - program_name); - exit(1); - break; - } - - switch (argc) { - case 0: - if (gethostname(hostname_buf, MAXHOSTLEN) < 0) { - perror("getting hostname"); - exit(1); - } - hostname = hostname_buf; - break; - case 1: - hostname = argv[0]; - break; - default: - fprintf(stderr, "%s: only one hostname is allowed\n", - program_name); - exit(1); - break; - } - - mclient = nfs_get_mount_client(hostname, mount_vers_tbl[vers]); - mclient->cl_auth = nfs_authsys_create(); - if (mclient->cl_auth == NULL) { - fprintf(stderr, "%s: unable to create RPC auth handle.\n", - program_name); - clnt_destroy(mclient); - exit(1); - } - total_timeout.tv_sec = TOTAL_TIMEOUT; - total_timeout.tv_usec = 0; - -again: - if (eflag) { - memset(&exportlist, '\0', sizeof(exportlist)); - - clnt_stat = clnt_call(mclient, MOUNTPROC_EXPORT, - (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_exports, (caddr_t) &exportlist, - total_timeout); - if (clnt_stat == RPC_PROGVERSMISMATCH) { - if (++vers < max_vers_tblsz) { - (void)CLNT_CONTROL(mclient, CLSET_VERS, - (void *)&mount_vers_tbl[vers]); - goto again; - } - } - if (clnt_stat != RPC_SUCCESS) { - clnt_perror(mclient, "rpc mount export"); - clnt_destroy(mclient); - exit(1); - } - if (headers) - printf("Export list for %s:\n", hostname); - maxlen = 0; - for (exl = exportlist; exl; exl = exl->ex_next) { - if ((n = strlen(exl->ex_dir)) > maxlen) - maxlen = n; - } - while (exportlist) { - printf("%-*s ", maxlen, exportlist->ex_dir); - grouplist = exportlist->ex_groups; - if (grouplist) - while (grouplist) { - printf("%s%s", grouplist->gr_name, - grouplist->gr_next ? "," : ""); - grouplist = grouplist->gr_next; - } - else - printf("(everyone)"); - printf("\n"); - exportlist = exportlist->ex_next; - } - clnt_destroy(mclient); - exit(0); - } - - memset(&dumplist, '\0', sizeof(dumplist)); - clnt_stat = clnt_call(mclient, MOUNTPROC_DUMP, - (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_mountlist, (caddr_t) &dumplist, - total_timeout); - if (clnt_stat == RPC_PROGVERSMISMATCH) { - if (++vers < max_vers_tblsz) { - (void)CLNT_CONTROL(mclient, CLSET_VERS, - (void *)&mount_vers_tbl[vers]); - goto again; - } - } - if (clnt_stat != RPC_SUCCESS) { - clnt_perror(mclient, "rpc mount dump"); - clnt_destroy(mclient); - exit(1); - } - clnt_destroy(mclient); - - n = 0; - for (list = dumplist; list; list = list->ml_next) - n++; - dumpv = (char **) calloc(n, sizeof (char *)); - if (n && !dumpv) { - fprintf(stderr, "%s: out of memory\n", program_name); - exit(1); - } - i = 0; - - if (hflag) { - if (headers) - printf("Hosts on %s:\n", hostname); - while (dumplist) { - dumpv[i++] = dumplist->ml_hostname; - dumplist = dumplist->ml_next; - } - } - else if (aflag) { - if (headers) - printf("All mount points on %s:\n", hostname); - while (dumplist) { - char *t; - - t=malloc(strlen(dumplist->ml_hostname)+strlen(dumplist->ml_directory)+2); - if (!t) - { - fprintf(stderr, "%s: out of memory\n", program_name); - exit(1); - } - sprintf(t, "%s:%s", dumplist->ml_hostname, dumplist->ml_directory); - dumpv[i++] = t; - dumplist = dumplist->ml_next; - } - } - else if (dflag) { - if (headers) - printf("Directories on %s:\n", hostname); - while (dumplist) { - dumpv[i++] = dumplist->ml_directory; - dumplist = dumplist->ml_next; - } - } - - qsort(dumpv, n, sizeof (char *), dump_cmp); - - for (i = 0; i < n; i++) { - if (i == 0 || strcmp(dumpv[i], dumpv[i - 1]) != 0) - printf("%s\n", dumpv[i]); - } - exit(0); -} - diff --git a/nfs-utils-2.5.2/utils/showmount/showmount.man b/nfs-utils-2.5.2/utils/showmount/showmount.man deleted file mode 100644 index 35818e1..0000000 --- a/nfs-utils-2.5.2/utils/showmount/showmount.man +++ /dev/null @@ -1,65 +0,0 @@ -.\" Copyright 1993 Rick Sladkey -.\" May be distributed under the GNU General Public License -.TH SHOWMOUNT 8 "6 October 1993" -.SH NAME -showmount \- show mount information for an NFS server -.SH SYNOPSIS -.B showmount -.B "[\ \-adehv\ ]" -.B "[\ \-\-all\ ]" -.B "[\ \-\-directories\ ]" -.B "[\ \-\-exports\ ]" -.B "[\ \-\-help\ ]" -.B "[\ \-\-version\ ]" -.B "[\ host\ ]" -.SH DESCRIPTION -.B showmount -queries the mount daemon on a remote host for information about -the state of the NFS server on that machine. With no options -.B showmount -lists the set of clients who are mounting from that host. -The output from -.B showmount -is designed to -appear as though it were processed through ``sort \-u''. -.SH OPTIONS -.TP -.BR \-a " or " \-\-all -List both the client hostname or IP address and mounted directory in -host:dir format. This info should not be considered reliable. See the notes -on rmtab in -.BR rpc.mountd (8). -.TP -.BR \-d " or " \-\-directories -List only the directories mounted by some client. -.TP -.BR \-e " or " \-\-exports -Show the NFS server's export list. -.TP -.BR \-h " or " \-\-help -Provide a short help summary. -.TP -.BR \-v " or " \-\-version -Report the current version number of the program. -.TP -.B \-\-no\-headers -Suppress the descriptive headings from the output. -.SH "SEE ALSO" -.BR rpc.mountd (8), -.BR rpc.nfsd (8) -.SH BUGS -The completeness and accuracy of the information that -.B showmount -displays varies according to the NFS server's implementation. -.P -Because -.B showmount -sorts and uniqs the output, it is impossible to determine from -the output whether a client is mounting the same directory more than once. -.P -.B showmount -works by contacting the server's MNT service directly. NFSv4-only servers have -no need to advertise their exported root filehandles via this method, and may -not expose their MNT service to clients. -.SH AUTHOR -Rick Sladkey diff --git a/nfs-utils-2.5.2/utils/statd/.gitignore b/nfs-utils-2.5.2/utils/statd/.gitignore deleted file mode 100644 index 99b0cce..0000000 --- a/nfs-utils-2.5.2/utils/statd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sm-notify diff --git a/nfs-utils-2.5.2/utils/statd/COPYING b/nfs-utils-2.5.2/utils/statd/COPYING deleted file mode 100644 index 60549be..0000000 --- a/nfs-utils-2.5.2/utils/statd/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/nfs-utils-2.5.2/utils/statd/Makefile.am b/nfs-utils-2.5.2/utils/statd/Makefile.am deleted file mode 100644 index 6facc15..0000000 --- a/nfs-utils-2.5.2/utils/statd/Makefile.am +++ /dev/null @@ -1,93 +0,0 @@ -## Process this file with automake to produce Makefile.in - -man8_MANS = statd.man sm-notify.man - -RPCPREFIX = rpc. -KPREFIX = @kprefix@ -sbin_PROGRAMS = statd sm-notify -dist_sbin_SCRIPTS = start-statd -statd_SOURCES = callback.c notlist.c misc.c monitor.c hostname.c \ - simu.c stat.c statd.c svc_run.c rmtcall.c \ - notlist.h statd.h system.h -sm_notify_SOURCES = sm-notify.c - -BUILT_SOURCES = $(GENFILES) -statd_LDADD = ../../support/nsm/libnsm.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a \ - $(LIBWRAP) $(LIBNSL) $(LIBCAP) $(LIBTIRPC) -sm_notify_LDADD = ../../support/nsm/libnsm.a \ - ../../support/nfs/libnfs.la \ - ../../support/misc/libmisc.a \ - $(LIBNSL) $(LIBCAP) $(LIBTIRPC) - -EXTRA_DIST = sim_sm_inter.x $(man8_MANS) simulate.c - -if CONFIG_RPCGEN -RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen -$(RPCGEN): - make -C ../../tools/rpcgen all -else -RPCGEN = @RPCGEN_PATH@ -endif - -$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -l -o $@ $< - -$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -m -o $@ $< - -$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -c -o $@ $< - -$(GENFILES_H): %.h: %.x $(RPCGEN) - test -f $@ && rm -rf $@ || true - $(RPCGEN) -h -o $@ $< - -MAINTAINERCLEANFILES = Makefile.in - -CLEANFILES = $(GENFILES) - -####################################################################### -# The following allows the current practice of having -# daemons renamed during the install to include RPCPREFIX -# and the KPREFIX -# This could all be done much easier with program_transform_name -# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) -# but that also renames the man pages, which the current -# practice does not do. -install-exec-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - [ $$p = sm-notify ] || mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) -uninstall-hook: - (cd $(DESTDIR)$(sbindir) && \ - for p in $(sbin_PROGRAMS); do \ - [ $$p = sm-notify ] || rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ - done) - - -# XXX This makes some assumptions about what automake does. -# XXX But there is no install-man-hook or install-man-local. -install-man: install-man8 install-man-links -uninstall-man: uninstall-man8 uninstall-man-links - -install-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ - done) - -uninstall-man-links: - (cd $(DESTDIR)$(man8dir) && \ - for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ - inst=`echo $$m | sed -e 's/man$$/8/'`; \ - rm -f $(RPCPREFIX)$$inst ; \ - done) - diff --git a/nfs-utils-2.5.2/utils/statd/TODO b/nfs-utils-2.5.2/utils/statd/TODO deleted file mode 100644 index 0ee050a..0000000 --- a/nfs-utils-2.5.2/utils/statd/TODO +++ /dev/null @@ -1,13 +0,0 @@ -Some things still left to do (not a comprehensive list): - -* Go through Olaf's extensive changes (especially the list and callback - handling, which is the meat of the server) and understand everything - that he's done. - -* Continue checking for security holes. - -* Handle multiple SM_MON requests that are identical save for the "priv" - information. How should I do this? No spec's...(it's not really - supposed to happen). [Did Olaf already address this?] - -* BETTER CODE COMMENTS! diff --git a/nfs-utils-2.5.2/utils/statd/callback.c b/nfs-utils-2.5.2/utils/statd/callback.c deleted file mode 100644 index bb7c590..0000000 --- a/nfs-utils-2.5.2/utils/statd/callback.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, Oct. 1996. - * Modified by Lon Hohberger, Oct. 2000. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "rpcmisc.h" -#include "statd.h" -#include "notlist.h" -#include "ha-callout.h" - -/* Callback notify list. */ -/* notify_list *cbnl = NULL; ... never used */ - - -/* - * Services SM_NOTIFY requests. - * - * When NLM uses an SM_MON request to tell statd to monitor a remote, - * the request contains a "mon_name" argument. This is usually the - * "caller_name" argument of an NLMPROC_LOCK request. On Linux, the - * NLM can send statd the remote's IP address instead of its - * caller_name. The NSM protocol does not allow both the remote's - * caller_name and it's IP address to be sent in the same SM_MON - * request. - * - * The remote's caller_name is useful because it makes it simple - * to identify rebooting remotes by matching the "mon_name" argument - * they sent via an SM_NOTIFY request. - * - * The caller_name string may not be a fully qualified domain name, - * or even registered in the DNS database, however. Having the - * remote's IP address is useful because then there is no ambiguity - * about where to send an SM_NOTIFY after the local system reboots. - * - * Without the actual caller_name, however, statd must use an - * heuristic to match an incoming SM_NOTIFY request to one of the - * hosts it is currently monitoring. The incoming mon_name in an - * SM_NOTIFY address is converted to a list of IP addresses using - * DNS. Each mon_name on statd's monitor list is also converted to - * an address list, and the two lists are checked to see if there is - * a matching address. - * - * There are some risks to this strategy: - * - * 1. The external DNS database is not reliable. It can change - * over time, or the forward and reverse mappings could be - * inconsistent. - * - * 2. If statd's monitor list becomes substantial, finding a match - * can generate a not inconsequential amount of DNS traffic. - * - * 3. statd is a single-threaded service. When DNS becomes slow or - * unresponsive, statd also becomes slow or unresponsive. - * - * 4. If the remote does not have a DNS entry at all (or if the - * remote can resolve itself, but the local host can't resolve - * the remote's hostname), the remote cannot be monitored, and - * therefore NLM locking cannot be provided for that host. - * - * 5. Local DNS resolution can produce different results for the - * mon_name than the results the remote might see for the same - * query, especially if the remote did not send a caller_name - * or mon_name that is a fully qualified domain name. - * - * Note that a caller_name is passed from NFS client to server, - * but the client never knows what mon_name the server might use - * to notify it of a reboot. On Linux, the client extracts the - * server's name from the devname it was passed by the mount - * command. This is often not a fully-qualified domain name. - */ -void * -sm_notify_1_svc(struct stat_chge *argp, struct svc_req *rqstp) -{ - notify_list *lp, *call; - static char *result = NULL; - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char ip_addr[INET6_ADDRSTRLEN]; - - xlog(D_CALL, "Received SM_NOTIFY from %s, state: %d", - argp->mon_name, argp->state); - - if (!statd_present_address(sap, ip_addr, sizeof(ip_addr))) { - xlog_warn("Unrecognized sender address"); - return ((void *) &result); - } - - ha_callout("sm-notify", argp->mon_name, ip_addr, argp->state); - - /* quick check - don't bother if we're not monitoring anyone */ - if (rtnl == NULL) { - xlog_warn("SM_NOTIFY from %s while not monitoring any hosts", - argp->mon_name); - return ((void *) &result); - } - - /* okir change: statd doesn't remove the remote host from its - * internal monitor list when receiving an SM_NOTIFY call from - * it. Lockd will want to continue monitoring the remote host - * until it issues an SM_UNMON call. - */ - for (lp = rtnl ; lp ; lp = lp->next) - if (NL_STATE(lp) != argp->state && - (statd_matchhostname(argp->mon_name, lp->dns_name) || - statd_matchhostname(ip_addr, lp->dns_name))) { - NL_STATE(lp) = argp->state; - call = nlist_clone(lp); - nlist_insert(¬ify, call); - } - - - return ((void *) &result); -} diff --git a/nfs-utils-2.5.2/utils/statd/hostname.c b/nfs-utils-2.5.2/utils/statd/hostname.c deleted file mode 100644 index 16e21fc..0000000 --- a/nfs-utils-2.5.2/utils/statd/hostname.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright 2009 Oracle. All rights reserved. - * - * This file is part of nfs-utils. - * - * nfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * nfs-utils is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with nfs-utils. If not, see . - */ - -/* - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nfslib.h" -#include "sockaddr.h" -#include "statd.h" -#include "xlog.h" - -/** - * statd_present_address - convert sockaddr to presentation address - * @sap: pointer to socket address to convert - * @buf: pointer to buffer to fill in - * @buflen: length of buffer - * - * Convert the passed-in sockaddr-style address to presentation format. - * The presentation format address is placed in @buf and is - * '\0'-terminated. - * - * Returns true if successful; otherwise false. - * - * getnameinfo(3) is preferred, since it can parse IPv6 scope IDs. - * An alternate version of statd_present_address() is available to - * handle older glibcs that do not have getnameinfo(3). - */ -#ifdef HAVE_GETNAMEINFO -_Bool -statd_present_address(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - socklen_t salen; - int error; - - salen = nfs_sockaddr_length(sap); - if (salen == 0) { - xlog(D_GENERAL, "%s: unsupported address family", - __func__); - return false; - } - - error = getnameinfo(sap, salen, buf, (socklen_t)buflen, - NULL, 0, NI_NUMERICHOST); - if (error != 0) { - xlog(D_GENERAL, "%s: getnameinfo(3): %s", - __func__, gai_strerror(error)); - return false; - } - return true; -} -#else /* !HAVE_GETNAMEINFO */ -_Bool -statd_present_address(const struct sockaddr *sap, char *buf, const size_t buflen) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; - - if (sin->sin_family != AF_INET) { - xlog(D_GENERAL, "%s: unsupported address family", __func__); - return false; - } - - /* ensure '\0' termination */ - memset(buf, 0, buflen); - - if (inet_ntop(AF_INET, (char *)&sin->sin_addr, - buf, (socklen_t)buflen) == NULL) { - xlog(D_GENERAL, "%s: inet_ntop(3): %m", __func__); - return false; - } - return true; -} -#endif /* !HAVE_GETNAMEINFO */ - -/* - * Look up the hostname; report exceptional errors. Caller must - * call freeaddrinfo(3) if a valid addrinfo is returned. - */ -__attribute__((__malloc__)) -static struct addrinfo * -get_addrinfo(const char *hostname, const struct addrinfo *hint) -{ - struct addrinfo *ai = NULL; - int error; - - error = getaddrinfo(hostname, NULL, hint, &ai); - switch (error) { - case 0: - return ai; - case EAI_NONAME: - break; - default: - xlog(D_GENERAL, "%s: failed to resolve host %s: %s", - __func__, hostname, gai_strerror(error)); - } - - return NULL; -} - -#ifdef HAVE_GETNAMEINFO -static _Bool -get_nameinfo(const struct sockaddr *sap, const socklen_t salen, - /*@out@*/ char *buf, const socklen_t buflen) -{ - int error; - - error = getnameinfo(sap, salen, buf, buflen, NULL, 0, NI_NAMEREQD); - if (error != 0) { - xlog(D_GENERAL, "%s: failed to resolve address: %s", - __func__, gai_strerror(error)); - return false; - } - - return true; -} -#else /* !HAVE_GETNAMEINFO */ -static _Bool -get_nameinfo(const struct sockaddr *sap, - __attribute__ ((unused)) const socklen_t salen, - /*@out@*/ char *buf, socklen_t buflen) -{ - struct sockaddr_in *sin = (struct sockaddr_in *)(char *)sap; - struct hostent *hp; - - if (sin->sin_family != AF_INET) { - xlog(D_GENERAL, "%s: unknown address family: %d", - sin->sin_family); - return false; - } - - hp = gethostbyaddr((const char *)&(sin->sin_addr.s_addr), - sizeof(struct in_addr), AF_INET); - if (hp == NULL) { - xlog(D_GENERAL, "%s: failed to resolve address: %m", __func__); - return false; - } - - strncpy(buf, hp->h_name, (size_t)buflen); - return true; -} -#endif /* !HAVE_GETNAMEINFO */ - -/** - * statd_canonical_name - choose file name for monitor record files - * @hostname: C string containing hostname or presentation address - * - * Returns a '\0'-terminated ASCII string containing a fully qualified - * canonical hostname, or NULL if @hostname does not have a reverse - * mapping. Caller must free the result with free(3). - * - * Incoming hostnames are looked up to determine the canonical hostname, - * and incoming presentation addresses are converted to canonical - * hostnames. - */ -__attribute__((__malloc__)) -char * -statd_canonical_name(const char *hostname) -{ - struct addrinfo hint = { -#ifdef IPV6_SUPPORTED - .ai_family = AF_UNSPEC, -#else /* !IPV6_SUPPORTED */ - .ai_family = AF_INET, -#endif /* !IPV6_SUPPORTED */ - .ai_flags = AI_NUMERICHOST, - .ai_protocol = (int)IPPROTO_UDP, - }; - char buf[NI_MAXHOST]; - struct addrinfo *ai; - - ai = get_addrinfo(hostname, &hint); - if (ai != NULL) { - /* @hostname was a presentation address */ - _Bool result; - result = get_nameinfo(ai->ai_addr, ai->ai_addrlen, - buf, (socklen_t)sizeof(buf)); - nfs_freeaddrinfo(ai); - if (!result || buf[0] == '\0') - /* OK to use presentation address, - * if no reverse map exists */ - return strdup(hostname); - return strdup(buf); - } - - /* @hostname was a hostname */ - hint.ai_flags = AI_CANONNAME; - ai = get_addrinfo(hostname, &hint); - if (ai == NULL) - return NULL; - strcpy(buf, ai->ai_canonname); - nfs_freeaddrinfo(ai); - - return strdup(buf); -} - -/* - * Take care to perform an explicit reverse lookup on presentation - * addresses. Otherwise we don't get a real canonical name or a - * complete list of addresses. - * - * Returns an addrinfo list that has ai_canonname filled in, or - * NULL if some error occurs. Caller must free the returned - * list with freeaddrinfo(3). - */ -__attribute__((__malloc__)) -static struct addrinfo * -statd_canonical_list(const char *hostname) -{ - struct addrinfo hint = { -#ifdef IPV6_SUPPORTED - .ai_family = AF_UNSPEC, -#else /* !IPV6_SUPPORTED */ - .ai_family = AF_INET, -#endif /* !IPV6_SUPPORTED */ - .ai_flags = AI_NUMERICHOST, - .ai_protocol = (int)IPPROTO_UDP, - }; - char buf[NI_MAXHOST]; - struct addrinfo *ai; - - ai = get_addrinfo(hostname, &hint); - if (ai != NULL) { - /* @hostname was a presentation address */ - _Bool result; - result = get_nameinfo(ai->ai_addr, ai->ai_addrlen, - buf, (socklen_t)sizeof(buf)); - nfs_freeaddrinfo(ai); - if (result) - goto out; - } - /* @hostname was a hostname or had no reverse mapping */ - strcpy(buf, hostname); - -out: - hint.ai_flags = AI_CANONNAME; - return get_addrinfo(buf, &hint); -} - -/** - * statd_matchhostname - check if two hostnames are equivalent - * @hostname1: C string containing hostname - * @hostname2: C string containing hostname - * - * Returns true if the hostnames are the same, the hostnames resolve - * to the same canonical name, or the hostnames resolve to at least - * one address that is the same. False is returned if the hostnames - * do not match in any of these ways, if either hostname contains - * wildcard characters, if either hostname is a netgroup name, or - * if an error occurs. - */ -_Bool -statd_matchhostname(const char *hostname1, const char *hostname2) -{ - struct addrinfo *ai1, *ai2, *results1 = NULL, *results2 = NULL; - _Bool result = false; - - if (strcasecmp(hostname1, hostname2) == 0) { - result = true; - goto out; - } - - results1 = statd_canonical_list(hostname1); - if (results1 == NULL) - goto out; - results2 = statd_canonical_list(hostname2); - if (results2 == NULL) - goto out; - - if (strcasecmp(results1->ai_canonname, results2->ai_canonname) == 0) { - result = true; - goto out; - } - - for (ai1 = results1; ai1 != NULL; ai1 = ai1->ai_next) - for (ai2 = results2; ai2 != NULL; ai2 = ai2->ai_next) - if (nfs_compare_sockaddr(ai1->ai_addr, ai2->ai_addr)) { - result = true; - break; - } - -out: - nfs_freeaddrinfo(results2); - nfs_freeaddrinfo(results1); - - xlog(D_CALL, "%s: hostnames %s and %s %s", __func__, - hostname1, hostname2, - (result ? "matched" : "did not match")); - return result; -} diff --git a/nfs-utils-2.5.2/utils/statd/misc.c b/nfs-utils-2.5.2/utils/statd/misc.c deleted file mode 100644 index f2a086f..0000000 --- a/nfs-utils-2.5.2/utils/statd/misc.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 1995-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, 1996. - * Modified by H.J. Lu, 1998. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include "statd.h" -#include "notlist.h" - -/* - * Error-checking malloc() wrapper. - */ -void * -xmalloc (size_t size) -{ - void *ptr; - - if (size == 0) - return ((void *)NULL); - - if (!(ptr = malloc (size))) - xlog_err ("malloc failed"); - - return (ptr); -} - - -/* - * Error-checking strdup() wrapper. - */ -char * -xstrdup (const char *string) -{ - char *result; - - /* Will only fail if underlying malloc() fails (ENOMEM). */ - if (!(result = strdup (string))) - xlog_err ("strdup failed"); - - return (result); -} diff --git a/nfs-utils-2.5.2/utils/statd/monitor.c b/nfs-utils-2.5.2/utils/statd/monitor.c deleted file mode 100644 index c76589c..0000000 --- a/nfs-utils-2.5.2/utils/statd/monitor.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (C) 1995-1999 Jeffrey A. Uphoff - * Major rewrite by Olaf Kirch, Dec. 1996. - * Modified by H.J. Lu, 1998. - * Tighter access control, Olaf Kirch June 1999. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sockaddr.h" -#include "rpcmisc.h" -#include "nsm.h" -#include "statd.h" -#include "notlist.h" -#include "ha-callout.h" - -notify_list * rtnl = NULL; /* Run-time notify list. */ - -/* - * Reject requests from non-loopback addresses in order - * to prevent attack described in CERT CA-99.05. - * - * Although the kernel contacts the statd service via only IPv4 - * transports, the statd service can receive other requests, such - * as SM_NOTIFY, from remote peers via IPv6. - */ -static _Bool -caller_is_localhost(struct svc_req *rqstp) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - - if (!nfs_is_v4_loopback(sap)) - goto out_nonlocal; - return true; - -out_nonlocal: - if (!statd_present_address(sap, buf, sizeof(buf))) - buf[0] = '\0'; - xlog_warn("SM_MON/SM_UNMON call from non-local host %s", buf); - return false; -} - -/* - * Services SM_MON requests. - */ -struct sm_stat_res * -sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) -{ - static sm_stat_res result; - char *mon_name = argp->mon_id.mon_name, - *my_name = argp->mon_id.my_id.my_name; - struct my_id *id = &argp->mon_id.my_id; - char *cp; - notify_list *clnt = NULL; - struct sockaddr_in my_addr = { - .sin_family = AF_INET, - .sin_addr.s_addr = htonl(INADDR_LOOPBACK), - }; - char *dnsname = NULL; - int existing = 0; - - xlog(D_CALL, "Received SM_MON for %s from %s", mon_name, my_name); - - /* Assume that we'll fail. */ - result.res_stat = STAT_FAIL; - result.state = -1; /* State is undefined for STAT_FAIL. */ - - /* 1. Reject any remote callers. - * Ignore the my_name specified by the caller, and - * use "127.0.0.1" instead. - */ - if (!caller_is_localhost(rqstp)) - goto failure; - - /* 2. Reject any registrations for non-lockd services. - * - * This is specific to the linux kernel lockd, which - * makes the callback procedure part of the lockd interface. - * It is also prone to break when lockd changes its callback - * procedure number -- which, in fact, has now happened once. - * There must be a better way.... XXX FIXME - */ - if (id->my_prog != 100021 || - (id->my_proc != 16 && id->my_proc != 24)) - { - xlog_warn("Attempt to register callback to %d/%d", - id->my_prog, id->my_proc); - goto failure; - } - - /* - * Check hostnames. If I can't look them up, I won't monitor. This - * might not be legal, but it adds a little bit of safety and sanity. - */ - - /* must check for /'s in hostname! See CERT's CA-96.09 for details. */ - if (strchr(mon_name, '/') || mon_name[0] == '.') { - xlog(L_ERROR, "SM_MON request for hostname containing '/' " - "or starting '.': %s", mon_name); - xlog(L_ERROR, "POSSIBLE SPOOF/ATTACK ATTEMPT!"); - goto failure; - } - - /* my_name must not have white space */ - for (cp=my_name ; *cp ; cp++) - if (*cp == ' ' || *cp == '\t' || *cp == '\r' || *cp == '\n') - *cp = '_'; - - /* - * Hostnames checked OK. - * Now choose a hostname to use for matching. We cannot - * really trust much in the incoming NOTIFY, so to make - * sure that multi-homed hosts work nicely, we get an - * FQDN now, and use that for matching. - */ - dnsname = statd_canonical_name(mon_name); - if (dnsname == NULL) { - xlog(L_WARNING, "No canonical hostname found for %s", mon_name); - goto failure; - } - - /* Now check to see if this is a duplicate, and warn if so. - * I will also return STAT_FAIL. (I *think* this is how I should - * handle it.) - * - * Olaf requests that I allow duplicate SM_MON requests for - * hosts due to the way he is coding lockd. No problem, - * I'll just do a quickie success return and things should - * be happy. - */ - clnt = rtnl; - - while ((clnt = nlist_gethost(clnt, mon_name, 0))) { - if (statd_matchhostname(NL_MY_NAME(clnt), my_name) && - NL_MY_PROC(clnt) == id->my_proc && - NL_MY_PROG(clnt) == id->my_prog && - NL_MY_VERS(clnt) == id->my_vers) { - if (memcmp(NL_PRIV(clnt), argp->priv, SM_PRIV_SIZE)) { - xlog(D_GENERAL, - "Received SM_MON request with new " - "cookie for %s from procedure on %s", - mon_name, my_name); - - existing = 1; - break; - } else { - /* Hey! We already know you guys! */ - xlog(D_GENERAL, - "Duplicate SM_MON request for %s " - "from procedure on %s", - mon_name, my_name); - - /* But we'll let you pass anyway. */ - free(dnsname); - goto success; - } - } - clnt = NL_NEXT(clnt); - } - - /* - * We're committed...ignoring errors. Let's hope that a malloc() - * doesn't fail. (I should probably fix this assumption.) - */ - if (!existing && !(clnt = nlist_new(my_name, mon_name, 0))) { - free(dnsname); - xlog_warn("out of memory"); - goto failure; - } - - NL_MY_PROG(clnt) = id->my_prog; - NL_MY_VERS(clnt) = id->my_vers; - NL_MY_PROC(clnt) = id->my_proc; - memcpy(NL_PRIV(clnt), argp->priv, SM_PRIV_SIZE); - clnt->dns_name = dnsname; - - /* - * Now, Create file on stable storage for host, first deleting any - * existing records on file. - */ - nsm_delete_monitored_host(dnsname, mon_name, my_name, 0); - - if (!nsm_insert_monitored_host(dnsname, - (struct sockaddr *)(char *)&my_addr, argp)) { - nlist_free(existing ? &rtnl : NULL, clnt); - goto failure; - } - - /* PRC: do the HA callout: */ - ha_callout("add-client", mon_name, my_name, -1); - if (!existing) - nlist_insert(&rtnl, clnt); - xlog(D_GENERAL, "MONITORING %s for %s", mon_name, my_name); - success: - result.res_stat = STAT_SUCC; - /* SUN's sm_inter.x says this should be "state number of local site". - * X/Open says '"state" will be contain the state of the remote NSM.' - * href=http://www.opengroup.org/onlinepubs/9629799/SM_MON.htm - * Linux lockd currently (2.6.21 and prior) ignores whatever is - * returned, and given the above contraction, it probably always will.. - * So we just return what we always returned. If possible, we - * have already told lockd about our state number via a sysctl. - * If lockd wants the remote state, it will need to - * use SM_STAT (and prayer). - */ - result.state = MY_STATE; - return (&result); - -failure: - xlog_warn("STAT_FAIL to %s for SM_MON of %s", my_name, mon_name); - free(clnt); - return (&result); -} - -static unsigned int -load_one_host(const char *hostname, - __attribute__ ((unused)) const struct sockaddr *sap, - const struct mon *m, - __attribute__ ((unused)) const time_t timestamp) -{ - notify_list *clnt; - - clnt = nlist_new(m->mon_id.my_id.my_name, - m->mon_id.mon_name, 0); - if (clnt == NULL) - return 0; - - clnt->dns_name = strdup(hostname); - if (clnt->dns_name == NULL) { - nlist_free(NULL, clnt); - free(clnt); - return 0; - } - - xlog(D_GENERAL, "Adding record for %s to the monitor list...", - hostname); - - NL_MY_PROG(clnt) = m->mon_id.my_id.my_prog; - NL_MY_VERS(clnt) = m->mon_id.my_id.my_vers; - NL_MY_PROC(clnt) = m->mon_id.my_id.my_proc; - memcpy(NL_PRIV(clnt), m->priv, SM_PRIV_SIZE); - - nlist_insert(&rtnl, clnt); - return 1; -} - -void load_state(void) -{ - unsigned int count; - - count = nsm_load_monitor_list(load_one_host); - if (count) - xlog(D_GENERAL, "Loaded %u previously monitored hosts", count); -} - -/* - * Services SM_UNMON requests. - * - * There is no statement in the X/Open spec's about returning an error - * for requests to unmonitor a host that we're *not* monitoring. I just - * return the state of the NSM when I get such foolish requests for lack - * of any better ideas. (I also log the "offense.") - */ -struct sm_stat * -sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp) -{ - static sm_stat result; - notify_list *clnt; - char *mon_name = argp->mon_name, - *my_name = argp->my_id.my_name; - struct my_id *id = &argp->my_id; - char *cp; - - xlog(D_CALL, "Received SM_UNMON for %s from %s", mon_name, my_name); - - result.state = MY_STATE; - - if (!caller_is_localhost(rqstp)) - goto failure; - - /* my_name must not have white space */ - for (cp=my_name ; *cp ; cp++) - if (*cp == ' ' || *cp == '\t' || *cp == '\r' || *cp == '\n') - *cp = '_'; - - - /* Check if we're monitoring anyone. */ - if (rtnl == NULL) { - xlog_warn("Received SM_UNMON request from %s for %s while not " - "monitoring any hosts", my_name, argp->mon_name); - return (&result); - } - clnt = rtnl; - - /* - * OK, we are. Now look for appropriate entry in run-time list. - * There should only be *one* match on this, since I block "duplicate" - * SM_MON calls. (Actually, duplicate calls are allowed, but only one - * entry winds up in the list the way I'm currently handling them.) - */ - while ((clnt = nlist_gethost(clnt, mon_name, 0))) { - if (statd_matchhostname(NL_MY_NAME(clnt), my_name) && - NL_MY_PROC(clnt) == id->my_proc && - NL_MY_PROG(clnt) == id->my_prog && - NL_MY_VERS(clnt) == id->my_vers) { - /* Match! */ - xlog(D_GENERAL, "UNMONITORING %s for %s", - mon_name, my_name); - - /* PRC: do the HA callout: */ - ha_callout("del-client", mon_name, my_name, -1); - - nsm_delete_monitored_host(clnt->dns_name, - mon_name, my_name, 1); - nlist_free(&rtnl, clnt); - - return (&result); - } else - clnt = NL_NEXT(clnt); - } - - failure: - xlog_warn("Received erroneous SM_UNMON request from %s for %s", - my_name, mon_name); - return (&result); -} - - -struct sm_stat * -sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp) -{ - short int count = 0; - static sm_stat result; - notify_list *clnt; - char *my_name = argp->my_name; - - xlog(D_CALL, "Received SM_UNMON_ALL for %s", my_name); - - if (!caller_is_localhost(rqstp)) - goto failure; - - result.state = MY_STATE; - - if (rtnl == NULL) { - xlog_warn("Received SM_UNMON_ALL request from %s " - "while not monitoring any hosts", my_name); - return (&result); - } - clnt = rtnl; - - while ((clnt = nlist_gethost(clnt, my_name, 1))) { - if (NL_MY_PROC(clnt) == argp->my_proc && - NL_MY_PROG(clnt) == argp->my_prog && - NL_MY_VERS(clnt) == argp->my_vers) { - /* Watch stack! */ - char mon_name[SM_MAXSTRLEN + 1]; - notify_list *temp; - - xlog(D_GENERAL, - "UNMONITORING (SM_UNMON_ALL) %s for %s", - NL_MON_NAME(clnt), NL_MY_NAME(clnt)); - strncpy(mon_name, NL_MON_NAME(clnt), - sizeof (mon_name) - 1); - mon_name[sizeof (mon_name) - 1] = '\0'; - temp = NL_NEXT(clnt); - /* PRC: do the HA callout: */ - ha_callout("del-client", mon_name, my_name, -1); - nsm_delete_monitored_host(clnt->dns_name, - mon_name, my_name, 1); - nlist_free(&rtnl, clnt); - ++count; - clnt = temp; - } else - clnt = NL_NEXT(clnt); - } - - if (!count) { - xlog(D_GENERAL, "SM_UNMON_ALL request from %s with no " - "SM_MON requests from it", my_name); - } - - failure: - return (&result); -} diff --git a/nfs-utils-2.5.2/utils/statd/notlist.c b/nfs-utils-2.5.2/utils/statd/notlist.c deleted file mode 100644 index 45879a4..0000000 --- a/nfs-utils-2.5.2/utils/statd/notlist.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, 1996. - * Modified by H.J. Lu, 1998. - * Modified by Lon Hohberger, Oct. 2000. - * - Fixed memory leaks, run-off-end problems, etc. - * - * NSM for Linux. - */ - -/* - * Simple list management for notify list - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "statd.h" -#include "notlist.h" - - -#ifdef DEBUG -/* - * LH - The linked list code had some bugs. Used this to help debug - * new code. - */ -static void -plist(notify_list *head, int en) -{ - /* case where we ran off the end */ - if (!head) return; - - printf("Entry %d: %s\n",en, NL_MON_NAME(head)); - plist(head->next, ++en); -} - -static void -nlist_print(notify_list **head) -{ - printf("--- Begin notify list dump ---\n"); - plist(*head,1); - printf("--- End notify list dump ---\n"); -} -#endif /* DEBUG */ - -/* - * Allocate memory and set up a new notify list entry. - */ -notify_list * -nlist_new(char *my_name, char *mon_name, int state) -{ - notify_list *new; - - new = (notify_list *) xmalloc(sizeof(notify_list)); - memset(new, 0, sizeof(*new)); - - NL_TIMES(new) = MAX_TRIES; - NL_STATE(new) = state; - NL_MY_NAME(new) = xstrdup(my_name); - NL_MON_NAME(new) = xstrdup(mon_name); - - return new; -} - -/* - * Insert *entry into a notify list at the point specified by - * **head. This can be in the middle. However, we do not handle - * list _append_ in this function; rather, the only place we should - * have to worry about this case is in nlist_insert_timer below. - * - entry must not be NULL. - */ -void -nlist_insert(notify_list **head, notify_list *entry) -{ - if (*head) { - /* - * Cases where we're prepending a non-empty list - * or inserting possibly in the middle somewhere (eg, - * nlist_insert_timer...) - */ - entry->next = (*head); /* Forward pointer */ - entry->prev = (*head)->prev; /* Back pointer */ - (*head)->prev = entry; /* head's new back pointer */ - } - - /* Common to all cases, including new list creation */ - *head = entry; /* New head */ - -#ifdef DEBUG - nlist_print(head); -#endif -} - -/* - * (re)insert *entry into notify_list **head. This requires that - * NL_WHEN(entry) has been set (usually, this is time() + 5 seconds). - * - entry must not be NULL - * - * LH - This used to cause (a) a memory leak and (b) dropped notify-list - * entries. The pointer ran off the end of the list, and changed the - * head-end to point to the new, one-entry list. All other entries became garbage. - * - * FIXME: Optimize this function. (I'll work on it - LH) - */ -void -nlist_insert_timer(notify_list **head, notify_list *entry) -{ - notify_list *spot = *head, /* Insertion location */ - /* ...Start at head */ - *back = NULL; /* Back pointer */ - - - /* Find first entry with higher timeout value or end of list */ - while (spot && NL_WHEN(spot) <= NL_WHEN(entry)) { - /* - * Keep the back pointer in case we - * run off the end... (see below) - */ - back = spot; - spot = spot->next; - } - - if (spot == (*head)) { - /* - * case where we're prepending an empty or non-empty - * list or inserting in the middle somewhere. Pass - * the real head of the list, since we'll be changing - * during the insert... - */ - nlist_insert(head, entry); - } else { - /* all other cases - don't move the real head pointer */ - nlist_insert(&spot, entry); - - /* - * If spot == entry, then spot was NULL when we called - * nlist_insert. This happened because we had run off - * the end of the list. Append entry to original list. - */ - if (spot == entry) { - back->next = entry; - entry->prev = back; - } - } -} - -/* - * Remove *entry from the list pointed to by **head. - * Do not destroy *entry. This is normally done before - * a re-insertion with a timer, but can be done anywhere. - * - entry must not be NULL. - */ -void -nlist_remove(notify_list **head, notify_list *entry) -{ - notify_list *prev = entry->prev, - *next = entry->next; - - if (next) { - next->prev = prev; - } - - if (prev) { - /* Case(s) where entry isn't at the front */ - prev->next = next; - } else { - /* cases where entry is at the front */ - *head = next; - } - - entry->next = entry->prev = NULL; -#ifdef DEBUG - nlist_print(head); -#endif -} - -/* - * Clone an entry in the notify list - - * - entry must not be NULL - */ -notify_list * -nlist_clone(notify_list *entry) -{ - notify_list *new; - - new = nlist_new(NL_MY_NAME(entry), NL_MON_NAME(entry), NL_STATE(entry)); - NL_MY_PROG(new) = NL_MY_PROG(entry); - NL_MY_VERS(new) = NL_MY_VERS(entry); - NL_MY_PROC(new) = NL_MY_PROC(entry); - memcpy(NL_PRIV(new), NL_PRIV(entry), SM_PRIV_SIZE); - - return new; -} - -/* - * Destroy an entry in a notify list and free the memory. - * If *head is NULL, just free the entry. This would be - * done only when we know entry isn't in any list. - * - entry must not be NULL. - */ -void -nlist_free(notify_list **head, notify_list *entry) -{ - if (head && (*head)) - nlist_remove(head, entry); - if (NL_MY_NAME(entry)) - free(NL_MY_NAME(entry)); - if (NL_MON_NAME(entry)) - free(NL_MON_NAME(entry)); - free(entry->dns_name); -} - -/* - * Destroy an entire notify list - */ -void -nlist_kill(notify_list **head) -{ - notify_list *next; - - while (*head) { - next = (*head)->next; - nlist_free(head, *head); - free(*head); - *head = next; - } -} - -/* - * Walk a list looking for a matching name in the NL_MON_NAME field. - */ -notify_list * -nlist_gethost(notify_list *list, char *host, int myname) -{ - notify_list *lp; - - for (lp = list; lp; lp = lp->next) { - if (statd_matchhostname(host, - myname? NL_MY_NAME(lp) : NL_MON_NAME(lp))) - return lp; - } - - return (notify_list *) NULL; -} diff --git a/nfs-utils-2.5.2/utils/statd/notlist.h b/nfs-utils-2.5.2/utils/statd/notlist.h deleted file mode 100644 index 6ed0da8..0000000 --- a/nfs-utils-2.5.2/utils/statd/notlist.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999, 2002 Jeffrey A. Uphoff - * Major rewrite by Olaf Kirch, Dec. 1996. - * - * NSM for Linux. - */ - -#include - -/* - * Primary information structure. - */ -struct notify_list { - mon mon; /* Big honkin' NSM structure. */ - in_port_t port; /* port number for callback */ - short int times; /* Counter used for various things. */ - int state; /* For storing notified state for callbacks. */ - char *dns_name; /* used for matching incoming - * NOTIFY requests */ - struct notify_list *next; /* Linked list forward pointer. */ - struct notify_list *prev; /* Linked list backward pointer. */ - uint32_t xid; /* XID of MS_NOTIFY RPC call */ - time_t when; /* notify: timeout for re-xmit */ -}; - -typedef struct notify_list notify_list; - -/* - * Global Variables - */ -extern notify_list * rtnl; /* Run-time notify list */ -extern notify_list * notify; /* Pending RPC calls */ - -/* - * List-handling functions - */ -extern notify_list * nlist_new(char *, char *, int); -extern void nlist_insert(notify_list **, notify_list *); -extern void nlist_remove(notify_list **, notify_list *); -extern void nlist_insert_timer(notify_list **, notify_list *); -extern notify_list * nlist_clone(notify_list *); -extern void nlist_free(notify_list **, notify_list *); -extern void nlist_kill(notify_list **); -extern notify_list * nlist_gethost(notify_list *, char *, int); - -/* - * List-handling macros. - * THESE INHERIT INFORMATION FROM PREVIOUSLY-DEFINED MACROS. - * (So don't change their order unless you study them first!) - */ -#define NL_NEXT(L) ((L)->next) -#define NL_FIRST NL_NEXT -#define NL_PREV(L) ((L)->prev) -#define NL_DATA(L) ((L)->mon) -#define NL_STATE(L) ((L)->state) -#define NL_TIMES(L) ((L)->times) -#define NL_MON_ID(L) (NL_DATA((L)).mon_id) -#define NL_PRIV(L) (NL_DATA((L)).priv) -#define NL_MON_NAME(L) (NL_MON_ID((L)).mon_name) -#define NL_MY_ID(L) (NL_MON_ID((L)).my_id) -#define NL_MY_NAME(L) (NL_MY_ID((L)).my_name) -#define NL_MY_PROC(L) (NL_MY_ID((L)).my_proc) -#define NL_MY_PROG(L) (NL_MY_ID((L)).my_prog) -#define NL_MY_VERS(L) (NL_MY_ID((L)).my_vers) -#define NL_WHEN(L) ((L)->when) diff --git a/nfs-utils-2.5.2/utils/statd/rmtcall.c b/nfs-utils-2.5.2/utils/statd/rmtcall.c deleted file mode 100644 index 5b26148..0000000 --- a/nfs-utils-2.5.2/utils/statd/rmtcall.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (C) 1996, 1999 Olaf Kirch - * Modified by Jeffrey A. Uphoff, 1997-1999. - * Modified by H.J. Lu, 1998. - * Modified by Lon Hohberger, Oct. 2000 - * - Bugfix handling client responses. - * - Paranoia on NOTIFY_CALLBACK case - * - * NSM for Linux. - */ - -/* - * After reboot, notify all hosts on our notify list. In order not to - * hang statd with delivery to dead hosts, we perform all RPC calls in - * parallel. - * - * It would have been nice to use the portmapper's rmtcall feature, - * but that's not possible for security reasons (the portmapper would - * have to forward the call with root privs for most statd's, which - * it won't if it's worth its money). - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sm_inter.h" -#include "statd.h" -#include "notlist.h" -#include "ha-callout.h" - -#include "nsm.h" -#include "nfsrpc.h" - -#if SIZEOF_SOCKLEN_T - 0 == 0 -#define socklen_t int -#endif - -static int sockfd = -1; /* notify socket */ - -/* How many times to try looking for an unused privileged port */ -#define MAX_BRP_RETRIES 100 - -/* - * Initialize socket used to notify lockd of peer reboots. - * - * Returns the file descriptor of the new socket if successful; - * otherwise returns -1 and logs an error. - * - * Lockd rejects such requests if the source port is not privileged. - * statd_get_socket() must be invoked while statd still holds root - * privileges in order for the socket to acquire a privileged source - * port. - */ -int -statd_get_socket(void) -{ - struct sockaddr_in sin; - struct servent *se; - static int prevsocks[MAX_BRP_RETRIES]; - unsigned int retries; - - if (sockfd >= 0) - return sockfd; - - retries = 0; - do { - if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - xlog(L_ERROR, "%s: Can't create socket: %m", __func__); - break; - } - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if (bindresvport(sockfd, &sin) < 0) { - xlog(D_GENERAL, "%s: can't bind to reserved port", - __func__); - break; - } - se = getservbyport(sin.sin_port, "udp"); - if (se == NULL) - break; - - if (retries == MAX_BRP_RETRIES) { - xlog(D_GENERAL, "%s: No unused privileged ports", - __func__); - break; - } - - /* rather not use that port, try again */ - prevsocks[retries++] = sockfd; - } while (1); - - while (retries) - close(prevsocks[--retries]); - - if (sockfd < 0) - return -1; - - return sockfd; -} - -static notify_list * -recv_rply(u_long *portp) -{ - char msgbuf[NSM_MAXMSGSIZE]; - ssize_t msglen; - notify_list *lp = NULL; - XDR xdr; - struct sockaddr_in sin; - socklen_t alen = (socklen_t)sizeof(sin); - uint32_t xid; - - memset(msgbuf, 0, sizeof(msgbuf)); - msglen = recvfrom(sockfd, msgbuf, sizeof(msgbuf), 0, - (struct sockaddr *)(char *)&sin, &alen); - if (msglen == (ssize_t)-1) { - xlog_warn("%s: recvfrom failed: %m", __func__); - return NULL; - } - - memset(&xdr, 0, sizeof(xdr)); - xdrmem_create(&xdr, msgbuf, (unsigned int)msglen, XDR_DECODE); - xid = nsm_parse_reply(&xdr); - if (xid == 0) - goto done; - if (sin.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { - struct in_addr addr = sin.sin_addr; - char buf[INET_ADDRSTRLEN]; - - xlog_warn("%s: Unrecognized reply from %s", __func__, - inet_ntop(AF_INET, &addr, buf, - (socklen_t)sizeof(buf))); - goto done; - } - - for (lp = notify; lp != NULL; lp = lp->next) { - /* LH - this was a bug... it should have been checking - * the xid from the response message from the client, - * not the static, internal xid */ - if (lp->xid != xid) - continue; - if (lp->port == 0) - *portp = nsm_recv_getport(&xdr); - break; - } - -done: - xdr_destroy(&xdr); - return lp; -} - -/* - * Notify operation for a single list entry - */ -static int -process_entry(notify_list *lp) -{ - struct sockaddr_in sin; - - if (NL_TIMES(lp) == 0) { - xlog(D_GENERAL, "%s: Cannot notify localhost, giving up", - __func__); - return 0; - } - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_port = lp->port; - /* LH - moved address into switch */ - - /* __FORCE__ loopback for callbacks to lockd ... */ - /* Just in case we somehow ignored it thus far */ - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if (sin.sin_port == 0) - lp->xid = nsm_xmit_getport(sockfd, &sin, - (rpcprog_t)NL_MY_PROG(lp), - (rpcvers_t)NL_MY_VERS(lp)); - else { - struct mon m; - - memcpy(m.priv, NL_PRIV(lp), SM_PRIV_SIZE); - - m.mon_id.mon_name = NL_MON_NAME(lp); - m.mon_id.my_id.my_name = NULL; - m.mon_id.my_id.my_prog = NL_MY_PROG(lp); - m.mon_id.my_id.my_vers = NL_MY_VERS(lp); - m.mon_id.my_id.my_proc = NL_MY_PROC(lp); - - lp->xid = nsm_xmit_nlmcall(sockfd, - (struct sockaddr *)(char *)&sin, - (socklen_t)sizeof(sin), &m, NL_STATE(lp)); - } - if (lp->xid == 0) { - xlog_warn("%s: failed to notify port %d", - __func__, ntohs(lp->port)); - } - NL_TIMES(lp) -= 1; - - return 1; -} - -/* - * Process a datagram received on the notify socket - */ -int -process_reply(FD_SET_TYPE *rfds) -{ - notify_list *lp; - u_long port; - - if (sockfd == -1 || !FD_ISSET(sockfd, rfds)) - return 0; - - /* Should not be processed again. */ - FD_CLR (sockfd, rfds); - - if (!(lp = recv_rply(&port))) - return 1; - - if (lp->port == 0) { - if (port != 0) { - lp->port = htons((unsigned short) port); - process_entry(lp); - NL_WHEN(lp) = time(NULL) + NOTIFY_TIMEOUT; - nlist_remove(¬ify, lp); - nlist_insert_timer(¬ify, lp); - return 1; - } - xlog_warn("%s: service %d not registered on localhost", - __func__, NL_MY_PROG(lp)); - } else { - xlog(D_GENERAL, "%s: Callback to %s (for %s) succeeded", - __func__, NL_MY_NAME(lp), NL_MON_NAME(lp)); - } - nlist_free(¬ify, lp); - return 1; -} - -/* - * Process a notify list, either for notifying remote hosts after reboot - * or for calling back (local) statd clients when the remote has notified - * us of a crash. - */ -int -process_notify_list(void) -{ - notify_list *entry; - time_t now; - - while ((entry = notify) != NULL && NL_WHEN(entry) < time(&now)) { - if (process_entry(entry)) { - NL_WHEN(entry) = time(NULL) + NOTIFY_TIMEOUT; - nlist_remove(¬ify, entry); - nlist_insert_timer(¬ify, entry); - } else { - xlog(L_ERROR, - "%s: Can't callback %s (%d,%d), giving up", - __func__, - NL_MY_NAME(entry), - NL_MY_PROG(entry), - NL_MY_VERS(entry)); - nlist_free(¬ify, entry); - } - } - - return 1; -} diff --git a/nfs-utils-2.5.2/utils/statd/sim_sm_inter.x b/nfs-utils-2.5.2/utils/statd/sim_sm_inter.x deleted file mode 100644 index 4346199..0000000 --- a/nfs-utils-2.5.2/utils/statd/sim_sm_inter.x +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, 1996. - * Modified by H.J. Lu, 1998. - * - * NSM for Linux. - */ - -#ifdef RPC_CLNT -%#include -#endif - -program SIM_SM_PROG { - version SIM_SM_VERS { - void SIM_SM_MON(struct status) = 1; - } = 1; -} = 200048; - -const SM_MAXSTRLEN = 1024; -const SM_PRIV_SIZE = 16; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -%#ifndef SM_INTER_X -struct status { - string mon_name; - int state; - opaque priv[SM_PRIV_SIZE]; /* stored private information */ -}; -%#endif /* SM_INTER_X */ diff --git a/nfs-utils-2.5.2/utils/statd/simu.c b/nfs-utils-2.5.2/utils/statd/simu.c deleted file mode 100644 index f1d0bf8..0000000 --- a/nfs-utils-2.5.2/utils/statd/simu.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "sockaddr.h" -#include "rpcmisc.h" -#include "statd.h" -#include "notlist.h" - -extern void my_svc_exit (void); - - -/* - * Services SM_SIMU_CRASH requests. - * - * Although the kernel contacts the statd service via only IPv4 - * transports, the statd service can receive other requests, such - * as SM_NOTIFY, from remote peers via IPv6. - */ -void * -sm_simu_crash_1_svc (__attribute__ ((unused)) void *argp, struct svc_req *rqstp) -{ - struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); - char buf[INET6_ADDRSTRLEN]; - static char *result = NULL; - - xlog(D_CALL, "Received SM_SIMU_CRASH"); - - if (!nfs_is_v4_loopback(sap)) - goto out_nonlocal; - - if ((int)nfs_get_port(sap) >= IPPORT_RESERVED) { - xlog_warn("SM_SIMU_CRASH call from unprivileged port"); - goto failure; - } - - my_svc_exit (); - - if (rtnl) - nlist_kill (&rtnl); - - failure: - return ((void *)&result); - - out_nonlocal: - if (!statd_present_address(sap, buf, sizeof(buf))) - buf[0] = '\0'; - xlog_warn("SM_SIMU_CRASH call from non-local host %s", buf); - goto failure; -} diff --git a/nfs-utils-2.5.2/utils/statd/simulate.c b/nfs-utils-2.5.2/utils/statd/simulate.c deleted file mode 100644 index 4ed1468..0000000 --- a/nfs-utils-2.5.2/utils/statd/simulate.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff - * - * NSM for Linux. - */ - -#include "config.h" -#ifndef SIMULATIONS -# error How the hell did we get here? -#endif - -/* If we're running the simulator, we're debugging. Pretty simple. */ -#ifndef DEBUG -# define DEBUG -#endif - -#include -#include -#include -#include -#include -#include "statd.h" -#include "sim_sm_inter.h" - -static void daemon_simulator (void); -static void sim_killer (int sig); -static void simulate_crash (char *); -static void simulate_mon (char *, char *, char *, char *, char *); -static void simulate_stat (char *, char *); -static void simulate_unmon (char *, char *, char *, char *); -static void simulate_unmon_all (char *, char *, char *); - -static int sim_port = 0; - -extern void sim_sm_prog_1 (struct svc_req *, register SVCXPRT); -extern void svc_exit (void); - -void -simulator (int argc, char **argv) -{ - xlog_stderr (1); - xlog_syslog (0); - xlog_open ("statd simulator"); - - if (argc == 2) - if (!strcasecmp (*argv, "crash")) - simulate_crash (*(&argv[1])); - - if (argc == 3) { - if (!strcasecmp (*argv, "stat")) - simulate_stat (*(&argv[1]), *(&argv[2])); - } - if (argc == 4) { - if (!strcasecmp (*argv, "unmon_all")) - simulate_unmon_all (*(&argv[1]), *(&argv[2]), *(&argv[3])); - } - if (argc == 5) { - if (!strcasecmp (*argv, "unmon")) - simulate_unmon (*(&argv[1]), *(&argv[2]), *(&argv[3]), *(&argv[4])); - } - if (argc == 6) { - if (!strcasecmp (*argv, "mon")) - simulate_mon (*(&argv[1]), *(&argv[2]), *(&argv[3]), *(&argv[4]), - *(&argv[5])); - } - xlog_err ("WTF? Give me something I can use!"); -} - -static void -simulate_mon (char *calling, char *monitoring, char *as, char *proggy, - char *fool) -{ - CLIENT *client; - sm_stat_res *result; - mon mon; - - xlog (D_GENERAL, "Calling %s (as %s) to monitor %s", calling, as, - monitoring); - - if ((client = clnt_create (calling, SM_PROG, SM_VERS, "udp")) == NULL) - xlog_err ("%s", clnt_spcreateerror ("clnt_create")); - - memcpy (mon.priv, fool, SM_PRIV_SIZE); - mon.mon_id.my_id.my_name = xstrdup (as); - sim_port = atoi (proggy) * SIM_SM_PROG; - mon.mon_id.my_id.my_prog = sim_port; /* Pseudo-dummy */ - mon.mon_id.my_id.my_vers = SIM_SM_VERS; - mon.mon_id.my_id.my_proc = SIM_SM_MON; - mon.mon_id.mon_name = monitoring; - - if (!(result = sm_mon_1 (&mon, client))) - xlog_err ("%s", clnt_sperror (client, "sm_mon_1")); - - free (mon.mon_id.my_id.my_name); - - if (result->res_stat != STAT_SUCC) { - xlog_err ("SM_MON request failed, state: %d", result->state); - } else { - xlog (D_GENERAL, "SM_MON result successful, state: %d\n", result->state); - xlog (D_GENERAL, "Waiting for callback"); - daemon_simulator (); - exit (0); - } -} - -static void -simulate_unmon (char *calling, char *unmonitoring, char *as, char *proggy) -{ - CLIENT *client; - sm_stat *result; - mon_id mon_id; - - xlog (D_GENERAL, "Calling %s (as %s) to unmonitor %s", calling, as, - unmonitoring); - - if ((client = clnt_create (calling, SM_PROG, SM_VERS, "udp")) == NULL) - xlog_err ("%s", clnt_spcreateerror ("clnt_create")); - - mon_id.my_id.my_name = xstrdup (as); - mon_id.my_id.my_prog = atoi (proggy) * SIM_SM_PROG; - mon_id.my_id.my_vers = SIM_SM_VERS; - mon_id.my_id.my_proc = SIM_SM_MON; - mon_id.mon_name = unmonitoring; - - if (!(result = sm_unmon_1 (&mon_id, client))) - xlog_err ("%s", clnt_sperror (client, "sm_unmon_1")); - - free (mon_id.my_id.my_name); - xlog (D_GENERAL, "SM_UNMON request returned state: %d\n", result->state); - exit (0); -} - -static void -simulate_unmon_all (char *calling, char *as, char *proggy) -{ - CLIENT *client; - sm_stat *result; - my_id my_id; - - xlog (D_GENERAL, "Calling %s (as %s) to unmonitor all hosts", calling, as); - - if ((client = clnt_create (calling, SM_PROG, SM_VERS, "udp")) == NULL) - xlog_err ("%s", clnt_spcreateerror ("clnt_create")); - - my_id.my_name = xstrdup (as); - my_id.my_prog = atoi (proggy) * SIM_SM_PROG; - my_id.my_vers = SIM_SM_VERS; - my_id.my_proc = SIM_SM_MON; - - if (!(result = sm_unmon_all_1 (&my_id, client))) - xlog_err ("%s", clnt_sperror (client, "sm_unmon_all_1")); - - free (my_id.my_name); - xlog (D_GENERAL, "SM_UNMON_ALL request returned state: %d\n", result->state); - exit (0); -} - -static void -simulate_crash (char *host) -{ - CLIENT *client; - - if ((client = clnt_create (host, SM_PROG, SM_VERS, "udp")) == NULL) - xlog_err ("%s", clnt_spcreateerror ("clnt_create")); - - if (!sm_simu_crash_1 (NULL, client)) - xlog_err ("%s", clnt_sperror (client, "sm_simu_crash_1")); - - exit (0); -} - -static void -simulate_stat (char *calling, char *monitoring) -{ - CLIENT *client; - sm_name checking; - sm_stat_res *result; - - if ((client = clnt_create (calling, SM_PROG, SM_VERS, "udp")) == NULL) - xlog_err ("%s", clnt_spcreateerror ("clnt_create")); - - checking.mon_name = monitoring; - - if (!(result = sm_stat_1 (&checking, client))) - xlog_err ("%s", clnt_sperror (client, "sm_stat_1")); - - if (result->res_stat == STAT_SUCC) - xlog (D_GENERAL, "STAT_SUCC from %s for %s, state: %d", calling, - monitoring, result->state); - else - xlog (D_GENERAL, "STAT_FAIL from %s for %s, state: %d", calling, - monitoring, result->state); - - exit (0); -} - -static void -sim_killer (int sig) -{ - pmap_unset (sim_port, SIM_SM_VERS); - xlog_err ("Simulator caught signal %d, un-registering and exiting", sig); -} - -static void -daemon_simulator (void) -{ - signal (SIGHUP, sim_killer); - signal (SIGINT, sim_killer); - signal (SIGTERM, sim_killer); - pmap_unset (sim_port, SIM_SM_VERS); - /* this registers both UDP and TCP services */ - rpc_init("statd", sim_port, SIM_SM_VERS, sim_sm_prog_1, 0); - svc_run (); - pmap_unset (sim_port, SIM_SM_VERS); -} - -void * -sim_sm_mon_1_svc (struct status *argp, struct svc_req *rqstp) -{ - static char *result; - - xlog (D_GENERAL, "Recieved state %d for mon_name %s (opaque \"%s\")", - argp->state, argp->mon_name, argp->priv); - svc_exit (); - return ((void *)&result); -} diff --git a/nfs-utils-2.5.2/utils/statd/sm-notify.c b/nfs-utils-2.5.2/utils/statd/sm-notify.c deleted file mode 100644 index 739731f..0000000 --- a/nfs-utils-2.5.2/utils/statd/sm-notify.c +++ /dev/null @@ -1,927 +0,0 @@ -/* - * Send NSM notify calls to all hosts listed in /var/lib/sm - * - * Copyright (C) 2004-2006 Olaf Kirch - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "sockaddr.h" -#include "xlog.h" -#include "nsm.h" -#include "nfslib.h" -#include "nfsrpc.h" - -/* glibc before 2.3.4 */ -#ifndef AI_NUMERICSERV -#define AI_NUMERICSERV 0 -#endif - -#define NSM_TIMEOUT 2 -#define NSM_MAX_TIMEOUT 120 /* don't make this too big */ - -#define NLM_END_GRACE_FILE "/proc/fs/lockd/nlm_end_grace" - -int lift_grace = 1; -int force = 0; - -struct nsm_host { - struct nsm_host * next; - char * name; - const char * mon_name; - const char * my_name; - char * notify_arg; - struct addrinfo *ai; - time_t last_used; - time_t send_next; - unsigned int timeout; - unsigned int retries; - uint32_t xid; -}; - -static char nsm_hostname[SM_MAXSTRLEN + 1]; -static int nsm_state; -static int nsm_family = AF_INET; -static int opt_debug = 0; -static _Bool opt_update_state = true; -static unsigned int opt_max_retry = 15 * 60; -static char * opt_srcaddr = NULL; -static char * opt_srcport = NULL; - -static void notify(const int sock); -static int notify_host(int, struct nsm_host *); -static void recv_reply(int); -static void insert_host(struct nsm_host *); -static struct nsm_host *find_host(uint32_t); -static int record_pid(void); - -static struct nsm_host * hosts = NULL; - -__attribute__((__malloc__)) -static struct addrinfo * -smn_lookup(const char *name) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { - .ai_family = (nsm_family == AF_INET ? AF_INET: AF_UNSPEC), - .ai_protocol = (int)IPPROTO_UDP, - }; - int error; - - res_init(); - error = getaddrinfo(name, NULL, &hint, &ai); - if (error != 0) { - xlog(D_GENERAL, "getaddrinfo(3): %s", gai_strerror(error)); - return NULL; - } - - return ai; -} - -#ifdef HAVE_GETNAMEINFO -static char * -smn_get_hostname(const struct sockaddr *sap, const socklen_t salen, - const char *name) -{ - char buf[NI_MAXHOST]; - int error; - - error = getnameinfo(sap, salen, buf, sizeof(buf), NULL, 0, NI_NAMEREQD); - if (error != 0) { - xlog(L_ERROR, "my_name '%s' is unusable: %s", - name, gai_strerror(error)); - return NULL; - } - return strdup(buf); -} -#else /* !HAVE_GETNAMEINFO */ -static char * -smn_get_hostname(const struct sockaddr *sap, - __attribute__ ((unused)) const socklen_t salen, - const char *name) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)(char *)sap; - const struct in_addr *addr = &sin->sin_addr; - struct hostent *hp; - - if (sap->sa_family != AF_INET) { - xlog(L_ERROR, "my_name '%s' is unusable: Bad address family", - name); - return NULL; - } - - hp = gethostbyaddr(addr, (socklen_t)sizeof(addr), AF_INET); - if (hp == NULL) { - xlog(L_ERROR, "my_name '%s' is unusable: %s", - name, hstrerror(h_errno)); - return NULL; - } - return strdup(hp->h_name); -} -#endif /* !HAVE_GETNAMEINFO */ - -/* - * Presentation addresses are converted to their canonical hostnames. - * If the IP address does not map to a hostname, it is an error: - * we never send a presentation address as the argument of SM_NOTIFY. - * - * If "name" is not a presentation address, it is left alone. This - * allows the administrator some flexibility if DNS isn't configured - * exactly how sm-notify prefers it. - * - * Returns NUL-terminated C string containing the result, or NULL - * if the canonical name doesn't exist or cannot be determined. - * The caller must free the result with free(3). - */ -__attribute__((__malloc__)) -static char * -smn_verify_my_name(const char *name) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { -#ifdef IPV6_SUPPORTED - .ai_family = AF_UNSPEC, -#else /* !IPV6_SUPPORTED */ - .ai_family = AF_INET, -#endif /* !IPV6_SUPPORTED */ - .ai_flags = AI_NUMERICHOST, - }; - char *retval; - int error; - - error = getaddrinfo(name, NULL, &hint, &ai); - switch (error) { - case 0: - /* @name was a presentation address */ - retval = smn_get_hostname(ai->ai_addr, ai->ai_addrlen, name); - nfs_freeaddrinfo(ai); - if (retval == NULL) - return NULL; - break; - case EAI_NONAME: - /* @name was not a presentation address */ - retval = strdup(name); - break; - default: - xlog(L_ERROR, "my_name '%s' is unusable: %s", - name, gai_strerror(error)); - return NULL; - } - - xlog(D_GENERAL, "Canonical name for my_name '%s': %s", - name, retval); - return retval; -} - -__attribute__((__malloc__)) -static struct nsm_host * -smn_alloc_host(const char *hostname, const char *mon_name, - const char *my_name, const time_t timestamp) -{ - struct nsm_host *host; - - host = calloc(1, sizeof(*host)); - if (host == NULL) - goto out_nomem; - - /* - * mon_name and my_name are preserved so sm-notify can - * find the right monitor record to remove when it is - * done processing this host. - */ - host->name = strdup(hostname); - host->mon_name = (const char *)strdup(mon_name); - host->my_name = (const char *)strdup(my_name); - host->notify_arg = strdup(opt_srcaddr != NULL ? - nsm_hostname : my_name); - if (host->name == NULL || - host->mon_name == NULL || - host->my_name == NULL || - host->notify_arg == NULL) { - free(host->notify_arg); - free((void *)host->my_name); - free((void *)host->mon_name); - free(host->name); - free(host); - goto out_nomem; - } - - host->last_used = timestamp; - host->timeout = NSM_TIMEOUT; - host->retries = 100; /* force address retry */ - - return host; - -out_nomem: - xlog_warn("Unable to allocate memory"); - return NULL; -} - -static void smn_forget_host(struct nsm_host *host) -{ - xlog(D_CALL, "Removing %s (%s, %s) from notify list", - host->name, host->mon_name, host->my_name); - - nsm_delete_notified_host(host->name, host->mon_name, host->my_name); - - free(host->notify_arg); - free((void *)host->my_name); - free((void *)host->mon_name); - free(host->name); - nfs_freeaddrinfo(host->ai); - - free(host); -} - -static unsigned int -smn_get_host(const char *hostname, - __attribute__ ((unused)) const struct sockaddr *sap, - const struct mon *m, const time_t timestamp) -{ - struct nsm_host *host; - - host = smn_alloc_host(hostname, - m->mon_id.mon_name, m->mon_id.my_id.my_name, timestamp); - if (host == NULL) - return 0; - - insert_host(host); - return 1; -} - -#ifdef IPV6_SUPPORTED -static int smn_socket(void) -{ - int sock; - - /* - * Use an AF_INET socket if IPv6 is disabled on the - * local system. - */ - sock = socket(AF_INET6, SOCK_DGRAM, 0); - if (sock == -1) { - if (errno != EAFNOSUPPORT) { - xlog(L_ERROR, "Failed to create RPC socket: %m"); - return -1; - } - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock < 0) { - xlog(L_ERROR, "Failed to create RPC socket: %m"); - return -1; - } - } else - nsm_family = AF_INET6; - - if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) { - xlog(L_ERROR, "fcntl(3) on RPC socket failed: %m"); - goto out_close; - } - - /* - * TI-RPC over IPv6 (udp6/tcp6) does not handle IPv4. However, - * since sm-notify open-codes all of its RPC support, it can - * use a single socket and let the local network stack provide - * the correct mapping between address families automatically. - * This is the same thing that is done in the kernel. - */ - if (nsm_family == AF_INET6) { - const int zero = 0; - socklen_t zerolen = (socklen_t)sizeof(zero); - - if (setsockopt(sock, SOL_IPV6, IPV6_V6ONLY, - (char *)&zero, zerolen) == -1) { - xlog(L_ERROR, "setsockopt(3) on RPC socket failed: %m"); - goto out_close; - } - } - - return sock; - -out_close: - (void)close(sock); - return -1; -} -#else /* !IPV6_SUPPORTED */ -static int smn_socket(void) -{ - int sock; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == -1) { - xlog(L_ERROR, "Failed to create RPC socket: %m"); - return -1; - } - - if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) { - xlog(L_ERROR, "fcntl(3) on RPC socket failed: %m"); - (void)close(sock); - return -1; - } - - return sock; -} -#endif /* !IPV6_SUPPORTED */ - -/* - * If admin specified a source address or srcport, then convert those - * to a sockaddr and return it. Otherwise, return an ANYADDR address. - */ -__attribute__((__malloc__)) -static struct addrinfo * -smn_bind_address(const char *srcaddr, const char *srcport) -{ - struct addrinfo *ai = NULL; - struct addrinfo hint = { - .ai_flags = AI_NUMERICSERV | AI_V4MAPPED, - .ai_family = nsm_family, - .ai_protocol = (int)IPPROTO_UDP, - }; - int error; - - if (srcaddr == NULL) - hint.ai_flags |= AI_PASSIVE; - - /* Do not allow "node" and "service" parameters both to be NULL */ - if (srcport == NULL) - error = getaddrinfo(srcaddr, "", &hint, &ai); - else - error = getaddrinfo(srcaddr, srcport, &hint, &ai); - if (error != 0) { - xlog(L_ERROR, - "Invalid bind address or port for RPC socket: %s", - gai_strerror(error)); - return NULL; - } - - return ai; -} - -#ifdef HAVE_LIBTIRPC -static int -smn_bindresvport(int sock, struct sockaddr *sap) -{ - return bindresvport_sa(sock, sap); -} - -#else /* !HAVE_LIBTIRPC */ -static int -smn_bindresvport(int sock, struct sockaddr *sap) -{ - if (sap->sa_family != AF_INET) { - errno = EAFNOSUPPORT; - return -1; - } - - return bindresvport(sock, (struct sockaddr_in *)(char *)sap); -} -#endif /* !HAVE_LIBTIRPC */ - -/* - * Prepare a socket for sending RPC requests - * - * Returns a bound datagram socket file descriptor, or -1 if - * an error occurs. - */ -static int -smn_create_socket(const char *srcaddr, const char *srcport) -{ - int sock, retry_cnt = 0; - struct addrinfo *ai; - -retry: - sock = smn_socket(); - if (sock == -1) - return -1; - - ai = smn_bind_address(srcaddr, srcport); - if (ai == NULL) { - (void)close(sock); - return -1; - } - - /* Use source port if provided on the command line, - * otherwise use bindresvport */ - if (srcport) { - if (bind(sock, ai->ai_addr, ai->ai_addrlen) == -1) { - xlog(L_ERROR, "Failed to bind RPC socket: %m"); - nfs_freeaddrinfo(ai); - (void)close(sock); - return -1; - } - } else { - struct servent *se; - - if (smn_bindresvport(sock, ai->ai_addr) == -1) { - xlog(L_ERROR, - "bindresvport on RPC socket failed: %m"); - nfs_freeaddrinfo(ai); - (void)close(sock); - return -1; - } - - /* try to avoid known ports */ - se = getservbyport((int)nfs_get_port(ai->ai_addr), "udp"); - if (se != NULL && retry_cnt < 100) { - retry_cnt++; - nfs_freeaddrinfo(ai); - (void)close(sock); - goto retry; - } - } - - nfs_freeaddrinfo(ai); - return sock; -} - -/* Inform the kernel that it's OK to lift lockd's grace period */ -static void -nsm_lift_grace_period(void) -{ - int fd; - - fd = open(NLM_END_GRACE_FILE, O_WRONLY); - if (fd < 0) { - /* Don't warn if file isn't present */ - if (errno != ENOENT) - xlog(L_WARNING, "Unable to open %s: %m", - NLM_END_GRACE_FILE); - return; - } - - if (write(fd, "Y", 1) < 0) - xlog(L_WARNING, "Unable to write to %s: %m", NLM_END_GRACE_FILE); - - close(fd); - return; -} -inline static void -read_nfsconf(char **argv) -{ - char *s; - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("sm-notify"); - opt_max_retry = conf_get_num("sm-notify", "retry-time", opt_max_retry / 60) * 60; - opt_srcport = conf_get_str("sm-notify", "outgoing-port"); - opt_srcaddr = conf_get_str("sm-notify", "outgoing-addr"); - lift_grace = conf_get_bool("sm-notify", "lift-grace", lift_grace); - - s = conf_get_str("statd", "state-directory-path"); - if (s && !nsm_setup_pathnames(argv[0], s)) - exit(1); - opt_update_state = conf_get_bool("sm-notify", "update-state", opt_update_state); - force = conf_get_bool("sm-notify", "force", force); -} - -int -main(int argc, char **argv) -{ - int c, sock; - char * progname; - - progname = strrchr(argv[0], '/'); - if (progname != NULL) - progname++; - else - progname = argv[0]; - - read_nfsconf(argv); - - while ((c = getopt(argc, argv, "dm:np:v:P:f")) != -1) { - switch (c) { - case 'f': - force = 1; - break; - case 'd': - opt_debug++; - break; - case 'm': - opt_max_retry = atoi(optarg) * 60; - break; - case 'n': - opt_update_state = false; - break; - case 'p': - opt_srcport = optarg; - break; - case 'v': - opt_srcaddr = optarg; - break; - case 'P': - if (!nsm_setup_pathnames(argv[0], optarg)) - exit(1); - break; - - default: - goto usage; - } - } - - if (optind < argc) { -usage: fprintf(stderr, - "Usage: %s -notify [-dfq] [-m max-retry-minutes] [-p srcport]\n" - " [-P /path/to/state/directory] [-v my_host_name]\n", - progname); - exit(1); - } - - if (opt_debug) { - xlog_syslog(0); - xlog_stderr(1); - xlog_config(D_ALL, 1); - } else { - xlog_syslog(1); - xlog_stderr(0); - } - - xlog_open(progname); - xlog(L_NOTICE, "Version " VERSION " starting"); - - if (nsm_is_default_parentdir()) { - if (record_pid() == 0 && force == 0 && opt_update_state) { - /* already run, don't try again */ - xlog(L_NOTICE, "Already notifying clients; Exiting!"); - exit(0); - } - } - - if (opt_srcaddr != NULL) { - char *name; - - name = smn_verify_my_name(opt_srcaddr); - if (name == NULL) - exit(1); - - strncpy(nsm_hostname, name, sizeof(nsm_hostname)-1); - free(name); - } - - (void)nsm_retire_monitored_hosts(); - if (nsm_load_notify_list(smn_get_host) == 0) { - xlog(D_GENERAL, "No hosts to notify; exiting"); - if (lift_grace) - nsm_lift_grace_period(); - return 0; - } - - nsm_state = nsm_get_state(opt_update_state); - if (nsm_state == 0) - exit(1); - nsm_update_kernel_state(nsm_state); - - if (!opt_debug) { - xlog(L_NOTICE, "Backgrounding to notify hosts...\n"); - - if (daemon(0, 0) < 0) { - xlog(L_ERROR, "unable to background: %m"); - exit(1); - } - - close(0); - close(1); - close(2); - } - - sock = smn_create_socket(opt_srcaddr, opt_srcport); - if (sock == -1) - exit(1); - - if (!nsm_drop_privileges(-1)) - exit(1); - - notify(sock); - - if (hosts) { - struct nsm_host *hp; - - while ((hp = hosts) != 0) { - hosts = hp->next; - xlog(L_NOTICE, "Unable to notify %s, giving up", - hp->name); - } - exit(1); - } - - exit(0); -} - -/* - * Notify hosts - */ -static void -notify(const int sock) -{ - time_t failtime = 0; - - if (opt_max_retry) - failtime = time(NULL) + opt_max_retry; - - while (hosts) { - struct pollfd pfd; - time_t now = time(NULL); - unsigned int sent = 0; - struct nsm_host *hp; - long wait; - - if (failtime && now >= failtime) - break; - - while (hosts && ((wait = hosts->send_next - now) <= 0)) { - /* Never send more than 10 packets at once */ - if (sent++ >= 10) - break; - - /* Remove queue head */ - hp = hosts; - hosts = hp->next; - - if (notify_host(sock, hp)) - continue; - - /* Set the timeout for this call, using an - exponential timeout strategy */ - wait = hp->timeout; - if ((hp->timeout <<= 1) > NSM_MAX_TIMEOUT) - hp->timeout = NSM_MAX_TIMEOUT; - hp->send_next = now + wait; - hp->retries++; - - insert_host(hp); - } - if (hosts == NULL) - return; - - xlog(D_GENERAL, "Host %s due in %ld seconds", - hosts->name, wait); - - pfd.fd = sock; - pfd.events = POLLIN; - - wait *= 1000; - if (wait < 100) - wait = 100; - if (poll(&pfd, 1, wait) != 1) - continue; - - recv_reply(sock); - } -} - -/* - * Send notification to a single host - */ -static int -notify_host(int sock, struct nsm_host *host) -{ - struct sockaddr *sap; - socklen_t salen; - - if (host->ai == NULL) { - host->ai = smn_lookup(host->name); - if (host->ai == NULL) { - xlog_warn("DNS resolution of %s failed; " - "retrying later", host->name); - return 0; - } - } - - /* If we retransmitted 4 times, reset the port to force - * a new portmap lookup (in case statd was restarted). - * We also rotate through multiple IP addresses at this - * point. - */ - if (host->retries >= 4) { - /* don't rotate if there is only one addrinfo */ - if (host->ai->ai_next != NULL) { - struct addrinfo *first = host->ai; - struct addrinfo **next = &host->ai; - - /* remove the first entry from the list */ - host->ai = first->ai_next; - first->ai_next = NULL; - /* find the end of the list */ - next = &first->ai_next; - while ( *next ) - next = & (*next)->ai_next; - /* put first entry at end */ - *next = first; - } - - nfs_set_port(host->ai->ai_addr, 0); - host->retries = 0; - } - - sap = host->ai->ai_addr; - salen = host->ai->ai_addrlen; - - if (nfs_get_port(sap) == 0) - host->xid = nsm_xmit_rpcbind(sock, sap, SM_PROG, SM_VERS); - else - host->xid = nsm_xmit_notify(sock, sap, salen, - SM_PROG, host->notify_arg, nsm_state); - - return 0; -} - -static void -smn_defer(struct nsm_host *host) -{ - host->xid = 0; - host->send_next = time(NULL) + NSM_MAX_TIMEOUT; - host->timeout = NSM_MAX_TIMEOUT; - insert_host(host); -} - -static void -smn_schedule(struct nsm_host *host) -{ - host->retries = 0; - host->xid = 0; - host->send_next = time(NULL); - host->timeout = NSM_TIMEOUT; - insert_host(host); -} - -/* - * Extract the returned port number and set up the SM_NOTIFY call. - */ -static void -recv_rpcbind_reply(struct sockaddr *sap, struct nsm_host *host, XDR *xdr) -{ - uint16_t port = nsm_recv_rpcbind(sap->sa_family, xdr); - - if (port == 0) { - /* No binding for statd... */ - xlog(D_GENERAL, "No statd on host %s", host->name); - smn_defer(host); - } else { - xlog(D_GENERAL, "Processing rpcbind reply for %s (port %u)", - host->name, port); - nfs_set_port(sap, port); - smn_schedule(host); - } -} - -/* - * Successful NOTIFY call. Server returns void. - * - * Try sending another SM_NOTIFY with an unqualified "my_name" - * argument. Reuse the port number. If "my_name" is already - * unqualified, we're done. - */ -static void -recv_notify_reply(struct nsm_host *host) -{ - char *dot = strchr(host->notify_arg, '.'); - - if (dot != NULL) { - *dot = '\0'; - smn_schedule(host); - } else { - xlog(D_GENERAL, "Host %s notified successfully", host->name); - smn_forget_host(host); - } -} - -/* - * Receive reply from remote host - */ -static void -recv_reply(int sock) -{ - struct nsm_host *hp; - struct sockaddr *sap; - char msgbuf[NSM_MAXMSGSIZE]; - uint32_t xid; - ssize_t msglen; - XDR xdr; - - memset(msgbuf, 0 , sizeof(msgbuf)); - msglen = recv(sock, msgbuf, sizeof(msgbuf), 0); - if (msglen < 0) - return; - - xlog(D_GENERAL, "Received packet..."); - - memset(&xdr, 0, sizeof(xdr)); - xdrmem_create(&xdr, msgbuf, (unsigned int)msglen, XDR_DECODE); - xid = nsm_parse_reply(&xdr); - if (xid == 0) - goto out; - - /* Before we look at the data, find the host struct for - this reply */ - if ((hp = find_host(xid)) == NULL) - goto out; - - sap = hp->ai->ai_addr; - if (nfs_get_port(sap) == 0) - recv_rpcbind_reply(sap, hp, &xdr); - else - recv_notify_reply(hp); - -out: - xdr_destroy(&xdr); -} - -/* - * Insert host into notification list, sorted by next send time - */ -static void -insert_host(struct nsm_host *host) -{ - struct nsm_host **where, *p; - - where = &hosts; - while ((p = *where) != 0) { - /* Sort in ascending order of timeout */ - if (host->send_next < p->send_next) - break; - /* If we have the same timeout, put the - * most recently used host first. - * This makes sure that "recent" hosts - * get notified first. - */ - if (host->send_next == p->send_next - && host->last_used > p->last_used) - break; - where = &p->next; - } - - host->next = *where; - *where = host; - xlog(D_GENERAL, "Added host %s to notify list", host->name); -} - -/* - * Find host given the XID - */ -static struct nsm_host * -find_host(uint32_t xid) -{ - struct nsm_host **where, *p; - - where = &hosts; - while ((p = *where) != 0) { - if (p->xid == xid) { - *where = p->next; - return p; - } - where = &p->next; - } - return NULL; -} - -/* - * Record pid in /var/run/sm-notify.pid - * This file should remain until a reboot, even if the - * program exits. - * If file already exists, fail. - */ -static int record_pid(void) -{ - char pid[20]; - ssize_t len; - int fd; - - (void)snprintf(pid, sizeof(pid), "%d\n", (int)getpid()); - fd = open("/var/run/sm-notify.pid", O_CREAT|O_EXCL|O_WRONLY, 0600); - if (fd < 0) - return 0; - - len = write(fd, pid, strlen(pid)); - if ((len < 0) || ((size_t)len != strlen(pid))) { - xlog_warn("Writing to pid file failed: errno %d (%m)", - errno); - } - - (void)close(fd); - return 1; -} diff --git a/nfs-utils-2.5.2/utils/statd/sm-notify.man b/nfs-utils-2.5.2/utils/statd/sm-notify.man deleted file mode 100644 index addf5d3..0000000 --- a/nfs-utils-2.5.2/utils/statd/sm-notify.man +++ /dev/null @@ -1,366 +0,0 @@ -.\"@(#)sm-notify.8" -.\" -.\" Copyright (C) 2004 Olaf Kirch -.\" -.\" Rewritten by Chuck Lever , 2009. -.\" Copyright 2009 Oracle. All rights reserved. -.\" -.TH SM-NOTIFY 8 "1 November 2009 -.SH NAME -sm-notify \- send reboot notifications to NFS peers -.SH SYNOPSIS -.BI "/usr/sbin/sm-notify [-dfn] [-m " minutes "] [-v " name "] [-p " notify-port "] [-P " path "] -.SH DESCRIPTION -File locks are not part of persistent file system state. -Lock state is thus lost when a host reboots. -.PP -Network file systems must also detect when lock state is lost -because a remote host has rebooted. -After an NFS client reboots, an NFS server must release all file locks -held by applications that were running on that client. -After a server reboots, a client must remind the -server of file locks held by applications running on that client. -.PP -For NFS version 2 and version 3, the -.I Network Status Monitor -protocol (or NSM for short) -is used to notify NFS peers of reboots. -On Linux, two separate user-space components constitute the NSM service: -.TP -.B sm-notify -A helper program that notifies NFS peers after the local system reboots -.TP -.B rpc.statd -A daemon that listens for reboot notifications from other hosts, and -manages the list of hosts to be notified when the local system reboots -.PP -The local NFS lock manager alerts its local -.B rpc.statd -of each remote peer that should be monitored. -When the local system reboots, the -.B sm-notify -command notifies the NSM service on monitored peers of the reboot. -When a remote reboots, that peer notifies the local -.BR rpc.statd , -which in turn passes the reboot notification -back to the local NFS lock manager. -.SH NSM OPERATION IN DETAIL -The first file locking interaction between an NFS client and server causes -the NFS lock managers on both peers to contact their local NSM service to -store information about the opposite peer. -On Linux, the local lock manager contacts -.BR rpc.statd . -.PP -.B rpc.statd -records information about each monitored NFS peer on persistent storage. -This information describes how to contact a remote peer -in case the local system reboots, -how to recognize which monitored peer is reporting a reboot, -and how to notify the local lock manager when a monitored peer -indicates it has rebooted. -.PP -An NFS client sends a hostname, known as the client's -.IR caller_name , -in each file lock request. -An NFS server can use this hostname to send asynchronous GRANT -calls to a client, or to notify the client it has rebooted. -.PP -The Linux NFS server can provide the client's -.I caller_name -or the client's network address to -.BR rpc.statd . -For the purposes of the NSM protocol, -this name or address is known as the monitored peer's -.IR mon_name . -In addition, the local lock manager tells -.B rpc.statd -what it thinks its own hostname is. -For the purposes of the NSM protocol, -this hostname is known as -.IR my_name . -.PP -There is no equivalent interaction between an NFS server and a client -to inform the client of the server's -.IR caller_name . -Therefore NFS clients do not actually know what -.I mon_name -an NFS server might use in an SM_NOTIFY request. -The Linux NFS client records the server's hostname used on the mount command -to identify rebooting NFS servers. -.SS Reboot notification -When the local system reboots, the -.B sm-notify -command reads the list of monitored peers from persistent storage and -sends an SM_NOTIFY request to the NSM service on each listed remote peer. -It uses the -.I mon_name -string as the destination. -To identify which host has rebooted, the -.B sm-notify -command normally sends -.I my_name -string recorded when that remote was monitored. -The remote -.B rpc.statd -matches incoming SM_NOTIFY requests using this string, -or the caller's network address, -to one or more peers on its own monitor list. -.PP -If -.B rpc.statd -does not find a peer on its monitor list that matches -an incoming SM_NOTIFY request, -the notification is not forwarded to the local lock manager. -In addition, each peer has its own -.IR "NSM state number" , -a 32-bit integer that is bumped after each reboot by the -.B sm-notify -command. -.B rpc.statd -uses this number to distinguish between actual reboots -and replayed notifications. -.PP -Part of NFS lock recovery is rediscovering -which peers need to be monitored again. -The -.B sm-notify -command clears the monitor list on persistent storage after each reboot. -.SH OPTIONS -.TP -.B -d -Keeps -.B sm-notify -attached to its controlling terminal and running in the foreground -so that notification progress may be monitored directly. -.TP -.B -f -Send notifications even if -.B sm-notify -has already run since the last system reboot. -.TP -.BI -m " retry-time -Specifies the length of time, in minutes, to continue retrying -notifications to unresponsive hosts. -If this option is not specified, -.B sm-notify -attempts to send notifications for 15 minutes. -Specifying a value of 0 causes -.B sm-notify -to continue sending notifications to unresponsive peers -until it is manually killed. -.IP -Notifications are retried if sending fails, -the remote does not respond, -the remote's NSM service is not registered, -or if there is a DNS failure -which prevents the remote's -.I mon_name -from being resolved to an address. -.IP -Hosts are not removed from the notification list until a valid -reply has been received. -However, the SM_NOTIFY procedure has a void result. -There is no way for -.B sm-notify -to tell if the remote recognized the sender and has started -appropriate lock recovery. -.TP -.B -n -Prevents -.B sm-notify -from updating the local system's NSM state number. -.TP -.BI -p " port -Specifies the source port number -.B sm-notify -should use when sending reboot notifications. -If this option is not specified, a randomly chosen ephemeral port is used. -.IP -This option can be used to traverse a firewall between client and server. -.TP -.BI "\-P, " "" \-\-state\-directory\-path " pathname -Specifies the pathname of the parent directory -where NSM state information resides. -If this option is not specified, -.B sm-notify -uses -.I /var/lib/nfs -by default. -.IP -After starting, -.B sm-notify -attempts to set its effective UID and GID to the owner -and group of the subdirectory -.B sm -of this directory. After changing the effective ids, -.B sm-notify -only needs to access files in -.B sm -and -.B sm.bak -within the state-directory-path. -.TP -.BI -v " ipaddr " | " hostname -Specifies the network address from which to send reboot notifications, -and the -.I mon_name -argument to use when sending SM_NOTIFY requests. -If this option is not specified, -.B sm-notify -uses a wildcard address as the transport bind address, -and uses the -.I my_name -recorded when the remote was monitored as the -.I mon_name -argument when sending SM_NOTIFY requests. -.IP -The -.I ipaddr -form can be expressed as either an IPv4 or an IPv6 presentation address. -If the -.I ipaddr -form is used, the -.B sm-notify -command converts this address to a hostname for use as the -.I mon_name -argument when sending SM_NOTIFY requests. -.IP -This option can be useful in multi-homed configurations where -the remote requires notification from a specific network address. -.SH CONFIGURATION FILE -Many of the options that can be set on the command line can also be -controlled through values set in the -.B [sm-notify] -or, in one case, the -.B [statd] -section of the -.I /etc/nfs.conf -configuration file. - -Values recognized in the -.B [sm-notify] -section include: -.BR retry-time , -.BR outgoing-port ", and" -.BR outgoing-addr . -These have the same effect as the command line options -.BR m , -.BR p ", and" -.B v -respectively. - -An additional value recognized in the -.B [sm-notify] -section is -.BR lift-grace . -By default, -.B sm-notify -will lift lockd's grace period early if it has no hosts to notify. -Some high availability configurations will run one -.B sm-notify -per floating IP address. In these configurations, lifting the -grace period early may prevent clients from reclaiming locks. -.RB "Setting " lift-grace " to " n -will prevent -.B sm-notify -from ending the grace period early. -.B lift-grace -has no corresponding command line option. - -The value recognized in the -.B [statd] -section is -.BR state-directory-path . - -.SH SECURITY -The -.B sm-notify -command must be started as root to acquire privileges needed -to access the state information database. -It drops root privileges -as soon as it starts up to reduce the risk of a privilege escalation attack. -.PP -During normal operation, -the effective user ID it chooses is the owner of the state directory. -This allows it to continue to access files in that directory after it -has dropped its root privileges. -To control which user ID -.B rpc.statd -chooses, simply use -.BR chown (1) -to set the owner of -the state directory. -.SH ADDITIONAL NOTES -Lock recovery after a reboot is critical to maintaining data integrity -and preventing unnecessary application hangs. -.PP -To help -.B rpc.statd -match SM_NOTIFY requests to NLM requests, a number of best practices -should be observed, including: -.IP -The UTS nodename of your systems should match the DNS names that NFS -peers use to contact them -.IP -The UTS nodenames of your systems should always be fully qualified domain names -.IP -The forward and reverse DNS mapping of the UTS nodenames should be -consistent -.IP -The hostname the client uses to mount the server should match the server's -.I mon_name -in SM_NOTIFY requests it sends -.PP -Unmounting an NFS file system does not necessarily stop -either the NFS client or server from monitoring each other. -Both may continue monitoring each other for a time in case subsequent -NFS traffic between the two results in fresh mounts and additional -file locking. -.PP -On Linux, if the -.B lockd -kernel module is unloaded during normal operation, -all remote NFS peers are unmonitored. -This can happen on an NFS client, for example, -if an automounter removes all NFS mount -points due to inactivity. -.SS IPv6 and TI-RPC support -TI-RPC is a pre-requisite for supporting NFS on IPv6. -If TI-RPC support is built into the -.B sm-notify -command ,it will choose an appropriate IPv4 or IPv6 transport -based on the network address returned by DNS for each remote peer. -It should be fully compatible with remote systems -that do not support TI-RPC or IPv6. -.PP -Currently, the -.B sm-notify -command supports sending notification only via datagram transport protocols. -.SH FILES -.TP 2.5i -.I /var/lib/nfs/sm -directory containing monitor list -.TP 2.5i -.I /var/lib/nfs/sm.bak -directory containing notify list -.TP 2.5i -.I /var/lib/nfs/state -NSM state number for this host -.TP 2.5i -.I /proc/sys/fs/nfs/nsm_local_state -kernel's copy of the NSM state number -.SH SEE ALSO -.BR rpc.statd (8), -.BR nfs (5), -.BR uname (2), -.BR hostname (7) -.PP -RFC 1094 - "NFS: Network File System Protocol Specification" -.br -RFC 1813 - "NFS Version 3 Protocol Specification" -.br -OpenGroup Protocols for Interworking: XNFS, Version 3W - Chapter 11 -.SH AUTHORS -Olaf Kirch -.br -Chuck Lever diff --git a/nfs-utils-2.5.2/utils/statd/start-statd b/nfs-utils-2.5.2/utils/statd/start-statd deleted file mode 100755 index 54ced82..0000000 --- a/nfs-utils-2.5.2/utils/statd/start-statd +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# nfsmount calls this script when mounting a filesystem with locking -# enabled, but when statd does not seem to be running (based on -# /var/run/rpc.statd.pid). -# It should run statd with whatever flags are apropriate for this -# site. -PATH="/sbin:/usr/sbin:/bin:/usr/bin" - -# Use flock to serialize the running of this script -exec 9> /var/run/rpc.statd.lock -flock -e 9 - -if [ -s /var/run/rpc.statd.pid ] && - [ 1`cat /var/run/rpc.statd.pid` -gt 1 ] && - kill -0 `cat /var/run/rpc.statd.pid` > /dev/null 2>&1 -then - # statd already running - must have been slow to respond. - exit 0 -fi -# First try systemd if it's installed. -if [ -d /run/systemd/system ]; then - # Quit only if the call worked. - if systemctl start rpc-statd.service; then - # Ensure systemd knows not to stop rpc.statd or its dependencies - # on 'systemctl isolate ..' - systemctl add-wants --runtime remote-fs.target rpc-statd.service - exit 0 - fi -fi - -cd / -# Fall back to launching it ourselves. -exec rpc.statd --no-notify diff --git a/nfs-utils-2.5.2/utils/statd/stat.c b/nfs-utils-2.5.2/utils/statd/stat.c deleted file mode 100644 index 8d8b65e..0000000 --- a/nfs-utils-2.5.2/utils/statd/stat.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 1995, 1997, 1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, 1996. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "statd.h" - -/* - * Services SM_STAT requests. - * - * According the the X/Open spec's on this procedure: "Implementations - * should not rely on this procedure being operative. In many current - * implementations of the NSM it will always return a 'STAT_FAIL' - * status." My implementation is operative; it returns 'STAT_SUCC' - * whenever it can resolve the hostname that it's being asked to - * monitor, and returns 'STAT_FAIL' otherwise. - * - * sm_inter.x says the 'state' returned should be - * "state number of site sm_name". It is not clear how to get this. - * X/Open says: - * STAT_SUCC - * The NSM will monitor the given host. "sm_stat_res.state" contains - * the state of the NSM. - * Which implies that 'state' is the state number of the *local* NSM. - * href=http://www.opengroup.org/onlinepubs/9629799/SM_STAT.htm - * - * We return the *local* state as - * 1/ We have easy access to it. - * 2/ It might be useful to a remote client who needs it and has no - * other way to get it. - * 3/ That's what we always did in the past. - */ -struct sm_stat_res * -sm_stat_1_svc(struct sm_name *argp, - __attribute__ ((unused)) struct svc_req *rqstp) -{ - static sm_stat_res result; - char *name; - - xlog(D_CALL, "Received SM_STAT from %s", argp->mon_name); - - name = statd_canonical_name(argp->mon_name); - if (name == NULL) { - result.res_stat = STAT_FAIL; - xlog (D_GENERAL, "STAT_FAIL for %s", argp->mon_name); - } else { - result.res_stat = STAT_SUCC; - xlog (D_GENERAL, "STAT_SUCC for %s", argp->mon_name); - free(name); - } - result.state = MY_STATE; - return(&result); -} diff --git a/nfs-utils-2.5.2/utils/statd/statd.c b/nfs-utils-2.5.2/utils/statd/statd.c deleted file mode 100644 index e4a1df4..0000000 --- a/nfs-utils-2.5.2/utils/statd/statd.c +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, Oct. 1996. - * Modified by H.J. Lu, 1998. - * Modified by L. Hohberger of Mission Critical Linux, 2000. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conffile.h" -#include "statd.h" -#include "nfslib.h" -#include "nfsrpc.h" -#include "nsm.h" - -/* Socket operations */ -#include -#include - -int run_mode = 0; /* foreground logging mode */ - -/* LH - I had these local to main, but it seemed silly to have - * two copies of each - one in main(), one static in log.c... - * It also eliminates the 256-char static in log.c */ -static char *name_p = NULL; - -/* PRC: a high-availability callout program can be specified with -H - * When this is done, the program will receive callouts whenever clients - * are added or deleted to the notify list */ -char *ha_callout_prog = NULL; - -static struct option longopts[] = -{ - { "foreground", 0, 0, 'F' }, - { "no-syslog", 0, 0, 'd' }, - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'v' }, - { "outgoing-port", 1, 0, 'o' }, - { "port", 1, 0, 'p' }, - { "name", 1, 0, 'n' }, - { "state-directory-path", 1, 0, 'P' }, - { "notify-mode", 0, 0, 'N' }, - { "ha-callout", 1, 0, 'H' }, - { "no-notify", 0, 0, 'L' }, - { "nlm-port", 1, 0, 'T'}, - { "nlm-udp-port", 1, 0, 'U'}, - { NULL, 0, 0, 0 } -}; - -extern void sm_prog_1 (struct svc_req *, register SVCXPRT *); -stat_chge SM_stat_chge; - -#ifdef SIMULATIONS -extern void simulator (int, char **); -#endif - - -#ifdef HAVE_TCP_WRAPPER -#include "tcpwrapper.h" - -static void -sm_prog_1_wrapper (struct svc_req *rqstp, register SVCXPRT *transp) -{ - /* remote host authorization check */ - if (!check_default("statd", nfs_getrpccaller(transp), SM_PROG)) { - svcerr_auth (transp, AUTH_FAILED); - return; - } - - sm_prog_1 (rqstp, transp); -} - -#define sm_prog_1 sm_prog_1_wrapper -#endif - -static void -statd_unregister(void) { - nfs_svc_unregister(SM_PROG, SM_VERS); -} - -/* - * Signal handler. - */ -static void -killer (int sig) -{ - statd_unregister (); - xlog(D_GENERAL, "Caught signal %d, un-registering and exiting", sig); - exit(0); -} - -static void -sigusr (int sig) -{ - extern void my_svc_exit (void); - xlog(D_GENERAL, "Caught signal %d, re-notifying (state %d)", sig, - MY_STATE); - my_svc_exit(); -} - -/* - * Startup information. - */ -static void log_modes(void) -{ - char buf[128]; /* watch stack size... */ - - /* No flags = no message */ - if (!run_mode) return; - - memset(buf,0,128); - sprintf(buf,"Flags: "); - if (run_mode & MODE_NODAEMON) - strcat(buf,"No-Daemon "); - if (run_mode & MODE_LOG_STDERR) - strcat(buf,"Log-STDERR "); -#ifdef HAVE_LIBTIRPC - strcat(buf, "TI-RPC "); -#endif - - xlog_warn("%s", buf); -} - -/* - * Since we do more than standard statd stuff, we might need to - * help the occasional admin. - */ -static void -usage(void) -{ - fprintf(stderr,"usage: %s [options]\n", name_p); - fprintf(stderr," -h, -?, --help Print this help screen.\n"); - fprintf(stderr," -F, --foreground Foreground (no-daemon mode)\n"); - fprintf(stderr," -d, --no-syslog Verbose logging to stderr. Foreground mode only.\n"); - fprintf(stderr," -p, --port Port to listen on\n"); - fprintf(stderr," -o, --outgoing-port Port for outgoing connections\n"); - fprintf(stderr," -V, -v, --version Display version information and exit.\n"); - fprintf(stderr," -n, --name Specify a local hostname.\n"); - fprintf(stderr," -P State directory path.\n"); - fprintf(stderr," -N Run in notify only mode.\n"); - fprintf(stderr," -L, --no-notify Do not perform any notification.\n"); - fprintf(stderr," -H Specify a high-availability callout program.\n"); -} - -static const char *pidfile = "/var/run/rpc.statd.pid"; - -int pidfd = -1; -static void create_pidfile(void) -{ - FILE *fp; - - unlink(pidfile); - fp = fopen(pidfile, "w"); - if (!fp) - xlog_err("Opening %s failed: %m\n", pidfile); - fprintf(fp, "%d\n", getpid()); - pidfd = dup(fileno(fp)); - if (fclose(fp) < 0) { - xlog_warn("Flushing pid file failed: errno %d (%m)\n", - errno); - } -} - -static void truncate_pidfile(void) -{ - if (pidfd >= 0) { - if (ftruncate(pidfd, 0) < 0) { - xlog_warn("truncating pid file failed: errno %d (%m)\n", - errno); - } - } -} - -static void run_sm_notify(int outport) -{ - char op[20]; - char *av[6]; - int ac = 0; - - av[ac++] = "/usr/sbin/sm-notify"; - if (run_mode & MODE_NODAEMON) - av[ac++] = "-d"; - if (outport) { - sprintf(op, "-p%d", outport); - av[ac++] = op; - } - if (run_mode & STATIC_HOSTNAME) { - av[ac++] = "-v"; - av[ac++] = MY_NAME; - } - av[ac] = NULL; - execv(av[0], av); - fprintf(stderr, "%s: failed to run %s\n", name_p, av[0]); - exit(2); - -} - -static void set_nlm_port(char *type, int port) -{ - char nbuf[20]; - char pathbuf[40]; - int fd; - if (!port) - return; - snprintf(nbuf, sizeof(nbuf), "%d", port); - snprintf(pathbuf, sizeof(pathbuf), "/proc/sys/fs/nfs/nlm_%sport", type); - fd = open(pathbuf, O_WRONLY); - if (fd < 0 && errno == ENOENT) { - /* probably module not loaded */ - if (system("modprobe lockd")) - {/* ignore return value */}; - fd = open(pathbuf, O_WRONLY); - } - if (fd >= 0) { - if (write(fd, nbuf, strlen(nbuf)) != (ssize_t)strlen(nbuf)) - fprintf(stderr, "%s: fail to set NLM %s port: %s\n", - name_p, type, strerror(errno)); - close(fd); - } else - fprintf(stderr, "%s: failed to open %s: %s\n", - name_p, pathbuf, strerror(errno)); -} -int port = 0, out_port = 0; -int nlm_udp = 0, nlm_tcp = 0; - -inline static void -read_nfsconf(char **argv) -{ - char *s; - - conf_init_file(NFS_CONFFILE); - xlog_from_conffile("statd"); - - out_port = conf_get_num("statd", "outgoing-port", out_port); - port = conf_get_num("statd", "port", port); - - MY_NAME = conf_get_str("statd", "name"); - if (MY_NAME) - run_mode |= STATIC_HOSTNAME; - - s = conf_get_str("statd", "state-directory-path"); - if (s && !nsm_setup_pathnames(argv[0], s)) - exit(1); - - s = conf_get_str("statd", "ha-callout"); - if (s) - ha_callout_prog = s; - - nlm_tcp = conf_get_num("lockd", "port", nlm_tcp); - /* udp defaults to the same as tcp ! */ - nlm_udp = conf_get_num("lockd", "udp-port", nlm_tcp); - - if (conf_get_bool("statd", "no-notify", false)) - run_mode |= MODE_NO_NOTIFY; -} - -/* - * Entry routine/main loop. - */ -int main (int argc, char **argv) -{ - extern char *optarg; - int pid; - int arg; - struct rlimit rlim; - int notify_sockfd; - char *env; - - /* Default: daemon mode, no other options */ - run_mode = 0; - - env = getenv("RPC_STATD_NO_NOTIFY"); - if (env && atoi(env) > 0) - run_mode |= MODE_NO_NOTIFY; - - /* Log to stderr if there's an error during startup */ - xlog_stderr(1); - xlog_syslog(0); - - /* Set the basename */ - if ((name_p = strrchr(argv[0],'/')) != NULL) { - name_p ++; - } else { - name_p = argv[0]; - } - - /* Set hostname */ - MY_NAME = NULL; - - /* Read nfs.conf */ - read_nfsconf(argv); - - /* Process command line switches */ - while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:LT:U:", longopts, NULL)) != EOF) { - switch (arg) { - case 'V': /* Version */ - case 'v': - printf("%s version " VERSION "\n",name_p); - exit(0); - case 'F': /* Foreground/nodaemon mode */ - run_mode |= MODE_NODAEMON; - break; - case 'N': - run_mode |= MODE_NOTIFY_ONLY; - break; - case 'L': /* Listen only */ - run_mode |= MODE_NO_NOTIFY; - break; - case 'd': /* No daemon only - log to stderr */ - run_mode |= MODE_LOG_STDERR; - break; - case 'o': - out_port = atoi(optarg); - if (out_port < 1 || out_port > 65535) { - fprintf(stderr, "%s: bad port number: %s\n", - argv[0], optarg); - usage(); - exit(1); - } - break; - case 'p': - port = atoi(optarg); - if (port < 1 || port > 65535) { - fprintf(stderr, "%s: bad port number: %s\n", - argv[0], optarg); - usage(); - exit(1); - } - break; - case 'T': /* NLM TCP and UDP port */ - nlm_tcp = atoi(optarg); - if (nlm_tcp < 1 || nlm_tcp > 65535) { - fprintf(stderr, "%s: bad nlm port number: %s\n", - argv[0], optarg); - usage(); - exit(1); - } - if (nlm_udp == 0) - nlm_udp = nlm_tcp; - break; - case 'U': /* NLM UDP port */ - nlm_udp = atoi(optarg); - if (nlm_udp < 1 || nlm_udp > 65535) { - fprintf(stderr, "%s: bad nlm UDP port number: %s\n", - argv[0], optarg); - usage(); - exit(1); - } - break; - case 'n': /* Specify local hostname */ - run_mode |= STATIC_HOSTNAME; - MY_NAME = xstrdup(optarg); - break; - case 'P': - if (!nsm_setup_pathnames(argv[0], optarg)) - exit(1); - break; - case 'H': /* PRC: specify the ha-callout program */ - if ((ha_callout_prog = xstrdup(optarg)) == NULL) - exit(1); - break; - case '?': /* heeeeeelllllllpppp? heh */ - case 'h': - usage(); - exit (0); - default: /* oh dear ... heh */ - usage(); - exit(-1); - } - } - - /* Refuse to start if another statd is running */ - if (nfs_probe_statd()) { - fprintf(stderr, "Statd service already running!\n"); - exit(1); - } - - if (port == out_port && port != 0) { - fprintf(stderr, "Listening and outgoing ports cannot be the same!\n"); - exit(-1); - } - - if (run_mode & MODE_NOTIFY_ONLY) { - fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n", - name_p); - run_sm_notify(out_port); - } - - if (!(run_mode & MODE_NODAEMON)) { - run_mode &= ~MODE_LOG_STDERR; /* Never log to console in - daemon mode. */ - } - - if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) - fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n", - argv [0], strerror(errno)); - else { - /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */ - if (rlim.rlim_cur > FD_SETSIZE) { - rlim.rlim_cur = FD_SETSIZE; - - if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) { - fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n", - argv [0], strerror(errno)); - } - } - } - - set_nlm_port("tcp", nlm_tcp); - set_nlm_port("udp", nlm_udp); - -#ifdef SIMULATIONS - if (argc > 1) - /* LH - I _really_ need to update simulator... */ - simulator (--argc, ++argv); /* simulator() does exit() */ -#endif - - daemon_init((run_mode & MODE_NODAEMON)); - - if (run_mode & MODE_LOG_STDERR) { - xlog_syslog(0); - xlog_stderr(1); - xlog_config(D_ALL, 1); - } else { - xlog_syslog(1); - xlog_stderr(0); - } - - xlog_open(name_p); - xlog(L_NOTICE, "Version " VERSION " starting"); - - log_modes(); - - signal (SIGHUP, killer); - signal (SIGINT, killer); - signal (SIGTERM, killer); - /* PRC: trap SIGUSR1 to re-read notify list from disk */ - signal(SIGUSR1, sigusr); - /* WARNING: the following works on Linux and SysV, but not BSD! */ - signal(SIGCHLD, SIG_IGN); - /* - * Ignore SIGPIPE to avoid statd dying when peers close their - * TCP connection while we're trying to reply to them. - */ - signal(SIGPIPE, SIG_IGN); - - create_pidfile(); - atexit(truncate_pidfile); - - if (! (run_mode & MODE_NO_NOTIFY)) - switch (pid = fork()) { - case 0: - run_sm_notify(out_port); - break; - case -1: - break; - default: - waitpid(pid, NULL, 0); - } - - /* Make sure we have a privilege port for calling into the kernel */ - if ((notify_sockfd = statd_get_socket()) < 0) - exit(1); - - /* If sm-notify didn't take all the state files, load - * state information into our notify-list so we can - * pass on any SM_NOTIFY that arrives - */ - load_state(); - - MY_STATE = nsm_get_state(0); - if (MY_STATE == 0) - exit(1); - xlog(D_GENERAL, "Local NSM state number: %d", MY_STATE); - nsm_update_kernel_state(MY_STATE); - - /* - * ORDER - * Clear old listeners while still root, to override any - * permission checking done by rpcbind. - */ - statd_unregister(); - - /* - * ORDER - */ - if (!nsm_drop_privileges(pidfd)) - exit(1); - - /* - * ORDER - * Create RPC listeners after dropping privileges. This permits - * statd to unregister its own listeners when it exits. - */ - if (nfs_svc_create("statd", SM_PROG, SM_VERS, sm_prog_1, port) == 0) { - xlog(L_ERROR, "failed to create RPC listeners, exiting"); - exit(1); - } - atexit(statd_unregister); - - /* If we got this far, we have successfully started */ - daemon_ready(); - - for (;;) { - /* - * Handle incoming requests: SM_NOTIFY socket requests, as - * well as callbacks from lockd. - */ - my_svc_run(notify_sockfd); /* I rolled my own, Olaf made it better... */ - - /* Only get here when simulating a crash so we should probably - * start sm-notify running again. As we have already dropped - * privileges, this might not work, but I don't think - * responding to SM_SIMU_CRASH is an important use cases to - * get perfect. - */ - if (! (run_mode & MODE_NO_NOTIFY)) - switch (pid = fork()) { - case 0: - run_sm_notify(out_port); - break; - case -1: - break; - default: - waitpid(pid, NULL, 0); - } - - } - return 0; -} diff --git a/nfs-utils-2.5.2/utils/statd/statd.h b/nfs-utils-2.5.2/utils/statd/statd.h deleted file mode 100644 index bb1fecb..0000000 --- a/nfs-utils-2.5.2/utils/statd/statd.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff - * Modified by Olaf Kirch, Dec. 1996. - * - * NSM for Linux. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "sm_inter.h" -#include "system.h" -#include "xlog.h" - -/* - * Status definitions. - */ -#define STAT_FAIL stat_fail -#define STAT_SUCC stat_succ - -/* - * Function prototypes. - */ -extern _Bool statd_matchhostname(const char *hostname1, const char *hostname2); -extern _Bool statd_present_address(const struct sockaddr *sap, char *buf, - const size_t buflen); -__attribute__((__malloc__)) -extern char * statd_canonical_name(const char *hostname); - -extern void my_svc_run(int); -extern void notify_hosts(void); -extern void shuffle_dirs(void); -extern int statd_get_socket(void); -extern int process_notify_list(void); -extern int process_reply(FD_SET_TYPE *); -extern char * xstrdup(const char *); -extern void * xmalloc(size_t); -extern void load_state(void); - -/* - * Host status structure and macros. - */ -extern stat_chge SM_stat_chge; -#define MY_NAME SM_stat_chge.mon_name -#define MY_STATE SM_stat_chge.state - -/* - * Some timeout values. (Timeout values are in whole seconds.) - */ -#define CALLBACK_TIMEOUT 3 /* For client call-backs. */ -#define NOTIFY_TIMEOUT 5 /* For status-change notifications. */ -#define SELECT_TIMEOUT 10 /* Max select() timeout when work to do. */ -#define MAX_TRIES 5 /* Max number of tries for any host. */ - -/* - * Modes of operation - Lon - */ -extern int run_mode; -#define MODE_NODAEMON 1 /* No-daemon/foreground mode. */ -#define MODE_LOG_STDERR 2 /* in foreground mode, log to stderr */ -#define MODE_NOTIFY_ONLY 4 /* Send SM_NOTIFY to everyone monitored on - a single interface/alias */ -/* LH - notify_only mode would be for notifying hosts on an IP alias - * that just came back up, for ex, when failing over a HA service to - * another host.... */ -#define STATIC_HOSTNAME 8 /* Always use the hostname set by -n */ -#define MODE_NO_NOTIFY 16 /* Don't notify peers of a reboot */ diff --git a/nfs-utils-2.5.2/utils/statd/statd.man b/nfs-utils-2.5.2/utils/statd/statd.man deleted file mode 100644 index ecd3e88..0000000 --- a/nfs-utils-2.5.2/utils/statd/statd.man +++ /dev/null @@ -1,474 +0,0 @@ -.\"@(#)rpc.statd.8" -.\" -.\" Copyright (C) 1999 Olaf Kirch -.\" Modified by Jeffrey A. Uphoff, 1999, 2002, 2005. -.\" Modified by Lon Hohberger, 2000. -.\" Modified by Paul Clements, 2004. -.\" -.\" Rewritten by Chuck Lever , 2009. -.\" Copyright 2009 Oracle. All rights reserved. -.\" -.TH RPC.STATD 8 "1 November 2009" -.SH NAME -rpc.statd \- NSM service daemon -.SH SYNOPSIS -.BI "rpc.statd [-dh?FLNvV] [-H " prog "] [-n " my-name "] [-o " outgoing-port ] -.ti +10 -.BI "[-p " listener-port "] [-P " path ] -.ti +10 -.BI "[--nlm-port " port "] [--nlm-udp-port " port ] -.SH DESCRIPTION -File locks are not part of persistent file system state. -Lock state is thus lost when a host reboots. -.PP -Network file systems must also detect when lock state is lost -because a remote host has rebooted. -After an NFS client reboots, an NFS server must release all file locks -held by applications that were running on that client. -After a server reboots, a client must remind the -server of file locks held by applications running on that client. -.PP -For NFS version 2 [RFC1094] and NFS version 3 [RFC1813], the -.I Network Status Monitor -protocol (or NSM for short) -is used to notify NFS peers of reboots. -On Linux, two separate user-space components constitute the NSM service: -.TP -.B rpc.statd -A daemon that listens for reboot notifications from other hosts, and -manages the list of hosts to be notified when the local system reboots -.TP -.B sm-notify -A helper program that notifies NFS peers after the local system reboots -.PP -The local NFS lock manager alerts its local -.B rpc.statd -of each remote peer that should be monitored. -When the local system reboots, the -.B sm-notify -command notifies the NSM service on monitored peers of the reboot. -When a remote reboots, that peer notifies the local -.BR rpc.statd , -which in turn passes the reboot notification -back to the local NFS lock manager. -.SH NSM OPERATION IN DETAIL -The first file locking interaction between an NFS client and server causes -the NFS lock managers on both peers to contact their local NSM service to -store information about the opposite peer. -On Linux, the local lock manager contacts -.BR rpc.statd . -.PP -.B rpc.statd -records information about each monitored NFS peer on persistent storage. -This information describes how to contact a remote peer -in case the local system reboots, -how to recognize which monitored peer is reporting a reboot, -and how to notify the local lock manager when a monitored peer -indicates it has rebooted. -.PP -An NFS client sends a hostname, known as the client's -.IR caller_name , -in each file lock request. -An NFS server can use this hostname to send asynchronous GRANT -calls to a client, or to notify the client it has rebooted. -.PP -The Linux NFS server can provide the client's -.I caller_name -or the client's network address to -.BR rpc.statd . -For the purposes of the NSM protocol, -this name or address is known as the monitored peer's -.IR mon_name . -In addition, the local lock manager tells -.B rpc.statd -what it thinks its own hostname is. -For the purposes of the NSM protocol, -this hostname is known as -.IR my_name . -.PP -There is no equivalent interaction between an NFS server and a client -to inform the client of the server's -.IR caller_name . -Therefore NFS clients do not actually know what -.I mon_name -an NFS server might use in an SM_NOTIFY request. -The Linux NFS client uses the server hostname from the mount command -to identify rebooting NFS servers. -.SS Reboot notification -When the local system reboots, the -.B sm-notify -command reads the list of monitored peers from persistent storage and -sends an SM_NOTIFY request to the NSM service on each listed remote peer. -It uses the -.I mon_name -string as the destination. -To identify which host has rebooted, the -.B sm-notify -command sends the -.I my_name -string recorded when that remote was monitored. -The remote -.B rpc.statd -matches incoming SM_NOTIFY requests using this string, -or the caller's network address, -to one or more peers on its own monitor list. -.PP -If -.B rpc.statd -does not find a peer on its monitor list that matches -an incoming SM_NOTIFY request, -the notification is not forwarded to the local lock manager. -In addition, each peer has its own -.IR "NSM state number" , -a 32-bit integer that is bumped after each reboot by the -.B sm-notify -command. -.B rpc.statd -uses this number to distinguish between actual reboots -and replayed notifications. -.PP -Part of NFS lock recovery is rediscovering -which peers need to be monitored again. -The -.B sm-notify -command clears the monitor list on persistent storage after each reboot. -.SH OPTIONS -.TP -.BR -d , " --no-syslog -Causes -.B rpc.statd -to write log messages on -.I stderr -instead of to the system log, -if the -.B -F -option was also specified. -.TP -.BR -F , " --foreground -Keeps -.B rpc.statd -attached to its controlling terminal so that NSM -operation can be monitored directly or run under a debugger. -If this option is not specified, -.B rpc.statd -backgrounds itself soon after it starts. -.TP -.BR -h , " -?" , " --help -Causes -.B rpc.statd -to display usage information on -.I stderr -and then exit. -.TP -.BI "\-H," "" " \-\-ha-callout " prog -Specifies a high availability callout program. -If this option is not specified, no callouts are performed. -See the -.B High-availability callouts -section below for details. -.TP -.BR -L , " --no-notify -Prevents -.B rpc.statd -from running the -.B sm-notify -command when it starts up, -preserving the existing NSM state number and monitor list. -.IP -Note: the -.B sm-notify -command contains a check to ensure it runs only once after each system reboot. -This prevents spurious reboot notification if -.B rpc.statd -restarts without the -.B -L -option. -.TP -.BI "\-n, " "" "\-\-name " ipaddr " | " hostname -This string is only used by the -.B sm-notify -command as the source address from which to send reboot notification requests. -.IP -The -.I ipaddr -form can be expressed as either an IPv4 or an IPv6 presentation address. -If this option is not specified, -.B rpc.statd -uses a wildcard address as the transport bind address. -See -.BR sm-notify (8) -for details. -.TP -.BR -N -Causes -.B rpc.statd -to run the -.B sm-notify -command, and then exit. -Since the -.B sm-notify -command can also be run directly, this option is deprecated. -.TP -.BI "\-o," "" " \-\-outgoing\-port " port -Specifies the source port number the -.B sm-notify -command should use when sending reboot notifications. -See -.BR sm-notify (8) -for details. -.TP -.BI "\-p," "" " \-\-port " port -Specifies the port number used for RPC listener sockets. -If this option is not specified, -.B rpc.statd -will try to consult -.IR /etc/services , -if gets port succeed, set the same port for all listener socket, -otherwise chooses a random ephemeral port for each listener socket. -.IP -This option can be used to fix the port value of its listeners when -SM_NOTIFY requests must traverse a firewall between clients and -servers. -.TP -.BI "\-T," "" " \-\-nlm\-port " port -Specifies the port number that -.I lockd -should listen on for -.B NLM -requests. This sets both the TCP and UDP ports unless the UDP port is -set separately. -.TP -.BI "\-U," "" " \-\-nlm\-udp\-port " port -Specifies the UDP port number that -.I lockd -should listen on for -.B NLM -requests. -.TP -.BI "\-P, " "" \-\-state\-directory\-path " pathname" -Specifies the pathname of the parent directory -where NSM state information resides. -If this option is not specified, -.B rpc.statd -uses -.I /var/lib/nfs -by default. -.IP -After starting, -.B rpc.statd -attempts to set its effective UID and GID to the owner -and group of the subdirectory -.B sm -of this directory. After changing the effective ids, -.B rpc.statd -only needs to access files in -.B sm -and -.B sm.bak -within the state-directory-path. -.TP -.BR -v ", " -V ", " --version -Causes -.B rpc.statd -to display version information on -.I stderr -and then exit. -.SH CONFIGURATION FILE -Many of the options that can be set on the command line can also be -controlled through values set in the -.B [statd] -or, in some cases, the -.B [lockd] -sections of the -.I /etc/nfs.conf -configuration file. -Values recognized in the -.B [statd] -section include -.BR port , -.BR outgoing-port , -.BR name , -.BR state-directory-path ", and" -.B ha-callout -which each have the same effect as the option with the same name. - -The values recognized in the -.B [lockd] -section include -.B port -and -.B udp-port -which have the same effect as the -.B --nlm-port -and -.B --nlm-udp-port -options, respectively. - -.SH SECURITY -The -.B rpc.statd -daemon must be started as root to acquire privileges needed -to create sockets with privileged source ports, and to access the -state information database. -Because -.B rpc.statd -maintains a long-running network service, however, it drops root privileges -as soon as it starts up to reduce the risk of a privilege escalation attack. -.PP -During normal operation, -the effective user ID it chooses is the owner of the state directory. -This allows it to continue to access files in that directory after it -has dropped its root privileges. -To control which user ID -.B rpc.statd -chooses, simply use -.BR chown (1) -to set the owner of -the state directory. -.PP -You can also protect your -.B rpc.statd -listeners using the -.B tcp_wrapper -library or -.BR iptables (8). -To use the -.B tcp_wrapper -library, add the hostnames of peers that should be allowed access to -.IR /etc/hosts.allow . -Use the daemon name -.B statd -even if the -.B rpc.statd -binary has a different filename. -.P -For further information see the -.BR tcpd (8) -and -.BR hosts_access (5) -man pages. -.SH ADDITIONAL NOTES -Lock recovery after a reboot is critical to maintaining data integrity -and preventing unnecessary application hangs. -To help -.B rpc.statd -match SM_NOTIFY requests to NLM requests, a number of best practices -should be observed, including: -.IP -The UTS nodename of your systems should match the DNS names that NFS -peers use to contact them -.IP -The UTS nodenames of your systems should always be fully qualified domain names -.IP -The forward and reverse DNS mapping of the UTS nodenames should be -consistent -.IP -The hostname the client uses to mount the server should match the server's -.I mon_name -in SM_NOTIFY requests it sends -.PP -Unmounting an NFS file system does not necessarily stop -either the NFS client or server from monitoring each other. -Both may continue monitoring each other for a time in case subsequent -NFS traffic between the two results in fresh mounts and additional -file locking. -.PP -On Linux, if the -.B lockd -kernel module is unloaded during normal operation, -all remote NFS peers are unmonitored. -This can happen on an NFS client, for example, -if an automounter removes all NFS mount -points due to inactivity. -.SS High-availability callouts -.B rpc.statd -can exec a special callout program during processing of -successful SM_MON, SM_UNMON, and SM_UNMON_ALL requests, -or when it receives SM_NOTIFY. -Such a program may be used in High Availability NFS (HA-NFS) -environments to track lock state that may need to be migrated after -a system reboot. -.PP -The name of the callout program is specified with the -.B -H -option. -The program is run with 3 arguments: -The first is either -.B add-client -.B del-client -or -.B sm-notify -depending on the reason for the callout. -The second is the -.I mon_name -of the monitored peer. -The third is the -.I caller_name -of the requesting lock manager for -.B add-client -or -.B del-client -, otherwise it is -.I IP_address -of the caller sending SM_NOTIFY. -The forth is the -.I state_value -in the SM_NOTIFY request. - -.SS IPv6 and TI-RPC support -TI-RPC is a pre-requisite for supporting NFS on IPv6. -If TI-RPC support is built into -.BR rpc.statd , -it attempts to start listeners on network transports marked 'visible' in -.IR /etc/netconfig . -As long as at least one network transport listener starts successfully, -.B rpc.statd -will operate. -.SH ENVIRONMENT -.TP -.B RPC_STATD_NO_NOTIFY= -If set to a positive integer, has the same effect as -.IR \-\-no\-notify . -.SH FILES -.TP 2.5i -.I /var/lib/nfs/sm -directory containing monitor list -.TP 2.5i -.I /var/lib/nfs/sm.bak -directory containing notify list -.TP 2.5i -.I /var/lib/nfs/state -NSM state number for this host -.TP 2.5i -.I /var/run/run.statd.pid -pid file -.TP 2.5i -.I /etc/netconfig -network transport capability database -.SH SEE ALSO -.BR sm-notify (8), -.BR nfs (5), -.BR rpc.nfsd (8), -.BR rpcbind (8), -.BR tcpd (8), -.BR hosts_access (5), -.BR iptables (8), -.BR netconfig (5) -.sp -RFC 1094 - "NFS: Network File System Protocol Specification" -.br -RFC 1813 - "NFS Version 3 Protocol Specification" -.br -OpenGroup Protocols for Interworking: XNFS, Version 3W - Chapter 11 -.SH AUTHORS -Jeff Uphoff -.br -Olaf Kirch -.br -H.J. Lu -.br -Lon Hohberger -.br -Paul Clements -.br -Chuck Lever diff --git a/nfs-utils-2.5.2/utils/statd/svc_run.c b/nfs-utils-2.5.2/utils/statd/svc_run.c deleted file mode 100644 index e343c76..0000000 --- a/nfs-utils-2.5.2/utils/statd/svc_run.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 1984 Sun Microsystems, Inc. - * Modified by Jeffrey A. Uphoff, 1995, 1997-1999. - * Modified by Olaf Kirch, 1996. - * - * NSM for Linux. - */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This has been modified for my own evil purposes to prevent deadlocks - * when two hosts start NSM's simultaneously and try to notify each - * other (which mainly occurs during testing), or to stop and smell the - * roses when I have callbacks due. - * --Jeff Uphoff. - */ - -/* - * This is the RPC server side idle loop. - * Wait for input, call server program. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include "statd.h" -#include "notlist.h" - -void my_svc_exit(void); -static int svc_stop = 0; - -/* - * This is the global notify list onto which all SM_NOTIFY and CALLBACK - * requests are put. - */ -notify_list * notify = NULL; - -/* - * Jump-off function. - */ -void -my_svc_exit(void) -{ - svc_stop = 1; -} - - -/* - * The heart of the server. A crib from libc for the most part... - */ -void -my_svc_run(int sockfd) -{ - FD_SET_TYPE readfds; - int selret; - time_t now; - - svc_stop = 0; - - for (;;) { - if (svc_stop) - return; - - /* Ah, there are some notifications to be processed */ - while (notify && NL_WHEN(notify) <= time(&now)) { - process_notify_list(); - } - - readfds = SVC_FDSET; - /* Set notify sockfd for waiting for reply */ - FD_SET(sockfd, &readfds); - if (notify) { - struct timeval tv; - - tv.tv_sec = NL_WHEN(notify) - now; - tv.tv_usec = 0; - xlog(D_GENERAL, "Waiting for reply... (timeo %jd)", - (intmax_t)tv.tv_sec); - selret = select(FD_SETSIZE, &readfds, - (void *) 0, (void *) 0, &tv); - } else { - xlog(D_GENERAL, "Waiting for client connections"); - selret = select(FD_SETSIZE, &readfds, - (void *) 0, (void *) 0, (struct timeval *) 0); - } - - switch (selret) { - case -1: - if (errno == EINTR || errno == ECONNREFUSED - || errno == ENETUNREACH || errno == EHOSTUNREACH) - continue; - xlog(L_ERROR, "my_svc_run() - select: %m"); - return; - - case 0: - /* A notify/callback timed out. */ - continue; - - default: - selret -= process_reply(&readfds); - if (selret) { - FD_CLR(sockfd, &readfds); - svc_getreqset(&readfds); - } - } - } -} diff --git a/nfs-utils-2.5.2/utils/statd/system.h b/nfs-utils-2.5.2/utils/statd/system.h deleted file mode 100644 index a1739c4..0000000 --- a/nfs-utils-2.5.2/utils/statd/system.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 1996 Olaf Kirch - * Modified by Jeffrey A. Uphoff, 1997, 1999. - * - * NSM for Linux. - */ - -/* - * System-dependent declarations - */ - -#ifdef FD_SETSIZE -# define FD_SET_TYPE fd_set -# define SVC_FDSET svc_fdset -#else -# define FD_SET_TYPE int -# define SVC_FDSET svc_fds -#endif diff --git a/rpcsvc-proto-1.4.2/ABOUT-NLS b/rpcsvc-proto-1.4.2/ABOUT-NLS deleted file mode 100644 index 3cc8286..0000000 --- a/rpcsvc-proto-1.4.2/ABOUT-NLS +++ /dev/null @@ -1,1379 +0,0 @@ -1 Notes on the Free Translation Project -*************************************** - -Free software is going international! The Free Translation Project is a -way to get maintainers of free software, translators, and users all -together, so that free software will gradually become able to speak many -languages. A few packages already provide translations for their -messages. - - If you found this 'ABOUT-NLS' file inside a distribution, you may -assume that the distributed package does use GNU 'gettext' internally, -itself available at your nearest GNU archive site. But you do _not_ -need to install GNU 'gettext' prior to configuring, installing or using -this package with messages translated. - - Installers will find here some useful hints. These notes also -explain how users should proceed for getting the programs to use the -available translations. They tell how people wanting to contribute and -work on translations can contact the appropriate team. - -1.1 INSTALL Matters -=================== - -Some packages are "localizable" when properly installed; the programs -they contain can be made to speak your own native language. Most such -packages use GNU 'gettext'. Other packages have their own ways to -internationalization, predating GNU 'gettext'. - - By default, this package will be installed to allow translation of -messages. It will automatically detect whether the system already -provides the GNU 'gettext' functions. Installers may use special -options at configuration time for changing the default behaviour. The -command: - - ./configure --disable-nls - -will _totally_ disable translation of messages. - - When you already have GNU 'gettext' installed on your system and run -configure without an option for your new package, 'configure' will -probably detect the previously built and installed 'libintl' library and -will decide to use it. If not, you may have to to use the -'--with-libintl-prefix' option to tell 'configure' where to look for it. - - Internationalized packages usually have many 'po/LL.po' files, where -LL gives an ISO 639 two-letter code identifying the language. Unless -translations have been forbidden at 'configure' time by using the -'--disable-nls' switch, all available translations are installed -together with the package. However, the environment variable 'LINGUAS' -may be set, prior to configuration, to limit the installed set. -'LINGUAS' should then contain a space separated list of two-letter -codes, stating which languages are allowed. - -1.2 Using This Package -====================== - -As a user, if your language has been installed for this package, you -only have to set the 'LANG' environment variable to the appropriate -'LL_CC' combination. If you happen to have the 'LC_ALL' or some other -'LC_xxx' environment variables set, you should unset them before setting -'LANG', otherwise the setting of 'LANG' will not have the desired -effect. Here 'LL' is an ISO 639 two-letter language code, and 'CC' is -an ISO 3166 two-letter country code. For example, let's suppose that -you speak German and live in Germany. At the shell prompt, merely -execute 'setenv LANG de_DE' (in 'csh'), 'export LANG; LANG=de_DE' (in -'sh') or 'export LANG=de_DE' (in 'bash'). This can be done from your -'.login' or '.profile' file, once and for all. - - You might think that the country code specification is redundant. -But in fact, some languages have dialects in different countries. For -example, 'de_AT' is used for Austria, and 'pt_BR' for Brazil. The -country code serves to distinguish the dialects. - - The locale naming convention of 'LL_CC', with 'LL' denoting the -language and 'CC' denoting the country, is the one use on systems based -on GNU libc. On other systems, some variations of this scheme are used, -such as 'LL' or 'LL_CC.ENCODING'. You can get the list of locales -supported by your system for your language by running the command -'locale -a | grep '^LL''. - - Not all programs have translations for all languages. By default, an -English message is shown in place of a nonexistent translation. If you -understand other languages, you can set up a priority list of languages. -This is done through a different environment variable, called -'LANGUAGE'. GNU 'gettext' gives preference to 'LANGUAGE' over 'LANG' -for the purpose of message handling, but you still need to have 'LANG' -set to the primary language; this is required by other parts of the -system libraries. For example, some Swedish users who would rather read -translations in German than English for when Swedish is not available, -set 'LANGUAGE' to 'sv:de' while leaving 'LANG' to 'sv_SE'. - - Special advice for Norwegian users: The language code for Norwegian -bokma*l changed from 'no' to 'nb' recently (in 2003). During the -transition period, while some message catalogs for this language are -installed under 'nb' and some older ones under 'no', it's recommended -for Norwegian users to set 'LANGUAGE' to 'nb:no' so that both newer and -older translations are used. - - In the 'LANGUAGE' environment variable, but not in the 'LANG' -environment variable, 'LL_CC' combinations can be abbreviated as 'LL' to -denote the language's main dialect. For example, 'de' is equivalent to -'de_DE' (German as spoken in Germany), and 'pt' to 'pt_PT' (Portuguese -as spoken in Portugal) in this context. - -1.3 Translating Teams -===================== - -For the Free Translation Project to be a success, we need interested -people who like their own language and write it well, and who are also -able to synergize with other translators speaking the same language. -Each translation team has its own mailing list. The up-to-date list of -teams can be found at the Free Translation Project's homepage, -'http://translationproject.org/', in the "Teams" area. - - If you'd like to volunteer to _work_ at translating messages, you -should become a member of the translating team for your own language. -The subscribing address is _not_ the same as the list itself, it has -'-request' appended. For example, speakers of Swedish can send a -message to 'sv-request@li.org', having this message body: - - subscribe - - Keep in mind that team members are expected to participate _actively_ -in translations, or at solving translational difficulties, rather than -merely lurking around. If your team does not exist yet and you want to -start one, or if you are unsure about what to do or how to get started, -please write to 'coordinator@translationproject.org' to reach the -coordinator for all translator teams. - - The English team is special. It works at improving and uniformizing -the terminology in use. Proven linguistic skills are praised more than -programming skills, here. - -1.4 Available Packages -====================== - -Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of Jun 2014. -The matrix shows, in regard of each package, for which languages PO -files have been submitted to translation coordination, with a -translation percentage of at least 50%. - - Ready PO files af am an ar as ast az be bg bn bn_IN bs ca crh cs - +---------------------------------------------------+ - a2ps | [] [] [] | - aegis | | - anubis | | - aspell | [] [] [] | - bash | [] [] [] | - bfd | | - binutils | [] | - bison | | - bison-runtime | [] | - buzztrax | [] | - ccd2cue | | - ccide | | - cflow | | - clisp | | - coreutils | [] [] | - cpio | | - cppi | | - cpplib | [] | - cryptsetup | [] | - datamash | | - denemo | [] [] | - dfarc | [] | - dialog | [] [] [] | - dico | | - diffutils | [] | - dink | [] | - direvent | | - doodle | [] | - dos2unix | | - dos2unix-man | | - e2fsprogs | [] [] | - enscript | [] | - exif | [] | - fetchmail | [] [] | - findutils | [] | - flex | [] | - freedink | [] [] | - fusionforge | | - gas | | - gawk | [] | - gcal | [] | - gcc | | - gdbm | | - gettext-examples | [] [] [] [] [] | - gettext-runtime | [] [] [] | - gettext-tools | [] [] | - gjay | | - glunarclock | [] [] [] | - gnubiff | [] | - gnubik | [] | - gnucash | () () [] | - gnuchess | | - gnulib | [] | - gnunet | | - gnunet-gtk | | - gold | | - gphoto2 | [] | - gprof | [] | - gramadoir | | - grep | [] [] [] | - grub | [] | - gsasl | | - gss | | - gst-plugins-bad | [] [] | - gst-plugins-base | [] [] [] | - gst-plugins-good | [] [] [] | - gst-plugins-ugly | [] [] [] | - gstreamer | [] [] [] [] | - gtick | [] | - gtkam | [] [] | - gtkspell | [] [] [] [] [] | - guix | | - guix-packages | | - gutenprint | [] | - hello | [] | - help2man | | - help2man-texi | | - hylafax | | - idutils | | - iso_15924 | [] | - iso_3166 | [] [] [] [] [] [] [] [] [] [] | - iso_3166_2 | | - iso_4217 | [] | - iso_639 | [] [] [] [] [] [] [] [] [] | - iso_639_3 | [] [] | - iso_639_5 | | - jwhois | | - kbd | [] | - klavaro | [] [] [] [] [] | - ld | [] | - leafpad | [] [] [] [] | - libc | [] [] [] | - libexif | () | - libextractor | | - libgnutls | [] | - libgphoto2 | [] | - libgphoto2_port | [] | - libgsasl | | - libiconv | [] [] | - libidn | [] | - liferea | [] [] [] [] | - lilypond | [] [] | - lordsawar | [] | - lprng | | - lynx | [] [] | - m4 | [] | - mailfromd | | - mailutils | | - make | [] | - man-db | [] [] | - man-db-manpages | | - midi-instruments | [] [] [] | - minicom | [] | - mkisofs | [] | - myserver | [] | - nano | [] [] [] | - opcodes | | - parted | [] | - pies | | - pnmixer | | - popt | [] | - procps-ng | | - procps-ng-man | | - psmisc | [] | - pspp | [] | - pushover | [] | - pwdutils | | - pyspread | | - radius | [] | - recode | [] [] [] | - recutils | | - rpm | | - rush | | - sarg | | - sed | [] [] [] [] | - sharutils | [] | - shishi | | - skribilo | | - solfege | [] [] | - solfege-manual | | - spotmachine | | - sudo | [] [] | - sudoers | [] [] | - sysstat | [] | - tar | [] [] [] | - texinfo | [] [] | - texinfo_document | [] [] | - tigervnc | [] | - tin | | - tin-man | | - tracgoogleappsa... | | - trader | | - util-linux | [] | - ve | | - vice | | - vmm | | - vorbis-tools | [] | - wastesedge | | - wcd | | - wcd-man | | - wdiff | [] [] | - wget | [] | - wyslij-po | | - xboard | | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] | - +---------------------------------------------------+ - af am an ar as ast az be bg bn bn_IN bs ca crh cs - 4 0 2 5 3 11 0 8 25 3 3 1 55 4 74 - - da de el en en_GB en_ZA eo es et eu fa fi fr - +--------------------------------------------------+ - a2ps | [] [] [] [] [] [] [] [] [] | - aegis | [] [] [] [] | - anubis | [] [] [] [] [] | - aspell | [] [] [] [] [] [] [] | - bash | [] [] [] | - bfd | [] [] [] [] | - binutils | [] [] [] | - bison | [] [] [] [] [] [] [] [] | - bison-runtime | [] [] [] [] [] [] [] [] | - buzztrax | [] [] [] [] | - ccd2cue | [] [] [] [] | - ccide | [] [] [] [] [] [] | - cflow | [] [] [] [] [] | - clisp | [] [] [] [] [] | - coreutils | [] [] [] [] [] | - cpio | [] [] [] [] [] | - cppi | [] [] [] [] [] | - cpplib | [] [] [] [] [] [] | - cryptsetup | [] [] [] [] [] | - datamash | [] [] [] [] | - denemo | [] | - dfarc | [] [] [] [] [] [] | - dialog | [] [] [] [] [] [] [] [] [] | - dico | [] [] [] [] | - diffutils | [] [] [] [] [] [] | - dink | [] [] [] [] [] [] | - direvent | [] [] [] [] | - doodle | [] [] [] [] | - dos2unix | [] [] [] [] [] | - dos2unix-man | [] [] [] | - e2fsprogs | [] [] [] [] [] | - enscript | [] [] [] [] [] [] | - exif | [] [] [] [] [] [] | - fetchmail | [] () [] [] [] [] [] | - findutils | [] [] [] [] [] [] [] [] | - flex | [] [] [] [] [] [] | - freedink | [] [] [] [] [] [] [] [] | - fusionforge | [] [] [] | - gas | [] [] [] | - gawk | [] [] [] [] [] | - gcal | [] [] [] [] | - gcc | [] | - gdbm | [] [] [] [] [] | - gettext-examples | [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] | - gettext-tools | [] [] [] [] [] | - gjay | [] [] [] [] | - glunarclock | [] [] [] [] [] | - gnubiff | () [] [] () | - gnubik | [] [] [] [] [] | - gnucash | [] () () () () () () | - gnuchess | [] [] [] [] | - gnulib | [] [] [] [] [] [] [] | - gnunet | [] | - gnunet-gtk | [] | - gold | [] [] [] | - gphoto2 | [] () [] [] | - gprof | [] [] [] [] [] [] | - gramadoir | [] [] [] [] [] | - grep | [] [] [] [] [] [] [] | - grub | [] [] [] [] [] | - gsasl | [] [] [] [] [] | - gss | [] [] [] [] [] | - gst-plugins-bad | [] [] [] | - gst-plugins-base | [] [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] [] [] | - gtick | [] () [] [] [] | - gtkam | [] () [] [] [] [] | - gtkspell | [] [] [] [] [] [] [] [] | - guix | [] [] | - guix-packages | | - gutenprint | [] [] [] [] | - hello | [] [] [] [] [] [] [] [] | - help2man | [] [] [] [] [] [] [] | - help2man-texi | [] [] [] | - hylafax | [] [] | - idutils | [] [] [] [] [] | - iso_15924 | [] () [] [] () [] () | - iso_3166 | [] () [] [] [] [] () [] () | - iso_3166_2 | [] () () () | - iso_4217 | [] () [] [] [] () [] () | - iso_639 | [] () [] [] () [] () | - iso_639_3 | () () () | - iso_639_5 | () () () | - jwhois | [] [] [] [] [] | - kbd | [] [] [] [] [] [] | - klavaro | [] [] [] [] [] [] [] | - ld | [] [] [] [] | - leafpad | [] [] [] [] [] [] [] [] | - libc | [] [] [] [] [] | - libexif | [] [] () [] [] | - libextractor | [] | - libgnutls | [] [] [] [] | - libgphoto2 | [] () [] | - libgphoto2_port | [] () [] [] [] [] | - libgsasl | [] [] [] [] [] | - libiconv | [] [] [] [] [] [] [] | - libidn | [] [] [] [] [] | - liferea | [] () [] [] [] [] [] | - lilypond | [] [] [] [] [] [] | - lordsawar | [] [] | - lprng | | - lynx | [] [] [] [] [] [] | - m4 | [] [] [] [] [] [] | - mailfromd | [] | - mailutils | [] [] [] [] | - make | [] [] [] [] [] | - man-db | [] [] [] [] | - man-db-manpages | [] [] | - midi-instruments | [] [] [] [] [] [] [] [] [] | - minicom | [] [] [] [] [] | - mkisofs | [] [] [] | - myserver | [] [] [] [] | - nano | [] [] [] [] [] [] [] | - opcodes | [] [] [] [] [] | - parted | [] [] [] | - pies | [] | - pnmixer | [] [] | - popt | [] [] [] [] [] [] | - procps-ng | [] [] | - procps-ng-man | [] [] | - psmisc | [] [] [] [] [] [] [] | - pspp | [] [] [] | - pushover | () [] [] [] | - pwdutils | [] [] [] | - pyspread | [] [] [] | - radius | [] [] | - recode | [] [] [] [] [] [] [] | - recutils | [] [] [] [] | - rpm | [] [] [] [] [] | - rush | [] [] [] | - sarg | [] [] | - sed | [] [] [] [] [] [] [] [] | - sharutils | [] [] [] [] | - shishi | [] [] [] | - skribilo | [] [] [] | - solfege | [] [] [] [] [] [] [] [] | - solfege-manual | [] [] [] [] [] | - spotmachine | [] [] [] [] [] | - sudo | [] [] [] [] [] [] | - sudoers | [] [] [] [] [] [] | - sysstat | [] [] [] [] [] [] | - tar | [] [] [] [] [] [] [] | - texinfo | [] [] [] [] [] | - texinfo_document | [] [] [] [] | - tigervnc | [] [] [] [] [] [] | - tin | [] [] [] [] | - tin-man | [] | - tracgoogleappsa... | [] [] [] [] [] | - trader | [] [] [] [] [] [] | - util-linux | [] [] [] [] | - ve | [] [] [] [] [] | - vice | () () () | - vmm | [] [] | - vorbis-tools | [] [] [] [] | - wastesedge | [] | - wcd | [] [] [] [] | - wcd-man | [] | - wdiff | [] [] [] [] [] [] [] | - wget | [] [] [] [] [] [] | - wyslij-po | [] [] [] [] | - xboard | [] [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] [] [] [] | - +--------------------------------------------------+ - da de el en en_GB en_ZA eo es et eu fa fi fr - 119 131 32 1 6 0 94 95 22 13 4 102 139 - - ga gd gl gu he hi hr hu hy ia id is it ja ka kk - +-------------------------------------------------+ - a2ps | [] [] [] [] | - aegis | [] | - anubis | [] [] [] [] | - aspell | [] [] [] [] [] | - bash | [] [] [] [] | - bfd | [] [] | - binutils | [] [] [] | - bison | [] | - bison-runtime | [] [] [] [] [] [] [] [] | - buzztrax | | - ccd2cue | [] | - ccide | [] [] | - cflow | [] [] [] | - clisp | | - coreutils | [] [] | - cpio | [] [] [] [] [] [] | - cppi | [] [] [] [] [] | - cpplib | [] [] | - cryptsetup | [] | - datamash | | - denemo | [] | - dfarc | [] [] [] | - dialog | [] [] [] [] [] [] [] [] [] [] | - dico | | - diffutils | [] [] [] [] | - dink | [] | - direvent | [] | - doodle | [] [] | - dos2unix | [] [] | - dos2unix-man | | - e2fsprogs | [] [] | - enscript | [] [] [] | - exif | [] [] [] [] [] [] | - fetchmail | [] [] [] | - findutils | [] [] [] [] [] [] [] | - flex | [] | - freedink | [] [] [] [] | - fusionforge | | - gas | [] | - gawk | [] () [] | - gcal | | - gcc | | - gdbm | | - gettext-examples | [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] [] | - gettext-tools | [] [] [] | - gjay | [] | - glunarclock | [] [] [] [] [] [] | - gnubiff | [] [] () | - gnubik | [] [] [] | - gnucash | () () () () () | - gnuchess | | - gnulib | [] [] [] [] [] | - gnunet | | - gnunet-gtk | | - gold | [] [] | - gphoto2 | [] [] [] [] | - gprof | [] [] [] [] | - gramadoir | [] [] [] | - grep | [] [] [] [] [] [] [] | - grub | [] [] [] | - gsasl | [] [] [] [] [] | - gss | [] [] [] [] [] | - gst-plugins-bad | [] [] [] | - gst-plugins-base | [] [] [] [] | - gst-plugins-good | [] [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] | - gtick | [] [] [] [] [] | - gtkam | [] [] [] [] [] | - gtkspell | [] [] [] [] [] [] [] [] [] [] | - guix | | - guix-packages | | - gutenprint | [] [] [] | - hello | [] [] [] [] [] | - help2man | [] [] [] | - help2man-texi | | - hylafax | [] | - idutils | [] [] | - iso_15924 | [] [] [] [] [] [] | - iso_3166 | [] [] [] [] [] [] [] [] [] [] [] [] [] | - iso_3166_2 | [] [] | - iso_4217 | [] [] [] [] [] [] | - iso_639 | [] [] [] [] [] [] [] [] [] | - iso_639_3 | [] [] | - iso_639_5 | | - jwhois | [] [] [] [] | - kbd | [] [] [] | - klavaro | [] [] [] [] [] | - ld | [] [] [] [] | - leafpad | [] [] [] [] [] [] [] () | - libc | [] [] [] [] [] | - libexif | [] | - libextractor | | - libgnutls | [] | - libgphoto2 | [] [] | - libgphoto2_port | [] [] | - libgsasl | [] [] [] [] | - libiconv | [] [] [] [] [] [] [] | - libidn | [] [] [] [] | - liferea | [] [] [] [] [] | - lilypond | [] | - lordsawar | | - lprng | [] | - lynx | [] [] [] [] | - m4 | [] [] [] [] [] | - mailfromd | | - mailutils | | - make | [] [] [] [] | - man-db | [] [] | - man-db-manpages | [] [] | - midi-instruments | [] [] [] [] [] [] [] [] [] | - minicom | [] [] [] | - mkisofs | [] [] | - myserver | [] | - nano | [] [] [] [] [] [] | - opcodes | [] [] [] | - parted | [] [] [] [] [] | - pies | | - pnmixer | [] [] | - popt | [] [] [] [] [] [] [] [] [] [] | - procps-ng | | - procps-ng-man | | - psmisc | [] [] [] [] | - pspp | [] [] | - pushover | [] | - pwdutils | [] | - pyspread | | - radius | [] | - recode | [] [] [] [] [] [] [] | - recutils | | - rpm | [] | - rush | [] | - sarg | | - sed | [] [] [] [] [] [] [] | - sharutils | | - shishi | | - skribilo | [] | - solfege | [] [] | - solfege-manual | | - spotmachine | | - sudo | [] [] [] [] | - sudoers | [] [] [] | - sysstat | [] [] [] [] | - tar | [] [] [] [] [] [] | - texinfo | [] [] [] | - texinfo_document | [] [] [] | - tigervnc | | - tin | | - tin-man | | - tracgoogleappsa... | [] [] [] [] | - trader | [] [] | - util-linux | [] | - ve | [] | - vice | () () | - vmm | | - vorbis-tools | [] [] | - wastesedge | [] | - wcd | | - wcd-man | | - wdiff | [] [] [] | - wget | [] [] [] [] | - wyslij-po | [] [] [] | - xboard | | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] [] [] | - +-------------------------------------------------+ - ga gd gl gu he hi hr hu hy ia id is it ja ka kk - 35 2 47 4 8 2 60 71 2 6 81 11 87 57 0 3 - - kn ko ku ky lg lt lv mk ml mn mr ms mt nb ne nl - +--------------------------------------------------+ - a2ps | [] [] | - aegis | [] | - anubis | [] [] [] | - aspell | [] [] | - bash | [] [] | - bfd | | - binutils | | - bison | [] | - bison-runtime | [] [] [] [] [] [] | - buzztrax | | - ccd2cue | | - ccide | [] [] | - cflow | [] | - clisp | [] | - coreutils | [] [] | - cpio | [] | - cppi | | - cpplib | [] | - cryptsetup | [] | - datamash | [] [] | - denemo | | - dfarc | [] [] | - dialog | [] [] [] [] [] [] | - dico | | - diffutils | [] [] [] | - dink | [] | - direvent | [] | - doodle | [] | - dos2unix | [] [] | - dos2unix-man | [] | - e2fsprogs | [] | - enscript | [] | - exif | [] [] [] | - fetchmail | [] | - findutils | [] [] | - flex | [] | - freedink | [] [] | - fusionforge | | - gas | | - gawk | [] | - gcal | | - gcc | | - gdbm | | - gettext-examples | [] [] [] [] [] [] | - gettext-runtime | [] [] [] | - gettext-tools | [] | - gjay | | - glunarclock | [] [] | - gnubiff | [] | - gnubik | [] [] | - gnucash | () () () () () () () [] | - gnuchess | [] [] | - gnulib | [] | - gnunet | | - gnunet-gtk | | - gold | | - gphoto2 | [] | - gprof | [] [] | - gramadoir | [] | - grep | [] [] | - grub | [] [] [] | - gsasl | [] | - gss | | - gst-plugins-bad | [] [] [] | - gst-plugins-base | [] [] [] | - gst-plugins-good | [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] | - gstreamer | [] [] [] | - gtick | [] | - gtkam | [] [] | - gtkspell | [] [] [] [] [] [] [] | - guix | | - guix-packages | | - gutenprint | [] | - hello | [] [] [] | - help2man | [] | - help2man-texi | | - hylafax | [] | - idutils | [] | - iso_15924 | () [] [] | - iso_3166 | [] [] [] () [] [] [] [] [] [] | - iso_3166_2 | () [] | - iso_4217 | () [] [] [] | - iso_639 | [] [] () [] [] [] [] | - iso_639_3 | [] () [] | - iso_639_5 | () | - jwhois | [] [] | - kbd | [] | - klavaro | [] [] | - ld | | - leafpad | [] [] [] [] [] | - libc | [] [] | - libexif | [] | - libextractor | [] | - libgnutls | [] [] | - libgphoto2 | [] | - libgphoto2_port | [] | - libgsasl | [] | - libiconv | [] [] | - libidn | [] | - liferea | [] [] [] | - lilypond | [] | - lordsawar | | - lprng | | - lynx | [] | - m4 | [] | - mailfromd | | - mailutils | | - make | [] [] | - man-db | [] | - man-db-manpages | [] | - midi-instruments | [] [] [] [] [] [] [] | - minicom | [] | - mkisofs | [] | - myserver | | - nano | [] [] [] | - opcodes | [] | - parted | [] [] | - pies | | - pnmixer | [] | - popt | [] [] [] [] [] | - procps-ng | | - procps-ng-man | | - psmisc | [] | - pspp | [] [] | - pushover | | - pwdutils | [] | - pyspread | | - radius | [] | - recode | [] [] | - recutils | [] | - rpm | [] | - rush | [] | - sarg | | - sed | [] [] | - sharutils | [] | - shishi | | - skribilo | | - solfege | [] [] | - solfege-manual | [] | - spotmachine | [] | - sudo | [] [] [] | - sudoers | [] [] [] | - sysstat | [] [] | - tar | [] [] [] | - texinfo | [] | - texinfo_document | [] | - tigervnc | [] | - tin | | - tin-man | | - tracgoogleappsa... | [] [] [] | - trader | [] | - util-linux | [] | - ve | [] | - vice | [] | - vmm | [] | - vorbis-tools | [] | - wastesedge | [] | - wcd | [] | - wcd-man | [] | - wdiff | [] | - wget | [] [] | - wyslij-po | [] | - xboard | [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] | - +--------------------------------------------------+ - kn ko ku ky lg lt lv mk ml mn mr ms mt nb ne nl - 5 15 4 6 0 13 23 3 3 3 4 11 2 42 1 125 - - nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr - +------------------------------------------------+ - a2ps | [] [] [] [] [] [] [] | - aegis | [] [] | - anubis | [] [] [] | - aspell | [] [] [] [] [] [] [] | - bash | [] [] [] [] [] [] | - bfd | [] [] | - binutils | [] [] | - bison | [] [] [] | - bison-runtime | [] [] [] [] [] [] [] [] | - buzztrax | [] | - ccd2cue | [] [] | - ccide | [] [] [] | - cflow | [] [] [] | - clisp | [] | - coreutils | [] [] [] [] | - cpio | [] [] [] | - cppi | [] [] [] | - cpplib | [] [] [] | - cryptsetup | [] [] [] | - datamash | [] [] | - denemo | | - dfarc | [] [] [] | - dialog | [] [] [] [] [] [] [] | - dico | [] | - diffutils | [] [] [] | - dink | | - direvent | [] [] [] | - doodle | [] [] | - dos2unix | [] [] [] [] | - dos2unix-man | [] [] | - e2fsprogs | [] | - enscript | [] [] [] [] [] [] | - exif | [] [] [] [] [] [] | - fetchmail | [] [] [] | - findutils | [] [] [] [] [] [] | - flex | [] [] [] [] [] | - freedink | [] [] [] [] [] | - fusionforge | | - gas | | - gawk | [] | - gcal | | - gcc | | - gdbm | [] [] [] | - gettext-examples | [] [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] [] [] [] | - gettext-tools | [] [] [] [] [] [] [] | - gjay | [] | - glunarclock | [] [] [] [] [] [] | - gnubiff | [] | - gnubik | [] [] [] [] | - gnucash | () () () () () [] | - gnuchess | [] [] | - gnulib | [] [] [] [] [] | - gnunet | | - gnunet-gtk | | - gold | | - gphoto2 | [] [] [] [] [] | - gprof | [] [] [] [] | - gramadoir | [] [] | - grep | [] [] [] [] [] [] | - grub | [] [] [] [] [] | - gsasl | [] [] [] | - gss | [] [] [] [] | - gst-plugins-bad | [] [] [] [] [] | - gst-plugins-base | [] [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] [] [] | - gtick | [] [] [] [] [] | - gtkam | [] [] [] [] [] [] | - gtkspell | [] [] [] [] [] [] [] [] [] | - guix | | - guix-packages | | - gutenprint | [] [] | - hello | [] [] [] [] [] [] | - help2man | [] [] [] [] | - help2man-texi | [] | - hylafax | | - idutils | [] [] [] | - iso_15924 | [] () [] [] [] [] | - iso_3166 | [] [] [] [] () [] [] [] [] [] [] [] [] | - iso_3166_2 | [] () [] | - iso_4217 | [] [] () [] [] [] [] [] | - iso_639 | [] [] [] () [] [] [] [] [] [] | - iso_639_3 | [] () | - iso_639_5 | () [] | - jwhois | [] [] [] [] | - kbd | [] [] | - klavaro | [] [] [] [] [] | - ld | | - leafpad | [] [] [] [] [] [] [] [] | - libc | [] [] [] | - libexif | [] () [] | - libextractor | [] | - libgnutls | [] | - libgphoto2 | [] | - libgphoto2_port | [] [] [] [] [] | - libgsasl | [] [] [] [] | - libiconv | [] [] [] [] [] | - libidn | [] [] [] | - liferea | [] [] [] [] () [] [] | - lilypond | | - lordsawar | | - lprng | [] | - lynx | [] [] | - m4 | [] [] [] [] [] | - mailfromd | [] | - mailutils | [] | - make | [] [] [] | - man-db | [] [] [] | - man-db-manpages | [] [] [] | - midi-instruments | [] [] [] [] [] [] [] [] | - minicom | [] [] [] [] | - mkisofs | [] [] [] | - myserver | [] [] | - nano | [] [] [] [] [] [] | - opcodes | | - parted | [] [] [] [] [] [] | - pies | [] | - pnmixer | [] | - popt | [] [] [] [] [] [] | - procps-ng | [] | - procps-ng-man | [] | - psmisc | [] [] [] [] | - pspp | [] [] | - pushover | | - pwdutils | [] | - pyspread | [] [] | - radius | [] [] | - recode | [] [] [] [] [] [] [] [] | - recutils | [] [] | - rpm | [] | - rush | [] [] [] | - sarg | [] [] | - sed | [] [] [] [] [] [] [] [] | - sharutils | [] [] [] | - shishi | [] [] | - skribilo | [] | - solfege | [] [] [] | - solfege-manual | [] [] | - spotmachine | [] [] | - sudo | [] [] [] [] [] [] | - sudoers | [] [] [] [] | - sysstat | [] [] [] [] [] | - tar | [] [] [] [] [] | - texinfo | [] [] [] | - texinfo_document | [] [] | - tigervnc | [] [] [] | - tin | [] | - tin-man | | - tracgoogleappsa... | [] [] [] [] | - trader | [] [] | - util-linux | [] [] | - ve | [] [] [] | - vice | | - vmm | | - vorbis-tools | [] [] [] | - wastesedge | | - wcd | | - wcd-man | | - wdiff | [] [] [] [] [] | - wget | [] [] [] [] [] | - wyslij-po | [] [] [] [] | - xboard | [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] | - +------------------------------------------------+ - nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr - 7 3 6 114 1 12 88 32 82 3 40 45 7 101 - - sv sw ta te tg th tr uk ur vi wa wo zh_CN - +----------------------------------------------+ - a2ps | [] [] [] [] [] | - aegis | [] | - anubis | [] [] [] [] | - aspell | [] [] [] [] [] | - bash | [] [] [] [] | - bfd | [] [] [] | - binutils | [] [] [] | - bison | [] [] [] [] | - bison-runtime | [] [] [] [] [] [] | - buzztrax | [] [] [] | - ccd2cue | [] [] [] | - ccide | [] [] [] [] | - cflow | [] [] [] [] | - clisp | | - coreutils | [] [] [] | - cpio | [] [] [] [] [] | - cppi | [] [] [] [] | - cpplib | [] [] [] [] [] | - cryptsetup | [] [] [] | - datamash | [] [] [] | - denemo | [] | - dfarc | [] [] | - dialog | [] [] [] [] [] [] | - dico | [] | - diffutils | [] [] [] [] [] | - dink | [] | - direvent | [] [] | - doodle | [] [] | - dos2unix | [] [] [] [] | - dos2unix-man | [] [] [] | - e2fsprogs | [] [] [] [] | - enscript | [] [] [] [] | - exif | [] [] [] [] [] | - fetchmail | [] [] [] [] | - findutils | [] [] [] [] [] | - flex | [] [] [] [] | - freedink | [] [] [] | - fusionforge | | - gas | [] | - gawk | [] [] [] | - gcal | [] [] [] | - gcc | [] | - gdbm | [] [] | - gettext-examples | [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] | - gettext-tools | [] [] [] [] [] | - gjay | [] [] [] | - glunarclock | [] [] [] [] | - gnubiff | [] [] | - gnubik | [] [] [] [] | - gnucash | () () () () [] | - gnuchess | [] [] [] | - gnulib | [] [] [] [] | - gnunet | | - gnunet-gtk | | - gold | [] [] | - gphoto2 | [] [] [] [] | - gprof | [] [] [] [] | - gramadoir | [] [] [] | - grep | [] [] [] [] [] | - grub | [] [] [] [] | - gsasl | [] [] [] [] | - gss | [] [] [] | - gst-plugins-bad | [] [] [] [] [] | - gst-plugins-base | [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] | - gstreamer | [] [] [] [] [] | - gtick | [] [] [] | - gtkam | [] [] [] [] | - gtkspell | [] [] [] [] [] [] [] | - guix | | - guix-packages | | - gutenprint | [] [] [] [] | - hello | [] [] [] [] [] [] | - help2man | [] [] [] | - help2man-texi | [] | - hylafax | [] | - idutils | [] [] [] | - iso_15924 | [] () [] [] () [] | - iso_3166 | [] [] () [] [] () [] [] | - iso_3166_2 | () [] [] () [] | - iso_4217 | [] () [] [] () [] | - iso_639 | [] [] [] () [] [] () [] [] | - iso_639_3 | [] () [] [] () | - iso_639_5 | () [] () | - jwhois | [] [] [] [] | - kbd | [] [] [] [] | - klavaro | [] [] [] [] [] [] | - ld | [] [] [] [] [] | - leafpad | [] [] [] [] [] [] | - libc | [] [] [] [] [] | - libexif | [] [] () | - libextractor | [] [] | - libgnutls | [] [] [] [] | - libgphoto2 | [] [] [] | - libgphoto2_port | [] [] [] [] | - libgsasl | [] [] [] [] | - libiconv | [] [] [] [] [] | - libidn | () [] [] [] | - liferea | [] [] [] [] [] | - lilypond | [] | - lordsawar | | - lprng | [] | - lynx | [] [] [] [] | - m4 | [] [] [] | - mailfromd | [] [] | - mailutils | [] | - make | [] [] [] [] | - man-db | [] [] [] | - man-db-manpages | [] [] | - midi-instruments | [] [] [] [] [] [] | - minicom | [] [] | - mkisofs | [] [] [] | - myserver | [] | - nano | [] [] [] [] | - opcodes | [] [] [] | - parted | [] [] [] [] [] | - pies | [] [] | - pnmixer | [] [] [] | - popt | [] [] [] [] [] [] [] | - procps-ng | [] [] | - procps-ng-man | [] | - psmisc | [] [] [] [] | - pspp | [] [] [] | - pushover | [] | - pwdutils | [] [] | - pyspread | [] | - radius | [] [] | - recode | [] [] [] [] | - recutils | [] [] [] | - rpm | [] [] [] [] | - rush | [] [] | - sarg | | - sed | [] [] [] [] [] | - sharutils | [] [] [] [] | - shishi | [] [] | - skribilo | [] [] | - solfege | [] [] [] [] | - solfege-manual | [] | - spotmachine | [] [] [] | - sudo | [] [] [] [] [] | - sudoers | [] [] [] [] | - sysstat | [] [] [] [] [] | - tar | [] [] [] [] [] | - texinfo | [] [] [] | - texinfo_document | [] | - tigervnc | [] [] [] | - tin | [] | - tin-man | | - tracgoogleappsa... | [] [] [] [] [] | - trader | [] | - util-linux | [] [] [] [] | - ve | [] [] [] [] | - vice | () () | - vmm | | - vorbis-tools | [] [] | - wastesedge | | - wcd | [] [] [] | - wcd-man | [] | - wdiff | [] [] [] [] | - wget | [] [] [] | - wyslij-po | [] [] | - xboard | [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] | - +----------------------------------------------+ - sv sw ta te tg th tr uk ur vi wa wo zh_CN - 106 1 4 3 0 13 51 115 1 125 7 1 100 - - zh_HK zh_TW - +-------------+ - a2ps | | 30 - aegis | | 9 - anubis | | 19 - aspell | | 29 - bash | [] | 23 - bfd | | 11 - binutils | | 12 - bison | [] | 18 - bison-runtime | [] | 38 - buzztrax | | 9 - ccd2cue | | 10 - ccide | | 17 - cflow | | 16 - clisp | | 10 - coreutils | | 18 - cpio | | 20 - cppi | | 17 - cpplib | [] | 19 - cryptsetup | | 14 - datamash | | 11 - denemo | | 5 - dfarc | | 17 - dialog | [] | 42 - dico | | 6 - diffutils | | 22 - dink | | 10 - direvent | | 11 - doodle | | 12 - dos2unix | [] | 18 - dos2unix-man | | 9 - e2fsprogs | | 15 - enscript | | 21 - exif | | 27 - fetchmail | | 19 - findutils | | 29 - flex | [] | 19 - freedink | | 24 - fusionforge | | 3 - gas | | 5 - gawk | | 13 - gcal | | 8 - gcc | | 2 - gdbm | | 10 - gettext-examples | [] [] | 40 - gettext-runtime | [] [] | 35 - gettext-tools | [] | 24 - gjay | | 9 - glunarclock | [] | 27 - gnubiff | | 9 - gnubik | | 19 - gnucash | () | 6 - gnuchess | | 11 - gnulib | | 23 - gnunet | | 1 - gnunet-gtk | | 1 - gold | | 7 - gphoto2 | [] | 19 - gprof | | 21 - gramadoir | | 14 - grep | [] | 31 - grub | | 21 - gsasl | [] | 19 - gss | | 17 - gst-plugins-bad | | 21 - gst-plugins-base | | 27 - gst-plugins-good | | 32 - gst-plugins-ugly | | 34 - gstreamer | [] | 32 - gtick | | 19 - gtkam | | 24 - gtkspell | [] [] | 48 - guix | | 2 - guix-packages | | 0 - gutenprint | | 15 - hello | [] | 30 - help2man | | 18 - help2man-texi | | 5 - hylafax | | 5 - idutils | | 14 - iso_15924 | [] | 23 - iso_3166 | [] [] | 58 - iso_3166_2 | | 9 - iso_4217 | [] [] | 28 - iso_639 | [] [] | 46 - iso_639_3 | | 10 - iso_639_5 | | 2 - jwhois | [] | 20 - kbd | | 17 - klavaro | | 30 - ld | [] | 15 - leafpad | [] | 39 - libc | [] | 24 - libexif | | 10 - libextractor | | 5 - libgnutls | | 13 - libgphoto2 | | 10 - libgphoto2_port | [] | 19 - libgsasl | | 18 - libiconv | [] | 29 - libidn | | 17 - liferea | | 29 - lilypond | | 11 - lordsawar | | 3 - lprng | | 3 - lynx | | 19 - m4 | [] | 22 - mailfromd | | 4 - mailutils | | 6 - make | | 19 - man-db | | 15 - man-db-manpages | | 10 - midi-instruments | [] | 43 - minicom | [] | 17 - mkisofs | | 13 - myserver | | 9 - nano | [] | 30 - opcodes | | 12 - parted | [] | 23 - pies | | 4 - pnmixer | | 9 - popt | [] | 36 - procps-ng | | 5 - procps-ng-man | | 4 - psmisc | [] | 22 - pspp | | 13 - pushover | | 6 - pwdutils | | 8 - pyspread | | 6 - radius | | 9 - recode | | 31 - recutils | | 10 - rpm | [] | 13 - rush | | 10 - sarg | | 4 - sed | [] | 35 - sharutils | | 13 - shishi | | 7 - skribilo | | 7 - solfege | | 21 - solfege-manual | | 9 - spotmachine | | 11 - sudo | | 26 - sudoers | | 22 - sysstat | | 23 - tar | [] | 30 - texinfo | | 17 - texinfo_document | | 13 - tigervnc | | 14 - tin | [] | 7 - tin-man | | 1 - tracgoogleappsa... | [] | 22 - trader | | 12 - util-linux | | 13 - ve | | 14 - vice | | 1 - vmm | | 3 - vorbis-tools | | 13 - wastesedge | | 3 - wcd | | 8 - wcd-man | | 3 - wdiff | [] | 23 - wget | | 21 - wyslij-po | | 14 - xboard | | 10 - xdg-user-dirs | [] [] | 68 - xkeyboard-config | [] | 28 - +-------------+ - 89 teams zh_HK zh_TW - 166 domains 7 42 2809 - - Some counters in the preceding matrix are higher than the number of -visible blocks let us expect. This is because a few extra PO files are -used for implementing regional variants of languages, or language -dialects. - - For a PO file in the matrix above to be effective, the package to -which it applies should also have been internationalized and distributed -as such by its maintainer. There might be an observable lag between the -mere existence a PO file and its wide availability in a distribution. - - If Jun 2014 seems to be old, you may fetch a more recent copy of this -'ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix -with full percentage details can be found at -'http://translationproject.org/extra/matrix.html'. - -1.5 Using 'gettext' in new packages -=================================== - -If you are writing a freely available program and want to -internationalize it you are welcome to use GNU 'gettext' in your -package. Of course you have to respect the GNU Lesser General Public -License which covers the use of the GNU 'gettext' library. This means -in particular that even non-free programs can use 'libintl' as a shared -library, whereas only free software can use 'libintl' as a static -library or use modified versions of 'libintl'. - - Once the sources are changed appropriately and the setup can handle -the use of 'gettext' the only thing missing are the translations. The -Free Translation Project is also available for packages which are not -developed inside the GNU project. Therefore the information given above -applies also for every other Free Software Project. Contact -'coordinator@translationproject.org' to make the '.pot' files available -to the translation teams. diff --git a/rpcsvc-proto-1.4.2/AUTHORS b/rpcsvc-proto-1.4.2/AUTHORS deleted file mode 100644 index e69de29..0000000 diff --git a/rpcsvc-proto-1.4.2/COPYING b/rpcsvc-proto-1.4.2/COPYING deleted file mode 100644 index 9ca3fa5..0000000 --- a/rpcsvc-proto-1.4.2/COPYING +++ /dev/null @@ -1,30 +0,0 @@ -Most files were part of the GNU C Library. - -Copyright (c) 2010, Oracle America, Inc. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - * Neither the name of the "Oracle America, Inc." nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/rpcsvc-proto-1.4.2/ChangeLog b/rpcsvc-proto-1.4.2/ChangeLog deleted file mode 100644 index b2ef44a..0000000 --- a/rpcsvc-proto-1.4.2/ChangeLog +++ /dev/null @@ -1,45 +0,0 @@ -2020-01-07 gettextize - - * m4/gettext.m4: Upgrade to gettext-0.19.8.1. - * m4/iconv.m4: Upgrade to gettext-0.19.8.1. - * m4/lib-ld.m4: Upgrade to gettext-0.19.8.1. - * m4/lib-link.m4: Upgrade to gettext-0.19.8.1. - * m4/lib-prefix.m4: Upgrade to gettext-0.19.8.1. - * m4/nls.m4: Upgrade to gettext-0.19.8.1. - * m4/po.m4: Upgrade to gettext-0.19.8.1. - * m4/progtest.m4: Upgrade to gettext-0.19.8.1. - * Makefile.am (ACLOCAL_AMFLAGS): New variable. - * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.19.8. - -2016-04-06 Thorsten Kukuk - - * release version 1.1 - - * Makefile.am: Add rpcgen to SUBDIRS - * README: enhance with rpcgen - * autogen.sh: enable autoheader - * configure.ac: disable rpcgen check, add check for C compiler - toolchain - * rpcsvc/Makefile.am: Use own rpcgen - * rpcgen/Makefile.am: New - * rpcgen/proto.h: New, from glibc/sunrpc - * rpcgen/rpc_clntout.c: Likewise - * rpcgen/rpc_cout.c: Likewise - * rpcgen/rpc_hout.c: Likewise - * rpcgen/rpc_main.c: Likewise - * rpcgen/rpc_parse.c: Likewise - * rpcgen/rpc_parse.h: Likewise - * rpcgen/rpc_sample.c: Likewise - * rpcgen/rpc_scan.c: Likewise - * rpcgen/rpc_scan.h: Likewise - * rpcgen/rpc_svcout.c: Likewise - * rpcgen/rpc_tblout.c: Likewise - * rpcgen/rpc_util.c: Likewise - * rpcgen/rpc_util.h: Likewise - * rpcgen/rpcgen.1: New - -2016-03-31 Thorsten Kukuk - - * release version 1.0 - - * Initial version diff --git a/rpcsvc-proto-1.4.2/INSTALL b/rpcsvc-proto-1.4.2/INSTALL deleted file mode 100644 index 8865734..0000000 --- a/rpcsvc-proto-1.4.2/INSTALL +++ /dev/null @@ -1,368 +0,0 @@ -Installation Instructions -************************* - - Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software -Foundation, Inc. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell command './configure && make && make install' -should configure, build, and install this package. The following -more-detailed instructions are generic; see the 'README' file for -instructions specific to this package. Some packages provide this -'INSTALL' file but do not implement all of the features documented -below. The lack of an optional feature in a given package is not -necessarily a bug. More recommendations for GNU packages can be found -in *note Makefile Conventions: (standards)Makefile Conventions. - - The 'configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a 'Makefile' in each directory of the package. -It may also create one or more '.h' files containing system-dependent -definitions. Finally, it creates a shell script 'config.status' that -you can run in the future to recreate the current configuration, and a -file 'config.log' containing compiler output (useful mainly for -debugging 'configure'). - - It can also use an optional file (typically called 'config.cache' and -enabled with '--cache-file=config.cache' or simply '-C') that saves the -results of its tests to speed up reconfiguring. Caching is disabled by -default to prevent problems with accidental use of stale cache files. - - If you need to do unusual things to compile the package, please try -to figure out how 'configure' could check whether to do them, and mail -diffs or instructions to the address given in the 'README' so they can -be considered for the next release. If you are using the cache, and at -some point 'config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file 'configure.ac' (or 'configure.in') is used to create -'configure' by a program called 'autoconf'. You need 'configure.ac' if -you want to change it or regenerate 'configure' using a newer version of -'autoconf'. - - The simplest way to compile this package is: - - 1. 'cd' to the directory containing the package's source code and type - './configure' to configure the package for your system. - - Running 'configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type 'make' to compile the package. - - 3. Optionally, type 'make check' to run any self-tests that come with - the package, generally using the just-built uninstalled binaries. - - 4. Type 'make install' to install the programs and any data files and - documentation. When installing into a prefix owned by root, it is - recommended that the package be configured and built as a regular - user, and only the 'make install' phase executed with root - privileges. - - 5. Optionally, type 'make installcheck' to repeat any self-tests, but - this time using the binaries in their final installed location. - This target does not install anything. Running this target as a - regular user, particularly if the prior 'make install' required - root privileges, verifies that the installation completed - correctly. - - 6. You can remove the program binaries and object files from the - source code directory by typing 'make clean'. To also remove the - files that 'configure' created (so you can compile the package for - a different kind of computer), type 'make distclean'. There is - also a 'make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 7. Often, you can also type 'make uninstall' to remove the installed - files again. In practice, not all packages have tested that - uninstallation works correctly, even though it is required by the - GNU Coding Standards. - - 8. Some packages, particularly those that use Automake, provide 'make - distcheck', which can by used by developers to test that all other - targets like 'make install' and 'make uninstall' work correctly. - This target is generally not run by end users. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the 'configure' script does not know about. Run './configure --help' -for details on some of the pertinent environment variables. - - You can give 'configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here is -an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU 'make'. 'cd' to the -directory where you want the object files and executables to go and run -the 'configure' script. 'configure' automatically checks for the source -code in the directory that 'configure' is in and in '..'. This is known -as a "VPATH" build. - - With a non-GNU 'make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use 'make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple '-arch' options to the -compiler but only a single '-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the 'lipo' tool if you have problems. - -Installation Names -================== - - By default, 'make install' installs the package's commands under -'/usr/local/bin', include files under '/usr/local/include', etc. You -can specify an installation prefix other than '/usr/local' by giving -'configure' the option '--prefix=PREFIX', where PREFIX must be an -absolute file name. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option '--exec-prefix=PREFIX' to 'configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like '--bindir=DIR' to specify different values for particular -kinds of files. Run 'configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the default -for these options is expressed in terms of '${prefix}', so that -specifying just '--prefix' will affect all of the other directory -specifications that were not explicitly provided. - - The most portable way to affect installation locations is to pass the -correct locations to 'configure'; however, many packages provide one or -both of the following shortcuts of passing variable assignments to the -'make install' command line to change installation locations without -having to reconfigure or recompile. - - The first method involves providing an override variable for each -affected directory. For example, 'make install -prefix=/alternate/directory' will choose an alternate location for all -directory configuration variables that were expressed in terms of -'${prefix}'. Any directories that were specified during 'configure', -but not in terms of '${prefix}', must each be overridden at install time -for the entire installation to be relocated. The approach of makefile -variable overrides for each directory variable is required by the GNU -Coding Standards, and ideally causes no recompilation. However, some -platforms have known limitations with the semantics of shared libraries -that end up requiring recompilation when using this method, particularly -noticeable in packages that use GNU Libtool. - - The second method involves providing the 'DESTDIR' variable. For -example, 'make install DESTDIR=/alternate/directory' will prepend -'/alternate/directory' before all installation names. The approach of -'DESTDIR' overrides is not required by the GNU Coding Standards, and -does not work on platforms that have drive letters. On the other hand, -it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of '${prefix}' -at 'configure' time. - -Optional Features -================= - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving 'configure' the -option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. - - Some packages pay attention to '--enable-FEATURE' options to -'configure', where FEATURE indicates an optional part of the package. -They may also pay attention to '--with-PACKAGE' options, where PACKAGE -is something like 'gnu-as' or 'x' (for the X Window System). The -'README' should mention any '--enable-' and '--with-' options that the -package recognizes. - - For packages that use the X Window System, 'configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the 'configure' options '--x-includes=DIR' and -'--x-libraries=DIR' to specify their locations. - - Some packages offer the ability to configure how verbose the -execution of 'make' will be. For these packages, running './configure ---enable-silent-rules' sets the default to minimal output, which can be -overridden with 'make V=1'; while running './configure ---disable-silent-rules' sets the default to verbose, which can be -overridden with 'make V=0'. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC -is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - HP-UX 'make' updates targets which have the same time stamps as their -prerequisites, which makes it generally unusable when shipped generated -files such as 'configure' are involved. Use GNU 'make' instead. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its '' header file. The option '-nodtk' can be used as a -workaround. If GNU CC is not installed, it is therefore recommended to -try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put '/usr/ucb' early in your 'PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in '/usr/bin'. So, if you need '/usr/ucb' -in your 'PATH', put it _after_ '/usr/bin'. - - On Haiku, software installed for all users goes in '/boot/common', -not '/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features 'configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, 'configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -'--build=TYPE' option. TYPE can either be a short name for the system -type, such as 'sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file 'config.sub' for the possible values of each field. If -'config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option '--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with '--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for 'configure' scripts to share, -you can create a site shell script called 'config.site' that gives -default values for variables like 'CC', 'cache_file', and 'prefix'. -'configure' looks for 'PREFIX/share/config.site' if it exists, then -'PREFIX/etc/config.site' if it exists. Or, you can set the -'CONFIG_SITE' environment variable to the location of the site script. -A warning: not all 'configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to 'configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the 'configure' command line, using 'VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified 'gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an -Autoconf limitation. Until the limitation is lifted, you can use this -workaround: - - CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash - -'configure' Invocation -====================== - - 'configure' recognizes the following options to control how it -operates. - -'--help' -'-h' - Print a summary of all of the options to 'configure', and exit. - -'--help=short' -'--help=recursive' - Print a summary of the options unique to this package's - 'configure', and exit. The 'short' variant lists options used only - in the top level, while the 'recursive' variant lists options also - present in any nested packages. - -'--version' -'-V' - Print the version of Autoconf used to generate the 'configure' - script, and exit. - -'--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally 'config.cache'. FILE defaults to '/dev/null' to - disable caching. - -'--config-cache' -'-C' - Alias for '--cache-file=config.cache'. - -'--quiet' -'--silent' -'-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to '/dev/null' (any error - messages will still be shown). - -'--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - 'configure' can determine that directory automatically. - -'--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: for - more details, including other options available for fine-tuning the - installation locations. - -'--no-create' -'-n' - Run the configure checks, but stop before creating any output - files. - -'configure' also accepts some other, not widely useful, options. Run -'configure --help' for more details. diff --git a/rpcsvc-proto-1.4.2/Makefile.am b/rpcsvc-proto-1.4.2/Makefile.am deleted file mode 100644 index f2de1e6..0000000 --- a/rpcsvc-proto-1.4.2/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -# -AUTOMAKE_OPTIONS = 1.7 gnits dist-xz -# -SUBDIRS = rpcgen rpcsvc po - -CLEANFILES = *~ - -ACLOCAL_AMFLAGS = -I m4 diff --git a/rpcsvc-proto-1.4.2/NEWS b/rpcsvc-proto-1.4.2/NEWS deleted file mode 100644 index e70310b..0000000 --- a/rpcsvc-proto-1.4.2/NEWS +++ /dev/null @@ -1,30 +0,0 @@ -rpcsvc-proto NEWS -- history of user-visible changes. - -Copyright (C) 2016-2020 Thorsten Kukuk - -Please use https://github.com/thkukuk/rpcsvc-proto/issues for bug reports. - -Version 1.4.2 -* Allow newer gettext versions - -Version 1.4.1 -* Add support for external libintl - -Version 1.4 -* Remove historic _RPC_THREAD_SAFE_ preprocessor conditional - -Version 1.3.1 -* Fix autogen.sh - -Version 1.3 -* Only use BSD-3 Clause code -* Adjust email address - -Version 1.2 -* Fix possible buffer overrun in rpcgen - -Version 1.1 -* Add rpcgen - -Version 1.0 -* Initial version diff --git a/rpcsvc-proto-1.4.2/README b/rpcsvc-proto-1.4.2/README deleted file mode 100644 index 3a4ce96..0000000 --- a/rpcsvc-proto-1.4.2/README +++ /dev/null @@ -1,5 +0,0 @@ -This package contains rpcsvc proto.x files from glibc, which are -missing in libtirpc. Additional it contains rpcgen, which is needed -to create header files and sources from protocol files. -This package is only needed, if glibc is installed without the -deprecated sunrpc functionality and libtirpc should replace it. diff --git a/rpcsvc-proto-1.4.2/THANKS b/rpcsvc-proto-1.4.2/THANKS deleted file mode 100644 index e69de29..0000000 diff --git a/rpcsvc-proto-1.4.2/aclocal.m4 b/rpcsvc-proto-1.4.2/aclocal.m4 deleted file mode 100644 index e45bdfb..0000000 --- a/rpcsvc-proto-1.4.2/aclocal.m4 +++ /dev/null @@ -1,1190 +0,0 @@ -# generated automatically by aclocal 1.15.1 -*- Autoconf -*- - -# Copyright (C) 1996-2017 Free Software Foundation, Inc. - -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) - -# Copyright (C) 2002-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Older Autoconf quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl -]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi -dnl The trailing newline in this macro's definition is deliberate, for -dnl backward compatibility and to allow trailing 'dnl'-style comments -dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. -]) - -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST([install_sh])]) - -# Copyright (C) 2003-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) -fi -]) - -# -*- Autoconf -*- -# Obsolete and "removed" macros, that must however still report explicit -# error messages when used, to smooth transition. -# -# Copyright (C) 1996-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -AC_DEFUN([AM_CONFIG_HEADER], -[AC_DIAGNOSE([obsolete], -['$0': this macro is obsolete. -You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl -AC_CONFIG_HEADERS($@)]) - -AC_DEFUN([AM_PROG_CC_STDC], -[AC_PROG_CC -am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc -AC_DIAGNOSE([obsolete], -['$0': this macro is obsolete. -You should simply use the 'AC][_PROG_CC' macro instead. -Also, your code should no longer depend upon 'am_cv_prog_cc_stdc', -but upon 'ac_cv_prog_cc_stdc'.])]) - -AC_DEFUN([AM_C_PROTOTYPES], - [AC_FATAL([automatic de-ANSI-fication support has been removed])]) -AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# -------------------- -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) - -# _AM_SET_OPTIONS(OPTIONS) -# ------------------------ -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Copyright (C) 1999-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor 'install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004-2017 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -# -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done - rm -rf conftest.dir - - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([m4/gettext.m4]) -m4_include([m4/iconv.m4]) -m4_include([m4/intlmacosx.m4]) -m4_include([m4/lib-ld.m4]) -m4_include([m4/lib-link.m4]) -m4_include([m4/lib-prefix.m4]) -m4_include([m4/nls.m4]) -m4_include([m4/po.m4]) -m4_include([m4/progtest.m4]) diff --git a/rpcsvc-proto-1.4.2/compile b/rpcsvc-proto-1.4.2/compile deleted file mode 100755 index 2ab71e4..0000000 --- a/rpcsvc-proto-1.4.2/compile +++ /dev/null @@ -1,348 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand '-c -o'. - -scriptversion=2016-01-11.22; # UTC - -# Copyright (C) 1999-2017 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -nl=' -' - -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent tools from complaining about whitespace usage. -IFS=" "" $nl" - -file_conv= - -# func_file_conv build_file lazy -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. If the determined conversion -# type is listed in (the comma separated) LAZY, no conversion will -# take place. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv/,$2, in - *,$file_conv,*) - ;; - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_cl_dashL linkdir -# Make cl look for libraries in LINKDIR -func_cl_dashL () -{ - func_file_conv "$1" - if test -z "$lib_path"; then - lib_path=$file - else - lib_path="$lib_path;$file" - fi - linker_opts="$linker_opts -LIBPATH:$file" -} - -# func_cl_dashl library -# Do a library search-path lookup for cl -func_cl_dashl () -{ - lib=$1 - found=no - save_IFS=$IFS - IFS=';' - for dir in $lib_path $LIB - do - IFS=$save_IFS - if $shared && test -f "$dir/$lib.dll.lib"; then - found=yes - lib=$dir/$lib.dll.lib - break - fi - if test -f "$dir/$lib.lib"; then - found=yes - lib=$dir/$lib.lib - break - fi - if test -f "$dir/lib$lib.a"; then - found=yes - lib=$dir/lib$lib.a - break - fi - done - IFS=$save_IFS - - if test "$found" != yes; then - lib=$lib.lib - fi -} - -# func_cl_wrapper cl arg... -# Adjust compile command to suit cl -func_cl_wrapper () -{ - # Assume a capable shell - lib_path= - shared=: - linker_opts= - for arg - do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - eat=1 - case $2 in - *.o | *.[oO][bB][jJ]) - func_file_conv "$2" - set x "$@" -Fo"$file" - shift - ;; - *) - func_file_conv "$2" - set x "$@" -Fe"$file" - shift - ;; - esac - ;; - -I) - eat=1 - func_file_conv "$2" mingw - set x "$@" -I"$file" - shift - ;; - -I*) - func_file_conv "${1#-I}" mingw - set x "$@" -I"$file" - shift - ;; - -l) - eat=1 - func_cl_dashl "$2" - set x "$@" "$lib" - shift - ;; - -l*) - func_cl_dashl "${1#-l}" - set x "$@" "$lib" - shift - ;; - -L) - eat=1 - func_cl_dashL "$2" - ;; - -L*) - func_cl_dashL "${1#-L}" - ;; - -static) - shared=false - ;; - -Wl,*) - arg=${1#-Wl,} - save_ifs="$IFS"; IFS=',' - for flag in $arg; do - IFS="$save_ifs" - linker_opts="$linker_opts $flag" - done - IFS="$save_ifs" - ;; - -Xlinker) - eat=1 - linker_opts="$linker_opts $2" - ;; - -*) - set x "$@" "$1" - shift - ;; - *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) - func_file_conv "$1" - set x "$@" -Tp"$file" - shift - ;; - *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) - func_file_conv "$1" mingw - set x "$@" "$file" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift - done - if test -n "$linker_opts"; then - linker_opts="-link$linker_opts" - fi - exec "$@" $linker_opts - exit 1 -} - -eat= - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand '-c -o'. -Remove '-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file 'INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ - icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) - func_cl_wrapper "$@" # Doesn't return... - ;; -esac - -ofile= -cfile= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - # So we strip '-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no '-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # '.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` - -# Create the lock directory. -# Note: use '[/\\:.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - test "$cofile" = "$ofile" || mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/rpcsvc-proto-1.4.2/config.guess b/rpcsvc-proto-1.4.2/config.guess deleted file mode 100755 index 1bf683d..0000000 --- a/rpcsvc-proto-1.4.2/config.guess +++ /dev/null @@ -1,1483 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. - -timestamp='2017-05-27' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess -# -# Please send patches to . - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` - ;; -esac - -case "${UNAME_MACHINE}" in - i?86) - test -z "$VENDOR" && VENDOR=pc - ;; - *) - test -z "$VENDOR" && VENDOR=unknown - ;; -esac -test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ - echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-${VENDOR}-unknown - ;; - *) machine=${UNAME_MACHINE_ARCH}-${VENDOR}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in - earm*) - os=netbsdelf - ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in - earm*) - expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-openbsd${UNAME_RELEASE} - exit ;; - *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-libertybsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-${VENDOR}-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-mirbsd${UNAME_RELEASE} - exit ;; - *:Sortix:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-sortix - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE=alpha ;; - "EV4.5 (21064)") - UNAME_MACHINE=alpha ;; - "LCA4 (21066/21068)") - UNAME_MACHINE=alpha ;; - "EV5 (21164)") - UNAME_MACHINE=alphaev5 ;; - "EV5.6 (21164A)") - UNAME_MACHINE=alphaev56 ;; - "EV5.6 (21164PC)") - UNAME_MACHINE=alphapca56 ;; - "EV5.7 (21164PC)") - UNAME_MACHINE=alphapca57 ;; - "EV6 (21264)") - UNAME_MACHINE=alphaev6 ;; - "EV6.7 (21264A)") - UNAME_MACHINE=alphaev67 ;; - "EV6.8CB (21264C)") - UNAME_MACHINE=alphaev68 ;; - "EV6.8AL (21264B)") - UNAME_MACHINE=alphaev68 ;; - "EV6.8CX (21264D)") - UNAME_MACHINE=alphaev68 ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE=alphaev69 ;; - "EV7 (21364)") - UNAME_MACHINE=alphaev7 ;; - "EV7.9 (21364A)") - UNAME_MACHINE=alphaev79 ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-${VENDOR}-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-${VENDOR}-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH=i386 - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH=x86_64 - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-${VENDOR}-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 - 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH=hppa2.0n ;; - 64) HP_ARCH=hppa2.0w ;; - '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = hppa2.0w ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH=hppa2.0w - else - HP_ARCH=hppa64 - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-${VENDOR}-osf1mk - else - echo ${UNAME_MACHINE}-${VENDOR}-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-${VENDOR}-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - UNAME_PROCESSOR=x86_64 ;; - i386) - UNAME_PROCESSOR=i586 ;; - esac - echo ${UNAME_PROCESSOR}-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-${VENDOR}-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-${VENDOR}-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-${VENDOR}-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-${VENDOR}-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-${VENDOR}-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-${VENDOR}-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-${VENDOR}-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - e2k:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - k1om:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-${VENDOR}-linux-${LIBC}"; exit; } - ;; - mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - openrisc*:Linux:*:*) - echo or1k-${VENDOR}-linux-${LIBC} - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-${VENDOR}-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-${VENDOR}-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-${VENDOR}-linux-${LIBC} ;; - PA8*) echo hppa2.0-${VENDOR}-linux-${LIBC} ;; - *) echo hppa-${VENDOR}-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-${VENDOR}-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-${VENDOR}-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-${VENDOR}-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-${VENDOR}-linux-${LIBC} - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-${VENDOR}-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-${VENODR}-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configure will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-${VENODR}-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-${VENDOR}-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-${VENDOR}-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = x86; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = 386; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-${VENDOR}-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-${VENDOR}-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-${VENDOR}-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-${VENDOR}-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-${VENDOR}-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-esx - exit ;; - amd64:Isilon\ OneFS:*:*) - echo x86_64-${VENDOR}-onefs - exit ;; -esac - -cat >&2 </dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/rpcsvc-proto-1.4.2/config.h.in b/rpcsvc-proto-1.4.2/config.h.in deleted file mode 100644 index 770bab5..0000000 --- a/rpcsvc-proto-1.4.2/config.h.in +++ /dev/null @@ -1,109 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#undef ENABLE_NLS - -/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -#undef HAVE_CFLOCALECOPYCURRENT - -/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -#undef HAVE_CFPREFERENCESCOPYAPPVALUE - -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -#undef HAVE_DCGETTEXT - -/* Define if the GNU gettext() function is already present or preinstalled. */ -#undef HAVE_GETTEXT - -/* Define if you have the iconv() function and it works. */ -#undef HAVE_ICONV - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Version number of package */ -#undef VERSION - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE diff --git a/rpcsvc-proto-1.4.2/config.rpath b/rpcsvc-proto-1.4.2/config.rpath deleted file mode 100755 index 98183ff..0000000 --- a/rpcsvc-proto-1.4.2/config.rpath +++ /dev/null @@ -1,684 +0,0 @@ -#! /bin/sh -# Output a system dependent set of variables, describing how to set the -# run time search path of shared libraries in an executable. -# -# Copyright 1996-2016 Free Software Foundation, Inc. -# Taken from GNU libtool, 2001 -# Originally by Gordon Matzigkeit , 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld -# should be set by the caller. -# -# The set of defined variables is at the end of this script. - -# Known limitations: -# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer -# than 256 bytes, otherwise the compiler driver will dump core. The only -# known workaround is to choose shorter directory names for the build -# directory and/or the installation directory. - -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -shrext=.so - -host="$1" -host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -# Code taken from libtool.m4's _LT_CC_BASENAME. - -for cc_temp in $CC""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` - -# Code taken from libtool.m4's _LT_COMPILER_PIC. - -wl= -if test "$GCC" = yes; then - wl='-Wl,' -else - case "$host_os" in - aix*) - wl='-Wl,' - ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) - ;; - hpux9* | hpux10* | hpux11*) - wl='-Wl,' - ;; - irix5* | irix6* | nonstopux*) - wl='-Wl,' - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - ecc*) - wl='-Wl,' - ;; - icc* | ifort*) - wl='-Wl,' - ;; - lf95*) - wl='-Wl,' - ;; - nagfor*) - wl='-Wl,-Wl,,' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - wl='-Wl,' - ;; - ccc*) - wl='-Wl,' - ;; - xl* | bgxl* | bgf* | mpixl*) - wl='-Wl,' - ;; - como) - wl='-lopt=' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) - wl= - ;; - *Sun\ C*) - wl='-Wl,' - ;; - esac - ;; - esac - ;; - newsos6) - ;; - *nto* | *qnx*) - ;; - osf3* | osf4* | osf5*) - wl='-Wl,' - ;; - rdos*) - ;; - solaris*) - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - wl='-Qoption ld ' - ;; - *) - wl='-Wl,' - ;; - esac - ;; - sunos4*) - wl='-Qoption ld ' - ;; - sysv4 | sysv4.2uw2* | sysv4.3*) - wl='-Wl,' - ;; - sysv4*MP*) - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - wl='-Wl,' - ;; - unicos*) - wl='-Wl,' - ;; - uts4*) - ;; - esac -fi - -# Code taken from libtool.m4's _LT_LINKER_SHLIBS. - -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no - -case "$host_os" in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - # Unlike libtool, we use -rpath here, not --rpath, since the documented - # option of GNU ld is called -rpath, not --rpath. - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - case "$host_os" in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - fi - ;; - amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - cygwin* | mingw* | pw32* | cegcc*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - haiku*) - ;; - interix[3-9]*) - hardcode_direct=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - netbsd*) - ;; - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - else - ld_shlibs=no - fi - ;; - esac - ;; - sunos4*) - hardcode_direct=yes - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - esac - if test "$ld_shlibs" = no; then - hardcode_libdir_flag_spec= - fi -else - case "$host_os" in - aix3*) - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - else - aix_use_runtimelinking=no - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - fi - hardcode_direct=yes - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - fi - # Begin _LT_AC_SYS_LIBPATH_AIX. - echo 'int main () { return 0; }' > conftest.c - ${CC} ${LDFLAGS} conftest.c -o conftest - aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - fi - if test -z "$aix_libpath"; then - aix_libpath="/usr/lib:/lib" - fi - rm -f conftest.c conftest - # End _LT_AC_SYS_LIBPATH_AIX. - if test "$aix_use_runtimelinking" = yes; then - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - else - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - fi - fi - ;; - amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - bsdi[45]*) - ;; - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - libext=lib - ;; - darwin* | rhapsody*) - hardcode_direct=no - if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then - : - else - ld_shlibs=no - fi - ;; - dgux*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - freebsd2.[01]*) - hardcode_direct=yes - hardcode_minus_L=yes - ;; - freebsd* | dragonfly*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - hpux9*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - hpux10*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - hpux11*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - ;; - *) - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - irix5* | irix6* | nonstopux*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - netbsd*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - newsos6) - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - *nto* | *qnx*) - ;; - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - osf3*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - osf4* | osf5*) - if test "$GCC" = yes; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - # Both cc and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - solaris*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - sunos4*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - sysv4) - case $host_vendor in - sni) - hardcode_direct=yes # is this really true??? - ;; - siemens) - hardcode_direct=no - ;; - motorola) - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - ;; - sysv4.3*) - ;; - sysv4*MP*) - if test -d /usr/nec; then - ld_shlibs=yes - fi - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - ;; - sysv5* | sco3.2v5* | sco5v6*) - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator=':' - ;; - uts4*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - *) - ld_shlibs=no - ;; - esac -fi - -# Check dynamic linker characteristics -# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. -# Unlike libtool.m4, here we don't care about _all_ names of the library, but -# only about the one the linker finds when passed -lNAME. This is the last -# element of library_names_spec in libtool.m4, or possibly two of them if the -# linker has special search rules. -library_names_spec= # the last element of library_names_spec in libtool.m4 -libname_spec='lib$name' -case "$host_os" in - aix3*) - library_names_spec='$libname.a' - ;; - aix[4-9]*) - library_names_spec='$libname$shrext' - ;; - amigaos*) - case "$host_cpu" in - powerpc*) - library_names_spec='$libname$shrext' ;; - m68k) - library_names_spec='$libname.a' ;; - esac - ;; - beos*) - library_names_spec='$libname$shrext' - ;; - bsdi[45]*) - library_names_spec='$libname$shrext' - ;; - cygwin* | mingw* | pw32* | cegcc*) - shrext=.dll - library_names_spec='$libname.dll.a $libname.lib' - ;; - darwin* | rhapsody*) - shrext=.dylib - library_names_spec='$libname$shrext' - ;; - dgux*) - library_names_spec='$libname$shrext' - ;; - freebsd[23].*) - library_names_spec='$libname$shrext$versuffix' - ;; - freebsd* | dragonfly*) - library_names_spec='$libname$shrext' - ;; - gnu*) - library_names_spec='$libname$shrext' - ;; - haiku*) - library_names_spec='$libname$shrext' - ;; - hpux9* | hpux10* | hpux11*) - case $host_cpu in - ia64*) - shrext=.so - ;; - hppa*64*) - shrext=.sl - ;; - *) - shrext=.sl - ;; - esac - library_names_spec='$libname$shrext' - ;; - interix[3-9]*) - library_names_spec='$libname$shrext' - ;; - irix5* | irix6* | nonstopux*) - library_names_spec='$libname$shrext' - case "$host_os" in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; - *) libsuff= shlibsuff= ;; - esac - ;; - esac - ;; - linux*oldld* | linux*aout* | linux*coff*) - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - library_names_spec='$libname$shrext' - ;; - knetbsd*-gnu) - library_names_spec='$libname$shrext' - ;; - netbsd*) - library_names_spec='$libname$shrext' - ;; - newsos6) - library_names_spec='$libname$shrext' - ;; - *nto* | *qnx*) - library_names_spec='$libname$shrext' - ;; - openbsd*) - library_names_spec='$libname$shrext$versuffix' - ;; - os2*) - libname_spec='$name' - shrext=.dll - library_names_spec='$libname.a' - ;; - osf3* | osf4* | osf5*) - library_names_spec='$libname$shrext' - ;; - rdos*) - ;; - solaris*) - library_names_spec='$libname$shrext' - ;; - sunos4*) - library_names_spec='$libname$shrext$versuffix' - ;; - sysv4 | sysv4.3*) - library_names_spec='$libname$shrext' - ;; - sysv4*MP*) - library_names_spec='$libname$shrext' - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - library_names_spec='$libname$shrext' - ;; - tpf*) - library_names_spec='$libname$shrext' - ;; - uts4*) - library_names_spec='$libname$shrext' - ;; -esac - -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' -escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` -shlibext=`echo "$shrext" | sed -e 's,^\.,,'` -escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` -escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` -escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` - -LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2017 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390) - basic_machine=s390-ibm - ;; - s390-*) - basic_machine=s390-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - s390x) - basic_machine=s390x-ibm - ;; - s390x-*) - basic_machine=s390x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - wasm32) - basic_machine=wasm32-unknown - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -ios) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - pru-*) - os=-elf - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/rpcsvc-proto-1.4.2/configure b/rpcsvc-proto-1.4.2/configure deleted file mode 100755 index 1934dcb..0000000 --- a/rpcsvc-proto-1.4.2/configure +++ /dev/null @@ -1,8277 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for rpcsvc-proto 1.4.2. -# -# Report bugs to . -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and kukuk@thkukuk.de -$0: about your system, including any error possibly output -$0: before this message. Then install a modern shell, or -$0: manually run the script under such a shell if you do -$0: have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='rpcsvc-proto' -PACKAGE_TARNAME='rpcsvc-proto' -PACKAGE_VERSION='1.4.2' -PACKAGE_STRING='rpcsvc-proto 1.4.2' -PACKAGE_BUGREPORT='kukuk@thkukuk.de' -PACKAGE_URL='' - -ac_unique_file="rpcgen/rpc_main.c" -ac_default_prefix=/usr -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -gt_needs= -ac_subst_vars='am__EXEEXT_FALSE -am__EXEEXT_TRUE -LTLIBOBJS -LIBOBJS -POSUB -LTLIBINTL -LIBINTL -INTLLIBS -LTLIBICONV -LIBICONV -INTL_MACOSX_LIBS -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -XGETTEXT_EXTRA_OPTIONS -MSGMERGE -XGETTEXT_015 -XGETTEXT -GMSGFMT_015 -MSGFMT_015 -GMSGFMT -MSGFMT -GETTEXT_MACRO_VERSION -USE_NLS -SED -EGREP -GREP -CPP -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -am__nodep -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -AM_BACKSLASH -AM_DEFAULT_VERBOSITY -AM_DEFAULT_V -AM_V -am__untar -am__tar -AMTAR -am__leading_dot -SET_MAKE -AWK -mkdir_p -MKDIR_P -INSTALL_STRIP_PROGRAM -STRIP -install_sh -MAKEINFO -AUTOHEADER -AUTOMAKE -AUTOCONF -ACLOCAL -VERSION -PACKAGE -CYGPATH_W -am__isrc -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_silent_rules -enable_dependency_tracking -enable_nls -with_gnu_ld -enable_rpath -with_libiconv_prefix -with_libintl_prefix -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures rpcsvc-proto 1.4.2 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/rpcsvc-proto] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of rpcsvc-proto 1.4.2:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-silent-rules less verbose build output (undo: "make V=1") - --disable-silent-rules verbose build output (undo: "make V=0") - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build - --disable-nls do not use Native Language Support - --disable-rpath do not hardcode runtime library paths - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib - --without-libiconv-prefix don't search for libiconv in includedir and libdir - --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib - --without-libintl-prefix don't search for libintl in includedir and libdir - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -rpcsvc-proto configure 1.4.2 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( $as_echo "## ------------------------------- ## -## Report this to kukuk@thkukuk.de ## -## ------------------------------- ##" - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by rpcsvc-proto $as_me 1.4.2, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -gt_needs="$gt_needs " -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -am__api_version='1.15' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='rpcsvc-proto' - VERSION='1.4.2' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. -# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AMTAR='$${TAR-tar}' - - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar pax cpio none' - -am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' - - - - - - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi - - -ac_config_headers="$ac_config_headers config.h" - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = xyes; then : - MINIX=yes -else - MINIX= -fi - - - if test "$MINIX" = yes; then - -$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h - - -$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h - - -$as_echo "#define _MINIX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if ${ac_cv_safe_to_define___extensions__+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_safe_to_define___extensions__=yes -else - ac_cv_safe_to_define___extensions__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h - - $as_echo "#define _ALL_SOURCE 1" >>confdefs.h - - $as_echo "#define _GNU_SOURCE 1" >>confdefs.h - - $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h - - $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 -$as_echo_n "checking for library containing strerror... " >&6; } -if ${ac_cv_search_strerror+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char strerror (); -int -main () -{ -return strerror (); - ; - return 0; -} -_ACEOF -for ac_lib in '' cposix; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_strerror=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_strerror+:} false; then : - break -fi -done -if ${ac_cv_search_strerror+:} false; then : - -else - ac_cv_search_strerror=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 -$as_echo "$ac_cv_search_strerror" >&6; } -ac_res=$ac_cv_search_strerror -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 -$as_echo_n "checking whether NLS is requested... " >&6; } - # Check whether --enable-nls was given. -if test "${enable_nls+set}" = set; then : - enableval=$enable_nls; USE_NLS=$enableval -else - USE_NLS=yes -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 -$as_echo "$USE_NLS" >&6; } - - - - - GETTEXT_MACRO_VERSION=0.19 - - - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "msgfmt", so it can be a program name with args. -set dummy msgfmt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MSGFMT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$MSGFMT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" - ;; -esac -fi -MSGFMT="$ac_cv_path_MSGFMT" -if test "$MSGFMT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 -$as_echo "$MSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - # Extract the first word of "gmsgfmt", so it can be a program name with args. -set dummy gmsgfmt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_GMSGFMT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $GMSGFMT in - [\\/]* | ?:[\\/]*) - ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" - ;; -esac -fi -GMSGFMT=$ac_cv_path_GMSGFMT -if test -n "$GMSGFMT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 -$as_echo "$GMSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac - - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; - *) GMSGFMT_015=$GMSGFMT ;; - esac - - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "xgettext", so it can be a program name with args. -set dummy xgettext; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XGETTEXT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$XGETTEXT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" - ;; -esac -fi -XGETTEXT="$ac_cv_path_XGETTEXT" -if test "$XGETTEXT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 -$as_echo "$XGETTEXT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - rm -f messages.po - - case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; - *) XGETTEXT_015=$XGETTEXT ;; - esac - - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "msgmerge", so it can be a program name with args. -set dummy msgmerge; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MSGMERGE+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$MSGMERGE" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then - ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" - ;; -esac -fi -MSGMERGE="$ac_cv_path_MSGMERGE" -if test "$MSGMERGE" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 -$as_echo "$MSGMERGE" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$localedir" || localedir='${datadir}/locale' - - - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - - - ac_config_commands="$ac_config_commands po-directories" - - - - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${acl_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${acl_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$acl_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$acl_cv_prog_gnu_ld - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 -$as_echo_n "checking for shared library run path origin... " >&6; } -if ${acl_cv_rpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 -$as_echo "$acl_cv_rpath" >&6; } - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - # Check whether --enable-rpath was given. -if test "${enable_rpath+set}" = set; then : - enableval=$enable_rpath; : -else - enable_rpath=yes -fi - - - - - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 -$as_echo_n "checking for 64-bit host... " >&6; } -if ${gl_cv_solaris_64bit+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef _LP64 -sixtyfour bits -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "sixtyfour bits" >/dev/null 2>&1; then : - gl_cv_solaris_64bit=yes -else - gl_cv_solaris_64bit=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 -$as_echo "$gl_cv_solaris_64bit" >&6; } - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" - - - - - - - - - - - - - use_additional=yes - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - -# Check whether --with-libiconv-prefix was given. -if test "${with_libiconv_prefix+set}" = set; then : - withval=$with_libiconv_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi - -fi - - LIBICONV= - LTLIBICONV= - INCICONV= - LIBICONV_PREFIX= - HAVE_LIBICONV= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='iconv ' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" - else - : - fi - else - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - if test "$acl_hardcode_direct" = yes; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - haveit= - for x in $LDFLAGS $LIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" - fi - fi - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INCICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - if test -n "$found_la"; then - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" - ;; - esac - done - fi - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" - else - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - for found_dir in $ltrpathdirs; do - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" - done - fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 -$as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } -if ${gt_cv_func_CFPreferencesCopyAppValue+:} false; then : - $as_echo_n "(cached) " >&6 -else - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -CFPreferencesCopyAppValue(NULL, NULL) - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - gt_cv_func_CFPreferencesCopyAppValue=yes -else - gt_cv_func_CFPreferencesCopyAppValue=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 -$as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - -$as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 -$as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } -if ${gt_cv_func_CFLocaleCopyCurrent+:} false; then : - $as_echo_n "(cached) " >&6 -else - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -CFLocaleCopyCurrent(); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - gt_cv_func_CFLocaleCopyCurrent=yes -else - gt_cv_func_CFLocaleCopyCurrent=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -$as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - -$as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h - - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - - - - - - - LIBINTL= - LTLIBINTL= - POSUB= - - case " $gt_needs " in - *" need-formatstring-macros "*) gt_api_version=3 ;; - *" need-ngettext "*) gt_api_version=2 ;; - *) gt_api_version=1 ;; - esac - gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" - gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" - - if test "$USE_NLS" = "yes"; then - gt_use_preinstalled_gnugettext=no - - - if test $gt_api_version -ge 3; then - gt_revision_test_code=' -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -#endif -typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -' - else - gt_revision_test_code= - fi - if test $gt_api_version -ge 2; then - gt_expression_test_code=' + * ngettext ("", "", 0)' - else - gt_expression_test_code= - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 -$as_echo_n "checking for GNU gettext in libc... " >&6; } -if eval \${$gt_func_gnugettext_libc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings; -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - -int -main () -{ - -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$gt_func_gnugettext_libc=yes" -else - eval "$gt_func_gnugettext_libc=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$gt_func_gnugettext_libc - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - - - - - - am_save_CPPFLAGS="$CPPFLAGS" - - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 -$as_echo_n "checking for iconv... " >&6; } -if ${am_cv_func_iconv+:} false; then : - $as_echo_n "(cached) " >&6 -else - - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_func_iconv=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_lib_iconv=yes - am_cv_func_iconv=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$am_save_LIBS" - fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 -$as_echo "$am_cv_func_iconv" >&6; } - if test "$am_cv_func_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 -$as_echo_n "checking for working iconv... " >&6; } -if ${am_cv_func_iconv_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - am_cv_func_iconv_works=no - for ac_iconv_const in '' 'const'; do - if test "$cross_compiling" = yes; then : - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -#ifndef ICONV_CONST -# define ICONV_CONST $ac_iconv_const -#endif - -int -main () -{ -int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\263"; - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - ICONV_CONST char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - am_cv_func_iconv_works=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - test "$am_cv_func_iconv_works" = no || break - done - LIBS="$am_save_LIBS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 -$as_echo "$am_cv_func_iconv_works" >&6; } - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - -$as_echo "#define HAVE_ICONV 1" >>confdefs.h - - fi - if test "$am_cv_lib_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 -$as_echo_n "checking how to link with libiconv... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 -$as_echo "$LIBICONV" >&6; } - else - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi - - - - - - - - - - - - use_additional=yes - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - -# Check whether --with-libintl-prefix was given. -if test "${with_libintl_prefix+set}" = set; then : - withval=$with_libintl_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi - -fi - - LIBINTL= - LTLIBINTL= - INCINTL= - LIBINTL_PREFIX= - HAVE_LIBINTL= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='intl ' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" - else - : - fi - else - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBINTL; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - if test "$acl_hardcode_direct" = yes; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - haveit= - for x in $LDFLAGS $LIBINTL; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" - fi - fi - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'intl'; then - LIBINTL_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'intl'; then - LIBINTL_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INCINTL; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - if test -n "$found_la"; then - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIBINTL; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIBINTL; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" - ;; - esac - done - fi - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" - else - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - for found_dir in $ltrpathdirs; do - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" - done - fi - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 -$as_echo_n "checking for GNU gettext in libintl... " >&6; } -if eval \${$gt_func_gnugettext_libintl+:} false; then : - $as_echo_n "(cached) " >&6 -else - gt_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $INCINTL" - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - -int -main () -{ - -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$gt_func_gnugettext_libintl=yes" -else - eval "$gt_func_gnugettext_libintl=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - -int -main () -{ - -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS" -fi -eval ac_res=\$$gt_func_gnugettext_libintl - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - fi - - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ - || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ - && test "$PACKAGE" != gettext-runtime \ - && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes - else - LIBINTL= - LTLIBINTL= - INCINTL= - fi - - - - if test -n "$INTL_MACOSX_LIBS"; then - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" - LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" - fi - fi - - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - -$as_echo "#define ENABLE_NLS 1" >>confdefs.h - - else - USE_NLS=no - fi - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 -$as_echo_n "checking whether to use NLS... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 -$as_echo "$USE_NLS" >&6; } - if test "$USE_NLS" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 -$as_echo_n "checking where the gettext function comes from... " >&6; } - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - gt_source="external libintl" - else - gt_source="libc" - fi - else - gt_source="included intl directory" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 -$as_echo "$gt_source" >&6; } - fi - - if test "$USE_NLS" = "yes"; then - - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 -$as_echo_n "checking how to link with libintl... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 -$as_echo "$LIBINTL" >&6; } - - for element in $INCINTL; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - fi - - -$as_echo "#define HAVE_GETTEXT 1" >>confdefs.h - - -$as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h - - fi - - POSUB=po - fi - - - - INTLLIBS="$LIBINTL" - - - - - - - - - - -ac_config_files="$ac_config_files Makefile rpcgen/Makefile rpcsvc/Makefile po/Makefile.in" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error $? "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by rpcsvc-proto $as_me 1.4.2, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -rpcsvc-proto config.status 1.4.2 -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" -# Capture the value of obsolete ALL_LINGUAS because we need it to compute - # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it - # from automake < 1.5. - eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "rpcgen/Makefile") CONFIG_FILES="$CONFIG_FILES rpcgen/Makefile" ;; - "rpcsvc/Makefile") CONFIG_FILES="$CONFIG_FILES rpcsvc/Makefile" ;; - "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi -# Compute "$ac_file"'s index in $config_headers. -_am_arg="$ac_file" -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || -$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$_am_arg" : 'X\(//\)[^/]' \| \ - X"$_am_arg" : 'X\(//\)$' \| \ - X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$_am_arg" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'`/stamp-h$_am_stamp_count - ;; - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Older Autoconf quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} - ;; - "po-directories":C) - for ac_file in $CONFIG_FILES; do - # Support "outfile[:infile[:infile...]]" - case "$ac_file" in - *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - esac - # PO directories have a Makefile.in generated from Makefile.in.in. - case "$ac_file" in */Makefile.in) - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - # Treat a directory as a PO directory if and only if it has a - # POTFILES.in file. This allows packages to have multiple PO - # directories under different names or in different locations. - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - gt_tab=`printf '\t'` - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" - POMAKEFILEDEPS="POTFILES.in" - # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. - if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" - fi - ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' - POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" - else - # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi - # Compute POFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) - # Compute UPDATEPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) - # Compute DUMMYPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) - # Compute GMOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= - UPDATEPOFILES= - DUMMYPOFILES= - GMOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" - GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. - INST_LINGUAS= - if test -n "$ALL_LINGUAS"; then - for presentlang in $ALL_LINGUAS; do - useit=no - if test "%UNSET%" != "$LINGUAS"; then - desiredlanguages="$LINGUAS" - else - desiredlanguages="$ALL_LINGUAS" - fi - for desiredlang in $desiredlanguages; do - # Use the presentlang catalog if desiredlang is - # a. equal to presentlang, or - # b. a variant of presentlang (because in this case, - # presentlang can be used as a fallback for messages - # which are not translated in the desiredlang catalog). - case "$desiredlang" in - "$presentlang"*) useit=yes;; - esac - done - if test $useit = yes; then - INST_LINGUAS="$INST_LINGUAS $presentlang" - fi - done - fi - CATALOGS= - if test -n "$INST_LINGUAS"; then - for lang in $INST_LINGUAS; do - CATALOGS="$CATALOGS $lang.gmo" - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" - sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in - *.orig | *.bak | *~) ;; - *) cat "$f" >> "$ac_dir/Makefile" ;; - esac - fi - done - fi - ;; - esac - done ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/rpcsvc-proto-1.4.2/configure.ac b/rpcsvc-proto-1.4.2/configure.ac deleted file mode 100644 index 0352b34..0000000 --- a/rpcsvc-proto-1.4.2/configure.ac +++ /dev/null @@ -1,25 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(rpcsvc-proto, 1.4.2, kukuk@thkukuk.de) -AM_INIT_AUTOMAKE -AC_CONFIG_SRCDIR([rpcgen/rpc_main.c]) -AM_CONFIG_HEADER(config.h) -AC_PREFIX_DEFAULT(/usr) - -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) - -AC_PROG_CC -AC_GNU_SOURCE -AM_PROG_CC_C_O -AC_PROG_CPP -AC_ISC_POSIX -AC_PROG_INSTALL -AC_PROG_MAKE_SET - -AM_GNU_GETTEXT([external]) -m4_ifndef([AM_GNU_GETTEXT_REQUIRE_VERSION], - [m4_define([AM_GNU_GETTEXT_REQUIRE_VERSION], [])]) -AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8]) -AM_GNU_GETTEXT_VERSION([0.19.8]) - -AC_OUTPUT([Makefile rpcgen/Makefile rpcsvc/Makefile po/Makefile.in]) diff --git a/rpcsvc-proto-1.4.2/depcomp b/rpcsvc-proto-1.4.2/depcomp deleted file mode 100755 index b39f98f..0000000 --- a/rpcsvc-proto-1.4.2/depcomp +++ /dev/null @@ -1,791 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2016-01-11.22; # UTC - -# Copyright (C) 1999-2017 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by 'PROGRAMS ARGS'. - object Object file output by 'PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -# Get the directory component of the given path, and save it in the -# global variables '$dir'. Note that this directory component will -# be either empty or ending with a '/' character. This is deliberate. -set_dir_from () -{ - case $1 in - */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; - *) dir=;; - esac -} - -# Get the suffix-stripped basename of the given path, and save it the -# global variable '$base'. -set_base_from () -{ - base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` -} - -# If no dependency file was actually created by the compiler invocation, -# we still have to create a dummy depfile, to avoid errors with the -# Makefile "include basename.Plo" scheme. -make_dummy_depfile () -{ - echo "#dummy" > "$depfile" -} - -# Factor out some common post-processing of the generated depfile. -# Requires the auxiliary global variable '$tmpdepfile' to be set. -aix_post_process_depfile () -{ - # If the compiler actually managed to produce a dependency file, - # post-process it. - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependency.h'. - # Do two passes, one to just change these to - # $object: dependency.h - # and one to simply output - # dependency.h: - # which is needed to avoid the deleted-header problem. - { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" - sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" - } > "$depfile" - rm -f "$tmpdepfile" - else - make_dummy_depfile - fi -} - -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' -# Character ranges might be problematic outside the C locale. -# These definitions help. -upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ -lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 -alpha=${upper}${lower} - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Avoid interferences from the environment. -gccflag= dashmflag= - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. - gccflag=-qmakedep=gcc,-MF - depmode=gcc -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. -## (see the conditional assignment to $gccflag above). -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). Also, it might not be -## supported by the other compilers which use the 'gcc' depmode. -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The second -e expression handles DOS-style file names with drive - # letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the "deleted header file" problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. -## Some versions of gcc put a space before the ':'. On the theory -## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like '#:fec' to the end of the - # dependency line. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ - | tr "$nl" ' ' >> "$depfile" - echo >> "$depfile" - # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" - ;; - -xlc) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts '$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - aix_post_process_depfile - ;; - -tcc) - # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 - # FIXME: That version still under development at the moment of writing. - # Make that this statement remains true also for stable, released - # versions. - # It will wrap lines (doesn't matter whether long or short) with a - # trailing '\', as in: - # - # foo.o : \ - # foo.c \ - # foo.h \ - # - # It will put a trailing '\' even on the last line, and will use leading - # spaces rather than leading tabs (at least since its commit 0394caf7 - # "Emit spaces for -MD"). - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. - # We have to change lines of the first kind to '$object: \'. - sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" - # And for each line of the second kind, we have to emit a 'dep.h:' - # dummy dependency, to avoid the deleted-header problem. - sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -## The order of this option in the case statement is important, since the -## shell code in configure will try each of these formats in the order -## listed in this file. A plain '-MD' option would be understood by many -## compilers, so we must ensure this comes after the gcc and icc options. -pgcc) - # Portland's C compiler understands '-MD'. - # Will always output deps to 'file.d' where file is the root name of the - # source file under compilation, even if file resides in a subdirectory. - # The object file name does not affect the name of the '.d' file. - # pgcc 10.2 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\' : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - set_dir_from "$object" - # Use the source, not the object, to determine the base name, since - # that's sadly what pgcc will do too. - set_base_from "$source" - tmpdepfile=$base.d - - # For projects that build the same source file twice into different object - # files, the pgcc approach of using the *source* file root name can cause - # problems in parallel builds. Use a locking strategy to avoid stomping on - # the same $tmpdepfile. - lockdir=$base.d-lock - trap " - echo '$0: caught signal, cleaning up...' >&2 - rmdir '$lockdir' - exit 1 - " 1 2 13 15 - numtries=100 - i=$numtries - while test $i -gt 0; do - # mkdir is a portable test-and-set. - if mkdir "$lockdir" 2>/dev/null; then - # This process acquired the lock. - "$@" -MD - stat=$? - # Release the lock. - rmdir "$lockdir" - break - else - # If the lock is being held by a different process, wait - # until the winning process is done or we timeout. - while test -d "$lockdir" && test $i -gt 0; do - sleep 1 - i=`expr $i - 1` - done - fi - i=`expr $i - 1` - done - trap - 1 2 13 15 - if test $i -le 0; then - echo "$0: failed to acquire lock after $numtries attempts" >&2 - echo "$0: check lockdir '$lockdir'" >&2 - exit 1 - fi - - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in 'foo.d' instead, so we check for that too. - # Subdirectories are respected. - set_dir_from "$object" - set_base_from "$object" - - if test "$libtool" = yes; then - # Libtool generates 2 separate objects for the 2 libraries. These - # two compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir$base.o.d # libtool 1.5 - tmpdepfile2=$dir.libs/$base.o.d # Likewise. - tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - # Same post-processing that is required for AIX mode. - aix_post_process_depfile - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - echo >> "$depfile" # make sure the fragment doesn't end with a backslash - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for ':' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. - "$@" $dashmflag | - sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this sed invocation - # correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix=`echo "$object" | sed 's/^.*\././'` - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process the last invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed '1,2d' "$tmpdepfile" \ - | tr ' ' "$nl" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E \ - | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - | sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/rpcsvc-proto-1.4.2/install-sh b/rpcsvc-proto-1.4.2/install-sh deleted file mode 100755 index 0360b79..0000000 --- a/rpcsvc-proto-1.4.2/install-sh +++ /dev/null @@ -1,501 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2016-01-11.22; # UTC - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# 'make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -tab=' ' -nl=' -' -IFS=" $tab$nl" - -# Set DOITPROG to "echo" to test this script. - -doit=${DOITPROG-} -doit_exec=${doit:-exec} - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -is_target_a_directory=possibly - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) - is_target_a_directory=always - dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) is_target_a_directory=never;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -# We allow the use of options -d and -T together, by making -d -# take the precedence; this is for compatibility with GNU install. - -if test -n "$dir_arg"; then - if test -n "$dst_arg"; then - echo "$0: target directory not allowed when installing a directory." >&2 - exit 1 - fi -fi - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call 'install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - if test $# -gt 1 || test "$is_target_a_directory" = always; then - if test ! -d "$dst_arg"; then - echo "$0: $dst_arg: Is not a directory." >&2 - exit 1 - fi - fi -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for 'test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test "$is_target_a_directory" = never; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - dstdir=`dirname "$dst"` - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - oIFS=$IFS - IFS=/ - set -f - set fnord $dstdir - shift - set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - set +f && - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/rpcsvc-proto-1.4.2/m4/gettext.m4 b/rpcsvc-proto-1.4.2/m4/gettext.m4 deleted file mode 100644 index eef5073..0000000 --- a/rpcsvc-proto-1.4.2/m4/gettext.m4 +++ /dev/null @@ -1,420 +0,0 @@ -# gettext.m4 serial 68 (gettext-0.19.8) -dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2006, 2008-2010. - -dnl Macro to add for using GNU gettext. - -dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). -dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The -dnl default (if it is not specified or empty) is 'no-libtool'. -dnl INTLSYMBOL should be 'external' for packages with no intl directory, -dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. -dnl If INTLSYMBOL is 'use-libtool', then a libtool library -dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, -dnl depending on --{enable,disable}-{shared,static} and on the presence of -dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library -dnl $(top_builddir)/intl/libintl.a will be created. -dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext -dnl implementations (in libc or libintl) without the ngettext() function -dnl will be ignored. If NEEDSYMBOL is specified and is -dnl 'need-formatstring-macros', then GNU gettext implementations that don't -dnl support the ISO C 99 formatstring macros will be ignored. -dnl INTLDIR is used to find the intl libraries. If empty, -dnl the value '$(top_builddir)/intl/' is used. -dnl -dnl The result of the configuration is one of three cases: -dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled -dnl and used. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 2) GNU gettext has been found in the system's C library. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 3) No internationalization, always use English msgid. -dnl Catalog format: none -dnl Catalog extension: none -dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. -dnl The use of .gmo is historical (it was needed to avoid overwriting the -dnl GNU format catalogs when building on a platform with an X/Open gettext), -dnl but we keep it in order not to force irrelevant filename changes on the -dnl maintainers. -dnl -AC_DEFUN([AM_GNU_GETTEXT], -[ - dnl Argument checking. - ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , - [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT -])])])])]) - ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], - [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) - ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , - [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT -])])])]) - define([gt_included_intl], - ifelse([$1], [external], - ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), - [yes])) - define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) - gt_NEEDS_INIT - AM_GNU_GETTEXT_NEED([$2]) - - AC_REQUIRE([AM_PO_SUBDIRS])dnl - ifelse(gt_included_intl, yes, [ - AC_REQUIRE([AM_INTL_SUBDIR])dnl - ]) - - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Sometimes libintl requires libiconv, so first search for libiconv. - dnl Ideally we would do this search only after the - dnl if test "$USE_NLS" = "yes"; then - dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT - dnl the configure script would need to contain the same shell code - dnl again, outside any 'if'. There are two solutions: - dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. - dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. - dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not - dnl documented, we avoid it. - ifelse(gt_included_intl, yes, , [ - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - ]) - - dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. - gt_INTL_MACOSX - - dnl Set USE_NLS. - AC_REQUIRE([AM_NLS]) - - ifelse(gt_included_intl, yes, [ - BUILD_INCLUDED_LIBINTL=no - USE_INCLUDED_LIBINTL=no - ]) - LIBINTL= - LTLIBINTL= - POSUB= - - dnl Add a version number to the cache macros. - case " $gt_needs " in - *" need-formatstring-macros "*) gt_api_version=3 ;; - *" need-ngettext "*) gt_api_version=2 ;; - *) gt_api_version=1 ;; - esac - gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" - gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" - - dnl If we use NLS figure out what method - if test "$USE_NLS" = "yes"; then - gt_use_preinstalled_gnugettext=no - ifelse(gt_included_intl, yes, [ - AC_MSG_CHECKING([whether included gettext is requested]) - AC_ARG_WITH([included-gettext], - [ --with-included-gettext use the GNU gettext library included here], - nls_cv_force_use_gnu_gettext=$withval, - nls_cv_force_use_gnu_gettext=no) - AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) - - nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" - if test "$nls_cv_force_use_gnu_gettext" != "yes"; then - ]) - dnl User does not insist on using GNU NLS library. Figure out what - dnl to use. If GNU gettext is available we use this. Else we have - dnl to fall back to GNU NLS library. - - if test $gt_api_version -ge 3; then - gt_revision_test_code=' -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -#endif -changequote(,)dnl -typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -changequote([,])dnl -' - else - gt_revision_test_code= - fi - if test $gt_api_version -ge 2; then - gt_expression_test_code=' + * ngettext ("", "", 0)' - else - gt_expression_test_code= - fi - - AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings; -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - ]])], - [eval "$gt_func_gnugettext_libc=yes"], - [eval "$gt_func_gnugettext_libc=no"])]) - - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl Sometimes libintl requires libiconv, so first search for libiconv. - ifelse(gt_included_intl, yes, , [ - AM_ICONV_LINK - ]) - dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL - dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) - dnl because that would add "-liconv" to LIBINTL and LTLIBINTL - dnl even if libiconv doesn't exist. - AC_LIB_LINKFLAGS_BODY([intl]) - AC_CACHE_CHECK([for GNU gettext in libintl], - [$gt_func_gnugettext_libintl], - [gt_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $INCINTL" - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - dnl Now see whether libintl exists and does not depend on libiconv. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - ]])], - [eval "$gt_func_gnugettext_libintl=yes"], - [eval "$gt_func_gnugettext_libintl=no"]) - dnl Now see whether libintl exists and depends on libiconv. - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) -#else -#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 -#endif -$gt_revision_test_code - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION - ]])], - [LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - ]) - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS"]) - fi - - dnl If an already present or preinstalled GNU gettext() is found, - dnl use it. But if this macro is used in GNU gettext, and GNU - dnl gettext is already preinstalled in libintl, we update this - dnl libintl. (Cf. the install rule in intl/Makefile.in.) - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ - || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ - && test "$PACKAGE" != gettext-runtime \ - && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes - else - dnl Reset the values set by searching for libintl. - LIBINTL= - LTLIBINTL= - INCINTL= - fi - - ifelse(gt_included_intl, yes, [ - if test "$gt_use_preinstalled_gnugettext" != "yes"; then - dnl GNU gettext is not found in the C library. - dnl Fall back on included GNU gettext library. - nls_cv_use_gnu_gettext=yes - fi - fi - - if test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions used to generate GNU NLS library. - BUILD_INCLUDED_LIBINTL=yes - USE_INCLUDED_LIBINTL=yes - LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" - LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" - LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` - fi - - CATOBJEXT= - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions to use GNU gettext tools. - CATOBJEXT=.gmo - fi - ]) - - if test -n "$INTL_MACOSX_LIBS"; then - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Some extra flags are needed during linking. - LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" - LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" - fi - fi - - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - AC_DEFINE([ENABLE_NLS], [1], - [Define to 1 if translation of program messages to the user's native language - is requested.]) - else - USE_NLS=no - fi - fi - - AC_MSG_CHECKING([whether to use NLS]) - AC_MSG_RESULT([$USE_NLS]) - if test "$USE_NLS" = "yes"; then - AC_MSG_CHECKING([where the gettext function comes from]) - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - gt_source="external libintl" - else - gt_source="libc" - fi - else - gt_source="included intl directory" - fi - AC_MSG_RESULT([$gt_source]) - fi - - if test "$USE_NLS" = "yes"; then - - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - AC_MSG_CHECKING([how to link with libintl]) - AC_MSG_RESULT([$LIBINTL]) - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) - fi - - dnl For backward compatibility. Some packages may be using this. - AC_DEFINE([HAVE_GETTEXT], [1], - [Define if the GNU gettext() function is already present or preinstalled.]) - AC_DEFINE([HAVE_DCGETTEXT], [1], - [Define if the GNU dcgettext() function is already present or preinstalled.]) - fi - - dnl We need to process the po/ directory. - POSUB=po - fi - - ifelse(gt_included_intl, yes, [ - dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL - dnl to 'yes' because some of the testsuite requires it. - if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then - BUILD_INCLUDED_LIBINTL=yes - fi - - dnl Make all variables we use known to autoconf. - AC_SUBST([BUILD_INCLUDED_LIBINTL]) - AC_SUBST([USE_INCLUDED_LIBINTL]) - AC_SUBST([CATOBJEXT]) - - dnl For backward compatibility. Some configure.ins may be using this. - nls_cv_header_intl= - nls_cv_header_libgt= - - dnl For backward compatibility. Some Makefiles may be using this. - DATADIRNAME=share - AC_SUBST([DATADIRNAME]) - - dnl For backward compatibility. Some Makefiles may be using this. - INSTOBJEXT=.mo - AC_SUBST([INSTOBJEXT]) - - dnl For backward compatibility. Some Makefiles may be using this. - GENCAT=gencat - AC_SUBST([GENCAT]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLOBJS= - if test "$USE_INCLUDED_LIBINTL" = yes; then - INTLOBJS="\$(GETTOBJS)" - fi - AC_SUBST([INTLOBJS]) - - dnl Enable libtool support if the surrounding package wishes it. - INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix - AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) - ]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLLIBS="$LIBINTL" - AC_SUBST([INTLLIBS]) - - dnl Make all documented variables known to autoconf. - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) - AC_SUBST([POSUB]) -]) - - -dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. -m4_define([gt_NEEDS_INIT], -[ - m4_divert_text([DEFAULTS], [gt_needs=]) - m4_define([gt_NEEDS_INIT], []) -]) - - -dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) -AC_DEFUN([AM_GNU_GETTEXT_NEED], -[ - m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) -]) - - -dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) -AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) - - -dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) -AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) diff --git a/rpcsvc-proto-1.4.2/m4/iconv.m4 b/rpcsvc-proto-1.4.2/m4/iconv.m4 deleted file mode 100644 index aa159c5..0000000 --- a/rpcsvc-proto-1.4.2/m4/iconv.m4 +++ /dev/null @@ -1,271 +0,0 @@ -# iconv.m4 serial 19 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], -[ - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([iconv]) -]) - -AC_DEFUN([AM_ICONV_LINK], -[ - dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and - dnl those with the standalone portable GNU libiconv installed). - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - - dnl Add $INCICONV to CPPFLAGS before performing the following checks, - dnl because if the user has installed libiconv and not disabled its use - dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. - am_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - - AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_func_iconv=yes]) - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_lib_iconv=yes] - [am_cv_func_iconv=yes]) - LIBS="$am_save_LIBS" - fi - ]) - if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, - dnl Solaris 10. - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - am_cv_func_iconv_works=no - for ac_iconv_const in '' 'const'; do - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - -#ifndef ICONV_CONST -# define ICONV_CONST $ac_iconv_const -#endif - ]], - [[int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\263"; - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - ICONV_CONST char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; -]])], - [am_cv_func_iconv_works=yes], , - [case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac]) - test "$am_cv_func_iconv_works" = no || break - done - LIBS="$am_save_LIBS" - ]) - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - AC_DEFINE([HAVE_ICONV], [1], - [Define if you have the iconv() function and it works.]) - fi - if test "$am_cv_lib_iconv" = yes; then - AC_MSG_CHECKING([how to link with libiconv]) - AC_MSG_RESULT([$LIBICONV]) - else - dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV - dnl either. - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi - AC_SUBST([LIBICONV]) - AC_SUBST([LTLIBICONV]) -]) - -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like -dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [m4_ifdef([gl_00GNULIB], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])])) -gl_iconv_AC_DEFUN([AM_ICONV], -[ - AM_ICONV_LINK - if test "$am_cv_func_iconv" = yes; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif - ]], - [[]])], - [am_cv_proto_iconv_arg1=""], - [am_cv_proto_iconv_arg1="const"]) - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], - [Define as const if the declaration of iconv() needs const.]) - dnl Also substitute ICONV_CONST in the gnulib generated . - m4_ifdef([gl_ICONV_H_DEFAULTS], - [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - if test -n "$am_cv_proto_iconv_arg1"; then - ICONV_CONST="const" - fi - ]) - fi -]) diff --git a/rpcsvc-proto-1.4.2/m4/intlmacosx.m4 b/rpcsvc-proto-1.4.2/m4/intlmacosx.m4 deleted file mode 100644 index aca924c..0000000 --- a/rpcsvc-proto-1.4.2/m4/intlmacosx.m4 +++ /dev/null @@ -1,56 +0,0 @@ -# intlmacosx.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2004-2014, 2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Checks for special options needed on Mac OS X. -dnl Defines INTL_MACOSX_LIBS. -AC_DEFUN([gt_INTL_MACOSX], -[ - dnl Check for API introduced in Mac OS X 10.2. - AC_CACHE_CHECK([for CFPreferencesCopyAppValue], - [gt_cv_func_CFPreferencesCopyAppValue], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFPreferencesCopyAppValue(NULL, NULL)]])], - [gt_cv_func_CFPreferencesCopyAppValue=yes], - [gt_cv_func_CFPreferencesCopyAppValue=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], - [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) - fi - dnl Check for API introduced in Mac OS X 10.3. - AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFLocaleCopyCurrent();]])], - [gt_cv_func_CFLocaleCopyCurrent=yes], - [gt_cv_func_CFLocaleCopyCurrent=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], - [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - AC_SUBST([INTL_MACOSX_LIBS]) -]) diff --git a/rpcsvc-proto-1.4.2/m4/lib-ld.m4 b/rpcsvc-proto-1.4.2/m4/lib-ld.m4 deleted file mode 100644 index 6209de6..0000000 --- a/rpcsvc-proto-1.4.2/m4/lib-ld.m4 +++ /dev/null @@ -1,119 +0,0 @@ -# lib-ld.m4 serial 6 -dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid -dnl collision with libtool.m4. - -dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], -[# I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 /dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL([acl_cv_path_LD], -[if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE([rpath], - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_FROMPACKAGE(name, package) -dnl declares that libname comes from the given package. The configure file -dnl will then not have a --with-libname-prefix option but a -dnl --with-package-prefix option. Several libraries can come from the same -dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar -dnl macro call that searches for libname. -AC_DEFUN([AC_LIB_FROMPACKAGE], -[ - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_frompackage_]NAME, [$2]) - popdef([NAME]) - pushdef([PACK],[$2]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) - popdef([PACKUP]) - popdef([PACK]) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found -dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) - dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_ARG_WITH(P_A_C_K[-prefix], -[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - LIB[]NAME[]_PREFIX= - dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been - dnl computed. So it has to be reset here. - HAVE_LIB[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - dnl The same code as in the loop below: - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$acl_hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi - popdef([P_A_C_K]) - popdef([PACKLIBS]) - popdef([PACKUP]) - popdef([PACK]) - popdef([NAME]) -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -dnl For those cases where a variable contains several -L and -l options -dnl referring to unknown libraries and directories, this macro determines the -dnl necessary additional linker options for the runtime path. -dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) -dnl sets LDADDVAR to linker options needed together with LIBSVALUE. -dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, -dnl otherwise linking without libtool is assumed. -AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], -[ - AC_REQUIRE([AC_LIB_RPATH]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - $1= - if test "$enable_rpath" != no; then - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode directories into the resulting - dnl binary. - rpathdirs= - next= - for opt in $2; do - if test -n "$next"; then - dir="$next" - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= - else - case $opt in - -L) next=yes ;; - -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= ;; - *) next= ;; - esac - fi - done - if test "X$rpathdirs" != "X"; then - if test -n ""$3""; then - dnl libtool is used for linking. Use -R options. - for dir in $rpathdirs; do - $1="${$1}${$1:+ }-R$dir" - done - else - dnl The linker is used for linking directly. - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user - dnl must pass all path elements in one option. - alldirs= - for dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="$flag" - else - dnl The -rpath options are cumulative. - for dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="${$1}${$1:+ }$flag" - done - fi - fi - fi - fi - fi - AC_SUBST([$1]) -]) diff --git a/rpcsvc-proto-1.4.2/m4/lib-prefix.m4 b/rpcsvc-proto-1.4.2/m4/lib-prefix.m4 deleted file mode 100644 index 6851031..0000000 --- a/rpcsvc-proto-1.4.2/m4/lib-prefix.m4 +++ /dev/null @@ -1,224 +0,0 @@ -# lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AC_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_PREPARE_MULTILIB creates -dnl - a variable acl_libdirstem, containing the basename of the libdir, either -dnl "lib" or "lib64" or "lib/64", -dnl - a variable acl_libdirstem2, as a secondary possible value for -dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or -dnl "lib/amd64". -AC_DEFUN([AC_LIB_PREPARE_MULTILIB], -[ - dnl There is no formal standard regarding lib and lib64. - dnl On glibc systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine - dnl the compiler's default mode by looking at the compiler's library search - dnl path. If at least one of its elements ends in /lib64 or points to a - dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. - dnl Otherwise we use the default, namely "lib". - dnl On Solaris systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or - dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. - AC_REQUIRE([AC_CANONICAL_HOST]) - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment - dnl . - dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." - dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the - dnl symlink is missing, so we set acl_libdirstem2 too. - AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], - [AC_EGREP_CPP([sixtyfour bits], [ -#ifdef _LP64 -sixtyfour bits -#endif - ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) - ]) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" -]) diff --git a/rpcsvc-proto-1.4.2/m4/nls.m4 b/rpcsvc-proto-1.4.2/m4/nls.m4 deleted file mode 100644 index afdb9ca..0000000 --- a/rpcsvc-proto-1.4.2/m4/nls.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# nls.m4 serial 5 (gettext-0.18) -dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016 Free Software -dnl Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.50]) - -AC_DEFUN([AM_NLS], -[ - AC_MSG_CHECKING([whether NLS is requested]) - dnl Default is enabled NLS - AC_ARG_ENABLE([nls], - [ --disable-nls do not use Native Language Support], - USE_NLS=$enableval, USE_NLS=yes) - AC_MSG_RESULT([$USE_NLS]) - AC_SUBST([USE_NLS]) -]) diff --git a/rpcsvc-proto-1.4.2/m4/po.m4 b/rpcsvc-proto-1.4.2/m4/po.m4 deleted file mode 100644 index c5a2f6b..0000000 --- a/rpcsvc-proto-1.4.2/m4/po.m4 +++ /dev/null @@ -1,453 +0,0 @@ -# po.m4 serial 24 (gettext-0.19) -dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.60]) - -dnl Checks for all prerequisites of the po subdirectory. -AC_DEFUN([AM_PO_SUBDIRS], -[ - AC_REQUIRE([AC_PROG_MAKE_SET])dnl - AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AC_PROG_MKDIR_P])dnl - AC_REQUIRE([AC_PROG_SED])dnl - AC_REQUIRE([AM_NLS])dnl - - dnl Release version of the gettext macros. This is used to ensure that - dnl the gettext macros and po/Makefile.in.in are in sync. - AC_SUBST([GETTEXT_MACRO_VERSION], [0.19]) - - dnl Perform the following tests also if --disable-nls has been given, - dnl because they are needed for "make dist" to work. - - dnl Search for GNU msgfmt in the PATH. - dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. - dnl The second test excludes FreeBSD msgfmt. - AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, - [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) - - dnl Test whether it is GNU msgfmt >= 0.15. -changequote(,)dnl - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([MSGFMT_015]) -changequote(,)dnl - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; - *) GMSGFMT_015=$GMSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([GMSGFMT_015]) - - dnl Search for GNU xgettext 0.12 or newer in the PATH. - dnl The first test excludes Solaris xgettext and early GNU xgettext versions. - dnl The second test excludes FreeBSD xgettext. - AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, - [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - dnl Remove leftover from FreeBSD xgettext call. - rm -f messages.po - - dnl Test whether it is GNU xgettext >= 0.15. -changequote(,)dnl - case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; - *) XGETTEXT_015=$XGETTEXT ;; - esac -changequote([,])dnl - AC_SUBST([XGETTEXT_015]) - - dnl Search for GNU msgmerge 0.11 or newer in the PATH. - AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, - [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) - - dnl Installation directories. - dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we - dnl have to define it here, so that it can be used in po/Makefile. - test -n "$localedir" || localedir='${datadir}/locale' - AC_SUBST([localedir]) - - dnl Support for AM_XGETTEXT_OPTION. - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) - - AC_CONFIG_COMMANDS([po-directories], [[ - for ac_file in $CONFIG_FILES; do - # Support "outfile[:infile[:infile...]]" - case "$ac_file" in - *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - esac - # PO directories have a Makefile.in generated from Makefile.in.in. - case "$ac_file" in */Makefile.in) - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - # Treat a directory as a PO directory if and only if it has a - # POTFILES.in file. This allows packages to have multiple PO - # directories under different names or in different locations. - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - gt_tab=`printf '\t'` - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" - POMAKEFILEDEPS="POTFILES.in" - # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. - if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" - fi - ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' - POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" - else - # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi - # Compute POFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) - # Compute UPDATEPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) - # Compute DUMMYPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) - # Compute GMOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= - UPDATEPOFILES= - DUMMYPOFILES= - GMOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" - GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. - INST_LINGUAS= - if test -n "$ALL_LINGUAS"; then - for presentlang in $ALL_LINGUAS; do - useit=no - if test "%UNSET%" != "$LINGUAS"; then - desiredlanguages="$LINGUAS" - else - desiredlanguages="$ALL_LINGUAS" - fi - for desiredlang in $desiredlanguages; do - # Use the presentlang catalog if desiredlang is - # a. equal to presentlang, or - # b. a variant of presentlang (because in this case, - # presentlang can be used as a fallback for messages - # which are not translated in the desiredlang catalog). - case "$desiredlang" in - "$presentlang"*) useit=yes;; - esac - done - if test $useit = yes; then - INST_LINGUAS="$INST_LINGUAS $presentlang" - fi - done - fi - CATALOGS= - if test -n "$INST_LINGUAS"; then - for lang in $INST_LINGUAS; do - CATALOGS="$CATALOGS $lang.gmo" - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" - sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in - *.orig | *.bak | *~) ;; - *) cat "$f" >> "$ac_dir/Makefile" ;; - esac - fi - done - fi - ;; - esac - done]], - [# Capture the value of obsolete ALL_LINGUAS because we need it to compute - # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it - # from automake < 1.5. - eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - ]) -]) - -dnl Postprocesses a Makefile in a directory containing PO files. -AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], -[ - # When this code is run, in config.status, two variables have already been - # set: - # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, - # - LINGUAS is the value of the environment variable LINGUAS at configure - # time. - -changequote(,)dnl - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - # Find a way to echo strings without interpreting backslash. - if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='echo' - else - if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='printf %s\n' - else - echo_func () { - cat < "$ac_file.tmp" - tab=`printf '\t'` - if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` - cat >> "$ac_file.tmp" < /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` - cat >> "$ac_file.tmp" <> "$ac_file.tmp" <, 1996. - -AC_PREREQ([2.50]) - -# Search path for a program which passes the given test. - -dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, -dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -AC_DEFUN([AM_PATH_PROG_WITH_TEST], -[ -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "$2", so it can be a program name with args. -set dummy $2; ac_word=[$]2 -AC_MSG_CHECKING([for $ac_word]) -AC_CACHE_VAL([ac_cv_path_$1], -[case "[$]$1" in - [[\\/]]* | ?:[[\\/]]*) - ac_cv_path_$1="[$]$1" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in ifelse([$5], , $PATH, [$5]); do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD - if [$3]; then - ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" -dnl If no 4th arg is given, leave the cache variable unset, -dnl so AC_PATH_PROGS will keep looking. -ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" -])dnl - ;; -esac])dnl -$1="$ac_cv_path_$1" -if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then - AC_MSG_RESULT([$][$1]) -else - AC_MSG_RESULT([no]) -fi -AC_SUBST([$1])dnl -]) diff --git a/rpcsvc-proto-1.4.2/missing b/rpcsvc-proto-1.4.2/missing deleted file mode 100755 index c6e3795..0000000 --- a/rpcsvc-proto-1.4.2/missing +++ /dev/null @@ -1,215 +0,0 @@ -#! /bin/sh -# Common wrapper for a few potentially missing GNU programs. - -scriptversion=2016-01-11.22; # UTC - -# Copyright (C) 1996-2017 Free Software Foundation, Inc. -# Originally written by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try '$0 --help' for more information" - exit 1 -fi - -case $1 in - - --is-lightweight) - # Used by our autoconf macros to check whether the available missing - # script is modern enough. - exit 0 - ;; - - --run) - # Back-compat with the calling convention used by older automake. - shift - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due -to PROGRAM being missing or too old. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man - -Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and -'g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: unknown '$1' option" - echo 1>&2 "Try '$0 --help' for more information" - exit 1 - ;; - -esac - -# Run the given program, remember its exit status. -"$@"; st=$? - -# If it succeeded, we are done. -test $st -eq 0 && exit 0 - -# Also exit now if we it failed (or wasn't found), and '--version' was -# passed; such an option is passed most likely to detect whether the -# program is present and works. -case $2 in --version|--help) exit $st;; esac - -# Exit code 63 means version mismatch. This often happens when the user -# tries to use an ancient version of a tool on a file that requires a -# minimum version. -if test $st -eq 63; then - msg="probably too old" -elif test $st -eq 127; then - # Program was missing. - msg="missing on your system" -else - # Program was found and executed, but failed. Give up. - exit $st -fi - -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software - -program_details () -{ - case $1 in - aclocal|automake) - echo "The '$1' program is part of the GNU Automake package:" - echo "<$gnu_software_URL/automake>" - echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/autoconf>" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - autoconf|autom4te|autoheader) - echo "The '$1' program is part of the GNU Autoconf package:" - echo "<$gnu_software_URL/autoconf/>" - echo "It also requires GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - esac -} - -give_advice () -{ - # Normalize program name to check for. - normalized_program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - - printf '%s\n' "'$1' is $msg." - - configure_deps="'configure.ac' or m4 files included by 'configure.ac'" - case $normalized_program in - autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' - ;; - autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" - echo "$configure_deps." - program_details 'autoheader' - ;; - automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" - echo "$configure_deps." - program_details 'aclocal' - ;; - autom4te*) - echo "You might have modified some maintainer files that require" - echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' - ;; - bison*|yacc*) - echo "You should only need it if you modified a '.y' file." - echo "You may want to install the GNU Bison package:" - echo "<$gnu_software_URL/bison/>" - ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; - help2man*) - echo "You should only need it if you modified a dependency" \ - "of a man page." - echo "You may want to install the GNU Help2man package:" - echo "<$gnu_software_URL/help2man/>" - ;; - makeinfo*) - echo "You should only need it if you modified a '.texi' file, or" - echo "any other file indirectly affecting the aspect of the manual." - echo "You might want to install the Texinfo package:" - echo "<$gnu_software_URL/texinfo/>" - echo "The spurious makeinfo call might also be the consequence of" - echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" - echo "want to install GNU make:" - echo "<$gnu_software_URL/make/>" - ;; - *) - echo "You might have modified some files without having the proper" - echo "tools for further handling them. Check the 'README' file, it" - echo "often tells you about the needed prerequisites for installing" - echo "this package. You may also peek at any GNU archive site, in" - echo "case some other package contains this missing '$1' program." - ;; - esac -} - -give_advice "$1" | sed -e '1s/^/WARNING: /' \ - -e '2,$s/^/ /' >&2 - -# Propagate the correct exit status (expected to be 127 for a program -# not found, 63 for a program that failed due to version mismatch). -exit $st - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/rpcsvc-proto-1.4.2/po/Makefile.in.in b/rpcsvc-proto-1.4.2/po/Makefile.in.in deleted file mode 100644 index 38c293d..0000000 --- a/rpcsvc-proto-1.4.2/po/Makefile.in.in +++ /dev/null @@ -1,483 +0,0 @@ -# Makefile for PO directory in any package using GNU gettext. -# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. This file is offered as-is, -# without any warranty. -# -# Origin: gettext-0.19.8 -GETTEXT_MACRO_VERSION = 0.19 - -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ - -SED = @SED@ -SHELL = /bin/sh -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -datarootdir = @datarootdir@ -datadir = @datadir@ -localedir = @localedir@ -gettextsrcdir = $(datadir)/gettext/po - -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -# We use $(mkdir_p). -# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as -# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, -# @install_sh@ does not start with $(SHELL), so we add it. -# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined -# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake -# versions, $(mkinstalldirs) and $(install_sh) are unused. -mkinstalldirs = $(SHELL) @install_sh@ -d -install_sh = $(SHELL) @install_sh@ -MKDIR_P = @MKDIR_P@ -mkdir_p = @mkdir_p@ - -# When building gettext-tools, we prefer to use the built programs -# rather than installed programs. However, we can't do that when we -# are cross compiling. -CROSS_COMPILING = @CROSS_COMPILING@ - -GMSGFMT_ = @GMSGFMT@ -GMSGFMT_no = @GMSGFMT@ -GMSGFMT_yes = @GMSGFMT_015@ -GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) -MSGFMT_ = @MSGFMT@ -MSGFMT_no = @MSGFMT@ -MSGFMT_yes = @MSGFMT_015@ -MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) -XGETTEXT_ = @XGETTEXT@ -XGETTEXT_no = @XGETTEXT@ -XGETTEXT_yes = @XGETTEXT_015@ -XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) -MSGMERGE = msgmerge -MSGMERGE_UPDATE = @MSGMERGE@ --update -MSGINIT = msginit -MSGCONV = msgconv -MSGFILTER = msgfilter - -POFILES = @POFILES@ -GMOFILES = @GMOFILES@ -UPDATEPOFILES = @UPDATEPOFILES@ -DUMMYPOFILES = @DUMMYPOFILES@ -DISTFILES.common = Makefile.in.in remove-potcdate.sin \ -$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) -DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \ -$(POFILES) $(GMOFILES) \ -$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) - -POTFILES = \ - -CATALOGS = @CATALOGS@ - -POFILESDEPS_ = $(srcdir)/$(DOMAIN).pot -POFILESDEPS_yes = $(POFILESDEPS_) -POFILESDEPS_no = -POFILESDEPS = $(POFILESDEPS_$(PO_DEPENDS_ON_POT)) - -DISTFILESDEPS_ = update-po -DISTFILESDEPS_yes = $(DISTFILESDEPS_) -DISTFILESDEPS_no = -DISTFILESDEPS = $(DISTFILESDEPS_$(DIST_DEPENDS_ON_UPDATE_PO)) - -# Makevars gets inserted here. (Don't remove this line!) - -.SUFFIXES: -.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update - -.po.mo: - @echo "$(MSGFMT) -c -o $@ $<"; \ - $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ - -.po.gmo: - @lang=`echo $* | sed -e 's,.*/,,'`; \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ - cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo - -.sin.sed: - sed -e '/^#/d' $< > t-$@ - mv t-$@ $@ - - -all: all-@USE_NLS@ - -all-yes: stamp-po -all-no: - -# Ensure that the gettext macros and this Makefile.in.in are in sync. -CHECK_MACRO_VERSION = \ - test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ - || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ - exit 1; \ - } - -# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no -# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because -# we don't want to bother translators with empty POT files). We assume that -# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. -# In this case, stamp-po is a nop (i.e. a phony target). - -# stamp-po is a timestamp denoting the last time at which the CATALOGS have -# been loosely updated. Its purpose is that when a developer or translator -# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, -# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent -# invocations of "make" will do nothing. This timestamp would not be necessary -# if updating the $(CATALOGS) would always touch them; however, the rule for -# $(POFILES) has been designed to not touch files that don't need to be -# changed. -stamp-po: $(srcdir)/$(DOMAIN).pot - @$(CHECK_MACRO_VERSION) - test ! -f $(srcdir)/$(DOMAIN).pot || \ - test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) - @test ! -f $(srcdir)/$(DOMAIN).pot || { \ - echo "touch stamp-po" && \ - echo timestamp > stamp-poT && \ - mv stamp-poT stamp-po; \ - } - -# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', -# otherwise packages like GCC can not be built if only parts of the source -# have been downloaded. - -# This target rebuilds $(DOMAIN).pot; it is an expensive operation. -# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. -# The determination of whether the package xyz is a GNU one is based on the -# heuristic whether some file in the top level directory mentions "GNU xyz". -# If GNU 'find' is available, we avoid grepping through monster files. -$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed - package_gnu="$(PACKAGE_GNU)"; \ - test -n "$$package_gnu" || { \ - if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \ - LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f \ - -size -10000000c -exec grep 'GNU @PACKAGE@' \ - /dev/null '{}' ';' 2>/dev/null; \ - else \ - LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \ - fi; \ - } | grep -v 'libtool:' >/dev/null; then \ - package_gnu=yes; \ - else \ - package_gnu=no; \ - fi; \ - }; \ - if test "$$package_gnu" = "yes"; then \ - package_prefix='GNU '; \ - else \ - package_prefix=''; \ - fi; \ - if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ - msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ - else \ - msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ - fi; \ - case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - *) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --package-name="$${package_prefix}@PACKAGE@" \ - --package-version='@VERSION@' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - esac - test ! -f $(DOMAIN).po || { \ - if test -f $(srcdir)/$(DOMAIN).pot-header; then \ - sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \ - cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po; \ - rm -f $(DOMAIN).1po; \ - fi; \ - if test -f $(srcdir)/$(DOMAIN).pot; then \ - sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ - sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ - if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ - rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ - else \ - rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ - mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ - fi; \ - else \ - mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ - fi; \ - } - -# This rule has no dependencies: we don't need to update $(DOMAIN).pot at -# every "make" invocation, only create it when it is missing. -# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. -$(srcdir)/$(DOMAIN).pot: - $(MAKE) $(DOMAIN).pot-update - -# This target rebuilds a PO file if $(DOMAIN).pot has changed. -# Note that a PO file is not touched if it doesn't need to be changed. -$(POFILES): $(POFILESDEPS) - @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ - if test -f "$(srcdir)/$${lang}.po"; then \ - test -f $(srcdir)/$(DOMAIN).pot || $(MAKE) $(srcdir)/$(DOMAIN).pot; \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ - cd $(srcdir) \ - && { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \ - esac; \ - }; \ - else \ - $(MAKE) $${lang}.po-create; \ - fi - - -install: install-exec install-data -install-exec: -install-data: install-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ - for file in $(DISTFILES.common) Makevars.template; do \ - $(INSTALL_DATA) $(srcdir)/$$file \ - $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - for file in Makevars; do \ - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - else \ - : ; \ - fi -install-data-no: all -install-data-yes: all - @catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - dir=$(localedir)/$$lang/LC_MESSAGES; \ - $(mkdir_p) $(DESTDIR)$$dir; \ - if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ - $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ - echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ - for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ - if test -n "$$lc"; then \ - if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ - fi; \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ - ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ - cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ - fi; \ - done; \ - done - -install-strip: install - -installdirs: installdirs-exec installdirs-data -installdirs-exec: -installdirs-data: installdirs-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ - else \ - : ; \ - fi -installdirs-data-no: -installdirs-data-yes: - @catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - dir=$(localedir)/$$lang/LC_MESSAGES; \ - $(mkdir_p) $(DESTDIR)$$dir; \ - for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ - if test -n "$$lc"; then \ - if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ - fi; \ - fi; \ - done; \ - done - -# Define this as empty until I found a useful application. -installcheck: - -uninstall: uninstall-exec uninstall-data -uninstall-exec: -uninstall-data: uninstall-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - for file in $(DISTFILES.common) Makevars.template; do \ - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - else \ - : ; \ - fi -uninstall-data-no: -uninstall-data-yes: - catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - done; \ - done - -check: all - -info dvi ps pdf html tags TAGS ctags CTAGS ID: - -mostlyclean: - rm -f remove-potcdate.sed - rm -f stamp-poT - rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po - rm -fr *.o - -clean: mostlyclean - -distclean: clean - rm -f Makefile Makefile.in POTFILES *.mo - -maintainer-clean: distclean - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - rm -f stamp-po $(GMOFILES) - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -dist distdir: - test -z "$(DISTFILESDEPS)" || $(MAKE) $(DISTFILESDEPS) - @$(MAKE) dist2 -# This is a separate target because 'update-po' must be executed before. -dist2: stamp-po $(DISTFILES) - dists="$(DISTFILES)"; \ - if test "$(PACKAGE)" = "gettext-tools"; then \ - dists="$$dists Makevars.template"; \ - fi; \ - if test -f $(srcdir)/$(DOMAIN).pot; then \ - dists="$$dists $(DOMAIN).pot stamp-po"; \ - fi; \ - if test -f $(srcdir)/ChangeLog; then \ - dists="$$dists ChangeLog"; \ - fi; \ - for i in 0 1 2 3 4 5 6 7 8 9; do \ - if test -f $(srcdir)/ChangeLog.$$i; then \ - dists="$$dists ChangeLog.$$i"; \ - fi; \ - done; \ - if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ - for file in $$dists; do \ - if test -f $$file; then \ - cp -p $$file $(distdir) || exit 1; \ - else \ - cp -p $(srcdir)/$$file $(distdir) || exit 1; \ - fi; \ - done - -update-po: Makefile - $(MAKE) $(DOMAIN).pot-update - test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) - $(MAKE) update-gmo - -# General rule for creating PO files. - -.nop.po-create: - @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ - echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ - exit 1 - -# General rule for updating PO files. - -.nop.po-update: - @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ - if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; fi; \ - tmpdir=`pwd`; \ - echo "$$lang:"; \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ - cd $(srcdir); \ - if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - esac; \ - }; then \ - if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ - rm -f $$tmpdir/$$lang.new.po; \ - else \ - if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ - :; \ - else \ - echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ - exit 1; \ - fi; \ - fi; \ - else \ - echo "msgmerge for $$lang.po failed!" 1>&2; \ - rm -f $$tmpdir/$$lang.new.po; \ - fi - -$(DUMMYPOFILES): - -update-gmo: Makefile $(GMOFILES) - @: - -# Recreate Makefile by invoking config.status. Explicitly invoke the shell, -# because execution permission bits may not work on the current file system. -# Use @SHELL@, which is the shell determined by autoconf for the use by its -# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient. -Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ - cd $(top_builddir) \ - && @SHELL@ ./config.status $(subdir)/$@.in po-directories - -force: - -# Tell versions [3.59,3.63) of GNU make not to export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/rpcsvc-proto-1.4.2/po/Makevars b/rpcsvc-proto-1.4.2/po/Makevars deleted file mode 100644 index 32692ab..0000000 --- a/rpcsvc-proto-1.4.2/po/Makevars +++ /dev/null @@ -1,41 +0,0 @@ -# Makefile variables for PO directory in any package using GNU gettext. - -# Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) - -# These two variables depend on the location of this directory. -subdir = po -top_builddir = .. - -# These options get passed to xgettext. -XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ - -# This is the copyright holder that gets inserted into the header of the -# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding -# package. (Note that the msgstr strings, extracted from the package's -# sources, belong to the copyright holder of the package.) Translators are -# expected to transfer the copyright for their translations to this person -# or entity, or to disclaim their copyright. The empty string stands for -# the public domain; in this case the translators are expected to disclaim -# their copyright. -COPYRIGHT_HOLDER = Free Software Foundation, Inc. - -# This is the email address or URL to which the translators shall report -# bugs in the untranslated strings: -# - Strings which are not entire sentences, see the maintainer guidelines -# in the GNU gettext documentation, section 'Preparing Strings'. -# - Strings which use unclear terms or require additional context to be -# understood. -# - Strings which make invalid assumptions about notation of date, time or -# money. -# - Pluralisation problems. -# - Incorrect English spelling. -# - Incorrect formatting. -# It can be your email address, or a mailing list address where translators -# can write to without being subscribed, or the URL of a web page through -# which the translators can contact you. -MSGID_BUGS_ADDRESS = - -# This is the list of locale categories, beyond LC_MESSAGES, for which the -# message catalogs shall be used. It is usually empty. -EXTRA_LOCALE_CATEGORIES = diff --git a/rpcsvc-proto-1.4.2/po/POTFILES.in b/rpcsvc-proto-1.4.2/po/POTFILES.in deleted file mode 100644 index 667e27c..0000000 --- a/rpcsvc-proto-1.4.2/po/POTFILES.in +++ /dev/null @@ -1 +0,0 @@ -# List of source files which contain translatable strings. diff --git a/rpcsvc-proto-1.4.2/po/Rules-quot b/rpcsvc-proto-1.4.2/po/Rules-quot deleted file mode 100644 index baf6528..0000000 --- a/rpcsvc-proto-1.4.2/po/Rules-quot +++ /dev/null @@ -1,58 +0,0 @@ -# This file, Rules-quot, can be copied and used freely without restrictions. -# Special Makefile rules for English message catalogs with quotation marks. - -DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot - -.SUFFIXES: .insert-header .po-update-en - -en@quot.po-create: - $(MAKE) en@quot.po-update -en@boldquot.po-create: - $(MAKE) en@boldquot.po-update - -en@quot.po-update: en@quot.po-update-en -en@boldquot.po-update: en@boldquot.po-update-en - -.insert-header.po-update-en: - @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ - if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ - tmpdir=`pwd`; \ - echo "$$lang:"; \ - ll=`echo $$lang | sed -e 's/@.*//'`; \ - LC_ALL=C; export LC_ALL; \ - cd $(srcdir); \ - if $(MSGINIT) $(MSGINIT_OPTIONS) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null \ - | $(SED) -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | \ - { case `$(MSGFILTER) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-8] | 0.1[0-8].*) \ - $(MSGFILTER) $(SED) -f `echo $$lang | sed -e 's/.*@//'`.sed \ - ;; \ - *) \ - $(MSGFILTER) `echo $$lang | sed -e 's/.*@//'` \ - ;; \ - esac } 2>/dev/null > $$tmpdir/$$lang.new.po \ - ; then \ - if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ - rm -f $$tmpdir/$$lang.new.po; \ - else \ - if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ - :; \ - else \ - echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ - exit 1; \ - fi; \ - fi; \ - else \ - echo "creation of $$lang.po failed!" 1>&2; \ - rm -f $$tmpdir/$$lang.new.po; \ - fi - -en@quot.insert-header: insert-header.sin - sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header - -en@boldquot.insert-header: insert-header.sin - sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header - -mostlyclean: mostlyclean-quot -mostlyclean-quot: - rm -f *.insert-header diff --git a/rpcsvc-proto-1.4.2/po/boldquot.sed b/rpcsvc-proto-1.4.2/po/boldquot.sed deleted file mode 100644 index 4b937aa..0000000 --- a/rpcsvc-proto-1.4.2/po/boldquot.sed +++ /dev/null @@ -1,10 +0,0 @@ -s/"\([^"]*\)"/“\1â€/g -s/`\([^`']*\)'/‘\1’/g -s/ '\([^`']*\)' / ‘\1’ /g -s/ '\([^`']*\)'$/ ‘\1’/g -s/^'\([^`']*\)' /‘\1’ /g -s/“â€/""/g -s/“/“/g -s/â€/â€/g -s/‘/‘/g -s/’/’/g diff --git a/rpcsvc-proto-1.4.2/po/en@boldquot.header b/rpcsvc-proto-1.4.2/po/en@boldquot.header deleted file mode 100644 index fedb6a0..0000000 --- a/rpcsvc-proto-1.4.2/po/en@boldquot.header +++ /dev/null @@ -1,25 +0,0 @@ -# All this catalog "translates" are quotation characters. -# The msgids must be ASCII and therefore cannot contain real quotation -# characters, only substitutes like grave accent (0x60), apostrophe (0x27) -# and double quote (0x22). These substitutes look strange; see -# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html -# -# This catalog translates grave accent (0x60) and apostrophe (0x27) to -# left single quotation mark (U+2018) and right single quotation mark (U+2019). -# It also translates pairs of apostrophe (0x27) to -# left single quotation mark (U+2018) and right single quotation mark (U+2019) -# and pairs of quotation mark (0x22) to -# left double quotation mark (U+201C) and right double quotation mark (U+201D). -# -# When output to an UTF-8 terminal, the quotation characters appear perfectly. -# When output to an ISO-8859-1 terminal, the single quotation marks are -# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to -# grave/acute accent (by libiconv), and the double quotation marks are -# transliterated to 0x22. -# When output to an ASCII terminal, the single quotation marks are -# transliterated to apostrophes, and the double quotation marks are -# transliterated to 0x22. -# -# This catalog furthermore displays the text between the quotation marks in -# bold face, assuming the VT100/XTerm escape sequences. -# diff --git a/rpcsvc-proto-1.4.2/po/en@quot.header b/rpcsvc-proto-1.4.2/po/en@quot.header deleted file mode 100644 index a9647fc..0000000 --- a/rpcsvc-proto-1.4.2/po/en@quot.header +++ /dev/null @@ -1,22 +0,0 @@ -# All this catalog "translates" are quotation characters. -# The msgids must be ASCII and therefore cannot contain real quotation -# characters, only substitutes like grave accent (0x60), apostrophe (0x27) -# and double quote (0x22). These substitutes look strange; see -# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html -# -# This catalog translates grave accent (0x60) and apostrophe (0x27) to -# left single quotation mark (U+2018) and right single quotation mark (U+2019). -# It also translates pairs of apostrophe (0x27) to -# left single quotation mark (U+2018) and right single quotation mark (U+2019) -# and pairs of quotation mark (0x22) to -# left double quotation mark (U+201C) and right double quotation mark (U+201D). -# -# When output to an UTF-8 terminal, the quotation characters appear perfectly. -# When output to an ISO-8859-1 terminal, the single quotation marks are -# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to -# grave/acute accent (by libiconv), and the double quotation marks are -# transliterated to 0x22. -# When output to an ASCII terminal, the single quotation marks are -# transliterated to apostrophes, and the double quotation marks are -# transliterated to 0x22. -# diff --git a/rpcsvc-proto-1.4.2/po/insert-header.sin b/rpcsvc-proto-1.4.2/po/insert-header.sin deleted file mode 100644 index b26de01..0000000 --- a/rpcsvc-proto-1.4.2/po/insert-header.sin +++ /dev/null @@ -1,23 +0,0 @@ -# Sed script that inserts the file called HEADER before the header entry. -# -# At each occurrence of a line starting with "msgid ", we execute the following -# commands. At the first occurrence, insert the file. At the following -# occurrences, do nothing. The distinction between the first and the following -# occurrences is achieved by looking at the hold space. -/^msgid /{ -x -# Test if the hold space is empty. -s/m/m/ -ta -# Yes it was empty. First occurrence. Read the file. -r HEADER -# Output the file's contents by reading the next line. But don't lose the -# current line while doing this. -g -N -bb -:a -# The hold space was nonempty. Following occurrences. Do nothing. -x -:b -} diff --git a/rpcsvc-proto-1.4.2/po/quot.sed b/rpcsvc-proto-1.4.2/po/quot.sed deleted file mode 100644 index 0122c46..0000000 --- a/rpcsvc-proto-1.4.2/po/quot.sed +++ /dev/null @@ -1,6 +0,0 @@ -s/"\([^"]*\)"/“\1â€/g -s/`\([^`']*\)'/‘\1’/g -s/ '\([^`']*\)' / ‘\1’ /g -s/ '\([^`']*\)'$/ ‘\1’/g -s/^'\([^`']*\)' /‘\1’ /g -s/“â€/""/g diff --git a/rpcsvc-proto-1.4.2/po/remove-potcdate.sin b/rpcsvc-proto-1.4.2/po/remove-potcdate.sin deleted file mode 100644 index 2436c49..0000000 --- a/rpcsvc-proto-1.4.2/po/remove-potcdate.sin +++ /dev/null @@ -1,19 +0,0 @@ -# Sed script that remove the POT-Creation-Date line in the header entry -# from a POT file. -# -# The distinction between the first and the following occurrences of the -# pattern is achieved by looking at the hold space. -/^"POT-Creation-Date: .*"$/{ -x -# Test if the hold space is empty. -s/P/P/ -ta -# Yes it was empty. First occurrence. Remove the line. -g -d -bb -:a -# The hold space was nonempty. Following occurrences. Do nothing. -x -:b -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/Makefile.am b/rpcsvc-proto-1.4.2/rpcgen/Makefile.am deleted file mode 100644 index 457cd50..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -CLEANFILES = *~ - -bin_PROGRAMS = rpcgen -man_MANS = rpcgen.1 - -EXTRA_DIST=${MANS} - -noinst_HEADERS = proto.h rpc_parse.h rpc_scan.h rpc_util.h - -rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ - rpc_parse.c rpc_sample.c rpc_scan.c rpc_svcout.c rpc_tblout.c \ - rpc_util.c -rpcgen_LDADD = $(LIBINTL) diff --git a/rpcsvc-proto-1.4.2/rpcgen/proto.h b/rpcsvc-proto-1.4.2/rpcgen/proto.h deleted file mode 100644 index ea28565..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/proto.h +++ /dev/null @@ -1,65 +0,0 @@ -/****** rpc_clntout.c ******/ - -void write_stubs(void); -void printarglist(proc_list *proc, const char *result, - const char *addargname, const char *addargtype); - -/****** rpc_cout.c ******/ - -void emit (definition *def); - -/****** rpc_hout.c ******/ - -void print_datadef(definition *def); -void print_funcdef(definition *def); -void pxdrfuncdecl(const char *name, int pointerp); -void pprocdef(proc_list *proc, version_list *vp, - const char *addargtype, int server_p, int mode); -void pdeclaration(const char *name, declaration *dec, int tab, - const char *separator); -void print_xdr_func_def (char* name, int pointerp, int i); - -/****** rpc_main.c ******/ - /* nil */ - -/****** rpc_parse.c ******/ -definition *get_definition(void); - -/****** rpc_sample.c ******/ -void write_sample_svc(definition *def); -int write_sample_clnt(definition *def); -void add_sample_msg(void); -void write_sample_clnt_main(void); - -/****** rpc_scan.c ******/ - /* see rpc_scan.h */ - -/****** rpc_svcout.c ******/ -int nullproc(const proc_list *proc); -void write_svc_aux(int nomain); -void write_msg_out(void); - -/****** rpc_tblout.c ******/ -void write_tables(void); - -/****** rpc_util.c ******/ -void reinitialize(void); -int streq(const char *a, const char *b); -void error(const char *msg) __attribute__ ((noreturn)); -void crash(void) __attribute__ ((noreturn)); -void tabify(FILE *f, int tab); -char *make_argname(const char *pname, const char *vname); -void add_type(int len, const char *type); - -/* This header is the last one included in all rpc_*.c files, - so we define stuff for cross-rpcgen here to avoid conflicts with - $build's C library and $host's glibc. */ - -#ifdef IS_IN_build - -/* Disable translated messages when built for $build and used in - building glibc. */ -#define _(X) (X) -#define textdomain(X) ((void) 0) - -#endif diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_clntout.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_clntout.c deleted file mode 100644 index 9b6a4aa..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_clntout.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -// #include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define DEFAULT_TIMEOUT 25 /* in seconds */ -static const char RESULT[] = "clnt_res"; - -static void write_program (definition * def); -static void printbody (proc_list * proc); -static const char *ampr (const char *type); -static void printbody (proc_list * proc); - - -void -write_stubs (void) -{ - list *l; - definition *def; - - fprintf (fout, - "\n/* Default timeout can be changed using clnt_control() */\n"); - fprintf (fout, "static struct timeval TIMEOUT = { %d, 0 };\n", - DEFAULT_TIMEOUT); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_program (def); - } - } -} - -static void -write_program (definition * def) -{ - version_list *vp; - proc_list *proc; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - fprintf (fout, "\n"); - if (mtflag == 0) - { - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*\n"); - pvname (proc->proc_name, vp->vers_num); - printarglist (proc, RESULT, "clnt", "CLIENT *"); - } - else - { - fprintf (fout, "enum clnt_stat \n"); - pvname (proc->proc_name, vp->vers_num); - printarglist (proc, RESULT, "clnt", "CLIENT *"); - } - fprintf (fout, "{\n"); - printbody (proc); - fprintf (fout, "}\n"); - } - } -} - -/* Writes out declarations of procedure's argument list. - In either ANSI C style, in one of old rpcgen style (pass by reference), - or new rpcgen style (multiple arguments, pass by value); - */ - -/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */ - -void -printarglist (proc_list * proc, const char *result, - const char *addargname, const char *addargtype) -{ - - decl_list *l; - - if (!newstyle) - { /* old style: always pass argument by reference */ - if (Cflag) - { /* C++ style heading */ - fprintf (fout, "("); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - - if (mtflag) - {/* Generate result field */ - fprintf (fout, "*argp, "); - ptype(proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname); - } - else - fprintf (fout, "*argp, %s%s)\n", addargtype, addargname); - } - else - { - if (!mtflag) - fprintf (fout, "(argp, %s)\n", addargname); - else - fprintf (fout, "(argp, %s, %s)\n", result, addargname); - fprintf (fout, "\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - fprintf (fout, "*argp;\n"); - if (mtflag) - { - fprintf (fout, "\t"); - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s;\n", result); - } - } - } - else if (streq (proc->args.decls->decl.type, "void")) - { - /* newstyle, 0 argument */ - if (mtflag) - { - fprintf (fout, "("); - if (Cflag) - { - ptype(proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname); - } - else - fprintf (fout, "(%s)\n", addargname); - } - else if (Cflag) - fprintf (fout, "(%s%s)\n", addargtype, addargname); - else - fprintf (fout, "(%s)\n", addargname); - } - else - { - /* new style, 1 or multiple arguments */ - if (!Cflag) - { - fprintf (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - fprintf (fout, "%s, ", l->decl.name); - if (mtflag) - fprintf (fout, "%s, ", result); - fprintf (fout, "%s)\n", addargname); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pdeclaration (proc->args.argname, &l->decl, 1, ";\n"); - } - if (mtflag) - { - fprintf (fout, "\t"); - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s;\n", result); - } - } - else - { /* C++ style header */ - fprintf (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pdeclaration (proc->args.argname, &l->decl, 0, ", "); - } - if (mtflag) - { - ptype (proc->res_prefix, proc->res_type, 1); - fprintf (fout, "*%s, ", result); - } - fprintf (fout, " %s%s)\n", addargtype, addargname); - } - } - - if (!Cflag) - fprintf (fout, "\t%s%s;\n", addargtype, addargname); -} - - -static -const char * -ampr (const char *type) -{ - if (isvectordef (type, REL_ALIAS)) - { - return ""; - } - else - { - return "&"; - } -} - -static void -printbody (proc_list * proc) -{ - decl_list *l; - int args2 = (proc->arg_num > 1); -/* int i; */ - - /* For new style with multiple arguments, need a structure in which - to stuff the arguments. */ - if (newstyle && args2) - { - fprintf (fout, "\t%s", proc->args.argname); - fprintf (fout, " arg;\n"); - } - if (!mtflag) - { - fprintf (fout, "\tstatic "); - if (streq (proc->res_type, "void")) - { - fprintf (fout, "char "); - } - else - { - ptype (proc->res_prefix, proc->res_type, 0); - } - fprintf (fout, "%s;\n", RESULT); - fprintf (fout, "\n"); - fprintf (fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n", - ampr (proc->res_type), RESULT, RESULT); - } - if (newstyle && !args2 && (streq (proc->args.decls->decl.type, "void"))) - { - /* newstyle, 0 arguments */ - if (mtflag) - fprintf (fout, "\t return "); - else - fprintf (fout, "\t if "); - fprintf (fout, - "(clnt_call (clnt, %s, (xdrproc_t) xdr_void, ", proc->proc_name); - - fprintf (fout, - "(caddr_t) NULL,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,", - stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type), - RESULT); - if (mtflag) - fprintf (fout, "\n\t\tTIMEOUT));\n\n"); - else - fprintf (fout, "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); - } - else if (newstyle && args2) - { - /* newstyle, multiple arguments: stuff arguments into structure */ - for (l = proc->args.decls; l != NULL; l = l->next) - { - fprintf (fout, "\targ.%s = %s;\n", - l->decl.name, l->decl.name); - } - if (mtflag) - fprintf (fout, "\treturn "); - else - fprintf (fout, "\tif "); - - fprintf (fout, - "(clnt_call (clnt, %s, (xdrproc_t) xdr_%s", proc->proc_name, - proc->args.argname); - fprintf (fout, - ", (caddr_t) &arg,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,", - stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type), - RESULT); - if (mtflag) - fprintf (fout, "\n\t\tTIMEOUT));\n"); - else - fprintf (fout, "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); - } - else - { /* single argument, new or old style */ - if (!mtflag) - fprintf (fout, - "\tif (clnt_call (clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT) != RPC_SUCCESS) {\n", - proc->proc_name, - stringfix (proc->args.decls->decl.type), - (newstyle ? "&" : ""), - (newstyle ? proc->args.decls->decl.name : "argp"), - stringfix (proc->res_type), ampr (proc->res_type), - RESULT); - else - fprintf(fout, - "\treturn (clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT));\n", - proc->proc_name, - stringfix (proc->args.decls->decl.type), - (newstyle ? "&" : ""), - (newstyle ? proc->args.decls->decl.name : "argp"), - stringfix (proc->res_type), "", - RESULT); - } - if (!mtflag) - { - fprintf (fout, "\t\treturn (NULL);\n"); - fprintf (fout, "\t}\n"); - if (streq (proc->res_type, "void")) - { - fprintf (fout, "\treturn ((void *)%s%s);\n", - ampr (proc->res_type), RESULT); - } - else - { - fprintf (fout, "\treturn (%s%s);\n", ampr (proc->res_type), RESULT); - } - } -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_cout.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_cout.c deleted file mode 100644 index 4627110..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_cout.c +++ /dev/null @@ -1,813 +0,0 @@ -/* - * From: @(#)rpc_cout.c 1.13 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_cout.c, XDR routine outputter for the RPC protocol compiler - */ -#include -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static void emit_enum (definition * def); -static void emit_program (const definition * def); -static void emit_union (const definition * def); -static void emit_struct (definition * def); -static void emit_typedef (const definition * def); -static void emit_inline (int indent, declaration * decl, int flag); -static void emit_single_in_line (int indent, declaration *decl, int flag, - relation rel); -static int findtype (const definition * def, const char *type); -static int undefined (const char *type); -static void print_generic_header (const char *procname, int pointerp); -static void print_ifopen (int indent, const char *name); -static void print_ifarg (const char *arg); -static void print_ifsizeof (int indent, const char *prefix, const char *type); -static void print_ifclose (int indent); -static void print_ifstat (int indent, const char *prefix, const char *type, - relation rel, const char *amax, - const char *objname, const char *name); -static void print_stat (int indent, const declaration * dec); -static void print_header (const definition * def); -static void print_trailer (void); -static char *upcase (const char *str); - -/* - * Emit the C-routine for the given definition - */ -void -emit (definition * def) -{ - if (def->def_kind == DEF_CONST) - { - return; - } - if (def->def_kind == DEF_PROGRAM) - { - emit_program (def); - return; - } - if (def->def_kind == DEF_TYPEDEF) - { - /* now we need to handle declarations like - struct typedef foo foo; - since we don't want this to be expanded - into 2 calls to xdr_foo */ - - if (strcmp (def->def.ty.old_type, def->def_name) == 0) - return; - }; - - print_header (def); - switch (def->def_kind) - { - case DEF_UNION: - emit_union (def); - break; - case DEF_ENUM: - emit_enum (def); - break; - case DEF_STRUCT: - emit_struct (def); - break; - case DEF_TYPEDEF: - emit_typedef (def); - break; - default: - /* can't happen */ - break; - } - print_trailer (); -} - -static int -findtype (const definition * def, const char *type) -{ - if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) - { - return 0; - } - else - { - return (streq (def->def_name, type)); - } -} - -static int -undefined (const char *type) -{ - definition *def; - def = (definition *) FINDVAL (defined, type, findtype); - return (def == NULL); -} - - -static void -print_generic_header (const char *procname, int pointerp) -{ - f_print (fout, "\n"); - f_print (fout, "bool_t\n"); - if (Cflag) - { - f_print (fout, "xdr_%s (", procname); - f_print (fout, "XDR *xdrs, "); - f_print (fout, "%s ", procname); - if (pointerp) - f_print (fout, "*"); - f_print (fout, "objp)\n{\n"); - } - else - { - f_print (fout, "xdr_%s (xdrs, objp)\n", procname); - f_print (fout, "\tXDR *xdrs;\n"); - f_print (fout, "\t%s ", procname); - if (pointerp) - f_print (fout, "*"); - f_print (fout, "objp;\n{\n"); - } -} - -static void -print_header (const definition * def) -{ - print_generic_header (def->def_name, - def->def_kind != DEF_TYPEDEF || - !isvectordef (def->def.ty.old_type, - def->def.ty.rel)); - - /* Now add Inline support */ - - if (inlineflag == 0) - return; - /*May cause lint to complain. but ... */ - f_print (fout, "\tregister int32_t *buf;\n\n"); -} - -static void -print_prog_header (const proc_list * plist) -{ - print_generic_header (plist->args.argname, 1); -} - -static void -print_trailer (void) -{ - f_print (fout, "\treturn TRUE;\n"); - f_print (fout, "}\n"); -} - - -static void -print_ifopen (int indent, const char *name) -{ - tabify (fout, indent); - f_print (fout, " if (!xdr_%s (xdrs", name); -} - -static void -print_ifarg (const char *arg) -{ - f_print (fout, ", %s", arg); -} - -static void -print_ifsizeof (int indent, const char *prefix, const char *type) -{ - if (indent) - { - fprintf (fout, ",\n"); - tabify (fout, indent); - } - else - fprintf (fout, ", "); - - if (streq (type, "bool")) - fprintf (fout, "sizeof (bool_t), (xdrproc_t) xdr_bool"); - else - { - fprintf (fout, "sizeof ("); - if (undefined (type) && prefix) - { - f_print (fout, "%s ", prefix); - } - fprintf (fout, "%s), (xdrproc_t) xdr_%s", type, type); - } -} - -static void -print_ifclose (int indent) -{ - f_print (fout, "))\n"); - tabify (fout, indent); - f_print (fout, "\t return FALSE;\n"); -} - -static void -print_ifstat (int indent, const char *prefix, const char *type, relation rel, - const char *amax, const char *objname, const char *name) -{ - const char *alt = NULL; - - switch (rel) - { - case REL_POINTER: - print_ifopen (indent, "pointer"); - print_ifarg ("(char **)"); - f_print (fout, "%s", objname); - print_ifsizeof (0, prefix, type); - break; - case REL_VECTOR: - if (streq (type, "string")) - { - alt = "string"; - } - else if (streq (type, "opaque")) - { - alt = "opaque"; - } - if (alt) - { - print_ifopen (indent, alt); - print_ifarg (objname); - } - else - { - print_ifopen (indent, "vector"); - print_ifarg ("(char *)"); - f_print (fout, "%s", objname); - } - print_ifarg (amax); - if (!alt) - { - print_ifsizeof (indent + 1, prefix, type); - } - break; - case REL_ARRAY: - if (streq (type, "string")) - { - alt = "string"; - } - else if (streq (type, "opaque")) - { - alt = "bytes"; - } - if (streq (type, "string")) - { - print_ifopen (indent, alt); - print_ifarg (objname); - } - else - { - if (alt) - { - print_ifopen (indent, alt); - } - else - { - print_ifopen (indent, "array"); - } - print_ifarg ("(char **)"); - if (*objname == '&') - { - f_print (fout, "%s.%s_val, (u_int *) %s.%s_len", - objname, name, objname, name); - } - else - { - f_print (fout, "&%s->%s_val, (u_int *) &%s->%s_len", - objname, name, objname, name); - } - } - print_ifarg (amax); - if (!alt) - { - print_ifsizeof (indent + 1, prefix, type); - } - break; - case REL_ALIAS: - print_ifopen (indent, type); - print_ifarg (objname); - break; - } - print_ifclose (indent); -} - -static void -emit_enum (definition * def) -{ - (void) def; - - print_ifopen (1, "enum"); - print_ifarg ("(enum_t *) objp"); - print_ifclose (1); -} - -static void -emit_program (const definition * def) -{ - decl_list *dl; - version_list *vlist; - proc_list *plist; - - for (vlist = def->def.pr.versions; vlist != NULL; vlist = vlist->next) - for (plist = vlist->procs; plist != NULL; plist = plist->next) - { - if (!newstyle || plist->arg_num < 2) - continue; /* old style, or single argument */ - print_prog_header (plist); - for (dl = plist->args.decls; dl != NULL; - dl = dl->next) - print_stat (1, &dl->decl); - print_trailer (); - } -} - -#pragma GCC diagnostic ignored "-Wformat-nonliteral" -static void -emit_union (const definition * def) -{ - declaration *dflt; - case_list *cl; - declaration *cs; - char *object; - const char *vecformat = "objp->%s_u.%s"; - const char *format = "&objp->%s_u.%s"; - - print_stat (1, &def->def.un.enum_decl); - f_print (fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); - for (cl = def->def.un.cases; cl != NULL; cl = cl->next) - { - - f_print (fout, "\tcase %s:\n", cl->case_name); - if (cl->contflag == 1) /* a continued case statement */ - continue; - cs = &cl->case_decl; - if (!streq (cs->type, "void")) - { - object = alloc (strlen (def->def_name) + strlen (format) + - strlen (cs->name) + 1); - if (isvectordef (cs->type, cs->rel)) - { - s_print (object, vecformat, def->def_name, - cs->name); - } - else - { - s_print (object, format, def->def_name, - cs->name); - } - print_ifstat (2, cs->prefix, cs->type, cs->rel, cs->array_max, - object, cs->name); - free (object); - } - f_print (fout, "\t\tbreak;\n"); - } - dflt = def->def.un.default_decl; - if (dflt != NULL) - { - if (!streq (dflt->type, "void")) - { - f_print (fout, "\tdefault:\n"); - object = alloc (strlen (def->def_name) + strlen (format) + - strlen (dflt->name) + 1); - if (isvectordef (dflt->type, dflt->rel)) - { - s_print (object, vecformat, def->def_name, - dflt->name); - } - else - { - s_print (object, format, def->def_name, - dflt->name); - } - - print_ifstat (2, dflt->prefix, dflt->type, dflt->rel, - dflt->array_max, object, dflt->name); - free (object); - f_print (fout, "\t\tbreak;\n"); - } - else - { - f_print (fout, "\tdefault:\n"); - f_print (fout, "\t\tbreak;\n"); - } - } - else - { - f_print (fout, "\tdefault:\n"); - f_print (fout, "\t\treturn FALSE;\n"); - } - - f_print (fout, "\t}\n"); -} -#pragma GCC diagnostic warning "-Wformat-nonliteral" - -static void -inline_struct (definition *def, int flag) -{ - decl_list *dl; - int i, size; - decl_list *cur = NULL; - decl_list *psav; - bas_type *ptr; - char *sizestr; - const char *plus; - char ptemp[256]; - int indent = 1; - - if (flag == PUT) - f_print (fout, "\n\tif (xdrs->x_op == XDR_ENCODE) {\n"); - else - f_print (fout, - "\t\treturn TRUE;\n\t} else if (xdrs->x_op == XDR_DECODE) {\n"); - - i = 0; - size = 0; - sizestr = NULL; - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - { /* xxx */ - /* now walk down the list and check for basic types */ - if ((dl->decl.prefix == NULL) && - ((ptr = find_type (dl->decl.type)) != NULL) && - ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) - { - if (i == 0) - cur = dl; - ++i; - - if (dl->decl.rel == REL_ALIAS) - size += ptr->length; - else - { - /* this is required to handle arrays */ - if (sizestr == NULL) - plus = ""; - else - plus = "+ "; - - if (ptr->length != 1) - s_print (ptemp, " %s %s * %d", plus, dl->decl.array_max, - ptr->length); - else - s_print (ptemp, " %s%s ", plus, dl->decl.array_max); - - /*now concatenate to sizestr !!!! */ - if (sizestr == NULL) - sizestr = strdup (ptemp); - else - { - sizestr = realloc (sizestr, strlen (sizestr) + - strlen (ptemp) + 1); - if (sizestr == NULL) - { - f_print (stderr, "Fatal error : no memory \n"); - crash (); - }; - sizestr = strcat (sizestr, ptemp); - /*build up length of array */ - } - } - } - else - { - if (i > 0) - { - if (sizestr == NULL && size < inlineflag) - { - /* don't expand into inline code if size < inlineflag */ - while (cur != dl) - { - print_stat (indent + 1, &cur->decl); - cur = cur->next; - } - } - else - { - /* were already looking at a xdr_inlineable structure */ - tabify (fout, indent + 1); - if (sizestr == NULL) - f_print (fout, "buf = XDR_INLINE (xdrs, %d * BYTES_PER_XDR_UNIT);", size); - else if (size == 0) - f_print (fout, - "buf = XDR_INLINE (xdrs, (%s) * BYTES_PER_XDR_UNIT);", - sizestr); - else - f_print (fout, - "buf = XDR_INLINE (xdrs, (%d + (%s)) * BYTES_PER_XDR_UNIT);", - size, sizestr); - f_print (fout, "\n"); - tabify (fout, indent + 1); - fprintf (fout, "if (buf == NULL) {\n"); - psav = cur; - while (cur != dl) - { - print_stat (indent + 2, &cur->decl); - cur = cur->next; - } - - f_print (fout, "\n\t\t} else {\n"); - cur = psav; - while (cur != dl) - { - emit_inline (indent + 1, &cur->decl, flag); - cur = cur->next; - } - tabify (fout, indent + 1); - f_print (fout, "}\n"); - } - } - size = 0; - i = 0; - free (sizestr); - sizestr = NULL; - print_stat (indent + 1, &dl->decl); - } - } - if (i > 0) - { - if (sizestr == NULL && size < inlineflag) - { - /* don't expand into inline code if size < inlineflag */ - while (cur != dl) - { - print_stat (indent + 1, &cur->decl); - cur = cur->next; - } - } - else - { - /* were already looking at a xdr_inlineable structure */ - if (sizestr == NULL) - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, %d * BYTES_PER_XDR_UNIT);", - size); - else if (size == 0) - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, (%s) * BYTES_PER_XDR_UNIT);", - sizestr); - else - f_print (fout, - "\t\tbuf = XDR_INLINE (xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", - size, sizestr); - f_print (fout, "\n\t\tif (buf == NULL) {\n"); - psav = cur; - while (cur != NULL) - { - print_stat (indent + 2, &cur->decl); - cur = cur->next; - } - f_print (fout, "\t\t} else {\n"); - - cur = psav; - while (cur != dl) - { - emit_inline (indent + 2, &cur->decl, flag); - cur = cur->next; - } - f_print (fout, "\t\t}\n"); - } - } -} - -/* this may be const. i haven't traced this one through yet. */ - -static void -emit_struct (definition * def) -{ - decl_list *dl; - int j, size, flag; - bas_type *ptr; - int can_inline; - - - if (inlineflag == 0) - { - /* No xdr_inlining at all */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); - return; - } - - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - if (dl->decl.rel == REL_VECTOR) - { - f_print (fout, "\tint i;\n"); - break; - } - - size = 0; - can_inline = 0; - /* - * Make a first pass and see if inling is possible. - */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - if ((dl->decl.prefix == NULL) && - ((ptr = find_type (dl->decl.type)) != NULL) && - ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) - { - if (dl->decl.rel == REL_ALIAS) - size += ptr->length; - else - { - can_inline = 1; - break; /* can be inlined */ - } - } - else - { - if (size >= inlineflag) - { - can_inline = 1; - break; /* can be inlined */ - } - size = 0; - } - if (size > inlineflag) - can_inline = 1; - - if (can_inline == 0) - { /* can not inline, drop back to old mode */ - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); - return; - }; - - flag = PUT; - for (j = 0; j < 2; j++) - { - inline_struct (def, flag); - if (flag == PUT) - flag = GET; - } - - f_print (fout, "\t return TRUE;\n\t}\n\n"); - - /* now take care of XDR_FREE case */ - - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) - print_stat (1, &dl->decl); -} - -static void -emit_typedef (const definition * def) -{ - const char *prefix = def->def.ty.old_prefix; - const char *type = def->def.ty.old_type; - const char *amax = def->def.ty.array_max; - relation rel = def->def.ty.rel; - - print_ifstat (1, prefix, type, rel, amax, "objp", def->def_name); -} - -static void -print_stat (int indent, const declaration * dec) -{ - const char *prefix = dec->prefix; - const char *type = dec->type; - const char *amax = dec->array_max; - relation rel = dec->rel; - char name[256]; - - if (isvectordef (type, rel)) - { - s_print (name, "objp->%s", dec->name); - } - else - { - s_print (name, "&objp->%s", dec->name); - } - print_ifstat (indent, prefix, type, rel, amax, name, dec->name); -} - - -static void -emit_inline (int indent, declaration * decl, int flag) -{ - switch (decl->rel) - { - case REL_ALIAS: - emit_single_in_line (indent, decl, flag, REL_ALIAS); - break; - case REL_VECTOR: - tabify (fout, indent); - f_print (fout, "{\n"); - tabify (fout, indent + 1); - f_print (fout, "register %s *genp;\n\n", decl->type); - tabify (fout, indent + 1); - f_print (fout, - "for (i = 0, genp = objp->%s;\n", decl->name); - tabify (fout, indent + 2); - f_print (fout, "i < %s; ++i) {\n", decl->array_max); - emit_single_in_line (indent + 2, decl, flag, REL_VECTOR); - tabify (fout, indent + 1); - f_print (fout, "}\n"); - tabify (fout, indent); - f_print (fout, "}\n"); - break; - default: - break; - /* ?... do nothing I guess */ - } -} - -static void -emit_single_in_line (int indent, declaration *decl, int flag, relation rel) -{ - char *upp_case; - int freed = 0; - - tabify (fout, indent); - if (flag == PUT) - f_print (fout, "IXDR_PUT_"); - else - { - if (rel == REL_ALIAS) - f_print (fout, "objp->%s = IXDR_GET_", decl->name); - else - f_print (fout, "*genp++ = IXDR_GET_"); - } - - upp_case = upcase (decl->type); - - /* hack - XX */ - if (!strcmp (upp_case, "INT")) - { - free (upp_case); - freed = 1; - /* Casting is safe since the `freed' flag is set. */ - upp_case = (char *) "LONG"; - } - - if (!strcmp (upp_case, "U_INT")) - { - free (upp_case); - freed = 1; - /* Casting is safe since the `freed' flag is set. */ - upp_case = (char *) "U_LONG"; - } - - if (flag == PUT) - { - if (rel == REL_ALIAS) - f_print (fout, "%s(buf, objp->%s);\n", upp_case, decl->name); - else - f_print (fout, "%s(buf, *genp++);\n", upp_case); - } - else - { - f_print (fout, "%s(buf);\n", upp_case); - } - - if (!freed) - free (upp_case); -} - - -static char * -upcase (const char *str) -{ - char *ptr, *hptr; - ptr = malloc (strlen (str) + 1); - if (ptr == NULL) - { - f_print (stderr, "malloc failed\n"); - exit (1); - } - hptr = ptr; - while (*str != '\0') - *ptr++ = toupper (*str++); - - *ptr = '\0'; - return hptr; -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_hout.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_hout.c deleted file mode 100644 index 10f793d..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_hout.c +++ /dev/null @@ -1,607 +0,0 @@ -/* - * From: @(#)rpc_hout.c 1.12 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_hout.c, Header file outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static void pconstdef (definition * def); -static void pargdef (definition * def); -static void pstructdef (definition * def); -static void puniondef (definition * def); -static void pdefine (const char *name, const char *num); -static int define_printed (proc_list * stop, version_list * start); -static void pprogramdef (definition * def); -static void parglist (proc_list * proc, const char *addargtype); -static void penumdef (definition * def); -static void ptypedef (definition * def); -static int undefined2 (const char *type, const char *stop); - -/* store away enough information to allow the XDR functions to be spat - out at the end of the file */ - -static void -storexdrfuncdecl (const char *name, int pointerp) -{ - xdrfunc * xdrptr; - - xdrptr = (xdrfunc *) malloc(sizeof (struct xdrfunc)); - - xdrptr->name = (char *)name; - xdrptr->pointerp = pointerp; - xdrptr->next = NULL; - - if (xdrfunc_tail == NULL) - { - xdrfunc_head = xdrptr; - xdrfunc_tail = xdrptr; - } - else - { - xdrfunc_tail->next = xdrptr; - xdrfunc_tail = xdrptr; - } -} - -/* - * Print the C-version of an xdr definition - */ -void -print_datadef (definition *def) -{ - - if (def->def_kind == DEF_PROGRAM) /* handle data only */ - return; - - if (def->def_kind != DEF_CONST) - { - f_print (fout, "\n"); - } - switch (def->def_kind) - { - case DEF_STRUCT: - pstructdef (def); - break; - case DEF_UNION: - puniondef (def); - break; - case DEF_ENUM: - penumdef (def); - break; - case DEF_TYPEDEF: - ptypedef (def); - break; - case DEF_PROGRAM: - pprogramdef (def); - break; - case DEF_CONST: - pconstdef (def); - break; - } - if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) - { - storexdrfuncdecl(def->def_name, - def->def_kind != DEF_TYPEDEF || - !isvectordef(def->def.ty.old_type, - def->def.ty.rel)); - } -} - - -void -print_funcdef (definition *def) -{ - switch (def->def_kind) - { - case DEF_PROGRAM: - f_print (fout, "\n"); - pprogramdef (def); - break; - default: - break; - /* ?... shouldn't happen I guess */ - } -} - -void -print_xdr_func_def (char *name, int pointerp, int i) -{ - if (i == 2) - { - f_print (fout, "extern bool_t xdr_%s ();\n", name); - return; - } - else - f_print(fout, "extern bool_t xdr_%s (XDR *, %s%s);\n", name, - name, pointerp ? "*" : ""); -} - -static void -pconstdef (definition *def) -{ - pdefine (def->def_name, def->def.co); -} - -/* print out the definitions for the arguments of functions in the - header file - */ -static void -pargdef (definition * def) -{ - decl_list *l; - version_list *vers; - const char *name; - proc_list *plist; - - for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) - { - for (plist = vers->procs; plist != NULL; - plist = plist->next) - { - - if (!newstyle || plist->arg_num < 2) - { - continue; /* old style or single args */ - } - name = plist->args.argname; - f_print (fout, "struct %s {\n", name); - for (l = plist->args.decls; - l != NULL; l = l->next) - { - pdeclaration (name, &l->decl, 1, ";\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); - storexdrfuncdecl (name, 1); - f_print (fout, "\n"); - } - } - -} - -static void -pstructdef (definition *def) -{ - decl_list *l; - const char *name = def->def_name; - - f_print (fout, "struct %s {\n", name); - for (l = def->def.st.decls; l != NULL; l = l->next) - { - pdeclaration (name, &l->decl, 1, ";\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); -} - -static void -puniondef (definition *def) -{ - case_list *l; - const char *name = def->def_name; - declaration *decl; - - f_print (fout, "struct %s {\n", name); - decl = &def->def.un.enum_decl; - if (streq (decl->type, "bool")) - { - f_print (fout, "\tbool_t %s;\n", decl->name); - } - else - { - f_print (fout, "\t%s %s;\n", decl->type, decl->name); - } - f_print (fout, "\tunion {\n"); - for (l = def->def.un.cases; l != NULL; l = l->next) - { - if (l->contflag == 0) - pdeclaration (name, &l->case_decl, 2, ";\n"); - } - decl = def->def.un.default_decl; - if (decl && !streq (decl->type, "void")) - { - pdeclaration (name, decl, 2, ";\n"); - } - f_print (fout, "\t} %s_u;\n", name); - f_print (fout, "};\n"); - f_print (fout, "typedef struct %s %s;\n", name, name); -} - -static void -pdefine (const char *name, const char *num) -{ - f_print (fout, "#define %s %s\n", name, num); -} - -static int -define_printed (proc_list *stop, version_list *start) -{ - version_list *vers; - proc_list *proc; - - for (vers = start; vers != NULL; vers = vers->next) - { - for (proc = vers->procs; proc != NULL; proc = proc->next) - { - if (proc == stop) - { - return 0; - } - else if (streq (proc->proc_name, stop->proc_name)) - { - return 1; - } - } - } - abort (); - /* NOTREACHED */ -} - -static void -pfreeprocdef (const char *name, const char *vers, int mode) -{ - f_print (fout, "extern int "); - pvname (name, vers); - if (mode == 1) - f_print (fout,"_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n"); - else - f_print (fout,"_freeresult ();\n"); -} - -static void -pprogramdef (definition *def) -{ - version_list *vers; - proc_list *proc; - int i; - const char *ext; - - pargdef (def); - - pdefine (def->def_name, def->def.pr.prog_num); - for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) - { - if (tblflag) - { - f_print (fout, "extern struct rpcgen_table %s_%s_table[];\n", - locase (def->def_name), vers->vers_num); - f_print (fout, "extern %s_%s_nproc;\n", - locase (def->def_name), vers->vers_num); - } - pdefine (vers->vers_name, vers->vers_num); - - /* - * Print out 2 definitions, one for ANSI-C, another for - * old K & R C - */ - - if(!Cflag) - { - ext = "extern "; - for (proc = vers->procs; proc != NULL; - proc = proc->next) - { - if (!define_printed(proc, def->def.pr.versions)) - { - pdefine (proc->proc_name, proc->proc_num); - } - f_print (fout, "%s", ext); - pprocdef (proc, vers, NULL, 0, 2); - - if (mtflag) - { - f_print(fout, "%s", ext); - pprocdef (proc, vers, NULL, 1, 2); - } - } - pfreeprocdef (def->def_name, vers->vers_num, 2); - } - else - { - for (i = 1; i < 3; i++) - { - if (i == 1) - { - f_print (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n"); - ext = "extern "; - } - else - { - f_print (fout, "\n#else /* K&R C */\n"); - ext = "extern "; - } - - for (proc = vers->procs; proc != NULL; proc = proc->next) - { - if (!define_printed(proc, def->def.pr.versions)) - { - pdefine(proc->proc_name, proc->proc_num); - } - f_print (fout, "%s", ext); - pprocdef (proc, vers, "CLIENT *", 0, i); - f_print (fout, "%s", ext); - pprocdef (proc, vers, "struct svc_req *", 1, i); - } - pfreeprocdef (def->def_name, vers->vers_num, i); - } - f_print (fout, "#endif /* K&R C */\n"); - } - } -} - -void -pprocdef (proc_list * proc, version_list * vp, - const char *addargtype, int server_p, int mode) -{ - if (mtflag) - {/* Print MT style stubs */ - if (server_p) - f_print (fout, "bool_t "); - else - f_print (fout, "enum clnt_stat "); - } - else - { - ptype (proc->res_prefix, proc->res_type, 1); - f_print (fout, "* "); - } - if (server_p) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - - /* - * mode 1 = ANSI-C, mode 2 = K&R C - */ - if (mode == 1) - parglist (proc, addargtype); - else - f_print (fout, "();\n"); -} - -/* print out argument list of procedure */ -static void -parglist (proc_list *proc, const char *addargtype) -{ - decl_list *dl; - - f_print(fout,"("); - if (proc->arg_num < 2 && newstyle && - streq (proc->args.decls->decl.type, "void")) - { - /* 0 argument in new style: do nothing */ - } - else - { - for (dl = proc->args.decls; dl != NULL; dl = dl->next) - { - ptype (dl->decl.prefix, dl->decl.type, 1); - if (!newstyle) - f_print (fout, "*"); /* old style passes by reference */ - - f_print (fout, ", "); - } - } - if (mtflag) - { - ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*, "); - } - - f_print (fout, "%s);\n", addargtype); -} - -static void -penumdef (definition *def) -{ - const char *name = def->def_name; - enumval_list *l; - const char *last = NULL; - int count = 0; - - f_print (fout, "enum %s {\n", name); - for (l = def->def.en.vals; l != NULL; l = l->next) - { - f_print (fout, "\t%s", l->name); - if (l->assignment) - { - f_print (fout, " = %s", l->assignment); - last = l->assignment; - count = 1; - } - else - { - if (last == NULL) - { - f_print (fout, " = %d", count++); - } - else - { - f_print (fout, " = %s + %d", last, count++); - } - } - f_print (fout, ",\n"); - } - f_print (fout, "};\n"); - f_print (fout, "typedef enum %s %s;\n", name, name); -} - -static void -ptypedef (definition *def) -{ - const char *name = def->def_name; - const char *old = def->def.ty.old_type; - char prefix[8]; /* enough to contain "struct ", including NUL */ - relation rel = def->def.ty.rel; - - if (!streq (name, old)) - { - if (streq (old, "string")) - { - old = "char"; - rel = REL_POINTER; - } - else if (streq (old, "opaque")) - { - old = "char"; - } - else if (streq (old, "bool")) - { - old = "bool_t"; - } - if (undefined2 (old, name) && def->def.ty.old_prefix) - { - s_print (prefix, "%s ", def->def.ty.old_prefix); - } - else - { - prefix[0] = 0; - } - f_print (fout, "typedef "); - switch (rel) - { - case REL_ARRAY: - f_print (fout, "struct {\n"); - f_print (fout, "\tu_int %s_len;\n", name); - f_print (fout, "\t%s%s *%s_val;\n", prefix, old, name); - f_print (fout, "} %s", name); - break; - case REL_POINTER: - f_print (fout, "%s%s *%s", prefix, old, name); - break; - case REL_VECTOR: - f_print (fout, "%s%s %s[%s]", prefix, old, name, - def->def.ty.array_max); - break; - case REL_ALIAS: - f_print (fout, "%s%s %s", prefix, old, name); - break; - } - f_print (fout, ";\n"); - } -} - -void -pdeclaration (const char *name, declaration * dec, int tab, - const char *separator) -{ - char buf[8]; /* enough to hold "struct ", include NUL */ - const char *prefix; - const char *type; - - if (streq (dec->type, "void")) - { - return; - } - tabify (fout, tab); - if (streq (dec->type, name) && !dec->prefix) - { - f_print (fout, "struct "); - } - if (streq (dec->type, "string")) - { - f_print (fout, "char *%s", dec->name); - } - else - { - prefix = ""; - if (streq (dec->type, "bool")) - { - type = "bool_t"; - } - else if (streq (dec->type, "opaque")) - { - type = "char"; - } - else - { - if (dec->prefix) - { - s_print (buf, "%s ", dec->prefix); - prefix = buf; - } - type = dec->type; - } - switch (dec->rel) - { - case REL_ALIAS: - f_print (fout, "%s%s %s", prefix, type, dec->name); - break; - case REL_VECTOR: - f_print (fout, "%s%s %s[%s]", prefix, type, dec->name, - dec->array_max); - break; - case REL_POINTER: - f_print (fout, "%s%s *%s", prefix, type, dec->name); - break; - case REL_ARRAY: - f_print (fout, "struct {\n"); - tabify (fout, tab); - f_print (fout, "\tu_int %s_len;\n", dec->name); - tabify (fout, tab); - f_print (fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); - tabify (fout, tab); - f_print (fout, "} %s", dec->name); - break; - } - } - f_print (fout, "%s", separator); -} - -static int -undefined2 (const char *type, const char *stop) -{ - list *l; - definition *def; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - if (streq (def->def_name, stop)) - { - return 1; - } - else if (streq (def->def_name, type)) - { - return 0; - } - } - } - return 1; -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_main.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_main.c deleted file mode 100644 index 1b26e52..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_main.c +++ /dev/null @@ -1,1453 +0,0 @@ -/* - * From @(#)rpc_main.c 1.30 89/03/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_main.c, Top level of the RPC protocol compiler. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "rpc_scan.h" -#include "proto.h" - -#ifndef _ -#define _(String) gettext (String) -#endif - -#define EXTEND 1 /* alias for TRUE */ -#define DONT_EXTEND 0 /* alias for FALSE */ - -struct commandline - { - int cflag; /* xdr C routines */ - int hflag; /* header file */ - int lflag; /* client side stubs */ - int mflag; /* server side stubs */ - int nflag; /* netid flag */ - int sflag; /* server stubs for the given transport */ - int tflag; /* dispatch Table file */ - int Ssflag; /* produce server sample code */ - int Scflag; /* produce client sample code */ - int makefileflag; /* Generate a template Makefile */ - const char *infile; /* input module name */ - const char *outfile; /* output module name */ - }; - - -static const char *cmdname; - -static const char *svcclosetime = "120"; -static int cppDefined; /* explicit path for C preprocessor */ -static const char *CPP = "/lib/cpp"; -static const char CPPFLAGS[] = "-C"; -static char *pathbuf; -static int cpp_pid; -static const char *allv[] = -{ - "rpcgen", "-s", "udp", "-s", "tcp" -}; -static int allc = sizeof (allv) / sizeof (allv[0]); -static const char *allnv[] = -{ - "rpcgen", "-s", "netpath", -}; -static int allnc = sizeof (allnv) / sizeof (allnv[0]); - -/* - * machinations for handling expanding argument list - */ -static void addarg (const char *); /* add another argument to the list */ -static void putarg (int, const char *); /* put argument at specified location */ -static void clear_args (void); /* clear argument list */ -static void checkfiles (const char *, const char *); - /* check if out file already exists */ - -static void clear_args (void); -static char *extendfile (const char *file, const char *ext); -static void open_output (const char *infile, const char *outfile); -static void add_warning (void); -static void clear_args (void); -static void find_cpp (void); -static void open_input (const char *infile, const char *define); -static int check_nettype (const char *name, const char *list_to_check[]); -static void c_output (const char *infile, const char *define, - int extend, const char *outfile); -static void h_output (const char *infile, const char *define, - int extend, const char *outfile); -static void s_output (int argc, const char *argv[], const char *infile, - const char *define, int extend, - const char *outfile, int nomain, int netflag); -static void l_output (const char *infile, const char *define, - int extend, const char *outfile); -static void t_output (const char *infile, const char *define, - int extend, const char *outfile); -static void svc_output (const char *infile, const char *define, - int extend, const char *outfile); -static void clnt_output (const char *infile, const char *define, - int extend, const char *outfile); -static void mkfile_output (struct commandline *cmd); -static int do_registers (int argc, const char *argv[]); -static void addarg (const char *cp); -static void putarg (int whereto, const char *cp); -static void checkfiles (const char *infile, const char *outfile); -static int parseargs (int argc, const char *argv[], struct commandline *cmd); -static void usage (FILE *stream, int status) __attribute__ ((noreturn)); -static void options_usage (FILE *stream, int status) __attribute__ ((noreturn)); -static void print_version (void); -static void c_initialize (void); -static char *generate_guard (const char *pathname); - - -#define ARGLISTLEN 20 -#define FIXEDARGS 2 - -static const char *arglist[ARGLISTLEN]; -static int argcount = FIXEDARGS; - - -int nonfatalerrors; /* errors */ -int inetdflag /* = 1 */ ; /* Support for inetd *//* is now the default */ -int pmflag; /* Support for port monitors */ -int logflag; /* Use syslog instead of fprintf for errors */ -int tblflag; /* Support for dispatch table file */ -int mtflag; /* Support for MT */ - -#define INLINE 3 -/*length at which to start doing an inline */ - -int inlineflag = INLINE; /* length at which to start doing an inline. 3 = default - if 0, no xdr_inline code */ - -int indefinitewait; /* If started by port monitors, hang till it wants */ -int exitnow; /* If started by port monitors, exit after the call */ -int timerflag; /* TRUE if !indefinite && !exitnow */ -int newstyle; /* newstyle of passing arguments (by value) */ -int Cflag = 1; /* ANSI C syntax */ -int CCflag; /* C++ files */ -static int allfiles; /* generate all files */ -int tirpcflag; /* generating code for tirpc, default is backward compatibility */ -xdrfunc *xdrfunc_head; /* xdr function list */ -xdrfunc *xdrfunc_tail; /* xdr function list */ - -int -main (int argc, const char *argv[]) -{ - struct commandline cmd; - - setlocale (LC_ALL, ""); - textdomain (PACKAGE); - - (void) memset ((char *) &cmd, 0, sizeof (struct commandline)); - clear_args (); - if (!parseargs (argc, argv, &cmd)) - usage (stderr, 1); - - if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag || - cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) - { - checkfiles (cmd.infile, cmd.outfile); - } - else - checkfiles (cmd.infile, NULL); - - if (cmd.cflag) - c_output (cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile); - else if (cmd.hflag) - h_output (cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile); - else if (cmd.lflag) - l_output (cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile); - else if (cmd.sflag || cmd.mflag || (cmd.nflag)) - s_output (argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND, - cmd.outfile, cmd.mflag, cmd.nflag); - else if (cmd.tflag) - t_output (cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile); - else if (cmd.Ssflag) - svc_output (cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile); - else if (cmd.Scflag) - clnt_output (cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile); - else if (cmd.makefileflag) - mkfile_output (&cmd); - else - { - /* the rescans are required, since cpp may effect input */ - c_output (cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); - reinitialize (); - h_output (cmd.infile, "-DRPC_HDR", EXTEND, ".h"); - reinitialize (); - l_output (cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); - reinitialize (); - if (inetdflag || !tirpcflag) - s_output (allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, - "_svc.c", cmd.mflag, cmd.nflag); - else - s_output (allnc, allnv, cmd.infile, "-DRPC_SVC", - EXTEND, "_svc.c", cmd.mflag, cmd.nflag); - if (tblflag) - { - reinitialize (); - t_output (cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i"); - } - if (allfiles) - { - reinitialize (); - svc_output (cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c"); - reinitialize (); - clnt_output (cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c"); - } - if (allfiles || (cmd.makefileflag == 1)) - { - reinitialize (); - mkfile_output (&cmd); - } - } - - return nonfatalerrors; -} - -/* - * add extension to filename - */ -static char * -extendfile (const char *file, const char *ext) -{ - char *res; - const char *p; - - res = alloc (strlen (file) + strlen (ext) + 1); - if (res == NULL) - abort (); - p = strrchr (file, '.'); - if (p == NULL) - p = file + strlen (file); - strcpy (res, file); - strcpy (res + (p - file), ext); - return res; -} - -/* - * Open output file with given extension - */ -static void -open_output (const char *infile, const char *outfile) -{ - if (outfile == NULL) - { - fout = stdout; - return; - } - - if (infile != NULL && streq (outfile, infile)) - { - fprintf (stderr, _("%s: output would overwrite %s\n"), cmdname, - infile); - crash (); - } - fout = fopen (outfile, "w"); - if (fout == NULL) - { - fprintf (stderr, _("%s: unable to open %s: %m\n"), cmdname, outfile); - crash (); - } - record_open (outfile); -} - -/* Close the output file and check for write errors. */ -static void -close_output (const char *outfile) -{ - if (fclose (fout) == EOF) - { - fprintf (stderr, _("%s: while writing output %s: %m"), cmdname, - outfile ?: ""); - crash (); - } -} - -static void -add_warning (void) -{ - fprintf (fout, "/*\n"); - fprintf (fout, " * Please do not edit this file.\n"); - fprintf (fout, " * It was generated using rpcgen.\n"); - fprintf (fout, " */\n\n"); -} - -/* clear list of arguments */ -static void -clear_args (void) -{ - int i; - for (i = FIXEDARGS; i < ARGLISTLEN; ++i) - arglist[i] = NULL; - argcount = FIXEDARGS; -} - -/* make sure that a CPP exists */ -static void -find_cpp (void) -{ - struct stat64 buf; - - if (stat64 (CPP, &buf) == 0) - return; - - if (cppDefined) /* user specified cpp but it does not exist */ - { - fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); - crash (); - } - - /* fall back to system CPP */ - CPP = "cpp"; -} - -/* - * Open input file with given define for C-preprocessor - */ -static void -open_input (const char *infile, const char *define) -{ - int pd[2]; - - infilename = (infile == NULL) ? "" : infile; - if (pipe (pd) != 0) - { - perror ("pipe"); - exit (1); - } - cpp_pid = fork (); - switch (cpp_pid) - { - case 0: - find_cpp (); - putarg (0, CPP); - putarg (1, CPPFLAGS); - addarg (define); - if (infile) - addarg (infile); - addarg ((char *) NULL); - close (1); - dup2 (pd[1], 1); - close (pd[0]); - execvp (arglist[0], (char **) arglist); - if (errno == ENOENT) - { - fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); - exit (1); - } - perror ("execvp"); - exit (1); - case -1: - perror ("fork"); - exit (1); - } - close (pd[1]); - fin = fdopen (pd[0], "r"); - if (fin == NULL) - { - fprintf (stderr, "%s: ", cmdname); - perror (infilename); - crash (); - } -} - -/* Close the connection to the C-preprocessor and check for successfull - termination. */ -static void -close_input (void) -{ - int status; - - fclose (fin); - /* Check the termination status. */ - if (waitpid (cpp_pid, &status, 0) < 0) - { - perror ("waitpid"); - crash (); - } - if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) - { - if (WIFSIGNALED (status)) - fprintf (stderr, _("%s: C preprocessor failed with signal %d\n"), - cmdname, WTERMSIG (status)); - else - fprintf (stderr, _("%s: C preprocessor failed with exit code %d\n"), - cmdname, WEXITSTATUS (status)); - crash (); - } -} - -/* valid tirpc nettypes */ -static const char *valid_ti_nettypes[] = -{ - "netpath", - "visible", - "circuit_v", - "datagram_v", - "circuit_n", - "datagram_n", - "udp", - "tcp", - "raw", - NULL -}; - -/* valid inetd nettypes */ -static const char *valid_i_nettypes[] = -{ - "udp", - "tcp", - NULL -}; - -static int -check_nettype (const char *name, const char *list_to_check[]) -{ - int i; - for (i = 0; list_to_check[i] != NULL; i++) - { - if (strcmp (name, list_to_check[i]) == 0) - { - return 1; - } - } - fprintf (stderr, _ ("illegal nettype: `%s'\n"), name); - return 0; -} - -/* - * Compile into an XDR routine output file - */ - -static void -c_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - - c_initialize (); - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - /* .h file already contains rpc/rpc.h */ - } - else - fprintf (fout, "#include \n"); - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - emit (def); - - if (extend && tell == ftell (fout)) - unlink (outfilename); - close_input (); - close_output (outfilename); -} - -void -c_initialize (void) -{ - - /* add all the starting basic types */ - - add_type (1, "int"); - add_type (1, "long"); - add_type (1, "short"); - add_type (1, "bool"); - - add_type (1, "u_int"); - add_type (1, "u_long"); - add_type (1, "u_short"); - -} - -char rpcgen_table_dcl[] = "struct rpcgen_table {\n\ - char *(*proc)();\n\ - xdrproc_t xdr_arg;\n\ - unsigned len_arg;\n\ - xdrproc_t xdr_res;\n\ - unsigned len_res;\n\ -};\n"; - - -static char * -generate_guard (const char *pathname) -{ - const char *filename; - char *guard, *tmp; - - filename = strrchr (pathname, '/'); /* find last component */ - filename = ((filename == NULL) ? pathname : filename + 1); - guard = extendfile (filename, "_H_RPCGEN"); - /* convert to upper case */ - tmp = guard; - while (*tmp) - { - if (islower (*tmp)) - *tmp = toupper (*tmp); - tmp++; - } - - return guard; -} - -/* - * Compile into an XDR header file - */ - - -static void -h_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - xdrfunc *xdrfuncp; - definition *def; - const char *ifilename; - const char *outfilename; - long tell; - char *guard; - list *l; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - ifilename = (infile == NULL) ? "STDIN" : infile; - guard = generate_guard (outfilename ? outfilename : ifilename); - - fprintf (fout, "#ifndef _%s\n#define _%s\n\n", guard, - guard); - - fprintf (fout, "#include \n\n"); - - if (mtflag) - { - fprintf (fout, "#include \n"); - } - - /* put the C++ support */ - if (Cflag && !CCflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "extern \"C\" {\n"); - fprintf (fout, "#endif\n\n"); - } - - tell = ftell (fout); - /* print data definitions */ - while ((def = get_definition ()) != NULL) - { - print_datadef (def); - } - - /* print function declarations. - Do this after data definitions because they might be used as - arguments for functions */ - for (l = defined; l != NULL; l = l->next) - { - print_funcdef (l->val); - } - /* Now print all xdr func declarations */ - if (xdrfunc_head != NULL) - { - fprintf (fout, "\n/* the xdr functions */\n"); - if (CCflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "extern \"C\" {\n"); - fprintf (fout, "#endif\n"); - } - if (!Cflag) - { - xdrfuncp = xdrfunc_head; - while (xdrfuncp != NULL) - { - print_xdr_func_def (xdrfuncp->name, - xdrfuncp->pointerp, 2); - xdrfuncp = xdrfuncp->next; - } - } - else - { - int i; - - for (i = 1; i < 3; ++i) - { - if (i == 1) - fprintf (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n"); - else - fprintf (fout, "\n#else /* K&R C */\n"); - - xdrfuncp = xdrfunc_head; - while (xdrfuncp != NULL) - { - print_xdr_func_def (xdrfuncp->name, - xdrfuncp->pointerp, i); - xdrfuncp = xdrfuncp->next; - } - } - fprintf (fout, "\n#endif /* K&R C */\n"); - } - } - - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - else if (tblflag) - { - fprintf (fout, "%s", rpcgen_table_dcl); - } - - if (Cflag) - { - fprintf (fout, "\n#ifdef __cplusplus\n"); - fprintf (fout, "}\n"); - fprintf (fout, "#endif\n"); - } - - fprintf (fout, "\n#endif /* !_%s */\n", guard); - free (guard); - close_input (); - close_output (outfilename); -} - -/* - * Compile into an RPC service - */ -static void -s_output (int argc, const char *argv[], const char *infile, const char *define, - int extend, const char *outfile, int nomain, int netflag) -{ - char *include; - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - if (Cflag) - fprintf (fout, "#include \n"); - if (strcmp (svcclosetime, "-1") == 0) - indefinitewait = 1; - else if (strcmp (svcclosetime, "0") == 0) - exitnow = 1; - else if (inetdflag || pmflag) - { - fprintf (fout, "#include \n"); - timerflag = 1; - } - - if (!tirpcflag && inetdflag) - fprintf (fout, "#include /* ioctl, TIOCNOTTY */\n"); - if (Cflag && (inetdflag || pmflag)) - { - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* open */\n"); - fprintf (fout, "#include /* getdtablesize */\n"); - } - if (tirpcflag && !(Cflag && (inetdflag || pmflag))) - fprintf (fout, "#include \n"); - - fprintf (fout, "#include \n"); - if (inetdflag || !tirpcflag) - { - fprintf (fout, "#include \n"); - fprintf (fout, "#include \n"); - } - - if ((netflag || pmflag) && tirpcflag && !nomain) - { - fprintf (fout, "#include \n"); - } - if ( /*timerflag && */ tirpcflag) - fprintf (fout, "#include /* rlimit */\n"); - if (logflag || inetdflag || pmflag) - { - fprintf (fout, "#include \n"); - } - - /* for ANSI-C */ - if (Cflag) - fprintf (fout, "\n#ifndef SIG_PF\n#define SIG_PF void(*)(int)\n#endif\n"); - - if (timerflag) - fprintf (fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_most (infile, netflag, nomain); - if (!nomain) - { - if (!do_registers (argc, argv)) - { - if (outfilename) - unlink (outfilename); - usage (stderr, 1); - } - write_rest (); - } - close_input (); - close_output (outfilename); -} - -/* - * generate client side stubs - */ -static void -l_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - char *include; - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - if (Cflag) - fprintf (fout, "#include /* for memset */\n"); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_stubs (); - close_input (); - close_output (outfilename); -} - -/* - * generate the dispatch table - */ -static void -t_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - int foundprogram = 0; - const char *outfilename; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - open_output (infile, outfilename); - add_warning (); - while ((def = get_definition ()) != NULL) - { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) - { - unlink (outfilename); - return; - } - write_tables (); - close_input (); - close_output (outfilename); -} - -/* sample routine for the server template */ -static void -svc_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - checkfiles (infile, outfilename); - /*check if outfile already exists. - if so, print an error message and exit */ - open_output (infile, outfilename); - add_sample_msg (); - - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - { - write_sample_svc (def); - } - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - close_input (); - close_output (outfilename); -} - - -/* sample main routine for client */ -static void -clnt_output (const char *infile, const char *define, int extend, - const char *outfile) -{ - definition *def; - char *include; - const char *outfilename; - long tell; - int has_program = 0; - - open_input (infile, define); - outfilename = extend ? extendfile (infile, outfile) : outfile; - checkfiles (infile, outfilename); - /*check if outfile already exists. - if so, print an error message and exit */ - - open_output (infile, outfilename); - add_sample_msg (); - if (infile && (include = extendfile (infile, ".h"))) - { - fprintf (fout, "#include \"%s\"\n", include); - free (include); - } - else - fprintf (fout, "#include \n"); - tell = ftell (fout); - while ((def = get_definition ()) != NULL) - { - has_program += write_sample_clnt (def); - } - - if (has_program) - write_sample_clnt_main (); - - if (extend && tell == ftell (fout)) - { - unlink (outfilename); - } - close_input (); - close_output (outfilename); -} - -static const char space[] = " "; - -static char * -file_name (const char *file, const char *ext) -{ - char *temp; - temp = extendfile (file, ext); - - if (access (temp, F_OK) != -1) - return (temp); - - free (temp); - return (char *) space; -} - -static void -mkfile_output (struct commandline *cmd) -{ - char *mkfilename; - char *clientname, *clntname, *xdrname, *hdrname; - char *servername, *svcname, *servprogname, *clntprogname; - - svcname = file_name (cmd->infile, "_svc.c"); - clntname = file_name (cmd->infile, "_clnt.c"); - xdrname = file_name (cmd->infile, "_xdr.c"); - hdrname = file_name (cmd->infile, ".h"); - - if (allfiles) - { - servername = extendfile (cmd->infile, "_server.c"); - clientname = extendfile (cmd->infile, "_client.c"); - } - else - { - servername = (char *) space; - clientname = (char *) space; - } - servprogname = extendfile (cmd->infile, "_server"); - clntprogname = extendfile (cmd->infile, "_client"); - - if (allfiles) - { - char *cp, *temp; - - mkfilename = alloc (strlen ("Makefile.") + strlen (cmd->infile) + 1); - if (mkfilename == NULL) - abort (); - temp = rindex (cmd->infile, '.'); - cp = stpcpy (mkfilename, "Makefile."); - if (temp != NULL) - *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0'; - else - stpcpy (cp, cmd->infile); - - } - else - mkfilename = (char *) cmd->outfile; - - checkfiles (NULL, mkfilename); - open_output (NULL, mkfilename); - - fprintf (fout, "\n# This is a template Makefile generated by rpcgen\n"); - - f_print (fout, "\n# Parameters\n\n"); - - f_print (fout, "CLIENT = %s\nSERVER = %s\n\n", clntprogname, servprogname); - f_print (fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n"); - f_print (fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n"); - f_print (fout, "SOURCES.x = %s\n\n", cmd->infile); - f_print (fout, "TARGETS_SVC.c = %s %s %s \n", - svcname, servername, xdrname); - f_print (fout, "TARGETS_CLNT.c = %s %s %s \n", - clntname, clientname, xdrname); - f_print (fout, "TARGETS = %s %s %s %s %s %s\n\n", - hdrname, xdrname, clntname, - svcname, clientname, servername); - - f_print (fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \ -$(TARGETS_CLNT.c:%%.c=%%.o)"); - - f_print (fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \ -$(TARGETS_SVC.c:%%.c=%%.o)"); - - f_print (fout, "\n# Compiler flags \n"); - if (mtflag) - fprintf (fout, "\nCPPFLAGS += -D_REENTRANT\nCFLAGS += -g \nLDLIBS \ -+= -lnsl -lpthread \n "); - else - f_print (fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n"); - f_print (fout, "RPCGENFLAGS = \n"); - - f_print (fout, "\n# Targets \n\n"); - - f_print (fout, "all : $(CLIENT) $(SERVER)\n\n"); - f_print (fout, "$(TARGETS) : $(SOURCES.x) \n"); - f_print (fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n"); - f_print (fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \ -$(TARGETS_CLNT.c) \n\n"); - - f_print (fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \ -$(TARGETS_SVC.c) \n\n"); - f_print (fout, "$(CLIENT) : $(OBJECTS_CLNT) \n"); - f_print (fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \ -$(LDLIBS) \n\n"); - f_print (fout, "$(SERVER) : $(OBJECTS_SVC) \n"); - f_print (fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n "); - f_print (fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \ -$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n"); - close_output (mkfilename); - - free (clntprogname); - free (servprogname); - if (servername != space) - free (servername); - if (clientname != space) - free (clientname); - if (mkfilename != (char *) cmd->outfile) - free (mkfilename); - if (svcname != space) - free (svcname); - if (clntname != space) - free (clntname); - if (xdrname != space) - free (xdrname); - if (hdrname != space) - free (hdrname); -} - -/* - * Perform registrations for service output - * Return 0 if failed; 1 otherwise. - */ -static int -do_registers (int argc, const char *argv[]) -{ - int i; - - if (inetdflag || !tirpcflag) - { - for (i = 1; i < argc; i++) - { - if (streq (argv[i], "-s")) - { - if (!check_nettype (argv[i + 1], valid_i_nettypes)) - return 0; - write_inetd_register (argv[i + 1]); - i++; - } - } - } - else - { - for (i = 1; i < argc; i++) - if (streq (argv[i], "-s")) - { - if (!check_nettype (argv[i + 1], valid_ti_nettypes)) - return 0; - write_nettype_register (argv[i + 1]); - i++; - } - else if (streq (argv[i], "-n")) - { - write_netid_register (argv[i + 1]); - i++; - } - } - return 1; -} - -/* - * Add another argument to the arg list - */ -static void -addarg (const char *cp) -{ - if (argcount >= ARGLISTLEN) - { - fprintf (stderr, _("rpcgen: too many defines\n")); - crash (); - /*NOTREACHED */ - } - arglist[argcount++] = cp; -} - -static void -putarg (int whereto, const char *cp) -{ - if (whereto >= ARGLISTLEN) - { - fprintf (stderr, _("rpcgen: arglist coding error\n")); - crash (); - /*NOTREACHED */ - } - arglist[whereto] = cp; -} - -/* - * if input file is stdin and an output file is specified then complain - * if the file already exists. Otherwise the file may get overwritten - * If input file does not exist, exit with an error - */ - -static void -checkfiles (const char *infile, const char *outfile) -{ - struct stat64 buf; - - if (infile) /* infile ! = NULL */ - if (stat64 (infile, &buf) < 0) - { - perror (infile); - crash (); - } - if (outfile) - { - if (stat64 (outfile, &buf) < 0) - return; /* file does not exist */ - else - { - fprintf (stderr, - /* TRANS: the file will not be removed; this is an - TRANS: informative message. */ - _("file `%s' already exists and may be overwritten\n"), - outfile); - crash (); - } - } -} - -/* - * Parse command line arguments - */ -static int -parseargs (int argc, const char *argv[], struct commandline *cmd) -{ - int i; - int j; - int c; - char flag[(1 << 8 * sizeof (char))]; - int nflags; - - cmdname = argv[0]; - cmd->infile = cmd->outfile = NULL; - if (argc < 2) - { - return (0); - } - allfiles = 0; - flag['c'] = 0; - flag['h'] = 0; - flag['l'] = 0; - flag['m'] = 0; - flag['o'] = 0; - flag['s'] = 0; - flag['n'] = 0; - flag['t'] = 0; - flag['S'] = 0; - flag['C'] = 0; - flag['M'] = 0; - - for (i = 1; i < argc; i++) - { - if (argv[i][0] != '-') - { - if (cmd->infile) - { - fprintf (stderr, - _("Cannot specify more than one input file!\n")); - return 0; - } - cmd->infile = argv[i]; - } - else if (strcmp (argv[i], "--help") == 0) - usage (stdout, 0); - else if (strcmp (argv[i], "--version") == 0) - print_version (); - else - { - for (j = 1; argv[i][j] != 0; j++) - { - c = argv[i][j]; - switch (c) - { - case 'a': - allfiles = 1; - break; - case 'c': - case 'h': - case 'l': - case 'm': - case 't': - if (flag[c]) - return 0; - flag[c] = 1; - break; - case 'S': - /* sample flag: Ss or Sc. - Ss means set flag['S']; - Sc means set flag['C']; - Sm means set flag['M']; */ - c = argv[i][++j]; /* get next char */ - if (c == 's') - c = 'S'; - else if (c == 'c') - c = 'C'; - else if (c == 'm') - c = 'M'; - else - return 0; - - if (flag[c]) - return 0; - flag[c] = 1; - break; - case 'C': /* ANSI C syntax */ - Cflag = 1; - break; - - case 'k': /* K&R C syntax */ - Cflag = 0; - break; - - case 'b': /* turn TIRPC flag off for - generating backward compatible - */ - tirpcflag = 0; - break; - - case '5': /* turn TIRPC flag on for - generating SysVr4 compatible - */ - tirpcflag = 1; - break; - case 'I': - inetdflag = 1; - break; - case 'N': - newstyle = 1; - break; - case 'L': - logflag = 1; - break; - case 'K': - if (++i == argc) - { - return (0); - } - svcclosetime = argv[i]; - goto nextarg; - case 'T': - tblflag = 1; - break; - case 'M': - mtflag = 1; - break; - case 'i': - if (++i == argc) - { - return (0); - } - inlineflag = atoi (argv[i]); - goto nextarg; - case 'n': - case 'o': - case 's': - if (argv[i][j - 1] != '-' || - argv[i][j + 1] != 0) - { - return (0); - } - flag[c] = 1; - if (++i == argc) - { - return (0); - } - if (c == 's') - { - if (!streq (argv[i], "udp") && - !streq (argv[i], "tcp")) - return 0; - } - else if (c == 'o') - { - if (cmd->outfile) - return 0; - cmd->outfile = argv[i]; - } - goto nextarg; - case 'D': - if (argv[i][j - 1] != '-') - return 0; - addarg (argv[i]); - goto nextarg; - case 'Y': - if (++i == argc) - return 0; - { - size_t len = strlen (argv[i]); - pathbuf = malloc (len + 5); - if (pathbuf == NULL) - { - perror (cmdname); - crash (); - } - stpcpy (stpcpy (pathbuf, - argv[i]), - "/cpp"); - CPP = pathbuf; - cppDefined = 1; - goto nextarg; - } - - default: - return 0; - } - } - nextarg: - ; - } - } - - cmd->cflag = flag['c']; - cmd->hflag = flag['h']; - cmd->lflag = flag['l']; - cmd->mflag = flag['m']; - cmd->nflag = flag['n']; - cmd->sflag = flag['s']; - cmd->tflag = flag['t']; - cmd->Ssflag = flag['S']; - cmd->Scflag = flag['C']; - cmd->makefileflag = flag['M']; - - if (tirpcflag) - { - pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */ - if ((inetdflag && cmd->nflag)) - { /* netid not allowed with inetdflag */ - fprintf (stderr, _("Cannot use netid flag with inetd flag!\n")); - return 0; - } - } - else - { /* 4.1 mode */ - pmflag = 0; /* set pmflag only in tirpcmode */ - if (cmd->nflag) - { /* netid needs TIRPC */ - f_print (stderr, _("Cannot use netid flag without TIRPC!\n")); - return (0); - } - } - - if (newstyle && (tblflag || cmd->tflag)) - { - f_print (stderr, _("Cannot use table flags with newstyle!\n")); - return (0); - } - - /* check no conflicts with file generation flags */ - nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag + - cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag; - - if (nflags == 0) - { - if (cmd->outfile != NULL || cmd->infile == NULL) - { - return (0); - } - } - else if (cmd->infile == NULL && - (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) - { - fprintf (stderr, - _("\"infile\" is required for template generation flags.\n")); - return 0; - } - if (nflags > 1) - { - fprintf (stderr, _("Cannot have more than one file generation flag!\n")); - return 0; - } - return 1; -} - -static void -usage (FILE *stream, int status) -{ - fprintf (stream, _("usage: %s infile\n"), cmdname); - fprintf (stream, _("\t%s [-abkCLNTM][-Dname[=value]] [-i size] \ -[-I [-K seconds]] [-Y path] infile\n"), cmdname); - fprintf (stream, _("\t%s [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm] \ -[-o outfile] [infile]\n"), cmdname); - fprintf (stream, _("\t%s [-s nettype]* [-o outfile] [infile]\n"), cmdname); - fprintf (stream, _("\t%s [-n netid]* [-o outfile] [infile]\n"), cmdname); - options_usage (stream, status); - exit (status); -} - -static void -options_usage (FILE *stream, int status) -{ - f_print (stream, _("options:\n")); - f_print (stream, _("-a\t\tgenerate all files, including samples\n")); - f_print (stream, _("-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n")); - f_print (stream, _("-c\t\tgenerate XDR routines\n")); - f_print (stream, _("-C\t\tANSI C mode\n")); - f_print (stream, _("-Dname[=value]\tdefine a symbol (same as #define)\n")); - f_print (stream, _("-h\t\tgenerate header file\n")); - f_print (stream, _("-i size\t\tsize at which to start generating inline code\n")); - f_print (stream, _("-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n")); - f_print (stream, _("-K seconds\tserver exits after K seconds of inactivity\n")); - f_print (stream, _("-l\t\tgenerate client side stubs\n")); - f_print (stream, _("-L\t\tserver errors will be printed to syslog\n")); - f_print (stream, _("-m\t\tgenerate server side stubs\n")); - f_print (stream, _("-M\t\tgenerate MT-safe code\n")); - f_print (stream, _("-n netid\tgenerate server code that supports named netid\n")); - f_print (stream, _("-N\t\tsupports multiple arguments and call-by-value\n")); - f_print (stream, _("-o outfile\tname of the output file\n")); - f_print (stream, _("-s nettype\tgenerate server code that supports named nettype\n")); - f_print (stream, _("-Sc\t\tgenerate sample client code that uses remote procedures\n")); - f_print (stream, _("-Ss\t\tgenerate sample server code that defines remote procedures\n")); - f_print (stream, _("-Sm \t\tgenerate makefile template \n")); - f_print (stream, _("-t\t\tgenerate RPC dispatch table\n")); - f_print (stream, _("-T\t\tgenerate code to support RPC dispatch tables\n")); - f_print (stream, _("-Y path\t\tdirectory name to find C preprocessor (cpp)\n")); - f_print (stream, _("-5\t\tSysVr4 compatibility mode\n")); - f_print (stream, _("--help\t\tgive this help list\n")); - f_print (stream, _("--version\tprint program version\n")); - - exit (status); -} - -static void -print_version (void) -{ - printf ("rpcgen (%s) %s\n", PACKAGE, VERSION); - exit (0); -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.c deleted file mode 100644 index ee37430..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.c +++ /dev/null @@ -1,686 +0,0 @@ -/* - * From: @(#)rpc_parse.c 1.8 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_parse.c, Parser for the RPC protocol compiler - * Copyright (C) 1987 Sun Microsystems, Inc. - */ -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define ARGNAME "arg" - -static void isdefined (definition * defp); -static void def_struct (definition * defp); -static void def_program (definition * defp); -static void def_enum (definition * defp); -static void def_const (definition * defp); -static void def_union (definition * defp); -static void check_type_name (const char *name, int new_type); -static void def_typedef (definition * defp); -static void get_declaration (declaration * dec, defkind dkind); -static void get_prog_declaration (declaration * dec, defkind dkind, int num); -static void get_type (const char **prefixp, const char **typep, defkind dkind); -static void unsigned_dec (const char **typep); - -/* - * return the next definition you see - */ -definition * -get_definition (void) -{ - definition *defp; - token tok; - - defp = ALLOC (definition); - get_token (&tok); - switch (tok.kind) - { - case TOK_STRUCT: - def_struct (defp); - break; - case TOK_UNION: - def_union (defp); - break; - case TOK_TYPEDEF: - def_typedef (defp); - break; - case TOK_ENUM: - def_enum (defp); - break; - case TOK_PROGRAM: - def_program (defp); - break; - case TOK_CONST: - def_const (defp); - break; - case TOK_EOF: - free (defp); - return (NULL); - default: - error ("definition keyword expected"); - } - scan (TOK_SEMICOLON, &tok); - isdefined (defp); - return (defp); -} - -static void -isdefined (definition * defp) -{ - STOREVAL (&defined, defp); -} - -static void -def_struct (definition * defp) -{ - token tok; - declaration dec; - decl_list *decls; - decl_list **tailp; - - defp->def_kind = DEF_STRUCT; - - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - tailp = &defp->def.st.decls; - do - { - get_declaration (&dec, DEF_STRUCT); - decls = ALLOC (decl_list); - decls->decl = dec; - *tailp = decls; - tailp = &decls->next; - scan (TOK_SEMICOLON, &tok); - peek (&tok); - } - while (tok.kind != TOK_RBRACE); - get_token (&tok); - *tailp = NULL; -} - -static void -def_program (definition * defp) -{ - token tok; - declaration dec; - decl_list *decls; - decl_list **tailp; - version_list *vlist; - version_list **vtailp; - proc_list *plist; - proc_list **ptailp; - int num_args; - int isvoid = 0; /* whether first argument is void */ - defp->def_kind = DEF_PROGRAM; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - vtailp = &defp->def.pr.versions; - tailp = &defp->def.st.decls; - scan (TOK_VERSION, &tok); - do - { - scan (TOK_IDENT, &tok); - vlist = ALLOC (version_list); - vlist->vers_name = tok.str; - scan (TOK_LBRACE, &tok); - ptailp = &vlist->procs; - do - { - /* get result type */ - plist = ALLOC (proc_list); - get_type (&plist->res_prefix, &plist->res_type, - DEF_PROGRAM); - if (streq (plist->res_type, "opaque")) - { - error ("illegal result type"); - } - scan (TOK_IDENT, &tok); - plist->proc_name = tok.str; - scan (TOK_LPAREN, &tok); - /* get args - first one */ - num_args = 1; - isvoid = 0; - /* type of DEF_PROGRAM in the first - * get_prog_declaration and DEF_STURCT in the next - * allows void as argument if it is the only argument - */ - get_prog_declaration (&dec, DEF_PROGRAM, num_args); - if (streq (dec.type, "void")) - isvoid = 1; - decls = ALLOC (decl_list); - plist->args.decls = decls; - decls->decl = dec; - tailp = &decls->next; - /* get args */ - while (peekscan (TOK_COMMA, &tok)) - { - num_args++; - get_prog_declaration (&dec, DEF_STRUCT, - num_args); - decls = ALLOC (decl_list); - decls->decl = dec; - *tailp = decls; - if (streq (dec.type, "void")) - isvoid = 1; - tailp = &decls->next; - } - /* multiple arguments are only allowed in newstyle */ - if (!newstyle && num_args > 1) - { - error ("only one argument is allowed"); - } - if (isvoid && num_args > 1) - { - error ("illegal use of void in program definition"); - } - *tailp = NULL; - scan (TOK_RPAREN, &tok); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - scan (TOK_SEMICOLON, &tok); - plist->proc_num = tok.str; - plist->arg_num = num_args; - *ptailp = plist; - ptailp = &plist->next; - peek (&tok); - } - while (tok.kind != TOK_RBRACE); - *ptailp = NULL; - *vtailp = vlist; - vtailp = &vlist->next; - scan (TOK_RBRACE, &tok); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - vlist->vers_num = tok.str; - /* make the argument structure name for each arg */ - for (plist = vlist->procs; plist != NULL; - plist = plist->next) - { - plist->args.argname = make_argname (plist->proc_name, - vlist->vers_num); - /* free the memory ?? */ - } - scan (TOK_SEMICOLON, &tok); - scan2 (TOK_VERSION, TOK_RBRACE, &tok); - } - while (tok.kind == TOK_VERSION); - scan (TOK_EQUAL, &tok); - scan_num (&tok); - defp->def.pr.prog_num = tok.str; - *vtailp = NULL; -} - - -static void -def_enum (definition * defp) -{ - token tok; - enumval_list *elist; - enumval_list **tailp; - - defp->def_kind = DEF_ENUM; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_LBRACE, &tok); - tailp = &defp->def.en.vals; - do - { - scan (TOK_IDENT, &tok); - elist = ALLOC (enumval_list); - elist->name = tok.str; - elist->assignment = NULL; - scan3 (TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok); - if (tok.kind == TOK_EQUAL) - { - scan_num (&tok); - elist->assignment = tok.str; - scan2 (TOK_COMMA, TOK_RBRACE, &tok); - } - *tailp = elist; - tailp = &elist->next; - } - while (tok.kind != TOK_RBRACE); - *tailp = NULL; -} - -static void -def_const (definition * defp) -{ - token tok; - - defp->def_kind = DEF_CONST; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_EQUAL, &tok); - scan2 (TOK_IDENT, TOK_STRCONST, &tok); - defp->def.co = tok.str; -} - -static void -def_union (definition *defp) -{ - token tok; - declaration dec; - case_list *cases; -/* case_list *tcase; */ - case_list **tailp; -#if 0 - int flag; -#endif - - defp->def_kind = DEF_UNION; - scan (TOK_IDENT, &tok); - defp->def_name = tok.str; - scan (TOK_SWITCH, &tok); - scan (TOK_LPAREN, &tok); - get_declaration (&dec, DEF_UNION); - defp->def.un.enum_decl = dec; - tailp = &defp->def.un.cases; - scan (TOK_RPAREN, &tok); - scan (TOK_LBRACE, &tok); - scan (TOK_CASE, &tok); - while (tok.kind == TOK_CASE) - { - scan2 (TOK_IDENT, TOK_CHARCONST, &tok); - cases = ALLOC (case_list); - cases->case_name = tok.str; - scan (TOK_COLON, &tok); - /* now peek at next token */ -#if 0 - flag = 0; -#endif - if (peekscan (TOK_CASE, &tok)) - { - - do - { - scan2 (TOK_IDENT, TOK_CHARCONST, &tok); - cases->contflag = 1; /* continued case statement */ - *tailp = cases; - tailp = &cases->next; - cases = ALLOC (case_list); - cases->case_name = tok.str; - scan (TOK_COLON, &tok); - - } - while (peekscan (TOK_CASE, &tok)); - } -#if 0 - else if (flag) - { - - *tailp = cases; - tailp = &cases->next; - cases = ALLOC (case_list); - }; -#endif - - get_declaration (&dec, DEF_UNION); - cases->case_decl = dec; - cases->contflag = 0; /* no continued case statement */ - *tailp = cases; - tailp = &cases->next; - scan (TOK_SEMICOLON, &tok); - - scan3 (TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok); - } - *tailp = NULL; - if (tok.kind == TOK_DEFAULT) - { - scan (TOK_COLON, &tok); - get_declaration (&dec, DEF_UNION); - defp->def.un.default_decl = ALLOC (declaration); - *defp->def.un.default_decl = dec; - scan (TOK_SEMICOLON, &tok); - scan (TOK_RBRACE, &tok); - } - else - { - defp->def.un.default_decl = NULL; - } -} - -static const char *reserved_words[] = -{ - "array", - "bytes", - "destroy", - "free", - "getpos", - "inline", - "pointer", - "reference", - "setpos", - "sizeof", - "union", - "vector", - NULL -}; - -static const char *reserved_types[] = -{ - "opaque", - "string", - NULL -}; - -/* - * check that the given name is not one that would eventually result in - * xdr routines that would conflict with internal XDR routines. - */ -static void -check_type_name (const char *name, int new_type) -{ - int i; - char tmp[100]; - - for (i = 0; reserved_words[i] != NULL; i++) - { - if (strcmp (name, reserved_words[i]) == 0) - { - sprintf (tmp, - "illegal (reserved) name :\'%s\' in type definition", name); - error (tmp); - } - } - if (new_type) - { - for (i = 0; reserved_types[i] != NULL; i++) - { - if (strcmp (name, reserved_types[i]) == 0) - { - sprintf (tmp, - "illegal (reserved) name :\'%s\' in type definition", name); - error (tmp); - } - } - } -} - - - -static void -def_typedef (definition * defp) -{ - declaration dec; - - defp->def_kind = DEF_TYPEDEF; - get_declaration (&dec, DEF_TYPEDEF); - defp->def_name = dec.name; - check_type_name (dec.name, 1); - defp->def.ty.old_prefix = dec.prefix; - defp->def.ty.old_type = dec.type; - defp->def.ty.rel = dec.rel; - defp->def.ty.array_max = dec.array_max; -} - -static void -get_declaration (declaration * dec, defkind dkind) -{ - token tok; - - get_type (&dec->prefix, &dec->type, dkind); - dec->rel = REL_ALIAS; - if (streq (dec->type, "void")) - { - return; - } - - check_type_name (dec->type, 0); - - scan2 (TOK_STAR, TOK_IDENT, &tok); - if (tok.kind == TOK_STAR) - { - dec->rel = REL_POINTER; - scan (TOK_IDENT, &tok); - } - dec->name = tok.str; - if (peekscan (TOK_LBRACKET, &tok)) - { - if (dec->rel == REL_POINTER) - { - error ("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_VECTOR; - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RBRACKET, &tok); - } - else if (peekscan (TOK_LANGLE, &tok)) - { - if (dec->rel == REL_POINTER) - { - error ("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_ARRAY; - if (peekscan (TOK_RANGLE, &tok)) - { - dec->array_max = "~0"; /* unspecified size, use max */ - } - else - { - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RANGLE, &tok); - } - } - if (streq (dec->type, "opaque")) - { - if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) - { - error ("array declaration expected"); - } - } - else if (streq (dec->type, "string")) - { - if (dec->rel != REL_ARRAY) - { - error ("variable-length array declaration expected"); - } - } -} - -static void -get_prog_declaration (declaration * dec, defkind dkind, int num /* arg number */ ) -{ - token tok; - char name[MAXLINESIZE]; /* argument name */ - - if (dkind == DEF_PROGRAM) - { - peek (&tok); - if (tok.kind == TOK_RPAREN) - { /* no arguments */ - dec->rel = REL_ALIAS; - dec->type = "void"; - dec->prefix = NULL; - dec->name = NULL; - return; - } - } - get_type (&dec->prefix, &dec->type, dkind); - dec->rel = REL_ALIAS; - if (peekscan (TOK_IDENT, &tok)) /* optional name of argument */ - strcpy (name, tok.str); - else - sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */ - - dec->name = (char *) strdup (name); - - if (streq (dec->type, "void")) - { - return; - } - - if (streq (dec->type, "opaque")) - { - error ("opaque -- illegal argument type"); - } - if (peekscan (TOK_STAR, &tok)) - { - if (streq (dec->type, "string")) - { - error ("pointer to string not allowed in program arguments\n"); - } - dec->rel = REL_POINTER; - if (peekscan (TOK_IDENT, &tok)) /* optional name of argument */ - dec->name = strdup (tok.str); - } - if (peekscan (TOK_LANGLE, &tok)) - { - if (!streq (dec->type, "string")) - { - error ("arrays cannot be declared as arguments to procedures -- use typedef"); - } - dec->rel = REL_ARRAY; - if (peekscan (TOK_RANGLE, &tok)) - { - dec->array_max = "~0"; /* unspecified size, use max */ - } - else - { - scan_num (&tok); - dec->array_max = tok.str; - scan (TOK_RANGLE, &tok); - } - } - if (streq (dec->type, "string")) - { - if (dec->rel != REL_ARRAY) - { /* .x specifies just string as - * type of argument - * - make it string<> - */ - dec->rel = REL_ARRAY; - dec->array_max = "~0"; /* unspecified size, use max */ - } - } -} - -static void -get_type (const char **prefixp, const char **typep, defkind dkind) -{ - token tok; - - *prefixp = NULL; - get_token (&tok); - switch (tok.kind) - { - case TOK_IDENT: - *typep = tok.str; - break; - case TOK_STRUCT: - case TOK_ENUM: - case TOK_UNION: - *prefixp = tok.str; - scan (TOK_IDENT, &tok); - *typep = tok.str; - break; - case TOK_UNSIGNED: - unsigned_dec (typep); - break; - case TOK_SHORT: - *typep = "short"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_LONG: - *typep = "long"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_HYPER: - *typep = "quad_t"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_VOID: - if (dkind != DEF_UNION && dkind != DEF_PROGRAM) - { - error ("voids allowed only inside union and program definitions with one argument"); - } - *typep = tok.str; - break; - case TOK_STRING: - case TOK_OPAQUE: - case TOK_CHAR: - case TOK_INT: - case TOK_FLOAT: - case TOK_DOUBLE: - case TOK_BOOL: - *typep = tok.str; - break; - default: - error ("expected type specifier"); - } -} - -static void -unsigned_dec (const char **typep) -{ - token tok; - - peek (&tok); - switch (tok.kind) - { - case TOK_CHAR: - get_token (&tok); - *typep = "u_char"; - break; - case TOK_SHORT: - get_token (&tok); - *typep = "u_short"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_LONG: - get_token (&tok); - *typep = "u_long"; - (void) peekscan (TOK_INT, &tok); - break; - case TOK_HYPER: - get_token (&tok); - *typep = "u_quad_t"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_INT: - get_token (&tok); - *typep = "u_int"; - break; - default: - *typep = "u_int"; - break; - } -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.h b/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.h deleted file mode 100644 index e2e2f1e..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_parse.h +++ /dev/null @@ -1,165 +0,0 @@ -/* @(#)rpc_parse.h 1.3 90/08/29 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_parse.h, Definitions for the RPCL parser - */ - -enum defkind { - DEF_CONST, - DEF_STRUCT, - DEF_UNION, - DEF_ENUM, - DEF_TYPEDEF, - DEF_PROGRAM -}; -typedef enum defkind defkind; - -typedef const char *const_def; - -enum relation { - REL_VECTOR, /* fixed length array */ - REL_ARRAY, /* variable length array */ - REL_POINTER, /* pointer */ - REL_ALIAS /* simple */ -}; -typedef enum relation relation; - -struct typedef_def { - const char *old_prefix; - const char *old_type; - relation rel; - const char *array_max; -}; -typedef struct typedef_def typedef_def; - -struct enumval_list { - const char *name; - const char *assignment; - struct enumval_list *next; -}; -typedef struct enumval_list enumval_list; - -struct enum_def { - enumval_list *vals; -}; -typedef struct enum_def enum_def; - -struct declaration { - const char *prefix; - const char *type; - const char *name; - relation rel; - const char *array_max; -}; -typedef struct declaration declaration; - -struct decl_list { - declaration decl; - struct decl_list *next; -}; -typedef struct decl_list decl_list; - -struct struct_def { - decl_list *decls; -}; -typedef struct struct_def struct_def; - -struct case_list { - const char *case_name; - int contflag; - declaration case_decl; - struct case_list *next; -}; -typedef struct case_list case_list; - -struct union_def { - declaration enum_decl; - case_list *cases; - declaration *default_decl; -}; -typedef struct union_def union_def; - -struct arg_list { - const char *argname; /* name of struct for arg*/ - decl_list *decls; -}; - -typedef struct arg_list arg_list; - -struct proc_list { - const char *proc_name; - const char *proc_num; - arg_list args; - int arg_num; - const char *res_type; - const char *res_prefix; - struct proc_list *next; -}; -typedef struct proc_list proc_list; - -struct version_list { - const char *vers_name; - const char *vers_num; - proc_list *procs; - struct version_list *next; -}; -typedef struct version_list version_list; - -struct program_def { - const char *prog_num; - version_list *versions; -}; -typedef struct program_def program_def; - -struct definition { - const char *def_name; - defkind def_kind; - union { - const_def co; - struct_def st; - union_def un; - enum_def en; - typedef_def ty; - program_def pr; - } def; -}; -typedef struct definition definition; - -definition *get_definition(void); - - -struct bas_type -{ - const char *name; - int length; - struct bas_type *next; -}; - -typedef struct bas_type bas_type; diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_sample.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_sample.c deleted file mode 100644 index e90b58c..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_sample.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * From: @(#)rpc_sample.c 1.1 90/08/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_sample.c, Sample client-server code outputter for the RPC protocol compiler - */ - -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - - -static const char RQSTP[] = "rqstp"; - -static void write_sample_client (const char *program_name, version_list * vp); -static void write_sample_server (definition * def); -static void return_type (proc_list * plist); - - -void -write_sample_svc (definition * def) -{ - - if (def->def_kind != DEF_PROGRAM) - return; - write_sample_server (def); -} - - -int -write_sample_clnt (definition * def) -{ - version_list *vp; - int count = 0; - - if (def->def_kind != DEF_PROGRAM) - return 0; - /* generate sample code for each version */ - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - write_sample_client (def->def_name, vp); - ++count; - } - return count; -} - - -static void -write_sample_client (const char *program_name, version_list * vp) -{ - proc_list *proc; - int i; - decl_list *l; - - f_print (fout, "\n\nvoid\n"); - pvname (program_name, vp->vers_num); - if (Cflag) - f_print (fout, "(char *host)\n{\n"); - else - f_print (fout, "(host)\nchar *host;\n{\n"); - f_print (fout, "\tCLIENT *clnt;\n"); - - i = 0; - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\t"); - ++i; - if (mtflag) - { - f_print (fout, "enum clnt_stat retval_%d;\n\t", i); - ptype (proc->res_prefix, proc->res_type, 1); - if (!streq (proc->res_type, "void")) - f_print (fout, "result_%d;\n", i); - else - fprintf (fout, "*result_%d;\n", i); - } - else - { - ptype (proc->res_prefix, proc->res_type, 1); - f_print (fout, " *result_%d;\n", i); - } - /* print out declarations for arguments */ - if (proc->arg_num < 2 && !newstyle) - { - f_print (fout, "\t"); - if (!streq (proc->args.decls->decl.type, "void")) - { - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 1); - f_print (fout, " "); - } - else - f_print (fout, "char *"); /* cannot have "void" type */ - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - } - else if (!streq (proc->args.decls->decl.type, "void")) - { - for (l = proc->args.decls; l != NULL; l = l->next) - { - f_print (fout, "\t"); - ptype (l->decl.prefix, l->decl.type, 1); - if (strcmp (l->decl.type, "string") == 1) - f_print (fout, " "); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_%s;\n", l->decl.name); - } - } - } - - /* generate creation of client handle */ - f_print(fout, "\n#ifndef\tDEBUG\n"); - f_print (fout, "\tclnt = clnt_create (host, %s, %s, \"%s\");\n", - program_name, vp->vers_name, tirpcflag ? "netpath" : "udp"); - f_print (fout, "\tif (clnt == NULL) {\n"); - f_print (fout, "\t\tclnt_pcreateerror (host);\n"); - f_print (fout, "\t\texit (1);\n\t}\n"); - f_print(fout, "#endif\t/* DEBUG */\n\n"); - - /* generate calls to procedures */ - i = 0; - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - if (mtflag) - f_print(fout, "\tretval_%d = ",++i); - else - f_print (fout, "\tresult_%d = ", ++i); - pvname (proc->proc_name, vp->vers_num); - if (proc->arg_num < 2 && !newstyle) - { - f_print (fout, "("); - if (streq (proc->args.decls->decl.type, "void"))/* cast to void* */ - f_print (fout, "(void*)"); - f_print (fout, "&"); - pvname (proc->proc_name, vp->vers_num); - if (mtflag) - f_print(fout, "_arg, &result_%d, clnt);\n", i); - else - f_print (fout, "_arg, clnt);\n"); - } - else if (streq (proc->args.decls->decl.type, "void")) - { - if (mtflag) - f_print (fout, "(&result_%d, clnt);\n", i); - else - f_print (fout, "(clnt);\n"); - } - else - { - f_print (fout, "("); - for (l = proc->args.decls; l != NULL; l = l->next) - { - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_%s, ", l->decl.name); - } - if (mtflag) - f_print(fout, "&result_%d, ", i); - f_print (fout, "clnt);\n"); - } - if (mtflag) - { - f_print(fout, "\tif (retval_%d != RPC_SUCCESS) {\n", i); - } - else - { - f_print(fout, "\tif (result_%d == (", i); - ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*) NULL) {\n"); - } - f_print(fout, "\t\tclnt_perror (clnt, \"call failed\");\n"); - f_print(fout, "\t}\n"); - } - - f_print (fout, "#ifndef\tDEBUG\n"); - f_print (fout, "\tclnt_destroy (clnt);\n"); - f_print (fout, "#endif\t /* DEBUG */\n"); - f_print (fout, "}\n"); -} - -static void -write_sample_server (definition * def) -{ - version_list *vp; - proc_list *proc; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\n"); - if (!mtflag) - { - return_type (proc); - f_print (fout, "*\n"); - } - else - f_print (fout, "bool_t\n"); - if (Cflag || mtflag) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname(proc->proc_name, vp->vers_num); - printarglist(proc, "result", RQSTP, "struct svc_req *"); - f_print(fout, "{\n"); - if (!mtflag) - { - f_print(fout, "\tstatic "); - if(!streq(proc->res_type, "void")) - return_type(proc); - else - f_print(fout, "char *"); - /* cannot have void type */ - /* f_print(fout, " result;\n", proc->res_type); */ - f_print(fout, " result;\n"); - } - else - f_print(fout, "\tbool_t retval;\n"); - fprintf (fout, "\n\t/*\n\t * insert server code here\n\t */\n\n"); - - if (!mtflag) - { - if (!streq(proc->res_type, "void")) - f_print(fout, "\treturn &result;\n}\n"); - else /* cast back to void * */ - f_print(fout, "\treturn (void *) &result;\n}\n"); - } - else - f_print(fout, "\treturn retval;\n}\n"); - } - - /* put in sample freeing routine */ - if (mtflag) - { - f_print(fout, "\nint\n"); - pvname(def->def_name, vp->vers_num); - if (Cflag) - f_print(fout,"_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)\n"); - else - { - f_print(fout,"_freeresult (transp, xdr_result, result)\n"); - f_print(fout,"\tSVCXPRT *transp;\n"); - f_print(fout,"\txdrproc_t xdr_result;\n"); - f_print(fout,"\tcaddr_t result;\n"); - } - f_print(fout, "{\n"); - f_print(fout, "\txdr_free (xdr_result, result);\n"); - f_print(fout, - "\n\t/*\n\t * Insert additional freeing code here, if needed\n\t */\n"); - f_print(fout, "\n\treturn 1;\n}\n"); - } - } -} - - - -static void -return_type (proc_list * plist) -{ - ptype (plist->res_prefix, plist->res_type, 1); -} - -void -add_sample_msg (void) -{ - f_print (fout, "/*\n"); - f_print (fout, " * This is sample code generated by rpcgen.\n"); - f_print (fout, " * These are only templates and you can use them\n"); - f_print (fout, " * as a guideline for developing your own functions.\n"); - f_print (fout, " */\n\n"); -} - -void -write_sample_clnt_main (void) -{ - list *l; - definition *def; - version_list *vp; - - f_print (fout, "\n\n"); - if (Cflag) - f_print (fout, "int\nmain (int argc, char *argv[])\n{\n"); - else - f_print (fout, "int\nmain (argc, argv)\nint argc;\nchar *argv[];\n{\n"); - - f_print (fout, "\tchar *host;"); - f_print (fout, "\n\n\tif (argc < 2) {"); - f_print (fout, "\n\t\tprintf (\"usage: %%s server_host\\n\", argv[0]);\n"); - f_print (fout, "\t\texit (1);\n\t}"); - f_print (fout, "\n\thost = argv[1];\n"); - - for (l = defined; l != NULL; l = l->next) - { - def = l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\t"); - pvname (def->def_name, vp->vers_num); - f_print (fout, " (host);\n"); - } - } - f_print (fout, "exit (0);\n}\n"); -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.c deleted file mode 100644 index 79eba96..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * From: @(#)rpc_scan.c 1.11 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_scan.c, Scanner for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#ifndef _ -#define _(String) gettext (String) -#endif - -#define startcomment(where) (where[0] == '/' && where[1] == '*') -#define endcomment(where) (where[-1] == '*' && where[0] == '/') - -static int pushed = 0; /* is a token pushed */ -static token lasttok; /* last token, if pushed */ - -static void unget_token (token * tokp); -static void findstrconst (const char **str, const char **val); -static void findchrconst (const char **str, const char **val); -static void findconst (const char **str, const char **val); -static void findkind (const char **mark, token * tokp); -static int cppline (const char *line); -static int directive (const char *line); -static void printdirective (const char *line); -static void docppline (const char *line, int *lineno, const char **fname); - -/* - * scan expecting 1 given token - */ -void -scan (tok_kind expect, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect) - expected1 (expect); -} - -/* - * scan expecting any of the 2 given tokens - */ -void -scan2 (tok_kind expect1, tok_kind expect2, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect1 && tokp->kind != expect2) - { - expected2 (expect1, expect2); - } -} - -/* - * scan expecting any of the 3 given token - */ -void -scan3 (tok_kind expect1, tok_kind expect2, tok_kind expect3, token * tokp) -{ - get_token (tokp); - if (tokp->kind != expect1 && tokp->kind != expect2 - && tokp->kind != expect3) - { - expected3 (expect1, expect2, expect3); - } -} - -/* - * scan expecting a constant, possibly symbolic - */ -void -scan_num (token *tokp) -{ - get_token (tokp); - switch (tokp->kind) - { - case TOK_IDENT: - break; - default: - error (_("constant or identifier expected")); - } -} - -/* - * Peek at the next token - */ -void -peek (token *tokp) -{ - get_token (tokp); - unget_token (tokp); -} - -/* - * Peek at the next token and scan it if it matches what you expect - */ -int -peekscan (tok_kind expect, token *tokp) -{ - peek (tokp); - if (tokp->kind == expect) - { - get_token (tokp); - return 1; - } - return 0; -} - -/* - * Get the next token, printing out any directive that are encountered. - */ -void -get_token (token *tokp) -{ - int commenting; - - if (pushed) - { - pushed = 0; - *tokp = lasttok; - return; - } - commenting = 0; - for (;;) - { - if (*where == 0) - { - for (;;) - { - if (!fgets (curline, MAXLINESIZE, fin)) - { - tokp->kind = TOK_EOF; - *curline = 0; - where = curline; - return; - } - linenum++; - if (commenting) - { - break; - } - else if (cppline (curline)) - { - docppline (curline, &linenum, - &infilename); - } - else if (directive (curline)) - { - printdirective (curline); - } - else - { - break; - } - } - where = curline; - } - else if (isspace (*where)) - { - while (isspace (*where)) - { - where++; /* eat */ - } - } - else if (commenting) - { - for (where++; *where; where++) - { - if (endcomment (where)) - { - where++; - commenting--; - break; - } - } - } - else if (startcomment (where)) - { - where += 2; - commenting++; - } - else - { - break; - } - } - - /* - * 'where' is not whitespace, comment or directive Must be a token! - */ - switch (*where) - { - case ':': - tokp->kind = TOK_COLON; - where++; - break; - case ';': - tokp->kind = TOK_SEMICOLON; - where++; - break; - case ',': - tokp->kind = TOK_COMMA; - where++; - break; - case '=': - tokp->kind = TOK_EQUAL; - where++; - break; - case '*': - tokp->kind = TOK_STAR; - where++; - break; - case '[': - tokp->kind = TOK_LBRACKET; - where++; - break; - case ']': - tokp->kind = TOK_RBRACKET; - where++; - break; - case '{': - tokp->kind = TOK_LBRACE; - where++; - break; - case '}': - tokp->kind = TOK_RBRACE; - where++; - break; - case '(': - tokp->kind = TOK_LPAREN; - where++; - break; - case ')': - tokp->kind = TOK_RPAREN; - where++; - break; - case '<': - tokp->kind = TOK_LANGLE; - where++; - break; - case '>': - tokp->kind = TOK_RANGLE; - where++; - break; - - case '"': - tokp->kind = TOK_STRCONST; - findstrconst (&where, &tokp->str); - break; - case '\'': - tokp->kind = TOK_CHARCONST; - findchrconst (&where, &tokp->str); - break; - - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - tokp->kind = TOK_IDENT; - findconst (&where, &tokp->str); - break; - - default: - if (!(isalpha (*where) || *where == '_')) - { - char buf[100]; - char *p; - - s_print (buf, _("illegal character in file: ")); - p = buf + strlen (buf); - if (isprint (*where)) - { - s_print (p, "%c", *where); - } - else - { - s_print (p, "%d", *where); - } - error (buf); - } - findkind (&where, tokp); - break; - } -} - -static void -unget_token (token * tokp) -{ - lasttok = *tokp; - pushed = 1; -} - -static void -findstrconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - do - { - p++; - } - while (*p && *p != '"'); - if (*p == 0) - { - error (_("unterminated string constant")); - } - p++; - size = p - *str; - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static void -findchrconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - do - { - p++; - } - while (*p && *p != '\''); - if (*p == 0) - { - error (_("unterminated string constant")); - } - p++; - size = p - *str; - if (size != 3) - { - error (_("empty char string")); - } - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static void -findconst (const char **str, const char **val) -{ - const char *p; - char *tmp; - int size; - - p = *str; - if (*p == '0' && *(p + 1) == 'x') - { - p++; - do - { - p++; - } - while (isxdigit (*p)); - } - else - { - do - { - p++; - } - while (isdigit (*p)); - } - size = p - *str; - tmp = alloc (size + 1); - strncpy (tmp, *str, size); - tmp[size] = 0; - *val = tmp; - *str = p; -} - -static const token symbols[] = -{ - {TOK_CONST, "const"}, - {TOK_UNION, "union"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_STRUCT, "struct"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_ENUM, "enum"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_CHAR, "char"}, - {TOK_INT, "int"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_HYPER, "hyper"}, - {TOK_FLOAT, "float"}, - {TOK_DOUBLE, "double"}, - {TOK_STRING, "string"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"}, -}; - -static void -findkind (const char **mark, token *tokp) -{ - int len; - const token *s; - const char *str; - char *tmp; - - str = *mark; - for (s = symbols; s->kind != TOK_EOF; s++) - { - len = strlen (s->str); - if (strncmp (str, s->str, len) == 0) - { - if (!isalnum (str[len]) && str[len] != '_') - { - tokp->kind = s->kind; - tokp->str = s->str; - *mark = str + len; - return; - } - } - } - tokp->kind = TOK_IDENT; - for (len = 0; isalnum (str[len]) || str[len] == '_'; len++); - tmp = alloc (len + 1); - strncpy (tmp, str, len); - tmp[len] = 0; - tokp->str = tmp; - *mark = str + len; -} - -static int -cppline (const char *line) -{ - return line == curline && *line == '#'; -} - -static int -directive (const char *line) -{ - return line == curline && *line == '%'; -} - -static void -printdirective (const char *line) -{ - f_print (fout, "%s", line + 1); -} - -static void -docppline (const char *line, int *lineno, const char **fname) -{ - char *file; - int num; - char *p; - - line++; - while (isspace (*line)) - { - line++; - } - num = atoi (line); - while (isdigit (*line)) - { - line++; - } - while (isspace (*line)) - { - line++; - } - if (*line != '"') - { - error (_("preprocessor error")); - } - line++; - p = file = alloc (strlen (line) + 1); - while (*line && *line != '"') - { - *p++ = *line++; - } - if (*line == 0) - { - error (_("preprocessor error")); - } - *p = 0; - if (*file == 0) - { - free (file); - *fname = NULL; - } - else - { - *fname = file; - } - *lineno = num - 1; -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.h b/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.h deleted file mode 100644 index 9786a51..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_scan.h +++ /dev/null @@ -1,104 +0,0 @@ -/* @(#)rpc_scan.h 1.3 90/08/29 */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_scan.h, Definitions for the RPCL scanner - */ - -/* - * kinds of tokens - */ -enum tok_kind { - TOK_IDENT, - TOK_CHARCONST, - TOK_STRCONST, - TOK_LPAREN, - TOK_RPAREN, - TOK_LBRACE, - TOK_RBRACE, - TOK_LBRACKET, - TOK_RBRACKET, - TOK_LANGLE, - TOK_RANGLE, - TOK_STAR, - TOK_COMMA, - TOK_EQUAL, - TOK_COLON, - TOK_SEMICOLON, - TOK_CONST, - TOK_STRUCT, - TOK_UNION, - TOK_SWITCH, - TOK_CASE, - TOK_DEFAULT, - TOK_ENUM, - TOK_TYPEDEF, - TOK_INT, - TOK_SHORT, - TOK_LONG, - TOK_HYPER, - TOK_UNSIGNED, - TOK_FLOAT, - TOK_DOUBLE, - TOK_OPAQUE, - TOK_CHAR, - TOK_STRING, - TOK_BOOL, - TOK_VOID, - TOK_PROGRAM, - TOK_VERSION, - TOK_EOF -}; -typedef enum tok_kind tok_kind; - -/* - * a token - */ -struct token { - tok_kind kind; - const char *str; -}; -typedef struct token token; - - -/* - * routine interface - */ -void scan(tok_kind expect, token *tokp); -void scan2(tok_kind expect1, tok_kind expect2, token *tokp); -void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp); -void scan_num(token *tokp); -void peek(token *tokp); -int peekscan(tok_kind expect, token *tokp); -void get_token(token *tokp); -void expected1(tok_kind exp1) __attribute__ ((noreturn)); -void expected2(tok_kind exp1, tok_kind exp2) __attribute__ ((noreturn)); -void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3) - __attribute__ ((noreturn)); diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_svcout.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_svcout.c deleted file mode 100644 index 4f12a81..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_svcout.c +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * From: @(#)rpc_svcout.c 1.29 89/03/30 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -static const char RQSTP[] = "rqstp"; -static const char TRANSP[] = "transp"; -static const char ARG[] = "argument"; -static const char RESULT[] = "result"; -static const char ROUTINE[] = "local"; -static char RETVAL[] = "retval"; - -char _errbuf[256]; /* For all messages */ - -static void internal_proctype (const proc_list * plist); -static void p_xdrfunc (const char *rname, const char *typename); -static void write_real_program (const definition * def); -static void write_program (const definition * def, const char *storage); -static void printerr (const char *err, const char *transp); -static void printif (const char *proc, const char *transp, const char *arg); -static void write_inetmost (const char *infile); -static void print_return (const char *space); -static void print_pmapunset (const char *space); -static void print_err_message (const char *space); -static void write_timeout_func (void); -static void write_pm_most (const char *infile, int netflag); -static void write_rpc_svc_fg (const char *infile, const char *sp); -static void open_log_file (const char *infile, const char *sp); - -static void -p_xdrfunc (const char *rname, const char *typename) -{ - if (Cflag) - f_print (fout, "\t\t_xdr_%s = (xdrproc_t) xdr_%s;\n", rname, - stringfix (typename)); - else - f_print (fout, "\t\t_xdr_%s = xdr_%s;\n", rname, stringfix (typename)); -} - -void -internal_proctype (const proc_list * plist) -{ - f_print (fout, "static "); - ptype (plist->res_prefix, plist->res_type, 1); - f_print (fout, "*"); -} - - -/* - * write most of the service, that is, everything but the registrations. - */ -void -write_most (const char *infile /* our name */ , int netflag, int nomain) -{ - if (inetdflag || pmflag) - { - const char *var_type; - /* WHY? */ - var_type = (nomain ? "extern" : ""); - f_print (fout, "%s int _rpcpmstart;", var_type); - f_print (fout, "\t\t/* Started by a port monitor ? */\n"); - if (!tirpcflag) - { - f_print (fout, "%s int _rpcfdtype;", var_type); - f_print (fout, "\t\t/* Whether Stream or Datagram ? */\n"); - } - if (timerflag) - { -#if 0 - f_print (fout, "%s int _rpcsvcdirty;", var_type); - f_print (fout, "\t/* Still serving ? */\n"); -#else - f_print(fout, " /* States a server can be in wrt request */\n\n"); - f_print(fout, "#define\t_IDLE 0\n"); - f_print(fout, "#define\t_SERVED 1\n"); - f_print(fout, "#define\t_SERVING 2\n\n"); - f_print(fout, "static int _rpcsvcstate = _IDLE;"); - f_print(fout, "\t /* Set when a request is serviced */\n"); - - if (mtflag) - { - f_print (fout, "mutex_t _svcstate_lock;"); - f_print (fout, - "\t\t\t/* Mutex lock for variable_rpcsvcstate */\n"); - } -#endif - } - write_svc_aux (nomain); - } - /* write out dispatcher and stubs */ - write_programs (nomain ? NULL : "static"); - - if (nomain) - return; - - if (Cflag) - f_print (fout, "\nint\nmain (int argc, char **argv)\n"); - else - { - f_print (fout, "\nint\nmain (argc, argv)\n"); - f_print (fout, "\tint argc;\n"); - f_print (fout, "\tchar **argv;\n"); - } - f_print (fout, "{\n"); - if (inetdflag) - { - write_inetmost (infile); /* Includes call to write_rpc_svc_fg() */ - } - else - { - if (tirpcflag) - { - if (netflag) - { - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\tstruct netconfig *nconf = NULL;\n"); - } - f_print (fout, "\tpid_t pid;\n"); - f_print (fout, "\tint i;\n"); - f_print (fout, "\tchar mname[FMNAMESZ + 1];\n\n"); - - if (mtflag & timerflag) - f_print (fout, - "\tmutex_init (&_svcstate_lock, USYNC_THREAD, NULL);\n"); - - write_pm_most (infile, netflag); - f_print (fout, "\telse {\n"); - write_rpc_svc_fg (infile, "\t\t"); - f_print (fout, "\t}\n"); - } - else - { - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\n"); - print_pmapunset ("\t"); - } - } - - if (logflag && !inetdflag) - { - open_log_file (infile, "\t"); - } -} - -/* - * write a registration for the given transport - */ -void -write_netid_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - const char *sp; - char tmpbuf[32]; - - sp = ""; - f_print (fout, "\n"); - f_print (fout, "%s\tnconf = getnetconfigent (\"%s\");\n", sp, transp); - f_print (fout, "%s\tif (nconf == NULL) {\n", sp); - (void) sprintf (_errbuf, "cannot find %s netid.", transp); - sprintf (tmpbuf, "%s\t\t", sp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - f_print (fout, "%s\t%s = svc_tli_create (RPC_ANYFD, nconf, 0, 0, 0);\n", - sp, TRANSP /*, transp *//* ?!?... */ ); - f_print (fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); - sprintf (_errbuf, "cannot create %s service.", transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "%s\t(void) rpcb_unset (%s, %s, nconf);\n", - sp, def->def_name, vp->vers_name); - f_print (fout, "%s\tif (!svc_reg (%s, %s, %s, ", - sp, TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", nconf)) {\n"); - (void) sprintf (_errbuf, "unable to register (%s, %s, %s).", - def->def_name, vp->vers_name, transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit (1);\n", sp); - f_print (fout, "%s\t}\n", sp); - } - } - f_print (fout, "%s\tfreenetconfigent (nconf);\n", sp); -} - -/* - * write a registration for the given transport for TLI - */ -void -write_nettype_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\tif (!svc_create ("); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", %s, %s, \"%s\")) {\n ", - def->def_name, vp->vers_name, transp); - (void) sprintf (_errbuf, - "unable to create (%s, %s) for %s.", - def->def_name, vp->vers_name, transp); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - } - } -} - -/* - * write the rest of the service - */ -void -write_rest (void) -{ - f_print (fout, "\n"); - if (inetdflag) - { - f_print (fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP); - (void) sprintf (_errbuf, "could not create a handle"); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - if (timerflag) - { - f_print (fout, "\tif (_rpcpmstart) {\n"); - f_print (fout, - "\t\t(void) signal (SIGALRM, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\t\t(void) alarm (_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "\t}\n"); - } - } - f_print (fout, "\tsvc_run ();\n"); - (void) sprintf (_errbuf, "svc_run returned"); - print_err_message ("\t"); - f_print (fout, "\texit (1);\n"); - f_print (fout, "\t/* NOTREACHED */\n"); - f_print (fout, "}\n"); -} - -void -write_programs (const char *storage) -{ - list *l; - definition *def; - - /* write out stubs for procedure definitions */ - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_real_program (def); - } - } - - /* write out dispatcher for each program */ - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_program (def, storage); - } - } -} - -/* write out definition of internal function (e.g. _printmsg_1(...)) - which calls server's defintion of actual function (e.g. printmsg_1(...)). - Unpacks single user argument of printmsg_1 to call-by-value format - expected by printmsg_1. */ -static void -write_real_program (const definition * def) -{ - version_list *vp; - proc_list *proc; - decl_list *l; - - if (!newstyle) - return; /* not needed for old style */ - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - fprintf (fout, "\n"); - if (!mtflag) - internal_proctype (proc); - else - f_print (fout, "int"); - f_print (fout, "\n_"); - pvname (proc->proc_name, vp->vers_num); - if (Cflag) - { - f_print (fout, " ("); - /* arg name */ - if (proc->arg_num > 1) - f_print (fout, "%s", proc->args.argname); - else - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - if (mtflag) - { - f_print(fout, " *argp, void *%s, struct svc_req *%s)\n", - RESULT, RQSTP); - } - else - f_print (fout, " *argp, struct svc_req *%s)\n", - RQSTP); - } - else - { - if (mtflag) - f_print(fout, " (argp, %s, %s)\n", RESULT, RQSTP); - else - f_print (fout, " (argp, %s)\n", RQSTP); - /* arg name */ - if (proc->arg_num > 1) - f_print (fout, "\t%s *argp;\n", proc->args.argname); - else - { - f_print (fout, "\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - f_print (fout, " *argp;\n"); - } - f_print (fout, " struct svc_req *%s;\n", RQSTP); - } - - f_print (fout, "{\n"); - f_print (fout, "\treturn ("); - if (Cflag || mtflag) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "("); - if (proc->arg_num < 2) - { /* single argument */ - if (!streq (proc->args.decls->decl.type, "void")) - f_print (fout, "*argp, "); /* non-void */ - } - else - { - for (l = proc->args.decls; l != NULL; l = l->next) - f_print (fout, "argp->%s, ", l->decl.name); - } - if (mtflag) - f_print (fout, "%s, ", RESULT); - f_print (fout, "%s));\n}\n", RQSTP); - } - } -} - -static void -write_program (const definition * def, const char *storage) -{ - version_list *vp; - proc_list *proc; - int filled; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "\n"); - if (storage != NULL) - { - f_print (fout, "%s ", storage); - } - f_print (fout, "void\n"); - pvname (def->def_name, vp->vers_num); - - if (Cflag) - { - f_print (fout, "(struct svc_req *%s, ", RQSTP); - f_print (fout, "register SVCXPRT *%s)\n", TRANSP); - } - else - { - f_print (fout, "(%s, %s)\n", RQSTP, TRANSP); - f_print (fout, " struct svc_req *%s;\n", RQSTP); - f_print (fout, " register SVCXPRT *%s;\n", TRANSP); - } - - f_print (fout, "{\n"); - - filled = 0; - f_print (fout, "\tunion {\n"); - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - if (proc->arg_num < 2) - { /* single argument */ - if (streq (proc->args.decls->decl.type, - "void")) - { - continue; - } - filled = 1; - f_print (fout, "\t\t"); - ptype (proc->args.decls->decl.prefix, - proc->args.decls->decl.type, 0); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - - } - else - { - filled = 1; - f_print (fout, "\t\t%s", proc->args.argname); - f_print (fout, " "); - pvname (proc->proc_name, vp->vers_num); - f_print (fout, "_arg;\n"); - } - } - if (!filled) - { - f_print (fout, "\t\tint fill;\n"); - } - f_print (fout, "\t} %s;\n", ARG); - if (mtflag) - { - f_print(fout, "\tunion {\n"); - for (proc = vp->procs; proc != NULL; proc = proc->next) - if (!streq (proc->res_type, "void")) - { - f_print(fout, "\t\t"); - ptype(proc->res_prefix, proc->res_type, 0); - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_res;\n"); - } - f_print(fout, "\t} %s;\n", RESULT); - f_print(fout, "\tbool_t %s;\n", RETVAL); - - } else - f_print (fout, "\tchar *%s;\n", RESULT); - - if (Cflag) - { - f_print (fout, "\txdrproc_t _xdr_%s, _xdr_%s;\n", ARG, RESULT); - if (mtflag) - f_print(fout, - "\tbool_t (*%s)(char *, void *, struct svc_req *);\n", - ROUTINE); - else - f_print (fout, "\tchar *(*%s)(char *, struct svc_req *);\n", - ROUTINE); - } - else - { - f_print (fout, "\tbool_t (*_xdr_%s)(), (*_xdr_%s)();\n", ARG, RESULT); - if (mtflag) - f_print(fout, "\tbool_t (*%s)();\n", ROUTINE); - else - f_print (fout, "\tchar *(*%s)();\n", ROUTINE); - } - f_print (fout, "\n"); - - if (timerflag) -#if 0 - f_print (fout, "\t_rpcsvcdirty = 1;\n"); -#else - { - if (mtflag) - f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); - f_print(fout, "\t_rpcsvcstate = _SERVING;\n"); - if (mtflag) - f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); - } -#endif - - f_print (fout, "\tswitch (%s->rq_proc) {\n", RQSTP); - if (!nullproc (vp->procs)) - { - f_print (fout, "\tcase NULLPROC:\n"); - f_print (fout, - "\t\t(void) svc_sendreply (%s, (xdrproc_t) xdr_void, (char *)NULL);\n", - TRANSP); - print_return ("\t\t"); - f_print (fout, "\n"); - } - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - f_print (fout, "\tcase %s:\n", proc->proc_name); - if (proc->arg_num < 2) - { /* single argument */ - p_xdrfunc (ARG, proc->args.decls->decl.type); - } - else - { - p_xdrfunc (ARG, proc->args.argname); - } - p_xdrfunc (RESULT, proc->res_type); - if (Cflag) - { - if (mtflag) - f_print(fout, - "\t\t%s = (bool_t (*) (char *, void *, struct svc_req *))", - ROUTINE); - else - f_print (fout, - "\t\t%s = (char *(*)(char *, struct svc_req *)) ", - ROUTINE); - } - else - if (mtflag) - f_print(fout, "\t\t%s = (bool_t (*)()) ", ROUTINE); - else - f_print (fout, "\t\t%s = (char *(*)()) ", ROUTINE); - - if (newstyle) - { /* new style: calls internal routine */ - f_print (fout, "_"); - } - if ((Cflag || mtflag) && !newstyle) - pvname_svc (proc->proc_name, vp->vers_num); - else - pvname (proc->proc_name, vp->vers_num); - f_print (fout, ";\n"); - f_print (fout, "\t\tbreak;\n\n"); - } - f_print (fout, "\tdefault:\n"); - printerr ("noproc", TRANSP); - print_return ("\t\t"); - f_print (fout, "\t}\n"); - - f_print (fout, "\tmemset ((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); - printif ("getargs", TRANSP, ARG); - printerr ("decode", TRANSP); - print_return ("\t\t"); - f_print (fout, "\t}\n"); - - if (!mtflag) - { - if (Cflag) - f_print (fout, "\t%s = (*%s)((char *)&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); - else - f_print (fout, "\t%s = (*%s)(&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); - } - else - if (Cflag) - f_print(fout, "\t%s = (bool_t) (*%s)((char *)&%s, (void *)&%s, %s);\n", - RETVAL, ROUTINE, ARG, RESULT, RQSTP); - else - f_print(fout, "\t%s = (bool_t) (*%s)(&%s, &%s, %s);\n", - RETVAL, ROUTINE, ARG, RESULT, RQSTP); - if (mtflag) - f_print(fout, - "\tif (%s > 0 && !svc_sendreply(%s, (xdrproc_t) _xdr_%s, (char *)&%s)) {\n", - RETVAL, TRANSP, RESULT, RESULT); - else - f_print(fout, - "\tif (%s != NULL && !svc_sendreply(%s, (xdrproc_t) _xdr_%s, %s)) {\n", - RESULT, TRANSP, RESULT, RESULT); - - printerr ("systemerr", TRANSP); - f_print (fout, "\t}\n"); - - printif ("freeargs", TRANSP, ARG); - - sprintf (_errbuf, "unable to free arguments"); - print_err_message ("\t\t"); - f_print (fout, "\t\texit (1);\n"); - f_print (fout, "\t}\n"); - /* print out free routine */ - if (mtflag) - { - f_print(fout,"\tif (!"); - pvname(def->def_name, vp->vers_num); - f_print(fout,"_freeresult (%s, _xdr_%s, (caddr_t) &%s))\n", - TRANSP, RESULT, RESULT); - (void) sprintf(_errbuf, "unable to free results"); - print_err_message("\t\t"); - f_print(fout, "\n"); - } - print_return ("\t"); - f_print (fout, "}\n"); - } -} - -static void -printerr (const char *err, const char *transp) -{ - f_print (fout, "\t\tsvcerr_%s (%s);\n", err, transp); -} - -static void -printif (const char *proc, const char *transp, const char *arg) -{ - f_print (fout, "\tif (!svc_%s (%s, (xdrproc_t) _xdr_%s, (caddr_t) &%s)) {\n", - proc, transp, arg, arg); -} - -int -nullproc (const proc_list * proc) -{ - for (; proc != NULL; proc = proc->next) - { - if (streq (proc->proc_num, "0")) - { - return 1; - } - } - return 0; -} - -static void -write_inetmost (const char *infile) -{ - f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print (fout, "\tint sock;\n"); - f_print (fout, "\tint proto;\n"); - f_print (fout, "\tstruct sockaddr_in saddr;\n"); - f_print (fout, "\tint asize = sizeof (saddr);\n"); - f_print (fout, "\n"); - f_print (fout, - "\tif (getsockname (0, (struct sockaddr *)&saddr, &asize) == 0) {\n"); - f_print (fout, "\t\tint ssize = sizeof (int);\n\n"); - f_print (fout, "\t\tif (saddr.sin_family != AF_INET)\n"); - f_print (fout, "\t\t\texit (1);\n"); - f_print (fout, "\t\tif (getsockopt (0, SOL_SOCKET, SO_TYPE,\n"); - f_print (fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n"); - f_print (fout, "\t\t\texit (1);\n"); - f_print (fout, "\t\tsock = 0;\n"); - f_print (fout, "\t\t_rpcpmstart = 1;\n"); - f_print (fout, "\t\tproto = 0;\n"); - open_log_file (infile, "\t\t"); - f_print (fout, "\t} else {\n"); - write_rpc_svc_fg (infile, "\t\t"); - f_print (fout, "\t\tsock = RPC_ANYSOCK;\n"); - print_pmapunset ("\t\t"); - f_print (fout, "\t}\n"); -} - -static void -print_return (const char *space) -{ - if (exitnow) - f_print (fout, "%sexit (0);\n", space); - else - { - if (timerflag) - { -#if 0 - f_print (fout, "%s_rpcsvcdirty = 0;\n", space); -#else - if (mtflag) - f_print(fout, "%smutex_lock(&_svcstate_lock);\n", space); - f_print(fout, "%s_rpcsvcstate = _SERVED;\n", space); - if (mtflag) - f_print(fout, "%smutex_unlock(&_svcstate_lock);\n", space); -#endif - } - f_print (fout, "%sreturn;\n", space); - } -} - -static void -print_pmapunset (const char *space) -{ - list *l; - definition *def; - version_list *vp; - - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - for (vp = def->def.pr.versions; vp != NULL; - vp = vp->next) - { - f_print (fout, "%spmap_unset (%s, %s);\n", - space, def->def_name, vp->vers_name); - } - } - } -} - -static void -print_err_message (const char *space) -{ - if (logflag) - f_print (fout, "%ssyslog (LOG_ERR, \"%%s\", \"%s\");\n", space, _errbuf); - else if (inetdflag || pmflag) - f_print (fout, "%s_msgout (\"%s\");\n", space, _errbuf); - else - f_print (fout, "%sfprintf (stderr, \"%%s\", \"%s\");\n", space, _errbuf); -} - -/* - * Write the server auxiliary function ( _msgout, timeout) - */ -void -write_svc_aux (int nomain) -{ - if (!logflag) - write_msg_out (); - if (!nomain) - write_timeout_func (); -} - -/* - * Write the _msgout function - */ - -void -write_msg_out (void) -{ - f_print (fout, "\n"); - f_print (fout, "static\n"); - if (!Cflag) - { - f_print (fout, "void _msgout (msg)\n"); - f_print (fout, "\tchar *msg;\n"); - } - else - { - f_print (fout, "void _msgout (char* msg)\n"); - } - f_print (fout, "{\n"); - f_print (fout, "#ifdef RPC_SVC_FG\n"); - if (inetdflag || pmflag) - f_print (fout, "\tif (_rpcpmstart)\n"); - f_print (fout, "\t\tsyslog (LOG_ERR, \"%%s\", msg);\n"); - f_print (fout, "\telse\n"); - f_print (fout, "\t\tfprintf (stderr, \"%%s\\n\", msg);\n"); - f_print (fout, "#else\n"); - f_print (fout, "\tsyslog (LOG_ERR, \"%%s\", msg);\n"); - f_print (fout, "#endif\n"); - f_print (fout, "}\n"); -} - -/* - * Write the timeout function - */ -static void -write_timeout_func (void) -{ - if (!timerflag) - return; - f_print (fout, "\n"); - f_print (fout, "static void\n"); - if (Cflag) - f_print (fout, "closedown (int sig)\n"); - else - f_print (fout, "closedown (sig)\n\tint sig;\n"); - f_print (fout, "{\n"); - -#if 0 - f_print (fout, "\t(void) signal (sig, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); -#endif - if (mtflag) - f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); -#if 0 - f_print (fout, "\tif (_rpcsvcdirty == 0) {\n"); -#else - f_print(fout, "\tif (_rpcsvcstate == _IDLE) {\n"); -#endif - f_print (fout, "\t\textern fd_set svc_fdset;\n"); - f_print (fout, "\t\tstatic int size;\n"); - f_print (fout, "\t\tint i, openfd;\n"); - if (tirpcflag && pmflag) - { - f_print (fout, "\t\tstruct t_info tinfo;\n\n"); - f_print (fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n"); - } - else - { - f_print (fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n"); - } - f_print (fout, "\t\t\texit (0);\n"); - f_print (fout, "\t\tif (size == 0) {\n"); - if (tirpcflag) - { - f_print (fout, "\t\t\tstruct rlimit rl;\n\n"); - f_print (fout, "\t\t\trl.rlim_max = 0;\n"); - f_print (fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n"); - f_print (fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n"); - if (mtflag) - f_print(fout, "\t\t\t\tmutex_unlock(&_svcstate_lock);\n"); - f_print (fout, "\t\t\t\treturn;\n\t\t\t}\n"); - } - else - { - f_print (fout, "\t\t\tsize = getdtablesize();\n"); - } - f_print (fout, "\t\t}\n"); - f_print (fout, "\t\tfor (i = 0, openfd = 0; i < size && openfd < 2; i++)\n"); - f_print (fout, "\t\t\tif (FD_ISSET(i, &svc_fdset))\n"); - f_print (fout, "\t\t\t\topenfd++;\n"); - f_print (fout, "\t\tif (openfd <= 1)\n"); - f_print (fout, "\t\t\texit (0);\n"); - f_print (fout, "\t}\n"); - f_print(fout, "\tif (_rpcsvcstate == _SERVED)\n"); - f_print(fout, "\t\t_rpcsvcstate = _IDLE;\n\n"); - if (mtflag) - f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); - f_print(fout, "\t(void) signal(SIGALRM, %s closedown);\n", - Cflag? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\talarm (_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "}\n"); -} - -/* - * Write the most of port monitor support - */ -static void -write_pm_most (const char *infile, int netflag) -{ - list *l; - definition *def; - version_list *vp; - - f_print (fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n"); - f_print (fout, "\t\t(!strcmp(mname, \"sockmod\") ||"); - f_print (fout, " !strcmp(mname, \"timod\"))) {\n"); - f_print (fout, "\t\tchar *netid;\n"); - if (!netflag) - { /* Not included by -n option */ - f_print (fout, "\t\tstruct netconfig *nconf = NULL;\n"); - f_print (fout, "\t\tSVCXPRT *%s;\n", TRANSP); - } - if (timerflag) - f_print (fout, "\t\tint pmclose;\n"); -/* not necessary, defined in /usr/include/stdlib */ -/* f_print(fout, "\t\textern char *getenv();\n"); */ - f_print (fout, "\n"); - f_print (fout, "\t\t_rpcpmstart = 1;\n"); - if (logflag) - open_log_file (infile, "\t\t"); - f_print (fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n"); - sprintf (_errbuf, "cannot get transport name"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n"); - sprintf (_errbuf, "cannot get transport info"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t}\n"); - /* - * A kludgy support for inetd services. Inetd only works with - * sockmod, and RPC works only with timod, hence all this jugglery - */ - f_print (fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n"); - f_print (fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n"); - sprintf (_errbuf, "could not get the right module"); - print_err_message ("\t\t\t\t"); - f_print (fout, "\t\t\t\texit(1);\n"); - f_print (fout, "\t\t\t}\n"); - f_print (fout, "\t\t}\n"); - if (timerflag) - f_print (fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n"); - f_print (fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n", - TRANSP); - sprintf (_errbuf, "cannot create server handle"); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t\texit(1);\n"); - f_print (fout, "\t\t}\n"); - f_print (fout, "\t\tif (nconf)\n"); - f_print (fout, "\t\t\tfreenetconfigent(nconf);\n"); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, - "\t\tif (!svc_reg(%s, %s, %s, ", - TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - f_print (fout, ", 0)) {\n"); - (void) sprintf (_errbuf, "unable to register (%s, %s).", - def->def_name, vp->vers_name); - print_err_message ("\t\t\t"); - f_print (fout, "\t\t\texit(1);\n"); - f_print (fout, "\t\t}\n"); - } - } - if (timerflag) - { - f_print (fout, "\t\tif (pmclose) {\n"); - f_print (fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n", - Cflag ? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); - f_print (fout, "\t\t}\n"); - } - f_print (fout, "\t\tsvc_run();\n"); - f_print (fout, "\t\texit(1);\n"); - f_print (fout, "\t\t/* NOTREACHED */\n"); - f_print (fout, "\t}\n"); -} - -/* - * Support for backgrounding the server if self started. - */ -static void -write_rpc_svc_fg (const char *infile, const char *sp) -{ - f_print (fout, "#ifndef RPC_SVC_FG\n"); - f_print (fout, "%sint size;\n", sp); - if (tirpcflag) - f_print (fout, "%sstruct rlimit rl;\n", sp); - if (inetdflag) - f_print (fout, "%sint pid, i;\n\n", sp); - f_print (fout, "%spid = fork();\n", sp); - f_print (fout, "%sif (pid < 0) {\n", sp); - f_print (fout, "%s\tperror(\"cannot fork\");\n", sp); - f_print (fout, "%s\texit(1);\n", sp); - f_print (fout, "%s}\n", sp); - f_print (fout, "%sif (pid)\n", sp); - f_print (fout, "%s\texit(0);\n", sp); - /* get number of file descriptors */ - if (tirpcflag) - { - f_print (fout, "%srl.rlim_max = 0;\n", sp); - f_print (fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp); - f_print (fout, "%sif ((size = rl.rlim_max) == 0)\n", sp); - f_print (fout, "%s\texit(1);\n", sp); - } - else - { - f_print (fout, "%ssize = getdtablesize();\n", sp); - } - - f_print (fout, "%sfor (i = 0; i < size; i++)\n", sp); - f_print (fout, "%s\t(void) close(i);\n", sp); - /* Redirect stderr and stdout to console */ - f_print (fout, "%si = open(\"/dev/console\", 2);\n", sp); - f_print (fout, "%s(void) dup2(i, 1);\n", sp); - f_print (fout, "%s(void) dup2(i, 2);\n", sp); - /* This removes control of the controlling terminal */ - if (tirpcflag) - f_print (fout, "%ssetsid();\n", sp); - else - { - f_print (fout, "%si = open(\"/dev/tty\", 2);\n", sp); - f_print (fout, "%sif (i >= 0) {\n", sp); - f_print (fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);; - f_print (fout, "%s\t(void) close(i);\n", sp); - f_print (fout, "%s}\n", sp); - } - if (!logflag) - open_log_file (infile, sp); - f_print (fout, "#endif\n"); - if (logflag) - open_log_file (infile, sp); -} - -static void -open_log_file (const char *infile, const char *sp) -{ - char *s; - - s = strrchr (infile, '.'); - if (s) - *s = '\0'; - f_print (fout, "%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile); - if (s) - *s = '.'; -} - -/* - * write a registration for the given transport for Inetd - */ -void -write_inetd_register (const char *transp) -{ - list *l; - definition *def; - version_list *vp; - const char *sp; - int isudp; - char tmpbuf[32]; - - if (inetdflag) - sp = "\t"; - else - sp = ""; - if (streq (transp, "udp") || streq (transp, "udp6")) - isudp = 1; - else - isudp = 0; - f_print (fout, "\n"); - if (inetdflag) - { - f_print (fout, "\tif ((_rpcfdtype == 0) || (_rpcfdtype == %s)) {\n", - isudp ? "SOCK_DGRAM" : "SOCK_STREAM"); - } - f_print (fout, "%s\t%s = svc%s_create(%s", - sp, TRANSP, transp, inetdflag ? "sock" : "RPC_ANYSOCK"); - if (!isudp) - f_print (fout, ", 0, 0"); - f_print (fout, ");\n"); - f_print (fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); - (void) sprintf (_errbuf, "cannot create %s service.", transp); - (void) sprintf (tmpbuf, "%s\t\t", sp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); - f_print (fout, "%s\t}\n", sp); - - if (inetdflag) - { - f_print (fout, "%s\tif (!_rpcpmstart)\n\t", sp); - f_print (fout, "%s\tproto = IPPROTO_%s;\n", - sp, isudp ? "UDP" : "TCP"); - } - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) - { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - f_print (fout, "%s\tif (!svc_register(%s, %s, %s, ", - sp, TRANSP, def->def_name, vp->vers_name); - pvname (def->def_name, vp->vers_num); - if (inetdflag) - f_print (fout, ", proto)) {\n"); - else - f_print (fout, ", IPPROTO_%s)) {\n", - isudp ? "UDP" : "TCP"); - (void) sprintf (_errbuf, "unable to register (%s, %s, %s).", - def->def_name, vp->vers_name, transp); - print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); - f_print (fout, "%s\t}\n", sp); - } - } - if (inetdflag) - f_print (fout, "\t}\n"); -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_tblout.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_tblout.c deleted file mode 100644 index a7d2f43..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_tblout.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * From: @(#)rpc_tblout.c 1.4 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define TABSIZE 8 -#define TABCOUNT 5 -#define TABSTOP (TABSIZE*TABCOUNT) - -static const char tabstr[TABCOUNT + 1] = "\t\t\t\t\t"; - -static const char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n"; -static const char tbl_end[] = "};\n"; - -static const char null_entry[] = "\n\t(char *(*)())0,\n\ - \t(xdrproc_t) xdr_void,\t\t\t0,\n\ - \t(xdrproc_t) xdr_void,\t\t\t0,\n"; - - -static const char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n"; - -static void write_table (const definition * def); -static void printit (const char *prefix, const char *type); - -void -write_tables (void) -{ - list *l; - definition *def; - - f_print (fout, "\n"); - for (l = defined; l != NULL; l = l->next) - { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) - { - write_table (def); - } - } -} - -static void -write_table (const definition * def) -{ - version_list *vp; - proc_list *proc; - int current; - int expected; - char progvers[100]; - int warning; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) - { - warning = 0; - s_print (progvers, "%s_%s", - locase (def->def_name), vp->vers_num); - /* print the table header */ - f_print (fout, tbl_hdr, progvers); - - if (nullproc (vp->procs)) - { - expected = 0; - } - else - { - expected = 1; - f_print (fout, null_entry); - } - for (proc = vp->procs; proc != NULL; proc = proc->next) - { - current = atoi (proc->proc_num); - if (current != expected++) - { - f_print (fout, - "\n/*\n * WARNING: table out of order\n */\n"); - if (warning == 0) - { - f_print (stderr, - "WARNING %s table is out of order\n", - progvers); - warning = 1; - nonfatalerrors = 1; - } - expected = current + 1; - } - f_print (fout, "\n\t(char *(*)())RPCGEN_ACTION("); - - /* routine to invoke */ - if (Cflag && !newstyle) - pvname_svc (proc->proc_name, vp->vers_num); - else - { - if (newstyle) - f_print (fout, "_"); /* calls internal func */ - pvname (proc->proc_name, vp->vers_num); - } - f_print (fout, "),\n"); - - /* argument info */ - if (proc->arg_num > 1) - printit ((char *) NULL, proc->args.argname); - else - /* do we have to do something special for newstyle */ - printit (proc->args.decls->decl.prefix, - proc->args.decls->decl.type); - /* result info */ - printit (proc->res_prefix, proc->res_type); - } - - /* print the table trailer */ - f_print (fout, tbl_end); - f_print (fout, tbl_nproc, progvers, progvers, progvers); - } -} - -static void -printit (const char *prefix, const char *type) -{ - int len; - int tabs; - - - len = fprintf (fout, "\txdr_%s,", stringfix (type)); - /* account for leading tab expansion */ - len += TABSIZE - 1; - /* round up to tabs required */ - tabs = (TABSTOP - len + TABSIZE - 1) / TABSIZE; - f_print (fout, "%s", &tabstr[TABCOUNT - tabs]); - - if (streq (type, "void")) - { - f_print (fout, "0"); - } - else - { - f_print (fout, "sizeof ( "); - /* XXX: should "follow" be 1 ??? */ - ptype (prefix, type, 0); - f_print (fout, ")"); - } - f_print (fout, ",\n"); -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_util.c b/rpcsvc-proto-1.4.2/rpcgen/rpc_util.c deleted file mode 100644 index 52aa697..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_util.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * From: @(#)rpc_util.c 1.11 89/02/22 - * - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpc_util.c, Utility routines for the RPC protocol compiler - */ -#include -#include -#include -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" -#include "proto.h" - -#define ARGEXT "argument" - -char curline[MAXLINESIZE]; /* current read line */ -const char *where = curline; /* current point in line */ -int linenum = 0; /* current line number */ - -const char *infilename; /* input filename */ - -#define NFILES 7 -const char *outfiles[NFILES]; /* output file names */ -int nfiles; - -FILE *fout; /* file pointer of current output */ -FILE *fin; /* file pointer of current input */ - -list *defined; /* list of defined things */ - -static int findit (const definition * def, const char *type); -static const char *fixit (const char *type, const char *orig); -static int typedefed (const definition * def, const char *type); -static const char *toktostr (tok_kind kind); -static void printbuf (void); -static void printwhere (void); - -/* - * Reinitialize the world - */ -void -reinitialize (void) -{ - memset (curline, 0, MAXLINESIZE); - where = curline; - linenum = 0; - defined = NULL; -} - -/* - * string equality - */ -int -streq (const char *a, const char *b) -{ - return strcmp (a, b) == 0; -} - -/* - * find a value in a list - */ -definition * -findval (list *lst, const char *val, - int (*cmp) (const definition *, const char *)) -{ - - for (; lst != NULL; lst = lst->next) - { - if (cmp (lst->val, val)) - { - return lst->val; - } - } - return NULL; -} - -/* - * store a value in a list - */ -void -storeval (list **lstp, definition *val) -{ - list **l; - list *lst; - - - for (l = lstp; *l != NULL; l = (list **) & (*l)->next); - lst = ALLOC (list); - lst->val = val; - lst->next = NULL; - *l = lst; -} - -static int -findit (const definition * def, const char *type) -{ - return streq (def->def_name, type); -} - -static const char * -fixit (const char *type, const char *orig) -{ - definition *def; - - def = findval (defined, type, findit); - if (def == NULL || def->def_kind != DEF_TYPEDEF) - { - return orig; - } - switch (def->def.ty.rel) - { - case REL_VECTOR: - if (streq (def->def.ty.old_type, "opaque")) - return ("char"); - else - return (def->def.ty.old_type); - case REL_ALIAS: - return (fixit (def->def.ty.old_type, orig)); - default: - return orig; - } -} - -const char * -fixtype (const char *type) -{ - return fixit (type, type); -} - -const char * -stringfix (const char *type) -{ - if (streq (type, "string")) - { - return "wrapstring"; - } - else - { - return type; - } -} - -void -ptype (const char *prefix, const char *type, int follow) -{ - if (prefix != NULL) - { - if (streq (prefix, "enum")) - { - f_print (fout, "enum "); - } - else - { - f_print (fout, "struct "); - } - } - if (streq (type, "bool")) - { - f_print (fout, "bool_t "); - } - else if (streq (type, "string")) - { - f_print (fout, "char *"); - } - else - { - f_print (fout, "%s ", follow ? fixtype (type) : type); - } -} - -static int -typedefed (const definition * def, const char *type) -{ - if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) - { - return 0; - } - else - { - return streq (def->def_name, type); - } -} - -int -isvectordef (const char *type, relation rel) -{ - definition *def; - - for (;;) - { - switch (rel) - { - case REL_VECTOR: - return !streq (type, "string"); - case REL_ARRAY: - return 0; - case REL_POINTER: - return 0; - case REL_ALIAS: - def = findval (defined, type, typedefed); - if (def == NULL) - { - return 0; - } - type = def->def.ty.old_type; - rel = def->def.ty.rel; - } - } -} - -char * -locase (const char *str) -{ - char c; - static char buf[100]; - char *p = buf; - - while ((c = *str++) != 0) - { - *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; - } - *p = 0; - return buf; -} - -void -pvname_svc (const char *pname, const char *vnum) -{ - f_print (fout, "%s_%s_svc", locase (pname), vnum); -} - -void -pvname (const char *pname, const char *vnum) -{ - f_print (fout, "%s_%s", locase (pname), vnum); -} - -/* - * print a useful (?) error message, and then die - */ -void -error (const char *msg) -{ - printwhere (); - f_print (stderr, "%s, line %d: ", infilename, linenum); - f_print (stderr, "%s\n", msg); - crash (); -} - -/* - * Something went wrong, unlink any files that we may have created and then - * die. - */ -void -crash (void) -{ - int i; - - for (i = 0; i < nfiles; i++) - { - unlink (outfiles[i]); - } - exit (1); -} - -void -record_open (const char *file) -{ - if (nfiles < NFILES) - { - outfiles[nfiles++] = file; - } - else - { - f_print (stderr, "too many files!\n"); - crash (); - } -} - -static char expectbuf[100]; - -/* - * error, token encountered was not the expected one - */ -void -expected1 (tok_kind exp1) -{ - s_print (expectbuf, "expected '%s'", - toktostr (exp1)); - error (expectbuf); -} - -/* - * error, token encountered was not one of two expected ones - */ -void -expected2 (tok_kind exp1, tok_kind exp2) -{ - s_print (expectbuf, "expected '%s' or '%s'", - toktostr (exp1), - toktostr (exp2)); - error (expectbuf); -} - -/* - * error, token encountered was not one of 3 expected ones - */ -void -expected3 (tok_kind exp1, tok_kind exp2, tok_kind exp3) -{ - s_print (expectbuf, "expected '%s', '%s' or '%s'", - toktostr (exp1), - toktostr (exp2), - toktostr (exp3)); - error (expectbuf); -} - -void -tabify (FILE * f, int tab) -{ - while (tab--) - { - (void) fputc ('\t', f); - } -} - - -static const token tokstrings[] = -{ - {TOK_IDENT, "identifier"}, - {TOK_CONST, "const"}, - {TOK_RPAREN, ")"}, - {TOK_LPAREN, "("}, - {TOK_RBRACE, "}"}, - {TOK_LBRACE, "{"}, - {TOK_LBRACKET, "["}, - {TOK_RBRACKET, "]"}, - {TOK_STAR, "*"}, - {TOK_COMMA, ","}, - {TOK_EQUAL, "="}, - {TOK_COLON, ":"}, - {TOK_SEMICOLON, ";"}, - {TOK_UNION, "union"}, - {TOK_STRUCT, "struct"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_ENUM, "enum"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_INT, "int"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_DOUBLE, "double"}, - {TOK_FLOAT, "float"}, - {TOK_CHAR, "char"}, - {TOK_STRING, "string"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"} -}; - -static const char * -toktostr (tok_kind kind) -{ - const token *sp; - - for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++); - return sp->str; -} - -static void -printbuf (void) -{ - char c; - int i; - int cnt; - -#define TABSIZE 4 - - for (i = 0; (c = curline[i]) != 0; i++) - { - if (c == '\t') - { - cnt = 8 - (i % TABSIZE); - c = ' '; - } - else - { - cnt = 1; - } - while (cnt--) - { - (void) fputc (c, stderr); - } - } -} - -static void -printwhere (void) -{ - int i; - char c; - int cnt; - - printbuf (); - for (i = 0; i < where - curline; i++) - { - c = curline[i]; - if (c == '\t') - { - cnt = 8 - (i % TABSIZE); - } - else - { - cnt = 1; - } - while (cnt--) - { - (void) fputc ('^', stderr); - } - } - (void) fputc ('\n', stderr); -} - -char * -make_argname (const char *pname, const char *vname) -{ - char *name; - - name = malloc (strlen (pname) + strlen (vname) + strlen (ARGEXT) + 3); - if (!name) - { - fprintf (stderr, "failed in malloc"); - exit (1); - } - sprintf (name, "%s_%s_%s", locase (pname), vname, ARGEXT); - return name; -} - -bas_type *typ_list_h; -bas_type *typ_list_t; - -void -add_type (int len, const char *type) -{ - bas_type *ptr; - - - if ((ptr = malloc (sizeof (bas_type))) == NULL) - { - fprintf (stderr, "failed in malloc"); - exit (1); - } - - ptr->name = type; - ptr->length = len; - ptr->next = NULL; - if (typ_list_t == NULL) - { - - typ_list_t = ptr; - typ_list_h = ptr; - } - else - { - - typ_list_t->next = ptr; - typ_list_t = ptr; - } - -} - - -bas_type * -find_type (const char *type) -{ - bas_type *ptr; - - ptr = typ_list_h; - - - while (ptr != NULL) - { - if (strcmp (ptr->name, type) == 0) - return ptr; - else - ptr = ptr->next; - }; - return NULL; -} diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpc_util.h b/rpcsvc-proto-1.4.2/rpcgen/rpc_util.h deleted file mode 100644 index 53316d9..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpc_util.h +++ /dev/null @@ -1,154 +0,0 @@ -/* @(#)rpc_util.h 1.5 90/08/29 */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * rpc_util.h, Useful definitions for the RPC protocol compiler - */ - -#include - -#define alloc(size) malloc((unsigned)(size)) -#define ALLOC(object) (object *) malloc(sizeof(object)) - -#define s_print (void) sprintf -#define f_print (void) fprintf - -struct list { - definition *val; - struct list *next; -}; -typedef struct list list; - -struct xdrfunc { - char *name; - int pointerp; - struct xdrfunc *next; -}; -typedef struct xdrfunc xdrfunc; - -#define PUT 1 -#define GET 2 - -/* - * Global variables - */ -#define MAXLINESIZE 1024 -extern char curline[MAXLINESIZE]; -extern const char *where; -extern int linenum; - -extern const char *infilename; -extern FILE *fout; -extern FILE *fin; - -extern list *defined; - -extern bas_type *typ_list_h; -extern bas_type *typ_list_t; -extern xdrfunc *xdrfunc_head, *xdrfunc_tail; - -/* - * All the option flags - */ -extern int inetdflag; -extern int pmflag; -extern int tblflag; -extern int logflag; -extern int newstyle; -extern int Cflag; /* C++ flag */ -extern int CCflag; /* C++ flag */ -extern int tirpcflag; /* flag for generating tirpc code */ -extern int inlineflag; /* if this is 0, then do not generate inline code */ -extern int mtflag; - -/* - * Other flags related with inetd jumpstart. - */ -extern int indefinitewait; -extern int exitnow; -extern int timerflag; - -extern int nonfatalerrors; - -/* - * rpc_util routines - */ -void storeval(list **lstp, definition *val); -#define STOREVAL(list,item) storeval(list,item) - -definition *findval(list *lst, const char *val, - int (*cmp)(const definition *, const char *)); -#define FINDVAL(list,item,finder) findval(list, item, finder) - -const char *fixtype(const char *type); -const char *stringfix(const char *type); -char *locase(const char *str); -void pvname_svc(const char *pname, const char *vnum); -void pvname(const char *pname, const char *vnum); -void ptype(const char *prefix, const char *type, int follow); -int isvectordef(const char *type, relation rel); -int streq(const char *a, const char *b); -void error(const char *msg); -void tabify(FILE *f, int tab); -void record_open(const char *file); -bas_type *find_type(const char *type); - - -/* - * rpc_cout routines - */ -void emit(definition *def); - -/* - * rpc_hout routines - */ -void print_datadef(definition *def); -void print_funcdef(definition *def); - -/* - * rpc_svcout routines - */ -void write_most(const char *infile, int netflag, int nomain); -void write_register(void); -void write_rest(void); -void write_programs(const char *storage); -void write_svc_aux(int nomain); -void write_inetd_register(const char *transp); -void write_netid_register(const char *); -void write_nettype_register(const char *); -/* - * rpc_clntout routines - */ -void write_stubs(void); - -/* - * rpc_tblout routines - */ -void write_tables(void); diff --git a/rpcsvc-proto-1.4.2/rpcgen/rpcgen.1 b/rpcsvc-proto-1.4.2/rpcgen/rpcgen.1 deleted file mode 100644 index 9db1b4a..0000000 --- a/rpcsvc-proto-1.4.2/rpcgen/rpcgen.1 +++ /dev/null @@ -1,442 +0,0 @@ -.\" @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89 -.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved. -.nr X -.if \nX=0 .ds x} rpcgen 1 "" "\&" -.if \nX=1 .ds x} rpcgen 1 "" -.if \nX=2 .ds x} rpcgen 1 "" "\&" -.if \nX=3 .ds x} rpcgen "" "" "\&" -.TH \*(x} -.SH NAME -\f4rpcgen\f1 \- an RPC protocol compiler -.SH SYNOPSIS -.ft 4 -.nf -rpcgen \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen [\-D\f2name\f4[=\f2value\f4]] [\-T] [\-K \f2secs\fP] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen \-c|\-h|\-l|\-m|\-M|\-t [\-o \f2outfile\f4 ] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen [\-I] \-s \f2nettype\f4 [\-o \f2outfile\f4] \f2infile\f4 -.fi -.ft 1 -.br -.ft 4 -.nf -rpcgen \-n \f2netid\f4 [\-o \f2outfile\f4] \f2infile\f4 -.ft 1 -.SH DESCRIPTION -.P -\f4rpcgen\f1 -is a tool that generates C code to implement an RPC protocol. -The input to -\f4rpcgen\f1 -is a language similar to C known as -RPC Language (Remote Procedure Call Language). -.P -\f4rpcgen\f1 -is normally used as in the first synopsis where -it takes an input file and generates up to four output files. -If the -\f2infile\f1 -is named -\f4proto.x\f1, -then -\f4rpcgen\f1 -will generate a header file in -\f4proto.h\f1, -XDR routines in -\f4proto_xdr.c\f1, -server-side stubs in -\f4proto_svc.c\f1, -and client-side stubs in -\f4proto_clnt.c\f1. -With the -\f4\-T\f1 -option, -it will also generate the RPC dispatch table in -\f4proto_tbl.i\f1. -With the -\f4\-Sc\f1 -option, -it will also generate sample code which would illustrate how to use the -remote procedures on the client side. This code would be created in -\f4proto_client.c\f1. -With the -\f4\-Ss\f1 -option, -it will also generate a sample server code which would illustrate how to write -the remote procedures. This code would be created in -\f4proto_server.c\f1. -.P -The server created can be started both by the port monitors -(for example, \f4inetd\f1 or \f4listen\f1) -or by itself. -When it is started by a port monitor, -it creates servers only for the transport for which -the file descriptor \f40\fP was passed. -The name of the transport must be specified -by setting up the environmental variable -\f4PM_TRANSPORT\f1. -When the server generated by -\f4rpcgen\f1 -is executed, -it creates server handles for all the transports -specified in -\f4NETPATH\f1 -environment variable, -or if it is unset, -it creates server handles for all the visible transports from -\f4/etc/netconfig\f1 -file. -Note: -the transports are chosen at run time and not at compile time. -.P -When built for a port monitor (\f4rpcgen\f1 \f4\-I\f1), and that the server -is self-started, it backgrounds itself by default. A special define symbol -\f4RPC_SVC_FG\f1 can be used to run the server process in foreground. -.P -The second synopsis provides special features which allow -for the creation of more sophisticated RPC servers. -These features include support for user provided -\f4#defines\f1 -and RPC dispatch tables. -The entries in the RPC dispatch table contain: -.RS -.PD 0 -.TP 3 -\(bu -pointers to the service routine corresponding to that procedure, -.TP -\(bu -a pointer to the input and output arguments -.TP -\(bu -the size of these routines -.PD -.RE -A server can use the dispatch table to check authorization -and then to execute the service routine; -a client library may use it to deal with the details of storage -management and XDR data conversion. -.P -The other three synopses shown above are used when -one does not want to generate all the output files, -but only a particular one. -Some examples of their usage is described in the -EXAMPLE -section below. -When -\f4rpcgen\f1 -is executed with the -\f4\-s\f1 -option, -it creates servers for that particular class of transports. -When -executed with the -\f4\-n\f1 -option, -it creates a server for the transport specified by -\f2netid\f1. -If -\f2infile\f1 -is not specified, -\f4rpcgen\f1 -accepts the standard input. -.P -The C preprocessor, -\f4cc \-E\f1 -[see \f4cc\fP(1)], -is run on the input file before it is actually interpreted by -\f4rpcgen\f1. -For each type of output file, -\f4rpcgen\f1 -defines a special preprocessor symbol for use by the -\f4rpcgen\f1 -programmer: -.P -.PD 0 -.TP 12 -\f4RPC_HDR\f1 -defined when compiling into header files -.TP -\f4RPC_XDR\f1 -defined when compiling into XDR routines -.TP -\f4RPC_SVC\f1 -defined when compiling into server-side stubs -.TP -\f4RPC_CLNT\f1 -defined when compiling into client-side stubs -.TP -\f4RPC_TBL\f1 -defined when compiling into RPC dispatch tables -.PD -.P -Any line beginning with -`\f4%\f1' -is passed directly into the output file, -uninterpreted by -\f4rpcgen\f1. -.P -For every data type referred to in -\f2infile\f1, -\f4rpcgen\f1 -assumes that there exists a -routine with the string -\f4xdr_\f1 -prepended to the name of the data type. -If this routine does not exist in the RPC/XDR -library, it must be provided. -Providing an undefined data type -allows customization of XDR routines. -.br -.ne 10 -.P -The following options are available: -.TP -\f4\-a\f1 -Generate all the files including sample code for client and server side. -.TP -\f4\-b\f1 -This generates code for the SunOS4.1 style of rpc. It is -for backward compatibility. This is the default. -.TP -\f4\-5\f1 -This generates code for the SysVr4 style of rpc. It is used by the -Transport Independent RPC that is in Svr4 systems. -By default rpcgen generates code for SunOS4.1 stype of rpc. -.TP -\f4\-c\f1 -Compile into XDR routines. -.TP -\f4\-C\f1 -Generate code in ANSI C. This option also generates code that could be -compiled with the C++ compiler. This is the default. -.TP -\f4\-k\f1 -Generate code in K&R C. The default is ANSI C. -.TP -\f4\-D\f2name\f4[=\f2value\f4]\f1 -Define a symbol -\f2name\f1. -Equivalent to the -\f4#define\f1 -directive in the source. -If no -\f2value\f1 -is given, -\f2value\f1 -is defined as \f41\f1. -This option may be specified more than once. -.TP -\f4\-h\f1 -Compile into -\f4C\f1 -data-definitions (a header file). -\f4\-T\f1 -option can be used in conjunction to produce a -header file which supports RPC dispatch tables. -.TP -\f4\-I\f1 -Generate a service that can be started from inetd. The default is -to generate a static service that handles transports selected with \f4\-s\f1. -Using \f4\-I\f1 allows starting a service by either method. -.TP -\f4-K\f2 secs\f1 -By default, services created using \f4rpcgen\fP wait \f4120\fP seconds -after servicing a request before exiting. -That interval can be changed using the \f4-K\fP flag. -To create a server that exits immediately upon servicing a request, -\f4-K\ 0\fP can be used. -To create a server that never exits, the appropriate argument is -\f4-K\ -1\fP. -.IP -When monitoring for a server, -some portmonitors, like -\f4listen\fP(1M), -.I always -spawn a new process in response to a service request. -If it is known that a server will be used with such a monitor, the -server should exit immediately on completion. -For such servers, \f4rpcgen\fP should be used with \f4-K\ -1\fP. -.TP -\f4\-l\f1 -Compile into client-side stubs. -.TP -\f4\-m\f1 -Compile into server-side stubs, -but do not generate a \(lqmain\(rq routine. -This option is useful for doing callback-routines -and for users who need to write their own -\(lqmain\(rq routine to do initialization. -.TP -\f4\-M\f1 -Generate multithread-safe stubs for passing arguments -and results between rpcgen-generated code and user written code. -This option is useful for users who want to use threads in their code. -.TP -\f4\-n \f2netid\f1 -Compile into server-side stubs for the transport -specified by -\f2netid\f1. -There should be an entry for -\f2netid\f1 -in the -netconfig database. -This option may be specified more than once, -so as to compile a server that serves multiple transports. -.TP -\f4\-N\f1 -Use the newstyle of rpcgen. This allows procedures to have multiple arguments. -It also uses the style of parameter passing that closely resembles C. So, when -passing an argument to a remote procedure you do not have to pass a pointer to -the argument but the argument itself. This behaviour is different from the oldstyle -of rpcgen generated code. The newstyle is not the default case because of -backward compatibility. -.TP -\f4\-o \f2outfile\f1 -Specify the name of the output file. -If none is specified, -standard output is used -(\f4\-c\f1, -\f4\-h\f1, -\f4\-l\f1, -\f4\-m\f1, -\f4\-n\f1, -\f4\-s\f1, -\f4\-Sc\f1, -\f4\-Sm\f1, -\f4\-Ss\f1, -and -\f4\-t\f1 -modes only). -.TP -\f4\-s \f2nettype\f1 -Compile into server-side stubs for all the -transports belonging to the class -\f2nettype\f1. -The supported classes are -\f4netpath\f1, -\f4visible\f1, -\f4circuit_n\f1, -\f4circuit_v\f1, -\f4datagram_n\f1, -\f4datagram_v\f1, -\f4tcp\f1, -and -\f4udp\f1 -[see \f4rpc\fP(3N) -for the meanings associated with these classes]. -This option may be specified more than once. -Note: -the transports are chosen at run time and not at compile time. -.TP -\f4\-Sc\f1 -Generate sample code to show the use of remote procedure and how to bind -to the server before calling the client side stubs generated by rpcgen. -.TP -\f4\-Sm\f1 -Generate a sample Makefile which can be used for compiling the application. -.TP -\f4\-Ss\f1 -Generate skeleton code for the remote procedures on the server side. You would need -to fill in the actual code for the remote procedures. -.TP -\f4\-t\f1 -Compile into RPC dispatch table. -.TP -\f4\-T\f1 -Generate the code to support RPC dispatch tables. -.P -The options -\f4\-c\f1, -\f4\-h\f1, -\f4\-l\f1, -\f4\-m\f1, -\f4\-s\f1 -and -\f4\-t\f1 -are used exclusively to generate a particular type of file, -while the options -\f4\-D\f1 -and -\f4\-T\f1 -are global and can be used with the other options. -.br -.ne 5 -.SH NOTES -The RPC Language does not support nesting of structures. -As a work-around, -structures can be declared at the top-level, -and their name used inside other structures in -order to achieve the same effect. -.P -Name clashes can occur when using program definitions, -since the apparent scoping does not really apply. -Most of these can be avoided by giving -unique names for programs, -versions, -procedures and types. -.P -The server code generated with -\f4\-n\f1 -option refers to the transport indicated by -\f2netid\f1 -and hence is very site specific. -.SH EXAMPLE -The following example: -.IP -.ft 4 -$ rpcgen \-T prot.x -.ft 1 -.P -generates the five files: -\f4prot.h\f1, -\f4prot_clnt.c\f1, -\f4prot_svc.c\f1, -\f4prot_xdr.c\f1 -and -\f4prot_tbl.i\f1. -.P -The following example sends the C data-definitions (header file) -to the standard output. -.IP -.ft 4 -$ rpcgen \-h prot.x -.ft 1 -.P -To send the test version of the -\f4-DTEST\f1, -server side stubs for -all the transport belonging to the class -\f4datagram_n\f1 -to standard output, use: -.IP -.ft 4 -$ rpcgen \-s datagram_n \-DTEST prot.x -.ft 1 -.P -To create the server side stubs for the transport indicated -by -\f2netid\f1 -\f4tcp\f1, -use: -.IP -.ft 4 -$ rpcgen \-n tcp \-o prot_svc.c prot.x -.ft 1 -.SH "SEE ALSO" -\f4cc\fP(1). diff --git a/rpcsvc-proto-1.4.2/rpcsvc/Makefile.am b/rpcsvc-proto-1.4.2/rpcsvc/Makefile.am deleted file mode 100644 index 83867c0..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -rpcsvcdir = $(includedir)/rpcsvc - -CLEANFILES = *~ $(nodist_rpcsvc_HEADERS) - -rpcsvc_HEADERS = klm_prot.x nlm_prot.x rstat.x spray.x \ - bootparam_prot.x mount.x rex.x rusers.x key_prot.x nfs_prot.x \ - rquota.x sm_inter.x - -nodist_rpcsvc_HEADERS = klm_prot.h nlm_prot.h rstat.h spray.h \ - bootparam_prot.h mount.h rex.h rusers.h key_prot.h \ - nfs_prot.h rquota.h sm_inter.h - -%.h: %.x - $(top_builddir)/rpcgen/rpcgen -h -o $@ $< - diff --git a/rpcsvc-proto-1.4.2/rpcsvc/bootparam_prot.x b/rpcsvc-proto-1.4.2/rpcsvc/bootparam_prot.x deleted file mode 100644 index 117e428..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/bootparam_prot.x +++ /dev/null @@ -1,97 +0,0 @@ -/* @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * RPC for bootparms service. - * There are two procedures: - * WHOAMI takes a net address and returns a client name and also a - * likely net address for routing - * GETFILE takes a client name and file identifier and returns the - * server name, server net address and pathname for the file. - * file identifiers typically include root, swap, pub and dump - */ - -#ifdef RPC_HDR -%#include -%#include -%#include -%#include -#endif - -const MAX_MACHINE_NAME = 255; -const MAX_PATH_LEN = 1024; -const MAX_FILEID = 32; -const IP_ADDR_TYPE = 1; - -typedef string bp_machine_name_t; -typedef string bp_path_t; -typedef string bp_fileid_t; - -struct ip_addr_t { - char net; - char host; - char lh; - char impno; -}; - -union bp_address switch (int address_type) { - case IP_ADDR_TYPE: - ip_addr_t ip_addr; -}; - -struct bp_whoami_arg { - bp_address client_address; -}; - -struct bp_whoami_res { - bp_machine_name_t client_name; - bp_machine_name_t domain_name; - bp_address router_address; -}; - -struct bp_getfile_arg { - bp_machine_name_t client_name; - bp_fileid_t file_id; -}; - -struct bp_getfile_res { - bp_machine_name_t server_name; - bp_address server_address; - bp_path_t server_path; -}; - -program BOOTPARAMPROG { - version BOOTPARAMVERS { - bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; - bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; - } = 1; -} = 100026; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/key_prot.x b/rpcsvc-proto-1.4.2/rpcsvc/key_prot.x deleted file mode 100644 index 9baf943..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/key_prot.x +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Key server protocol definition - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The keyserver is a public key storage/encryption/decryption service - * The encryption method used is based on the Diffie-Hellman exponential - * key exchange technology. - * - * The key server is local to each machine, akin to the portmapper. - * Under TI-RPC, communication with the keyserver is through the - * loopback transport. - * - * NOTE: This .x file generates the USER level headers for the keyserver. - * the KERNEL level headers are created by hand as they kernel has special - * requirements. - */ - -%#if 0 -%#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" -%#endif -% -%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -% -%/* -% * Compiled from key_prot.x using rpcgen. -% * DO NOT EDIT THIS FILE! -% * This is NOT source code! -% */ - -/* - * PROOT and MODULUS define the way the Diffie-Hellman key is generated. - * - * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1, - * where p is also prime. - * - * PROOT satisfies the following two conditions: - * (1) (PROOT ** 2) % MODULUS != 1 - * (2) (PROOT ** p) % MODULUS != 1 - * - */ - -const PROOT = 3; -const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; - -const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */ -const KEYSIZE = 192; /* KEYSIZE == bit length of key */ -const KEYBYTES = 24; /* byte length of key */ - -/* - * The first 16 hex digits of the encrypted secret key are used as - * a checksum in the database. - */ -const KEYCHECKSUMSIZE = 16; - -/* - * status of operation - */ -enum keystatus { - KEY_SUCCESS, /* no problems */ - KEY_NOSECRET, /* no secret key stored */ - KEY_UNKNOWN, /* unknown netname */ - KEY_SYSTEMERR /* system error (out of memory, encryption failure) */ -}; - -typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */ - -typedef string netnamestr; - -/* - * Argument to ENCRYPT or DECRYPT - */ -struct cryptkeyarg { - netnamestr remotename; - des_block deskey; -}; - -/* - * Argument to ENCRYPT_PK or DECRYPT_PK - */ -struct cryptkeyarg2 { - netnamestr remotename; - netobj remotekey; /* Contains a length up to 1024 bytes */ - des_block deskey; -}; - - -/* - * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK - */ -union cryptkeyres switch (keystatus status) { -case KEY_SUCCESS: - des_block deskey; -default: - void; -}; - -const MAXGIDS = 16; /* max number of gids in gid list */ - -/* - * Unix credential - */ -struct unixcred { - u_int uid; - u_int gid; - u_int gids; -}; - -/* - * Result returned from GETCRED - */ -union getcredres switch (keystatus status) { -case KEY_SUCCESS: - unixcred cred; -default: - void; -}; -/* - * key_netstarg; - */ - -struct key_netstarg { - keybuf st_priv_key; - keybuf st_pub_key; - netnamestr st_netname; -}; - -union key_netstres switch (keystatus status){ -case KEY_SUCCESS: - key_netstarg knet; -default: - void; -}; - -#ifdef RPC_HDR -% -%#ifndef opaque -%#define opaque char -%#endif -% -#endif -program KEY_PROG { - version KEY_VERS { - - /* - * This is my secret key. - * Store it for me. - */ - keystatus - KEY_SET(keybuf) = 1; - - /* - * I want to talk to X. - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT(cryptkeyarg) = 2; - - /* - * X just sent me a message. - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT(cryptkeyarg) = 3; - - /* - * Generate a secure conversation key for me - */ - des_block - KEY_GEN(void) = 4; - - /* - * Get me the uid, gid and group-access-list associated - * with this netname (for kernel which cannot use NIS) - */ - getcredres - KEY_GETCRED(netnamestr) = 5; - } = 1; - version KEY_VERS2 { - - /* - * ####### - * Procedures 1-5 are identical to version 1 - * ####### - */ - - /* - * This is my secret key. - * Store it for me. - */ - keystatus - KEY_SET(keybuf) = 1; - - /* - * I want to talk to X. - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT(cryptkeyarg) = 2; - - /* - * X just sent me a message. - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT(cryptkeyarg) = 3; - - /* - * Generate a secure conversation key for me - */ - des_block - KEY_GEN(void) = 4; - - /* - * Get me the uid, gid and group-access-list associated - * with this netname (for kernel which cannot use NIS) - */ - getcredres - KEY_GETCRED(netnamestr) = 5; - - /* - * I want to talk to X. and I know X's public key - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT_PK(cryptkeyarg2) = 6; - - /* - * X just sent me a message. and I know X's public key - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT_PK(cryptkeyarg2) = 7; - - /* - * Store my public key, netname and private key. - */ - keystatus - KEY_NET_PUT(key_netstarg) = 8; - - /* - * Retrieve my public key, netname and private key. - */ - key_netstres - KEY_NET_GET(void) = 9; - - /* - * Return me the conversation key that is constructed - * from my secret key and this publickey. - */ - - cryptkeyres - KEY_GET_CONV(keybuf) = 10; - - - } = 2; -} = 100029; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/klm_prot.x b/rpcsvc-proto-1.4.2/rpcsvc/klm_prot.x deleted file mode 100644 index aee5b1a..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/klm_prot.x +++ /dev/null @@ -1,130 +0,0 @@ -/* @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Kernel/lock manager protocol definition - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * protocol used between the UNIX kernel (the "client") and the - * local lock manager. The local lock manager is a deamon running - * above the kernel. - */ - -const LM_MAXSTRLEN = 1024; - -/* - * lock manager status returns - */ -enum klm_stats { - klm_granted = 0, /* lock is granted */ - klm_denied = 1, /* lock is denied */ - klm_denied_nolocks = 2, /* no lock entry available */ - klm_working = 3 /* lock is being processed */ -}; - -/* - * lock manager lock identifier - */ -struct klm_lock { - string server_name; - netobj fh; /* a counted file handle */ - int pid; /* holder of the lock */ - unsigned l_offset; /* beginning offset of the lock */ - unsigned l_len; /* byte length of the lock; - * zero means through end of file */ -}; - -/* - * lock holder identifier - */ -struct klm_holder { - bool exclusive; /* FALSE if shared lock */ - int svid; /* holder of the lock (pid) */ - unsigned l_offset; /* beginning offset of the lock */ - unsigned l_len; /* byte length of the lock; - * zero means through end of file */ -}; - -/* - * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL - */ -struct klm_stat { - klm_stats stat; -}; - -/* - * reply to a KLM_TEST call - */ -union klm_testrply switch (klm_stats stat) { - case klm_denied: - struct klm_holder holder; - default: /* All other cases return no arguments */ - void; -}; - - -/* - * arguments to KLM_LOCK - */ -struct klm_lockargs { - bool block; - bool exclusive; - struct klm_lock alock; -}; - -/* - * arguments to KLM_TEST - */ -struct klm_testargs { - bool exclusive; - struct klm_lock alock; -}; - -/* - * arguments to KLM_UNLOCK - */ -struct klm_unlockargs { - struct klm_lock alock; -}; - -program KLM_PROG { - version KLM_VERS { - - klm_testrply KLM_TEST (struct klm_testargs) = 1; - - klm_stat KLM_LOCK (struct klm_lockargs) = 2; - - klm_stat KLM_CANCEL (struct klm_lockargs) = 3; - /* klm_granted=> the cancel request fails due to lock is already granted */ - /* klm_denied=> the cancel request successfully aborts -lock request */ - - klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4; - } = 1; -} = 100020; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/mount.x b/rpcsvc-proto-1.4.2/rpcsvc/mount.x deleted file mode 100644 index ed3b339..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/mount.x +++ /dev/null @@ -1,161 +0,0 @@ -/* @(#)mount.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Protocol description for the mount program - */ - - -const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ -const MNTNAMLEN = 255; /* maximum bytes in a name argument */ -const FHSIZE = 32; /* size in bytes of a file handle */ - -/* - * The fhandle is the file handle that the server passes to the client. - * All file operations are done using the file handles to refer to a file - * or a directory. The file handle can contain whatever information the - * server needs to distinguish an individual file. - */ -typedef opaque fhandle[FHSIZE]; - -/* - * If a status of zero is returned, the call completed successfully, and - * a file handle for the directory follows. A non-zero status indicates - * some sort of error. The status corresponds with UNIX error numbers. - */ -union fhstatus switch (unsigned fhs_status) { -case 0: - fhandle fhs_fhandle; -default: - void; -}; - -/* - * The type dirpath is the pathname of a directory - */ -typedef string dirpath; - -/* - * The type name is used for arbitrary names (hostnames, groupnames) - */ -typedef string name; - -/* - * A list of who has what mounted - */ -typedef struct mountbody *mountlist; -struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; -}; - -/* - * A list of netgroups - */ -typedef struct groupnode *groups; -struct groupnode { - name gr_name; - groups gr_next; -}; - -/* - * A list of what is exported and to whom - */ -typedef struct exportnode *exports; -struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; -}; - -program MOUNTPROG { - /* - * Version one of the mount protocol communicates with version two - * of the NFS protocol. The only connecting point is the fhandle - * structure, which is the same for both protocols. - */ - version MOUNTVERS { - /* - * Does no work. It is made available in all RPC services - * to allow server response testing and timing - */ - void - MOUNTPROC_NULL(void) = 0; - - /* - * If fhs_status is 0, then fhs_fhandle contains the - * file handle for the directory. This file handle may - * be used in the NFS protocol. This procedure also adds - * a new entry to the mount list for this client mounting - * the directory. - * Unix authentication required. - */ - fhstatus - MOUNTPROC_MNT(dirpath) = 1; - - /* - * Returns the list of remotely mounted filesystems. The - * mountlist contains one entry for each hostname and - * directory pair. - */ - mountlist - MOUNTPROC_DUMP(void) = 2; - - /* - * Removes the mount list entry for the directory - * Unix authentication required. - */ - void - MOUNTPROC_UMNT(dirpath) = 3; - - /* - * Removes all of the mount list entries for this client - * Unix authentication required. - */ - void - MOUNTPROC_UMNTALL(void) = 4; - - /* - * Returns a list of all the exported filesystems, and which - * machines are allowed to import it. - */ - exports - MOUNTPROC_EXPORT(void) = 5; - - /* - * Identical to MOUNTPROC_EXPORT above - */ - exports - MOUNTPROC_EXPORTALL(void) = 6; - } = 1; -} = 100005; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/nfs_prot.x b/rpcsvc-proto-1.4.2/rpcsvc/nfs_prot.x deleted file mode 100644 index ad992e2..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/nfs_prot.x +++ /dev/null @@ -1,352 +0,0 @@ -/* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * nfs_prot.x 1.2 87/10/12 - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -const NFS_PORT = 2049; -const NFS_MAXDATA = 8192; -const NFS_MAXPATHLEN = 1024; -const NFS_MAXNAMLEN = 255; -const NFS_FHSIZE = 32; -const NFS_COOKIESIZE = 4; -const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ - -/* - * File types - */ -const NFSMODE_FMT = 0170000; /* type of file */ -const NFSMODE_DIR = 0040000; /* directory */ -const NFSMODE_CHR = 0020000; /* character special */ -const NFSMODE_BLK = 0060000; /* block special */ -const NFSMODE_REG = 0100000; /* regular */ -const NFSMODE_LNK = 0120000; /* symbolic link */ -const NFSMODE_SOCK = 0140000; /* socket */ -const NFSMODE_FIFO = 0010000; /* fifo */ - -/* - * Error status - */ -enum nfsstat { - NFS_OK= 0, /* no error */ - NFSERR_PERM=1, /* Not owner */ - NFSERR_NOENT=2, /* No such file or directory */ - NFSERR_IO=5, /* I/O error */ - NFSERR_NXIO=6, /* No such device or address */ - NFSERR_ACCES=13, /* Permission denied */ - NFSERR_EXIST=17, /* File exists */ - NFSERR_NODEV=19, /* No such device */ - NFSERR_NOTDIR=20, /* Not a directory*/ - NFSERR_ISDIR=21, /* Is a directory */ - NFSERR_FBIG=27, /* File too large */ - NFSERR_NOSPC=28, /* No space left on device */ - NFSERR_ROFS=30, /* Read-only file system */ - NFSERR_NAMETOOLONG=63, /* File name too long */ - NFSERR_NOTEMPTY=66, /* Directory not empty */ - NFSERR_DQUOT=69, /* Disc quota exceeded */ - NFSERR_STALE=70, /* Stale NFS file handle */ - NFSERR_WFLUSH=99 /* write cache flushed */ -}; - -/* - * File types - */ -enum ftype { - NFNON = 0, /* non-file */ - NFREG = 1, /* regular file */ - NFDIR = 2, /* directory */ - NFBLK = 3, /* block special */ - NFCHR = 4, /* character special */ - NFLNK = 5, /* symbolic link */ - NFSOCK = 6, /* unix domain sockets */ - NFBAD = 7, /* unused */ - NFFIFO = 8 /* named pipe */ -}; - -/* - * File access handle - */ -struct nfs_fh { - opaque data[NFS_FHSIZE]; -}; - -/* - * Timeval - */ -struct nfstime { - unsigned seconds; - unsigned useconds; -}; - - -/* - * File attributes - */ -struct fattr { - ftype type; /* file type */ - unsigned mode; /* protection mode bits */ - unsigned nlink; /* # hard links */ - unsigned uid; /* owner user id */ - unsigned gid; /* owner group id */ - unsigned size; /* file size in bytes */ - unsigned blocksize; /* preferred block size */ - unsigned rdev; /* special device # */ - unsigned blocks; /* Kb of disk used by file */ - unsigned fsid; /* device # */ - unsigned fileid; /* inode # */ - nfstime atime; /* time of last access */ - nfstime mtime; /* time of last modification */ - nfstime ctime; /* time of last change */ -}; - -/* - * File attributes which can be set - */ -struct sattr { - unsigned mode; /* protection mode bits */ - unsigned uid; /* owner user id */ - unsigned gid; /* owner group id */ - unsigned size; /* file size in bytes */ - nfstime atime; /* time of last access */ - nfstime mtime; /* time of last modification */ -}; - - -typedef string filename; -typedef string nfspath; - -/* - * Reply status with file attributes - */ -union attrstat switch (nfsstat status) { -case NFS_OK: - fattr attributes; -default: - void; -}; - -struct sattrargs { - nfs_fh file; - sattr attributes; -}; - -/* - * Arguments for directory operations - */ -struct diropargs { - nfs_fh dir; /* directory file handle */ - filename name; /* name (up to NFS_MAXNAMLEN bytes) */ -}; - -struct diropokres { - nfs_fh file; - fattr attributes; -}; - -/* - * Results from directory operation - */ -union diropres switch (nfsstat status) { -case NFS_OK: - diropokres diropres; -default: - void; -}; - -union readlinkres switch (nfsstat status) { -case NFS_OK: - nfspath data; -default: - void; -}; - -/* - * Arguments to remote read - */ -struct readargs { - nfs_fh file; /* handle for file */ - unsigned offset; /* byte offset in file */ - unsigned count; /* immediate read count */ - unsigned totalcount; /* total read count (from this offset)*/ -}; - -/* - * Status OK portion of remote read reply - */ -struct readokres { - fattr attributes; /* attributes, need for pagin*/ - opaque data; -}; - -union readres switch (nfsstat status) { -case NFS_OK: - readokres reply; -default: - void; -}; - -/* - * Arguments to remote write - */ -struct writeargs { - nfs_fh file; /* handle for file */ - unsigned beginoffset; /* beginning byte offset in file */ - unsigned offset; /* current byte offset in file */ - unsigned totalcount; /* total write count (to this offset)*/ - opaque data; -}; - -struct createargs { - diropargs where; - sattr attributes; -}; - -struct renameargs { - diropargs from; - diropargs to; -}; - -struct linkargs { - nfs_fh from; - diropargs to; -}; - -struct symlinkargs { - diropargs from; - nfspath to; - sattr attributes; -}; - - -typedef opaque nfscookie[NFS_COOKIESIZE]; - -/* - * Arguments to readdir - */ -struct readdirargs { - nfs_fh dir; /* directory handle */ - nfscookie cookie; - unsigned count; /* number of directory bytes to read */ -}; - -struct entry { - unsigned fileid; - filename name; - nfscookie cookie; - entry *nextentry; -}; - -struct dirlist { - entry *entries; - bool eof; -}; - -union readdirres switch (nfsstat status) { -case NFS_OK: - dirlist reply; -default: - void; -}; - -struct statfsokres { - unsigned tsize; /* preferred transfer size in bytes */ - unsigned bsize; /* fundamental file system block size */ - unsigned blocks; /* total blocks in file system */ - unsigned bfree; /* free blocks in fs */ - unsigned bavail; /* free blocks avail to non-superuser */ -}; - -union statfsres switch (nfsstat status) { -case NFS_OK: - statfsokres reply; -default: - void; -}; - -/* - * Remote file service routines - */ -program NFS_PROGRAM { - version NFS_VERSION { - void - NFSPROC_NULL(void) = 0; - - attrstat - NFSPROC_GETATTR(nfs_fh) = 1; - - attrstat - NFSPROC_SETATTR(sattrargs) = 2; - - void - NFSPROC_ROOT(void) = 3; - - diropres - NFSPROC_LOOKUP(diropargs) = 4; - - readlinkres - NFSPROC_READLINK(nfs_fh) = 5; - - readres - NFSPROC_READ(readargs) = 6; - - void - NFSPROC_WRITECACHE(void) = 7; - - attrstat - NFSPROC_WRITE(writeargs) = 8; - - diropres - NFSPROC_CREATE(createargs) = 9; - - nfsstat - NFSPROC_REMOVE(diropargs) = 10; - - nfsstat - NFSPROC_RENAME(renameargs) = 11; - - nfsstat - NFSPROC_LINK(linkargs) = 12; - - nfsstat - NFSPROC_SYMLINK(symlinkargs) = 13; - - diropres - NFSPROC_MKDIR(createargs) = 14; - - nfsstat - NFSPROC_RMDIR(diropargs) = 15; - - readdirres - NFSPROC_READDIR(readdirargs) = 16; - - statfsres - NFSPROC_STATFS(nfs_fh) = 17; - } = 2; -} = 100003; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/nlm_prot.x b/rpcsvc-proto-1.4.2/rpcsvc/nlm_prot.x deleted file mode 100644 index 81ff137..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/nlm_prot.x +++ /dev/null @@ -1,203 +0,0 @@ -/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Network lock manager protocol definition - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * protocol used between local lock manager and remote lock manager - */ - -#ifdef RPC_HDR -%#define LM_MAXSTRLEN 1024 -%#define MAXNAMELEN LM_MAXSTRLEN+1 -#endif - -/* - * status of a call to the lock manager - */ -enum nlm_stats { - nlm_granted = 0, - nlm_denied = 1, - nlm_denied_nolocks = 2, - nlm_blocked = 3, - nlm_denied_grace_period = 4 -}; - -struct nlm_holder { - bool exclusive; - int svid; - netobj oh; - unsigned l_offset; - unsigned l_len; -}; - -union nlm_testrply switch (nlm_stats stat) { - case nlm_denied: - struct nlm_holder holder; - default: - void; -}; - -struct nlm_stat { - nlm_stats stat; -}; - -struct nlm_res { - netobj cookie; - nlm_stat stat; -}; - -struct nlm_testres { - netobj cookie; - nlm_testrply stat; -}; - -struct nlm_lock { - string caller_name; - netobj fh; /* identify a file */ - netobj oh; /* identify owner of a lock */ - int svid; /* generated from pid for svid */ - unsigned l_offset; - unsigned l_len; -}; - -struct nlm_lockargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; - bool reclaim; /* used for recovering locks */ - int state; /* specify local status monitor state */ -}; - -struct nlm_cancargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_testargs { - netobj cookie; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_unlockargs { - netobj cookie; - struct nlm_lock alock; -}; - - -#ifdef RPC_HDR -%/* -% * The following enums are actually bit encoded for efficient -% * boolean algebra.... DON'T change them..... -% */ -#endif -enum fsh_mode { - fsm_DN = 0, /* deny none */ - fsm_DR = 1, /* deny read */ - fsm_DW = 2, /* deny write */ - fsm_DRW = 3 /* deny read/write */ -}; - -enum fsh_access { - fsa_NONE = 0, /* for completeness */ - fsa_R = 1, /* read only */ - fsa_W = 2, /* write only */ - fsa_RW = 3 /* read/write */ -}; - -struct nlm_share { - string caller_name; - netobj fh; - netobj oh; - fsh_mode mode; - fsh_access access; -}; - -struct nlm_shareargs { - netobj cookie; - nlm_share share; - bool reclaim; -}; - -struct nlm_shareres { - netobj cookie; - nlm_stats stat; - int sequence; -}; - -struct nlm_notify { - string name; - long state; -}; - -/* - * Over-the-wire protocol used between the network lock managers - */ - -program NLM_PROG { - version NLM_VERS { - - nlm_testres NLM_TEST(struct nlm_testargs) = 1; - - nlm_res NLM_LOCK(struct nlm_lockargs) = 2; - - nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; - nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; - - /* - * remote lock manager call-back to grant lock - */ - nlm_res NLM_GRANTED(struct nlm_testargs)= 5; - /* - * message passing style of requesting lock - */ - void NLM_TEST_MSG(struct nlm_testargs) = 6; - void NLM_LOCK_MSG(struct nlm_lockargs) = 7; - void NLM_CANCEL_MSG(struct nlm_cancargs) =8; - void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; - void NLM_GRANTED_MSG(struct nlm_testargs) = 10; - void NLM_TEST_RES(nlm_testres) = 11; - void NLM_LOCK_RES(nlm_res) = 12; - void NLM_CANCEL_RES(nlm_res) = 13; - void NLM_UNLOCK_RES(nlm_res) = 14; - void NLM_GRANTED_RES(nlm_res) = 15; - } = 1; - - version NLM_VERSX { - nlm_shareres NLM_SHARE(nlm_shareargs) = 20; - nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; - nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; - void NLM_FREE_ALL(nlm_notify) = 23; - } = 3; - -} = 100021; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/rex.x b/rpcsvc-proto-1.4.2/rpcsvc/rex.x deleted file mode 100644 index b5baf15..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/rex.x +++ /dev/null @@ -1,229 +0,0 @@ -/* @(#)rex.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Remote execution (rex) protocol specification - */ - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimiter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/rquota.x b/rpcsvc-proto-1.4.2/rpcsvc/rquota.x deleted file mode 100644 index c457524..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/rquota.x +++ /dev/null @@ -1,61 +0,0 @@ -/* @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */ - -/* - * Remote quota protocol - * Requires unix authentication - */ - -const RQ_PATHLEN = 1024; - -struct getquota_args { - string gqa_pathp; /* path to filesystem of interest */ - int gqa_uid; /* inquire about quota for uid */ -}; - -/* - * remote quota structure - */ -struct rquota { - int rq_bsize; /* block size for block counts */ - bool rq_active; /* indicates whether quota is active */ - unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ - unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ - unsigned int rq_curblocks; /* current block count */ - unsigned int rq_fhardlimit; /* absolute limit on allocated files */ - unsigned int rq_fsoftlimit; /* preferred file limit */ - unsigned int rq_curfiles; /* current # allocated files */ - unsigned int rq_btimeleft; /* time left for excessive disk use */ - unsigned int rq_ftimeleft; /* time left for excessive files */ -}; - -enum gqr_status { - Q_OK = 1, /* quota returned */ - Q_NOQUOTA = 2, /* noquota for uid */ - Q_EPERM = 3 /* no permission to access quota */ -}; - -union getquota_rslt switch (gqr_status status) { -case Q_OK: - rquota gqr_rquota; /* valid if status == Q_OK */ -case Q_NOQUOTA: - void; -case Q_EPERM: - void; -}; - -program RQUOTAPROG { - version RQUOTAVERS { - /* - * Get all quotas - */ - getquota_rslt - RQUOTAPROC_GETQUOTA(getquota_args) = 1; - - /* - * Get active quotas only - */ - getquota_rslt - RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; - } = 1; -} = 100011; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/rstat.x b/rpcsvc-proto-1.4.2/rpcsvc/rstat.x deleted file mode 100644 index 9b7b102..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/rstat.x +++ /dev/null @@ -1,145 +0,0 @@ -/* @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Gather statistics on remote machines - */ - -#ifdef RPC_HDR - -%#ifndef FSCALE -%/* -% * Scale factor for scaled integers used to count load averages. -% */ -%#define FSHIFT 8 /* bits to right of fixed binary point */ -%#define FSCALE (1<; /* aka ut_name */ - string ut_line; /* device */ - string ut_host; /* host user logged on from */ - int ut_type; /* type of entry */ - int ut_time; /* time entry was made */ - unsigned int ut_idle; /* minutes idle */ -}; - -typedef rusers_utmp utmp_array<>; - -#ifdef RPC_HDR -% -%/* -% * Values for ut_type field above. -% */ -#endif -const RUSERS_EMPTY = 0; -const RUSERS_RUN_LVL = 1; -const RUSERS_BOOT_TIME = 2; -const RUSERS_OLD_TIME = 3; -const RUSERS_NEW_TIME = 4; -const RUSERS_INIT_PROCESS = 5; -const RUSERS_LOGIN_PROCESS = 6; -const RUSERS_USER_PROCESS = 7; -const RUSERS_DEAD_PROCESS = 8; -const RUSERS_ACCOUNTING = 9; - -program RUSERSPROG { - - version RUSERSVERS_3 { - int - RUSERSPROC_NUM(void) = 1; - - utmp_array - RUSERSPROC_NAMES(void) = 2; - - utmp_array - RUSERSPROC_ALLNAMES(void) = 3; - } = 3; - -} = 100002; - -#ifdef RPC_HDR -% -% -%#ifdef __cplusplus -%extern "C" { -%#endif -% -%#include -% -%/* -% * The following structures are used by version 2 of the rusersd protocol. -% * They were not developed with rpcgen, so they do not appear as RPCL. -% */ -% -%#define RUSERSVERS_IDLE 2 -%#define RUSERSVERS 3 /* current version */ -%#define MAXUSERS 100 -% -%/* -% * This is the structure used in version 2 of the rusersd RPC service. -% * It corresponds to the utmp structure for BSD systems. -% */ -%struct ru_utmp { -% char ut_line[8]; /* tty name */ -% char ut_name[8]; /* user id */ -% char ut_host[16]; /* host name, if remote */ -% long int ut_time; /* time on */ -%}; -% -%struct utmparr { -% struct ru_utmp **uta_arr; -% int uta_cnt; -%}; -%typedef struct utmparr utmparr; -% -%extern bool_t xdr_utmparr (XDR *xdrs, struct utmparr *objp) __THROW; -% -%struct utmpidle { -% struct ru_utmp ui_utmp; -% unsigned int ui_idle; -%}; -% -%struct utmpidlearr { -% struct utmpidle **uia_arr; -% int uia_cnt; -%}; -% -%extern bool_t xdr_utmpidlearr (XDR *xdrs, struct utmpidlearr *objp) __THROW; -% -%#ifdef __cplusplus -%} -%#endif -#endif - - -#ifdef RPC_XDR -%bool_t xdr_utmp (XDR *xdrs, struct ru_utmp *objp); -% -%bool_t -%xdr_utmp (XDR *xdrs, struct ru_utmp *objp) -%{ -% /* Since the fields are char foo [xxx], we should not free them. */ -% if (xdrs->x_op != XDR_FREE) -% { -% char *ptr; -% unsigned int size; -% ptr = objp->ut_line; -% size = sizeof (objp->ut_line); -% if (!xdr_bytes (xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% ptr = objp->ut_name; -% size = sizeof (objp->ut_name); -% if (!xdr_bytes (xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% ptr = objp->ut_host; -% size = sizeof (objp->ut_host); -% if (!xdr_bytes (xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% } -% if (!xdr_long(xdrs, &objp->ut_time)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp); -% -%bool_t -%xdr_utmpptr (XDR *xdrs, struct ru_utmp **objpp) -%{ -% if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp), -% (xdrproc_t) xdr_utmp)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmparr (XDR *xdrs, struct utmparr *objp) -%{ -% if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt, -% MAXUSERS, sizeof(struct ru_utmp *), -% (xdrproc_t) xdr_utmpptr)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t xdr_utmpidle(XDR *xdrs, struct utmpidle *objp); -% -%bool_t -%xdr_utmpidle (XDR *xdrs, struct utmpidle *objp) -%{ -% if (!xdr_utmp(xdrs, &objp->ui_utmp)) { -% return (FALSE); -% } -% if (!xdr_u_int(xdrs, &objp->ui_idle)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objp); -% -%bool_t -%xdr_utmpidleptr (XDR *xdrs, struct utmpidle **objpp) -%{ -% if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle), -% (xdrproc_t) xdr_utmpidle)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmpidlearr (XDR *xdrs, struct utmpidlearr *objp) -%{ -% if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt, -% MAXUSERS, sizeof(struct utmpidle *), -% (xdrproc_t) xdr_utmpidleptr)) { -% return (FALSE); -% } -% return (TRUE); -%} -#endif diff --git a/rpcsvc-proto-1.4.2/rpcsvc/sm_inter.x b/rpcsvc-proto-1.4.2/rpcsvc/sm_inter.x deleted file mode 100644 index 767f0e0..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/sm_inter.x +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Status monitor protocol specification - * Copyright (c) 2010, Oracle America, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -program SM_PROG { - version SM_VERS { - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* if res_stat == stat_succ, state = state number of site sm_name */ - struct sm_stat_res SM_STAT(struct sm_name) = 1; - - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* stat consists of state number of local site */ - struct sm_stat_res SM_MON(struct mon) = 2; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON(struct mon_id) = 3; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON_ALL(struct my_id) = 4; - - void SM_SIMU_CRASH(void) = 5; - - } = 1; -} = 100024; - -const SM_MAXSTRLEN = 1024; - -struct sm_name { - string mon_name; -}; - -struct my_id { - string my_name; /* name of the site initiating the monitoring request*/ - int my_prog; /* rpc program # of the requesting process */ - int my_vers; /* rpc version # of the requesting process */ - int my_proc; /* rpc procedure # of the requesting process */ -}; - -struct mon_id { - string mon_name; /* name of the site to be monitored */ - struct my_id my_id; -}; - - -struct mon{ - struct mon_id mon_id; - opaque priv[16]; /* private information to store at monitor for requesting process */ -}; - - -/* - * state # of status monitor monotonically increases each time - * status of the site changes: - * an even number (>= 0) indicates the site is down and - * an odd number (> 0) indicates the site is up; - */ -struct sm_stat { - int state; /* state # of status monitor */ -}; - -enum res { - stat_succ = 0, /* status monitor agrees to monitor */ - stat_fail = 1 /* status monitor cannot monitor */ -}; - -struct sm_stat_res { - res res_stat; - int state; -}; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct status { - string mon_name; - int state; - opaque priv[16]; /* stored private information */ -}; diff --git a/rpcsvc-proto-1.4.2/rpcsvc/spray.x b/rpcsvc-proto-1.4.2/rpcsvc/spray.x deleted file mode 100644 index 68b7c48..0000000 --- a/rpcsvc-proto-1.4.2/rpcsvc/spray.x +++ /dev/null @@ -1,84 +0,0 @@ -/* @(#)spray.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Copyright (c) 2010, Oracle America, Inc. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * * Neither the name of the "Oracle America, Inc." nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Spray a server with packets - * Useful for testing flakiness of network interfaces - */ - -const SPRAYMAX = 8845; /* max amount can spray */ - -/* - * GMT since 0:00, 1 January 1970 - */ -struct spraytimeval { - unsigned int sec; - unsigned int usec; -}; - -/* - * spray statistics - */ -struct spraycumul { - unsigned int counter; - spraytimeval clock; -}; - -/* - * spray data - */ -typedef opaque sprayarr; - -program SPRAYPROG { - version SPRAYVERS { - /* - * Just throw away the data and increment the counter - * This call never returns, so the client should always - * time it out. - */ - void - SPRAYPROC_SPRAY(sprayarr) = 1; - - /* - * Get the value of the counter and elapsed time since - * last CLEAR. - */ - spraycumul - SPRAYPROC_GET(void) = 2; - - /* - * Clear the counter and reset the elapsed time - */ - void - SPRAYPROC_CLEAR(void) = 3; - } = 1; -} = 100012;