From 6f8ea6f4ee785d81bafd6a8449dd511d8e713002 Mon Sep 17 00:00:00 2001 From: winnerym Date: Mon, 17 Apr 2023 14:44:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug#167371=20=E3=80=90=E6=8F=90=E6=9D=83?= =?UTF-8?q?=E3=80=91A=E7=94=A8=E6=88=B7=E6=B7=BB=E5=8A=A0=E7=94=9F?= =?UTF-8?q?=E7=89=A9=E8=AF=86=E5=88=AB=E7=89=B9=E5=BE=81=EF=BC=8CB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E4=BD=BF=E7=94=A8A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=9B=E8=A1=8C=E6=8F=90=E6=9D=83=E6=97=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=94=9F=E7=89=A9=E8=AF=86=E5=88=AB=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bioauth/src/loginoptionswidget.cpp | 14 +++++++++++--- polkit-agent/src/mainwindow.cpp | 10 +++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bioauth/src/loginoptionswidget.cpp b/bioauth/src/loginoptionswidget.cpp index 6f55dba..955270c 100644 --- a/bioauth/src/loginoptionswidget.cpp +++ b/bioauth/src/loginoptionswidget.cpp @@ -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:"<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_(); } diff --git a/polkit-agent/src/mainwindow.cpp b/polkit-agent/src/mainwindow.cpp index d11e08b..e8b66c1 100644 --- a/polkit-agent/src/mainwindow.cpp +++ b/polkit-agent/src/mainwindow.cpp @@ -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) {