diff -Naur ../glibc-2.1.3/ChangeLog glibc-2.1.3/ChangeLog --- ../glibc-2.1.3/ChangeLog 2000-02-24 18:05:16.000000000 -0800 +++ glibc-2.1.3/ChangeLog 2000-02-29 13:15:05.000000000 -0800 @@ -1,3 +1,16 @@ +2000-02-28 David S. Miller + + * sysdeps/unix/sysv/linux/sparc/getsysstats.c: New file. + +2000-02-24 Ulrich Drepper + + * locale/C-ctype.c (_nl_C_LC_CTYPE): Move comma to correct place + for big endian machines. + +2000-02-24 Andreas Jaeger + + * locale/programs/ld-ctype.c (ctype_output): Add missing &. + 2000-02-24 Ulrich Drepper * locale/C-ctype.c: Add table pointer for both endianesses. @@ -42,6 +55,10 @@ conditions so as not to clobber the final '\0' when there is only one element in the vector. +2000-02-23 Cristian Gafton + + * locale/programs/ld-ctype.c (CTYPE_DATA): Make sure we keep the alignment + 2000-02-22 Ulrich Drepper * libio/stdio.h: Define macros stdin, stdout, and stderr. @@ -230,6 +247,11 @@ Rebel-NetWinder to platform table so _ioperm platform lookup via /proc/cpuinfo works on later version NetWinders. +2000-02-14 Cristian Gafton + + * timezone/aliases: New file + * timezone/Makefile (tzlinks): Add aliases + 2000-02-13 Ulrich Drepper * sysdeps/i386/fpu/s_cosf.S: Domain of opcode is not large enough @@ -406,6 +428,12 @@ * sysdeps/unix/sysv/linux/arm/mmap64.S: Correct check for ENOSYS. +2000-02-01 Cristian Gafton + + * misc/syslog.c (closelog): reset LogType to SOCK_DGRAM + (openlog_internal): retry with SOCK_DGRAM if we are in SOCK_STREAM + mode and we get a connection refused. + 2000-01-25 Ulrich Drepper * sysdeps/unix/sysv/linux/i386/Dist: Add sys/io.h. diff -Naur ../glibc-2.1.3/Makeconfig glibc-2.1.3/Makeconfig --- ../glibc-2.1.3/Makeconfig 1999-11-29 11:19:20.000000000 -0800 +++ glibc-2.1.3/Makeconfig 2000-01-10 14:11:06.000000000 -0800 @@ -789,7 +789,8 @@ $(patsubst $<,/dev/null,$^) > $@-tmp mv -f $@-tmp $@ -all-Depend-files = $(wildcard $(..)*/Depend) +all-Depend-files = $(wildcard $(patsubst %,$(..)%/Depend,$(add-ons))) + $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk $(all-Depend-files) \ $(common-objpfx)sysd-dirs $(..)Makeconfig { { dirs='$(patsubst $(..)%/Depend,$(..)%,$(filter %/Depend,$^))';\ diff -Naur ../glibc-2.1.3/Makefile.in glibc-2.1.3/Makefile.in --- ../glibc-2.1.3/Makefile.in 1998-02-26 06:51:55.000000000 -0800 +++ glibc-2.1.3/Makefile.in 1998-03-12 12:17:58.000000000 -0800 @@ -1,4 +1,4 @@ -# Generated from $Id: Makefile.in,v 1.6 1998/02/26 14:51:55 drepper Exp $. +# Generated from $Id: Makefile.in,v 1.1.1.1 1998/03/12 20:17:58 gafton Exp $. srcdir = @srcdir@ diff -Naur ../glibc-2.1.3/README-alpha glibc-2.1.3/README-alpha --- ../glibc-2.1.3/README-alpha 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/README-alpha 1999-06-16 15:30:43.000000000 -0700 @@ -0,0 +1,287 @@ + GNU libc SNAPSHOT SYSTEM + (general info) + Updated 1997-9-26 + +WHAT ARE GNU libc SNAPSHOTS +--------------------------- + +Snapshots are an "image" of the main glibc development tree, captured at a +particular random instant in time. When you use the snapshots, you should be +able to maintain a local copy of libc that is no more than one day older than +the official source tree used by the libc maintainers. + +The primary purpose of providing snapshots is to widen the group of motivated +developers that would like to help test, debug, and enhance glibc, by providing +you with access to the "latest and greatest" source. This has several +advantages, and several disadvantages. + + First the advantages: + + o Once we have a large base of motivated testers using the snapshots, + this should provide good coverage across all currently supported + glibc hosts and targets. If a new bug is introduced in glibc due to + fixing another bug or ongoing development, it should become + obvious much more quickly and get fixed before the next general + net release. This should help to reduce the chances of glibc being + released to the general public with a major bug that went unnoticed + during the release cycle testing because they are machine dependent. + We hope to greatly improve glibc's stability and reliability by + involving more people and more execution environments in the + prerelease testing. + + o With access to the latest source, any diffs that you send to fix + bugs or add new features should be much easier for the glibc team + to merge into the official source base (after suitable review + of course). This encourages us to merge your changes quicker, + while they are still "fresh". + + o Once your diffs are merged, you can obtain a new copy of glibc + containing your changes almost immediately. Thus you do not + have to maintain local copies of your changes for any longer + than it takes to get them merged into the official source base. + This encourages you to send in changes quicker. + + And the disadvantages: + + o The snapshot you get will be largely untested and of unknown quality. + It may fail to configure or compile. It may have serious bugs. + You should always keep a copy of the last known working version + before updating to the current snapshot, or at least be able to + regenerate a working version if the latest snapshot is unusable + in your environment for some reason. + + If a production version of glibc has a bug and a snapshot has the fix, + and you care about stability, you should put only the fix for that + particular problem into your production version. Of course, if you + are eager to test glibc, you can use the snapshot versions in your + daily work, but users who have not been consulted about whether they + feel like testing glibc should generally have something which is at + least as bug free as the last released version. + + o Providing timely response to your questions, bug reports, and + submitted patches will require the glibc development team to allocate + time from an already thin time budget. Please try to help us make + this time as productive as possible. See the section below about + how to submit changes. + + +WHO SHOULD TRY THE SNAPSHOTS +---------------------------- + +Remember, these are snapshots not tested versions. So if you use +these versions you should be able to + + o make sure your system stays usable + + o locate and hopefully fix problems + + o to port glibc to a new target yourself + +You should not use the snapshots if + + o your system is needed in a production environment which needs + stability + + o you expect us to fix your problems since you somehow depend on them. + You must be willing to fix the problems yourself, we don't want to + see "I have problems, fix this" messages. + + +HOW TO GET THE SNAPSHOTS +------------------------ + +At the moment we provide a full snapshot weekly (every sunday), so +that users getting a snapshot for the first time, or updating after +a long period of not updating, can get the latest version in a single +operation. Along with the full snapshot, we will provide incremental +diffs on a nearly daily basis (whenever code changes). Each daily +diff will be relative to the source tree after applying all previous +daily diffs. The daily diffs are for people who have relatively low +bandwidth ftp or uucp connections. + +The files will be available via anonymous ftp from alpha.gnu.org, in +directory /gnu/libc and on linux.kernel.org in /pub/software/libs/glibc. The +directories should look something like: + + libc-970921.tar.gz + libc-970917-970922.diff.gz + libc-970922-970925.diff.gz + . + . + . + +Please note that the snapshots on alpha.gnu.org and on +linux.kernel.org are not always in sync. Patches to some files might +appear a day a diff earlier or later on alpha than on kernel. +Use always alpha or always kernel but don't mix them. + +There are sometimes additionally test releases of the add-ons available in +these directories. If a new version of an add-on is available it is normally +required for the corresponding snapshot so always pay attention for these. + +Note that we provide GNU gzip compressed files only. You can ftp gzip +from ftp.gnu.org in directory pub/gnu. + +In some cases the dates for diffs and snapshots do not match like in the +example above. The full release is for 970921 but the patch is for +970917-970922. This only means that nothing changed between 970917 and 970922 +and that you have to use this patch on top of the 970921 snapshot since the +patch is made on 970922. + +Also, as the gcc developers did with their gcc snapshot system, even though we +will make the snapshots available on a publically accessible ftp area, we ask +that recipients not widely publicise their availability. The motivation for +this request is not to hoard them, but to avoid the situation where the +general glibc user base naively attempts to use the snapshots, has trouble with +them, complains publically, and the reputation of glibc declines because of a +perception of instability or lack of quality control. + + +GLIBC TEST SUITE +---------------- + +A test suite is distributed as an integral part of the snapshots. A simple +"make check" in your build directory is sufficient to run the tests. glibc +should pass all tests and if any fails, please report it. A failure might not +originate from a bug in glibc but also from bugs in the tools, e.g. with gcc +2.7.2.x the math tests fail some of the tests because of compiler bugs. + +Note that the test suite is still in its infancy. The tests themselves only +cover a small portion of libc features, and where tests do exist for a feature +they are not exhaustive. New tests are welcome. + + +GETTING HELP, GLIBC DISCUSSIONS, etc +------------------------------------ + +People who want to help with glibc and who test out snapshots +regularly should get on the libc-alpha@sourceware.cygnus.com mailing +list by sending an email to libc-alpha-subscribe@sourceware.cygnus.com. +This list is meant (as the name suggests) for the discussion of test +releases and also reports for them. People who are on this list are +welcome to post questions of general interest. + +People who are not only willing to test the snapshots but instead +really want to help developing glibc should contact +libc-hacker-subscribe@sourceware.cygnus.com.org to be put on the developers +mailing list. This list is really only meant for developers. No +questions about installation problems or other simple topics are +wanted nor will they be answered. + +Do *not* send any questions about the snapshots or patches specific to the +snapshots to bug-glibc@gnu.org. Nobody there will have any idea what +you are talking about and it will just cause confusion. + + +BUG REPORTS +----------- + +Send bug reports directly to Ulrich Drepper . Please +do *not* use the glibcbug script for reporting bugs in the snapshots. +glibcbug should only be used for problems with the official released versions. +We don't like bug reports in the bug database because otherwise the impression +of instability or lack of quality control of glibc as a whole might manifest +in people's mind. + +Note that since no testing is done on the snapshots, and snapshots may even be +made when glibc is in an inconsistent state, it may not be unusual for an +occasional snapshot to have a very obvious bug, such as failure to compile on +*any* machine. It is likely that such bugs will be fixed by the next +snapshot, so it really isn't necessary to report them unless they persist for +a couple of days. + +Missing files should always be reported, since they usually mean there is a +problem with the snapshot-generating process and we won't know about them +unless someone tells us. + +Bugs which are non-obvious, such as failure to compile on only a specific +machine, a new machine dependent or obscure bug (particularly one not detected +by the testsuite), etc should be reported when you discover them, or have a +suggested patch to fix them. + + +FORMAT FOR PATCHES +------------------ + +If you have a fix for a bug, or an enhancement to submit, send your patch to +Ulrich Drepper . Here are some simple guidelines for +submitting patches: + + o Use "unified diffs" for patches. A typical command for generating + context diffs is "diff -ru glibc-old glibc-patched". + + o Use the "minimalist approach" for patches. That is, each patch + should address only one particular bug, new feature, etc. Do not + save up many unrelated changes and submit them all in one big + patch, since in general, the larger the patch the more difficult + it is for us to decide if the patch is either correct or + desirable. And if we find something about the patch that needs + to be corrected before it can be installed, we would have to reject + the entire patch, which might contain changes which otherwise would + be accepted if submitted separately. + + o Submit a sample ChangeLog entry with your patch. See the existing + glibc ChangeLog for examples of what a ChangeLog entry should look + like. The emacs command ^X4A will create a ChangeLog entry header + for you. + + +BUILDING SNAPSHOTS +------------------ + +The `best' way to build glibc is to use an extra directory, e.g.: +tar xzf libc-970921.tar.gz +mkdir build-glibc +cd build-glibc +../libc-970921/configure ... + +In this way you can easily clean up (since `make clean' doesn't work at +the moment) and rebuild glibc. + + +NECESSARY TOOLS +--------------- + +For the recommended versions of gcc, binutils, make, texinfo, gettext, +autoconf and other tools which might be especially needed when using patches, +please read the file INSTALL. + + +HOW CAN YOU HELP +---------------- + +It helps already a lot if you just install glibc on your system and try to +solve any problems. You might want to look at the file `PROJECTS' and help +with one of those projects, fix some bugs (see `BUGS' or the bug database), +port to an unsupported platform, ... + + +FURTHER DOCUMENTATION +--------------------- + +A lot of questions are answered in the FAQ. The files `INSTALL', `README' and +`NOTES' contain the most important documentation. Furthermore glibc has its +own 700+ pages info documentation, ... + + + +And finally a word of caution: The libc is one of the most fundamental parts +of your system - and these snapshots are untested and come without any +guarantee or warranty. You might be lucky and everything works or you might +crash your system. If you install a glibc snapshot as primary library, you +should have a backup somewhere. + +On many systems it is also a problem to replace the libc while the system is +running. In the worst case on broken OSes some systems crash. On better +systems you can move the old libc aside but removing it will cause problems +since there are still processes using this libc image and so you might have to +check the filesystem to get rid of the libc data. One good alternative (which +is also safer) is to use a chroot'ed environment. + +Thanks for your help and support. + +Thanks to Fred Fish from Cygnus for the original version of this text +(for GDB). + + +Ulrich Drepper diff -Naur ../glibc-2.1.3/README.template glibc-2.1.3/README.template --- ../glibc-2.1.3/README.template 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/README.template 1999-07-28 15:46:07.000000000 -0700 @@ -0,0 +1,96 @@ +This directory contains the version VERSION release of the GNU C Library. +Many bugs have been fixed since the last release. +Some bugs surely remain. + +As of this release, the GNU C library is known to run on the following +configurations: + + *-*-gnu GNU Hurd + i[3456]86-*-linux-gnu Linux-2.x on Intel + m68k-*-linux-gnu Linux-2.x on Motorola 680x0 + alpha-*-linux-gnu Linux-2.x on DEC Alpha + powerpc-*-linux-gnu Linux and MkLinux on PowerPC systems + sparc-*-linux-gnu Linux-2.x on SPARC + sparc64-*-linux-gnu Linux-2.x on UltraSPARC + arm-*-none ARM standalone systems + arm-*-linux Linux-2.x on ARM + arm-*-linuxaout Linux-2.x on ARM using a.out binaries + + +Former releases of this library (version 1.09.1 and perhaps earlier +versions) used to run on the following configurations: + + alpha-dec-osf1 + i[3456]86-*-bsd4.3 + i[3456]86-*-isc2.2 + i[3456]86-*-isc3 + i[3456]86-*-sco3.2 + i[3456]86-*-sco3.2v4 + i[3456]86-*-sysv + i[3456]86-*-sysv4 + i[3456]86-force_cpu386-none + i[3456]86-sequent-bsd + i960-nindy960-none + m68k-hp-bsd4.3 + m68k-mvme135-none + m68k-mvme136-none + m68k-sony-newsos3 + m68k-sony-newsos4 + m68k-sun-sunos4 + mips-dec-ultrix4 + mips-sgi-irix4 + sparc-sun-solaris2 + sparc-sun-sunos4 + +Since no one has volunteered to test and fix the above configurations, +these are not supported at the moment. It's expected that these don't +work anymore. Porting the library is not hard. If you are interested +in doing a port, please contact the glibc maintainers by sending +electronic mail to . + +The GNU C library now includes Michael Glad's Ultra Fast Crypt, which +provides the Unix `crypt' function, plus some other entry points. +Because of the United States export restriction on DES +implementations, we are distributing this code separately from the +rest of the C library. There is an extra distribution tar file just +for crypt; it is called `glibc-crypt-VERSION.tar.gz'. You can just +unpack the crypt distribution along with the rest of the C library and +build; you can also build the library without getting crypt. Users +outside the USA can get the crypt distribution via anonymous FTP from +ftp.gwdg.de [134.76.11.100] in the directory pub/linux/glibc, or +another archive site outside the USA. Archive maintainers are +encouraged to copy this distribution to their archives outside the +USA. Please get it from ftp.gwdg.de; transferring this distribution +from ftp.gnu.org (or any other site in the USA) to a site outside the +USA is in violation of US export laws. + +Beside the separate crypt tar file there are some more add-ons which can be +used together with GNU libc. They are designed in a way to ease the +installation by integrating them in the libc source tree. Simply get the +add-ons you need and use the --enable-add-ons option of the `configure' +script to tell where the add-ons are found. Please read the FAQ file for +more details. + +See the file INSTALL to find out how to configure, build, install, and port +the GNU C library. You might also consider reading the WWW pages for the +GNU libc at http://www.gnu.org/software/libc/libc.html. + +The GNU C Library is completely documented by the Texinfo manual found +in the `manual/' subdirectory. The manual is still being updated and +contains some known errors and omissions; we regret that we do not +have the resources to work on the manual as much as we would like. +Please send comments on the manual to , and +not to the library bug-reporting address. + +The file NOTES contains a description of the feature-test macros used +in the GNU C library, explaining how you can tell the library what +facilities you want it to make available. + +We prefer to get bug reports sent using the `glibcbug' shell script which +is installed together with the rest of the GNU libc to . +Simply run this shell script and fill in the information. Nevertheless +you can still send bug reports to as normal electronic +mails. + +The GNU C Library is free software. See the file COPYING.LIB for copying +conditions. diff -Naur ../glibc-2.1.3/Versions.def glibc-2.1.3/Versions.def --- ../glibc-2.1.3/Versions.def 1999-11-15 16:24:57.000000000 -0800 +++ glibc-2.1.3/Versions.def 1999-12-27 08:16:06.000000000 -0800 @@ -31,6 +31,7 @@ libnsl { GLIBC_2.0 GLIBC_2.1 GLIBC_2.0 + GLIBC_2.1.2 GLIBC_2.1 } libnss_compat { GLIBC_2.0 diff -Naur ../glibc-2.1.3/c_stubs/Banner glibc-2.1.3/c_stubs/Banner --- ../glibc-2.1.3/c_stubs/Banner 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/Banner 2000-02-25 16:35:04.000000000 -0800 @@ -0,0 +1 @@ +The C stubs add-on version 2.1.2. diff -Naur ../glibc-2.1.3/c_stubs/COPYING.LIB glibc-2.1.3/c_stubs/COPYING.LIB --- ../glibc-2.1.3/c_stubs/COPYING.LIB 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/COPYING.LIB 2000-02-25 16:35:05.000000000 -0800 @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Naur ../glibc-2.1.3/c_stubs/ChangeLog glibc-2.1.3/c_stubs/ChangeLog --- ../glibc-2.1.3/c_stubs/ChangeLog 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/ChangeLog 2000-02-27 11:35:23.000000000 -0800 @@ -0,0 +1,32 @@ +2000-02-27 Cristian Gafton + + * gconv_stubs.c: Return __gconv_OK for: + __gconv_transform_ascii_internal + __gconv_transform_ucs2little_internal + __gconv_transform_utf16_internal + __gconv_transform_utf8_internal + __gconv_transform_ucs2_internal + +2000-02-25 Cristian Gafton + + * gconv_stubs.c: add __c_stubs_is_compiled_in so we can detect when + the library is linked in. + +Wed Dec 8 13:47:25 1999 Ivan Brunello + + * Makefile (extra-objs): Changed stubs.o to gconv_stubs.o. + +Sun Dec 5 11:32:17 1999 H.J. Lu + + * gconv_stubs.c: Renamed from stubs.c. + Support glibc 2.1.x. + +Mon Aug 23 16:42:05 1999 H.J. Lu + + * Banner: New. + * COPYING.LIB: Likewise. + * Makefile: Likewise. + * README: Likewise. + * configure: Likewise. + * stubs.c: Likewise. + * test-stdio.c: Likewise. diff -Naur ../glibc-2.1.3/c_stubs/Makefile glibc-2.1.3/c_stubs/Makefile --- ../glibc-2.1.3/c_stubs/Makefile 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/Makefile 2000-02-25 16:35:05.000000000 -0800 @@ -0,0 +1,46 @@ +# Copyright (C) 1999 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 Library General Public License as +# published by the Free Software Foundation; either version 2 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# +# Sub-makefile for the C stub add-on library. +# +subdir := c_stubs + +tests-static := test-stdio +tests := $(tests-static) + +libc_stubs-objs := gconv_stubs.o + +install-lib := libc_stubs.a +non-lib.a := libc_stubs.a + +extra-objs := gconv_stubs.o libc_stubs.a + +include ../Makeconfig + +CPPFLAGS += -I../iconv + +include ../Rules + +$(objpfx)libc_stubs.a: $(addprefix $(objpfx), $(libc_stubs-objs)) + -rm -f $@ + $(LD) -r -o $@ $^ + +lib: $(objpfx)libc_stubs.a + +$(objpfx)test-stdio: $(objpfx)libc_stubs.a diff -Naur ../glibc-2.1.3/c_stubs/README glibc-2.1.3/c_stubs/README --- ../glibc-2.1.3/c_stubs/README 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/README 2000-02-25 16:35:05.000000000 -0800 @@ -0,0 +1,8 @@ +This is a stub add-on library for the GNU C library version 2.1.2 and +above. It is used to create the smaller static binaries by stubbing +out the gconv related functions. The resulting binaries may not have +all the functionalities. + +H.J. Lu +hjl@gnu.org +12/05/1999 diff -Naur ../glibc-2.1.3/c_stubs/configure glibc-2.1.3/c_stubs/configure --- ../glibc-2.1.3/c_stubs/configure 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/configure 2000-02-25 16:35:05.000000000 -0800 @@ -0,0 +1,2 @@ +# This is only to keep the GNU C library configure mechanism happy. +exit 0 diff -Naur ../glibc-2.1.3/c_stubs/gconv_stubs.c glibc-2.1.3/c_stubs/gconv_stubs.c --- ../glibc-2.1.3/c_stubs/gconv_stubs.c 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/gconv_stubs.c 2000-02-27 11:35:23.000000000 -0800 @@ -0,0 +1,83 @@ +/* Provide gconv stub functions for the minimum static binaries. + Copyright (C) 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +/* hack for self identification */ +int __c_stubs_is_compiled_in; + +/* Don't drag in the dynamic linker. */ +void *__libc_stack_end; + +int +__gconv_OK () +{ +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 1 + return __GCONV_OK; +#else + return GCONV_OK; +#endif +} + +int +__gconv_NOCONV () +{ +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 1 + return __GCONV_NOCONV; +#else + return GCONV_NOCONV; +#endif +} + +strong_alias (__gconv_OK, + __gconv_close_transform); + +strong_alias (__gconv_NOCONV, + __gconv); +strong_alias (__gconv_NOCONV, + __gconv_find_transform); +strong_alias (__gconv_NOCONV, + __gconv_open); + +/* These transformations should not fail in normal conditions */ +strong_alias (__gconv_OK, + __gconv_transform_ascii_internal); +strong_alias (__gconv_OK, + __gconv_transform_ucs2little_internal); +strong_alias (__gconv_OK, + __gconv_transform_utf16_internal); +strong_alias (__gconv_OK, + __gconv_transform_utf8_internal); +strong_alias (__gconv_OK, + __gconv_transform_ucs2_internal); + +/* We can assume no conversion for these ones */ +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_ascii); +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_ucs2); +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_ucs2little); +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_ucs4); +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_utf16); +strong_alias (__gconv_NOCONV, + __gconv_transform_internal_utf8); diff -Naur ../glibc-2.1.3/c_stubs/test-stdio.c glibc-2.1.3/c_stubs/test-stdio.c --- ../glibc-2.1.3/c_stubs/test-stdio.c 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/c_stubs/test-stdio.c 2000-02-25 16:35:05.000000000 -0800 @@ -0,0 +1,8 @@ +#include + +int +main () +{ + printf ("Hello world\n"); + return 0; +} diff -Naur ../glibc-2.1.3/config-name.in glibc-2.1.3/config-name.in --- ../glibc-2.1.3/config-name.in 1994-12-08 01:12:33.000000000 -0800 +++ glibc-2.1.3/config-name.in 1998-02-07 12:00:39.000000000 -0800 @@ -1,5 +1,5 @@ /* @configure_input@ -*- C -*- - Generated from $Id: config-name.in,v 1.1 1994/12/08 09:12:33 roland Exp $. + Generated from $Id: config-name.in,v 1.1.1.1 1998/02/07 20:00:39 gafton Exp $. This is used only by the generic `uname' function for systems with no real `uname' call. If this data is not correct, it does not matter much. */ diff -Naur ../glibc-2.1.3/config.make.in glibc-2.1.3/config.make.in --- ../glibc-2.1.3/config.make.in 2000-02-11 15:49:41.000000000 -0800 +++ glibc-2.1.3/config.make.in 2000-02-14 12:05:50.000000000 -0800 @@ -1,5 +1,5 @@ # @configure_input@ -# From $Id: config.make.in,v 1.61.2.2 2000/02/11 20:45:02 drepper Exp $. +# From $Id: config.make.in,v 1.1.1.2 2000/02/14 20:05:50 gafton Exp $. # Don't edit this file. Put configuration parameters in configparms instead. version = @VERSION@ diff -Naur ../glibc-2.1.3/db2/include/queue.h glibc-2.1.3/db2/include/queue.h --- ../glibc-2.1.3/db2/include/queue.h 1998-06-09 08:03:53.000000000 -0700 +++ glibc-2.1.3/db2/include/queue.h 1998-07-09 11:45:13.000000000 -0700 @@ -1,4 +1,4 @@ -/* BSDI $Id: queue.h,v 1.3 1998/06/09 15:03:53 drepper Exp $ */ +/* BSDI $Id: queue.h,v 1.1.1.1 1998/07/09 18:45:13 gafton Exp $ */ /* * Copyright (c) 1991, 1993 diff -Naur ../glibc-2.1.3/elf/rtld.c glibc-2.1.3/elf/rtld.c --- ../glibc-2.1.3/elf/rtld.c 2000-02-22 23:02:47.000000000 -0800 +++ glibc-2.1.3/elf/rtld.c 2000-02-23 14:48:17.000000000 -0800 @@ -758,6 +758,60 @@ __munmap (file, file_size); } + + /* + * Modifications by Red Hat Software + * + * Deal with the broken binaries from the non-versioned ages of glibc. + * If a binary does not have version information enebled, we assume that + * it is a glibc 2.0 binary andwe load a compatibility library to try to + * overcome binary incompatibilities. + * Blame: gafton@redhat.com + */ +#define LIB_NOVERSION "/lib/libNoVersion.so.1" + + if (_dl_loaded->l_info[DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (DT_VERNEED)] == NULL) { + struct link_map *new_map = NULL; + struct stat test_st; + int test_fd; + int can_load; + + HP_TIMING_NOW (start); + +/* _dl_sysdep_message("Loading compatibility library... ", NULL); */ + + can_load = 1; + test_fd = __open (LIB_NOVERSION, O_RDONLY); + if (test_fd < 0) { + can_load = 0; +/* _dl_sysdep_message(" Can't find " LIB_NOVERSION "\n", NULL); */ + } else { + if (__fxstat (_STAT_VER, test_fd, &test_st) < 0 || test_st.st_size == 0) { + can_load = 0; +/* _dl_sysdep_message(" Can't stat " LIB_NOVERSION "\n", NULL); */ + } + } + + if (test_fd >= 0) /* open did no fail.. */ + __close(test_fd); /* avoid fd leaks */ + + if (can_load != 0) { + new_map = _dl_map_object (_dl_loaded, LIB_NOVERSION, + 1, lt_library, 0); + if (new_map->l_opencount == 1) { + /* It is no duplicate. */ + ++npreloads; +/* _dl_sysdep_message(" DONE\n", NULL); */ + } else { +/* _dl_sysdep_message(" FAILED\n", NULL); */ + } + } + + HP_TIMING_NOW (stop); + HP_TIMING_DIFF (diff, start, stop); + HP_TIMING_ACCUM_NT (load_time, diff); + } + if (npreloads != 0) { /* Set up PRELOADS with a vector of the preloaded libraries. */ diff -Naur ../glibc-2.1.3/glibc-2.1.spec glibc-2.1.3/glibc-2.1.spec --- ../glibc-2.1.3/glibc-2.1.spec 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-2.1.spec 2000-02-29 13:27:37.000000000 -0800 @@ -0,0 +1,305 @@ +Summary: The GNU libc libraries. +Name: glibc +Version: 2.1.3 +Release: 15 +Copyright: LGPL +Group: System Environment/Libraries +Source: %{name}-%{version}.tar.gz +# Other sources are available at: +# http://www.ozemail.com.au/~geoffk/glibc-crypt/glibc-crypt-2.1.tar.gz +# In the source tarball the file diff-CYGNUS-to-REDHAT.patch contains all +# diffs applied by Red Hat to the current CVS version of glibc +Buildroot: /var/tmp/glibc-%{PACKAGE_VERSION}-root +Obsoletes: zoneinfo, libc-static, libc-devel, libc-profile, libc-headers, +Obsoletes: linuxthreads, gencat, locale +Autoreq: false +%ifarch alpha +Provides: ld.so.2 +%else +%endif +%ifarch sparc +Obsoletes: libc +%endif + +%description +The glibc package contains standard libraries which are used by +multiple programs on the system. In order to save disk space and +memory, as well as to make upgrading easier, common system code is +kept in one place and shared between programs. This particular package +contains the most important sets of shared libraries: the standard C +library and the standard math library. Without these two libraries, a +Linux system will not function. The glibc package also contains +national language (locale) support and timezone databases. + +%package devel +Summary: Header and object files for development using standard C libraries. +Group: Development/Libraries +Conflicts: texinfo < 3.11 +Prereq: /sbin/install-info +Obsoletes: libc-debug, libc-headers, libc-devel, linuxthreads-devel +Obsoletes: glibc-debug +Prereq: kernel-headers +Requires: kernel-headers >= 2.2.1 +Autoreq: true + +%description devel +The glibc-devel package contains the header and object files necessary +for developing programs which use the standard C libraries (which are +used by nearly all programs). If you are developing programs which +will use the standard C libraries, your system needs to have these +standard header and object files available in order to create the +executables. + +Install glibc-devel if you are going to develop programs which will +use the standard C libraries. + +%package profile +Summary: The GNU libc libraries, including support for gprof profiling. +Group: Development/Libraries +Obsoletes: libc-profile +Autoreq: true + +%description profile +The glibc-profile package includes the GNU libc libraries and support +for profiling using the gprof program. Profiling is analyzing a +program's functions to see how much CPU time they use and determining +which functions are calling other functions during execution. To use +gprof to profile a program, your program needs to use the GNU libc +libraries included in glibc-profile (instead of the standard GNU libc +libraries included in the glibc package). + +If you are going to use the gprof program to profile a program, you'll +need to install the glibc-profile program. + +%package -n nscd +Summary: A Name Service Caching Daemon (nscd). +Group: System Environment/Daemons +Conflicts: kernel < 2.2.0 +Prereq: /sbin/chkconfig +Autoreq: true + +%description -n nscd +Nscd caches name service lookups and can dramatically improve +performance with NIS+, and may help with DNS as well. Note that you +can't use nscd with 2.0 kernels because of bugs in the kernel-side +thread support. Unfortunately, nscd happens to hit these bugs +particularly hard. + +Install nscd if you need a name service lookup caching daemon, and +you're not using a version 2.0 kernel. + +%prep +%setup -q + +%ifarch armv4l +rm -rf glibc-compat +%endif + +find . -type f -size 0 -o -name "*.orig" -exec rm -f {} \; + +%build +rm -rf build-$RPM_ARCH-linux +mkdir build-$RPM_ARCH-linux ; cd build-$RPM_ARCH-linux +%ifarch i586 i686 +BuildFlags="-mpentium -D__USE_STRING_INLINES -fstrict-aliasing -mcpu=%{_target_cpu}" +%endif +%ifarch sparcv9 +BuildFlags="-mv8 -mtune=ultrasparc" +%endif +CC=egcs CFLAGS="$BuildFlags -g -O3" ../configure --prefix=/usr \ + --enable-add-ons=yes --without-cvs \ + %{_target_cpu}-redhat-linux +make -r CFLAGS="$BuildFlags -g -O3" PARALLELMFLAGS=-s + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT +make install_root=$RPM_BUILD_ROOT install -C build-$RPM_ARCH-linux +cd build-$RPM_ARCH-linux && \ + make install_root=$RPM_BUILD_ROOT install-locales -C ../localedata objdir=`pwd` && \ + cd .. + +# compatibility hack: this locale has vanished from glibc, but some other +# programs are still using it. Normally we would handle it in the %pre +# section but with glibc that is simply not an option +mkdir -p $RPM_BUILD_ROOT/usr/share/locale/ru_RU/LC_MESSAGES + +# Remove the files we don't want to distribute +rm -f $RPM_BUILD_ROOT/usr/lib/libNoVersion* + +# the man pages for the linuxthreads require special attention +make -C linuxthreads/man +mkdir -p $RPM_BUILD_ROOT/usr/man/man3 +install -m 0644 linuxthreads/man/*.3thr $RPM_BUILD_ROOT/usr/man/man3 +gzip -9nvf $RPM_BUILD_ROOT/usr/man/man3/* + +gzip -9nvf $RPM_BUILD_ROOT/usr/info/libc* + +ln -sf libbsd-compat.a $RPM_BUILD_ROOT/usr/lib/libbsd.a + +install -m 644 redhat/nsswitch.conf $RPM_BUILD_ROOT/etc/nsswitch.conf + +# Take care of setuids +# -- new security review sez that this shouldn't be needed anymore +#chmod 755 $RPM_BUILD_ROOT/usr/libexec/pt_chown + +# This is for ncsd - in glibc 2.1 +install -m 644 nscd/nscd.conf $RPM_BUILD_ROOT/etc +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d +install -m 755 nscd/nscd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/nscd + +# The database support +mkdir -p $RPM_BUILD_ROOT/var/db +install -m 644 nss/db-Makefile $RPM_BUILD_ROOT/var/db/Makefile + +# Strip binaries +strip $RPM_BUILD_ROOT/sbin/* || : +strip $RPM_BUILD_ROOT/usr/bin/* || : +strip $RPM_BUILD_ROOT/usr/sbin/* || : + +# BUILD THE FILE LIST +find $RPM_BUILD_ROOT -type f -or -type l | + sed -e 's|.*/etc|%config &|' > rpm.filelist.in +for n in /usr/share /usr/include; do + find ${RPM_BUILD_ROOT}${n} -type d | \ + grep -v '^/usr/share$' | \ + sed "s/^/%dir /" >> rpm.filelist.in +done + +# primary filelist +sed "s|$RPM_BUILD_ROOT||" < rpm.filelist.in | + grep -v '/etc/localtime' | \ + grep -v '/etc/nsswitch.conf' | \ + sort > rpm.filelist + +grep '/usr/lib/lib.*_p\.a' < rpm.filelist > profile.filelist +egrep "(/usr/include)|(/usr/info)" < rpm.filelist | + grep -v /usr/info/dir > devel.filelist + +mv rpm.filelist rpm.filelist.full +grep -v '/usr/lib/lib.*_p.a' rpm.filelist.full | + egrep -v "(/usr/include)|(/usr/info)" > rpm.filelist + +grep '/usr/lib/lib.*\.a' < rpm.filelist >> devel.filelist +grep '/usr/lib/.*\.o' < rpm.filelist >> devel.filelist +grep '/usr/lib/lib.*\.so' < rpm.filelist >> devel.filelist +grep '/usr/man/man' < rpm.filelist >> devel.filelist + +mv rpm.filelist rpm.filelist.full +grep -v '/usr/lib/lib.*\.a' < rpm.filelist.full | + grep -v '/usr/lib/.*\.o' | + grep -v '/usr/lib/lib.*\.so'| + grep -v '/usr/man/man' | + grep -v 'nscd' > rpm.filelist + +# /etc/localtime - we're proud of our timezone +rm -f $RPM_BUILD_ROOT/etc/localtime +cp -f $RPM_BUILD_ROOT/usr/share/zoneinfo/US/Eastern $RPM_BUILD_ROOT/etc/localtime +#ln -sf ../usr/share/zoneinfo/US/Eastern $RPM_BUILD_ROOT/etc/localtime + +# the last bit: more documentation +rm -rf documentation +mkdir documentation +cp linuxthreads/ChangeLog documentation/ChangeLog.threads +cp linuxthreads/Changes documentation/Changes.threads +cp linuxthreads/README documentation/README.threads +cp linuxthreads/FAQ.html documentation/FAQ-threads.html +cp -r linuxthreads/Examples documentation/examples.threads +cp crypt/README documentation/README.crypt +cp db2/README documentation/README.db2 +cp db2/mutex/README documentation/README.db2.mutex +cp timezone/README documentation/README.timezone +cp ChangeLog* documentation +gzip -9 documentation/ChangeLog* + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%post devel +/sbin/install-info /usr/info/libc.info.gz /usr/info/dir + +%pre devel +# this used to be a link and it is causing nightmares now +if [ -L /usr/include/scsi ] ; then + rm -f /usr/include/scsi +fi + +%preun devel +if [ "$1" = 0 ]; then + /sbin/install-info --delete /usr/info/libc.info.gz /usr/info/dir +fi + +%post -n nscd +/sbin/chkconfig --add nscd + +%preun -n nscd +if [ $1 = 0 ] ; then + /sbin/chkconfig --del nscd +fi + +%clean +rm -rf "$RPM_BUILD_ROOT" +rm -f *.filelist* + +%files -f rpm.filelist +%defattr(-,root,root) +%config(noreplace) /etc/localtime +%config(noreplace) /etc/nsswitch.conf +%doc README NEWS INSTALL FAQ BUGS NOTES PROJECTS +%doc documentation/* README.template README.libm +%doc login/README.utmpd hesiod/README.hesiod +%dir /var/db + +%ifnarch sparcv9 i586 i686 +%files -f devel.filelist devel +%defattr(-,root,root) + +%files -f profile.filelist profile +%defattr(-,root,root) + +%files -n nscd +%defattr(-,root,root) +%config /etc/nscd.conf +/etc/rc.d/init.d/nscd +/usr/sbin/nscd +%endif + +%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) + +%changelog +* %{date} Cristian Gafton +- fix c_stubs add-on to work around various assert()s in glibc +- add Davem's patch for _NPROCESSORS_ONLN on Sparc + +* Fri Feb 25 2000 Cristian Gafton +- add the c_stubs add-on +- sparc patch from davem + +* Thu Feb 24 2000 Cristian Gafton +- fix locale problems on 64 bit arches + +* Tue Feb 22 2000 Cristian Gafton +- cygnus sync up for fixes to nscd + +* Thu Feb 17 2000 Cristian Gafton +- updated to include new China timezones +- sync up with the locale changes from Cygnus + +* Tue Feb 01 2000 Cristian Gafton +- updated from cygnus branch +- fix syslog so that it will continuously try to fallback from SOK_DGRAM to + SOCK_STREAM and backwards + +* Mon Jan 31 2000 Cristian Gafton +- update from cygnus branch +- compress man pages for the linuxthreads stuff + +* Fri Jan 21 2000 Cristian Gafton +- add Jakub's patch so we back out even more + +* Thu Jan 20 2000 Cristian Gafton +- back out the setrlimit changes (well, sort of) + +* Mon Jan 03 2000 Cristian Gafton +- make release from CVS server directly now diff -Naur ../glibc-2.1.3/glibc-compat/.cvsignore glibc-2.1.3/glibc-compat/.cvsignore --- ../glibc-2.1.3/glibc-compat/.cvsignore 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/.cvsignore 2000-01-03 18:17:33.000000000 -0800 @@ -0,0 +1 @@ +glibc-compat*.tar.gz diff -Naur ../glibc-2.1.3/glibc-compat/Banner glibc-2.1.3/glibc-compat/Banner --- ../glibc-2.1.3/glibc-compat/Banner 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/Banner 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1 @@ +Glibc-2.0 compatibility add-on by Cristian Gafton diff -Naur ../glibc-2.1.3/glibc-compat/ChangeLog glibc-2.1.3/glibc-compat/ChangeLog --- ../glibc-2.1.3/glibc-compat/ChangeLog 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/ChangeLog 2000-02-23 17:59:39.000000000 -0800 @@ -0,0 +1,24 @@ +2000-02-23 Cristian Gafton + + * stubs.c (__setfpucw): Avoid using _FPU_SETCW on platform that do not have it + +1999-07-08 Cristian Gafton + + * stubs.c (__setfpucw): New function + * Makefile: Use -include, not include + (archive): New target. + + +1999-04-09 Andreas Jaeger + * glibc-compat/Makefile: Add rules to link libnss_*.so.1 to libnss1_*.so.2. + +1998-11-18 Cristian Gafton + + * shlib-versions: added alpha versions + + * Makefile (services): Added libnss_dns + +1998-11-16 Cristian Gafton + + * makedist (archive): remove old tar file just in case + diff -Naur ../glibc-2.1.3/glibc-compat/Depend glibc-2.1.3/glibc-compat/Depend --- ../glibc-2.1.3/glibc-compat/Depend 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/Depend 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1,3 @@ +resolv +nss +nis diff -Naur ../glibc-2.1.3/glibc-compat/Makefile glibc-2.1.3/glibc-compat/Makefile --- ../glibc-2.1.3/glibc-compat/Makefile 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/Makefile 2000-01-06 09:33:12.000000000 -0800 @@ -0,0 +1,152 @@ +# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + +# This is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# $Id: Makefile,v 1.2 2000/01/06 17:33:12 gafton Exp $ + +subdir := glibc-compat + +distribute := nss-nis.h + +# This is the trivial part which goes into libc itself. +routines = + +# These are the databases that go through nss dispatch. +# Caution: if you add a database here, you must add its real name +# in databases.def, too. +databases = proto service hosts network grp pwd rpc ethers \ + spwd netgrp alias + +# Specify rules for the nss_* modules. We have some services. +services := files nis compat dns db + +extra-libs := $(services:%=libnss1_%) libNoVersion +# 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) + +# The sources are found in the appropriate subdir. +subdir-dirs = $(services:%=nss_%) +vpath %.c $(subdir-dirs) + +libnss1_files-routines := $(addprefix files-,$(databases)) +libnss1_db-routines := $(addprefix db-,$(filter-out hosts network,$(databases))) +libnss1_compat-routines := $(addprefix compat-,grp pwd spwd) +libnss1_nis-routines := $(addprefix nis-,$(databases)) +libnss1_dns-routines := $(addprefix dns-, host network) + +libcompat-routines := $(addprefix old, fileops iofdopen iopopen stdfiles \ + iofclose iofopen pclose tmpfile) +libNoVersion-routines := stubs + +generated += $(filter-out db-alias.c db-netgrp.c, \ + $(addsuffix .c,$(libnss1_db-routines))) + +libnss1_files-inhibit-o = $(filter-out .os,$(object-suffixes)) +libnss1_db-inhibit-o = $(filter-out .os,$(object-suffixes)) +libnss1_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) +libnss1_nis-inhibit-o = $(filter-out .os,$(object-suffixes)) +libnss1_dns-inhibit-o = $(filter-out .os,$(object-suffixes)) + +-include ../Rules + +# Force the soname to be libnss_*.so.1 for compatibility. +LDFLAGS-nss1_files.so = -Wl,-soname=lib$(libprefix)nss_files.so$($(@F)-version) +LDFLAGS-nss1_db.so = -Wl,-soname=lib$(libprefix)nss_db.so$($(@F)-version) +LDFLAGS-nss1_nis.so = -Wl,-soname=lib$(libprefix)nss_nis.so$($(@F)-version) +LDFLAGS-nss1_compat.so = -Wl,-soname=lib$(libprefix)nss_compat.so$($(@F)-version) +LDFLAGS-nss1_dns.so = -Wl,-soname=lib$(libprefix)nss_dns.so$($(@F)-version) + +-include ../Makeconfig + +ifeq (yes,$(build-shared)) +install-others += $(inst_slibdir)/libnss_files.so$(libnss1_files.so-version) \ + $(inst_slibdir)/libnss_db.so$(libnss1_db.so-version) \ + $(inst_slibdir)/libnss_nis.so$(libnss1_nis.so-version) \ + $(inst_slibdir)/libnss_compat.so$(libnss1_compat.so-version) \ + $(inst_slibdir)/libnss_dns.so$(libnss1_dns.so-version) +endif + +$(inst_slibdir)/libnss_files.so$(libnss1_files.so-version): $(inst_slibdir)/libnss1_files-$(version).so $(+force) + rm -f $@ + $(LN_S) $(') > $@.new + mv -f $@.new $@ + +$(objpfx)libnss1_compat.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \ + $(objpfx)libnss1_files.so +$(objpfx)libnss1_nis.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \ + $(objpfx)libnss1_files.so + +# The DNS NSS modules needs the resolver. +#$(objpfx)libnss1_dns.so: $(filter-out $(common-objpfx)resolv/stamp.os, \ +# $(wildcard $(common-objpfx)resolv/*.os)) \ +# $(common-objpfx)libc.so +$(objpfx)libnss1_dns.so: $(common-objpfx)resolv/libresolv.so $(common-objpfx)libc.so + +# Depend on libc.so so a DT_NEEDED is generated in the shared objects. +# This ensures they will load libc.so for needed symbols if loaded by +# a statically-linked program that hasn't already loaded it. +$(objpfx)libnss1_compat.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \ + $(objpfx)libnss1_files.so $(common-objpfx)libc.so +$(objpfx)libnss1_db.so: $(common-objpfx)db2/libdb.so $(objpfx)libnss1_files.so\ + $(common-objpfx)libc.so +$(objpfx)libnss1_dns.so: $(common-objpfx)resolv/libresolv.so \ + $(common-objpfx)libc.so +$(objpfs)libnss1_files.so: $(common-objpfx)libc.so +$(objpfx)libnss1_nis.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \ + $(objpfx)libnss1_files.so $(common-objpfx)libc.so + + +# +# This is needed to build the separate tarball +# +pkgNAME = $(subdir) +pkgVERSION = 2.1.2 +pkgCVSTAG = $(pkgNAME)_$(subst .,-,$(pkgVERSION)) + +archive: + @rm -f *.tar.gz *~ + cvs tag -F $(pkgCVSTAG) . + @rm -rf /tmp/$(pkgNAME)-$(pkgVERSION) /tmp/$(pkgNAME) $(pkgNAME)-$(pkgVERSION).tar.gz + @cd /tmp; cvs export -r$(pkgCVSTAG) $(pkgNAME) + @pkgDIR=$$PWD; cd /tmp; tar cvzf $$pkgDIR/$(pkgNAME)-$(pkgVERSION).tar.gz $(pkgNAME) + @rm -rf /tmp/$(pkgNAME) + @echo "The archive is in $(pkgNAME)-$(pkgVERSION).tar.gz" diff -Naur ../glibc-2.1.3/glibc-compat/Versions glibc-2.1.3/glibc-compat/Versions --- ../glibc-2.1.3/glibc-compat/Versions 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/Versions 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1,106 @@ +libnss1_db { + GLIBC_2.0 { + _nss_db_endaliasent; _nss_db_endetherent; _nss_db_endgrent; + _nss_db_endnetgrent; _nss_db_endprotoent; _nss_db_endpwent; + _nss_db_endrpcent; _nss_db_endservent; _nss_db_endspent; + _nss_db_getaliasbyname_r; _nss_db_getaliasent_r; _nss_db_getetherent_r; + _nss_db_getgrent_r; _nss_db_getgrgid_r; _nss_db_getgrnam_r; + _nss_db_gethostton_r; _nss_db_getnetgrent_r; _nss_db_getntohost_r; + _nss_db_getprotobyname_r; _nss_db_getprotobynumber_r; + _nss_db_getprotoent_r; _nss_db_getpwent_r; _nss_db_getpwnam_r; + _nss_db_getpwuid_r; _nss_db_getrpcbyname_r; _nss_db_getrpcbynumber_r; + _nss_db_getrpcent_r; _nss_db_getservbyname_r; _nss_db_getservbyport_r; + _nss_db_getservent_r; _nss_db_getspent_r; _nss_db_getspnam_r; + _nss_db_setaliasent; _nss_db_setetherent; _nss_db_setgrent; + _nss_db_setnetgrent; _nss_db_setprotoent; _nss_db_setpwent; + _nss_db_setrpcent; _nss_db_setservent; _nss_db_setspent; + } +} + +libnss1_dns { + GLIBC_2.0 { + _nss_dns_gethostbyaddr_r; _nss_dns_gethostbyname2_r; + _nss_dns_gethostbyname_r; _nss_dns_getnetbyaddr_r; + _nss_dns_getnetbyname_r; + } +} + +libnss1_files { + GLIBC_2.0 { + _nss_files_setaliasent; _nss_files_endaliasent; + _nss_files_getaliasbyname_r; _nss_files_getaliasent_r; + + _nss_files_setetherent; _nss_files_endetherent; + _nss_files_getetherent_r; _nss_files_parse_etherent; + + _nss_files_setgrent; _nss_files_endgrent; + _nss_files_getgrent_r; _nss_files_getgrgid_r; _nss_files_getgrnam_r; + + _nss_files_sethostent; _nss_files_endhostent; + _nss_files_gethostbyaddr_r; _nss_files_gethostbyname2_r; _nss_files_gethostbyname_r; + _nss_files_gethostent_r; _nss_files_gethostton_r; + + _nss_files_setnetent; _nss_files_endnetent; + _nss_files_getnetbyaddr_r; _nss_files_getnetbyname_r; + _nss_files_getnetent_r; _nss_files_getntohost_r; + _nss_files_parse_netent; + + _nss_files_setnetgrent; _nss_files_endnetgrent; _nss_files_getnetgrent_r; + + _nss_files_setprotoent; _nss_files_endprotoent; + _nss_files_getprotobyname_r; _nss_files_getprotobynumber_r; + _nss_files_getprotoent_r; _nss_files_parse_protoent; + + _nss_files_setpwent; _nss_files_endpwent; + _nss_files_getpwent_r; _nss_files_getpwnam_r; _nss_files_getpwuid_r; + + _nss_files_setrpcent; _nss_files_endrpcent; + _nss_files_getrpcbyname_r; _nss_files_getrpcbynumber_r; + _nss_files_getrpcent_r; + _nss_files_parse_rpcent; + + _nss_files_setservent; _nss_files_endservent; + _nss_files_getservbyname_r; _nss_files_getservbyport_r; + _nss_files_getservent_r; + _nss_files_parse_servent; + + _nss_files_setspent; _nss_files_endspent; + _nss_files_getspent_r; _nss_files_getspnam_r; + + _nss_netgroup_parseline; + } +} + +libnss1_compat { + GLIBC_2.0 { + _nss_compat_endgrent; _nss_compat_endpwent; _nss_compat_endspent; + _nss_compat_getgrent_r; _nss_compat_getgrgid_r; _nss_compat_getgrnam_r; + _nss_compat_getpwent_r; _nss_compat_getpwnam_r; _nss_compat_getpwuid_r; + _nss_compat_getspent_r; _nss_compat_getspnam_r; _nss_compat_initgroups; + _nss_compat_setgrent; _nss_compat_setpwent; _nss_compat_setspent; + } +} + +libnss1_nis { + GLIBC_2.0 { + _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_initgroups; + _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; + } +} diff -Naur ../glibc-2.1.3/glibc-compat/Versions.def glibc-2.1.3/glibc-compat/Versions.def --- ../glibc-2.1.3/glibc-compat/Versions.def 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/Versions.def 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1,15 @@ +libnss1_files { + GLIBC_2.0 +} +libnss1_db { + GLIBC_2.0 +} +libnss1_dns { + GLIBC_2.0 +} +libnss1_nis { + GLIBC_2.0 +} +libnss1_compat { + GLIBC_2.0 +} diff -Naur ../glibc-2.1.3/glibc-compat/configure glibc-2.1.3/glibc-compat/configure --- ../glibc-2.1.3/glibc-compat/configure 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/configure 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1,28 @@ +#! /bin/sh +# +# We need a configure script only when compiling as part of GNU C library. +# Here we have to generate one of the files we need while compiling. +# +# The only problem is that no users of the package might thing they have to +# run configure themself and find it irritating when nothing happens. +# +# So we try here to find out whether we are called from the glibc configure +# or by a user. If the later is true show a gentle message. +# +saw_srcdir=no +srcdir= +saw_cache_file=no +# We use a simple heuristic which might fail: if we see the argument the +# glibc configure passes we assume it's glibc who calls us. +for opt in $*; do + case $opt in + --srcdir=*) saw_srcdir=yes + srcdir=`echo "$opt" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; + --cache-file=*) saw_cache_file=yes ;; + *) ;; + esac +done + +echo "Configure stage for glibc 2.0 add-on" + +exit 0 diff -Naur ../glibc-2.1.3/glibc-compat/nss-nis.h glibc-2.1.3/glibc-compat/nss-nis.h --- ../glibc-2.1.3/glibc-compat/nss-nis.h 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/nss-nis.h 2000-01-03 17:07:07.000000000 -0800 @@ -0,0 +1,58 @@ +/* Copyright (C) 1996 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _NIS_NSS_NIS_H +#define _NIS_NSS_NIS_H 1 + +#include + +#include "nsswitch.h" + + +/* Convert YP error number to NSS error number. */ +static 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 +}; +#define YPERR_COUNT (sizeof (yperr2nss_tab) / sizeof (yperr2nss_tab[0])) + +static inline enum nss_status +yperr2nss (int errval) +{ + if ((unsigned int) errval > YPERR_COUNT) + return NSS_STATUS_UNAVAIL; + return yperr2nss_tab[errval]; +} + +#endif /* nis/nss-nis.h */ diff -Naur ../glibc-2.1.3/glibc-compat/nss_compat/compat-grp.c glibc-2.1.3/glibc-compat/nss_compat/compat-grp.c --- ../glibc-2.1.3/glibc-compat/nss_compat/compat-grp.c 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/nss_compat/compat-grp.c 2000-01-03 17:07:08.000000000 -0800 @@ -0,0 +1,769 @@ +/* Copyright (C) 1996, 1997, 1998 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Get the declaration of the parser function. */ +#define ENTNAME grent +#define STRUCTURE group +#define EXTERN_PARSER +#include "../nss_files/files-parse.c" + +/* Structure for remembering -group members ... */ +#define BLACKLIST_INITIAL_SIZE 512 +#define BLACKLIST_INCREMENT 256 +struct blacklist_t + { + char *data; + int current; + int size; + }; + +struct ent_t + { + bool_t nis; + bool_t nis_first; + char *oldkey; + int oldkeylen; + FILE *stream; + struct blacklist_t blacklist; +}; +typedef struct ent_t ent_t; + +static ent_t ext_ent = {0, 0, NULL, 0, NULL, {NULL, 0, 0}}; + +/* Protect global state against multiple changers. */ +__libc_lock_define_initialized (static, lock) + +/* Prototypes for local functions. */ +static void blacklist_store_name (const char *, ent_t *); +static int in_blacklist (const char *, int, ent_t *); + +static enum nss_status +internal_setgrent (ent_t *ent) +{ + enum nss_status status = NSS_STATUS_SUCCESS; + + ent->nis = ent->nis_first = 0; + + if (ent->oldkey != NULL) + { + free (ent->oldkey); + ent->oldkey = NULL; + ent->oldkeylen = 0; + } + + if (ent->blacklist.data != NULL) + { + ent->blacklist.current = 1; + ent->blacklist.data[0] = '|'; + ent->blacklist.data[1] = '\0'; + } + else + ent->blacklist.current = 0; + + if (ent->stream == NULL) + { + ent->stream = fopen ("/etc/group", "r"); + + if (ent->stream == NULL) + status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + else + { + /* We have to make sure the file is `closed on exec'. */ + int result, flags; + + result = flags = fcntl (fileno (ent->stream), F_GETFD, 0); + if (result >= 0) + { + flags |= FD_CLOEXEC; + result = fcntl (fileno (ent->stream), F_SETFD, flags); + } + if (result < 0) + { + /* Something went wrong. Close the stream and return a + failure. */ + fclose (ent->stream); + ent->stream = NULL; + status = NSS_STATUS_UNAVAIL; + } + } + } + else + rewind (ent->stream); + + return status; +} + + +enum nss_status +_nss_compat_setgrent (void) +{ + enum nss_status result; + + __libc_lock_lock (lock); + + result = internal_setgrent (&ext_ent); + + __libc_lock_unlock (lock); + + return result; +} + + +static enum nss_status +internal_endgrent (ent_t *ent) +{ + if (ent->stream != NULL) + { + fclose (ent->stream); + ent->stream = NULL; + } + + ent->nis = ent->nis_first = 0; + + if (ent->oldkey != NULL) + { + free (ent->oldkey); + ent->oldkey = NULL; + ent->oldkeylen = 0; + } + + if (ent->blacklist.data != NULL) + { + ent->blacklist.current = 1; + ent->blacklist.data[0] = '|'; + ent->blacklist.data[1] = '\0'; + } + else + ent->blacklist.current = 0; + + return NSS_STATUS_SUCCESS; +} + +enum nss_status +_nss_compat_endgrent (void) +{ + enum nss_status result; + + __libc_lock_lock (lock); + + result = internal_endgrent (&ext_ent); + + __libc_lock_unlock (lock); + + return result; +} + +static enum nss_status +getgrent_next_nis (struct group *result, ent_t *ent, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + char *domain; + char *outkey, *outval; + int outkeylen, outvallen, parse_res; + char *p; + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + { + ent->nis = 0; + return NSS_STATUS_NOTFOUND; + } + + do + { + char *save_oldkey; + int save_oldlen; + bool_t save_nis_first; + + if (ent->nis_first) + { + if (yp_first (domain, "group.byname", &outkey, &outkeylen, + &outval, &outvallen) != YPERR_SUCCESS) + { + ent->nis = 0; + return NSS_STATUS_UNAVAIL; + } + save_oldkey = ent->oldkey; + save_oldlen = ent->oldkeylen; + save_nis_first = TRUE; + ent->oldkey = outkey; + ent->oldkeylen = outkeylen; + ent->nis_first = FALSE; + } + else + { + if (yp_next (domain, "group.byname", ent->oldkey, ent->oldkeylen, + &outkey, &outkeylen, &outval, &outvallen) + != YPERR_SUCCESS) + { + ent->nis = 0; + return NSS_STATUS_NOTFOUND; + } + + save_oldkey = ent->oldkey; + save_oldlen = ent->oldkeylen; + save_nis_first = FALSE; + ent->oldkey = outkey; + ent->oldkeylen = outkeylen; + } + + /* Copy the found data to our buffer */ + p = strncpy (buffer, outval, buflen); + + /* ...and free the data. */ + free (outval); + + while (isspace (*p)) + ++p; + + if ((parse_res = _nss_files_parse_grent (p, result, data, buflen)) == -1) + { + free (ent->oldkey); + ent->oldkey = save_oldkey; + ent->oldkeylen = save_oldlen; + ent->nis_first = save_nis_first; + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + else + { + if (!save_nis_first) + free (save_oldkey); + } + + if (parse_res && + in_blacklist (result->gr_name, strlen (result->gr_name), ent)) + parse_res = 0; /* if result->gr_name in blacklist,search next entry */ + } + while (!parse_res); + + return NSS_STATUS_SUCCESS; +} + +/* This function handle the +group entrys in /etc/group */ +static enum nss_status +getgrnam_plusgroup (const char *name, struct group *result, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + int parse_res; + char *domain, *outval, *p; + int outvallen; + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + return NSS_STATUS_NOTFOUND; + + if (yp_match (domain, "group.byname", name, strlen (name), + &outval, &outvallen) != YPERR_SUCCESS) + return NSS_STATUS_NOTFOUND; + p = strncpy (buffer, outval, + buflen < (size_t) outvallen ? buflen : (size_t) outvallen); + free (outval); + while (isspace (*p)) + p++; + if ((parse_res = _nss_files_parse_grent (p, result, data, buflen)) == -1) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (parse_res) + /* We found the entry. */ + return NSS_STATUS_SUCCESS; + else + return NSS_STATUS_RETURN; +} + +static enum nss_status +getgrent_next_file (struct group *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + while (1) + { + fpos_t pos; + int parse_res = 0; + char *p; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_grent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (result->gr_name[0] != '+' && result->gr_name[0] != '-') + /* This is a real entry. */ + break; + + /* -group */ + if (result->gr_name[0] == '-' && result->gr_name[1] != '\0' + && result->gr_name[1] != '@') + { + blacklist_store_name (&result->gr_name[1], ent); + continue; + } + + /* +group */ + if (result->gr_name[0] == '+' && result->gr_name[1] != '\0' + && result->gr_name[1] != '@') + { + enum nss_status status; + + /* Store the group in the blacklist for the "+" at the end of + /etc/group */ + blacklist_store_name (&result->gr_name[1], ent); + status = getgrnam_plusgroup (&result->gr_name[1], result, buffer, + buflen); + if (status == NSS_STATUS_SUCCESS) /* We found the entry. */ + break; + else + if (status == NSS_STATUS_RETURN /* We couldn't parse the entry */ + || status == NSS_STATUS_NOTFOUND) /* No group in NIS */ + continue; + else + { + if (status == NSS_STATUS_TRYAGAIN) + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + return status; + } + } + + /* +:... */ + if (result->gr_name[0] == '+' && result->gr_name[1] == '\0') + { + ent->nis = TRUE; + ent->nis_first = TRUE; + + return getgrent_next_nis (result, ent, buffer, buflen); + } + } + + return NSS_STATUS_SUCCESS; +} + + +static enum nss_status +internal_getgrent_r (struct group *gr, ent_t *ent, char *buffer, + size_t buflen) +{ + if (ent->nis) + { + return getgrent_next_nis (gr, ent, buffer, buflen); + } + else + return getgrent_next_file (gr, ent, buffer, buflen); +} + +enum nss_status +_nss_compat_getgrent_r (struct group *grp, char *buffer, size_t buflen) +{ + enum nss_status status = NSS_STATUS_SUCCESS; + + __libc_lock_lock (lock); + + /* Be prepared that the setgrent function was not called before. */ + if (ext_ent.stream == NULL) + status = internal_setgrent (&ext_ent); + + if (status == NSS_STATUS_SUCCESS) + status = internal_getgrent_r (grp, &ext_ent, buffer, buflen); + + __libc_lock_unlock (lock); + + return status; +} + +/* Searches in /etc/group and the NIS/NIS+ map for a special group */ +static enum nss_status +internal_getgrnam_r (const char *name, struct group *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + while (1) + { + fpos_t pos; + int parse_res = 0; + char *p; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_grent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* This is a real entry. */ + if (result->gr_name[0] != '+' && result->gr_name[0] != '-') + { + if (strcmp (result->gr_name, name) == 0) + return NSS_STATUS_SUCCESS; + else + continue; + } + + /* -group */ + if (result->gr_name[0] == '-' && result->gr_name[1] != '\0') + { + if (strcmp (&result->gr_name[1], name) == 0) + return NSS_STATUS_NOTFOUND; + else + continue; + } + + /* +group */ + if (result->gr_name[0] == '+' && result->gr_name[1] != '\0') + { + if (strcmp (name, &result->gr_name[1]) == 0) + { + enum nss_status status; + + status = getgrnam_plusgroup (name, result, buffer, buflen); + if (status == NSS_STATUS_RETURN) + /* We couldn't parse the entry */ + continue; + else + return status; + } + } + /* +:... */ + if (result->gr_name[0] == '+' && result->gr_name[1] == '\0') + { + enum nss_status status; + + status = getgrnam_plusgroup (name, result, buffer, buflen); + if (status == NSS_STATUS_RETURN) + /* We couldn't parse the entry */ + continue; + else + return status; + } + } + + return NSS_STATUS_SUCCESS; +} + +enum nss_status +_nss_compat_getgrnam_r (const char *name, struct group *grp, + char *buffer, size_t buflen) +{ + ent_t ent = {0, 0, NULL, 0, NULL, {NULL, 0, 0}}; + enum nss_status status; + + if (name[0] == '-' || name[0] == '+') + return NSS_STATUS_NOTFOUND; + + __libc_lock_lock (lock); + + status = internal_setgrent (&ent); + + __libc_lock_unlock (lock); + + if (status != NSS_STATUS_SUCCESS) + return status; + + status = internal_getgrnam_r (name, grp, &ent, buffer, buflen); + + internal_endgrent (&ent); + + return status; +} + +/* This function handle the + entry in /etc/group */ +static enum nss_status +getgrgid_plusgroup (gid_t gid, struct group *result, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + int parse_res; + char buf[1024]; + char *domain, *outval, *p; + int outvallen; + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + return NSS_STATUS_TRYAGAIN; + + snprintf (buf, sizeof (buf), "%d", gid); + + if (yp_match (domain, "group.bygid", buf, strlen (buf), + &outval, &outvallen) != YPERR_SUCCESS) + return NSS_STATUS_TRYAGAIN; + p = strncpy (buffer, outval, + buflen < (size_t) outvallen ? buflen : (size_t) outvallen); + free (outval); + while (isspace (*p)) + p++; + if ((parse_res = _nss_files_parse_grent (p, result, data, buflen)) == -1) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (parse_res) + /* We found the entry. */ + return NSS_STATUS_SUCCESS; + else + return NSS_STATUS_RETURN; +} + +/* Searches in /etc/group and the NIS/NIS+ map for a special group id */ +static enum nss_status +internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + while (1) + { + fpos_t pos; + int parse_res = 0; + char *p; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_grent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* This is a real entry. */ + if (result->gr_name[0] != '+' && result->gr_name[0] != '-') + { + if (result->gr_gid == gid) + return NSS_STATUS_SUCCESS; + else + continue; + } + + /* -group */ + if (result->gr_name[0] == '-' && result->gr_name[1] != '\0') + { + blacklist_store_name (&result->gr_name[1], ent); + continue; + } + + /* +group */ + if (result->gr_name[0] == '+' && result->gr_name[1] != '\0') + { + enum nss_status status; + + /* Store the group in the blacklist for the "+" at the end of + /etc/group */ + blacklist_store_name (&result->gr_name[1], ent); + status = getgrnam_plusgroup (&result->gr_name[1], result, buffer, + buflen); + if (status == NSS_STATUS_SUCCESS && result->gr_gid == gid) + break; + else + continue; + } + /* +:... */ + if (result->gr_name[0] == '+' && result->gr_name[1] == '\0') + { + enum nss_status status; + + status = getgrgid_plusgroup (gid, result, buffer, buflen); + if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ + return NSS_STATUS_NOTFOUND; + else + return status; + } + } + + return NSS_STATUS_SUCCESS; +} + +enum nss_status +_nss_compat_getgrgid_r (gid_t gid, struct group *grp, + char *buffer, size_t buflen) +{ + ent_t ent = {0, 0, NULL, 0, NULL, {NULL, 0, 0}}; + enum nss_status status; + + __libc_lock_lock (lock); + + status = internal_setgrent (&ent); + + __libc_lock_unlock (lock); + + if (status != NSS_STATUS_SUCCESS) + return status; + + status = internal_getgrgid_r (gid, grp, &ent, buffer, buflen); + + internal_endgrent (&ent); + + return status; +} + + +/* Support routines for remembering -@netgroup and -user entries. + The names are stored in a single string with `|' as separator. */ +static void +blacklist_store_name (const char *name, ent_t *ent) +{ + int namelen = strlen (name); + char *tmp; + + /* first call, setup cache */ + if (ent->blacklist.size == 0) + { + ent->blacklist.size = MAX (BLACKLIST_INITIAL_SIZE, 2 * namelen); + ent->blacklist.data = malloc (ent->blacklist.size); + if (ent->blacklist.data == NULL) + return; + ent->blacklist.data[0] = '|'; + ent->blacklist.data[1] = '\0'; + ent->blacklist.current = 1; + } + else + { + if (in_blacklist (name, namelen, ent)) + return; /* no duplicates */ + + if (ent->blacklist.current + namelen + 1 >= ent->blacklist.size) + { + ent->blacklist.size += MAX (BLACKLIST_INCREMENT, 2 * namelen); + tmp = realloc (ent->blacklist.data, ent->blacklist.size); + if (tmp == NULL) + { + free (ent->blacklist.data); + ent->blacklist.size = 0; + return; + } + ent->blacklist.data = tmp; + } + } + + tmp = stpcpy (ent->blacklist.data + ent->blacklist.current, name); + *tmp++ = '|'; + *tmp = '\0'; + ent->blacklist.current += namelen + 1; + + return; +} + +/* returns TRUE if ent->blacklist contains name, else FALSE */ +static bool_t +in_blacklist (const char *name, int namelen, ent_t *ent) +{ + char buf[namelen + 3]; + char *cp; + + if (ent->blacklist.data == NULL) + return FALSE; + + buf[0] = '|'; + cp = stpcpy (&buf[1], name); + *cp++= '|'; + *cp = '\0'; + return strstr (ent->blacklist.data, buf) != NULL; +} diff -Naur ../glibc-2.1.3/glibc-compat/nss_compat/compat-pwd.c glibc-2.1.3/glibc-compat/nss_compat/compat-pwd.c --- ../glibc-2.1.3/glibc-compat/nss_compat/compat-pwd.c 1969-12-31 16:00:00.000000000 -0800 +++ glibc-2.1.3/glibc-compat/nss_compat/compat-pwd.c 2000-01-03 17:07:08.000000000 -0800 @@ -0,0 +1,1199 @@ +/* Copyright (C) 1996, 1997, 1998 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "netgroup.h" + +/* Get the declaration of the parser function. */ +#define ENTNAME pwent +#define STRUCTURE passwd +#define EXTERN_PARSER +#include "../nss_files/files-parse.c" + +/* Structure for remembering -@netgroup and -user members ... */ +#define BLACKLIST_INITIAL_SIZE 512 +#define BLACKLIST_INCREMENT 256 +struct blacklist_t + { + char *data; + int current; + int size; + }; + +struct ent_t + { + bool_t netgroup; + bool_t nis; + bool_t first; + char *oldkey; + int oldkeylen; + FILE *stream; + struct blacklist_t blacklist; + struct passwd pwd; + struct __netgrent netgrdata; + }; +typedef struct ent_t ent_t; + +static ent_t ext_ent = {0, 0, 0, NULL, 0, NULL, {NULL, 0, 0}, + {NULL, NULL, 0, 0, NULL, NULL, NULL}}; + +/* Protect global state against multiple changers. */ +__libc_lock_define_initialized (static, lock) + +/* Prototypes for local functions. */ +static void blacklist_store_name (const char *, ent_t *); +static int in_blacklist (const char *, int, ent_t *); + +static void +give_pwd_free (struct passwd *pwd) +{ + if (pwd->pw_name != NULL) + free (pwd->pw_name); + if (pwd->pw_passwd != NULL) + free (pwd->pw_passwd); + if (pwd->pw_gecos != NULL) + free (pwd->pw_gecos); + if (pwd->pw_dir != NULL) + free (pwd->pw_dir); + if (pwd->pw_shell != NULL) + free (pwd->pw_shell); + + memset (pwd, '\0', sizeof (struct passwd)); +} + +static size_t +pwd_need_buflen (struct passwd *pwd) +{ + size_t len = 0; + + if (pwd->pw_passwd != NULL) + len += strlen (pwd->pw_passwd) + 1; + + if (pwd->pw_gecos != NULL) + len += strlen (pwd->pw_gecos) + 1; + + if (pwd->pw_dir != NULL) + len += strlen (pwd->pw_dir) + 1; + + if (pwd->pw_shell != NULL) + len += strlen (pwd->pw_shell) + 1; + + return len; +} + +static void +copy_pwd_changes (struct passwd *dest, struct passwd *src, + char *buffer, size_t buflen) +{ + if (src->pw_passwd != NULL && strlen (src->pw_passwd)) + { + if (buffer == NULL) + dest->pw_passwd = strdup (src->pw_passwd); + else if (dest->pw_passwd && + strlen (dest->pw_passwd) >= strlen (src->pw_passwd)) + strcpy (dest->pw_passwd, src->pw_passwd); + else + { + dest->pw_passwd = buffer; + strcpy (dest->pw_passwd, src->pw_passwd); + buffer += strlen (dest->pw_passwd) + 1; + buflen = buflen - (strlen (dest->pw_passwd) + 1); + } + } + + if (src->pw_gecos != NULL && strlen (src->pw_gecos)) + { + if (buffer == NULL) + dest->pw_gecos = strdup (src->pw_gecos); + else if (dest->pw_gecos && + strlen (dest->pw_gecos) >= strlen (src->pw_gecos)) + strcpy (dest->pw_gecos, src->pw_gecos); + else + { + dest->pw_gecos = buffer; + strcpy (dest->pw_gecos, src->pw_gecos); + buffer += strlen (dest->pw_gecos) + 1; + buflen = buflen - (strlen (dest->pw_gecos) + 1); + } + } + if (src->pw_dir != NULL && strlen (src->pw_dir)) + { + if (buffer == NULL) + dest->pw_dir = strdup (src->pw_dir); + else if (dest->pw_dir && + strlen (dest->pw_dir) >= strlen (src->pw_dir)) + strcpy (dest->pw_dir, src->pw_dir); + else + { + dest->pw_dir = buffer; + strcpy (dest->pw_dir, src->pw_dir); + buffer += strlen (dest->pw_dir) + 1; + buflen = buflen - (strlen (dest->pw_dir) + 1); + } + } + + if (src->pw_shell != NULL && strlen (src->pw_shell)) + { + if (buffer == NULL) + dest->pw_shell = strdup (src->pw_shell); + else if (dest->pw_shell && + strlen (dest->pw_shell) >= strlen (src->pw_shell)) + strcpy (dest->pw_shell, src->pw_shell); + else + { + dest->pw_shell = buffer; + strcpy (dest->pw_shell, src->pw_shell); + buffer += strlen (dest->pw_shell) + 1; + buflen = buflen - (strlen (dest->pw_shell) + 1); + } + } +} + +static enum nss_status +internal_setpwent (ent_t *ent) +{ + enum nss_status status = NSS_STATUS_SUCCESS; + + ent->nis = ent->first = ent->netgroup = 0; + + /* If something was left over free it. */ + if (ent->netgroup) + __internal_endnetgrent (&ent->netgrdata); + + if (ent->oldkey != NULL) + { + free (ent->oldkey); + ent->oldkey = NULL; + ent->oldkeylen = 0; + } + + if (ent->blacklist.data != NULL) + { + ent->blacklist.current = 1; + ent->blacklist.data[0] = '|'; + ent->blacklist.data[1] = '\0'; + } + else + ent->blacklist.current = 0; + + if (ent->stream == NULL) + { + ent->stream = fopen ("/etc/passwd", "r"); + + if (ent->stream == NULL) + status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + else + { + /* We have to make sure the file is `closed on exec'. */ + int result, flags; + + result = flags = fcntl (fileno (ent->stream), F_GETFD, 0); + if (result >= 0) + { + flags |= FD_CLOEXEC; + result = fcntl (fileno (ent->stream), F_SETFD, flags); + } + if (result < 0) + { + /* Something went wrong. Close the stream and return a + failure. */ + fclose (ent->stream); + ent->stream = NULL; + status = NSS_STATUS_UNAVAIL; + } + } + } + else + rewind (ent->stream); + + give_pwd_free (&ent->pwd); + + return status; +} + + +enum nss_status +_nss_compat_setpwent (void) +{ + enum nss_status result; + + __libc_lock_lock (lock); + + result = internal_setpwent (&ext_ent); + + __libc_lock_unlock (lock); + + return result; +} + + +static enum nss_status +internal_endpwent (ent_t *ent) +{ + if (ent->stream != NULL) + { + fclose (ent->stream); + ent->stream = NULL; + } + + if (ent->netgroup) + __internal_endnetgrent (&ent->netgrdata); + + ent->nis = ent->first = ent->netgroup = 0; + + if (ent->oldkey != NULL) + { + free (ent->oldkey); + ent->oldkey = NULL; + ent->oldkeylen = 0; + } + + if (ent->blacklist.data != NULL) + { + ent->blacklist.current = 1; + ent->blacklist.data[0] = '|'; + ent->blacklist.data[1] = '\0'; + } + else + ent->blacklist.current = 0; + + give_pwd_free (&ent->pwd); + + return NSS_STATUS_SUCCESS; +} + +enum nss_status +_nss_compat_endpwent (void) +{ + enum nss_status result; + + __libc_lock_lock (lock); + + result = internal_endpwent (&ext_ent); + + __libc_lock_unlock (lock); + + return result; +} + +static enum nss_status +getpwent_next_nis_netgr (const char *name, struct passwd *result, ent_t *ent, + char *group, char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + char *ypdomain, *host, *user, *domain, *outval, *p, *p2; + int status, outvallen; + size_t p2len; + + if (yp_get_default_domain (&ypdomain) != YPERR_SUCCESS) + { + ent->netgroup = 0; + ent->first = 0; + give_pwd_free (&ent->pwd); + return NSS_STATUS_UNAVAIL; + } + + if (ent->first == TRUE) + { + memset (&ent->netgrdata, 0, sizeof (struct __netgrent)); + __internal_setnetgrent (group, &ent->netgrdata); + ent->first = FALSE; + } + + while (1) + { + char *saved_cursor; + int parse_res; + + saved_cursor = ent->netgrdata.cursor; + status = __internal_getnetgrent_r (&host, &user, &domain, + &ent->netgrdata, buffer, buflen, + &errno); + if (status != 1) + { + __internal_endnetgrent (&ent->netgrdata); + ent->netgroup = 0; + give_pwd_free (&ent->pwd); + return NSS_STATUS_RETURN; + } + + if (user == NULL || user[0] == '-') + continue; + + if (domain != NULL && strcmp (ypdomain, domain) != 0) + continue; + + /* If name != NULL, we are called from getpwnam */ + if (name != NULL) + if (strcmp (user, name) != 0) + continue; + + if (yp_match (ypdomain, "passwd.byname", user, + strlen (user), &outval, &outvallen) + != YPERR_SUCCESS) + continue; + + p2len = pwd_need_buflen (&ent->pwd); + if (p2len > buflen) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + p2 = buffer + (buflen - p2len); + buflen -= p2len; + p = strncpy (buffer, outval, buflen); + while (isspace (*p)) + p++; + free (outval); + if ((parse_res = _nss_files_parse_pwent (p, result, data, buflen)) == -1) + { + ent->netgrdata.cursor = saved_cursor; + return NSS_STATUS_TRYAGAIN; + } + + if (parse_res) + { + /* Store the User in the blacklist for the "+" at the end of + /etc/passwd */ + blacklist_store_name (result->pw_name, ent); + copy_pwd_changes (result, &ent->pwd, p2, p2len); + break; + } + } + + return NSS_STATUS_SUCCESS; +} + +static enum nss_status +getpwent_next_nis (struct passwd *result, ent_t *ent, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + char *domain, *outkey, *outval, *p, *p2; + int outkeylen, outvallen, parse_res; + size_t p2len; + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + { + ent->nis = 0; + give_pwd_free (&ent->pwd); + return NSS_STATUS_UNAVAIL; + } + + p2len = pwd_need_buflen (&ent->pwd); + if (p2len > buflen) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + p2 = buffer + (buflen - p2len); + buflen -= p2len; + do + { + bool_t saved_first; + char *saved_oldkey; + int saved_oldlen; + + if (ent->first) + { + if (yp_first (domain, "passwd.byname", &outkey, &outkeylen, + &outval, &outvallen) != YPERR_SUCCESS) + { + ent->nis = 0; + give_pwd_free (&ent->pwd); + return NSS_STATUS_UNAVAIL; + } + + saved_first = TRUE; + saved_oldkey = ent->oldkey; + saved_oldlen = ent->oldkeylen; + ent->oldkey = outkey; + ent->oldkeylen = outkeylen; + ent->first = FALSE; + } + else + { + if (yp_next (domain, "passwd.byname", ent->oldkey, ent->oldkeylen, + &outkey, &outkeylen, &outval, &outvallen) + != YPERR_SUCCESS) + { + ent->nis = 0; + give_pwd_free (&ent->pwd); + return NSS_STATUS_NOTFOUND; + } + + saved_first = FALSE; + saved_oldkey = ent->oldkey; + saved_oldlen = ent->oldkeylen; + ent->oldkey = outkey; + ent->oldkeylen = outkeylen; + } + + /* Copy the found data to our buffer */ + p = strncpy (buffer, outval, buflen); + + /* ...and free the data. */ + free (outval); + + while (isspace (*p)) + ++p; + if ((parse_res = _nss_files_parse_pwent (p, result, data, buflen)) == -1) + { + free (ent->oldkey); + ent->oldkey = saved_oldkey; + ent->oldkeylen = saved_oldlen; + ent->first = saved_first; + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + else + { + if (!saved_first) + free (saved_oldkey); + } + if (parse_res && + in_blacklist (result->pw_name, strlen (result->pw_name), ent)) + parse_res = 0; + } + while (!parse_res); + + copy_pwd_changes (result, &ent->pwd, p2, p2len); + + return NSS_STATUS_SUCCESS; +} + +/* This function handle the +user entrys in /etc/passwd */ +static enum nss_status +getpwnam_plususer (const char *name, struct passwd *result, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + struct passwd pwd; + int parse_res; + char *p; + size_t plen; + char *domain, *outval, *ptr; + int outvallen; + + memset (&pwd, '\0', sizeof (struct passwd)); + + copy_pwd_changes (&pwd, result, NULL, 0); + + plen = pwd_need_buflen (&pwd); + if (plen > buflen) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + p = buffer + (buflen - plen); + buflen -= plen; + + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + return NSS_STATUS_NOTFOUND; + + if (yp_match (domain, "passwd.byname", name, strlen (name), + &outval, &outvallen) != YPERR_SUCCESS) + return NSS_STATUS_NOTFOUND; + ptr = strncpy (buffer, outval, buflen < (size_t) outvallen ? + buflen : (size_t) outvallen); + buffer[buflen < (size_t) outvallen ? buflen : (size_t) outvallen] = '\0'; + free (outval); + while (isspace (*ptr)) + ptr++; + if ((parse_res = _nss_files_parse_pwent (ptr, result, data, buflen)) + == -1) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (parse_res > 0) + { + copy_pwd_changes (result, &pwd, p, plen); + give_pwd_free (&pwd); + /* We found the entry. */ + return NSS_STATUS_SUCCESS; + } + else + { + /* Give buffer the old len back */ + buflen += plen; + give_pwd_free (&pwd); + } + return NSS_STATUS_RETURN; +} + +/* get the next user from NIS+ (+ entry) */ +static enum nss_status +getpwent_next_file (struct passwd *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + while (1) + { + fpos_t pos; + char *p; + int parse_res; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_pwent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (result->pw_name[0] != '+' && result->pw_name[0] != '-') + /* This is a real entry. */ + break; + + /* -@netgroup */ + if (result->pw_name[0] == '-' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + char buf2[1024]; + char *user, *host, *domain; + struct __netgrent netgrdata; + + bzero (&netgrdata, sizeof (struct __netgrent)); + __internal_setnetgrent (&result->pw_name[2], &netgrdata); + while (__internal_getnetgrent_r (&host, &user, &domain, + &netgrdata, buf2, sizeof (buf2), + &errno)) + { + if (user != NULL && user[0] != '-') + blacklist_store_name (user, ent); + } + __internal_endnetgrent (&netgrdata); + continue; + } + + /* +@netgroup */ + if (result->pw_name[0] == '+' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + int status; + + ent->netgroup = TRUE; + ent->first = TRUE; + copy_pwd_changes (&ent->pwd, result, NULL, 0); + + status = getpwent_next_nis_netgr (NULL, result, ent, + &result->pw_name[2], + buffer, buflen); + if (status == NSS_STATUS_RETURN) + continue; + else + return status; + } + + /* -user */ + if (result->pw_name[0] == '-' && result->pw_name[1] != '\0' + && result->pw_name[1] != '@') + { + blacklist_store_name (&result->pw_name[1], ent); + continue; + } + + /* +user */ + if (result->pw_name[0] == '+' && result->pw_name[1] != '\0' + && result->pw_name[1] != '@') + { + enum nss_status status; + + /* Store the User in the blacklist for the "+" at the end of + /etc/passwd */ + blacklist_store_name (&result->pw_name[1], ent); + status = getpwnam_plususer (&result->pw_name[1], result, buffer, + buflen); + if (status == NSS_STATUS_SUCCESS) /* We found the entry. */ + break; + else + if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ + continue; + else + return status; + } + + /* +:... */ + if (result->pw_name[0] == '+' && result->pw_name[1] == '\0') + { + ent->nis = TRUE; + ent->first = TRUE; + copy_pwd_changes (&ent->pwd, result, NULL, 0); + + return getpwent_next_nis (result, ent, buffer, buflen); + } + } + + return NSS_STATUS_SUCCESS; +} + + +/* get the next user from NIS (+ entry) */ +static enum nss_status +internal_getpwent_r (struct passwd *pw, ent_t *ent, char *buffer, + size_t buflen) +{ + if (ent->netgroup) + { + int status; + + /* We are searching members in a netgroup */ + /* Since this is not the first call, we don't need the group name */ + status = getpwent_next_nis_netgr (NULL, pw, ent, NULL, buffer, buflen); + if (status == NSS_STATUS_RETURN) + return getpwent_next_file (pw, ent, buffer, buflen); + else + return status; + } + else + if (ent->nis) + { + return getpwent_next_nis (pw, ent, buffer, buflen); + } + else + return getpwent_next_file (pw, ent, buffer, buflen); +} + +enum nss_status +_nss_compat_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) +{ + enum nss_status status = NSS_STATUS_SUCCESS; + + __libc_lock_lock (lock); + + /* Be prepared that the setpwent function was not called before. */ + if (ext_ent.stream == NULL) + status = internal_setpwent (&ext_ent); + + if (status == NSS_STATUS_SUCCESS) + status = internal_getpwent_r (pwd, &ext_ent, buffer, buflen); + + __libc_lock_unlock (lock); + + return status; +} + +/* Searches in /etc/passwd and the NIS/NIS+ map for a special user */ +static enum nss_status +internal_getpwnam_r (const char *name, struct passwd *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + + while (1) + { + fpos_t pos; + char *p; + int parse_res; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_pwent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* This is a real entry. */ + if (result->pw_name[0] != '+' && result->pw_name[0] != '-') + { + if (strcmp (result->pw_name, name) == 0) + return NSS_STATUS_SUCCESS; + else + continue; + } + + /* -@netgroup */ + if (result->pw_name[0] == '-' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + char buf2[1024]; + char *user, *host, *domain; + struct __netgrent netgrdata; + + bzero (&netgrdata, sizeof (struct __netgrent)); + __internal_setnetgrent (&result->pw_name[2], &netgrdata); + while (__internal_getnetgrent_r (&host, &user, &domain, + &netgrdata, buf2, sizeof (buf2), + &errno)) + { + if (user != NULL && user[0] != '-') + if (strcmp (user, name) == 0) + return NSS_STATUS_NOTFOUND; + } + __internal_endnetgrent (&netgrdata); + continue; + } + + /* +@netgroup */ + if (result->pw_name[0] == '+' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + char buf[strlen (result->pw_name)]; + int status; + + strcpy (buf, &result->pw_name[2]); + ent->netgroup = TRUE; + ent->first = TRUE; + copy_pwd_changes (&ent->pwd, result, NULL, 0); + + do + { + status = getpwent_next_nis_netgr (name, result, ent, buf, + buffer, buflen); + if (status == NSS_STATUS_RETURN) + continue; + + if (status == NSS_STATUS_SUCCESS && + strcmp (result->pw_name, name) == 0) + return NSS_STATUS_SUCCESS; + } while (status == NSS_STATUS_SUCCESS); + continue; + } + + /* -user */ + if (result->pw_name[0] == '-' && result->pw_name[1] != '\0' + && result->pw_name[1] != '@') + { + if (strcmp (&result->pw_name[1], name) == 0) + return NSS_STATUS_NOTFOUND; + else + continue; + } + + /* +user */ + if (result->pw_name[0] == '+' && result->pw_name[1] != '\0' + && result->pw_name[1] != '@') + { + if (strcmp (name, &result->pw_name[1]) == 0) + { + enum nss_status status; + + status = getpwnam_plususer (name, result, buffer, buflen); + if (status == NSS_STATUS_RETURN) + /* We couldn't parse the entry */ + return NSS_STATUS_NOTFOUND; + else + return status; + } + } + + /* +:... */ + if (result->pw_name[0] == '+' && result->pw_name[1] == '\0') + { + enum nss_status status; + + status = getpwnam_plususer (name, result, buffer, buflen); + if (status == NSS_STATUS_SUCCESS) /* We found the entry. */ + break; + else + if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ + return NSS_STATUS_NOTFOUND; + else + return status; + } + } + return NSS_STATUS_SUCCESS; +} + +enum nss_status +_nss_compat_getpwnam_r (const char *name, struct passwd *pwd, + char *buffer, size_t buflen) +{ + ent_t ent = {0, 0, 0, NULL, 0, NULL, {NULL, 0, 0}, + {NULL, NULL, 0, 0, NULL, NULL, NULL}}; + enum nss_status status; + + if (name[0] == '-' || name[0] == '+') + return NSS_STATUS_NOTFOUND; + + status = internal_setpwent (&ent); + if (status != NSS_STATUS_SUCCESS) + return status; + + status = internal_getpwnam_r (name, pwd, &ent, buffer, buflen); + + internal_endpwent (&ent); + + return status; +} + +/* This function handle the + entry in /etc/passwd for getpwuid */ +static enum nss_status +getpwuid_plususer (uid_t uid, struct passwd *result, char *buffer, + size_t buflen) +{ + struct parser_data *data = (void *) buffer; + struct passwd pwd; + int parse_res; + char *p; + size_t plen; + char buf[1024]; + char *domain, *outval, *ptr; + int outvallen; + + memset (&pwd, '\0', sizeof (struct passwd)); + + copy_pwd_changes (&pwd, result, NULL, 0); + + plen = pwd_need_buflen (&pwd); + if (plen > buflen) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + p = buffer + (buflen - plen); + buflen -= plen; + + + if (yp_get_default_domain (&domain) != YPERR_SUCCESS) + return NSS_STATUS_TRYAGAIN; + + sprintf (buf, "%d", uid); + if (yp_match (domain, "passwd.byuid", buf, strlen (buf), + &outval, &outvallen) + != YPERR_SUCCESS) + return NSS_STATUS_TRYAGAIN; + ptr = strncpy (buffer, outval, buflen < (size_t) outvallen ? + buflen : (size_t) outvallen); + buffer[buflen < (size_t) outvallen ? buflen : (size_t) outvallen] = '\0'; + free (outval); + while (isspace (*ptr)) + ptr++; + if ((parse_res = _nss_files_parse_pwent (ptr, result, data, buflen)) + == -1) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + if (parse_res > 0) + { + copy_pwd_changes (result, &pwd, p, plen); + give_pwd_free (&pwd); + /* We found the entry. */ + return NSS_STATUS_SUCCESS; + } + else + { + /* Give buffer the old len back */ + buflen += plen; + give_pwd_free (&pwd); + } + return NSS_STATUS_RETURN; +} + +/* Searches in /etc/passwd and the NIS/NIS+ map for a special user id */ +static enum nss_status +internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, + char *buffer, size_t buflen) +{ + struct parser_data *data = (void *) buffer; + + while (1) + { + fpos_t pos; + char *p; + int parse_res; + + do + { + fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; + p = fgets (buffer, buflen, ent->stream); + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + + /* Skip leading blanks. */ + while (isspace (*p)) + ++p; + } + while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ + /* Parse the line. If it is invalid, loop to + get the next line of the file to parse. */ + !(parse_res = _nss_files_parse_pwent (p, result, data, buflen))); + + if (parse_res == -1) + { + /* The parser ran out of space. */ + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + + /* This is a real entry. */ + if (result->pw_name[0] != '+' && result->pw_name[0] != '-') + { + if (result->pw_uid == uid) + return NSS_STATUS_SUCCESS; + else + continue; + } + + /* -@netgroup */ + if (result->pw_name[0] == '-' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + char buf2[1024]; + char *user, *host, *domain; + struct __netgrent netgrdata; + + bzero (&netgrdata, sizeof (struct __netgrent)); + __internal_setnetgrent (&result->pw_name[2], &netgrdata); + while (__internal_getnetgrent_r (&host, &user, &domain, + &netgrdata, buf2, sizeof (buf2), + &errno)) + { + if (user != NULL && user[0] != '-') + blacklist_store_name (user, ent); + } + __internal_endnetgrent (&netgrdata); + continue; + } + + /* +@netgroup */ + if (result->pw_name[0] == '+' && result->pw_name[1] == '@' + && result->pw_name[2] != '\0') + { + char buf[strlen (result->pw_name)]; + int status; + + strcpy (buf, &result->pw_name[2]); + ent->netgroup = TRUE; + en