Skip to content

Instantly share code, notes, and snippets.

@jorritfolmer
Last active August 24, 2020 00:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jorritfolmer/e4bfb69b6d609542730b to your computer and use it in GitHub Desktop.
Save jorritfolmer/e4bfb69b6d609542730b to your computer and use it in GitHub Desktop.
.spec file to build Russell Stuart's pam-python on RHEL

pam_python.so on RHEL systems

pam_python.so is not readily available on RHEL systems. Here's how to create an RPM from Russell's tar.gz:

  1. download pam-python.1.0.4.tar.gz to ~/rpmbuild/SOURCES
  2. copy/paste pam-python.spec from below in ~/rpmbuild/SPECS/
  3. copy/paste pam-python-1.0.4-fix-compile-rhel.patch from below in ~/rpmbuild/SOURCES
  4. rpmbuild -bb ~/rpmbuild/SPECS/pam-python.spec

pam-python.spec

Name:		pam-python
Version:	1.0.4
Release:	1%{?dist}
Summary:	PAM module for Python

Group:		System Environment/Libraries
License:	AGPL 3.0
Vendor:		Russell Stuart
URL:		http://pam-python.sourceforge.net/
Source0:	%{name}-%{version}.tar.gz
BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

BuildRequires:	pam-devel
BuildRequires:	python-devel
BuildRequires:	python-sphinx
BuildRequires:	gcc
BuildRequires:	make
Requires:	python

Patch0:		pam-python-1.0.4-fix-compile-rhel.patch

%description
Pam-python is a PAM Module that runs the Python interpreter, thus allowing PAM Modules to be written in Python.

%prep
%setup -q
%patch0 -p0


%build
make  %{?_smp_mflags}


%install
rm -rf %{buildroot}
make install LIBDIR=/%{_lib}/security DESTDIR=%{buildroot}


%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
/%{_lib}/security/pam_python.so
%doc /usr/share/doc/pam_python/examples/pam_deny.py
%doc /usr/share/doc/pam_python/examples/pam_nologin.py
%doc /usr/share/doc/pam_python/examples/pam_permit.py
%doc /usr/share/doc/pam_python/html/_sources/pam_python.txt
%doc /usr/share/doc/pam_python/html/_static/basic.css
%doc /usr/share/doc/pam_python/html/_static/default.css
%doc /usr/share/doc/pam_python/html/_static/doctools.js
%doc /usr/share/doc/pam_python/html/_static/file.png
%doc /usr/share/doc/pam_python/html/_static/jquery.js
%doc /usr/share/doc/pam_python/html/_static/minus.png
%doc /usr/share/doc/pam_python/html/_static/plus.png
%doc /usr/share/doc/pam_python/html/_static/pygments.css
%doc /usr/share/doc/pam_python/html/_static/searchtools.js
%doc /usr/share/doc/pam_python/html/genindex.html
%doc /usr/share/doc/pam_python/html/index.html
%doc /usr/share/doc/pam_python/html/objects.inv
%doc /usr/share/doc/pam_python/html/pam_python.html
%doc /usr/share/doc/pam_python/html/search.html
%doc /usr/share/doc/pam_python/html/searchindex.js

%changelog

pam-python-1.0.4-fix-compile-rhel.patch

--- src/pam_python_old.c	2015-12-12 08:48:52.427887790 +0100
+++ src/pam_python.c	2015-12-12 08:49:01.241664132 +0100
@@ -23,6 +23,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <Python.h>
+
 #define PAM_SM_AUTH
 #define PAM_SM_ACCOUNT
 #define PAM_SM_SESSION
@@ -33,7 +35,6 @@
 
 #undef	_POSIX_C_SOURCE
 
-#include <Python.h>
 #include <dlfcn.h>
 #include <signal.h>
 #include <structmember.h>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment