diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..e9cf558 --- /dev/null +++ b/COPYING @@ -0,0 +1,344 @@ +NOTE: authd is released under the GPL with the additional exemption + that compiling, linking, and/or using OpenSSL is allowed. + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. 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 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. + + 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 +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) 19yy + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This 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 Library General +Public License instead of this License. diff --git a/COPYING.license b/COPYING.license new file mode 100644 index 0000000..6852373 --- /dev/null +++ b/COPYING.license @@ -0,0 +1,343 @@ +NOTE: authd is released under the GPL with the additional exemption + that compiling, linking, and/or using OpenSSL is allowed. + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. 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 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. + + 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 +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) 19yy + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This 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 Library General +Public License instead of this License. diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..8f940e5 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,51 @@ +prefix=/usr/local +exec_prefix=$(prefix) +sbindir=$(exec_prefix)/sbin +datadir=$(prefix)/share + +PACKAGE=$(shell gcc -E -dM config.h|awk '$$2=="PACKAGE"{gsub(/"/,"");print$$3}') +VERSION=$(shell gcc -E -dM config.h|awk '$$2=="VERSION"{gsub(/"/,"");print$$3}') +URL=$(shell gcc -E -dM config.h|awk '$$2=="CONTACT"{gsub(/"/,"");print$$3}') + +PROJECT_ID := $(PACKAGE)-$(VERSION) + +CFLAGS=-std=gnu99 -Wall -W -DNDEBUG -g -O +#CFLAGS=-std=gnu99 -Wall -W -g -O0 +LDFLAGS=-lcrypto + +targets := in.authd $(patsubst %.po,%.mo,$(wildcard *.po)) +docs := README.html COPYING + +all: $(targets) + +ja.mo: ja.po + +in.authd: authd.c config.h + gcc $(CFLAGS) $(LDFLAGS) -o $@ $< +authd.pot: authd.c + + +.PHONY: clean +clean: + $(RM) $(targets) *.po~ *.pot tags TAGS + +.PHONY: install +install: $(targets) + install -d $(sbindir) $(datadir)/doc/$(PACKAGE) + install in.authd $(sbindir) + install -m 644 $(docs) $(datadir)/doc/$(PACKAGE) + for file in *.mo; \ + do dir=$(datadir)/locale/$$(basename $${file} .mo)/LC_MESSAGES; \ + install -d $${dir}; \ + install -m 644 $${file} $${dir}/authd.mo; \ + done + +%.mo: %.po authd.pot + msgmerge -U $< authd.pot + sed -r -i 's|(Project-Id-Version:).*(\\n)|\1 $(PROJECT_ID)\2|' $< + sed -r -i 's|(Report-Msgid-Bugs-To:).*(\\n)|\1 <$(URL)>\2|' $< + sed -r -i 's|(Language-Team:).*(\\n)|\1 $(basename $@) <$(URL)>\2|' $< + msgfmt --statistics --check -o $@ $< + +%.pot: %.c + xgettext --keyword=_ --output=$@ $< diff --git a/GNUmakefile.docdir b/GNUmakefile.docdir new file mode 100644 index 0000000..1c3a562 --- /dev/null +++ b/GNUmakefile.docdir @@ -0,0 +1,51 @@ +prefix=/usr/local +exec_prefix=$(prefix) +sbindir=$(exec_prefix)/sbin +datadir=$(prefix)/share + +PACKAGE=$(shell gcc -E -dM config.h|awk '$$2=="PACKAGE"{gsub(/"/,"");print$$3}') +VERSION=$(shell gcc -E -dM config.h|awk '$$2=="VERSION"{gsub(/"/,"");print$$3}') +URL=$(shell gcc -E -dM config.h|awk '$$2=="CONTACT"{gsub(/"/,"");print$$3}') + +PROJECT_ID := $(PACKAGE)-$(VERSION) + +CFLAGS=-std=gnu99 -Wall -W -DNDEBUG -g -O +#CFLAGS=-std=gnu99 -Wall -W -g -O0 +LDFLAGS=-lcrypto + +targets := in.authd $(patsubst %.po,%.mo,$(wildcard *.po)) +docs := README.html COPYING + +all: $(targets) + +ja.mo: ja.po + +in.authd: authd.c config.h + gcc $(CFLAGS) $(LDFLAGS) -o $@ $< +authd.pot: authd.c + + +.PHONY: clean +clean: + $(RM) $(targets) *.po~ *.pot tags TAGS + +.PHONY: install +install: $(targets) + install -d $(sbindir) $(datadir)/doc/$(PROJECT_ID) + install in.authd $(sbindir) + install -m 644 $(docs) $(datadir)/doc/$(PROJECT_ID) + for file in *.mo; \ + do dir=$(datadir)/locale/$$(basename $${file} .mo)/LC_MESSAGES; \ + install -d $${dir}; \ + install -m 644 $${file} $${dir}/authd.mo; \ + done + +%.mo: %.po authd.pot + msgmerge -U $< authd.pot + sed -r -i 's|(Project-Id-Version:).*(\\n)|\1 $(PROJECT_ID)\2|' $< + sed -r -i 's|(Report-Msgid-Bugs-To:).*(\\n)|\1 <$(URL)>\2|' $< + sed -r -i 's|(Language-Team:).*(\\n)|\1 $(basename $@) <$(URL)>\2|' $< + msgfmt --statistics --check -o $@ $< + +%.pot: %.c + xgettext --keyword=_ --output=$@ $< diff --git a/README.html b/README.html new file mode 100644 index 0000000..2bc7ccf --- /dev/null +++ b/README.html @@ -0,0 +1,547 @@ + + + + + + + README for authd + + + +

authd: a RFC 1413 ident protocol daemon

