pax_global_header00006660000000000000000000000064121372117060014512gustar00rootroot0000000000000052 comment=1bb6718fa767107e97893c5fe538420ef249b0a0 pam_script-1.1.7/000077500000000000000000000000001213721170600136615ustar00rootroot00000000000000pam_script-1.1.7/.gitignore000066400000000000000000000004061213721170600156510ustar00rootroot00000000000000.deps .libs aclocal.m4 autom4te.cache build-stamp config.guess config.h config.h.in config.log config.status config.sub configure libtool Makefile Makefile.in pam_script.la pam_script_la-pam_script.lo pam_script.lo pam-script.spec pam-script.7 stamp-h1 *.tar.gz pam_script-1.1.7/AUTHORS000066400000000000000000000002031213721170600147240ustar00rootroot00000000000000Primary Author: Jeroen Nijhof Other Authors and Major Contributors: R.K. Owen, Ph.D. pam_script-1.1.7/COPYING000066400000000000000000000431001213721170600147120ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, 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 Appendix: 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., 675 Mass Ave, Cambridge, MA 02139, 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. pam_script-1.1.7/ChangeLog000066400000000000000000000327341213721170600154440ustar00rootroot000000000000002013-04-28 Jeroen Nijhof * pam_script.c: Fixed strcmp issue, thanks to Andy Igoshin 2013-02-11 Jeroen Nijhof * .ftp.sf: Removed old ftp script 2012-05-07 Jeroen Nijhof * debian/control: Changed Debian control standards-version to 3.9.3 2012-05-07 Jeroen Nijhof * NEWS, configure.ac, debian/changelog: Release version 1.1.6 2012-05-07 Jeroen Nijhof * debian/README.Debian, debian/README.source, debian/changelog, debian/compat, debian/control, debian/copyright, debian/dirs, debian/docs, debian/libpam-script.dirs, debian/libpam-script.docs, debian/libpam-script.examples, debian/libpam-script.links, debian/libpam-script.manpages, debian/postinst, debian/prerm, debian/rules, debian/script, debian/source/format, debian/watch: Changed /debian to maintainer version. Added pam-auth-update support 2012-01-30 Jeroen * ChangeLog, NEWS, debian/changelog, debian/copyright, debian/rules, pam-script.spec.in: Release version 1.1.5 2012-01-27 Jeroen * .gitignore, AUTHORS, NEWS, README, configure.ac, debian/copyright, pam-script.7.in, pam_script.c: * AC_CHECK_HEADERS improvements for libpam header files. 2010-12-23 Jeroen Nijhof * ChangeLog: Updated ChangeLog 2010-12-23 Jeroen Nijhof * config/.cvsignore, config/.gitignore, debian/.cvsignore, debian/.gitignore: Updated ChangeLog 2010-12-23 Jeroen Nijhof * .cvsignore, .gitignore, cvs2cl.pl, git2cl.pl: Changed cvs specific stuff to git 2010-07-28 j-nijhof * NEWS, pam_script.c: fixed an expression in function pam_sm_chauthtok() used == for flags instead of a binary logic bit operator, report and fix by Mikolaj Kucharski. 2010-06-14 j-nijhof * Makefile.am, configure.ac, debian/changelog: Changed version number to 1.1.4 configure.ac and debian/changelog. Removed debian from make dist to be compatible for official debian packaging. 2010-06-04 j-nijhof * ChangeLog: * New changelog 2010-06-04 j-nijhof * NEWS: * NEWS: Added 1.1.4 to NEWS 2010-06-03 j-nijhof * ChangeLog: [no log message] 2010-06-03 j-nijhof * Makefile.am, NEWS, configure.ac, debian/libpam-script.manpages, debian/pam-script.7.in, pam-script.7.in: * Moved the man page to the correct path 2009-11-11 j-nijhof * NEWS, README, etc/README, pam_script.c: * fixed bug 2871389 - pam_sm_chauthtok() should first set PAM_OLDAUTHTOK and not PAM_AUTHTOK. PAM_AUTHTOK should contain the new password. * pam_sm_chauthtok() - Don't ask current password for user root. 2009-05-12 rkowen * etc/pam_script: Discovered some glob weirdness when the ./pam-script.d/ dir is empty. 2009-05-07 rkowen * ChangeLog: updated 2009-05-07 rkowen * NEWS: Added 1.1.3 to NEWS 2009-05-06 rkowen * ChangeLog: updated. 2009-05-06 rkowen * configure.ac, debian/changelog: Advanced the version number to 1.1.3 2009-05-06 rkowen * pam_script.c: Moved the PAM_* environment set-up to the child process prior to executing the local pam-script. 2009-05-06 rkowen * ChangeLog, debian/copyright, etc/README, etc/README.pam_script: Minor grammar changes. 2009-05-06 rkowen * INSTALL: Added blurb on "make uninstall" 2009-05-06 rkowen * etc/pam_script: Removed extraneous "echo $script". 2009-04-14 j-nijhof * ChangeLog, NEWS: Official release of pam-script 1.1.2 2008-10-20 j-nijhof * pam_script.c: * Finished pam_sm_chauthtok(), it now's fill PAM_AUTHTOK and PAM_OLDAUTHTOK environment variable which can be used in pam_script_passwd * Fixed layout 2008-10-08 j-nijhof * pam_script.c: * Changed pam_script_converse() and pam_script_set_authtok() to static functions. 2008-10-07 j-nijhof * pam_script.c: * Added pam_script_converse(), pam_script_set_authtok() for converse functionality in pam_sm_authenticate(). If there are no early pam modules to get a password from pam_script ask for a password. So it's now possible to use the pam_script module alone. 2008-05-22 rkowen * ChangeLog: [no log message] 2008-05-22 rkowen * .cvsignore, Makefile.am, NEWS, configure.ac, debian/.cvsignore, debian/changelog, debian/control, debian/libpam-script.dirs, debian/libpam-script.docs, debian/libpam-script.links, debian/libpam-script.manpages, debian/rules, etc/README.pam_script, etc/pam_script: pam-script 1.1.2 May 22, 2008 R.K. Owen * Added the pam_script driver script and the ./pam-script.d/ directory for an easy way for other packages to include PAM capability via pam-script (suggested by Petter Reinholdtsen). * Further improvements in the Debian/Ubuntu packaging. 2008-05-08 rkowen * etc/README, etc/README.examples, etc/README.pam_script, etc/pam_script: Added the pam_script tool for handling the programs in ./pam-script.d/ 2008-05-07 rkowen * README, debian/changelog, debian/control, debian/copyright, debian/libpam-script.examples, debian/pam-script-examples.dirs, debian/pam-script-examples.files, debian/pam-script-module.dirs, debian/rules: Changing the Debian packaging to adhere to Debian policy, and to resolve some lintian issues. 2008-04-22 rkowen * debian/README.Debian, debian/control: Further refinement of what packages are needed to build a Debian package. 2008-04-21 rkowen * debian/README.Debian, debian/changelog: More fixes with the debian package building. 2008-02-05 rkowen * ChangeLog: Updated 2008-02-05 rkowen * NEWS: Updated with 1.1.1 changes 2008-02-05 rkowen * configure.ac: Upgrade the minor version for these trivial changes. 2008-02-05 rkowen * debian/README.Debian: Clarified the Debian/Ubuntu instructions. 2008-02-05 rkowen * pam_script.c: Need to have any conditional inclusions after config.h 2007-12-12 rkowen * ChangeLog: Updated. 2007-12-12 rkowen * NEWS: Ready for official release. 2007-12-12 rkowen * ChangeLog: Updated 2007-12-12 rkowen * Makefile.am: Fixing sourceforge uploading 2007-12-12 rkowen * ChangeLog: Updated. 2007-12-12 rkowen * .ftp.sf, ChangeLog, Makefile.am, config/.README: More release preparation. 2007-12-12 rkowen * ChangeLog, INSTALL, Makefile.am, configure.ac: Added distribution specific targets in Makefile. 2007-12-12 rkowen * README: Updated the README info, in preparation for release. 2007-09-07 rkowen * ChangeLog: Updated. 2007-09-07 rkowen * ChangeLog, NEWS: Note that rpms can now be generated. 2007-09-07 rkowen * .cvsignore, etc/tally: Need to override the umask. 2007-09-07 rkowen * etc/README.examples, etc/logscript, etc/tally: The example support files need to have permissive access. 2007-09-06 rkowen * Makefile.am, configure.ac, pam-script.spec.in: Crafted a working rpm spec file. 2007-09-05 rkowen * ChangeLog: Updated 2007-09-05 rkowen * NEWS: Added the debian packaging notice. 2007-09-05 rkowen * Makefile.am, debian/pam-script-examples.files, debian/pam-script-examples.install, debian/pam-script-module.install, debian/rules: Got the debian packaging the way I want it. 2007-09-05 rkowen * pam_script.c: Need stdlib.h for calloc() as well as setenv() and putenv(). 2007-09-05 rkowen * etc/README.examples: Fixed reference to tally. 2007-09-04 rkowen * Makefile.am, debian/README.Debian, debian/control, debian/pam-script-examples.dirs, debian/pam-script-examples.install, debian/pam-script-module.dirs, debian/pam-script-module.install, debian/rules, etc/README, etc/README.examples: Changes for creating two debian packages. 2007-09-04 rkowen * pam_script.c: Changes to remove any compiler warnings. 2007-08-31 rkowen * ChangeLog: Updated. 2007-08-31 rkowen * NEWS: Updated with the tally example. 2007-08-31 rkowen * .cvsignore, debian/.cvsignore: Ignore more generated files. 2007-08-31 rkowen * etc/tally: Need to give a specific #! line and not a generic search for perl concoction. 2007-08-31 rkowen * pam_script.c: pam_script_exec() should only return PAM_SUCCESS or the return value given ... not what the script returns else this confuses PAM which will give incorrect error messages. 2007-08-31 rkowen * Makefile.am: Added a target for just copying all of the example scripts. 2007-08-31 rkowen * etc/README: Hopefully, made the documentation clearer. 2007-08-31 rkowen * etc/README, etc/tally: Fine tuned the lock_time and unlock_time algorithm. 2007-08-30 rkowen * Makefile.am: Added install-logger and install-tally targets. 2007-08-30 rkowen * configure.ac: Added the items indicated by another autoscan. 2007-08-30 rkowen * etc/README, etc/tally: Added another example - tally, which implements something similar to the pam-tally.so module. 2007-08-29 rkowen * ChangeLog: Updated. 2007-08-29 rkowen * NEWS, README, debian/pam-script.7.in, etc/logscript, pam_script.c: Switched from using the system() command to fork()/execve(), so the pam_script.so arguments could be passed on to the scripts. Therefore, a single script could be distributed to many systems in an organization, but custom behavior could be flagged in the pam.conf. 2007-08-28 rkowen * ChangeLog, NEWS: Updated the NEWS. 2007-08-28 rkowen * ChangeLog, Makefile.am, etc/README, etc/logscript: Added an example pam-script, which logs the PAM_* env.vars to a file. 2007-08-28 rkowen * pam_script.c: Should set the PAM_* env.vars to NULL if not present, else random garbage will be passed along. 2007-08-27 rkowen * Makefile.am, configure.ac, debian/pam-script.7.in, pam_script.c: Added the dir=/some/path/ option to pam_script.so . Seeing that snprintf() was no longer needed, now that the "complex" string formatting is nicely handled by strcpy() and strcat() and friends, eliminated the configure test for snprintf(). 2007-08-27 rkowen * configure.ac, debian/pam-script.7.in, pam_script.c: Expanded the list of env.vars. passed to the scripts. Aggregated the setenv() code to an internal routine pam_script_setenv() and use setenv() or putenv() depending on their existence. 2007-08-27 rkowen * README, debian/pam-script.7.in, pam_script.c: Added a functioning handler to the "account" module-type; so a script, pam_script_acct, could be called. Also moved the PAM_SM_* definitions to ahead of the security/pam_module.h header file so the the prototypes for static modules are properly declared. 2007-08-24 rkowen * Makefile.am, configure.ac, debian/README.Debian, debian/changelog, debian/control, debian/copyright, debian/pam-script-module.dirs, debian/pam-script-module.install, debian/pam-script.7.in, debian/rules: Started the debian packaging. 2007-08-23 j-nijhof * pam_script.c: [no log message] 2007-08-23 j-nijhof * pam_script.c: - fixed segfault at 'check for pam.conf options' part, rewritten it to old style argv handling - added PAM_USER, PAM_RHOST, PAM_SERVICE and PAM_AUTHTOK for use with environment - fixed default retval not PAM_SUCCESS but rv because otherwise everyone can enter the system if the program's are missing. 2007-08-23 rkowen * debian/pam-script.7.in: Added a man page. 2007-08-22 rkowen * pam_script.c: PAM doesn't pass an argv vector if there are no pam.conf options. 2007-08-22 rkowen * .cvsignore, ChangeLog, NEWS, README: Updated the documentation to the current state. 2007-08-22 rkowen * pam_script.c: Fixed the static PAM info. 2007-08-22 rkowen * pam_script.c: Forgot strcmp() header file. 2007-08-22 rkowen * configure.ac, pam_script.c: Check for vsyslog() and act accordingly. 2007-08-22 rkowen * README: Noted where to get the pamtest.c program from for debugging. 2007-08-22 rkowen * pam_script.c: Added the onerr=(success|fail) pam.conf option to specify what the default behaviour if the scripts are not found or executable. The scripts need to be executable at all levels (--x--x--x) because never know who will be executing them. syslog any pam_script_get_user() errors. 2007-08-21 rkowen * pam_script.c: Broke out the common code into static functions. Test for the script with stat(), and make sure it's executable. Added syslog support. Got it generally working. 2007-08-21 j-nijhof * pam_script.c: - Fixed execution of macro for auth, session open and session close. - Added default value for macro PAM_SCRIPT_DIR if not set. 2007-08-20 rkowen * Makefile, Makefile.am, configure.ac, pam_script.c: The pam_script_* programs are now pointed to by the sysconfdir in the configure script. 2007-08-17 rkowen * .cvsignore, config/.cvsignore: Have CVS ignore some of the generated files. 2007-08-17 rkowen * AUTHORS, ChangeLog, INSTALL, Makefile.am, NEWS, config/.README, configure.ac, cvs2cl.pl: Initial draft of autotool configuration files. 2005-03-16 j-nijhof * Initial revision pam_script-1.1.7/INSTALL000066400000000000000000000224501213721170600147150ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. pam_script-1.1.7/Makefile.am000066400000000000000000000056431213721170600157250ustar00rootroot00000000000000########################################################################### ## ## File: ./Makefile.am ## Versions: $Id: Makefile.am,v 1.16 2010/06/14 12:50:57 j-nijhof Exp $ ## Created: 2002/06/14 ## ########################################################################### ## ## run automake to generate a Makefile.in ## Makefile.am \ ## configure.ac > Makefile.in ## aclocal.m4 / ## ACLOCAL_AMFLAGS= -I config man_MANS = pam-script.7 moduledir = @libdir@ module_LTLIBRARIES = pam_script.la pam_script_la_SOURCES = pam_script.c pam_script_la_CFLAGS = $(AM_CFLAGS) -DPAM_SCRIPT_DIR="\"$(sysconfdir)\"" pam_script_la_LDFLAGS = -module -avoid-version EXTRA_DIST= \ pam-script.spec \ etc CL: rmChangeLog @echo "Updating ChangeLog" -@./cvs2cl.pl rmChangeLog: -@rm -f ChangeLog dist-hook: -rm -rf `find $(distdir) -name CVS` install-data-hook: # @echo === install-data-hook === -rm $(DESTDIR)/$(libdir)/$(module_LTLIBRARIES) install-exec-hook: ${INSTALL} -d $(DESTDIR)$(sysconfdir) ${INSTALL} -d $(DESTDIR)$(sysconfdir)/pam-script.d ${INSTALL} -m 644 etc/README $(DESTDIR)$(sysconfdir) ${INSTALL} -m 755 etc/pam_script $(DESTDIR)$(sysconfdir) (cd $(DESTDIR)$(sysconfdir); \ PAMSCRIPTDIR=. ./pam_script -x -s all pam_script) # @echo === install-exec-hook === install-examples: ${INSTALL} -d $(DESTDIR)$(sysconfdir) ${INSTALL} -m 644 etc/README.examples $(DESTDIR)$(sysconfdir) ${INSTALL} -m 755 etc/logscript $(DESTDIR)$(sysconfdir) ${INSTALL} -m 755 etc/tally $(DESTDIR)$(sysconfdir) install-logger: ${INSTALL} -d $(DESTDIR)$(sysconfdir) ${INSTALL} -m 755 etc/logscript $(DESTDIR)$(sysconfdir) cd $(DESTDIR)$(sysconfdir) && \ for f in pam_script_auth pam_script_acct pam_script_passwd \ pam_script_ses_open pam_script_ses_close; do \ test -e $$f || $(LN_S) logscript $$f; \ done install-tally: ${INSTALL} -d $(DESTDIR)$(sysconfdir) ${INSTALL} -m 755 etc/tally $(DESTDIR)$(sysconfdir) cd $(DESTDIR)$(sysconfdir) && \ for f in pam_script_auth pam_script_acct ; do \ test -e $$f || $(LN_S) tally $$f; \ done ftp-sourceforge: dist @echo "placing sourceforge.net files"; ${SHELL} ./.ftp.sf $(DIST_ARCHIVES); help: @echo "" @echo "make - compile sources to a shared library module" @echo "make all - same as above" @echo "make install - copy module and docs to destination" @echo "make install-examples - install all of the example scripts" @echo "make install-logger - install the logger example scripts" @echo "make install-tally - install the tally example scripts" @echo "make clean - cleans out most useless files" @echo "make disthelp - extra help for developers" @echo "" disthelp: @echo "" @echo "make dist - creates distribution tarballs" @echo "make distclean - cleans & removes most made files" @echo "make maintainer-clean - cleans even more" @echo "make CL - remakes the ChangeLog from the CVS commits" @echo "make ftp-sourceforge - upload to sourceforge" @echo "" pam_script-1.1.7/NEWS000066400000000000000000000061101213721170600143560ustar00rootroot00000000000000* Note: Implied Consent - If you send in a code patch or fix of one type or another you consent to have your name and email address listed here unless you explicitly note otherwise. Whether your name & email is actually listed depends on how extensive the change. (If it's a minor code, document change, or spelling correction your name will probably not be listed.) **************************** Release 1.1 ****************************** pam-script 1.1.7 Jeroen Nijhof * Fixed strcmp issue (thanks to Andy Igoshin) * Moved from SF to Github pam-script 1.1.6 Jeroen Nijhof * Added pam-auth-update support (thanks to Gaudenz Steinlin) * Changed /debian to maintainer version pam-script 1.1.5 Jeroen Nijhof * AC_CHECK_HEADERS improvements for libpam header files * Changed LOG_AUTHPRIV to LOG_AUTH for better syslog portability * fixed an expression in function pam_sm_chauthtok() used == for flags instead of a binary logic bit operator, report and fix by Mikolaj Kucharski. pam-script 1.1.4 Jeroen Nijhof * Moved the manpage to the correct path * fixed bug 2871389 - pam_sm_chauthtok() should first set PAM_OLDAUTHTOK and not PAM_AUTHTOK. PAM_AUTHTOK should contain the new password. * pam_sm_chauthtok() - Don't ask current password for user root. pam-script 1.1.3 R.K. Owen * fixed bugs 2787860 - extra echo in driver script & * 2784468 - leaked PAM_* env.vars. (thanks to yvan-seth) pam-script 1.1.2 Apr 14, 2009 Jeroen Nijhof * Official release of pam-script 1.1.2 pam-script 1.1.2 Oct 21, 2008 Jeroen Nijhof * Added converse functionality. pam-script 1.1.2 May 22, 2008 R.K. Owen * Added the pam_script driver script and the ./pam-script.d/ directory for an easy way for other packages to include PAM capability via pam-script (suggested by Petter Reinholdtsen). * Further improvements in the Debian/Ubuntu packaging. pam-script 1.1.1 Feb 5, 2008 R.K. Owen * conditional sections need to be after including config.h . * improved the Debian/Ubuntu package build instructions. pam-script 1.1.0 Dec 12, 2007 R.K. Owen * sources put under the GNU autotools: automake,libtool,autoconf. * test whether the pam-script exists and is executable. * added the pam.conf configure option - onerr=(success|fail) to set the default behavior when the script test fails. * added the pam.conf configure option - dir=/some/path/ to specify an alternative directory of where to look for the scripts. * set several PAM_* environment variables and pass them to the scripts. * pass the pam_script.so arguments to the script's command line. * added a man page for pam-script. * included examples: logscript and tally, where the latter mimics much of the pam-tally module capability. * package compatible to Debian and RedHat derivatives. pam-script 1.0.0 Mar 01, 2005 Jeroen Nijhof * Written by Jeroen Nijhof pam_script-1.1.7/README000066400000000000000000000047531213721170600145520ustar00rootroot00000000000000README PAM-script has been written by Jeroen Nijhof with packaging and some modifications by R.K. Owen . Description: PAM-script allows you to execute scripts during authorization, passwd changes, or session opening or closing. So if you need extra work done after login you can use this pam module to execute a session script. Options to pam_script.so: onerr=(success|fail) - default behavior if the module can not find or execute the various pam-scripts. The default is 'fail'. dir=/some/path - where to find the pam-scripts listed below. All options are passed on to the script commandlines and those not intercepted by PAM may be used to modify the script behavior. Module-type and Scripts: auth: pam_script_auth - username/password handshake account: pam_script_acct - non-auth account management passwd: pam_script_passwd - changing a password session: pam_script_ses_open - actions performed before and pam_script_ses_close after a session All the scripts will be passed several environment variables: PAM_USER, PAM_RUSER, PAM_RHOST, PAM_SERVICE, PAM_AUTHTOK, PAM_OLDAUTHTOK, PAM_TTY, and PAM_TYPE referring to the module-type. Whether the variable has a non-null value or not depends on the context. Pam.conf example: --- start pam.conf --- ssh auth required pam_script.so ssh session required pam_script.so ssh passwd required pam_script.so --- end pam.conf --- or as an extra step (here pam_script.so is optional because this application does some extra logging and doesn't want access denied if there is a problem): --- start pam.conf --- ssh auth required pam_unix.so ssh auth optional pam_script.so ssh session required pam_unix.so ssh session optional pam_script.so ssh passwd required pam_unix.so ssh passwd optional pam_script.so --- end pam.conf --- This example application has the pam_script_auth script check a database and return non-zero if the user should not be granted access. If the script does not exist or is not executable at all levels (chmod a+x) then deny access. ssh auth required pam_unix.so ssh auth required pam_script.so onerr=fail Debugging: Get the pamtest.c program from the pam-dotfile distribution and it can be used to step through the module. Examples: Look at the README.examples file, which may be located under /usr/share/doc/libpam-script/ for a Debian derived distribution. Problem/BUGS report: If you find any bugs or problems just mail me Jeroen Nijhof pam_script-1.1.7/config/000077500000000000000000000000001213721170600151265ustar00rootroot00000000000000pam_script-1.1.7/config/.README000066400000000000000000000003421213721170600160630ustar00rootroot00000000000000This directory contains the GNU autotools helper scripts, and this file is just here so the directory gets created when a fresh CVS chechout is done. The only files that are "native" to this directory are: .cvsignore .README pam_script-1.1.7/config/.gitignore000066400000000000000000000000021213721170600171060ustar00rootroot00000000000000* pam_script-1.1.7/configure.ac000066400000000000000000000052671213721170600161610ustar00rootroot00000000000000dnl dnl File: configure.in dnl Revision: $Id: configure.ac,v 1.14 2010/06/14 12:50:57 j-nijhof Exp $ dnl Created: 2007/08/17 dnl Author: Jeroen Nijhof dnl R.K. Owen dnl dnl Process this file with autoconf to produce a configure script dnl You need autoconf 2.59 or better! dnl dnl --------------------------------------------------------------------------- AC_PREREQ(2.59) AC_COPYRIGHT([ See the included file: COPYING for copyright information. ]) AC_INIT(pam-script, 1.1.7, [jeroen@jeroennijhof.nl,rkowen@nersc.gov]) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE(1.9.6) AC_CONFIG_SRCDIR([pam_script.c]) AC_CONFIG_HEADER([config.h]) AC_AIX AM_DISABLE_STATIC dnl -------------------------------------------------------------------- # Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_LIBTOOL dnl -------------------------------------------------------------------- # Checks for libraries. AC_CHECK_LIB(pam,pam_start) AC_CHECK_LIB(pam_misc,pam_misc_setenv) dnl -------------------------------------------------------------------- dnl Autoheader "templates" (was acconfig.h) AH_TOP([ /***** **** PAM-SCRIPT Header ************************************************ ** ** pam-script ** execute scripts or programs during the PAM stack phases: ** AUTH, ACCOUNT, SESSION, PASSWORD ** ** Description: config.h.in (generated by autoheader from configure.ac) ** *********************************************************************** ****/ ])dnl dnl -------------------------------------------------------------------- dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h syslog.h unistd.h]) AC_CHECK_HEADERS([security/pam_appl.h], [], [AC_MSG_ERROR([*** Sorry, you must install the PAM development module ***])]) AC_CHECK_HEADERS([security/pam_modules.h], [], [], [#include ]) dnl -------------------------------------------------------------------- dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T dnl -------------------------------------------------------------------- dnl Checks for library functions. AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_STAT AC_FUNC_VPRINTF AC_CHECK_FUNCS(vsyslog) if test $ac_cv_func_vsyslog = no; then # syslog is not in the default libraries. See if it's in some other. for lib in bsd socket inet; do AC_CHECK_LIB($lib, vsyslog, [AC_DEFINE(HAVE_VSYSLOG) LIBS="$LIBS -l$lib"; break]) done fi AC_CHECK_FUNCS([setenv putenv]) dnl -------------------------------------------------------------------- dnl Generate made files AC_CONFIG_FILES([Makefile pam-script.7 pam-script.spec]) AC_OUTPUT pam_script-1.1.7/debian/000077500000000000000000000000001213721170600151035ustar00rootroot00000000000000pam_script-1.1.7/debian/.gitignore000066400000000000000000000000711213721170600170710ustar00rootroot00000000000000pam-script.7 files libpam-script libpam-script.substvars pam_script-1.1.7/debian/README.Debian000066400000000000000000000011241213721170600171420ustar00rootroot00000000000000libpam-script for Debian ----------------- Libpam-script is using /usr/share/libpam-script/ as the default location, for storing the scripts. Keep in mind that you need to create or symlink the following files: - pam_script_acct - pam_script_auth - pam_script_passwd - pam_script_ses_close - pam_script_ses_open Please read the man-page, README, README.pam_script and README.example file in /usr/share/doc/libpam-script for further instructions. Examples can be found in /usr/share/doc/libpam-script/examples/ -- Martijn van Brummelen Tue, 23 Mar 2010 21:18:25 +0100 pam_script-1.1.7/debian/README.source000066400000000000000000000004021213721170600172560ustar00rootroot00000000000000 This package uses quilt to manage all modifications to the upstream source. Changes are stored in the source package as diffs in debian/patches and applied during the build. See /usr/share/doc/quilt/README.source for a detailed explanation. pam_script-1.1.7/debian/changelog000066400000000000000000000025521213721170600167610ustar00rootroot00000000000000libpam-script (1.1.7-1) unstable; urgency=low * New upstream release * Moved from SF to Github -- Jeroen Nijhof Sun, 28 Apr 2013 12:26:00 +0100 libpam-script (1.1.6-1) unstable; urgency=low * Added pam-auth-update support (thanks to Gaudenz Steinlin) * Changed /debian to maintainer version -- Jeroen Nijhof Mon, 7 May 2012 16:56:10 +0100 libpam-script (1.1.5-1) unstable; urgency=low * New upstream release * Adjust debian/copyright file to fix lintian error. * Bump standard version to 3.9.2. -- Martijn van Brummelen Wed, 22 Feb 2012 19:09:10 +0100 libpam-script (1.1.4-1) unstable; urgency=low * New upstream release * Remove pam-script.7.in.patch no longer needed. (upstream author accepted this patch) * pam_script_acct and pam_script_auth examples are removed. -- Martijn van Brummelen Tue, 15 Jun 2010 08:39:48 +0200 libpam-script (1.1.3-2) unstable; urgency=low * Adjust Description in control file (Closes: #582241). -- Martijn van Brummelen Wed, 19 May 2010 21:09:54 +0200 libpam-script (1.1.3-1) unstable; urgency=low * Initial release (Closes: #484289). * Added man-page patch to fix lintian warning. * Added README.Debian. -- Martijn van Brummelen Sun, 16 May 2010 13:43:26 +0200 pam_script-1.1.7/debian/compat000066400000000000000000000000021213721170600163010ustar00rootroot000000000000007 pam_script-1.1.7/debian/control000066400000000000000000000011721213721170600165070ustar00rootroot00000000000000Source: libpam-script Section: admin Priority: extra Maintainer: Martijn van Brummelen Build-Depends: debhelper (>= 7.0.50~), autotools-dev, libpam0g-dev Standards-Version: 3.9.3 Homepage: https://github.com/jeroennijhof/pam_script Package: libpam-script Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libpam-runtime Description: PAM module which allows executing a script This module will allow you to execute scripts during authorization, password changes and sessions. This is very handy if your current security application has no PAM support but is accessible with perl or other scripts. pam_script-1.1.7/debian/copyright000066400000000000000000000046151213721170600170440ustar00rootroot00000000000000This work was packaged for Debian by: Martijn van Brummelen on Tue, 23 Mar 2010 21:18:25 +0100 It was downloaded from: Upstream Authors: Primary Author: Other Authors and Major Contributors: Copyright: File: pam_script License GPL-2: This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". File: pam_script.c This file 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. Files: debian/* Copyright: 2011 Martijn van Brummelen License: GPL-3.0+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". pam_script-1.1.7/debian/dirs000066400000000000000000000000451213721170600157660ustar00rootroot00000000000000usr/share/doc/libpam-script/examples pam_script-1.1.7/debian/docs000066400000000000000000000000141213721170600157510ustar00rootroot00000000000000NEWS README pam_script-1.1.7/debian/libpam-script.examples000066400000000000000000000000611213721170600214060ustar00rootroot00000000000000etc/logscript etc/pam_script etc/README.examples pam_script-1.1.7/debian/postinst000066400000000000000000000001701213721170600167070ustar00rootroot00000000000000#!/bin/sh # postinst script for libpam-script # # see: dh_installdeb(1) set -e pam-auth-update --package #DEBHELPER# pam_script-1.1.7/debian/prerm000066400000000000000000000002471213721170600161560ustar00rootroot00000000000000#!/bin/sh # prerm script for libpam-script # # see: dh_installdeb(1) set -e if [ "$1" = remove ]; then pam-auth-update --package --remove script fi #DEBHELPER# pam_script-1.1.7/debian/rules000077500000000000000000000021001213721170600161540ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 SHELL := sh -e %: dh $@ override_dh_clean: rm -f config.status config.log dh_clean override_dh_auto_configure: dh_auto_configure -- --sysconfdir=/usr/share/libpam-script --libdir=/lib/security override_dh_install: rm -f debian/libpam-script/usr/share/libpam-script/pam_script* rm -f debian/libpam-script/usr/share/libpam-script/README rmdir debian/libpam-script/usr/share/libpam-script/pam-script.d mkdir debian/libpam-script/usr/share/pam-configs cp debian/script debian/libpam-script/usr/share/pam-configs/ dh_install override_dh_installdocs: cp etc/README debian/libpam-script/usr/share/doc/libpam-script/README.pam_script dh_installdocs pam_script-1.1.7/debian/script000066400000000000000000000004721213721170600163350ustar00rootroot00000000000000Name: Support for authentication by external scripts Default: yes Priority: 257 Auth-Type: Primary Auth: sufficient pam_script.so Account-Type: Primary Account: sufficient pam_script.so Password-Type: Primary Password: sufficient pam_script.so Session-Type: Additional Session: optional pam_script.so pam_script-1.1.7/debian/source/000077500000000000000000000000001213721170600164035ustar00rootroot00000000000000pam_script-1.1.7/debian/source/format000066400000000000000000000000141213721170600176110ustar00rootroot000000000000003.0 (quilt) pam_script-1.1.7/debian/watch000066400000000000000000000001251213721170600161320ustar00rootroot00000000000000version=3 https://github.com/jeroennijhof/pam_script/tags .*/v?(\d[\d\.]+)\.tar\.gz pam_script-1.1.7/etc/000077500000000000000000000000001213721170600144345ustar00rootroot00000000000000pam_script-1.1.7/etc/README000066400000000000000000000031111213721170600153100ustar00rootroot00000000000000Pam-script will look for the following scripts (or programs) in this directory. Only doing so if pam_script.so is included in the PAM stack for module-types of auth, account, password, and session respectively: pam_script_auth pam_script_acct pam_script_passwd pam_script_ses_open pam_script_ses_close The scripts can be symbolic links or not exist at all as the case may be. However, if the script is used, then it will receive several environment variables: PAM_SERVICE - the application that's invoking the PAM stack PAM_TYPE - the module-type (e.g. auth,account,session,password) PAM_USER - the user being authenticated into PAM_RUSER - the remote user, the user invoking the application PAM_RHOST - remote host PAM_TTY - the controlling tty PAM_AUTHTOK - password in readable text PAM_OLDAUTHTOK - old password in readable text Also the scripts will receive on the command line the arguments sent to pam_script.so as configured in the PAM configuration file(s). Whatever arguments that are not needed by pam_script.so are ignored and just passed on. The scripts must return an exit value of 0 if successful with regards to its purpose; else return a non-zero exit value. The pam_script.so module does not interpret non-zero values as anything else except as the appropriate failure for the given module-type. The pam_script tool can be used to create the links as needed. For example, if the script or program is named "foobar" then the links can be created with env PAMSCRIPTDIR=. ./pam_script -v -x -s all foobar run "./pam_script -h" for more options and further information. pam_script-1.1.7/etc/README.examples000066400000000000000000000074111213721170600171340ustar00rootroot00000000000000This directory gives some pam-script examples. To use these scripts they must be placed in the directory indicated by "configure --sysconfdir", which is usually /etc/pam-script, and symbolic links need to be made to conform to the acceptable list of scripts that are invoked by pam-script: pam_script_auth pam_script_acct pam_script_passwd pam_script_ses_open pam_script_ses_close Note that each example requires log or data files that are readable and writeable at all levels of authorization, because not all services that use PAM are run as the root user (e.g. gnome-screensaver, etc.) and may not allow successful access otherwise. Therefore, be aware of the security implications though. logscript: Simply records the PAM_* environment variables and the pam_script.so arguments to /tmp/pam-script.log. It's useful to observe which stages are executed and by whom. However, if the script is modified to show PAM_AUTHTOK, this exposes the raw password text. The default behavior for pam-script is to fail if a needed script is missing for the corresponding module-type. To try out the pam-script.so module and the logscript program with the various module-types, it's easiest to edit the individual common service configuration files. Make the following symbolic links in /etc/pam-script/ ln -s logscript pam_script_auth ln -s logscript pam_script_acct ln -s logscript pam_script_passwd ln -s logscript pam_script_ses_open ln -s logscript pam_script_ses_close or do env PAMSCRIPTDIR=. ./pam_script -v -x -s all logscript For Ubuntu/Debian: cat >>/etc/pam.d/common-account <>/etc/pam.d/common-auth <>/etc/pam.d/common-password <>/etc/pam.d/common-session <> /etc/pam.d/system-auth <>/etc/pam.d/common-account <>/etc/pam.d/common-auth <> /etc/pam.d/system-auth < COPYRIGHT AND LICENCE AUTHOR: R K Owen, Ph.D., of the National Energy Research Scientific Computing Center (NERSC), a Division of the Lawrence Berkeley National Laboratory (LBL), funded by the U.S. Department of Energy. Copyright (C) 2008 The Regents of the University of California This 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; version 2.0 of the License. pam_script-1.1.7/etc/logscript000077500000000000000000000020371213721170600163720ustar00rootroot00000000000000#! /bin/sh # # An example pam-script, which can be used as a template for your own # # The accepted list of scripts: # pam_script_auth # pam_script_acct # pam_script_passwd # pam_script_ses_open # pam_script_ses_close # # The environment variables passed by pam-script onto the script # (all will exist but some may be null if not applicable): # PAM_SERVICE - the application that's invoking the PAM stack # PAM_TYPE - the module-type (e.g. auth,account,session,password) # PAM_USER - the user being authenticated into # PAM_RUSER - the remote user, the user invoking the application # PAM_RHOST - remote host # PAM_TTY - the controlling tty # PAM_AUTHTOK - password in readable text # # assume a GNU compatible date stamp=`/bin/date +'%Y%m%d%H%M%S %a'` # get the script name (could be link) script=`basename $0` # LOGFILE=/tmp/pam-script.log echo $stamp $script $PAM_SERVICE $PAM_TYPE \ user=$PAM_USER ruser=$PAM_RUSER rhost=$PAM_RHOST \ tty=$PAM_TTY \ args=["$@"] \ >> $LOGFILE chmod 666 $LOGFILE > /dev/null 2>&1 # success exit 0 pam_script-1.1.7/etc/pam_script000077500000000000000000000073751213721170600165370ustar00rootroot00000000000000#! /bin/sh # COPYRIGHT AND LICENCE # # AUTHOR: R K Owen, Ph.D., # of the National Energy Research Scientific Computing Center (NERSC), # a Division of the Lawrence Berkeley National Laboratory (LBL), # funded by the U.S. Department of Energy. # # Copyright (C) 2008 The Regents of the University of California # # This 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; # version 2.0 of the License. basedir=`dirname $0` [ x"$basedir" = x"" ] && basedir="." fname=`basename $0` PAMSCRIPTDIR=${PAMSCRIPTDIR:-$basedir/pam-script.d} if [ x"$fname" != x"pam_script" ]; then # process files in pam-script.d/ mtype='' PAM_SCRIPT_STATUS=0 export PAM_SCRIPT_STATUS case $fname in *_auth) mtype='_auth' ;; *_acct) mtype='_acct' ;; *_passwd) mtype='_passwd' ;; *_ses_open) mtype='_ses_open' ;; *_ses_close) mtype='_ses_close' ;; esac for script in $PAMSCRIPTDIR/*$mtype; do if [ -e $script ]; then /bin/sh $script "$@" || PAM_SCRIPT_STATUS=1 fi export PAM_SCRIPT_STATUS done exit $PAM_SCRIPT_STATUS else # do administrative things usage() { /bin/cat </dev/null ;; link|remove) [ $verbose = 1 ] && echo $op eval set -- `echo $mtype | sed 's/,/ /g'` while [ $# -gt 0 ]; do case "$1" in auth) rmlink $op auth $pamfile $xbase ;; acct) rmlink $op acct $pamfile $xbase ;; passwd) rmlink $op passwd $pamfile $xbase ;; ses_open) rmlink $op ses_open $pamfile $xbase ;; ses_close) rmlink $op ses_close $pamfile $xbase ;; session) rmlink $op ses_open $pamfile $xbase rmlink $op ses_close $pamfile $xbase ;; all) rmlink $op auth $pamfile $xbase rmlink $op acct $pamfile $xbase rmlink $op passwd $pamfile $xbase rmlink $op ses_open $pamfile $xbase rmlink $op ses_close $pamfile $xbase ;; esac shift done ;; esac fi exit pam_script-1.1.7/etc/tally000077500000000000000000000073001213721170600155070ustar00rootroot00000000000000#! /usr/bin/perl # # May need to change the path for perl above # # Tally example # see the pam-tally module for details # my ($FILE,$deny,$lock_time, $unlock_time, $magic_root, $even_deny_root_account, $retval) = ("/tmp/pam-script-tally", 5, 5, 0, 0, 0, 0); my ($fmt) = ("%-12s %3d %s %s\n"); our ($opt_h,$opt_L,$opt_t,$opt_l,$opt_r); use Getopt::Std; getopts('hLt:l:r:'); $| = 1; # flush output $0 =~ s{^.*/}{}; # strip to basename &usage() if defined $opt_h; sub usage { print < 1); $tally{$user} = &dset(0,0,0) if ! exists $tally{$user}; my ($cnt,$sess,$auth) = &dget($tally{$user}); $cnt=0 if ! defined $cnt; $sess=0 if ! defined $sess; $auth=0 if ! defined $auth; if (defined $opt_t) { $tally{$user} = &dset($cnt+1, time, time); } elsif (defined $opt_r) { $tally{$user} = &dset(0, $sess, $auth); } elsif (defined $opt_l) { printf $fmt,$user,$cnt,&datetime($sess),&datetime($auth); } } elsif ($0 =~ /^pam_script_auth$/ || $0 =~ /^pam_script_acct$/) { foreach my $arg (@ARGV) { $deny = $1 if ($arg =~ /^deny=(\d+)/); $lock_time = $1 if ($arg =~ /^lock_time=(\d+)/); $unlock_time = $1 if ($arg =~ /^unlock_time=(\d+)/); $magic_root = 1 if ($arg =~ /^magic_root$/); $even_deny_root_account = 1 if ($arg =~ /^even_deny_root_account$/); } # grab some PAM env.vars. my $PAM_USER = $ENV{"PAM_USER"}; my ($cnt, $sess, $auth) = &dget($tally{$PAM_USER}); my $now = time; if ($0 =~ /^pam_script_auth$/) { # tally count $retval = 1 if $cnt && ($now < $auth + $lock_time); $cnt = 0 if ($cnt > $deny) && $unlock_time && ($now > $auth + $unlock_time); $cnt++; $cnt-- if $magic_root && $PAM_USER =~ /^root$/; $retval = 1 if $cnt >= $deny; $retval = 0 if ! $even_deny_root_account && $PAM_USER =~ /^root$/; $auth = $now; } elsif ($0 =~ /^pam_script_acct$/) { $sess = $now; $auth = $now; $cnt = 0; } $tally{$PAM_USER} = &dset($cnt,$sess,$auth); } untie %tally; exit $retval; sub datetime { my $time = shift; return "unset" if !$time; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); return sprintf "%04d%02d%02d%02d%02d%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec; } sub dset { my ($cnt,$sess,$auth) = @_; return pack "ill", $cnt, $sess, $auth; } sub dget { my $data = shift; return unpack "ill", $data; } 1; pam_script-1.1.7/git2cl.pl000077500000000000000000000246071213721170600154160ustar00rootroot00000000000000#!/usr/bin/perl # Copyright (C) 2007, 2008 Simon Josefsson # Copyright (C) 2007 Luis Mondesi # * calls git directly. To use it just: # cd ~/Project/my_git_repo; git2cl > ChangeLog # * implements strptime() # * fixes bugs in $comment parsing # - copy input before we remove leading spaces # - skip "merge branch" statements as they don't # have information about files (i.e. we never # go into $state 2) # - behaves like a pipe/filter if input is given from the CLI # else it calls git log by itself # # The functions mywrap, last_line_len, wrap_log_entry are derived from # the cvs2cl tool, see : # Copyright (C) 2001,2002,2003,2004 Martyn J. Pearce # Copyright (C) 1999 Karl Fogel # # git2cl 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, or (at your option) # any later version. # # git2cl 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 git2cl; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. use strict; use POSIX qw(strftime); use Text::Wrap qw(wrap); use FileHandle; use constant EMPTY_LOG_MESSAGE => '*** empty log message ***'; # this is a helper hash for stptime. # Assumes you are calling 'git log ...' with LC_ALL=C my %month = ( 'Jan'=>0, 'Feb'=>1, 'Mar'=>2, 'Apr'=>3, 'May'=>4, 'Jun'=>5, 'Jul'=>6, 'Aug'=>7, 'Sep'=>8, 'Oct'=>9, 'Nov'=>10, 'Dec'=>11, ); my $fh = new FileHandle; sub key_ready { my ($rin, $nfd); vec($rin, fileno(STDIN), 1) = 1; return $nfd = select($rin, undef, undef, 0); } sub strptime { my $str = shift; return undef if not defined $str; # we are parsing this format # Fri Oct 26 00:42:56 2007 -0400 # to these fields # sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1 # Luis Mondesi my @date; if ($str =~ /([[:alpha:]]{3})\s+([[:alpha:]]{3})\s+([[:digit:]]{1,2})\s+([[:digit:]]{1,2}):([[:digit:]]{1,2}):([[:digit:]]{1,2})\s+([[:digit:]]{4})/){ push(@date,$6,$5,$4,$3,$month{$2},($7 - 1900),-1,-1,-1); } else { die ("Cannot parse date '$str'\n'"); } return @date; } sub mywrap { my ($indent1, $indent2, @text) = @_; # If incoming text looks preformatted, don't get clever my $text = Text::Wrap::wrap($indent1, $indent2, @text); if ( grep /^\s+/m, @text ) { return $text; } my @lines = split /\n/, $text; $indent2 =~ s!^((?: {8})+)!"\t" x (length($1)/8)!e; $lines[0] =~ s/^$indent1\s+/$indent1/; s/^$indent2\s+/$indent2/ for @lines[1..$#lines]; my $newtext = join "\n", @lines; $newtext .= "\n" if substr($text, -1) eq "\n"; return $newtext; } sub last_line_len { my $files_list = shift; my @lines = split (/\n/, $files_list); my $last_line = pop (@lines); return length ($last_line); } # A custom wrap function, sensitive to some common constructs used in # log entries. sub wrap_log_entry { my $text = shift; # The text to wrap. my $left_pad_str = shift; # String to pad with on the left. # These do NOT take left_pad_str into account: my $length_remaining = shift; # Amount left on current line. my $max_line_length = shift; # Amount left for a blank line. my $wrapped_text = ''; # The accumulating wrapped entry. my $user_indent = ''; # Inherited user_indent from prev line. my $first_time = 1; # First iteration of the loop? my $suppress_line_start_match = 0; # Set to disable line start checks. my @lines = split (/\n/, $text); while (@lines) # Don't use `foreach' here, it won't work. { my $this_line = shift (@lines); chomp $this_line; if ($this_line =~ /^(\s+)/) { $user_indent = $1; } else { $user_indent = ''; } # If it matches any of the line-start regexps, print a newline now... if ($suppress_line_start_match) { $suppress_line_start_match = 0; } elsif (($this_line =~ /^(\s*)\*\s+[a-zA-Z0-9]/) || ($this_line =~ /^(\s*)\* [a-zA-Z0-9_\.\/\+-]+/) || ($this_line =~ /^(\s*)\([a-zA-Z0-9_\.\/\+-]+(\)|,\s*)/) || ($this_line =~ /^(\s+)(\S+)/) || ($this_line =~ /^(\s*)- +/) || ($this_line =~ /^()\s*$/) || ($this_line =~ /^(\s*)\*\) +/) || ($this_line =~ /^(\s*)[a-zA-Z0-9](\)|\.|\:) +/)) { $length_remaining = $max_line_length - (length ($user_indent)); } # Now that any user_indent has been preserved, strip off leading # whitespace, so up-folding has no ugly side-effects. $this_line =~ s/^\s*//; # Accumulate the line, and adjust parameters for next line. my $this_len = length ($this_line); if ($this_len == 0) { # Blank lines should cancel any user_indent level. $user_indent = ''; $length_remaining = $max_line_length; } elsif ($this_len >= $length_remaining) # Line too long, try breaking it. { # Walk backwards from the end. At first acceptable spot, break # a new line. my $idx = $length_remaining - 1; if ($idx < 0) { $idx = 0 }; while ($idx > 0) { if (substr ($this_line, $idx, 1) =~ /\s/) { my $line_now = substr ($this_line, 0, $idx); my $next_line = substr ($this_line, $idx); $this_line = $line_now; # Clean whitespace off the end. chomp $this_line; # The current line is ready to be printed. $this_line .= "\n${left_pad_str}"; # Make sure the next line is allowed full room. $length_remaining = $max_line_length - (length ($user_indent)); # Strip next_line, but then preserve any user_indent. $next_line =~ s/^\s*//; # Sneak a peek at the user_indent of the upcoming line, so # $next_line (which will now precede it) can inherit that # indent level. Otherwise, use whatever user_indent level # we currently have, which might be none. my $next_next_line = shift (@lines); if ((defined ($next_next_line)) && ($next_next_line =~ /^(\s+)/)) { $next_line = $1 . $next_line if (defined ($1)); # $length_remaining = $max_line_length - (length ($1)); $next_next_line =~ s/^\s*//; } else { $next_line = $user_indent . $next_line; } if (defined ($next_next_line)) { unshift (@lines, $next_next_line); } unshift (@lines, $next_line); # Our new next line might, coincidentally, begin with one of # the line-start regexps, so we temporarily turn off # sensitivity to that until we're past the line. $suppress_line_start_match = 1; last; } else { $idx--; } } if ($idx == 0) { # We bottomed out because the line is longer than the # available space. But that could be because the space is # small, or because the line is longer than even the maximum # possible space. Handle both cases below. if ($length_remaining == ($max_line_length - (length ($user_indent)))) { # The line is simply too long -- there is no hope of ever # breaking it nicely, so just insert it verbatim, with # appropriate padding. $this_line = "\n${left_pad_str}${this_line}"; } else { # Can't break it here, but may be able to on the next round... unshift (@lines, $this_line); $length_remaining = $max_line_length - (length ($user_indent)); $this_line = "\n${left_pad_str}"; } } } else # $this_len < $length_remaining, so tack on what we can. { # Leave a note for the next iteration. $length_remaining = $length_remaining - $this_len; if ($this_line =~ /\.$/) { $this_line .= " "; $length_remaining -= 2; } else # not a sentence end { $this_line .= " "; $length_remaining -= 1; } } # Unconditionally indicate that loop has run at least once. $first_time = 0; $wrapped_text .= "${user_indent}${this_line}"; } # One last bit of padding. $wrapped_text .= "\n"; return $wrapped_text; } # main my @date; my $author; my @files; my $comment; my $state; # 0-header 1-comment 2-files my $done = 0; $state = 0; # if reading from STDIN, we assume that we are # getting git log as input if (key_ready()) { #my $dummyfh; # don't care about writing #($fh,$dummyfh) = FileHandle::pipe; $fh->fdopen(*STDIN, 'r'); } else { $fh->open("LC_ALL=C git log --pretty --numstat --summary|") or die("Cannot execute git log...$!\n"); } while (my $_l = <$fh>) { #print STDERR "debug ($state, " . (@date ? (strftime "%Y-%m-%d", @date) : "") . "): `$_'\n"; if ($state == 0) { if ($_l =~ m,^Author: (.*),) { $author = $1; } if ($_l =~ m,^Date: (.*),) { @date = strptime($1); } $state = 1 if ($_l =~ m,^$, and $author and (@date+0>0)); } elsif ($state == 1) { # * modifying our input text is a bad choice # let's make a copy of it first, then we remove spaces # * if we meet a "merge branch" statement, we need to start # over and find a real entry # Luis Mondesi my $_s = $_l; $_s =~ s/^ //g; if ($_s =~ m/^Merge branch/) { $state=0; next; } $comment = $comment . $_s; $state = 2 if ($_l =~ m,^$,); } elsif ($state == 2) { if ($_l =~ m,^([0-9]+)\t([0-9]+)\t(.*)$,) { push @files, $3; } $done = 1 if ($_l =~ m,^$,); } if ($done) { print (strftime "%Y-%m-%d $author\n\n", @date); my $files = join (", ", @files); $files = mywrap ("\t", "\t", "* $files"), ": "; if (index($comment, EMPTY_LOG_MESSAGE) > -1 ) { $comment = "[no log message]\n"; } my $files_last_line_len = 0; $files_last_line_len = last_line_len($files) + 1; my $msg = wrap_log_entry($comment, "\t", 69-$files_last_line_len, 69); $msg =~ s/[ \t]+\n/\n/g; print "$files: $msg\n"; @date = (); $author = ""; @files = (); $comment = ""; $state = 0; $done = 0; } } if (@date + 0) { print (strftime "%Y-%m-%d $author\n\n", @date); my $msg = wrap_log_entry($comment, "\t", 69, 69); $msg =~ s/[ \t]+\n/\n/g; print "\t* $msg\n"; } pam_script-1.1.7/pam-script.7.in000066400000000000000000000061351213721170600164420ustar00rootroot00000000000000.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH PAM-SCRIPT 7 "August 22, 2007" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME pam-script \- a PAM module that can invoke scripts within the PAM stack. .SH SYNOPSIS .B pam-script.so .RI [ onerr=(success|fail) ][ dir=/some/path/ ] .SH DESCRIPTION .B pam-script allows you to execute scripts during authorization, passwd changes, and on session opening or closing. .PP Such scripts can perform necessary tasks or influence the outcome of the PAM stack. For example, if the following entry was included in .I pam.conf sshd auth required pam_script then if the script, .IR pam_script_auth , exits with a non-zero value this would cause the user to be denied SSH access to the machine. .PP .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, .\" respectively. .SH OPTIONS A summary of options is included below. .TP .B onerr=(success|fail) the default behavior if the module can not find or execute the script. The default is to fail if the option is not given. .TP .B dir=/some/path/ where to find the pam-scripts to invoke for each of the various module-types as described below. The default is dir=@sysconfdir@ if not given. List of scripts .TP .B pam_script_auth Executed under .I "auth" which handles the authentication stage of establishing the user via some challenge-response (i.e. username/password) .TP .B pam_script_acct invoked under .I "account" module-type for non-authentication based account management. .TP .B pam_script_passwd invoked under .I "passwd" for changing the password tokens. .TP .B pam_script_ses_open invoked when a .I "session" is first opened. .TP .B pam_script_ses_close run after a .I "session" is first closed. All the scripts will be passed several environment variables: PAM_USER, PAM_RUSER, PAM_RHOST, PAM_SERVICE, PAM_AUTHTOK, PAM_TTY, and PAM_TYPE referring to the module-type. The pam_script.so arguments in the pam.conf will be passed on the command line, which can be used to modify the script behavior. .SH FILES .B @libdir@/pam_script.so - the PAM module .br .B @sysconfdir@ - where the scripts should be placed by default .SH VERSION @PACKAGE_STRING@ .SH SEE ALSO .BR PAM (7) and the PAM "The System Administrators' Guide" .SH AUTHOR .nf pam-script was written by Jeroen Nijhof with some additions and modifications by R.K. Owen, Ph.D. . .PP This manual page was written by R.K. Owen , for the Debian project (but may be used by others). pam_script-1.1.7/pam-script.spec.in000066400000000000000000000031531213721170600172230ustar00rootroot00000000000000# see http://www.rpm.org/RPM-HOWTO/build.html for details # and sub-package details for maximum-rpm too # Summary: a PAM module that can invoke scripts within the PAM stack Name: pam-script Version: @VERSION@ Release: 2 License: GPL Vendor: LBNL/NERSC Group: System Environment/Base Source: https://github.com/jeroennijhof/pam_script/archive/@VERSION@.tar.gz BuildRoot: /var/tmp/%{name}-buildroot Provides: pam-script-@VERSION@ Requires: pam %description pam-script allows you to execute scripts during authorization, passwd changes, and on session opening or closing; which can affect the PAM stack. ---------- %package examples Summary: some pam-script example scripts and docs Group: System Environment/Base %description examples logscript - simply records the various PAM_* environment variables to a log file. Useful for studying how the various PAM modules work together. tally - a pam-script version of the pam-tally module with much of the same options. It's a perl script and is useful for hacking your own authentication scheme. %prep %setup %build %pre %install # pam-script ./configure --prefix=/usr \ --libdir=/lib/security \ --sysconfdir=/etc/pam-script \ --mandir=/usr/share/man make DESTDIR=$RPM_BUILD_ROOT install make DESTDIR=$RPM_BUILD_ROOT install-man7 make DESTDIR=$RPM_BUILD_ROOT install-examples %post # pam-script %preun # pam-script %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README /lib/security/pam_script.so /etc/pam-script/README /usr/share/man/man7/pam-script.7.gz %files examples /etc/pam-script/README.examples /etc/pam-script/logscript /etc/pam-script/tally pam_script-1.1.7/pam_script.c000066400000000000000000000265531213721170600162010ustar00rootroot00000000000000/* * Written by Jeroen Nijhof 2005/03/01 * * 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 - see the file COPYING. */ /* --- includes --- */ #include #include /* varg... */ #include /* strcmp,strncpy,... */ #include /* stat, fork, wait */ #include /* stat */ #include /* wait */ #include /* stat, fork, execve, **environ */ #include /* calloc, setenv, putenv */ /* enable these module-types */ #define PAM_SM_AUTH #define PAM_SM_ACCOUNT #define PAM_SM_SESSION #define PAM_SM_PASSWORD #include /* pam_* */ #include #ifdef HAVE_CONFIG_H # include "config.h" #endif #if HAVE_VSYSLOG # include /* vsyslog */ #endif /* --- customize these defines --- */ #ifndef PAM_SCRIPT_DIR # define PAM_SCRIPT_DIR "/usr/bin" #endif #define PAM_SCRIPT_AUTH "pam_script_auth" #define PAM_SCRIPT_ACCT "pam_script_acct" #define PAM_SCRIPT_PASSWD "pam_script_passwd" #define PAM_SCRIPT_SES_OPEN "pam_script_ses_open" #define PAM_SCRIPT_SES_CLOSE "pam_script_ses_close" /* --- defines --- */ #define PAM_EXTERN extern #define BUFSIZE 128 #define DEFAULT_USER "nobody" /* --- macros --- */ #define PAM_SCRIPT_SETENV(key) \ {if (pam_get_item(pamh, key, &envval) == PAM_SUCCESS) \ pam_script_setenv(#key, (const char *) envval); \ else pam_script_setenv(#key, (const char *) NULL);} /* external variables */ extern char **environ; #if 0 /* convenient function to throw into one of the methods below * for setting as a breakpoint for debugging purposes. */ void pam_script_xxx(void) { int i = 1; } #endif /* internal helper functions */ static void pam_script_syslog(int priority, const char *format, ...) { va_list args; va_start(args, format); #if HAVE_VSYSLOG openlog(PACKAGE, LOG_CONS|LOG_PID, LOG_AUTH); vsyslog(priority, format, args); closelog(); #else vfprintf(stderr, format, args); #endif } static void pam_script_setenv(const char *key, const char *value) { #if HAVE_SETENV setenv(key, (value?value:""), 1); #elif HAVE_PUTENV char buffer[BUFSIZE], *str; strncpy(buffer,key,BUFSIZE-2); strcat(buffer,"="); strncat(buffer,(value?value:""),BUFSIZE-strlen(buffer)-1); if ((str = (char *) malloc(strlen(buffer)+1)) != NULL) { strcpy(str,buffer); putenv(str); } /* else { untrapped memory error - just do not add to environment } */ #else # error Can not set the environment #endif } static int pam_script_get_user(pam_handle_t *pamh, const char **user) { int retval; retval = pam_get_user(pamh, user, NULL); if (retval != PAM_SUCCESS) { pam_script_syslog(LOG_ALERT, "pam_get_user returned error: %s", pam_strerror(pamh,retval)); return retval; } if (*user == NULL || **user == '\0') { pam_script_syslog(LOG_ALERT, "username not known"); retval = pam_set_item(pamh, PAM_USER, (const void *) DEFAULT_USER); if (retval != PAM_SUCCESS) return PAM_USER_UNKNOWN; } return retval; } static int pam_script_exec(pam_handle_t *pamh, const char *type, const char *script, const char *user, int rv, int argc, const char **argv) { int retval = rv, status, i; char cmd[BUFSIZE]; char **newargv; struct stat fs; const void *envval = NULL; pid_t child_pid = 0; strncpy(cmd, PAM_SCRIPT_DIR, BUFSIZE - 1); /* check for pam.conf options */ for (i = 0; i < argc; i++) { if (!strncmp(argv[i],"onerr=",6)) { if (!strcmp(argv[i],"onerr=fail")) retval = rv; else if (!strcmp(argv[i],"onerr=success")) retval = PAM_SUCCESS; else pam_script_syslog(LOG_ERR, "invalid option: %s", argv[i]); } if (!strncmp(argv[i],"dir=",4)) { if (argv[i] + 4) { /* got new scriptdir */ strncpy(cmd,argv[i] + 4, BUFSIZE - 2); } } } /* strip trailing '/' */ if (cmd[strlen(cmd)-1] == '/') cmd[strlen(cmd)-1] = '\0'; strcat(cmd,"/"); strncat(cmd,script,BUFSIZE-strlen(cmd)-1); /* test for script existence first */ if (stat(cmd, &fs) < 0) { /* stat failure */ pam_script_syslog(LOG_ERR,"can not stat %s", cmd); return retval; } if ((fs.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) != (S_IXUSR|S_IXGRP|S_IXOTH)) { /* script not executable at all levels */ pam_script_syslog(LOG_ALERT, "script %s not fully executable", cmd); return retval; } /* Execute external program */ /* fork process */ switch(child_pid = fork()) { case -1: /* fork failure */ pam_script_syslog(LOG_ALERT, "script %s fork failure", cmd); return retval; case 0: /* child */ /* Get PAM environment, pass it onto the child's environment */ PAM_SCRIPT_SETENV(PAM_SERVICE); pam_script_setenv("PAM_TYPE", type); pam_script_setenv("PAM_USER", user); PAM_SCRIPT_SETENV(PAM_RUSER); PAM_SCRIPT_SETENV(PAM_RHOST); PAM_SCRIPT_SETENV(PAM_TTY); PAM_SCRIPT_SETENV(PAM_AUTHTOK); PAM_SCRIPT_SETENV(PAM_OLDAUTHTOK); /* construct newargv */ if (!(newargv = (char **) calloc(sizeof(char *), argc+2))) return retval; newargv[0] = cmd; for (i = 0; i < argc; i++) { newargv[1+i] = (char *) argv[i]; } (void) execve(cmd, newargv, environ); /* shouldn't get here, unless an error */ pam_script_syslog(LOG_ALERT, "script %s exec failure", cmd); return retval; default: /* parent */ (void) waitpid(child_pid, &status, 0); if (WIFEXITED(status)) return (WEXITSTATUS(status) ? rv : PAM_SUCCESS); else return retval; } return PAM_SUCCESS; } static int pam_script_converse(pam_handle_t *pamh, int argc, struct pam_message **message, struct pam_response **response) { int retval; struct pam_conv *conv; retval = pam_get_item(pamh, PAM_CONV, (const void **)(void *) &conv); if (retval == PAM_SUCCESS) { retval = conv->conv(argc, (const struct pam_message **) message, response, conv->appdata_ptr); } return retval; } static int pam_script_set_authtok(pam_handle_t *pamh, int flags, int argc, const char **argv, char *prompt, int authtok) { int retval; char *password; struct pam_message msg[1],*pmsg[1]; struct pam_response *response; /* set up conversation call */ pmsg[0] = &msg[0]; msg[0].msg_style = PAM_PROMPT_ECHO_OFF; msg[0].msg = prompt; response = NULL; if ((retval = pam_script_converse(pamh, 1, pmsg, &response)) != PAM_SUCCESS) return retval; if (response) { if ((flags & PAM_DISALLOW_NULL_AUTHTOK) && response[0].resp == NULL) { free(response); return PAM_AUTH_ERR; } password = response[0].resp; response[0].resp = NULL; } else return PAM_CONV_ERR; free(response); pam_set_item(pamh, authtok, password); return PAM_SUCCESS; } static int pam_script_senderr(pam_handle_t *pamh, int flags, int argc, const char **argv, char *message) { int retval; struct pam_message msg[1],*pmsg[1]; struct pam_response *response; /* set up conversation call */ pmsg[0] = &msg[0]; msg[0].msg_style = PAM_ERROR_MSG; msg[0].msg = message; response = NULL; if ((retval = pam_script_converse(pamh, 1, pmsg, &response)) != PAM_SUCCESS) return retval; free(response); return PAM_SUCCESS; } /* --- authentication management functions --- */ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user=NULL; char *password; if ((retval = pam_script_get_user(pamh, &user)) != PAM_SUCCESS) return retval; /* * Check if PAM_AUTHTOK is set by early pam modules and * if not ask user for password. */ pam_get_item(pamh, PAM_AUTHTOK, (void*) &password); if (!password) { retval = pam_script_set_authtok(pamh, flags, argc, argv, "Password: ", PAM_AUTHTOK); if (retval != PAM_SUCCESS) return retval; } return pam_script_exec(pamh, "auth", PAM_SCRIPT_AUTH, user, PAM_AUTH_ERR, argc, argv); } PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv) { return PAM_SUCCESS; } /* --- account management functions --- */ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user=NULL; if ((retval = pam_script_get_user(pamh, &user)) != PAM_SUCCESS) return retval; return pam_script_exec(pamh, "account", PAM_SCRIPT_ACCT, user,PAM_AUTH_ERR,argc,argv); } /* --- password management --- */ PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user = NULL; char *password = NULL; char new_password[BUFSIZE]; if ((retval = pam_script_get_user(pamh, &user)) != PAM_SUCCESS) return retval; if ( flags & PAM_UPDATE_AUTHTOK ) { /* * Check if PAM_OLDAUTHTOK is set by early pam modules and * if not ask user (not root) for current password. */ pam_get_item(pamh, PAM_OLDAUTHTOK, (void*) &password); if (!password && strcmp(user, "root")) { retval = pam_script_set_authtok(pamh, flags, argc, argv, "Current password: ", PAM_OLDAUTHTOK); if (retval != PAM_SUCCESS) return retval; pam_get_item(pamh, PAM_OLDAUTHTOK, (void*) &password); } /* * Check if PAM_AUTHTOK is set by early pam modules and * if not ask user for the new password. */ pam_get_item(pamh, PAM_AUTHTOK, (void*) &password); if (!password) { retval = pam_script_set_authtok(pamh, flags, argc, argv, "New password: ", PAM_AUTHTOK); if (retval != PAM_SUCCESS) return retval; pam_get_item(pamh, PAM_AUTHTOK, (void*) &password); strncpy(new_password, password, BUFSIZE); password = NULL; retval = pam_script_set_authtok(pamh, flags, argc, argv, "New password (again): ", PAM_AUTHTOK); if (retval != PAM_SUCCESS) return retval; pam_get_item(pamh, PAM_AUTHTOK, (void*) &password); /* Check if new password's are the same */ if (strcmp(new_password, password)) { retval = pam_script_senderr(pamh, flags, argc, argv, "You must enter the same password twice."); if (retval != PAM_SUCCESS) return retval; return PAM_AUTHTOK_ERR; } } return pam_script_exec(pamh, "password", PAM_SCRIPT_PASSWD, user, PAM_AUTHTOK_ERR, argc, argv); } return PAM_SUCCESS; } /* --- session management --- */ PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user = NULL; if ((retval = pam_script_get_user(pamh, &user)) != PAM_SUCCESS) return retval; return pam_script_exec(pamh, "session", PAM_SCRIPT_SES_OPEN, user, PAM_SESSION_ERR, argc, argv); } PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user = NULL; if ((retval = pam_script_get_user(pamh, &user)) != PAM_SUCCESS) return retval; return pam_script_exec(pamh, "session", PAM_SCRIPT_SES_CLOSE, user, PAM_SESSION_ERR, argc, argv); } /* end of module definition */ #ifdef PAM_STATIC /* static module data */ struct pam_module _pam_script_modstruct = { "pam_script", pam_sm_authenticate, pam_sm_setcred, pam_sm_acct_mgmt, pam_sm_open_session, pam_sm_close_session, pam_sm_chauthtok }; #endif