comparison src/handle.rs @ 95:51c9d7e8261a

Return owned strings rather than borrowed strings. It's going to be irritating to have to work with strings borrowed from the PAM handle rather than just using your own. They're cheap enough to copy.
author Paul Fisher <paul@pfish.zone>
date Mon, 23 Jun 2025 14:03:44 -0400
parents db167f96ba46
children efe2f5f8b5b2
comparison
equal deleted inserted replaced
94:db167f96ba46 95:51c9d7e8261a
22 /// [`pam_get_item` in the Application Developers' Guide][adg]. 22 /// [`pam_get_item` in the Application Developers' Guide][adg].
23 /// 23 ///
24 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_item.3.html 24 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_item.3.html
25 /// [adg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/adg-interface-by-app-expected.html#adg-pam_get_item 25 /// [adg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/adg-interface-by-app-expected.html#adg-pam_get_item
26 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_item 26 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_item
27 fn $getter(&self) -> Result<Option<&str>>; 27 fn $getter(&self) -> Result<Option<String>>;
28 }; 28 };
29 ($(#[$md:meta])* set = $setter:ident, item = $item:literal $(, see = $see:path)?) => { 29 ($(#[$md:meta])* set = $setter:ident, item = $item:literal $(, see = $see:path)?) => {
30 $(#[$md])* 30 $(#[$md])*
31 #[doc = concat!("Sets the `", $item, "` from the PAM handle.")] 31 #[doc = concat!("Sets the `", $item, "` from the PAM handle.")]
32 $( 32 $(
109 /// # } 109 /// # }
110 /// ``` 110 /// ```
111 /// 111 ///
112 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_user.3.html 112 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_user.3.html
113 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_user 113 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_user
114 fn username(&mut self, prompt: Option<&str>) -> Result<&str>; 114 fn username(&mut self, prompt: Option<&str>) -> Result<String>;
115 115
116 trait_item!( 116 trait_item!(
117 /// The identity of the user for whom service is being requested. 117 /// The identity of the user for whom service is being requested.
118 /// 118 ///
119 /// Unlike [`username`](Self::username), this will simply get 119 /// Unlike [`username`](Self::username), this will simply get
280 /// # } 280 /// # }
281 /// ``` 281 /// ```
282 /// 282 ///
283 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_authtok.3.html 283 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_get_authtok.3.html
284 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_item 284 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/mwg-expected-by-module-item.html#mwg-pam_get_item
285 fn authtok(&mut self, prompt: Option<&str>) -> Result<&str>; 285 fn authtok(&mut self, prompt: Option<&str>) -> Result<String>;
286 286
287 trait_item!( 287 trait_item!(
288 /// Gets the user's authentication token (e.g., password). 288 /// Gets the user's authentication token (e.g., password).
289 /// 289 ///
290 /// This is normally set automatically by PAM when calling 290 /// This is normally set automatically by PAM when calling