Mercurial > crates > nonstick
diff src/handle.rs @ 116:a12706e42c9d
Logging, macros, and building:
- Changes logging API to accept the `Location` of the log statement.
Fixes OpenPAM implementation.
- Stops publicly exporting doc macros.
- Uses dlopen to detect the PAM library rather than header jankery.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 29 Jun 2025 18:27:51 -0400 |
parents | dfcd96a74ac4 |
children |
line wrap: on
line diff
--- a/src/handle.rs Sun Jun 29 03:35:59 2025 -0400 +++ b/src/handle.rs Sun Jun 29 18:27:51 2025 -0400 @@ -3,8 +3,8 @@ use crate::constants::{Flags, Result}; use crate::conv::Conversation; use crate::environ::{EnvironMap, EnvironMapMut}; -use crate::logging::Level; -use crate::{_guide, _linklist, _man7, _manbsd, _stdlinks}; +use crate::logging::{Level, Location}; +use crate::{guide, linklist, man7, manbsd, stdlinks}; macro_rules! trait_item { ($(#[$md:meta])* get = $getter:ident, item = $item:literal $(, see = $see:path)?) => { @@ -21,11 +21,11 @@ /// /// # References /// - #[doc = _linklist!(pam_get_item: mwg, adg, _std)] + #[doc = linklist!(pam_get_item: mwg, adg, _std)] /// - #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_get_item")] - #[doc = _guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_item")] - #[doc = _stdlinks!(3 pam_get_item)] + #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_get_item")] + #[doc = guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_item")] + #[doc = stdlinks!(3 pam_get_item)] fn $getter(&self) -> Result<Option<String>>; }; ($(#[$md:meta])* set = $setter:ident, item = $item:literal $(, see = $see:path)?) => { @@ -42,11 +42,11 @@ /// /// # References /// - #[doc = _linklist!(pam_set_item: mwg, adg, _std)] + #[doc = linklist!(pam_set_item: mwg, adg, _std)] /// - #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_set_item")] - #[doc = _guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_set_item")] - #[doc = _stdlinks!(3 pam_set_item)] + #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_set_item")] + #[doc = guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_set_item")] + #[doc = stdlinks!(3 pam_set_item)] fn $setter(&mut self, value: Option<&str>) -> Result<()>; }; } @@ -75,8 +75,9 @@ /// # Example /// /// ```no_run - /// # use nonstick::{PamShared}; - /// # use nonstick::logging::Level; + /// # use nonstick::PamShared; + /// use nonstick::logging::Level; + /// use nonstick::location; /// # fn _test(pam_hdl: impl PamShared) { /// # let delay_ms = 100; /// # let url = "https://zombo.com"; @@ -86,12 +87,12 @@ /// nonstick::info!(pam_hdl, "using network backend"); /// nonstick::debug!(pam_hdl, "sending GET request to {url}"); /// // But if you really want to, you can call this yourself: - /// pam_hdl.log(Level::Warning, "this is unnecessarily verbose"); + /// pam_hdl.log(Level::Warning, location!(), "this is unnecessarily verbose"); /// # } /// ``` - #[doc = _man7!(3 pam_syslog)] - #[doc = _manbsd!(3 openpam_log)] - fn log(&self, level: Level, entry: &str); + #[doc = man7!(3 pam_syslog)] + #[doc = manbsd!(3 openpam_log)] + fn log(&self, level: Level, loc: Location<'_>, entry: &str); /// Retrieves the name of the user who is authenticating or logging in. /// @@ -103,7 +104,7 @@ /// 3. The default prompt, `login: `. /// /// # References - #[doc = _linklist!(pam_get_user: mwg, _std)] + #[doc = linklist!(pam_get_user: mwg, _std)] /// /// # Example /// @@ -119,8 +120,8 @@ /// # Ok(()) /// # } /// ``` - #[doc = _stdlinks!(3 pam_get_user)] - #[doc = _guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_user")] + #[doc = stdlinks!(3 pam_get_user)] + #[doc = guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_user")] fn username(&mut self, prompt: Option<&str>) -> Result<String>; /// The contents of the environment to set, read-only. @@ -276,10 +277,10 @@ /// any PAM application call. /// /// # References - #[doc = _linklist!(pam_authenticate: adg, _std)] + #[doc = linklist!(pam_authenticate: adg, _std)] /// - #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_authenticate")] - #[doc = _stdlinks!(3 pam_authenticate)] + #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_authenticate")] + #[doc = stdlinks!(3 pam_authenticate)] fn authenticate(&mut self, flags: Flags) -> Result<()>; /// Verifies the validity of the user's account (and other stuff). @@ -289,19 +290,19 @@ /// for token expiration or that the user's account is not locked. /// /// # References - #[doc = _linklist!(pam_acct_mgmt: adg, _std)] + #[doc = linklist!(pam_acct_mgmt: adg, _std)] /// - #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_acct_mgmt")] - #[doc = _stdlinks!(3 pam_acct_mgmt)] + #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_acct_mgmt")] + #[doc = stdlinks!(3 pam_acct_mgmt)] fn account_management(&mut self, flags: Flags) -> Result<()>; /// Changes the authentication token. /// /// # References - #[doc = _linklist!(pam_chauthtok: adg, _std)] + #[doc = linklist!(pam_chauthtok: adg, _std)] /// - #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_chauthtok")] - #[doc = _stdlinks!(3 pam_chauthtok)] + #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_chauthtok")] + #[doc = stdlinks!(3 pam_chauthtok)] fn change_authtok(&mut self, flags: Flags) -> Result<()>; } @@ -321,7 +322,7 @@ /// /// # References /// - #[doc = _linklist!(pam_get_authtok: man7, manbsd)] + #[doc = linklist!(pam_get_authtok: man7, manbsd)] /// /// # Example /// @@ -335,8 +336,8 @@ /// Ok(()) /// # } /// ``` - #[doc = _man7!(3 pam_get_authtok)] - #[doc = _manbsd!(3 pam_get_authtok)] + #[doc = man7!(3 pam_get_authtok)] + #[doc = manbsd!(3 pam_get_authtok)] fn authtok(&mut self, prompt: Option<&str>) -> Result<String>; trait_item!(