From patchwork Wed Jul 8 12:05:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39960 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC8043861843; Wed, 8 Jul 2020 12:05:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC8043861843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594209943; bh=q8A3rEzAZHN1ScD5aL6oX3MUZKxLbLqnV+l8gd7fHwM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WzlAhKDFmgFe2OyvB3vzEqVFgkSkh+OuOth2lMdwTR7o0UnRA5CexA3dGtw8fUi8e RADDYgPtTysEpxhbYQAgXSp7eMgxWgwMsXs3f3Ee7c7+fN67+XyUk6WrBRMZ5Kfz99 zzvul8Whc+2ou+QbCiXmVGqzsubs7HvNguW2YMxU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 2DC8A3861024 for ; Wed, 8 Jul 2020 12:05:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DC8A3861024 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-IQziwwPeMM60taEJa4Oq2w-1; Wed, 08 Jul 2020 08:05:39 -0400 X-MC-Unique: IQziwwPeMM60taEJa4Oq2w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17E508015CE for ; Wed, 8 Jul 2020 12:05:38 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-117.ams2.redhat.com [10.36.112.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68E125C1B2 for ; Wed, 8 Jul 2020 12:05:37 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/3] Move non-deprecated RPC-related functions from sunrpc to inet In-Reply-To: References: X-From-Line: c961187637fc816341eadfee91df1f769ff020eb Mon Sep 17 00:00:00 2001 Message-Id: Date: Wed, 08 Jul 2020 14:05:35 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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. --- inet/Makefile | 11 +++++++++-- sunrpc/bindrsvprt.c => inet/bindresvport.c | 0 {sunrpc => inet}/etc.rpc | 0 {sunrpc => inet}/getrpcbyname.c | 0 {sunrpc => inet}/getrpcbyname_r.c | 0 {sunrpc => inet}/getrpcbynumber.c | 0 {sunrpc => inet}/getrpcbynumber_r.c | 0 {sunrpc => inet}/getrpcent.c | 0 {sunrpc => inet}/getrpcent_r.c | 0 sunrpc/Makefile | 9 +-------- 10 files changed, 10 insertions(+), 10 deletions(-) rename sunrpc/bindrsvprt.c => inet/bindresvport.c (100%) rename {sunrpc => inet}/etc.rpc (100%) rename {sunrpc => inet}/getrpcbyname.c (100%) rename {sunrpc => inet}/getrpcbyname_r.c (100%) rename {sunrpc => inet}/getrpcbynumber.c (100%) rename {sunrpc => inet}/getrpcbynumber_r.c (100%) rename {sunrpc => inet}/getrpcent.c (100%) rename {sunrpc => inet}/getrpcent_r.c (100%) 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/sunrpc/bindrsvprt.c b/inet/bindresvport.c similarity index 100% rename from sunrpc/bindrsvprt.c rename to inet/bindresvport.c diff --git a/sunrpc/etc.rpc b/inet/etc.rpc similarity index 100% rename from sunrpc/etc.rpc rename to inet/etc.rpc diff --git a/sunrpc/getrpcbyname.c b/inet/getrpcbyname.c similarity index 100% rename from sunrpc/getrpcbyname.c rename to inet/getrpcbyname.c diff --git a/sunrpc/getrpcbyname_r.c b/inet/getrpcbyname_r.c similarity index 100% rename from sunrpc/getrpcbyname_r.c rename to inet/getrpcbyname_r.c diff --git a/sunrpc/getrpcbynumber.c b/inet/getrpcbynumber.c similarity index 100% rename from sunrpc/getrpcbynumber.c rename to inet/getrpcbynumber.c diff --git a/sunrpc/getrpcbynumber_r.c b/inet/getrpcbynumber_r.c similarity index 100% rename from sunrpc/getrpcbynumber_r.c rename to inet/getrpcbynumber_r.c diff --git a/sunrpc/getrpcent.c b/inet/getrpcent.c similarity index 100% rename from sunrpc/getrpcent.c rename to inet/getrpcent.c diff --git a/sunrpc/getrpcent_r.c b/inet/getrpcent_r.c similarity index 100% rename from sunrpc/getrpcent_r.c rename to inet/getrpcent_r.c diff --git a/sunrpc/Makefile b/sunrpc/Makefile index d5840d0770..2d1861f3dc 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -32,7 +32,6 @@ include ../Makeconfig # file name limits: # # authunix_prot.c -> authuxprot.c -# bindresvport.c -> bindrsvprt.c # clnt_generic.c -> clnt_gen.c # clnt_perror.c -> clnt_perr.c # clnt_simple.c -> clnt_simp.c @@ -54,7 +53,6 @@ headers-sunrpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \ key_prot.h) \ $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h headers = rpc/netdb.h -install-others = $(inst_sysconfdir)/rpc generated += $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \ $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen generated-dirs += rpcsvc @@ -70,13 +68,11 @@ need-export-routines := auth_des auth_unix clnt_gen clnt_perr clnt_tcp \ xdr_intXX_t xdr_mem xdr_ref xdr_sizeof xdr_stdio \ svc_run -routines := auth_none authuxprot bindrsvprt clnt_raw clnt_simp \ +routines := auth_none authuxprot clnt_raw clnt_simp \ rpc_dtable getrpcport pmap_clnt pm_getmaps pmap_prot pmap_prot2 \ pmap_rmt rpc_prot rpc_common rpc_cmsg svc_auth svc_authux svc_raw \ svc_simple xdr_float xdr_rec publickey authdes_prot \ des_crypt des_impl des_soft key_prot openchild rtime svcauth_des \ - getrpcent getrpcbyname getrpcbynumber \ - getrpcent_r getrpcbyname_r getrpcbynumber_r \ clnt_unix svc_unix create_xid $(need-export-routines) \ rpc_gethostbyname ifneq ($(link-obsolete-rpc),yes) @@ -188,9 +184,6 @@ include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) # binary be the second dependency listed in each rule using rpcgen-cmd. rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-file) -Y ../scripts -# Install the rpc data base file. -$(inst_sysconfdir)/rpc: etc.rpc $(+force) - $(do-install) # Generate the rpcsvc headers with rpcgen. # We use a stamp file to avoid unnessary recompilation each time rpcgen is From patchwork Wed Jul 8 12:05:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39962 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B505386181A; Wed, 8 Jul 2020 12:06:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B505386181A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594209997; bh=lwMo4Z7s+WFxdO1pxMNDFkJYof7owzslkjpL0FPB2hc=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IM11TcrmBEXRB4xCvmnGTvyPkYPQBVWp6aYieK4Uw6QahgWWahNi65PdorZuabWtK U42KYi01zh/WLn1LSI3T1FtfufKng3OFL/g2k+Jt5lg5ul4xTys8oe5dOZvE4r1Jj9 N6ejAY+rXya6gvRc0HV9TTY0KHFPUn/ljfKtMQD8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id EE478386181A for ; Wed, 8 Jul 2020 12:06:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EE478386181A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-O37Hb0oxMuCs6ynCLUTD9A-1; Wed, 08 Jul 2020 08:06:01 -0400 X-MC-Unique: O37Hb0oxMuCs6ynCLUTD9A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E39080183C; Wed, 8 Jul 2020 12:06:00 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-117.ams2.redhat.com [10.36.112.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B67412B4C2; Wed, 8 Jul 2020 12:05:57 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 2/3] Remove --enable-obsolete-nsl configure flag In-Reply-To: References: Message-Id: Date: Wed, 08 Jul 2020 14:05:56 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Petr Vorel this means that *always* libnsl is only built as shared library for backward compatibility and the NSS modules libnss_nis and libnss_nisplus are not built at all, libnsl's headers aren't installed. This compatibility is kept only for architectures and ABIs that have been added in or before version 2.28. Replacement implementations based on TIRPC, which additionally support IPv6, are available from . This change does not affect libnss_compat which does not depended on libnsl since 2.27 and thus can be used without NIS. libnsl code depends on Sun RPC, e.g. on --enable-obsolete-rpc (installed libnsl headers use installed Sun RPC headers), which will be removed in the following commit. --- INSTALL | 9 - NEWS | 20 +- config.h.in | 4 - config.make.in | 1 - configure | 20 +- configure.ac | 11 - grp/initgroups.c | 8 +- include/aliases.h | 2 - include/dlfcn.h | 9 +- include/grp.h | 2 - include/libc-symbols.h | 55 +- include/netdb.h | 6 - include/netinet/ether.h | 2 - include/pwd.h | 2 - include/rpc/auth.h | 11 - include/rpc/auth_des.h | 13 - include/rpc/netdb.h | 2 - include/rpcsvc/yp_prot.h | 1 - include/shadow.h | 2 - manual/install.texi | 10 - manual/nss.texi | 15 +- manual/nsswitch.texi | 16 +- nis/Makefile | 55 +- nis/Versions | 58 +- nis/libnsl.h | 3 - nis/nisplus-parser.h | 35 -- nis/nss-default.c | 127 ----- nis/nss-nis.c | 44 -- nis/nss-nis.h | 59 -- nis/nss-nisplus.c | 78 --- nis/nss-nisplus.h | 41 -- nis/nss_nis/nis-alias.c | 281 ---------- nis/nss_nis/nis-ethers.c | 292 ---------- nis/nss_nis/nis-grp.c | 359 ------------ nis/nss_nis/nis-hosts.c | 535 ------------------ nis/nss_nis/nis-initgroups.c | 343 ------------ nis/nss_nis/nis-netgrp.c | 98 ---- nis/nss_nis/nis-network.c | 314 ----------- nis/nss_nis/nis-proto.c | 278 ---------- nis/nss_nis/nis-pwd.c | 581 ------------------- nis/nss_nis/nis-rpc.c | 279 ---------- nis/nss_nis/nis-service.c | 438 --------------- nis/nss_nis/nis-spwd.c | 235 -------- nis/nss_nisplus/nisplus-alias.c | 337 ----------- nis/nss_nisplus/nisplus-ethers.c | 356 ------------ nis/nss_nisplus/nisplus-grp.c | 401 -------------- nis/nss_nisplus/nisplus-hosts.c | 584 -------------------- nis/nss_nisplus/nisplus-initgroups.c | 148 ----- nis/nss_nisplus/nisplus-netgrp.c | 191 ------- nis/nss_nisplus/nisplus-network.c | 494 ----------------- nis/nss_nisplus/nisplus-parser.c | 375 ------------- nis/nss_nisplus/nisplus-proto.c | 441 --------------- nis/nss_nisplus/nisplus-pwd.c | 408 -------------- nis/nss_nisplus/nisplus-rpc.c | 444 --------------- nis/nss_nisplus/nisplus-service.c | 461 --------------- nis/nss_nisplus/nisplus-spwd.c | 220 -------- nis/rpcsvc/nis.x | 474 ---------------- nis/rpcsvc/nis_callback.x | 63 --- nis/rpcsvc/nis_object.x | 328 ----------- nis/rpcsvc/yp.x | 311 ----------- nis/rpcsvc/yp_prot.h | 366 ------------ nscd/initgrcache.c | 8 +- nss/grp-lookup.c | 6 +- nss/nsswitch.c | 14 +- nss/nsswitch.conf | 2 - nss/pwd-lookup.c | 6 +- nss/spwd-lookup.c | 6 +- scripts/build-many-glibcs.py | 6 +- shlib-versions | 2 - sysdeps/mach/Makefile | 2 - sysdeps/unix/sysv/linux/mips/shlib-versions | 2 - 71 files changed, 48 insertions(+), 11162 deletions(-) delete mode 100644 include/rpcsvc/yp_prot.h delete mode 100644 nis/nisplus-parser.h delete mode 100644 nis/nss-default.c delete mode 100644 nis/nss-nis.c delete mode 100644 nis/nss-nis.h delete mode 100644 nis/nss-nisplus.c delete mode 100644 nis/nss-nisplus.h delete mode 100644 nis/nss_nis/nis-alias.c delete mode 100644 nis/nss_nis/nis-ethers.c delete mode 100644 nis/nss_nis/nis-grp.c delete mode 100644 nis/nss_nis/nis-hosts.c delete mode 100644 nis/nss_nis/nis-initgroups.c delete mode 100644 nis/nss_nis/nis-netgrp.c delete mode 100644 nis/nss_nis/nis-network.c delete mode 100644 nis/nss_nis/nis-proto.c delete mode 100644 nis/nss_nis/nis-pwd.c delete mode 100644 nis/nss_nis/nis-rpc.c delete mode 100644 nis/nss_nis/nis-service.c delete mode 100644 nis/nss_nis/nis-spwd.c delete mode 100644 nis/nss_nisplus/nisplus-alias.c delete mode 100644 nis/nss_nisplus/nisplus-ethers.c delete mode 100644 nis/nss_nisplus/nisplus-grp.c delete mode 100644 nis/nss_nisplus/nisplus-hosts.c delete mode 100644 nis/nss_nisplus/nisplus-initgroups.c delete mode 100644 nis/nss_nisplus/nisplus-netgrp.c delete mode 100644 nis/nss_nisplus/nisplus-network.c delete mode 100644 nis/nss_nisplus/nisplus-parser.c delete mode 100644 nis/nss_nisplus/nisplus-proto.c delete mode 100644 nis/nss_nisplus/nisplus-pwd.c delete mode 100644 nis/nss_nisplus/nisplus-rpc.c delete mode 100644 nis/nss_nisplus/nisplus-service.c delete mode 100644 nis/nss_nisplus/nisplus-spwd.c delete mode 100644 nis/rpcsvc/nis.x delete mode 100644 nis/rpcsvc/nis_callback.x delete mode 100644 nis/rpcsvc/nis_object.x delete mode 100644 nis/rpcsvc/yp.x delete mode 100644 nis/rpcsvc/yp_prot.h diff --git a/INSTALL b/INSTALL index 62e78725f5..3f5575e23e 100644 --- a/INSTALL +++ b/INSTALL @@ -227,15 +227,6 @@ if 'CFLAGS' is specified it must enable optimization. For example: colon-separated list in a single environment variable 'GLIBC_TUNABLES'. -'--enable-obsolete-nsl' - By default, libnsl is only built as shared library for backward - compatibility and the NSS modules libnss_compat, libnss_nis and - libnss_nisplus are not built at all. Use this option to enable - libnsl with all depending NSS modules and header files. For - architectures and ABIs that have been added after version 2.28 of - the GNU C Library this option is not available, and the libnsl - compatibility library is not built. - '--disable-crypt' Do not install the passphrase-hashing library 'libcrypt' or the header file 'crypt.h'. 'unistd.h' will still declare the function diff --git a/NEWS b/NEWS index d7282b4ad5..f0782d6096 100644 --- a/NEWS +++ b/NEWS @@ -69,6 +69,16 @@ Major new features: Deprecated and removed features, and other changes affecting compatibility: +* Remove configure option --enable-obsolete-nsl. libnsl is only built + as shared library for backward compatibility and the NSS modules "nis" + and "nisplus" are not built at all and libnsl's headers aren't + installed. This compatibility is kept only for architectures and ABIs + that have been added in or before version 2.28. Replacement + implementations based on TI-RPC, which additionally support IPv6, are + available from . This change does not + affect the "compat" NSS module, which does not depended on libnsl + since 2.27 and thus can be used without NIS. + * The deprecated header and the sysctl function have been removed. To support old binaries, the sysctl function continues to exist as a compatibility symbol (on those architectures which had it), @@ -104,11 +114,11 @@ Deprecated and removed features, and other changes affecting compatibility: or contents might be overwritten on subsequent calls in the same thread or if the thread is terminated. It makes strerror MT-safe. -* The "files", "nis" and "nisplus" NSS modules no longer supports the - "key" database (used for secure RPC). The contents of the - /etc/publickey file will be ignored, regardless of the settings in - /etc/nsswitch.conf. (This method of storing RPC keys only supported - the obsolete and insecure AUTH_DES flavor of secure RPC.) +* The "files" NSS module no longer supports the "key" database (used for + secure RPC). The contents of the /etc/publickey file will be ignored, + regardless of the settings in /etc/nsswitch.conf. (This method of + storing RPC keys only supported the obsolete and insecure AUTH_DES + flavor of secure RPC.) Changes to build and runtime requirements: diff --git a/config.h.in b/config.h.in index 831eca2fe1..9eb71a81b7 100644 --- a/config.h.in +++ b/config.h.in @@ -161,10 +161,6 @@ to link against. */ #undef LINK_OBSOLETE_RPC -/* Define if obsolete libnsl code should be made available for user-level - code to link against. */ -#undef LINK_OBSOLETE_NSL - /* Define if Systemtap probes should be defined. */ #undef USE_STAP_PROBE diff --git a/config.make.in b/config.make.in index 2fed3da773..cefb6d4a90 100644 --- a/config.make.in +++ b/config.make.in @@ -97,7 +97,6 @@ build-static-nss = @static_nss@ cross-compiling = @cross_compiling@ force-install = @force_install@ link-obsolete-rpc = @link_obsolete_rpc@ -build-obsolete-nsl = @build_obsolete_nsl@ build-crypt = @build_crypt@ build-nscd = @build_nscd@ use-nscd = @use_nscd@ diff --git a/configure b/configure index b8ef8c7a51..793c0068cc 100755 --- a/configure +++ b/configure @@ -673,7 +673,6 @@ base_machine have_tunables build_pt_chown build_nscd -build_obsolete_nsl link_obsolete_rpc libc_cv_static_nss_crypt libc_cv_nss_crypt @@ -786,7 +785,6 @@ enable_experimental_malloc enable_crypt enable_nss_crypt enable_obsolete_rpc -enable_obsolete_nsl enable_systemtap enable_build_nscd enable_nscd @@ -1459,8 +1457,6 @@ Optional Features: --enable-nss-crypt enable libcrypt to use nss --enable-obsolete-rpc build and install the obsolete RPC code for link-time usage - --enable-obsolete-nsl build and install the obsolete libnsl library and - depending NSS modules --enable-systemtap enable systemtap static probe points [default=no] --disable-build-nscd disable building and installing the nscd daemon --disable-nscd library functions will not contact the nscd daemon @@ -3654,20 +3650,6 @@ if test "$link_obsolete_rpc" = yes; then fi -# Check whether --enable-obsolete-nsl was given. -if test "${enable_obsolete_nsl+set}" = set; then : - enableval=$enable_obsolete_nsl; build_obsolete_nsl=$enableval -else - build_obsolete_nsl=no -fi - - - -if test "$build_obsolete_nsl" = yes; then - $as_echo "#define LINK_OBSOLETE_NSL 1" >>confdefs.h - -fi - # Check whether --enable-systemtap was given. if test "${enable_systemtap+set}" = set; then : enableval=$enable_systemtap; systemtap=$enableval @@ -3785,7 +3767,7 @@ main () { #ifndef __CET__ -#error no CET compiler support +# error no CET compiler support #endif ; return 0; diff --git a/configure.ac b/configure.ac index ff00591fd4..33a1189804 100644 --- a/configure.ac +++ b/configure.ac @@ -387,17 +387,6 @@ if test "$link_obsolete_rpc" = yes; then AC_DEFINE(LINK_OBSOLETE_RPC) fi -AC_ARG_ENABLE([obsolete-nsl], - AC_HELP_STRING([--enable-obsolete-nsl], - [build and install the obsolete libnsl library and depending NSS modules]), - [build_obsolete_nsl=$enableval], - [build_obsolete_nsl=no]) -AC_SUBST(build_obsolete_nsl) - -if test "$build_obsolete_nsl" = yes; then - AC_DEFINE(LINK_OBSOLETE_NSL) -fi - AC_ARG_ENABLE([systemtap], [AS_HELP_STRING([--enable-systemtap], [enable systemtap static probe points @<:@default=no@:>@])], diff --git a/grp/initgroups.c b/grp/initgroups.c index f4c4e986e9..0c17141117 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -31,12 +31,6 @@ #include "../nscd/nscd-client.h" #include "../nscd/nscd_proto.h" -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -#endif - /* Type of the lookup function. */ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t, long int *, long int *, @@ -83,7 +77,7 @@ internal_getgrouplist (const char *user, gid_t group, long int *size, &__nss_initgroups_database) < 0) { if (__nss_group_database == NULL) - no_more = __nss_database_lookup2 ("group", NULL, DEFAULT_CONFIG, + no_more = __nss_database_lookup2 ("group", NULL, "files", &__nss_group_database); __nss_initgroups_database = __nss_group_database; diff --git a/include/aliases.h b/include/aliases.h index 11b81d4d24..db82588630 100644 --- a/include/aliases.h +++ b/include/aliases.h @@ -33,8 +33,6 @@ extern enum nss_status _nss_ ## service ## _getaliasbyname_r \ DECLARE_NSS_PROTOTYPES (files) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES # endif /* !_ISOMAC */ diff --git a/include/dlfcn.h b/include/dlfcn.h index 93dd369ab1..a1816e4991 100644 --- a/include/dlfcn.h +++ b/include/dlfcn.h @@ -39,10 +39,11 @@ extern char **__libc_argv attribute_hidden; __libgcc_s_init because unwinding is already in progress, so libgcc_s.so has already been loaded if its unwinder is used (Bug 22636). 2. It allows us to provide robust fallback code at dlopen time for - incorrectly configured systems that mix old libnss_* modules with newly - installed libraries e.g. old libnss_nis.so.2 with new libnsl.so.1. Using - RTLD_LAZY here causes a failure at the time the symbol is called and at - that point it is much harder to safely return an error (Bug 22766). + incorrectly configured systems that mix old libnss_* modules + with newly installed libraries e.g. old libnss_dns.so.2 with new + libresolv.so.2. Using RTLD_LAZY here causes a failure at the + time the symbol is called and at that point it is much harder to + safely return an error (Bug 22766). The use of RTLD_NOW also impacts gconv module loading, backtracing (where the unwinder form libgcc_s.so is used), and IDNA functions diff --git a/include/grp.h b/include/grp.h index 871701adbe..58f7b4d233 100644 --- a/include/grp.h +++ b/include/grp.h @@ -56,8 +56,6 @@ extern enum nss_status _nss_ ## service ##_initgroups_dyn \ DECLARE_NSS_PROTOTYPES (compat) DECLARE_NSS_PROTOTYPES (files) DECLARE_NSS_PROTOTYPES (hesiod) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES #endif diff --git a/include/libc-symbols.h b/include/libc-symbols.h index b2f36bc44b..29483779fe 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -833,13 +833,7 @@ for linking") # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libnsl_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) -# ifdef LINK_OBSOLETE_NSL - /* libnsl_hidden_nolink should only get used in libnsl code. */ -# define libnsl_hidden_nolink_def(name, version) libnsl_hidden_def (name) -# else -# define libnsl_hidden_nolink_def(name, version) hidden_nolink (name, libnsl, version) -# endif -# define libnsl_hidden_def(name) hidden_def (name) +# define libnsl_hidden_nolink_def(name, version) hidden_nolink (name, libnsl, version) # define libnsl_hidden_weak(name) hidden_weak (name) # define libnsl_hidden_ver(local, name) hidden_ver (local, name) # define libnsl_hidden_data_def(name) hidden_data_def (name) @@ -849,7 +843,6 @@ for linking") #else # define libnsl_hidden_proto(name, attrs...) # define libnsl_hidden_tls_proto(name, attrs...) -# define libnsl_hidden_def(name) # define libnsl_hidden_weak(name) # define libnsl_hidden_ver(local, name) # define libnsl_hidden_data_def(name) @@ -858,52 +851,6 @@ for linking") # define libnsl_hidden_data_ver(local, name) #endif -#if IS_IN (libnss_nis) -# define libnss_nis_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) -# define libnss_nis_hidden_tls_proto(name, attrs...) \ - hidden_tls_proto (name, ##attrs) -# define libnss_nis_hidden_def(name) hidden_def (name) -# define libnss_nis_hidden_weak(name) hidden_weak (name) -# define libnss_nis_hidden_ver(local, name) hidden_ver (local, name) -# define libnss_nis_hidden_data_def(name) hidden_data_def (name) -# define libnss_nis_hidden_tls_def(name) hidden_tls_def (name) -# define libnss_nis_hidden_data_weak(name) hidden_data_weak (name) -# define libnss_nis_hidden_data_ver(local, name) hidden_data_ver (local, name) -#else -# define libnss_nis_hidden_proto(name, attrs...) -# define libnss_nis_hidden_tls_proto(name, attrs...) -# define libnss_nis_hidden_def(name) -# define libnss_nis_hidden_weak(name) -# define libnss_nis_hidden_ver(local, name) -# define libnss_nis_hidden_data_def(name) -# define libnss_nis_hidden_tls_def(name) -# define libnss_nis_hidden_data_weak(name) -# define libnss_nis_hidden_data_ver(local, name) -#endif - -#if IS_IN (libnss_nisplus) -# define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) -# define libnss_nisplus_hidden_tls_proto(name, attrs...) \ - hidden_tls_proto (name, ##attrs) -# define libnss_nisplus_hidden_def(name) hidden_def (name) -# define libnss_nisplus_hidden_weak(name) hidden_weak (name) -# define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name) -# define libnss_nisplus_hidden_data_def(name) hidden_data_def (name) -# define libnss_nisplus_hidden_tls_def(name) hidden_tls_def (name) -# define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name) -# define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name) -#else -# define libnss_nisplus_hidden_proto(name, attrs...) -# define libnss_nisplus_hidden_tls_proto(name, attrs...) -# define libnss_nisplus_hidden_def(name) -# define libnss_nisplus_hidden_weak(name) -# define libnss_nisplus_hidden_ver(local, name) -# define libnss_nisplus_hidden_data_def(name) -# define libnss_nisplus_hidden_tls_def(name) -# define libnss_nisplus_hidden_data_weak(name) -# define libnss_nisplus_hidden_data_ver(local, name) -#endif - #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs) #define libc_hidden_builtin_def(name) libc_hidden_def (name) #define libc_hidden_builtin_weak(name) libc_hidden_weak (name) diff --git a/include/netdb.h b/include/netdb.h index 3c78da60c5..6b431350df 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -286,15 +286,9 @@ DECLARE_NSS_PROTOTYPES (compat) DECLARE_NSS_PROTOTYPES (dns) DECLARE_NSS_PROTOTYPES (files) DECLARE_NSS_PROTOTYPES (hesiod) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES -libnss_nis_hidden_proto (_nss_nis_endhostent) -libnss_nis_hidden_proto (_nss_nis_endnetent) -libnss_nis_hidden_proto (_nss_nis_endspent) - #endif #endif /* !_NETDB_H */ diff --git a/include/netinet/ether.h b/include/netinet/ether.h index 8bfe7e03ad..8fd05f8193 100644 --- a/include/netinet/ether.h +++ b/include/netinet/ether.h @@ -36,8 +36,6 @@ extern enum nss_status _nss_ ## service ## _getntohost_r \ char *buffer, size_t buflen, int *errnop); DECLARE_NSS_PROTOTYPES (files) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES diff --git a/include/pwd.h b/include/pwd.h index fc995065d9..fd23fe9d6b 100644 --- a/include/pwd.h +++ b/include/pwd.h @@ -48,8 +48,6 @@ extern enum nss_status _nss_ ## service ##_getpwent_r \ DECLARE_NSS_PROTOTYPES (compat) DECLARE_NSS_PROTOTYPES (files) DECLARE_NSS_PROTOTYPES (hesiod) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES #endif diff --git a/include/rpc/auth.h b/include/rpc/auth.h index 2e55cce11d..86cbd77196 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -13,17 +13,6 @@ libc_hidden_proto (key_gendes) struct key_netstarg; extern int key_setnet (struct key_netstarg *arg); -#define DECLARE_NSS_PROTOTYPES(service) \ -extern enum nss_status _nss_ ##service ## _netname2user \ - (char netname[MAXNETNAMELEN + 1], uid_t *uidp, \ - gid_t *gidp, int *gidlenp, gid_t *gidlist, \ - int *errnop); - -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) - -#undef DECLARE_NSS_PROTOTYPES - libc_hidden_proto (key_encryptsession_pk) libc_hidden_proto (key_decryptsession_pk) diff --git a/include/rpc/auth_des.h b/include/rpc/auth_des.h index 6afed56b71..31e0742096 100644 --- a/include/rpc/auth_des.h +++ b/include/rpc/auth_des.h @@ -17,19 +17,6 @@ extern enum auth_stat _svcauth_des (struct svc_req *rqst, struct rpc_msg *msg); -#define DECLARE_NSS_PROTOTYPES(service) \ -extern enum nss_status _nss_ ## service ## _getpublickey \ - (const char *netname, char *pkey, int *errnop); \ -extern enum nss_status _nss_ ## service ## _getsecretkey \ - (const char *netname, char *skey, char *passwd, \ - int *errnop); - -DECLARE_NSS_PROTOTYPES (files) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) - -#undef DECLARE_NSS_PROTOTYPES - libc_hidden_proto (authdes_getucred) libc_hidden_proto (xdr_authdes_cred) libc_hidden_proto (xdr_authdes_verf) diff --git a/include/rpc/netdb.h b/include/rpc/netdb.h index eb75f3f58c..dc0d0e26b9 100644 --- a/include/rpc/netdb.h +++ b/include/rpc/netdb.h @@ -45,8 +45,6 @@ extern enum nss_status _nss_ ## service ## _getrpcbynumber_r \ DECLARE_NSS_PROTOTYPES (files) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES diff --git a/include/rpcsvc/yp_prot.h b/include/rpcsvc/yp_prot.h deleted file mode 100644 index ab1ca10a28..0000000000 --- a/include/rpcsvc/yp_prot.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/include/shadow.h b/include/shadow.h index 366ea83482..5168d8d4a3 100644 --- a/include/shadow.h +++ b/include/shadow.h @@ -44,8 +44,6 @@ extern enum nss_status _nss_ ## service ## _getspnam_r \ DECLARE_NSS_PROTOTYPES (compat) DECLARE_NSS_PROTOTYPES (files) DECLARE_NSS_PROTOTYPES (hesiod) -DECLARE_NSS_PROTOTYPES (nis) -DECLARE_NSS_PROTOTYPES (nisplus) #undef DECLARE_NSS_PROTOTYPES diff --git a/manual/install.texi b/manual/install.texi index c1e49a94fe..ea0059a4ec 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -257,16 +257,6 @@ This frontend allows users to specify tunables as a colon-separated list in a single environment variable @env{GLIBC_TUNABLES}. @end table -@item --enable-obsolete-nsl -By default, libnsl is only built as shared library for backward -compatibility and the NSS modules libnss_compat, libnss_nis and -libnss_nisplus are not built at all. -Use this option to enable libnsl with all depending NSS modules and -header files. -For architectures and ABIs that have been added after version 2.28 of -@theglibc{} this option is not available, and the libnsl compatibility -library is not built. - @item --disable-crypt Do not install the passphrase-hashing library @file{libcrypt} or the header file @file{crypt.h}. @file{unistd.h} will still declare the diff --git a/manual/nss.texi b/manual/nss.texi index 821469a78a..80e730768e 100644 --- a/manual/nss.texi +++ b/manual/nss.texi @@ -328,17 +328,12 @@ For the @code{hosts} and @code{networks} databases the default value is the DNS service not to be available but if it is available the answer it returns is definitive. -The @code{passwd}, @code{group}, and @code{shadow} databases are +The @code{passwd}, @code{group}, and @code{shadow} databases was traditionally handled in a special way. The appropriate files in the -@file{/etc} directory are read but if an entry with a name starting -with a @code{+} character is found NIS is used. This kind of lookup -remains possible if @theglibc{} was configured with the -@code{--enable-obsolete-nsl} option and the special lookup service -@code{compat} is used. If @theglibc{} was configured with the -@code{--enable-obsolete-nsl} option the default value for the three -databases above is @code{compat [NOTFOUND=return] files}. If the -@code{--enable-obsolete-nsl} option was not used the default value -for the services is @code{files}. +@file{/etc} directory were read but if an entry with a name starting +with a @code{+} character was found NIS was used. This kind of lookup +was removed and now the default value for the services is @code{files}. +libnss_compat no longer depends on libnsl and can be used without NIS. For all other databases the default value is @code{files} unless @theglibc{} was configured with @code{--enable-obsolete-rpc} option, in diff --git a/manual/nsswitch.texi b/manual/nsswitch.texi index 62e7f607d1..a6ff3bed74 100644 --- a/manual/nsswitch.texi +++ b/manual/nsswitch.texi @@ -3,14 +3,14 @@ # Name Service Switch configuration file. # -passwd: db files nis +passwd: db files shadow: files -group: db files nis +group: db files -hosts: files nisplus nis dns -networks: nisplus [NOTFOUND=return] files +hosts: files dns +networks: files -ethers: nisplus [NOTFOUND=return] db files -protocols: nisplus [NOTFOUND=return] db files -rpc: nisplus [NOTFOUND=return] db files -services: nisplus [NOTFOUND=return] db files +ethers: db files +protocols: db files +rpc: db files +services: db files diff --git a/nis/Makefile b/nis/Makefile index 9ad5e1db7a..2d3c586890 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -22,40 +22,13 @@ subdir := nis include ../Makeconfig -ifndef have-GLIBC_2.28 - -ifeq ($(build-obsolete-nsl),yes) -$(error --enabe-obsolete-nsl is not available) -endif - -else - -ifeq ($(build-obsolete-nsl),yes) -headers := $(wildcard rpcsvc/*.[hx]) - -# These are the databases available for the nis (and perhaps later nisplus) -# service. This must be a superset of the services in nss. -databases = proto service hosts network grp pwd rpc ethers \ - spwd netgrp alias - -# Specify rules for the nss_* modules. -services := nis nisplus -endif +ifdef have-GLIBC_2.28 extra-libs = libnsl -ifeq ($(build-obsolete-nsl),yes) -extra-libs += $(services:%=libnss_%) -endif # These libraries will be built in the `others' pass rather than # the `lib' pass, because they depend on libc.so being built already. extra-libs-others = $(extra-libs) -ifeq ($(build-obsolete-nsl),yes) -# The sources are found in the appropriate subdir. -subdir-dirs = $(services:%=nss_%) -vpath %.c $(subdir-dirs) -endif - libnsl-routines = yp_xdr ypclnt ypupdate_xdr \ nis_subr nis_local_names nis_free nis_file \ nis_print nis_error nis_call nis_lookup\ @@ -68,17 +41,6 @@ libnsl-routines = yp_xdr ypclnt ypupdate_xdr \ nis_findserv nis_callback nis_clone_dir nis_clone_obj\ nis_clone_res -ifeq ($(build-obsolete-nsl),yes) -libnsl-routines += nss-default -libnss_nis-routines := $(addprefix nis-,$(databases)) nis-initgroups \ - nss-nis -libnss_nis-inhibit-o = $(filter-out .os,$(object-suffixes)) - -libnss_nisplus-routines := $(addprefix nisplus-,$(databases)) nisplus-parser \ - nss-nisplus nisplus-initgroups -libnss_nisplus-inhibit-o = $(filter-out .os,$(object-suffixes)) - -else # not $(build-obsolete-nsl) # Pretend that libnsl.so is a linker script, so that the symbolic link # is not installed. install-lib-ldscripts = libnsl.so @@ -86,31 +48,18 @@ $(inst_libdir)/libnsl.so: # Build only shared libnsl. libnsl-inhibit-o = $(filter-out .os,$(object-suffixes)) -endif # not $(build-obsolete-nsl) - endif # have-GLIBC_2.28 include ../Rules -ifeq ($(build-obsolete-nsl),yes) -$(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \ - $(common-objpfx)nss/libnss_files.so -$(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version) -endif - libnsl-libc = $(common-objpfx)linkobj/libc.so # Target-specific variable setting to link objects using deprecated # RPC interfaces with the version of libc.so that makes them available # for new links: -$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: \ - libc-for-link = $(libnsl-libc) +$(objpfx)libnsl.so: libc-for-link = $(libnsl-libc) ifeq ($(build-shared),yes) $(others:%=$(objpfx)%): $(objpfx)libnsl.so$(libnsl.so-version) -else -ifeq ($(build-obsolete-nsl),yes) -$(others:%=$(objpfx)%): $(objpfx)libnsl.a -endif endif diff --git a/nis/Versions b/nis/Versions index 90d3d9dfaa..9f8285fd05 100644 --- a/nis/Versions +++ b/nis/Versions @@ -58,63 +58,7 @@ libnsl { xdr_ypall; } GLIBC_PRIVATE { - _nsl_default_nss; __prepare_niscall; __follow_path; __do_niscall3; + __prepare_niscall; __follow_path; __do_niscall3; __create_ib_request; _xdr_ib_request; _xdr_nis_result; } } - -libnss_nis { - GLIBC_PRIVATE { - _nss_nis_endaliasent; _nss_nis_endetherent; _nss_nis_endgrent; - _nss_nis_endhostent; _nss_nis_endnetent; _nss_nis_endnetgrent; - _nss_nis_endprotoent; _nss_nis_endpwent; _nss_nis_endrpcent; - _nss_nis_endservent; _nss_nis_endspent; _nss_nis_getaliasbyname_r; - _nss_nis_getaliasent_r; _nss_nis_getetherent_r; _nss_nis_getgrent_r; - _nss_nis_getgrgid_r; _nss_nis_getgrnam_r; _nss_nis_gethostbyaddr_r; - _nss_nis_gethostbyname2_r; _nss_nis_gethostbyname_r; _nss_nis_gethostent_r; - _nss_nis_gethostton_r; _nss_nis_getnetbyaddr_r; _nss_nis_getnetbyname_r; - _nss_nis_getnetent_r; _nss_nis_getnetgrent_r; _nss_nis_getntohost_r; - _nss_nis_getprotobyname_r; _nss_nis_getprotobynumber_r; - _nss_nis_getprotoent_r; _nss_nis_getpublickey; _nss_nis_getpwent_r; - _nss_nis_getpwnam_r; _nss_nis_getpwuid_r; _nss_nis_getrpcbyname_r; - _nss_nis_getrpcbynumber_r; _nss_nis_getrpcent_r; _nss_nis_getsecretkey; - _nss_nis_getservbyname_r; _nss_nis_getservbyport_r; _nss_nis_getservent_r; - _nss_nis_getspent_r; _nss_nis_getspnam_r; - _nss_nis_netname2user; _nss_nis_setaliasent; _nss_nis_setetherent; - _nss_nis_setgrent; _nss_nis_sethostent; _nss_nis_setnetent; - _nss_nis_setnetgrent; _nss_nis_setprotoent; _nss_nis_setpwent; - _nss_nis_setrpcent; _nss_nis_setservent; _nss_nis_setspent; - _nss_nis_initgroups_dyn; _nss_nis_gethostbyname4_r; - } -} - -libnss_nisplus { - GLIBC_PRIVATE { - _nss_nisplus_endaliasent; _nss_nisplus_endetherent; _nss_nisplus_endgrent; - _nss_nisplus_endhostent; _nss_nisplus_endnetent; _nss_nisplus_endnetgrent; - _nss_nisplus_endprotoent; _nss_nisplus_endpwent; _nss_nisplus_endrpcent; - _nss_nisplus_endservent; _nss_nisplus_endspent; - _nss_nisplus_getaliasbyname_r; _nss_nisplus_getaliasent_r; - _nss_nisplus_getetherent_r; _nss_nisplus_getgrent_r; - _nss_nisplus_getgrgid_r; _nss_nisplus_getgrnam_r; - _nss_nisplus_gethostbyaddr_r; _nss_nisplus_gethostbyname2_r; - _nss_nisplus_gethostbyname_r; _nss_nisplus_gethostent_r; - _nss_nisplus_gethostton_r; _nss_nisplus_getnetbyaddr_r; - _nss_nisplus_getnetbyname_r; _nss_nisplus_getnetent_r; - _nss_nisplus_getnetgrent_r; _nss_nisplus_getntohost_r; - _nss_nisplus_getprotobyname_r; _nss_nisplus_getprotobynumber_r; - _nss_nisplus_getprotoent_r; _nss_nisplus_getpublickey; - _nss_nisplus_getpwent_r; _nss_nisplus_getpwnam_r; _nss_nisplus_getpwuid_r; - _nss_nisplus_getrpcbyname_r; _nss_nisplus_getrpcbynumber_r; - _nss_nisplus_getrpcent_r; _nss_nisplus_getsecretkey; - _nss_nisplus_getservbyname_r; _nss_nisplus_getservbynumber_r; - _nss_nisplus_getservent_r; _nss_nisplus_getspent_r; - _nss_nisplus_getspnam_r; _nss_nisplus_netname2user; - _nss_nisplus_setaliasent; - _nss_nisplus_setetherent; _nss_nisplus_setgrent; _nss_nisplus_sethostent; - _nss_nisplus_setnetent; _nss_nisplus_setnetgrent; _nss_nisplus_setprotoent; - _nss_nisplus_setpwent; _nss_nisplus_setrpcent; _nss_nisplus_setservent; - _nss_nisplus_setspent; _nss_nisplus_initgroups_dyn; - _nss_nisplus_gethostbyname4_r; - } -} diff --git a/nis/libnsl.h b/nis/libnsl.h index 3c88c6ac73..64ca262579 100644 --- a/nis/libnsl.h +++ b/nis/libnsl.h @@ -23,9 +23,6 @@ #define NSS_FLAG_ADJUNCT_AS_SHADOW 8 -/* Get current set of default flags. */ -extern int _nsl_default_nss (void); - /* Set up everything for a call to __do_niscall3. */ extern nis_error __prepare_niscall (const_nis_name name, directory_obj **dirp, dir_binding *bptrp, unsigned int flags); diff --git a/nis/nisplus-parser.h b/nis/nisplus-parser.h deleted file mode 100644 index 89bc901841..0000000000 --- a/nis/nisplus-parser.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#ifndef __NISPLUS_PARSER_H -#define __NISPLUS_PARSER_H 1 - -#include -#include -#include - -extern int _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, - char *buffer, size_t buflen, int *errnop); - -extern int _nss_nisplus_parse_grent (nis_result *result, struct group *gr, - char *buffer, size_t buflen, int *errnop); - -extern int _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, - char *buffer, size_t buflen, int *errnop); - -#endif diff --git a/nis/nss-default.c b/nis/nss-default.c deleted file mode 100644 index 7fb06461cd..0000000000 --- a/nis/nss-default.c +++ /dev/null @@ -1,127 +0,0 @@ -/* 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 - . */ - -#include -#include -#include -#include -#include -#include -#include - -#include - - -/* Path of the file. */ -static const char default_nss[] = "/etc/default/nss"; - -/* Flags once read from the file. */ -static int default_nss_flags; - -/* Code to make sure we call 'init' once. */ -__libc_once_define (static, once); - -/* Table of the recognized variables. */ -static const struct -{ - char name[23]; - unsigned int len; - int flag; -} vars[] = - { -#define STRNLEN(s) s, sizeof (s) - 1 - { STRNLEN ("NETID_AUTHORITATIVE"), NSS_FLAG_NETID_AUTHORITATIVE }, - { STRNLEN ("SERVICES_AUTHORITATIVE"), NSS_FLAG_SERVICES_AUTHORITATIVE }, - { STRNLEN ("SETENT_BATCH_READ"), NSS_FLAG_SETENT_BATCH_READ }, - { STRNLEN ("ADJUNCT_AS_SHADOW"), NSS_FLAG_ADJUNCT_AS_SHADOW }, - }; -#define nvars (sizeof (vars) / sizeof (vars[0])) - - -static void -init (void) -{ - int saved_errno = errno; - FILE *fp = fopen (default_nss, "rce"); - if (fp != NULL) - { - char *line = NULL; - size_t linelen = 0; - - __fsetlocking (fp, FSETLOCKING_BYCALLER); - - while (!feof_unlocked (fp)) - { - ssize_t n = getline (&line, &linelen, fp); - if (n <= 0) - break; - - /* Recognize only - - = TRUE - - with arbitrary white spaces. */ - char *cp = line; - while (isspace (*cp)) - ++cp; - - /* Recognize comment lines. */ - if (*cp == '#') - continue; - - int idx; - for (idx = 0; idx < nvars; ++idx) - if (strncmp (cp, vars[idx].name, vars[idx].len) == 0) - break; - if (idx == nvars) - continue; - - cp += vars[idx].len; - while (isspace (*cp)) - ++cp; - if (*cp++ != '=') - continue; - while (isspace (*cp)) - ++cp; - - if (strncmp (cp, "TRUE", 4) != 0) - continue; - cp += 4; - - while (isspace (*cp)) - ++cp; - - if (*cp == '\0') - default_nss_flags |= vars[idx].flag; - } - - free (line); - - fclose (fp); - } - __set_errno (saved_errno); -} - - -int -_nsl_default_nss (void) -{ - /* If we have not yet read the file yet do it now. */ - __libc_once (once, init); - - return default_nss_flags; -} diff --git a/nis/nss-nis.c b/nis/nss-nis.c deleted file mode 100644 index f496017a27..0000000000 --- a/nis/nss-nis.c +++ /dev/null @@ -1,44 +0,0 @@ -/* 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 - . */ - -#include "nss-nis.h" -#include "nsswitch.h" - - -/* Convert YP error number to NSS error number. */ -const enum nss_status __yperr2nss_tab[] = -{ - [YPERR_SUCCESS] = NSS_STATUS_SUCCESS, - [YPERR_BADARGS] = NSS_STATUS_UNAVAIL, - [YPERR_RPC] = NSS_STATUS_UNAVAIL, - [YPERR_DOMAIN] = NSS_STATUS_UNAVAIL, - [YPERR_MAP] = NSS_STATUS_UNAVAIL, - [YPERR_KEY] = NSS_STATUS_NOTFOUND, - [YPERR_YPERR] = NSS_STATUS_UNAVAIL, - [YPERR_RESRC] = NSS_STATUS_TRYAGAIN, - [YPERR_NOMORE] = NSS_STATUS_NOTFOUND, - [YPERR_PMAP] = NSS_STATUS_UNAVAIL, - [YPERR_YPBIND] = NSS_STATUS_UNAVAIL, - [YPERR_YPSERV] = NSS_STATUS_UNAVAIL, - [YPERR_NODOM] = NSS_STATUS_UNAVAIL, - [YPERR_BADDB] = NSS_STATUS_UNAVAIL, - [YPERR_VERS] = NSS_STATUS_UNAVAIL, - [YPERR_ACCESS] = NSS_STATUS_UNAVAIL, - [YPERR_BUSY] = NSS_STATUS_TRYAGAIN -}; -const unsigned int __yperr2nss_count = (sizeof (__yperr2nss_tab) - / sizeof (__yperr2nss_tab[0])); diff --git a/nis/nss-nis.h b/nis/nss-nis.h deleted file mode 100644 index 7c009d7e87..0000000000 --- a/nis/nss-nis.h +++ /dev/null @@ -1,59 +0,0 @@ -/* 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 - . */ - -#ifndef _NIS_NSS_NIS_H -#define _NIS_NSS_NIS_H 1 - -#include - -#include "nsswitch.h" - -NSS_DECLARE_MODULE_FUNCTIONS (nis) - -/* Convert YP error number to NSS error number. */ -extern const enum nss_status __yperr2nss_tab[] attribute_hidden; -extern const unsigned int __yperr2nss_count attribute_hidden; - -static inline enum nss_status -yperr2nss (int errval) -{ - if ((unsigned int) errval >= __yperr2nss_count) - return NSS_STATUS_UNAVAIL; - return __yperr2nss_tab[(unsigned int) errval]; -} - - -struct response_t -{ - struct response_t *next; - size_t size; - char mem[0]; -}; - -typedef struct intern_t -{ - struct response_t *start; - struct response_t *next; - size_t offset; -} intern_t; - - -extern int _nis_saveit (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) attribute_hidden; - - -#endif /* nis/nss-nis.h */ diff --git a/nis/nss-nisplus.c b/nis/nss-nisplus.c deleted file mode 100644 index 70cc7b939e..0000000000 --- a/nis/nss-nisplus.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include - -#include "nss-nisplus.h" -#include "nsswitch.h" - - -/* Convert NIS+ error number to NSS error number. */ -const enum nss_status __niserr2nss_tab[] = -{ - [NIS_SUCCESS] = NSS_STATUS_SUCCESS, - [NIS_S_SUCCESS] = NSS_STATUS_SUCCESS, - [NIS_NOTFOUND] = NSS_STATUS_NOTFOUND, - [NIS_S_NOTFOUND] = NSS_STATUS_NOTFOUND, - [NIS_CACHEEXPIRED] = NSS_STATUS_UNAVAIL, - [NIS_NAMEUNREACHABLE] = NSS_STATUS_UNAVAIL, - [NIS_UNKNOWNOBJ] = NSS_STATUS_NOTFOUND, - [NIS_TRYAGAIN] = NSS_STATUS_TRYAGAIN, - [NIS_SYSTEMERROR] = NSS_STATUS_UNAVAIL, - [NIS_CHAINBROKEN] = NSS_STATUS_UNAVAIL, - [NIS_PERMISSION] = NSS_STATUS_UNAVAIL, - [NIS_NOTOWNER] = NSS_STATUS_UNAVAIL, - [NIS_NOT_ME] = NSS_STATUS_UNAVAIL, - [NIS_NOMEMORY] = NSS_STATUS_TRYAGAIN, - [NIS_NAMEEXISTS] = NSS_STATUS_UNAVAIL, - [NIS_NOTMASTER] = NSS_STATUS_UNAVAIL, - [NIS_INVALIDOBJ] = NSS_STATUS_UNAVAIL, - [NIS_BADNAME] = NSS_STATUS_UNAVAIL, - [NIS_NOCALLBACK] = NSS_STATUS_UNAVAIL, - [NIS_CBRESULTS] = NSS_STATUS_UNAVAIL, - [NIS_NOSUCHNAME] = NSS_STATUS_NOTFOUND, - [NIS_NOTUNIQUE] = NSS_STATUS_UNAVAIL, - [NIS_IBMODERROR] = NSS_STATUS_UNAVAIL, - [NIS_NOSUCHTABLE] = NSS_STATUS_UNAVAIL, - [NIS_TYPEMISMATCH] = NSS_STATUS_UNAVAIL, - [NIS_LINKNAMEERROR] = NSS_STATUS_UNAVAIL, - [NIS_PARTIAL] = NSS_STATUS_NOTFOUND, - [NIS_TOOMANYATTRS] = NSS_STATUS_UNAVAIL, - [NIS_RPCERROR] = NSS_STATUS_UNAVAIL, - [NIS_BADATTRIBUTE] = NSS_STATUS_UNAVAIL, - [NIS_NOTSEARCHABLE] = NSS_STATUS_UNAVAIL, - [NIS_CBERROR] = NSS_STATUS_UNAVAIL, - [NIS_FOREIGNNS] = NSS_STATUS_UNAVAIL, - [NIS_BADOBJECT] = NSS_STATUS_UNAVAIL, - [NIS_NOTSAMEOBJ] = NSS_STATUS_UNAVAIL, - [NIS_MODFAIL] = NSS_STATUS_UNAVAIL, - [NIS_BADREQUEST] = NSS_STATUS_UNAVAIL, - [NIS_NOTEMPTY] = NSS_STATUS_UNAVAIL, - [NIS_COLDSTART_ERR] = NSS_STATUS_UNAVAIL, - [NIS_RESYNC] = NSS_STATUS_UNAVAIL, - [NIS_FAIL] = NSS_STATUS_UNAVAIL, - [NIS_UNAVAIL] = NSS_STATUS_UNAVAIL, - [NIS_RES2BIG] = NSS_STATUS_UNAVAIL, - [NIS_SRVAUTH] = NSS_STATUS_UNAVAIL, - [NIS_CLNTAUTH] = NSS_STATUS_UNAVAIL, - [NIS_NOFILESPACE] = NSS_STATUS_UNAVAIL, - [NIS_NOPROC] = NSS_STATUS_UNAVAIL, - [NIS_DUMPLATER] = NSS_STATUS_UNAVAIL -}; -const unsigned int __niserr2nss_count = (sizeof (__niserr2nss_tab) - / sizeof (__niserr2nss_tab[0])); diff --git a/nis/nss-nisplus.h b/nis/nss-nisplus.h deleted file mode 100644 index 92c67880b9..0000000000 --- a/nis/nss-nisplus.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#ifndef _NIS_NSS_NISPLUS_H -#define _NIS_NSS_NISPLUS_H 1 - -#include - -#include "nsswitch.h" - -NSS_DECLARE_MODULE_FUNCTIONS (nisplus) - -/* Convert NIS+ error number to NSS error number. */ -extern const enum nss_status __niserr2nss_tab[] attribute_hidden; -extern const unsigned int __niserr2nss_count attribute_hidden; - -static enum nss_status -__attribute__ ((unused)) -niserr2nss (int errval) -{ - if ((unsigned int) errval >= __niserr2nss_count) - return NSS_STATUS_UNAVAIL; - return __niserr2nss_tab[(unsigned int) errval]; -} - -#endif /* nis/nss-nisplus.h */ diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c deleted file mode 100644 index b8f83b94b7..0000000000 --- a/nis/nss_nis/nis-alias.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -__libc_lock_define_initialized (static, lock) - -static bool_t new_start = 1; -static char *oldkey; -static int oldkeylen; - -static int -_nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer + strlen (alias) + 1; - size_t room_left = - buflen - (buflen % __alignof__ (char *)) - strlen (alias) - 2; - char *line; - char *cp; - - result->alias_members_len = 0; - *first_unused = '\0'; - first_unused++; - strcpy (first_unused, key); - - if (first_unused[room_left - 1] != '\0') - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - result->alias_name = first_unused; - - /* Terminate the line for any case. */ - cp = strpbrk (alias, "#\n"); - if (cp != NULL) - *cp = '\0'; - - first_unused += strlen (result->alias_name) + 1; - /* Adjust the pointer so it is aligned for - storing pointers. */ - first_unused += __alignof__ (char *) - 1; - first_unused -= ((first_unused - (char *) 0) % __alignof__ (char *)); - result->alias_members = (char **) first_unused; - - line = alias; - - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - line++; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - room_left -= sizeof (char *); - result->alias_members[result->alias_members_len] = line; - - while (*line != '\0' && *line != ',') - line++; - - if (line != result->alias_members[result->alias_members_len]) - { - *line = '\0'; - line++; - result->alias_members_len++; - } - } - return result->alias_members_len == 0 ? 0 : 1; -} - -enum nss_status -_nss_nis_setaliasent (void) -{ - __libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} -/* The 'endaliasent' function is identical. */ -strong_alias (_nss_nis_setaliasent, _nss_nis_endaliasent) - -static enum nss_status -internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, - size_t buflen, int *errnop) -{ - char *domain; - - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - alias->alias_local = 0; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - char *result; - int len; - char *outkey; - int keylen; - int yperr; - - if (new_start) - yperr = yp_first (domain, "mail.aliases", &outkey, &keylen, &result, - &len); - else - yperr = yp_next (domain, "mail.aliases", oldkey, oldkeylen, &outkey, - &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer, - buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - { - free (outkey); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = 0; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen, - int *errnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_getaliasent_r (alias, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - size_t namlen = strlen (name); - char *name2; - int use_alloca = __libc_use_alloca (namlen + 1); - if (use_alloca) - name2 = __alloca (namlen + 1); - else - { - name2 = malloc (namlen + 1); - if (name2 == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - } - - /* Convert name to lowercase. */ - size_t i; - for (i = 0; i < namlen; ++i) - name2[i] = _tolower (name[i]); - name2[i] = '\0'; - - char *result; - int len; - int yperr = yp_match (domain, "mail.aliases", name2, namlen, &result, &len); - - if (!use_alloca) - free (name2); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - alias->alias_local = 0; - int parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c deleted file mode 100644 index c7441ff6b5..0000000000 --- a/nis/nss_nis/nis-ethers.c +++ /dev/null @@ -1,292 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -/* Protect global state against multiple changers */ -__libc_lock_define_initialized (static, lock) - -/* Get the declaration of the parser function. */ -#define ENTNAME etherent -#define STRUCTURE etherent -#define EXTERN_PARSER -#include - -struct response -{ - struct response *next; - char val[0]; -}; - -static struct response *start; -static struct response *next; - -static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) -{ - if (instatus != YP_TRUE) - return 1; - - if (inkey && inkeylen > 0 && inval && invallen > 0) - { - struct response *newp = malloc (sizeof (struct response) + invallen + 1); - if (newp == NULL) - return 1; /* We have no error code for out of memory */ - - if (start == NULL) - start = newp; - else - next->next = newp; - next = newp; - - newp->next = NULL; - *((char *) mempcpy (newp->val, inval, invallen)) = '\0'; - } - - return 0; -} - -static void -internal_nis_endetherent (void) -{ - while (start != NULL) - { - next = start; - start = start->next; - free (next); - } -} - -enum nss_status -_nss_nis_endetherent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endetherent (); - next = NULL; - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nis_setetherent (void) -{ - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - yp_get_default_domain (&domainname); - - internal_nis_endetherent (); - - ypcb.foreach = saveit; - ypcb.data = NULL; - status = yperr2nss (yp_all (domainname, "ethers.byname", &ypcb)); - next = start; - - return status; -} - -enum nss_status -_nss_nis_setetherent (int stayopen) -{ - enum nss_status result; - - __libc_lock_lock (lock); - - result = internal_nis_setetherent (); - - __libc_lock_unlock (lock); - - return result; -} - -static enum nss_status -internal_nis_getetherent_r (struct etherent *eth, char *buffer, size_t buflen, - int *errnop) -{ - struct parser_data *data = (void *) buffer; - int parse_res; - - if (start == NULL) - internal_nis_setetherent (); - - /* Get the next entry until we found a correct one. */ - do - { - char *p; - - if (next == NULL) - return NSS_STATUS_NOTFOUND; - - p = strncpy (buffer, next->val, buflen); - - while (isspace (*p)) - ++p; - - parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop); - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - next = next->next; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getetherent_r (struct etherent *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nis_getetherent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_gethostton_r (const char *name, struct etherent *eth, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char *result; - int len; - int yperr = yp_match (domain, "ethers.byname", name, strlen (name), &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, - char *buffer, size_t buflen, int *errnop) -{ - if (addr == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char buf[33]; - int nlen = snprintf (buf, sizeof (buf), "%x:%x:%x:%x:%x:%x", - (int) addr->ether_addr_octet[0], - (int) addr->ether_addr_octet[1], - (int) addr->ether_addr_octet[2], - (int) addr->ether_addr_octet[3], - (int) addr->ether_addr_octet[4], - (int) addr->ether_addr_octet[5]); - - char *result; - int len; - int yperr = yp_match (domain, "ethers.byaddr", buf, nlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c deleted file mode 100644 index 74a8f82f9a..0000000000 --- a/nis/nss_nis/nis-grp.c +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" -#include - -/* Get the declaration of the parser function. */ -#define ENTNAME grent -#define STRUCTURE group -#define EXTERN_PARSER -#include - -/* Protect global state against multiple changers */ -__libc_lock_define_initialized (static, lock) - -static bool_t new_start = 1; -static char *oldkey; -static int oldkeylen; -static intern_t intern; - - -static void -internal_nis_endgrent (void) -{ - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - struct response_t *curr = intern.start; - - while (curr != NULL) - { - struct response_t *last = curr; - curr = curr->next; - free (last); - } - - intern.next = intern.start = NULL; -} - - -enum nss_status -_nss_nis_endgrent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endgrent (); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -internal_nis_setgrent (void) -{ - /* We have to read all the data now. */ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - struct ypall_callback ypcb; - - ypcb.foreach = _nis_saveit; - ypcb.data = (char *) &intern; - enum nss_status status = yperr2nss (yp_all (domain, "group.byname", &ypcb)); - - - /* Mark the last buffer as full. */ - if (intern.next != NULL) - intern.next->size = intern.offset; - - intern.next = intern.start; - intern.offset = 0; - - return status; -} - - -enum nss_status -_nss_nis_setgrent (int stayopen) -{ - enum nss_status result = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - internal_nis_endgrent (); - - if (_nsl_default_nss () & NSS_FLAG_SETENT_BATCH_READ) - result = internal_nis_setgrent (); - - __libc_lock_unlock (lock); - - return result; -} - - -static enum nss_status -internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, - int *errnop) -{ - /* If we read the entire database at setpwent time we just iterate - over the data we have in memory. */ - bool batch_read = intern.start != NULL; - - char *domain = NULL; - if (!batch_read && __builtin_expect (yp_get_default_domain (&domain), 0)) - return NSS_STATUS_UNAVAIL; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - char *result; - char *outkey; - int len; - int keylen; - - if (batch_read) - { - struct response_t *bucket; - - handle_batch_read: - bucket = intern.next; - - if (__glibc_unlikely (intern.offset >= bucket->size)) - { - if (bucket->next == NULL) - return NSS_STATUS_NOTFOUND; - - /* We look at all the content in the current bucket. Go on - to the next. */ - bucket = intern.next = bucket->next; - intern.offset = 0; - } - - for (result = &bucket->mem[intern.offset]; isspace (*result); - ++result) - ++intern.offset; - - len = strlen (result); - } - else - { - int yperr; - - if (new_start) - { - /* Maybe we should read the database in one piece. */ - if ((_nsl_default_nss () & NSS_FLAG_SETENT_BATCH_READ) - && internal_nis_setgrent () == NSS_STATUS_SUCCESS - && intern.start != NULL) - { - batch_read = true; - goto handle_batch_read; - } - - yperr = yp_first (domain, "group.byname", &outkey, &keylen, - &result, &len); - } - else - yperr = yp_next (domain, "group.byname", oldkey, oldkeylen, - &outkey, &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - if (!batch_read) - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - if (!batch_read) - free (result); - - parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res == -1)) - { - if (!batch_read) - free (outkey); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - if (batch_read) - intern.offset += len + 1; - else - { - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = 0; - } - } - while (parse_res < 1); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nis_getgrent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getgrnam_r (const char *name, struct group *grp, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char *result; - int len; - int yperr = yp_match (domain, "group.byname", name, strlen (name), &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, - errnop); - if (__builtin_expect (parse_res < 1, 0)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getgrgid_r (gid_t gid, struct group *grp, - char *buffer, size_t buflen, int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char buf[32]; - int nlen = sprintf (buf, "%lu", (unsigned long int) gid); - - char *result; - int len; - int yperr = yp_match (domain, "group.bygid", buf, nlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c deleted file mode 100644 index eb074783f7..0000000000 --- a/nis/nss_nis/nis-hosts.c +++ /dev/null @@ -1,535 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -#define ENTNAME hostent -#define DATABASE "hosts" -#define NEED_H_ERRNO - -#define EXTRA_ARGS , af -#define EXTRA_ARGS_DECL , int af - -#define ENTDATA hostent_data -struct hostent_data - { - unsigned char host_addr[16]; /* IPv4 or IPv6 address. */ - char *h_addr_ptrs[2]; /* Points to that and null terminator. */ - }; - -#define TRAILING_LIST_MEMBER h_aliases -#define TRAILING_LIST_SEPARATOR_P isspace -#include -LINE_PARSER -("#", - { - char *addr; - - STRING_FIELD (addr, isspace, 1); - - assert (af == AF_INET || af == AF_INET6 || af == AF_UNSPEC); - - /* Parse address. */ - if (af != AF_INET6 && inet_pton (AF_INET, addr, entdata->host_addr) > 0) - { - result->h_addrtype = AF_INET; - result->h_length = INADDRSZ; - } - else if (af != AF_INET - && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) - { - result->h_addrtype = AF_INET6; - result->h_length = IN6ADDRSZ; - } - else - /* Illegal address: ignore line. */ - return 0; - - /* Store a pointer to the address in the expected form. */ - entdata->h_addr_ptrs[0] = (char *) entdata->host_addr; - entdata->h_addr_ptrs[1] = NULL; - result->h_addr_list = entdata->h_addr_ptrs; - - STRING_FIELD (result->h_name, isspace, 1); - }) - - -__libc_lock_define_initialized (static, lock) - -static bool_t new_start = 1; -static char *oldkey = NULL; -static int oldkeylen = 0; - -enum nss_status -_nss_nis_sethostent (int stayopen) -{ - return _nss_nis_endhostent (); -} - -enum nss_status -_nss_nis_endhostent (void) -{ - __libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} -libnss_nis_hidden_def (_nss_nis_endhostent) - -/* The calling function always need to get a lock first. */ -static enum nss_status -internal_nis_gethostent_r (struct hostent *host, char *buffer, - size_t buflen, int *errnop, int *h_errnop, - int af) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); - buffer += pad; - - struct parser_data *data = (void *) buffer; - if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) - { - *errnop = ERANGE; - *h_errnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - buflen -= pad; - - /* Get the next entry until we found a correct one. */ - const size_t linebuflen = buffer + buflen - data->linebuffer; - int parse_res; - do - { - char *result; - int len; - char *outkey; - int keylen; - int yperr; - if (new_start) - yperr = yp_first (domain, "hosts.byname", &outkey, &keylen, &result, - &len); - else - yperr = yp_next (domain, "hosts.byname", oldkey, oldkeylen, &outkey, - &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - switch (retval) - { - case NSS_STATUS_TRYAGAIN: - *errnop = errno; - *h_errnop = TRY_AGAIN; - break; - case NSS_STATUS_NOTFOUND: - *h_errnop = HOST_NOT_FOUND; - break; - default: - *h_errnop = NO_RECOVERY; - break; - } - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) - { - free (result); - *h_errnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (data->linebuffer, result, len); - data->linebuffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - parse_res = parse_line (p, host, data, buflen, errnop, af); - if (__glibc_unlikely (parse_res == -1)) - { - free (outkey); - *h_errnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = 0; - } - while (!parse_res); - - *h_errnop = NETDB_SUCCESS; - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, - int *errnop, int *h_errnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop, - AF_INET); - - __libc_lock_unlock (lock); - - return status; -} - - -static enum nss_status -internal_gethostbyname2_r (const char *name, int af, struct hostent *host, - char *buffer, size_t buflen, int *errnop, - int *h_errnop) -{ - uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); - buffer += pad; - - struct parser_data *data = (void *) buffer; - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (yp_get_default_domain (&domain)) - return NSS_STATUS_UNAVAIL; - - if (buflen < sizeof *data + 1 + pad) - { - *h_errnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - buflen -= pad; - - /* Convert name to lowercase. */ - size_t namlen = strlen (name); - /* Limit name length to the maximum size of an RPC packet. */ - if (namlen > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - char name2[namlen + 1]; - size_t i; - - for (i = 0; i < namlen; ++i) - name2[i] = tolower (name[i]); - name2[i] = '\0'; - - char *result; - int len; - int yperr = yp_match (domain, "hosts.byname", name2, namlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - { - *h_errnop = TRY_AGAIN; - *errnop = errno; - } - if (retval == NSS_STATUS_NOTFOUND) - *h_errnop = HOST_NOT_FOUND; - return retval; - } - - const size_t linebuflen = buffer + buflen - data->linebuffer; - if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) - { - free (result); - *h_errnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (data->linebuffer, result, len); - data->linebuffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = parse_line (p, host, data, buflen, errnop, af); - - if (__glibc_unlikely (parse_res < 1 || host->h_addrtype != af)) - { - if (parse_res == -1) - { - *h_errnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - else - { - *h_errnop = HOST_NOT_FOUND; - return NSS_STATUS_NOTFOUND; - } - } - - *h_errnop = NETDB_SUCCESS; - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, - char *buffer, size_t buflen, int *errnop, - int *h_errnop) -{ - if (af != AF_INET && af != AF_INET6) - { - *h_errnop = HOST_NOT_FOUND; - return NSS_STATUS_NOTFOUND; - } - - return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop, - h_errnop); -} - - -enum nss_status -_nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer, - size_t buflen, int *errnop, int *h_errnop) -{ - return internal_gethostbyname2_r (name, AF_INET, host, buffer, buflen, - errnop, h_errnop); -} - - -enum nss_status -_nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, - struct hostent *host, char *buffer, size_t buflen, - int *errnop, int *h_errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); - buffer += pad; - - struct parser_data *data = (void *) buffer; - if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) - { - *errnop = ERANGE; - *h_errnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - buflen -= pad; - - char *buf = inet_ntoa (*(const struct in_addr *) addr); - - char *result; - int len; - int yperr = yp_match (domain, "hosts.byaddr", buf, strlen (buf), &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - { - *h_errnop = TRY_AGAIN; - *errnop = errno; - } - else if (retval == NSS_STATUS_NOTFOUND) - *h_errnop = HOST_NOT_FOUND; - - return retval; - } - - const size_t linebuflen = buffer + buflen - data->linebuffer; - if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) - { - free (result); - *errnop = ERANGE; - *h_errnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (data->linebuffer, result, len); - data->linebuffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = parse_line (p, host, data, buflen, errnop, af); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *h_errnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - else - { - *h_errnop = HOST_NOT_FOUND; - return NSS_STATUS_NOTFOUND; - } - } - - *h_errnop = NETDB_SUCCESS; - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, - char *buffer, size_t buflen, int *errnop, - int *herrnop, int32_t *ttlp) -{ - char *domain; - if (yp_get_default_domain (&domain)) - { - *herrnop = NO_DATA; - return NSS_STATUS_UNAVAIL; - } - - /* Convert name to lowercase. */ - size_t namlen = strlen (name); - /* Limit name length to the maximum size of an RPC packet. */ - if (namlen > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - char name2[namlen + 1]; - size_t i; - - for (i = 0; i < namlen; ++i) - name2[i] = tolower (name[i]); - name2[i] = '\0'; - - char *result; - int len; - int yperr = yp_match (domain, "hosts.byname", name2, namlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = TRY_AGAIN; - *errnop = errno; - } - if (retval == NSS_STATUS_NOTFOUND) - *herrnop = HOST_NOT_FOUND; - return retval; - } - - if (*pat == NULL) - { - uintptr_t pad = (-(uintptr_t) buffer - % __alignof__ (struct gaih_addrtuple)); - buffer += pad; - buflen = buflen > pad ? buflen - pad : 0; - - if (__glibc_unlikely (buflen < sizeof (struct gaih_addrtuple))) - { - erange: - free (result); - *errnop = ERANGE; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - *pat = (struct gaih_addrtuple *) buffer; - buffer += sizeof (struct gaih_addrtuple); - buflen -= sizeof (struct gaih_addrtuple); - } - - uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); - buffer += pad; - - struct parser_data *data = (void *) buffer; - - if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) - goto erange; - buflen -= pad; - - struct hostent host; - int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - else - { - *herrnop = HOST_NOT_FOUND; - return NSS_STATUS_NOTFOUND; - } - } - - (*pat)->next = NULL; - (*pat)->family = host.h_addrtype; - memcpy ((*pat)->addr, host.h_addr_list[0], host.h_length); - (*pat)->scopeid = 0; - assert (host.h_addr_list[1] == NULL); - - /* Undo the alignment for parser_data. */ - buffer -= pad; - buflen += pad; - - size_t h_name_len = strlen (host.h_name) + 1; - if (h_name_len >= buflen) - goto erange; - (*pat)->name = memcpy (buffer, host.h_name, h_name_len); - - free (result); - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c deleted file mode 100644 index 9dc945a1bc..0000000000 --- a/nis/nss_nis/nis-initgroups.c +++ /dev/null @@ -1,343 +0,0 @@ -/* Copyright (C) 1998-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1998. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" -#include - -/* Get the declaration of the parser function. */ -#define ENTNAME grent -#define STRUCTURE group -#define EXTERN_PARSER -#include - - -static enum nss_status -internal_setgrent (char *domainname, intern_t *intern) -{ - struct ypall_callback ypcb; - enum nss_status status; - - ypcb.foreach = _nis_saveit; - ypcb.data = (char *) intern; - status = yperr2nss (yp_all (domainname, "group.byname", &ypcb)); - - /* Mark the last buffer as full. */ - if (intern->next != NULL) - intern->next->size = intern->offset; - - intern->next = intern->start; - intern->offset = 0; - - return status; -} - - -static enum nss_status -internal_getgrent_r (struct group *grp, char *buffer, size_t buflen, - int *errnop, intern_t *intern) -{ - if (intern->start == NULL) - return NSS_STATUS_NOTFOUND; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - struct response_t *bucket = intern->next; - - if (__glibc_unlikely (intern->offset >= bucket->size)) - { - if (bucket->next == NULL) - return NSS_STATUS_NOTFOUND; - - /* We look at all the content in the current bucket. Go on - to the next. */ - bucket = intern->next = bucket->next; - intern->offset = 0; - } - - char *p; - for (p = &bucket->mem[intern->offset]; isspace (*p); ++p) - ++intern->offset; - - size_t len = strlen (p) + 1; - if (__glibc_unlikely (len > buflen)) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - /* We unfortunately have to copy the data in the user-provided - buffer because that buffer might be around for a very long - time and the servent structure must remain valid. If we would - rely on the BUCKET memory the next 'setservent' or 'endservent' - call would destroy it. - - The important thing is that it is a single NUL-terminated - string. This is what the parsing routine expects. */ - p = memcpy (buffer, &bucket->mem[intern->offset], len); - - parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res == -1)) - return NSS_STATUS_TRYAGAIN; - - intern->offset += len; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - - -static int -get_uid (const char *user, uid_t *uidp) -{ - struct scratch_buffer tmpbuf; - scratch_buffer_init (&tmpbuf); - - while (1) - { - struct passwd result; - struct passwd *resp; - - int r = getpwnam_r (user, &result, tmpbuf.data, tmpbuf.length, &resp); - if (r == 0 && resp != NULL) - { - *uidp = resp->pw_uid; - scratch_buffer_free (&tmpbuf); - return 0; - } - - if (r != ERANGE) - break; - - if (!scratch_buffer_grow (&tmpbuf)) - return 1; - } - - scratch_buffer_free (&tmpbuf); - return 1; -} - - -static enum nss_status -initgroups_netid (uid_t uid, gid_t group, long int *start, long int *size, - gid_t **groupsp, long int limit, int *errnop, - const char *domainname) -{ - /* Limit domainname length to the maximum size of an RPC packet. */ - if (strlen (domainname) > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - /* Prepare the key. The form is "unix.UID@DOMAIN" with the UID and - DOMAIN field filled in appropriately. */ - char key[sizeof ("unix.@") + sizeof (uid_t) * 3 + strlen (domainname)]; - ssize_t keylen = snprintf (key, sizeof (key), "unix.%lu@%s", - (unsigned long int) uid, domainname); - - char *result; - int reslen; - int yperr = yp_match (domainname, "netid.byname", key, keylen, &result, - &reslen); - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - return yperr2nss (yperr); - - /* Parse the result: following the colon is a comma separated list of - group IDs. */ - char *cp = strchr (result, ':'); - if (cp == NULL) - { - errout: - free (result); - return NSS_STATUS_NOTFOUND; - } - /* Skip the colon. */ - ++cp; - - gid_t *groups = *groupsp; - while (*cp != '\0') - { - char *endp; - unsigned long int gid = strtoul (cp, &endp, 0); - if (cp == endp) - goto errout; - if (*endp == ',') - ++endp; - else if (*endp != '\0') - goto errout; - cp = endp; - - if (gid == group) - /* We do not need this group again. */ - continue; - - /* Insert this group. */ - if (*start == *size) - { - /* Need a bigger buffer. */ - long int newsize; - - if (limit > 0 && *size == limit) - /* We reached the maximum. */ - break; - - if (limit <= 0) - newsize = 2 * *size; - else - newsize = MIN (limit, 2 * *size); - - gid_t *newgroups = realloc (groups, newsize * sizeof (*groups)); - if (newgroups == NULL) - goto errout; - *groupsp = groups = newgroups; - *size = newsize; - } - - groups[*start] = gid; - *start += 1; - } - - free (result); - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start, - long int *size, gid_t **groupsp, long int limit, - int *errnop) -{ - /* We always need the domain name. */ - char *domainname; - if (yp_get_default_domain (&domainname)) - return NSS_STATUS_UNAVAIL; - - /* Check whether we are supposed to use the netid.byname map. */ - if (_nsl_default_nss () & NSS_FLAG_NETID_AUTHORITATIVE) - { - /* We need the user ID. */ - uid_t uid; - - if (get_uid (user, &uid) == 0 - && initgroups_netid (uid, group, start, size, groupsp, limit, - errnop, domainname) == NSS_STATUS_SUCCESS) - return NSS_STATUS_SUCCESS; - } - - struct group grpbuf, *g; - enum nss_status status; - intern_t intern = { NULL, NULL, 0 }; - gid_t *groups = *groupsp; - - status = internal_setgrent (domainname, &intern); - if (status != NSS_STATUS_SUCCESS) - return status; - - struct scratch_buffer tmpbuf; - scratch_buffer_init (&tmpbuf); - - while (1) - { - while ((status = - internal_getgrent_r (&grpbuf, tmpbuf.data, tmpbuf.length, errnop, - &intern)) == NSS_STATUS_TRYAGAIN - && *errnop == ERANGE) - if (!scratch_buffer_grow (&tmpbuf)) - { - status = NSS_STATUS_TRYAGAIN; - goto done; - } - - if (status != NSS_STATUS_SUCCESS) - { - if (status == NSS_STATUS_NOTFOUND) - status = NSS_STATUS_SUCCESS; - goto done; - } - - g = &grpbuf; - if (g->gr_gid != group) - { - char **m; - - for (m = g->gr_mem; *m != NULL; ++m) - if (strcmp (*m, user) == 0) - { - /* Matches user. Insert this group. */ - if (*start == *size) - { - /* Need a bigger buffer. */ - gid_t *newgroups; - long int newsize; - - if (limit > 0 && *size == limit) - /* We reached the maximum. */ - goto done; - - if (limit <= 0) - newsize = 2 * *size; - else - newsize = MIN (limit, 2 * *size); - - newgroups = realloc (groups, newsize * sizeof (*groups)); - if (newgroups == NULL) - { - status = NSS_STATUS_TRYAGAIN; - *errnop = errno; - goto done; - } - *groupsp = groups = newgroups; - *size = newsize; - } - - groups[*start] = g->gr_gid; - *start += 1; - - break; - } - } - } - -done: - while (intern.start != NULL) - { - intern.next = intern.start; - intern.start = intern.start->next; - free (intern.next); - } - scratch_buffer_free (&tmpbuf); - - return status; -} diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c deleted file mode 100644 index 41b530a979..0000000000 --- a/nis/nss_nis/nis-netgrp.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -extern enum nss_status -_nss_netgroup_parseline (char **cursor, struct __netgrent *netgrp, - char *buffer, size_t buflen, int *errnop); - - -static void -internal_nis_endnetgrent (struct __netgrent *netgrp) -{ - free (netgrp->data); - netgrp->data = NULL; - netgrp->data_size = 0; - netgrp->cursor = NULL; -} - - -enum nss_status -_nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp) -{ - int len; - enum nss_status status; - - status = NSS_STATUS_SUCCESS; - - if (__glibc_unlikely (group == NULL || group[0] == '\0')) - return NSS_STATUS_UNAVAIL; - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - status = yperr2nss (yp_match (domain, "netgroup", group, strlen (group), - &netgrp->data, &len)); - if (__glibc_likely (status == NSS_STATUS_SUCCESS)) - { - /* Our implementation of yp_match already allocates a buffer - which is one byte larger than the value in LEN specifies - and the last byte is filled with NUL. So we can simply - use that buffer. */ - assert (len >= 0); - assert (netgrp->data[len] == '\0'); - - netgrp->data_size = len; - netgrp->cursor = netgrp->data; - } - - return status; -} - - -enum nss_status -_nss_nis_endnetgrent (struct __netgrent *netgrp) -{ - internal_nis_endnetgrent (netgrp); - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen, - int *errnop) -{ - return _nss_netgroup_parseline (&result->cursor, result, buffer, buflen, - errnop); -} diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c deleted file mode 100644 index 8d87c69d8e..0000000000 --- a/nis/nss_nis/nis-network.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -/* Get the declaration of the parser function. */ -#define ENTNAME netent -#define EXTERN_PARSER -#include - -__libc_lock_define_initialized (static, lock) - -static bool_t new_start = 1; -static char *oldkey; -static int oldkeylen; - -enum nss_status -_nss_nis_setnetent (int stayopen) -{ - return _nss_nis_endnetent (); -} - -enum nss_status -_nss_nis_endnetent (void) -{ -__libc_lock_lock (lock); - - new_start = 1; - if (oldkey != NULL) - { - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} -libnss_nis_hidden_def (_nss_nis_endnetent) - -static enum nss_status -internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, - int *errnop, int *herrnop) -{ - struct parser_data *data = (void *) buffer; - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - char *result; - char *outkey; - int len; - int keylen; - int yperr; - - if (new_start) - yperr = yp_first (domain, "networks.byname", &outkey, &keylen, &result, - &len); - else - yperr = yp_next (domain, "networks.byname", oldkey, oldkeylen, &outkey, - &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = NETDB_INTERNAL; - *errnop = errno; - } - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - { - free (outkey); - *herrnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = 0; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, - int *errnop, int *herrnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_getnetent_r (net, buffer, buflen, errnop, herrnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - struct parser_data *data = (void *) buffer; - if (buflen < sizeof *data + 1) - { - *herrnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - /* Convert name to lowercase. */ - size_t namlen = strlen (name); - /* Limit name length to the maximum size of an RPC packet. */ - if (namlen > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - char name2[namlen + 1]; - size_t i; - - for (i = 0; i < namlen; ++i) - name2[i] = _tolower (name[i]); - name2[i] = '\0'; - - char *result; - int len; - int yperr = yp_match (domain, "networks.byname", name2, namlen, &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - { - *errnop = errno; - *herrnop = NETDB_INTERNAL; - } - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); - - if (__glibc_unlikely (parse_res < 1)) - { - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, - char *buffer, size_t buflen, int *errnop, - int *herrnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - struct in_addr in = { .s_addr = htonl (addr) }; - char *buf = inet_ntoa (in); - size_t blen = strlen (buf); - - while (1) - { - char *result; - int len; - - int yperr = yp_match (domain, "networks.byaddr", buf, blen, &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_NOTFOUND) - { - if (buf[blen - 2] == '.' && buf[blen - 1] == '0') - { - /* Try again, but with trailing dot(s) - removed (one by one) */ - buf[blen - 2] = '\0'; - blen -= 2; - continue; - } - else - return NSS_STATUS_NOTFOUND; - } - else - { - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_netent (p, net, (void *) buffer, - buflen, errnop); - - if (__glibc_unlikely (parse_res < 1)) - { - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; - } -} diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c deleted file mode 100644 index 9aa698e96a..0000000000 --- a/nis/nss_nis/nis-proto.c +++ /dev/null @@ -1,278 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -/* Get the declaration of the parser function. */ -#define ENTNAME protoent -#define EXTERN_PARSER -#include - -__libc_lock_define_initialized (static, lock) - -struct response -{ - struct response *next; - char val[0]; -}; - -static struct response *start; -static struct response *next; - -static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) -{ - if (instatus != YP_TRUE) - return 1; - - if (inkey && inkeylen > 0 && inval && invallen > 0) - { - struct response *newp = malloc (sizeof (struct response) + invallen + 1); - if (newp == NULL) - return 1; /* We have no error code for out of memory */ - - if (start == NULL) - start = newp; - else - next->next = newp; - next = newp; - - newp->next = NULL; - *((char *) mempcpy (newp->val, inval, invallen)) = '\0'; - } - - return 0; -} - -static void -internal_nis_endprotoent (void) -{ - while (start != NULL) - { - next = start; - start = start->next; - free (next); - } -} - -static enum nss_status -internal_nis_setprotoent (void) -{ - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - yp_get_default_domain (&domainname); - - internal_nis_endprotoent (); - - ypcb.foreach = saveit; - ypcb.data = NULL; - status = yperr2nss (yp_all (domainname, "protocols.bynumber", &ypcb)); - next = start; - - return status; -} - -enum nss_status -_nss_nis_setprotoent (int stayopen) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_setprotoent (); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_endprotoent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endprotoent (); - next = NULL; - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nis_getprotoent_r (struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - struct parser_data *data = (void *) buffer; - int parse_res; - - if (start == NULL) - internal_nis_setprotoent (); - - /* Get the next entry until we found a correct one. */ - do - { - char *p; - - if (next == NULL) - return NSS_STATUS_NOTFOUND; - - p = strncpy (buffer, next->val, buflen); - - while (isspace (*p)) - ++p; - - parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop); - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - next = next->next; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen, - int *errnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_getprotoent_r (proto, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getprotobyname_r (const char *name, struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char *result; - int len; - int yperr = yp_match (domain, "protocols.byname", name, strlen (name), - &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getprotobynumber_r (int number, struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char buf[32]; - int nlen = snprintf (buf, sizeof (buf), "%d", number); - - char *result; - int len; - int yperr = yp_match (domain, "protocols.bynumber", buf, nlen, &result, - &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c deleted file mode 100644 index 00dcda41e5..0000000000 --- a/nis/nss_nis/nis-pwd.c +++ /dev/null @@ -1,581 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" -#include - -/* Get the declaration of the parser function. */ -#define ENTNAME pwent -#define STRUCTURE passwd -#define EXTERN_PARSER -#include - -/* Protect global state against multiple changers */ -__libc_lock_define_initialized (static, lock) - -static bool new_start = true; -static char *oldkey; -static int oldkeylen; -static intern_t intern; - - -int -_nis_saveit (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) -{ - intern_t *intern = (intern_t *) indata; - - if (instatus != YP_TRUE) - return 1; - - if (inkey && inkeylen > 0 && inval && invallen > 0) - { - struct response_t *bucket = intern->next; - - if (__glibc_unlikely (bucket == NULL)) - { -#define MINSIZE 4096 - 4 * sizeof (void *) - const size_t minsize = MAX (MINSIZE, 2 * (invallen + 1)); - bucket = malloc (sizeof (struct response_t) + minsize); - if (bucket == NULL) - /* We have no error code for out of memory. */ - return 1; - - bucket->next = NULL; - bucket->size = minsize; - intern->start = intern->next = bucket; - intern->offset = 0; - } - else if (__builtin_expect (invallen + 1 > bucket->size - intern->offset, - 0)) - { - /* We need a new (larger) buffer. */ - const size_t newsize = 2 * MAX (bucket->size, invallen + 1); - struct response_t *newp = malloc (sizeof (struct response_t) - + newsize); - if (newp == NULL) - /* We have no error code for out of memory. */ - return 1; - - /* Mark the old bucket as full. */ - bucket->size = intern->offset; - - newp->next = NULL; - newp->size = newsize; - bucket = intern->next = bucket->next = newp; - intern->offset = 0; - } - - char *p = mempcpy (&bucket->mem[intern->offset], inval, invallen); - if (__glibc_unlikely (p[-1] != '\0')) - { - *p = '\0'; - ++invallen; - } - intern->offset += invallen; - } - - return 0; -} - - -static void -internal_nis_endpwent (void) -{ - new_start = true; - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - - struct response_t *curr = intern.start; - - while (curr != NULL) - { - struct response_t *last = curr; - curr = curr->next; - free (last); - } - - intern.next = intern.start = NULL; -} - - -enum nss_status -_nss_nis_endpwent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endpwent (); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -internal_nis_setpwent (void) -{ - /* We have to read all the data now. */ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - struct ypall_callback ypcb; - - ypcb.foreach = _nis_saveit; - ypcb.data = (char *) &intern; - enum nss_status status = yperr2nss (yp_all (domain, "passwd.byname", &ypcb)); - - - /* Mark the last buffer as full. */ - if (intern.next != NULL) - intern.next->size = intern.offset; - - intern.next = intern.start; - intern.offset = 0; - - return status; -} - - -enum nss_status -_nss_nis_setpwent (int stayopen) -{ - enum nss_status result = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - internal_nis_endpwent (); - - if (_nsl_default_nss () & NSS_FLAG_SETENT_BATCH_READ) - result = internal_nis_setpwent (); - - __libc_lock_unlock (lock); - - return result; -} - - -static enum nss_status -internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, - int *errnop) -{ - /* If we read the entire database at setpwent time we just iterate - over the data we have in memory. */ - bool batch_read = intern.start != NULL; - - char *domain = NULL; - if (!batch_read && __builtin_expect (yp_get_default_domain (&domain), 0)) - return NSS_STATUS_UNAVAIL; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - char *result; - char *outkey; - int len; - int keylen; - - if (batch_read) - { - struct response_t *bucket; - - handle_batch_read: - bucket = intern.next; - - if (__glibc_unlikely (intern.offset >= bucket->size)) - { - if (bucket->next == NULL) - return NSS_STATUS_NOTFOUND; - - /* We look at all the content in the current bucket. Go on - to the next. */ - bucket = intern.next = bucket->next; - intern.offset = 0; - } - - for (result = &bucket->mem[intern.offset]; isspace (*result); - ++result) - ++intern.offset; - - len = strlen (result); - } - else - { - int yperr; - - if (new_start) - { - /* Maybe we should read the database in one piece. */ - if ((_nsl_default_nss () & NSS_FLAG_SETENT_BATCH_READ) - && internal_nis_setpwent () == NSS_STATUS_SUCCESS - && intern.start != NULL) - { - batch_read = true; - goto handle_batch_read; - } - - yperr = yp_first (domain, "passwd.byname", &outkey, &keylen, - &result, &len); - } - else - yperr = yp_next (domain, "passwd.byname", oldkey, oldkeylen, - &outkey, &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - } - - /* Check for adjunct style secret passwords. They can be - recognized by a password starting with "##". We do not use - it if the passwd.adjunct.byname table is supposed to be used - as a shadow.byname replacement. */ - char *p = strchr (result, ':'); - size_t namelen; - char *result2; - int len2; - if ((_nsl_default_nss () & NSS_FLAG_ADJUNCT_AS_SHADOW) == 0 - && p != NULL /* This better should be true in all cases. */ - && p[1] == '#' && p[2] == '#' - && (namelen = p - result, - yp_match (domain, "passwd.adjunct.byname", result, namelen, - &result2, &len2)) == YPERR_SUCCESS) - { - /* We found a passwd.adjunct.byname entry. Merge encrypted - password therein into original result. */ - char *encrypted = strchr (result2, ':'); - char *endp; - size_t restlen; - - if (encrypted == NULL - || (endp = strchr (++encrypted, ':')) == NULL - || (p = strchr (p + 1, ':')) == NULL) - { - /* Invalid format of the entry. This never should happen - unless the data from which the NIS table is generated is - wrong. We simply ignore it. */ - free (result2); - goto non_adjunct; - } - - restlen = len - (p - result); - if (__builtin_expect ((size_t) (namelen + (endp - encrypted) - + restlen + 2) > buflen, 0)) - { - free (result2); - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - mempcpy (mempcpy (mempcpy (mempcpy (buffer, result, namelen), - ":", 1), - encrypted, endp - encrypted), - p, restlen + 1); - p = buffer; - - free (result2); - } - else - { - non_adjunct: - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - p = buffer; - *((char *) mempcpy (buffer, result, len)) = '\0'; - } - - while (isspace (*p)) - ++p; - if (!batch_read) - free (result); - - parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res == -1)) - { - if (!batch_read) - free (outkey); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - if (batch_read) - intern.offset += len + 1; - else - { - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = false; - } - } - while (parse_res < 1); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nis_getpwent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getpwnam_r (const char *name, struct passwd *pwd, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - size_t namelen = strlen (name); - - char *result; - int len; - int yperr = yp_match (domain, "passwd.byname", name, namelen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - /* Check for adjunct style secret passwords. They can be recognized - by a password starting with "##". We do not use it if the - passwd.adjunct.byname table is supposed to be used as a shadow.byname - replacement. */ - char *result2; - int len2; - char *p = strchr (result, ':'); - if ((_nsl_default_nss () & NSS_FLAG_ADJUNCT_AS_SHADOW) == 0 - && p != NULL /* This better should be true in all cases. */ - && p[1] == '#' && p[2] == '#' - && yp_match (domain, "passwd.adjunct.byname", name, namelen, - &result2, &len2) == YPERR_SUCCESS) - { - /* We found a passwd.adjunct.byname entry. Merge encrypted password - therein into original result. */ - char *encrypted = strchr (result2, ':'); - char *endp; - - if (encrypted == NULL - || (endp = strchr (++encrypted, ':')) == NULL - || (p = strchr (p + 1, ':')) == NULL) - { - /* Invalid format of the entry. This never should happen - unless the data from which the NIS table is generated is - wrong. We simply ignore it. */ - free (result2); - goto non_adjunct; - } - - size_t restlen = len - (p - result); - if (__builtin_expect ((size_t) (namelen + (endp - encrypted) - + restlen + 2) > buflen, 0)) - { - free (result2); - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __mempcpy (__mempcpy (__mempcpy (__mempcpy (buffer, name, namelen), - ":", 1), - encrypted, endp - encrypted), - p, restlen + 1); - p = buffer; - - free (result2); - } - else - { - non_adjunct: - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - p = strncpy (buffer, result, len); - buffer[len] = '\0'; - } - - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, - char *buffer, size_t buflen, int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char buf[32]; - int nlen = snprintf (buf, sizeof (buf), "%lu", (unsigned long int) uid); - - char *result; - int len; - int yperr = yp_match (domain, "passwd.byuid", buf, nlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - /* Check for adjunct style secret passwords. They can be recognized - by a password starting with "##". We do not use it if the - passwd.adjunct.byname table is supposed to be used as a shadow.byname - replacement. */ - char *result2; - int len2; - size_t namelen; - char *p = strchr (result, ':'); - if ((_nsl_default_nss () & NSS_FLAG_ADJUNCT_AS_SHADOW) == 0 - && p != NULL /* This better should be true in all cases. */ - && p[1] == '#' && p[2] == '#' - && (namelen = p - result, - yp_match (domain, "passwd.adjunct.byname", result, namelen, - &result2, &len2)) == YPERR_SUCCESS) - { - /* We found a passwd.adjunct.byname entry. Merge encrypted password - therein into original result. */ - char *encrypted = strchr (result2, ':'); - char *endp; - size_t restlen; - - if (encrypted == NULL - || (endp = strchr (++encrypted, ':')) == NULL - || (p = strchr (p + 1, ':')) == NULL) - { - /* Invalid format of the entry. This never should happen - unless the data from which the NIS table is generated is - wrong. We simply ignore it. */ - free (result2); - goto non_adjunct; - } - - restlen = len - (p - result); - if (__builtin_expect ((size_t) (namelen + (endp - encrypted) - + restlen + 2) > buflen, 0)) - { - free (result2); - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __mempcpy (__mempcpy (__mempcpy (__mempcpy (buffer, result, namelen), - ":", 1), - encrypted, endp - encrypted), - p, restlen + 1); - p = buffer; - - free (result2); - } - else - { - non_adjunct: - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - p = strncpy (buffer, result, len); - buffer[len] = '\0'; - } - - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c deleted file mode 100644 index b118e1b01c..0000000000 --- a/nis/nss_nis/nis-rpc.c +++ /dev/null @@ -1,279 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" - -/* Get the declaration of the parser function. */ -#define ENTNAME rpcent -#define EXTERN_PARSER -#include - -__libc_lock_define_initialized (static, lock) - -static intern_t intern; - - -static void -internal_nis_endrpcent (intern_t *intern) -{ - struct response_t *curr = intern->next; - - while (curr != NULL) - { - struct response_t *last = curr; - curr = curr->next; - free (last); - } - - intern->next = intern->start = NULL; -} - -static enum nss_status -internal_nis_setrpcent (intern_t *intern) -{ - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - if (yp_get_default_domain (&domainname)) - return NSS_STATUS_UNAVAIL; - - internal_nis_endrpcent (intern); - - ypcb.foreach = _nis_saveit; - ypcb.data = (char *) intern; - status = yperr2nss (yp_all (domainname, "rpc.bynumber", &ypcb)); - - /* Mark the last buffer as full. */ - if (intern->next != NULL) - intern->next->size = intern->offset; - - intern->next = intern->start; - intern->offset = 0; - - return status; -} - -enum nss_status -_nss_nis_setrpcent (int stayopen) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_setrpcent (&intern); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_endrpcent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endrpcent (&intern); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, - int *errnop, intern_t *intern) -{ - struct parser_data *pdata = (void *) buffer; - int parse_res; - char *p; - - if (intern->start == NULL) - internal_nis_setrpcent (intern); - - if (intern->next == NULL) - /* Not one entry in the map. */ - return NSS_STATUS_NOTFOUND; - - /* Get the next entry until we found a correct one. */ - do - { - struct response_t *bucket = intern->next; - - if (__glibc_unlikely (intern->offset >= bucket->size)) - { - if (bucket->next == NULL) - return NSS_STATUS_NOTFOUND; - - /* We look at all the content in the current bucket. Go on - to the next. */ - bucket = intern->next = bucket->next; - intern->offset = 0; - } - - for (p = &bucket->mem[intern->offset]; isspace (*p); ++p) - ++intern->offset; - - size_t len = strlen (p) + 1; - if (__glibc_unlikely (len > buflen)) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - /* We unfortunately have to copy the data in the user-provided - buffer because that buffer might be around for a very long - time and the servent structure must remain valid. If we would - rely on the BUCKET memory the next 'setservent' or 'endservent' - call would destroy it. - - The important thing is that it is a single NUL-terminated - string. This is what the parsing routine expects. */ - p = memcpy (buffer, &bucket->mem[intern->offset], len); - - parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - return NSS_STATUS_TRYAGAIN; - - intern->offset += len; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, - int *errnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop, &intern); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - intern_t data = { NULL, NULL, 0 }; - enum nss_status status = internal_nis_setrpcent (&data); - if (__glibc_unlikely (status != NSS_STATUS_SUCCESS)) - return status; - - int found = 0; - while (!found - && ((status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop, - &data)) == NSS_STATUS_SUCCESS)) - { - if (strcmp (rpc->r_name, name) == 0) - found = 1; - else - { - int i = 0; - - while (rpc->r_aliases[i] != NULL) - { - if (strcmp (rpc->r_aliases[i], name) == 0) - { - found = 1; - break; - } - else - ++i; - } - } - } - - internal_nis_endrpcent (&data); - - if (__glibc_unlikely (!found && status == NSS_STATUS_SUCCESS)) - return NSS_STATUS_NOTFOUND; - - return status; -} - -enum nss_status -_nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, - char *buffer, size_t buflen, int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - char buf[32]; - int nlen = snprintf (buf, sizeof (buf), "%d", number); - - char *result; - int len; - int yperr = yp_match (domain, "rpc.bynumber", buf, nlen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_rpcent (p, rpc, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c deleted file mode 100644 index 61a8ff5f46..0000000000 --- a/nis/nss_nis/nis-service.c +++ /dev/null @@ -1,438 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" -#include - - -/* Get the declaration of the parser function. */ -#define ENTNAME servent -#define EXTERN_PARSER -#include - -__libc_lock_define_initialized (static, lock) - -static intern_t intern; - -struct search_t -{ - const char *name; - const char *proto; - int port; - enum nss_status status; - struct servent *serv; - char *buffer; - size_t buflen; - int *errnop; -}; - -static int -dosearch (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) -{ - struct search_t *req = (struct search_t *) indata; - - if (__glibc_unlikely (instatus != YP_TRUE)) - return 1; - - if (inkey && inkeylen > 0 && inval && invallen > 0) - { - if (__glibc_unlikely ((size_t) (invallen + 1) > req->buflen)) - { - *req->errnop = ERANGE; - req->status = NSS_STATUS_TRYAGAIN; - return 1; - } - - char *p = strncpy (req->buffer, inval, invallen); - req->buffer[invallen] = '\0'; - while (isspace (*p)) - ++p; - - int parse_res = _nss_files_parse_servent (p, req->serv, - (void *) req->buffer, - req->buflen, req->errnop); - if (parse_res == -1) - { - req->status = NSS_STATUS_TRYAGAIN; - return 1; - } - - if (!parse_res) - return 0; - - if (req->proto != NULL && strcmp (req->serv->s_proto, req->proto) != 0) - return 0; - - if (req->port != -1 && req->serv->s_port != req->port) - return 0; - - if (req->name != NULL && strcmp (req->serv->s_name, req->name) != 0) - { - char **cp; - for (cp = req->serv->s_aliases; *cp; cp++) - if (strcmp (req->name, *cp) == 0) - break; - - if (*cp == NULL) - return 0; - } - - req->status = NSS_STATUS_SUCCESS; - return 1; - } - - return 0; -} - -static void -internal_nis_endservent (void) -{ - struct response_t *curr = intern.next; - - while (curr != NULL) - { - struct response_t *last = curr; - curr = curr->next; - free (last); - } - - intern.next = intern.start = NULL; -} - -enum nss_status -_nss_nis_endservent (void) -{ - __libc_lock_lock (lock); - - internal_nis_endservent (); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nis_setservent (void) -{ - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - if (yp_get_default_domain (&domainname)) - return NSS_STATUS_UNAVAIL; - - internal_nis_endservent (); - - ypcb.foreach = _nis_saveit; - ypcb.data = (char *) &intern; - status = yperr2nss (yp_all (domainname, "services.byname", &ypcb)); - - /* Mark the last buffer as full. */ - if (intern.next != NULL) - intern.next->size = intern.offset; - - intern.next = intern.start; - intern.offset = 0; - - return status; -} - -enum nss_status -_nss_nis_setservent (int stayopen) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_setservent (); - - __libc_lock_unlock (lock); - - return status; -} - -static enum nss_status -internal_nis_getservent_r (struct servent *serv, char *buffer, - size_t buflen, int *errnop) -{ - struct parser_data *pdata = (void *) buffer; - int parse_res; - char *p; - - if (intern.start == NULL) - internal_nis_setservent (); - - if (intern.next == NULL) - /* Not one entry in the map. */ - return NSS_STATUS_NOTFOUND; - - /* Get the next entry until we found a correct one. */ - do - { - struct response_t *bucket = intern.next; - - if (__glibc_unlikely (intern.offset >= bucket->size)) - { - if (bucket->next == NULL) - return NSS_STATUS_NOTFOUND; - - /* We look at all the content in the current bucket. Go on - to the next. */ - bucket = intern.next = bucket->next; - intern.offset = 0; - } - - for (p = &bucket->mem[intern.offset]; isspace (*p); ++p) - ++intern.offset; - - size_t len = strlen (p) + 1; - if (__glibc_unlikely (len > buflen)) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - /* We unfortunately have to copy the data in the user-provided - buffer because that buffer might be around for a very long - time and the servent structure must remain valid. If we would - rely on the BUCKET memory the next 'setservent' or 'endservent' - call would destroy it. - - The important thing is that it is a single NUL-terminated - string. This is what the parsing routine expects. */ - p = memcpy (buffer, &bucket->mem[intern.offset], len); - - parse_res = _nss_files_parse_servent (p, serv, pdata, buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - return NSS_STATUS_TRYAGAIN; - - intern.offset += len; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen, - int *errnop) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_nis_getservent_r (serv, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getservbyname_r (const char *name, const char *protocol, - struct servent *serv, char *buffer, size_t buflen, - int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - /* If the protocol is given, we could try if our NIS server knows - about services.byservicename map. If yes, we only need one query. */ - size_t keylen = strlen (name) + (protocol ? 1 + strlen (protocol) : 0); - /* Limit key length to the maximum size of an RPC packet. */ - if (keylen > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - char key[keylen + 1]; - - /* key is: "name/proto" */ - char *cp = stpcpy (key, name); - if (protocol != NULL) - { - *cp++ = '/'; - strcpy (cp, protocol); - } - - char *result; - int int_len; - int status = yp_match (domain, "services.byservicename", key, - keylen, &result, &int_len); - size_t len = int_len; - - /* If we found the key, it's ok and parse the result. If not, - fall through and parse the complete table. */ - if (__glibc_likely (status == YPERR_SUCCESS)) - { - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer, - buflen, errnop); - if (__glibc_unlikely (parse_res < 0)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - else - return NSS_STATUS_SUCCESS; - } - - /* Check if it is safe to rely on services.byservicename. */ - if (_nsl_default_nss () & NSS_FLAG_SERVICES_AUTHORITATIVE) - return yperr2nss (status); - - struct ypall_callback ypcb; - struct search_t req; - - ypcb.foreach = dosearch; - ypcb.data = (char *) &req; - req.name = name; - req.proto = protocol; - req.port = -1; - req.serv = serv; - req.buffer = buffer; - req.buflen = buflen; - req.errnop = errnop; - req.status = NSS_STATUS_NOTFOUND; - status = yp_all (domain, "services.byname", &ypcb); - - if (__glibc_unlikely (status != YPERR_SUCCESS)) - return yperr2nss (status); - - return req.status; -} - -enum nss_status -_nss_nis_getservbyport_r (int port, const char *protocol, - struct servent *serv, char *buffer, - size_t buflen, int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - /* If the protocol is given, we only need one query. - Otherwise try first port/tcp, then port/udp and then fallback - to sequential scanning of services.byname. */ - const char *proto = protocol != NULL ? protocol : "tcp"; - /* Limit protocol name length to the maximum size of an RPC packet. */ - if (strlen (proto) > UDPMSGSIZE) - { - *errnop = ERANGE; - return NSS_STATUS_UNAVAIL; - } - - do - { - /* key is: "port/proto" */ - char key[sizeof (int) * 3 + strlen (proto) + 2]; - size_t keylen = snprintf (key, sizeof (key), "%d/%s", ntohs (port), - proto); - - char *result; - int int_len; - int status = yp_match (domain, "services.byname", key, keylen, &result, - &int_len); - size_t len = int_len; - - /* If we found the key, it's ok and parse the result. If not, - fall through and parse the complete table. */ - if (__glibc_likely (status == YPERR_SUCCESS)) - { - if (__glibc_unlikely ((size_t) (len + 1) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer, - buflen, errnop); - if (__glibc_unlikely (parse_res < 0)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; - } - } - while (protocol == NULL && (proto[0] == 't' ? (proto = "udp") : NULL)); - - if (port == -1) - return NSS_STATUS_NOTFOUND; - - struct ypall_callback ypcb; - struct search_t req; - - ypcb.foreach = dosearch; - ypcb.data = (char *) &req; - req.name = NULL; - req.proto = protocol; - req.port = port; - req.serv = serv; - req.buffer = buffer; - req.buflen = buflen; - req.errnop = errnop; - req.status = NSS_STATUS_NOTFOUND; - int status = yp_all (domain, "services.byname", &ypcb); - - if (__glibc_unlikely (status != YPERR_SUCCESS)) - return yperr2nss (status); - - return req.status; -} diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c deleted file mode 100644 index 9790dd4104..0000000000 --- a/nis/nss_nis/nis-spwd.c +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nis.h" -#include - -/* Get the declaration of the parser function. */ -#define ENTNAME spent -#define STRUCTURE spwd -#define EXTERN_PARSER -#include - -/* Protect global state against multiple changers */ -__libc_lock_define_initialized (static, lock) - -static bool new_start = true; -static bool ent_adjunct_used; -static char *oldkey; -static int oldkeylen; - -enum nss_status -_nss_nis_setspent (int stayopen) -{ - return _nss_nis_endspent (); -} - -enum nss_status -_nss_nis_endspent (void) -{ - __libc_lock_lock (lock); - - new_start = true; - ent_adjunct_used = false; - free (oldkey); - oldkey = NULL; - oldkeylen = 0; - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} -libnss_nis_hidden_def (_nss_nis_endspent) - -static enum nss_status -internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen, - int *errnop) -{ - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - char *result; - char *outkey; - int len; - int keylen; - int yperr; - - if (new_start) - { - yperr = yp_first (domain, "shadow.byname", &outkey, &keylen, &result, - &len); - if (__builtin_expect (yperr == YPERR_MAP, 0) - && (_nsl_default_nss () & NSS_FLAG_ADJUNCT_AS_SHADOW)) - { - free (result); - yperr = yp_first (domain, "passwd.adjunct.byname", &outkey, - &keylen, &result, &len); - ent_adjunct_used = true; - } - } - else - yperr = yp_next (domain, (ent_adjunct_used - ? "passwd.adjunct.byname" : "shadow.byname"), - oldkey, oldkeylen, &outkey, &keylen, &result, &len); - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__builtin_expect ((size_t) (len + (ent_adjunct_used ? 3 : 1)) - > buflen, 0)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - if (ent_adjunct_used) - /* This is an ugly trick. The format of passwd.adjunct.byname almost - matches the shadow.byname format except that the last two fields - are missing. Synthesize them by marking them empty. */ - strcpy (&buffer[len], "::"); - else - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - parse_res = _nss_files_parse_spent (p, sp, (void *) buffer, buflen, - errnop); - if (__builtin_expect (parse_res == -1, 0)) - { - free (outkey); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - free (oldkey); - oldkey = outkey; - oldkeylen = keylen; - new_start = false; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nis_getspent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nis_getspnam_r (const char *name, struct spwd *sp, - char *buffer, size_t buflen, int *errnop) -{ - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - const size_t name_len = strlen (name); - - char *domain; - if (__glibc_unlikely (yp_get_default_domain (&domain))) - return NSS_STATUS_UNAVAIL; - - bool adjunct_used = false; - char *result; - int len; - int yperr = yp_match (domain, "shadow.byname", name, name_len, &result, - &len); - if (__builtin_expect (yperr == YPERR_MAP, 0) - && (_nsl_default_nss () & NSS_FLAG_ADJUNCT_AS_SHADOW)) - { - free (result); - yperr = yp_match (domain, "passwd.adjunct.byname", name, name_len, - &result, &len); - adjunct_used = true; - } - - if (__glibc_unlikely (yperr != YPERR_SUCCESS)) - { - enum nss_status retval = yperr2nss (yperr); - - if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; - return retval; - } - - if (__glibc_unlikely ((size_t) (len + (adjunct_used ? 3 : 1)) > buflen)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - char *p = strncpy (buffer, result, len); - if (__builtin_expect (adjunct_used, false)) - /* This is an ugly trick. The format of passwd.adjunct.byname almost - matches the shadow.byname format except that the last two fields - are missing. Synthesize them by marking them empty. */ - strcpy (&buffer[len], "::"); - else - buffer[len] = '\0'; - while (isspace (*p)) - ++p; - free (result); - - int parse_res = _nss_files_parse_spent (p, sp, (void *) buffer, buflen, - errnop); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c deleted file mode 100644 index d938763ac9..0000000000 --- a/nis/nss_nisplus/nisplus-alias.c +++ /dev/null @@ -1,337 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static u_long next_entry; -static nis_name tablename_val; -static size_t tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "mail_aliases.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - -static int -_nss_nisplus_parse_aliasent (nis_result *result, unsigned long entry, - struct aliasent *alias, char *buffer, - size_t buflen, int *errnop) -{ - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (&NIS_RES_OBJECT (result)[entry]) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)[entry].EN_data.en_type, - "mail_aliases") != 0 - || NIS_RES_OBJECT (result)[entry].EN_data.en_cols.en_cols_len < 2) - return 0; - - if (NISENTRYLEN (entry, 1, result) >= buflen) - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - char *cp = __stpncpy (buffer, NISENTRYVAL (entry, 1, result), - NISENTRYLEN (entry, 1, result)); - *cp = '\0'; - - char *first_unused = cp + 1; - size_t room_left = buflen - (first_unused - buffer); - - alias->alias_local = 0; - alias->alias_members_len = 0; - - if (NISENTRYLEN (entry, 0, result) >= room_left) - goto no_more_room; - - cp = __stpncpy (first_unused, NISENTRYVAL (entry, 0, result), - NISENTRYLEN (entry, 0, result)); - *cp = '\0'; - alias->alias_name = first_unused; - - /* Terminate the line for any case. */ - cp = strpbrk (alias->alias_name, "#\n"); - if (cp != NULL) - *cp = '\0'; - - size_t len = strlen (alias->alias_name) + 1; - first_unused += len; - room_left -= len; - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - - alias->alias_members = (char **) first_unused; - - char *line = buffer; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - room_left -= sizeof (char *); - alias->alias_members[alias->alias_members_len] = line; - - while (*line != '\0' && *line != ',') - ++line; - - if (line != alias->alias_members[alias->alias_members_len]) - { - *line++ = '\0'; - ++alias->alias_members_len; - } - else if (*line == ',') - ++line; - } - - return alias->alias_members_len == 0 ? 0 : 1; -} - -static enum nss_status -internal_setaliasent (void) -{ - enum nss_status status; - int err; - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (_nss_create_tablename (&err) != NSS_STATUS_SUCCESS) - return NSS_STATUS_UNAVAIL; - - next_entry = 0; - result = nis_list (tablename_val, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - if (result == NULL) - { - status = NSS_STATUS_TRYAGAIN; - __set_errno (ENOMEM); - } - else - { - status = niserr2nss (result->status); - if (status != NSS_STATUS_SUCCESS) - { - nis_freeresult (result); - result = NULL; - } - } - return status; -} - -enum nss_status -_nss_nisplus_setaliasent (void) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - status = internal_setaliasent (); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endaliasent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - next_entry = 0; - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getaliasent_r (struct aliasent *alias, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (result == NULL) - { - enum nss_status status; - - status = internal_setaliasent (); - if (result == NULL || status != NSS_STATUS_SUCCESS) - return status; - } - - /* Get the next entry until we found a correct one. */ - do - { - if (next_entry >= result->objects.objects_len) - return NSS_STATUS_NOTFOUND; - - parse_res = _nss_nisplus_parse_aliasent (result, next_entry, alias, - buffer, buflen, errnop); - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - - ++next_entry; - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getaliasent_r (struct aliasent *result, char *buffer, - size_t buflen, int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getaliasent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char buf[strlen (name) + 9 + tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_aliasent (result, 0, alias, - buffer, buflen, errnop); - - /* We do not need the lookup result anymore. */ - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - __set_errno (olderr); - - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-ethers.c b/nis/nss_nisplus/nisplus-ethers.c deleted file mode 100644 index 51aa6a6e83..0000000000 --- a/nis/nss_nisplus/nisplus-ethers.c +++ /dev/null @@ -1,356 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].zo_data.objdata_u.en_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].zo_data.objdata_u.en_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -static int -_nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether, - char *buffer, size_t buflen, int *errnop) -{ - char *p = buffer; - size_t room_left = buflen; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || NIS_RES_NUMOBJ (result) != 1 - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, - "ethers_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 2) - return 0; - - /* Generate the ether entry format and use the normal parser */ - if (NISENTRYLEN (0, 0, result) + 1 > room_left) - { - *errnop = ERANGE; - return -1; - } - char *cp = __stpncpy (p, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - *cp = '\0'; - room_left -= NISENTRYLEN (0, 0, result) + 1; - ether->e_name = p; - - struct ether_addr *ea = ether_aton (NISENTRYVAL (0, 1, result)); - if (ea == NULL) - { - *errnop = EINVAL; - return -2; - } - - ether->e_addr = *ea; - - return 1; -} - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "ethers.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nisplus_setetherent (int stayopen) -{ - enum nss_status status; - int err; - - status = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (_nss_create_tablename (&err) != NSS_STATUS_SUCCESS) - status = NSS_STATUS_UNAVAIL; - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endetherent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getetherent_r (struct etherent *ether, char *buffer, - size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - /* Get the next entry until we found a correct one. */ - int parse_res; - do - { - nis_result *saved_result; - - if (result == NULL) - { - saved_result = NULL; - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); - } - else - { - saved_result = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - nis_freeresult (saved_result); - return niserr2nss (result->status); - } - } - - parse_res = _nss_nisplus_parse_etherent (result, ether, buffer, - buflen, errnop); - if (parse_res == -1) - { - nis_freeresult (result); - result = saved_result; - return NSS_STATUS_TRYAGAIN; - } - - if (saved_result != NULL) - nis_freeresult (saved_result); - - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getetherent_r (struct etherent *result, char *buffer, - size_t buflen, int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getetherent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_gethostton_r (const char *name, struct etherent *eth, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char buf[strlen (name) + 9 + tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, - buflen, errnop); - - /* We do not need the lookup result anymore. */ - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - __set_errno (olderr); - - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getntohost_r (const struct ether_addr *addr, struct etherent *eth, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (addr == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - char buf[26 + tablename_len]; - - snprintf (buf, sizeof (buf), - "[addr=%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 - ":%" PRIx8 "],%s", - addr->ether_addr_octet[0], addr->ether_addr_octet[1], - addr->ether_addr_octet[2], addr->ether_addr_octet[3], - addr->ether_addr_octet[4], addr->ether_addr_octet[5], - tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, - buflen, errnop); - - /* We do not need the lookup result anymore. */ - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; - - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-grp.c b/nis/nss_nisplus/nisplus-grp.c deleted file mode 100644 index 8223c37bb9..0000000000 --- a/nis/nss_nisplus/nisplus-grp.c +++ /dev/null @@ -1,401 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" -#include "nisplus-parser.h" -#include -#include -#include - - -__libc_lock_define_initialized (static, lock); - -/* Connection information. */ -static ib_request *ibreq; -static directory_obj *dir; -static dir_binding bptr; -static char *tablepath; -static char *tableptr; -/* Cursor. */ -static netobj cursor; - - -nis_name grp_tablename_val attribute_hidden; -size_t grp_tablename_len attribute_hidden; - -enum nss_status -_nss_grp_create_tablename (int *errnop) -{ - if (grp_tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "group.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - grp_tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - if (atomic_compare_and_exchange_bool_acq (&grp_tablename_val, p, NULL)) - { - /* Another thread already installed the value. */ - free (p); - grp_tablename_len = strlen (grp_tablename_val); - } - } - - return NSS_STATUS_SUCCESS; -} - - -static void -internal_endgrent (void) -{ - __nisbind_destroy (&bptr); - memset (&bptr, '\0', sizeof (bptr)); - - nis_free_directory (dir); - dir = NULL; - - nis_free_request (ibreq); - ibreq = NULL; - - xdr_free ((xdrproc_t) xdr_netobj, (char *) &cursor); - memset (&cursor, '\0', sizeof (cursor)); - - free (tablepath); - tableptr = tablepath = NULL; -} - - -static enum nss_status -internal_setgrent (int *errnop) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - - if (grp_tablename_val == NULL) - status = _nss_grp_create_tablename (errnop); - - if (status == NSS_STATUS_SUCCESS) - { - ibreq = __create_ib_request (grp_tablename_val, 0); - if (ibreq == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - nis_error retcode = __prepare_niscall (grp_tablename_val, &dir, &bptr, 0); - if (retcode != NIS_SUCCESS) - { - nis_free_request (ibreq); - ibreq = NULL; - status = niserr2nss (retcode); - } - } - - return status; -} - - -enum nss_status -_nss_nisplus_setgrent (int stayopen) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - internal_endgrent (); - - // XXX We need to be able to set errno. Pass in new parameter. - int err; - status = internal_setgrent (&err); - - __libc_lock_unlock (lock); - - return status; -} - - -enum nss_status -_nss_nisplus_endgrent (void) -{ - __libc_lock_lock (lock); - - internal_endgrent (); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - - -static enum nss_status -internal_nisplus_getgrent_r (struct group *gr, char *buffer, size_t buflen, - int *errnop) -{ - int parse_res = -1; - enum nss_status retval = NSS_STATUS_SUCCESS; - - /* Get the next entry until we found a correct one. */ - do - { - nis_error status; - nis_result result; - memset (&result, '\0', sizeof (result)); - - if (cursor.n_bytes == NULL) - { - if (ibreq == NULL) - { - retval = internal_setgrent (errnop); - if (retval != NSS_STATUS_SUCCESS) - return retval; - } - - status = __do_niscall3 (&bptr, NIS_IBFIRST, - (xdrproc_t) _xdr_ib_request, - (caddr_t) ibreq, - (xdrproc_t) _xdr_nis_result, - (caddr_t) &result, - 0, NULL); - } - else - { - ibreq->ibr_cookie.n_bytes = cursor.n_bytes; - ibreq->ibr_cookie.n_len = cursor.n_len; - - status = __do_niscall3 (&bptr, NIS_IBNEXT, - (xdrproc_t) _xdr_ib_request, - (caddr_t) ibreq, - (xdrproc_t) _xdr_nis_result, - (caddr_t) &result, - 0, NULL); - - ibreq->ibr_cookie.n_bytes = NULL; - ibreq->ibr_cookie.n_len = 0; - } - - if (status != NIS_SUCCESS) - return niserr2nss (status); - - if (NIS_RES_STATUS (&result) == NIS_NOTFOUND) - { - /* No more entries on this server. This means we have to go - to the next server on the path. */ - status = __follow_path (&tablepath, &tableptr, ibreq, &bptr); - if (status != NIS_SUCCESS) - return niserr2nss (status); - - directory_obj *newdir = NULL; - dir_binding newbptr; - status = __prepare_niscall (ibreq->ibr_name, &newdir, &newbptr, 0); - if (status != NIS_SUCCESS) - return niserr2nss (status); - - nis_free_directory (dir); - dir = newdir; - __nisbind_destroy (&bptr); - bptr = newbptr; - - xdr_free ((xdrproc_t) xdr_netobj, (char *) &result.cookie); - result.cookie.n_bytes = NULL; - result.cookie.n_len = 0; - parse_res = 0; - goto next; - } - else if (NIS_RES_STATUS (&result) != NIS_SUCCESS) - return niserr2nss (NIS_RES_STATUS (&result)); - - parse_res = _nss_nisplus_parse_grent (&result, gr, - buffer, buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - { - *errnop = ERANGE; - retval = NSS_STATUS_TRYAGAIN; - goto freeres; - } - - next: - /* Free the old cursor. */ - xdr_free ((xdrproc_t) xdr_netobj, (char *) &cursor); - /* Remember the new one. */ - cursor.n_bytes = result.cookie.n_bytes; - cursor.n_len = result.cookie.n_len; - /* Free the result structure. NB: we do not remove the cookie. */ - result.cookie.n_bytes = NULL; - result.cookie.n_len = 0; - freeres: - xdr_free ((xdrproc_t) _xdr_nis_result, (char *) &result); - memset (&result, '\0', sizeof (result)); - } - while (!parse_res); - - return retval; -} - -enum nss_status -_nss_nisplus_getgrent_r (struct group *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getgrent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getgrnam_r (const char *name, struct group *gr, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (grp_tablename_val == NULL) - { - enum nss_status status = _nss_grp_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_NOTFOUND; - } - - nis_result *result; - char buf[strlen (name) + 9 + grp_tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[name=%s],%s", name, grp_tablename_val); - - result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen, errnop); - nis_freeresult (result); - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getgrgid_r (const gid_t gid, struct group *gr, - char *buffer, size_t buflen, int *errnop) -{ - if (grp_tablename_val == NULL) - { - enum nss_status status = _nss_grp_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - int parse_res; - nis_result *result; - char buf[8 + 3 * sizeof (unsigned long int) + grp_tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[gid=%lu],%s", - (unsigned long int) gid, grp_tablename_val); - - result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen, errnop); - - nis_freeresult (result); - if (__glibc_unlikely (parse_res < 1)) - { - __set_errno (olderr); - - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c deleted file mode 100644 index 1e66e4ff92..0000000000 --- a/nis/nss_nisplus/nisplus-hosts.c +++ /dev/null @@ -1,584 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -static int -_nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host, - char *buffer, size_t buflen, int *errnop) -{ - unsigned int i; - char *first_unused = buffer; - size_t room_left = buflen; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)[0].EN_data.en_type, "hosts_tbl") != 0 - || NIS_RES_OBJECT (result)[0].EN_data.en_cols.en_cols_len < 4) - return 0; - - char *data = first_unused; - - if (room_left < (af != AF_INET ? IN6ADDRSZ : INADDRSZ)) - { - no_more_room: - *errnop = ERANGE; - return -1; - } - - /* Parse address. */ - if (af != AF_INET6 - && inet_pton (AF_INET, NISENTRYVAL (0, 2, result), data) > 0) - { - host->h_addrtype = AF_INET; - host->h_length = INADDRSZ; - } - else if (af != AF_INET - && inet_pton (AF_INET6, NISENTRYVAL (0, 2, result), data) > 0) - { - host->h_addrtype = AF_INET6; - host->h_length = IN6ADDRSZ; - } - else - /* Illegal address: ignore line. */ - return 0; - - first_unused += host->h_length; - room_left -= host->h_length; - - if (NISENTRYLEN (0, 0, result) + 1 > room_left) - goto no_more_room; - - host->h_name = first_unused; - first_unused = __stpncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - *first_unused++ = '\0'; - - room_left -= NISENTRYLEN (0, 0, result) + 1; - char *line = first_unused; - - /* When this is a call to gethostbyname4_r we do not need the aliases. */ - if (af != AF_UNSPEC) - { - /* XXX Rewrite at some point to allocate the array first and then - copy the strings. It is wasteful to first concatenate the strings - to just split them again later. */ - for (i = 0; i < NIS_RES_NUMOBJ (result); ++i) - { - if (strcmp (NISENTRYVAL (i, 1, result), host->h_name) != 0) - { - if (NISENTRYLEN (i, 1, result) + 2 > room_left) - goto no_more_room; - - *first_unused++ = ' '; - first_unused = __stpncpy (first_unused, - NISENTRYVAL (i, 1, result), - NISENTRYLEN (i, 1, result)); - *first_unused = '\0'; - room_left -= NISENTRYLEN (i, 1, result) + 1; - } - } - *first_unused++ = '\0'; - } - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust + 3 * sizeof (char *)) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - host->h_addr_list = (char **) first_unused; - - room_left -= 3 * sizeof (char *); - host->h_addr_list[0] = data; - host->h_addr_list[1] = NULL; - host->h_aliases = &host->h_addr_list[2]; - - /* When this is a call to gethostbyname4_r we do not need the aliases. */ - if (af != AF_UNSPEC) - { - i = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - - room_left -= sizeof (char *); - host->h_aliases[i++] = line; - - while (*line != '\0' && *line != ' ') - ++line; - - if (*line == ' ') - *line++ = '\0'; - } - - host->h_aliases[i] = NULL; - } - - return 1; -} - - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "hosts.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nisplus_sethostent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - int err; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (tablename_val == NULL) - status = _nss_create_tablename (&err); - - __libc_lock_unlock (lock); - - return status; -} - - -enum nss_status -_nss_nisplus_endhostent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - - -static enum nss_status -internal_nisplus_gethostent_r (struct hostent *host, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - enum nss_status retval = niserr2nss (result->status); - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = NETDB_INTERNAL; - *errnop = errno; - } - return retval; - } - - } - else - { - saved_res = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - enum nss_status retval= niserr2nss (result->status); - - nis_freeresult (result); - result = saved_res; - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = NETDB_INTERNAL; - *errnop = errno; - } - return retval; - } - } - - parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer, - buflen, errnop); - - if (parse_res == -1) - { - nis_freeresult (result); - result = saved_res; - *herrnop = NETDB_INTERNAL; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - if (saved_res != NULL) - nis_freeresult (saved_res); - - } while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nisplus_gethostent_r (struct hostent *result, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_gethostent_r (result, buffer, buflen, errnop, - herrnop); - - __libc_lock_unlock (lock); - - return status; -} - - -static enum nss_status -get_tablename (int *herrnop) -{ - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (herrnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - *herrnop = NETDB_INTERNAL; - - return status; -} - - -static enum nss_status -internal_gethostbyname2_r (const char *name, int af, struct hostent *host, - char *buffer, size_t buflen, int *errnop, - int *herrnop) -{ - if (tablename_val == NULL) - { - enum nss_status status = get_tablename (herrnop); - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_NOTFOUND; - } - - char buf[strlen (name) + 10 + tablename_len]; - int olderr = errno; - - /* Search at first in the alias list, and use the correct name - for the next search. */ - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - - if (result != NULL) - { - /* If we did not find it, try it as original name. But if the - database is correct, we should find it in the first case, too. */ - char *bufptr = buf; - size_t buflen = sizeof (buf); - - if ((result->status == NIS_SUCCESS || result->status == NIS_S_SUCCESS) - && __type_of (result->objects.objects_val) == NIS_ENTRY_OBJ - && strcmp (result->objects.objects_val->EN_data.en_type, - "hosts_tbl") == 0 - && result->objects.objects_val->EN_data.en_cols.en_cols_len >= 3) - { - /* We need to allocate a new buffer since there is no - guarantee the returned alias name has a length limit. */ - name = NISENTRYVAL(0, 0, result); - size_t buflen = strlen (name) + 10 + tablename_len; - bufptr = alloca (buflen); - } - - snprintf (bufptr, buflen, "[cname=%s],%s", name, tablename_val); - - nis_freeresult (result); - result = nis_list (bufptr, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - } - - if (result == NULL) - { - *errnop = ENOMEM; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - int retval = niserr2nss (result->status); - if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) - { - if (retval == NSS_STATUS_TRYAGAIN) - { - *errnop = errno; - *herrnop = TRY_AGAIN; - } - else - { - __set_errno (olderr); - *herrnop = NETDB_INTERNAL; - } - nis_freeresult (result); - return retval; - } - - int parse_res = _nss_nisplus_parse_hostent (result, af, host, buffer, - buflen, errnop); - - nis_freeresult (result); - - if (parse_res > 0) - return NSS_STATUS_SUCCESS; - - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; -} - - -enum nss_status -_nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host, - char *buffer, size_t buflen, int *errnop, - int *herrnop) -{ - if (af != AF_INET && af != AF_INET6) - { - *herrnop = HOST_NOT_FOUND; - return NSS_STATUS_NOTFOUND; - } - - return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop, - herrnop); -} - - -enum nss_status -_nss_nisplus_gethostbyname_r (const char *name, struct hostent *host, - char *buffer, size_t buflen, int *errnop, - int *h_errnop) -{ - return internal_gethostbyname2_r (name, AF_INET, host, buffer, - buflen, errnop, h_errnop); -} - - -enum nss_status -_nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, - struct hostent *host, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - if (tablename_val == NULL) - { - enum nss_status status = get_tablename (herrnop); - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (addr == NULL) - return NSS_STATUS_NOTFOUND; - - char buf[24 + tablename_len]; - int retval, parse_res; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[addr=%s],%s", - inet_ntoa (*(const struct in_addr *) addr), tablename_val); - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - - if (result == NULL) - { - __set_errno (ENOMEM); - return NSS_STATUS_TRYAGAIN; - } - - retval = niserr2nss (result->status); - if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) - { - if (retval == NSS_STATUS_TRYAGAIN) - { - *errnop = errno; - *herrnop = NETDB_INTERNAL; - } - else - __set_errno (olderr); - nis_freeresult (result); - return retval; - } - - parse_res = _nss_nisplus_parse_hostent (result, af, host, - buffer, buflen, errnop); - nis_freeresult (result); - - if (parse_res > 0) - return NSS_STATUS_SUCCESS; - - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; -} - - -enum nss_status -_nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, - char *buffer, size_t buflen, int *errnop, - int *herrnop, int32_t *ttlp) -{ - struct hostent host; - - enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host, - buffer, buflen, - errnop, herrnop); - if (__glibc_likely (status == NSS_STATUS_SUCCESS)) - { - if (*pat == NULL) - { - uintptr_t pad = (-(uintptr_t) buffer - % __alignof__ (struct gaih_addrtuple)); - buffer += pad; - buflen = buflen > pad ? buflen - pad : 0; - - if (__glibc_unlikely (buflen < sizeof (struct gaih_addrtuple))) - { - free (result); - *errnop = ERANGE; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - } - - (*pat)->next = NULL; - (*pat)->name = host.h_name; - (*pat)->family = host.h_addrtype; - - memcpy ((*pat)->addr, host.h_addr_list[0], host.h_length); - (*pat)->scopeid = 0; - assert (host.h_addr_list[1] == NULL); - } - - return status; -} diff --git a/nis/nss_nisplus/nisplus-initgroups.c b/nis/nss_nisplus/nisplus-initgroups.c deleted file mode 100644 index 9a6ee5cf9e..0000000000 --- a/nis/nss_nisplus/nisplus-initgroups.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 1997-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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" -#include "nisplus-parser.h" -#include -#include -#include - -#define NISOBJVAL(col, obj) \ - ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISOBJLEN(col, obj) \ - ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -extern nis_name grp_tablename_val attribute_hidden; -extern size_t grp_tablename_len attribute_hidden; -extern enum nss_status _nss_grp_create_tablename (int *errnop); - - -enum nss_status -_nss_nisplus_initgroups_dyn (const char *user, gid_t group, long int *start, - long int *size, gid_t **groupsp, long int limit, - int *errnop) -{ - if (grp_tablename_val == NULL) - { - enum nss_status status = _nss_grp_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - nis_result *result; - char buf[strlen (user) + 12 + grp_tablename_len]; - - snprintf (buf, sizeof (buf), "[members=%s],%s", user, grp_tablename_val); - - result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH | ALL_RESULTS, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - nis_freeresult (result); - return status; - } - - if (NIS_RES_NUMOBJ (result) == 0) - { - errout: - nis_freeresult (result); - return NSS_STATUS_NOTFOUND; - } - - gid_t *groups = *groupsp; - nis_object *obj = NIS_RES_OBJECT (result); - for (unsigned int cnt = 0; cnt < NIS_RES_NUMOBJ (result); ++cnt, ++obj) - { - if (__type_of (obj) != NIS_ENTRY_OBJ - || strcmp (obj->EN_data.en_type, "group_tbl") != 0 - || obj->EN_data.en_cols.en_cols_len < 4) - continue; - - char *numstr = NISOBJVAL (2, obj); - size_t len = NISOBJLEN (2, obj); - if (len == 0 || numstr[0] == '\0') - continue; - - gid_t gid; - char *endp; - if (__glibc_unlikely (numstr[len - 1] != '\0')) - { - char numstrbuf[len + 1]; - memcpy (numstrbuf, numstr, len); - numstrbuf[len] = '\0'; - gid = strtoul (numstrbuf, &endp, 10); - if (*endp) - continue; - } - else - { - gid = strtoul (numstr, &endp, 10); - if (*endp) - continue; - } - - if (gid == group) - continue; - - /* Insert this group. */ - if (*start == *size) - { - /* Need a bigger buffer. */ - long int newsize; - - if (limit > 0 && *size == limit) - /* We reached the maximum. */ - break; - - if (limit <= 0) - newsize = 2 * *size; - else - newsize = MIN (limit, 2 * *size); - - gid_t *newgroups = realloc (groups, newsize * sizeof (*groups)); - if (newgroups == NULL) - goto errout; - *groupsp = groups = newgroups; - *size = newsize; - } - - groups[*start] = gid; - *start += 1; - } - - nis_freeresult (result); - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c deleted file mode 100644 index d8512b35ce..0000000000 --- a/nis/nss_nisplus/nisplus-netgrp.c +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -enum nss_status -_nss_nisplus_getnetgrent_r (struct __netgrent *result, char *buffer, - size_t buflen, int *errnop) -{ - enum nss_status status; - - /* Some sanity checks. */ - if (result->data == NULL || result->data_size == 0) - return NSS_STATUS_NOTFOUND; - - if (result->position == result->data_size) - return result->first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN; - - unsigned int entrylen - = NISENTRYLEN (result->position, 1, (nis_result *) result->data); - if (entrylen > 0) - { - /* We have a list of other netgroups. */ - - result->type = group_val; - if (entrylen >= buflen) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - strncpy (buffer, NISENTRYVAL (result->position, 1, - (nis_result *) result->data), - entrylen); - buffer[entrylen] = '\0'; - result->val.group = buffer; - ++result->position; - result->first = 0; - - return NSS_STATUS_SUCCESS; - } - - /* Before we can copy the entry to the private buffer we have to make - sure it is big enough. */ - unsigned int hostlen - = NISENTRYLEN (result->position, 2, (nis_result *) result->data); - unsigned int userlen - = NISENTRYLEN (result->position, 3, (nis_result *) result->data); - unsigned int domainlen - = NISENTRYLEN (result->position, 4, (nis_result *) result->data); - if (hostlen + userlen + domainlen + 6 > buflen) - { - *errnop = ERANGE; - status = NSS_STATUS_TRYAGAIN; - } - else - { - char *cp = buffer; - - result->type = triple_val; - - if (hostlen == 0 - || NISENTRYVAL (result->position, 2, - (nis_result *) result->data)[0] == '\0') - result->val.triple.host = NULL; - else - { - result->val.triple.host = cp; - cp = __stpncpy (cp, NISENTRYVAL (result->position, 2, - (nis_result *) result->data), - hostlen); - *cp++ = '\0'; - } - - if (userlen == 0 - || NISENTRYVAL (result->position, 3, - (nis_result *) result->data)[0] == '\0') - result->val.triple.user = NULL; - else - { - result->val.triple.user = cp; - cp = __stpncpy (cp, NISENTRYVAL (result->position, 3, - (nis_result *) result->data), - userlen); - *cp++ = '\0'; - } - - if (domainlen == 0 - || NISENTRYVAL (result->position, 4, - (nis_result *) result->data)[0] == '\0') - result->val.triple.domain = NULL; - else - { - result->val.triple.domain = cp; - cp = __stpncpy (cp, NISENTRYVAL (result->position, 4, - (nis_result *) result->data), - domainlen); - *cp = '\0'; - } - - status = NSS_STATUS_SUCCESS; - - /* Remember where we stopped reading. */ - ++result->position; - - result->first = 0; - } - - return status; -} - -static void -internal_endnetgrent (struct __netgrent *netgrp) -{ - nis_freeresult ((nis_result *) netgrp->data); - netgrp->data = NULL; - netgrp->data_size = 0; - netgrp->position = 0; -} - -enum nss_status -_nss_nisplus_setnetgrent (const char *group, struct __netgrent *netgrp) -{ - char buf[strlen (group) + 25]; - - if (group == NULL || group[0] == '\0') - return NSS_STATUS_UNAVAIL; - - enum nss_status status = NSS_STATUS_SUCCESS; - - snprintf (buf, sizeof (buf), "[name=%s],netgroup.org_dir", group); - - netgrp->data = (char *) nis_list (buf, EXPAND_NAME, NULL, NULL); - - if (netgrp->data == NULL) - { - __set_errno (ENOMEM); - status = NSS_STATUS_TRYAGAIN; - } - else if (niserr2nss (((nis_result *) netgrp->data)->status) - != NSS_STATUS_SUCCESS) - { - status = niserr2nss (((nis_result *) netgrp->data)->status); - - internal_endnetgrent (netgrp); - } - else - { - netgrp->data_size = ((nis_result *) netgrp->data)->objects.objects_len; - netgrp->position = 0; - netgrp->first = 1; - } - - return status; -} - -enum nss_status -_nss_nisplus_endnetgrent (struct __netgrent *netgrp) -{ - internal_endnetgrent (netgrp); - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c deleted file mode 100644 index a731ed7e8b..0000000000 --- a/nis/nss_nisplus/nisplus-network.c +++ /dev/null @@ -1,494 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - - -static int -_nss_nisplus_parse_netent (nis_result *result, struct netent *network, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer; - size_t room_left = buflen; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)[0].EN_data.en_type, - "networks_tbl") != 0 - || NIS_RES_OBJECT (result)[0].EN_data.en_cols.en_cols_len < 3) - return 0; - - if (NISENTRYLEN (0, 0, result) >= room_left) - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - strncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - first_unused[NISENTRYLEN (0, 0, result)] = '\0'; - network->n_name = first_unused; - size_t len = strlen (first_unused) + 1; - room_left -= len; - first_unused += len; - - network->n_addrtype = 0; - network->n_net = inet_network (NISENTRYVAL (0, 2, result)); - - /* XXX Rewrite at some point to allocate the array first and then - copy the strings. It wasteful to first concatenate the strings - to just split them again later. */ - char *line = first_unused; - for (unsigned int i = 0; i < NIS_RES_NUMOBJ (result); ++i) - { - if (strcmp (NISENTRYVAL (i, 1, result), network->n_name) != 0) - { - if (NISENTRYLEN (i, 1, result) + 2 > room_left) - goto no_more_room; - - *first_unused++ = ' '; - first_unused = __stpncpy (first_unused, NISENTRYVAL (i, 1, result), - NISENTRYLEN (i, 1, result)); - room_left -= (NISENTRYLEN (i, 1, result) + 1); - } - } - *first_unused++ = '\0'; - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust + sizeof (char *)) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - network->n_aliases = (char **) first_unused; - - /* For the terminating NULL pointer. */ - room_left -= sizeof (char *); - - unsigned int i = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - - room_left -= sizeof (char *); - network->n_aliases[i++] = line; - - while (*line != '\0' && *line != ' ') - ++line; - - if (*line == ' ') - *line++ = '\0'; - } - network->n_aliases[i] = NULL; - - return 1; -} - - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "networks.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_setnetent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (tablename_val == NULL) - { - int err; - status = _nss_create_tablename (&err); - } - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endnetent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getnetent_r (struct netent *network, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - int retval = niserr2nss (result->status); - nis_freeresult (result); - result = NULL; - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = NETDB_INTERNAL; - *errnop = errno; - return retval; - } - else - return retval; - } - } - else - { - saved_res = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - int retval = niserr2nss (result->status); - nis_freeresult (result); - result = saved_res; - if (retval == NSS_STATUS_TRYAGAIN) - { - *herrnop = NETDB_INTERNAL; - *errnop = errno; - } - return retval; - } - } - - parse_res = _nss_nisplus_parse_netent (result, network, buffer, - buflen, errnop); - if (parse_res == -1) - { - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_TRYAGAIN; - } - - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getnetent_r (struct netent *result, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getnetent_r (result, buffer, buflen, errnop, - herrnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getnetbyname_r (const char *name, struct netent *network, - char *buffer, size_t buflen, int *errnop, - int *herrnop) -{ - int parse_res, retval; - - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - *herrnop = NETDB_INTERNAL; - return NSS_STATUS_UNAVAIL; - } - - nis_result *result; - char buf[strlen (name) + 10 + tablename_len]; - int olderr = errno; - - /* Search at first in the alias list, and use the correct name - for the next search */ - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH | USE_DGRAM, NULL, NULL); - - if (result != NULL) - { - char *bufptr = buf; - - /* If we do not find it, try it as original name. But if the - database is correct, we should find it in the first case, too */ - if ((result->status != NIS_SUCCESS - && result->status != NIS_S_SUCCESS) - || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ - || strcmp (result->objects.objects_val[0].EN_data.en_type, - "networks_tbl") != 0 - || (result->objects.objects_val[0].EN_data.en_cols.en_cols_len - < 3)) - snprintf (buf, sizeof (buf), "[cname=%s],%s", name, tablename_val); - else - { - /* We need to allocate a new buffer since there is no - guarantee the returned name has a length limit. */ - const char *entryval = NISENTRYVAL (0, 0, result); - size_t buflen = strlen (entryval) + 10 + tablename_len; - bufptr = alloca (buflen); - snprintf (bufptr, buflen, "[cname=%s],%s", - entryval, tablename_val); - } - - nis_freeresult (result); - result = nis_list (bufptr, FOLLOW_LINKS | FOLLOW_PATH | USE_DGRAM, - NULL, NULL); - } - - if (result == NULL) - { - __set_errno (ENOMEM); - return NSS_STATUS_TRYAGAIN; - } - - retval = niserr2nss (result->status); - if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) - { - if (retval == NSS_STATUS_TRYAGAIN) - { - *errnop = errno; - *herrnop = NETDB_INTERNAL; - } - else - __set_errno (olderr); - nis_freeresult (result); - return retval; - } - - parse_res = _nss_nisplus_parse_netent (result, network, buffer, buflen, - errnop); - - nis_freeresult (result); - - if (parse_res > 0) - return NSS_STATUS_SUCCESS; - - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; -} - -/* XXX type is ignored, SUN's NIS+ table doesn't support it */ -enum nss_status -_nss_nisplus_getnetbyaddr_r (uint32_t addr, const int type, - struct netent *network, char *buffer, - size_t buflen, int *errnop, int *herrnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - { - char buf[27 + tablename_len]; - char buf2[18]; - int olderr = errno; - - struct in_addr in = { .s_addr = htonl (addr) }; - strcpy (buf2, inet_ntoa (in)); - size_t b2len = strlen (buf2); - - while (1) - { - snprintf (buf, sizeof (buf), "[addr=%s],%s", buf2, tablename_val); - nis_result *result = nis_list (buf, EXPAND_NAME | USE_DGRAM, - NULL, NULL); - - if (result == NULL) - { - __set_errno (ENOMEM); - return NSS_STATUS_TRYAGAIN; - } - enum nss_status retval = niserr2nss (result->status); - if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) - { - if (b2len > 2 && buf2[b2len - 2] == '.' && buf2[b2len - 1] == '0') - { - /* Try again, but with trailing dot(s) - removed (one by one) */ - buf2[b2len - 2] = '\0'; - b2len -= 2; - nis_freeresult (result); - continue; - } - - if (retval == NSS_STATUS_TRYAGAIN) - { - *errnop = errno; - *herrnop = NETDB_INTERNAL; - } - else - __set_errno (olderr); - nis_freeresult (result); - return retval; - } - - int parse_res = _nss_nisplus_parse_netent (result, network, buffer, - buflen, errnop); - - nis_freeresult (result); - - if (parse_res > 0) - return NSS_STATUS_SUCCESS; - - *herrnop = NETDB_INTERNAL; - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - } -} diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c deleted file mode 100644 index 175b9cbf42..0000000000 --- a/nis/nss_nisplus/nisplus-parser.c +++ /dev/null @@ -1,375 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include - -#include "nisplus-parser.h" - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - -#define NISOBJVAL(col, obj) \ - ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISOBJLEN(col, obj) \ - ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - - -int -_nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, - char *buffer, size_t buflen, int *errnop) -{ - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || NIS_RES_NUMOBJ (result) != 1 - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, "passwd_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 7) - return 0; - - nis_object *obj = NIS_RES_OBJECT (result); - char *first_unused = buffer; - size_t room_left = buflen; - size_t len; - - if (NISOBJLEN (0, obj) >= room_left) - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - strncpy (first_unused, NISOBJVAL (0, obj), NISOBJLEN (0, obj)); - first_unused[NISOBJLEN (0, obj)] = '\0'; - len = strlen (first_unused); - if (len == 0) /* No name ? Should never happen, database is corrupt */ - return 0; - pw->pw_name = first_unused; - room_left -= len + 1; - first_unused += len + 1; - - if (NISOBJLEN (1, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (1, obj), NISOBJLEN (1, obj)); - first_unused[NISOBJLEN (1, obj)] = '\0'; - pw->pw_passwd = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - char *numstr = NISOBJVAL (2, obj); - len = NISOBJLEN (2, obj); - if (len == 0 || numstr[len - 1] != '\0') - { - if (len >= room_left) - goto no_more_room; - - strncpy (first_unused, numstr, len); - first_unused[len] = '\0'; - numstr = first_unused; - } - if (numstr[0] == '\0') - /* If we don't have a uid, it's an invalid shadow entry. */ - return 0; - pw->pw_uid = strtoul (numstr, NULL, 10); - - numstr = NISOBJVAL (3, obj); - len = NISOBJLEN (3, obj); - if (len == 0 || numstr[len - 1] != '\0') - { - if (len >= room_left) - goto no_more_room; - - strncpy (first_unused, numstr, len); - first_unused[len] = '\0'; - numstr = first_unused; - } - if (numstr[0] == '\0') - /* If we don't have a gid, it's an invalid shadow entry. */ - return 0; - pw->pw_gid = strtoul (numstr, NULL, 10); - - if (NISOBJLEN(4, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (4, obj), NISOBJLEN (4, obj)); - first_unused[NISOBJLEN (4, obj)] = '\0'; - pw->pw_gecos = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - if (NISOBJLEN (5, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (5, obj), NISOBJLEN (5, obj)); - first_unused[NISOBJLEN (5, obj)] = '\0'; - pw->pw_dir = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - if (NISOBJLEN (6, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (6, obj), NISOBJLEN (6, obj)); - first_unused[NISOBJLEN (6, obj)] = '\0'; - pw->pw_shell = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - return 1; -} - - -int -_nss_nisplus_parse_grent (nis_result *result, struct group *gr, - char *buffer, size_t buflen, int *errnop) -{ - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of(NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)[0].EN_data.en_type, "group_tbl") != 0 - || NIS_RES_OBJECT (result)[0].EN_data.en_cols.en_cols_len < 4) - return 0; - - nis_object *obj = NIS_RES_OBJECT (result); - char *first_unused = buffer; - size_t room_left = buflen; - char *line; - int count; - size_t len; - - if (NISOBJLEN (0, obj) >= room_left) - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - strncpy (first_unused, NISOBJVAL (0, obj), NISOBJLEN (0, obj)); - first_unused[NISOBJLEN (0, obj)] = '\0'; - len = strlen (first_unused); - if (len == 0) /* group table is corrupt */ - return 0; - gr->gr_name = first_unused; - room_left -= len + 1; - first_unused += len + 1; - - if (NISOBJLEN (1, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (1, obj), NISOBJLEN (1, obj)); - first_unused[NISOBJLEN (1, obj)] = '\0'; - gr->gr_passwd = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - char *numstr = NISOBJVAL (2, obj); - len = NISOBJLEN (2, obj); - if (len == 0 || numstr[len - 1] != '\0') - { - if (len >= room_left) - goto no_more_room; - - strncpy (first_unused, numstr, len); - first_unused[len] = '\0'; - numstr = first_unused; - } - if (numstr[0] == '\0') - /* We should always have a gid. */ - return 0; - gr->gr_gid = strtoul (numstr, NULL, 10); - - if (NISOBJLEN (3, obj) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISOBJVAL (3, obj), NISOBJLEN (3, obj)); - first_unused[NISOBJLEN (3, obj)] = '\0'; - line = first_unused; - len = strlen (line); - room_left -= len + 1; - first_unused += len + 1; - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - gr->gr_mem = (char **) first_unused; - - count = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - room_left -= sizeof (char *); - gr->gr_mem[count++] = line; - - while (*line != '\0' && *line != ',' && !isspace (*line)) - ++line; - - if (*line == ',' || isspace (*line)) - { - int is = isspace (*line); - - *line++ = '\0'; - if (is) - while (*line != '\0' && (*line == ',' || isspace (*line))) - ++line; - } - } - if (room_left < sizeof (char *)) - goto no_more_room; - room_left -= sizeof (char *); - gr->gr_mem[count] = NULL; - - return 1; -} - - -int -_nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer; - size_t room_left = buflen; - size_t len; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || NIS_RES_NUMOBJ (result) != 1 - || __type_of(NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, "passwd_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 8) - return 0; - - if (NISENTRYLEN (0, 0, result) >= room_left) - { - /* The line is too long for our buffer. */ - no_more_room: - *errnop = ERANGE; - return -1; - } - - strncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - first_unused[NISENTRYLEN (0, 0, result)] = '\0'; - len = strlen (first_unused); - if (len == 0) - return 0; - sp->sp_namp = first_unused; - room_left -= len + 1; - first_unused += len + 1; - - if (NISENTRYLEN (0, 1, result) >= room_left) - goto no_more_room; - - strncpy (first_unused, NISENTRYVAL (0, 1, result), - NISENTRYLEN (0, 1, result)); - first_unused[NISENTRYLEN (0, 1, result)] = '\0'; - sp->sp_pwdp = first_unused; - len = strlen (first_unused); - room_left -= len + 1; - first_unused += len + 1; - - sp->sp_lstchg = sp->sp_min = sp->sp_max = sp->sp_warn = sp->sp_inact = - sp->sp_expire = -1; - sp->sp_flag = ~0ul; - - if (NISENTRYLEN (0, 7, result) > 0) - { - char *line = NISENTRYVAL (0, 7, result); - char *cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_lstchg = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_min = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_max = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_warn = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_inact = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 1; - *cp++ = '\0'; - if (*line) - sp->sp_expire = atol (line); - - line = cp; - if (line == NULL) - return 1; - if (*line) - sp->sp_flag = atol (line); - } - - return 1; -} diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c deleted file mode 100644 index fc1ac2e9d7..0000000000 --- a/nis/nss_nisplus/nisplus-proto.c +++ /dev/null @@ -1,441 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - - -static int -_nss_nisplus_parse_protoent (nis_result *result, struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer; - size_t room_left = buflen; - unsigned int i; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, - "protocols_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 3) - return 0; - - /* Generate the protocols entry format and use the normal parser */ - if (NISENTRYLEN (0, 0, result) + 1 > room_left) - { - no_more_room: - *errnop = ERANGE; - return -1; - } - strncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - first_unused[NISENTRYLEN (0, 0, result)] = '\0'; - proto->p_name = first_unused; - size_t len = strlen (first_unused) + 1; - room_left -= len; - first_unused += len; - - - proto->p_proto = atoi (NISENTRYVAL (0, 2, result)); - - /* XXX Rewrite at some point to allocate the array first and then - copy the strings. It wasteful to first concatenate the strings - to just split them again later. */ - char *line = first_unused; - for (i = 0; i < NIS_RES_NUMOBJ (result); ++i) - { - if (strcmp (NISENTRYVAL (i, 1, result), proto->p_name) != 0) - { - if (NISENTRYLEN (i, 1, result) + 2 > room_left) - goto no_more_room; - *first_unused++ = ' '; - first_unused = __stpncpy (first_unused, NISENTRYVAL (i, 1, result), - NISENTRYLEN (i, 1, result)); - room_left -= NISENTRYLEN (i, 1, result) + 1; - } - } - *first_unused++ = '\0'; - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust + sizeof (char *)) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - proto->p_aliases = (char **) first_unused; - - /* For the terminating NULL pointer. */ - room_left -= sizeof (char *); - - i = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - line++; - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - - room_left -= sizeof (char *); - proto->p_aliases[i++] = line; - - while (*line != '\0' && *line != ' ') - ++line; - - if (*line == ' ') - *line++ = '\0'; - } - proto->p_aliases[i] = NULL; - - return 1; -} - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "protocols.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_setprotoent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (tablename_val == NULL) - { - int err; - status = _nss_create_tablename (&err); - } - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endprotoent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer, - size_t buflen, int *errnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); - } - else - { - saved_res = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - nis_freeresult (saved_res); - return niserr2nss (result->status); - } - } - - parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, - buflen, errnop); - if (parse_res == -1) - { - nis_freeresult (result); - result = saved_res; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - if (saved_res) - nis_freeresult (saved_res); - } - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getprotoent_r (struct protoent *result, char *buffer, - size_t buflen, int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getprotoent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - return NSS_STATUS_NOTFOUND; - - char buf[strlen (name) + 10 + tablename_len]; - int olderr = errno; - - /* Search at first in the alias list, and use the correct name - for the next search */ - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - - if (result != NULL) - { - char *bufptr = buf; - - /* If we did not find it, try it as original name. But if the - database is correct, we should find it in the first case, too */ - if ((result->status != NIS_SUCCESS - && result->status != NIS_S_SUCCESS) - || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ - || strcmp (result->objects.objects_val->EN_data.en_type, - "protocols_tbl") != 0 - || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3) - snprintf (buf, sizeof (buf), "[cname=%s],%s", name, tablename_val); - else - { - /* We need to allocate a new buffer since there is no - guarantee the returned name has a length limit. */ - const char *entryval = NISENTRYVAL (0, 0, result); - size_t buflen = strlen (entryval) + 10 + tablename_len; - bufptr = alloca (buflen); - snprintf (bufptr, buflen, "[cname=%s],%s", - entryval, tablename_val); - } - - nis_freeresult (result); - result = nis_list (bufptr, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - } - - if (result == NULL) - { - __set_errno (ENOMEM); - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen, - errnop); - - nis_freeresult (result); - - if (parse_res < 1) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - char buf[12 + 3 * sizeof (number) + tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[number=%d],%s", number, tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL); - - if (result == NULL) - { - __set_errno (ENOMEM); - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen, - errnop); - - nis_freeresult (result); - - if (parse_res < 1) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c deleted file mode 100644 index b1834609a8..0000000000 --- a/nis/nss_nisplus/nisplus-pwd.c +++ /dev/null @@ -1,408 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" -#include "nisplus-parser.h" -#include -#include -#include - - -__libc_lock_define_initialized (static, lock) - -/* Connection information. */ -static ib_request *ibreq; -static directory_obj *dir; -static dir_binding bptr; -static char *tablepath; -static char *tableptr; -/* Cursor. */ -static netobj cursor; - - -nis_name pwd_tablename_val attribute_hidden; -size_t pwd_tablename_len attribute_hidden; - -enum nss_status -_nss_pwd_create_tablename (int *errnop) -{ - if (pwd_tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "passwd.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - pwd_tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - if (atomic_compare_and_exchange_bool_acq (&pwd_tablename_val, p, NULL)) - { - /* Another thread already installed the value. */ - free (p); - pwd_tablename_len = strlen (pwd_tablename_val); - } - } - - return NSS_STATUS_SUCCESS; -} - - -static void -internal_nisplus_endpwent (void) -{ - __nisbind_destroy (&bptr); - memset (&bptr, '\0', sizeof (bptr)); - - nis_free_directory (dir); - dir = NULL; - - nis_free_request (ibreq); - ibreq = NULL; - - xdr_free ((xdrproc_t) xdr_netobj, (char *) &cursor); - memset (&cursor, '\0', sizeof (cursor)); - - free (tablepath); - tableptr = tablepath = NULL; -} - - -static enum nss_status -internal_nisplus_setpwent (int *errnop) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - - if (pwd_tablename_val == NULL) - status = _nss_pwd_create_tablename (errnop); - - if (status == NSS_STATUS_SUCCESS) - { - ibreq = __create_ib_request (pwd_tablename_val, 0); - if (ibreq == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - nis_error retcode = __prepare_niscall (pwd_tablename_val, &dir, - &bptr, 0); - if (retcode != NIS_SUCCESS) - { - nis_free_request (ibreq); - ibreq = NULL; - status = niserr2nss (retcode); - } - } - - return status; -} - - -enum nss_status -_nss_nisplus_setpwent (int stayopen) -{ - enum nss_status status; - - __libc_lock_lock (lock); - - internal_nisplus_endpwent (); - - // XXX We need to be able to set errno. Pass in new parameter. - int err; - status = internal_nisplus_setpwent (&err); - - __libc_lock_unlock (lock); - - return status; -} - - -enum nss_status -_nss_nisplus_endpwent (void) -{ - __libc_lock_lock (lock); - - internal_nisplus_endpwent (); - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - - -static enum nss_status -internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen, - int *errnop) -{ - int parse_res = -1; - enum nss_status retval = NSS_STATUS_SUCCESS; - - /* Get the next entry until we found a correct one. */ - do - { - nis_error status; - nis_result result; - memset (&result, '\0', sizeof (result)); - - if (cursor.n_bytes == NULL) - { - if (ibreq == NULL) - { - retval = internal_nisplus_setpwent (errnop); - if (retval != NSS_STATUS_SUCCESS) - return retval; - } - - status = __do_niscall3 (&bptr, NIS_IBFIRST, - (xdrproc_t) _xdr_ib_request, - (caddr_t) ibreq, - (xdrproc_t) _xdr_nis_result, - (caddr_t) &result, - 0, NULL); - } - else - { - ibreq->ibr_cookie.n_bytes = cursor.n_bytes; - ibreq->ibr_cookie.n_len = cursor.n_len; - - status = __do_niscall3 (&bptr, NIS_IBNEXT, - (xdrproc_t) _xdr_ib_request, - (caddr_t) ibreq, - (xdrproc_t) _xdr_nis_result, - (caddr_t) &result, - 0, NULL); - - ibreq->ibr_cookie.n_bytes = NULL; - ibreq->ibr_cookie.n_len = 0; - } - - if (status != NIS_SUCCESS) - return niserr2nss (status); - - if (NIS_RES_STATUS (&result) == NIS_NOTFOUND) - { - /* No more entries on this server. This means we have to go - to the next server on the path. */ - status = __follow_path (&tablepath, &tableptr, ibreq, &bptr); - if (status != NIS_SUCCESS) - return niserr2nss (status); - - directory_obj *newdir = NULL; - dir_binding newbptr; - status = __prepare_niscall (ibreq->ibr_name, &newdir, &newbptr, 0); - if (status != NIS_SUCCESS) - return niserr2nss (status); - - nis_free_directory (dir); - dir = newdir; - __nisbind_destroy (&bptr); - bptr = newbptr; - - xdr_free ((xdrproc_t) xdr_netobj, (char *) &result.cookie); - result.cookie.n_bytes = NULL; - result.cookie.n_len = 0; - parse_res = 0; - goto next; - } - else if (NIS_RES_STATUS (&result) != NIS_SUCCESS) - return niserr2nss (NIS_RES_STATUS (&result)); - - parse_res = _nss_nisplus_parse_pwent (&result, pw, buffer, - buflen, errnop); - - if (__glibc_unlikely (parse_res == -1)) - { - *errnop = ERANGE; - retval = NSS_STATUS_TRYAGAIN; - goto freeres; - } - - next: - /* Free the old cursor. */ - xdr_free ((xdrproc_t) xdr_netobj, (char *) &cursor); - /* Remember the new one. */ - cursor.n_bytes = result.cookie.n_bytes; - cursor.n_len = result.cookie.n_len; - /* Free the result structure. NB: we do not remove the cookie. */ - result.cookie.n_bytes = NULL; - result.cookie.n_len = 0; - freeres: - xdr_free ((xdrproc_t) _xdr_nis_result, (char *) &result); - memset (&result, '\0', sizeof (result)); - } - while (!parse_res); - - return retval; -} - -enum nss_status -_nss_nisplus_getpwent_r (struct passwd *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getpwent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getpwnam_r (const char *name, struct passwd *pw, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (pwd_tablename_val == NULL) - { - enum nss_status status = _nss_pwd_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_UNAVAIL; - } - - nis_result *result; - char buf[strlen (name) + 9 + pwd_tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[name=%s],%s", name, pwd_tablename_val); - - result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen, errnop); - - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw, - char *buffer, size_t buflen, int *errnop) -{ - if (pwd_tablename_val == NULL) - { - enum nss_status status = _nss_pwd_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - int parse_res; - nis_result *result; - char buf[8 + 3 * sizeof (unsigned long int) + pwd_tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[uid=%lu],%s", - (unsigned long int) uid, pwd_tablename_val); - - result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen, errnop); - - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-rpc.c b/nis/nss_nisplus/nisplus-rpc.c deleted file mode 100644 index 4a55ee1b0e..0000000000 --- a/nis/nss_nisplus/nisplus-rpc.c +++ /dev/null @@ -1,444 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - - -static int -_nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer; - size_t room_left = buflen; - unsigned int i; - char *line; - - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)[0].EN_data.en_type, "rpc_tbl") != 0 - || NIS_RES_OBJECT (result)[0].EN_data.en_cols.en_cols_len < 3) - return 0; - - if (NISENTRYLEN (0, 0, result) >= room_left) - { - no_more_room: - *errnop = ERANGE; - return -1; - } - strncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - first_unused[NISENTRYLEN (0, 0, result)] = '\0'; - rpc->r_name = first_unused; - size_t len = strlen (first_unused) + 1; - room_left -= len; - first_unused += len; - - rpc->r_number = atoi (NISENTRYVAL (0, 2, result)); - - /* XXX Rewrite at some point to allocate the array first and then - copy the strings. It wasteful to first concatenate the strings - to just split them again later. */ - line = first_unused; - for (i = 0; i < NIS_RES_NUMOBJ (result); ++i) - { - if (strcmp (NISENTRYVAL (i, 1, result), rpc->r_name) != 0) - { - if (NISENTRYLEN (i, 1, result) + 2 > room_left) - goto no_more_room; - *first_unused++ = ' '; - first_unused = __stpncpy (first_unused, NISENTRYVAL (i, 1, result), - NISENTRYLEN (i, 1, result)); - room_left -= NISENTRYLEN (i, 1, result) + 1; - } - } - *first_unused++ = '\0'; - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust + sizeof (char *)) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - rpc->r_aliases = (char **) first_unused; - - /* For the terminating NULL pointer. */ - room_left -= sizeof (char *); - - i = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - - room_left -= sizeof (char *); - rpc->r_aliases[i++] = line; - - while (*line != '\0' && *line != ' ') - ++line; - - if (*line == ' ') - *line++ = '\0'; - } - rpc->r_aliases[i] = NULL; - - return 1; -} - - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "rpc.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nisplus_setrpcent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (tablename_val == NULL) - { - int err; - status = _nss_create_tablename (&err); - } - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endrpcent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getrpcent_r (struct rpcent *rpc, char *buffer, - size_t buflen, int *errnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); - } - else - { - saved_res = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - nis_freeresult (saved_res); - return niserr2nss (result->status); - } - } - - parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, - buflen, errnop); - if (parse_res == -1) - { - nis_freeresult (result); - result = saved_res; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - if (saved_res) - nis_freeresult (saved_res); - } - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getrpcent_r (struct rpcent *result, char *buffer, - size_t buflen, int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getrpcent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getrpcbyname_r (const char *name, struct rpcent *rpc, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - return NSS_STATUS_NOTFOUND; - - char buf[strlen (name) + 10 + tablename_len]; - int olderr = errno; - - /* Search at first in the alias list, and use the correct name - for the next search */ - snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val); - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - - if (result != NULL) - { - char *bufptr = buf; - - /* If we did not find it, try it as original name. But if the - database is correct, we should find it in the first case, too */ - if ((result->status != NIS_SUCCESS - && result->status != NIS_S_SUCCESS) - || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ - || strcmp (result->objects.objects_val->EN_data.en_type, - "rpc_tbl") != 0 - || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3) - snprintf (buf, sizeof (buf), "[cname=%s],%s", name, tablename_val); - else - { - /* We need to allocate a new buffer since there is no - guarantee the returned name has a length limit. */ - const char *entryval = NISENTRYVAL (0, 0, result); - size_t buflen = strlen (entryval) + 10 + tablename_len; - bufptr = alloca (buflen); - snprintf (bufptr, buflen, "[cname=%s],%s", - entryval, tablename_val); - } - - nis_freeresult (result); - result = nis_list (bufptr, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - } - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen, - errnop); - - nis_freeresult (result); - - if (parse_res < 1) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getrpcbynumber_r (const int number, struct rpcent *rpc, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - char buf[12 + 3 * sizeof (number) + tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[number=%d],%s", number, tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH | USE_DGRAM, - NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen, - errnop); - - nis_freeresult (result); - - if (parse_res < 1) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-service.c b/nis/nss_nisplus/nisplus-service.c deleted file mode 100644 index ef4d996ab2..0000000000 --- a/nis/nss_nisplus/nisplus-service.c +++ /dev/null @@ -1,461 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" - -__libc_lock_define_initialized (static, lock); - -static nis_result *result; -static nis_name tablename_val; -static u_long tablename_len; - -#define NISENTRYVAL(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val) - -#define NISENTRYLEN(idx, col, res) \ - (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len) - - -static int -_nss_nisplus_parse_servent (nis_result *result, struct servent *serv, - char *buffer, size_t buflen, int *errnop) -{ - char *first_unused = buffer; - size_t room_left = buflen; - - if (result == NULL) - return 0; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, "services_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 4) - return 0; - - if (NISENTRYLEN (0, 0, result) >= room_left) - { - no_more_room: - *errnop = ERANGE; - return -1; - } - strncpy (first_unused, NISENTRYVAL (0, 0, result), - NISENTRYLEN (0, 0, result)); - first_unused[NISENTRYLEN (0, 0, result)] = '\0'; - serv->s_name = first_unused; - size_t len = strlen (first_unused) + 1; - room_left -= len; - first_unused += len; - - if (NISENTRYLEN (0, 2, result) >= room_left) - goto no_more_room; - strncpy (first_unused, NISENTRYVAL (0, 2, result), - NISENTRYLEN (0, 2, result)); - first_unused[NISENTRYLEN (0, 2, result)] = '\0'; - serv->s_proto = first_unused; - len = strlen (first_unused) + 1; - room_left -= len; - first_unused += len; - - serv->s_port = htons (atoi (NISENTRYVAL (0, 3, result))); - - /* XXX Rewrite at some point to allocate the array first and then - copy the strings. It wasteful to first concatenate the strings - to just split them again later. */ - char *line = first_unused; - for (unsigned int i = 0; i < NIS_RES_NUMOBJ (result); ++i) - { - if (strcmp (NISENTRYVAL (i, 1, result), serv->s_name) != 0) - { - if (NISENTRYLEN (i, 1, result) + 2 > room_left) - goto no_more_room; - *first_unused++ = ' '; - first_unused = __stpncpy (first_unused, NISENTRYVAL (i, 1, result), - NISENTRYLEN (i, 1, result)); - room_left -= NISENTRYLEN (i, 1, result) + 1; - } - } - *first_unused++ = '\0'; - - /* Adjust the pointer so it is aligned for - storing pointers. */ - size_t adjust = ((__alignof__ (char *) - - (first_unused - (char *) 0) % __alignof__ (char *)) - % __alignof__ (char *)); - if (room_left < adjust + sizeof (char *)) - goto no_more_room; - first_unused += adjust; - room_left -= adjust; - serv->s_aliases = (char **) first_unused; - - /* For the terminating NULL pointer. */ - room_left -= (sizeof (char *)); - - unsigned int i = 0; - while (*line != '\0') - { - /* Skip leading blanks. */ - while (isspace (*line)) - ++line; - - if (*line == '\0') - break; - - if (room_left < sizeof (char *)) - goto no_more_room; - - room_left -= sizeof (char *); - serv->s_aliases[i++] = line; - - while (*line != '\0' && *line != ' ') - ++line; - - if (*line == ' ') - *line++ = '\0'; - } - serv->s_aliases[i] = NULL; - - return 1; -} - - -static enum nss_status -_nss_create_tablename (int *errnop) -{ - if (tablename_val == NULL) - { - const char *local_dir = nis_local_directory (); - size_t local_dir_len = strlen (local_dir); - static const char prefix[] = "services.org_dir."; - - char *p = malloc (sizeof (prefix) + local_dir_len); - if (p == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - - memcpy (__stpcpy (p, prefix), local_dir, local_dir_len + 1); - - tablename_len = sizeof (prefix) - 1 + local_dir_len; - - atomic_write_barrier (); - - tablename_val = p; - } - - return NSS_STATUS_SUCCESS; -} - - -enum nss_status -_nss_nisplus_setservent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - int err; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (tablename_val == NULL) - status = _nss_create_tablename (&err); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endservent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getservent_r (struct servent *serv, char *buffer, - size_t buflen, int *errnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - if (tablename_val == NULL) - { - enum nss_status status = _nss_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); - } - else - { - saved_res = result; - result = nis_next_entry (tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - nis_freeresult (saved_res); - return niserr2nss (result->status); - } - } - - parse_res = _nss_nisplus_parse_servent (result, serv, buffer, - buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - { - nis_freeresult (result); - result = saved_res; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - if (saved_res) - nis_freeresult (saved_res); - } - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getservent_r (struct servent *result, char *buffer, - size_t buflen, int *errnop) -{ - __libc_lock_lock (lock); - - int status = internal_nisplus_getservent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getservbyname_r (const char *name, const char *protocol, - struct servent *serv, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL || protocol == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_NOTFOUND; - } - - size_t protocol_len = strlen (protocol); - char buf[strlen (name) + protocol_len + 17 + tablename_len]; - int olderr = errno; - - /* Search at first in the alias list, and use the correct name - for the next search */ - snprintf (buf, sizeof (buf), "[name=%s,proto=%s],%s", name, protocol, - tablename_val); - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - - if (result != NULL) - { - char *bufptr = buf; - - /* If we did not find it, try it as original name. But if the - database is correct, we should find it in the first case, too */ - if ((result->status != NIS_SUCCESS - && result->status != NIS_S_SUCCESS) - || __type_of (NIS_RES_OBJECT (result)) != NIS_ENTRY_OBJ - || strcmp (NIS_RES_OBJECT (result)->EN_data.en_type, - "services_tbl") != 0 - || NIS_RES_OBJECT (result)->EN_data.en_cols.en_cols_len < 4) - snprintf (buf, sizeof (buf), "[cname=%s,proto=%s],%s", name, protocol, - tablename_val); - else - { - /* We need to allocate a new buffer since there is no - guarantee the returned name has a length limit. */ - const char *entryval = NISENTRYVAL(0, 0, result); - size_t buflen = (strlen (entryval) + protocol_len + 17 - + tablename_len); - bufptr = alloca (buflen); - snprintf (bufptr, buflen, "[cname=%s,proto=%s],%s", - entryval, protocol, tablename_val); - } - - nis_freeresult (result); - result = nis_list (bufptr, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - } - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen, - errnop); - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getservbyport_r (const int number, const char *protocol, - struct servent *serv, - char *buffer, size_t buflen, int *errnop) -{ - if (tablename_val == NULL) - { - __libc_lock_lock (lock); - - enum nss_status status = _nss_create_tablename (errnop); - - __libc_lock_unlock (lock); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (protocol == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_NOTFOUND; - } - - char buf[17 + 3 * sizeof (int) + strlen (protocol) + tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[port=%d,proto=%s],%s", - number, protocol, tablename_val); - - nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, - NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - int parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen, - errnop); - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c deleted file mode 100644 index 8ff71a9c90..0000000000 --- a/nis/nss_nisplus/nisplus-spwd.c +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 - . */ - -#include -#include -#include -#include -#include -#include - -#include "nss-nisplus.h" -#include "nisplus-parser.h" - -__libc_lock_define_initialized (static, lock) - -static nis_result *result; - -/* Defined in nisplus-pwd.c. */ -extern nis_name pwd_tablename_val attribute_hidden; -extern size_t pwd_tablename_len attribute_hidden; -extern enum nss_status _nss_pwd_create_tablename (int *errnop); - - -enum nss_status -_nss_nisplus_setspent (int stayopen) -{ - enum nss_status status = NSS_STATUS_SUCCESS; - int err; - - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - if (pwd_tablename_val == NULL) - status = _nss_pwd_create_tablename (&err); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_endspent (void) -{ - __libc_lock_lock (lock); - - if (result != NULL) - { - nis_freeresult (result); - result = NULL; - } - - __libc_lock_unlock (lock); - - return NSS_STATUS_SUCCESS; -} - -static enum nss_status -internal_nisplus_getspent_r (struct spwd *sp, char *buffer, size_t buflen, - int *errnop) -{ - int parse_res; - - /* Get the next entry until we found a correct one. */ - do - { - nis_result *saved_res; - - if (result == NULL) - { - saved_res = NULL; - - if (pwd_tablename_val == NULL) - { - enum nss_status status = _nss_pwd_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - result = nis_first_entry (pwd_tablename_val); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); - } - else - { - saved_res = result; - result = nis_next_entry (pwd_tablename_val, &result->cookie); - if (result == NULL) - { - *errnop = errno; - return NSS_STATUS_TRYAGAIN; - } - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - { - nis_freeresult (saved_res); - return niserr2nss (result->status); - } - } - - parse_res = _nss_nisplus_parse_spent (result, sp, buffer, - buflen, errnop); - if (__glibc_unlikely (parse_res == -1)) - { - nis_freeresult (result); - result = saved_res; - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - - if (saved_res != NULL) - nis_freeresult (saved_res); - } - while (!parse_res); - - return NSS_STATUS_SUCCESS; -} - -enum nss_status -_nss_nisplus_getspent_r (struct spwd *result, char *buffer, size_t buflen, - int *errnop) -{ - int status; - - __libc_lock_lock (lock); - - status = internal_nisplus_getspent_r (result, buffer, buflen, errnop); - - __libc_lock_unlock (lock); - - return status; -} - -enum nss_status -_nss_nisplus_getspnam_r (const char *name, struct spwd *sp, - char *buffer, size_t buflen, int *errnop) -{ - int parse_res; - - if (pwd_tablename_val == NULL) - { - enum nss_status status = _nss_pwd_create_tablename (errnop); - - if (status != NSS_STATUS_SUCCESS) - return status; - } - - if (name == NULL) - { - *errnop = EINVAL; - return NSS_STATUS_NOTFOUND; - } - - nis_result *result; - char buf[strlen (name) + 9 + pwd_tablename_len]; - int olderr = errno; - - snprintf (buf, sizeof (buf), "[name=%s],%s", name, pwd_tablename_val); - - result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS | USE_DGRAM, NULL, NULL); - - if (result == NULL) - { - *errnop = ENOMEM; - return NSS_STATUS_TRYAGAIN; - } - - if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) - { - enum nss_status status = niserr2nss (result->status); - - __set_errno (olderr); - - nis_freeresult (result); - return status; - } - - parse_res = _nss_nisplus_parse_spent (result, sp, buffer, buflen, errnop); - nis_freeresult (result); - - if (__glibc_unlikely (parse_res < 1)) - { - if (parse_res == -1) - { - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } - else - { - __set_errno (olderr); - return NSS_STATUS_NOTFOUND; - } - } - - return NSS_STATUS_SUCCESS; -} diff --git a/nis/rpcsvc/nis.x b/nis/rpcsvc/nis.x deleted file mode 100644 index e318af29a6..0000000000 --- a/nis/rpcsvc/nis.x +++ /dev/null @@ -1,474 +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. -% */ - -#ifdef RPC_HDR -%/* -% * nis.h -% * -% * This file is the main include file for NIS clients. It contains -% * both the client library function defines and the various data -% * structures used by the NIS service. It includes the file nis_tags.h -% * which defines the tag values. This allows the tags to change without -% * having to change the nis.x file. -% * -% * NOTE : DO NOT EDIT THIS FILE! It is automatically generated when -% * rpcgen is run on the nis.x file. Note that there is a -% * simple sed script to remove some unneeded lines. (See the -% * Makefile target nis.h) -% * -% */ -%#include -#endif - -/* This gets stuffed into the source files. */ -#if RPC_HDR -%#include -#endif - -/* Include the RPC Language description of NIS objects */ -#include "nis_object.x" - -/* Errors that can be returned by the service */ -enum nis_error { - NIS_SUCCESS = 0, /* A-ok, let's rock n roll */ - NIS_S_SUCCESS = 1, /* Name found (maybe) */ - NIS_NOTFOUND = 2, /* Name definitely not found */ - NIS_S_NOTFOUND = 3, /* Name maybe not found */ - NIS_CACHEEXPIRED = 4, /* Name exists but cache out of date */ - NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */ - NIS_UNKNOWNOBJ = 6, /* Object type is bogus */ - NIS_TRYAGAIN = 7, /* I'm busy, call back */ - NIS_SYSTEMERROR = 8, /* Generic system error */ - NIS_CHAINBROKEN = 9, /* First/Next warning */ - NIS_PERMISSION = 10, /* Not enough permission to access */ - NIS_NOTOWNER = 11, /* You don't own it, sorry */ - NIS_NOT_ME = 12, /* I don't serve this name */ - NIS_NOMEMORY = 13, /* Outta VM! Help! */ - NIS_NAMEEXISTS = 14, /* Can't create over another name */ - NIS_NOTMASTER = 15, /* I'm justa secondaray, don't ask me */ - NIS_INVALIDOBJ = 16, /* Object is broken somehow */ - NIS_BADNAME = 17, /* Unparsable name */ - NIS_NOCALLBACK = 18, /* Couldn't talk to call back proc */ - NIS_CBRESULTS = 19, /* Results being called back to you */ - NIS_NOSUCHNAME = 20, /* Name unknown */ - NIS_NOTUNIQUE = 21, /* Value is not uniques (entry) */ - NIS_IBMODERROR = 22, /* Inf. Base. Modify error. */ - NIS_NOSUCHTABLE = 23, /* Name for table was wrong */ - NIS_TYPEMISMATCH = 24, /* Entry and table type mismatch */ - NIS_LINKNAMEERROR = 25, /* Link points to bogus name */ - NIS_PARTIAL = 26, /* Partial success, found table */ - NIS_TOOMANYATTRS = 27, /* Too many attributes */ - NIS_RPCERROR = 28, /* RPC error encountered */ - NIS_BADATTRIBUTE = 29, /* Bad or invalid attribute */ - NIS_NOTSEARCHABLE = 30, /* Non-searchable object searched */ - NIS_CBERROR = 31, /* Error during callback (svc crash) */ - NIS_FOREIGNNS = 32, /* Foreign Namespace */ - NIS_BADOBJECT = 33, /* Malformed object structure */ - NIS_NOTSAMEOBJ = 34, /* Object swapped during deletion */ - NIS_MODFAIL = 35, /* Failure during a Modify. */ - NIS_BADREQUEST = 36, /* Illegal query for table */ - NIS_NOTEMPTY = 37, /* Attempt to remove a non-empty tbl */ - NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */ - NIS_RESYNC = 39, /* Transaction log too far out of date */ - NIS_FAIL = 40, /* NIS operation failed. */ - NIS_UNAVAIL = 41, /* NIS+ service is unavailable (client) */ - NIS_RES2BIG = 42, /* NIS+ result too big for datagram */ - NIS_SRVAUTH = 43, /* NIS+ server wasn't authenticated. */ - NIS_CLNTAUTH = 44, /* NIS+ Client wasn't authenticated. */ - NIS_NOFILESPACE = 45, /* NIS+ server ran out of disk space */ - NIS_NOPROC = 46, /* NIS+ server couldn't create new proc */ - NIS_DUMPLATER = 47 /* NIS+ server already has dump child */ -}; - - -/* - * Structure definitions for the parameters and results of the actual - * NIS RPC calls. - * - * This is the standard result (in the protocol) of most of the nis - * requests. - */ - -struct nis_result { - nis_error status; /* Status of the response */ - nis_object objects<>; /* objects found */ - netobj cookie; /* Cookie Data */ - uint32_t zticks; /* server ticks */ - uint32_t dticks; /* DBM ticks. */ - uint32_t aticks; /* Cache (accel) ticks */ - uint32_t cticks; /* Client ticks */ -}; - -/* - * A Name Service request - * This request is used to access the name space, ns_name is the name - * of the object within the namespace and the object is it's value, for - * add/modify, a copy of the original for remove. - */ - -struct ns_request { - nis_name ns_name; /* Name in the NIS name space */ - nis_object ns_object<1>; /* Optional Object (add/remove) */ -}; - -/* - * An information base request - * This request includes the NIS name of the table we wish to search, the - * search criteria in the form of attribute/value pairs and an optional - * callback program number. If the callback program number is provided - * the server will send back objects one at a time, otherwise it will - * return them all in the response. - */ - -struct ib_request { - nis_name ibr_name; /* The name of the Table */ - nis_attr ibr_srch<>; /* The search critereia */ - uint32_t ibr_flags; /* Optional flags */ - nis_object ibr_obj<1>; /* optional object (add/modify) */ - nis_server ibr_cbhost<1>; /* Optional callback info */ - u_int ibr_bufsize; /* Optional first/next bufsize */ - netobj ibr_cookie; /* The first/next cookie */ -}; - -/* - * This argument to the PING call notifies the replicas that something in - * a directory has changed and this is it's timestamp. The replica will use - * the timestamp to determine if its resync operation was successful. - */ -struct ping_args { - nis_name dir; /* Directory that had the change */ - uint32_t stamp; /* timestamp of the transaction */ -}; - -/* - * These are the type of entries that are stored in the transaction log, - * note that modifications will appear as two entries, for names, they have - * a "OLD" entry followed by a "NEW" entry. For entries in tables, there - * is a remove followed by an add. It is done this way so that we can read - * the log backwards to back out transactions and forwards to propogate - * updated. - */ -enum log_entry_t { - LOG_NOP = 0, - ADD_NAME = 1, /* Name Added to name space */ - REM_NAME = 2, /* Name removed from name space */ - MOD_NAME_OLD = 3, /* Name was modified in the name space */ - MOD_NAME_NEW = 4, /* Name was modified in the name space */ - ADD_IBASE = 5, /* Entry added to information base */ - REM_IBASE = 6, /* Entry removed from information base */ - MOD_IBASE = 7, /* Entry was modified in information base */ - UPD_STAMP = 8 /* Update timestamp (used as fenceposts) */ -}; - -/* - * This result is returned from the name service when it is requested to - * dump logged entries from its transaction log. Information base updates - * will have the name of the information base in the le_name field and - * a canonical set of attribute/value pairs to fully specify the entry's - * 'name'. - */ -struct log_entry { - uint32_t le_time; /* Time in seconds */ - log_entry_t le_type; /* Type of log entry */ - nis_name le_princp; /* Principal making the change */ - nis_name le_name; /* Name of table/dir involved */ - nis_attr le_attrs<>; /* List of AV pairs. */ - nis_object le_object; /* Actual object value */ -}; - -struct log_result { - nis_error lr_status; /* The status itself */ - netobj lr_cookie; /* Used by the dump callback */ - log_entry lr_entries<>; /* zero or more entries */ -}; - -struct cp_result { - nis_error cp_status; /* Status of the checkpoint */ - uint32_t cp_zticks; /* Service 'ticks' */ - uint32_t cp_dticks; /* Database 'ticks' */ -}; - -/* - * This structure defines a generic NIS tag list. The taglist contains - * zero or tags, each of which is a type and a value. (u_int). - * These are used to report statistics (see tag definitions below) - * and to set or reset state variables. - */ -struct nis_tag { - uint32_t tag_type; /* Statistic tag (may vary) */ - string tag_val<>; /* Statistic value may also vary */ -}; - -struct nis_taglist { - nis_tag tags<>; /* List of tags */ -}; - -struct dump_args { - nis_name da_dir; /* Directory to dump */ - uint32_t da_time; /* From this timestamp */ - nis_server da_cbhost<1>; /* Callback to use. */ -}; - -struct fd_args { - nis_name dir_name; /* The directory we're looking for */ - nis_name requester; /* Host principal name for signature */ -}; - -struct fd_result { - nis_error status; /* Status returned by function */ - nis_name source; /* Source of this answer */ - opaque dir_data<>; /* Directory Data (XDR'ed) */ - opaque signature<>; /* Signature of the source */ -}; - -%/* -% * Structures used for server binding. -% */ -struct nis_bound_endpoint { - endpoint ep; - int generation; - int rank; - uint32_t flags; - int hostnum; - int epnum; - nis_name uaddr; - endpoint cbep; -}; -typedef struct nis_bound_endpoint nis_bound_endpoint; - -struct nis_bound_directory { - int generation; - int min_rank; /* minimum rank of bound endpoints */ - int optimal_rank; /* best possible rank of all endpoints */ - directory_obj dobj; - nis_bound_endpoint BEP<>; -}; -typedef struct nis_bound_directory nis_bound_directory; -%#define bep_len BEP.BEP_len -%#define bep_val BEP.BEP_val - -struct nis_active_endpoint { - endpoint ep; - nis_name hostname; - int rank; - int uaddr_generation; - nis_name uaddr; - int cbep_generation; - endpoint cbep; -}; -typedef struct nis_active_endpoint nis_active_endpoint; - -%/* defines for nis_bound_endpoint.flags */ -%#define NIS_BOUND 0x1 -%#define NIS_TRANSIENT_ERRORS 0x2 - -program NIS_PROG { - - /* RPC Language description of the NIS+ protocol */ - version NIS_VERSION { - /* The name service functions */ - nis_result NIS_LOOKUP(ns_request) = 1; - nis_result NIS_ADD(ns_request) = 2; - nis_result NIS_MODIFY(ns_request) = 3; - nis_result NIS_REMOVE(ns_request) = 4; - - /* The information base functions */ - nis_result NIS_IBLIST(ib_request) = 5; - nis_result NIS_IBADD(ib_request) = 6; - nis_result NIS_IBMODIFY(ib_request) = 7; - nis_result NIS_IBREMOVE(ib_request) = 8; - nis_result NIS_IBFIRST(ib_request) = 9; - nis_result NIS_IBNEXT(ib_request) = 10; - - /* NIS Administrative functions */ - fd_result NIS_FINDDIRECTORY(fd_args) = 12; - - /* If fetch and optionally reset statistics */ - nis_taglist NIS_STATUS(nis_taglist) = 14; - - /* Dump changes to directory since time in da_time */ - log_result NIS_DUMPLOG(dump_args) = 15; - - /* Dump contents of directory named */ - log_result NIS_DUMP(dump_args) = 16; - - /* Check status of callback thread */ - bool NIS_CALLBACK(netobj) = 17; - - /* Return last update time for named dir */ - uint32_t NIS_CPTIME(nis_name) = 18; - - /* Checkpoint directory or table named */ - cp_result NIS_CHECKPOINT(nis_name) = 19; - - /* Send 'status changed' ping to replicates */ - void NIS_PING(ping_args) = 20; - - /* Modify server behaviour (such as debugging) */ - nis_taglist NIS_SERVSTATE(nis_taglist) = 21; - - /* Create a Directory */ - nis_error NIS_MKDIR(nis_name) = 22; - - /* Remove a Directory */ - nis_error NIS_RMDIR(nis_name) = 23; - - /* Update public keys of a directory object */ - nis_error NIS_UPDKEYS(nis_name) = 24; - } = 3; -} = 100300; - -/* - * Included below are the defines that become part of nis.h, - * they are technically not part of the protocol, but do define - * key aspects of the implementation and are therefore useful - * in building a conforming server or client. - */ -#if RPC_HDR -%/* -% * Generic "hash" datastructures, used by all types of hashed data. -% */ -%struct nis_hash_data { -% nis_name name; /* NIS name of hashed item */ -% int keychain; /* It's hash key (for pop) */ -% struct nis_hash_data *next; /* Hash collision pointer */ -% struct nis_hash_data *prv_item; /* A serial, doubly linked list */ -% struct nis_hash_data *nxt_item; /* of items in the hash table */ -%}; -%typedef struct nis_hash_data NIS_HASH_ITEM; -% -%struct nis_hash_table { -% NIS_HASH_ITEM *keys[64]; /* A hash table of items */ -% NIS_HASH_ITEM *first; /* The first "item" in serial list */ -%}; -%typedef struct nis_hash_table NIS_HASH_TABLE; -% -%/* Structure for storing dynamically allocated static data */ -%struct nis_sdata { -% void *buf; /* Memory allocation pointer */ -% u_int size; /* Buffer size */ -%}; -% -%/* Generic client creating flags */ -%#define ZMH_VC 1 -%#define ZMH_DG 2 -%#define ZMH_AUTH 4 -% -%/* Testing Access rights for objects */ -% -%#define NIS_READ_ACC 1 -%#define NIS_MODIFY_ACC 2 -%#define NIS_CREATE_ACC 4 -%#define NIS_DESTROY_ACC 8 -%/* Test macros. a == access rights, m == desired rights. */ -%#define NIS_WORLD(a, m) (((a) & (m)) != 0) -%#define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) -%#define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) -%#define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) -%/* -% * EOL Alert - The following non-prefixed test macros are -% * here for backward compatability, and will be not be present -% * in future releases - use the NIS_*() macros above. -% */ -%#define WORLD(a, m) (((a) & (m)) != 0) -%#define GROUP(a, m) (((a) & ((m) << 8)) != 0) -%#define OWNER(a, m) (((a) & ((m) << 16)) != 0) -%#define NOBODY(a, m) (((a) & ((m) << 24)) != 0) -% -%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) -%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) -%#define WORLD_DEFAULT (NIS_READ_ACC) -%#define GROUP_DEFAULT (NIS_READ_ACC << 8) -%#define OWNER_DEFAULT ((NIS_READ_ACC +\ - NIS_MODIFY_ACC +\ - NIS_CREATE_ACC +\ - NIS_DESTROY_ACC) << 16) -%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) -% -%/* Result manipulation defines ... */ -%#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) -%#define NIS_RES_OBJECT(x) ((x)->objects.objects_val) -%#define NIS_RES_COOKIE(x) ((x)->cookie) -%#define NIS_RES_STATUS(x) ((x)->status) -% -%/* These defines make getting at the variant part of the object easier. */ -%#define TA_data zo_data.objdata_u.ta_data -%#define EN_data zo_data.objdata_u.en_data -%#define DI_data zo_data.objdata_u.di_data -%#define LI_data zo_data.objdata_u.li_data -%#define GR_data zo_data.objdata_u.gr_data -% -%#define __type_of(o) ((o)->zo_data.zo_type) -% -%/* Declarations for the internal subroutines in nislib.c */ -%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; -%typedef enum name_pos name_pos; -% -%/* -% * Defines for getting at column data in entry objects. Because RPCGEN -% * generates some rather wordy structures, we create some defines that -% * collapse the needed keystrokes to access a particular value using -% * these definitions they take an nis_object *, and an int and return -% * a u_char * for Value, and an int for length. -% */ -%#define ENTRY_VAL(obj, col) \ -% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val -%#define ENTRY_LEN(obj, col) \ -% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len -% -% -% -%#ifdef __cplusplus -%} -%#endif -% -%/* Prototypes, and extern declarations for the NIS library functions. */ -%#include -%#endif /* __NIS_RPCGEN_H */ -%/* EDIT_START */ -% -%/* -% * nis_3.h -% * -% * This file contains definitions that are only of interest to the actual -% * service daemon and client stubs. Normal users of NIS will not include -% * this file. -% * -% * NOTE : This include file is automatically created by a combination -% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead -% * and then remake this file. -% */ -%#ifndef __nis_3_h -%#define __nis_3_h -%#ifdef __cplusplus -%extern "C" { -%#endif -#endif diff --git a/nis/rpcsvc/nis_callback.x b/nis/rpcsvc/nis_callback.x deleted file mode 100644 index 0fdca9eeec..0000000000 --- a/nis/rpcsvc/nis_callback.x +++ /dev/null @@ -1,63 +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. -% */ - -/* - * nis_callback.x - */ - -%#pragma ident "@(#)nis_callback.x 1.7 94/05/03" - -/* - * "@(#)zns_cback.x 1.2 90/09/10" - * - * RPCL description of the Callback Service. - */ - -#ifdef RPC_HDR -%#include -#endif -#ifdef RPC_XDR -%#include "nis_clnt.h" -#endif - -typedef nis_object *obj_p; - -struct cback_data { - obj_p entries<>; /* List of objects */ -}; - -program CB_PROG { - version CB_VERS { - bool CBPROC_RECEIVE(cback_data) = 1; - void CBPROC_FINISH(void) = 2; - void CBPROC_ERROR(nis_error) = 3; - } = 1; -} = 100302; diff --git a/nis/rpcsvc/nis_object.x b/nis/rpcsvc/nis_object.x deleted file mode 100644 index 774b38fa9c..0000000000 --- a/nis/rpcsvc/nis_object.x +++ /dev/null @@ -1,328 +0,0 @@ -/* - * nis_object.x - * - * 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. - */ - -%#pragma ident "@(#)nis_object.x 1.12 97/11/19" - -#if RPC_HDR -% -%#ifndef __nis_object_h -%#define __nis_object_h -% -#endif -/* - * This file defines the format for a NIS object in RPC language. - * It is included by the main .x file and the database access protocol - * file. It is common because both of them need to deal with the same - * type of object. Generating the actual code though is a bit messy because - * the nis.x file and the nis_dba.x file will generate xdr routines to - * encode/decode objects when only one set is needed. Such is life when - * one is using rpcgen. - * - * Note, the protocol doesn't specify any limits on such things as - * maximum name length, number of attributes, etc. These are enforced - * by the database backend. When you hit them you will no. Also see - * the db_getlimits() function for fetching the limit values. - * - */ - -/* Some manifest constants, chosen to maximize flexibility without - * plugging the wire full of data. - */ -const NIS_MAXSTRINGLEN = 255; -const NIS_MAXNAMELEN = 1024; -const NIS_MAXATTRNAME = 32; -const NIS_MAXATTRVAL = 2048; -const NIS_MAXCOLUMNS = 64; -const NIS_MAXATTR = 16; -const NIS_MAXPATH = 1024; -const NIS_MAXREPLICAS = 128; -const NIS_MAXLINKS = 16; - -const NIS_PK_NONE = 0; /* no public key (unix/sys auth) */ -const NIS_PK_DH = 1; /* Public key is Diffie-Hellman type */ -const NIS_PK_RSA = 2; /* Public key if RSA type */ -const NIS_PK_KERB = 3; /* Use kerberos style authentication */ -const NIS_PK_DHEXT = 4; /* Extended Diffie-Hellman for RPC-GSS */ - -/* - * The fundamental name type of NIS. The name may consist of two parts, - * the first being the fully qualified name, and the second being an - * optional set of attribute/value pairs. - */ -struct nis_attr { - string zattr_ndx<>; /* name of the index */ - opaque zattr_val<>; /* Value for the attribute. */ -}; - -typedef string nis_name<>; /* The NIS name itself. */ - -/* NIS object types are defined by the following enumeration. The numbers - * they use are based on the following scheme : - * 0 - 1023 are reserved for Sun, - * 1024 - 2047 are defined to be private to a particular tree. - * 2048 - 4095 are defined to be user defined. - * 4096 - ... are reserved for future use. - * - * EOL Alert - The non-prefixed names are present for backward - * compatability only, and will not exist in future releases. Use - * the NIS_* names for future compatability. - */ - -enum zotypes { - - BOGUS_OBJ = 0, /* Uninitialized object structure */ - NO_OBJ = 1, /* NULL object (no data) */ - DIRECTORY_OBJ = 2, /* Directory object describing domain */ - GROUP_OBJ = 3, /* Group object (a list of names) */ - TABLE_OBJ = 4, /* Table object (a database schema) */ - ENTRY_OBJ = 5, /* Entry object (a database record) */ - LINK_OBJ = 6, /* A name link. */ - PRIVATE_OBJ = 7, /* Private object (all opaque data) */ - - NIS_BOGUS_OBJ = 0, /* Uninitialized object structure */ - NIS_NO_OBJ = 1, /* NULL object (no data) */ - NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain */ - NIS_GROUP_OBJ = 3, /* Group object (a list of names) */ - NIS_TABLE_OBJ = 4, /* Table object (a database schema) */ - NIS_ENTRY_OBJ = 5, /* Entry object (a database record) */ - NIS_LINK_OBJ = 6, /* A name link. */ - NIS_PRIVATE_OBJ = 7 /* Private object (all opaque data) */ -}; - -/* - * The types of Name services NIS knows about. They are enumerated - * here. The Binder code will use this type to determine if it has - * a set of library routines that will access the indicated name service. - */ -enum nstype { - UNKNOWN = 0, - NIS = 1, /* Nis Plus Service */ - SUNYP = 2, /* Old NIS Service */ - IVY = 3, /* Nis Plus Plus Service */ - DNS = 4, /* Domain Name Service */ - X500 = 5, /* ISO/CCCIT X.500 Service */ - DNANS = 6, /* Digital DECNet Name Service */ - XCHS = 7, /* Xerox ClearingHouse Service */ - CDS= 8 -}; - -/* - * DIRECTORY - The name service object. These objects identify other name - * servers that are serving some portion of the name space. Each has a - * type associated with it. The resolver library will note whether or not - * is has the needed routines to access that type of service. - * The oarmask structure defines an access rights mask on a per object - * type basis for the name spaces. The only bits currently used are - * create and destroy. By enabling or disabling these access rights for - * a specific object type for a one of the accessor entities (owner, - * group, world) the administrator can control what types of objects - * may be freely added to the name space and which require the - * administrator's approval. - */ -struct oar_mask { - uint32_t oa_rights; /* Access rights mask */ - zotypes oa_otype; /* Object type */ -}; - -struct endpoint { - string uaddr<>; - string family<>; /* Transport family (INET, OSI, etc) */ - string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */ -}; - -/* - * Note: pkey is a netobj which is limited to 1024 bytes which limits the - * keysize to 8192 bits. This is consider to be a reasonable limit for - * the expected lifetime of this service. - */ -struct nis_server { - nis_name name; /* Principal name of the server */ - endpoint ep<>; /* Universal addr(s) for server */ - uint32_t key_type; /* Public key type */ - netobj pkey; /* server's public key */ -}; - -struct directory_obj { - nis_name do_name; /* Name of the directory being served */ - nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */ - nis_server do_servers<>; /* <0> == Primary name server */ - uint32_t do_ttl; /* Time To Live (for caches) */ - oar_mask do_armask<>; /* Create/Destroy rights by object type */ -}; - -/* - * ENTRY - This is one row of data from an information base. - * The type value is used by the client library to convert the entry to - * it's internal structure representation. The Table name is a back pointer - * to the table where the entry is stored. This allows the client library - * to determine where to send a request if the client wishes to change this - * entry but got to it through a LINK rather than directly. - * If the entry is a "standalone" entry then this field is void. - */ -const EN_BINARY = 1; /* Indicates value is binary data */ -const EN_CRYPT = 2; /* Indicates the value is encrypted */ -const EN_XDR = 4; /* Indicates the value is XDR encoded */ -const EN_MODIFIED = 8; /* Indicates entry is modified. */ -const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */ - -struct entry_col { - uint32_t ec_flags; /* Flags for this value */ - opaque ec_value<>; /* It's textual value */ -}; - -struct entry_obj { - string en_type<>; /* Type of entry such as "passwd" */ - entry_col en_cols<>; /* Value for the entry */ -}; - -/* - * GROUP - The group object contains a list of NIS principal names. Groups - * are used to authorize principals. Each object has a set of access rights - * for members of its group. Principal names in groups are in the form - * name.directory and recursive groups are expressed as @groupname.directory - */ -struct group_obj { - uint32_t gr_flags; /* Flags controlling group */ - nis_name gr_members<>; /* List of names in group */ -}; - -/* - * LINK - This is the LINK object. It is quite similar to a symbolic link - * in the UNIX filesystem. The attributes in the main object structure are - * relative to the LINK data and not what it points to (like the file system) - * "modify" privleges here indicate the right to modify what the link points - * at and not to modify that actual object pointed to by the link. - */ -struct link_obj { - zotypes li_rtype; /* Real type of the object */ - nis_attr li_attrs<>; /* Attribute/Values for tables */ - nis_name li_name; /* The object's real NIS name */ -}; - -/* - * TABLE - This is the table object. It implements a simple - * data base that applications and use for configuration or - * administration purposes. The role of the table is to group together - * a set of related entries. Tables are the simple database component - * of NIS. Like many databases, tables are logically divided into columns - * and rows. The columns are labeled with indexes and each ENTRY makes - * up a row. Rows may be addressed within the table by selecting one - * or more indexes, and values for those indexes. Each row which has - * a value for the given index that matches the desired value is returned. - * Within the definition of each column there is a flags variable, this - * variable contains flags which determine whether or not the column is - * searchable, contains binary data, and access rights for the entry objects - * column value. - */ - -const TA_BINARY = 1; /* Means table data is binary */ -const TA_CRYPT = 2; /* Means value should be encrypted */ -const TA_XDR = 4; /* Means value is XDR encoded */ -const TA_SEARCHABLE = 8; /* Means this column is searchable */ -const TA_CASE = 16; /* Means this column is Case Sensitive */ -const TA_MODIFIED = 32; /* Means this columns attrs are modified*/ -const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */ - -struct table_col { - string tc_name<64>; /* Column Name */ - uint32_t tc_flags; /* control flags */ - uint32_t tc_rights; /* Access rights mask */ -}; - -struct table_obj { - string ta_type<64>; /* Table type such as "passwd" */ - int ta_maxcol; /* Total number of columns */ - u_char ta_sep; /* Separator character */ - table_col ta_cols<>; /* The number of table indexes */ - string ta_path<>; /* A search path for this table */ -}; - -/* - * This union joins together all of the currently known objects. - */ -union objdata switch (zotypes zo_type) { - case NIS_DIRECTORY_OBJ : - struct directory_obj di_data; - case NIS_GROUP_OBJ : - struct group_obj gr_data; - case NIS_TABLE_OBJ : - struct table_obj ta_data; - case NIS_ENTRY_OBJ: - struct entry_obj en_data; - case NIS_LINK_OBJ : - struct link_obj li_data; - case NIS_PRIVATE_OBJ : - opaque po_data<>; - case NIS_NO_OBJ : - void; - case NIS_BOGUS_OBJ : - void; - default : - void; -}; - -/* - * This is the basic NIS object data type. It consists of a generic part - * which all objects contain, and a specialized part which varies depending - * on the type of the object. All of the specialized sections have been - * described above. You might have wondered why they all start with an - * integer size, followed by the useful data. The answer is, when the - * server doesn't recognize the type returned it treats it as opaque data. - * And the definition for opaque data is {int size; char *data;}. In this - * way, servers and utility routines that do not understand a given type - * may still pass it around. One has to be careful in setting - * this variable accurately, it must take into account such things as - * XDR padding of structures etc. The best way to set it is to note one's - * position in the XDR encoding stream, encode the structure, look at the - * new position and calculate the size. - */ -struct nis_oid { - uint32_t ctime; /* Time of objects creation */ - uint32_t mtime; /* Time of objects modification */ -}; - -struct nis_object { - nis_oid zo_oid; /* object identity verifier. */ - nis_name zo_name; /* The NIS name for this object */ - nis_name zo_owner; /* NIS name of object owner. */ - nis_name zo_group; /* NIS name of access group. */ - nis_name zo_domain; /* The administrator for the object */ - uint32_t zo_access; /* Access rights (owner, group, world) */ - uint32_t zo_ttl; /* Object's time to live in seconds. */ - objdata zo_data; /* Data structure for this type */ -}; -#if RPC_HDR -% -%#endif /* if __nis_object_h */ -% -#endif diff --git a/nis/rpcsvc/yp.x b/nis/rpcsvc/yp.x deleted file mode 100644 index 269ae6f606..0000000000 --- a/nis/rpcsvc/yp.x +++ /dev/null @@ -1,311 +0,0 @@ -/* @(#)yp.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 file for the Yellow Pages Service - */ - -const YPMAXRECORD = 1024; -const YPMAXDOMAIN = 64; -const YPMAXMAP = 64; -const YPMAXPEER = 64; - - -enum ypstat { - YP_TRUE = 1, - YP_NOMORE = 2, - YP_FALSE = 0, - YP_NOMAP = -1, - YP_NODOM = -2, - YP_NOKEY = -3, - YP_BADOP = -4, - YP_BADDB = -5, - YP_YPERR = -6, - YP_BADARGS = -7, - YP_VERS = -8 -}; - - -enum ypxfrstat { - YPXFR_SUCC = 1, - YPXFR_AGE = 2, - YPXFR_NOMAP = -1, - YPXFR_NODOM = -2, - YPXFR_RSRC = -3, - YPXFR_RPC = -4, - YPXFR_MADDR = -5, - YPXFR_YPERR = -6, - YPXFR_BADARGS = -7, - YPXFR_DBM = -8, - YPXFR_FILE = -9, - YPXFR_SKEW = -10, - YPXFR_CLEAR = -11, - YPXFR_FORCE = -12, - YPXFR_XFRERR = -13, - YPXFR_REFUSED = -14 -}; - - -typedef string domainname; -typedef string mapname; -typedef string peername; -typedef opaque keydat; -typedef opaque valdat; - - -struct ypmap_parms { - domainname domain; - mapname map; - unsigned int ordernum; - peername peer; -}; - -struct ypreq_key { - domainname domain; - mapname map; - keydat key; -}; - -struct ypreq_nokey { - domainname domain; - mapname map; -}; - -struct ypreq_xfr { - ypmap_parms map_parms; - unsigned int transid; - unsigned int prog; - unsigned int port; -}; - - -struct ypresp_val { - ypstat stat; - valdat val; -}; - -struct ypresp_key_val { - ypstat stat; -#ifdef STUPID_SUN_BUG - /* This is the form as distributed by Sun. But even the Sun NIS - servers expect the values in the other order. So their - implementation somehow must change the order internally. We - don't want to follow this bad example since the user should be - able to use rpcgen on this file. */ - keydat key; - valdat val; -#else - valdat val; - keydat key; -#endif -}; - - -struct ypresp_master { - ypstat stat; - peername peer; -}; - -struct ypresp_order { - ypstat stat; - unsigned int ordernum; -}; - -union ypresp_all switch (bool more) { -case TRUE: - ypresp_key_val val; -case FALSE: - void; -}; - -struct ypresp_xfr { - unsigned int transid; - ypxfrstat xfrstat; -}; - -struct ypmaplist { - mapname map; - ypmaplist *next; -}; - -struct ypresp_maplist { - ypstat stat; - ypmaplist *maps; -}; - -enum yppush_status { - YPPUSH_SUCC = 1, /* Success */ - YPPUSH_AGE = 2, /* Master's version not newer */ - YPPUSH_NOMAP = -1, /* Can't find server for map */ - YPPUSH_NODOM = -2, /* Domain not supported */ - YPPUSH_RSRC = -3, /* Local resource alloc failure */ - YPPUSH_RPC = -4, /* RPC failure talking to server */ - YPPUSH_MADDR = -5, /* Can't get master address */ - YPPUSH_YPERR = -6, /* YP server/map db error */ - YPPUSH_BADARGS = -7, /* Request arguments bad */ - YPPUSH_DBM = -8, /* Local dbm operation failed */ - YPPUSH_FILE = -9, /* Local file I/O operation failed */ - YPPUSH_SKEW = -10, /* Map version skew during transfer */ - YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ - YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ - YPPUSH_XFRERR = -13, /* ypxfr error */ - YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ -}; - -struct yppushresp_xfr { - unsigned transid; - yppush_status status; -}; - -/* - * Response structure and overall result status codes. Success and failure - * represent two separate response message types. - */ - -enum ypbind_resptype { - YPBIND_SUCC_VAL = 1, - YPBIND_FAIL_VAL = 2 -}; - -struct ypbind_binding { - opaque ypbind_binding_addr[4]; /* In network order */ - opaque ypbind_binding_port[2]; /* In network order */ -}; - -union ypbind_resp switch (ypbind_resptype ypbind_status) { -case YPBIND_FAIL_VAL: - unsigned ypbind_error; -case YPBIND_SUCC_VAL: - ypbind_binding ypbind_bindinfo; -}; - -/* Detailed failure reason codes for response field ypbind_error*/ - -const YPBIND_ERR_ERR = 1; /* Internal error */ -const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ -const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ - - -/* - * Request data structure for ypbind "Set domain" procedure. - */ -struct ypbind_setdom { - domainname ypsetdom_domain; - ypbind_binding ypsetdom_binding; - unsigned ypsetdom_vers; -}; - - -/* - * YP access protocol - */ -program YPPROG { - version YPVERS { - void - YPPROC_NULL(void) = 0; - - bool - YPPROC_DOMAIN(domainname) = 1; - - bool - YPPROC_DOMAIN_NONACK(domainname) = 2; - - ypresp_val - YPPROC_MATCH(ypreq_key) = 3; - - ypresp_key_val - YPPROC_FIRST(ypreq_key) = 4; - - ypresp_key_val - YPPROC_NEXT(ypreq_key) = 5; - - ypresp_xfr - YPPROC_XFR(ypreq_xfr) = 6; - - void - YPPROC_CLEAR(void) = 7; - - ypresp_all - YPPROC_ALL(ypreq_nokey) = 8; - - ypresp_master - YPPROC_MASTER(ypreq_nokey) = 9; - - ypresp_order - YPPROC_ORDER(ypreq_nokey) = 10; - - ypresp_maplist - YPPROC_MAPLIST(domainname) = 11; - } = 2; -} = 100004; - - -/* - * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR - */ -program YPPUSH_XFRRESPPROG { - version YPPUSH_XFRRESPVERS { - void - YPPUSHPROC_NULL(void) = 0; - -#ifdef STUPID_SUN_BUG - /* This is the form as distributed by Sun. But even - the Sun NIS servers expect the values in the other - order. So their implementation somehow must change - the order internally. We don't want to follow this - bad example since the user should be able to use - rpcgen on this file. */ - yppushresp_xfr - YPPUSHPROC_XFRRESP(void) = 1; -#else - void - YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1; -#endif - } = 1; -} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ - -/* - * YP binding protocol - */ -program YPBINDPROG { - version YPBINDVERS { - void - YPBINDPROC_NULL(void) = 0; - - ypbind_resp - YPBINDPROC_DOMAIN(domainname) = 1; - - void - YPBINDPROC_SETDOM(ypbind_setdom) = 2; - } = 2; -} = 100007; diff --git a/nis/rpcsvc/yp_prot.h b/nis/rpcsvc/yp_prot.h deleted file mode 100644 index ae0db3688e..0000000000 --- a/nis/rpcsvc/yp_prot.h +++ /dev/null @@ -1,366 +0,0 @@ -/* - * This file contains symbols and structures defining the rpc protocol - * between the NIS clients and the NIS servers. The servers - * are the NIS database servers, and the NIS binders. - */ - -#ifndef _RPCSVC_YP_PROT_H -#define _RPCSVC_YP_PROT_H - -#include - -#include -#include - -__BEGIN_DECLS - -/* - * The following procedures are supported by the protocol: - * - * YPPROC_NULL() returns () takes nothing, returns nothing. This indicates - * that the NIS server is alive. - * - * YPPROC_DOMAIN (char *) returns (bool_t) TRUE. Indicates that the - * responding NIS server does serve the named domain; FALSE indicates no - * support. - * - * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the NIS server does serve - * the named domain, otherwise does not return. Used in the broadcast case. - * - * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val). Returns the - * right-hand value for a passed left-hand key, within a named map and - * domain. - * - * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val). - * Returns the first key-value pair from a named domain and map. - * - * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val). Returns - * the key-value pair following a passed key-value pair within a named - * domain and map. - * - * YPPROC_XFR (struct ypreq_xfr) returns nothing. Indicates to a server that - * a map should be updated. - * - * YPPROC_CLEAR takes nothing, returns nothing. Instructs a NIS server to - * close the current map, so that old versions of the disk file don't get - * held open. - * - * YPPROC_ALL (struct ypreq_nokey), returns - * union switch (bool_t more) { - * TRUE: (struct ypresp_key_val); - * FALSE: (struct) {}; - * } - * - * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master) - * - * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order) - * - * YPPROC_MAPLIST (char *), returns (struct ypmaplist *) - */ - -/* Program and version symbols, magic numbers */ - -#define YPPROG 100004 -#define YPVERS 2 -#define YPVERS_ORIG 1 -#define YPMAXRECORD 1024 -#define YPMAXDOMAIN 64 /* XXX orig. yp_prot.h defines 256 */ -#define YPMAXMAP 64 -#define YPMAXPEER 64 /* XXX orig. yp_prot.h defines 256 */ - -/* byte size of a large NIS packet */ -#define YPMSGSZ 1600 - -typedef struct { - u_int keydat_len; - char *keydat_val; -} keydat_t; - -typedef struct { - u_int valdat_len; - char *valdat_val; -} valdat_t; - -struct ypmap_parms { - char *domain; /* Null string means not available */ - char *map; /* Null string means not available */ - unsigned int ordernum; /* 0 means not available */ - char *owner; /* Null string means not available */ -}; - -/* - * Request parameter structures - */ - -struct ypreq_key { - const char *domain; - const char *map; - keydat_t keydat; -}; - -struct ypreq_nokey { - char *domain; - char *map; -}; - -struct ypreq_xfr { - struct ypmap_parms map_parms; - u_int transid; - u_int proto; - u_int port; -}; - -#define ypxfr_domain map_parms.domain -#define ypxfr_map map_parms.map -#define ypxfr_ordernum map_parms.ordernum -#define ypxfr_owner map_parms.owner - -/* Return status values */ - -enum ypstat { - YP_TRUE = 1, /* General purpose success code */ -#define YP_TRUE YP_TRUE - YP_NOMORE = 2, /* No more entries in map */ -#define YP_NOMORE YP_NOMORE - YP_FALSE = 0, /* General purpose failure code */ -#define YP_FALSE YP_FALSE - YP_NOMAP = -1, /* No such map in domain */ -#define YP_NOMAP YP_NOMAP - YP_NODOM = -2, /* Domain not supported */ -#define YP_NODOM YP_NODOM - YP_NOKEY = -3, /* No such key in map */ -#define YP_NOKEY YP_NOKEY - YP_BADOP = -4, /* Invalid operation */ -#define YP_BADOP YP_BADOP - YP_BADDB = -5, /* Server data base is bad */ -#define YP_BADDB YP_BADDB - YP_YPERR = -6, /* NIS server error */ -#define YP_YPERR YP_YPERR - YP_BADARGS = -7, /* Request arguments bad */ -#define YP_BADARGS YP_BADARGS - YP_VERS = -8, /* NIS server version mismatch - server can't supply - requested service. */ -#define YP_VERS YP_VERS -}; - -/* - * Response parameter structures - */ - -typedef enum ypstat ypstat; - -struct ypresp_val { - ypstat status; - valdat_t valdat; -}; - -struct ypresp_key_val { - ypstat status; -#ifdef STUPID_SUN_BUG - /* This is the form as distributed by Sun. But even the Sun NIS - servers expect the values in the other order. So their - implementation somehow must change the order internally. We - don't want to follow this bad example since the user should be - able to use rpcgen on this file. */ - keydat_t keydat; - valdat_t valdat; -#else - valdat_t valdat; - keydat_t keydat; -#endif -}; - -struct ypresp_master { - ypstat status; - char *master; -}; - -struct ypresp_order { - ypstat status; - u_int ordernum; -}; - -struct ypmaplist { - char *map; -#define ypml_name map - struct ypmaplist *next; -#define ypml_next next -}; - -struct ypresp_maplist { - ypstat status; - struct ypmaplist *list; -}; - -/* - * Procedure symbols. YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK - * must keep the same values (0, 1, and 2) that they had in the first version - * of the protocol. - */ - -#define YPPROC_NULL 0 -#define YPPROC_DOMAIN 1 -#define YPPROC_DOMAIN_NONACK 2 -#define YPPROC_MATCH 3 -#define YPPROC_FIRST 4 -#define YPPROC_NEXT 5 -#define YPPROC_XFR 6 -#define YPPROC_CLEAR 7 -#define YPPROC_ALL 8 -#define YPPROC_MASTER 9 -#define YPPROC_ORDER 10 -#define YPPROC_MAPLIST 11 -#define YPPROC_NEWXFR 12 - -/* - * Protocol between clients and NIS binder servers - */ - -/* - * The following procedures are supported by the protocol: - * - * YPBINDPROC_NULL() returns () - * takes nothing, returns nothing - * - * YPBINDPROC_DOMAIN takes (char *) returns (struct ypbind_resp) - * - * YPBINDPROC_SETDOM takes (struct ypbind_setdom) returns nothing - */ - -/* Program and version symbols, magic numbers */ - -#define YPBINDPROG 100007 -#define YPBINDVERS 2 -#define YPBINDVERS_ORIG 1 - -/* Procedure symbols */ - -#define YPBINDPROC_NULL 0 -#define YPBINDPROC_DOMAIN 1 -#define YPBINDPROC_SETDOM 2 -/* - * Response structure and overall result status codes. Success and failure - * represent two separate response message types. - */ - -enum ypbind_resptype {YPBIND_SUCC_VAL = 1, YPBIND_FAIL_VAL = 2}; - -struct ypbind_binding { - struct in_addr ypbind_binding_addr; /* In network order */ - unsigned short int ypbind_binding_port; /* In network order */ -}; - -struct ypbind_resp { - enum ypbind_resptype ypbind_status; - union { - u_int ypbind_error; - struct ypbind_binding ypbind_bindinfo; - } ypbind_respbody; -}; - - -/* Detailed failure reason codes for response field ypbind_error*/ - -#define YPBIND_ERR_ERR 1 /* Internal error */ -#define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */ -#define YPBIND_ERR_RESC 3 /* System resource allocation failure */ - -/* - * Request data structure for ypbind "Set domain" procedure. - */ -struct ypbind_setdom { - char *ypsetdom_domain; - struct ypbind_binding ypsetdom_binding; - u_int ypsetdom_vers; -}; -#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr -#define ypsetdom_port ypsetdom_binding.ypbind_binding_port - -/* - * Protocol between clients (ypxfr, only) and yppush - * yppush speaks a protocol in the transient range, which - * is supplied to ypxfr as a command-line parameter when it - * is activated by ypserv. - */ -#define YPPUSHVERS 1 -#define YPPUSHVERS_ORIG 1 - -/* Procedure symbols */ - -#define YPPUSHPROC_NULL 0 -#define YPPUSHPROC_XFRRESP 1 - -/* Status values for yppushresp_xfr.status */ - -enum yppush_status { - YPPUSH_SUCC = 1, /* Success */ -#define YPPUSH_SUCC YPPUSH_SUCC - YPPUSH_AGE = 2, /* Master's version not newer */ -#define YPPUSH_AGE YPPUSH_AGE - YPPUSH_NOMAP = -1, /* Can't find server for map */ -#define YPPUSH_NOMAP YPPUSH_NOMAP - YPPUSH_NODOM = -2, /* Domain not supported */ -#define YPPUSH_NODOM YPPUSH_NODOM - YPPUSH_RSRC = -3, /* Local resouce alloc failure */ -#define YPPUSH_RSRC YPPUSH_RSRC - YPPUSH_RPC = -4, /* RPC failure talking to server */ -#define YPPUSH_RPC YPPUSH_RPC - YPPUSH_MADDR = -5, /* Can't get master address */ -#define YPPUSH_MADDR YPPUSH_MADDR - YPPUSH_YPERR = -6, /* NIS server/map db error */ -#define YPPUSH_YPERR YPPUSH_YPERR - YPPUSH_BADARGS = -7, /* Request arguments bad */ -#define YPPUSH_BADARGS YPPUSH_BADARGS - YPPUSH_DBM = -8, /* Local dbm operation failed */ -#define YPPUSH_DBM YPPUSH_DBM - YPPUSH_FILE = -9, /* Local file I/O operation failed */ -#define YPPUSH_FILE YPPUSH_FILE - YPPUSH_SKEW = -10, /* Map version skew during transfer */ -#define YPPUSH_SKEW YPPUSH_SKEW - YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ -#define YPPUSH_CLEAR YPPUSH_CLEAR - YPPUSH_FORCE = -12, /* No local order number in map - use -f flag*/ -#define YPPUSH_FORCE YPPUSH_FORCE - YPPUSH_XFRERR = -13, /* ypxfr error */ -#define YPPUSH_XFRERR YPPUSH_XFRERR - YPPUSH_REFUSED = -14, /* Transfer request refused by ypserv */ -#define YPPUSH_REFUSED YPPUSH_REFUSED - YPPUSH_NOALIAS = -15 /* Alias not found for map or domain */ -#define YPPUSH_NOALIAS YPPUSH_NOALIAS -}; -typedef enum yppush_status yppush_status; - -struct yppushresp_xfr { - u_int transid; - yppush_status status; -}; - -struct ypresp_all { - bool_t more; - union { - struct ypresp_key_val val; - } ypresp_all_u; -}; - -extern bool_t xdr_ypreq_key (XDR *__xdrs, struct ypreq_key * __objp); -extern bool_t xdr_ypreq_nokey (XDR *__xdrs, struct ypreq_nokey * __objp); -extern bool_t xdr_ypreq_xfr (XDR *__xdrs, struct ypreq_xfr * __objp); -extern bool_t xdr_ypresp_val (XDR *__xdrs, struct ypresp_val * __objp); -extern bool_t xdr_ypresp_key_val (XDR *__xdrs, struct ypresp_key_val * __objp); -extern bool_t xdr_ypbind_resp (XDR *__xdrs, struct ypbind_resp * __objp); -extern bool_t xdr_ypbind_setdom (XDR *__xdrs, struct ypbind_setdom * __objp); -extern bool_t xdr_ypmap_parms (XDR *__xdrs, struct ypmap_parms * __objp); -extern bool_t xdr_yppushresp_xfr (XDR *__xdrs, struct yppushresp_xfr * __objp); -extern bool_t xdr_ypresp_order (XDR *__xdrs, struct ypresp_order * __objp); -extern bool_t xdr_ypresp_master (XDR *__xdrs, struct ypresp_master * __objp); -extern bool_t xdr_ypall (XDR *__xdrs, struct ypall_callback * __objp); -extern bool_t xdr_ypresp_maplist (XDR *__xdrs, struct ypresp_maplist * __objp); -extern bool_t xdr_ypbind_binding (XDR *__xdrs, struct ypbind_binding * __objp); -extern bool_t xdr_ypbind_resptype (XDR *__xdrs, enum ypbind_resptype * __objp); -extern bool_t xdr_ypstat (XDR *__xdrs, enum ypbind_resptype * __objp); -extern bool_t xdr_ypresp_all (XDR *__xdrs, struct ypresp_all * __objp); -extern bool_t xdr_domainname (XDR *__xdrs, char ** __objp); - -__END_DECLS - -#endif /* _RPCSVC_YP_PROT_H */ diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index a9f230bfb0..a1102e4e46 100644 --- a/nscd/initgrcache.c +++ b/nscd/initgrcache.c @@ -32,12 +32,6 @@ #include "../nss/nsswitch.h" -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -#endif - /* Type of the lookup function. */ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t, long int *, long int *, @@ -88,7 +82,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, int no_more; if (group_database == NULL) - no_more = __nss_database_lookup2 ("group", NULL, DEFAULT_CONFIG, + no_more = __nss_database_lookup2 ("group", NULL, "files", &group_database); else no_more = 0; diff --git a/nss/grp-lookup.c b/nss/grp-lookup.c index d147201b0a..f65da2089b 100644 --- a/nss/grp-lookup.c +++ b/nss/grp-lookup.c @@ -19,10 +19,6 @@ #include #define DATABASE_NAME group -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -#endif +#define DEFAULT_CONFIG "files" #include "XXX-lookup.c" diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 319e22c3fc..8d7b69d4bc 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -42,14 +42,6 @@ #include #include -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -# define DEFAULT_DEFCONFIG "nis [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -# define DEFAULT_DEFCONFIG "files" -#endif - /* Prototypes for the local functions. */ static name_database *nss_parse_file (const char *fname); static name_database_entry *nss_getline (char *line); @@ -161,7 +153,7 @@ __nss_database_lookup2 (const char *database, const char *alternate_name, or null to use the most common default. */ if (*ni == NULL) { - *ni = nss_parse_service_list (defconfig ?: DEFAULT_DEFCONFIG); + *ni = nss_parse_service_list (defconfig ?: "files"); if (*ni != NULL) { /* Record the memory we've just allocated in defconfig_entries list, @@ -845,8 +837,8 @@ __nss_disable_nscd (void (*cb) (size_t, struct traced_file *)) is_nscd = true; /* Find all the relevant modules so that the init functions are called. */ - nss_load_all_libraries ("passwd", DEFAULT_CONFIG); - nss_load_all_libraries ("group", DEFAULT_CONFIG); + nss_load_all_libraries ("passwd", "files"); + nss_load_all_libraries ("group", "files"); nss_load_all_libraries ("hosts", "dns [!UNAVAIL=return] files"); nss_load_all_libraries ("services", NULL); diff --git a/nss/nsswitch.conf b/nss/nsswitch.conf index 4a6bcb1f7b..40030d1dd7 100644 --- a/nss/nsswitch.conf +++ b/nss/nsswitch.conf @@ -15,8 +15,6 @@ # dns Use DNS (Domain Name Service) # files Use the local files in /etc # hesiod Use Hesiod (DNS) for user lookups -# nis Use NIS (NIS version 2), also called YP -# nisplus Use NIS+ (NIS version 3) # # See `info libc 'NSS Basics'` for more information. # diff --git a/nss/pwd-lookup.c b/nss/pwd-lookup.c index 401306785d..e15e150019 100644 --- a/nss/pwd-lookup.c +++ b/nss/pwd-lookup.c @@ -19,10 +19,6 @@ #include #define DATABASE_NAME passwd -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -#endif +#define DEFAULT_CONFIG "files" #include "XXX-lookup.c" diff --git a/nss/spwd-lookup.c b/nss/spwd-lookup.c index c7ca74fa44..21ea0afe75 100644 --- a/nss/spwd-lookup.c +++ b/nss/spwd-lookup.c @@ -20,10 +20,6 @@ #define DATABASE_NAME shadow #define ALTERNATE_NAME passwd -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -#endif +#define DEFAULT_CONFIG "files" #include "XXX-lookup.c" diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index 07e9b457da..dfaaf50a19 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -396,8 +396,7 @@ class Context(object): extra_glibcs=[{'variant': 'disable-multi-arch', 'cfg': ['--disable-multi-arch']}, {'variant': 'enable-obsolete', - 'cfg': ['--enable-obsolete-rpc', - '--enable-obsolete-nsl']}, + 'cfg': ['--enable-obsolete-rpc']}, {'variant': 'static-pie', 'cfg': ['--enable-static-pie']}, {'variant': 'x32-static-pie', @@ -414,8 +413,7 @@ class Context(object): {'variant': 'enable-obsolete', 'arch': 'i686', 'ccopts': '-m32 -march=i686', - 'cfg': ['--enable-obsolete-rpc', - '--enable-obsolete-nsl']}, + 'cfg': ['--enable-obsolete-rpc']}, {'arch': 'i486', 'ccopts': '-m32 -march=i486'}, {'arch': 'i586', diff --git a/shlib-versions b/shlib-versions index b9cb99d2fb..edabba08eb 100644 --- a/shlib-versions +++ b/shlib-versions @@ -43,8 +43,6 @@ libresolv=2 libnss_files=2 libnss_dns=2 libnss_compat=2 -libnss_nis=2 -libnss_nisplus=2 libnss_ldap=2 libnss_hesiod=2 libnss_db=2 diff --git a/sysdeps/mach/Makefile b/sysdeps/mach/Makefile index b4e31d35f7..c3ba6c91cd 100644 --- a/sysdeps/mach/Makefile +++ b/sysdeps/mach/Makefile @@ -56,8 +56,6 @@ else ifeq (dlfcn,$(subdir)) LDLIBS-dl.so += $(objdir)/mach/libmachuser.so else ifeq (nis,$(subdir)) LDLIBS-nsl.so += $(objdir)/mach/libmachuser.so - LDLIBS-nss_nis.so += $(objdir)/mach/libmachuser.so - LDLIBS-nss_nisplus.so += $(objdir)/mach/libmachuser.so LDLIBS-nss_compat.so += $(objdir)/mach/libmachuser.so else ifeq (nss,$(subdir)) LDLIBS-nss.so += $(objdir)/mach/libmachuser.so diff --git a/sysdeps/unix/sysv/linux/mips/shlib-versions b/sysdeps/unix/sysv/linux/mips/shlib-versions index c5bd7db098..ecfe1845f4 100644 --- a/sysdeps/unix/sysv/linux/mips/shlib-versions +++ b/sysdeps/unix/sysv/linux/mips/shlib-versions @@ -15,8 +15,6 @@ libresolv=2 GLIBC_2.0 GLIBC_2.2 libnss_files=2 GLIBC_2.0 GLIBC_2.2 libnss_dns=2 GLIBC_2.0 GLIBC_2.2 libnss_compat=2 GLIBC_2.0 GLIBC_2.2 -libnss_nis=2 GLIBC_2.0 GLIBC_2.2 -libnss_nisplus=2 GLIBC_2.0 GLIBC_2.2 libnss_ldap=2 GLIBC_2.0 GLIBC_2.2 libnss_hesiod=2 GLIBC_2.0 GLIBC_2.2 From patchwork Wed Jul 8 12:06:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39963 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 430F13861038; Wed, 8 Jul 2020 12:06:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 430F13861038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594210004; bh=RsIx6Ogd+tRN/yVRu7jQaQmNuiz1ulrLmAoKgjc71TI=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=g8pfK8jw+oIXzun4Ik6U5CcjzApqeJryo7gJquX3VqKzYfZQ3i8F/wA423uxXz2l+ Bx1hR1QuiaDekByPiRtzkUG5QSRBam4/h8tMr733VVWjLXKQjj5nUuw2lz6k2gF8hh tEyo1fsTqz0neWkrK7/DxtoYONwJ2lbfXv1CsR7Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 2F1A83861865 for ; Wed, 8 Jul 2020 12:06:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F1A83861865 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-Zw3m3LtePmixEZoTXuCK1A-1; Wed, 08 Jul 2020 08:06:14 -0400 X-MC-Unique: Zw3m3LtePmixEZoTXuCK1A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01B96107ACF3; Wed, 8 Jul 2020 12:06:14 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-117.ams2.redhat.com [10.36.112.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D02115D9F3; Wed, 8 Jul 2020 12:06:11 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 3/3] Remove --enable-obsolete-rpc configure flag In-Reply-To: References: Message-Id: Date: Wed, 08 Jul 2020 14:06:10 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPAM_BODY, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Petr Vorel Sun RPC was removed from glibc. This includes rpcgen program, librpcsvc, and Sun RPC headers. Also test for bug #20790 was removed (test for rpcgen). Backward compatibility for old programs is kept only for architectures and ABIs that have been added in or before version 2.28. libtirpc is mature enough, librpcsvc and rpcgen are provided in rpcsvc-proto project. NOTE: libnsl code depends on Sun RPC (installed libnsl headers use installed Sun RPC headers), thus --enable-obsolete-rpc was a dependency for --enable-obsolete-nsl (removed in previous commit). --- NEWS | 8 + .../strcoll-inputs/filelist#en_US.UTF-8 | 29 - config.h.in | 4 - config.make.in | 1 - configure | 18 - configure.ac | 11 - include/libc-symbols.h | 7 +- include/shlib-compat.h | 8 +- malloc/thread-freeres.c | 5 +- manual/nss.texi | 4 +- scripts/build-many-glibcs.py | 6 - sunrpc/Makefile | 152 +- sunrpc/bug20790.x | 1 - sunrpc/proto.h | 65 - sunrpc/rpc_clntout.c | 333 ---- sunrpc/rpc_cout.c | 811 --------- sunrpc/rpc_hout.c | 607 ------- sunrpc/rpc_main.c | 1451 ----------------- sunrpc/rpc_parse.c | 687 -------- sunrpc/rpc_parse.h | 165 -- sunrpc/rpc_sample.c | 336 ---- sunrpc/rpc_scan.c | 544 ------ sunrpc/rpc_scan.h | 104 -- sunrpc/rpc_svcout.c | 1093 ------------- sunrpc/rpc_tblout.c | 178 -- sunrpc/rpc_util.c | 525 ------ sunrpc/rpc_util.h | 154 -- sunrpc/rpcgen.c | 2 - sunrpc/rpcsvc/bootparam.h | 23 - sunrpc/rpcsvc/bootparam_prot.x | 97 -- sunrpc/rpcsvc/key_prot.x | 283 ---- sunrpc/rpcsvc/klm_prot.x | 130 -- sunrpc/rpcsvc/mount.x | 161 -- sunrpc/rpcsvc/nfs_prot.x | 352 ---- sunrpc/rpcsvc/nlm_prot.x | 203 --- sunrpc/rpcsvc/rex.x | 229 --- sunrpc/rpcsvc/rquota.x | 61 - sunrpc/rpcsvc/rstat.x | 145 -- sunrpc/rpcsvc/rusers.x | 228 --- sunrpc/rpcsvc/sm_inter.x | 110 -- sunrpc/rpcsvc/spray.x | 84 - sunrpc/rpcsvc/yppasswd.x | 61 - 42 files changed, 35 insertions(+), 9441 deletions(-) delete mode 100644 sunrpc/bug20790.x delete mode 100644 sunrpc/proto.h delete mode 100644 sunrpc/rpc_clntout.c delete mode 100644 sunrpc/rpc_cout.c delete mode 100644 sunrpc/rpc_hout.c delete mode 100644 sunrpc/rpc_main.c delete mode 100644 sunrpc/rpc_parse.c delete mode 100644 sunrpc/rpc_parse.h delete mode 100644 sunrpc/rpc_sample.c delete mode 100644 sunrpc/rpc_scan.c delete mode 100644 sunrpc/rpc_scan.h delete mode 100644 sunrpc/rpc_svcout.c delete mode 100644 sunrpc/rpc_tblout.c delete mode 100644 sunrpc/rpc_util.c delete mode 100644 sunrpc/rpc_util.h delete mode 100644 sunrpc/rpcgen.c delete mode 100644 sunrpc/rpcsvc/bootparam.h delete mode 100644 sunrpc/rpcsvc/bootparam_prot.x delete mode 100644 sunrpc/rpcsvc/key_prot.x delete mode 100644 sunrpc/rpcsvc/klm_prot.x delete mode 100644 sunrpc/rpcsvc/mount.x delete mode 100644 sunrpc/rpcsvc/nfs_prot.x delete mode 100644 sunrpc/rpcsvc/nlm_prot.x delete mode 100644 sunrpc/rpcsvc/rex.x delete mode 100644 sunrpc/rpcsvc/rquota.x delete mode 100644 sunrpc/rpcsvc/rstat.x delete mode 100644 sunrpc/rpcsvc/rusers.x delete mode 100644 sunrpc/rpcsvc/sm_inter.x delete mode 100644 sunrpc/rpcsvc/spray.x delete mode 100644 sunrpc/rpcsvc/yppasswd.x diff --git a/NEWS b/NEWS index f0782d6096..2a90a755b9 100644 --- a/NEWS +++ b/NEWS @@ -69,6 +69,14 @@ Major new features: Deprecated and removed features, and other changes affecting compatibility: +* Remove configure option --enable-obsolete-rpc. Sun RPC is removed + from glibc. This includes the rpcgen program, librpcsvc, and the Sun + RPC header files. Backward compatibility for old programs is kept + only for architectures and ABIs that have been added in or before + glibc 2.31. New programs need to use TI-RPC + and + rpcsvc-proto . + * Remove configure option --enable-obsolete-nsl. libnsl is only built as shared library for backward compatibility and the NSS modules "nis" and "nisplus" are not built at all and libnsl's headers aren't diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 index aa44107ad6..2f4ef195bb 100644 --- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 +++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 @@ -14107,40 +14107,20 @@ nptl bits manual sunrpc -rpc_hout.c tst-xdrmem2.c -rpc_util.h getrpcbynumber_r.c xdr_intXX_t.c -rpc_tblout.c svc.c -rpc_svcout.c get_myaddr.c getrpcport.c auth_unix.c rpc_prot.c svcauth_des.c -rpc_clntout.c des_soft.c thrsvc.c xdr_rec.c rpcinfo.c rpcsvc -sm_inter.x -spray.x -nfs_prot.x -bootparam.h -klm_prot.x -key_prot.x -rstat.x -rusers.x -rex.x -yppasswd.x -mount.x -bootparam_prot.x -rquota.x -nlm_prot.x -rpc_main.c pmap_prot.c pmap_prot2.c rtime.c @@ -14150,7 +14130,6 @@ svc_simple.c svc_raw.c getrpcent.c pmap_rmt.c -rpc_sample.c pm_getport.c openchild.c xdr_stdio.c @@ -14187,11 +14166,8 @@ clnt.h pmap_clnt.c xdr.c bindrsvprt.c -rpc_parse.c Makefile -rpc_util.c des_crypt.c -rpc_parse.h key_call.c authdes_prot.c xdr_float.c @@ -14201,7 +14177,6 @@ clnt_gen.c getrpcbyname_r.c getrpcbyname.c clnt_udp.c -proto.h publickey.c svc_auth.c etc.rpc @@ -14212,20 +14187,16 @@ getrpcent_r.c rpc_common.c rpc_dtable.c clnt_unix.c -rpcgen.c auth_none.c -rpc_scan.c authuxprot.c svc_udp.c Versions test-rpcent.c svc_run.c key_prot.c -rpc_cout.c pm_getmaps.c xdr_ref.c getrpcbynumber.c -rpc_scan.h ChangeLog.old-ports-arm libc-abis configure.ac diff --git a/config.h.in b/config.h.in index 9eb71a81b7..16b2cf9999 100644 --- a/config.h.in +++ b/config.h.in @@ -157,10 +157,6 @@ /* Define if multi-arch DSOs should be generated. */ #undef USE_MULTIARCH -/* Define if obsolete RPC code should be made available for user-level code - to link against. */ -#undef LINK_OBSOLETE_RPC - /* Define if Systemtap probes should be defined. */ #undef USE_STAP_PROBE diff --git a/config.make.in b/config.make.in index cefb6d4a90..1ac9417245 100644 --- a/config.make.in +++ b/config.make.in @@ -96,7 +96,6 @@ build-profile = @profile@ build-static-nss = @static_nss@ cross-compiling = @cross_compiling@ force-install = @force_install@ -link-obsolete-rpc = @link_obsolete_rpc@ build-crypt = @build_crypt@ build-nscd = @build_nscd@ use-nscd = @use_nscd@ diff --git a/configure b/configure index 793c0068cc..4795e721e5 100755 --- a/configure +++ b/configure @@ -673,7 +673,6 @@ base_machine have_tunables build_pt_chown build_nscd -link_obsolete_rpc libc_cv_static_nss_crypt libc_cv_nss_crypt build_crypt @@ -784,7 +783,6 @@ enable_multi_arch enable_experimental_malloc enable_crypt enable_nss_crypt -enable_obsolete_rpc enable_systemtap enable_build_nscd enable_nscd @@ -1455,8 +1453,6 @@ Optional Features: --disable-crypt do not build nor install the passphrase hashing library, libcrypt --enable-nss-crypt enable libcrypt to use nss - --enable-obsolete-rpc build and install the obsolete RPC code for - link-time usage --enable-systemtap enable systemtap static probe points [default=no] --disable-build-nscd disable building and installing the nscd daemon --disable-nscd library functions will not contact the nscd daemon @@ -3636,20 +3632,6 @@ fi -# Check whether --enable-obsolete-rpc was given. -if test "${enable_obsolete_rpc+set}" = set; then : - enableval=$enable_obsolete_rpc; link_obsolete_rpc=$enableval -else - link_obsolete_rpc=no -fi - - - -if test "$link_obsolete_rpc" = yes; then - $as_echo "#define LINK_OBSOLETE_RPC 1" >>confdefs.h - -fi - # Check whether --enable-systemtap was given. if test "${enable_systemtap+set}" = set; then : enableval=$enable_systemtap; systemtap=$enableval diff --git a/configure.ac b/configure.ac index 33a1189804..93e68fb696 100644 --- a/configure.ac +++ b/configure.ac @@ -376,17 +376,6 @@ AC_SUBST(libc_cv_nss_crypt) AC_SUBST(libc_cv_static_nss_crypt) -AC_ARG_ENABLE([obsolete-rpc], - AC_HELP_STRING([--enable-obsolete-rpc], - [build and install the obsolete RPC code for link-time usage]), - [link_obsolete_rpc=$enableval], - [link_obsolete_rpc=no]) -AC_SUBST(link_obsolete_rpc) - -if test "$link_obsolete_rpc" = yes; then - AC_DEFINE(LINK_OBSOLETE_RPC) -fi - AC_ARG_ENABLE([systemtap], [AS_HELP_STRING([--enable-systemtap], [enable systemtap static probe points @<:@default=no@:>@])], diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 29483779fe..60153bb50d 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -625,12 +625,7 @@ for linking") # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) # define libc_hidden_def(name) hidden_def (name) # define libc_hidden_weak(name) hidden_weak (name) -# ifdef LINK_OBSOLETE_RPC - /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */ -# define libc_hidden_nolink_sunrpc(name, version) hidden_def (name) -# else -# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version) -# endif +# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version) # define libc_hidden_ver(local, name) hidden_ver (local, name) # define libc_hidden_data_def(name) hidden_data_def (name) # define libc_hidden_tls_def(name) hidden_tls_def (name) diff --git a/include/shlib-compat.h b/include/shlib-compat.h index c8fc6925a0..b58281857a 100644 --- a/include/shlib-compat.h +++ b/include/shlib-compat.h @@ -127,15 +127,9 @@ #define compat_symbol_reference_2(local, symbol, name) \ symbol_version_reference (local, symbol, name) -# ifdef LINK_OBSOLETE_RPC -/* Export the symbol for both static and dynamic linking. */ -# define libc_sunrpc_symbol(name, aliasname, version) \ - strong_alias (name, aliasname) -# else /* Export the symbol only for shared-library compatibility. */ -# define libc_sunrpc_symbol(name, aliasname, version) \ +#define libc_sunrpc_symbol(name, aliasname, version) \ compat_symbol (libc, name, aliasname, version); -# endif /* The TEST_COMPAT macro acts just like the SHLIB_COMPAT macro except that it does not check IS_IN. It is used by tests that are testing diff --git a/malloc/thread-freeres.c b/malloc/thread-freeres.c index eb29d53310..268f1c3688 100644 --- a/malloc/thread-freeres.c +++ b/malloc/thread-freeres.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Thread shutdown function. Note that this function must be called for threads during shutdown for correctness reasons. Unlike @@ -30,7 +31,9 @@ void __libc_thread_freeres (void) { - call_function_static_weak (__rpc_thread_destroy); +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32) + __rpc_thread_destroy (); +#endif call_function_static_weak (__res_thread_freeres); __glibc_tls_internal_free (); diff --git a/manual/nss.texi b/manual/nss.texi index 80e730768e..3aaa7786f8 100644 --- a/manual/nss.texi +++ b/manual/nss.texi @@ -335,9 +335,7 @@ with a @code{+} character was found NIS was used. This kind of lookup was removed and now the default value for the services is @code{files}. libnss_compat no longer depends on libnsl and can be used without NIS. -For all other databases the default value is @code{files} unless -@theglibc{} was configured with @code{--enable-obsolete-rpc} option, in -which case it the default value is @code{nis [NOTFOUND=return] files}. +For all other databases the default value is @code{files}. @cindex optimizing NSS A second point is that the user should try to optimize the lookup diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index dfaaf50a19..48319f8ab1 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -395,8 +395,6 @@ class Context(object): {'arch': 'i686', 'ccopts': '-m32 -march=i686'}], extra_glibcs=[{'variant': 'disable-multi-arch', 'cfg': ['--disable-multi-arch']}, - {'variant': 'enable-obsolete', - 'cfg': ['--enable-obsolete-rpc']}, {'variant': 'static-pie', 'cfg': ['--enable-static-pie']}, {'variant': 'x32-static-pie', @@ -410,10 +408,6 @@ class Context(object): 'arch': 'i686', 'ccopts': '-m32 -march=i686', 'cfg': ['--disable-multi-arch']}, - {'variant': 'enable-obsolete', - 'arch': 'i686', - 'ccopts': '-m32 -march=i686', - 'cfg': ['--enable-obsolete-rpc']}, {'arch': 'i486', 'ccopts': '-m32 -march=i486'}, {'arch': 'i586', diff --git a/sunrpc/Makefile b/sunrpc/Makefile index 2d1861f3dc..82710b379a 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -22,11 +22,13 @@ subdir := sunrpc include ../Makeconfig +ifdef have-GLIBC_2.31 + # The code in this subdirectory is taken from Sun's RPCSRC-4.0 # distribution with some additional changes from the TI-RPC package # which is also available from Sun. The files are heavily changed to # compile cleanly and to fit in the GNU environment. All the code -# from Sun's rpc, etc, and rpcgen subdirectories is in this directory; +# from Sun's rpc and etc subdirectories is in this directory; # the rpc subdirectory contains only the header files. Other than # that, several files were renamed so as not to exceed 14-character # file name limits: @@ -44,23 +46,6 @@ include ../Makeconfig # svc_auth_unix.c -> svc_authux.c # xdr_reference.c -> xdr_ref.c -rpcsvc = bootparam_prot.x nlm_prot.x rstat.x \ - yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \ - rusers.x spray.x nfs_prot.x rquota.x key_prot.x -headers-sunrpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \ - pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h \ - svc.h svc_auth.h types.h xdr.h auth_des.h \ - key_prot.h) \ - $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h -headers = rpc/netdb.h -generated += $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \ - $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen -generated-dirs += rpcsvc - -ifeq ($(link-obsolete-rpc),yes) -headers += $(headers-sunrpc) -endif - ifeq ($(build-shared),yes) need-export-routines := auth_des auth_unix clnt_gen clnt_perr clnt_tcp \ clnt_udp get_myaddr key_call netname pm_getport \ @@ -75,20 +60,9 @@ routines := auth_none authuxprot clnt_raw clnt_simp \ des_crypt des_impl des_soft key_prot openchild rtime svcauth_des \ clnt_unix svc_unix create_xid $(need-export-routines) \ rpc_gethostbyname -ifneq ($(link-obsolete-rpc),yes) # We only add the RPC for compatibility to libc.so. shared-only-routines = $(routines) endif -endif - -ifeq ($(link-obsolete-rpc),yes) -install-bin := rpcgen -rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \ - rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \ - rpc_tblout.o rpc_sample.o -extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs)) -others += rpcgen -endif tests = tst-xdrmem tst-xdrmem2 test-rpcent tst-udp-error tst-udp-timeout \ tst-udp-nonblocking @@ -100,22 +74,6 @@ tests += tst-udp-garbage tests-internal += tst-svc_register endif -ifeq ($(run-built-tests),yes) -ifeq ($(link-obsolete-rpc),yes) -rpcgen-tests := $(objpfx)bug20790.out -tests-special += $(rpcgen-tests) -endif -endif - -ifeq ($(link-obsolete-rpc),yes) -headers += $(rpcsvc:%.x=rpcsvc/%.h) -extra-libs := librpcsvc -extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass. -librpcsvc-routines = $(rpcsvc:%.x=x%) -librpcsvc-inhibit-o = .os # Build no shared rpcsvc library. -omit-deps = $(librpcsvc-routines) -endif - ifeq (yes,$(build-shared)) rpc-compat-routines = $(addprefix compat-,$(need-export-routines)) rpc-compat-routines.os = $(addprefix $(objpfx), \ @@ -133,19 +91,6 @@ $(rpc-compat-routines.os): $(objpfx)compat-%.os: %.c $(before-compile) $(compile-command.c) -DEXPORT_RPC_SYMBOLS endif -CFLAGS-xbootparam_prot.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xnlm_prot.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xrstat.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xyppasswd.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xklm_prot.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xrex.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xsm_inter.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xmount.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xrusers.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xspray.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xnfs_prot.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xrquota.c += -Wno-unused $(PIC-ccflag) -CFLAGS-xkey_prot.c += -Wno-unused $(PIC-ccflag) CFLAGS-auth_unix.c += -fexceptions CFLAGS-key_call.c += -fexceptions CFLAGS-pmap_rmt.c += -fexceptions @@ -159,83 +104,26 @@ $(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so $(objpfx)tst-svc_register: \ $(common-objpfx)linkobj/libc.so $(shared-thread-library) -$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) - -cross-rpcgen-objs := $(addprefix $(objpfx)cross-,$(rpcgen-objs)) - -# When generic makefile support for build system programs is -# available, it should replace this code. See -# . -$(cross-rpcgen-objs): $(objpfx)cross-%.o: %.c $(before-compile) - $(BUILD_CC) $($(basename $( -#include -#include "rpc/types.h" -#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; - bool_t 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/sunrpc/rpc_cout.c b/sunrpc/rpc_cout.c deleted file mode 100644 index db7b571b33..0000000000 --- a/sunrpc/rpc_cout.c +++ /dev/null @@ -1,811 +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 (); - } -} - -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"); -} - -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/sunrpc/rpc_hout.c b/sunrpc/rpc_hout.c deleted file mode 100644 index 10f793d233..0000000000 --- a/sunrpc/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/sunrpc/rpc_main.c b/sunrpc/rpc_main.c deleted file mode 100644 index c6607848cc..0000000000 --- a/sunrpc/rpc_main.c +++ /dev/null @@ -1,1451 +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. - */ - -#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" - -#include "../version.h" -#define PACKAGE _libc_intl_domainname - -#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, by default */ -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 (_libc_intl_domainname); - - (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 = strrchr (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")); - - f_print (stream, _("\n\ -For bug reporting instructions, please see:\n\ -%s.\n"), REPORT_BUGS_TO); - exit (status); -} - -static void -print_version (void) -{ - printf ("rpcgen %s%s\n", PKGVERSION, VERSION); - exit (0); -} diff --git a/sunrpc/rpc_parse.c b/sunrpc/rpc_parse.c deleted file mode 100644 index 505a6554cf..0000000000 --- a/sunrpc/rpc_parse.c +++ /dev/null @@ -1,687 +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/types.h" -#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; - bool_t isvoid = FALSE; /* 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 = FALSE; - /* 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 = TRUE; - 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 = TRUE; - 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/sunrpc/rpc_parse.h b/sunrpc/rpc_parse.h deleted file mode 100644 index e2e2f1e106..0000000000 --- a/sunrpc/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/sunrpc/rpc_sample.c b/sunrpc/rpc_sample.c deleted file mode 100644 index e90b58c080..0000000000 --- a/sunrpc/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/sunrpc/rpc_scan.c b/sunrpc/rpc_scan.c deleted file mode 100644 index 0a88bafe76..0000000000 --- a/sunrpc/rpc_scan.c +++ /dev/null @@ -1,544 +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" - -#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/sunrpc/rpc_scan.h b/sunrpc/rpc_scan.h deleted file mode 100644 index 9786a513b9..0000000000 --- a/sunrpc/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/sunrpc/rpc_svcout.c b/sunrpc/rpc_svcout.c deleted file mode 100644 index 4f12a8146c..0000000000 --- a/sunrpc/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/sunrpc/rpc_tblout.c b/sunrpc/rpc_tblout.c deleted file mode 100644 index a7d2f43528..0000000000 --- a/sunrpc/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/sunrpc/rpc_util.c b/sunrpc/rpc_util.c deleted file mode 100644 index 52aa69757b..0000000000 --- a/sunrpc/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/sunrpc/rpc_util.h b/sunrpc/rpc_util.h deleted file mode 100644 index 53316d9516..0000000000 --- a/sunrpc/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/sunrpc/rpcgen.c b/sunrpc/rpcgen.c deleted file mode 100644 index 1b455ba243..0000000000 --- a/sunrpc/rpcgen.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Empty file expected by glibc's standard build rules for - executables. */ diff --git a/sunrpc/rpcsvc/bootparam.h b/sunrpc/rpcsvc/bootparam.h deleted file mode 100644 index 0cd3ebbe5a..0000000000 --- a/sunrpc/rpcsvc/bootparam.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 1999-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 - . */ - -#ifndef _RPCSVC_BOOTPARAM_H -#define _RPCSVC_BOOTPARAM_H - -#include - -#endif /* _RPCSVC_BOOTPARAM_H */ diff --git a/sunrpc/rpcsvc/bootparam_prot.x b/sunrpc/rpcsvc/bootparam_prot.x deleted file mode 100644 index 117e428560..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/key_prot.x b/sunrpc/rpcsvc/key_prot.x deleted file mode 100644 index 9baf943916..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/klm_prot.x b/sunrpc/rpcsvc/klm_prot.x deleted file mode 100644 index aee5b1a962..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/mount.x b/sunrpc/rpcsvc/mount.x deleted file mode 100644 index ed3b339c49..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/nfs_prot.x b/sunrpc/rpcsvc/nfs_prot.x deleted file mode 100644 index ad992e238f..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/nlm_prot.x b/sunrpc/rpcsvc/nlm_prot.x deleted file mode 100644 index 81ff13735e..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/rex.x b/sunrpc/rpcsvc/rex.x deleted file mode 100644 index b5baf15a85..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/rquota.x b/sunrpc/rpcsvc/rquota.x deleted file mode 100644 index c4575240d3..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/rstat.x b/sunrpc/rpcsvc/rstat.x deleted file mode 100644 index 9b7b102218..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/sm_inter.x b/sunrpc/rpcsvc/sm_inter.x deleted file mode 100644 index 767f0e0856..0000000000 --- a/sunrpc/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/sunrpc/rpcsvc/spray.x b/sunrpc/rpcsvc/spray.x deleted file mode 100644 index 68b7c48442..0000000000 --- a/sunrpc/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; diff --git a/sunrpc/rpcsvc/yppasswd.x b/sunrpc/rpcsvc/yppasswd.x deleted file mode 100644 index 34e3efe3f9..0000000000 --- a/sunrpc/rpcsvc/yppasswd.x +++ /dev/null @@ -1,61 +0,0 @@ -/* @(#)yppasswd.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. - */ - -/* - * YP password update protocol - * Requires unix authentication - */ -program YPPASSWDPROG { - version YPPASSWDVERS { - /* - * Update my passwd entry - */ - int - YPPASSWDPROC_UPDATE(yppasswd) = 1; - } = 1; -} = 100009; - - -struct passwd { - string pw_name<>; /* username */ - string pw_passwd<>; /* encrypted password */ - int pw_uid; /* user id */ - int pw_gid; /* group id */ - string pw_gecos<>; /* in real life name */ - string pw_dir<>; /* home directory */ - string pw_shell<>; /* default shell */ -}; - -struct yppasswd { - string oldpass<>; /* unencrypted old password */ - passwd newpw; /* new passwd entry */ -};