1wilkens / pam-sys

Rust FFI bindings to the Linux Pluggable Authentication Modules (PAM)
https://docs.rs/pam-sys/
Apache License 2.0
18 stars 21 forks source link

Won't build on OS X Sierra (10.12.3+, at least) #1

Closed RomainMuller closed 7 years ago

RomainMuller commented 7 years ago

Hey,

The bindings don't build on OS X Sierra because it attempts linking against pam_misc, which apparently does not exist.

See the below trace:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/usr/local/Cellar/rust/1.16.0/lib/rustlib/x86_64-apple-darwin/lib" "/Users/rmuller/Dropbox/Private/Development/test/target/debug/deps/test.0.o" "-o" "/Users/rmuller/Dropbox/Private/Development/test/target/debug/deps/libtest.dylib" "/Users/rmuller/Dropbox/Private/Development/test/target/debug/deps/test.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/rmuller/Dropbox/Private/Development/test/target/debug/deps" "-L" "/usr/local/Cellar/rust/1.16.0/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libpam_sys-ab9e9d3b8ab186e5.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/liblibc-5dc7b85e748840b4.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libstd-a71699d9a2708b89.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/librand-670a947df89a2ccc.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libcollections-5b3898f8c5f0e814.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libstd_unicode-a3427337083eea0c.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libpanic_unwind-938ad17540379fcc.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libunwind-cb9ccdab2eb2dc79.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/liballoc-a6daae03bd7bd954.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/liballoc_system-997c707c901d0bda.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/liblibc-4e8e9be8cd6f1b87.rlib" "-Wl,-force_load,/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libcore-f29b4bdb6959fcf5.rlib" "/var/folders/61/gpv4h95539n7fwl076y822bhr5yvck/T/rustc.OiuyAIbfTR4x/libcompiler_builtins-87bae4784d673068.rlib" "-l" "pam" "-l" "pam_misc" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib"
  = note: ld: library not found for -lpam_misc
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there a way this binding can be made optional?

1wilkens commented 7 years ago

Sorry totally missed that issue! I think it should be possible with standard config attributes as they are used in the standard library as well. Unfortunately I don't have a mac to test any changes, so it would be great if you could help with that once I cook something up.

steveatinfincia commented 7 years ago

This can be resolved in part by preventing functions that don't exist on OS X from being compiled, I have a branch that does this here.

The other part is to add a bit of code to pam-auth (or any other crate using pam-sys) that uses the functions that are available on OS X to do the roughly the same thing.

It looks like pam_putenv and pam_getenv can substitute for part of it, and the behavior of pam_misc_drop_env can be replicated in other ways.

1wilkens commented 7 years ago

@steveatinfincia looks good, mind opening a PR? I was going to go the same route but didn't get around to do it. Yeah, pam_misc_drop_env is just a convenience function, I should be able to replace it somehow.

steveatinfincia commented 7 years ago

@1wilkens sure I'll open one tonight :)

1wilkens commented 7 years ago

Fixed by #2!