Skip to content

Commit b7850f4

Browse files
bjorn3squell
authored andcommitted
Rename the pam binding files as requested
Also fix the Makefile to generate the bindings.
1 parent 50c5d42 commit b7850f4

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ PAM_SRC_DIR = src/pam
22

33
BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-function pam_vinfo --blocklist-function pam_verror --blocklist-type '.*va_list.*' --ctypes-prefix libc --no-layout-tests --sort-semantically
44

5+
PAM_VARIANT = $$(./get-pam-variant.bash)
6+
57
.PHONY: all clean pam-sys pam-sys-diff
68

79
pam-sys-diff:
8-
@$(BINDGEN_CMD) $< | diff --color=auto $(PAM_SRC_DIR)/sys.rs - || (echo run \'make -B pam-sys\' to apply these changes && false)
9-
@echo $(PAM_SRC_DIR)/sys.rs does not need to be re-generated
10+
@$(BINDGEN_CMD) $(PAM_SRC_DIR)/wrapper.h | \
11+
sed 's/rust-bindgen [0-9]*\.[0-9]*\.[0-9]*/&, minified by cargo-minify/' | \
12+
diff --color=auto $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs - \
13+
|| (echo run \'make -B pam-sys\' to apply these changes && false)
14+
@echo $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs does not need to be re-generated
1015

1116
# use 'make pam-sys' to re-generate the sys.rs file for your local platform
1217
pam-sys:
13-
$(BINDGEN_CMD) $(PAM_SRC_DIR)/wrapper.h --output $(PAM_SRC_DIR)/sys_$$(uname | tr 'A-Z' 'a-z').rs
18+
$(BINDGEN_CMD) $(PAM_SRC_DIR)/wrapper.h --output $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs
1419
cargo minify --apply --allow-dirty
15-
sed -i.bak 's/rust-bindgen [0-9]*\.[0-9]*\.[0-9]*/&, minified by cargo-minify/' $(PAM_SRC_DIR)/sys_$$(uname | tr 'A-Z' 'a-z').rs
16-
rm $(PAM_SRC_DIR)/sys_$$(uname | tr 'A-Z' 'a-z').rs.bak
20+
sed -i.bak 's/rust-bindgen [0-9]*\.[0-9]*\.[0-9]*/&, minified by cargo-minify/' $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs
21+
rm $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs.bak
1722

1823
clean:
1924
rm $(PAM_SRC_DIR)/sys.rs

get-pam-variant.bash

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# FIXME read headers to find the actually used variant
4+
case $(uname) in
5+
Linux)
6+
echo linuxpam
7+
;;
8+
FreeBSD)
9+
echo openpam
10+
;;
11+
*)
12+
echo "Unsupported platform"
13+
exit 1
14+
;;
15+
esac

src/pam/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ mod error;
1616
mod rpassword;
1717
mod securemem;
1818

19-
#[cfg_attr(target_os = "linux", path = "sys_linux.rs")]
20-
#[cfg_attr(target_os = "freebsd", path = "sys_freebsd.rs")]
19+
#[cfg_attr(target_os = "linux", path = "sys_linuxpam.rs")]
20+
#[cfg_attr(target_os = "freebsd", path = "sys_openpam.rs")]
2121
#[allow(nonstandard_style)]
2222
pub mod sys;
2323

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)