{
m_maxAttempt = PASSWORD_INFINITE_ATTEMPT_COUNT;
- LOGD("hal_backend_security_auth constructor user_id : "<< user_id << ", password_type : " << password_type);
- LOGD(" default value max_attempt : "<< m_maxAttempt << ", max_history_size : " << m_maxHistorySize);
- LOGD(" expire_time : "<< m_expireTime << ", expire_time_left : " << m_expireTimeLeft << ", password_is_active : " << m_passwordActive);
- LOGD(" password_is_rcv_active : "<< m_passwordRcvActive << ", attempt : " << m_attempt);
+ LOGD("hal_backend_security_auth constructor");
+ LOGD("user_id : "<< user_id << ", password_type : " << password_type);
+ LOGD("default value max_attempt : "<< m_maxAttempt << ", max_history_size : " << m_maxHistorySize);
+ LOGD("expire_time : "<< m_expireTime << ", expire_time_left : " << m_expireTimeLeft << ", password_is_active : " << m_passwordActive);
+ LOGD("password_is_rcv_active : "<< m_passwordRcvActive << ", attempt : " << m_attempt);
std::string userDir = create_dir(RW_DATA_DIR, m_user);
m_expireTimeLeft = PASSWORD_INFINITE_EXPIRATION_TIME;
m_passwordRcvActive = false;
m_passwordActive = false;
+ LOGD("reset_state m_maxAtttempt : " << m_maxAttempt << " m_maxHistorySize : " << m_maxHistorySize
+ << " m_expireTime : " << m_expireTime << " m_expireTimeLeft : " << m_expireTimeLeft
+ << " m_passwordRcvActive : " << m_passwordRcvActive << " m_passwordActive : " << m_passwordActive);
m_passwordCurrent.reset(new NoPassword());
}
bool hal_backend_security_auth::load_memory_from_file(const std::string& passwdFilePath)
{
struct stat fileStat;
-
+ LOGD("passwdFilePath : " << passwdFilePath);
if (stat(passwdFilePath.c_str(), &fileStat) != 0)
return false;
LOGE("Invaild password version: " << fileVersion);
}
- LOGD("loadMemoryFromFile: File=" << passwdFilePath <<
- ":: User: " << m_user << ", loaded max_att: " << m_maxAttempt <<
- ", history_size: " << m_maxHistorySize << ", m_expireTime: " <<
- m_expireTime << ", m_expireTimeLeft: " << m_expireTimeLeft <<
- ", isActive: " << m_passwordActive << ", isRcvActive: " <<
- m_passwordRcvActive<< ", m_passwordType: " << m_passwordType);
+ LOGD("m_user : " << m_user << " m_maxAttempt : " << m_maxAttempt
+ << " m_maxHistorySize : " << m_maxHistorySize << " m_expireTime : " << m_expireTime
+ << " m_expireTimeLeft: " << m_expireTimeLeft << " m_passwordActive : " << m_passwordActive
+ << " isRcvActive: " << m_passwordRcvActive<< " m_passwordType : " << m_passwordType);
return true;
}
return;
}
- LOGE("PWD_DBG not found " << m_user << " password file. Creating.");
+ LOGE("m_user : " << m_user << " pwdFile : " << pwdFile << " pwdFile is Creating.");
//create file
write_memory_to_file(m_user);
} else { //if file exists, load data
- LOGE("PWD_DBG found " << m_user << " password file. Opening.");
-
+ LOGE("pwdFile : " << pwdFile << " pwdFile found");
+ LOGE("m_user : " << m_user << " password file. Opening.");
try {
load_memory_from_file(oldVersionPwdFile);
} catch (...) {
// check if attempt file exists
if (!file_exists(attemptFile)) {
- LOGE("PWD_DBG not found " << m_user << " attempt file. Creating.");
+ LOGE("attemptFile : " << attemptFile << " not found");
+ LOGE("m_user : " << m_user << " attempt file. Creating.");
write_attempt_to_file(m_user);
} else {
- LOGE("PWD_DBG found " << m_user << " attempt file. Opening.");
+ LOGE("attemptFile : " << attemptFile << " found");
+ LOGE("m_user : " << m_user << " attempt file. Opening.");
std::ifstream AttemptFile(attemptFile);
-
if (!AttemptFile) {
LOGE("Failed to open " << m_user << " attempt file.");
// ignore error
AttemptFile.read(reinterpret_cast<char *>(&m_attempt), sizeof(unsigned int));
if (!AttemptFile) {
- LOGE("Failed to read " << m_user << " attempt count.");
+ LOGE("Failed to read AttemptFile m_user : " << m_user);
// ignore error
reset_attempt(m_user);
}
int hal_backend_security_auth::write_memory_to_file(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::write_memory_to_file");
+ LOGD("hal_backend_security_auth::write_memory_to_file user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
std::string pwdFile = create_dir(RW_DATA_DIR, m_user) + PASSWORD_FILE;
PasswordFileBuffer pwdBuffer;
- LOGD(" user: " << m_user << ", max_attempt: " << m_maxAttempt <<
- ", history_size: " << m_maxHistorySize << ", m_expireTime: " <<
- m_expireTime << ", m_expireTimeLeft: " << m_expireTimeLeft <<
- ", isActive: " << m_passwordActive << ", isRcvActive: " <<
- m_passwordRcvActive << ", m_passwordType: " << m_passwordType);
+ LOGD("m_user : " << m_user << " m_maxAttempt : " << m_maxAttempt << " m_maxHistorySize : "
+ << m_maxHistorySize << " m_expireTime : " << m_expireTime << " m_expireTimeLeft : "
+ << m_expireTimeLeft << " m_passwordActive : " << m_passwordActive << " m_passwordRcvActive : "
+ << m_passwordRcvActive << " m_passwordType : " << m_passwordType);
//serialize password attributes
Serialization::Serialize(pwdBuffer, CURRENT_FILE_VERSION);
Serialization::Serialize(pwdBuffer, m_maxAttempt);
pwdBuffer.Save(pwdFile);
if (chmod(pwdFile.c_str(), FILE_MODE)) {
- LOGE(" Failed to chmod for " << pwdFile << " Error: " << errnoToString());
+ LOGE("Failed to chmod for " << pwdFile << " Error: " << errnoToString());
}
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::write_attempt_to_file(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::write_attempt_to_file");
+ LOGD("hal_backend_security_auth::write_attempt_to_file user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
std::string attemptFile = create_dir(RW_DATA_DIR, m_user) + ATTEMPT_FILE;
std::ofstream AttemptFile(attemptFile, std::ofstream::trunc);
if (!AttemptFile.good()) {
- LOGE(" Failed to open " << m_user << " attempt file.");
+ LOGE("Failed to open " << m_user << " attempt file.");
}
AttemptFile.write(reinterpret_cast<const char *>(&m_attempt), sizeof(unsigned int));
if (!AttemptFile) {
- LOGE(" Failed to write " << m_user << " attempt count.");
+ LOGE("Failed to write " << m_user << " attempt count.");
}
AttemptFile.flush();
if (::fsync(FstreamAccessors<std::ofstream>::GetFd(AttemptFile)) != 0)
- LOGE(" Failed to synchronize a file's state.");
+ LOGE("Failed to synchronize a file's state.");
AttemptFile.close();
return HAL_SECURITY_AUTH_ERROR_NONE;
int hal_backend_security_auth::set_password(uid_t user_id, const char* password)
{
- LOGD("hal_backend_security_auth::set_password");
+ LOGD("hal_backend_security_auth::set_password user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user || password == nullptr)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
if (password[0] == '\0') {
m_passwordActive = true;
}
- LOGD("hal_backend_security_auth::set_password: m_passwordActive=" << m_passwordActive);
+ LOGD("m_passwordActive : " << m_passwordActive);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::set_max_history_size(uid_t user_id, unsigned int history_size)
{
- LOGD("hal_backend_security_auth::set_max_history_size");
+ LOGD("hal_backend_security_auth::set_max_history_size user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
// put current password in history
//setting history should be independent from password being set
m_maxHistorySize = history_size;
+ LOGE("m_maxHistorySize : " << m_maxHistorySize);
while (m_passwordHistory.size() > history_size)
m_passwordHistory.pop_back();
int hal_backend_security_auth::get_max_history_size(uid_t user_id, unsigned int *history_size) const
{
- LOGD("hal_backend_security_auth::get_max_history_size");
+ LOGD("hal_backend_security_auth::get_max_history_size user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
*history_size = m_maxHistorySize;
+ LOGE("m_maxHistorySize : " << m_maxHistorySize);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::get_expire_time(uid_t user_id, unsigned int *expire_time) const
{
- LOGD("hal_backend_security_auth::get_expire_time");
+ LOGD("hal_backend_security_auth::get_expire_time user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
*expire_time = m_expireTime;
- LOGE(" *expire_time : "<<m_expireTime);
+ LOGE("m_expireTime : " << m_expireTime);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::set_expire_time(uid_t user_id, unsigned int expire_time)
{
- LOGD("hal_backend_security_auth::set_expire_time m_expireTime: " << m_expireTime);
+ LOGD("hal_backend_security_auth::set_expire_time user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_expireTime = expire_time;
- LOGD(" expire_time : "<< m_expireTime);
+ LOGD("m_expireTime : " << m_expireTime);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::get_attempt(uid_t user_id, unsigned int *attempt) const
{
- LOGD("hal_backend_security_auth::get_attempt");
+ LOGD("hal_backend_security_auth::get_attempt user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
*attempt = m_attempt;
-
+ LOGD("m_attempt : " << m_attempt);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::set_expire_time_left(uid_t user_id, unsigned int expire_time_left)
{
- LOGD("hal_backend_security_auth::set_expire_time_left");
+ LOGD("hal_backend_security_auth::set_expire_time_left user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_expireTimeLeft = expire_time_left;
- LOGD(" expire_time_left : "<<m_expireTimeLeft);
+ LOGD("expire_time_left : " << expire_time_left);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::get_expire_time_left(uid_t user_id, unsigned int *expire_time_left) const
{
- LOGD("hal_backend_security_auth::get_expire_time_left");
+ LOGD("hal_backend_security_auth::get_expire_time_left user_id : " << user_id << " m_user : " << m_user);
//calculate left secs by the time of password expiration
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
if (m_expireTimeLeft != PASSWORD_INFINITE_EXPIRATION_TIME) {
- LOGD(" not eq m_expireTimeLeft : " << m_expireTimeLeft << " PIET : " << PASSWORD_INFINITE_EXPIRATION_TIME);
+ LOGD("Not Equal m_expireTimeLeft : " << m_expireTimeLeft << " vs PASSWORD_INFINITE_EXPIRATION_TIME : "
+ << PASSWORD_INFINITE_EXPIRATION_TIME);
time_t timeLeft = m_expireTimeLeft - time(NULL);
*expire_time_left = (timeLeft < 0) ? 0 : static_cast<unsigned int>(timeLeft);
- LOGD(" not eq expire_time_left : " << *expire_time_left << " timeLeft : " << timeLeft);
+ LOGD("*expire_time_left : " << *expire_time_left << " timeLeft : " << timeLeft);
} else {
*expire_time_left = PASSWORD_API_NO_EXPIRATION;
- LOGD(" expire_time_left : " << *expire_time_left);
+ LOGD("*expire_time_left : " << *expire_time_left);
}
return HAL_SECURITY_AUTH_ERROR_NONE;
int hal_backend_security_auth::reset_attempt(uid_t user_id)
{
- LOGD("hal_backend_security_auth::reset_attempt");
+ LOGD("hal_backend_security_auth::reset_attempt user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_attempt = 0;
int hal_backend_security_auth::increment_attempt(uid_t user_id)
{
- LOGD("hal_backend_security_auth::increment_attempt");
+ LOGD("hal_backend_security_auth::increment_attempt user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_attempt++;
+ LOGD("m_attempt : " << m_attempt);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::get_max_attempt(uid_t user_id, unsigned int *max_attempt) const
{
- LOGD("hal_backend_security_auth::get_max_attempt");
-
+ LOGD("hal_backend_security_auth::get_max_attempt user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
*max_attempt = m_maxAttempt;
+ LOGD("*m_maxAttempt : " << m_maxAttempt);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::set_max_attempt(uid_t user_id, unsigned int max_attempt)
{
- LOGD("hal_backend_security_auth::set_max_attempt");
+ LOGD("hal_backend_security_auth::set_max_attempt user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_maxAttempt = max_attempt;
+ LOGD("max_attempt : " << max_attempt);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::is_password_active(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::is_password_active");
- LOGD("hal_backend_security_auth::is_password_active: user_id=" << user_id << ", m_user=" << m_user <<", m_passwordActive=" << m_passwordActive);
+ LOGD("hal_backend_security_auth::is_password_active user_id : " << user_id << " m_user : " << m_user <<" m_passwordActive : " << m_passwordActive);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
return m_passwordActive ? HAL_SECURITY_AUTH_ERROR_NONE : HAL_SECURITY_AUTH_ERROR_STATUS;
int hal_backend_security_auth::is_password_reused(uid_t user_id, const char* password) const
{
- LOGD("hal_backend_security_auth::is_password_reused");
+ LOGD("hal_backend_security_auth::is_password_reused user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
- LOGD(" user_id : "<< m_user << " history_size: " <<
- m_passwordHistory.size() << ", max_history_size: " << m_maxHistorySize);
+ LOGD("m_passwordHistory : " << m_passwordHistory.size() << " m_maxHistorySize : " << m_maxHistorySize);
// go through history and check if password existed earlier
if (std::any_of(
[&password](const IPasswordPtr & pwd) {
return pwd->match(password);
})) {
- LOGE(" password match!");
+ LOGE("password match!");
return HAL_SECURITY_AUTH_ERROR_NONE;
}
- LOGE(" Failed isPasswordReused: No passwords match");
+ LOGE("Failed isPasswordReused: No passwords match");
return HAL_SECURITY_AUTH_ERROR_STATUS;
}
int hal_backend_security_auth::check_expiration(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::check_expiration");
+ LOGD("hal_backend_security_auth::check_expiration user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
- LOGD(" m_expireTimeLeft : " << m_expireTimeLeft << " PIET : "<< PASSWORD_INFINITE_EXPIRATION_TIME << " time: " << time(NULL) << " m_eTLeft : " << m_expireTimeLeft);
+ LOGD("m_expireTimeLeft : " << m_expireTimeLeft << " PASSWORD_INFINITE_EXPIRATION_TIME : "
+ << PASSWORD_INFINITE_EXPIRATION_TIME << " time : " << time(NULL) << " m_expireTimeLeft : " << m_expireTimeLeft);
return ((m_expireTimeLeft != PASSWORD_INFINITE_EXPIRATION_TIME) && (time(NULL) > m_expireTimeLeft)) ? HAL_SECURITY_AUTH_ERROR_PASSWORD_EXPIRED : HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::check_attempt_exceeded(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::check_attempt_exceeded");
- LOGD(" m_maxAttempt : " << m_maxAttempt << " P_I_A_C : " << PASSWORD_INFINITE_ATTEMPT_COUNT << " m_attempt : " << m_attempt);
+ LOGD("hal_backend_security_auth::check_attempt_exceeded user_id : " << user_id << " m_user : " << m_user);
+ LOGD("m_maxAttempt : " << m_maxAttempt << " PASSWORD_INFINITE_ATTEMPT_COUNT : " << PASSWORD_INFINITE_ATTEMPT_COUNT
+ << " m_attempt : " << m_attempt);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
return ((m_maxAttempt != PASSWORD_INFINITE_ATTEMPT_COUNT) && (m_attempt > m_maxAttempt)) ? HAL_SECURITY_AUTH_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED : HAL_SECURITY_AUTH_ERROR_NONE;
int hal_backend_security_auth::is_ignore_period(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::is_ignore_period");
+ LOGD("hal_backend_security_auth::is_ignore_period user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
TimePoint retryTimerStop = ClockType::now();
TimeDiff diff = retryTimerStop - m_retryTimerStart;
-
m_retryTimerStart = retryTimerStop;
+ LOGD( "diff.count() : " << diff.count() << " RETRY_TIMEOUT : " << RETRY_TIMEOUT);
+
return (diff.count() < RETRY_TIMEOUT) ? HAL_SECURITY_AUTH_ERROR_NONE : HAL_SECURITY_AUTH_ERROR_PASSWORD_RETRY_TIMER;
}
int hal_backend_security_auth::is_history_active(uid_t user_id) const
{
- LOGD("hal_backend_security_auth::is_history_active");
+ LOGD("hal_backend_security_auth::is_history_active user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
+ LOGD( "m_maxHistorySize : " << m_maxHistorySize);
return (m_maxHistorySize != 0) ? HAL_SECURITY_AUTH_ERROR_NONE : HAL_SECURITY_AUTH_ERROR_STATUS;
}
int hal_backend_security_auth::get_password_type(uid_t user_id,
hal_security_auth_password_type_e *password_type) const
{
- LOGD("hal_backend_security_auth::get_password_type");
+ LOGD("hal_backend_security_auth::get_password_type user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
*password_type = m_passwordType;
+ LOGD( "m_passwordType : " << m_passwordType);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
int hal_backend_security_auth::set_password_type(uid_t user_id,
hal_security_auth_password_type_e password_type)
{
- LOGD("hal_backend_security_auth::set_password_type");
+ LOGD("hal_backend_security_auth::set_password_type user_id : " << user_id << " m_user : " << m_user);
if(user_id != m_user)
return HAL_SECURITY_AUTH_ERROR_INPUT_PARAM;
m_passwordType = password_type;
+ LOGD( "passwordType : " << password_type);
return HAL_SECURITY_AUTH_ERROR_NONE;
}
{
LOGD("hal_backend_security_auth::get_user_id");
uid_t user_id = getuid();
+ LOGD( "user_id : " << user_id);
return user_id;
}
{
hal_security_auth_password_type_e current_password_type;
auto itAuth = hal_backend_security_auth_instance_map.find(user_id);
- LOGD("get_hal_backend_security_auth_instance");
+ LOGD("get_hal_backend_security_auth_instance user_id : " << user_id);
if (itAuth != hal_backend_security_auth_instance_map.end()){
hal_backend_security_auth *authInstance = itAuth->second;
authInstance->get_password_type(user_id, ¤t_password_type);
if(current_password_type == password_type){
- LOGD(" found the user and the same type");
+ LOGD("Found the same password_type : " << password_type);
return authInstance;
}
else{
authInstance->set_password_type(user_id, password_type);
- LOGD(" found the user and the diffent type, so changed.");
+ LOGD("Not found the same type. so, set the password_type : " << password_type);
return authInstance;
}
}
- LOGD(" Not found and created a new instance");
+ LOGD("Not found and created a new instance");
hal_backend_security_auth* new_security_auth = new hal_backend_security_auth(user_id,password_type);
hal_backend_security_auth_instance_map[user_id] = new_security_auth;
return new_security_auth;