+
+ +
    +
  1. + FEATURES + +
      +
    • written in C; small and fast
    • + +
    • + two operation modes: + +
        +
      1. server via inetd/xinetd
      2. + +
      3. script/interactive via command line + arguments
      4. +
      +
    • + +
    • supports IPv6 and IPv4
    • + +
    • pidentd option compatibility
    • + +
    • easy to use openssl compatible strong symmetric + encryption
    • + +
    • many privacy and anonymizing options
    • + +
    • works well even with broken clients
    • + +
    • internationalized log and help messages
    • + +
    • free software licensed under the GPL. This program is + released under the GPL with the additional exemption that + compiling, linking, and/or using OpenSSL is allowed.
    • +
    +
  2. + +
  3. + REQUIREMENTS & SETUP + +
      +
    1. + Building
      + Although authd was built and tested on Red Hat Linux + 9, Red Hat Enterprise Linux and Fedora Core 1 & 2, + it will probably compile on any recent 2003/2004-era + GNU/Linux distro with openssl and recent versions of + the GNU tool chain (compiler + make) and GNU C library. + + +

      authd does not require autoconf. If needed, change + any defaults by editing the config.h file. + To build, simply run "make"

      +
    2. + +
    3. + Installing
      + "make install" will install + "in.authd" and any translations in + "/usr/local/sbin" and + "/usr/local/locale" respectively, so + you'll need to set the make variable + prefix if you want the files to go somewhere + else than "/usr/local". It will install as + the filename "in.authd" to reflect that it + is intended to run as a inetd/xinetd hosted server; in + other words, server input/output is connected to stdin + and stdout. + +

      If you're using encryption, put a one line pass + phrase in the file "/etc/ident.key" (or + another place if you change the default location via a + server option), making sure the file is readable by the + authd process and NOT readable/writable by others + ("chmod o-rw"). If the permissions + are not set correctly, authd will refuse to + encrypt.

      +
    4. + +
    5. + Running
      + authd should be able to read + /proc/net/tcp and/or + /proc/net/tcp6 to actually match users to + ports-- although it will run without these files. + +

      A sample xinetd configuration file has been + provided; copying xinetd.conf.auth to + /etc/xinetd.d should work for Red Hat + distributions. Be sure to make any changes needed to + the default values and path as needed then + restart/reload the xinetd daemon to use it.

      + +

      All of the options available can be seen with the + "-h" option. Some notes on some of the less + obvious options and parameters:

      + +
        +
      • --abrupt
        + If an error occurs after the client has sent the + port pair, just drop the connection rather than tell + the client (allowed by RFC 1413). authd may do this + anyway for certain errors that prevent it from + sending a reply (I/O error or an out of memory + situation). "--abrupt" overrides + "-e" and "--xerror".
      • + +
      • -E[cipher]
        + Any symmetric block/stream encryption method + supported by the installed openssl can be used as a + parameter. To see a list of available + ciphers, use "openssl enc + -h"
      • + +
      • -l[mask]
        + An optional base 10, base 8 (prefix with + "0"), or base 16 (prefix with + "0x") bit mask of system log priority + levels that you wish to log. For example, an + mask of 178 + ("-l017") only logs messages of priority + error or higher.
        +
      • + +
      • + --fn[=uint]
        + Sends the full-name/"finger" info rather than the + username. Some systems contain additional fields of + information after the full name of a person, such + as the office, office phone number and home phone, + separated by commas. To display only the first + field, specify "1". To specify up to two + fields, specify "2"... and so on. + +

        If the "-n" option is also specified, + then the numeric user id will be followed by the + 2nd up to uint fields providing that + uint is greater than two.

        +
      • + +
      • --hybrid
        + Only applies to IPv6 addresses activated with the + "--verbose" option. When used, the bottom 32 bits of + the address with be displayed in the traditional IPv4 + format of four dot separated base 10 numbers rather + than the IPv6 style of eight 16-bit colon separated + hex pairs.
      • + +
      • --mapped=ipv6
        + Allows IPv6 addresses whose first 96 bits (in other + words, everything except for the last 32 bits) are + ipv6 to match IPv4 addresses which are + identical to the bottom 32-bits of the IPv6 address. + Useful for IPv6/IPv4 multi-interface environments + where IPv4 addresses on different interfaces are + mapped to IPv6 addresses. It does not match IPv4 + "localhost" (127.0.0.1) + with IPv6's equivalent (::1).
      • + +
      • + --os[=rfc1340]
        + Without an argument, it will display the same value + returned by the "uname" command as the + operating system, rather than "UNIX". You may wish to + do this if the username returned (perhaps from pam + talking to a Windows server) does not make sense + within a traditional UNIX or Linux system.
      • + +
      • --resolve
        + Only applies to addresses and ports activated with + the "--verbose" option. Causes in.authd + to resolve addresses using nameservers, and replace + service port numbers with their names, when + available. Resolving addresses slows the server + down.
      • + +
      • + --username[=login]
        + + Causes authd to report the username login + for all valid established tcp connections, regardless + of the actual user. login must point to a + valid entry in the password database. If used in + conjunction with "-n", the uid of the + login will be returned. It will + not change the uid number provided with the + "--verbose" option. + "--username" is useful for providing the + actual user on single user workstations or servers + that have changed their original associated uids to + effective ones. It is also useful for masking the + true username for privacy purposes (in this case + authd is running as a dummy placebo server).
      • + +
      • + --verbose
        + Adds the following information after the username + or full name (depending on the option selected), + separated by commas: + +
          +
        • true userid number
          + Different from "-n" which is affected + by "--username".
        • + +
        • time stamp
          + Date and time is provided in ASCII ISO 8601 + UTC/Zulu (aka Greenwich Median, or GMT) time. The + day of week and time in the authd's local + timezone using the locale's format and encoding + are also provided in parentheses.
        • + +
        • local address and port
          + Port is separated from the address by a vertical + bar, "local" is from the perspective of the authd + server.
        • + +
        • remote address and port
          + Port is separated from the address by a vertical + bar, "remote" is from the perspective of the + authd server.
        • +
        +
      • +
      + The authd daemon will not read any input from stdin if + port pairs are specified as parameters. Also, only the + first port pair will be processed unless the + "-m" option is specified. +
    6. + +
    7. + Testing + +
        +
      1. Run "netstat -A inet -n" and find an + established tcp connection.
      2. + +
      3. + Input the two ports prefixed with colons as single + command line argument (no whitespace unless the + entire pair is enclosed in quotes for the command + line parser), in the same order, separated by a + comma. Example: + +

        $ /usr/sbin/in.inetd + 33201,6667

        +
      4. + +
      5. Execute "telnet localhost auth" and + type the two ports separated by a comma. The two + ports selected must have a foreign address of + localhost, or 127.0.0.1 as + well as a matching local address. If they do + not, a NO-USER error will be + returned.
      6. +
      +
    8. +
    +
  4. + +
  5. + DIFFERENCES FROM PIDENTD 3.0.18 + +
      +
    • no config file
      + There is no "/etc/ident.conf", as all the + options you need for a simple inet super daemon based + server can be easily passed from the command line
    • + +
    • no special crypto tools
      + Key generation requires no special tools; a plain text + pass phrase in a file is all that's required to encrypt. + To decrypt, the openssl enc tool is used.
    • + +
    • no standalone server mode
      + For a simple server, launching via the ubiquitous + inetd/xinetd is all that's needed. The super server + provides most of the options present in pidentd.
    • + +
    • no protocol extensions
      + The VERSION and QUIT commands are + unnecessary, a security risk in the case of + VERSION, and a violation of RFC 1413 protocol. + As they are not used by any client, they have been + intentionally omitted. The "-e" option is + instead used to mask error messages.
      +
    • + +
    • no automatic verbose encryption
      + Encrypting replies does not automatically include port + and time information, which makes the reply excessively + long. This information may be included with the + "--verbose" option.
    • +
    +
  6. + +
  7. + HOW TO INCREASE PRIVACY + +
      +
    • You can allow users to either opt-out or opt-in from + exposing their userid creating a file in their home + directory (defaults are "~/.noident" and + "~/.ident" respectively) and by setting the + appropriate server option ("-N" or + "--ident"). If both options are set then + "~/.noident" will cancel out a + "~/.ident" if both are present. If a file is + present (or not present) which indicates that the user + does not wish his information to be revealed, a + HIDDER-USER error message is returned.
    • + +
    • + If you just want an ident server to speed up broken + servers that insist on some form of ident but you don't + want to reveal any usernames, you can make authd "lie" + to clients and tell them that the ports are owned by + any arbitrary user with the "--username" + option. When set to its default, the authd daemon will + reply with either NO-USER errors or + "nobody" as the port owner. Note that the + argument supplied to "--username" must be a + valid username. As some daemons do run as + "nobody", you may wish to create a special + username just for authd, such as + "somebody", using the command: + +

      $ /usr/sbin/useradd -s /sbin/nologin -r + somebody

      +
    • + +
    • Encryption allows the system administrator owning the + authd server to be aware of any ident information that is + sent to him from remote sites while not unnecessarily + exposing the usernames to any anonymous system.
    • + +
    • The "-e" option can be used to return + UNKNOWN-ERROR instead of + INVALID-PORT, NO-USER, and + HIDDEN-USER.
      +
    • +
    +
  8. + +
  9. + HOW TO USE ENCRYPTION + +
      +
    1. put a plain text password or pass phrase that is + terminated by a newline in the file + "/etc/ident.key". Any additional data after + the newline is ignored. If the pass phrase is in a + different file and/or location, use the + "--passwd" option to tell authd where it + is.
    2. + +
    3. + Make sure the owner/group and permissions are set so + that the daemon (which usually runs as + "nobody" if you use the default xinetd + configuration file) can read it. Make sure that other + can't read or write to it by using: + +

      $ chmod o-rw + /etc/ident.key

      + +

      authd will refuse to encrypt if this is not + done.

      +
    4. + +
    5. + To decrypt the string, the "openssl" tool + (using the "enc" sub-tool) is needed. If the + base64 encrypted string is longer than 64 characters, + it will need to be broken into multiple lines of 64 + characters or less (why? because openssl enc -base64 + doesn't like it any other way-- even though base64 only + needs line breaks for e-mail). Feed the short base64 + string into the command: + +

      $ /usr/bin/openssl enc -d -base64 + -aes-128-cbc -pass file:/etc/ident.key

      + +

      (Change the cipher to what's appropriate if you did + not use the default for the "-E" authd + option or the default was changed in + config.h) Use enc's + -in option if the base64 encryption is + stored in a file rather than being piped into + stdin)

      +
    6. + +
    7. Do understand the security ramifications of + storing a password/pass phrase in unencrypted form on a + file system. A system is secure if the cost of + breaking the system is greater than the value of the + data. Thus, do not increase the value of the authd + password by using it anywhere else-- it should only be + used to encrypt usernames & userids and address/port + info returned by "--verbose" -- (relatively + low value information already readable by any local + user)
    8. +
    +
  10. + +
  11. + INTERNATIONALIZATION + +
      +
    • Sometimes, the username and/or gecos field returned + by the system may not be in ASCII. An example would be a + system that authenticates against accounts stored on + Windows. Windows permits non-ASCII in their usernames and + Name/Comment descriptions. In these cases, use the + "--codeset" option to specify the character + encoding/charset used. This will not convert any + messages; it will simply inform the client as to the + character encoding. The character encoding will + not be sent to the client if the response + appears to be all ASCII (all printable characters; no + control characters), even if the option is + specified.
    • + +
    • in the rare case that the string to be sent is not + ASCII, a --codeset has been specified without + the optional parameter, and the program is unable to + determine the codeset used by the operating system, + "X-UNKNOWN" will be returned as the + codeset.
    • + +
    • + You may want error messages (also local timestamps with + the --verbose option) to be sent in a different locale + from the current locale (inetd/xinetd often is + configured to launch daemons in the "C" + locale). The locale to use can be configured with the + "--lang" option. By default, the daemon + starts in the locale of the parent (usually + xinetd/inetd) that launched it. If --codeset + is also specified, it overrides the character encoding + of the specified locale. + +

      Be aware that many system log daemons are not + capable of handling non-ASCII yet, so combining this + with the "-l" option may not produce + readable syslog messages.

      +
    • +
    +
  12. + +
  13. + EXTENDED ERROR MESSAGES + +

    These only appear when authd is launched with the + "--xerror" option, because some server + administrators do not believe in giving outsiders any + useful information regarding the state of their servers. + However, the --xerror is useful for diagnostics + and troubleshooting.

    + +
      +
    • + X-PROC
      + either /proc/net/tcp or + /proc/net/tcp6 was not in the format that + authd expected it to be in. This may be because: + +
        +
      1. the files are not part of a true linux + /proc filesystem
      2. + +
      3. you are running a modified or experimental + kernel
      4. + +
      5. you are running a kernel much newer than this + program's last update and the file format has + changed
      6. + +
      7. the proc file macros in config.h have been + changed to point to something else
      8. +
      +
    • + +
    • X-NAME
      + A username was specified as an argument, but the + username couldn't be found in the password database + (/etc/passwd, NIS, or whatever the system + uses).
    • + +
    • X-UID
      + The UID taken from /proc/net/tcp6 or + /proc/net/tcp couldn't be found in the + password database.
    • + +
    • X-FILE
      + The pathname for the .ident or + .noident file (home directory path + + filename) was excessively long or bogus.
    • + +
    • X-CRYPTO
      + Suffixed by zero or more sequences of dashes and eight + digit hexadecimal numbers. Either the pass phrase file + couldn't be opened (wrong filename, doesn't exist, wrong + permissions (must be readable by authd and NOT + readable/writable by "others"), the pass phrase was too + short for the given encryption, the crypto algorithm was + inappropriate for the type of data (for example, not + symmetric or does not permit non-fixed lengths), or some + other internal (usually memory resource related) + condition.
    • + +
    • X-ERRNO
      + Suffixed with a dash and a decimal number corresponding + to what was returned by errno. Usually will occur due to + an I/O error or an out-of-memory condition. On Linux, + 2 is a "file not found" and 12 + is an out of memory condition. Note that some out of + memory conditions will cause the server to exit before + printing a message.
      +
    • + +
    • X-RFC1413
      + The userid reply was longer than 512 characters and/or + contained CRLF. While this shouldn't happen with sane + data, this could possibly occur if an exceptionally + long/strange gecos field and the combination of + "--verbose" and "--fn".
    • +
    +
  14. +
+ + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..87126a2 --- /dev/null +++ b/README.md @@ -0,0 +1,139 @@ +# authd: a RFC 1413 ident protocol daemon + +* * * + +1. FEATURES + * written in C; small and fast + * two operation modes: + 1. server via inetd/xinetd + 2. script/interactive via command line arguments + * supports IPv6 and IPv4 + * pidentd option compatibility + * easy to use openssl compatible strong symmetric encryption + * many privacy and anonymizing options + * works well even with broken clients + * internationalized log and help messages + * free software licensed under the GPL. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. +2. REQUIREMENTS & SETUP + 1. Building + Although authd was built and tested on Red Hat Linux 9, Red Hat Enterprise Linux and Fedora Core 1 & 2, it will probably compile on any recent 2003/2004-era GNU/Linux distro with openssl and recent versions of the GNU tool chain (compiler + make) and GNU C library. + + authd does not require autoconf. If needed, change any defaults by editing the config.h file. To build, simply run "make" + + 2. Installing + "make install" will install "in.authd" and any translations in "/usr/local/sbin" and "/usr/local/locale" respectively, so you'll need to set the make variable prefix if you want the files to go somewhere else than "/usr/local". It will install as the filename "in.authd" to reflect that it is intended to run as a inetd/xinetd hosted server; in other words, server input/output is connected to stdin and stdout. + + If you're using encryption, put a one line pass phrase in the file "/etc/ident.key" (or another place if you change the default location via a server option), making sure the file is readable by the authd process and NOT readable/writable by others ("chmod o-rw"). **If the permissions are not set correctly, authd will refuse to encrypt.** + + 3. Running + authd should be able to read /proc/net/tcp and/or /proc/net/tcp6 to actually match users to ports-- although it will run without these files. + + A sample xinetd configuration file has been provided; copying xinetd.conf.auth to /etc/xinetd.d should work for Red Hat distributions. Be sure to make any changes needed to the default values and path as needed then restart/reload the xinetd daemon to use it. + + All of the options available can be seen with the "-h" option. Some notes on some of the less obvious options and parameters: + + * --abrupt + If an error occurs after the client has sent the port pair, just drop the connection rather than tell the client (allowed by RFC 1413). authd may do this anyway for certain errors that prevent it from sending a reply (I/O error or an out of memory situation). "--abrupt" overrides "-e" and "--xerror". + * -E[cipher] + Any symmetric block/stream encryption method supported by the installed openssl can be used as a parameter. To see a list of available ciphers, use "openssl enc -h" + * -l[mask] + An optional base 10, base 8 (prefix with "0"), or base 16 (prefix with "0x") bit mask of system log priority levels that you wish to log. For example, an mask of 178 ("-l017") only logs messages of priority error or higher. + + * --fn[=uint] + Sends the full-name/"finger" info rather than the username. Some systems contain additional fields of information after the full name of a person, such as the office, office phone number and home phone, separated by commas. To display only the first field, specify "1". To specify up to two fields, specify "2"... and so on. + + If the "-n" option is also specified, then the numeric user id will be followed by the 2nd up to uint fields providing that uint is greater than two. + + * --hybrid + Only applies to IPv6 addresses activated with the "--verbose" option. When used, the bottom 32 bits of the address with be displayed in the traditional IPv4 format of four dot separated base 10 numbers rather than the IPv6 style of eight 16-bit colon separated hex pairs. + * --mapped=ipv6 + Allows IPv6 addresses whose first 96 bits (in other words, everything except for the last 32 bits) are ipv6 to match IPv4 addresses which are identical to the bottom 32-bits of the IPv6 address. Useful for IPv6/IPv4 multi-interface environments where IPv4 addresses on different interfaces are mapped to IPv6 addresses. _It does not match IPv4 "localhost" (127.0.0.1) with IPv6's equivalent (::1)._ + * --os[=rfc1340] + Without an argument, it will display the same value returned by the "uname" command as the operating system, rather than "UNIX". You may wish to do this if the username returned (perhaps from pam talking to a Windows server) does not make sense within a traditional UNIX or Linux system. + * --resolve + Only applies to addresses and ports activated with the "--verbose" option. Causes in.authd to resolve addresses using nameservers, and replace service port numbers with their names, when available. _Resolving addresses slows the server down._ + * --username[=login] + Causes authd to report the username login for all valid established tcp connections, regardless of the actual user. login must point to a valid entry in the password database. If used in conjunction with "-n", the uid of the login will be returned. It will _not_ change the uid number provided with the "--verbose" option. "--username" is useful for providing the actual user on single user workstations or servers that have changed their original associated uids to effective ones. It is also useful for masking the true username for privacy purposes (in this case authd is running as a dummy placebo server). + * --verbose + Adds the following information after the username or full name (depending on the option selected), separated by commas: + * true userid number + Different from "-n" which is affected by "--username". + * time stamp + Date and time is provided in ASCII ISO 8601 UTC/Zulu (aka Greenwich Median, or GMT) time. The day of week and time in the authd's local timezone using the locale's format and encoding are also provided in parentheses. + * local address and port + Port is separated from the address by a vertical bar, "local" is from the perspective of the authd server. + * remote address and port + Port is separated from the address by a vertical bar, "remote" is from the perspective of the authd server.The authd daemon will not read any input from stdin if port pairs are specified as parameters. Also, only the first port pair will be processed unless the "-m" option is specified. + 4. Testing + 1. Run "netstat -A inet -n" and find an established tcp connection. + 2. Input the two ports prefixed with colons as single command line argument (no whitespace unless the entire pair is enclosed in quotes for the command line parser), in the same order, separated by a comma. Example: + + $ /usr/sbin/in.inetd 33201,6667 + + 3. Execute "telnet localhost auth" and type the two ports separated by a comma. _The two ports selected must have a foreign address of localhost, or 127.0.0.1 as well as a matching local address._ If they do not, a NO-USER error will be returned. +3. DIFFERENCES FROM PIDENTD 3.0.18 + * no config file + There is no "/etc/ident.conf", as all the options you need for a simple inet super daemon based server can be easily passed from the command line + * no special crypto tools + Key generation requires no special tools; a plain text pass phrase in a file is all that's required to encrypt. To decrypt, the openssl enc tool is used. + * no standalone server mode + For a simple server, launching via the ubiquitous inetd/xinetd is all that's needed. The super server provides most of the options present in pidentd. + * no protocol extensions + The VERSION and QUIT commands are unnecessary, a security risk in the case of VERSION, and a violation of RFC 1413 protocol. As they are not used by any client, they have been intentionally omitted. The "-e" option is instead used to mask error messages. + + * no automatic verbose encryption + Encrypting replies does not automatically include port and time information, which makes the reply excessively long. This information may be included with the "--verbose" option. +4. HOW TO INCREASE PRIVACY + * You can allow users to either opt-out or opt-in from exposing their userid creating a file in their home directory (defaults are "~/.noident" and "~/.ident" respectively) and by setting the appropriate server option ("-N" or "--ident"). If both options are set then "~/.noident" will cancel out a "~/.ident" if both are present. If a file is present (or not present) which indicates that the user does not wish his information to be revealed, a HIDDER-USER error message is returned. + * If you just want an ident server to speed up broken servers that insist on some form of ident but you don't want to reveal any usernames, you can make authd "lie" to clients and tell them that the ports are owned by any arbitrary user with the "--username" option. When set to its default, the authd daemon will reply with either NO-USER errors or "nobody" as the port owner. Note that the argument supplied to "--username" must be a valid username. As some daemons do run as "nobody", you may wish to create a special username just for authd, such as "somebody", using the command: + + $ /usr/sbin/useradd -s /sbin/nologin -r somebody + + * Encryption allows the system administrator owning the authd server to be aware of any ident information that is sent to him from remote sites while not unnecessarily exposing the usernames to any anonymous system. + * The "-e" option can be used to return UNKNOWN-ERROR instead of INVALID-PORT, NO-USER, and HIDDEN-USER. + +5. HOW TO USE ENCRYPTION + 1. put a plain text password or pass phrase that is terminated by a newline in the file "/etc/ident.key". Any additional data after the newline is ignored. If the pass phrase is in a different file and/or location, use the "--passwd" option to tell authd where it is. + 2. Make sure the owner/group and permissions are set so that the daemon (which usually runs as "nobody" if you use the default xinetd configuration file) can read it. Make sure that other can't read or write to it by using: + + $ chmod o-rw /etc/ident.key + + authd will refuse to encrypt if this is not done. + + 3. To decrypt the string, the "openssl" tool (using the "enc" sub-tool) is needed. If the base64 encrypted string is longer than 64 characters, it will need to be broken into multiple lines of 64 characters or less (why? because openssl enc -base64 doesn't like it any other way-- even though base64 only needs line breaks for e-mail). Feed the short base64 string into the command: + + $ /usr/bin/openssl enc -d -base64 -aes-128-cbc -pass file:/etc/ident.key + + (Change the cipher to what's appropriate if you did not use the default for the "-E" authd option or the default was changed in config.h) Use enc's -in option if the base64 encryption is stored in a file rather than being piped into stdin) + + 4. **Do understand the security ramifications of storing a password/pass phrase in unencrypted form on a file system.** A system is secure if the cost of breaking the system is greater than the value of the data. Thus, do not increase the value of the authd password by using it anywhere else-- it should only be used to encrypt usernames & userids and address/port info returned by "--verbose" -- (relatively low value information already readable by any local user) +6. INTERNATIONALIZATION + * Sometimes, the username and/or gecos field returned by the system may not be in ASCII. An example would be a system that authenticates against accounts stored on Windows. Windows permits non-ASCII in their usernames and Name/Comment descriptions. In these cases, use the "--codeset" option to specify the character encoding/charset used. This will _not_ convert any messages; it will simply inform the client as to the character encoding. The character encoding will _not_ be sent to the client if the response appears to be all ASCII (all printable characters; no control characters), even if the option is specified. + * in the rare case that the string to be sent is not ASCII, a --codeset has been specified without the optional parameter, and the program is unable to determine the codeset used by the operating system, "X-UNKNOWN" will be returned as the codeset. + * You may want error messages (also local timestamps with the --verbose option) to be sent in a different locale from the current locale (inetd/xinetd often is configured to launch daemons in the "C" locale). The locale to use can be configured with the "--lang" option. By default, the daemon starts in the locale of the parent (usually xinetd/inetd) that launched it. If --codeset is also specified, it overrides the character encoding of the specified locale. + + Be aware that many system log daemons are not capable of handling non-ASCII yet, so combining this with the "-l" option may not produce readable syslog messages. + +7. EXTENDED ERROR MESSAGES + + These only appear when authd is launched with the "--xerror" option, because some server administrators do not believe in giving outsiders any useful information regarding the state of their servers. However, the --xerror is useful for diagnostics and troubleshooting. + + * X-PROC + either /proc/net/tcp or /proc/net/tcp6 was not in the format that authd expected it to be in. This may be because: + 1. the files are not part of a true linux /proc filesystem + 2. you are running a modified or experimental kernel + 3. you are running a kernel much newer than this program's last update and the file format has changed + 4. the proc file macros in config.h have been changed to point to something else + * X-NAME + A username was specified as an argument, but the username couldn't be found in the password database (/etc/passwd, NIS, or whatever the system uses). + * X-UID + The UID taken from /proc/net/tcp6 or /proc/net/tcp couldn't be found in the password database. + * X-FILE + The pathname for the .ident or .noident file (home directory path + filename) was excessively long or bogus. + * X-CRYPTO + Suffixed by zero or more sequences of dashes and eight digit hexadecimal numbers. Either the pass phrase file couldn't be opened (wrong filename, doesn't exist, wrong permissions (must be readable by authd and NOT readable/writable by "others"), the pass phrase was too short for the given encryption, the crypto algorithm was inappropriate for the type of data (for example, not symmetric or does not permit non-fixed lengths), or some other internal (usually memory resource related) condition. + * X-ERRNO + Suffixed with a dash and a decimal number corresponding to what was returned by errno. Usually will occur due to an I/O error or an out-of-memory condition. On Linux, 2 is a "file not found" and 12 is an out of memory condition. Note that some out of memory conditions will cause the server to exit before printing a message. + + * X-RFC1413 + The userid reply was longer than 512 characters and/or contained CRLF. While this shouldn't happen with sane data, this could possibly occur if an exceptionally long/strange gecos field and the combination of "--verbose" and "--fn". diff --git a/authd.c b/authd.c new file mode 100644 index 0000000..a2072de --- /dev/null +++ b/authd.c @@ -0,0 +1,1041 @@ +/* authd, a lightweight IPv6/IPv4 inetd RFC 1413 ident protocol daemon + * Copyright 2004 by Red Hat, Inc. + * + * THIS PROGRAM IS RELEASED UNDER THE GPL WITH THE ADDITIONAL EXEMPTION + * THAT COMPILING, LINKING, AND/OR USING OPENSSL IS ALLOWED. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * Initial Author: Adrian Havill + */ + +static const char RCSID[] = "$Revision: 1.18 $ $Date: 2004/07/28 16:04:05 $"; + +#include "config.h" + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#if !defined NDEBUG + #include +#endif + +#define _(ascii_msgid) gettext(ascii_msgid) + +static struct { + int log_mask; + int abrupt, help, hybrid, resolve, verbose, xerror; // longopt bool is pint + bool debug, error, log, number, other, Version; + char *codeset, *ident, *lang, *mapped, *os, *passwd, *username; + char *Encrypt, *Noident; + unsigned timeout, fn; unsigned long long multiquery; +} opt; + +static void log_printf(int level, const char *s, ...) { + if (opt.debug || level != LOG_DEBUG) { + va_list ap; + + if (s == NULL || *s == '\0') { + s = strerror(errno); + assert(strchr(s, '%') == NULL); + } + if (opt.log) { + va_start(ap, s); + vsyslog(level, s, ap); + va_end(ap); + } + va_start(ap, s); + if (vfprintf(level == LOG_INFO ? stdout : stderr, s, ap) < 0) { + perror(program_invocation_name); + level = INT_MIN; + } + va_end(ap); + } + if (level <= LOG_ERR) exit(EXIT_FAILURE); +} +#define debug(...) log_printf(LOG_DEBUG, __VA_ARGS__) +#define show(...) log_printf(LOG_INFO, __VA_ARGS__) +#define log_notice(...) log_printf(LOG_NOTICE, __VA_ARGS__) +#define log_warning(...) log_printf(LOG_WARNING, __VA_ARGS__) +#define handle_error(...) log_printf(LOG_ERR, __VA_ARGS__) + +#if !defined NDEBUG +static const void *const LAST_VA_ARG = "FIXME"; // debugging sentinel +#endif + +static char *vstrdup(const char *s, ...) { + va_list ap; char *dup; + + assert(s != LAST_VA_ARG); + va_start(ap, s); + while (s == NULL || *s == '\0') { + s = va_arg(ap, const char *); + assert(s != LAST_VA_ARG); + } + va_end(ap); + if ((dup = strdup(s)) == NULL) handle_error(NULL); + return dup; +} +#if !defined NDEBUG + #define vstrdup(s, ...) vstrdup((s) ,##__VA_ARGS__ ,LAST_VA_ARG) +#endif + +static void show_help(void) { + show(_("%s [options]... [request]...\n"), program_invocation_short_name); + show(_(" -d\t\t\tOutput debug messages\n")); + show(_(" -E[cipher]\t\tEncrypt username using [%s]\n"), DFL_CIPHER); + show(_(" -e\t\t\tSend UNKNOWN-ERROR for common error messages\n")); + show(_(" -l[mask]\t\tLog to syslog, [mask] for priority levels\n")); + show(_(" -m[reps]\t\tAllow at most [unlimited] requests/connection\n")); + show(_(" -N[basename]\t\tHide users with ~/[%s] file\n"), DFL_NO_IDENT); + show(_(" -n\t\t\tSend uid number instead of username\n")); + show(_(" -o\t\t\tSend OTHER instead of the operating system\n")); + show(_(" -t[secs]\t\tTimeout request after [%u] seconds\n"), DFL_T_O); + show(_(" -V\t\t\tPrint program and version information\n")); + show(_(" --abrupt\t\tDisconnect without displaying error msgs\n")); + show(_(" --codeset=rfc1340\tSend [charset] if reply is not ASCII\n")); + show(_(" --fn[=fields]\t\tUse [all] gecos fields instead of username\n")); + show(_(" --hybrid\t\tUse hybrid notation (ex. ::127.0.0.1) for IPv6\n")); + show(_(" --ident[=basename]\tHide users with no ~/[%s]\n"), DFL_IDENT); + show(_(" --lang=lc\t\tLocalize messages, charsets, & time to [locale]\n")); + show(_(" --mapped=ipv6\t\tMap addresses with same top 96 bits to IPv4\n")); + show(_(" --os[=rfc1340]\t\tUse [uname], not %s, as OS name\n"), DFL_OS); + show(_(" --passwd=pathname\tUse line 1 of [%s] for crypto\n"), DFL_PASSWD); + show(_(" --resolve\t\tUse host and service names if available\n")); + show(_(" --username[=login]\tUse [%s] as username\n"), DFL_USERNAME); + show(_(" --verbose\t\tAdd real uid, addresses/ports, & timestamps\n")); + show(_(" --xerror\t\tSend more helpful error messages for rare errors\n")); +} + +static void show_version(void) { + show("%s-%s:\n\t%s\n\t%s\n", PACKAGE, VERSION, RCSID, CONTACT); +} + +static bool is_print_ascii(const char *s) { + assert(s != NULL); + while (*s != '\0') + if (!isascii(*s) || iscntrl(*s)) return false; + else s++; + return true; +} + +#define is_in_range(lo,x,hi) ((lo) <= (x) && (x) <= (hi)) + +static bool is_rfc1413_token(const char *s) { + assert(s != NULL); + if (!is_print_ascii(s) || strchr(s, ':') != NULL) return false; + return is_in_range((size_t) 1, strlen(s), (size_t) 64); +} + +static bool is_bad_strto(const char *s, const char *endptr) { + if (errno == ERANGE || errno == EINVAL) return true; + return endptr == s || (*endptr != '\0' && !isspace(*endptr)); +} + +static const int HEX_DIG = 2; // two digits in 8-bit base 16 octet +static const size_t HEX_LEN_MAX = 32; // strlen() of /proc/net/tcp6 address + +static char *created_addr_hex(const unsigned char *addr, size_t addr_size) { + char *addr_hex; + size_t addr_hex_size = addr_size * HEX_DIG + sizeof '\0'; + + if ((addr_hex = calloc(addr_hex_size, sizeof(char))) != NULL) { + size_t z = addr_size; char *p = addr_hex; + + while (z != 0) { + int n = snprintf(p, addr_hex_size, "%.*hhX", HEX_DIG, addr[--z]); + + assert(n >= 0 && (size_t) n < addr_hex_size); + addr_hex_size -= (size_t) n; p += (size_t) n; + } + } + return addr_hex; +} + +static char *created_pton_hex(const char *prefix) { + struct in6_addr addr; const size_t SIZE = sizeof(addr.s6_addr); + + assert(prefix != NULL); + if (inet_pton(AF_INET6, prefix, &addr) <= 0) return NULL; + return created_addr_hex((const void *) addr.s6_addr, SIZE); +} + +static void create_opt(int argc, char *argv[]) { + enum { PRE_FIRST_LONGOPT = UCHAR_MAX, // no short opt value overlap + CODESET_LONGOPT, IDENT_LONGOPT, FN_LONGOPT, LANG_LONGOPT, + MAPPED_LONGOPT, OS_LONGOPT, PASSWD_LONGOPT, USERNAME_LONGOPT + }; + int c, i; + const char *const IPV4_HEX_0 = "00000000"; + const char *const S_FMT = _("%s: invalid argument to --%s: %s\n"); + const char *const C_FMT = _("%s: invalid argument to -%c: %s\n"); + const char *const SHORT_OPTS = "dE::ehl::m::N::not::V"; // pidentd compat + const struct option LONG_OPTS[] = { + { "abrupt", no_argument, &opt.abrupt, true }, + { "codeset", required_argument, NULL, CODESET_LONGOPT }, + { "fn", optional_argument, NULL, FN_LONGOPT }, + { "help", no_argument, NULL, 'h' }, + { "hybrid", no_argument, &opt.hybrid, true }, + { "ident", optional_argument, NULL, IDENT_LONGOPT }, + { "lang", required_argument, NULL, LANG_LONGOPT }, + { "mapped", required_argument, NULL, MAPPED_LONGOPT }, + { "os", optional_argument, NULL, OS_LONGOPT }, + { "passwd", required_argument, NULL, PASSWD_LONGOPT }, + { "resolve", no_argument, &opt.resolve, true }, + { "usage", no_argument, NULL, 'h' }, + { "username", optional_argument, NULL, USERNAME_LONGOPT }, + { "verbose", no_argument, &opt.verbose, true }, + { "xerror", no_argument, &opt.xerror, true }, + { 0, 0, 0, 0 } + }; + + assert(argc > 0 && argv != NULL); + memset(&opt, 0, sizeof(opt)); + opt.passwd = vstrdup(DFL_PASSWD); + if ((opt.mapped = calloc(HEX_LEN_MAX + sizeof '\0', sizeof(char))) == NULL) + handle_error(NULL); + memset(opt.mapped, '0', HEX_LEN_MAX); + opt.multiquery = 1; + opt.timeout = UINT_MAX; + while ((c = getopt_long(argc, argv, SHORT_OPTS, LONG_OPTS, &i)) != -1) { + switch (c) { + struct utsname os; + unsigned long lu; char *endptr, *lc; + + case 'd': opt.debug = true; break; + case 'E': + free(opt.Encrypt); opt.Encrypt = vstrdup(optarg, DFL_CIPHER); + break; + case 'e': opt.error = true; break; + case 'h': opt.help = true; break; + case 'l': + if (optarg != NULL) { + lu = strtoul(optarg, &endptr, 0); + if (lu > UINT_MAX || is_bad_strto(optarg, endptr)) + handle_error(C_FMT, *argv, c, optarg); + else opt.log_mask = (int) lu; + setlogmask(opt.log_mask); + } + opt.log = true; + break; + case 'm': + if (optarg != NULL) { + opt.multiquery = strtoull(optarg, &endptr, 10); + if (is_bad_strto(optarg, endptr)) + handle_error(C_FMT, *argv, c, optarg); + } + else opt.multiquery = ULLONG_MAX; + break; + case 'n': opt.number = true; break; + case 'N': + free(opt.Noident); opt.Noident = vstrdup(optarg, DFL_NO_IDENT); + break; + case 'o': opt.other = true; break; + case 't': + lu = optarg == NULL ? DFL_T_O : strtoul(optarg, &endptr, 10); + if (lu > UINT_MAX || is_bad_strto(optarg, endptr)) + handle_error(C_FMT, *argv, c, optarg); + else if (lu < 30) { + log_notice(_("Timeout's too low; Raising to 30.\n")); + lu = 30; + } + else if (lu != 0 && !is_in_range(60, lu, 180)) + log_notice(_("Timeout should be from 60..180 seconds.\n")); + opt.timeout = (unsigned) lu; + break; + case 'V': opt.Version = true; break; + case CODESET_LONGOPT: + if (!is_rfc1413_token(optarg)) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + free(opt.codeset); opt.codeset = vstrdup(optarg); + break; + case FN_LONGOPT: + if (optarg != NULL) { + lu = strtoul(optarg, &endptr, 10); + if (lu > UINT_MAX || is_bad_strto(optarg, endptr)) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + else opt.fn = (unsigned) lu; + } + else opt.fn = UINT_MAX; + break; + case IDENT_LONGOPT: + free(opt.ident); opt.ident = vstrdup(optarg, DFL_IDENT); + break; + case LANG_LONGOPT: + lc = strlen(optarg) == 0 ? NULL : setlocale(LC_ALL, optarg); + if (lc == NULL) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + else { + free(opt.lang); opt.lang = vstrdup(lc); + debug("LC_ALL = %s\n", opt.lang); + } + break; + case MAPPED_LONGOPT: + free(opt.mapped); + if ((opt.mapped = created_pton_hex(optarg)) == NULL) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + if (strncmp(opt.mapped, IPV4_HEX_0, strlen(IPV4_HEX_0)) != 0) + log_notice(_("Mapped lower 32 bits not 0; ignoring.\n")); + debug("prefix map =%s/%s\n", IPV4_HEX_0, opt.mapped + 8); + break; + case OS_LONGOPT: + if (optarg == NULL && uname(&os) != 0) handle_error(NULL); + free(opt.os); opt.os = vstrdup(optarg, os.sysname); + if (!is_rfc1413_token(opt.os)) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + break; + case PASSWD_LONGOPT: + free(opt.passwd); opt.passwd = vstrdup(optarg, DFL_PASSWD); + if (strlen(opt.passwd) == 0) + handle_error(S_FMT, *argv, LONG_OPTS[i].name, optarg); + break; + case USERNAME_LONGOPT: + free(opt.username); + opt.username = vstrdup(optarg, DFL_USERNAME); + break; + default: + assert(0 == c); // GNU extensions ('\1' and ':') should be off + break; + case '?': exit(EXIT_FAILURE); + } + } + if (optind < argc) + opt.timeout = 0; // don't get client input if request(s) in cmd +} + +static const char *const DELIM = ",: \t\r\n\v\f"; + +static unsigned long long get_tok_ullong(char *s, unsigned base) { + unsigned long long ull = ULLONG_MAX; + + assert(base <= 36); + if ((s = strtok(s, DELIM)) != NULL) { + char *endptr; + + ull = strtoull(s, &endptr, (int) base); + if ((errno == ERANGE && ull == ULLONG_MAX) || is_bad_strto(s, endptr)) + errno = EINVAL; + } + else errno = EINVAL; + return ull; +} + + +static unsigned long get_tok_uint(char *s, unsigned base) { + unsigned long ul = ULONG_MAX; + + assert(base <= 36); + if ((s = strtok(s, DELIM)) != NULL) { + char *endptr; + + ul = strtoul(s, &endptr, (int) base); + if (ul > UINT_MAX || is_bad_strto(s, endptr)) + errno = EINVAL; + } + else errno = EINVAL; + return ul; +} + +static long get_tok_int(char *s, unsigned base) { + + long l = LONG_MAX; + + assert(base <= 36); + if ((s = strtok(s, DELIM)) != NULL) { + char *endptr; + + l = strtol(s, &endptr, (int) base); + if (l > INT_MAX || is_bad_strto(s, endptr)) + errno = EINVAL; + } + else errno = EINVAL; + return l; +} + + +static void destroy_opt(void) { + free(opt.codeset); free(opt.Encrypt); free(opt.ident); free(opt.lang); + free(opt.Noident); free(opt.os); free(opt.passwd); free(opt.mapped); + free(opt.username); + memset(&opt, 0, sizeof(opt)); +} + +typedef struct { + unsigned long lport, rport; + char *laddr, *raddr; +} request_t; + +typedef int (*getsockaddr_t)(int, struct sockaddr *, socklen_t *); + +static char *created_connected_addr(int sockfd, getsockaddr_t getXXXXname) { + struct sockaddr_storage name; socklen_t namelen = sizeof(name); + char *addr_hex = NULL; + + if (getXXXXname(sockfd, (struct sockaddr *) &name, &namelen) == 0) { + size_t addr_size = 0; + const unsigned char *addr = NULL; + + switch (name.ss_family) { + struct sockaddr_in *sin; struct sockaddr_in6 *sin6; + + case AF_INET: + sin = (struct sockaddr_in *) &name; + addr_size = sizeof(sin->sin_addr.s_addr); + addr = (unsigned char *) &sin->sin_addr.s_addr; + break; + case AF_INET6: + sin6 = (struct sockaddr_in6 *) &name; + addr_size = sizeof(sin6->sin6_addr.s6_addr); + addr = (unsigned char *) sin6->sin6_addr.s6_addr; + break; + default: + errno = EAFNOSUPPORT; + } + addr_hex = created_addr_hex(addr, addr_size); + } + else if (errno == ENOTSOCK) + errno = 0; // no error if invoked from cmdline + return addr_hex; +} + +static request_t created_request(int argc, char *argv[]) { + request_t in; + char *line = NULL; size_t n = 0; + + assert(argv != NULL && argc >= 1); + if (optind >= argc) { + if (fflush_unlocked(stdout) == EOF) handle_error(NULL); + in.laddr = created_connected_addr(STDIN_FILENO, getsockname); + in.raddr = created_connected_addr(STDIN_FILENO, getpeername); + if (opt.timeout != UINT_MAX) + alarm(opt.timeout); + if (getline(&line, &n, stdin) == (ssize_t) -1) { + if (feof_unlocked(stdin)) { + free(line); + exit(EXIT_SUCCESS); + } + assert(ferror(stdin)); + handle_error(NULL); + } + alarm(0); + } + else { + line = vstrdup(argv[(size_t) optind++]); + in.laddr = in.raddr = NULL; + } + in.lport = get_tok_uint(line, 10); in.rport = get_tok_uint(NULL, 10); + debug("local_address =%s:%04lX\n", in.laddr, in.lport); + debug("rem_address =%s:%04lX\n", in.raddr, in.rport); + free(line); + return in; +} + +static char *created_hostname(const char *node) { + char *s; + struct addrinfo *res, hints = { ai_flags: AI_CANONNAME }; + + assert(node != NULL && *node != '\0'); + if (opt.resolve && getaddrinfo(node, NULL, &hints, &res) == 0) { + s = vstrdup(res->ai_canonname, node); freeaddrinfo(res); + } + else s = vstrdup(node); + return s; +} + +static const unsigned long PORT_MIN = 1, PORT_MAX = 65535; + +static char *created_servicename(unsigned long port) { + char *s; + const char *const PROTO = "tcp", *const PORT_FMT = "%lu"; + const int NS_PORT = (int) htons((uint16_t) port); + struct servent *res = opt.resolve ? getservbyport(NS_PORT, PROTO) : NULL; + + assert(is_in_range(PORT_MIN, port, PORT_MAX)); + if (res == NULL || res->s_name == NULL || *res->s_name == '\0') { + if (asprintf(&s, PORT_FMT, port) < 0) handle_error(NULL); + } + else s = vstrdup(res->s_name); + return s; +} + +static char *get_created_tok_addr(const char *peer_addr_hex) { + const char *const IPV6_0 = ":0000", *const IPV6_0_RUN = "::"; + const size_t IPV6_SIZE_MAX = INET6_ADDRSTRLEN + sizeof '\0'; + const size_t IPV6_0_RUN_LEN = strlen(IPV6_0_RUN); + char *addr = calloc(sizeof ':' + IPV6_SIZE_MAX, sizeof(char)); + char *addr_hex, *p = addr, *q, *zero = NULL; size_t zero_n = 0; + + if (addr != NULL) { + if ((addr_hex = strtok(NULL, DELIM)) != NULL) { + size_t z = strlen(addr_hex); const bool IS_IPV6 = z > 8; + bool is_16_bits = true; + + if (peer_addr_hex != NULL) { + char peer_128[HEX_LEN_MAX + sizeof '\0']; + char host_128[HEX_LEN_MAX + sizeof '\0']; + + assert(opt.mapped != NULL); + strcpy(peer_128, opt.mapped); strcpy(host_128, opt.mapped); + + /* + If mapping IPV4 to IPV6 space is enabled, + take only last 4 numbers of IPV6 + */ + if(opt.mapped[0]) { + strncpy(host_128, addr_hex+z-8, 8); + strncpy(peer_128, peer_addr_hex, 8); + } else { + strncpy(host_128, addr_hex, z); + strncpy(peer_128, peer_addr_hex, strlen(peer_addr_hex)); + } + + if (strcmp(peer_128, host_128) != 0) return addr; + } + // hex addr must have even number of digits + if ((int) z & 1) { + errno = EINVAL; return NULL; + } + while (z > 1) { + unsigned long ul; char *endptr; + const bool IS_IPV4 = (opt.hybrid && z < 9) || !IS_IPV6; + + addr_hex[z] = '\0'; z -= HEX_DIG; + ul = strtoul(addr_hex + z, &endptr, 16); + if (is_bad_strto(addr_hex + z, endptr)) { + errno = EINVAL; return NULL; + } + if ((!IS_IPV4 || 6 == z) && is_16_bits) + *p++ = ':'; + if (IS_IPV4) + p += sprintf(p, "%lu", ul); + else p += sprintf(p, "%.*lX", HEX_DIG, ul); + if (IS_IPV4 && z != 0) + *p++ = '.'; + is_16_bits = !is_16_bits; + } + } + // compress 16-bit runs of zeros + for (p = strstr(addr, IPV6_0); p != NULL; p = strstr(q, IPV6_0)) { + size_t count = 0; const size_t IPV6_0_LEN = strlen(IPV6_0); + + for (q = p; strncmp(q, IPV6_0, IPV6_0_LEN) == 0; q += IPV6_0_LEN) + count += IPV6_0_LEN; + if (count > zero_n) { + zero_n = count; zero = p; + } + } + if (zero_n >= IPV6_0_RUN_LEN) { + memcpy(zero, IPV6_0_RUN, IPV6_0_RUN_LEN); + zero += IPV6_0_RUN_LEN; zero_n -= IPV6_0_RUN_LEN; + if (zero[zero_n] == ':') + zero_n++; + memmove(zero, zero + zero_n, strlen(zero + zero_n) + 1); + } + // compress four digit hex sequences by removing leading zeros + while ((zero = strstr(addr, ":0")) != NULL) + if (strchr(++zero, ':') == NULL) break; + else memmove(zero, zero + 1, strlen(zero)); + if (addr[1] != ':') + memmove(addr, addr + 1, IPV6_SIZE_MAX); // rm ':' prefix + } + return addr; +} + +static bool is_regular_file(const char *dir, const char *name) { + bool is_existing = false; + + assert(dir != NULL); + if (name != NULL) { + struct stat st; + + if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) { + char *s; + const char *const PATHNAME_FMT = "%s/%s"; + + if (*name != '\0') { + if (asprintf(&s, PATHNAME_FMT, dir, name) < 0) return false; + is_existing = stat(s, &st) == 0 && S_ISREG(st.st_mode); + free(s); + } + else errno = EISDIR; + } + else errno = ENOTDIR; + if (errno == ENOENT) + errno = 0; // don't report X-ERRNO-%d + } + return is_existing; +} + +typedef struct { + bool error; + unsigned lport, rport; char *os, *enc, *s; +} reply_t; + +static const size_t USERID_MAX_LEN = 512; // as per RFC1413 +static const char *const TEXT_READ_MODE = "r"; // passphrase, /proc plaintext + +static bool get_info(reply_t *out, request_t in, const char *tcpname) { + //unsigned long lport, rport, uid, status; FILE *stream; + unsigned long lport, rport, status; FILE *stream; + long uid; + const unsigned long ESTABLISHED = 0x01; + unsigned lineno = 0; + char *laddr = NULL, *raddr = NULL; + bool is_port_pair_found = false; + + char *created_verbose(const char *name, unsigned long id) { + size_t n; time_t tod; + char *s, when[USERID_MAX_LEN], *host1, *port1, *host2, *port2; + const char *const UTC_FMT = "%FT%TZ", *const TZ_FMT = "(%a %EX %z/%Z)"; + const char *const VERBOSE_FMT = "%s:%lu,%s,%s|%s,%s|%s"; + + if (time(&tod) == (time_t) -1) handle_error(NULL); + n = strftime(when, sizeof(when), UTC_FMT, gmtime(&tod)); + strftime(when + n, sizeof(when) - n, TZ_FMT, localtime(&tod)); + host1 = created_hostname(laddr); port1 = created_servicename(lport); + host2 = created_hostname(raddr); port2 = created_servicename(rport); + asprintf(&s, VERBOSE_FMT, name, id, when, host1, port1, host2, port2); + free(host1); free(port1); free(host2); free(port2); + return s; + } + + assert(out != NULL); + if (tcpname == NULL) return false; + if ((stream = fopen(tcpname, TEXT_READ_MODE)) == NULL) { + // some systems won't have tcp6 (and rarely, plain IPv4 tcp) files in + // /proc/net. The absence of either file isn't an error; although + // the lack of both prevents authd from looking up anything + if (errno == ENOENT) { + if (opt.log) log_notice("%s: %s\n", tcpname, strerror(errno)); + errno = 0; + } + else out->error = true; + } + else for (;;) { + unsigned long sl, inode; + uid_t euid; + char line[PROC_MAX_LEN], tmp[PROC_MAX_LEN]; + + // FIXME: setting the buffer to be larger than normal is done to + // lessen (but not eliminate) the chance of the proc file changing + // while in the middle of reading it + if (0 == lineno) { + const size_t SIZE = (size_t) (BUFSIZ * PROC_SIZE); + + if (setvbuf(stream, NULL, _IOFBF, SIZE) != 0) { + out->error = true; break; + } + } + if (fgets_unlocked(line, (int) PROC_MAX_LEN, stream) == NULL) { + if (ferror_unlocked(stream)) + out->error = true; + assert(feof(stream)); + break; + } + else lineno++; + // first line of /proc/net/tcp* is a header that looks similar to: + // sl local rem st tx rx tr tm->when retrnsmt uid timeout inode + if (1 == lineno) continue; + // sample line from tcp (tcp6 just has a bigger ip address): + // 0: 00000000:800B 00000000:0000 0A 0000:0000 00:0000 0000 0000 ... + sl = get_tok_uint(strcpy(tmp, line), 10); // sl (base 10 uint) + laddr = get_created_tok_addr(in.laddr); // local (little endian hex) + lport = get_tok_uint(NULL, 16); // ... local port + raddr = get_created_tok_addr(in.raddr); // remote (little endian hex) + rport = get_tok_uint(NULL, 16); // ... remote port + status = get_tok_uint(NULL, 16); // status (01 = ESTABLISHED) + (void) get_tok_uint(NULL, 16); // tx_queue + (void) get_tok_uint(NULL, 16); // rx_queue + (void) get_tok_uint(NULL, 16); // tr (boolean) + (void) get_tok_ullong(NULL, 16); // tm->when (unit: jiffies) + strtok(NULL, DELIM); // retrnsmt + //uid = get_tok_uint(NULL, 10); // uid (base 10 uint) + uid = get_tok_int(NULL, 10); // uid (base 10 int) + strtok(NULL, DELIM); // timeout + inode = get_tok_uint(NULL, 10); // inode (base 10 uint) + if (errno == EINVAL) { + // format of /proc/net/tcp* has changed or it's a bogus file + debug("%s:%u: %s", tcpname, lineno, line); // XXX: NL terminated? + out->error = true; errno = 0; + out->s = opt.xerror ? vstrdup("X-PROC") : NULL; break; + } + else if (errno != 0) { + // most likely an out-of-memory error + out->error = true; break; + } + else if (*laddr == '\0' || *raddr == '\0') { + // host address doesn't match peer address, so skip it + free(laddr); free(raddr); laddr = raddr = NULL; continue; + } + else euid = (uid_t) uid; + if (lport == in.lport && rport == in.rport && status == ESTABLISHED) { + struct passwd *pwd = getpwuid(euid); + + is_port_pair_found = true; + debug("%-14s=sl:%lu uid:%lu inode:%lu\n", tcpname, sl, uid, inode); + if (opt.username != NULL) { + if ((pwd = getpwnam(opt.username)) == NULL) { + out->error = true; + out->s = opt.xerror ? vstrdup("X-NAME") : NULL; break; + } + else euid = pwd->pw_uid; + } + if (pwd == NULL) { // passwd db doesn't have uid in /proc/net/tcp* + out->error = true; + out->s = opt.xerror ? vstrdup("X-UID") : NULL; break; + } + else { + bool hidden = opt.ident != NULL; + + if (is_regular_file(pwd->pw_dir, opt.ident)) + hidden = false; + if (is_regular_file(pwd->pw_dir, opt.Noident)) + hidden = true; + if (errno) { + out->error = true; + out->s = opt.xerror ? vstrdup("X-FILE") : NULL; + break; + } + else if (hidden) { + out->error = true; out->s = vstrdup("HIDDEN-USER"); break; + } + out->s = vstrdup(pwd->pw_name); + if (opt.number) { + const char *const UID_FMT = "%lu"; + + free(out->s); + if (asprintf(&out->s, UID_FMT, (unsigned long) euid) < 0) { + out->error = true; break; + } + } + if (opt.fn != 0 && *pwd->pw_gecos != '\0') { + char *s = vstrdup(pwd->pw_gecos); + size_t n = 0; + + // gecos field usually just has 1 field, the full name-- + // but sometimes the user's office, office phone and home + // phone will be in csv format + for (unsigned u = 0; u < opt.fn && s[n] != '\0'; u++, n++) + n += strcspn(s + n, ","); + s[--n] = '\0'; + if (opt.number) { + n = strcspn(s, ","); + memmove(s, s + n, strlen(s + n) + 1); + n = strlen(out->s) + strlen(s); + if ((out->s = realloc(out->s, ++n)) == NULL) { + out->error = true; break; + } + strcat(out->s, s); free(s); + } + else { free(out->s); out->s = s; } + } + } + if (opt.verbose && !out->error) { + char *brief = out->s; + + if ((out->s = created_verbose(brief, uid)) == NULL) + out->error = true; + else free(brief); + } + break; + } + else { free(laddr); free(raddr); laddr = raddr = NULL; } + } + free(laddr); free(raddr); + if (stream != NULL && fclose(stream) == EOF) { + out->error = true; out->s = NULL; + } + return is_port_pair_found; +} + +typedef struct { + const EVP_CIPHER *cipher; BIO *writer; BUF_MEM *buffer; + unsigned char *key, *iv, salt[PKCS5_SALT_LEN]; +} crypto_t; + +static bool initialize_crypto(crypto_t *x, const char *filename) { + struct stat file; + bool is_initialized = false; + + assert(filename != NULL && x != NULL); + if (stat(filename, &file) == 0) { + FILE *stream; ssize_t len; + const EVP_MD *const HASH = EVP_md5(); // openssl compat: enc -pass + const size_t KEY_SIZE = EVP_CIPHER_key_length(x->cipher); + const size_t IV_SIZE = EVP_CIPHER_iv_length(x->cipher); + char *pass = NULL; size_t z = 0; + + if (!S_ISREG(file.st_mode)) return false; // no dirs, devs, etc. + if (file.st_mode & (S_IROTH | S_IWOTH)) return false; // no ------rw- + if ((x->key = malloc(KEY_SIZE)) == NULL) return false; + if ((x->iv = malloc(IV_SIZE)) == NULL) return false; + if ((stream = fopen(filename, TEXT_READ_MODE)) == NULL) return false; + if ((len = getline(&pass, &z, stream)) == (ssize_t) -1) return false; + if (fclose(stream) == EOF) return false; + if (len > 0 && pass[(size_t) (len - 1)] == '\n') + pass[(size_t) --len] = '\0'; + if (RAND_pseudo_bytes(x->salt, sizeof(x->salt)) <= 0) return false; + EVP_BytesToKey(x->cipher, HASH, x->salt, pass, len, 1, x->key, x->iv); + memset(pass, 0, len); // XXX: crypto erase + free(pass); + is_initialized = true; + if (opt.debug) { + char line[80] = { '\0' }, *p = line; + int n; size_t size = sizeof(line); + + n = snprintf(p, size, "salt[%2zu bytes]=", sizeof(x->salt)); + assert(n >= 0); + for (z = 0; z < sizeof(x->salt) && n < (int) size; z++) { + p += n; size -= n; + n = snprintf(p, size, "%.*hhX", CHAR_BIT / 4, x->salt[z]); + assert(n >= 0); + } + debug("%s\n", line); p = line; size = sizeof(line); + n = snprintf(p, size, "key[%4d bits]=", (int) KEY_SIZE * CHAR_BIT); + assert(n >= 0); + for (z = 0; z < KEY_SIZE && n < (int) size; z++) { + p += n; size -= n; + n = snprintf(p, size, "%.*hhX", CHAR_BIT / 4, x->key[z]); + assert(n >= 0); + } + debug("%s\n", line); p = line; size = sizeof(line); + n = snprintf(p, size, "iv[%5d bits]=", (int) IV_SIZE * CHAR_BIT); + assert(n >= 0); + for (z = 0; z < IV_SIZE && n < (int) size; z++) { + p += n; size -= n; + n = snprintf(p, size, "%.*hhX", CHAR_BIT / 4, x->iv[z]); + assert(n >= 0); + } + debug("%s\n", line); + memset(line, 0, sizeof(line)); // XXX: crypto erase + } + } + return is_initialized; +} + +static char *created_ciphertext_b64(const char *s) { + BIO *encoder; char *b64; + const char *const MAGIC = "Salted__"; // openssl compat: enc -salt + const char *const NL = "\n"; // is strcat()ed to plaintext + crypto_t x = { cipher: NULL }; + + assert(s != NULL); + OpenSSL_add_all_ciphers(); + if ((x.cipher = EVP_get_cipherbyname(opt.Encrypt)) == NULL) return NULL; + debug("cipher name =%s\n", EVP_CIPHER_name(x.cipher)); + debug("cipher block =%d bytes\n", EVP_CIPHER_block_size(x.cipher)); + switch (EVP_CIPHER_mode(x.cipher)) { + case EVP_CIPH_ECB_MODE: debug("cipher mode =%s\n", "ECB"); break; + case EVP_CIPH_CBC_MODE: debug("cipher mode =%s\n", "CBC"); break; + case EVP_CIPH_CFB_MODE: debug("cipher mode =%s\n", "CFB"); break; + case EVP_CIPH_OFB_MODE: debug("cipher mode =%s\n", "OFB"); break; + case EVP_CIPH_STREAM_CIPHER: debug("cipher mode =%s\n", "stream"); + } + if (!initialize_crypto(&x, opt.passwd)) return NULL; + if ((encoder = BIO_new(BIO_s_mem())) == NULL) return NULL; + else x.writer = encoder; + if ((encoder = BIO_new(BIO_f_base64())) == NULL) return NULL; + else { + BIO_set_flags(encoder, BIO_FLAGS_BASE64_NO_NL); + x.writer = BIO_push(encoder, x.writer); + if (BIO_write(x.writer, MAGIC, strlen(MAGIC)) <= 0) return NULL; + if (BIO_write(x.writer, x.salt, sizeof(x.salt)) <= 0) return NULL; + } + if ((encoder = BIO_new(BIO_f_cipher())) == NULL) return NULL; + else { + BIO_set_cipher(encoder, x.cipher, x.key, x.iv, true); + x.writer = BIO_push(encoder, x.writer); + } + if (BIO_write(x.writer, s, strlen(s)) <= 0) return NULL; + if (BIO_write(x.writer, NL, strlen(NL)) <= 0) return NULL; + if (BIO_flush(x.writer) <= 0) return NULL; + BIO_get_mem_ptr(x.writer, &x.buffer); + if ((b64 = calloc(x.buffer->length + 3, sizeof(char))) != NULL) { + b64[0] = '['; // pidentd compat: base64 in brackets + memcpy(b64 + 1, x.buffer->data, x.buffer->length); + b64[x.buffer->length + 1] = ']'; + } + BIO_free_all(x.writer); EVP_cleanup(); + free(x.key); free(x.iv); + memset(&x, 0, sizeof(x)); // XXX: crypto erase + return b64; +} + +static reply_t created_reply(request_t in) { + reply_t out = { lport: 0, rport: 0 }; + bool is_invalid_port = false; + unsigned attempts = 0; + + out.os = vstrdup(opt.other ? "OTHER" : opt.os, DFL_OS); + out.enc = vstrdup(opt.codeset, nl_langinfo(CODESET), "X-UNKNOWN"); + if (!is_in_range(PORT_MIN, in.lport, PORT_MAX)) { + in.lport = 0; is_invalid_port = true; errno = 0; + } + if (!is_in_range(PORT_MIN, in.rport, PORT_MAX)) { + in.rport = 0; is_invalid_port = true; errno = 0; + } + out.lport = (unsigned) in.lport; out.rport = (unsigned) in.rport; + if (is_invalid_port) { + out.s = vstrdup("INVALID-PORT"); out.error = true; + } + // FIXME: because the /proc/net/tcp*'s updated asyncronously, it's possible + // to miss reading a pair when reading syncronously (even with a locked + // read & a large enough buffer). To lessen the chance of a false negative, + // inefficiently & unreliably re-read proc more than once if not found. + else for (;;) { + // TODO: port pair more likely to be IPv4 than IPv6, + // so scan IPv4 first for better performance; should be configurable + if (get_info(&out, in, PROC_V4) || get_info(&out, in, PROC_V6)) break; + else if (attempts++ < PROC_RETRY) { + if (usleep(PROC_SLEEP_US) == -1) handle_error(NULL); + continue; + } + out.error = true; errno = 0; out.s = vstrdup("NO-USER"); break; + } + if (!out.error && opt.Encrypt != NULL) { + char *encrypted = created_ciphertext_b64(out.s); + + memset(out.s, 0, strlen(out.s)); // XXX: crypto erase + free(out.s); + if (encrypted == NULL) { + int n; + char msg[USERID_MAX_LEN], *p = msg; + unsigned long code; + size_t size = USERID_MAX_LEN; + + out.error = true; + if (opt.xerror) { + n = snprintf(p, size, "%s", "X-CRYPTO"); + assert(n >= 0); + do if ((code = ERR_get_error()) != 0) { + p += n; size = (size_t) n > size ? 0 : size - n; + n = snprintf(p, size, "-%08lX", code); + assert(n >= 0); + } while (code != 0 && (size_t) n < size); + out.s = vstrdup(msg); + } + else out.s = NULL; + } + else out.s = encrypted; + } + // RFC1413: when the info field isn't usable as-is, set OS to OTHER + if (opt.fn != 0 || opt.verbose || opt.number || opt.Encrypt != NULL) { + free(out.os); out.os = vstrdup("OTHER"); + } + return out; +} + +static void send_reply(reply_t out) { + char *s; int n; const char *fmt; + // RFC 1413 says servers shouldn't use unnecessary space, but mimic + // existing servers' behavior so inflexible clients work + const char *const GOOD_FMT = "%u , %u : USERID : %s%.0s :%s\r\n"; + const char *const GOOD_NONASCII_FMT = "%u , %u : USERID : %s , %s :%s\r\n"; + const char *const BAD_FMT = "%u , %u : ERROR :%.0s%.0s%s%.0d\r\n"; + + if (out.s == NULL || (opt.error && *out.s != 'X')) { + out.s = "UNKNOWN-ERROR"; out.error = true; + } + if (strlen(out.s) > USERID_MAX_LEN || strpbrk(out.s, "\r\n") != NULL) { + out.error = true; out.s = opt.xerror ? "X-RFC1413" : NULL; + } + if (out.error) { + fmt = BAD_FMT; + if (opt.log && errno != 0) log_warning(NULL); + if (opt.abrupt) goto abrupt; + if (opt.xerror && errno != 0 && *out.s != 'X') + out.s = "X-ERRNO-"; + } + else fmt = is_print_ascii(out.s) ? GOOD_FMT : GOOD_NONASCII_FMT; + n = asprintf(&s, fmt, out.lport, out.rport, out.os, out.enc, out.s, errno); + if (n < 0) handle_error(NULL); + if (fputs_unlocked(s, stdout) == EOF) handle_error(NULL); + else free(s); +abrupt: + if (out.error) exit(EXIT_FAILURE); // must exit to clean alloc res +} + +static void destroy_reply(reply_t *out) { + assert(out != NULL && !out->error); + free(out->os); free(out->enc); free(out->s); memset(out, 0, sizeof(*out)); +} + +static void destroy_request(request_t *in) { + free(in->laddr); free(in->raddr); memset(in, 0, sizeof(*in)); +} + +static void catch_signal(int which) { + _Exit(which == SIGALRM ? EXIT_SUCCESS : EXIT_FAILURE); +} + +int main(int argc, char *argv[]) { +# if !defined NDEBUG + mtrace(); +# endif + if (setlocale(LC_ALL, "") == NULL) abort(); + errno = 0; /* not an error for some locale files to + be missing */ + if (signal(SIGALRM, catch_signal) == SIG_ERR) abort(); + if (textdomain(PACKAGE) == NULL) handle_error(NULL); + if (bindtextdomain(PACKAGE, NULL) == NULL) handle_error(NULL); + openlog(PACKAGE, LOG_PID, LOG_DAEMON); + create_opt(argc, argv); + atexit(destroy_opt); + if (opt.help) show_help(); + else if (opt.Version) show_version(); + else while (opt.multiquery-- != 0 && (opt.timeout != 0 || optind < argc)) { + request_t in = created_request(argc, argv); + reply_t out = created_reply(in); + + destroy_request(&in); + send_reply(out); + destroy_reply(&out); + } + return EXIT_SUCCESS; +} diff --git a/config.h b/config.h new file mode 100644 index 0000000..00f3de3 --- /dev/null +++ b/config.h @@ -0,0 +1,28 @@ +// command line option defaults + +#define DFL_CIPHER "AES-128-CBC" // any "openssl -h" cipher command +#define DFL_IDENT ".ident" +#define DFL_NO_IDENT ".noident" // pidentd compatible +#define DFL_OS "UNIX" // any RFC-1340 operating system token +#define DFL_PASSWD "/etc/ident.key"// chmod o-rw; line #1 is passphrase +#define DFL_T_O 60U // timeout must be >0; should be >29 +#define DFL_USERNAME "nobody" // must be in passwd database + +// controls where files are installed and how the prog IDs itself + +#define PACKAGE "authd" // must match gettext MO filename +#define VERSION "1.4.4" // should match rpm.spec %{version} + +#define CONTACT "http://bugzilla.redhat.com/" + +// reliability vs performance tuning; defaults fine for most busy servers + +#define PROC_RETRY 10U // how many scans of tcp* to do +#define PROC_SLEEP_US 500000UL // microsecs of sleep between retries +#define PROC_SIZE 4U // size of avg proc file (unit: BUFSIZ) + +// you shouldn't need to change PROC_* macros unless you're debugging/testing + +#define PROC_V4 "/proc/net/tcp" // linux procfs: IPv4 version or NULL +#define PROC_V6 "/proc/net/tcp6"// ... IPv6 version or NULL +#define PROC_MAX_LEN 256U // max line length in tcp/tcp6 diff --git a/ja.po b/ja.po new file mode 100644 index 0000000..64d722f --- /dev/null +++ b/ja.po @@ -0,0 +1,146 @@ +# Japanese translations for authd +# Copyright (C) 2004 Red Hat, Inc. +# This file is distributed under the same license as the authd package. +# Adrian Havill , 2004. +# +msgid "" +msgstr "" +"Project-Id-Version: authd-1.4.2\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2004-08-31 16:09-0400\n" +"PO-Revision-Date: 2004-07-21 14:41-0400\n" +"Last-Translator: Adrian Havill \n" +"Language-Team: ja \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: authd.c:126 +#, c-format +msgid "%s [options]... [request]...\n" +msgstr "%s [オプション]... [リクエスト]...\n" + +#: authd.c:127 +msgid " -d\t\t\tOutput debug messages\n" +msgstr " -d\t\t\tデバッグの情報を出力します。\n" + +#: authd.c:128 +#, c-format +msgid " -E[cipher]\t\tEncrypt username using [%s]\n" +msgstr " -E[暗号名]\t\t情報を[%s]アルゴリズムで暗号化します。\n" + +#: authd.c:129 +msgid " -e\t\t\tSend UNKNOWN-ERROR for common error messages\n" +msgstr " -e\t\t\t普通のエラーの場合、\"UNKNOWN-ERROR\"を送信します。\n" + +#: authd.c:130 +msgid " -l[mask]\t\tLog to syslog, [mask] for priority levels\n" +msgstr " -l[マスク]\t\t[マスク]によるとシステム・ログに記録します。\n" + +#: authd.c:131 +msgid " -m[reps]\t\tAllow at most [unlimited] requests/connection\n" +msgstr " -m[回数]\t\t各接続に最大[無限]回のリクエストが可能になります。\n" + +#: authd.c:132 +#, c-format +msgid " -N[basename]\t\tHide users with ~/[%s] file\n" +msgstr " -N[ファイル名]\t\t~/[%s]というファイルを持つユーザを隠蔽します。\n" + +#: authd.c:133 +msgid " -n\t\t\tSend uid number instead of username\n" +msgstr " -n\t\t\tユーザ名ではなく、ユーザ番号を送信します。\n" + +#: authd.c:134 +msgid " -o\t\t\tSend OTHER instead of the operating system\n" +msgstr " -o\t\t\tOS名ではなく、\"OTHER\"を送信します。\n" + +#: authd.c:135 +#, c-format +msgid " -t[secs]\t\tTimeout request after [%u] seconds\n" +msgstr " -t[秒間]\t\t[%u]秒以上になるとタイムアウトになります。\n" + +#: authd.c:136 +msgid " -V\t\t\tPrint program and version information\n" +msgstr " -V\t\t\tプログラム名とバージョン情報を表示します。\n" + +#: authd.c:137 +msgid " --abrupt\t\tDisconnect without displaying error msgs\n" +msgstr " --abrupt\t\tエラーメッセージを表示せずに切断します。\n" + +#: authd.c:138 +msgid " --codeset=rfc1340\tSend [charset] if reply is not ASCII\n" +msgstr "" +" --codeset=文字コード\tASCIIではない場合、変換せずにコードを送信します。\n" + +#: authd.c:139 +msgid " --fn[=fields]\t\tUse [all] gecos fields instead of username\n" +msgstr " --fn[=部分]\t\tユーザ名ではなく、氏名から[全部]の部分を利用します。\n" + +#: authd.c:140 +msgid " --hybrid\t\tUse hybrid notation (ex. ::127.0.0.1) for IPv6\n" +msgstr " --hybrid\t\tIPv6の混種の形(例 ::127.0.0.1)を利用します。\n" + +#: authd.c:141 +#, c-format +msgid " --ident[=basename]\tHide users with no ~/[%s]\n" +msgstr " --ident[=ファイル名]\t[~/%s]を持たないユーザを隠蔽します。\n" + +#: authd.c:142 +msgid " --lang=lc\t\tLocalize messages, charsets, & time to [locale]\n" +msgstr " --lang=ローケル\tメッセージ、文字コード、時間など地域化します。\n" + +#: authd.c:143 +msgid " --mapped=ipv6\t\tMap addresses with same top 96 bits to IPv4\n" +msgstr " --mapped=IPv6\t始めの96ビットのプレフィックスのと合致します。\n" + +#: authd.c:144 +#, c-format +msgid " --os[=rfc1340]\t\tUse [uname], not %s, as OS name\n" +msgstr " --os[=OS名]\t\t\"%s\"ではなく、OS名を利用します。\n" + +#: authd.c:145 +#, c-format +msgid " --passwd=pathname\tUse line 1 of [%s] for crypto\n" +msgstr " --passwd=パス名\t[%s]の1行目を合い言葉として利用します。\n" + +#: authd.c:146 +msgid " --resolve\t\tUse host and service names if available\n" +msgstr " --resolve\t\t数字を使わずに名前を利用します。\n" + +#: authd.c:147 +#, c-format +msgid " --username[=login]\tUse [%s] as username\n" +msgstr " --username[=ユーザ名]\t[%s]をユーザ名として利用します。\n" + +#: authd.c:148 +msgid " --verbose\t\tAdd real uid, addresses/ports, & timestamps\n" +msgstr " --verbose\t\t本当のユーザ番号、アドレス/ポート、時間を追加します。\n" + +#: authd.c:149 +msgid " --xerror\t\tSend more helpful error messages for rare errors\n" +msgstr " --xerror\t\t珍しいエラーの場合、詳細なメッセージを送信します。\n" + +#: authd.c:212 +#, c-format +msgid "%s: invalid argument to --%s: %s\n" +msgstr "%s:'--%s'オプションの引数が違います:%s\n" + +#: authd.c:213 +#, c-format +msgid "%s: invalid argument to -%c: %s\n" +msgstr "%s:'-%c'オプションの引数が違います:%s\n" + +#: authd.c:281 +msgid "Timeout's too low; Raising to 30.\n" +msgstr "タイムアウトが低過ぎます。30秒に設定します。\n" + +#: authd.c:285 +msgid "Timeout should be from 60..180 seconds.\n" +msgstr "タイムアウトは60秒から180秒までを勧めます。\n" + +#: authd.c:320 +msgid "Mapped lower 32 bits not 0; ignoring.\n" +msgstr "プレフィックスの下の32ビットはゼロではありません。無視します。\n" + +#~ msgid " -h --help --usage\tPrint this information\n" +#~ msgstr " -h --help --usage\tこの説明を表示します。\n" diff --git a/packaging/Fedora/auth.socket b/packaging/Fedora/auth.socket new file mode 100644 index 0000000..d701b04 --- /dev/null +++ b/packaging/Fedora/auth.socket @@ -0,0 +1,9 @@ +[Unit] +Description=Authd Activation Socket + +[Socket] +ListenStream=113 +Accept=true + +[Install] +WantedBy=sockets.target diff --git a/packaging/Fedora/auth@.service b/packaging/Fedora/auth@.service new file mode 100644 index 0000000..8da5bd2 --- /dev/null +++ b/packaging/Fedora/auth@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Authd Ident Protocol Requests Server +After=local-fs.target + +[Service] +User=ident +ExecStart=/usr/sbin/in.authd -t60 --xerror --os -E +StandardInput=socket diff --git a/packaging/Fedora/authd.spec b/packaging/Fedora/authd.spec new file mode 100644 index 0000000..84e7c9e --- /dev/null +++ b/packaging/Fedora/authd.spec @@ -0,0 +1,330 @@ +Summary: A RFC 1413 ident protocol daemon +Name: authd +Version: @VERSION@ +Release: @RELEASE@%{?dist} +License: GPLv2+ +URL: https://github.com/InfrastructureServices/authd +Obsoletes: pidentd < 3.2 +Provides: pidentd = 3.2 +Requires(post): openssl +Source0: https://github.com/InfrastructureServices/authd/archive/authd-%{version}.tar.gz +Source1: auth.socket +Source2: auth@.service + +BuildRequires: gcc +BuildRequires: openssl-devel gettext help2man systemd-units +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units + +%description +authd is a small and fast RFC 1413 ident protocol daemon +with both xinetd server and interactive modes that +supports IPv6 and IPv4 as well as the more popular features +of pidentd. + +%prep +%autosetup + +%build +CFLAGS=%{optflags} make prefix=%{_prefix} + +%install +make install + +install -d %{buildroot}%{_unitdir}/ +install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ +install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/ + +install -d %{buildroot}%{_sysconfdir}/ +touch %{buildroot}%{_sysconfdir}/ident.key + +install -d %{buildroot}/%{_mandir}/man1/ +help2man -N -v -V %{buildroot}/%{_sbindir}/in.authd -o \ + %{buildroot}/%{_mandir}/man1/in.authd.1 + +%find_lang %{name} + +%post +/usr/sbin/adduser -s /sbin/nologin -u 98 -r -d '/' ident 2>/dev/null || true +/usr/bin/openssl rand -base64 -out %{_sysconfdir}/ident.key 32 +echo CHANGE THE LINE ABOVE TO A PASSPHRASE >> %{_sysconfdir}/ident.key +/bin/chown ident:ident %{_sysconfdir}/ident.key +chmod o-rw %{_sysconfdir}/ident.key +%systemd_post auth.socket + +%postun +%systemd_postun_with_restart auth.socket + +%preun +%systemd_preun auth.socket + +%files -f authd.lang +%verify(not md5 size mtime user group) %config(noreplace) %attr(640,root,root) %{_sysconfdir}/ident.key +%doc COPYING README.html rfc1413.txt +%{_sbindir}/in.authd +%{_mandir}/*/* +%{_unitdir}/* + +%changelog +* Thu Jan 31 2019 Fedora Release Engineering - 1.4.3-51 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Thu Jul 12 2018 Fedora Release Engineering - 1.4.3-50 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Feb 07 2018 Fedora Release Engineering - 1.4.3-49 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Aug 02 2017 Fedora Release Engineering - 1.4.3-48 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.4.3-47 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.4.3-46 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Dec 22 2016 CAI Qian - 1.4.3-45 +- Fix some lint warnings + +* Wed Feb 03 2016 Fedora Release Engineering - 1.4.3-44 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 1.4.3-43 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Fri Aug 15 2014 Fedora Release Engineering - 1.4.3-42 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 1.4.3-41 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Mon Aug 05 2013 Roman Rakus - 1.4.3-40 +- Fix doc dir to satisfy new policy +- Don't return negative uid + Resolves: #991998, #482811 + +* Sat Aug 03 2013 Fedora Release Engineering - 1.4.3-39 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Feb 13 2013 Fedora Release Engineering - 1.4.3-38 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Nov 30 2012 Roman Rakus - 1.4.3-37 +- Fix a typo in build requirements + +* Fri Nov 30 2012 Roman Rakus - 1.4.3-36 +- Provide native systemd service file + Resolves: #737153 + +* Thu Nov 29 2012 Roman Rakus - 1.4.3-35 +- Generate and include man page + +* Mon Nov 19 2012 Roman Rakus - 1.4.3-34 +- Fixed address in license text + +* Wed Jul 18 2012 Fedora Release Engineering - 1.4.3-33 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Jan 12 2012 Fedora Release Engineering - 1.4.3-32 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 1.4.3-31 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Jun 14 2010 Roman Rakus - 1.4.3-30 +- Use only once defattr macro +- Use RPM_OPT_FLAGS for CFLAGS in build section + +* Fri Aug 21 2009 Tomas Mraz - 1.4.3-28 +- rebuilt with new openssl + +* Fri Jul 24 2009 Fedora Release Engineering - 1.4.3-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu Apr 09 2009 Roman Rakus - 1.4.3-26 +- get back to older version of jiffies64 patch + +* Tue Mar 31 2009 Roman Rakus - 1.4.3-25 +- Fixed source tag + +* Tue Mar 31 2009 Roman Rakus - 1.4.3-24 +- Fixed using valist with log option on. + Resolves: #446844 +- user ident has home dir set to / + Resolves: #458144 + +* Mon Feb 23 2009 Fedora Release Engineering - 1.4.3-23 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Jan 15 2009 Tomas Mraz - 1.4.3-22 +- rebuild with new openssl + +* Wed Jul 23 2008 Roman Rakus - 1.4.3-21 +- Corrected config directive for ident.key to noreplace +- Fixed some typos in specfile + +* Tue Apr 29 2008 Roman Rakus - 1.4.3-20 +- another corrections of jiffies64 patch + +* Wed Mar 26 2008 Roman Rakus - 1.4.3-19 +- corrected jiffies64 patch + +* Thu Mar 6 2008 Roman Rakus - 1.4.3-18 +- corrected Source0 +- corrected link in URL +- source added to svn on fedorahosted + +* Wed Mar 5 2008 Roman Rakus - 1.4.3-16 +- fixed Source0 + +* Wed Mar 5 2008 Roman Rakus - 1.4.3-15 +- added dist tag +- added URL + +* Tue Feb 26 2008 Roman Rakus - 1.4.3-14 +- fix 234262 bug + +* Wed Feb 13 2008 Jan Safranek - 1.4.3-13 +- fix rpmlint errors + +* Tue Feb 12 2008 Jan Safranek - 1.4.3-12 +- fix build with new gcc + +* Fri Dec 07 2007 Release Engineering - 1.4.3-11 +- Rebuild for deps + +* Wed Sep 19 2007 Ondrej Dvoracek - 1.4.3-10 +- corrected illegal identifier in longopt enumeration (#245436) +- corrected summary and license + +* Mon Jul 24 2006 Martin Stransky - 1.4.3-9 +- added locale patch (#199721) + +* Wed Jul 12 2006 Jesse Keating - 1.4.3-8.1 +- rebuild + +* Sun May 28 2006 Martin Stransky - 1.4.3-8 +- added gettext dependency (#193350) + +* Fri Feb 10 2006 Jesse Keating - 1.4.3-7.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Martin Stransky - 1.4.3-7 +- re-tag + +* Tue Feb 07 2006 Jesse Keating - 1.4.3-6.devel.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Tue Nov 8 2005 Martin Stransky +- rebuilt + +* Fri Jun 24 2005 Martin Stransky - 1.4.3-5.devel +- add xinetd to Prereq +- fix for #150502 (authd doesn't map IPv6 to IPv4 from xinetd) + +* Fri Apr 8 2005 Martin Stransky - 1.4.3-4.devel +- clear last update + +* Fri Apr 8 2005 Martin Stransky - 1.4.3-3.devel +- delete user "ident" after uninstalation + +* Thu Apr 7 2005 Martin Stransky - 1.4.3-2.devel +- in.authd disabled by default (#151905) + +* Mon Mar 7 2005 Martin Stransky - 1.4.3-1.devel +- update to 1.4.3 +- gcc4.0 patch +- add post-uninstall reconfiguration (#150460) + +* Mon Feb 14 2005 Adrian Havill +- rebuilt + +* Fri Oct 15 2004 Adrian Havill - 1.4.2-8 +- tweak setting of uid/gid for key file so systems with no prior + ident user/group don't generate a warning (#135837) + +* Thu Oct 14 2004 Adrian Havill - 1.4.2-4 +- slightly better error checking for insane cases +- tweak of the openssl requires dependency loop (#131291) +- as ident.key is created in %%post, tweak so verify passes (#131530) +- make the uid/gid for ident conform to the past (#135752) + +* Wed Jul 28 2004 Adrian Havill - 1.4.1-1 +- only scan for ESTABLISHED connections +- extra debug output for crypto + +* Mon Jul 26 2004 Adrian Havill - 1.4.0-1 +- revise makefile; don't over-optimize as gcc can produce bad code +- ptr cleanup when multiquery and missing /proc/net/tcp* +- improve create_opt (error handling, debugging, identifiers) +- add --prefix option for matching IPv4 to IPv6 + +* Tue Jul 13 2004 Adrian Havill - 1.3.4-1 +- retry reading proc with pauses to reduce false negatives +- match IPv4 addresses against IPv6 compatibility addresses + +* Mon Jul 12 2004 Adrian Havill - 1.3.3-1 +- use gnu *_unlocked stream funcs for faster I/O + +* Sat Jul 10 2004 Adrian Havill - 1.3.2-1 +- enforce rfc restriction limiting port search to the connected + local/foreign pair + +* Thu Jul 08 2004 Adrian Havill - 1.3.1-1 +- increase default connections-per-sec/max-instances for HP +- more doc cleanup +- remove unnecessary rootdir check for -N/--ident + +* Fri Jul 02 2004 Adrian Havill - 1.3.0-1 +- add unknown-error only -e option +- edit readme, add rfc to docdir +- code cleanup; remove static buffers, orthagonalize id names +- ipv6 hybrid addr zero run correction +- extra eight bits added to random key + +* Wed Jun 30 2004 Adrian Havill - 1.2.8-1 +- zero out invalid port(s) + +* Tue Jun 29 2004 Adrian Havill - 1.2.7-1 +- added Provides to satisfy HP pkg rpm dep (#121447, #111640) +- more code cleanup; minimize --resolve dns lookups + +* Mon Jun 28 2004 Adrian Havill - 1.2.6-1 +- incorporated suggestions from Thomas Zehetbauer (#124914) + +* Sat Jun 26 2004 Adrian Havill - 1.2.5-1 +- clean up src + +* Thu Jun 24 2004 Adrian Havill - 1.2.4-1 +- code vet and minor changes re alan@'s comments +- default operating mode to alias all usernames as 'nobody' + to prevent noobies from getting their mail addr harvested +- clean up README documentation + +* Wed Jun 23 2004 Adrian Havill - 1.2.3-1 +- mark xinetd conf file as a noreplace config file +- more robust error checking for proper rfc1413 tokens + +* Tue Jun 22 2004 Adrian Havill - 1.2.1-1 +- add Requires and BuildRequires + +* Mon Jun 21 2004 Adrian Havill - 1.2.0-1 +- A few tweaks in the cmdline options for orthagonality +- minor bug fix regarding reading from stdin in some multiquery cmdline cases +- add --resolve + +* Sun Jun 20 2004 Adrian Havill - 1.1.0-1 +- add extra options for --help, --usage + +* Sat Jun 19 2004 Adrian Havill - 1.0.0-2 +- Obsolete pidentd -- authd and pidentd can't/shouldn't coexist on FC/RHEL +- license tweak to allow openssl under any condition +- no spec url needed; package is not worthy enough. + +* Fri Jun 18 2004 Jens Petersen - 1.0.0-1 +- Initial packaging diff --git a/rfc1413.txt b/rfc1413.txt new file mode 100644 index 0000000..17ede58 --- /dev/null +++ b/rfc1413.txt @@ -0,0 +1,451 @@ + + + + + + +Network Working Group M. St. Johns +Request for Comments: 1413 US Department of Defense +Obsoletes: 931 February 1993 + + + Identification Protocol + +Status of this Memo + + This RFC specifies an IAB standards track protocol for the Internet + community, and requests discussion and suggestions for improvements. + Please refer to the current edition of the "IAB Official Protocol + Standards" for the standardization state and status of this protocol. + Distribution of this memo is unlimited. + +1. INTRODUCTION + + The Identification Protocol (a.k.a., "ident", a.k.a., "the Ident + Protocol") provides a means to determine the identity of a user of a + particular TCP connection. Given a TCP port number pair, it returns + a character string which identifies the owner of that connection on + the server's system. + + The Identification Protocol was formerly called the Authentication + Server Protocol. It has been renamed to better reflect its function. + This document is a product of the TCP Client Identity Protocol + Working Group of the Internet Engineering Task Force (IETF). + +2. OVERVIEW + + This is a connection based application on TCP. A server listens for + TCP connections on TCP port 113 (decimal). Once a connection is + established, the server reads a line of data which specifies the + connection of interest. If it exists, the system dependent user + identifier of the connection of interest is sent as the reply. The + server may then either shut the connection down or it may continue to + read/respond to multiple queries. + + The server should close the connection down after a configurable + amount of time with no queries - a 60-180 second idle timeout is + recommended. The client may close the connection down at any time; + however to allow for network delays the client should wait at least + 30 seconds (or longer) after a query before abandoning the query and + closing the connection. + + + + + + + +St. Johns [Page 1] + +RFC 1413 Identification Protocol February 1993 + + +3. RESTRICTIONS + + Queries are permitted only for fully specified connections. The + query contains the local/foreign port pair -- the local/foreign + address pair used to fully specify the connection is taken from the + local and foreign address of query connection. This means a user on + address A may only query the server on address B about connections + between A and B. + +4. QUERY/RESPONSE FORMAT + + The server accepts simple text query requests of the form: + + , + + where is the TCP port (decimal) on the target (where + the "ident" server is running) system, and is the + TCP port (decimal) on the source (client) system. + + N.B - If a client on host A wants to ask a server on host B about a + connection specified locally (on the client's machine) as 23, 6191 + (an inbound TELNET connection), the client must actually ask about + 6191, 23 - which is how the connection would be specified on host B. + + For example: + + 6191, 23 + + The response is of the form + + , : : + + where , are the same pair as the + query, is a keyword identifying the type of response, and + is context dependent. + + The information returned is that associated with the fully specified + TCP connection identified by , , + , , where and + are the local and foreign IP addresses of the + querying connection -- i.e., the TCP connection to the Identification + Protocol Server. ( and are taken + from the query.) + + For example: + + 6193, 23 : USERID : UNIX : stjohns + 6195, 23 : ERROR : NO-USER + + + +St. Johns [Page 2] + +RFC 1413 Identification Protocol February 1993 + + +5. RESPONSE TYPES + +A response can be one of two types: + +USERID + + In this case, is a string consisting of an + operating system name (with an optional character set + identifier), followed by ":", followed by an + identification string. + + The character set (if present) is separated from the + operating system name by ",". The character set + identifier is used to indicate the character set of the + identification string. The character set identifier, + if omitted, defaults to "US-ASCII" (see below). + + Permitted operating system names and character set + names are specified in RFC 1340, "Assigned Numbers" or + its successors. + + In addition to those operating system and character set + names specified in "Assigned Numbers" there is one + special case operating system identifier - "OTHER". + + Unless "OTHER" is specified as the operating system + type, the server is expected to return the "normal" + user identification of the owner of this connection. + "Normal" in this context may be taken to mean a string + of characters which uniquely identifies the connection + owner such as a user identifier assigned by the system + administrator and used by such user as a mail + identifier, or as the "user" part of a user/password + pair used to gain access to system resources. When an + operating system is specified (e.g., anything but + "OTHER"), the user identifier is expected to be in a + more or less immediately useful form - e.g., something + that could be used as an argument to "finger" or as a + mail address. + + "OTHER" indicates the identifier is an unformatted + character string consisting of printable characters in + the specified character set. "OTHER" should be + specified if the user identifier does not meet the + constraints of the previous paragraph. Sending an + encrypted audit token, or returning other non-userid + information about a user (such as the real name and + phone number of a user from a UNIX passwd file) are + + + +St. Johns [Page 3] + +RFC 1413 Identification Protocol February 1993 + + + both examples of when "OTHER" should be used. + + Returned user identifiers are expected to be printable + in the character set indicated. + + The identifier is an unformatted octet string - - all + octets are permissible EXCEPT octal 000 (NUL), 012 (LF) + and 015 (CR). N.B. - space characters (040) following the + colon separator ARE part of the identifier string and + may not be ignored. A response string is still + terminated normally by a CR/LF. N.B. A string may be + printable, but is not *necessarily* printable. + +ERROR + + For some reason the port owner could not be determined, + tells why. The following are the permitted values of and + their meanings: + + INVALID-PORT + + Either the local or foreign port was improperly + specified. This should be returned if either or + both of the port ids were out of range (TCP port + numbers are from 1-65535), negative integers, reals or + in any fashion not recognized as a non-negative + integer. + + NO-USER + + The connection specified by the port pair is not + currently in use or currently not owned by an + identifiable entity. + + HIDDEN-USER + + The server was able to identify the user of this + port, but the information was not returned at the + request of the user. + + UNKNOWN-ERROR + + Can't determine connection owner; reason unknown. + Any error not covered above should return this + error code value. Optionally, this code MAY be + returned in lieu of any other specific error code + if, for example, the server desires to hide + information implied by the return of that error + + + +St. Johns [Page 4] + +RFC 1413 Identification Protocol February 1993 + + + code, or for any other reason. If a server + implements such a feature, it MUST be configurable + and it MUST default to returning the proper error + message. + + Other values may eventually be specified and defined in future + revisions to this document. If an implementer has a need to specify + a non-standard error code, that code must begin with "X". + + In addition, the server is allowed to drop the query connection + without responding. Any premature close (i.e., one where the client + does not receive the EOL, whether graceful or an abort should be + considered to have the same meaning as "ERROR : UNKNOWN-ERROR". + +FORMAL SYNTAX + + ::= + + ::= "," + + ::= + + ::= "015 012" ; CR-LF End of Line Indicator + + ::= | + + ::= ":" "ERROR" ":" + + ::= ":" "USERID" ":" + ":" + + ::= "INVALID-PORT" | "NO-USER" | "UNKNOWN-ERROR" + | "HIDDEN-USER" | + + ::= [ "," ] + + ::= "OTHER" | "UNIX" | ...etc. + ; (See "Assigned Numbers") + + ::= "US-ASCII" | ...etc. + ; (See "Assigned Numbers") + + ::= + + ::= 1*64 ; 1-64 characters + + ::= "X"1*63 + ; 2-64 chars beginning w/X + + + +St. Johns [Page 5] + +RFC 1413 Identification Protocol February 1993 + + + ::= 1*5 ; 1-5 digits. + + ::= "0" | "1" ... "8" | "9" ; 0-9 + + ::= + /?"'~`{}[]; > + ; upper and lowercase a-z plus + ; printables minus the colon ":" + ; character. + + ::= 1*512 + + ::= + + +Notes on Syntax: + + 1) To promote interoperability among variant + implementations, with respect to white space the above + syntax is understood to embody the "be conservative in + what you send and be liberal in what you accept" + philosophy. Clients and servers should not generate + unnecessary white space (space and tab characters) but + should accept white space anywhere except within a + token. In parsing responses, white space may occur + anywhere, except within a token. Specifically, any + amount of white space is permitted at the beginning or + end of a line both for queries and responses. This + does not apply for responses that contain a user ID + because everything after the colon after the operating + system type until the terminating CR/LF is taken as + part of the user ID. The terminating CR/LF is NOT + considered part of the user ID. + + 2) The above notwithstanding, servers should restrict the + amount of inter-token white space they send to the + smallest amount reasonable or useful. Clients should + feel free to abort a connection if they receive 1000 + characters without receiving an . + + 3) The 512 character limit on user IDs and the 64 + character limit on tokens should be understood to mean + as follows: a) No new token (i.e., OPSYS or ERROR-TYPE) + token will be defined that has a length greater than 64 + and b) a server SHOULD NOT send more than 512 octets of + user ID and a client MUST accept at least 512 octets of + + + +St. Johns [Page 6] + +RFC 1413 Identification Protocol February 1993 + + + user ID. Because of this limitation, a server MUST + return the most significant portion of the user ID in + the first 512 octets. + + 4) The character sets and character set identifiers should + map directly to those defined in or referenced by RFC 1340, + "Assigned Numbers" or its successors. Character set + identifiers only apply to the user identification field + - all other fields will be defined in and must be sent + as US-ASCII. + + 5) Although is defined as an + above, it must follow the format and character set + constraints implied by the ; see the + discussion above. + + 6) The character set provides context for the client to + print or store the returned user identification string. + If the client does not recognize or implement the + returned character set, it should handle the returned + identification string as OCTET, but should in addition + store or report the character set. An OCTET string + should be printed, stored or handled in hex notation + (0-9a-f) in addition to any other representation the + client implements - this provides a standard + representation among differing implementations. + +6. Security Considerations + + The information returned by this protocol is at most as trustworthy + as the host providing it OR the organization operating the host. For + example, a PC in an open lab has few if any controls on it to prevent + a user from having this protocol return any identifier the user + wants. Likewise, if the host has been compromised the information + returned may be completely erroneous and misleading. + + The Identification Protocol is not intended as an authorization or + access control protocol. At best, it provides some additional + auditing information with respect to TCP connections. At worst, it + can provide misleading, incorrect, or maliciously incorrect + information. + + The use of the information returned by this protocol for other than + auditing is strongly discouraged. Specifically, using Identification + Protocol information to make access control decisions - either as the + primary method (i.e., no other checks) or as an adjunct to other + methods may result in a weakening of normal host security. + + + + +St. Johns [Page 7] + +RFC 1413 Identification Protocol February 1993 + + + An Identification server may reveal information about users, + entities, objects or processes which might normally be considered + private. An Identification server provides service which is a rough + analog of the CallerID services provided by some phone companies and + many of the same privacy considerations and arguments that apply to + the CallerID service apply to Identification. If you wouldn't run a + "finger" server due to privacy considerations you may not want to run + this protocol. + +7. ACKNOWLEDGEMENTS + + Acknowledgement is given to Dan Bernstein who is primarily + responsible for renewing interest in this protocol and for pointing + out some annoying errors in RFC 931. + +References + + [1] St. Johns, M., "Authentication Server", RFC 931, TPSC, January + 1985. + + [2] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, RFC 1340, + USC/Information Sciences Institute, July 1992. + +Author's Address + + Michael C. St. Johns + DARPA/CSTO + 3701 N. Fairfax Dr + Arlington, VA 22203 + + Phone: (703) 696-2271 + EMail: stjohns@DARPA.MIL + + + + + + + + + + + + + + + + + + + +St. Johns [Page 8] + \ No newline at end of file diff --git a/xinetd.conf.auth b/xinetd.conf.auth new file mode 100644 index 0000000..7c66a2b --- /dev/null +++ b/xinetd.conf.auth @@ -0,0 +1,19 @@ +# default: off +# description: The authd server handles ident protocol requests. \ +# The Identification Protocol (a.k.a., "ident", a.k.a., "the Ident \ +# Protocol") provides a means to determine the identity of a user of a \ +# particular TCP connection. Given a TCP port number pair, it returns \ +# a character string which identifies the owner of that connection on \ +# the server's system. UNDERSTAND THE RISKS REGARDING PRIVACY (I.E. \ +# SPAM HARVESTERS) BEFORE RUNNING THIS DAEMON WITH NO ARGUMENTS. +service auth +{ + disable = yes + socket_type = stream + wait = no + user = ident + cps = 4096 10 + instances = UNLIMITED + server = /usr/local/sbin/in.authd + server_args = -t60 --xerror --os -E +}