1941 lines
64 KiB
Plaintext
1941 lines
64 KiB
Plaintext
To: Linux-Development@senator-bedfellow.MIT.EDU
|
||
Crossposted-To: alt.sources
|
||
From: jfh@rpp386 (John F. Haugh II)
|
||
Subject: LGPL'd Shadow Password Library
|
||
Date: Sun, 13 Feb 1994 18:32:42 GMT
|
||
|
||
|
||
Sorry this took so long. This is the "free'd" shadow functions that
|
||
seem to be the core set of requirements for having shadowing in all
|
||
versions of Linux. This is the only posting I plan to make of this
|
||
code as the "real" Shadow is regularly posted to comp.sources.misc
|
||
and regularly archived.
|
||
|
||
---- Cut Here and unpack ----
|
||
#!/bin/sh
|
||
# shar: Shell Archiver (v1.29)
|
||
# Packed Sun Feb 13 12:23:43 CST 1994 by jfh
|
||
# from directory /home/jfh/src/c/gnu-shadow-lib
|
||
#
|
||
# Run the following text with /bin/sh to create:
|
||
# COPYING
|
||
# Makefile
|
||
# shadow.c
|
||
# shadow.h
|
||
# gshadow.c
|
||
# gshadow.h
|
||
#
|
||
sed 's/^X//' << 'Spam_Animals' > COPYING &&
|
||
X GNU LIBRARY GENERAL PUBLIC LICENSE
|
||
X Version 2, June 1991
|
||
X
|
||
X Copyright (C) 1991 Free Software Foundation, Inc.
|
||
X 675 Mass Ave, Cambridge, MA 02139, USA
|
||
X Everyone is permitted to copy and distribute verbatim copies
|
||
X of this license document, but changing it is not allowed.
|
||
X
|
||
X[This is the first released version of the library GPL. It is
|
||
X numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||
X
|
||
X Preamble
|
||
X
|
||
X The licenses for most software are designed to take away your
|
||
Xfreedom to share and change it. By contrast, the GNU General Public
|
||
XLicenses are intended to guarantee your freedom to share and change
|
||
Xfree software--to make sure the software is free for all its users.
|
||
X
|
||
X This license, the Library General Public License, applies to some
|
||
Xspecially designated Free Software Foundation software, and to any
|
||
Xother libraries whose authors decide to use it. You can use it for
|
||
Xyour libraries, too.
|
||
X
|
||
X When we speak of free software, we are referring to freedom, not
|
||
Xprice. Our General Public Licenses are designed to make sure that you
|
||
Xhave the freedom to distribute copies of free software (and charge for
|
||
Xthis service if you wish), that you receive source code or can get it
|
||
Xif you want it, that you can change the software or use pieces of it
|
||
Xin new free programs; and that you know you can do these things.
|
||
X
|
||
X To protect your rights, we need to make restrictions that forbid
|
||
Xanyone to deny you these rights or to ask you to surrender the rights.
|
||
XThese restrictions translate to certain responsibilities for you if
|
||
Xyou distribute copies of the library, or if you modify it.
|
||
X
|
||
X For example, if you distribute copies of the library, whether gratis
|
||
Xor for a fee, you must give the recipients all the rights that we gave
|
||
Xyou. You must make sure that they, too, receive or can get the source
|
||
Xcode. If you link a program with the library, you must provide
|
||
Xcomplete object files to the recipients so that they can relink them
|
||
Xwith the library, after making changes to the library and recompiling
|
||
Xit. And you must show them these terms so they know their rights.
|
||
X
|
||
X Our method of protecting your rights has two steps: (1) copyright
|
||
Xthe library, and (2) offer you this license which gives you legal
|
||
Xpermission to copy, distribute and/or modify the library.
|
||
X
|
||
X Also, for each distributor's protection, we want to make certain
|
||
Xthat everyone understands that there is no warranty for this free
|
||
Xlibrary. If the library is modified by someone else and passed on, we
|
||
Xwant its recipients to know that what they have is not the original
|
||
Xversion, so that any problems introduced by others will not reflect on
|
||
Xthe original authors' reputations.
|
||
X
|
||
X Finally, any free program is threatened constantly by software
|
||
Xpatents. We wish to avoid the danger that companies distributing free
|
||
Xsoftware will individually obtain patent licenses, thus in effect
|
||
Xtransforming the program into proprietary software. To prevent this,
|
||
Xwe have made it clear that any patent must be licensed for everyone's
|
||
Xfree use or not licensed at all.
|
||
X
|
||
X Most GNU software, including some libraries, is covered by the ordinary
|
||
XGNU General Public License, which was designed for utility programs. This
|
||
Xlicense, the GNU Library General Public License, applies to certain
|
||
Xdesignated libraries. This license is quite different from the ordinary
|
||
Xone; be sure to read it in full, and don't assume that anything in it is
|
||
Xthe same as in the ordinary license.
|
||
X
|
||
X The reason we have a separate public license for some libraries is that
|
||
Xthey blur the distinction we usually make between modifying or adding to a
|
||
Xprogram and simply using it. Linking a program with a library, without
|
||
Xchanging the library, is in some sense simply using the library, and is
|
||
Xanalogous to running a utility program or application program. However, in
|
||
Xa textual and legal sense, the linked executable is a combined work, a
|
||
Xderivative of the original library, and the ordinary General Public License
|
||
Xtreats it as such.
|
||
X
|
||
X Because of this blurred distinction, using the ordinary General
|
||
XPublic License for libraries did not effectively promote software
|
||
Xsharing, because most developers did not use the libraries. We
|
||
Xconcluded that weaker conditions might promote sharing better.
|
||
X
|
||
X However, unrestricted linking of non-free programs would deprive the
|
||
Xusers of those programs of all benefit from the free status of the
|
||
Xlibraries themselves. This Library General Public License is intended to
|
||
Xpermit developers of non-free programs to use free libraries, while
|
||
Xpreserving your freedom as a user of such programs to change the free
|
||
Xlibraries that are incorporated in them. (We have not seen how to achieve
|
||
Xthis as regards changes in header files, but we have achieved it as regards
|
||
Xchanges in the actual functions of the Library.) The hope is that this
|
||
Xwill lead to faster development of free libraries.
|
||
X
|
||
X The precise terms and conditions for copying, distribution and
|
||
Xmodification follow. Pay close attention to the difference between a
|
||
X"work based on the library" and a "work that uses the library". The
|
||
Xformer contains code derived from the library, while the latter only
|
||
Xworks together with the library.
|
||
X
|
||
X Note that it is possible for a library to be covered by the ordinary
|
||
XGeneral Public License rather than by this special one.
|
||
X
|
||
X GNU LIBRARY GENERAL PUBLIC LICENSE
|
||
X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||
X
|
||
X 0. This License Agreement applies to any software library which
|
||
Xcontains a notice placed by the copyright holder or other authorized
|
||
Xparty saying it may be distributed under the terms of this Library
|
||
XGeneral Public License (also called "this License"). Each licensee is
|
||
Xaddressed as "you".
|
||
X
|
||
X A "library" means a collection of software functions and/or data
|
||
Xprepared so as to be conveniently linked with application programs
|
||
X(which use some of those functions and data) to form executables.
|
||
X
|
||
X The "Library", below, refers to any such software library or work
|
||
Xwhich has been distributed under these terms. A "work based on the
|
||
XLibrary" means either the Library or any derivative work under
|
||
Xcopyright law: that is to say, a work containing the Library or a
|
||
Xportion of it, either verbatim or with modifications and/or translated
|
||
Xstraightforwardly into another language. (Hereinafter, translation is
|
||
Xincluded without limitation in the term "modification".)
|
||
X
|
||
X "Source code" for a work means the preferred form of the work for
|
||
Xmaking modifications to it. For a library, complete source code means
|
||
Xall the source code for all modules it contains, plus any associated
|
||
Xinterface definition files, plus the scripts used to control compilation
|
||
Xand installation of the library.
|
||
X
|
||
X Activities other than copying, distribution and modification are not
|
||
Xcovered by this License; they are outside its scope. The act of
|
||
Xrunning a program using the Library is not restricted, and output from
|
||
Xsuch a program is covered only if its contents constitute a work based
|
||
Xon the Library (independent of the use of the Library in a tool for
|
||
Xwriting it). Whether that is true depends on what the Library does
|
||
Xand what the program that uses the Library does.
|
||
X
|
||
X 1. You may copy and distribute verbatim copies of the Library's
|
||
Xcomplete source code as you receive it, in any medium, provided that
|
||
Xyou conspicuously and appropriately publish on each copy an
|
||
Xappropriate copyright notice and disclaimer of warranty; keep intact
|
||
Xall the notices that refer to this License and to the absence of any
|
||
Xwarranty; and distribute a copy of this License along with the
|
||
XLibrary.
|
||
X
|
||
X You may charge a fee for the physical act of transferring a copy,
|
||
Xand you may at your option offer warranty protection in exchange for a
|
||
Xfee.
|
||
X
|
||
X 2. You may modify your copy or copies of the Library or any portion
|
||
Xof it, thus forming a work based on the Library, and copy and
|
||
Xdistribute such modifications or work under the terms of Section 1
|
||
Xabove, provided that you also meet all of these conditions:
|
||
X
|
||
X a) The modified work must itself be a software library.
|
||
X
|
||
X b) You must cause the files modified to carry prominent notices
|
||
X stating that you changed the files and the date of any change.
|
||
X
|
||
X c) You must cause the whole of the work to be licensed at no
|
||
X charge to all third parties under the terms of this License.
|
||
X
|
||
X d) If a facility in the modified Library refers to a function or a
|
||
X table of data to be supplied by an application program that uses
|
||
X the facility, other than as an argument passed when the facility
|
||
X is invoked, then you must make a good faith effort to ensure that,
|
||
X in the event an application does not supply such function or
|
||
X table, the facility still operates, and performs whatever part of
|
||
X its purpose remains meaningful.
|
||
X
|
||
X (For example, a function in a library to compute square roots has
|
||
X a purpose that is entirely well-defined independent of the
|
||
X application. Therefore, Subsection 2d requires that any
|
||
X application-supplied function or table used by this function must
|
||
X be optional: if the application does not supply it, the square
|
||
X root function must still compute square roots.)
|
||
X
|
||
XThese requirements apply to the modified work as a whole. If
|
||
Xidentifiable sections of that work are not derived from the Library,
|
||
Xand can be reasonably considered independent and separate works in
|
||
Xthemselves, then this License, and its terms, do not apply to those
|
||
Xsections when you distribute them as separate works. But when you
|
||
Xdistribute the same sections as part of a whole which is a work based
|
||
Xon the Library, the distribution of the whole must be on the terms of
|
||
Xthis License, whose permissions for other licensees extend to the
|
||
Xentire whole, and thus to each and every part regardless of who wrote
|
||
Xit.
|
||
X
|
||
XThus, it is not the intent of this section to claim rights or contest
|
||
Xyour rights to work written entirely by you; rather, the intent is to
|
||
Xexercise the right to control the distribution of derivative or
|
||
Xcollective works based on the Library.
|
||
X
|
||
XIn addition, mere aggregation of another work not based on the Library
|
||
Xwith the Library (or with a work based on the Library) on a volume of
|
||
Xa storage or distribution medium does not bring the other work under
|
||
Xthe scope of this License.
|
||
X
|
||
X 3. You may opt to apply the terms of the ordinary GNU General Public
|
||
XLicense instead of this License to a given copy of the Library. To do
|
||
Xthis, you must alter all the notices that refer to this License, so
|
||
Xthat they refer to the ordinary GNU General Public License, version 2,
|
||
Xinstead of to this License. (If a newer version than version 2 of the
|
||
Xordinary GNU General Public License has appeared, then you can specify
|
||
Xthat version instead if you wish.) Do not make any other change in
|
||
Xthese notices.
|
||
X
|
||
X Once this change is made in a given copy, it is irreversible for
|
||
Xthat copy, so the ordinary GNU General Public License applies to all
|
||
Xsubsequent copies and derivative works made from that copy.
|
||
X
|
||
X This option is useful when you wish to copy part of the code of
|
||
Xthe Library into a program that is not a library.
|
||
X
|
||
X 4. You may copy and distribute the Library (or a portion or
|
||
Xderivative of it, under Section 2) in object code or executable form
|
||
Xunder the terms of Sections 1 and 2 above provided that you accompany
|
||
Xit with the complete corresponding machine-readable source code, which
|
||
Xmust be distributed under the terms of Sections 1 and 2 above on a
|
||
Xmedium customarily used for software interchange.
|
||
X
|
||
X If distribution of object code is made by offering access to copy
|
||
Xfrom a designated place, then offering equivalent access to copy the
|
||
Xsource code from the same place satisfies the requirement to
|
||
Xdistribute the source code, even though third parties are not
|
||
Xcompelled to copy the source along with the object code.
|
||
X
|
||
X 5. A program that contains no derivative of any portion of the
|
||
XLibrary, but is designed to work with the Library by being compiled or
|
||
Xlinked with it, is called a "work that uses the Library". Such a
|
||
Xwork, in isolation, is not a derivative work of the Library, and
|
||
Xtherefore falls outside the scope of this License.
|
||
X
|
||
X However, linking a "work that uses the Library" with the Library
|
||
Xcreates an executable that is a derivative of the Library (because it
|
||
Xcontains portions of the Library), rather than a "work that uses the
|
||
Xlibrary". The executable is therefore covered by this License.
|
||
XSection 6 states terms for distribution of such executables.
|
||
X
|
||
X When a "work that uses the Library" uses material from a header file
|
||
Xthat is part of the Library, the object code for the work may be a
|
||
Xderivative work of the Library even though the source code is not.
|
||
XWhether this is true is especially significant if the work can be
|
||
Xlinked without the Library, or if the work is itself a library. The
|
||
Xthreshold for this to be true is not precisely defined by law.
|
||
X
|
||
X If such an object file uses only numerical parameters, data
|
||
Xstructure layouts and accessors, and small macros and small inline
|
||
Xfunctions (ten lines or less in length), then the use of the object
|
||
Xfile is unrestricted, regardless of whether it is legally a derivative
|
||
Xwork. (Executables containing this object code plus portions of the
|
||
XLibrary will still fall under Section 6.)
|
||
X
|
||
X Otherwise, if the work is a derivative of the Library, you may
|
||
Xdistribute the object code for the work under the terms of Section 6.
|
||
XAny executables containing that work also fall under Section 6,
|
||
Xwhether or not they are linked directly with the Library itself.
|
||
X
|
||
X 6. As an exception to the Sections above, you may also compile or
|
||
Xlink a "work that uses the Library" with the Library to produce a
|
||
Xwork containing portions of the Library, and distribute that work
|
||
Xunder terms of your choice, provided that the terms permit
|
||
Xmodification of the work for the customer's own use and reverse
|
||
Xengineering for debugging such modifications.
|
||
X
|
||
X You must give prominent notice with each copy of the work that the
|
||
XLibrary is used in it and that the Library and its use are covered by
|
||
Xthis License. You must supply a copy of this License. If the work
|
||
Xduring execution displays copyright notices, you must include the
|
||
Xcopyright notice for the Library among them, as well as a reference
|
||
Xdirecting the user to the copy of this License. Also, you must do one
|
||
Xof these things:
|
||
X
|
||
X a) Accompany the work with the complete corresponding
|
||
X machine-readable source code for the Library including whatever
|
||
X changes were used in the work (which must be distributed under
|
||
X Sections 1 and 2 above); and, if the work is an executable linked
|
||
X with the Library, with the complete machine-readable "work that
|
||
X uses the Library", as object code and/or source code, so that the
|
||
X user can modify the Library and then relink to produce a modified
|
||
X executable containing the modified Library. (It is understood
|
||
X that the user who changes the contents of definitions files in the
|
||
X Library will not necessarily be able to recompile the application
|
||
X to use the modified definitions.)
|
||
X
|
||
X b) Accompany the work with a written offer, valid for at
|
||
X least three years, to give the same user the materials
|
||
X specified in Subsection 6a, above, for a charge no more
|
||
X than the cost of performing this distribution.
|
||
X
|
||
X c) If distribution of the work is made by offering access to copy
|
||
X from a designated place, offer equivalent access to copy the above
|
||
X specified materials from the same place.
|
||
X
|
||
X d) Verify that the user has already received a copy of these
|
||
X materials or that you have already sent this user a copy.
|
||
X
|
||
X For an executable, the required form of the "work that uses the
|
||
XLibrary" must include any data and utility programs needed for
|
||
Xreproducing the executable from it. However, as a special exception,
|
||
Xthe source code distributed need not include anything that is normally
|
||
Xdistributed (in either source or binary form) with the major
|
||
Xcomponents (compiler, kernel, and so on) of the operating system on
|
||
Xwhich the executable runs, unless that component itself accompanies
|
||
Xthe executable.
|
||
X
|
||
X It may happen that this requirement contradicts the license
|
||
Xrestrictions of other proprietary libraries that do not normally
|
||
Xaccompany the operating system. Such a contradiction means you cannot
|
||
Xuse both them and the Library together in an executable that you
|
||
Xdistribute.
|
||
X
|
||
X 7. You may place library facilities that are a work based on the
|
||
XLibrary side-by-side in a single library together with other library
|
||
Xfacilities not covered by this License, and distribute such a combined
|
||
Xlibrary, provided that the separate distribution of the work based on
|
||
Xthe Library and of the other library facilities is otherwise
|
||
Xpermitted, and provided that you do these two things:
|
||
X
|
||
X a) Accompany the combined library with a copy of the same work
|
||
X based on the Library, uncombined with any other library
|
||
X facilities. This must be distributed under the terms of the
|
||
X Sections above.
|
||
X
|
||
X b) Give prominent notice with the combined library of the fact
|
||
X that part of it is a work based on the Library, and explaining
|
||
X where to find the accompanying uncombined form of the same work.
|
||
X
|
||
X 8. You may not copy, modify, sublicense, link with, or distribute
|
||
Xthe Library except as expressly provided under this License. Any
|
||
Xattempt otherwise to copy, modify, sublicense, link with, or
|
||
Xdistribute the Library is void, and will automatically terminate your
|
||
Xrights under this License. However, parties who have received copies,
|
||
Xor rights, from you under this License will not have their licenses
|
||
Xterminated so long as such parties remain in full compliance.
|
||
X
|
||
X 9. You are not required to accept this License, since you have not
|
||
Xsigned it. However, nothing else grants you permission to modify or
|
||
Xdistribute the Library or its derivative works. These actions are
|
||
Xprohibited by law if you do not accept this License. Therefore, by
|
||
Xmodifying or distributing the Library (or any work based on the
|
||
XLibrary), you indicate your acceptance of this License to do so, and
|
||
Xall its terms and conditions for copying, distributing or modifying
|
||
Xthe Library or works based on it.
|
||
X
|
||
X 10. Each time you redistribute the Library (or any work based on the
|
||
XLibrary), the recipient automatically receives a license from the
|
||
Xoriginal licensor to copy, distribute, link with or modify the Library
|
||
Xsubject to these terms and conditions. You may not impose any further
|
||
Xrestrictions on the recipients' exercise of the rights granted herein.
|
||
XYou are not responsible for enforcing compliance by third parties to
|
||
Xthis License.
|
||
X
|
||
X 11. If, as a consequence of a court judgment or allegation of patent
|
||
Xinfringement or for any other reason (not limited to patent issues),
|
||
Xconditions are imposed on you (whether by court order, agreement or
|
||
Xotherwise) that contradict the conditions of this License, they do not
|
||
Xexcuse you from the conditions of this License. If you cannot
|
||
Xdistribute so as to satisfy simultaneously your obligations under this
|
||
XLicense and any other pertinent obligations, then as a consequence you
|
||
Xmay not distribute the Library at all. For example, if a patent
|
||
Xlicense would not permit royalty-free redistribution of the Library by
|
||
Xall those who receive copies directly or indirectly through you, then
|
||
Xthe only way you could satisfy both it and this License would be to
|
||
Xrefrain entirely from distribution of the Library.
|
||
X
|
||
XIf any portion of this section is held invalid or unenforceable under any
|
||
Xparticular circumstance, the balance of the section is intended to apply,
|
||
Xand the section as a whole is intended to apply in other circumstances.
|
||
X
|
||
XIt is not the purpose of this section to induce you to infringe any
|
||
Xpatents or other property right claims or to contest validity of any
|
||
Xsuch claims; this section has the sole purpose of protecting the
|
||
Xintegrity of the free software distribution system which is
|
||
Ximplemented by public license practices. Many people have made
|
||
Xgenerous contributions to the wide range of software distributed
|
||
Xthrough that system in reliance on consistent application of that
|
||
Xsystem; it is up to the author/donor to decide if he or she is willing
|
||
Xto distribute software through any other system and a licensee cannot
|
||
Ximpose that choice.
|
||
X
|
||
XThis section is intended to make thoroughly clear what is believed to
|
||
Xbe a consequence of the rest of this License.
|
||
X
|
||
X 12. If the distribution and/or use of the Library is restricted in
|
||
Xcertain countries either by patents or by copyrighted interfaces, the
|
||
Xoriginal copyright holder who places the Library under this License may add
|
||
Xan explicit geographical distribution limitation excluding those countries,
|
||
Xso that distribution is permitted only in or among countries not thus
|
||
Xexcluded. In such case, this License incorporates the limitation as if
|
||
Xwritten in the body of this License.
|
||
X
|
||
X 13. The Free Software Foundation may publish revised and/or new
|
||
Xversions of the Library General Public License from time to time.
|
||
XSuch new versions will be similar in spirit to the present version,
|
||
Xbut may differ in detail to address new problems or concerns.
|
||
X
|
||
XEach version is given a distinguishing version number. If the Library
|
||
Xspecifies a version number of this License which applies to it and
|
||
X"any later version", you have the option of following the terms and
|
||
Xconditions either of that version or of any later version published by
|
||
Xthe Free Software Foundation. If the Library does not specify a
|
||
Xlicense version number, you may choose any version ever published by
|
||
Xthe Free Software Foundation.
|
||
X
|
||
X 14. If you wish to incorporate parts of the Library into other free
|
||
Xprograms whose distribution conditions are incompatible with these,
|
||
Xwrite to the author to ask for permission. For software which is
|
||
Xcopyrighted by the Free Software Foundation, write to the Free
|
||
XSoftware Foundation; we sometimes make exceptions for this. Our
|
||
Xdecision will be guided by the two goals of preserving the free status
|
||
Xof all derivatives of our free software and of promoting the sharing
|
||
Xand reuse of software generally.
|
||
X
|
||
X NO WARRANTY
|
||
X
|
||
X 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||
XWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||
XEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||
XOTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||
XKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||
XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
XPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||
XLIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||
XTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||
X
|
||
X 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||
XWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||
XAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||
XFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||
XCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||
XLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||
XRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||
XFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||
XSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||
XDAMAGES.
|
||
X
|
||
X END OF TERMS AND CONDITIONS
|
||
X
|
||
X Appendix: How to Apply These Terms to Your New Libraries
|
||
X
|
||
X If you develop a new library, and you want it to be of the greatest
|
||
Xpossible use to the public, we recommend making it free software that
|
||
Xeveryone can redistribute and change. You can do so by permitting
|
||
Xredistribution under these terms (or, alternatively, under the terms of the
|
||
Xordinary General Public License).
|
||
X
|
||
X To apply these terms, attach the following notices to the library. It is
|
||
Xsafest to attach them to the start of each source file to most effectively
|
||
Xconvey the exclusion of warranty; and each file should have at least the
|
||
X"copyright" line and a pointer to where the full notice is found.
|
||
X
|
||
X <one line to give the library's name and a brief idea of what it does.>
|
||
X Copyright (C) <year> <name of author>
|
||
X
|
||
X This library is free software; you can redistribute it and/or
|
||
X modify it under the terms of the GNU Library General Public
|
||
X License as published by the Free Software Foundation; either
|
||
X version 2 of the License, or (at your option) any later version.
|
||
X
|
||
X This library is distributed in the hope that it will be useful,
|
||
X but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
X Library General Public License for more details.
|
||
X
|
||
X You should have received a copy of the GNU Library General Public
|
||
X License along with this library; if not, write to the Free
|
||
X Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X
|
||
XAlso add information on how to contact you by electronic and paper mail.
|
||
X
|
||
XYou should also get your employer (if you work as a programmer) or your
|
||
Xschool, if any, to sign a "copyright disclaimer" for the library, if
|
||
Xnecessary. Here is a sample; alter the names:
|
||
X
|
||
X Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||
X library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||
X
|
||
X <signature of Ty Coon>, 1 April 1990
|
||
X Ty Coon, President of Vice
|
||
X
|
||
XThat's all there is to it!
|
||
Spam_Animals
|
||
chmod 0444 COPYING || echo "restore of COPYING fails"
|
||
sed 's/^X//' << 'Spam_Animals' > Makefile &&
|
||
X#
|
||
X# Copyright 1994, John F. Haugh II
|
||
X#
|
||
X# This software is derived from the Shadow Password Suite, version 3.3.2.
|
||
X# No portion of this comment block or copyright statement may be altered
|
||
X# without the written permission of the copyright holder.
|
||
X#
|
||
X# This library is free software; you can redistribute it and/or modify
|
||
X# it under the terms of the GNU Library General Public License as
|
||
X# published by the Free Software Foundation; either version 2 of the
|
||
X# License, or (at your option) any later version.
|
||
X#
|
||
X# This library is distributed in the hope that it will be useful,
|
||
X# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
X# GNU Library General Public License for more details.
|
||
X#
|
||
X# You should have received a copy of the GNU Library General Public
|
||
X# License along with this program; if not, write to the Free Software
|
||
X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X#
|
||
X# @(#)Makefile 1.1 12:22:44 13 Feb 1994 (GNU Shadow Library Suite)
|
||
X#
|
||
XSHELL = /bin/sh
|
||
X
|
||
X# Pick your favorite C compiler and tags command
|
||
XCC = gcc
|
||
XTAGS = ctags
|
||
X
|
||
X# Pick the features you want.
|
||
XDEF_NIS = -DUSE_NIS
|
||
XDEF_NDBM = -DNDBM
|
||
X# DEBUG = -g
|
||
XOPTIM = -O
|
||
XLOCAL = -ansi
|
||
XINCLUDES = -I.
|
||
X
|
||
XCFLAGS = $(DEF_NIS) $(DEF_NDBM) $(DEBUG) $(OPTIM) $(LOCAL) $(INCLUDES)
|
||
X
|
||
X# Do you have to do ranlib?
|
||
XRANLIB = ranlib
|
||
X# RANLIB = echo
|
||
X
|
||
XDEST_INCLUDE_DIR = /usr/include
|
||
X
|
||
X# Define your library name and directory
|
||
XLIBDIR = /lib
|
||
XLIBSEC = libsec.a
|
||
X
|
||
X# Some flags for making the shar file
|
||
XSHARFLAGS = -D -c -dSpam_Animals
|
||
X
|
||
X# Rules for .L (lint) files.
|
||
X.SUFFIXES: .L
|
||
XLINT = lint
|
||
XLINTFLAGS = $(OS) -Dlint
|
||
X
|
||
X.c.L:
|
||
X $(LINT) -pxu $(LINTFLAGS) $*.c > $*.L
|
||
X
|
||
XALLSRCS = gshadow.c shadow.c
|
||
X
|
||
XFILES = COPYING Makefile shadow.c shadow.h gshadow.c gshadow.h
|
||
X
|
||
Xall: $(LIBSEC)
|
||
X
|
||
X.PRECIOUS: $(LIBSEC)
|
||
X
|
||
X$(LIBSEC): \
|
||
X $(LIBSEC)(shadow.o) \
|
||
X $(LIBSEC)(gshadow.o)
|
||
X $(RANLIB) $(LIBSEC)
|
||
X
|
||
Xsave:
|
||
X [ ! -d save ] && mkdir save
|
||
X -cp $(LIBDIR)/$(LIBSEC) save
|
||
X -cp $(DEST_INCLUDE_DIR)/shadow.h $(DEST_INCLUDE_DIR)/gshadow.h save
|
||
X
|
||
Xrestore:
|
||
X [ -d save ]
|
||
X -(cd save ; cp shadow.h gshadow.h $(DEST_INCLUDE_DIR) )
|
||
X -(cd save ; cp $(LIBSEC) $(LIBDIR) )
|
||
X
|
||
Xinstall: all
|
||
X cp shadow.h gshadow.h $(DEST_INCLUDE_DIR)
|
||
X cp $(LIBSEC) $(LIBDIR)
|
||
X chown bin $(LIBDIR)/$(LIBSEC) $(DEST_INCLUDE_DIR)/shadow.h \
|
||
X $(DEST_INCLUDE_DIR)/gshadow.h
|
||
X chgrp bin $(LIBDIR)/$(LIBSEC) $(DEST_INCLUDE_DIR)/shadow.h \
|
||
X $(DEST_INCLUDE_DIR)/gshadow.h
|
||
X chmod 444 $(DEST_INCLUDE_DIR)/shadow.h $(DEST_INCLUDE_DIR)/gshadow.h
|
||
X chmod 555 $(LIBDIR)/$(LIBSEC)
|
||
X
|
||
Xlint: $(ALLSRCS:.c=.L)
|
||
X
|
||
Xtags: $(ALLSRCS)
|
||
X $(TAGS) $(ALLSRCS)
|
||
X
|
||
Xlibshadow.a(shadow.o): shadow.h
|
||
Xlibshadow.a(gshadow.o): gshadow.h
|
||
X
|
||
Xclean:
|
||
X -rm -f *.o
|
||
X
|
||
Xclobber: clean
|
||
X -rm -f $(LIBSEC)
|
||
X
|
||
Xshar: gnu-shadow-lib.shar
|
||
X
|
||
Xgnu-shadow-lib.shar: $(FILES)
|
||
X shar $(SHARFLAGS) $(FILES) > gnu-shadow-lib.shar
|
||
Spam_Animals
|
||
chmod 0444 Makefile || echo "restore of Makefile fails"
|
||
sed 's/^X//' << 'Spam_Animals' > shadow.c &&
|
||
X/*
|
||
X * Copyright 1989 - 1994, John F. Haugh II
|
||
X * All rights reserved.
|
||
X *
|
||
X * This software is derived from the Shadow Password Suite, version 3.3.2.
|
||
X * No portion of this comment block or copyright statement may be altered
|
||
X * without the written permission of the copyright holder.
|
||
X *
|
||
X * This library is free software; you can redistribute it and/or modify
|
||
X * it under the terms of the GNU Library General Public License as
|
||
X * published by the Free Software Foundation; either version 2 of the
|
||
X * License, or (at your option) any later version.
|
||
X *
|
||
X * This library is distributed in the hope that it will be useful,
|
||
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
X * GNU Library General Public License for more details.
|
||
X *
|
||
X * You should have received a copy of the GNU Library General Public
|
||
X * License along with this program; if not, write to the Free Software
|
||
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X */
|
||
X
|
||
X
|
||
X#ifndef lint
|
||
Xstatic char copyright[] = "@(#)Copyright 1989 - 1994, John F. Haugh II";
|
||
Xstatic char sccsid[] = "@(#)shadow.c 1.1 12:23:06 13 Feb 1994 (GNU Shadow Library Suite)";
|
||
X#endif
|
||
X
|
||
X#include <sys/types.h>
|
||
X#include <stdio.h>
|
||
X#include <stdlib.h>
|
||
X#include <string.h>
|
||
X#include <memory.h>
|
||
X#include "shadow.h"
|
||
X
|
||
X#ifdef NDBM
|
||
X#include <ndbm.h>
|
||
X#include <fcntl.h>
|
||
XDBM *sp_dbm;
|
||
Xint sp_dbm_mode = -1;
|
||
Xstatic int dbmopened;
|
||
Xstatic int dbmerror;
|
||
X#endif
|
||
X
|
||
X#ifdef USE_NIS
|
||
Xstatic int nis_used;
|
||
Xstatic int nis_ignore;
|
||
Xstatic enum { native, start, middle, native2 } nis_state;
|
||
Xstatic int nis_bound;
|
||
Xstatic char *nis_domain;
|
||
Xstatic char *nis_key;
|
||
Xstatic int nis_keylen;
|
||
Xstatic char *nis_val;
|
||
Xstatic int nis_vallen;
|
||
X#define IS_NISCHAR(c) ((c)=='+')
|
||
X#endif
|
||
X
|
||
Xstatic FILE *shadow;
|
||
Xstatic char spwbuf[BUFSIZ];
|
||
Xstatic struct spwd spwd;
|
||
X
|
||
X#define FIELDS 9
|
||
X#define OFIELDS 5
|
||
X
|
||
X#ifdef USE_NIS
|
||
X
|
||
X/*
|
||
X * __setspNIS - turn on or off NIS searches
|
||
X */
|
||
X
|
||
Xvoid
|
||
X__setspNIS (flag)
|
||
Xint flag;
|
||
X{
|
||
X nis_ignore = ! flag;
|
||
X
|
||
X if (nis_ignore)
|
||
X nis_used = 0;
|
||
X}
|
||
X
|
||
X/*
|
||
X * bind_nis - bind to NIS server
|
||
X */
|
||
X
|
||
Xstatic int
|
||
Xbind_nis ()
|
||
X{
|
||
X if (yp_get_default_domain (&nis_domain))
|
||
X return -1;
|
||
X
|
||
X nis_bound = 1;
|
||
X return 0;
|
||
X}
|
||
X#endif
|
||
X
|
||
X/*
|
||
X * setspent - initialize access to shadow text and DBM files
|
||
X */
|
||
X
|
||
Xvoid
|
||
Xsetspent ()
|
||
X{
|
||
X if (shadow)
|
||
X rewind (shadow);
|
||
X else
|
||
X shadow = fopen (SHADOW, "r");
|
||
X
|
||
X#ifdef USE_NIS
|
||
X nis_state = native;
|
||
X#endif
|
||
X
|
||
X /*
|
||
X * Attempt to open the DBM files if they have never been opened
|
||
X * and an error has never been returned.
|
||
X */
|
||
X
|
||
X#ifdef NDBM
|
||
X if (! dbmerror && ! dbmopened) {
|
||
X int mode;
|
||
X char dbmfiles[BUFSIZ];
|
||
X
|
||
X strcpy (dbmfiles, SHADOW);
|
||
X strcat (dbmfiles, ".pag");
|
||
X
|
||
X if (sp_dbm_mode == -1)
|
||
X mode = O_RDWR;
|
||
X else
|
||
X mode = (sp_dbm_mode == O_RDWR) ? O_RDWR:O_RDONLY;
|
||
X
|
||
X if (! (sp_dbm = dbm_open (SHADOW, mode, 0)))
|
||
X dbmerror = 1;
|
||
X else
|
||
X dbmopened = 1;
|
||
X }
|
||
X#endif
|
||
X}
|
||
X
|
||
X/*
|
||
X * endspent - terminate access to shadow text and DBM files
|
||
X */
|
||
X
|
||
Xvoid
|
||
Xendspent ()
|
||
X{
|
||
X if (shadow)
|
||
X (void) fclose (shadow);
|
||
X
|
||
X shadow = (FILE *) 0;
|
||
X#ifdef NDBM
|
||
X if (dbmopened && sp_dbm) {
|
||
X dbm_close (sp_dbm);
|
||
X sp_dbm = 0;
|
||
X }
|
||
X dbmopened = 0;
|
||
X dbmerror = 0;
|
||
X#endif
|
||
X}
|
||
X
|
||
X/*
|
||
X * sgetspent - convert string in shadow file format to (struct spwd *)
|
||
X */
|
||
X
|
||
Xstruct spwd *
|
||
Xsgetspent (string)
|
||
X#ifdef __STDC__
|
||
Xconst
|
||
X#endif
|
||
Xchar *string;
|
||
X{
|
||
X char *fields[FIELDS];
|
||
X char *cp;
|
||
X char *cpp;
|
||
X int atoi ();
|
||
X long atol ();
|
||
X int i;
|
||
X
|
||
X /*
|
||
X * Copy string to local buffer. It has to be tokenized and we
|
||
X * have to do that to our private copy.
|
||
X */
|
||
X
|
||
X strncpy (spwbuf, string, BUFSIZ-1);
|
||
X spwbuf[BUFSIZ-1] = '\0';
|
||
X
|
||
X if (cp = strrchr (spwbuf, '\n'))
|
||
X *cp = '\0';
|
||
X
|
||
X /*
|
||
X * Tokenize the string into colon separated fields. Allow up to
|
||
X * FIELDS different fields.
|
||
X */
|
||
X
|
||
X for (cp = spwbuf, i = 0;*cp && i < FIELDS;i++) {
|
||
X fields[i] = cp;
|
||
X while (*cp && *cp != ':')
|
||
X cp++;
|
||
X
|
||
X if (*cp)
|
||
X *cp++ = '\0';
|
||
X }
|
||
X
|
||
X /*
|
||
X * It is acceptable for the last SVR4 field to be blank. This
|
||
X * results in the loop being terminated early. In which case,
|
||
X * we just make the last field be blank and be done with it.
|
||
X */
|
||
X
|
||
X if (i == (FIELDS-1))
|
||
X fields[i++] = cp;
|
||
X
|
||
X if ((cp && *cp) || (i != FIELDS && i != OFIELDS))
|
||
X return 0;
|
||
X
|
||
X /*
|
||
X * Start populating the structure. The fields are all in
|
||
X * static storage, as is the structure we pass back. If we
|
||
X * ever see a name with '+' as the first character, we try
|
||
X * to turn on NIS processing.
|
||
X */
|
||
X
|
||
X spwd.sp_namp = fields[0];
|
||
X#ifdef USE_NIS
|
||
X if (IS_NISCHAR (fields[0][0]))
|
||
X nis_used = 1;
|
||
X#endif
|
||
X spwd.sp_pwdp = fields[1];
|
||
X
|
||
X /*
|
||
X * Get the last changed date. For all of the integer fields,
|
||
X * we check for proper format. It is an error to have an
|
||
X * incorrectly formatted number, unless we are using NIS.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_lstchg = strtol (fields[2], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_lstchg = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[2][0] == '\0')
|
||
X spwd.sp_lstchg = -1;
|
||
X
|
||
X /*
|
||
X * Get the minimum period between password changes.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_min = strtol (fields[3], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_min = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[3][0] == '\0')
|
||
X spwd.sp_min = -1;
|
||
X
|
||
X /*
|
||
X * Get the maximum number of days a password is valid.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_max = strtol (fields[4], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_max = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[4][0] == '\0')
|
||
X spwd.sp_max = -1;
|
||
X
|
||
X /*
|
||
X * If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
|
||
X * formatted file), initialize the other field members to -1.
|
||
X */
|
||
X
|
||
X if (i == OFIELDS) {
|
||
X spwd.sp_warn = spwd.sp_inact = spwd.sp_expire =
|
||
X spwd.sp_flag = -1;
|
||
X
|
||
X return &spwd;
|
||
X }
|
||
X
|
||
X /*
|
||
X * The rest of the fields are mandatory for SVR4, but optional
|
||
X * for anything else. However, if one is present the others
|
||
X * must be as well.
|
||
X */
|
||
X
|
||
X /*
|
||
X * Get the number of days of password expiry warning.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_warn = strtol (fields[5], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_warn = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[5][0] == '\0')
|
||
X spwd.sp_warn = -1;
|
||
X
|
||
X /*
|
||
X * Get the number of days of inactivity before an account is
|
||
X * disabled.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_inact = strtol (fields[6], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_inact = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[6][0] == '\0')
|
||
X spwd.sp_inact = -1;
|
||
X
|
||
X /*
|
||
X * Get the number of days after the epoch before the account is
|
||
X * set to expire.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_expire = strtol (fields[7], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_expire = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[7][0] == '\0')
|
||
X spwd.sp_expire = -1;
|
||
X
|
||
X /*
|
||
X * This field is reserved for future use. But it isn't supposed
|
||
X * to have anything other than a valid integer in it.
|
||
X */
|
||
X
|
||
X if ((spwd.sp_flag = strtol (fields[8], &cpp, 10)) == 0 && *cpp) {
|
||
X#ifdef USE_NIS
|
||
X if (! nis_used)
|
||
X return 0;
|
||
X else
|
||
X spwd.sp_flag = -1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X } else if (fields[8][0] == '\0')
|
||
X spwd.sp_flag = -1;
|
||
X
|
||
X return (&spwd);
|
||
X}
|
||
X
|
||
X/*
|
||
X * fgetspent - get an entry from a /etc/shadow formatted stream
|
||
X */
|
||
X
|
||
Xstruct spwd
|
||
X*fgetspent (fp)
|
||
XFILE *fp;
|
||
X{
|
||
X char buf[BUFSIZ];
|
||
X char *cp;
|
||
X
|
||
X if (! fp)
|
||
X return (0);
|
||
X
|
||
X#ifdef USE_NIS
|
||
X while (fgets (buf, sizeof buf, fp) != (char *) 0)
|
||
X#else
|
||
X if (fgets (buf, sizeof buf, fp) != (char *) 0)
|
||
X#endif
|
||
X {
|
||
X if (cp = strchr (buf, '\n'))
|
||
X *cp = '\0';
|
||
X#ifdef USE_NIS
|
||
X if (nis_ignore && IS_NISCHAR (buf[0]))
|
||
X continue;
|
||
X#endif
|
||
X return (sgetspent (buf));
|
||
X }
|
||
X return 0;
|
||
X}
|
||
X
|
||
X/*
|
||
X * getspent - get a (struct spwd *) from the current shadow file
|
||
X */
|
||
X
|
||
Xstruct spwd
|
||
X*getspent ()
|
||
X{
|
||
X#ifdef USE_NIS
|
||
X int nis_1_user = 0;
|
||
X struct spwd *val;
|
||
X char buf[BUFSIZ];
|
||
X#endif
|
||
X if (! shadow)
|
||
X setspent ();
|
||
X
|
||
X#ifdef USE_NIS
|
||
Xagain:
|
||
X /*
|
||
X * See if we are reading from the local file.
|
||
X */
|
||
X
|
||
X if (nis_state == native || nis_state == native2) {
|
||
X
|
||
X /*
|
||
X * Get the next entry from the shadow file. Return NULL
|
||
X * right away if there is none.
|
||
X */
|
||
X
|
||
X if (! (val = fgetspent (shadow)))
|
||
X return 0;
|
||
X
|
||
X /*
|
||
X * If this entry began with a NIS escape character, we have
|
||
X * to see if this is just a single user, or if the entire
|
||
X * map is being asked for.
|
||
X */
|
||
X
|
||
X if (IS_NISCHAR (val->sp_namp[0])) {
|
||
X if (val->sp_namp[1])
|
||
X nis_1_user = 1;
|
||
X else
|
||
X nis_state = start;
|
||
X }
|
||
X
|
||
X /*
|
||
X * If this isn't a NIS user and this isn't an escape to go
|
||
X * use a NIS map, it must be a regular local user.
|
||
X */
|
||
X
|
||
X if (nis_1_user == 0 && nis_state != start)
|
||
X return val;
|
||
X
|
||
X /*
|
||
X * If this is an escape to use an NIS map, switch over to
|
||
X * that bunch of code.
|
||
X */
|
||
X
|
||
X if (nis_state == start)
|
||
X goto again;
|
||
X
|
||
X /*
|
||
X * NEEDSWORK. Here we substitute pieces-parts of this entry.
|
||
X */
|
||
X
|
||
X return 0;
|
||
X } else {
|
||
X if (nis_bound == 0) {
|
||
X if (bind_nis ()) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X }
|
||
X if (nis_state == start) {
|
||
X if (yp_first (nis_domain, "shadow.bynam", &nis_key,
|
||
X &nis_keylen, &nis_val, &nis_vallen)) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X nis_state = middle;
|
||
X } else if (nis_state == middle) {
|
||
X if (yp_next (nis_domain, "shadow.bynam", nis_key,
|
||
X nis_keylen, &nis_key, &nis_keylen,
|
||
X &nis_val, &nis_vallen)) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X }
|
||
X return sgetspent (nis_val);
|
||
X }
|
||
X#else
|
||
X return (fgetspent (shadow));
|
||
X#endif
|
||
X}
|
||
X
|
||
X/*
|
||
X * getspnam - get a shadow entry by name
|
||
X */
|
||
X
|
||
Xstruct spwd
|
||
X*getspnam (name)
|
||
X#if __STDC__
|
||
Xconst
|
||
X#endif
|
||
Xchar *name;
|
||
X{
|
||
X struct spwd *sp;
|
||
X#ifdef NDBM
|
||
X datum key;
|
||
X datum content;
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X char buf[BUFSIZ];
|
||
X static char save_name[16];
|
||
X int nis_disabled = 0;
|
||
X#endif
|
||
X
|
||
X setspent ();
|
||
X
|
||
X#ifdef NDBM
|
||
X
|
||
X /*
|
||
X * If the DBM file are now open, create a key for this UID and
|
||
X * try to fetch the entry from the database. A matching record
|
||
X * will be unpacked into a static structure and returned to
|
||
X * the user.
|
||
X */
|
||
X
|
||
X if (dbmopened) {
|
||
X key.dsize = strlen (name);
|
||
X key.dptr = name;
|
||
X
|
||
X content = dbm_fetch (sp_dbm, key);
|
||
X if (content.dptr != 0) {
|
||
X memcpy (spwbuf, content.dptr, content.dsize);
|
||
X spw_unpack (spwbuf, content.dsize, &spwd);
|
||
X return &spwd;
|
||
X }
|
||
X }
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X /*
|
||
X * Search the shadow.byname map for this user.
|
||
X */
|
||
X
|
||
X if (! nis_ignore && ! nis_bound)
|
||
X bind_nis ();
|
||
X
|
||
X if (! nis_ignore && nis_bound) {
|
||
X char *cp;
|
||
X
|
||
X if (yp_match (nis_domain, "shadow.byname", name,
|
||
X strlen (name), &nis_val, &nis_vallen) == 0) {
|
||
X
|
||
X if (cp = strchr (nis_val, '\n'))
|
||
X *cp = '\0';
|
||
X
|
||
X nis_state = middle;
|
||
X if (sp = sgetspent (nis_val)) {
|
||
X strcpy (save_name, sp->sp_namp);
|
||
X nis_key = save_name;
|
||
X nis_keylen = strlen (save_name);
|
||
X }
|
||
X return (sgetspent (nis_val));
|
||
X } else
|
||
X nis_state = native2;
|
||
X }
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X /*
|
||
X * NEEDSWORK -- this is a mess, and it is the same mess in the
|
||
X * other three files. I can't just blindly turn off NIS because
|
||
X * this might be the first pass through the local files. In
|
||
X * that case, I never discover that NIS is present.
|
||
X */
|
||
X
|
||
X if (nis_used) {
|
||
X nis_ignore++;
|
||
X nis_disabled++;
|
||
X }
|
||
X#endif
|
||
X while ((sp = getspent ()) != (struct spwd *) 0) {
|
||
X if (strcmp (name, sp->sp_namp) == 0)
|
||
X break;
|
||
X }
|
||
X#ifdef USE_NIS
|
||
X if (nis_disabled)
|
||
X nis_ignore--;
|
||
X#endif
|
||
X return (sp);
|
||
X}
|
||
X
|
||
Xint
|
||
Xputspent (sp, fp)
|
||
X#if __STDC__
|
||
Xconst
|
||
X#endif
|
||
Xstruct spwd *sp;
|
||
XFILE *fp;
|
||
X{
|
||
X int errors = 0;
|
||
X
|
||
X if (! fp || ! sp)
|
||
X return -1;
|
||
X
|
||
X if (fprintf (fp, "%s:%s:", sp->sp_namp, sp->sp_pwdp) < 0)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_lstchg != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_lstchg) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_min != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_min) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_max != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_max) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_warn != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_warn) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_inact != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_inact) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_expire != -1) {
|
||
X if (fprintf (fp, "%ld:", sp->sp_expire) < 0)
|
||
X errors++;
|
||
X } else if (putc (':', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (sp->sp_flag != -1) {
|
||
X if (fprintf (fp, "%ld", sp->sp_flag) < 0)
|
||
X errors++;
|
||
X }
|
||
X if (putc ('\n', fp) == EOF)
|
||
X errors++;
|
||
X
|
||
X if (errors)
|
||
X return -1;
|
||
X else
|
||
X return 0;
|
||
X}
|
||
Spam_Animals
|
||
chmod 0444 shadow.c || echo "restore of shadow.c fails"
|
||
sed 's/^X//' << 'Spam_Animals' > shadow.h &&
|
||
X/*
|
||
X * Copyright 1988 - 1994, John F. Haugh II
|
||
X * All rights reserved.
|
||
X *
|
||
X * This software is derived from the Shadow Password Suite, version 3.3.2.
|
||
X * No portion of this comment block or copyright statement may be altered
|
||
X * without the written permission of the copyright holder.
|
||
X *
|
||
X * This library is free software; you can redistribute it and/or modify
|
||
X * it under the terms of the GNU Library General Public License as
|
||
X * published by the Free Software Foundation; either version 2 of the
|
||
X * License, or (at your option) any later version.
|
||
X *
|
||
X * This library is distributed in the hope that it will be useful,
|
||
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
X * GNU Library General Public License for more details.
|
||
X *
|
||
X * You should have received a copy of the GNU Library General Public
|
||
X * License along with this program; if not, write to the Free Software
|
||
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X */
|
||
X
|
||
X#ifndef _H_SHADOW
|
||
X#define _H_SHADOW
|
||
X
|
||
X/*
|
||
X * This information is not derived from AT&T licensed sources. Posted
|
||
X * to the USENET 11/88, and updated 11/90 with information from SVR4.
|
||
X *
|
||
X * @(#)shadow.h 1.1 12:23:13 13 Feb 1994 (GNU Shadow Library Suite)
|
||
X */
|
||
X
|
||
X/*
|
||
X * Shadow password security file structure.
|
||
X */
|
||
X
|
||
Xstruct spwd {
|
||
X char *sp_namp; /* login name */
|
||
X char *sp_pwdp; /* encrypted password */
|
||
X time_t sp_lstchg; /* date of last change */
|
||
X time_t sp_min; /* minimum number of days between changes */
|
||
X time_t sp_max; /* maximum number of days between changes */
|
||
X time_t sp_warn; /* number of days of warning before password
|
||
X expires */
|
||
X time_t sp_inact; /* number of days after password expires
|
||
X until the account becomes unusable. */
|
||
X time_t sp_expire; /* days since 1/1/70 until account expires */
|
||
X unsigned long sp_flag; /* reserved for future use */
|
||
X};
|
||
X
|
||
X/*
|
||
X * Shadow password security file functions.
|
||
X */
|
||
X
|
||
X#if defined(__STDC__)
|
||
Xstruct spwd *getspent (void);
|
||
Xstruct spwd *getspnam (const char *);
|
||
Xstruct spwd *sgetspent (const char *);
|
||
Xstruct spwd *fgetspent (FILE *);
|
||
Xvoid setspent (void);
|
||
Xvoid endspent (void);
|
||
Xint putspent (const struct spwd *, FILE *);
|
||
X#else
|
||
Xstruct spwd *getspent ();
|
||
Xstruct spwd *getspnam ();
|
||
Xstruct spwd *sgetspent ();
|
||
Xstruct spwd *fgetspent ();
|
||
Xvoid setspent ();
|
||
Xvoid endspent ();
|
||
Xint putspent ();
|
||
X#endif
|
||
X
|
||
X#define SHADOW "/etc/shadow"
|
||
X#endif
|
||
Spam_Animals
|
||
chmod 0444 shadow.h || echo "restore of shadow.h fails"
|
||
sed 's/^X//' << 'Spam_Animals' > gshadow.c &&
|
||
X/*
|
||
X * Copyright 1990 - 1994, John F. Haugh II
|
||
X * All rights reserved.
|
||
X *
|
||
X * This software is derived from the Shadow Password Suite, version 3.3.2.
|
||
X * No portion of this comment block or copyright statement may be altered
|
||
X * without the written permission of the copyright holder.
|
||
X *
|
||
X * This library is free software; you can redistribute it and/or modify
|
||
X * it under the terms of the GNU Library General Public License as
|
||
X * published by the Free Software Foundation; either version 2 of the
|
||
X * License, or (at your option) any later version.
|
||
X *
|
||
X * This library is distributed in the hope that it will be useful,
|
||
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
X * GNU Library General Public License for more details.
|
||
X *
|
||
X * You should have received a copy of the GNU Library General Public
|
||
X * License along with this program; if not, write to the Free Software
|
||
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X */
|
||
X
|
||
X#ifndef lint
|
||
Xstatic char copyright[] = "@(#)Copyright 1990 - 1994, John F. Haugh II";
|
||
Xstatic char sccsid[] = "@(#)gshadow.c 1.1 12:22:51 13 Feb 1994 (GNU Shadow Library Suite)";
|
||
X#endif
|
||
X
|
||
X#include <stdio.h>
|
||
X#include <gshadow.h>
|
||
X#include <string.h>
|
||
X#include <memory.h>
|
||
X
|
||
X#ifdef NDBM
|
||
X#include <ndbm.h>
|
||
X#include <fcntl.h>
|
||
XDBM *sg_dbm;
|
||
Xint sg_dbm_mode = -1;
|
||
Xstatic int dbmopened;
|
||
Xstatic int dbmerror;
|
||
X#endif
|
||
X
|
||
X#define MAXMEM 1024
|
||
X
|
||
X#ifndef GSHADOW
|
||
X#define GSHADOW "/etc/gshadow"
|
||
X#endif
|
||
X
|
||
Xstatic FILE *shadow;
|
||
Xstatic char *sgrpfile = GSHADOW ;
|
||
Xstatic char sgrbuf[BUFSIZ*4];
|
||
Xstatic char *members[MAXMEM+1];
|
||
Xstatic char *admins[MAXMEM+1];
|
||
Xstatic struct sgrp sgroup;
|
||
X
|
||
X#define FIELDS 4
|
||
X
|
||
X#ifdef USE_NIS
|
||
Xstatic int nis_used;
|
||
Xstatic int nis_ignore;
|
||
Xstatic enum { native, start, middle, native2 } nis_state;
|
||
Xstatic int nis_bound;
|
||
Xstatic char *nis_domain;
|
||
Xstatic char *nis_key;
|
||
Xstatic int nis_keylen;
|
||
Xstatic char *nis_val;
|
||
Xstatic int nis_vallen;
|
||
X#define IS_NISCHAR(c) ((c)=='+')
|
||
X#endif
|
||
X
|
||
X#ifdef USE_NIS
|
||
X
|
||
X/*
|
||
X * __setsgNIS - turn on or off NIS searches
|
||
X */
|
||
X
|
||
Xvoid
|
||
X__setsgNIS (flag)
|
||
Xint flag;
|
||
X{
|
||
X nis_ignore = ! flag;
|
||
X
|
||
X if (nis_ignore)
|
||
X nis_used = 0;
|
||
X}
|
||
X
|
||
X/*
|
||
X * bind_nis - bind to NIS server
|
||
X */
|
||
X
|
||
Xstatic int
|
||
Xbind_nis ()
|
||
X{
|
||
X if (yp_get_default_domain (&nis_domain))
|
||
X return -1;
|
||
X
|
||
X nis_bound = 1;
|
||
X return 0;
|
||
X}
|
||
X#endif
|
||
X
|
||
Xstatic char **
|
||
Xlist (s, l)
|
||
Xchar *s;
|
||
Xchar **l;
|
||
X{
|
||
X int nmembers = 0;
|
||
X
|
||
X while (s && *s) {
|
||
X l[nmembers++] = s;
|
||
X if (s = strchr (s, ','))
|
||
X *s++ = '\0';
|
||
X }
|
||
X l[nmembers] = (char *) 0;
|
||
X return l;
|
||
X}
|
||
X
|
||
Xvoid
|
||
Xsetsgent ()
|
||
X{
|
||
X#ifdef NDBM
|
||
X int mode;
|
||
X#endif /* NDBM */
|
||
X
|
||
X#ifdef USE_NIS
|
||
X nis_state = native;
|
||
X#endif
|
||
X if (shadow)
|
||
X rewind (shadow);
|
||
X else
|
||
X shadow = fopen (GSHADOW, "r");
|
||
X
|
||
X /*
|
||
X * Attempt to open the DBM files if they have never been opened
|
||
X * and an error has never been returned.
|
||
X */
|
||
X
|
||
X#ifdef NDBM
|
||
X if (! dbmerror && ! dbmopened) {
|
||
X char dbmfiles[BUFSIZ];
|
||
X
|
||
X strcpy (dbmfiles, sgrpfile);
|
||
X strcat (dbmfiles, ".pag");
|
||
X
|
||
X if (sg_dbm_mode == -1)
|
||
X mode = O_RDWR;
|
||
X else
|
||
X mode = (sg_dbm_mode == O_RDWR) ? O_RDWR:O_RDONLY;
|
||
X
|
||
X if (access (dbmfiles, 0) ||
|
||
X (! (sg_dbm = dbm_open (sgrpfile, mode, 0))))
|
||
X dbmerror = 1;
|
||
X else
|
||
X dbmopened = 1;
|
||
X }
|
||
X#endif /* NDBM */
|
||
X}
|
||
X
|
||
Xvoid
|
||
Xendsgent ()
|
||
X{
|
||
X if (shadow)
|
||
X (void) fclose (shadow);
|
||
X
|
||
X shadow = (FILE *) 0;
|
||
X#ifdef NDBM
|
||
X if (dbmopened && sg_dbm) {
|
||
X dbm_close (sg_dbm);
|
||
X dbmopened = 0;
|
||
X sg_dbm = 0;
|
||
X }
|
||
X#endif
|
||
X}
|
||
X
|
||
Xstruct sgrp *
|
||
Xsgetsgent (string)
|
||
X#if defined(__STDC__)
|
||
Xconst
|
||
X#endif
|
||
Xchar *string;
|
||
X{
|
||
X char *fields[FIELDS];
|
||
X char *cp;
|
||
X int atoi ();
|
||
X long atol ();
|
||
X int i;
|
||
X
|
||
X strncpy (sgrbuf, string, (int) sizeof sgrbuf - 1);
|
||
X sgrbuf[sizeof sgrbuf - 1] = '\0';
|
||
X
|
||
X if (cp = strrchr (sgrbuf, '\n'))
|
||
X *cp = '\0';
|
||
X
|
||
X /*
|
||
X * There should be exactly 4 colon separated fields. Find
|
||
X * all 4 of them and save the starting addresses in fields[].
|
||
X */
|
||
X
|
||
X for (cp = sgrbuf, i = 0;i < FIELDS && cp;i++) {
|
||
X fields[i] = cp;
|
||
X if (cp = strchr (cp, ':'))
|
||
X *cp++ = '\0';
|
||
X }
|
||
X
|
||
X /*
|
||
X * If there was an extra field somehow, or perhaps not enough,
|
||
X * the line is invalid.
|
||
X */
|
||
X
|
||
X if (cp || i != FIELDS)
|
||
X#ifdef USE_NIS
|
||
X if (! IS_NISCHAR (fields[0][0]))
|
||
X return 0;
|
||
X else
|
||
X nis_used = 1;
|
||
X#else
|
||
X return 0;
|
||
X#endif
|
||
X
|
||
X sgroup.sg_name = fields[0];
|
||
X sgroup.sg_passwd = fields[1];
|
||
X sgroup.sg_adm = list (fields[2], admins);
|
||
X sgroup.sg_mem = list (fields[3], members);
|
||
X
|
||
X return &sgroup;
|
||
X}
|
||
X
|
||
Xstruct sgrp
|
||
X*fgetsgent (fp)
|
||
XFILE *fp;
|
||
X{
|
||
X char buf[sizeof sgrbuf];
|
||
X char *cp;
|
||
X
|
||
X if (! fp)
|
||
X return (0);
|
||
X
|
||
X#ifdef USE_NIS
|
||
X while (fgets (buf, sizeof buf, fp) != (char *) 0)
|
||
X#else
|
||
X if (fgets (buf, sizeof buf, fp) != (char *) 0)
|
||
X#endif
|
||
X {
|
||
X if (cp = strchr (buf, '\n'))
|
||
X *cp = '\0';
|
||
X#ifdef USE_NIS
|
||
X if (nis_ignore && IS_NISCHAR (buf[0]))
|
||
X continue;
|
||
X#endif
|
||
X return (sgetsgent (buf));
|
||
X }
|
||
X return 0;
|
||
X}
|
||
X
|
||
X/*
|
||
X * getsgent - get a single shadow group entry
|
||
X */
|
||
X
|
||
Xstruct sgrp
|
||
X*getsgent ()
|
||
X{
|
||
X#ifdef USE_NIS
|
||
X int nis_1_group = 0;
|
||
X struct sgrp *val;
|
||
X char buf[BUFSIZ];
|
||
X#endif
|
||
X if (! shadow)
|
||
X setsgent ();
|
||
X
|
||
X#ifdef USE_NIS
|
||
Xagain:
|
||
X /*
|
||
X * See if we are reading from the local file.
|
||
X */
|
||
X
|
||
X if (nis_state == native || nis_state == native2) {
|
||
X
|
||
X /*
|
||
X * Get the next entry from the shadow group file. Return
|
||
X * NULL right away if there is none.
|
||
X */
|
||
X
|
||
X if (! (val = fgetsgent (shadow)))
|
||
X return 0;
|
||
X
|
||
X /*
|
||
X * If this entry began with a NIS escape character, we have
|
||
X * to see if this is just a single group, or if the entire
|
||
X * map is being asked for.
|
||
X */
|
||
X
|
||
X if (IS_NISCHAR (val->sg_name[0])) {
|
||
X if (val->sg_name[1])
|
||
X nis_1_group = 1;
|
||
X else
|
||
X nis_state = start;
|
||
X }
|
||
X
|
||
X /*
|
||
X * If this isn't a NIS group and this isn't an escape to go
|
||
X * use a NIS map, it must be a regular local group.
|
||
X */
|
||
X
|
||
X if (nis_1_group == 0 && nis_state != start)
|
||
X return val;
|
||
X
|
||
X /*
|
||
X * If this is an escape to use an NIS map, switch over to
|
||
X * that bunch of code.
|
||
X */
|
||
X
|
||
X if (nis_state == start)
|
||
X goto again;
|
||
X
|
||
X /*
|
||
X * NEEDSWORK. Here we substitute pieces-parts of this entry.
|
||
X */
|
||
X
|
||
X return 0;
|
||
X } else {
|
||
X if (nis_bound == 0) {
|
||
X if (bind_nis ()) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X }
|
||
X if (nis_state == start) {
|
||
X if (yp_first (nis_domain, "gshadow.byname", &nis_key,
|
||
X &nis_keylen, &nis_val, &nis_vallen)) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X nis_state = middle;
|
||
X } else if (nis_state == middle) {
|
||
X if (yp_next (nis_domain, "gshadow.byname", nis_key,
|
||
X nis_keylen, &nis_key, &nis_keylen,
|
||
X &nis_val, &nis_vallen)) {
|
||
X nis_state = native2;
|
||
X goto again;
|
||
X }
|
||
X }
|
||
X return sgetsgent (nis_val);
|
||
X }
|
||
X#else
|
||
X return (fgetsgent (shadow));
|
||
X#endif
|
||
X}
|
||
X
|
||
X/*
|
||
X * getsgnam - get a shadow group entry by name
|
||
X */
|
||
X
|
||
Xstruct sgrp *
|
||
Xgetsgnam (name)
|
||
X#if defined(__STDC__)
|
||
Xconst
|
||
X#endif
|
||
Xchar *name;
|
||
X{
|
||
X struct sgrp *sgrp;
|
||
X#ifdef NDBM
|
||
X datum key;
|
||
X datum content;
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X char buf[BUFSIZ];
|
||
X static char save_name[16];
|
||
X int nis_disabled = 0;
|
||
X#endif
|
||
X
|
||
X setsgent ();
|
||
X
|
||
X#ifdef NDBM
|
||
X
|
||
X /*
|
||
X * If the DBM file are now open, create a key for this group and
|
||
X * try to fetch the entry from the database. A matching record
|
||
X * will be unpacked into a static structure and returned to
|
||
X * the user.
|
||
X */
|
||
X
|
||
X if (dbmopened) {
|
||
X key.dsize = strlen (name);
|
||
X key.dptr = (void *) name;
|
||
X
|
||
X content = dbm_fetch (sg_dbm, key);
|
||
X if (content.dptr != 0) {
|
||
X memcpy (sgrbuf, content.dptr, content.dsize);
|
||
X sgroup.sg_mem = members;
|
||
X sgroup.sg_adm = admins;
|
||
X sgr_unpack (sgrbuf, content.dsize, &sgroup);
|
||
X return &sgroup;
|
||
X }
|
||
X }
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X if (nis_used) {
|
||
Xagain:
|
||
X
|
||
X /*
|
||
X * Search the gshadow.byname map for this group.
|
||
X */
|
||
X
|
||
X if (! nis_bound)
|
||
X bind_nis ();
|
||
X
|
||
X if (nis_bound) {
|
||
X char *cp;
|
||
X
|
||
X if (yp_match (nis_domain, "gshadow.byname", name,
|
||
X strlen (name), &nis_val, &nis_vallen) == 0) {
|
||
X if (cp = strchr (nis_val, '\n'))
|
||
X *cp = '\0';
|
||
X
|
||
X nis_state = middle;
|
||
X if (sgrp = sgetsgent (nis_val)) {
|
||
X strcpy (save_name, sgrp->sg_name);
|
||
X nis_key = save_name;
|
||
X nis_keylen = strlen (save_name);
|
||
X }
|
||
X return sgrp;
|
||
X }
|
||
X }
|
||
X nis_state = native2;
|
||
X }
|
||
X#endif
|
||
X#ifdef USE_NIS
|
||
X if (nis_used) {
|
||
X nis_ignore++;
|
||
X nis_disabled++;
|
||
X }
|
||
X#endif
|
||
X while ((sgrp = getsgent ()) != (struct sgrp *) 0) {
|
||
X if (strcmp (name, sgrp->sg_name) == 0)
|
||
X break;
|
||
X }
|
||
X#ifdef USE_NIS
|
||
X nis_ignore--;
|
||
X#endif
|
||
X if (sgrp)
|
||
X return sgrp;
|
||
X return (0);
|
||
X}
|
||
X
|
||
Xint
|
||
Xputsgent (sgrp, fp)
|
||
X#if defined(__STDC__)
|
||
Xconst
|
||
X#endif
|
||
Xstruct sgrp *sgrp;
|
||
XFILE *fp;
|
||
X{
|
||
X char buf[sizeof sgrbuf];
|
||
X char *cp = buf;
|
||
X int i;
|
||
X
|
||
X if (! fp || ! sgrp)
|
||
X return -1;
|
||
X
|
||
X /*
|
||
X * Copy the group name and passwd.
|
||
X */
|
||
X
|
||
X strcpy (cp, sgrp->sg_name);
|
||
X cp += strlen (cp);
|
||
X *cp++ = ':';
|
||
X
|
||
X strcpy (cp, sgrp->sg_passwd);
|
||
X cp += strlen (cp);
|
||
X *cp++ = ':';
|
||
X
|
||
X /*
|
||
X * Copy the administrators, separating each from the other
|
||
X * with a ",".
|
||
X */
|
||
X
|
||
X for (i = 0;sgrp->sg_adm[i];i++) {
|
||
X if (i > 0)
|
||
X *cp++ = ',';
|
||
X
|
||
X strcpy (cp, sgrp->sg_adm[i]);
|
||
X cp += strlen (cp);
|
||
X }
|
||
X *cp++ = ':';
|
||
X
|
||
X /*
|
||
X * Now do likewise with the group members.
|
||
X */
|
||
X
|
||
X for (i = 0;sgrp->sg_mem[i];i++) {
|
||
X if (i > 0)
|
||
X *cp++ = ',';
|
||
X
|
||
X strcpy (cp, sgrp->sg_mem[i]);
|
||
X cp += strlen (cp);
|
||
X }
|
||
X *cp++ = '\n';
|
||
X *cp = '\0';
|
||
X
|
||
X /*
|
||
X * Output using the function which understands the line
|
||
X * continuation conventions.
|
||
X */
|
||
X
|
||
X return fputsx (buf, fp);
|
||
X}
|
||
Spam_Animals
|
||
chmod 0444 gshadow.c || echo "restore of gshadow.c fails"
|
||
sed 's/^X//' << 'Spam_Animals' > gshadow.h &&
|
||
X/*
|
||
X * Copyright 1988 - 1994, John F. Haugh II
|
||
X * All rights reserved.
|
||
X *
|
||
X * This software is derived from the Shadow Password Suite, version 3.3.2.
|
||
X * No portion of this comment block or copyright statement may be altered
|
||
X * without the written permission of the copyright holder.
|
||
X *
|
||
X * This library is free software; you can redistribute it and/or modify
|
||
X * it under the terms of the GNU Library General Public License as
|
||
X * published by the Free Software Foundation; either version 2 of the
|
||
X * License, or (at your option) any later version.
|
||
X *
|
||
X * This library is distributed in the hope that it will be useful,
|
||
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
X * GNU Library General Public License for more details.
|
||
X *
|
||
X * You should have received a copy of the GNU Library General Public
|
||
X * License along with this program; if not, write to the Free Software
|
||
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
X *
|
||
X * @(#)gshadow.h 1.1 12:22:59 13 Feb 1994 (GNU Shadow Library Suite)
|
||
X */
|
||
X
|
||
X#ifndef _H_GSHADOW
|
||
X#define _H_GSHADOW
|
||
X
|
||
X/*
|
||
X * Shadow group security file structure
|
||
X */
|
||
X
|
||
Xstruct sgrp {
|
||
X char *sg_name; /* group name */
|
||
X char *sg_passwd; /* group password */
|
||
X char **sg_adm; /* group administator list */
|
||
X char **sg_mem; /* group membership list */
|
||
X};
|
||
X
|
||
X/*
|
||
X * Shadow group security file functions.
|
||
X */
|
||
X
|
||
X#if defined(__STDC__)
|
||
Xstruct sgrp *getsgent (void);
|
||
Xstruct sgrp *getsgnam (const char *);
|
||
Xstruct sgrp *sgetsgent (const char *);
|
||
Xstruct sgrp *fgetsgent (FILE *);
|
||
Xvoid setsgent (void);
|
||
Xvoid endsgent (void);
|
||
Xint putsgent (const struct sgrp *, FILE *);
|
||
X#else
|
||
Xstruct sgrp *getsgent ();
|
||
Xstruct sgrp *getsgnam ();
|
||
Xstruct sgrp *sgetsgent ();
|
||
Xstruct sgrp *fgetsgent ();
|
||
Xvoid setsgent ();
|
||
Xvoid endsgent ();
|
||
Xint putsgent ();
|
||
X#endif
|
||
X
|
||
X#define GSHADOW "/etc/gshadow"
|
||
X#endif
|
||
Spam_Animals
|
||
chmod 0444 gshadow.h || echo "restore of gshadow.h fails"
|
||
exit 0
|
||
--
|
||
John F. Haugh II [ NRA-ILA ] [ Kill Barney ] !'s: ...!cs.utexas.edu!rpp386!jfh
|
||
Ma Bell: (512) 251-2151 [GOP][DoF #17][PADI][ENTJ] @'s: jfh@rpp386.cactus.org
|
||
There are three documents that run my life: The King James Bible, the United
|
||
States Constitution, and the UNIX System V Release 4 Programmer's Reference.
|
||
|