aboutsummaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-07-08 12:15:23 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-07-08 17:25:57 +0200
commitacb527929d0c2b3bb0798472c42ddb3203729708 (patch)
tree811e3dccd989b71c1e44b18e9e790538725d2c29 /inet
parenta2a83bf6d9f1d4d297c5378f0fda0d8f85bc75f2 (diff)
downloadglibc-acb527929d0c2b3bb0798472c42ddb3203729708.tar
glibc-acb527929d0c2b3bb0798472c42ddb3203729708.tar.gz
glibc-acb527929d0c2b3bb0798472c42ddb3203729708.tar.bz2
glibc-acb527929d0c2b3bb0798472c42ddb3203729708.zip
Move non-deprecated RPC-related functions from sunrpc to inet
This includes bindresvport and the NSS-related RPC functions. This will simplify the removal of the sunrpc functionality because these functions no longer have to be treated specially.
Diffstat (limited to 'inet')
-rw-r--r--inet/Makefile11
-rw-r--r--inet/bindresvport.c110
-rw-r--r--inet/etc.rpc70
-rw-r--r--inet/getrpcbyname.c32
-rw-r--r--inet/getrpcbyname_r.c31
-rw-r--r--inet/getrpcbynumber.c32
-rw-r--r--inet/getrpcbynumber_r.c31
-rw-r--r--inet/getrpcent.c28
-rw-r--r--inet/getrpcent_r.c32
9 files changed, 375 insertions, 2 deletions
diff --git a/inet/Makefile b/inet/Makefile
index bd2fc317b5..1ca06bba80 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -36,10 +36,11 @@ routines := htonl htons \
getnetbynm_r \
getproto getproto_r getprtent getprtent_r getprtname getprtname_r \
getsrvbynm getsrvbynm_r getsrvbypt getsrvbypt_r getservent \
- getservent_r \
+ getservent_r getrpcent getrpcbyname getrpcbynumber \
+ getrpcent_r getrpcbyname_r getrpcbynumber_r \
ether_aton ether_aton_r ether_hton ether_line \
ether_ntoa ether_ntoa_r ether_ntoh \
- rcmd rexec ruserpass \
+ rcmd rexec ruserpass bindresvport \
getnetgrent_r getnetgrent \
getaliasent_r getaliasent getaliasname getaliasname_r \
in6_addr getnameinfo if_index ifaddrs inet6_option \
@@ -47,6 +48,8 @@ routines := htonl htons \
getsourcefilter setsourcefilter inet6_opt inet6_rth \
inet6_scopeid_pton deadline idna idna_name_classify
+install-others = $(inst_sysconfdir)/rpc
+
aux := check_pf check_native ifreq
tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
@@ -108,6 +111,10 @@ CFLAGS-tst-sockaddr.c += -fno-strict-aliasing
endif
+# Install the rpc database file.
+$(inst_sysconfdir)/rpc: etc.rpc $(+force)
+ $(do-install)
+
ifeq ($(build-static-nss),yes)
CFLAGS += -DSTATIC_NSS
endif
diff --git a/inet/bindresvport.c b/inet/bindresvport.c
new file mode 100644
index 0000000000..da33c05101
--- /dev/null
+++ b/inet/bindresvport.c
@@ -0,0 +1,110 @@
+/*
+ * 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 <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <libc-lock.h>
+
+/*
+ * Locks the static variables in this file.
+ */
+__libc_lock_define_initialized (static, lock);
+
+/*
+ * Bind a socket to a privileged IP port
+ */
+int
+bindresvport (int sd, struct sockaddr_in *sin)
+{
+ static short port;
+ struct sockaddr_in myaddr;
+ int i;
+
+#define STARTPORT 600
+#define LOWPORT 512
+#define ENDPORT (IPPORT_RESERVED - 1)
+#define NPORTS (ENDPORT - STARTPORT + 1)
+ static short startport = STARTPORT;
+
+ if (sin == (struct sockaddr_in *) 0)
+ {
+ sin = &myaddr;
+ memset (sin, 0, sizeof (*sin));
+ sin->sin_family = AF_INET;
+ }
+ else if (sin->sin_family != AF_INET)
+ {
+ __set_errno (EAFNOSUPPORT);
+ return -1;
+ }
+
+ if (port == 0)
+ {
+ port = (__getpid () % NPORTS) + STARTPORT;
+ }
+
+ /* Initialize to make gcc happy. */
+ int res = -1;
+
+ int nports = ENDPORT - startport + 1;
+ int endport = ENDPORT;
+
+ __libc_lock_lock (lock);
+
+ again:
+ for (i = 0; i < nports; ++i)
+ {
+ sin->sin_port = htons (port++);
+ if (port > endport)
+ port = startport;
+ res = __bind (sd, sin, sizeof (struct sockaddr_in));
+ if (res >= 0 || errno != EADDRINUSE)
+ break;
+ }
+
+ if (i == nports && startport != LOWPORT)
+ {
+ startport = LOWPORT;
+ endport = STARTPORT - 1;
+ nports = STARTPORT - LOWPORT;
+ port = LOWPORT + port % (STARTPORT - LOWPORT);
+ goto again;
+ }
+
+ __libc_lock_unlock (lock);
+
+ return res;
+}
+libc_hidden_def (bindresvport)
diff --git a/inet/etc.rpc b/inet/etc.rpc
new file mode 100644
index 0000000000..e099ebb289
--- /dev/null
+++ b/inet/etc.rpc
@@ -0,0 +1,70 @@
+#ident "@(#)rpc 1.11 95/07/14 SMI" /* SVr4.0 1.2 */
+#
+# rpc
+#
+portmapper 100000 portmap sunrpc rpcbind
+rstatd 100001 rstat rup perfmeter rstat_svc
+rusersd 100002 rusers
+nfs 100003 nfsprog
+ypserv 100004 ypprog
+mountd 100005 mount showmount
+ypbind 100007
+walld 100008 rwall shutdown
+yppasswdd 100009 yppasswd
+etherstatd 100010 etherstat
+rquotad 100011 rquotaprog quota rquota
+sprayd 100012 spray
+3270_mapper 100013
+rje_mapper 100014
+selection_svc 100015 selnsvc
+database_svc 100016
+rexd 100017 rex
+alis 100018
+sched 100019
+llockmgr 100020
+nlockmgr 100021
+x25.inr 100022
+statmon 100023
+status 100024
+bootparam 100026
+ypupdated 100028 ypupdate
+keyserv 100029 keyserver
+sunlink_mapper 100033
+tfsd 100037
+nsed 100038
+nsemntd 100039
+showfhd 100043 showfh
+ioadmd 100055 rpc.ioadmd
+NETlicense 100062
+sunisamd 100065
+debug_svc 100066 dbsrv
+ypxfrd 100069 rpc.ypxfrd
+bugtraqd 100071
+kerbd 100078
+event 100101 na.event # SunNet Manager
+logger 100102 na.logger # SunNet Manager
+sync 100104 na.sync
+hostperf 100107 na.hostperf
+activity 100109 na.activity # SunNet Manager
+hostmem 100112 na.hostmem
+sample 100113 na.sample
+x25 100114 na.x25
+ping 100115 na.ping
+rpcnfs 100116 na.rpcnfs
+hostif 100117 na.hostif
+etherif 100118 na.etherif
+iproutes 100120 na.iproutes
+layers 100121 na.layers
+snmp 100122 na.snmp snmp-cmc snmp-synoptics snmp-unisys snmp-utk
+traffic 100123 na.traffic
+nfs_acl 100227
+sadmind 100232
+nisd 100300 rpc.nisd
+nispasswd 100303 rpc.nispasswdd
+ufsd 100233 ufsd
+fedfs_admin 100418
+pcnfsd 150001 pcnfs
+amd 300019 amq
+sgi_fam 391002 fam
+bwnfsd 545580417
+fypxfrd 600100069 freebsd-ypxfrd
diff --git a/inet/getrpcbyname.c b/inet/getrpcbyname.c
new file mode 100644
index 0000000000..c82d121c30
--- /dev/null
+++ b/inet/getrpcbyname.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <rpc/netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define FUNCTION_NAME getrpcbyname
+#define DATABASE_NAME rpc
+#define ADD_PARAMS const char *name
+#define ADD_VARIABLES name
+#define BUFLEN 1024
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXbyYY.c"
diff --git a/inet/getrpcbyname_r.c b/inet/getrpcbyname_r.c
new file mode 100644
index 0000000000..d87639a3cd
--- /dev/null
+++ b/inet/getrpcbyname_r.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <rpc/netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define FUNCTION_NAME getrpcbyname
+#define DATABASE_NAME rpc
+#define ADD_PARAMS const char *name
+#define ADD_VARIABLES name
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXbyYY_r.c"
diff --git a/inet/getrpcbynumber.c b/inet/getrpcbynumber.c
new file mode 100644
index 0000000000..8eced2e422
--- /dev/null
+++ b/inet/getrpcbynumber.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <rpc/netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define FUNCTION_NAME getrpcbynumber
+#define DATABASE_NAME rpc
+#define ADD_PARAMS int number
+#define ADD_VARIABLES number
+#define BUFLEN 1024
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXbyYY.c"
diff --git a/inet/getrpcbynumber_r.c b/inet/getrpcbynumber_r.c
new file mode 100644
index 0000000000..d10f2636b0
--- /dev/null
+++ b/inet/getrpcbynumber_r.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <rpc/netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define FUNCTION_NAME getrpcbynumber
+#define DATABASE_NAME rpc
+#define ADD_PARAMS int number
+#define ADD_VARIABLES number
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXbyYY_r.c"
diff --git a/inet/getrpcent.c b/inet/getrpcent.c
new file mode 100644
index 0000000000..16b1c32d4c
--- /dev/null
+++ b/inet/getrpcent.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1996-2020 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <rpc/netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define GETFUNC_NAME getrpcent
+#define BUFLEN 1024
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXent.c"
diff --git a/inet/getrpcent_r.c b/inet/getrpcent_r.c
new file mode 100644
index 0000000000..419b78c33c
--- /dev/null
+++ b/inet/getrpcent_r.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2020 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <netdb.h>
+
+
+#define LOOKUP_TYPE struct rpcent
+#define SETFUNC_NAME setrpcent
+#define GETFUNC_NAME getrpcent
+#define ENDFUNC_NAME endrpcent
+#define DATABASE_NAME rpc
+#define STAYOPEN int stayopen
+#define STAYOPEN_VAR stayopen
+
+/* There is no nscd support for the rpc file. */
+#undef USE_NSCD
+
+#include "../nss/getXXent_r.c"