Use pkg-config to link against pam (#665)

* Use pkg-config to link against pam

Some distros, such as nixos, require more than just '-lpam' to locate
the library. Adding a naive pkg-config invocation to the pam FFI
crate allows pam_kanidm to build on my system, where before this change
it did not.

* Update contributors

Add myself, as requested
This commit is contained in:
Euan Kemp 2022-04-01 20:28:48 -07:00 committed by GitHub
parent 0c3ce226cf
commit 4862b919de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View file

@ -14,9 +14,9 @@
* Samuel Cabrero (scabrero) * Samuel Cabrero (scabrero)
* Victor Wai (vcwai) * Victor Wai (vcwai)
* James Hodgkinson (yaleman) * James Hodgkinson (yaleman)
* Euan Kemp (euank)
## Acknowledgements ## Acknowledgements
* M. Gerstner * M. Gerstner
* Perri Boulton * Perri Boulton

5
Cargo.lock generated
View file

@ -2528,6 +2528,7 @@ version = "1.1.0-alpha.7"
dependencies = [ dependencies = [
"kanidm_unix_int", "kanidm_unix_int",
"libc", "libc",
"pkg-config",
] ]
[[package]] [[package]]
@ -2675,9 +2676,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.24" version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]] [[package]]
name = "plotters" name = "plotters"

View file

@ -4,6 +4,7 @@ version = "1.1.0-alpha.7"
authors = ["William Brown <william@blackhats.net.au>"] authors = ["William Brown <william@blackhats.net.au>"]
rust-version = "1.59" rust-version = "1.59"
edition = "2021" edition = "2021"
links = "pam"
[lib] [lib]
name = "pam_kanidm" name = "pam_kanidm"
@ -13,3 +14,6 @@ path = "src/lib.rs"
[dependencies] [dependencies]
kanidm_unix_int = { path = "../", version = "1.1.0-alpha" } kanidm_unix_int = { path = "../", version = "1.1.0-alpha" }
libc = "0.2" libc = "0.2"
[build-dependencies]
pkg-config = "0.3.25"

View file

@ -0,0 +1,8 @@
fn main() {
// ignore errors here since older versions of pam do not ship the pkg-config `pam.pc` file.
// Not setting anything here will fall back on just blindly linking with `-lpam`,
// which will work on environments with libpam.so, but no pkg-config file.
let _ = pkg_config::Config::new()
.atleast_version("1.3.0")
.probe("pam");
}