Mercurial > crates > nonstick
diff src/handle.rs @ 90:f6186e41399b
Miscellaneous fixes and cleanup:
- Rename `get_user` to `username` and `get_authtok` to `authtok`.
- Use pam_strerror for error messages.
- Add library linkage to build.rs (it was missing???).
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 14 Jun 2025 09:30:16 -0400 |
parents | 5aa1a010f1e8 |
children | 039aae9a01f7 |
line wrap: on
line diff
--- a/src/handle.rs Fri Jun 13 05:22:48 2025 -0400 +++ b/src/handle.rs Sat Jun 14 09:30:16 2025 -0400 @@ -74,36 +74,36 @@ /// # use nonstick::PamShared; /// # fn _doc(handle: &mut impl PamShared) -> Result<(), Box<dyn std::error::Error>> { /// // Get the username using the default prompt. - /// let user = handle.get_user(None)?; + /// let user = handle.username(None)?; /// // Get the username using a custom prompt. /// // If this were actually called right after the above, /// // both user and user_2 would have the same value. - /// let user_2 = handle.get_user(Some("who ARE you even???"))?; + /// let user_2 = handle.username(Some("who ARE you even???"))?; /// # Ok(()) /// # } /// ``` /// /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_user.3.html /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_user - fn get_user(&mut self, prompt: Option<&str>) -> Result<&str>; + fn username(&mut self, prompt: Option<&str>) -> Result<&str>; trait_item!( /// The identity of the user for whom service is being requested. /// - /// Unlike [`get_user`](Self::get_user), this will simply get + /// Unlike [`username`](Self::username), this will simply get /// the current state of the user item, and not request the username. - /// While PAM usually sets this automatically in the `get_user` call, + /// While PAM usually sets this automatically in the `username` call, /// it may be changed by a module during the PAM transaction. /// Applications should check it after each step of the PAM process. get = user_item, item = "PAM_USER", - see = Self::get_user + see = Self::username ); trait_item!( /// Sets the identity of the logging-in user. /// /// Usually this will be set during the course of - /// a [`get_user`](Self::get_user) call, but you may set it manually + /// a [`username`](Self::username) call, but you may set it manually /// or change it during the PAM process. set = set_user_item, item = "PAM_USER", @@ -198,7 +198,7 @@ /// Gets the user's authentication token (e.g., password). /// /// This is usually set automatically when - /// [`get_authtok`](PamHandleModule::get_authtok) is called, + /// [`authtok`](PamHandleModule::authtok) is called, /// but can be manually set. set = set_authtok_item, item = "PAM_AUTHTOK", @@ -248,28 +248,28 @@ /// # use nonstick::handle::PamHandleModule; /// # fn _doc(handle: &mut impl PamHandleModule) -> Result<(), Box<dyn std::error::Error>> { /// // Get the user's password using the default prompt. - /// let pass = handle.get_authtok(None)?; + /// let pass = handle.authtok(None)?; /// // Get the user's password using a custom prompt. - /// let pass = handle.get_authtok(Some("Reveal your secrets!"))?; + /// let pass = handle.authtok(Some("Reveal your secrets!"))?; /// Ok(()) /// # } /// ``` /// /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_authtok.3.html /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_item - fn get_authtok(&mut self, prompt: Option<&str>) -> Result<&str>; + fn authtok(&mut self, prompt: Option<&str>) -> Result<&str>; trait_item!( /// Gets the user's authentication token (e.g., password). /// /// This is normally set automatically by PAM when calling - /// [`get_authtok`](Self::get_authtok), but can be set explicitly. + /// [`authtok`](Self::authtok), but can be set explicitly. /// - /// Like `get_authtok`, this should only ever be called + /// Like `authtok`, this should only ever be called /// by *authentication* and *password-change* PAM modules. get = authtok_item, item = "PAM_AUTHTOK", - see = Self::get_authtok + see = Self::authtok ); trait_item!(