python-pam-0.4.2/0000755000000000000000000000000010577530637012324 5ustar rootrootpython-pam-0.4.2/PAMmodule.c0000644000000000000000000004234310577027560014315 0ustar rootroot/* * PAMmodule.c * * Python PAM module * * Copyright (c) 1999 Rob Riggs and tummy.com, Ltd. All rights reserved. * Copyright (c) 2002 Benjamin POUSSIN and codelutin.com. All rights reserved. * Released under GNU GPL version 2. */ #include #include #include static PyObject *PyPAM_Error; typedef struct { PyObject_HEAD struct pam_conv *conv; pam_handle_t *pamh; char *service; char *user; PyObject *callback; PyObject *userData; } PyPAMObject; staticforward PyTypeObject PyPAMObject_Type; static void PyPAM_Err(PyPAMObject *self, int result) { PyObject *error; const char *err_msg; err_msg = pam_strerror(self->pamh, result); error = Py_BuildValue("(si)", err_msg, result); PyErr_SetObject(PyPAM_Error, error); } static int PyPAM_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { int i; PyPAMObject *self = (PyPAMObject *) appdata_ptr; PyObject *msgTuple, *respList, *msgList, *args; PyObject *respTuple; char *resp_text; int resp_retcode; struct pam_response *spr; if (self->callback == NULL) return PAM_CONV_ERR; Py_INCREF(self); msgList = PyList_New(num_msg); for (i = 0; i < num_msg; i++) { msgTuple = Py_BuildValue("(si)", msg[i]->msg, msg[i]->msg_style); PyList_SetItem(msgList, i, msgTuple); } args = Py_BuildValue("(OOO)", self, msgList, self->userData); respList = PyEval_CallObject(self->callback, args); Py_DECREF(args); Py_DECREF(self); if (respList == NULL) return PAM_CONV_ERR; if (!PyList_Check(respList)) { Py_DECREF(respList); return PAM_CONV_ERR; } *resp = (struct pam_response *) malloc(PyList_Size(respList) * sizeof(struct pam_response)); spr = *resp; for (i = 0; i < PyList_Size(respList); i++, spr++) { respTuple = PyList_GetItem(respList, i); resp_retcode = 0; if (!PyArg_ParseTuple(respTuple, "si", &resp_text, &resp_retcode)) { free(*resp); Py_DECREF(respList); return PAM_CONV_ERR; } spr->resp = strdup(resp_text); spr->resp_retcode = resp_retcode; } Py_DECREF(respList); return PAM_SUCCESS; } static struct pam_conv default_conv = { misc_conv, NULL }; static struct pam_conv python_conv = { PyPAM_conv, NULL }; static PyObject * PyPAM_pam(PyObject *self, PyObject *args) { PyPAMObject *p; struct pam_conv *spc; PyPAMObject_Type.ob_type = &PyType_Type; p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type); if ((spc = (struct pam_conv *) malloc(sizeof(struct pam_conv))) == NULL) { PyErr_SetString(PyExc_MemoryError, "out of memory"); return NULL; } p->conv = spc; p->pamh = NULL; p->service = NULL; p->user = NULL; p->callback = NULL; Py_INCREF(Py_None); p->userData = Py_None; return (PyObject *) p; } static PyObject * PyPAM_start(PyObject *self, PyObject *args) { int result; char *service = NULL, *user = NULL; PyObject *callback = NULL; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "s|sO:set_callback", &service, &user, &callback)) { PyErr_SetString(PyExc_TypeError, "parameter error"); return NULL; } if (callback != NULL && !PyCallable_Check(callback)) { PyErr_SetString(PyExc_TypeError, "parameter must be a function"); return NULL; } if (service) _self->service = strdup(service); if (user) _self->user = strdup(user); if (callback) { _self->callback = callback; Py_INCREF(callback); memcpy(_self->conv, &python_conv, sizeof(struct pam_conv)); _self->conv->appdata_ptr = (void *) self; } else { _self->callback = NULL; memcpy(_self->conv, &default_conv, sizeof(struct pam_conv)); } result = pam_start(_self->service, _self->user, _self->conv, &_self->pamh); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_authenticate(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "|i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_authenticate(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_setcred(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_setcred(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_acct_mgmt(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "|i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_acct_mgmt(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_chauthtok(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "|i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_chauthtok(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_open_session(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "|i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_open_session(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_close_session(PyObject *self, PyObject *args) { int result, flags = 0; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "|i", &flags)) { PyErr_SetString(PyExc_TypeError, "parameter must be integer"); return NULL; } result = pam_close_session(_self->pamh, flags); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_set_item(PyObject *self, PyObject *args) { int result, item; char *s_val, *n_val; PyObject *o_val; PyPAMObject *_self = (PyPAMObject *) self; if (PyArg_ParseTuple(args, "is", &item, &s_val)) { n_val = strdup(s_val); if (item == PAM_USER) _self->user = n_val; if (item == PAM_SERVICE) _self->service = n_val; result = pam_set_item(_self->pamh, item, (void *) n_val); } else { PyErr_Clear(); if (PyArg_ParseTuple(args, "iO:set_callback", &item, &o_val)) { if (item == PAM_CONV && !PyCallable_Check(o_val)) { PyErr_SetString(PyExc_TypeError, "parameter must be a function"); return NULL; } else { Py_XDECREF(_self->callback); _self->callback = o_val; Py_INCREF(_self->callback); memcpy(_self->conv, &python_conv, sizeof(struct pam_conv)); _self->conv->appdata_ptr = (void *) self; result = pam_set_item(_self->pamh, item, (void *) _self->conv); } } else { PyErr_SetString(PyExc_TypeError, "bad parameter"); return NULL; } } if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_get_item(PyObject *self, PyObject *args) { int result, item; const void *val; PyObject *retval; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "i", &item)) { PyErr_SetString(PyExc_TypeError, "bad parameter"); return NULL; } result = pam_get_item(_self->pamh, item, &val); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } if (item == PAM_CONV) retval = Py_BuildValue("O:set_callback", val); else retval = Py_BuildValue("s", val); return retval; } static PyObject * PyPAM_putenv(PyObject *self, PyObject *args) { int result; char *val; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "s", &val)) { PyErr_SetString(PyExc_TypeError, "parameter must be a string"); return NULL; } result = pam_putenv(_self->pamh, val); if (result != PAM_SUCCESS) { PyPAM_Err(_self, result); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * PyPAM_getenv(PyObject *self, PyObject *args) { const char *result, *val; PyObject *retval; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "s", &val)) { PyErr_SetString(PyExc_TypeError, "parameter must be a string"); return NULL; } result = pam_getenv(_self->pamh, val); if (result == NULL) { Py_INCREF(Py_None); return Py_None; } retval = Py_BuildValue("s", result); return retval; } static PyObject * PyPAM_getenvlist(PyObject *self, PyObject *args) { char **result, *cp; PyObject *retval, *entry; PyPAMObject *_self = (PyPAMObject *) self; result = pam_getenvlist(_self->pamh); if (result == NULL) { Py_INCREF(Py_None); return Py_None; } retval = PyList_New(0); while ((cp = *(result++)) != NULL) { entry = Py_BuildValue("s", cp); PyList_Append(retval, entry); Py_DECREF(entry); } return retval; } static PyObject * PyPAM_setUserData(PyObject *self, PyObject *args) { PyObject *userData = NULL; PyPAMObject *_self = (PyPAMObject *) self; if (!PyArg_ParseTuple(args, "O", &userData)) { PyErr_SetString(PyExc_TypeError, "parameter error"); return NULL; } Py_XDECREF(_self->userData); if (userData) { _self->userData = userData; Py_INCREF(userData); } else { _self->userData = NULL; } Py_INCREF(Py_None); return Py_None; } static PyMethodDef PyPAMObject_Methods[] = { {"start", PyPAM_start, METH_VARARGS, NULL}, {"authenticate", PyPAM_authenticate, METH_VARARGS, NULL}, {"setcred", PyPAM_setcred, METH_VARARGS, NULL}, {"acct_mgmt", PyPAM_acct_mgmt, METH_VARARGS, NULL}, {"chauthtok", PyPAM_chauthtok, METH_VARARGS, NULL}, {"open_session", PyPAM_open_session, METH_VARARGS, NULL}, {"close_session", PyPAM_close_session, METH_VARARGS, NULL}, {"set_item", PyPAM_set_item, METH_VARARGS, NULL}, {"get_item", PyPAM_get_item, METH_VARARGS, NULL}, {"putenv", PyPAM_putenv, METH_VARARGS, NULL}, {"getenv", PyPAM_getenv, METH_VARARGS, NULL}, {"getenvlist", PyPAM_getenvlist, METH_VARARGS, NULL}, {"setUserData", PyPAM_setUserData, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; static void PyPAM_dealloc(PyPAMObject *self) { free(self->service); free(self->user); free(self->conv); pam_end(self->pamh, PAM_SUCCESS); PyObject_FREE(self); } static PyObject * PyPAM_getattr(PyPAMObject *self, char *name) { return Py_FindMethod(PyPAMObject_Methods, (PyObject *) self, name); } static PyObject * PyPAM_repr(PyPAMObject *self) { char buf[1024]; snprintf(buf, 1024, "", self->service, self->user, self->conv, self->pamh); return PyString_FromString(buf); } static PyTypeObject PyPAMObject_Type = { PyObject_HEAD_INIT(0) /* Must fill in type value later */ 0, "pam", sizeof(PyPAMObject), 0, (destructor)PyPAM_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)PyPAM_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc)PyPAM_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ }; static PyMethodDef PyPAM_Methods[] = { {"pam", PyPAM_pam, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; static char PyPAMObject_doc[] = ""; /* Convenience routine to export an integer value. * * Errors are silently ignored, for better or for worse... * Happily borrowed from Python's socketmodule.c */ static void insint(PyObject *d, char *name, int value) { PyObject *v = PyInt_FromLong((long) value); if (!v || PyDict_SetItemString(d, name, v)) PyErr_Clear(); Py_XDECREF(v); } void initPAM(void) { PyObject *m, *d; m = Py_InitModule("PAM", PyPAM_Methods); d = PyModule_GetDict(m); PyPAM_Error = PyErr_NewException("PAM.error", NULL, NULL); if (PyPAM_Error == NULL) return; PyDict_SetItemString(d, "error", PyPAM_Error); PyPAMObject_Type.ob_type = &PyType_Type; PyPAMObject_Type.tp_doc = PyPAMObject_doc; Py_INCREF(&PyPAMObject_Type); insint(d, "PAM_SUCCESS", PAM_SUCCESS); insint(d, "PAM_OPEN_ERR", PAM_OPEN_ERR); insint(d, "PAM_SYMBOL_ERR", PAM_SYMBOL_ERR); insint(d, "PAM_SERVICE_ERR", PAM_SERVICE_ERR); insint(d, "PAM_SYSTEM_ERR", PAM_SYSTEM_ERR); insint(d, "PAM_BUF_ERR", PAM_BUF_ERR); insint(d, "PAM_PERM_DENIED", PAM_PERM_DENIED); insint(d, "PAM_AUTH_ERR", PAM_AUTH_ERR); insint(d, "PAM_CRED_INSUFFICIENT", PAM_CRED_INSUFFICIENT); insint(d, "PAM_AUTHINFO_UNAVAIL", PAM_AUTHINFO_UNAVAIL); insint(d, "PAM_USER_UNKNOWN", PAM_USER_UNKNOWN); insint(d, "PAM_MAXTRIES", PAM_MAXTRIES); insint(d, "PAM_NEW_AUTHTOK_REQD", PAM_NEW_AUTHTOK_REQD); insint(d, "PAM_ACCT_EXPIRED", PAM_ACCT_EXPIRED); insint(d, "PAM_SESSION_ERR", PAM_SESSION_ERR); insint(d, "PAM_CRED_UNAVAIL", PAM_CRED_UNAVAIL); insint(d, "PAM_CRED_EXPIRED", PAM_CRED_EXPIRED); insint(d, "PAM_CRED_ERR", PAM_CRED_ERR); insint(d, "PAM_NO_MODULE_DATA", PAM_NO_MODULE_DATA); insint(d, "PAM_CONV_ERR", PAM_CONV_ERR); insint(d, "PAM_AUTHTOK_ERR", PAM_AUTHTOK_ERR); insint(d, "PAM_AUTHTOK_RECOVER_ERR", PAM_AUTHTOK_RECOVER_ERR); insint(d, "PAM_AUTHTOK_LOCK_BUSY", PAM_AUTHTOK_LOCK_BUSY); insint(d, "PAM_AUTHTOK_DISABLE_AGING", PAM_AUTHTOK_DISABLE_AGING); insint(d, "PAM_TRY_AGAIN", PAM_TRY_AGAIN); insint(d, "PAM_IGNORE", PAM_IGNORE); insint(d, "PAM_ABORT", PAM_ABORT); insint(d, "PAM_AUTHTOK_EXPIRED", PAM_AUTHTOK_EXPIRED); insint(d, "PAM_MODULE_UNKNOWN", PAM_MODULE_UNKNOWN); insint(d, "PAM_BAD_ITEM", PAM_BAD_ITEM); insint(d, "_PAM_RETURN_VALUES", _PAM_RETURN_VALUES); insint(d, "PAM_SILENT", PAM_SILENT); insint(d, "PAM_DISALLOW_NULL_AUTHTOK", PAM_DISALLOW_NULL_AUTHTOK); insint(d, "PAM_ESTABLISH_CRED", PAM_ESTABLISH_CRED); insint(d, "PAM_DELETE_CRED", PAM_DELETE_CRED); insint(d, "PAM_REINITIALIZE_CRED", PAM_REINITIALIZE_CRED); insint(d, "PAM_REFRESH_CRED", PAM_REFRESH_CRED); insint(d, "PAM_CHANGE_EXPIRED_AUTHTOK", PAM_CHANGE_EXPIRED_AUTHTOK); insint(d, "PAM_SERVICE", PAM_SERVICE); insint(d, "PAM_USER", PAM_USER); insint(d, "PAM_TTY", PAM_TTY); insint(d, "PAM_RHOST", PAM_RHOST); insint(d, "PAM_CONV", PAM_CONV); /* These next two are most likely not needed for client apps */ insint(d, "PAM_RUSER", PAM_RUSER); insint(d, "PAM_USER_PROMPT", PAM_USER_PROMPT); insint(d, "PAM_DATA_SILENT", PAM_DATA_SILENT); insint(d, "PAM_PROMPT_ECHO_OFF", PAM_PROMPT_ECHO_OFF); insint(d, "PAM_PROMPT_ECHO_ON", PAM_PROMPT_ECHO_ON); insint(d, "PAM_ERROR_MSG", PAM_ERROR_MSG); insint(d, "PAM_TEXT_INFO", PAM_TEXT_INFO); #ifdef __LINUX__ insint(d, "PAM_RADIO_TYPE", PAM_RADIO_TYPE); insint(d, "PAM_BINARY_MSG", PAM_BINARY_MSG); insint(d, "PAM_BINARY_PROMPT", PAM_BINARY_PROMPT); #endif } python-pam-0.4.2/debian/0000755000000000000000000000000010577530637013546 5ustar rootrootpython-pam-0.4.2/debian/changelog0000644000000000000000000000670610577530551015424 0ustar rootrootpython-pam (0.4.2-12) unstable; urgency=low * Added Build-Depends: python2.5-dev (Closes: #415377) -- Dima Barsky Mon, 19 Mar 2007 15:51:05 +0000 python-pam (0.4.2-11) unstable; urgency=low * Acknowledged NMUs * Added 2.5 support (thanks to Harro Verkouter ) -- Dima Barsky Sat, 17 Mar 2007 17:46:16 +0000 python-pam (0.4.2-10.4) unstable; urgency=low * Non-maintainer upload. * Add the missing Conflicts/Replaces on python2.X-pam. -- Raphael Hertzog Thu, 29 Jun 2006 08:46:49 +0200 python-pam (0.4.2-10.3) unstable; urgency=low * Non-maintainer upload. * Switch to the new Python policy. Closes: #373335 -- Raphael Hertzog Sun, 25 Jun 2006 17:34:49 +0200 python-pam (0.4.2-10.2) unstable; urgency=low * Non-maintainer upload. * Stop building module for python2.1 and python2.2. (Closes: #351148) * Also support python2.4. -- Pierre Habouzit Sun, 9 Apr 2006 19:38:00 +0200 python-pam (0.4.2-10.1) unstable; urgency=low * NMU. * Change package section to python. * Make python dependency more robust. * Make python-pam package architecture all. -- Matthias Klose Sun, 28 Sep 2003 17:27:51 +0200 python-pam (0.4.2-10) unstable; urgency=low * Python2.3 is the default version now -- Dima Barsky Sat, 9 Aug 2003 19:44:56 +0100 python-pam (0.4.2-9) unstable; urgency=low * Removed all calls to dlopen and dlclose. Not sure why they were required before, but they only cause problems now. (Closes: #192005) -- Dima Barsky Sat, 10 May 2003 19:37:43 +0100 python-pam (0.4.2-8) unstable; urgency=low * python2.2-pam: now conflicts with python-pam (<=0.4.2-6) (Closes: #182949) * Added userData parameter to pam_conv function in pamtest.py, this test was broken in 0.4.2-7 -- Dima Barsky Mon, 10 Mar 2003 21:51:02 +0000 python-pam (0.4.2-7) unstable; urgency=low * Build three versions of python-pam for all Python versions (Closes: #181325) * Added user argument to the conversation method, thanks to Benjamin Poussin for the patch. (Closes: #170972) -- Dima Barsky Sun, 23 Feb 2003 10:55:15 +0000 python-pam (0.4.2-6) unstable; urgency=low * Removed compiled binary examples/pamexample from the package -- Dima Barsky Sat, 26 Oct 2002 02:49:54 +0100 python-pam (0.4.2-5) unstable; urgency=low * Added build dependency on libpam0g-dev (Closes: #166365) -- Dima Barsky Fri, 25 Oct 2002 20:38:46 +0100 python-pam (0.4.2-4) unstable; urgency=low * Taken over from Gregor Hoffleit * Compiled against python 2.2 * Replaced autoconf/automake by setup.py script * Bumped up Standards-Sersion to 3.5.7 -- Dima Barsky Wed, 16 Oct 2002 14:45:50 +0100 python-pam (0.4.2-3) unstable; urgency=low * Recompiled for unstable (closes: #66359). * Fixed buglet in examples/pamtest.py. -- Gregor Hoffleit Sun, 28 Jan 2001 20:35:44 +0100 python-pam (0.4.2-2) unstable; urgency=low * FHS transition: move documentation to /usr/share/doc. * Bumped up standards-version to 3.1.0. -- Gregor Hoffleit Thu, 13 Jan 2000 00:06:45 +0100 python-pam (0.4.2-1) unstable; urgency=low * Initial Release. -- Gregor Hoffleit Sat, 28 Aug 1999 19:20:23 +0200 python-pam-0.4.2/debian/control0000644000000000000000000000127110577530330015140 0ustar rootrootSource: python-pam Section: python Priority: optional Build-Depends: debhelper (>= 5.0.37.2), python-all-dev (>= 2.3.5-11), python2.5-dev, libpam0g-dev Maintainer: Dima Barsky Standards-Version: 3.7.2 Package: python-pam Architecture: any Depends: ${python:Depends}, ${shlibs:Depends} Conflicts: python2.3-pam, python2.4-pam Replaces: python2.3-pam, python2.4-pam Provides: ${python:Provides} XB-Python-Version: ${python:Versions} Description: A Python interface to the PAM library This module makes the PAM (Pluggable Authentication Modules) functions available in Python. With this module you can write Python applications that implement authentication services using PAM. python-pam-0.4.2/debian/rules0000755000000000000000000000227010577017257014625 0ustar rootroot#!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This is the debhelper compatibility version to use. export DH_COMPAT=5 PYVERS=$(shell pyversions -r) python2.5 build: build-stamp build-stamp: dh_testdir for python in $(PYVERS); \ do $$python setup.py build; \ done touch build-stamp clean: dh_testdir for python in $(PYVERS); \ do $$python setup.py clean; \ done rm -rf build-stamp build dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs for python in $(PYVERS); \ do $$python setup.py install --root=debian/python-pam; \ done # Build architecture-independent files here. binary-indep: build install # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installdocs -a -A AUTHORS README dh_installexamples -a -A examples/* dh_installchangelogs -a ChangeLog dh_strip -a dh_compress -a dh_fixperms -a #dh_pycentral is not needed as we don't have .py files (only a .so) #dh_pycentral -a dh_python -a dh_installdeb -a dh_shlibdeps -a dh_gencontrol -a dh_md5sums -a dh_builddeb -a binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary python-pam-0.4.2/debian/pycompat0000644000000000000000000000000210447526716015314 0ustar rootroot2 python-pam-0.4.2/debian/docs0000644000000000000000000000001707553266436014422 0ustar rootrootAUTHORS README python-pam-0.4.2/debian/README.Debian0000644000000000000000000000073107626012077015602 0ustar rootroot A Python PAM module for Debian ------------------------------ This is a Python PAM module packaged for Debian. Debian tries to use PAM for all authentication services. This module lets you write Python applications that implement authentication using PAM. No documentation yet. The module is mostly a wrapper around the PAM library functions. There's a simple example included in /usr/doc/python-pam/examples. 28.08.1999, Gregor Hoffleit python-pam-0.4.2/debian/copyright0000644000000000000000000000074307553266436015510 0ustar rootrootThis is the Debian package of a Python PAM module. This package was put together by Gregor Hoffleit , from sources obtained from ftp://ftp.pangalactic.org/pub/tummy/. Author: Rob Riggs Copyright: Copyright (c) 1999 Rob Riggs and tummy.com, Ltd. All rights reserved. Released under GNU GPL version 2. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. python-pam-0.4.2/setup.py0000644000000000000000000000066607553566107014047 0ustar rootroot#! /usr/bin/env python """Setup script for the Python-PAM module distribution.""" import distutils from distutils.core import setup from distutils.extension import Extension ext = Extension( name="PAMmodule", libraries=["pam","pam_misc"], sources=["PAMmodule.c"] ) ##print ext.__dict__; sys.exit(1) setup (name = 'PAM', version = '0.4.2', description = 'Python bindings for PAM', ext_modules = [ext]) python-pam-0.4.2/README0000644000000000000000000000166306756115202013201 0ustar rootrootPyPAM -- Python bindings for PAM ==================================== Author: Rob Riggs Sponsor: tummy.com, Ltd. This is a set of Python bindings for the PAM libraries. This package requires Python-1.5.2 or later. You can find an SRPM at these locations: ftp://ftp.pangalactic.org/pub/tummy/ You will need PAM 0.64 or later to compile and use this module. For some simple examples of its use, look in the examples directory. Compilation and Installation ==================================== I use RPM, so all that is needed is to unpack the SRPM and then a "rpm -bb /usr/src/redhat/SPECS/PyPAM.spec". If you received this as a tarball, try "rpm -ta PyPAM.tar.gz" instead. If you really enjoy doing things the hard way, try the following: ./configure make make install Contacting the Author ==================================== You can reach me via email at . python-pam-0.4.2/examples/0000755000000000000000000000000007633206370014133 5ustar rootrootpython-pam-0.4.2/examples/pamtest.py0000755000000000000000000000157307633206360016172 0ustar rootroot#!/usr/bin/env python import sys import PAM from getpass import getpass def pam_conv(auth, query_list, userData): resp = [] for i in range(len(query_list)): query, type = query_list[i] if type == PAM.PAM_PROMPT_ECHO_ON: val = raw_input(query) resp.append((val, 0)) elif type == PAM.PAM_PROMPT_ECHO_OFF: val = getpass(query) resp.append((val, 0)) elif type == PAM.PAM_PROMPT_ERROR_MSG or type == PAM.PAM_PROMPT_TEXT_INFO: print query resp.append(('', 0)) else: return None return resp service = 'passwd' if len(sys.argv) == 2: user = sys.argv[1] else: user = None auth = PAM.pam() auth.start(service) if user != None: auth.set_item(PAM.PAM_USER, user) auth.set_item(PAM.PAM_CONV, pam_conv) try: auth.authenticate() auth.acct_mgmt() except PAM.error, resp: print 'Go away! (%s)' % resp except: print 'Internal error' else: print 'Good to go!' python-pam-0.4.2/examples/pamexample.c0000644000000000000000000000261006756115202016425 0ustar rootroot/* This program was contributed by Shane Watts [modifications by AGM] You need to add the following (or equivalent) to the /etc/pam.conf file. # check authorization check_user auth required /usr/lib/security/pam_unix_auth.so check_user account required /usr/lib/security/pam_unix_acct.so */ #include #include #include static struct pam_conv conv = { misc_conv, NULL }; int main(int argc, char *argv[]) { pam_handle_t *pamh=NULL; int retval; const char *user="nobody"; if(argc == 2) { user = argv[1]; } if(argc > 2) { fprintf(stderr, "Usage: check_user [username]\n"); exit(1); } retval = pam_start("check_user", user, &conv, &pamh); if (retval == PAM_SUCCESS) retval = pam_authenticate(pamh, 0); /* is user really user? */ if (retval == PAM_SUCCESS) retval = pam_acct_mgmt(pamh, 0); /* permitted access? */ /* This is where we have been authorized or not. */ if (retval == PAM_SUCCESS) { fprintf(stdout, "Authenticated\n"); } else { fprintf(stdout, "Not Authenticated\n"); } if (pam_end(pamh,retval) != PAM_SUCCESS) { /* close Linux-PAM */ pamh = NULL; fprintf(stderr, "check_user: failed to release authenticator\n"); exit(1); } return ( retval == PAM_SUCCESS ? 0:1 ); /* indicate success */ } python-pam-0.4.2/ChangeLog0000644000000000000000000000306406756203403014071 0ustar rootroot1999-08-17 06:48 cvs * pamtest.py: Fix up example files a bit. 1999-08-17 06:47 cvs * examples/pamtest.py: Fix up the example files a bit. 1999-08-17 06:27 cvs * PAMmodule.c, pamtest.py: getpass.getpass() is not cooperating in the demo program. It seems to require that raw_input() be run before it gets run. Strange. 1999-08-17 04:46 cvs * PAMmodule.c, pamtest.py: Remove debugging code. Fix the PyPAM_conv callback code. Fix the pamtest.py example. 1999-08-17 02:47 cvs * Makefile, Makefile.in, PAMmodule.c, pamtest.py, .deps/PAMmodule.P: Figured out the silly shared library issues with Python. Solved with dlopen()/dlclose() using RTLD_GLOBAL. This should not be a problem, since PAM is fairly name-space friendly. 1999-08-16 23:21 cvs * COPYING, INSTALL, PAMmodule.c, install-sh, missing, mkinstalldirs, py-compile: Added missing files. Added revision string to PAMmodule. 1999-08-16 23:10 cvs * AUTHORS, Makefile, Makefile.am, Makefile.in, NEWS, PAMmodule.c, PyPAM.spec, README, aclocal.m4, autogen.sh, config.cache, config.log, config.status, configure, configure.in, pamtest.py, .deps/PAMmodule.P, examples/pamexample, examples/pamexample.c, examples/pamtest.py: [no log message] 1999-08-16 23:10 cvs * AUTHORS, Makefile, Makefile.am, Makefile.in, NEWS, PAMmodule.c, PyPAM.spec, README, aclocal.m4, autogen.sh, config.cache, config.log, config.status, configure, configure.in, pamtest.py, .deps/PAMmodule.P, examples/pamexample, examples/pamexample.c, examples/pamtest.py: Initial revision python-pam-0.4.2/COPYING0000644000000000000000000004311006756116361013354 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. python-pam-0.4.2/AUTHORS0000644000000000000000000000004106756115202013356 0ustar rootrootRob Riggs