From c0922dd567c4adff486761b6096089f9ba54828c Mon Sep 17 00:00:00 2001 From: Franco Ricci Date: Wed, 3 Jul 2019 11:44:45 +0200 Subject: [PATCH 1/2] New FreeBSD support + fix setup.py Added support to build under FreeBSD with gcc >=5. To build use gmake instead of make. Fixed use of os.environ to be complaint with Python3 --- doc/Makefile | 4 ++++ src/Makefile | 5 +++++ src/pam_python.c | 8 +++++--- src/setup.py | 6 ++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 28243a1..b5eac89 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,3 +1,7 @@ +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),FreeBSD) + PREFIX ?= /usr/local +endif PREFIX ?= /usr DOCDIR ?= $(PREFIX)/share/doc/pam_python diff --git a/src/Makefile b/src/Makefile index 8d683ea..37e026d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,6 +3,11 @@ all: ctest pam_python.so test-pam_python.pam WARNINGS=-Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror #WARNINGS=-Wunreachable-code # Gcc 4.1 .. 4.4 are too buggy to make this useful +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),FreeBSD) + LIBDIR ?= /usr/local/lib/security +endif + LIBDIR ?= /lib/security pam_python.so: pam_python.c setup.py Makefile diff --git a/src/pam_python.c b/src/pam_python.c index e01ee68..64f76d3 100644 --- a/src/pam_python.c +++ b/src/pam_python.c @@ -29,7 +29,7 @@ #define PAM_SM_PASSWORD #include -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include #include #else @@ -51,8 +51,10 @@ #endif #ifndef DEFAULT_SECURITY_DIR -#ifdef __APPLE__ +#if defined(__APPLE__) #define DEFAULT_SECURITY_DIR "/usr/lib/pam/" +#elif defined(__FreeBSD__) +#define DEFAULT_SECURITY_DIR "/usr/lib/" #else #define DEFAULT_SECURITY_DIR "/lib/security/" #endif @@ -1927,7 +1929,7 @@ static PyObject* PamHandle_fail_delay( { int err; int micro_sec = 0; - int pam_result; + /*int pam_result; */ PyObject* result = 0; static char* kwlist[] = {"micro_sec", NULL}; diff --git a/src/setup.py b/src/setup.py index ce718dd..66d0b4d 100755 --- a/src/setup.py +++ b/src/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -W default +#!/usr/bin/env -S python2.7 -W default import warnings; warnings.simplefilter('default') import distutils.sysconfig @@ -25,7 +25,9 @@ "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Systems Administration :: Authentication/Directory"] -if not os.environ.has_key("Py_DEBUG"): +#if not os.environ.has_key("Py_DEBUG"): +# fixed for python3 compatibility +if not 'Py_DEBUG' in os.environ: Py_DEBUG = [] else: Py_DEBUG = [('Py_DEBUG',1)] From 10a7578d52462e7321fcb1bd6ec3f38cbd62eda4 Mon Sep 17 00:00:00 2001 From: Franco Ricci Date: Wed, 3 Jul 2019 18:37:16 +0200 Subject: [PATCH 2/2] Update README --- README.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.txt b/README.txt index 296c02a..6c3e5f1 100644 --- a/README.txt +++ b/README.txt @@ -42,6 +42,31 @@ Building and Installing To run the test suite, in the directory containing this file run: make test +Building and Installing FreeBSD +----------------------- + + The build dependencies are: + - Python2 development system, http://www.python.org + - A POSIX system (make, unix shell, sed, etc). + - gcc >= 5 + - The PAM development libraries, + http://pam.sourceforge.net + + In addition the unit test requires: + - sudo, http://www.sudo.ws/ + - An account with root privileges. + + To build the re-distributable, in the directory containing + this file run: + gmake + + To install, in the directory containing this file run: + gmake install + + To run the test suite, in the directory containing this file run: + gmake test + + PAM module pam_python.so will be installed in /usr/local/lib/security path License -------