From 618b1d730306484ba59e776d136c5ca7fb76a493 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sat, 9 Jan 2010 08:48:43 -0500 Subject: [PATCH] Ported to libassuan 2.0. This version supports building a DSO so no in-tree libassuan is needed. --- Makefile.am | 2 +- assuan/AUTHORS | 35 -- assuan/COPYING | 676 --------------------------- assuan/COPYING.LIB | 510 -------------------- assuan/ChangeLog | 305 ------------ assuan/INSTALL | 291 ------------ assuan/Makefile.am | 34 -- assuan/NEWS | 219 --------- assuan/README | 21 - assuan/autogen.sh | 200 -------- assuan/config.rpath | 547 ---------------------- assuan/configure.ac | 279 ----------- assuan/m4/Makefile.am | 1 - assuan/m4/autobuild.m4 | 34 -- assuan/m4/gnupg-pth.m4 | 105 ----- assuan/m4/onceonly.m4 | 66 --- assuan/m4/socklen.m4 | 52 --- assuan/m4/sys_socket_h.m4 | 23 - assuan/src/Makefile.am | 66 --- assuan/src/assuan-buffer.c | 569 ---------------------- assuan/src/assuan-client.c | 236 ---------- assuan/src/assuan-connect.c | 83 ---- assuan/src/assuan-defs.h | 365 --------------- assuan/src/assuan-handler.c | 934 ------------------------------------- assuan/src/assuan-inquire.c | 387 --------------- assuan/src/assuan-io-pth.c | 191 -------- assuan/src/assuan-io.c | 245 ---------- assuan/src/assuan-listen.c | 155 ------ assuan/src/assuan-logging.c | 291 ------------ assuan/src/assuan-pipe-connect.c | 894 ----------------------------------- assuan/src/assuan-pipe-server.c | 189 -------- assuan/src/assuan-socket-connect.c | 180 ------- assuan/src/assuan-socket-server.c | 208 --------- assuan/src/assuan-socket.c | 439 ----------------- assuan/src/assuan-uds.c | 313 ------------- assuan/src/assuan-util.c | 188 -------- assuan/src/assuan.h | 663 -------------------------- assuan/src/funopen.c | 62 --- assuan/src/isascii.c | 28 -- assuan/src/libassuan-config.in | 144 ------ assuan/src/libassuan.m4 | 175 ------- assuan/src/memrchr.c | 39 -- assuan/src/mkerrors | 257 ---------- assuan/src/putc_unlocked.c | 30 -- assuan/src/setenv.c | 352 -------------- assuan/src/stpcpy.c | 54 --- configure.ac | 2 +- src/Makefile.am | 8 +- src/commands.c | 270 ++++++++--- src/common.h | 4 +- src/pinentry.c | 13 +- src/pwmd.c | 26 +- 52 files changed, 231 insertions(+), 11229 deletions(-) delete mode 100644 assuan/AUTHORS delete mode 100644 assuan/COPYING delete mode 100644 assuan/COPYING.LIB delete mode 100644 assuan/ChangeLog delete mode 100644 assuan/INSTALL delete mode 100644 assuan/Makefile.am delete mode 100644 assuan/NEWS delete mode 100644 assuan/README delete mode 100755 assuan/autogen.sh delete mode 100755 assuan/config.rpath delete mode 100644 assuan/configure.ac delete mode 100644 assuan/m4/Makefile.am delete mode 100644 assuan/m4/autobuild.m4 delete mode 100644 assuan/m4/gnupg-pth.m4 delete mode 100644 assuan/m4/onceonly.m4 delete mode 100644 assuan/m4/socklen.m4 delete mode 100644 assuan/m4/sys_socket_h.m4 delete mode 100644 assuan/src/Makefile.am delete mode 100644 assuan/src/assuan-buffer.c delete mode 100644 assuan/src/assuan-client.c delete mode 100644 assuan/src/assuan-connect.c delete mode 100644 assuan/src/assuan-defs.h delete mode 100644 assuan/src/assuan-handler.c delete mode 100644 assuan/src/assuan-inquire.c delete mode 100644 assuan/src/assuan-io-pth.c delete mode 100644 assuan/src/assuan-io.c delete mode 100644 assuan/src/assuan-listen.c delete mode 100644 assuan/src/assuan-logging.c delete mode 100644 assuan/src/assuan-pipe-connect.c delete mode 100644 assuan/src/assuan-pipe-server.c delete mode 100644 assuan/src/assuan-socket-connect.c delete mode 100644 assuan/src/assuan-socket-server.c delete mode 100644 assuan/src/assuan-socket.c delete mode 100644 assuan/src/assuan-uds.c delete mode 100644 assuan/src/assuan-util.c delete mode 100644 assuan/src/assuan.h delete mode 100644 assuan/src/funopen.c delete mode 100644 assuan/src/isascii.c delete mode 100644 assuan/src/libassuan-config.in delete mode 100644 assuan/src/libassuan.m4 delete mode 100644 assuan/src/memrchr.c delete mode 100755 assuan/src/mkerrors delete mode 100644 assuan/src/putc_unlocked.c delete mode 100644 assuan/src/setenv.c delete mode 100644 assuan/src/stpcpy.c diff --git a/Makefile.am b/Makefile.am index 1abc99fa..9590a082 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ RA_DIST= KnownBugs TODO ChangeLog INSTALL NEWS debian ABOUT-NLS -SUBDIRS= po doc assuan src +SUBDIRS= po doc src changelog: git log --no-color > ChangeLog || exit 1 diff --git a/assuan/AUTHORS b/assuan/AUTHORS deleted file mode 100644 index 42bb79d3..00000000 --- a/assuan/AUTHORS +++ /dev/null @@ -1,35 +0,0 @@ -Package: libassuan -Maintainer: Werner Koch -Bug reports: gnupg-devel@gnupg.org -Security related bug reports: security@gnupg.org -License (library): LGPLv2.1+ -License (manual): GPLv3+ - - -Werner Koch - - Initial code. - -Neal H. Walfield - - Code cleanup, descriptor passing and bug fixes. - -Marcus Brinkmann - - Bug fixes. - -g10 Code GmbH - - all work indicated by mail addresses in ChangeLogs - - -Libassuan was orginally part of NewPG, a temporary fork of GnuPG, and -later split of into a separate library. - - - Copyright 2003, 2007, 2008 Free Software Foundation, Inc. - - This file is free software; as a special exception the author gives - unlimited permission to copy and/or distribute it, with or without - modifications, as long as this notice is preserved. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY, to the extent permitted by law; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - diff --git a/assuan/COPYING b/assuan/COPYING deleted file mode 100644 index 44325404..00000000 --- a/assuan/COPYING +++ /dev/null @@ -1,676 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them 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 prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If 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 convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/assuan/COPYING.LIB b/assuan/COPYING.LIB deleted file mode 100644 index 2d2d780e..00000000 --- a/assuan/COPYING.LIB +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - 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 Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -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 other code 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. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - 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, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser 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 combine 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) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) 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. - - d) 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. - - e) 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 materials to be 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 with -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 Lesser 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 - - 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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 --git a/assuan/ChangeLog b/assuan/ChangeLog deleted file mode 100644 index e7d5faf1..00000000 --- a/assuan/ChangeLog +++ /dev/null @@ -1,305 +0,0 @@ -2009-01-22 Werner Koch - - * configure.ac: Check for nanoleep only in libc. - -2008-11-03 Marcus Brinkmann - - * tests/fdpassing.c (register_commands): Add missing initializer - to silence gcc -W warning. - -2008-05-25 Werner Koch - - Released 1.0.5. - -2008-05-23 Werner Koch - - * configure.ac: Use -fPIC with GCC under Linux. - -2007-12-12 Werner Koch - - Released 1.0.4. - - * config.sub, config.guess: Update to version 2007-11-19. - -2007-08-24 Werner Koch - - Released 1.0.3. - - Switched license of the library code back to LGPLv2.1. See NEWS. - - * COPYING.LIB: Replaced by LPGLv2.1 - -2007-07-05 Werner Koch - - Released 1.0.2. - - Relicensed to LGPLv3. - - * COPYING: Replaced by GPLv3. - * COPYING.LESSER: Removed. - * COPYING.LIB: New. - - * Makefile.am (ACLOCAL_AMFLAGS): Do not create gzipped tarball. - -2007-07-03 Werner Koch - - * configure.ac (NETLIBS): Use ws2_32 instead of wsock32. - -2007-06-15 Werner Koch - - * autogen.sh: Use = and not == in test to be POSIXly correct. - Change shell back to /bin/sh. - -2007-06-15 Marcus Brinkmann - - * autogen.sh: Require bash. - -2007-05-30 Werner Koch - - * autogen.sh <--build-w32>: Modernize. - -2007-05-29 Werner Koch - - * configure.ac: Require automake 1.10 and autoconf 2.61. - (AM_PROG_CC_C_O): New. Error out if no C-89 cc is installed. - (gl_HEADER_SYS_SOCKET): Explicitly add this for documentation. - -2007-05-24 Werner Koch - - * configure.ac: Use -Wpointer-arith is possible. - -2006-11-22 Werner Koch - - Released 1.0.1. - -2006-11-21 Werner Koch - - * configure.ac (AH_BOTTOM): Define PTH_SYSCALL_SOFT to 0. - (AC_INIT): Use the SVN magic. - - * m4/gnupg-pth.m4 (GNUPG_PTH_VERSION_CHECK): Use --all with - pth-config. - -2006-11-15 Werner Koch - - * autogen.sh: Add convenience option --build-amd64. - -2006-10-31 Werner Koch - - Released 1.0.0. - -2006-10-20 Werner Koch - - * Makefile.am (stowinstall): New convenience target. - -2006-10-10 Werner Koch - - Released 0.9.3. - - * tests/Makefile.am (LDADD): Add NETLIBS. - - * configure.ac: Check for cmsghdr. - (USE_DESCRIPTOR_PASSING): Define it then. - -2006-10-09 Werner Koch - - * m4/gnupg-pth.m4: New. Taked from GnuPG. - -2006-10-04 Werner Koch - - Released 0.9.2. - -2006-10-04 Werner Koch - - Released 0.9.1. - - * configure.ac (AB_INIT): New. - - * m4/autobuild.m4: New. - -2006-09-19 Werner Koch - - * tests/fdpassing.c: Reverted Marcus changes. - (client): New arg FNAME to replace hardwired file name. - (main): Pass motd to client. - * tests/Makefile.am (AM_CPPFLAGS): Removed. - (EXTRA_DIST): Add motd. - -2006-09-19 Marcus Brinkmann - - * tests/fdpassing.c (MOTD): New macro. - * tests/Makefile.am (AM_CPPFLAGS): New variable. - * tests/motd: New file. - -2006-09-14 Werner Koch - - Released 0.9.0. - - * configure.ac: Check for S_PEERCRED. Include check for socklen_t. - * m4/sys_socket_h.m4, m4/onceonly.m4, m4/socklen.m4: New. - * m4/Makefile.am: New. - -2006-09-05 Werner Koch - - * configure.ac (AH_BOTTOM): Define _ASSUAN_IN_LIBASSUAN. - -2005-10-24 Werner Koch - - * COPYING.LESSER: Added. - * README.CVS: Renamed to .. - * README.SVN: .. this. - -2005-10-08 Marcus Brinkmann - - * configure.ac: Check for socket library and add it to - LIBASSUAN_CONFIG_LIBS if necessary. - -2005-10-07 Marcus Brinkmann - - * configure.ac: Invoke AC_CANONICAL_HOST. Define _XOPEN_SOURCE, - _XOPEN_SOURCE_EXTENDED and __EXTENSIONS__ on Solaris. - Add stpcy as replacement function. - Add setenv as replacement function (and check for unistd.h). - -2005-06-20 Werner Koch - - Released 0.6.10. - -2004-12-22 Werner Koch - - Released 0.6.9. - - For security reasons switched to automake 1.9. - -2004-12-18 Werner Koch - - * autogen.sh: Add Option --build-w32. - -2004-12-07 Werner Koch - - * configure.ac: Define HAVE_W32_SYSTEM and HAVE_DOSISH_SYSTEM. - Add -lwsock2 to the config lib flags for W32. - -2004-11-25 Werner Koch - - Released 0.6.8. - -2004-09-27 Werner Koch - - * config.sub, config.guess: Updated. - -2004-06-23 Marcus Brinkmann - - * configure.ac: Check for . - -2004-06-08 Werner Koch - - Released 0.6.6. - -2004-04-02 Thomas Schwinge - - * autogen.sh: Added ACLOCAL_FLAGS. - -2004-02-20 Werner Koch - - Released 0.6.4. - -2004-02-11 Werner Koch - - * autogen.sh (check_version): Removed bashism and simplified. - -2004-01-29 Werner Koch - - Released 0.6.3. - -2003-12-18 Werner Koch - - Released 0.6.2. - -2003-12-08 Werner Koch - - * TODO: New. - * Makefile.am: Add README.CVS and autogen.sh. Removed m4/Makefile. - * README.CVS: New. - * autogen.sh: Revamped. - * configure.ac: Add automake version number for autogen.sh use. - -2003-11-17 Werner Koch - - Released 0.6.1. - -2003-08-06 Werner Koch - - Released 0.6.0. - -2003-07-29 Werner Koch - - * configure.ac: Cleanups for newer autoconf. - -2003-07-29 gettextize - - * Makefile.am (EXTRA_DIST): Add config.rpath. - * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in, - -2003-04-28 gettextize - - * Makefile.am (SUBDIRS): Add m4. - (ACLOCAL_AMFLAGS): New variable. - (EXTRA_DIST): New variable. - * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in, - -2003-02-18 Neal H. Walfield - - * COPYING: New file. - -2003-02-18 Neal H. Walfield - - * configure.ac: Fix typo. - (AC_CONFIG_FILES): Remove common/Makefile.am. - * common: Remove directory. - -2003-02-18 Neal H. Walfield - - * common: New directory. - * Makefile.am (SUBDIRS): Add common. - - * configure.ac: Check for funopen. If not present, check for - fopencookie and implement it in terms of that. Otherwise, fail. - (AC_CONFIG_FILES): Add common/Makefile. - -2003-02-18 Neal H. Walfield - - * configure.ac (AC_CONFIG_FILES): Add src/libassuan-config. - (LIBASSUAN_CONFIG_LIBS, LIBASSUAN_CONFIG_CFLAGS): New variables. - AC_SUBST them. - -2003-02-17 Neal H. Walfield - - * AUTHORS: New file. - * INSTALL: New file. - * Makefile.am: New file. - * NEWS: New file. - * README: New file. - * autogen.sh: New file, copied from newpg. - * configure.ac: New file, imported from newpg. - * depcomp: New file. - * install-sh: New file. - * missing: New file. - * mkinstalldirs: New file. - - * doc: New directory. - * src: New directory. - * tests: New directory. - - - Copyright 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. - - This file is free software; as a special exception the author gives - unlimited permission to copy and/or distribute it, with or without - modifications, as long as this notice is preserved. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY, to the extent permitted by law; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - diff --git a/assuan/INSTALL b/assuan/INSTALL deleted file mode 100644 index 8b82ade0..00000000 --- a/assuan/INSTALL +++ /dev/null @@ -1,291 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008 Free Software Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 6. Often, you can also type `make uninstall' to remove the installed - files again. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *Note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/assuan/Makefile.am b/assuan/Makefile.am deleted file mode 100644 index 880b63c3..00000000 --- a/assuan/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -# Assuan top level Makefile -# Copyright (C) 2001, 2002, 2003, 2007 Free Software Foundation, Inc. -# -# This file is part of Assuan. -# -# Assuan is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# Assuan is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, see . -## Process this file with automake to produce Makefile.in - - -ACLOCAL_AMFLAGS = -I m4 -AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip - -EXTRA_DIST = config.rpath autogen.sh - -SUBDIRS = m4 src - - -dist-hook: - echo "$(VERSION)" > $(distdir)/VERSION - - -stowinstall: - $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/libassuan diff --git a/assuan/NEWS b/assuan/NEWS deleted file mode 100644 index 1d96c896..00000000 --- a/assuan/NEWS +++ /dev/null @@ -1,219 +0,0 @@ -Noteworthy changes in version 1.1.0 ------------------------------------------------- - - * API change: See doc/README.apichanges. - - * Now using libtool and builds a DSO. - - -Noteworthy changes in version 1.0.5 (2008-05-25) ------------------------------------------------- - - * Minor fixes. - - * Build library for GNU/Linux as PIC. - - -Noteworthy changes in version 1.0.4 (2007-12-12) ------------------------------------------------- - - * New socket wrapper functions to support Unix domain sockets under - Windows. - - * New hook feature to enhance the internal I/O functions. - - -Noteworthy changes in version 1.0.3 (2007-08-24) ------------------------------------------------- - - * New type assuan_fd_t and constant ASSUAN_INVALID_FD for better W32 - support. It does not change the semantics under Unix. Under W32 - all file descriptors are now guaranteed to be system handles. - - * New functions assuan_process_done and assuan_inquire_ext to support - external event loops. - - * Changed the license of the library code back to LGPLv2.1 to support - a bunch of GPLv2(only) software which does not allow the use of - LGPLv3. Note that this is only a temporary change and authors of - GPLv2(only) software are asked to switch to GPLv3 or to add an - exception which allow the use of LPGLv3 software. - - -Noteworthy changes in version 1.0.2 (2007-07-05) ------------------------------------------------- - - * Changed license to LGPLv3. - - * New flag ASSUAN_CONFIDENTIAL to return the state of - confidential logging. - - * Better support for W32. - - * Assorted bug fixed and code cleanups. - - -Noteworthy changes in version 1.0.1 (2006-11-22) ------------------------------------------------- - - * New function: assuan_set_io_monitor. - - * New function: assuan_register_post_cmd_notify. - - * Fixed a memory leak. - - -Noteworthy changes in version 1.0.0 (2006-10-31) ------------------------------------------------- - - * Finished the manual. - - -Noteworthy changes in version 0.9.3 (2006-10-10) ------------------------------------------------- - - * Portability fixes. - - * Pth is not anymore linked by means of weak symbol tricks. It is - now required to link to the pth version of libassuan. New autoconf - macros are provided to to check for this. The pth version is only - build if Pth is available. - - * configure does now check that descripotor passing is available. A - way to check at runtime for this is also provided - - -Noteworthy changes in version 0.9.2 (2006-10-04) ------------------------------------------------- - - * A fix to make CANCEL work again in Pinentries. - - -Noteworthy changes in version 0.9.1 (2006-10-04) ------------------------------------------------- - - * Minor bug fixes - - * Portability fixes. - - -Noteworthy changes in version 0.9.0 (2006-09-14) ------------------------------------------------- - - * Internal cleanups to make inclusion of the code into libraries - easier. - - * Made clear that the software is under the LGPL. - - * New function assuan_set_assuan_err_source. All gpg-error enabled - software should call this right at startup to switch libassuan into - the gpg-error style mode. All error codes are then returned as - gpg-error style codes (GPG_ERR_ASS_* as well as others). - If the new macro _ASSUAN_ONLY_GPG_ERRORS is defned all old - definitions are excluded from assuan.h. - - * Logging of hex strings is now limited to 16 bytes. To enable - printing of the full data, a new environment variable - ASSUAN_FULL_LOGGING may be set to any value. - - * Removed the assuan_domain_* functions. - - * New functions assuan_pipe_connect_ext and assuan_socket_connect_ext - to allow connections on a socketpair and to pass descriptors. - - * New function assuan_get_peercred. - - -Noteworthy changes in version 0.6.10 (2005-06-20) -------------------------------------------------- - - * New functions assuan_get_flag and assuan_set_flag. - - * Add flag ASSUAN_NO_WAITPID. - - -Noteworthy changes in version 0.6.9 (2004-12-22) ------------------------------------------------- - - * Ported to W32 based systems. - - -Noteworthy changes in version 0.6.8 (2004-11-25) ------------------------------------------------- - - * assuan_write_status does now return an error code. - - * Fixes for C89 compatibility and some first takes on a W32 port. - - -Noteworthy changes in version 0.6.7 (2004-09-27) ------------------------------------------------- - - * Minor build fixes. - - -Noteworthy changes in version 0.6.6 (2004-06-08) ------------------------------------------------- - - * assuan_set_hello_line may now take a multi line argument where the - first lines are send as comment lines and the last one as a OK - line. - - -Noteworthy changes in version 0.6.5 (2004-04-29) ------------------------------------------------- - - * Pass the client's pid to a pipe server. - - -Noteworthy changes in version 0.6.4 (2004-02-20) ------------------------------------------------- - - * Will now also build on systems not providing funopen or - fopencookie. - - * Some smaller build fixes. - - -Noteworthy changes in version 0.6.3 (2004-01-29) ------------------------------------------------- - - * Fixed a data corruption bug in assuan_get_data_fp. - - * New function assuan_pipe_connect2. - - -Noteworthy changes in version 0.6.2 (2003-12-18) ------------------------------------------------- - - * New function assuan_set_assuan_log_prefix to store a log prefix to - be used when no context is available. The existing function - assuan_get_assuan_log_context is not anymore declared as user - overridable. - - * Documentation cleanups. - -Noteworthy changes in version 0.6.1 (2003-11-17) ------------------------------------------------- - - * Fixed a bug in assuan_inquire which led to an Invalid_Value error - for large inquiry parameters. - - * Fixed a bug in the client socket connect code. - - -Noteworthy changes in version 0.6.0 (2003-08-06) ------------------------------------------------- - - * Initial release as a standalone library. - - - Copyright 2003, 2004, 2006, 2007 Free Software Foundation, Inc. - - This file is free software; as a special exception the author gives - unlimited permission to copy and/or distribute it, with or without - modifications, as long as this notice is preserved. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY, to the extent permitted by law; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/assuan/README b/assuan/README deleted file mode 100644 index daefeae2..00000000 --- a/assuan/README +++ /dev/null @@ -1,21 +0,0 @@ - Libassuan - =========== - -This is the IPC library used by GnuPG 2, GPGME and a few other -packages. It used to be included with the latter packages but we -decided to make your life not too easy and separated it out to a stand -alone library. - -It is currently not intended to be used as a shared library. - -See COPYING.LIB on how to share, modify and distribute the software -itself (LGPLv2.1+) and COPYING for the documentation (GPLv3+). - -Please send bug report to the gnupg-devel mailing list or enter them -into the gnupg bug tracker at http://bugs.g10code.com using the -category "libassuan". - -The primary FTP site is ftp://ftp.gnupg.org/gcrypt/libassuan. - - - diff --git a/assuan/autogen.sh b/assuan/autogen.sh deleted file mode 100755 index 1c53b0d1..00000000 --- a/assuan/autogen.sh +++ /dev/null @@ -1,200 +0,0 @@ -#! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -configure_ac="configure.ac" - -cvtver () { - awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}' -} - -check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then - return 0 - fi - echo "**Error**: "\`$1\'" not installed or too old." >&2 - echo ' Version '$3' or newer is required.' >&2 - [ -n "$4" ] && echo ' Note that this is part of '\`$4\''.' >&2 - DIE="yes" - return 1 -} - - -DIE=no -FORCE= -if test x"$1" = x"--force"; then - FORCE=" --force" - shift -fi - - -# ***** W32 build script ******* -# Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 - exit 1 - fi - build=`$tsdir/config.guess` - - [ -z "$w32root" ] && w32root="$HOME/w32root" - echo "Using $w32root as standard install directory" >&2 - - crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc mingw32; do - if ${host}-gcc --version >/dev/null 2>&1 ; then - crossbindir=/usr/${host}/bin - conf_CC="CC=${host}-gcc" - break; - fi - done - if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 - echo "Stop." >&2 - exit 1 - fi - - if [ -f "$tsdir/config.log" ]; then - if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 - fi - fi - - ./configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-pth-prefix=${w32root} \ - --disable-shared - - exit $? -fi -# ***** end W32 build script ******* - - -# ***** AMD64 cross build script ******* -# Used to cross-compile for AMD64 (for testing) -if test "$1" = "--build-amd64"; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 - exit 1 - fi - build=`$tsdir/config.guess` - - [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 - - # Locate the cross compiler - crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do - if ${host}-gcc --version >/dev/null 2>&1 ; then - crossbindir=/usr/${host}/bin - conf_CC="CC=${host}-gcc" - break; - fi - done - if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - echo "Stop." >&2 - exit 1 - fi - - if [ -f "$tsdir/config.log" ]; then - if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Please run a 'make distclean' first" >&2 - exit 1 - fi - fi - - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ - --host=${host} --build=${build} - rc=$? - exit $rc -fi -# ***** end AMD64 cross build script ******* - - - -# Grep the required versions from configure.ac -autoconf_vers=`sed -n '/^AC_PREREQ(/ { -s/^.*(\(.*\))/\1/p -q -}' ${configure_ac}` -autoconf_vers_num=`echo "$autoconf_vers" | cvtver` - -automake_vers=`sed -n '/^min_automake_version=/ { -s/^.*="\(.*\)"/\1/p -q -}' ${configure_ac}` -automake_vers_num=`echo "$automake_vers" | cvtver` - -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - - -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] -then - echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 - exit 1 -fi - -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - - -if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then - check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf -fi -if check_version $AUTOMAKE $automake_vers_num $automake_vers; then - check_version $ACLOCAL $automake_vers_num $autoconf_vers automake -fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi - -if test "$DIE" = "yes"; then - cat <, 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld -# should be set by the caller. -# -# The set of defined variables is at the end of this script. - -# Known limitations: -# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer -# than 256 bytes, otherwise the compiler driver will dump core. The only -# known workaround is to choose shorter directory names for the build -# directory and/or the installation directory. - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -shrext=.so - -host="$1" -host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. - -wl= -if test "$GCC" = yes; then - wl='-Wl,' -else - case "$host_os" in - aix*) - wl='-Wl,' - ;; - mingw* | pw32* | os2*) - ;; - hpux9* | hpux10* | hpux11*) - wl='-Wl,' - ;; - irix5* | irix6* | nonstopux*) - wl='-Wl,' - ;; - newsos6) - ;; - linux*) - case $CC in - icc|ecc) - wl='-Wl,' - ;; - ccc) - wl='-Wl,' - ;; - esac - ;; - osf3* | osf4* | osf5*) - wl='-Wl,' - ;; - sco3.2v5*) - ;; - solaris*) - wl='-Wl,' - ;; - sunos4*) - wl='-Qoption ld ' - ;; - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - wl='-Wl,' - ;; - sysv4*MP*) - ;; - uts4*) - ;; - esac -fi - -# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. - -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no - -case "$host_os" in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - case "$host_os" in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - fi - ;; - amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can use - # them. - ld_shlibs=no - ;; - beos*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - cygwin* | mingw* | pw32*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - netbsd*) - ;; - solaris* | sysv5*) - if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - sunos4*) - hardcode_direct=yes - ;; - *) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - esac - if test "$ld_shlibs" = yes; then - # Unlike libtool, we use -rpath here, not --rpath, since the documented - # option of GNU ld is called -rpath, not --rpath. - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - fi -else - case "$host_os" in - aix3*) - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - else - aix_use_runtimelinking=no - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - esac - fi - hardcode_direct=yes - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - esac - fi - # Begin _LT_AC_SYS_LIBPATH_AIX. - echo 'int main () { return 0; }' > conftest.c - ${CC} ${LDFLAGS} conftest.c -o conftest - aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - fi - if test -z "$aix_libpath"; then - aix_libpath="/usr/lib:/lib" - fi - rm -f conftest.c conftest - # End _LT_AC_SYS_LIBPATH_AIX. - if test "$aix_use_runtimelinking" = yes; then - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - else - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - fi - fi - ;; - amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - bsdi4*) - ;; - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - libext=lib - ;; - darwin* | rhapsody*) - if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then - hardcode_direct=no - fi - ;; - dgux*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - freebsd1*) - ld_shlibs=no - ;; - freebsd2.2*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - freebsd2*) - hardcode_direct=yes - hardcode_minus_L=yes - ;; - freebsd*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - hpux9*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - hpux10* | hpux11*) - if test "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=no - ;; - ia64*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=no - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - *) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - irix5* | irix6* | nonstopux*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - netbsd*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - newsos6) - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - openbsd*) - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - osf3*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - osf4* | osf5*) - if test "$GCC" = yes; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - # Both cc and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - sco3.2v5*) - ;; - solaris*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - sunos4*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - sysv4) - case $host_vendor in - sni) - hardcode_direct=yes # is this really true??? - ;; - siemens) - hardcode_direct=no - ;; - motorola) - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - ;; - sysv4.3*) - ;; - sysv4*MP*) - if test -d /usr/nec; then - ld_shlibs=yes - fi - ;; - sysv4.2uw2*) - hardcode_direct=yes - hardcode_minus_L=no - ;; - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) - ;; - sysv5*) - hardcode_libdir_flag_spec= - ;; - uts4*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - *) - ld_shlibs=no - ;; - esac -fi - -# Check dynamic linker characteristics -# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. -libname_spec='lib$name' -case "$host_os" in - aix3*) - ;; - aix4* | aix5*) - ;; - amigaos*) - ;; - beos*) - ;; - bsdi4*) - ;; - cygwin* | mingw* | pw32*) - shrext=.dll - ;; - darwin* | rhapsody*) - shrext=.dylib - ;; - dgux*) - ;; - freebsd1*) - ;; - freebsd*) - ;; - gnu*) - ;; - hpux9* | hpux10* | hpux11*) - case "$host_cpu" in - ia64*) - shrext=.so - ;; - hppa*64*) - shrext=.sl - ;; - *) - shrext=.sl - ;; - esac - ;; - irix5* | irix6* | nonstopux*) - case "$host_os" in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; - *) libsuff= shlibsuff= ;; - esac - ;; - esac - ;; - linux*oldld* | linux*aout* | linux*coff*) - ;; - linux*) - ;; - netbsd*) - ;; - newsos6) - ;; - nto-qnx) - ;; - openbsd*) - ;; - os2*) - libname_spec='$name' - shrext=.dll - ;; - osf3* | osf4* | osf5*) - ;; - sco3.2v5*) - ;; - solaris*) - ;; - sunos4*) - ;; - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - ;; - sysv4*MP*) - ;; - uts4*) - ;; -esac - -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' -escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` -shlibext=`echo "$shrext" | sed -e 's,^\.,,'` -escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` - -sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. - -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.61) -min_automake_version="1.10" - -# Remember to change the version number immediately *after* a release. -# Set my_issvn to "yes" for non-released code. Remember to run an -# "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.1.0]) -m4_define([my_issvn], [yes]) - -m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ - || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) -AC_INIT([libassuan], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), - [bug-libassuan@gnupg.org]) -# Note, that this is not yet available as a shared library. - -PACKAGE=$PACKAGE_NAME -VERSION=$PACKAGE_VERSION - -AM_INIT_AUTOMAKE -AM_MAINTAINER_MODE -AC_CONFIG_SRCDIR(src/assuan.h) -AM_CONFIG_HEADER(config.h) -AC_CANONICAL_HOST -AB_INIT - -AC_GNU_SOURCE - - -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) -AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) -AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) -AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT", - [Bug report address]) - - - -# Checks for programs. -missing_dir=`cd $ac_aux_dir && pwd` -AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) -AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) -AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) -AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) -AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) -AC_PROG_AWK -AC_PROG_CC -AC_PROG_CPP -AM_PROG_CC_C_O -if test "x$ac_cv_prog_cc_c89" = "xno" ; then - AC_MSG_ERROR([[No C-89 compiler found]]) -fi -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -AC_PROG_RANLIB -#AC_ARG_PROGRAM - -if test "$GCC" = yes; then - CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" - - AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) - _gcc_cflags_save=$CFLAGS - CFLAGS="-Wpointer-arith" - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) - AC_MSG_RESULT($_gcc_wopt) - CFLAGS=$_gcc_cflags_save; - if test x"$_gcc_wopt" = xyes ; then - CFLAGS="$CFLAGS -Wpointer-arith" - fi -fi - - -AH_BOTTOM([ -#define _ASSUAN_IN_LIBASSUAN 1 - -/* We explicitly need to disable PTH's soft mapping as Debian - currently enables it by default for no reason. */ -#define PTH_SYSCALL_SOFT 0 - -]) - - -# -# Options depending on the host OS. -# -have_dosish_system=no -have_w32_system=no -case "${host}" in - *-linux*) - if test "$GCC" = yes; then - CFLAGS="$CFLAGS -fPIC -DPIC" - fi - ;; - *-mingw32*) - have_dosish_system=yes - have_w32_system=yes - ;; - *-solaris*) - AC_DEFINE(_XOPEN_SOURCE, 500, Activate extensions on Solaris) - AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Activate extensions on Solaris) - AC_DEFINE(__EXTENSIONS__, 1, Activate extensions on Solaris) - ;; -esac - -if test "$have_dosish_system" = yes; then - AC_DEFINE(HAVE_DOSISH_SYSTEM,1, - [Defined if we run on some of the PCDOS like systems - (DOS, Windoze. OS/2) with special properties like - no file modes]) -fi -dnl AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) - -if test "$have_w32_system" = yes; then - AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) -fi -dnl AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) - -# -# See whether we can build a Pth enabled version -# -GNUPG_PATH_PTH -AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes") - - -# Check for network libraries. They are needed for tests. -AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt, - [NETLIBS="-lsocket $NETLIBS"])) -AC_SUBST(NETLIBS) - -# For src/libassuan-config.in -LIBASSUAN_CONFIG_LIB="-lassuan" -LIBASSUAN_CONFIG_CFLAGS="" -LIBASSUAN_CONFIG_API_VERSION="1" -LIBASSUAN_CONFIG_THREAD_MODULES= -if test "$have_pth" = yes; then -LIBASSUAN_CONFIG_THREAD_MODULES="pth" -fi -LIBASSUAN_CONFIG_EXTRA_LIBS= -if test "$have_w32_system" = yes; then - LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lws2_32" -fi -if test x"$NETLIBS" != x; then - LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS" -fi -AC_SUBST(LIBASSUAN_CONFIG_LIB) -AC_SUBST(LIBASSUAN_CONFIG_CFLAGS) -AC_SUBST(LIBASSUAN_CONFIG_API_VERSION) -AC_SUBST(LIBASSUAN_CONFIG_THREAD_MODULES) -AC_SUBST(LIBASSUAN_CONFIG_EXTRA_LIBS) - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([string.h locale.h sys/uio.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_C_INLINE -AC_TYPE_SIZE_T -AC_TYPE_SIGNAL -AC_DECL_SYS_SIGLIST - -gl_HEADER_SYS_SOCKET -gl_TYPE_SOCKLEN_T - -AC_CHECK_MEMBER(struct cmsghdr.cmsg_len, - [use_descriptor_passing=yes], - [use_descriptor_passing=no - AC_MSG_WARN([ -*** -*** Data structure for sending ancillary data missing. -*** Descriptor passing won't work. -***])],[ -#include -#include -#include -#include -#include -#include -#if HAVE_SYS_UIO_H -#include -#endif -#include - ]) -if test "$use_descriptor_passing" = "yes"; then - AC_DEFINE(USE_DESCRIPTOR_PASSING, 1, - [Defined if descriptor passing is supported]) -fi -AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") - - -# -# Checks for library functions. -# -AC_CHECK_FUNCS([flockfile funlockfile]) - -# On some systems (e.g. Solaris) nanosleep requires linking to librl. -# Given that we use nanosleep only as an optimization over a select -# based wait function we want it only if it is available in libc. -_save_libs="$LIBS" -AC_SEARCH_LIBS([nanosleep], [], - [AC_DEFINE(HAVE_NANOSLEEP,1, - [Define to 1 if you have the `nanosleep' function in libc.])]) -LIBS="$_save_libs" - - -# Check for funopen -AC_CHECK_FUNCS(funopen) -if test $ac_cv_func_funopen != yes; then - # No funopen but we can implement that in terms of fopencookie. - AC_CHECK_FUNCS(fopencookie) - if test $ac_cv_func_fopencookie = yes; then - AC_LIBOBJ([funopen]) - else - AC_MSG_WARN([ -*** -*** No implementation of fopencookie or funopen available. -*** The assuan_get_data_fp feature won't work. -***]) - fi -fi - - -AC_REPLACE_FUNCS(isascii) -AC_REPLACE_FUNCS(putc_unlocked) -AC_REPLACE_FUNCS(memrchr) -AC_REPLACE_FUNCS(stpcpy) -# Check for unistd.h for setenv replacement function. -AC_CHECK_HEADERS(unistd.h) -AC_REPLACE_FUNCS(setenv) - - -# -# Check for the getsockopt SO_PEERCRED -# -AC_MSG_CHECKING(for SO_PEERCRED) -AC_CACHE_VAL(assuan_cv_sys_so_peercred, - [AC_TRY_COMPILE([#include ], - [struct ucred cr; - int cl = sizeof cr; - getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);], - assuan_cv_sys_so_peercred=yes, - assuan_cv_sys_so_peercred=no) - ]) -AC_MSG_RESULT($assuan_cv_sys_so_peercred) -if test $assuan_cv_sys_so_peercred = yes; then - AC_DEFINE(HAVE_SO_PEERCRED, 1, - [Defined if SO_PEERCRED is supported (Linux specific)]) -fi - - - - -# Create the config files. -AC_CONFIG_FILES([Makefile]) -AC_CONFIG_FILES([m4/Makefile]) -AC_CONFIG_FILES([src/Makefile]) -AC_CONFIG_FILES([src/libassuan-config], [chmod +x src/libassuan-config]) - -AC_OUTPUT diff --git a/assuan/m4/Makefile.am b/assuan/m4/Makefile.am deleted file mode 100644 index 0848e42b..00000000 --- a/assuan/m4/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 autobuild.m4 gnupg-pth.m4 diff --git a/assuan/m4/autobuild.m4 b/assuan/m4/autobuild.m4 deleted file mode 100644 index bd1f4dc1..00000000 --- a/assuan/m4/autobuild.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# autobuild.m4 serial 2 (autobuild-3.3) -# Copyright (C) 2004 Simon Josefsson -# -# This file is free software, distributed under the terms of the GNU -# General Public License. As a special exception to the GNU General -# Public License, this file may be distributed as part of a program -# that contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# This file can can be used in projects which are not available under -# the GNU General Public License or the GNU Library General Public -# License but which still want to provide support for Autobuild. - -# Usage: AB_INIT([MODE]). -AC_DEFUN([AB_INIT], -[ - AC_REQUIRE([AC_CANONICAL_BUILD]) - AC_REQUIRE([AC_CANONICAL_HOST]) - - AC_MSG_NOTICE([autobuild project... ${PACKAGE_NAME:-$PACKAGE}]) - AC_MSG_NOTICE([autobuild revision... ${PACKAGE_VERSION:-$VERSION}]) - hostname=`hostname` - if test "$hostname"; then - AC_MSG_NOTICE([autobuild hostname... $hostname]) - fi - ifelse([$1],[],,[AC_MSG_NOTICE([autobuild mode... $1])]) - date=`date +%Y%m%d-%H%M%S` - if test "$?" != 0; then - date=`date` - fi - if test "$date"; then - AC_MSG_NOTICE([autobuild timestamp... $date]) - fi -]) diff --git a/assuan/m4/gnupg-pth.m4 b/assuan/m4/gnupg-pth.m4 deleted file mode 100644 index 6dc9e0ee..00000000 --- a/assuan/m4/gnupg-pth.m4 +++ /dev/null @@ -1,105 +0,0 @@ -dnl GnuPG's check for Pth. -dnl Copyright (C) 2003 Free Software Foundation, Inc. -dnl -dnl This file is free software; as a special exception the author gives -dnl unlimited permission to copy and/or distribute it, with or without -dnl modifications, as long as this notice is preserved. -dnl -dnl This file is distributed in the hope that it will be useful, but -dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - -# GNUPG_PTH_VERSION_CHECK(REQUIRED) -# -# If the version is sufficient, HAVE_PTH will be set to yes. -# -# Taken and modified from the m4 macros which come with Pth. -AC_DEFUN([GNUPG_PTH_VERSION_CHECK], - [ - _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'` - _req_version="ifelse([$1],,1.2.0,$1)" - - AC_MSG_CHECKING(for PTH - version >= $_req_version) - for _var in _pth_version _req_version; do - eval "_val=\"\$${_var}\"" - _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` - _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` - _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` - _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` - case $_rtype in - "a" ) _rtype=0 ;; - "b" ) _rtype=1 ;; - "." ) _rtype=2 ;; - esac - _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ - "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` - eval "${_var}_hex=\"\$_hex\"" - done - have_pth=no - if test ".$_pth_version_hex" != .; then - if test ".$_req_version_hex" != .; then - if test $_pth_version_hex -ge $_req_version_hex; then - have_pth=yes - fi - fi - fi - if test $have_pth = yes; then - AC_MSG_RESULT(yes) - AC_MSG_CHECKING([whether PTH installation is sane]) - AC_CACHE_VAL(gnupg_cv_pth_is_sane,[ - _gnupg_pth_save_cflags=$CFLAGS - _gnupg_pth_save_ldflags=$LDFLAGS - _gnupg_pth_save_libs=$LIBS - CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`" - LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`" - LIBS="$LIBS `$PTH_CONFIG --libs --all`" - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include - ], - [[ pth_init ();]])], - gnupg_cv_pth_is_sane=yes, - gnupg_cv_pth_is_sane=no) - CFLAGS=$_gnupg_pth_save_cflags - LDFLAGS=$_gnupg_pth_save_ldflags - LIBS=$_gnupg_pth_save_libs - ]) - if test $gnupg_cv_pth_is_sane != yes; then - have_pth=no - fi - AC_MSG_RESULT($gnupg_cv_pth_is_sane) - else - AC_MSG_RESULT(no) - fi - ]) - - - -# GNUPG_PATH_PTH([MINIMUM_VERSION]) -# -# On return $have_pth is set as well as HAVE_PTH is defined and -# PTH_CLFAGS and PTH_LIBS are AS_SUBST. -# -AC_DEFUN([GNUPG_PATH_PTH], -[ AC_ARG_WITH(pth-prefix, - AC_HELP_STRING([--with-pth-prefix=PFX], - [prefix where GNU Pth is installed (optional)]), - pth_config_prefix="$withval", pth_config_prefix="") - if test x$pth_config_prefix != x ; then - PTH_CONFIG="$pth_config_prefix/bin/pth-config" - fi - AC_PATH_PROG(PTH_CONFIG, pth-config, no) - tmp=ifelse([$1], ,1.3.7,$1) - if test "$PTH_CONFIG" != "no"; then - GNUPG_PTH_VERSION_CHECK($tmp) - if test $have_pth = yes; then - PTH_CFLAGS=`$PTH_CONFIG --cflags` - PTH_LIBS=`$PTH_CONFIG --ldflags` - PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`" - AC_DEFINE(HAVE_PTH, 1, - [Defined if the GNU Pth is available]) - fi - fi - AC_SUBST(PTH_CFLAGS) - AC_SUBST(PTH_LIBS) -]) - diff --git a/assuan/m4/onceonly.m4 b/assuan/m4/onceonly.m4 deleted file mode 100644 index 6d913faf..00000000 --- a/assuan/m4/onceonly.m4 +++ /dev/null @@ -1,66 +0,0 @@ -# onceonly.m4 serial 4 (gettext-0.15) -dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This file defines some "once only" variants of standard autoconf macros. -dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS -dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS -dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS -dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC -dnl The advantage is that the check for each of the headers/functions/decls -dnl will be put only once into the 'configure' file. It keeps the size of -dnl the 'configure' file down, and avoids redundant output when 'configure' -dnl is run. -dnl The drawback is that the checks cannot be conditionalized. If you write -dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi -dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to -dnl empty, and the check will be inserted before the body of the AC_DEFUNed -dnl function. - -dnl This file is only needed in autoconf <= 2.59. Newer versions of autoconf -dnl have this macro built-in. But about AC_CHECK_DECLS_ONCE: note that in -dnl autoconf >= 2.60 the symbol separator is a comma, whereas here it is -dnl whitespace. - -dnl Autoconf version 2.57 or newer is recommended. -AC_PREREQ(2.54) - -# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of -# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). -AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ - : - AC_FOREACH([gl_HEADER_NAME], [$1], [ - AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]), - [-./], [___])), [ - AC_CHECK_HEADERS(gl_HEADER_NAME) - ]) - AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, - [-./], [___]))) - ]) -]) - -# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of -# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). -AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ - : - AC_FOREACH([gl_FUNC_NAME], [$1], [ - AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ - AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME])) - ]) - AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) - ]) -]) - -# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of -# AC_CHECK_DECLS(DECL1, DECL2, ...). -AC_DEFUN([AC_CHECK_DECLS_ONCE], [ - : - AC_FOREACH([gl_DECL_NAME], [$1], [ - AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ - AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) - ]) - AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) - ]) -]) diff --git a/assuan/m4/socklen.m4 b/assuan/m4/socklen.m4 deleted file mode 100644 index 5e3765a6..00000000 --- a/assuan/m4/socklen.m4 +++ /dev/null @@ -1,52 +0,0 @@ -# socklen.m4 serial 4 -dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Albert Chin, Windows fixes from Simon Josefsson. - -dnl Check for socklen_t: historically on BSD it is an int, and in -dnl POSIX 1g it is a type of its own, but some platforms use different -dnl types for the argument to getsockopt, getpeername, etc. So we -dnl have to test to find something that will work. - -dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find -dnl it there first. That file is included by gnulib's socket_.h, which -dnl all users of this module should include. Cygwin must not include -dnl ws2tcpip.h. -AC_DEFUN([gl_TYPE_SOCKLEN_T], - [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl - AC_CHECK_TYPE([socklen_t], , - [AC_MSG_CHECKING([for socklen_t equivalent]) - AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv], - [# Systems have either "struct sockaddr *" or - # "void *" as the second argument to getpeername - gl_cv_socklen_t_equiv= - for arg2 in "struct sockaddr" void; do - for t in int size_t "unsigned int" "long int" "unsigned long int"; do - AC_TRY_COMPILE( - [#include - #include - - int getpeername (int, $arg2 *, $t *);], - [$t len; - getpeername (0, 0, &len);], - [gl_cv_socklen_t_equiv="$t"]) - test "$gl_cv_socklen_t_equiv" != "" && break - done - test "$gl_cv_socklen_t_equiv" != "" && break - done - ]) - if test "$gl_cv_socklen_t_equiv" = ""; then - AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) - fi - AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) - AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], - [type to use in place of socklen_t if not defined])], - [#include - #if HAVE_SYS_SOCKET_H - # include - #elif HAVE_WS2TCPIP_H - # include - #endif])]) diff --git a/assuan/m4/sys_socket_h.m4 b/assuan/m4/sys_socket_h.m4 deleted file mode 100644 index d3e45b48..00000000 --- a/assuan/m4/sys_socket_h.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# sys_socket_h.m4 serial 2 -dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Simon Josefsson. - -AC_DEFUN([gl_HEADER_SYS_SOCKET], -[ - AC_CHECK_HEADERS_ONCE([sys/socket.h]) - if test $ac_cv_header_sys_socket_h = yes; then - SYS_SOCKET_H='' - else - dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make - dnl the check for those headers unconditional; yet cygwin reports - dnl that the headers are present but cannot be compiled (since on - dnl cygwin, all socket information should come from sys/socket.h). - AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) - SYS_SOCKET_H='sys/socket.h' - fi - AC_SUBST(SYS_SOCKET_H) -]) diff --git a/assuan/src/Makefile.am b/assuan/src/Makefile.am deleted file mode 100644 index 3bfb125a..00000000 --- a/assuan/src/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -# Assuan Makefile -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. -# -# This file is part of Assuan. -# -# Assuan is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# Assuan is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, see . -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = libassuan-config.in mkerrors libassuan.m4 -INCLUDES = -I.. -I$(top_srcdir)/include -BUILT_SOURCES = assuan-errors.c -MOSTLYCLEANFILES = assuan-errors.c - -if HAVE_PTH -libassuan_pth = libassuan-pth.a -else -libassuan_pth = -endif - -noinst_SCRIPTS = libassuan-config -m4datadir = $(datadir)/aclocal -noinst_DATA = libassuan.m4 -noinst_LIBRARIES = $(libassuan_pth) -noinst_HEADERS = assuan.h - - -common_sources = \ - assuan-defs.h \ - assuan-util.c \ - assuan-errors.c \ - assuan-buffer.c \ - assuan-handler.c \ - assuan-inquire.c \ - assuan-listen.c \ - assuan-connect.c \ - assuan-client.c \ - assuan-pipe-server.c \ - assuan-socket-server.c \ - assuan-pipe-connect.c \ - assuan-socket-connect.c \ - assuan-uds.c \ - assuan-logging.c \ - assuan-socket.c - -#libassuan_a_SOURCES = $(common_sources) assuan-io.c -#libassuan_a_LIBADD = @LIBOBJS@ - -if HAVE_PTH -libassuan_pth_a_SOURCES = $(common_sources) assuan-io-pth.c -libassuan_pth_a_CFLAGS = $(AM_CFLAGS) $(PTH_CFLAGS) -libassuan_pth_a_LIBADD = @LIBOBJS@ -endif - -assuan-errors.c : assuan.h mkerrors - $(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c diff --git a/assuan/src/assuan-buffer.c b/assuan/src/assuan-buffer.c deleted file mode 100644 index b9e35721..00000000 --- a/assuan/src/assuan-buffer.c +++ /dev/null @@ -1,569 +0,0 @@ -/* assuan-buffer.c - read and send data - * Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -#include -#endif -#include "assuan-defs.h" - - -/* Extended version of write(2) to guarantee that all bytes are - written. Returns 0 on success or -1 and ERRNO on failure. */ -static int -writen (assuan_context_t ctx, const char *buffer, size_t length) -{ - while (length) - { - ssize_t nwritten = ctx->io->writefnc (ctx, buffer, length); - - if (nwritten < 0) - { - if (errno == EINTR) - continue; - return -1; /* write error */ - } - length -= nwritten; - buffer += nwritten; - } - return 0; /* okay */ -} - -/* Read an entire line. Returns 0 on success or -1 and ERRNO on - failure. EOF is indictated by setting the integer at address - R_EOF. Note: BUF, R_NREAD and R_EOF contain a valid result even if - an error is returned. */ -static int -readline (assuan_context_t ctx, char *buf, size_t buflen, - int *r_nread, int *r_eof) -{ - size_t nleft = buflen; - char *p; - - *r_eof = 0; - *r_nread = 0; - while (nleft > 0) - { - ssize_t n = ctx->io->readfnc (ctx, buf, nleft); - - if (n < 0) - { - if (errno == EINTR) - continue; - return -1; /* read error */ - } - else if (!n) - { - *r_eof = 1; - break; /* allow incomplete lines */ - } - p = buf; - nleft -= n; - buf += n; - *r_nread += n; - - p = memrchr (p, '\n', n); - if (p) - break; /* at least one full line available - that's enough for now */ - } - - return 0; -} - - -/* Function returns an Assuan error. */ -assuan_error_t -_assuan_read_line (assuan_context_t ctx) -{ - char *line = ctx->inbound.line; - int nread, atticlen; - int rc; - char *endp = 0; - - if (ctx->inbound.eof) - return _assuan_error (-1); - - atticlen = ctx->inbound.attic.linelen; - if (atticlen) - { - memcpy (line, ctx->inbound.attic.line, atticlen); - ctx->inbound.attic.linelen = 0; - - endp = memchr (line, '\n', atticlen); - if (endp) - /* Found another line in the attic. */ - { - rc = 0; - nread = atticlen; - atticlen = 0; - } - else - /* There is pending data but not a full line. */ - { - assert (atticlen < LINELENGTH); - rc = readline (ctx, line + atticlen, - LINELENGTH - atticlen, &nread, &ctx->inbound.eof); - } - } - else - /* No pending data. */ - rc = readline (ctx, line, LINELENGTH, - &nread, &ctx->inbound.eof); - if (rc) - { - int saved_errno = errno; - - if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd, - strerror (errno)); - - if (saved_errno == EAGAIN) - { - /* We have to save a partial line. */ - memcpy (ctx->inbound.attic.line, line, atticlen + nread); - ctx->inbound.attic.pending = 0; - ctx->inbound.attic.linelen = atticlen + nread; - } - - errno = saved_errno; - return _assuan_error (ASSUAN_Read_Error); - } - if (!nread) - { - assert (ctx->inbound.eof); - if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [EOF]\n", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - return _assuan_error (-1); - } - - ctx->inbound.attic.pending = 0; - nread += atticlen; - - if (! endp) - endp = memchr (line, '\n', nread); - - if (endp) - { - unsigned monitor_result; - int n = endp - line + 1; - - if (n < nread) - /* LINE contains more than one line. We copy it to the attic - now as handlers are allowed to modify the passed - buffer. */ - { - int len = nread - n; - memcpy (ctx->inbound.attic.line, endp + 1, len); - ctx->inbound.attic.pending = memrchr (endp + 1, '\n', len) ? 1 : 0; - ctx->inbound.attic.linelen = len; - } - - if (endp != line && endp[-1] == '\r') - endp --; - *endp = 0; - - ctx->inbound.linelen = endp - line; - - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 0, - ctx->inbound.line, - ctx->inbound.linelen) - : 0); - if ( (monitor_result & 2) ) - ctx->inbound.linelen = 0; - - if (ctx->log_fp && !(monitor_result & 1)) - { - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- ", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); - else - _assuan_log_print_buffer (ctx->log_fp, - ctx->inbound.line, - ctx->inbound.linelen); - putc ('\n', ctx->log_fp); - } - return 0; - } - else - { - if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Invalid line]\n", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - *line = 0; - ctx->inbound.linelen = 0; - return _assuan_error (ctx->inbound.eof - ? ASSUAN_Line_Not_Terminated - : ASSUAN_Line_Too_Long); - } -} - - -/* Read the next line from the client or server and return a pointer - in *LINE to a buffer holding the line. LINELEN is the length of - *LINE. The buffer is valid until the next read operation on it. - The caller may modify the buffer. The buffer is invalid (i.e. must - not be used) if an error is returned. - - Returns 0 on success or an assuan error code. - See also: assuan_pending_line(). -*/ -assuan_error_t -assuan_read_line (assuan_context_t ctx, char **line, size_t *linelen) -{ - assuan_error_t err; - - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - - do - { - err = _assuan_read_line (ctx); - } - while (_assuan_error_is_eagain (err)); - - *line = ctx->inbound.line; - *linelen = ctx->inbound.linelen; - return err; -} - - -/* Return true if a full line is buffered (i.e. an entire line may be - read without any I/O). */ -int -assuan_pending_line (assuan_context_t ctx) -{ - return ctx && ctx->inbound.attic.pending; -} - - -assuan_error_t -_assuan_write_line (assuan_context_t ctx, const char *prefix, - const char *line, size_t len) -{ - assuan_error_t rc = 0; - size_t prefixlen = prefix? strlen (prefix):0; - unsigned int monitor_result; - - /* Make sure that the line is short enough. */ - if (len + prefixlen + 2 > ASSUAN_LINELENGTH) - { - if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " - "[supplied line too long -truncated]\n", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - if (prefixlen > 5) - prefixlen = 5; - if (len > ASSUAN_LINELENGTH - prefixlen - 2) - len = ASSUAN_LINELENGTH - prefixlen - 2 - 1; - } - - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, line, len) - : 0); - - /* Fixme: we should do some kind of line buffering. */ - if (ctx->log_fp && !(monitor_result & 1)) - { - fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); - else - { - if (prefixlen) - _assuan_log_print_buffer (ctx->log_fp, prefix, prefixlen); - _assuan_log_print_buffer (ctx->log_fp, line, len); - } - putc ('\n', ctx->log_fp); - } - - if (prefixlen && !(monitor_result & 2)) - { - rc = writen (ctx, prefix, prefixlen); - if (rc) - rc = _assuan_error (ASSUAN_Write_Error); - } - if (!rc && !(monitor_result & 2)) - { - rc = writen (ctx, line, len); - if (rc) - rc = _assuan_error (ASSUAN_Write_Error); - if (!rc) - { - rc = writen (ctx, "\n", 1); - if (rc) - rc = _assuan_error (ASSUAN_Write_Error); - } - } - return rc; -} - - -assuan_error_t -assuan_write_line (assuan_context_t ctx, const char *line) -{ - size_t len; - const char *s; - - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - - /* Make sure that we never take a LF from the user - this might - violate the protocol. */ - s = strchr (line, '\n'); - len = s? (s-line) : strlen (line); - - if (ctx->log_fp && s) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " - "[supplied line contained a LF - truncated]\n", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - - return _assuan_write_line (ctx, NULL, line, len); -} - - - -/* Write out the data in buffer as datalines with line wrapping and - percent escaping. This function is used for GNU's custom streams. */ -int -_assuan_cookie_write_data (void *cookie, const char *buffer, size_t orig_size) -{ - assuan_context_t ctx = cookie; - size_t size = orig_size; - char *line; - size_t linelen; - - if (ctx->outbound.data.error) - return 0; - - line = ctx->outbound.data.line; - linelen = ctx->outbound.data.linelen; - line += linelen; - while (size) - { - unsigned int monitor_result; - - /* Insert data line header. */ - if (!linelen) - { - *line++ = 'D'; - *line++ = ' '; - linelen += 2; - } - - /* Copy data, keep space for the CRLF and to escape one character. */ - while (size && linelen < LINELENGTH-2-2) - { - if (*buffer == '%' || *buffer == '\r' || *buffer == '\n') - { - sprintf (line, "%%%02X", *(unsigned char*)buffer); - line += 3; - linelen += 3; - buffer++; - } - else - { - *line++ = *buffer++; - linelen++; - } - size--; - } - - - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, - ctx->outbound.data.line, linelen) - : 0); - - if (linelen >= LINELENGTH-2-2) - { - if (ctx->log_fp && !(monitor_result & 1)) - { - fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - - if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); - else - _assuan_log_print_buffer (ctx->log_fp, - ctx->outbound.data.line, - linelen); - putc ('\n', ctx->log_fp); - } - *line++ = '\n'; - linelen++; - if ( !(monitor_result & 2) - && writen (ctx, ctx->outbound.data.line, linelen)) - { - ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error); - return 0; - } - line = ctx->outbound.data.line; - linelen = 0; - } - } - - ctx->outbound.data.linelen = linelen; - return (int)orig_size; -} - - -/* Write out any buffered data - This function is used for GNU's custom streams */ -int -_assuan_cookie_write_flush (void *cookie) -{ - assuan_context_t ctx = cookie; - char *line; - size_t linelen; - unsigned int monitor_result; - - if (ctx->outbound.data.error) - return 0; - - line = ctx->outbound.data.line; - linelen = ctx->outbound.data.linelen; - line += linelen; - - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, - ctx->outbound.data.line, linelen) - : 0); - - if (linelen) - { - if (ctx->log_fp && !(monitor_result & 1)) - { - fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", - assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); - else - _assuan_log_print_buffer (ctx->log_fp, - ctx->outbound.data.line, linelen); - putc ('\n', ctx->log_fp); - } - *line++ = '\n'; - linelen++; - if ( !(monitor_result & 2) - && writen (ctx, ctx->outbound.data.line, linelen)) - { - ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error); - return 0; - } - ctx->outbound.data.linelen = 0; - } - return 0; -} - - -/** - * assuan_send_data: - * @ctx: An assuan context - * @buffer: Data to send or NULL to flush - * @length: length of the data to send/ - * - * This function may be used by the server or the client to send data - * lines. The data will be escaped as required by the Assuan protocol - * and may get buffered until a line is full. To force sending the - * data out @buffer may be passed as NULL (in which case @length must - * also be 0); however when used by a client this flush operation does - * also send the terminating "END" command to terminate the reponse on - * a INQUIRE response. However, when assuan_transact() is used, this - * function takes care of sending END itself. - * - * If BUFFER is NULL and LENGTH is 1 and we are a client, a "CAN" is - * send instead of an "END". - * - * Return value: 0 on success or an error code - **/ - -assuan_error_t -assuan_send_data (assuan_context_t ctx, const void *buffer, size_t length) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - if (!buffer && length > 1) - return _assuan_error (ASSUAN_Invalid_Value); - - if (!buffer) - { /* flush what we have */ - _assuan_cookie_write_flush (ctx); - if (ctx->outbound.data.error) - return ctx->outbound.data.error; - if (!ctx->is_server) - return assuan_write_line (ctx, length == 1? "CAN":"END"); - } - else - { - _assuan_cookie_write_data (ctx, buffer, length); - if (ctx->outbound.data.error) - return ctx->outbound.data.error; - } - - return 0; -} - -assuan_error_t -assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd) -{ - /* It is explicitly allowed to use (NULL, -1) as a runtime test to - check whether descriptor passing is available. */ - if (!ctx && fd == ASSUAN_INVALID_FD) -#ifdef USE_DESCRIPTOR_PASSING - return 0; -#else - return _assuan_error (ASSUAN_Not_Implemented); -#endif - - if (! ctx->io->sendfd) - return set_error (ctx, Not_Implemented, - "server does not support sending and receiving " - "of file descriptors"); - return ctx->io->sendfd (ctx, fd); -} - -assuan_error_t -assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd) -{ - if (! ctx->io->receivefd) - return set_error (ctx, Not_Implemented, - "server does not support sending and receiving " - "of file descriptors"); - return ctx->io->receivefd (ctx, fd); -} diff --git a/assuan/src/assuan-client.c b/assuan/src/assuan-client.c deleted file mode 100644 index 15f4f1cd..00000000 --- a/assuan/src/assuan-client.c +++ /dev/null @@ -1,236 +0,0 @@ -/* assuan-client.c - client functions - * Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include "assuan-defs.h" - -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - - -assuan_error_t -_assuan_read_from_server (assuan_context_t ctx, int *okay, int *off) -{ - char *line; - int linelen; - assuan_error_t rc; - - *okay = 0; - *off = 0; - do - { - do - { - rc = _assuan_read_line (ctx); - } - while (_assuan_error_is_eagain (rc)); - if (rc) - return rc; - line = ctx->inbound.line; - linelen = ctx->inbound.linelen; - } - while (*line == '#' || !linelen); - - if (linelen >= 1 - && line[0] == 'D' && line[1] == ' ') - { - *okay = 2; /* data line */ - *off = 2; - } - else if (linelen >= 1 - && line[0] == 'S' - && (line[1] == '\0' || line[1] == ' ')) - { - *okay = 4; - *off = 1; - while (line[*off] == ' ') - ++*off; - } - else if (linelen >= 2 - && line[0] == 'O' && line[1] == 'K' - && (line[2] == '\0' || line[2] == ' ')) - { - *okay = 1; - *off = 2; - while (line[*off] == ' ') - ++*off; - } - else if (linelen >= 3 - && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' - && (line[3] == '\0' || line[3] == ' ')) - { - *okay = 0; - *off = 3; - while (line[*off] == ' ') - ++*off; - } - else if (linelen >= 7 - && line[0] == 'I' && line[1] == 'N' && line[2] == 'Q' - && line[3] == 'U' && line[4] == 'I' && line[5] == 'R' - && line[6] == 'E' - && (line[7] == '\0' || line[7] == ' ')) - { - *okay = 3; - *off = 7; - while (line[*off] == ' ') - ++*off; - } - else if (linelen >= 3 - && line[0] == 'E' && line[1] == 'N' && line[2] == 'D' - && (line[3] == '\0' || line[3] == ' ')) - { - *okay = 5; /* end line */ - *off = 3; - } - else - rc = _assuan_error (ASSUAN_Invalid_Response); - return rc; -} - - - -/** - * assuan_transact: - * @ctx: The Assuan context - * @command: Command line to be send to the server - * @data_cb: Callback function for data lines - * @data_cb_arg: first argument passed to @data_cb - * @inquire_cb: Callback function for a inquire response - * @inquire_cb_arg: first argument passed to @inquire_cb - * @status_cb: Callback function for a status response - * @status_cb_arg: first argument passed to @status_cb - * - * FIXME: Write documentation - * - * Return value: 0 on success or error code. The error code may be - * the one one returned by the server in error lines or from the - * callback functions. Take care: When a callback returns an error - * this function returns immediately with an error and thus the caller - * will altter return an Assuan error (write erro in most cases). - **/ -assuan_error_t -assuan_transact (assuan_context_t ctx, - const char *command, - int (*data_cb)(void *, const void *, size_t), - void *data_cb_arg, - int (*inquire_cb)(void*, const char *), - void *inquire_cb_arg, - int (*status_cb)(void*, const char *), - void *status_cb_arg) -{ - assuan_error_t rc; - int okay, off; - char *line; - int linelen; - - rc = assuan_write_line (ctx, command); - if (rc) - return rc; - - if (*command == '#' || !*command) - return 0; /* Don't expect a response for a comment line. */ - - again: - rc = _assuan_read_from_server (ctx, &okay, &off); - if (rc) - return rc; /* error reading from server */ - - line = ctx->inbound.line + off; - linelen = ctx->inbound.linelen - off; - - if (!okay) - { - rc = atoi (line); - if (rc > 0 && rc < 100) - rc = _assuan_error (ASSUAN_Server_Fault); - else if (rc > 0 && rc <= 405) - rc = _assuan_error (rc); - } - else if (okay == 2) - { - if (!data_cb) - rc = _assuan_error (ASSUAN_No_Data_Callback); - else - { - char *s, *d; - - for (s=d=line; linelen; linelen--) - { - if (*s == '%' && linelen > 2) - { /* handle escaping */ - s++; - *d++ = xtoi_2 (s); - s += 2; - linelen -= 2; - } - else - *d++ = *s++; - } - *d = 0; /* add a hidden string terminator */ - rc = data_cb (data_cb_arg, line, d - line); - if (!rc) - goto again; - } - } - else if (okay == 3) - { - if (!inquire_cb) - { - assuan_write_line (ctx, "END"); /* get out of inquire mode */ - _assuan_read_from_server (ctx, &okay, &off); /* dummy read */ - rc = _assuan_error (ASSUAN_No_Inquire_Callback); - } - else - { - rc = inquire_cb (inquire_cb_arg, line); - if (!rc) - rc = assuan_send_data (ctx, NULL, 0); /* flush and send END */ - if (!rc) - goto again; - } - } - else if (okay == 4) - { - if (status_cb) - rc = status_cb (status_cb_arg, line); - if (!rc) - goto again; - } - else if (okay == 5) - { - if (!data_cb) - rc = _assuan_error (ASSUAN_No_Data_Callback); - else - { - rc = data_cb (data_cb_arg, NULL, 0); - if (!rc) - goto again; - } - } - - return rc; -} - diff --git a/assuan/src/assuan-connect.c b/assuan/src/assuan-connect.c deleted file mode 100644 index 2106ac30..00000000 --- a/assuan/src/assuan-connect.c +++ /dev/null @@ -1,83 +0,0 @@ -/* assuan-connect.c - Establish a connection (client) - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#ifndef HAVE_W32_SYSTEM -#include -#endif - -#include "assuan-defs.h" - -/* Disconnect and release the context CTX. */ -void -assuan_disconnect (assuan_context_t ctx) -{ - if (ctx) - { - assuan_write_line (ctx, "BYE"); - ctx->finish_handler (ctx); - ctx->deinit_handler (ctx); - ctx->deinit_handler = NULL; - _assuan_release_context (ctx); - } -} - -/* Return the PID of the peer or -1 if not known. This function works - in some situations where assuan_get_ucred fails. */ -pid_t -assuan_get_pid (assuan_context_t ctx) -{ - return (ctx && ctx->pid)? ctx->pid : -1; -} - - -#ifndef HAVE_W32_SYSTEM -/* Return user credentials. PID, UID and GID may be given as NULL if - you are not interested in a value. For getting the pid of the - peer the assuan_get_pid is usually better suited. */ -assuan_error_t -assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - if (!ctx->peercred.valid) - return _assuan_error (ASSUAN_General_Error); - -#ifdef HAVE_SO_PEERCRED - if (pid) - *pid = ctx->peercred.pid; - if (uid) - *uid = ctx->peercred.uid; - if (gid) - *gid = ctx->peercred.gid; -#endif - - return 0; -} -#endif /* HAVE_W32_SYSTEM */ diff --git a/assuan/src/assuan-defs.h b/assuan/src/assuan-defs.h deleted file mode 100644 index c2025bd1..00000000 --- a/assuan/src/assuan-defs.h +++ /dev/null @@ -1,365 +0,0 @@ -/* assuan-defs.c - Internal definitions to Assuan - * Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -#ifndef ASSUAN_DEFS_H -#define ASSUAN_DEFS_H - -#include -#ifndef HAVE_W32_SYSTEM -#include -#include -#else -#include -#endif -#include - -#include "assuan.h" - -#ifndef HAVE_W32_SYSTEM -#define DIRSEP_C '/' -#else -#define DIRSEP_C '\\' -#endif - -#ifdef HAVE_W32_SYSTEM -/* Not needed anymore because the current mingw32 defines this in - sys/types.h */ -/* typedef int ssize_t; */ - -/* Missing W32 functions */ -int putc_unlocked (int c, FILE *stream); -void * memrchr (const void *block, int c, size_t size); -char * stpcpy (char *dest, const char *src); -#endif - -#define LINELENGTH ASSUAN_LINELENGTH - - -struct cmdtbl_s -{ - const char *name; - int (*handler)(assuan_context_t, char *line); -}; - - -/* A structure to dispatch I/O functions. All these functions need to - return 0 on success and set ERRNO on failure. */ -struct assuan_io -{ - /* Routine to read from input_fd. */ - ssize_t (*readfnc) (assuan_context_t, void *, size_t); - /* Routine to write to output_fd. */ - ssize_t (*writefnc) (assuan_context_t, const void *, size_t); - /* Send a file descriptor. */ - assuan_error_t (*sendfd) (assuan_context_t, assuan_fd_t); - /* Receive a file descriptor. */ - assuan_error_t (*receivefd) (assuan_context_t, assuan_fd_t *); -}; - - -/* The global variable with the optional hook fucntions. */ -extern struct assuan_io_hooks _assuan_io_hooks; - - -/* The context we use with most functions. */ -struct assuan_context_s -{ - assuan_error_t err_no; - const char *err_str; - int os_errno; /* Last system error number used with certain - error codes. */ - - /* Context specific flags (cf. assuan_flag_t). */ - struct - { - unsigned int no_waitpid:1; /* See ASSUAN_NO_WAITPID. */ - } flags; - - int confidential; - int is_server; /* Set if this is context belongs to a server */ - int in_inquire; - int in_process_next; - int in_command; - - /* The following members are used by assuan_inquire_ext. */ - int (*inquire_cb) (void *cb_data, int rc, unsigned char *buf, size_t len); - void *inquire_cb_data; - void *inquire_membuf; - - char *hello_line; - char *okay_line; /* See assuan_set_okay_line() */ - - void *user_pointer; /* For assuan_get_pointer and assuan_set_pointer (). */ - - FILE *log_fp; - - struct { - assuan_fd_t fd; - int eof; - char line[LINELENGTH]; - int linelen; /* w/o CR, LF - might not be the same as - strlen(line) due to embedded nuls. However a nul - is always written at this pos. */ - struct { - char line[LINELENGTH]; - int linelen ; - int pending; /* i.e. at least one line is available in the attic */ - } attic; - } inbound; - - struct { - assuan_fd_t fd; - struct { - FILE *fp; - char line[LINELENGTH]; - int linelen; - int error; - } data; - } outbound; - - int pipe_mode; /* We are in pipe mode, i.e. we can handle just one - connection and must terminate then. */ - pid_t pid; /* The pid of the peer. */ - assuan_fd_t listen_fd; /* The fd we are listening on (used by - socket servers) */ - assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */ - assuan_fd_t connected_fd; /* helper */ - - struct { - int valid; /* Whether this structure has valid information. */ -#ifdef HAVE_SO_PEERCRED - pid_t pid; /* The pid of the peer. */ - uid_t uid; /* The uid of the peer. */ - gid_t gid; /* The gid of the peer. */ -#endif /* HAVE_SO_PEERCRED */ - } peercred; - - /* Used for Unix domain sockets. */ - struct sockaddr_un myaddr; - struct sockaddr_un serveraddr; - - /* Structure used for unix domain socket buffering. FIXME: We don't - use datagrams anymore thus we could get away with a simpler - buffering approach. */ - struct { - void *buffer; /* Malloced buffer. */ - int bufferallocated; /* Memory allocated. */ - int bufferoffset; /* Offset of start of buffer. */ - int buffersize; /* Bytes buffered. */ - - assuan_fd_t pendingfds[5]; /* Array to save received descriptors. */ - int pendingfdscount; /* Number of received descriptors. */ - } uds; - - void (*deinit_handler)(assuan_context_t); - int (*accept_handler)(assuan_context_t); - int (*finish_handler)(assuan_context_t); - - struct cmdtbl_s *cmdtbl; - size_t cmdtbl_used; /* used entries */ - size_t cmdtbl_size; /* allocated size of table */ - - void (*bye_notify_fnc)(assuan_context_t); - void (*reset_notify_fnc)(assuan_context_t); - void (*cancel_notify_fnc)(assuan_context_t); - int (*option_handler_fnc)(assuan_context_t,const char*, const char*); - void (*input_notify_fnc)(assuan_context_t, const char *); - void (*output_notify_fnc)(assuan_context_t, const char *); - - /* This function is called right after a command has been processed. - It may be used to command related cleanup. */ - void (*post_cmd_notify_fnc)(assuan_context_t, int); - - /* Called right before the actual command. Should return 0 on success or an - * error code which will abort the command. */ - int (*pre_cmd_notify_fnc)(assuan_context_t, const char *); - - /* If set, this is called right before logging an I/O line. With - DIRECTION set to 1 it is called for an output oeration; 0 means - an input operation. If bit 0 is set in the return value, the - logging of the line will be suppressed. With bit 1 set, the - entire line will be ignored. */ - unsigned int (*io_monitor)(assuan_context_t ctx, - int direction, - const char *line, - size_t linelen); - - assuan_fd_t input_fd; /* Set by the INPUT command. */ - assuan_fd_t output_fd; /* Set by the OUTPUT command. */ - - /* io routines. */ - struct assuan_io *io; -}; - -/*-- assuan-pipe-server.c --*/ -int _assuan_new_context (assuan_context_t *r_ctx); -void _assuan_release_context (assuan_context_t ctx); - -/*-- assuan-uds.c --*/ -void _assuan_uds_close_fds (assuan_context_t ctx); -void _assuan_uds_deinit (assuan_context_t ctx); -void _assuan_init_uds_io (assuan_context_t ctx); - - -/*-- assuan-handler.c --*/ -int _assuan_register_std_commands (assuan_context_t ctx); - -/*-- assuan-buffer.c --*/ -assuan_error_t _assuan_read_line (assuan_context_t ctx); -int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size); -int _assuan_cookie_write_flush (void *cookie); -assuan_error_t _assuan_write_line (assuan_context_t ctx, const char *prefix, - const char *line, size_t len); - -/*-- assuan-client.c --*/ -assuan_error_t _assuan_read_from_server (assuan_context_t ctx, - int *okay, int *off); - -/*-- assuan-error.c --*/ - -/*-- assuan-inquire.c --*/ -int _assuan_inquire_ext_cb (assuan_context_t ctx); -void _assuan_inquire_release (assuan_context_t ctx); - -/* Map error codes as used in this implementation to the libgpg-error - codes. */ -assuan_error_t _assuan_error (int oldcode); -/* Check if ERR means EAGAIN. */ -int _assuan_error_is_eagain (assuan_error_t err); - -/* Extract the error code from A. This works for both the old and the - new style error codes. This needs to be used whenever an error - code is compared. */ -#define err_code(a) ((a) & 0x00ffffff) - -/* Check whether A is the erro code for EOF. We allow for old and new - style EOF error codes here. */ -#define err_is_eof(a) ((a) == (-1) || err_code (a) == 16383) - - - -/*-- assuan-util.c --*/ -void *_assuan_malloc (size_t n); -void *_assuan_calloc (size_t n, size_t m); -void *_assuan_realloc (void *p, size_t n); -void _assuan_free (void *p); - -#define xtrymalloc(a) _assuan_malloc ((a)) -#define xtrycalloc(a,b) _assuan_calloc ((a),(b)) -#define xtryrealloc(a,b) _assuan_realloc((a),(b)) -#define xfree(a) _assuan_free ((a)) - -#define set_error(c,e,t) \ - assuan_set_error ((c), _assuan_error (ASSUAN_ ## e), (t)) - -#ifdef HAVE_W32_SYSTEM -const char *_assuan_w32_strerror (int ec); -#define w32_strerror(e) _assuan_w32_strerror ((e)) -int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen); -const char *_assuan_gpg_strsource (unsigned int err); -#endif /*HAVE_W32_SYSTEM*/ - - -/*-- assuan-logging.c --*/ -void _assuan_set_default_log_stream (FILE *fp); - -void _assuan_log_printf (const char *format, ...) -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) - __attribute__ ((format (printf,1,2))) -#endif - ; -void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); -void _assuan_log_sanitized_string (const char *string); - - -/*-- assuan-io.c --*/ -pid_t _assuan_waitpid (pid_t pid, int *status, int options); - -ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size); -ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, - size_t size); -ssize_t _assuan_io_read (assuan_fd_t fd, void *buffer, size_t size); -ssize_t _assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size); -#ifdef HAVE_W32_SYSTEM -int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg); -int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg); -#else -ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); -ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); -#endif - -void _assuan_usleep (unsigned int usec); - - -/*-- assuan-socket.c --*/ -int _assuan_close (assuan_fd_t fd); -assuan_fd_t _assuan_sock_new (int domain, int type, int proto); -int _assuan_sock_connect (assuan_fd_t sockfd, - struct sockaddr *addr, int addrlen); -int _assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen); -int _assuan_sock_get_nonce (struct sockaddr *addr, int addrlen, - assuan_sock_nonce_t *nonce); -int _assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce); -#ifdef HAVE_W32_SYSTEM -int _assuan_sock_wsa2errno (int err); -#endif - -#ifdef HAVE_FOPENCOOKIE -/* We have to implement funopen in terms of glibc's fopencookie. */ -FILE *_assuan_funopen(void *cookie, - cookie_read_function_t *readfn, - cookie_write_function_t *writefn, - cookie_seek_function_t *seekfn, - cookie_close_function_t *closefn); -#define funopen(a,r,w,s,c) _assuan_funopen ((a), (r), (w), (s), (c)) -#endif /*HAVE_FOPENCOOKIE*/ - -/* Prototypes for replacement functions. */ -#ifndef HAVE_MEMRCHR -void *memrchr (const void *block, int c, size_t size); -#endif -#ifndef HAVE_STPCPY -char *stpcpy (char *dest, const char *src); -#endif -#ifndef HAVE_SETENV -#define setenv _assuan_setenv -#define unsetenv _assuan_unsetenv -#define clearenv _assuan_clearenv -int setenv (const char *name, const char *value, int replace); -#endif -#ifndef HAVE_PUTC_UNLOCKED -int putc_unlocked (int c, FILE *stream); -#endif - -#define DIM(v) (sizeof(v)/sizeof((v)[0])) -#define DIMof(type,member) DIM(((type *)0)->member) - - -#if HAVE_W32_SYSTEM -#define SOCKET2HANDLE(s) ((void *)(s)) -#define HANDLE2SOCKET(h) ((unsigned int)(h)) -#else -#define SOCKET2HANDLE(s) (s) -#define HANDLE2SOCKET(h) (h) -#endif - - -#endif /*ASSUAN_DEFS_H*/ diff --git a/assuan/src/assuan-handler.c b/assuan/src/assuan-handler.c deleted file mode 100644 index 55b83c32..00000000 --- a/assuan/src/assuan-handler.c +++ /dev/null @@ -1,934 +0,0 @@ -/* assuan-handler.c - dispatch commands - * Copyright (C) 2001, 2002, 2003, 2007 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include - -#include "assuan-defs.h" - - - -#define spacep(p) (*(p) == ' ' || *(p) == '\t') -#define digitp(a) ((a) >= '0' && (a) <= '9') - -static int my_strcasecmp (const char *a, const char *b); - - -#define PROCESS_DONE(ctx, rc) \ - ((ctx)->in_process_next ? assuan_process_done ((ctx), (rc)) : (rc)) - -static int -dummy_handler (assuan_context_t ctx, char *line) -{ - return - PROCESS_DONE (ctx, set_error (ctx, Server_Fault, "no handler registered")); -} - - -static int -std_handler_nop (assuan_context_t ctx, char *line) -{ - return PROCESS_DONE (ctx, 0); /* okay */ -} - -static int -std_handler_cancel (assuan_context_t ctx, char *line) -{ - if (ctx->cancel_notify_fnc) - ctx->cancel_notify_fnc (ctx); - return PROCESS_DONE (ctx, set_error (ctx, Not_Implemented, NULL)); -} - -static int -std_handler_option (assuan_context_t ctx, char *line) -{ - char *key, *value, *p; - - for (key=line; spacep (key); key++) - ; - if (!*key) - return - PROCESS_DONE (ctx, set_error (ctx, Syntax_Error, "argument required")); - if (*key == '=') - return - PROCESS_DONE (ctx, set_error (ctx, Syntax_Error, - "no option name given")); - for (value=key; *value && !spacep (value) && *value != '='; value++) - ; - if (*value) - { - if (spacep (value)) - *value++ = 0; /* terminate key */ - for (; spacep (value); value++) - ; - if (*value == '=') - { - *value++ = 0; /* terminate key */ - for (; spacep (value); value++) - ; - if (!*value) - return - PROCESS_DONE (ctx, set_error (ctx, Syntax_Error, - "option argument expected")); - } - if (*value) - { - for (p = value + strlen(value) - 1; p > value && spacep (p); p--) - ; - if (p > value) - *++p = 0; /* strip trailing spaces */ - } - } - - if (*key == '-' && key[1] == '-' && key[2]) - key += 2; /* the double dashes are optional */ - if (*key == '-') - return PROCESS_DONE (ctx, - set_error (ctx, Syntax_Error, - "option should not begin with one dash")); - - if (ctx->option_handler_fnc) - return PROCESS_DONE (ctx, ctx->option_handler_fnc (ctx, key, value)); - return PROCESS_DONE (ctx, 0); -} - -static int -std_handler_bye (assuan_context_t ctx, char *line) -{ - if (ctx->bye_notify_fnc) - ctx->bye_notify_fnc (ctx); - assuan_close_input_fd (ctx); - assuan_close_output_fd (ctx); - return PROCESS_DONE (ctx, _assuan_error (-1)); /* pretty simple :-) */ -} - -static int -std_handler_auth (assuan_context_t ctx, char *line) -{ - return PROCESS_DONE (ctx, set_error (ctx, Not_Implemented, NULL)); -} - -static int -std_handler_reset (assuan_context_t ctx, char *line) -{ - if (ctx->reset_notify_fnc) - ctx->reset_notify_fnc (ctx); - assuan_close_input_fd (ctx); - assuan_close_output_fd (ctx); - _assuan_uds_close_fds (ctx); - return PROCESS_DONE (ctx, 0); -} - -static int -std_handler_help (assuan_context_t ctx, char *line) -{ - unsigned int i; - char buf[ASSUAN_LINELENGTH]; - - for (i = 0; i < ctx->cmdtbl_used; i++) - { - snprintf (buf, sizeof (buf), "# %s", ctx->cmdtbl[i].name); - buf[ASSUAN_LINELENGTH - 1] = '\0'; - assuan_write_line (ctx, buf); - } - - return PROCESS_DONE (ctx, 0); -} - - -static int -std_handler_end (assuan_context_t ctx, char *line) -{ - return PROCESS_DONE (ctx, set_error (ctx, Not_Implemented, NULL)); -} - - -assuan_error_t -assuan_command_parse_fd (assuan_context_t ctx, char *line, assuan_fd_t *rfd) -{ - char *endp; - - if ((strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) - || (line[2] != '=' && line[2] != '\0' && !spacep(&line[2]))) - return set_error (ctx, Syntax_Error, "FD[=] expected"); - line += 2; - if (*line == '=') - { - line ++; - if (!digitp (*line)) - return set_error (ctx, Syntax_Error, "number required"); -#ifdef HAVE_W32_SYSTEM - /* Fixme: For a W32/64bit system we will need to change the cast - and the conversion fucntion. */ - *rfd = (void*)strtoul (line, &endp, 10); -#else - *rfd = strtoul (line, &endp, 10); -#endif - /* Remove that argument so that a notify handler won't see it. */ - memset (line, ' ', endp? (endp-line):strlen(line)); - - if (*rfd == ctx->inbound.fd) - return set_error (ctx, Parameter_Conflict, "fd same as inbound fd"); - if (*rfd == ctx->outbound.fd) - return set_error (ctx, Parameter_Conflict, "fd same as outbound fd"); - return 0; - } - else - /* Our peer has sent the file descriptor. */ - return assuan_receivefd (ctx, rfd); -} - - -/* Format is INPUT FD= */ -static int -std_handler_input (assuan_context_t ctx, char *line) -{ - int rc; - assuan_fd_t fd; - - rc = assuan_command_parse_fd (ctx, line, &fd); - if (rc) - return PROCESS_DONE (ctx, rc); - ctx->input_fd = fd; - if (ctx->input_notify_fnc) - ctx->input_notify_fnc (ctx, line); - return PROCESS_DONE (ctx, 0); -} - -/* Format is OUTPUT FD= */ -static int -std_handler_output (assuan_context_t ctx, char *line) -{ - int rc; - assuan_fd_t fd; - - rc = assuan_command_parse_fd (ctx, line, &fd); - if (rc) - return PROCESS_DONE (ctx, rc); - ctx->output_fd = fd; - if (ctx->output_notify_fnc) - ctx->output_notify_fnc (ctx, line); - return PROCESS_DONE (ctx, 0); -} - - - - - -/* This is a table with the standard commands and handler for them. - The table is used to initialize a new context and associate strings - with default handlers */ -static struct { - const char *name; - int (*handler)(assuan_context_t, char *line); - int always; /* always initialize this command */ -} std_cmd_table[] = { - { "NOP", std_handler_nop, 1 }, - { "CANCEL", std_handler_cancel, 1 }, - { "OPTION", std_handler_option, 1 }, - { "BYE", std_handler_bye, 1 }, - { "AUTH", std_handler_auth, 1 }, - { "RESET", std_handler_reset, 1 }, - { "END", std_handler_end, 1 }, - { "HELP", std_handler_help, 1 }, - - { "INPUT", std_handler_input, 0 }, - { "OUTPUT", std_handler_output, 0 }, - { NULL, NULL, 0 } -}; - - -/** - * assuan_register_command: - * @ctx: the server context - * @cmd_name: A string with the command name - * @handler: The handler function to be called or NULL to use a default - * handler. - * - * Register a handler to be used for a given command. Note that - * several default handlers are already regsitered with a new context. - * This function however allows to override them. - * - * Return value: 0 on success or an error code - **/ -int -assuan_register_command (assuan_context_t ctx, - const char *cmd_name, - int (*handler)(assuan_context_t, char *)) -{ - int i; - const char *s; - - if (cmd_name && !*cmd_name) - cmd_name = NULL; - - if (!cmd_name) - return _assuan_error (ASSUAN_Invalid_Value); - - if (!handler) - { /* find a default handler. */ - for (i=0; (s=std_cmd_table[i].name) && strcmp (cmd_name, s); i++) - ; - if (!s) - { /* Try again but case insensitive. */ - for (i=0; (s=std_cmd_table[i].name) - && my_strcasecmp (cmd_name, s); i++) - ; - } - if (s) - handler = std_cmd_table[i].handler; - if (!handler) - handler = dummy_handler; /* Last resort is the dummy handler. */ - } - - if (!ctx->cmdtbl) - { - ctx->cmdtbl_size = 50; - ctx->cmdtbl = xtrycalloc ( ctx->cmdtbl_size, sizeof *ctx->cmdtbl); - if (!ctx->cmdtbl) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->cmdtbl_used = 0; - } - else if (ctx->cmdtbl_used >= ctx->cmdtbl_size) - { - struct cmdtbl_s *x; - - x = xtryrealloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x); - if (!x) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->cmdtbl = x; - ctx->cmdtbl_size += 50; - } - - ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name; - ctx->cmdtbl[ctx->cmdtbl_used].handler = handler; - ctx->cmdtbl_used++; - return 0; -} - -int -assuan_register_post_cmd_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, int)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->post_cmd_notify_fnc = fnc; - return 0; -} - -int -assuan_register_pre_cmd_notify (assuan_context_t ctx, - int (*fnc)(assuan_context_t, const char *)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->pre_cmd_notify_fnc = fnc; - return 0; -} - -int -assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->bye_notify_fnc = fnc; - return 0; -} - -int -assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->reset_notify_fnc = fnc; - return 0; -} - -int -assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->cancel_notify_fnc = fnc; - return 0; -} - -int -assuan_register_option_handler (assuan_context_t ctx, - int (*fnc)(assuan_context_t, - const char*, const char*)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->option_handler_fnc = fnc; - return 0; -} - -int -assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->input_notify_fnc = fnc; - return 0; -} - -int -assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - ctx->output_notify_fnc = fnc; - return 0; -} - - -/* Helper to register the standards commands */ -int -_assuan_register_std_commands (assuan_context_t ctx) -{ - int i, rc; - - for (i=0; std_cmd_table[i].name; i++) - { - if (std_cmd_table[i].always) - { - rc = assuan_register_command (ctx, std_cmd_table[i].name, NULL); - if (rc) - return rc; - } - } - return 0; -} - - - -/* Process the special data lines. The "D " has already been removed - from the line. As all handlers this function may modify the line. */ -static int -handle_data_line (assuan_context_t ctx, char *line, int linelen) -{ - return set_error (ctx, Not_Implemented, NULL); -} - -/* like ascii_strcasecmp but assume that B is already uppercase */ -static int -my_strcasecmp (const char *a, const char *b) -{ - if (a == b) - return 0; - - for (; *a && *b; a++, b++) - { - if (((*a >= 'a' && *a <= 'z')? (*a&~0x20):*a) != *b) - break; - } - return *a == *b? 0 : (((*a >= 'a' && *a <= 'z')? (*a&~0x20):*a) - *b); -} - - -/* Parse the line, break out the command, find it in the command - table, remove leading and white spaces from the arguments, call the - handler with the argument line and return the error. */ -static int -dispatch_command (assuan_context_t ctx, char *line, int linelen) -{ - char *p; - const char *s; - int shift, i; - int rc; - - /* Note that as this function is invoked by assuan_process_next as - well, we need to hide non-critical errors with PROCESS_DONE. */ - - if (*line == 'D' && line[1] == ' ') /* divert to special handler */ - /* FIXME: Depending on the final implementation of - handle_data_line, this may be wrong here. For example, if a - user callback is invoked, and that callback is responsible for - calling assuan_process_done, then this is wrong. */ - return PROCESS_DONE (ctx, handle_data_line (ctx, line+2, linelen-2)); - - for (p=line; *p && *p != ' ' && *p != '\t'; p++) - ; - if (p==line) - return PROCESS_DONE - (ctx, set_error (ctx, Syntax_Error, "leading white-space")); - if (*p) - { /* Skip over leading WS after the keyword */ - *p++ = 0; - while ( *p == ' ' || *p == '\t') - p++; - } - shift = p - line; - - for (i=0; (s=ctx->cmdtbl[i].name); i++) - { - if (!strcmp (line, s)) - break; - } - if (!s) - { /* and try case insensitive */ - for (i=0; (s=ctx->cmdtbl[i].name); i++) - { - if (!my_strcasecmp (line, s)) - break; - } - } - if (!s) - return PROCESS_DONE (ctx, set_error (ctx, Unknown_Command, NULL)); - line += shift; - linelen -= shift; - - if (ctx->pre_cmd_notify_fnc) { - rc = ctx->pre_cmd_notify_fnc(ctx, ctx->cmdtbl[i].name); - - if (rc) - return PROCESS_DONE (ctx, rc); - } - -/* fprintf (stderr, "DBG-assuan: processing %s `%s'\n", s, line); */ - return ctx->cmdtbl[i].handler (ctx, line); -} - - -/* Call this to acknowledge the current command. */ -int -assuan_process_done (assuan_context_t ctx, int rc) -{ - if (!ctx->in_command) - return _assuan_error (ASSUAN_General_Error); - - ctx->in_command = 0; - - /* Check for data write errors. */ - if (ctx->outbound.data.fp) - { - /* Flush the data lines. */ - fclose (ctx->outbound.data.fp); - ctx->outbound.data.fp = NULL; - if (!rc && ctx->outbound.data.error) - rc = ctx->outbound.data.error; - } - else - { - /* Flush any data send without using the data FP. */ - assuan_send_data (ctx, NULL, 0); - if (!rc && ctx->outbound.data.error) - rc = ctx->outbound.data.error; - } - - /* Error handling. */ - if (!rc) - { - rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK"); - } - else if (err_is_eof (rc)) - { /* No error checking because the peer may have already disconnect. */ - assuan_write_line (ctx, "OK closing connection"); - ctx->finish_handler (ctx); - } - else - { - char errline[300]; - - if (rc < 100) - sprintf (errline, "ERR %d server fault (%.50s)", - _assuan_error (ASSUAN_Server_Fault), assuan_strerror (rc)); - else - { - const char *text = ctx->err_no == rc? ctx->err_str:NULL; - -#if defined(HAVE_W32_SYSTEM) - unsigned int source, code; - char ebuf[50]; - const char *esrc; - - source = ((rc >> 24) & 0xff); - code = (rc & 0x00ffffff); - if (source - && !_assuan_gpg_strerror_r (rc, ebuf, sizeof ebuf) - && (esrc=_assuan_gpg_strsource (rc))) - { - /* Assume this is an libgpg-error. */ - sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s", - rc, ebuf, esrc, - text? " - ":"", text?text:""); - } - else -#elif defined(__GNUC__) && defined(__ELF__) - /* If we have weak symbol support we try to use the error - strings from libgpg-error without creating a dependency. - They are used for debugging purposes only, so there is no - problem if they are not available. We need to make sure - that we are using ELF because only this guarantees that - weak symbol support is available in case GNU ld is not - used. It seems that old gcc versions don't implement the - weak attribute properly but it works with the weak - pragma. */ - - unsigned int source, code; - - int gpg_strerror_r (unsigned int err, char *buf, size_t buflen) - __attribute__ ((weak)); - const char *gpg_strsource (unsigned int err) - __attribute__ ((weak)); -#if __GNUC__ < 3 -#pragma weak gpg_strerror_r -#pragma weak gpg_strsource -#endif - - source = ((rc >> 24) & 0xff); - code = (rc & 0x00ffffff); - if (source && gpg_strsource && gpg_strerror_r) - { - /* Assume this is an libgpg-error. */ - char ebuf[50]; - - gpg_strerror_r (rc, ebuf, sizeof ebuf ); - sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s", - rc, - ebuf, - gpg_strsource (rc), - text? " - ":"", text?text:""); - } - else -#endif /* __GNUC__ && __ELF__ */ - sprintf (errline, "ERR %d %.50s%s%.100s", - rc, assuan_strerror (rc), text? " - ":"", text?text:""); - } - rc = assuan_write_line (ctx, errline); - } - - if (ctx->post_cmd_notify_fnc) - ctx->post_cmd_notify_fnc (ctx, rc); - - ctx->confidential = 0; - if (ctx->okay_line) - { - xfree (ctx->okay_line); - ctx->okay_line = NULL; - } - - return rc; -} - - -static int -process_next (assuan_context_t ctx) -{ - int rc; - - /* What the next thing to do is depends on the current state. - However, we will always first read the next line. The client is - required to write full lines without blocking long after starting - a partial line. */ - rc = _assuan_read_line (ctx); - if (_assuan_error_is_eagain (rc)) - return 0; - if (rc) - return rc; - if (*ctx->inbound.line == '#' || !ctx->inbound.linelen) - /* Comment lines are ignored. */ - return 0; - - /* Now we have a line that really means something. It could be one - of the following things: First, if we are not in a command - already, it is the next command to dispatch. Second, if we are - in a command, it can only be the response to an INQUIRE - reply. */ - - if (!ctx->in_command) - { - ctx->in_command = 1; - - ctx->outbound.data.error = 0; - ctx->outbound.data.linelen = 0; - /* Dispatch command and return reply. */ - ctx->in_process_next = 1; - rc = dispatch_command (ctx, ctx->inbound.line, ctx->inbound.linelen); - ctx->in_process_next = 0; - } - else if (ctx->in_inquire) - { - /* FIXME: Pick up the continuation. */ - rc = _assuan_inquire_ext_cb (ctx); - } - else - { - /* Should not happen. The client is sending data while we are - in a command and not waiting for an inquire. We log an error - and discard it. */ - _assuan_log_printf ("unexpected client data\n"); - rc = 0; - } - - return rc; -} - - -/* This function should be invoked when the assuan connected FD is - ready for reading. If the equivalent to EWOULDBLOCK is returned - (this should be done by the command handler), assuan_process_next - should be invoked the next time the connected FD is readable. - Eventually, the caller will finish by invoking - assuan_process_done. */ -int -assuan_process_next (assuan_context_t ctx) -{ - int rc; - - do - { - rc = process_next (ctx); - } - while (!rc && assuan_pending_line (ctx)); - - return rc; -} - - - -static int -process_request (assuan_context_t ctx) -{ - int rc; - - if (ctx->in_inquire) - return _assuan_error (ASSUAN_Nested_Commands); - - do - { - rc = _assuan_read_line (ctx); - } - while (_assuan_error_is_eagain (rc)); - if (rc) - return rc; - if (*ctx->inbound.line == '#' || !ctx->inbound.linelen) - return 0; /* comment line - ignore */ - - ctx->in_command = 1; - ctx->outbound.data.error = 0; - ctx->outbound.data.linelen = 0; - /* dispatch command and return reply */ - rc = dispatch_command (ctx, ctx->inbound.line, ctx->inbound.linelen); - - return assuan_process_done (ctx, rc); -} - -/** - * assuan_process: - * @ctx: assuan context - * - * This function is used to handle the assuan protocol after a - * connection has been established using assuan_accept(). This is the - * main protocol handler. - * - * Return value: 0 on success or an error code if the assuan operation - * failed. Note, that no error is returned for operational errors. - **/ -int -assuan_process (assuan_context_t ctx) -{ - int rc; - - do { - rc = process_request (ctx); - } while (!rc); - - if (err_is_eof (rc)) - rc = 0; - - return rc; -} - - -/** - * assuan_get_active_fds: - * @ctx: Assuan context - * @what: 0 for read fds, 1 for write fds - * @fdarray: Caller supplied array to store the FDs - * @fdarraysize: size of that array - * - * Return all active filedescriptors for the given context. This - * function can be used to select on the fds and call - * assuan_process_next() if there is an active one. The first fd in - * the array is the one used for the command connection. - * - * Note, that write FDs are not yet supported. - * - * Return value: number of FDs active and put into @fdarray or -1 on - * error which is most likely a too small fdarray. - **/ -int -assuan_get_active_fds (assuan_context_t ctx, int what, - assuan_fd_t *fdarray, int fdarraysize) -{ - int n = 0; - - if (!ctx || fdarraysize < 2 || what < 0 || what > 1) - return -1; - - if (!what) - { - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - fdarray[n++] = ctx->inbound.fd; - } - else - { - if (ctx->outbound.fd != ASSUAN_INVALID_FD) - fdarray[n++] = ctx->outbound.fd; - if (ctx->outbound.data.fp) -#ifdef HAVE_W32_SYSTEM - fdarray[n++] = (void*)_get_osfhandle (fileno (ctx->outbound.data.fp)); -#else - fdarray[n++] = fileno (ctx->outbound.data.fp); -#endif - } - - return n; -} - - -/* Two simple wrappers to make the expected function types match. */ -#ifdef HAVE_FUNOPEN -static int -fun1_cookie_write (void *cookie, const char *buffer, int orig_size) -{ - return _assuan_cookie_write_data (cookie, buffer, orig_size); -} -#endif /*HAVE_FUNOPEN*/ -#ifdef HAVE_FOPENCOOKIE -static ssize_t -fun2_cookie_write (void *cookie, const char *buffer, size_t orig_size) -{ - return _assuan_cookie_write_data (cookie, buffer, orig_size); -} -#endif /*HAVE_FOPENCOOKIE*/ - -/* Return a FP to be used for data output. The FILE pointer is valid - until the end of a handler. So a close is not needed. Assuan does - all the buffering needed to insert the status line as well as the - required line wappping and quoting for data lines. - - We use GNU's custom streams here. There should be an alternative - implementaion for systems w/o a glibc, a simple implementation - could use a child process */ -FILE * -assuan_get_data_fp (assuan_context_t ctx) -{ -#if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN) - if (ctx->outbound.data.fp) - return ctx->outbound.data.fp; - -#ifdef HAVE_FUNOPEN - ctx->outbound.data.fp = funopen (ctx, 0, fun1_cookie_write, - 0, _assuan_cookie_write_flush); -#else - ctx->outbound.data.fp = funopen (ctx, 0, fun2_cookie_write, - 0, _assuan_cookie_write_flush); -#endif - - ctx->outbound.data.error = 0; - return ctx->outbound.data.fp; -#else - errno = ENOSYS; - return NULL; -#endif -} - - -/* Set the text used for the next OK reponse. This string is - automatically reset to NULL after the next command. */ -assuan_error_t -assuan_set_okay_line (assuan_context_t ctx, const char *line) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - if (!line) - { - xfree (ctx->okay_line); - ctx->okay_line = NULL; - } - else - { - /* FIXME: we need to use gcry_is_secure() to test whether - we should allocate the entire line in secure memory */ - char *buf = xtrymalloc (3+strlen(line)+1); - if (!buf) - return _assuan_error (ASSUAN_Out_Of_Core); - strcpy (buf, "OK "); - strcpy (buf+3, line); - xfree (ctx->okay_line); - ctx->okay_line = buf; - } - return 0; -} - - - -assuan_error_t -assuan_write_status (assuan_context_t ctx, - const char *keyword, const char *text) -{ - char buffer[256]; - char *helpbuf; - size_t n; - assuan_error_t ae; - - if ( !ctx || !keyword) - return _assuan_error (ASSUAN_Invalid_Value); - if (!text) - text = ""; - - n = 2 + strlen (keyword) + 1 + strlen (text) + 1; - if (n < sizeof (buffer)) - { - strcpy (buffer, "S "); - strcat (buffer, keyword); - if (*text) - { - strcat (buffer, " "); - strcat (buffer, text); - } - ae = assuan_write_line (ctx, buffer); - } - else if ( (helpbuf = xtrymalloc (n)) ) - { - strcpy (helpbuf, "S "); - strcat (helpbuf, keyword); - if (*text) - { - strcat (helpbuf, " "); - strcat (helpbuf, text); - } - ae = assuan_write_line (ctx, helpbuf); - xfree (helpbuf); - } - else - ae = 0; - return ae; -} diff --git a/assuan/src/assuan-inquire.c b/assuan/src/assuan-inquire.c deleted file mode 100644 index 58b9f029..00000000 --- a/assuan/src/assuan-inquire.c +++ /dev/null @@ -1,387 +0,0 @@ -/* assuan-inquire.c - handle inquire stuff - * Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include - -#include "assuan-defs.h" - -#define digitp(a) ((a) >= '0' && (a) <= '9') -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - - -struct membuf -{ - size_t len; - size_t size; - char *buf; - int out_of_core; - int too_large; - size_t maxlen; -}; - - - -/* A simple implementation of a dynamic buffer. Use init_membuf() to - create a buffer, put_membuf to append bytes and get_membuf to - release and return the buffer. Allocation errors are detected but - only returned at the final get_membuf(), this helps not to clutter - the code with out of core checks. */ - -static void -init_membuf (struct membuf *mb, int initiallen, size_t maxlen) -{ - mb->len = 0; - mb->size = initiallen; - mb->out_of_core = 0; - mb->too_large = 0; - mb->maxlen = maxlen; - /* we need to allocate one byte more for get_membuf */ - mb->buf = xtrymalloc (initiallen+1); - if (!mb->buf) - mb->out_of_core = 1; -} - -static void -put_membuf (struct membuf *mb, const void *buf, size_t len) -{ - if (mb->out_of_core || mb->too_large) - return; - - if (mb->maxlen && mb->len + len > mb->maxlen) - { - mb->too_large = 1; - return; - } - - if (mb->len + len >= mb->size) - { - char *p; - - mb->size += len + 1024; - /* we need to allocate one byte more for get_membuf */ - p = xtryrealloc (mb->buf, mb->size+1); - if (!p) - { - mb->out_of_core = 1; - return; - } - mb->buf = p; - } - memcpy (mb->buf + mb->len, buf, len); - mb->len += len; -} - -static void * -get_membuf (struct membuf *mb, size_t *len) -{ - char *p; - - if (mb->out_of_core || mb->too_large) - { - xfree (mb->buf); - mb->buf = NULL; - return NULL; - } - - mb->buf[mb->len] = 0; /* there is enough space for the hidden eos */ - p = mb->buf; - *len = mb->len; - mb->buf = NULL; - mb->out_of_core = 1; /* don't allow a reuse */ - return p; -} - -static void -free_membuf (struct membuf *mb) -{ - xfree (mb->buf); - mb->buf = NULL; -} - - -/** - * assuan_inquire: - * @ctx: An assuan context - * @keyword: The keyword used for the inquire - * @r_buffer: Returns an allocated buffer - * @r_length: Returns the length of this buffer - * @maxlen: If not 0, the size limit of the inquired data. - * - * A Server may use this to Send an inquire. r_buffer, r_length and - * maxlen may all be NULL/0 to indicate that no real data is expected. - * - * Return value: 0 on success or an ASSUAN error code - **/ -assuan_error_t -assuan_inquire (assuan_context_t ctx, const char *keyword, - unsigned char **r_buffer, size_t *r_length, size_t maxlen) -{ - assuan_error_t rc; - struct membuf mb; - char cmdbuf[LINELENGTH-10]; /* (10 = strlen ("INQUIRE ")+CR,LF) */ - unsigned char *line, *p; - int linelen; - int nodataexpected; - - if (!ctx || !keyword || (10 + strlen (keyword) >= sizeof (cmdbuf))) - return _assuan_error (ASSUAN_Invalid_Value); - nodataexpected = !r_buffer && !r_length && !maxlen; - if (!nodataexpected && (!r_buffer || !r_length)) - return _assuan_error (ASSUAN_Invalid_Value); - if (!ctx->is_server) - return _assuan_error (ASSUAN_Not_A_Server); - if (ctx->in_inquire) - return _assuan_error (ASSUAN_Nested_Commands); - - ctx->in_inquire = 1; - if (nodataexpected) - memset (&mb, 0, sizeof mb); /* avoid compiler warnings */ - else - init_membuf (&mb, maxlen? maxlen:1024, maxlen); - - strcpy (stpcpy (cmdbuf, "INQUIRE "), keyword); - rc = assuan_write_line (ctx, cmdbuf); - if (rc) - goto leave; - - for (;;) - { - do - { - do - rc = _assuan_read_line (ctx); - while (_assuan_error_is_eagain (rc)); - if (rc) - goto leave; - line = (unsigned char *) ctx->inbound.line; - linelen = ctx->inbound.linelen; - } - while (*line == '#' || !linelen); - if (line[0] == 'E' && line[1] == 'N' && line[2] == 'D' - && (!line[3] || line[3] == ' ')) - break; /* END command received*/ - if (line[0] == 'C' && line[1] == 'A' && line[2] == 'N') - { - rc = _assuan_error (ASSUAN_Canceled); - goto leave; - } - if (line[0] != 'D' || line[1] != ' ' || nodataexpected) - { - rc = _assuan_error (ASSUAN_Unexpected_Command); - goto leave; - } - if (linelen < 3) - continue; - line += 2; - linelen -= 2; - - p = line; - while (linelen) - { - for (;linelen && *p != '%'; linelen--, p++) - ; - put_membuf (&mb, line, p-line); - if (linelen > 2) - { /* handle escaping */ - unsigned char tmp[1]; - p++; - *tmp = xtoi_2 (p); - p += 2; - linelen -= 3; - put_membuf (&mb, tmp, 1); - } - line = p; - } - if (mb.too_large) - { - rc = _assuan_error (ASSUAN_Too_Much_Data); - goto leave; - } - } - - if (!nodataexpected) - { - *r_buffer = get_membuf (&mb, r_length); - if (!*r_buffer) - rc = _assuan_error (ASSUAN_Out_Of_Core); - } - - leave: - if (!nodataexpected) - free_membuf (&mb); - ctx->in_inquire = 0; - return rc; -} - - -void -_assuan_inquire_release (assuan_context_t ctx) -{ - if (ctx->in_inquire) - { - if (ctx->inquire_membuf) - { - free_membuf (ctx->inquire_membuf); - free (ctx->inquire_membuf); - } - ctx->in_inquire = 0; - } -} - - -int -_assuan_inquire_ext_cb (assuan_context_t ctx) -{ - int rc; - unsigned char *line; - int linelen; - struct membuf *mb; - unsigned char *p; - - line = (unsigned char *) ctx->inbound.line; - linelen = ctx->inbound.linelen; - mb = ctx->inquire_membuf; - - if (line[0] == 'C' && line[1] == 'A' && line[2] == 'N') - { - rc = _assuan_error (ASSUAN_Canceled); - goto leave; - } - if (line[0] == 'E' && line[1] == 'N' && line[2] == 'D' - && (!line[3] || line[3] == ' ')) - { - rc = 0; - goto leave; - } - - if (line[0] != 'D' || line[1] != ' ' || mb == NULL) - { - rc = _assuan_error (ASSUAN_Unexpected_Command); - goto leave; - } - - if (linelen < 3) - return 0; - line += 2; - linelen -= 2; - - p = line; - while (linelen) - { - for (;linelen && *p != '%'; linelen--, p++) - ; - put_membuf (mb, line, p-line); - if (linelen > 2) - { /* handle escaping */ - unsigned char tmp[1]; - p++; - *tmp = xtoi_2 (p); - p += 2; - linelen -= 3; - put_membuf (mb, tmp, 1); - } - line = p; - } - if (mb->too_large) - { - rc = _assuan_error (ASSUAN_Too_Much_Data); - goto leave; - } - - return 0; - - leave: - { - size_t buf_len = 0; - unsigned char *buf = NULL; - - if (mb) - { - buf = get_membuf (mb, &buf_len); - if (!buf) - rc = _assuan_error (ASSUAN_Out_Of_Core); - free_membuf (mb); - free (mb); - ctx->inquire_membuf = NULL; - } - ctx->in_inquire = 0; - rc = (ctx->inquire_cb) (ctx->inquire_cb_data, rc, buf, buf_len); - } - return rc; -} - -/** - * assuan_inquire_ext: - * @ctx: An assuan context - * @keyword: The keyword used for the inquire - * @maxlen: If not 0, the size limit of the inquired data. - * @cb: A callback handler which is invoked after the operation completed. - * @cb_data: A user-provided value passed to the callback handler. - * - * A Server may use this to Send an inquire. r_buffer, r_length and - * maxlen may all be NULL/0 to indicate that no real data is expected. - * When this function returns, - * - * Return value: 0 on success or an ASSUAN error code - **/ -assuan_error_t -assuan_inquire_ext (assuan_context_t ctx, const char *keyword, size_t maxlen, - int (*cb) (void *cb_data, int rc, unsigned char *buf, - size_t len), - void *cb_data) -{ - assuan_error_t rc; - struct membuf *mb = NULL; - char cmdbuf[LINELENGTH-10]; /* (10 = strlen ("INQUIRE ")+CR,LF) */ - - if (!ctx || !keyword || (10 + strlen (keyword) >= sizeof (cmdbuf))) - return _assuan_error (ASSUAN_Invalid_Value); - if (!ctx->is_server) - return _assuan_error (ASSUAN_Not_A_Server); - if (ctx->in_inquire) - return _assuan_error (ASSUAN_Nested_Commands); - - mb = malloc (sizeof (struct membuf)); - if (!mb) - return _assuan_error (ASSUAN_Out_Of_Core); - init_membuf (mb, maxlen ? maxlen : 1024, maxlen); - - strcpy (stpcpy (cmdbuf, "INQUIRE "), keyword); - rc = assuan_write_line (ctx, cmdbuf); - if (rc) - { - free_membuf (mb); - free (mb); - return rc; - } - - ctx->in_inquire = 1; - - /* Set up the continuation. */ - ctx->inquire_cb = cb; - ctx->inquire_cb_data = cb_data; - ctx->inquire_membuf = mb; - - return 0; -} diff --git a/assuan/src/assuan-io-pth.c b/assuan/src/assuan-io-pth.c deleted file mode 100644 index 6064ec43..00000000 --- a/assuan/src/assuan-io-pth.c +++ /dev/null @@ -1,191 +0,0 @@ -/* assuan-io-pth.c - Pth version of assua-io.c. - * Copyright (C) 2002, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#if HAVE_SYS_UIO_H -# include -#endif -#include -#include -#ifdef HAVE_W32_SYSTEM -# include -#else -# include -#endif -#include - -#include "assuan-defs.h" - - - -#ifndef HAVE_W32_SYSTEM -pid_t -_assuan_waitpid (pid_t pid, int *status, int options) -{ - return pth_waitpid (pid, status, options); -} -#endif - - -ssize_t -_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) -{ - /* Fixme: For W32 we should better not cast the HANDLE type to int. - However, this requires changes in w32pth too. */ - ssize_t retval; - - if (_assuan_io_hooks.read_hook - && _assuan_io_hooks.read_hook (ctx, ctx->inbound.fd, - buffer, size, &retval) == 1) - return retval; - - return _assuan_io_read (ctx->inbound.fd, buffer, size); -} - -ssize_t -_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.write_hook - && _assuan_io_hooks.write_hook (ctx, ctx->outbound.fd, - buffer, size, &retval) == 1) - return retval; - return _assuan_io_write (ctx->outbound.fd, buffer, size); -} - -ssize_t -_assuan_io_read (assuan_fd_t fd, void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.read_hook - && _assuan_io_hooks.read_hook (NULL, fd, buffer, size, &retval) == 1) - return retval; - return pth_read ((int)fd, buffer, size); -} - -ssize_t -_assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.write_hook - && _assuan_io_hooks.write_hook (NULL, fd, buffer, size, &retval) == 1) - return retval; - return pth_write ((int)fd, buffer, size); -} - - -#ifdef HAVE_W32_SYSTEM -int -_assuan_simple_sendmsg (assuan_context_t ctx, void *msg) -#else -ssize_t -_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) -#endif -{ -#if defined(HAVE_W32_SYSTEM) - return _assuan_error (ASSUAN_Not_Implemented); -#else - /* Pth does not provide a sendmsg function. Thus we implement it here. */ - int ret; - int fd = ctx->outbound.fd; - int fdmode; - - fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); - if (fdmode == PTH_FDMODE_ERROR) - { - errno = EBADF; - return -1; - } - if (fdmode == PTH_FDMODE_BLOCK) - { - fd_set fds; - - FD_ZERO (&fds); - FD_SET (fd, &fds); - while ( (ret = pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0 - && errno == EINTR) - ; - if (ret < 0) - return -1; - } - - while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR) - ; - return ret; -#endif -} - -#ifdef HAVE_W32_SYSTEM -int -_assuan_simple_recvmsg (assuan_context_t ctx, void *msg) -#else -ssize_t -_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) -#endif -{ -#if defined(HAVE_W32_SYSTEM) - return _assuan_error (ASSUAN_Not_Implemented); -#else - /* Pth does not provide a recvmsg function. Thus we implement it here. */ - int ret; - int fd = ctx->inbound.fd; - int fdmode; - - fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); - if (fdmode == PTH_FDMODE_ERROR) - { - errno = EBADF; - return -1; - } - if (fdmode == PTH_FDMODE_BLOCK) - { - fd_set fds; - - FD_ZERO (&fds); - FD_SET (fd, &fds); - while ( (ret = pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0 - && errno == EINTR) - ; - if (ret < 0) - return -1; - } - - while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR) - ; - return ret; -#endif -} - - -void -_assuan_usleep (unsigned int usec) -{ - pth_usleep (usec); -} diff --git a/assuan/src/assuan-io.c b/assuan/src/assuan-io.c deleted file mode 100644 index 647237db..00000000 --- a/assuan/src/assuan-io.c +++ /dev/null @@ -1,245 +0,0 @@ -/* assuan-io.c - Wraps the read and write functions. - * Copyright (C) 2002, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include -#include -#ifdef HAVE_W32_SYSTEM -# include -#else -# include -#endif - -#include "assuan-defs.h" - - -#ifndef HAVE_W32_SYSTEM -pid_t -_assuan_waitpid (pid_t pid, int *status, int options) -{ - return waitpid (pid, status, options); -} -#endif - - -static ssize_t -do_io_read (assuan_fd_t fd, void *buffer, size_t size) -{ -#ifdef HAVE_W32_SYSTEM - /* Due to the peculiarities of the W32 API we can't use read for a - network socket and thus we try to use recv first and fallback to - read if recv detects that it is not a network socket. */ - int n; - - n = recv (HANDLE2SOCKET(fd), buffer, size, 0); - if (n == -1) - { - switch (WSAGetLastError ()) - { - case WSAENOTSOCK: - { - DWORD nread = 0; - - n = ReadFile (fd, buffer, size, &nread, NULL); - if (!n) - { - switch (GetLastError()) - { - case ERROR_BROKEN_PIPE: errno = EPIPE; break; - default: errno = EIO; - } - n = -1; - } - else - n = (int)nread; - } - break; - - case WSAEWOULDBLOCK: errno = EAGAIN; break; - case ERROR_BROKEN_PIPE: errno = EPIPE; break; - default: errno = EIO; break; - } - } - return n; -#else /*!HAVE_W32_SYSTEM*/ - return read (fd, buffer, size); -#endif /*!HAVE_W32_SYSTEM*/ -} - - -ssize_t -_assuan_io_read (assuan_fd_t fd, void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.read_hook - && _assuan_io_hooks.read_hook (NULL, fd, buffer, size, &retval) == 1) - return retval; - - return do_io_read (fd, buffer, size); -} - -ssize_t -_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.read_hook - && _assuan_io_hooks.read_hook (ctx, ctx->inbound.fd, - buffer, size, &retval) == 1) - return retval; - - return do_io_read (ctx->inbound.fd, buffer, size); -} - - - -static ssize_t -do_io_write (assuan_fd_t fd, const void *buffer, size_t size) -{ -#ifdef HAVE_W32_SYSTEM - /* Due to the peculiarities of the W32 API we can't use write for a - network socket and thus we try to use send first and fallback to - write if send detects that it is not a network socket. */ - int n; - - n = send (HANDLE2SOCKET(fd), buffer, size, 0); - if (n == -1 && WSAGetLastError () == WSAENOTSOCK) - { - DWORD nwrite; - - n = WriteFile (fd, buffer, size, &nwrite, NULL); - if (!n) - { - switch (GetLastError ()) - { - case ERROR_BROKEN_PIPE: - case ERROR_NO_DATA: errno = EPIPE; break; - default: errno = EIO; break; - } - n = -1; - } - else - n = (int)nwrite; - } - return n; -#else /*!HAVE_W32_SYSTEM*/ - return write (fd, buffer, size); -#endif /*!HAVE_W32_SYSTEM*/ -} - -ssize_t -_assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.write_hook - && _assuan_io_hooks.write_hook (NULL, fd, buffer, size, &retval) == 1) - return retval; - return do_io_write (fd, buffer, size); -} - -ssize_t -_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) -{ - ssize_t retval; - - if (_assuan_io_hooks.write_hook - && _assuan_io_hooks.write_hook (ctx, ctx->outbound.fd, - buffer, size, &retval) == 1) - return retval; - - return do_io_write (ctx->outbound.fd, buffer, size); -} - - -#ifdef HAVE_W32_SYSTEM -int -_assuan_simple_sendmsg (assuan_context_t ctx, void *msg) -#else -ssize_t -_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) -#endif -{ -#ifdef HAVE_W32_SYSTEM - return _assuan_error (ASSUAN_Not_Implemented); -#else - int ret; - while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR) - ; - return ret; -#endif -} - - -#ifdef HAVE_W32_SYSTEM -int -_assuan_simple_recvmsg (assuan_context_t ctx, void *msg) -#else -ssize_t -_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) -#endif -{ -#ifdef HAVE_W32_SYSTEM - return _assuan_error (ASSUAN_Not_Implemented); -#else - int ret; - while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR) - ; - return ret; -#endif -} - - -void -_assuan_usleep (unsigned int usec) -{ - if (usec) - { -#ifdef HAVE_NANOSLEEP - struct timespec req; - struct timespec rem; - - req.tv_sec = 0; - req.tv_nsec = usec * 1000; - - while (nanosleep (&req, &rem) < 0 && errno == EINTR) - req = rem; - -#elif defined(HAVE_W32_SYSTEM) - Sleep (usec / 1000); -#else - struct timeval tv; - - tv.tv_sec = usec / 1000000; - tv.tv_usec = usec % 1000000; - select (0, NULL, NULL, NULL, &tv); -#endif - } -} - diff --git a/assuan/src/assuan-listen.c b/assuan/src/assuan-listen.c deleted file mode 100644 index 2ef93340..00000000 --- a/assuan/src/assuan-listen.c +++ /dev/null @@ -1,155 +0,0 @@ -/* assuan-listen.c - Wait for a connection (server) - * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include "assuan-defs.h" - -assuan_error_t -assuan_set_hello_line (assuan_context_t ctx, const char *line) -{ - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - if (!line) - { - xfree (ctx->hello_line); - ctx->hello_line = NULL; - } - else - { - char *buf = xtrymalloc (3+strlen(line)+1); - if (!buf) - return _assuan_error (ASSUAN_Out_Of_Core); - if (strchr (line, '\n')) - strcpy (buf, line); - else - { - strcpy (buf, "OK "); - strcpy (buf+3, line); - } - xfree (ctx->hello_line); - ctx->hello_line = buf; - } - return 0; -} - - -/** - * assuan_accept: - * @ctx: context - * - * Cancel any existing connection and wait for a connection from a - * client. The initial handshake is performed which may include an - * initial authentication or encryption negotiation. - * - * Return value: 0 on success or an error if the connection could for - * some reason not be established. - **/ -assuan_error_t -assuan_accept (assuan_context_t ctx) -{ - int rc; - const char *p, *pend; - - if (!ctx) - return _assuan_error (ASSUAN_Invalid_Value); - - if (ctx->pipe_mode > 1) - return -1; /* second invocation for pipemode -> terminate */ - ctx->finish_handler (ctx); - - rc = ctx->accept_handler (ctx); - if (rc) - return rc; - - /* Send the hello. */ - p = ctx->hello_line; - if (p && (pend = strchr (p, '\n'))) - { /* This is a multi line hello. Send all but the last line as - comments. */ - do - { - rc = _assuan_write_line (ctx, "# ", p, pend - p); - if (rc) - return rc; - p = pend + 1; - pend = strchr (p, '\n'); - } - while (pend); - rc = _assuan_write_line (ctx, "OK ", p, strlen (p)); - } - else if (p) - rc = assuan_write_line (ctx, p); - else - rc = assuan_write_line (ctx, "OK Pleased to meet you"); - if (rc) - return rc; - - if (ctx->pipe_mode) - ctx->pipe_mode = 2; - - return 0; -} - - - -assuan_fd_t -assuan_get_input_fd (assuan_context_t ctx) -{ - return ctx? ctx->input_fd : ASSUAN_INVALID_FD; -} - - -assuan_fd_t -assuan_get_output_fd (assuan_context_t ctx) -{ - return ctx? ctx->output_fd : ASSUAN_INVALID_FD; -} - - -/* Close the fd descriptor set by the command INPUT FD=n. We handle - this fd inside assuan so that we can do some initial checks */ -assuan_error_t -assuan_close_input_fd (assuan_context_t ctx) -{ - if (!ctx || ctx->input_fd == ASSUAN_INVALID_FD) - return _assuan_error (ASSUAN_Invalid_Value); - _assuan_close (ctx->input_fd); - ctx->input_fd = ASSUAN_INVALID_FD; - return 0; -} - -/* Close the fd descriptor set by the command OUTPUT FD=n. We handle - this fd inside assuan so that we can do some initial checks */ -assuan_error_t -assuan_close_output_fd (assuan_context_t ctx) -{ - if (!ctx || ctx->output_fd == ASSUAN_INVALID_FD) - return _assuan_error (ASSUAN_Invalid_Value); - - _assuan_close (ctx->output_fd); - ctx->output_fd = ASSUAN_INVALID_FD; - return 0; -} - diff --git a/assuan/src/assuan-logging.c b/assuan/src/assuan-logging.c deleted file mode 100644 index 2ebd6678..00000000 --- a/assuan/src/assuan-logging.c +++ /dev/null @@ -1,291 +0,0 @@ -/* assuan-logging.c - Default logging function. - * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -#include -#endif /*HAVE_W32_SYSTEM*/ -#include -#include - -#include "assuan-defs.h" - -static char prefix_buffer[80]; -static FILE *_assuan_log; -static int full_logging; - -void -_assuan_set_default_log_stream (FILE *fp) -{ - if (!_assuan_log) - { - _assuan_log = fp; - full_logging = !!getenv ("ASSUAN_FULL_LOGGING"); - } -} - -void -assuan_set_assuan_log_stream (FILE *fp) -{ - _assuan_log = fp; -} - - -/* Set the per context log stream. Also enable the default log stream - if it has not been set. */ -void -assuan_set_log_stream (assuan_context_t ctx, FILE *fp) -{ - if (ctx) - { - if (ctx->log_fp) - fflush (ctx->log_fp); - ctx->log_fp = fp; - _assuan_set_default_log_stream (fp); - } -} - - -FILE * -assuan_get_assuan_log_stream (void) -{ - return _assuan_log ? _assuan_log : stderr; -} - - -/* Set the prefix to be used for logging to TEXT or - resets it to the default if TEXT is NULL. */ -void -assuan_set_assuan_log_prefix (const char *text) -{ - if (text) - { - strncpy (prefix_buffer, text, sizeof (prefix_buffer)-1); - prefix_buffer[sizeof (prefix_buffer)-1] = 0; - } - else - *prefix_buffer = 0; -} - -const char * -assuan_get_assuan_log_prefix (void) -{ - return prefix_buffer; -} - - -void -_assuan_log_printf (const char *format, ...) -{ - va_list arg_ptr; - FILE *fp; - const char *prf; - int save_errno = errno; - - fp = assuan_get_assuan_log_stream (); - prf = assuan_get_assuan_log_prefix (); - if (*prf) - fprintf (fp, "%s[%u]: ", prf, (unsigned int)getpid ()); - - va_start (arg_ptr, format); - vfprintf (fp, format, arg_ptr ); - va_end (arg_ptr); - /* If the log stream is a file, the output would be buffered. This - is bad for debugging, thus we flush the stream if FORMAT ends - with a LF. */ - if (format && *format && format[strlen(format)-1] == '\n') - fflush (fp); - errno = save_errno; -} - - -/* Dump a possibly binary string (used for debugging). Distinguish - ascii text from binary and print it accordingly. This function - takes FILE pointer arg because logging may be enabled on a per - context basis. */ -void -_assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) -{ - const unsigned char *s; - unsigned int n; - - for (n = length, s = buffer; n; n--, s++) - if ((! isascii (*s) || iscntrl (*s) || ! isprint (*s)) && !(*s >= 0x80)) - break; - - s = buffer; - if (! n && *s != '[') - fwrite (buffer, length, 1, fp); - else - { -#ifdef HAVE_FLOCKFILE - flockfile (fp); -#endif - putc_unlocked ('[', fp); - if (length > 16 && ! full_logging) - { - for (n = 0; n < 12; n++, s++) - fprintf (fp, " %02x", *s); - fprintf (fp, " ...(%d bytes skipped)", (int) length - 12); - } - else - { - for (n = 0; n < length; n++, s++) - fprintf (fp, " %02x", *s); - } - putc_unlocked (' ', fp); - putc_unlocked (']', fp); -#ifdef HAVE_FUNLOCKFILE - funlockfile (fp); -#endif - } -} - -/* Log a user supplied string. Escapes non-printable before - printing. */ -void -_assuan_log_sanitized_string (const char *string) -{ - const unsigned char *s = (const unsigned char *) string; - FILE *fp = assuan_get_assuan_log_stream (); - - if (! *s) - return; - -#ifdef HAVE_FLOCKFILE - flockfile (fp); -#endif - - for (; *s; s++) - { - int c = 0; - - switch (*s) - { - case '\r': - c = 'r'; - break; - - case '\n': - c = 'n'; - break; - - case '\f': - c = 'f'; - break; - - case '\v': - c = 'v'; - break; - - case '\b': - c = 'b'; - break; - - default: - if ((isascii (*s) && isprint (*s)) || (*s >= 0x80)) - putc_unlocked (*s, fp); - else - { - putc_unlocked ('\\', fp); - fprintf (fp, "x%02x", *s); - } - } - - if (c) - { - putc_unlocked ('\\', fp); - putc_unlocked (c, fp); - } - } - -#ifdef HAVE_FUNLOCKFILE - funlockfile (fp); -#endif -} - - - -#ifdef HAVE_W32_SYSTEM -const char * -_assuan_w32_strerror (int ec) -{ - static char strerr[256]; - - if (ec == -1) - ec = (int)GetLastError (); - FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - strerr, sizeof (strerr)-1, NULL); - return strerr; -} - -static int (*my_strerror_r) (unsigned int err, char *buf, size_t buflen); -static const char * (*my_strsource) (unsigned int err); - -static int -load_libgpg_error (void) -{ - /* This code is not race free but suitable for our purpose. */ - static volatile int initialized; - void *handle; - - if (initialized) - return (my_strerror_r && my_strsource)? 0:-1; - handle = LoadLibrary ("libgpg-error-0.dll"); - if (handle) - { - void *foo, *bar; - foo = GetProcAddress (handle, "gpg_strerror_r"); - bar = GetProcAddress (handle, "gpg_strsource"); - if (foo && bar) - { - my_strerror_r = foo; - my_strsource = bar; - } - else - CloseHandle (handle); - } - initialized = 1; - return 0; -} - -int -_assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen) -{ - if (load_libgpg_error ()) - return -1; - return my_strerror_r (err, buf, buflen); -} - - -const char * -_assuan_gpg_strsource (unsigned int err) -{ - if (load_libgpg_error ()) - return NULL; - return my_strsource (err); -} -#endif /*HAVE_W32_SYSTEM*/ diff --git a/assuan/src/assuan-pipe-connect.c b/assuan/src/assuan-pipe-connect.c deleted file mode 100644 index 05a3be98..00000000 --- a/assuan/src/assuan-pipe-connect.c +++ /dev/null @@ -1,894 +0,0 @@ -/* assuan-pipe-connect.c - Establish a pipe connection (client) - * Copyright (C) 2001, 2002, 2003, 2005, 2006, - * 2007 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef HAVE_W32_SYSTEM -#include -#else -#include -#endif - -#include "assuan-defs.h" - -/* Hacks for Slowaris. */ -#ifndef PF_LOCAL -# ifdef PF_UNIX -# define PF_LOCAL PF_UNIX -# else -# define PF_LOCAL AF_UNIX -# endif -#endif -#ifndef AF_LOCAL -# define AF_LOCAL AF_UNIX -#endif - - -#ifdef _POSIX_OPEN_MAX -#define MAX_OPEN_FDS _POSIX_OPEN_MAX -#else -#define MAX_OPEN_FDS 20 -#endif - - -/* This should be called to make sure that SIGPIPE gets ignored. */ -static void -fix_signals (void) -{ -#ifndef _ASSUAN_NO_FIXED_SIGNALS -#ifndef HAVE_DOSISH_SYSTEM /* No SIGPIPE for these systems. */ - static int fixed_signals; - - if (!fixed_signals) - { - struct sigaction act; - - sigaction (SIGPIPE, NULL, &act); - if (act.sa_handler == SIG_DFL) - { - act.sa_handler = SIG_IGN; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; - sigaction (SIGPIPE, &act, NULL); - } - fixed_signals = 1; - /* FIXME: This is not MT safe */ - } -#endif /*HAVE_DOSISH_SYSTEM*/ -#endif /*!_ASSUAN_NO_FIXED_SIGNALS*/ -} - - -#ifndef HAVE_W32_SYSTEM -static int -writen (int fd, const char *buffer, size_t length) -{ - while (length) - { - int nwritten = write (fd, buffer, length); - - if (nwritten < 0) - { - if (errno == EINTR) - continue; - return -1; /* write error */ - } - length -= nwritten; - buffer += nwritten; - } - return 0; /* okay */ -} -#endif - -static int -do_finish (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx->inbound.fd); - if (ctx->inbound.fd == ctx->outbound.fd) - ctx->outbound.fd = ASSUAN_INVALID_FD; - ctx->inbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->outbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx->outbound.fd); - ctx->outbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->pid != (pid_t)(-1) && ctx->pid) - { -#ifndef HAVE_W32_SYSTEM -#ifndef _ASSUAN_USE_DOUBLE_FORK - if (!ctx->flags.no_waitpid) - _assuan_waitpid (ctx->pid, NULL, 0); - ctx->pid =(pid_t)(-1); -#endif -#else /*!HAVE_W32_SYSTEM*/ - CloseHandle ((HANDLE) ctx->pid); - ctx->pid = (pid_t) INVALID_HANDLE_VALUE; -#endif /*HAVE_W32_SYSTEM*/ - } - return 0; -} - - -static void -do_deinit (assuan_context_t ctx) -{ - do_finish (ctx); -} - - -/* Helper for pipe_connect. */ -static assuan_error_t -initial_handshake (assuan_context_t *ctx) -{ - int okay, off; - assuan_error_t err; - - err = _assuan_read_from_server (*ctx, &okay, &off); - if (err) - _assuan_log_printf ("can't connect server: %s\n", - assuan_strerror (err)); - else if (okay != 1) - { - _assuan_log_printf ("can't connect server: `%s'\n", - (*ctx)->inbound.line); - err = _assuan_error (ASSUAN_Connect_Failed); - } - - if (err) - { - assuan_disconnect (*ctx); - *ctx = NULL; - } - return err; -} - - -#ifndef HAVE_W32_SYSTEM -#define pipe_connect pipe_connect_unix -/* Unix version of the pipe connection code. We use an extra macro to - make ChangeLog entries easier. */ -static assuan_error_t -pipe_connect_unix (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue, unsigned int flags) -{ - assuan_error_t err; - int rp[2]; - int wp[2]; - char mypidstr[50]; - - (void)flags; - - if (!ctx || !name || !argv || !argv[0]) - return _assuan_error (ASSUAN_Invalid_Value); - - fix_signals (); - - sprintf (mypidstr, "%lu", (unsigned long)getpid ()); - - if (pipe (rp) < 0) - return _assuan_error (ASSUAN_General_Error); - - if (pipe (wp) < 0) - { - close (rp[0]); - close (rp[1]); - return _assuan_error (ASSUAN_General_Error); - } - - err = _assuan_new_context (ctx); - if (err) - { - close (rp[0]); - close (rp[1]); - close (wp[0]); - close (wp[1]); - return err; - } - (*ctx)->pipe_mode = 1; - (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ - (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ - (*ctx)->deinit_handler = do_deinit; - (*ctx)->finish_handler = do_finish; - - /* FIXME: For GPGME we should better use _gpgme_io_spawn. The PID - stored here is actually soon useless. */ - (*ctx)->pid = fork (); - if ((*ctx)->pid < 0) - { - close (rp[0]); - close (rp[1]); - close (wp[0]); - close (wp[1]); - _assuan_release_context (*ctx); - return _assuan_error (ASSUAN_General_Error); - } - - if ((*ctx)->pid == 0) - { -#ifdef _ASSUAN_USE_DOUBLE_FORK - pid_t pid; - - if ((pid = fork ()) == 0) -#endif - { - int i, n; - char errbuf[512]; - int *fdp; - - if (atfork) - atfork (atforkvalue, 0); - - /* Dup handles to stdin/stdout. */ - if (rp[1] != STDOUT_FILENO) - { - if (dup2 (rp[1], STDOUT_FILENO) == -1) - { - _assuan_log_printf ("dup2 failed in child: %s\n", - strerror (errno)); - _exit (4); - } - } - if (wp[0] != STDIN_FILENO) - { - if (dup2 (wp[0], STDIN_FILENO) == -1) - { - _assuan_log_printf ("dup2 failed in child: %s\n", - strerror (errno)); - _exit (4); - } - } - - /* Dup stderr to /dev/null unless it is in the list of FDs to be - passed to the child. */ - fdp = fd_child_list; - if (fdp) - { - for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) - ; - } - if (!fdp || *fdp == -1) - { - int fd = open ("/dev/null", O_WRONLY); - if (fd == -1) - { - _assuan_log_printf ("can't open `/dev/null': %s\n", - strerror (errno)); - _exit (4); - } - if (dup2 (fd, STDERR_FILENO) == -1) - { - _assuan_log_printf ("dup2(dev/null, 2) failed: %s\n", - strerror (errno)); - _exit (4); - } - } - - - /* Close all files which will not be duped and are not in the - fd_child_list. */ - n = sysconf (_SC_OPEN_MAX); - if (n < 0) - n = MAX_OPEN_FDS; - for (i=0; i < n; i++) - { - if ( i == STDIN_FILENO || i == STDOUT_FILENO - || i == STDERR_FILENO) - continue; - fdp = fd_child_list; - if (fdp) - { - while (*fdp != -1 && *fdp != i) - fdp++; - } - - if (!(fdp && *fdp != -1)) - close(i); - } - errno = 0; - - /* We store our parents pid in the environment so that the - execed assuan server is able to read the actual pid of the - client. The server can't use getppid because it might have - been double forked before the assuan server has been - initialized. */ - setenv ("_assuan_pipe_connect_pid", mypidstr, 1); - - /* Make sure that we never pass a connection fd variable - when using a simple pipe. */ - unsetenv ("_assuan_connection_fd"); - - execv (name, (char *const *) argv); - /* oops - use the pipe to tell the parent about it */ - snprintf (errbuf, sizeof(errbuf)-1, - "ERR %d can't exec `%s': %.50s\n", - _assuan_error (ASSUAN_Problem_Starting_Server), - name, strerror (errno)); - errbuf[sizeof(errbuf)-1] = 0; - writen (1, errbuf, strlen (errbuf)); - _exit (4); - } -#ifdef _ASSUAN_USE_DOUBLE_FORK - if (pid == -1) - _exit (1); - else - _exit (0); -#endif - } - -#ifdef _ASSUAN_USE_DOUBLE_FORK - _assuan_waitpid ((*ctx)->pid, NULL, 0); - (*ctx)->pid = -1; -#endif - - close (rp[1]); - close (wp[0]); - - return initial_handshake (ctx); -} -#endif /*!HAVE_W32_SYSTEM*/ - - -#ifndef HAVE_W32_SYSTEM -/* This function is similar to pipe_connect but uses a socketpair and - sets the I/O up to use sendmsg/recvmsg. */ -static assuan_error_t -socketpair_connect (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue) -{ - assuan_error_t err; - int fds[2]; - char mypidstr[50]; - - if (!ctx - || (name && (!argv || !argv[0])) - || (!name && argv)) - return _assuan_error (ASSUAN_Invalid_Value); - - fix_signals (); - - sprintf (mypidstr, "%lu", (unsigned long)getpid ()); - - if ( socketpair (AF_LOCAL, SOCK_STREAM, 0, fds) ) - { - _assuan_log_printf ("socketpair failed: %s\n", strerror (errno)); - return _assuan_error (ASSUAN_General_Error); - } - - err = _assuan_new_context (ctx); - if (err) - { - close (fds[0]); - close (fds[1]); - return err; - } - (*ctx)->pipe_mode = 1; - (*ctx)->inbound.fd = fds[0]; - (*ctx)->outbound.fd = fds[0]; - _assuan_init_uds_io (*ctx); - (*ctx)->deinit_handler = _assuan_uds_deinit; - (*ctx)->finish_handler = do_finish; - - (*ctx)->pid = fork (); - if ((*ctx)->pid < 0) - { - close (fds[0]); - close (fds[1]); - _assuan_release_context (*ctx); - *ctx = NULL; - return _assuan_error (ASSUAN_General_Error); - } - - if ((*ctx)->pid == 0) - { -#ifdef _ASSUAN_USE_DOUBLE_FORK - pid_t pid; - - if ((pid = fork ()) == 0) -#endif - { - int fd, i, n; - char errbuf[512]; - int *fdp; - - if (atfork) - atfork (atforkvalue, 0); - - /* Connect stdin and stdout to /dev/null. */ - fd = open ("/dev/null", O_RDONLY); - if (fd == -1 || dup2 (fd, STDIN_FILENO) == -1) - { - _assuan_log_printf ("dup2(dev/null) failed: %s\n", - strerror (errno)); - _exit (4); - } - fd = open ("/dev/null", O_WRONLY); - if (fd == -1 || dup2 (fd, STDOUT_FILENO) == -1) - { - _assuan_log_printf ("dup2(dev/null) failed: %s\n", - strerror (errno)); - _exit (4); - } - - /* Dup stderr to /dev/null unless it is in the list of FDs to be - passed to the child. */ - fdp = fd_child_list; - if (fdp) - { - for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) - ; - } - if (!fdp || *fdp == -1) - { - fd = open ("/dev/null", O_WRONLY); - if (fd == -1 || dup2 (fd, STDERR_FILENO) == -1) - { - _assuan_log_printf ("dup2(dev/null) failed: %s\n", - strerror (errno)); - _exit (4); - } - } - - - /* Close all files which will not be duped, are not in the - fd_child_list and are not the connection fd. */ - n = sysconf (_SC_OPEN_MAX); - if (n < 0) - n = MAX_OPEN_FDS; - for (i=0; i < n; i++) - { - if ( i == STDIN_FILENO || i == STDOUT_FILENO - || i == STDERR_FILENO || i == fds[1]) - continue; - fdp = fd_child_list; - if (fdp) - { - while (*fdp != -1 && *fdp != i) - fdp++; - } - - if (!(fdp && *fdp != -1)) - close(i); - } - errno = 0; - - /* We store our parents pid in the environment so that the - execed assuan server is able to read the actual pid of the - client. The server can't use getppid becuase it might have - been double forked before the assuan server has been - initialized. */ - setenv ("_assuan_pipe_connect_pid", mypidstr, 1); - - /* Now set the environment variable used to convey the - connection's file descriptor. */ - sprintf (mypidstr, "%d", fds[1]); - if (setenv ("_assuan_connection_fd", mypidstr, 1)) - { - _assuan_log_printf ("setenv failed: %s\n", strerror (errno)); - _exit (4); - } - - if (!name && !argv) - { - /* No name and no args given, thus we don't do an exec - but continue the forked process. */ - _assuan_release_context (*ctx); - *ctx = NULL; - return 0; - } - - execv (name, (char *const *) argv); - /* oops - use the pipe to tell the parent about it */ - snprintf (errbuf, sizeof(errbuf)-1, - "ERR %d can't exec `%s': %.50s\n", - _assuan_error (ASSUAN_Problem_Starting_Server), - name, strerror (errno)); - errbuf[sizeof(errbuf)-1] = 0; - writen (fds[1], errbuf, strlen (errbuf)); - _exit (4); - } -#ifdef _ASSUAN_USE_DOUBLE_FORK - if (pid == -1) - _exit (1); - else - _exit (0); -#endif - } - - -#ifdef _ASSUAN_USE_DOUBLE_FORK - _assuan_waitpid ((*ctx)->pid, NULL, 0); - (*ctx)->pid = -1; -#endif - - close (fds[1]); - - return initial_handshake (ctx); -} -#endif /*!HAVE_W32_SYSTEM*/ - - - -#ifdef HAVE_W32_SYSTEM -/* Build a command line for use with W32's CreateProcess. On success - CMDLINE gets the address of a newly allocated string. */ -static int -build_w32_commandline (const char * const *argv, char **cmdline) -{ - int i, n; - const char *s; - char *buf, *p; - - *cmdline = NULL; - n = 0; - for (i=0; (s=argv[i]); i++) - { - n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */ - for (; *s; s++) - if (*s == '\"') - n++; /* Need to double inner quotes. */ - } - n++; - - buf = p = xtrymalloc (n); - if (!buf) - return -1; - - for (i=0; argv[i]; i++) - { - if (i) - p = stpcpy (p, " "); - if (!*argv[i]) /* Empty string. */ - p = stpcpy (p, "\"\""); - else if (strpbrk (argv[i], " \t\n\v\f\"")) - { - p = stpcpy (p, "\""); - for (s=argv[i]; *s; s++) - { - *p++ = *s; - if (*s == '\"') - *p++ = *s; - } - *p++ = '\"'; - *p = 0; - } - else - p = stpcpy (p, argv[i]); - } - - *cmdline= buf; - return 0; -} -#endif /*HAVE_W32_SYSTEM*/ - - -#ifdef HAVE_W32_SYSTEM -/* Create pipe where one end end is inheritable. */ -static int -create_inheritable_pipe (assuan_fd_t filedes[2], int for_write) -{ - HANDLE r, w, h; - SECURITY_ATTRIBUTES sec_attr; - - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - if (!CreatePipe (&r, &w, &sec_attr, 0)) - { - _assuan_log_printf ("CreatePipe failed: %s\n", w32_strerror (-1)); - return -1; - } - - if (!DuplicateHandle (GetCurrentProcess(), for_write? r : w, - GetCurrentProcess(), &h, 0, - TRUE, DUPLICATE_SAME_ACCESS )) - { - _assuan_log_printf ("DuplicateHandle failed: %s\n", w32_strerror (-1)); - CloseHandle (r); - CloseHandle (w); - return -1; - } - if (for_write) - { - CloseHandle (r); - r = h; - } - else - { - CloseHandle (w); - w = h; - } - - filedes[0] = r; - filedes[1] = w; - return 0; -} -#endif /*HAVE_W32_SYSTEM*/ - - -#ifdef HAVE_W32_SYSTEM -#define pipe_connect pipe_connect_w32 -/* W32 version of the pipe connection code. */ -static assuan_error_t -pipe_connect_w32 (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue, unsigned int flags) -{ - assuan_error_t err; - assuan_fd_t rp[2]; - assuan_fd_t wp[2]; - char mypidstr[50]; - char *cmdline; - SECURITY_ATTRIBUTES sec_attr; - PROCESS_INFORMATION pi = - { - NULL, /* Returns process handle. */ - 0, /* Returns primary thread handle. */ - 0, /* Returns pid. */ - 0 /* Returns tid. */ - }; - STARTUPINFO si; - int fd, *fdp; - HANDLE nullfd = INVALID_HANDLE_VALUE; - - if (!ctx || !name || !argv || !argv[0]) - return _assuan_error (ASSUAN_Invalid_Value); - - fix_signals (); - - sprintf (mypidstr, "%lu", (unsigned long)getpid ()); - - /* Build the command line. */ - if (build_w32_commandline (argv, &cmdline)) - return _assuan_error (ASSUAN_Out_Of_Core); - - /* Create thew two pipes. */ - if (create_inheritable_pipe (rp, 0)) - { - xfree (cmdline); - return _assuan_error (ASSUAN_General_Error); - } - - if (create_inheritable_pipe (wp, 1)) - { - CloseHandle (rp[0]); - CloseHandle (rp[1]); - xfree (cmdline); - return _assuan_error (ASSUAN_General_Error); - } - - - err = _assuan_new_context (ctx); - if (err) - { - CloseHandle (rp[0]); - CloseHandle (rp[1]); - CloseHandle (wp[0]); - CloseHandle (wp[1]); - xfree (cmdline); - return _assuan_error (ASSUAN_General_Error); - } - - (*ctx)->pipe_mode = 1; - (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ - (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ - (*ctx)->deinit_handler = do_deinit; - (*ctx)->finish_handler = do_finish; - - - /* fixme: Actually we should set the "_assuan_pipe_connect_pid" env - variable. However this requires us to write a full environment - handler, because the strings are expected in sorted order. The - suggestion given in the MS Reference Library, to save the old - value, changeit, create proces and restore it, is not thread - safe. */ - - /* Start the process. */ - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - memset (&si, 0, sizeof si); - si.cb = sizeof (si); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = wp[0]; - si.hStdOutput = rp[1]; - - /* Dup stderr to /dev/null unless it is in the list of FDs to be - passed to the child. */ - fd = fileno (stderr); - fdp = fd_child_list; - if (fdp) - { - for (; *fdp != -1 && *fdp != fd; fdp++) - ; - } - if (!fdp || *fdp == -1) - { - nullfd = CreateFile ("nul", GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, NULL); - if (nullfd == INVALID_HANDLE_VALUE) - { - _assuan_log_printf ("can't open `nul': %s\n", w32_strerror (-1)); - CloseHandle (rp[0]); - CloseHandle (rp[1]); - CloseHandle (wp[0]); - CloseHandle (wp[1]); - xfree (cmdline); - _assuan_release_context (*ctx); - return -1; - } - si.hStdError = nullfd; - } - else - si.hStdError = (void*)_get_osfhandle (fd); - - - /* Note: We inherit all handles flagged as inheritable. This seems - to be a security flaw but there seems to be no way of selecting - handles to inherit. */ - /* _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */ - /* name, cmdline); */ - if (!CreateProcess (name, /* Program to start. */ - cmdline, /* Command line arguments. */ - &sec_attr, /* Process security attributes. */ - &sec_attr, /* Thread security attributes. */ - TRUE, /* Inherit handles. */ - (CREATE_DEFAULT_ERROR_MODE - | ((flags & 128)? DETACHED_PROCESS : 0) - | GetPriorityClass (GetCurrentProcess ()) - | CREATE_SUSPENDED), /* Creation flags. */ - NULL, /* Environment. */ - NULL, /* Use current drive/directory. */ - &si, /* Startup information. */ - &pi /* Returns process information. */ - )) - { - _assuan_log_printf ("CreateProcess failed: %s\n", w32_strerror (-1)); - CloseHandle (rp[0]); - CloseHandle (rp[1]); - CloseHandle (wp[0]); - CloseHandle (wp[1]); - if (nullfd != INVALID_HANDLE_VALUE) - CloseHandle (nullfd); - xfree (cmdline); - _assuan_release_context (*ctx); - return _assuan_error (ASSUAN_General_Error); - } - xfree (cmdline); - cmdline = NULL; - if (nullfd != INVALID_HANDLE_VALUE) - { - CloseHandle (nullfd); - nullfd = INVALID_HANDLE_VALUE; - } - - CloseHandle (rp[1]); - CloseHandle (wp[0]); - - /* _assuan_log_printf ("CreateProcess ready: hProcess=%p hThread=%p" */ - /* " dwProcessID=%d dwThreadId=%d\n", */ - /* pi.hProcess, pi.hThread, */ - /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ - - ResumeThread (pi.hThread); - CloseHandle (pi.hThread); - (*ctx)->pid = (pid_t) pi.hProcess; - - return initial_handshake (ctx); -} -#endif /*HAVE_W32_SYSTEM*/ - - -/* Connect to a server over a pipe, creating the assuan context and - returning it in CTX. The server filename is NAME, the argument - vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file - descriptors not to close in the child. */ -assuan_error_t -assuan_pipe_connect (assuan_context_t *ctx, const char *name, - const char *const argv[], int *fd_child_list) -{ - return pipe_connect (ctx, name, argv, fd_child_list, NULL, NULL, 0); -} - - - -assuan_error_t -assuan_pipe_connect2 (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue) -{ - return pipe_connect (ctx, name, argv, fd_child_list, atfork, atforkvalue, 0); -} - - -/* Connect to a server over a full-duplex socket (i.e. created by - socketpair), creating the assuan context and returning it in CTX. - The server filename is NAME, the argument vector in ARGV. - FD_CHILD_LIST is a -1 terminated list of file descriptors not to - close in the child. ATFORK is called in the child right after the - fork; ATFORKVALUE is passed as the first argument and 0 is passed - as the second argument. The ATFORK function should only act if the - second value is 0. - - FLAGS is a bit vector and controls how the function acts: - Bit 0: If cleared a simple pipe based server is expected and the - function behaves similar to `assuan_pipe_connect'. - - If set a server based on full-duplex pipes is expected. Such - pipes are usually created using the `socketpair' function. - It also enables features only available with such servers. - - Bit 7: If set and there is a need to start ther server it will be - started as a background process. This flag is useful under - W32 systems, so that no new console is created and pops up a - console window when starting the server - - - If NAME as well as ARGV are NULL, no exec is done but the same - process is continued. However all file descriptors are closed and - some special environment variables are set. To let the caller - detect whether the child or the parent continues, the child returns - a CTX of NULL. */ -assuan_error_t -assuan_pipe_connect_ext (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue, unsigned int flags) -{ - if ((flags & 1)) - { -#ifdef HAVE_W32_SYSTEM - return _assuan_error (ASSUAN_Not_Implemented); -#else - return socketpair_connect (ctx, name, argv, fd_child_list, - atfork, atforkvalue); -#endif - } - else - return pipe_connect (ctx, name, argv, fd_child_list, atfork, atforkvalue, - flags); -} - diff --git a/assuan/src/assuan-pipe-server.c b/assuan/src/assuan-pipe-server.c deleted file mode 100644 index 70404144..00000000 --- a/assuan/src/assuan-pipe-server.c +++ /dev/null @@ -1,189 +0,0 @@ -/* assuan-pipe-server.c - Assuan server working over a pipe - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -#include -#include -#endif - -#include "assuan-defs.h" - - -static void -deinit_pipe_server (assuan_context_t ctx) -{ - /* nothing to do for this simple server */ -} - -static int -accept_connection (assuan_context_t ctx) -{ - /* This is a NOP for a pipe server */ - return 0; -} - -static int -finish_connection (assuan_context_t ctx) -{ - /* This is a NOP for a pipe server */ - return 0; -} - -/* Create a new context. Note that the handlers are set up for a pipe - server/client - this way we don't need extra dummy functions */ -int -_assuan_new_context (assuan_context_t *r_ctx) -{ - static struct assuan_io io = { _assuan_simple_read, - _assuan_simple_write, - 0, 0 }; - - assuan_context_t ctx; - int rc; - - *r_ctx = NULL; - ctx = xtrycalloc (1, sizeof *ctx); - if (!ctx) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->input_fd = ASSUAN_INVALID_FD; - ctx->output_fd = ASSUAN_INVALID_FD; - - ctx->inbound.fd = ASSUAN_INVALID_FD; - ctx->outbound.fd = ASSUAN_INVALID_FD; - ctx->io = &io; - - ctx->listen_fd = ASSUAN_INVALID_FD; - /* Use the pipe server handler as a default. */ - ctx->deinit_handler = deinit_pipe_server; - ctx->accept_handler = accept_connection; - ctx->finish_handler = finish_connection; - - rc = _assuan_register_std_commands (ctx); - if (rc) - xfree (ctx); - else - *r_ctx = ctx; - return rc; -} - - -/* Returns true if atoi(S) denotes a valid socket. */ -#ifndef HAVE_W32_SYSTEM -static int -is_valid_socket (const char *s) -{ - struct stat buf; - - if ( fstat (atoi (s), &buf ) ) - return 0; - return S_ISSOCK (buf.st_mode); -} -#endif /*!HAVE_W32_SYSTEM*/ - - -int -assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]) -{ - int rc; - - rc = _assuan_new_context (r_ctx); - if (!rc) - { - assuan_context_t ctx = *r_ctx; - const char *s; - unsigned long ul; - - ctx->is_server = 1; -#ifdef HAVE_W32_SYSTEM - /* MS Windows has so many different types of handle that one - needs to tranlsate them at many place forth and back. Also - make sure that the file descriptors are in binary mode. */ - setmode (filedes[0], O_BINARY); - setmode (filedes[1], O_BINARY); - ctx->inbound.fd = (void*)_get_osfhandle (filedes[0]); - ctx->outbound.fd = (void*)_get_osfhandle (filedes[1]); -#else - s = getenv ("_assuan_connection_fd"); - if (s && *s && is_valid_socket (s) ) - { - /* Well, we are called with an bi-directional file - descriptor. Prepare for using sendmsg/recvmsg. In this - case we ignore the passed file descriptors. */ - ctx->inbound.fd = ctx->outbound.fd = atoi (s); - _assuan_init_uds_io (ctx); - ctx->deinit_handler = _assuan_uds_deinit; - } - else if (filedes && filedes[0] != ASSUAN_INVALID_FD - && filedes[1] != ASSUAN_INVALID_FD ) - { - /* Standard pipe server. */ - ctx->inbound.fd = filedes[0]; - ctx->outbound.fd = filedes[1]; - } - else - { - _assuan_release_context (*r_ctx); - *r_ctx = NULL; - return ASSUAN_Problem_Starting_Server; - } -#endif - ctx->pipe_mode = 1; - - s = getenv ("_assuan_pipe_connect_pid"); - if (s && (ul=strtoul (s, NULL, 10)) && ul) - ctx->pid = (pid_t)ul; - else - ctx->pid = (pid_t)-1; - - } - return rc; -} - - -void -_assuan_release_context (assuan_context_t ctx) -{ - if (ctx) - { - _assuan_inquire_release (ctx); - xfree (ctx->hello_line); - xfree (ctx->okay_line); - xfree (ctx->cmdtbl); - xfree (ctx); - } -} - -void -assuan_deinit_server (assuan_context_t ctx) -{ - if (ctx) - { - /* We use this function pointer to avoid linking other server - when not needed but still allow for a generic deinit function. */ - ctx->deinit_handler (ctx); - ctx->deinit_handler = NULL; - _assuan_release_context (ctx); - } -} diff --git a/assuan/src/assuan-socket-connect.c b/assuan/src/assuan-socket-connect.c deleted file mode 100644 index 8eb6d828..00000000 --- a/assuan/src/assuan-socket-connect.c +++ /dev/null @@ -1,180 +0,0 @@ -/* assuan-socket-connect.c - Assuan socket based client - * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef HAVE_W32_SYSTEM -#include -#include -#else -#include -#endif - -#include "assuan-defs.h" - -/* Hacks for Slowaris. */ -#ifndef PF_LOCAL -# ifdef PF_UNIX -# define PF_LOCAL PF_UNIX -# else -# define PF_LOCAL AF_UNIX -# endif -#endif -#ifndef AF_LOCAL -# define AF_LOCAL AF_UNIX -#endif - -#ifndef SUN_LEN -# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ - + strlen ((ptr)->sun_path)) -#endif - - -static int -do_finish (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx->inbound.fd); - } - ctx->inbound.fd = ASSUAN_INVALID_FD; - ctx->outbound.fd = ASSUAN_INVALID_FD; - return 0; -} - -static void -do_deinit (assuan_context_t ctx) -{ - do_finish (ctx); -} - - -/* Make a connection to the Unix domain socket NAME and return a new - Assuan context in CTX. SERVER_PID is currently not used but may - become handy in the future. */ -assuan_error_t -assuan_socket_connect (assuan_context_t *r_ctx, - const char *name, pid_t server_pid) -{ - return assuan_socket_connect_ext (r_ctx, name, server_pid, 0); -} - - -/* Make a connection to the Unix domain socket NAME and return a new - Assuan context in CTX. SERVER_PID is currently not used but may - become handy in the future. With flags set to 1 sendmsg and - recvmsg are used. */ -assuan_error_t -assuan_socket_connect_ext (assuan_context_t *r_ctx, - const char *name, pid_t server_pid, - unsigned int flags) -{ - static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write, - NULL, NULL }; - assuan_error_t err; - assuan_context_t ctx; - assuan_fd_t fd; - struct sockaddr_un srvr_addr; - size_t len; - const char *s; - - if (!r_ctx || !name) - return _assuan_error (ASSUAN_Invalid_Value); - *r_ctx = NULL; - - /* We require that the name starts with a slash, so that we - eventually can reuse this function for other socket types. To - make things easier we allow an optional driver prefix. */ - s = name; - if (*s && s[1] == ':') - s += 2; - if (*s != DIRSEP_C && *s != '/') - return _assuan_error (ASSUAN_Invalid_Value); - - if (strlen (name)+1 >= sizeof srvr_addr.sun_path) - return _assuan_error (ASSUAN_Invalid_Value); - - err = _assuan_new_context (&ctx); - if (err) - return err; - ctx->deinit_handler = ((flags&1))? _assuan_uds_deinit : do_deinit; - ctx->finish_handler = do_finish; - - fd = _assuan_sock_new (PF_LOCAL, SOCK_STREAM, 0); - if (fd == ASSUAN_INVALID_FD) - { - _assuan_log_printf ("can't create socket: %s\n", strerror (errno)); - _assuan_release_context (ctx); - return _assuan_error (ASSUAN_General_Error); - } - - memset (&srvr_addr, 0, sizeof srvr_addr); - srvr_addr.sun_family = AF_LOCAL; - strncpy (srvr_addr.sun_path, name, sizeof (srvr_addr.sun_path) - 1); - srvr_addr.sun_path[sizeof (srvr_addr.sun_path) - 1] = 0; - len = SUN_LEN (&srvr_addr); - - if ( _assuan_sock_connect (fd, (struct sockaddr *) &srvr_addr, len) == -1 ) - { - _assuan_log_printf ("can't connect to `%s': %s\n", - name, strerror (errno)); - _assuan_release_context (ctx); - _assuan_close (fd); - return _assuan_error (ASSUAN_Connect_Failed); - } - - ctx->inbound.fd = fd; - ctx->outbound.fd = fd; - ctx->io = &io; - if ((flags&1)) - _assuan_init_uds_io (ctx); - - /* initial handshake */ - { - int okay, off; - - err = _assuan_read_from_server (ctx, &okay, &off); - if (err) - _assuan_log_printf ("can't connect to server: %s\n", - assuan_strerror (err)); - else if (okay != 1) - { - /*LOG ("can't connect to server: `");*/ - _assuan_log_sanitized_string (ctx->inbound.line); - fprintf (assuan_get_assuan_log_stream (), "'\n"); - err = _assuan_error (ASSUAN_Connect_Failed); - } - } - - if (err) - { - assuan_disconnect (ctx); - } - else - *r_ctx = ctx; - return 0; -} - - diff --git a/assuan/src/assuan-socket-server.c b/assuan/src/assuan-socket-server.c deleted file mode 100644 index c536dba4..00000000 --- a/assuan/src/assuan-socket-server.c +++ /dev/null @@ -1,208 +0,0 @@ -/* assuan-socket-server.c - Assuan socket based server - * Copyright (C) 2002, 2007 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -# include -# if HAVE_SYS_SOCKET_H -# include -# elif HAVE_WS2TCPIP_H -# include -# endif -#else -# include -# include -#endif - - -#include "assuan-defs.h" - -static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write, - NULL, NULL }; - -static int -accept_connection_bottom (assuan_context_t ctx) -{ - assuan_fd_t fd = ctx->connected_fd; - - ctx->peercred.valid = 0; -#ifdef HAVE_SO_PEERCRED - { - struct ucred cr; - socklen_t cl = sizeof cr; - - if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl)) - { - ctx->peercred.pid = cr.pid; - ctx->peercred.uid = cr.uid; - ctx->peercred.gid = cr.gid; - ctx->peercred.valid = 1; - - /* This overrides any already set PID if the function returns - a valid one. */ - if (cr.pid != (pid_t)-1 && cr.pid) - ctx->pid = cr.pid; - } - } -#endif - - ctx->inbound.fd = fd; - ctx->inbound.eof = 0; - ctx->inbound.linelen = 0; - ctx->inbound.attic.linelen = 0; - ctx->inbound.attic.pending = 0; - - ctx->outbound.fd = fd; - ctx->outbound.data.linelen = 0; - ctx->outbound.data.error = 0; - - ctx->confidential = 0; - - return 0; -} - - -static int -accept_connection (assuan_context_t ctx) -{ - assuan_fd_t fd; - struct sockaddr_un clnt_addr; - socklen_t len = sizeof clnt_addr; - - fd = SOCKET2HANDLE(accept (HANDLE2SOCKET(ctx->listen_fd), - (struct sockaddr*)&clnt_addr, &len )); - if (fd == ASSUAN_INVALID_FD) - { - ctx->os_errno = errno; - return _assuan_error (ASSUAN_Accept_Failed); - } - if (_assuan_sock_check_nonce (fd, &ctx->listen_nonce)) - { - _assuan_close (fd); - ctx->os_errno = EACCES; - return _assuan_error (ASSUAN_Accept_Failed); - } - - ctx->connected_fd = fd; - return accept_connection_bottom (ctx); -} - -static int -finish_connection (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx->inbound.fd); - } - ctx->inbound.fd = ASSUAN_INVALID_FD; - ctx->outbound.fd = ASSUAN_INVALID_FD; - return 0; -} - - -static void -deinit_socket_server (assuan_context_t ctx) -{ - finish_connection (ctx); -} - -/* Initialize a server for the socket LISTEN_FD which has already be - put into listen mode */ -int -assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd) -{ - return assuan_init_socket_server_ext (r_ctx, listen_fd, 0); -} - -/* Initialize a server using the already accepted socket FD. This - function is deprecated. */ -int -assuan_init_connected_socket_server (assuan_context_t *r_ctx, assuan_fd_t fd) -{ - return assuan_init_socket_server_ext (r_ctx, fd, 2); -} - - -/* - Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing - 1 - FD has already been accepted. -*/ -int -assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, - unsigned int flags) -{ - assuan_context_t ctx; - int rc; - - *r_ctx = NULL; - ctx = xtrycalloc (1, sizeof *ctx); - if (!ctx) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->is_server = 1; - if ((flags & 2)) - ctx->pipe_mode = 1; /* We want a second accept to indicate EOF. */ - ctx->input_fd = ASSUAN_INVALID_FD; - ctx->output_fd = ASSUAN_INVALID_FD; - - ctx->inbound.fd = ASSUAN_INVALID_FD; - ctx->outbound.fd = ASSUAN_INVALID_FD; - - if ((flags & 2)) - { - ctx->listen_fd = ASSUAN_INVALID_FD; - ctx->connected_fd = fd; - } - else - { - ctx->listen_fd = fd; - ctx->connected_fd = ASSUAN_INVALID_FD; - } - ctx->deinit_handler = (flags & 1)? _assuan_uds_deinit:deinit_socket_server; - ctx->accept_handler = ((flags & 2) - ? accept_connection_bottom - : accept_connection); - ctx->finish_handler = finish_connection; - - ctx->io = &io; - if ((flags & 1)) - _assuan_init_uds_io (ctx); - - rc = _assuan_register_std_commands (ctx); - if (rc) - xfree (ctx); - else - *r_ctx = ctx; - return rc; -} - - -/* Save a copy of NONCE in context CTX. This should be used to - register the server's nonce with an context established by - assuan_init_socket_server. */ -void -assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce) -{ - if (ctx && nonce) - ctx->listen_nonce = *nonce; -} diff --git a/assuan/src/assuan-socket.c b/assuan/src/assuan-socket.c deleted file mode 100644 index 044b1f1c..00000000 --- a/assuan/src/assuan-socket.c +++ /dev/null @@ -1,439 +0,0 @@ -/* assuan-socket.c - * Copyright (C) 2004, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#else -#include -#include -#endif -#include -#include -#include -#include - -#include "assuan-defs.h" - -/* Hacks for Slowaris. */ -#ifndef PF_LOCAL -# ifdef PF_UNIX -# define PF_LOCAL PF_UNIX -# else -# define PF_LOCAL AF_UNIX -# endif -#endif -#ifndef AF_LOCAL -# define AF_LOCAL AF_UNIX -#endif - -#ifdef HAVE_W32_SYSTEM -#ifndef S_IRGRP -# define S_IRGRP 0 -# define S_IWGRP 0 -#endif -#endif - - -#ifdef HAVE_W32_SYSTEM -int -_assuan_sock_wsa2errno (int err) -{ - switch (err) - { - case WSAENOTSOCK: - return EINVAL; - case WSAEWOULDBLOCK: - return EAGAIN; - case ERROR_BROKEN_PIPE: - return EPIPE; - case WSANOTINITIALISED: - return ENOSYS; - default: - return EIO; - } -} - - -/* W32: Fill BUFFER with LENGTH bytes of random. Returns -1 on - failure, 0 on success. Sets errno on failure. */ -static int -get_nonce (char *buffer, size_t nbytes) -{ - HCRYPTPROV prov; - int ret = -1; - - if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL, - (CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) ) - errno = ENODEV; - else - { - if (!CryptGenRandom (prov, nbytes, buffer)) - errno = ENODEV; - else - ret = 0; - CryptReleaseContext (prov, 0); - } - return ret; -} - - -/* W32: The buffer for NONCE needs to be at least 16 bytes. Returns 0 on - success and sets errno on failure. */ -static int -read_port_and_nonce (const char *fname, unsigned short *port, char *nonce) -{ - FILE *fp; - char buffer[50], *p; - size_t nread; - int aval; - - fp = fopen (fname, "rb"); - if (!fp) - return -1; - nread = fread (buffer, 1, sizeof buffer - 1, fp); - fclose (fp); - if (!nread) - { - errno = ENOFILE; - return -1; - } - buffer[nread] = 0; - aval = atoi (buffer); - if (aval < 1 || aval > 65535) - { - errno = EINVAL; - return -1; - } - *port = (unsigned int)aval; - for (p=buffer; nread && *p != '\n'; p++, nread--) - ; - if (*p != '\n' || nread != 17) - { - errno = EINVAL; - return -1; - } - p++; nread--; - memcpy (nonce, p, 16); - return 0; -} -#endif /*HAVE_W32_SYSTEM*/ - - - -int -_assuan_close (assuan_fd_t fd) -{ -#ifdef HAVE_W32_SYSTEM - int rc = closesocket (HANDLE2SOCKET(fd)); - if (rc) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - if (rc && WSAGetLastError () == WSAENOTSOCK) - { - rc = CloseHandle (fd); - if (rc) - /* FIXME. */ - errno = EIO; - } - return rc; -#else - return close (fd); -#endif -} - - -/* Return a new socket. Note that under W32 we consider a socket the - same as an System Handle; all functions using such a handle know - about this dual use and act accordingly. */ -assuan_fd_t -_assuan_sock_new (int domain, int type, int proto) -{ -#ifdef HAVE_W32_SYSTEM - assuan_fd_t res; - if (domain == AF_UNIX || domain == AF_LOCAL) - domain = AF_INET; - res = SOCKET2HANDLE(socket (domain, type, proto)); - if (res == ASSUAN_INVALID_FD) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - return res; -#else - return socket (domain, type, proto); -#endif -} - - -int -_assuan_sock_connect (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen) -{ -#ifdef HAVE_W32_SYSTEM - if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) - { - struct sockaddr_in myaddr; - struct sockaddr_un *unaddr; - unsigned short port; - char nonce[16]; - int ret; - - unaddr = (struct sockaddr_un *)addr; - if (read_port_and_nonce (unaddr->sun_path, &port, nonce)) - return -1; - - myaddr.sin_family = AF_INET; - myaddr.sin_port = htons (port); - myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - /* Set return values. */ - unaddr->sun_family = myaddr.sin_family; - unaddr->sun_port = myaddr.sin_port; - unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr; - - ret = connect (HANDLE2SOCKET(sockfd), - (struct sockaddr *)&myaddr, sizeof myaddr); - if (!ret) - { - /* Send the nonce. */ - ret = _assuan_io_write (sockfd, nonce, 16); - if (ret >= 0 && ret != 16) - { - errno = EIO; - ret = -1; - } - } - return ret; - } - else - { - int res; - res = connect (HANDLE2SOCKET (sockfd), addr, addrlen); - if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - return res; - } -#else - return connect (sockfd, addr, addrlen); -#endif -} - - -int -_assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen) -{ -#ifdef HAVE_W32_SYSTEM - if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) - { - struct sockaddr_in myaddr; - struct sockaddr_un *unaddr; - int filefd; - FILE *fp; - int len = sizeof myaddr; - int rc; - char nonce[16]; - - if (get_nonce (nonce, 16)) - return -1; - - unaddr = (struct sockaddr_un *)addr; - - myaddr.sin_port = 0; - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - filefd = open (unaddr->sun_path, - (O_WRONLY|O_CREAT|O_EXCL|O_BINARY), - (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)); - if (filefd == -1) - { - if (errno == EEXIST) - errno = WSAEADDRINUSE; - return -1; - } - fp = fdopen (filefd, "wb"); - if (!fp) - { - int save_e = errno; - close (filefd); - errno = save_e; - return -1; - } - - rc = bind (HANDLE2SOCKET (sockfd), (struct sockaddr *)&myaddr, len); - if (!rc) - rc = getsockname (HANDLE2SOCKET (sockfd), - (struct sockaddr *)&myaddr, &len); - if (rc) - { - int save_e = errno; - fclose (fp); - remove (unaddr->sun_path); - errno = save_e; - return rc; - } - fprintf (fp, "%d\n", ntohs (myaddr.sin_port)); - fwrite (nonce, 16, 1, fp); - fclose (fp); - - return 0; - } - else - { - int res = bind (HANDLE2SOCKET(sockfd), addr, addrlen); - if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - return res; - } -#else - return bind (sockfd, addr, addrlen); -#endif -} - - -int -_assuan_sock_get_nonce (struct sockaddr *addr, int addrlen, - assuan_sock_nonce_t *nonce) -{ -#ifdef HAVE_W32_SYSTEM - if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) - { - struct sockaddr_un *unaddr; - unsigned short port; - - if (sizeof nonce->nonce != 16) - { - errno = EINVAL; - return -1; - } - nonce->length = 16; - unaddr = (struct sockaddr_un *)addr; - if (read_port_and_nonce (unaddr->sun_path, &port, nonce->nonce)) - return -1; - } - else - { - nonce->length = 42; /* Arbitrary valuie to detect unitialized nonce. */ - nonce->nonce[0] = 42; - } -#else - (void)addr; - (void)addrlen; - nonce->length = 0; -#endif - return 0; -} - - -int -_assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce) -{ -#ifdef HAVE_W32_SYSTEM - char buffer[16], *p; - size_t nleft; - int n; - - if (sizeof nonce->nonce != 16) - { - errno = EINVAL; - return -1; - } - - if (nonce->length == 42 && nonce->nonce[0] == 42) - return 0; /* Not a Unix domain socket. */ - - if (nonce->length != 16) - { - errno = EINVAL; - return -1; - } - - p = buffer; - nleft = 16; - while (nleft) - { - n = _assuan_io_read (SOCKET2HANDLE(fd), p, nleft); - if (n < 0 && errno == EINTR) - ; - else if (n < 0 && errno == EAGAIN) - Sleep (100); - else if (n < 0) - return -1; - else if (!n) - { - errno = EIO; - return -1; - } - else - { - p += n; - nleft -= n; - } - } - if (memcmp (buffer, nonce->nonce, 16)) - { - errno = EACCES; - return -1; - } -#else - (void)fd; - (void)nonce; -#endif - return 0; -} - - -/* Public API. */ -int -assuan_sock_close (assuan_fd_t fd) -{ - return _assuan_close (fd); -} - -assuan_fd_t -assuan_sock_new (int domain, int type, int proto) -{ - return _assuan_sock_new (domain, type, proto); -} - -int -assuan_sock_connect (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen) -{ - return _assuan_sock_connect (sockfd, addr, addrlen); -} - -int -assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen) -{ - return _assuan_sock_bind (sockfd, addr, addrlen); -} - -int -assuan_sock_get_nonce (struct sockaddr *addr, int addrlen, - assuan_sock_nonce_t *nonce) -{ - return _assuan_sock_get_nonce (addr, addrlen, nonce); -} - -int -assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce) -{ - return _assuan_sock_check_nonce (fd, nonce); -} diff --git a/assuan/src/assuan-uds.c b/assuan/src/assuan-uds.c deleted file mode 100644 index 02f77a52..00000000 --- a/assuan/src/assuan-uds.c +++ /dev/null @@ -1,313 +0,0 @@ -/* assuan-uds.c - Assuan unix domain socket utilities - * Copyright (C) 2006 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#ifndef HAVE_W32_SYSTEM -#include -#include -#else -#include -#endif -#if HAVE_SYS_UIO_H -#include -#endif -#include -#include -#include -#include - -#include "assuan-defs.h" - -#ifdef USE_DESCRIPTOR_PASSING -/* Provide replacement for missing CMSG maccros. We assume that - size_t matches the alignment requirement. */ -#define MY_ALIGN(n) ((((n))+ sizeof(size_t)-1) & (size_t)~(sizeof(size_t)-1)) -#ifndef CMSG_SPACE -#define CMSG_SPACE(n) (MY_ALIGN(sizeof(struct cmsghdr)) + MY_ALIGN((n))) -#endif -#ifndef CMSG_LEN -#define CMSG_LEN(n) (MY_ALIGN(sizeof(struct cmsghdr)) + (n)) -#endif -#ifndef CMSG_FIRSTHDR -#define CMSG_FIRSTHDR(mhdr) \ - ((size_t)(mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ - ? (struct cmsghdr*) (mhdr)->msg_control : (struct cmsghdr*)NULL) -#endif -#ifndef CMSG_DATA -#define CMSG_DATA(cmsg) ((unsigned char*)((struct cmsghdr*)(cmsg)+1)) -#endif -#endif /*USE_DESCRIPTOR_PASSING*/ - - -/* Read from a unix domain socket using sendmsg. - - FIXME: We don't need the buffering. It is a leftover from the time - when we used datagrams. */ -static ssize_t -uds_reader (assuan_context_t ctx, void *buf, size_t buflen) -{ -#ifndef HAVE_W32_SYSTEM - int len = ctx->uds.buffersize; - - if (!ctx->uds.bufferallocated) - { - ctx->uds.buffer = xtrymalloc (2048); - if (!ctx->uds.buffer) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->uds.bufferallocated = 2048; - } - - while (!len) /* No data is buffered. */ - { - struct msghdr msg; - struct iovec iovec; -#ifdef USE_DESCRIPTOR_PASSING - union { - struct cmsghdr cm; - char control[CMSG_SPACE(sizeof (int))]; - } control_u; - struct cmsghdr *cmptr; -#endif /*USE_DESCRIPTOR_PASSING*/ - - memset (&msg, 0, sizeof (msg)); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = &iovec; - msg.msg_iovlen = 1; - iovec.iov_base = ctx->uds.buffer; - iovec.iov_len = ctx->uds.bufferallocated; -#ifdef USE_DESCRIPTOR_PASSING - msg.msg_control = control_u.control; - msg.msg_controllen = sizeof (control_u.control); -#endif - - len = _assuan_simple_recvmsg (ctx, &msg); - if (len < 0) - return -1; - if (len == 0) - return 0; - - ctx->uds.buffersize = len; - ctx->uds.bufferoffset = 0; - -#ifdef USE_DESCRIPTOR_PASSING - cmptr = CMSG_FIRSTHDR (&msg); - if (cmptr && cmptr->cmsg_len == CMSG_LEN (sizeof(int))) - { - if (cmptr->cmsg_level != SOL_SOCKET - || cmptr->cmsg_type != SCM_RIGHTS) - _assuan_log_printf ("unexpected ancillary data received\n"); - else - { - int fd = *((int*)CMSG_DATA (cmptr)); - - if (ctx->uds.pendingfdscount >= DIM (ctx->uds.pendingfds)) - { - _assuan_log_printf ("too many descriptors pending - " - "closing received descriptor %d\n", fd); - _assuan_close (fd); - } - else - ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = fd; - } - } -#endif /*USE_DESCRIPTOR_PASSING*/ - } - - /* Return some data to the user. */ - - if (len > buflen) /* We have more than the user requested. */ - len = buflen; - - memcpy (buf, (char*)ctx->uds.buffer + ctx->uds.bufferoffset, len); - ctx->uds.buffersize -= len; - assert (ctx->uds.buffersize >= 0); - ctx->uds.bufferoffset += len; - assert (ctx->uds.bufferoffset <= ctx->uds.bufferallocated); - - return len; -#else /*HAVE_W32_SYSTEM*/ - int res = recvfrom (HANDLE2SOCKET(ctx->inbound.fd), buf, buflen, 0, NULL, NULL); - if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - return res; -#endif /*HAVE_W32_SYSTEM*/ -} - - -/* Write to the domain server. */ -static ssize_t -uds_writer (assuan_context_t ctx, const void *buf, size_t buflen) -{ -#ifndef HAVE_W32_SYSTEM - struct msghdr msg; - struct iovec iovec; - ssize_t len; - - memset (&msg, 0, sizeof (msg)); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iovlen = 1; - msg.msg_iov = &iovec; - iovec.iov_base = (void*)buf; - iovec.iov_len = buflen; - - len = _assuan_simple_sendmsg (ctx, &msg); - - return len; -#else /*HAVE_W32_SYSTEM*/ - int res = sendto (HANDLE2SOCKET(ctx->outbound.fd), buf, buflen, 0, - (struct sockaddr *)&ctx->serveraddr, - sizeof (struct sockaddr_in)); - if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); - return res; -#endif /*HAVE_W32_SYSTEM*/ -} - - -static assuan_error_t -uds_sendfd (assuan_context_t ctx, assuan_fd_t fd) -{ -#ifdef USE_DESCRIPTOR_PASSING - struct msghdr msg; - struct iovec iovec; - union { - struct cmsghdr cm; - char control[CMSG_SPACE(sizeof (int))]; - } control_u; - struct cmsghdr *cmptr; - int len; - char buffer[80]; - - /* We need to send some real data so that a read won't return 0 - which will be taken as an EOF. It also helps with debugging. */ - snprintf (buffer, sizeof(buffer)-1, "# descriptor %d is in flight\n", fd); - buffer[sizeof(buffer)-1] = 0; - - memset (&msg, 0, sizeof (msg)); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iovlen = 1; - msg.msg_iov = &iovec; - iovec.iov_base = buffer; - iovec.iov_len = strlen (buffer); - - msg.msg_control = control_u.control; - msg.msg_controllen = sizeof (control_u.control); - cmptr = CMSG_FIRSTHDR (&msg); - cmptr->cmsg_len = CMSG_LEN(sizeof(int)); - cmptr->cmsg_level = SOL_SOCKET; - cmptr->cmsg_type = SCM_RIGHTS; - *((int*)CMSG_DATA (cmptr)) = fd; - - len = _assuan_simple_sendmsg (ctx, &msg); - if (len < 0) - { - _assuan_log_printf ("uds_sendfd: %s\n", strerror (errno)); - return _assuan_error (ASSUAN_Write_Error); - } - else - return 0; -#else - return _assuan_error (ASSUAN_Not_Implemented); -#endif -} - - -static assuan_error_t -uds_receivefd (assuan_context_t ctx, assuan_fd_t *fd) -{ -#ifdef USE_DESCRIPTOR_PASSING - int i; - - if (!ctx->uds.pendingfdscount) - { - _assuan_log_printf ("no pending file descriptors!\n"); - return _assuan_error (ASSUAN_General_Error); - } - assert (ctx->uds.pendingfdscount <= DIM(ctx->uds.pendingfds)); - - *fd = ctx->uds.pendingfds[0]; - for (i=1; i < ctx->uds.pendingfdscount; i++) - ctx->uds.pendingfds[i-1] = ctx->uds.pendingfds[i]; - ctx->uds.pendingfdscount--; - - return 0; -#else - return _assuan_error (ASSUAN_Not_Implemented); -#endif -} - - -/* Close all pending fds. */ -void -_assuan_uds_close_fds (assuan_context_t ctx) -{ - int i; - - for (i = 0; i < ctx->uds.pendingfdscount; i++) - _assuan_close (ctx->uds.pendingfds[i]); - ctx->uds.pendingfdscount = 0; -} - -/* Deinitialize the unix domain socket I/O functions. */ -void -_assuan_uds_deinit (assuan_context_t ctx) -{ - /* First call the finish_handler which should close descriptors etc. */ - ctx->finish_handler (ctx); - - if (ctx->uds.buffer) - { - assert (ctx->uds.bufferallocated); - ctx->uds.bufferallocated = 0; - xfree (ctx->uds.buffer); - } - - _assuan_uds_close_fds (ctx); -} - - -/* Helper function to initialize a context for domain I/O. */ -void -_assuan_init_uds_io (assuan_context_t ctx) -{ - static struct assuan_io io = { uds_reader, uds_writer, - uds_sendfd, uds_receivefd }; - - ctx->io = &io; - ctx->uds.buffer = 0; - ctx->uds.bufferoffset = 0; - ctx->uds.buffersize = 0; - ctx->uds.bufferallocated = 0; - ctx->uds.pendingfdscount = 0; -} - diff --git a/assuan/src/assuan-util.c b/assuan/src/assuan-util.c deleted file mode 100644 index cefefcb2..00000000 --- a/assuan/src/assuan-util.c +++ /dev/null @@ -1,188 +0,0 @@ -/* assuan-util.c - Utility functions for Assuan - * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include "assuan-defs.h" - -static void *(*alloc_func)(size_t n) = malloc; -static void *(*realloc_func)(void *p, size_t n) = realloc; -static void (*free_func)(void*) = free; - -struct assuan_io_hooks _assuan_io_hooks; - - - -void -assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), - void *(*new_realloc_func)(void *p, size_t n), - void (*new_free_func)(void*) ) -{ - alloc_func = new_alloc_func; - realloc_func = new_realloc_func; - free_func = new_free_func; -} - - -void -assuan_set_io_hooks (assuan_io_hooks_t io_hooks) -{ - _assuan_io_hooks.read_hook = NULL; - _assuan_io_hooks.write_hook = NULL; - if (io_hooks) - { - _assuan_io_hooks.read_hook = io_hooks->read_hook; - _assuan_io_hooks.write_hook = io_hooks->write_hook; - } -} - - -void * -_assuan_malloc (size_t n) -{ - return alloc_func (n); -} - -void * -_assuan_realloc (void *a, size_t n) -{ - return realloc_func (a, n); -} - -void * -_assuan_calloc (size_t n, size_t m) -{ - void *p; - size_t nbytes; - - nbytes = n * m; - if (m && nbytes / m != n) - { - errno = ENOMEM; - return NULL; - } - - p = _assuan_malloc (nbytes); - if (p) - memset (p, 0, nbytes); - return p; -} - -void -_assuan_free (void *p) -{ - if (p) - free_func (p); -} - - -/* Store the error in the context so that the error sending function - can take out a descriptive text. Inside the assuan code, use the - macro set_error instead of this function. */ -int -assuan_set_error (assuan_context_t ctx, int err, const char *text) -{ - ctx->err_no = err; - ctx->err_str = text; - return err; -} - -void -assuan_set_pointer (assuan_context_t ctx, void *pointer) -{ - if (ctx) - ctx->user_pointer = pointer; -} - -void * -assuan_get_pointer (assuan_context_t ctx) -{ - return ctx? ctx->user_pointer : NULL; -} - - -void -assuan_begin_confidential (assuan_context_t ctx) -{ - if (ctx) - { - ctx->confidential = 1; - } -} - -void -assuan_end_confidential (assuan_context_t ctx) -{ - if (ctx) - { - ctx->confidential = 0; - } -} - - -void -assuan_set_io_monitor (assuan_context_t ctx, - unsigned int (*monitor)(assuan_context_t ctx, - int direction, - const char *line, - size_t linelen)) -{ - if (ctx) - { - ctx->io_monitor = monitor; - } -} - - - - -/* For context CTX, set the flag FLAG to VALUE. Values for flags - are usually 1 or 0 but certain flags might allow for other values; - see the description of the type assuan_flag_t for details. */ -void -assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value) -{ - if (!ctx) - return; - switch (flag) - { - case ASSUAN_NO_WAITPID: ctx->flags.no_waitpid = value; break; - case ASSUAN_CONFIDENTIAL: ctx->confidential = value; break; - } -} - -/* Return the VALUE of FLAG in context CTX. */ -int -assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag) -{ - if (!ctx) - return 0; - switch (flag) - { - case ASSUAN_NO_WAITPID: return ctx->flags.no_waitpid; - case ASSUAN_CONFIDENTIAL: return ctx->confidential; - } - return 0; -} - diff --git a/assuan/src/assuan.h b/assuan/src/assuan.h deleted file mode 100644 index ed9b4ef6..00000000 --- a/assuan/src/assuan.h +++ /dev/null @@ -1,663 +0,0 @@ -/* assuan.h - Definitions for the Assuan IPC library - * Copyright (C) 2001, 2002, 2003, 2005, 2007, - * 2008 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifndef ASSUAN_H -#define ASSUAN_H - -#include -#include -#include -#ifndef _ASSUAN_NO_SOCKET_WRAPPER -#ifdef _WIN32 -#include -#else -#include -#endif -#endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/ - -/* To use this file with libraries the following macros are useful: - - #define _ASSUAN_EXT_SYM_PREFIX _foo_ - - This prefixes all external symbols with "_foo_". - - #define _ASSUAN_ONLY_GPG_ERRORS - - If this is defined all old-style Assuan error codes are made - inactive as well as other deprecated stuff. - - #define _ASSUAN_NO_SOCKET_WRAPPER - - Do not include the definitions for the socket wrapper feature. - - The follwing macros are used internally in the implementation of - libassuan: - - #define _ASSUAN_NO_PTH - - This avoids inclusion of special GNU Pth hacks. - - #define _ASSUAN_NO_FIXED_SIGNALS - - This disables changing of certain signal handler; i.e. SIGPIPE. - - #define _ASSUAN_USE_DOUBLE_FORK - - Use a double fork approach when connecting to a server through - a pipe. - */ - - -#ifdef _ASSUAN_EXT_SYM_PREFIX -#define _ASSUAN_PREFIX1(x,y) x ## y -#define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y) -#define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x) -#define assuan_ _ASSUAN_PREFIX(assuan_) -#define assuan_register_command _ASSUAN_PREFIX(assuan_register_command) -#define assuan_register_post_cmd_notify \ - _ASSUAN_PREFIX(assuan_register_post_cmd_notify) -#define assuan_register_pre_cmd_notify \ - _ASSUAN_PREFIX(assuan_register_pre_cmd_notify) -#define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify) -#define assuan_register_reset_notify \ - _ASSUAN_PREFIX(assuan_register_reset_notify) -#define assuan_register_cancel_notify \ - _ASSUAN_PREFIX(assuan_register_cancel_notify) -#define assuan_register_input_notify \ - _ASSUAN_PREFIX(assuan_register_input_notify) -#define assuan_register_output_notify \ - _ASSUAN_PREFIX(assuan_register_output_notify) -#define assuan_register_option_handler \ - _ASSUAN_PREFIX(assuan_register_option_handler) -#define assuan_process _ASSUAN_PREFIX(assuan_process) -#define assuan_process_next _ASSUAN_PREFIX(assuan_process_next) -#define assuan_process_done _ASSUAN_PREFIX(assuan_process_done) -#define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds) -#define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp) -#define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line) -#define assuan_write_status _ASSUAN_PREFIX(assuan_write_status) -#define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd) -#define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line) -#define assuan_accept _ASSUAN_PREFIX(assuan_accept) -#define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd) -#define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd) -#define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd) -#define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd) -#define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server) -#define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server) -#define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server) -#define assuan_init_connected_socket_server \ - _ASSUAN_PREFIX(assuan_init_connected_socket_server) -#define assuan_init_socket_server_ext \ - _ASSUAN_PREFIX(assuan_init_socket_server_ext) -#define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect) -#define assuan_pipe_connect_ext _ASSUAN_PREFIX(assuan_pipe_connect_ext) -#define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect) -#define assuan_socket_connect_ext _ASSUAN_PREFIX(assuan_socket_connect_ext) -#define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect) -#define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid) -#define assuan_get_peercred _ASSUAN_PREFIX(assuan_get_peercred) -#define assuan_transact _ASSUAN_PREFIX(assuan_transact) -#define assuan_inquire _ASSUAN_PREFIX(assuan_inquire) -#define assuan_inquire_ext _ASSUAN_PREFIX(assuan_inquire_ext) -#define assuan_read_line _ASSUAN_PREFIX(assuan_read_line) -#define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line) -#define assuan_write_line _ASSUAN_PREFIX(assuan_write_line) -#define assuan_send_data _ASSUAN_PREFIX(assuan_send_data) -#define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd) -#define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd) -#define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks) -#define assuan_set_io_hooks _ASSUAN_PREFIX(assuan_set_io_hooks) -#define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream) -#define assuan_set_error _ASSUAN_PREFIX(assuan_set_error) -#define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer) -#define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer) -#define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor) -#define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential) -#define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential) -#define assuan_strerror _ASSUAN_PREFIX(assuan_strerror) -#define assuan_set_assuan_err_source \ - _ASSUAN_PREFIX(assuan_set_assuan_err_source) -#define assuan_set_assuan_log_stream \ - _ASSUAN_PREFIX(assuan_set_assuan_log_stream) -#define assuan_get_assuan_log_stream \ - _ASSUAN_PREFIX(assuan_get_assuan_log_stream) -#define assuan_get_assuan_log_prefix \ - _ASSUAN_PREFIX(assuan_get_assuan_log_prefix) -#define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag) -#define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag) -#define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2) -#define assuan_set_assuan_log_prefix \ - _ASSUAN_PREFIX(assuan_set_assuan_log_prefix) -#define assuan_sock_close _ASSUAN_PREFIX(assuan_sock_close) -#define assuan_sock_new _ASSUAN_PREFIX(assuan_sock_new) -#define assuan_sock_connect _ASSUAN_PREFIX(assuan_sock_connect) -#define assuan_sock_bind _ASSUAN_PREFIX(assuan_sock_bind) -#define assuan_sock_get_nonce _ASSUAN_PREFIX(assuan_sock_get_nonce) -#define assuan_sock_check_nonce _ASSUAN_PREFIX(assuan_sock_check_nonce) - - -/* And now the internal functions, argh... */ -#define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line) -#define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data) -#define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush) -#define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server) -#define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init) -#define _assuan_register_std_commands \ - _ASSUAN_PREFIX(_assuan_register_std_commands) -#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read) -#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write) -#define _assuan_io_read _ASSUAN_PREFIX(_assuan_io_read) -#define _assuan_io_write _ASSUAN_PREFIX(_assuan_io_write) -#define _assuan_io_hooks _ASSUAN_PREFIX(_assuan_io_hooks) -#define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context) -#define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context) -#define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc) -#define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc) -#define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc) -#define _assuan_free _ASSUAN_PREFIX(_assuan_free) -#define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer) -#define _assuan_log_sanitized_string \ - _ASSUAN_PREFIX(_assuan_log_sanitized_string) -#define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf) -#define _assuan_set_default_log_stream \ - _ASSUAN_PREFIX(_assuan_set_default_log_stream) -#define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror) -#define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r) -#define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource) -#define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line) -#define _assuan_error _ASSUAN_PREFIX(_assuan_error) -#define _assuan_error_is_eagain _ASSUAN_PREFIX(_assuan_error_is_eagain) -#define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io) -#define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds) -#define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit) -#define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg) -#define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg) -#define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid) -#define _assuan_sock_wsa2errno _ASSUAN_PREFIX(_assuan_sock_wsa2errno) -#define _assuan_sock_close _ASSUAN_PREFIX(_assuan_sock_close) -#define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new) -#define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect) -#define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind) -#define _assuan_sock_get_nonce _ASSUAN_PREFIX(_assuan_sock_get_nonce) -#define _assuan_sock_check_nonce _ASSUAN_PREFIX(_assuan_sock_check_nonce) - -#endif /*_ASSUAN_EXT_SYM_PREFIX*/ - - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - - -/* Check for compiler features. */ -#if __GNUC__ -#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) - -#if _ASSUAN_GCC_VERSION > 30100 -#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__)) -#endif -#endif -#ifndef _ASSUAN_DEPRECATED -#define _ASSUAN_DEPRECATED -#endif - - -/* Assuan error codes. These are only used by old applications or - those applications which won't make use of libgpg-error. */ -#ifndef _ASSUAN_ONLY_GPG_ERRORS -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_No_Error 0 -#endif -#define ASSUAN_General_Error 1 -#define ASSUAN_Out_Of_Core 2 -#define ASSUAN_Invalid_Value 3 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Timeout 4 -#endif -#define ASSUAN_Read_Error 5 -#define ASSUAN_Write_Error 6 -#define ASSUAN_Problem_Starting_Server 7 -#define ASSUAN_Not_A_Server 8 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Not_A_Client 9 -#endif -#define ASSUAN_Nested_Commands 10 -#define ASSUAN_Invalid_Response 11 -#define ASSUAN_No_Data_Callback 12 -#define ASSUAN_No_Inquire_Callback 13 -#define ASSUAN_Connect_Failed 14 -#define ASSUAN_Accept_Failed 15 - - /* Error codes above 99 are meant as status codes */ -#define ASSUAN_Not_Implemented 100 -#define ASSUAN_Server_Fault 101 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Invalid_Command 102 -#endif -#define ASSUAN_Unknown_Command 103 -#define ASSUAN_Syntax_Error 104 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Parameter_Error 105 -#endif -#define ASSUAN_Parameter_Conflict 106 -#define ASSUAN_Line_Too_Long 107 -#define ASSUAN_Line_Not_Terminated 108 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_No_Input 109 -#define ASSUAN_No_Output 110 -#endif -#define ASSUAN_Canceled 111 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Unsupported_Algorithm 112 -#define ASSUAN_Server_Resource_Problem 113 -#define ASSUAN_Server_IO_Error 114 -#define ASSUAN_Server_Bug 115 -#define ASSUAN_No_Data_Available 116 -#define ASSUAN_Invalid_Data 117 -#endif -#define ASSUAN_Unexpected_Command 118 -#define ASSUAN_Too_Much_Data 119 -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Inquire_Unknown 120 -#define ASSUAN_Inquire_Error 121 -#define ASSUAN_Invalid_Option 122 -#define ASSUAN_Invalid_Index 123 -#define ASSUAN_Unexpected_Status 124 -#define ASSUAN_Unexpected_Data 125 -#define ASSUAN_Invalid_Status 126 -#define ASSUAN_Locale_Problem 127 -#endif -#define ASSUAN_Not_Confirmed 128 - - /* Warning: Don't use the Error codes, below they are deprecated. */ -#ifndef _ASSUAN_IN_LIBASSUAN -#define ASSUAN_Bad_Certificate 201 -#define ASSUAN_Bad_Certificate_Chain 202 -#define ASSUAN_Missing_Certificate 203 -#define ASSUAN_Bad_Signature 204 -#define ASSUAN_No_Agent 205 -#define ASSUAN_Agent_Error 206 -#define ASSUAN_No_Public_Key 207 -#define ASSUAN_No_Secret_Key 208 -#define ASSUAN_Invalid_Name 209 - -#define ASSUAN_Cert_Revoked 301 -#define ASSUAN_No_CRL_For_Cert 302 -#define ASSUAN_CRL_Too_Old 303 -#define ASSUAN_Not_Trusted 304 - -#define ASSUAN_Card_Error 401 -#define ASSUAN_Invalid_Card 402 -#define ASSUAN_No_PKCS15_App 403 -#define ASSUAN_Card_Not_Present 404 -#define ASSUAN_Invalid_Id 405 - - /* Error codes in the range 1000 to 9999 may be used by applications - at their own discretion. */ -#define ASSUAN_USER_ERROR_FIRST 1000 -#define ASSUAN_USER_ERROR_LAST 9999 -#endif - -typedef int assuan_error_t; - -typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED; - -/* This is a list of pre-registered ASSUAN commands */ -/* Note, these command IDs are now deprectated and solely exists for - compatibility reasons. */ -typedef enum -{ - ASSUAN_CMD_NOP = 0, - ASSUAN_CMD_CANCEL, /* cancel the current request */ - ASSUAN_CMD_BYE, - ASSUAN_CMD_AUTH, - ASSUAN_CMD_RESET, - ASSUAN_CMD_OPTION, - ASSUAN_CMD_DATA, - ASSUAN_CMD_END, - ASSUAN_CMD_INPUT, - ASSUAN_CMD_OUTPUT, - - ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/ -} AssuanCommand; - - -#else /*!_ASSUAN_ONLY_GPG_ERRORS*/ - -/* Choose a type compatible with gpg_error_t. */ -typedef unsigned int assuan_error_t; - -#endif /*!_ASSUAN_ONLY_GPG_ERRORS*/ - - -/* Definitions of flags for assuan_set_flag(). */ -typedef enum - { - /* When using a pipe server, by default Assuan will wait for the - forked process to die in assuan_disconnect. In certain cases - this is not desirable. By setting this flag, the waitpid will - be skipped and the caller is responsible to cleanup a forked - process. */ - ASSUAN_NO_WAITPID = 1, - /* This flag indicates whether Assuan logging is in confidential - mode. Use assuan_{begin,end}_condidential to change the - mode. */ - ASSUAN_CONFIDENTIAL = 2 - } -assuan_flag_t; - -#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */ - -struct assuan_context_s; -typedef struct assuan_context_s *assuan_context_t; -#ifndef _ASSUAN_ONLY_GPG_ERRORS -typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED; -#endif /*_ASSUAN_ONLY_GPG_ERRORS*/ - -/* Because we use system handles and not libc low level file - descriptors on W32, we need to declare them as HANDLE (which - actually is a plain pointer). This is required to eventually - support 64 bit Windows systems. */ -#ifdef _WIN32 -typedef void *assuan_fd_t; -#define ASSUAN_INVALID_FD ((void*)(-1)) -#define ASSUAN_INT2FD(s) ((void *)(s)) -#define ASSUAN_FD2INT(h) ((unsigned int)(h)) -#else -typedef int assuan_fd_t; -#define ASSUAN_INVALID_FD (-1) -#define ASSUAN_INT2FD(s) ((s)) -#define ASSUAN_FD2INT(h) ((h)) -#endif - - -/* Assuan features an emulation of Unix domain sockets based on a - local TCP connections. To implement access permissions based on - file permissions a nonce is used which is expected by th server as - the first bytes received. This structure is used by the server to - save the nonce created initially by bind. On POSIX systems this is - a dummy operation. */ -struct assuan_sock_nonce_s -{ - size_t length; -#ifdef _WIN32 - char nonce[16]; -#endif -}; -typedef struct assuan_sock_nonce_s assuan_sock_nonce_t; - -/* Define the Unix domain socket structure for Windows. */ -#if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER) -#ifndef AF_LOCAL -#define AF_LOCAL AF_UNIX -#endif -#define EADDRINUSE WSAEADDRINUSE -struct sockaddr_un -{ - short sun_family; - unsigned short sun_port; - struct in_addr sun_addr; - char sun_path[108-2-4]; -}; -#endif - - -/* Definition of hook functions used to conditionally replace the - default I/O functions. */ -struct assuan_io_hooks -{ - int (*read_hook)(assuan_context_t, assuan_fd_t, void *, size_t, ssize_t *); - int (*write_hook)(assuan_context_t, assuan_fd_t fd, - const void *, size_t, ssize_t *); -}; -typedef struct assuan_io_hooks *assuan_io_hooks_t; - - - -/*-- assuan-handler.c --*/ -int assuan_register_command (assuan_context_t ctx, - const char *cmd_string, - int (*handler)(assuan_context_t, char *)); -int assuan_register_post_cmd_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, int)); -int assuan_register_pre_cmd_notify (assuan_context_t ctx, - int (*fnc)(assuan_context_t, const char *)); -int assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); -int assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); - -int assuan_register_option_handler (assuan_context_t ctx, - int (*fnc)(assuan_context_t, - const char*, const char*)); - -int assuan_process (assuan_context_t ctx); -int assuan_process_next (assuan_context_t ctx); -int assuan_process_done (assuan_context_t ctx, int rc); -int assuan_get_active_fds (assuan_context_t ctx, int what, - assuan_fd_t *fdarray, int fdarraysize); - - -FILE *assuan_get_data_fp (assuan_context_t ctx); -assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line); -assuan_error_t assuan_write_status (assuan_context_t ctx, - const char *keyword, const char *text); - -/* Negotiate a file descriptor. If LINE contains "FD=N", returns N - assuming a local file descriptor. If LINE contains "FD" reads a - file descriptor via CTX and stores it in *RDF (the CTX must be - capable of passing file descriptors). Under W32 the returned FD is - a libc-type one. */ -assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, - assuan_fd_t *rfd); - - -/*-- assuan-listen.c --*/ -assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line); -assuan_error_t assuan_accept (assuan_context_t ctx); -assuan_fd_t assuan_get_input_fd (assuan_context_t ctx); -assuan_fd_t assuan_get_output_fd (assuan_context_t ctx); -assuan_error_t assuan_close_input_fd (assuan_context_t ctx); -assuan_error_t assuan_close_output_fd (assuan_context_t ctx); - - -/*-- assuan-pipe-server.c --*/ -int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]); -void assuan_deinit_server (assuan_context_t ctx); - -/*-- assuan-socket-server.c --*/ -int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd); -int assuan_init_connected_socket_server (assuan_context_t *r_ctx, - assuan_fd_t fd) _ASSUAN_DEPRECATED; -int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, - unsigned int flags); -void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce); - -/*-- assuan-pipe-connect.c --*/ -assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, - const char *name, - const char *const argv[], - int *fd_child_list); -assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, - const char *name, - const char *const argv[], - int *fd_child_list, - void (*atfork) (void*, int), - void *atforkvalue) _ASSUAN_DEPRECATED; -assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, - const char *name, - const char *const argv[], - int *fd_child_list, - void (*atfork) (void *, int), - void *atforkvalue, - unsigned int flags); - -/*-- assuan-socket-connect.c --*/ -assuan_error_t assuan_socket_connect (assuan_context_t *ctx, - const char *name, - pid_t server_pid); -assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx, - const char *name, - pid_t server_pid, - unsigned int flags); - -/*-- assuan-connect.c --*/ -void assuan_disconnect (assuan_context_t ctx); -pid_t assuan_get_pid (assuan_context_t ctx); -#ifndef _WIN32 -assuan_error_t assuan_get_peercred (assuan_context_t ctx, - pid_t *pid, uid_t *uid, gid_t *gid); -#endif - -/*-- assuan-client.c --*/ -assuan_error_t -assuan_transact (assuan_context_t ctx, - const char *command, - assuan_error_t (*data_cb)(void *, const void *, size_t), - void *data_cb_arg, - assuan_error_t (*inquire_cb)(void*, const char *), - void *inquire_cb_arg, - assuan_error_t (*status_cb)(void*, const char *), - void *status_cb_arg); - - -/*-- assuan-inquire.c --*/ -assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword, - unsigned char **r_buffer, size_t *r_length, - size_t maxlen); -assuan_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword, - size_t maxlen, - int (*cb) (void *cb_data, int rc, - unsigned char *buf, - size_t buf_len), - void *cb_data); -/*-- assuan-buffer.c --*/ -assuan_error_t assuan_read_line (assuan_context_t ctx, - char **line, size_t *linelen); -int assuan_pending_line (assuan_context_t ctx); -assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line ); -assuan_error_t assuan_send_data (assuan_context_t ctx, - const void *buffer, size_t length); - -/* The file descriptor must be pending before assuan_receivefd is - called. This means that assuan_sendfd should be called *before* the - trigger is sent (normally via assuan_write_line ("INPUT FD")). */ -assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd); -assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd); - - -/*-- assuan-util.c --*/ -void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), - void *(*new_realloc_func)(void *p, size_t n), - void (*new_free_func)(void*) ); -void assuan_set_io_hooks (assuan_io_hooks_t io_hooks); -void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); -int assuan_set_error (assuan_context_t ctx, int err, const char *text); -void assuan_set_pointer (assuan_context_t ctx, void *pointer); -void *assuan_get_pointer (assuan_context_t ctx); - -void assuan_begin_confidential (assuan_context_t ctx); -void assuan_end_confidential (assuan_context_t ctx); - -void assuan_set_io_monitor (assuan_context_t ctx, - unsigned int (*monitor)(assuan_context_t ctx, - int direction, - const char *line, - size_t linelen)); - -/* For context CTX, set the flag FLAG to VALUE. Values for flags - are usually 1 or 0 but certain flags might allow for other values; - see the description of the type assuan_flag_t for details. */ -void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value); - -/* Return the VALUE of FLAG in context CTX. */ -int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); - - -/*-- assuan-errors.c --*/ - -#ifndef _ASSUAN_ONLY_GPG_ERRORS -/* Return a string describing the assuan error. The use of this - function is deprecated; it is better to call - assuan_set_assuan_err_source once and then make use libgpg-error. */ -const char *assuan_strerror (assuan_error_t err); -#endif /*_ASSUAN_ONLY_GPG_ERRORS*/ - -/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error - sources. Note, that this function is not thread-safe and should be - used right at startup. Switching back to the old style mode is not - supported. */ -void assuan_set_assuan_err_source (int errsource); - -/*-- assuan-logging.c --*/ - -/* Set the stream to which assuan should log message not associated - with a context. By default, this is stderr. The default value - will be changed when the first log stream is associated with a - context. Note, that this function is not thread-safe and should - in general be used right at startup. */ -extern void assuan_set_assuan_log_stream (FILE *fp); - -/* Return the stream which is currently being using for global logging. */ -extern FILE *assuan_get_assuan_log_stream (void); - -/* Set the prefix to be used at the start of a line emitted by assuan - on the log stream. The default is the empty string. Note, that - this function is not thread-safe and should in general be used - right at startup. */ -void assuan_set_assuan_log_prefix (const char *text); - -/* Return a prefix to be used at the start of a line emitted by assuan - on the log stream. The default implementation returns the empty - string, i.e. "" */ -const char *assuan_get_assuan_log_prefix (void); - - -/*-- assuan-socket.c --*/ - -/* These are socket wrapper functions to support an emulation of Unix - domain sockets on Windows W32. */ -int assuan_sock_close (assuan_fd_t fd); -assuan_fd_t assuan_sock_new (int domain, int type, int proto); -int assuan_sock_connect (assuan_fd_t sockfd, - struct sockaddr *addr, int addrlen); -int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen); -int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen, - assuan_sock_nonce_t *nonce); -int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce); - - -#ifdef __cplusplus -} -#endif -#endif /* ASSUAN_H */ diff --git a/assuan/src/funopen.c b/assuan/src/funopen.c deleted file mode 100644 index fb87f962..00000000 --- a/assuan/src/funopen.c +++ /dev/null @@ -1,62 +0,0 @@ -/* funopen.c - Replacement for funopen. - * Copyright (C) 2003, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - - -/* Replacement for the *BSD function: - - FILE *funopen (void *cookie, - int (*readfn)(void *, char *, int), - int (*writefn)(void *, const char *, int), - fpos_t (*seekfn)(void *, fpos_t, int), - int (*closefn)(void *)); - - The functions to provide my either be NULL if not required or - similar to the unistd function with the exception of using the - cookie instead of the fiel descripor. -*/ - - -#ifdef HAVE_FOPENCOOKIE -FILE * -_assuan_funopen(void *cookie, - cookie_read_function_t *readfn, - cookie_write_function_t *writefn, - cookie_seek_function_t *seekfn, - cookie_close_function_t *closefn) -{ - cookie_io_functions_t io; - - io.read = readfn; - io.write = writefn; - io.seek = seekfn; - io.close = closefn; - - return fopencookie (cookie, - readfn ? ( writefn ? "rw" : "r" ) - : ( writefn ? "w" : ""), io); -} -#else -#error No known way to implement funopen. -#endif diff --git a/assuan/src/isascii.c b/assuan/src/isascii.c deleted file mode 100644 index 77ed970b..00000000 --- a/assuan/src/isascii.c +++ /dev/null @@ -1,28 +0,0 @@ -/* isascii.c - Replacement for isascii. - * Copyright (C) 2002, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -int -isascii (int c) -{ - return (((c) & ~0x7f) == 0); -} diff --git a/assuan/src/libassuan-config.in b/assuan/src/libassuan-config.in deleted file mode 100644 index 60f4aa2d..00000000 --- a/assuan/src/libassuan-config.in +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh -# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This file is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -PGM=libassuan-config -lib="@LIBASSUAN_CONFIG_LIB@" -extralibs="@LIBASSUAN_CONFIG_EXTRA_LIBS@" -cflags="@LIBASSUAN_CONFIG_CFLAGS@" -api_version="@LIBASSUAN_CONFIG_API_VERSION@" -all_thread_modules="@LIBASSUAN_CONFIG_THREAD_MODULES@" -thread_module= -prefix=@prefix@ -exec_prefix=@exec_prefix@ -includes="" -libdirs="" -exec_prefix_set=no -echo_libs=no -echo_cflags=no -echo_prefix=no -echo_exec_prefix=no - -if test x"$all_thread_modules" = x; then - all_thread_modules="none pthread" -else - all_thread_modules="none pthread $all_thread_modules" -fi - -usage() -{ - cat <&2 -fi - -while test $# -gt 0; do - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case $1 in - --prefix=*) - # Dummy - ;; - --prefix) - echo_prefix=yes - ;; - --exec-prefix=*) - # Dummy - ;; - --exec-prefix) - echo_exec_prefix=yes - ;; - --version) - echo "@VERSION@" - exit 0 - ;; - --api-version) - echo_api_version=yes - ;; - --thread=*) - for mod in $all_thread_modules; do - if test "$mod" = "$optarg"; then - thread_module="-$mod" - fi - done - if test "x$thread_module" = "x"; then - usage 1 1>&2 - fi - if test "$thread_module" = "-none"; then - thread_module="" - fi - if test "$thread_module" = "-pthread"; then - thread_module="" - fi - ;; - --cflags) - echo_cflags=yes - ;; - --libs) - echo_libs=yes - ;; - *) - usage 1 1>&2 - ;; - esac - shift -done - -if test "$echo_prefix" = "yes"; then - echo $prefix -fi - -if test "$echo_exec_prefix" = "yes"; then - echo $exec_prefix -fi - -if test "$echo_api_version" = "yes"; then - echo $api_version -fi - - -if test "$echo_cflags" = "yes"; then - if test "@includedir@" != "/usr/include" ; then - includes="-I@includedir@" - for i in $cflags ; do - if test "$i" = "-I@includedir@" ; then - includes="" - fi - done - fi - echo $includes $cflags -fi - -if test "$echo_libs" = "yes"; then - if test "@libdir@" != "/usr/lib" ; then - libdirs="-L@libdir@" - for i in $lib $extralibs ; do - if test "$i" = "-L@libdir@" ; then - libdirs="" - fi - done - fi - echo $libdirs $lib${thread_module} $extralibs -fi diff --git a/assuan/src/libassuan.m4 b/assuan/src/libassuan.m4 deleted file mode 100644 index 004eee39..00000000 --- a/assuan/src/libassuan.m4 +++ /dev/null @@ -1,175 +0,0 @@ -dnl Autoconf macros for libassuan -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. -dnl -dnl This file is free software; as a special exception the author gives -dnl unlimited permission to copy and/or distribute it, with or without -dnl modifications, as long as this notice is preserved. -dnl -dnl This file is distributed in the hope that it will be useful, but -dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -dnl -dnl Common code used for libassuan detection [internal] -dnl Returns ok set to yes or no. -dnl -AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON], -[ AC_ARG_WITH(libassuan-prefix, - AC_HELP_STRING([--with-libassuan-prefix=PFX], - [prefix where LIBASSUAN is installed (optional)]), - libassuan_config_prefix="$withval", libassuan_config_prefix="") - if test x$libassuan_config_prefix != x ; then - libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix" - if test x${LIBASSUAN_CONFIG+set} != xset ; then - LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config - fi - fi - AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no) - - tmp=ifelse([$1], ,1:0.9.2,$1) - if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then - req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` - min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` - else - req_libassuan_api=0 - min_libassuan_version="$tmp" - fi - - if test "$LIBASSUAN_CONFIG" != "no" ; then - libassuan_version=`$LIBASSUAN_CONFIG --version` - fi - libassuan_version_major=`echo $libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - libassuan_version_minor=`echo $libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - libassuan_version_micro=`echo $libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` - - AC_MSG_CHECKING(for LIBASSUAN ifelse([$2], ,,[$2 ])- version >= $min_libassuan_version) - ok=no - if test "$LIBASSUAN_CONFIG" != "no" ; then - ifelse([$2], ,,[if `$LIBASSUAN_CONFIG --thread=$2 2> /dev/null` ; then]) - req_major=`echo $min_libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` - req_minor=`echo $min_libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` - req_micro=`echo $min_libassuan_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` - if test "$libassuan_version_major" -gt "$req_major"; then - ok=yes - else - if test "$libassuan_version_major" -eq "$req_major"; then - if test "$libassuan_version_minor" -gt "$req_minor"; then - ok=yes - else - if test "$libassuan_version_minor" -eq "$req_minor"; then - if test "$libassuan_version_micro" -ge "$req_micro"; then - ok=yes - fi - fi - fi - fi - fi - ifelse([$2], ,,[fi]) - fi - - if test $ok = yes; then - AC_MSG_RESULT([yes ($libassuan_version)]) - else - AC_MSG_RESULT(no) - fi - - if test $ok = yes; then - if test "$req_libassuan_api" -gt 0 ; then - tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0` - if test "$tmp" -gt 0 ; then - AC_MSG_CHECKING([LIBASSUAN ifelse([$2], ,,[$2 ])API version]) - if test "$req_libassuan_api" -eq "$tmp" ; then - AC_MSG_RESULT(okay) - else - ok=no - AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.]) - fi - fi - fi - fi - -]) - -dnl AM_CHECK_LIBASSUAN([MINIMUM-VERSION, -dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) -dnl Test whether libassuan has at least MINIMUM-VERSION. This is -dnl used to test for features only available in newer versions. -dnl -AC_DEFUN([AM_CHECK_LIBASSUAN], -[ _AM_PATH_LIBASSUAN_COMMON($1) - if test $ok = yes; then - ifelse([$2], , :, [$2]) - else - ifelse([$3], , :, [$3]) - fi -]) - - - - -dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION, -dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) -dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS -dnl -AC_DEFUN([AM_PATH_LIBASSUAN], -[ _AM_PATH_LIBASSUAN_COMMON($1) - if test $ok = yes; then - LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags` - LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs` - ifelse([$2], , :, [$2]) - else - LIBASSUAN_CFLAGS="" - LIBASSUAN_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(LIBASSUAN_CFLAGS) - AC_SUBST(LIBASSUAN_LIBS) -]) - - -dnl AM_PATH_LIBASSUAN_PTH([MINIMUM-VERSION, -dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) -dnl Test for libassuan and define LIBASSUAN_PTH_CFLAGS and LIBASSUAN_PTH_LIBS -dnl -AC_DEFUN([AM_PATH_LIBASSUAN_PTH], -[ _AM_PATH_LIBASSUAN_COMMON($1,pth) - if test $ok = yes; then - LIBASSUAN_PTH_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pth --cflags` - LIBASSUAN_PTH_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pth --libs` - ifelse([$2], , :, [$2]) - else - LIBASSUAN_PTH_CFLAGS="" - LIBASSUAN_PTH_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(LIBASSUAN_PTH_CFLAGS) - AC_SUBST(LIBASSUAN_PTH_LIBS) -]) - - -dnl AM_PATH_LIBASSUAN_PTHREAD([MINIMUM-VERSION, -dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) -dnl Test for libassuan and define LIBASSUAN_PTHREAD_CFLAGS -dnl and LIBASSUAN_PTHREAD_LIBS -dnl -AC_DEFUN([AM_PATH_LIBASSUAN_PTHREAD], -[ _AM_PATH_LIBASSUAN_COMMON($1,pthread) - if test $ok = yes; then - LIBASSUAN_PTHREAD_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pthread --cflags` - LIBASSUAN_PTHREAD_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pthread --libs` - ifelse([$2], , :, [$2]) - else - LIBASSUAN_PTHREAD_CFLAGS="" - LIBASSUAN_PTHREAD_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(LIBASSUAN_PTHREAD_CFLAGS) - AC_SUBST(LIBASSUAN_PTHREAD_LIBS) -]) - diff --git a/assuan/src/memrchr.c b/assuan/src/memrchr.c deleted file mode 100644 index 258216ce..00000000 --- a/assuan/src/memrchr.c +++ /dev/null @@ -1,39 +0,0 @@ -/* memrchr.c - Replacement for memrchr. - * Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -void * -memrchr (const void *block, int c, size_t size) -{ - const unsigned char *p = block; - - if (size) - { - for (p += size - 1; size; p--, size--) - if (*p == c) - return (void *)p; - } - return NULL; -} - diff --git a/assuan/src/mkerrors b/assuan/src/mkerrors deleted file mode 100755 index 79ac23b6..00000000 --- a/assuan/src/mkerrors +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/sh -# mkerrors - Extract error strings from assuan.h -# and create C source for assuan_strerror -# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. -# -# This file is part of Assuan. -# -# Assuan is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# Assuan is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, see . -cat < -#endif - -#include -#include -#include - -#undef _ASSUAN_IN_LIBASSUAN /* undef to get all error codes. */ -#include "assuan.h" -#include "assuan-defs.h" - -/* If true the modern gpg-error style error codes are used in the - API. */ -static unsigned int err_source; - -/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error - sources. Note, that this function is not thread-safe and should be - used right at startup. Switching back to the old style mode is not - supported. */ -void -assuan_set_assuan_err_source (int errsource) -{ - errsource &= 0xff; - err_source = errsource? errsource : 31 /*GPG_ERR_SOURCE_ANY*/; -} - - -/* Helper to map old style Assuan error codes to gpg-error codes. - This is used internally to keep an compatible ABI. */ -assuan_error_t -_assuan_error (int oldcode) -{ - unsigned int n; - - if (!err_source) - { - if (oldcode == -1) - return -1; - else - return (oldcode & 0x00ffffff); /* Make sure that the gpg-error - source part is cleared. */ - } - - switch (oldcode) - { - case ASSUAN_General_Error: n = 257; break; - case ASSUAN_Accept_Failed: n = 258; break; - case ASSUAN_Connect_Failed: n = 259; break; - case ASSUAN_Invalid_Response: n = 260; break; - case ASSUAN_Invalid_Value: n = 261; break; - case ASSUAN_Line_Not_Terminated: n = 262; break; - case ASSUAN_Line_Too_Long: n = 263; break; - case ASSUAN_Nested_Commands: n = 264; break; - case ASSUAN_No_Data_Callback: n = 265; break; - case ASSUAN_No_Inquire_Callback: n = 266; break; - case ASSUAN_Not_A_Server: n = 267; break; - case ASSUAN_Not_Implemented: n = 69; break; - case ASSUAN_Parameter_Conflict: n = 280; break; - case ASSUAN_Problem_Starting_Server: n = 269; break; - case ASSUAN_Server_Fault: n = 80; break; - case ASSUAN_Syntax_Error: n = 276; break; - case ASSUAN_Too_Much_Data: n = 273; break; - case ASSUAN_Unexpected_Command: n = 274; break; - case ASSUAN_Unknown_Command: n = 275; break; - case ASSUAN_Canceled: n = 277; break; - case ASSUAN_No_Secret_Key: n = 17; break; - case ASSUAN_Not_Confirmed: n = 114; break; - - case ASSUAN_Read_Error: - switch (errno) - { - case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; - case EAGAIN: - n = (6 | (1 << 15)); - break; - default: n = 270; /*GPG_ERR_ASS_READ_ERROR*/ break; - } - break; - - case ASSUAN_Write_Error: - switch (errno) - { - case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; - case EAGAIN: - n = (6 | (1 << 15)); - break; - default: n = 271; /*GPG_ERR_ASS_WRITE_ERROR*/ break; - } - break; - - case ASSUAN_Out_Of_Core: - switch (errno) - { - case 0: /* Should not happen but a user might have provided - an incomplete implemented malloc function. Give - him a chance to correct this fault but make sure - an error is indeed returned. */ - n = 16381; /*GPG_ERR_MISSING_ERRNO*/ - break; - case ENOMEM: - n = (86 | (1 << 15)); - break; - default: - n = 16382; /*GPG_ERR_UNKNOWN_ERRNO*/ - break; - } - break; - - case -1: n = 16383 /*GPG_ERR_EOF*/; break; - - default: - n = 257; - break; - } - - return ((err_source << 24) | (n & 0x00ffffff)); - -} - - -/* A small helper function to treat EAGAIN transparently to the - caller. */ -int -_assuan_error_is_eagain (assuan_error_t err) -{ - if ((!err_source && err == ASSUAN_Read_Error && errno == EAGAIN) - || (err_source && (err & ((1 << 24) - 1)) == (6 | (1 << 15)))) - { - /* Avoid spinning by sleeping for one tenth of a second. */ - _assuan_usleep (100000); - return 1; - } - else - return 0; -} - - -/** - * assuan_strerror: - * @err: Error code - * - * This function returns a textual representaion of the given - * errorcode. If this is an unknown value, a string with the value - * is returned (Beware: it is hold in a static buffer). - * - * Return value: String with the error description. - **/ -const char * -assuan_strerror (assuan_error_t err) -{ - const char *s; - static char buf[50]; - - switch (err) - { -EOF - -awk ' -/ASSUAN_No_Error/ { okay=1 } -!okay {next} -/^#define[ ]+ASSUAN_[A-Za-z_]*/ { print_code($2) } -/ASSUAN_USER_ERROR_LAST/ { exit 0 } - - -function print_code( s ) -{ -printf " case %s: s=\"", s ; -gsub(/_/, " ", s ); -printf "%s\"; break;\n", tolower(substr(s,8)); -} -' - -cat <> 24) & 0xff); - code = (err & 0x00ffffff); - if (source) - { - /* Assume this is an libgpg-error and try to map the codes - back. */ - switch (code) - { - case 257: n = ASSUAN_General_Error ; break; - case 258: n = ASSUAN_Accept_Failed ; break; - case 259: n = ASSUAN_Connect_Failed ; break; - case 260: n = ASSUAN_Invalid_Response ; break; - case 261: n = ASSUAN_Invalid_Value ; break; - case 262: n = ASSUAN_Line_Not_Terminated ; break; - case 263: n = ASSUAN_Line_Too_Long ; break; - case 264: n = ASSUAN_Nested_Commands ; break; - case 265: n = ASSUAN_No_Data_Callback ; break; - case 266: n = ASSUAN_No_Inquire_Callback ; break; - case 267: n = ASSUAN_Not_A_Server ; break; - case 69: n = ASSUAN_Not_Implemented ; break; - case 280: n = ASSUAN_Parameter_Conflict ; break; - case 269: n = ASSUAN_Problem_Starting_Server; break; - case 270: n = ASSUAN_Read_Error ; break; - case 271: n = ASSUAN_Write_Error ; break; - case 80: n = ASSUAN_Server_Fault ; break; - case 276: n = ASSUAN_Syntax_Error ; break; - case 273: n = ASSUAN_Too_Much_Data ; break; - case 274: n = ASSUAN_Unexpected_Command ; break; - case 275: n = ASSUAN_Unknown_Command ; break; - case 277: n = ASSUAN_Canceled ; break; - case 114: n = ASSUAN_Not_Confirmed ; break; - case ((1<<15)|86): n = ASSUAN_Out_Of_Core ; break; - default: n = 0; break; - } - if (n) - s = assuan_strerror (n); - else - { - sprintf (buf, "ec=%u.%u", source, code ); - s=buf; - } - } - else - { - sprintf (buf, "ec=%d", err ); - s=buf; - } - } - break; - } - - return s; -} - -EOF diff --git a/assuan/src/putc_unlocked.c b/assuan/src/putc_unlocked.c deleted file mode 100644 index 80b3aa1a..00000000 --- a/assuan/src/putc_unlocked.c +++ /dev/null @@ -1,30 +0,0 @@ -/* putc_unlocked.c - Replacement for putc_unlocked. - * Copyright (C) 2002, 2005 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -int -putc_unlocked (int c, FILE *stream) -{ - return putc (c, stream); -} diff --git a/assuan/src/setenv.c b/assuan/src/setenv.c deleted file mode 100644 index ff07d7b0..00000000 --- a/assuan/src/setenv.c +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (C) 1992,1995-2001,2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, - see . - */ - -#if HAVE_CONFIG_H -# include -#endif - -#include "assuan-defs.h" - -#define __builtin_expect(cond,val) (cond) - -#include -#if !_LIBC -# if !defined errno && !defined HAVE_ERRNO_DECL -extern int errno; -# endif -# define __set_errno(ev) ((errno) = (ev)) -#endif - -#if _LIBC || HAVE_STDLIB_H -# include -#endif -#if _LIBC || HAVE_STRING_H -# include -#endif -#if _LIBC || HAVE_UNISTD_H -# include -#endif - -#if !_LIBC -# define __environ environ -# ifndef HAVE_ENVIRON_DECL -extern char **environ; -# endif -#endif - -#if _LIBC -/* This lock protects against simultaneous modifications of `environ'. */ -# include -__libc_lock_define_initialized (static, envlock) -# define LOCK __libc_lock_lock (envlock) -# define UNLOCK __libc_lock_unlock (envlock) -#else -# define LOCK -# define UNLOCK -#endif - -/* In the GNU C library we must keep the namespace clean. */ -#ifdef _LIBC -# define setenv __setenv -# define unsetenv __unsetenv -# define clearenv __clearenv -# define tfind __tfind -# define tsearch __tsearch -#endif - -/* In the GNU C library implementation we try to be more clever and - allow arbitrarily many changes of the environment given that the used - values are from a small set. Outside glibc this will eat up all - memory after a while. */ -#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ - && defined __GNUC__) -# define USE_TSEARCH 1 -# include - -/* This is a pointer to the root of the search tree with the known - values. */ -static void *known_values; - -# define KNOWN_VALUE(Str) \ - ({ \ - void *value = tfind (Str, &known_values, (__compar_fn_t) strcmp); \ - value != NULL ? *(char **) value : NULL; \ - }) -# define STORE_VALUE(Str) \ - tsearch (Str, &known_values, (__compar_fn_t) strcmp) - -#else -# undef USE_TSEARCH - -# define KNOWN_VALUE(Str) NULL -# define STORE_VALUE(Str) do { } while (0) - -#endif - - -/* If this variable is not a null pointer we allocated the current - environment. */ -static char **last_environ; - - -/* This function is used by `setenv' and `putenv'. The difference between - the two functions is that for the former must create a new string which - is then placed in the environment, while the argument of `putenv' - must be used directly. This is all complicated by the fact that we try - to reuse values once generated for a `setenv' call since we can never - free the strings. */ -static int -__add_to_environ (const char *name, const char *value, const char *combined, - int replace) -{ - register char **ep; - register size_t size; - const size_t namelen = strlen (name); - const size_t vallen = value != NULL ? strlen (value) + 1 : 0; - - LOCK; - - /* We have to get the pointer now that we have the lock and not earlier - since another thread might have created a new environment. */ - ep = __environ; - - size = 0; - if (ep != NULL) - { - for (; *ep != NULL; ++ep) - if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') - break; - else - ++size; - } - - if (ep == NULL || __builtin_expect (*ep == NULL, 1)) - { - char **new_environ; - - /* We allocated this space; we can extend it. */ - new_environ = (char **) realloc (last_environ, - (size + 2) * sizeof (char *)); - if (new_environ == NULL) - { - UNLOCK; - return -1; - } - - /* If the whole entry is given add it. */ - if (combined != NULL) - /* We must not add the string to the search tree since it belongs - to the user. */ - new_environ[size] = (char *) combined; - else - { - /* See whether the value is already known. */ -#ifdef USE_TSEARCH -# ifdef __GNUC__ - char new_value[namelen + 1 + vallen]; -# else - char *new_value = (char *) alloca (namelen + 1 + vallen); -# endif -# ifdef _LIBC - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); -# else - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); -# endif - - new_environ[size] = KNOWN_VALUE (new_value); - if (__builtin_expect (new_environ[size] == NULL, 1)) -#endif - { - new_environ[size] = (char *) malloc (namelen + 1 + vallen); - if (__builtin_expect (new_environ[size] == NULL, 0)) - { - __set_errno (ENOMEM); - UNLOCK; - return -1; - } - -#ifdef USE_TSEARCH - memcpy (new_environ[size], new_value, namelen + 1 + vallen); -#else - memcpy (new_environ[size], name, namelen); - new_environ[size][namelen] = '='; - memcpy (&new_environ[size][namelen + 1], value, vallen); -#endif - /* And save the value now. We cannot do this when we remove - the string since then we cannot decide whether it is a - user string or not. */ - STORE_VALUE (new_environ[size]); - } - } - - if (__environ != last_environ) - memcpy ((char *) new_environ, (char *) __environ, - size * sizeof (char *)); - - new_environ[size + 1] = NULL; - - last_environ = __environ = new_environ; - } - else if (replace) - { - char *np; - - /* Use the user string if given. */ - if (combined != NULL) - np = (char *) combined; - else - { -#ifdef USE_TSEARCH -# ifdef __GNUC__ - char new_value[namelen + 1 + vallen]; -# else - char *new_value = (char *) alloca (namelen + 1 + vallen); -# endif -# ifdef _LIBC - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); -# else - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); -# endif - - np = KNOWN_VALUE (new_value); - if (__builtin_expect (np == NULL, 1)) -#endif - { - np = malloc (namelen + 1 + vallen); - if (__builtin_expect (np == NULL, 0)) - { - UNLOCK; - return -1; - } - -#ifdef USE_TSEARCH - memcpy (np, new_value, namelen + 1 + vallen); -#else - memcpy (np, name, namelen); - np[namelen] = '='; - memcpy (&np[namelen + 1], value, vallen); -#endif - /* And remember the value. */ - STORE_VALUE (np); - } - } - - *ep = np; - } - - UNLOCK; - - return 0; -} - -int -setenv (const char *name, const char *value, int replace) -{ - if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) - { - __set_errno (EINVAL); - return -1; - } - - return __add_to_environ (name, value, NULL, replace); -} - -int -unsetenv (const char *name) -{ - size_t len; - char **ep; - - if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) - { - __set_errno (EINVAL); - return -1; - } - - len = strlen (name); - - LOCK; - - ep = __environ; - while (*ep != NULL) - if (!strncmp (*ep, name, len) && (*ep)[len] == '=') - { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; - - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ - } - else - ++ep; - - UNLOCK; - - return 0; -} - -/* The `clearenv' was planned to be added to POSIX.1 but probably - never made it. Nevertheless the POSIX.9 standard (POSIX bindings - for Fortran 77) requires this function. */ -int -clearenv (void) -{ - LOCK; - - if (__environ == last_environ && __environ != NULL) - { - /* We allocated this environment so we can free it. */ - free (__environ); - last_environ = NULL; - } - - /* Clear the environment pointer removes the whole environment. */ - __environ = NULL; - - UNLOCK; - - return 0; -} -#ifdef _LIBC -libc_freeres_fn (free_mem) -{ - /* Remove all traces. */ - clearenv (); - - /* Now remove the search tree. */ - __tdestroy (known_values, free); - known_values = NULL; -} - -# undef setenv -# undef unsetenv -# undef clearenv -weak_alias (__setenv, setenv) -weak_alias (__unsetenv, unsetenv) -weak_alias (__clearenv, clearenv) -#endif - - diff --git a/assuan/src/stpcpy.c b/assuan/src/stpcpy.c deleted file mode 100644 index 8c489b85..00000000 --- a/assuan/src/stpcpy.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1992, 1995, 1997, 2002, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, - see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#undef __stpcpy -#undef stpcpy - -#ifndef weak_alias -# define __stpcpy stpcpy -#endif - -/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -char * -__stpcpy (dest, src) - char *dest; - const char *src; -{ - register char *d = dest; - register const char *s = src; - - do - *d++ = *s; - while (*s++ != '\0'); - - return d - 1; -} -#ifdef libc_hidden_def -libc_hidden_def (__stpcpy) -#endif -#ifdef weak_alias -weak_alias (__stpcpy, stpcpy) -#endif -#ifdef libc_hidden_builtin_def -libc_hidden_builtin_def (stpcpy) -#endif diff --git a/configure.ac b/configure.ac index f991f60e..77903216 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,6 @@ AC_CONFIG_SRCDIR([src/pwmd.c]) AM_CONFIG_HEADER([config.h]) AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.16.1]) -AC_CONFIG_SUBDIRS([assuan]) dnl Checks for programs. AC_PROG_CC_C99 @@ -28,6 +27,7 @@ AC_PROG_CPP AC_PROG_MKDIR_P dnl Checks for library functions. +AM_PATH_LIBASSUAN(2.0.0,, AC_MSG_ERROR([Missing or incomplete libassuan installation])) AM_PATH_GLIB_2_0(,, AC_MSG_ERROR([glib2 not found])) AM_PATH_LIBGCRYPT([1.3.1],, AC_MSG_ERROR([libgcrypt not found])) AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found])) diff --git a/src/Makefile.am b/src/Makefile.am index 13f598d2..dee05f7c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,14 +1,14 @@ -DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_srcdir)/assuan/src +DEFAULT_INCLUDES = -I. -I$(top_builddir) bin_PROGRAMS = pwmd pwmd_SOURCES = pwmd.c pwmd.h xml.c xml.h pwmd_error.c pwmd_error.h commands.c \ commands.h common.h cache.c cache.h gettext.h misc.c misc.h \ status.c status.h lock.h pwmd_LDFLAGS = @XML_LIBS@ @GLIB_LIBS@ @LIBGCRYPT_LIBS@ @GPG_ERROR_LIBS@ \ - @PTH_LDFLAGS@ @PTH_LIBS@ + @PTH_LDFLAGS@ @PTH_LIBS@ @LIBASSUAN_LIBS@ pwmd_CFLAGS = -DLOCALEDIR=\"${prefix}/share/locale\" @XML_CPPFLAGS@ \ - @GLIB_CFLAGS@ @LIBGCRYPT_CFLAGS@ @GPG_ERROR_CFLAGS@ @PTH_CFLAGS@ -pwmd_LDADD = ${top_builddir}/assuan/src/libassuan-pth.a + @GLIB_CFLAGS@ @LIBGCRYPT_CFLAGS@ @GPG_ERROR_CFLAGS@ \ + @PTH_CFLAGS@ @LIBASSUAN_CFLAGS@ if NEED_GETOPT_LONG pwmd_SOURCES += getopt_long.c getopt_long.h diff --git a/src/commands.c b/src/commands.c index 863ba1fd..0f709d74 100644 --- a/src/commands.c +++ b/src/commands.c @@ -397,6 +397,50 @@ file_header_internal_t *read_file_header(const gchar *filename, gboolean v1, return fh; } +/* + * This is called before every Assuan command. + */ +gpg_error_t command_startup(assuan_context_t ctx) +{ + struct client_s *cl = assuan_get_pointer(ctx); + gpg_error_t rc; + const gchar *name = assuan_get_command_name(ctx); + + if (!name) + return 0; + + log_write1("%s", name); + + if (!g_ascii_strcasecmp(name, "ISCACHED") || + !g_ascii_strcasecmp(name, "CLEARCACHE") || + !g_ascii_strcasecmp(name, "CACHETIMEOUT") || + !g_ascii_strcasecmp(name, "GETCONFIG") || + !g_ascii_strcasecmp(name, "GETPID") || + !g_ascii_strcasecmp(name, "VERSION") || + !g_ascii_strcasecmp(name, "SET") || + !g_ascii_strcasecmp(name, "BYE") || + !g_ascii_strcasecmp(name, "NOP") || + !g_ascii_strcasecmp(name, "CANCEL") || + !g_ascii_strcasecmp(name, "RESET") || + !g_ascii_strcasecmp(name, "END") || + !g_ascii_strcasecmp(name, "HELP") || + !g_ascii_strcasecmp(name, "OPTION") || + !g_ascii_strcasecmp(name, "INPUT") || + !g_ascii_strcasecmp(name, "OUTPUT") || + !g_ascii_strcasecmp(name, "UNSET")) + return 0; + + cl->last_rc = rc = file_modified(cl); + + if (rc) { + if ((rc == EPWMD_NO_FILE || rc == EPWMD_FILE_MODIFIED) && + !g_ascii_strcasecmp(name, "OPEN")) + rc = 0; + } + + return rc; +} + static gpg_error_t open_command_finalize(assuan_context_t ctx, guchar *key, gboolean cached) { @@ -480,7 +524,7 @@ static void req_cleanup(void *arg) g_strfreev((gchar **)arg); } -static gint open_command(assuan_context_t ctx, gchar *line) +static gpg_error_t open_command(assuan_context_t ctx, gchar *line) { gboolean cached = FALSE; gpg_error_t rc; @@ -489,6 +533,11 @@ static gint open_command(assuan_context_t ctx, gchar *line) gchar *filename = NULL; guint hashlen = gcry_md_get_algo_dlen(GCRY_MD_SHA256); + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + if ((req = split_input_line(line, " ", 2)) != NULL) filename = req[0]; @@ -1243,12 +1292,18 @@ static gpg_error_t save_command_finalize(assuan_context_t ctx, guchar *key, return send_error(ctx, 0); } -static gint save_command(assuan_context_t ctx, gchar *line) +static gpg_error_t save_command(assuan_context_t ctx, gchar *line) { gboolean cached = FALSE; struct stat st; struct client_s *client = assuan_get_pointer(ctx); guint hashlen = gcry_md_get_algo_dlen(GCRY_MD_SHA256); + gpg_error_t rc; + + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); if (line && *line) log_write2("ARGS=%s", ""); @@ -1361,13 +1416,18 @@ done: return save_command_finalize(ctx, client->crypto->key, cached); } -static gint delete_command(assuan_context_t ctx, gchar *line) +static gpg_error_t delete_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gchar **req; gpg_error_t rc; xmlNodePtr n; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); if (strchr(line, '\t')) @@ -1417,8 +1477,8 @@ static gint delete_command(assuan_context_t ctx, gchar *line) * assuan_process_next() and the command should be finished in * client_thread(). */ -static gint store_command_finalize(gpointer data, gint assuan_rc, guchar *line, - gsize len) +static gpg_error_t store_command_finalize(gpointer data, gpg_error_t assuan_rc, + guchar *line, gsize len) { assuan_context_t ctx = data; struct client_s *client = assuan_get_pointer(ctx); @@ -1470,11 +1530,16 @@ again: return rc; } -static gint store_command(assuan_context_t ctx, gchar *line) +static gpg_error_t store_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + rc = assuan_inquire_ext(ctx, "STORE", 0, store_command_finalize, ctx); if (rc) @@ -1599,13 +1664,18 @@ again: return rc; } -static gint get_command(assuan_context_t ctx, gchar *line) +static gpg_error_t get_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gchar **req; gpg_error_t rc; xmlNodePtr n; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); req = split_input_line(line, "\t", -1); @@ -1691,7 +1761,7 @@ static xmlNodePtr realpath_elements_cb(xmlNodePtr node, gchar **target, } static void list_command_cleanup1(void *arg); -static gint realpath_command(assuan_context_t ctx, gchar *line) +static gpg_error_t realpath_command(assuan_context_t ctx, gchar *line) { gpg_error_t rc; struct client_s *client = assuan_get_pointer(ctx); @@ -1702,6 +1772,11 @@ static gint realpath_command(assuan_context_t ctx, gchar *line) GString *string; gchar *rp = NULL; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); if (strchr(line, '\t') != NULL) { @@ -1789,13 +1864,18 @@ static void list_command_cleanup2(void *arg) } } -static gint list_command(assuan_context_t ctx, gchar *line) +static gpg_error_t list_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; struct element_list_s *elements = NULL; gchar *tmp; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + if (disable_list_and_dump == TRUE) return send_error(ctx, GPG_ERR_NOT_IMPLEMENTED); @@ -2334,12 +2414,17 @@ fail: * req[2] - element path * req[2] - element path or value */ -static gint attr_command(assuan_context_t ctx, gchar *line) +static gpg_error_t attr_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gchar **req; gpg_error_t rc = 0; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); req = split_input_line(line, " ", 4); @@ -2365,8 +2450,13 @@ static gint attr_command(assuan_context_t ctx, gchar *line) return send_error(ctx, rc); } -static gint iscached_command(assuan_context_t ctx, gchar *line) +static gpg_error_t iscached_command(assuan_context_t ctx, gchar *line) { + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + gchar **req = split_input_line(line, " ", 0); guchar md5file[16]; gchar *path, *tmp; @@ -2430,8 +2520,13 @@ static gint iscached_command(assuan_context_t ctx, gchar *line) return send_error(ctx, EPWMD_CACHE_NOT_FOUND); } -static gint clearcache_command(assuan_context_t ctx, gchar *line) +static gpg_error_t clearcache_command(assuan_context_t ctx, gchar *line) { + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + struct client_s *client = assuan_get_pointer(ctx); gchar **req = split_input_line(line, " ", 0); guchar md5file[16]; @@ -2458,8 +2553,13 @@ static gint clearcache_command(assuan_context_t ctx, gchar *line) return send_error(ctx, 0); } -static gint cachetimeout_command(assuan_context_t ctx, gchar *line) +static gpg_error_t cachetimeout_command(assuan_context_t ctx, gchar *line) { + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + guchar md5file[16]; glong timeout; gchar **req = split_input_line(line, " ", 0); @@ -2490,13 +2590,18 @@ static gint cachetimeout_command(assuan_context_t ctx, gchar *line) return send_error(ctx, 0); } -static gint dump_command(assuan_context_t ctx, gchar *line) +static gpg_error_t dump_command(assuan_context_t ctx, gchar *line) { xmlChar *xml; gint len; struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + if (disable_list_and_dump == TRUE) return send_error(ctx, GPG_ERR_NOT_IMPLEMENTED); @@ -2513,13 +2618,18 @@ static gint dump_command(assuan_context_t ctx, gchar *line) return send_error(ctx, rc); } -static gint getconfig_command(assuan_context_t ctx, gchar *line) +static gpg_error_t getconfig_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc = 0; gchar filename[255]={0}, param[747]={0}; gchar *p, *tmp, *fp = client->filename, *paramp = line; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); if (strchr(line, ' ')) { @@ -2647,11 +2757,16 @@ static void xpath_command_cleanup(void *arg) xmlXPathFreeContext(xpath->xp); } -static gint xpath_command(assuan_context_t ctx, gchar *line) +static gpg_error_t xpath_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; struct xpath_s xpath; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); @@ -2709,8 +2824,8 @@ fail: return send_error(ctx, rc); } -static gint import_command_finalize(gpointer data, gint assuan_rc, guchar *line, - gsize len) +static gpg_error_t import_command_finalize(gpointer data, + gpg_error_t assuan_rc, guchar *line, gsize len) { struct client_s *client = assuan_get_pointer((assuan_context_t)data); gpg_error_t rc = file_modified(client); @@ -2816,11 +2931,16 @@ fail: return rc; } -static gint import_command(assuan_context_t ctx, gchar *line) +static gpg_error_t import_command(assuan_context_t ctx, gchar *line) { gpg_error_t rc; struct client_s *client = assuan_get_pointer(ctx); + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + rc = assuan_inquire_ext(ctx, "IMPORT", 0, import_command_finalize, ctx); if (rc) @@ -2831,11 +2951,16 @@ static gint import_command(assuan_context_t ctx, gchar *line) return 0; } -static gint lock_command(assuan_context_t ctx, gchar *line) +static gpg_error_t lock_command(assuan_context_t ctx, gchar *line) { gpg_error_t rc; struct client_s *client = assuan_get_pointer(ctx); + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + rc = lock_file_mutex(client); if (!rc) @@ -2844,30 +2969,45 @@ static gint lock_command(assuan_context_t ctx, gchar *line) return send_error(ctx, rc); } -static gint unlock_command(assuan_context_t ctx, gchar *line) +static gpg_error_t unlock_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + unlock_file_mutex(client); return send_error(ctx, 0); } -static gint getpid_command(assuan_context_t ctx, gchar *line) +static gpg_error_t getpid_command(assuan_context_t ctx, gchar *line) { gpg_error_t rc; gchar buf[32]; pid_t pid = getpid(); + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + print_fmt(buf, sizeof(buf), "%i", pid); rc = xfer_data(ctx, buf, strlen(buf)); return send_error(ctx, rc); } -static gint version_command(assuan_context_t ctx, gchar *line) +static gpg_error_t version_command(assuan_context_t ctx, gchar *line) { gpg_error_t rc; gchar buf[32]; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + print_fmt(buf, sizeof(buf), "0x%X", VERSION_HEX); rc = xfer_data(ctx, buf, strlen(buf)); return send_error(ctx, rc); @@ -3064,16 +3204,26 @@ done: return 0; } -static gint unset_command(assuan_context_t ctx, gchar *line) +static gpg_error_t unset_command(assuan_context_t ctx, gchar *line) { + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); return send_error(ctx, set_unset_common(ctx, line, NULL)); } -static gint set_command(assuan_context_t ctx, gchar *line) +static gpg_error_t set_command(assuan_context_t ctx, gchar *line) { gchar name[64] = {0}, value[256] = {0}; + gpg_error_t rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); if (sscanf(line, " %63[_a-zA-Z] = %255c", name, value) != 2) @@ -3082,13 +3232,18 @@ static gint set_command(assuan_context_t ctx, gchar *line) return send_error(ctx, set_unset_common(ctx, name, value)); } -static gint rename_command(assuan_context_t ctx, gchar *line) +static gpg_error_t rename_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; gchar **req, **src, *dst; xmlNodePtr n; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); req = split_input_line(line, " ", -1); @@ -3134,13 +3289,18 @@ fail: return send_error(ctx, rc); } -static gint copy_command(assuan_context_t ctx, gchar *line) +static gpg_error_t copy_command(assuan_context_t ctx, gchar *line) { struct client_s *client = assuan_get_pointer(ctx); gpg_error_t rc; gchar **req, **src = NULL, **dst = NULL; xmlNodePtr nsrc, ndst, new, n; + rc = command_startup(ctx); + + if (rc) + return send_error(ctx, rc); + log_write2("ARGS=\"%s\"", line); req = split_input_line(line, " ", -1); @@ -3219,66 +3379,29 @@ fail: return send_error(ctx, rc); } -static void bye_notify(assuan_context_t ctx) +static gpg_error_t bye_notify(assuan_context_t ctx, gchar *data) { struct client_s *cl = assuan_get_pointer(ctx); /* This will let assuan_process_next() return. */ fcntl(cl->thd->fd, F_SETFL, O_NONBLOCK); + return 0; } -static void reset_notify(assuan_context_t ctx) +static gpg_error_t reset_notify(assuan_context_t ctx, gchar *data) { struct client_s *cl = assuan_get_pointer(ctx); if (cl) cleanup_client(cl); -} - -/* - * This is called before every Assuan command. - */ -gint command_startup(assuan_context_t ctx, const gchar *name) -{ - struct client_s *cl = assuan_get_pointer(ctx); - gpg_error_t rc; - - log_write1("%s", name); - - if (!g_ascii_strcasecmp(name, "ISCACHED") || - !g_ascii_strcasecmp(name, "CLEARCACHE") || - !g_ascii_strcasecmp(name, "CACHETIMEOUT") || - !g_ascii_strcasecmp(name, "GETCONFIG") || - !g_ascii_strcasecmp(name, "GETPID") || - !g_ascii_strcasecmp(name, "VERSION") || - !g_ascii_strcasecmp(name, "SET") || - !g_ascii_strcasecmp(name, "BYE") || - !g_ascii_strcasecmp(name, "NOP") || - !g_ascii_strcasecmp(name, "CANCEL") || - !g_ascii_strcasecmp(name, "RESET") || - !g_ascii_strcasecmp(name, "END") || - !g_ascii_strcasecmp(name, "HELP") || - !g_ascii_strcasecmp(name, "OPTION") || - !g_ascii_strcasecmp(name, "INPUT") || - !g_ascii_strcasecmp(name, "OUTPUT") || - !g_ascii_strcasecmp(name, "UNSET")) - return 0; - - cl->last_rc = rc = file_modified(cl); - - if (rc) { - if ((rc == EPWMD_NO_FILE || rc == EPWMD_FILE_MODIFIED) && - !g_ascii_strcasecmp(name, "OPEN")) - rc = 0; - } - return rc; + return 0; } /* * This is called after every Assuan command. */ -void command_finalize(assuan_context_t ctx, gint rc) +void command_finalize(assuan_context_t ctx, gpg_error_t rc) { struct client_s *client = assuan_get_pointer(ctx); @@ -3292,7 +3415,7 @@ gpg_error_t register_commands(assuan_context_t ctx) { static struct { const gchar *name; - gint (*handler)(assuan_context_t, gchar *line); + gpg_error_t (*handler)(assuan_context_t, gchar *line); } table[] = { { "OPEN", open_command }, { "SAVE", save_command }, @@ -3324,7 +3447,7 @@ gpg_error_t register_commands(assuan_context_t ctx) gint i, rc; for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; @@ -3340,11 +3463,6 @@ gpg_error_t register_commands(assuan_context_t ctx) if (rc) return rc; - rc = assuan_register_pre_cmd_notify(ctx, command_startup); - - if (rc) - return rc; - return assuan_register_post_cmd_notify(ctx, command_finalize); } diff --git a/src/common.h b/src/common.h index 2d704c31..1214f879 100644 --- a/src/common.h +++ b/src/common.h @@ -23,8 +23,6 @@ #include #include #include - -#define _ASSUAN_ONLY_GPG_ERRORS 1 #include #ifdef ENABLE_NLS @@ -106,7 +104,7 @@ struct pinentry_s { gboolean has_lock; gint enable; membuf_t data; - assuan_error_t (*inquire_cb)(void *data, const char *line); + gpg_error_t (*inquire_cb)(void *data, const char *line); void *inquire_data; }; #endif diff --git a/src/pinentry.c b/src/pinentry.c index 8938ef34..bdc56ce8 100644 --- a/src/pinentry.c +++ b/src/pinentry.c @@ -51,7 +51,7 @@ void free_client_list(); static gpg_error_t set_pinentry_strings(struct pinentry_s *pin, gint which); -static assuan_error_t mem_realloc_cb(void *data, const void *buffer, size_t len) +static gpg_error_t mem_realloc_cb(void *data, const void *buffer, size_t len) { membuf_t *mem = (membuf_t *)data; void *p; @@ -214,8 +214,13 @@ static gpg_error_t launch_pinentry(struct pinentry_s *pin) *p = NULL; tmp = get_key_file_string("global", "pinentry_path"); - rc = assuan_pipe_connect(&ctx, pin->path ? pin->path : tmp, argv, - child_list); + rc = assuan_new(&ctx); + + if (rc) + return rc; + + rc = assuan_pipe_connect(ctx, pin->path ? pin->path : tmp, argv, + child_list, NULL, NULL, 0); g_free(tmp); if (rc) @@ -308,7 +313,7 @@ static void pinentry_disconnect(struct pinentry_s *pin) return; if (pin->ctx) - assuan_disconnect(pin->ctx); + assuan_release(pin->ctx); pin->ctx = NULL; pin->pid = 0; diff --git a/src/pwmd.c b/src/pwmd.c index 59279b39..b3e2300e 100644 --- a/src/pwmd.c +++ b/src/pwmd.c @@ -78,6 +78,7 @@ #include "lock.h" GCRY_THREAD_OPTION_PTH_IMPL; +ASSUAN_SYSTEM_PTH_IMPL; static void clear_rcfile_keys() { @@ -317,7 +318,13 @@ static gint new_connection(struct client_s *cl) gpg_error_t rc; gchar *ver; - rc = assuan_init_socket_server_ext(&cl->ctx, cl->thd->fd, 2); + rc = assuan_new(&cl->ctx); + + if (rc) + goto fail; + + rc = assuan_init_socket_server(cl->ctx, cl->thd->fd, + ASSUAN_SOCKET_SERVER_ACCEPTED); if (rc) goto fail; @@ -472,7 +479,7 @@ static void cleanup_cb(void *arg) cleanup_client(cl); if (cl->ctx) - assuan_deinit_server(cl->ctx); + assuan_release(cl->ctx); else if (cl->thd && cl->thd->fd != -1) close(cl->thd->fd); @@ -592,7 +599,12 @@ static void *client_thread(void *data) wst = pth_event_status(wev); if (st == PTH_STATUS_OCCURRED || wst == PTH_STATUS_OCCURRED) { - rc = assuan_process_next(cl->ctx); + int ended; + + rc = assuan_process_next(cl->ctx, &ended); + + if (ended) + goto done; if (rc) { cl->inquire_status = INQUIRE_INIT; @@ -2099,9 +2111,13 @@ int main(int argc, char *argv[]) #endif setup_gcrypt(); gpg_err_init(); - assuan_set_assuan_err_source(GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source(GPG_ERR_SOURCE_DEFAULT); g_mem_set_vtable(&mtable); - assuan_set_malloc_hooks(xmalloc, xrealloc, xfree); + struct assuan_malloc_hooks mhooks = { + xmalloc, xrealloc, xfree + }; + assuan_set_system_hooks(ASSUAN_SYSTEM_PTH); + assuan_set_malloc_hooks(&mhooks); xmlMemSetup(xfree, xmalloc, xrealloc, xstrdup); xmlInitMemory(); xmlInitGlobals(); -- 2.11.4.GIT