pam_f/
enums.rs

1#![allow(non_upper_case_globals)]
2
3//! Types defined by Linux-PAM
4//!
5//! This modules contains struct and enum definitions used by `pam-sys`.
6
7use pam_macros_f::pam_enum;
8
9/// The Linux-PAM return values
10#[pam_enum]
11pub enum PamReturnCode {
12    /// System error
13    System_Err,
14
15    /// Successful function return
16    Success,
17
18    /// dlopen() failure when dynamically loading a service module
19    Open_Err,
20
21    /// Symbol not found
22    Symbol_Err,
23
24    /// Error in service module
25    Service_Err,
26
27    /// Memory buffer error
28    Buf_Err,
29
30    /// Permission denied
31    Perm_Denied,
32
33    /// Authentication failure
34    Auth_Err,
35
36    /// Can not access authentication data due to insufficient credentials
37    Cred_Insufficient,
38
39    /// Underlying authentication service can not retrieve authentication information
40    Authinfo_Unavail,
41
42    /// User not known to the underlying authentication module
43    User_Unknown,
44
45    /// An authentication service has maintained a retry count which has been reached.
46    /// No further retries should be attempted
47    MaxTries,
48
49    /// New authentication token required.
50    /// This is normally returned if the machine security policies require
51    /// that the password should be changed beccause the password is NULL or it has aged
52    New_Authtok_Reqd,
53
54    /// User account has expired
55    Acct_Expired,
56
57    /// Can not make/remove an entry for the specified session
58    Session_Err,
59
60    /// Underlying authentication service can not retrieve user credentials unavailable
61    Cred_Unavail,
62
63    /// User credentials expired
64    Cred_Expired,
65
66    /// Failure setting user credentials
67    Cred_Err,
68
69    /// No module specific data is present
70    No_Module_Data,
71
72    /// Conversation error
73    Conv_Err,
74
75    /// Authentication token manipulation error
76    AuthTok_Err,
77
78    /// Authentication information cannot be recovered
79    AuthTok_Recovery_Err,
80
81    /// Authentication token lock busy
82    AuthTok_Lock_Busy,
83
84    /// Authentication token aging disabled
85    AuthTok_Disable_Aging,
86
87    /// Preliminary check by password service
88    Try_Again,
89
90    /// Ignore underlying account module regardless of whether
91    /// the control flag is required, optional, or sufficient
92    Ignore,
93
94    /// Critical error (?module fail now request)
95    AuthTok_Expired,
96
97    /// user's authentication token has expired
98    Abort,
99
100    /// module is not known
101    Module_Unknown,
102
103    /// Bad item passed to pam_*_item()
104    Bad_Item,
105
106    /// conversation function is event driven and data is not available yet
107    Conv_Again,
108
109    /// please call this function again to complete authentication stack.
110    /// Before calling again as isize, verify that conversation is completed
111    Incomplete,
112}
113
114impl std::fmt::Display for PamReturnCode {
115    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
116        f.write_str(&format!("{:?} ({})", self, *self as i32))
117    }
118}
119
120/// The Linux-PAM flags
121#[pam_enum]
122pub enum PamFlag {
123    /// Default value, if no specific flags should be passed
124    None = 0,
125
126    /// Authentication service should not generate any messages
127    Silent,
128
129    /// The authentication service should return AUTH_ERROR
130    /// if the user has a null authentication token
131    /// (used by pam_authenticate{,_secondary}())
132    Disallow_Null_AuthTok,
133
134    /// Set user credentials for an authentication service
135    /// (used for pam_setcred())
136    Establish_Cred,
137
138    /// Delete user credentials associated with an authentication service
139    /// (used for pam_setcred())
140    Delete_Cred,
141
142    /// Reinitialize user credentials
143    /// (used for pam_setcred())
144    Reinitialize_Cred,
145
146    /// Extend lifetime of user credentials
147    /// (used for pam_setcred())
148    Refresh_Cred,
149
150    /// The password service should only update those passwords that have aged.
151    /// If this flag is not passed, the password service should update all passwords.
152    /// (used by pam_chauthtok)
153    Change_Expired_AuthTok,
154
155    /// The password service should update passwords Note: PAM_PRELIM_CHECK
156    /// and PAM_UPDATE_AUTHTOK cannot both be set simultaneously!
157    Update_AuthTok,
158
159    /// The following two flags are for use across the Linux-PAM/module
160    /// interface only. The Application is not permitted to use these
161    /// tokens.
162    ///
163    /// The password service should only perform preliminary checks.  No
164    /// passwords should be updated.
165    Prelim_Check,
166}
167
168impl std::fmt::Display for PamFlag {
169    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
170        f.write_str(&format!("{:?} ({})", self, *self as i32))
171    }
172}
173
174/// The Linux-PAM item types
175///
176/// These defines are used by `pam_set_item()` `and pam_get_item()`.
177/// Please check the spec which are allowed for use by applications
178/// and which are only allowed for use by modules.
179#[pam_enum]
180pub enum PamItemType {
181    /// The service name
182    Service,
183
184    /// The user name
185    User,
186
187    /// The tty name
188    TTY,
189
190    /// The remote host name
191    RHost,
192
193    /// The pam_conv structure
194    Conv,
195
196    /// The authentication token (password)
197    AuthTok,
198
199    /// The old authentication token
200    OldAuthTok,
201
202    /// The remote user name
203    RUser,
204
205    /// the prompt for getting a username Linux-PAM extensions
206    User_Prompt,
207
208    /// app supplied function to override failure delays
209    Fail_Delay,
210
211    /// X display name
212    XDisplay,
213
214    /// X server authentication data
215    XAuthData,
216
217    /// The type for pam_get_authtok
218    AuthTok_Type,
219}
220
221impl std::fmt::Display for PamItemType {
222    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
223        f.write_str(&format!("{:?} ({})", self, *self as i32))
224    }
225}
226
227/// The Linux-PAM message styles
228#[pam_enum]
229pub enum PamMessageStyle {
230    Prompt_Echo_On,
231    Prompt_Echo_Off,
232    Error_Msg,
233    Text_Info,
234}
235
236impl std::fmt::Display for PamMessageStyle {
237    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
238        f.write_str(&format!("{:?} ({})", self, *self as i32))
239    }
240}