Mercurial > crates > nonstick
annotate src/constants.rs @ 55:676675c3d434
Make PamResultCode implement Error.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 04 May 2025 00:58:04 -0400 |
parents | ce47901aab7a |
children | daa2cde64601 |
rev | line source |
---|---|
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
1 use libc::{c_int, c_uint}; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
2 |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
3 // TODO: Import constants from C header file at compile time. |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
4 |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
5 pub type PamFlag = c_uint; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
6 pub type PamItemType = c_int; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
7 pub type PamMessageStyle = c_int; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
8 |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
9 // The Linux-PAM flags |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
10 // see /usr/include/security/_pam_types.h |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
11 pub const PAM_SILENT: PamFlag = 0x8000; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
12 pub const PAM_DISALLOW_NULL_AUTHTOK: PamFlag = 0x0001; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
13 pub const PAM_ESTABLISH_CRED: PamFlag = 0x0002; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
14 pub const PAM_DELETE_CRED: PamFlag = 0x0004; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
15 pub const PAM_REINITIALIZE_CRED: PamFlag = 0x0008; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
16 pub const PAM_REFRESH_CRED: PamFlag = 0x0010; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
17 pub const PAM_CHANGE_EXPIRED_AUTHTOK: PamFlag = 0x0020; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
18 |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
19 // Message styles |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
20 pub const PAM_PROMPT_ECHO_OFF: PamMessageStyle = 1; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
21 pub const PAM_PROMPT_ECHO_ON: PamMessageStyle = 2; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
22 pub const PAM_ERROR_MSG: PamMessageStyle = 3; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
23 pub const PAM_TEXT_INFO: PamMessageStyle = 4; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
24 /// yes/no/maybe conditionals |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
25 pub const PAM_RADIO_TYPE: PamMessageStyle = 5; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
26 pub const PAM_BINARY_PROMPT: PamMessageStyle = 7; |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
27 |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
28 /// The Linux-PAM return values. |
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
29 /// For more detailed information, see |
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
30 /// /usr/include/security/_pam_types.h |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
31 #[allow(non_camel_case_types, dead_code)] |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
32 #[derive(Debug, PartialEq, thiserror::Error)] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
33 #[repr(C)] |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
34 pub enum PamResultCode { |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
35 #[error("Not an error")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
36 PAM_SUCCESS = 0, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
37 #[error("dlopen() failure when dynamically loading a service module")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
38 PAM_OPEN_ERR = 1, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
39 #[error("symbol not found")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
40 PAM_SYMBOL_ERR = 2, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
41 #[error("error in service module")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
42 PAM_SERVICE_ERR = 3, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
43 #[error("system error")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
44 PAM_SYSTEM_ERR = 4, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
45 #[error("memory buffer error")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
46 PAM_BUF_ERR = 5, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
47 #[error("permission denied")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
48 PAM_PERM_DENIED = 6, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
49 #[error("authentication failure")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
50 PAM_AUTH_ERR = 7, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
51 #[error("cannot access authentication data due to insufficient credentials")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
52 PAM_CRED_INSUFFICIENT = 8, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
53 #[error("underlying authentication service cannot retrieve authentication information")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
54 PAM_AUTHINFO_UNAVAIL = 9, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
55 #[error("user not known to the underlying authentication module")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
56 PAM_USER_UNKNOWN = 10, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
57 #[error("retry limit reached; do not attempt further")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
58 PAM_MAXTRIES = 11, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
59 #[error("new authentication token required")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
60 PAM_NEW_AUTHTOK_REQD = 12, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
61 #[error("user account has expired")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
62 PAM_ACCT_EXPIRED = 13, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
63 #[error("cannot make/remove an entry for the specified session")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
64 PAM_SESSION_ERR = 14, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
65 #[error("underlying authentication service cannot retrieve user credentials")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
66 PAM_CRED_UNAVAIL = 15, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
67 #[error("user credentials expired")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
68 PAM_CRED_EXPIRED = 16, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
69 #[error("failure setting user credentials")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
70 PAM_CRED_ERR = 17, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
71 #[error("no module-specific data is present")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
72 PAM_NO_MODULE_DATA = 18, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
73 #[error("conversation error")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
74 PAM_CONV_ERR = 19, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
75 #[error("authentication token manipulation error")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
76 PAM_AUTHTOK_ERR = 20, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
77 #[error("authentication information cannot be recovered")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
78 PAM_AUTHTOK_RECOVERY_ERR = 21, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
79 #[error("authentication token lock busy")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
80 PAM_AUTHTOK_LOCK_BUSY = 22, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
81 #[error("authentication token aging disabled")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
82 PAM_AUTHTOK_DISABLE_AGING = 23, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
83 #[error("preliminary check by password service")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
84 PAM_TRY_AGAIN = 24, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
85 #[error("ignore underlying account module, regardless of control flag")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
86 PAM_IGNORE = 25, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
87 #[error("critical error; this module should fail now")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
88 PAM_ABORT = 26, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
89 #[error("authentication token has expired")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
90 PAM_AUTHTOK_EXPIRED = 27, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
91 #[error("module is not known")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
92 PAM_MODULE_UNKNOWN = 28, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
93 #[error("bad item passed to pam_[whatever]_item")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
94 PAM_BAD_ITEM = 29, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
95 #[error("conversation function is event-driven and data is not available yet")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
96 PAM_CONV_AGAIN = 30, |
55
676675c3d434
Make PamResultCode implement Error.
Paul Fisher <paul@pfish.zone>
parents:
45
diff
changeset
|
97 #[error("call this function again to complete authentication stack")] |
15
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
98 PAM_INCOMPLETE = 31, |
27730595f1ea
Adding pam-http module
Anthony Nowell <anthony@algorithmia.com>
parents:
diff
changeset
|
99 } |