fix bug#167371 【提权】A用户添加生物识别特征,B用户登录使用A用户进行提权时没有生物识别选项

This commit is contained in:
winnerym 2023-04-17 14:44:59 +08:00
parent 96968ac48d
commit 6f8ea6f4ee
2 changed files with 16 additions and 8 deletions

View File

@ -188,7 +188,10 @@ unsigned LoginOptionsWidget::getLoginOptCount()
DeviceInfoPtr LoginOptionsWidget::getFirstDevInfo()
{
DeviceInfoPtr devInfo = nullptr;
int nDrvId = m_bioDevices->GetLastDevice(getpwuid(getuid())->pw_name);
struct passwd* pwdInfo = getpwuid(m_uid);
if (!pwdInfo)
return devInfo;
int nDrvId = m_bioDevices->GetLastDevice(pwdInfo->pw_name);
if (nDrvId >= 0) {
qDebug()<<"GetLastDevice:"<<nDrvId;
DeviceMap::iterator itDevInfo = m_mapDevices.begin();
@ -443,11 +446,16 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid)
qDebug()<<"deviceInfo:"<<device->device_id;
this->m_curDevInfo = device;
this->m_uid = uid;
this->m_strUserName = getpwuid(uid)->pw_name;
struct passwd *pwdInfo = getpwuid(uid);
if (pwdInfo) {
this->m_strUserName = pwdInfo->pw_name;
}
this->m_isStopped = false;
this->m_curLoginOptType = convertDeviceType(this->m_curDevInfo->biotype);
updateUIStatus(true);
m_bioDevices->SetLastDevice(getpwuid(getuid())->pw_name, this->m_curDevInfo->device_id);
if (pwdInfo) {
m_bioDevices->SetLastDevice(pwdInfo->pw_name, this->m_curDevInfo->device_id);
}
startAuth_();
}

View File

@ -330,7 +330,7 @@ void MainWindow::onConfigurationChanged(QString key)
void MainWindow::restart_bio_identify()
{
DeviceInfoPtr device = bioDevices.getDefaultDevice(getuid());
DeviceInfoPtr device = bioDevices.getDefaultDevice(getUid(userName));
if(device){
m_loginOptsWidget->startAuth(device, getUid(userName));
setMessage(tr("Please enter your password or enroll your fingerprint "));
@ -902,7 +902,7 @@ void MainWindow::switchAuthMode(Mode mode)
// if(enableBioAuth && useDoubleAuth){
// DeviceInfoPtr device = bioDevices.getDefaultDevice(getuid());
// DeviceInfoPtr device = bioDevices.getDefaultDevice(getUid(userName));
// if(device){
// widgetBioAuth->startAuth(getUid(userName), device);
// }
@ -933,9 +933,9 @@ void MainWindow::switchAuthMode(Mode mode)
} else if(authMode == BIOMETRIC) {
QString strDeviceName;
if(isLoadingUkey){
strDeviceName = m_loginOptsWidget->GetDefaultDevice(getuid(),UniT_General_Ukey);
strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid, UniT_General_Ukey);
}else{
strDeviceName = m_loginOptsWidget->GetDefaultDevice(getuid());
strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid);
}
//如果默认设备为空的话,第一次不启动生物识别认证
if(strDeviceName.isEmpty() && !m_deviceInfo)
@ -989,7 +989,7 @@ void MainWindow::switchAuthMode(Mode mode)
if(enableBioAuth) {
qDebug() << "enable biometric authenticaion";
QString strDeviceName = m_loginOptsWidget->GetDefaultDevice(getuid());
QString strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid);
//如果默认设备为空的话,第一次不启动生物识别认证
if(strDeviceName.isEmpty() && !m_deviceInfo)
{