|
1 | | -use std::{ffi::NulError, fmt, str::Utf8Error}; |
| 1 | +use std::ffi::{c_int, NulError}; |
| 2 | +use std::fmt; |
| 3 | +use std::str::Utf8Error; |
2 | 4 |
|
3 | 5 | use crate::cutils::string_from_ptr; |
4 | 6 |
|
@@ -65,7 +67,7 @@ pub enum PamErrorType { |
65 | 67 | } |
66 | 68 |
|
67 | 69 | impl PamErrorType { |
68 | | - pub(super) fn from_int(errno: libc::c_int) -> PamErrorType { |
| 70 | + pub(super) fn from_int(errno: c_int) -> PamErrorType { |
69 | 71 | use PamErrorType::*; |
70 | 72 |
|
71 | 73 | match errno as _ { |
@@ -109,46 +111,46 @@ impl PamErrorType { |
109 | 111 | } |
110 | 112 | } |
111 | 113 |
|
112 | | - pub fn as_int(&self) -> libc::c_int { |
| 114 | + pub fn as_int(&self) -> c_int { |
113 | 115 | use PamErrorType::*; |
114 | 116 |
|
115 | 117 | match self { |
116 | | - Success => PAM_SUCCESS as libc::c_int, |
117 | | - OpenError => PAM_OPEN_ERR as libc::c_int, |
118 | | - SymbolError => PAM_SYMBOL_ERR as libc::c_int, |
119 | | - ServiceError => PAM_SERVICE_ERR as libc::c_int, |
120 | | - SystemError => PAM_SYSTEM_ERR as libc::c_int, |
121 | | - BufferError => PAM_BUF_ERR as libc::c_int, |
122 | | - ConversationError => PAM_CONV_ERR as libc::c_int, |
123 | | - PermissionDenied => PAM_PERM_DENIED as libc::c_int, |
124 | | - MaxTries => PAM_MAXTRIES as libc::c_int, |
125 | | - AuthError => PAM_AUTH_ERR as libc::c_int, |
126 | | - NewAuthTokenRequired => PAM_NEW_AUTHTOK_REQD as libc::c_int, |
127 | | - CredentialsInsufficient => PAM_CRED_INSUFFICIENT as libc::c_int, |
128 | | - AuthInfoUnavailable => PAM_AUTHINFO_UNAVAIL as libc::c_int, |
129 | | - UserUnknown => PAM_USER_UNKNOWN as libc::c_int, |
130 | | - CredentialsUnavailable => PAM_CRED_UNAVAIL as libc::c_int, |
131 | | - CredentialsExpired => PAM_CRED_EXPIRED as libc::c_int, |
132 | | - CredentialsError => PAM_CRED_ERR as libc::c_int, |
133 | | - AccountExpired => PAM_ACCT_EXPIRED as libc::c_int, |
134 | | - AuthTokenExpired => PAM_AUTHTOK_EXPIRED as libc::c_int, |
135 | | - SessionError => PAM_SESSION_ERR as libc::c_int, |
136 | | - AuthTokenError => PAM_AUTHTOK_ERR as libc::c_int, |
137 | | - AuthTokenRecoveryError => PAM_AUTHTOK_RECOVERY_ERR as libc::c_int, |
138 | | - AuthTokenLockBusy => PAM_AUTHTOK_LOCK_BUSY as libc::c_int, |
139 | | - AuthTokenDisableAging => PAM_AUTHTOK_DISABLE_AGING as libc::c_int, |
140 | | - NoModuleData => PAM_NO_MODULE_DATA as libc::c_int, |
141 | | - Ignore => PAM_IGNORE as libc::c_int, |
142 | | - Abort => PAM_ABORT as libc::c_int, |
143 | | - TryAgain => PAM_TRY_AGAIN as libc::c_int, |
144 | | - ModuleUnknown => PAM_MODULE_UNKNOWN as libc::c_int, |
145 | | - BadItem => PAM_BAD_ITEM as libc::c_int, |
146 | | - // DomainUnknown => PAM_DOMAIN_UNKNOWN as libc::c_int, |
147 | | - // BadHandle => PAM_BAD_HANDLE as libc::c_int, |
148 | | - // BadFeature => PAM_BAD_FEATURE as libc::c_int, |
149 | | - // BadConstant => PAM_BAD_CONSTANT as libc::c_int, |
150 | | - // ConverseAgain => PAM_CONV_AGAIN as libc::c_int, |
151 | | - // Incomplete => PAM_INCOMPLETE as libc::c_int, |
| 118 | + Success => PAM_SUCCESS as c_int, |
| 119 | + OpenError => PAM_OPEN_ERR as c_int, |
| 120 | + SymbolError => PAM_SYMBOL_ERR as c_int, |
| 121 | + ServiceError => PAM_SERVICE_ERR as c_int, |
| 122 | + SystemError => PAM_SYSTEM_ERR as c_int, |
| 123 | + BufferError => PAM_BUF_ERR as c_int, |
| 124 | + ConversationError => PAM_CONV_ERR as c_int, |
| 125 | + PermissionDenied => PAM_PERM_DENIED as c_int, |
| 126 | + MaxTries => PAM_MAXTRIES as c_int, |
| 127 | + AuthError => PAM_AUTH_ERR as c_int, |
| 128 | + NewAuthTokenRequired => PAM_NEW_AUTHTOK_REQD as c_int, |
| 129 | + CredentialsInsufficient => PAM_CRED_INSUFFICIENT as c_int, |
| 130 | + AuthInfoUnavailable => PAM_AUTHINFO_UNAVAIL as c_int, |
| 131 | + UserUnknown => PAM_USER_UNKNOWN as c_int, |
| 132 | + CredentialsUnavailable => PAM_CRED_UNAVAIL as c_int, |
| 133 | + CredentialsExpired => PAM_CRED_EXPIRED as c_int, |
| 134 | + CredentialsError => PAM_CRED_ERR as c_int, |
| 135 | + AccountExpired => PAM_ACCT_EXPIRED as c_int, |
| 136 | + AuthTokenExpired => PAM_AUTHTOK_EXPIRED as c_int, |
| 137 | + SessionError => PAM_SESSION_ERR as c_int, |
| 138 | + AuthTokenError => PAM_AUTHTOK_ERR as c_int, |
| 139 | + AuthTokenRecoveryError => PAM_AUTHTOK_RECOVERY_ERR as c_int, |
| 140 | + AuthTokenLockBusy => PAM_AUTHTOK_LOCK_BUSY as c_int, |
| 141 | + AuthTokenDisableAging => PAM_AUTHTOK_DISABLE_AGING as c_int, |
| 142 | + NoModuleData => PAM_NO_MODULE_DATA as c_int, |
| 143 | + Ignore => PAM_IGNORE as c_int, |
| 144 | + Abort => PAM_ABORT as c_int, |
| 145 | + TryAgain => PAM_TRY_AGAIN as c_int, |
| 146 | + ModuleUnknown => PAM_MODULE_UNKNOWN as c_int, |
| 147 | + BadItem => PAM_BAD_ITEM as c_int, |
| 148 | + // DomainUnknown => PAM_DOMAIN_UNKNOWN as c_int, |
| 149 | + // BadHandle => PAM_BAD_HANDLE as c_int, |
| 150 | + // BadFeature => PAM_BAD_FEATURE as c_int, |
| 151 | + // BadConstant => PAM_BAD_CONSTANT as c_int, |
| 152 | + // ConverseAgain => PAM_CONV_AGAIN as c_int, |
| 153 | + // Incomplete => PAM_INCOMPLETE as c_int, |
152 | 154 | UnknownErrorType(e) => *e, |
153 | 155 | } |
154 | 156 | } |
@@ -236,15 +238,15 @@ impl fmt::Display for PamError { |
236 | 238 |
|
237 | 239 | impl PamError { |
238 | 240 | /// Create a new PamError based on the error number from pam. |
239 | | - pub(super) fn from_pam(errno: libc::c_int) -> PamError { |
| 241 | + pub(super) fn from_pam(errno: c_int) -> PamError { |
240 | 242 | let tp = PamErrorType::from_int(errno); |
241 | 243 | PamError::Pam(tp) |
242 | 244 | } |
243 | 245 | } |
244 | 246 |
|
245 | 247 | /// Returns `Ok(())` if the error code is `PAM_SUCCESS` or a `PamError` in other cases |
246 | | -pub(super) fn pam_err(err: libc::c_int) -> Result<(), PamError> { |
247 | | - if err == PAM_SUCCESS as libc::c_int { |
| 248 | +pub(super) fn pam_err(err: c_int) -> Result<(), PamError> { |
| 249 | + if err == PAM_SUCCESS as c_int { |
248 | 250 | Ok(()) |
249 | 251 | } else { |
250 | 252 | Err(PamError::from_pam(err)) |
|
0 commit comments