rpam-ruby19-1.2.1/0000755000175000017500000000000012520722441011736 5ustar rikrikrpam-ruby19-1.2.1/README.rdoc0000644000175000017500000000334612520722441013552 0ustar rikrik= Rpam * https://github.com/canweriotnow/rpam-ruby19 == DESCRIPTION: This extension provides PAM (Pluggable Authentication Modules) integration. The library provides a stable API for applications to defer to for authentication tasks. == FEATURES/PROBLEMS: * Not reported == SYNOPSIS: In a nutshell (using the 'rpam' PAM service): require 'rpam' if Rpam.auth("user","password") == true puts "Authenticate Successful" else puts "Authenticate Failure" end Or, to use a different PAM service: if Rpam.auth("user", "password", :service => 'my_foo') == true This also supports compatibility with the original 'rpam': include Rpam if authpam("user","password") == true == REQUIREMENTS: * pam-devel * ruby-devel == INSTALL: * gem install rpam-ruby19 (might need sudo privileges) Or, you can do it the hard way (without Rubygems): * tar xzf rpam-*.tar.gz * cd rpam-*/ext * ruby extconf.rb * make * make install (might need sudo privileges) == LICENSE: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA A full copy of the GNU license is provided in the file LICENSE. rpam-ruby19-1.2.1/metadata.yml0000644000175000017500000000235212520722441014243 0ustar rikrik--- !ruby/object:Gem::Specification name: rpam-ruby19 version: !ruby/object:Gem::Version version: 1.2.1 prerelease: platform: ruby authors: - Andre Osti de Moura - Jason Lewis - Fred Emmott autorequire: bindir: bin cert_chain: [] date: 2011-08-16 00:00:00.000000000Z dependencies: [] description: ! "This extension provides PAM - Pluggable Authentication\n Modules - integration" email: jasonlewis.x@gmail.com executables: [] extensions: - ext/Rpam/extconf.rb extra_rdoc_files: - README.rdoc files: - ext/Rpam/rpam_ext.c - ext/Rpam/extconf.rb - rpam.gemspec - README.rdoc - LICENSE - lib/rpam.rb homepage: https://github.com/canweriotnow/rpam-ruby19 licenses: [] post_install_message: rdoc_options: - --line-numbers - --inline-source - --title - Rpam - --main - README.rdoc require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: 1.9.1 required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 1.8.10 signing_key: specification_version: 3 summary: PAM integration with ruby. test_files: [] rpam-ruby19-1.2.1/lib/0000755000175000017500000000000012520722441012504 5ustar rikrikrpam-ruby19-1.2.1/lib/rpam.rb0000644000175000017500000000046212520722441013772 0ustar rikrikrequire 'rpam_ext' module Rpam def authpam *args ::Rpam.auth(*args) end class < Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year 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. rpam-ruby19-1.2.1/rpam.gemspec0000644000175000017500000000151112520722441014240 0ustar rikrikGem::Specification.new do |s| s.name = %q{rpam-ruby19} s.version = "1.2.1" s.date = %q{2011-08-16} s.summary = %q{PAM integration with ruby.} s.require_paths = ["lib"] s.email = %q{jasonlewis.x@gmail.com} s.homepage = %q{https://github.com/canweriotnow/rpam-ruby19} s.description = %q{This extension provides PAM - Pluggable Authentication Modules - integration} s.required_ruby_version = Gem::Version::Requirement.new(">= 1.9.1") s.extra_rdoc_files = ["README.rdoc"] s.authors = ["Andre Osti de Moura", "Jason Lewis", "Fred Emmott"] s.files = ["ext/Rpam/rpam_ext.c", "ext/Rpam/extconf.rb", "rpam.gemspec", "README.rdoc", "LICENSE", 'lib/rpam.rb'] s.has_rdoc = true s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rpam", "--main", "README.rdoc"] s.extensions = ["ext/Rpam/extconf.rb"] end rpam-ruby19-1.2.1/ext/0000755000175000017500000000000012520722441012536 5ustar rikrikrpam-ruby19-1.2.1/ext/Rpam/0000755000175000017500000000000012520722441013435 5ustar rikrikrpam-ruby19-1.2.1/ext/Rpam/extconf.rb0000644000175000017500000000077312520722441015437 0ustar rikrikrequire 'mkmf' $CFLAGS = "" $LDFLAGS = "" have_pam_appl_h = have_header("security/pam_appl.h") have_pam_modules_h = have_header("security/pam_modules.h") have_pam_lib = have_library("pam","pam_start") have_func("pam_end") have_func("pam_open_session") have_func("pam_close_session") have_func("pam_authenticate") have_func("pam_acct_mgmt") # have_func("pam_fail_delay") #have_func("pam_setcred") #have_func("pam_chauthtok") #have_func("pam_putenv") #have_func("pam_getenv") create_makefile("rpam_ext") rpam-ruby19-1.2.1/ext/Rpam/rpam_ext.c0000644000175000017500000000724012520722441015423 0ustar rikrik/****************************************************************************** * * Rpam Copyright (c) 2008 Andre Osti de Moura * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * A full copy of the GNU license is provided in the file LICENSE. * *******************************************************************************/ #include "ruby.h" #include typedef struct { char *name, *pw; } pam_auth_t; VALUE Rpam; VALUE Rpam_Ext; void Init_rpam_ext(); /* * auth_pam_talker: supply authentication information to PAM when asked * * Assumptions: * A password is asked for by requesting input without echoing * A username is asked for by requesting input _with_ echoing * */ static int auth_pam_talker(int num_msg, const struct pam_message ** msg, struct pam_response ** resp, void *appdata_ptr) { unsigned short i = 0; pam_auth_t *userinfo = (pam_auth_t *) appdata_ptr; struct pam_response *response = 0; /* parameter sanity checking */ if (!resp || !msg || !userinfo) return PAM_CONV_ERR; /* allocate memory to store response */ response = malloc(num_msg * sizeof(struct pam_response)); if (!response) return PAM_CONV_ERR; /* copy values */ for (i = 0; i < num_msg; i++) { /* initialize to safe values */ response[i].resp_retcode = 0; response[i].resp = 0; /* select response based on requested output style */ switch (msg[i]->msg_style) { case PAM_PROMPT_ECHO_ON: /* on memory allocation failure, auth fails */ response[i].resp = strdup(userinfo->name); break; case PAM_PROMPT_ECHO_OFF: response[i].resp = strdup(userinfo->pw); break; default: if (response) free(response); return PAM_CONV_ERR; } } /* everything okay, set PAM response values */ *resp = response; return PAM_SUCCESS; } /* Authenticates a user and returns TRUE on success, FALSE on failure */ VALUE method_authpam(VALUE self, VALUE username, VALUE password, VALUE servicename) { char* rpam_servicename; pam_auth_t userinfo = {NULL, NULL}; struct pam_conv conv_info = {&auth_pam_talker, (void *) &userinfo}; pam_handle_t *pamh = NULL; int result; rpam_servicename = StringValuePtr(servicename); userinfo.name = StringValuePtr(username); userinfo.pw = StringValuePtr(password); if ((result = pam_start(rpam_servicename, userinfo.name, &conv_info, &pamh)) != PAM_SUCCESS) { return Qfalse; } if ((result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) { pam_end(pamh, PAM_SUCCESS); return Qfalse; } if ((result = pam_acct_mgmt(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) { pam_end(pamh, PAM_SUCCESS); return Qfalse; } pam_end(pamh, PAM_SUCCESS); return Qtrue; } /* initialize */ void Init_rpam_ext() { Rpam = rb_define_module("Rpam"); Rpam_Ext = rb_define_module_under(Rpam, "Ext"); rb_define_singleton_method(Rpam_Ext, "authpam", method_authpam, 3); }