diff src/libpam/pam_ffi.rs @ 87:05291b601f0a

Well and truly separate the Linux extensions. This separates the Linux extensions on the libpam side, and disables the two enums on the interface side. Users can still call the Linux extensions from non-Linux PAM impls, but they'll get a conversation error back.
author Paul Fisher <paul@pfish.zone>
date Tue, 10 Jun 2025 04:40:01 -0400
parents a8f4718fed5d
children
line wrap: on
line diff
--- a/src/libpam/pam_ffi.rs	Tue Jun 10 02:43:31 2025 -0400
+++ b/src/libpam/pam_ffi.rs	Tue Jun 10 04:40:01 2025 -0400
@@ -3,8 +3,7 @@
 #![allow(non_camel_case_types)]
 
 use crate::libpam::memory::Immovable;
-use num_enum::{IntoPrimitive, TryFromPrimitive};
-use std::ffi::{c_int, c_void};
+use std::ffi::{c_int, c_uint, c_void};
 use std::marker::PhantomData;
 
 /// An opaque structure that a PAM handle points to.
@@ -38,27 +37,6 @@
     _marker: Immovable,
 }
 
-/// The C enum values for messages shown to the user.
-#[derive(Debug, PartialEq, TryFromPrimitive, IntoPrimitive)]
-#[repr(i32)]
-pub enum Style {
-    /// Requests information from the user; will be masked when typing.
-    PromptEchoOff = 1,
-    /// Requests information from the user; will not be masked.
-    PromptEchoOn = 2,
-    /// An error message.
-    ErrorMsg = 3,
-    /// An informational message.
-    TextInfo = 4,
-    /// Yes/No/Maybe conditionals. A Linux-PAM extension.
-    RadioType = 5,
-    /// For server–client non-human interaction.
-    ///
-    /// NOT part of the X/Open PAM specification.
-    /// A Linux-PAM extension.
-    BinaryPrompt = 7,
-}
-
 /// A question sent by PAM or a module to an application.
 ///
 /// PAM refers to this as a "message", but we call it a question
@@ -69,7 +47,7 @@
 #[repr(C)]
 pub struct Question {
     /// The style of message to request.
-    pub style: c_int,
+    pub style: c_uint,
     /// A description of the data requested.
     ///
     /// For most requests, this will be an owned [`CStr`](std::ffi::CStr), but for requests