Repository navigation
Support J715 Touch ID and SDDM fingerprint login #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
06a361d
2f08443
66d56c7
57e1ca1
3d9195c
cbecf9f
716b0c9
267ee02
6658d80
3ea608a
cd2642b
9f48c58
6a61152
1e20d4c
97add39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,8 @@ if compatible apple,t8103 || compatible apple,t6000 || compatible apple,t6001; t | |
| echo unsupported:m1-family | ||
| exit 0 | ||
| elif ! compatible apple,t8112 && ! compatible apple,t6020 && ! compatible apple,t6021 && ! compatible apple,t8140 && | ||
| ! { compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; }; then | ||
| ! { compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; } && | ||
| ! { compatible apple,t8132 && compatible apple,j715; }; then | ||
| echo unsupported:board | ||
| exit 0 | ||
| fi | ||
|
|
@@ -68,7 +69,7 @@ calibration=apple/mesa_calibration.bin | |
| if [[ -r $sensor/firmware-name ]]; then | ||
| calibration=$(tr -d '\0' <"$sensor/firmware-name") | ||
| fi | ||
| if ! installed "$calibration" && { compatible apple,t8140 || ! can_extract extract-mesa-calibration; }; then | ||
| if ! installed "$calibration" && { compatible apple,t8140 || compatible apple,t8132 || ! can_extract extract-mesa-calibration; }; then | ||
| echo unsupported:no-calibration | ||
| exit 0 | ||
|
audreyt marked this conversation as resolved.
Resolved
|
||
| fi | ||
|
|
@@ -79,4 +80,10 @@ if compatible apple,t8140 && ! installed apple/msrk-j700.bin && | |
| echo unsupported:no-root-key | ||
| exit 0 | ||
| fi | ||
| # J715 needs its own FDR MSRk and FSC2, not the Neo's reconstructed key or | ||
| # the older calibration an extractor can find in the system container. | ||
| if compatible apple,t8132 && ! installed apple/msrk-j715.bin; then | ||
| echo unsupported:no-root-key | ||
| exit 0 | ||
| fi | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed: eligibility now checks metadata for every present J715 key candidate, requiring a regular readable 10848-byte file and rejecting malformed shadows even beside a good copy. No private body is read. The new cases fail on the old helper; the calibration/key suite now passes 50 cases, including missing files, valid symlinks and unchanged non-J715 rules. Fixed in 1e20d4c. |
||
| echo available | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| #!/usr/bin/python3 -I | ||
| # SPDX-License-Identifier: MIT | ||
| """Add or remove Touch ID in a stock SDDM PAM stack under the Touch ID lock.""" | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| import stat | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
|
|
||
| PREFIX = "# omarchy-mac Touch ID\n" "auth include omarchy-mac-touchid\n" | ||
| POLICY = """#%PAM-1.0 | ||
| auth requisite pam_shells.so | ||
| auth requisite pam_nologin.so | ||
| auth required pam_faillock.so preauth | ||
| auth sufficient pam_fprintd.so max-tries=3 timeout=10 | ||
| """ | ||
| AUTH = { | ||
| ("auth", "include", "system-login"), | ||
| ("-auth", "optional", "pam_gnome_keyring.so"), | ||
| ("-auth", "optional", "pam_kwallet5.so"), | ||
| ("-auth", "optional", "pam_kwallet6.so"), | ||
| } | ||
| LOGIN_AUTH = [ | ||
| ("auth", "required", "pam_shells.so"), | ||
| ("auth", "requisite", "pam_nologin.so"), | ||
| ("auth", "include", "system-auth"), | ||
| ] | ||
| SYSTEM_AUTH = [ | ||
| ("auth", "required", "pam_faillock.so", "preauth"), | ||
| ("-auth", "[success=2", "default=ignore]", "pam_systemd_home.so"), | ||
| ("auth", "[success=1", "default=bad]", "pam_unix.so", "try_first_pass", "nullok"), | ||
| ("auth", "[default=die]", "pam_faillock.so", "authfail"), | ||
| ("auth", "optional", "pam_permit.so"), | ||
| ("auth", "required", "pam_env.so"), | ||
| ("auth", "required", "pam_faillock.so", "authsucc"), | ||
| ] | ||
|
|
||
|
|
||
| class Refused(Exception): | ||
| """The existing PAM configuration is not one this helper owns.""" | ||
|
|
||
|
|
||
| def read_regular(path: Path) -> str | None: | ||
| try: | ||
| mode = path.lstat().st_mode | ||
| except FileNotFoundError: | ||
| return None | ||
| if not stat.S_ISREG(mode): | ||
| raise Refused(f"{path} is not a regular file") | ||
| with path.open(encoding="utf-8", newline="") as stream: | ||
| return stream.read() | ||
|
|
||
|
|
||
| def write_atomic(path: Path, content: str) -> None: | ||
| fd, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent) | ||
| try: | ||
| with os.fdopen(fd, "w", encoding="utf-8", newline="\n") as stream: | ||
| stream.write(content) | ||
| stream.flush() | ||
| os.fchmod(stream.fileno(), 0o644) | ||
| os.fsync(stream.fileno()) | ||
| os.replace(temporary, path) | ||
| finally: | ||
| Path(temporary).unlink(missing_ok=True) | ||
|
|
||
|
|
||
| def auth_lines(content: str) -> list[tuple[str, ...]]: | ||
| auth: list[tuple[str, ...]] = [] | ||
| for line in content.splitlines(): | ||
| fields = line.split() | ||
| if not fields or fields[0].startswith("#"): | ||
| continue | ||
| kind = fields[0].lower() | ||
| if kind in ("auth", "-auth"): | ||
| auth.append(tuple(fields)) | ||
| elif kind not in ("account", "-account", "password", "-password", "session", "-session"): | ||
| raise Refused("unrecognized PAM module type") | ||
| return auth | ||
|
|
||
|
|
||
| def configure(directory: Path, enable: bool) -> None: | ||
| if not directory.exists(): | ||
| return | ||
| if not stat.S_ISDIR(directory.lstat().st_mode): | ||
| raise Refused(f"{directory} is not a regular directory") | ||
| sddm = directory / "sddm" | ||
| policy = directory / "omarchy-mac-touchid" | ||
| original = read_regular(sddm) | ||
| existing_policy = read_regular(policy) | ||
| if existing_policy not in (None, POLICY): | ||
| raise Refused(f"{policy} was changed; leaving it alone") | ||
| if original is None: | ||
| return | ||
| active = original.startswith(PREFIX) | ||
| original = original.removeprefix(PREFIX) | ||
| if "omarchy-mac-touchid" in original: | ||
| raise Refused(f"{sddm} has a custom Touch ID entry") | ||
| if enable: | ||
| auth = auth_lines(original) | ||
| if auth.count(("auth", "include", "system-login")) != 1 or any( | ||
| entry not in AUTH for entry in auth): | ||
| raise Refused(f"{sddm} is not the stock system-login stack") | ||
| for name, expected in (("system-login", LOGIN_AUTH), ("system-auth", SYSTEM_AUTH)): | ||
| content = read_regular(directory / name) | ||
| if content is None or auth_lines(content) != expected: | ||
| raise Refused(f"{directory / name} has custom authentication requirements") | ||
| if existing_policy is None: | ||
| write_atomic(policy, POLICY) | ||
| if not active: | ||
| write_atomic(sddm, PREFIX + original) | ||
| else: | ||
| if active: | ||
| write_atomic(sddm, original) | ||
| if existing_policy is not None: | ||
| policy.unlink() | ||
|
|
||
|
|
||
| def main() -> int: | ||
| if subprocess.run(["omarchy-hw-apple-silicon"], check=False).returncode != 0: | ||
| return 0 | ||
| if len(sys.argv) != 2 or sys.argv[1] not in ("enable", "disable"): | ||
| print("Usage: touchid-sddm enable|disable", file=sys.stderr) | ||
| return 2 | ||
| directory = Path(os.environ.get("OMARCHY_MAC_TOUCHID_PAM", "/etc/pam.d")) | ||
| try: | ||
| configure(directory, sys.argv[1] == "enable") | ||
| except (OSError, UnicodeError, Refused) as error: | ||
| print(f"touchid-sddm: {error}", file=sys.stderr) | ||
| return 1 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
Uh oh!
There was an error while loading. Please reload this page.