diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e8df279 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +include/json.hpp +*.o +pam_privacyidea.so +*.swp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2b2f133 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +CC = g++ +CFLAGS = -g -Wall -fPIC -Iinclude +LDFLAGS = -Wno-undef -lcurl --shared + +# Determine which folder to use +libdir.x86_64 = /lib64/security +libdir.i686 = /lib/security + +MACHINE := $(shell uname -m) +libdir = $(libdir.$(MACHINE)) + +target = pam_privacyidea.so +objects = src/pam_privacyidea.o src/PrivacyIDEA.o + +all: pam_privacyidea.so + +$(objects): src/%.o: src/%.cpp + +%.o: + $(CC) -c $(CFLAGS) $< -o $@ + +$(target): $(objects) + $(CC) $(LDFLAGS) -o $@ $^ + +clean: + rm -f src/*.o $(target) + +install: all + strip --strip-unneeded $(target) + cp $(target) $(libdir) + +uninstall: + rm $(libdir)/$(target) + +.PHONY: all clean install uninstall diff --git a/README.md b/README.md index 3d1a458..f1d5c06 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,21 @@ * Multi-Challenge ## Build -This project requires the [very good JSON parser from nlohmann](https://github.com/nlohmann/json). Put the single include file `json.hpp` in `include`. +This project requires the [very good JSON parser from nlohmann](https://github.com/nlohmann/json). Put the `json.hpp` file from the `single_include` folder in `include`. It also requires the following libraries: `libcurl4-openssl-dev`, `libssl-dev`, `libpam0g-dev` +Compilation requires g++ and make. Installation also uses strip to remove debug symbols from the module. Compile with: - g++ -Wall -fPIC -g -Iinclude -c /path/to/src/pam_privacyidea.cpp -o obj/(Debug/Release)/src/pam_privacyidea.o - g++ -Wall -fPIC -g -Iinclude -c /path/to/src/PrivacyIDEA.cpp -o obj/(Debug/Release)/src/PrivacyIDEA.o - g++ -shared obj/(Debug/Release)/src/pam_privacyidea.o obj/(Debug/Release)/src/PrivacyIDEA.o -o bin/(Debug/Release)/pam_privacyidea.so -Wno-undef -lcurl + make + +Install and remove with: + + make install + make uninstall + +This will install the PAM module in `/lib/security` or `/lib64/security` ## Configuration The following values can be appended to the pam config file line that references this module: diff --git a/include/Config.h b/include/config.h similarity index 100% rename from include/Config.h rename to include/config.h diff --git a/include/PrivacyIDEA.h b/include/privacyIDEA.h similarity index 100% rename from include/PrivacyIDEA.h rename to include/privacyIDEA.h diff --git a/include/Response.h b/include/response.h similarity index 100% rename from include/Response.h rename to include/response.h